@shumai-one/shumai 0.4.9 → 0.5.0

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.
Files changed (163) hide show
  1. package/bin/{chunk-ckd5hnd0.js → chunk-03bfjh8k.js} +2 -2
  2. package/bin/{chunk-spm13ndr.js → chunk-0tf15vee.js} +2 -2
  3. package/bin/{chunk-ryvq9pbw.js → chunk-0vtk7wrf.js} +2 -2
  4. package/bin/{chunk-1v11geh0.js → chunk-0yv0nnmh.js} +2 -2
  5. package/bin/{chunk-tcyp8qtg.js → chunk-12npypek.js} +2 -2
  6. package/bin/chunk-13d525jm.js +2 -0
  7. package/bin/{chunk-snedd3at.js → chunk-1k16xsqq.js} +9 -9
  8. package/bin/{chunk-yyj21k15.js → chunk-1yt1gsyy.js} +1 -1
  9. package/bin/{chunk-0w3388vp.js → chunk-20anqpf1.js} +2 -2
  10. package/bin/{chunk-v2vdm22x.js → chunk-2g5qdx4s.js} +1 -1
  11. package/bin/{chunk-9fe75ns9.js → chunk-31vx01aw.js} +2 -2
  12. package/bin/{chunk-sg8hjkyg.js → chunk-32japja5.js} +1 -1
  13. package/bin/chunk-35mpp84e.js +2 -0
  14. package/bin/{chunk-6m44n3ms.js → chunk-36r20sj7.js} +1 -1
  15. package/bin/{chunk-rv15x8aw.js → chunk-3btc8a0p.js} +1 -1
  16. package/bin/{chunk-82cg5497.js → chunk-3cvbb6kh.js} +2 -2
  17. package/bin/chunk-3ewmtf1c.js +1 -0
  18. package/bin/chunk-3fjgf7eb.js +3 -0
  19. package/bin/chunk-3xw70yr4.js +2 -0
  20. package/bin/{chunk-nr80mrry.js → chunk-3z20b2hz.js} +2 -2
  21. package/bin/{chunk-6vqga3ma.js → chunk-3zvvct3r.js} +1 -1
  22. package/bin/{chunk-f3f6cary.js → chunk-51h2bgpf.js} +3 -3
  23. package/bin/{chunk-ytffpk7c.js → chunk-5bpvwv66.js} +2 -2
  24. package/bin/{chunk-eedhf8eb.js → chunk-5jbx9gqe.js} +1 -1
  25. package/bin/{chunk-sby10fz6.js → chunk-5patxztz.js} +4 -4
  26. package/bin/chunk-5seey9ee.js +2 -0
  27. package/bin/{chunk-c7hr2jga.js → chunk-5t05jpna.js} +3 -3
  28. package/bin/{chunk-c0wqfya9.js → chunk-5yd9cv7f.js} +5 -5
  29. package/bin/{chunk-8mhj6r2q.js → chunk-628k58ek.js} +2 -2
  30. package/bin/chunk-66hdwm6f.js +2 -0
  31. package/bin/{chunk-g6rw4jj5.js → chunk-6bgbx563.js} +2 -2
  32. package/bin/{chunk-tefct00a.js → chunk-6vvs18bw.js} +1 -1
  33. package/bin/chunk-756mr32b.js +2 -0
  34. package/bin/{chunk-gj0yxtqz.js → chunk-7vd5yajk.js} +7 -7
  35. package/bin/{chunk-qah2r4xa.js → chunk-7wb3dga5.js} +1 -1
  36. package/bin/{chunk-e2qn4d57.js → chunk-9h6nn1a3.js} +1 -1
  37. package/bin/chunk-9k86d2a3.js +4 -0
  38. package/bin/chunk-9wk11jtz.js +1 -0
  39. package/bin/chunk-a1crhhzy.js +1 -0
  40. package/bin/chunk-axfwh5et.js +2 -0
  41. package/bin/{chunk-rd5ek2sk.js → chunk-b9j5575n.js} +2 -2
  42. package/bin/chunk-cgsxyw07.js +2 -0
  43. package/bin/{chunk-kn82bccp.js → chunk-cw8z9w5c.js} +2 -2
  44. package/bin/{chunk-qa7pphr5.js → chunk-czny5thj.js} +2 -2
  45. package/bin/{chunk-sfwmwrq3.js → chunk-d7mgjqf8.js} +1 -1
  46. package/bin/{chunk-46hmh2ag.js → chunk-d9btz95y.js} +1 -1
  47. package/bin/chunk-dckdnqc0.js +2 -0
  48. package/bin/chunk-dx0wz749.js +211 -0
  49. package/bin/{chunk-2txahdj8.js → chunk-dz33q4v1.js} +2 -2
  50. package/bin/chunk-dz4fdrmk.js +1 -0
  51. package/bin/{chunk-nz16584e.js → chunk-e3r1m6rb.js} +1 -1
  52. package/bin/chunk-edjtb7pk.js +2 -0
  53. package/bin/{chunk-7hmt2gs5.js → chunk-eez1yncf.js} +1 -1
  54. package/bin/{chunk-zhtc1j3r.js → chunk-exgtwask.js} +1 -1
  55. package/bin/{chunk-fw5xzcnf.js → chunk-f22nrm6r.js} +4 -4
  56. package/bin/{chunk-q6k1ctph.js → chunk-fhq5m9ya.js} +2 -2
  57. package/bin/{chunk-ns8whqp6.js → chunk-fyssg02c.js} +30 -30
  58. package/bin/{chunk-09367z2r.js → chunk-g8h1e1kh.js} +2 -2
  59. package/bin/{chunk-kemfwmyq.js → chunk-ghjhyajn.js} +2 -2
  60. package/bin/{chunk-8r9q7xcv.js → chunk-gptzcgte.js} +1 -1
  61. package/bin/{chunk-2j31y48k.js → chunk-grsgkkrb.js} +5 -5
  62. package/bin/{chunk-1kr1jsrt.js → chunk-gy8z8sd7.js} +1 -1
  63. package/bin/{chunk-p4nbgn3v.js → chunk-h153xefb.js} +1 -1
  64. package/bin/chunk-h82r29wm.js +129 -0
  65. package/bin/{chunk-6yayg55q.js → chunk-h9x81yp6.js} +1 -1
  66. package/bin/{chunk-v2901ff5.js → chunk-hr2027z3.js} +8 -8
  67. package/bin/{chunk-xw7jea6g.js → chunk-hx76pje1.js} +1 -1
  68. package/bin/chunk-hz9stgvn.js +1 -0
  69. package/bin/chunk-hzr8100w.js +3 -0
  70. package/bin/{chunk-5w7yxz6p.js → chunk-j3xaq9s3.js} +2 -2
  71. package/bin/{chunk-5e4de0a1.js → chunk-j909v9p5.js} +1 -1
  72. package/bin/chunk-jb6d142z.js +1 -0
  73. package/bin/chunk-k9cgfzgk.js +3 -0
  74. package/bin/{chunk-0mv8jp7h.js → chunk-kgfa5y9w.js} +8 -8
  75. package/bin/{chunk-jxfz4h24.js → chunk-kzsdp31a.js} +2 -2
  76. package/bin/{chunk-ht4chp45.js → chunk-m1xc3t0p.js} +7 -7
  77. package/bin/{chunk-sedbz4km.js → chunk-m7dp8rqv.js} +1 -1
  78. package/bin/{chunk-46brm12f.js → chunk-m9sp00a9.js} +4 -4
  79. package/bin/{chunk-pw81eh3g.js → chunk-mcd7zas7.js} +2 -2
  80. package/bin/chunk-meyvvmgk.js +1 -0
  81. package/bin/{chunk-4cj3pz27.js → chunk-mqr096rn.js} +1 -1
  82. package/bin/{chunk-yfjyjjpz.js → chunk-mt532a33.js} +1 -1
  83. package/bin/{chunk-dzj91k6v.js → chunk-myd3wg9a.js} +2 -2
  84. package/bin/chunk-n1b3pt17.js +14 -0
  85. package/bin/chunk-n5v48hz5.js +2 -0
  86. package/bin/{chunk-zpk482rb.js → chunk-p5v22g5n.js} +2 -2
  87. package/bin/chunk-phzemmmy.js +2 -0
  88. package/bin/{chunk-jyg525f5.js → chunk-q5mkbnr9.js} +2 -2
  89. package/bin/chunk-qhzat67w.js +2 -0
  90. package/bin/{chunk-7zfyrt40.js → chunk-r1m4q8vw.js} +1 -1
  91. package/bin/{chunk-41fbx9mc.js → chunk-r5rpdhed.js} +2 -2
  92. package/bin/{chunk-d70acjwn.js → chunk-r6gkv98n.js} +5 -5
  93. package/bin/{chunk-p46em0kf.js → chunk-rkq6jvhb.js} +3 -3
  94. package/bin/{chunk-0g7ayjb5.js → chunk-rn9rktp4.js} +5 -5
  95. package/bin/{chunk-g7qejgap.js → chunk-rq2h2bwt.js} +2 -2
  96. package/bin/{chunk-yet4fnab.js → chunk-sg7n2g3z.js} +1 -1
  97. package/bin/chunk-smcn7ep7.js +2 -0
  98. package/bin/{chunk-cphwmdq5.js → chunk-tcat7q9p.js} +2 -2
  99. package/bin/{chunk-anky1dmg.js → chunk-tf8q7h6b.js} +1 -1
  100. package/bin/{chunk-bg2vgnzt.js → chunk-trndqdaa.js} +1 -1
  101. package/bin/chunk-tvr5rm1g.js +1 -0
  102. package/bin/chunk-ty88m3yg.js +2 -0
  103. package/bin/chunk-v2x9915x.js +1 -0
  104. package/bin/{chunk-tnv4ggx2.js → chunk-v42jcex0.js} +4 -4
  105. package/bin/{chunk-n6sny5c8.js → chunk-vbbn4hth.js} +1 -1
  106. package/bin/chunk-vnk2p7mq.css +1 -0
  107. package/bin/{chunk-r7e2fmmx.js → chunk-wkxm6yny.js} +2 -2
  108. package/bin/{chunk-6mnj9adr.js → chunk-wydd7sz7.js} +2 -2
  109. package/bin/chunk-x8hky9td.js +1 -0
  110. package/bin/{chunk-rbh4w2v2.js → chunk-xvdd04gy.js} +1 -1
  111. package/bin/{chunk-m0xbfmf0.js → chunk-y03z5rrg.js} +3 -3
  112. package/bin/{chunk-h29rwayb.js → chunk-y12ah7c6.js} +1 -1
  113. package/bin/{chunk-zy32pf0s.js → chunk-y7jz31ay.js} +1 -1
  114. package/bin/chunk-ydk3edsw.js +1 -0
  115. package/bin/{chunk-thzf89fp.js → chunk-yfe6hkzk.js} +3 -3
  116. package/bin/{chunk-aant41bd.js → chunk-z1r86fna.js} +2 -2
  117. package/bin/{chunk-szjkmkwc.js → chunk-z8mmqfm4.js} +1 -1
  118. package/bin/chunk-zbma2zeh.js +1 -0
  119. package/bin/{chunk-jpjc44j6.js → chunk-zcrtr8qd.js} +2 -2
  120. package/bin/{chunk-c3010erf.js → chunk-zfqz72sd.js} +1 -1
  121. package/bin/{chunk-6snwrej9.js → chunk-zhe16jvg.js} +1 -1
  122. package/bin/{chunk-8mjb093y.js → chunk-zwb9kamp.js} +2 -2
  123. package/bin/shumai-app.html +1 -1
  124. package/bin/shumai-app.js +360 -353
  125. package/package.json +9 -8
  126. package/prisma/migrations/20261001015042_migrate_video_strategy_multi_and_resolutions/migration.sql +16 -0
  127. package/prisma/migrations/20261002104921_add_asset_status_failed/migration.sql +2 -0
  128. package/prisma/schema.prisma +1 -0
  129. package/bin/chunk-01v2xh5b.js +0 -1
  130. package/bin/chunk-15n1v8mm.js +0 -1
  131. package/bin/chunk-17k9a427.js +0 -211
  132. package/bin/chunk-258tjpym.js +0 -1
  133. package/bin/chunk-2ar64j3z.js +0 -2
  134. package/bin/chunk-2kxhdnma.js +0 -3
  135. package/bin/chunk-315w58w6.js +0 -3
  136. package/bin/chunk-4sqbjvjt.js +0 -2
  137. package/bin/chunk-c8aw8dye.js +0 -2
  138. package/bin/chunk-e2724ggn.js +0 -2
  139. package/bin/chunk-e2j3vwcv.js +0 -2
  140. package/bin/chunk-ef3av8ay.js +0 -1
  141. package/bin/chunk-fjvbgahx.css +0 -1
  142. package/bin/chunk-fw0f45qw.js +0 -2
  143. package/bin/chunk-gvbajsje.js +0 -1
  144. package/bin/chunk-h37zfvmp.js +0 -3
  145. package/bin/chunk-jraqe5z0.js +0 -2
  146. package/bin/chunk-jy8by162.js +0 -1
  147. package/bin/chunk-jz9mcrj6.js +0 -1
  148. package/bin/chunk-k4n9rdq3.js +0 -1
  149. package/bin/chunk-kmx350y5.js +0 -14
  150. package/bin/chunk-kx0qbs28.js +0 -1
  151. package/bin/chunk-nhfbnqdr.js +0 -2
  152. package/bin/chunk-p7j6zgdg.js +0 -2
  153. package/bin/chunk-pbyp1xnb.js +0 -2
  154. package/bin/chunk-r4w1e3bd.js +0 -2
  155. package/bin/chunk-s9whhdb3.js +0 -2
  156. package/bin/chunk-ss1jchgx.js +0 -1
  157. package/bin/chunk-t0nktwrm.js +0 -1
  158. package/bin/chunk-t9eb2mdq.js +0 -4
  159. package/bin/chunk-tptgxbqa.js +0 -2
  160. package/bin/chunk-v8ngtwzx.js +0 -299
  161. package/bin/chunk-xex9v0rn.js +0 -2
  162. package/bin/chunk-xs2w45vp.js +0 -1
  163. package/bin/chunk-xza8wate.js +0 -2
@@ -1,32 +1,32 @@
1
1
  // @bun
2
- import{z,w,G}from"./chunk-jxfz4h24.js";var es=w(function(Xp,Zn){function Ee(e,t){if(typeof t==="boolean")t={forever:t};if(this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Zn.exports=Ee;Ee.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Ee.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);if(this._timer)clearTimeout(this._timer);this._timeouts=[],this._cachedTimeouts=null};Ee.prototype.retry=function(e){if(this._timeout)clearTimeout(this._timeout);if(!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;if(this._timer=setTimeout(function(){if(n._attempts++,n._operationTimeoutCb){if(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref)n._timeout.unref()}n._fn(n._attempts)},r),this._options.unref)this._timer.unref();return!0};Ee.prototype.attempt=function(e,t){if(this._fn=e,t){if(t.timeout)this._operationTimeout=t.timeout;if(t.cb)this._operationTimeoutCb=t.cb}var r=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};Ee.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Ee.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Ee.prototype.start=Ee.prototype.try;Ee.prototype.errors=function(){return this._errors};Ee.prototype.attempts=function(){return this._attempts};Ee.prototype.mainError=function(){if(this._errors.length===0)return null;var e={},t=null,r=0;for(var n=0;n<this._errors.length;n++){var s=this._errors[n],i=s.message,u=(e[i]||0)+1;if(e[i]=u,u>=r)t=s,r=u}return t}});var rs=w(function(mr){var lu=es();mr.operation=function(e){var t=mr.timeouts(e);return new lu(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};mr.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var n=[];for(var s=0;s<t.retries;s++)n.push(this.createTimeout(s,t));if(e&&e.forever&&!n.length)n.push(this.createTimeout(s,t));return n.sort(function(i,u){return i-u}),n};mr.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};mr.wrap=function(e,t,r){if(t instanceof Array)r=t,t=null;if(!r){r=[];for(var n in e)if(typeof e[n]==="function")r.push(n)}for(var s=0;s<r.length;s++){var i=r[s],u=e[i];e[i]=function(y){var S=mr.operation(t),A=Array.prototype.slice.call(arguments,1),k=A.pop();A.push(function(N){if(S.retry(N))return;if(N)arguments[0]=S.mainError();k.apply(this,arguments)}),S.attempt(function(){y.apply(e,A)})}.bind(e,u),e[i].options=t}}});var wu=w(function(Zp,Pt){var pu=rs(),gu=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class Er extends Error{constructor(e){super();if(e instanceof Error)this.originalError=e,{message:e}=e;else this.originalError=Error(e),this.originalError.stack=this.stack;this.name="AbortError",this.message=e}}var _u=(e,t,r)=>{let n=r.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=n,e},yu=(e)=>gu.includes(e),ns=(e,t)=>new Promise((r,n)=>{t={onFailedAttempt:()=>{},retries:10,...t};let s=pu.operation(t);s.attempt(async(i)=>{try{r(await e(i))}catch(u){if(!(u instanceof Error)){n(TypeError(`Non-error was thrown: "${u}". You should only throw errors.`));return}if(u instanceof Er)s.stop(),n(u.originalError);else if(u instanceof TypeError&&!yu(u.message))s.stop(),n(u);else{_u(u,i,t);try{await t.onFailedAttempt(u)}catch(h){n(h);return}if(!s.retry(u))n(s.mainError())}}})});Pt.exports=ns;Pt.exports.default=ns;Pt.exports.AbortError=Er});var wr=w(function(eg,hs){var It=Object.prototype.hasOwnProperty,ls=Object.prototype.toString,{defineProperty:ss,getOwnPropertyDescriptor:is}=Object,os=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return ls.call(t)==="[object Array]"},as=function(t){if(!t||ls.call(t)!=="[object Object]")return!1;var r=It.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&It.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!n)return!1;var s;for(s in t);return typeof s>"u"||It.call(t,s)},cs=function(t,r){if(ss&&r.name==="__proto__")ss(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},us=function(t,r){if(r==="__proto__"){if(!It.call(t,r))return;else if(is)return is(t,r).value}return t[r]};hs.exports=function e(){var t,r,n,s,i,u,h=arguments[0],y=1,S=arguments.length,A=!1;if(typeof h==="boolean")A=h,h=arguments[1]||{},y=2;if(h==null||typeof h!=="object"&&typeof h!=="function")h={};for(;y<S;++y)if(t=arguments[y],t!=null){for(r in t)if(n=us(h,r),s=us(t,r),h!==s){if(A&&s&&(as(s)||(i=os(s)))){if(i)i=!1,u=n&&os(n)?n:[];else u=n&&as(n)?n:{};cs(h,{name:r,newValue:e(A,u,s)})}else if(typeof s<"u")cs(h,{name:r,newValue:s})}}return h}});var fs=w(function(tg,mu){mu.exports={name:"gaxios",version:"7.3.1",description:"A simple common HTTP client specifically for Google APIs and services.",main:"build/cjs/src/index.js",types:"build/cjs/src/index.d.ts",files:["build/"],exports:{".":{import:{types:"./build/esm/src/index.d.ts",default:"./build/esm/src/index.js"},require:{types:"./build/cjs/src/index.d.ts",default:"./build/cjs/src/index.js"}}},scripts:{lint:"gts check --no-inline-config",test:"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000",compile:"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs",fix:"gts fix",prepare:"npm run compile",pretest:"npm run compile",webpack:"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js",docs:"jsdoc -c .jsdoc.js","samples-test":"cd samples/ && npm link ../ && npm test && cd ../",prelint:"cd samples; npm link ../; npm install",clean:"gts clean"},repository:{type:"git",directory:"core/packages/gaxios",url:"https://github.com/googleapis/google-cloud-node.git"},keywords:["google"],engines:{node:">=18"},author:"Google, LLC",license:"Apache-2.0",devDependencies:{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","@types/tmp":"^0.2.6",assert:"^2.0.0",browserify:"^17.0.0",c8:"^10.1.3",cors:"^2.8.5",express:"^5.0.0",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.0",mocha:"^11.1.0",multiparty:"^4.2.1",mv:"^2.1.1",ncp:"^2.0.0",nock:"14.0.5","null-loader":"^4.0.1","pack-n-play":"^4.0.0",puppeteer:"^24.0.0",sinon:"21.0.3","stream-browserify":"^3.0.0",tmp:"0.2.7","ts-loader":"^9.5.2",typescript:"5.8.3","undici-types":"^7.24.1",webpack:"^5.97.1","webpack-cli":"^6.0.1"},dependencies:{extend:"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2"},homepage:"https://github.com/googleapis/google-cloud-node/tree/main/core/packages/gaxios"}});var ps=w(function(rg,ds){var Eu=fs();ds.exports={pkg:Eu}});var vr=w(function(we){var _s=we&&we.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(we,"__esModule",{value:!0});we.GaxiosError=we.GAXIOS_ERROR_SYMBOL=void 0;we.defaultErrorRedactor=ys;var gs=_s(wr()),Tu=_s(ps()),Tr=Tu.default.pkg;we.GAXIOS_ERROR_SYMBOL=Symbol.for(`${Tr.name}-gaxios-error`);class Ar extends Error{config;response;code;status;error;[we.GAXIOS_ERROR_SYMBOL]=Tr.version;static[Symbol.hasInstance](e){if(e&&typeof e==="object"&&we.GAXIOS_ERROR_SYMBOL in e&&e[we.GAXIOS_ERROR_SYMBOL]===Tr.version)return!0;return Function.prototype[Symbol.hasInstance].call(Ar,e)}constructor(e,t,r,n){super(e,{cause:n});if(this.config=t,this.response=r,this.error=n instanceof Error?n:void 0,this.config=(0,gs.default)(!0,{},t),this.response)this.response.config=(0,gs.default)(!0,{},this.response.config);if(this.response){try{this.response.data=Au(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}if(n instanceof DOMException)this.code=n.name;else if(n&&typeof n==="object"&&"code"in n&&(typeof n.code==="string"||typeof n.code==="number"))this.code=n.code}static extractAPIErrorFromResponse(e,t="The request failed"){let r=t;if(typeof e.data==="string")r=e.data;if(e.data&&typeof e.data==="object"&&"error"in e.data&&e.data.error&&!e.ok){if(typeof e.data.error==="string")return{message:e.data.error,code:e.status,status:e.statusText};if(typeof e.data.error==="object"){r="message"in e.data.error&&typeof e.data.error.message==="string"?e.data.error.message:r;let n="status"in e.data.error&&typeof e.data.error.status==="string"?e.data.error.status:e.statusText,s="code"in e.data.error&&typeof e.data.error.code==="number"?e.data.error.code:e.status;if("errors"in e.data.error&&Array.isArray(e.data.error.errors)){let i=[];for(let u of e.data.error.errors)if(typeof u==="object"&&"message"in u&&typeof u.message==="string")i.push(u.message);return Object.assign({message:i.join(`
2
+ import{H,w,G}from"./chunk-kzsdp31a.js";var es=w(function(Xp,Zn){function Ee(e,t){if(typeof t==="boolean")t={forever:t};if(this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Zn.exports=Ee;Ee.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Ee.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);if(this._timer)clearTimeout(this._timer);this._timeouts=[],this._cachedTimeouts=null};Ee.prototype.retry=function(e){if(this._timeout)clearTimeout(this._timeout);if(!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;if(this._timer=setTimeout(function(){if(n._attempts++,n._operationTimeoutCb){if(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref)n._timeout.unref()}n._fn(n._attempts)},r),this._options.unref)this._timer.unref();return!0};Ee.prototype.attempt=function(e,t){if(this._fn=e,t){if(t.timeout)this._operationTimeout=t.timeout;if(t.cb)this._operationTimeoutCb=t.cb}var r=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};Ee.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Ee.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Ee.prototype.start=Ee.prototype.try;Ee.prototype.errors=function(){return this._errors};Ee.prototype.attempts=function(){return this._attempts};Ee.prototype.mainError=function(){if(this._errors.length===0)return null;var e={},t=null,r=0;for(var n=0;n<this._errors.length;n++){var s=this._errors[n],i=s.message,u=(e[i]||0)+1;if(e[i]=u,u>=r)t=s,r=u}return t}});var rs=w(function(mr){var lu=es();mr.operation=function(e){var t=mr.timeouts(e);return new lu(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};mr.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var n=[];for(var s=0;s<t.retries;s++)n.push(this.createTimeout(s,t));if(e&&e.forever&&!n.length)n.push(this.createTimeout(s,t));return n.sort(function(i,u){return i-u}),n};mr.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};mr.wrap=function(e,t,r){if(t instanceof Array)r=t,t=null;if(!r){r=[];for(var n in e)if(typeof e[n]==="function")r.push(n)}for(var s=0;s<r.length;s++){var i=r[s],u=e[i];e[i]=function(y){var S=mr.operation(t),A=Array.prototype.slice.call(arguments,1),k=A.pop();A.push(function(N){if(S.retry(N))return;if(N)arguments[0]=S.mainError();k.apply(this,arguments)}),S.attempt(function(){y.apply(e,A)})}.bind(e,u),e[i].options=t}}});var Eu=w(function(Zp,Pt){var pu=rs(),gu=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class Er extends Error{constructor(e){super();if(e instanceof Error)this.originalError=e,{message:e}=e;else this.originalError=Error(e),this.originalError.stack=this.stack;this.name="AbortError",this.message=e}}var _u=(e,t,r)=>{let n=r.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=n,e},yu=(e)=>gu.includes(e),ns=(e,t)=>new Promise((r,n)=>{t={onFailedAttempt:()=>{},retries:10,...t};let s=pu.operation(t);s.attempt(async(i)=>{try{r(await e(i))}catch(u){if(!(u instanceof Error)){n(TypeError(`Non-error was thrown: "${u}". You should only throw errors.`));return}if(u instanceof Er)s.stop(),n(u.originalError);else if(u instanceof TypeError&&!yu(u.message))s.stop(),n(u);else{_u(u,i,t);try{await t.onFailedAttempt(u)}catch(h){n(h);return}if(!s.retry(u))n(s.mainError())}}})});Pt.exports=ns;Pt.exports.default=ns;Pt.exports.AbortError=Er});var wr=w(function(eg,hs){var It=Object.prototype.hasOwnProperty,ls=Object.prototype.toString,{defineProperty:ss,getOwnPropertyDescriptor:is}=Object,os=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return ls.call(t)==="[object Array]"},as=function(t){if(!t||ls.call(t)!=="[object Object]")return!1;var r=It.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&It.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!n)return!1;var s;for(s in t);return typeof s>"u"||It.call(t,s)},cs=function(t,r){if(ss&&r.name==="__proto__")ss(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},us=function(t,r){if(r==="__proto__"){if(!It.call(t,r))return;else if(is)return is(t,r).value}return t[r]};hs.exports=function e(){var t,r,n,s,i,u,h=arguments[0],y=1,S=arguments.length,A=!1;if(typeof h==="boolean")A=h,h=arguments[1]||{},y=2;if(h==null||typeof h!=="object"&&typeof h!=="function")h={};for(;y<S;++y)if(t=arguments[y],t!=null){for(r in t)if(n=us(h,r),s=us(t,r),h!==s){if(A&&s&&(as(s)||(i=os(s)))){if(i)i=!1,u=n&&os(n)?n:[];else u=n&&as(n)?n:{};cs(h,{name:r,newValue:e(A,u,s)})}else if(typeof s<"u")cs(h,{name:r,newValue:s})}}return h}});var fs=w(function(tg,mu){mu.exports={name:"gaxios",version:"7.3.1",description:"A simple common HTTP client specifically for Google APIs and services.",main:"build/cjs/src/index.js",types:"build/cjs/src/index.d.ts",files:["build/"],exports:{".":{import:{types:"./build/esm/src/index.d.ts",default:"./build/esm/src/index.js"},require:{types:"./build/cjs/src/index.d.ts",default:"./build/cjs/src/index.js"}}},scripts:{lint:"gts check --no-inline-config",test:"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000",compile:"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs",fix:"gts fix",prepare:"npm run compile",pretest:"npm run compile",webpack:"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js",docs:"jsdoc -c .jsdoc.js","samples-test":"cd samples/ && npm link ../ && npm test && cd ../",prelint:"cd samples; npm link ../; npm install",clean:"gts clean"},repository:{type:"git",directory:"core/packages/gaxios",url:"https://github.com/googleapis/google-cloud-node.git"},keywords:["google"],engines:{node:">=18"},author:"Google, LLC",license:"Apache-2.0",devDependencies:{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","@types/tmp":"^0.2.6",assert:"^2.0.0",browserify:"^17.0.0",c8:"^10.1.3",cors:"^2.8.5",express:"^5.0.0",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.0",mocha:"^11.1.0",multiparty:"^4.2.1",mv:"^2.1.1",ncp:"^2.0.0",nock:"14.0.5","null-loader":"^4.0.1","pack-n-play":"^4.0.0",puppeteer:"^24.0.0",sinon:"21.0.3","stream-browserify":"^3.0.0",tmp:"0.2.7","ts-loader":"^9.5.2",typescript:"5.8.3","undici-types":"^7.24.1",webpack:"^5.97.1","webpack-cli":"^6.0.1"},dependencies:{extend:"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2"},homepage:"https://github.com/googleapis/google-cloud-node/tree/main/core/packages/gaxios"}});var ps=w(function(rg,ds){var wu=fs();ds.exports={pkg:wu}});var vr=w(function(we){var _s=we&&we.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(we,"__esModule",{value:!0});we.GaxiosError=we.GAXIOS_ERROR_SYMBOL=void 0;we.defaultErrorRedactor=ys;var gs=_s(wr()),Tu=_s(ps()),Tr=Tu.default.pkg;we.GAXIOS_ERROR_SYMBOL=Symbol.for(`${Tr.name}-gaxios-error`);class Ar extends Error{config;response;code;status;error;[we.GAXIOS_ERROR_SYMBOL]=Tr.version;static[Symbol.hasInstance](e){if(e&&typeof e==="object"&&we.GAXIOS_ERROR_SYMBOL in e&&e[we.GAXIOS_ERROR_SYMBOL]===Tr.version)return!0;return Function.prototype[Symbol.hasInstance].call(Ar,e)}constructor(e,t,r,n){super(e,{cause:n});if(this.config=t,this.response=r,this.error=n instanceof Error?n:void 0,this.config=(0,gs.default)(!0,{},t),this.response)this.response.config=(0,gs.default)(!0,{},this.response.config);if(this.response){try{this.response.data=Au(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}if(n instanceof DOMException)this.code=n.name;else if(n&&typeof n==="object"&&"code"in n&&(typeof n.code==="string"||typeof n.code==="number"))this.code=n.code}static extractAPIErrorFromResponse(e,t="The request failed"){let r=t;if(typeof e.data==="string")r=e.data;if(e.data&&typeof e.data==="object"&&"error"in e.data&&e.data.error&&!e.ok){if(typeof e.data.error==="string")return{message:e.data.error,code:e.status,status:e.statusText};if(typeof e.data.error==="object"){r="message"in e.data.error&&typeof e.data.error.message==="string"?e.data.error.message:r;let n="status"in e.data.error&&typeof e.data.error.status==="string"?e.data.error.status:e.statusText,s="code"in e.data.error&&typeof e.data.error.code==="number"?e.data.error.code:e.status;if("errors"in e.data.error&&Array.isArray(e.data.error.errors)){let i=[];for(let u of e.data.error.errors)if(typeof u==="object"&&"message"in u&&typeof u.message==="string")i.push(u.message);return Object.assign({message:i.join(`
3
3
  `)||r,code:s,status:n},e.data.error)}return Object.assign({message:r,code:s,status:n},e.data.error)}}return{message:r,code:e.status,status:e.statusText}}}we.GaxiosError=Ar;function Au(e,t){switch(e){case"stream":return t;case"json":return JSON.parse(JSON.stringify(t));case"arraybuffer":return JSON.parse(Buffer.from(t).toString("utf8"));case"blob":return JSON.parse(t.text());default:return t}}function ys(e){function r(i){if(!i)return;i.forEach((u,h)=>{if(/^authentication$/i.test(h)||/^authorization$/i.test(h)||/secret/i.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")})}function n(i,u){if(typeof i==="object"&&i!==null&&typeof i[u]==="string"){let h=i[u];if(/grant_type=/i.test(h)||/assertion=/i.test(h)||/secret/i.test(h))i[u]="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}function s(i){if(!i||typeof i!=="object")return;else if(i instanceof FormData||i instanceof URLSearchParams||"forEach"in i&&"set"in i)i.forEach((u,h)=>{if(["grant_type","assertion"].includes(h)||/secret/.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")});else{if("grant_type"in i)i.grant_type="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("assertion"in i)i.assertion="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("client_secret"in i)i.client_secret="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}if(e.config){if(r(e.config.headers),n(e.config,"data"),s(e.config.data),n(e.config,"body"),s(e.config.body),e.config.url.searchParams.has("token"))e.config.url.searchParams.set("token","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.");if(e.config.url.searchParams.has("client_secret"))e.config.url.searchParams.set("client_secret","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")}if(e.response){if(ys({config:e.response.config}),r(e.response.headers),e.response.bodyUsed)n(e.response,"data"),s(e.response.data)}return e}});var ws=w(function(Es){Object.defineProperty(Es,"__esModule",{value:!0});Es.getRetryConfig=vu;async function vu(e){let t=ms(e);if(!e||!e.config||!t&&!e.config.retry)return{shouldRetry:!1};t=t||{},t.currentRetryAttempt=t.currentRetryAttempt||0,t.retry=t.retry===void 0||t.retry===null?3:t.retry,t.httpMethodsToRetry=t.httpMethodsToRetry||["GET","HEAD","PUT","OPTIONS","DELETE"],t.noResponseRetries=t.noResponseRetries===void 0||t.noResponseRetries===null?2:t.noResponseRetries,t.retryDelayMultiplier=t.retryDelayMultiplier?t.retryDelayMultiplier:2,t.timeOfFirstRequest=t.timeOfFirstRequest?t.timeOfFirstRequest:Date.now(),t.totalTimeout=t.totalTimeout?t.totalTimeout:Number.MAX_SAFE_INTEGER,t.maxRetryDelay=t.maxRetryDelay?t.maxRetryDelay:Number.MAX_SAFE_INTEGER;let r=[[100,199],[408,408],[429,429],[500,599]];if(t.statusCodesToRetry=t.statusCodesToRetry||r,e.config.retryConfig=t,!await(t.shouldRetry||Su)(e))return{shouldRetry:!1,config:e.config};let s=Cu(t);e.config.retryConfig.currentRetryAttempt+=1;let i=t.retryBackoff?t.retryBackoff(e,s):new Promise((u)=>{setTimeout(u,s)});if(t.onRetryAttempt)await t.onRetryAttempt(e);return await i,{shouldRetry:!0,config:e.config}}function Su(e){let t=ms(e);if(e.config.signal?.aborted&&e.code!=="TimeoutError"||e.code==="AbortError")return!1;if(!t||t.retry===0)return!1;if(!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries)return!1;if(!t.httpMethodsToRetry||!t.httpMethodsToRetry.includes(e.config.method?.toUpperCase()||"GET"))return!1;if(e.response&&e.response.status){let r=!1;for(let[n,s]of t.statusCodesToRetry){let i=e.response.status;if(i>=n&&i<=s){r=!0;break}}if(!r)return!1}if(t.currentRetryAttempt=t.currentRetryAttempt||0,t.currentRetryAttempt>=t.retry)return!1;return!0}function ms(e){if(e&&e.config&&e.config.retryConfig)return e.config.retryConfig;return}function Cu(e){let r=(e.currentRetryAttempt?0:e.retryDelay??100)+(Math.pow(e.retryDelayMultiplier,e.currentRetryAttempt)-1)/2*1000,n=e.totalTimeout-(Date.now()-e.timeOfFirstRequest);return Math.min(r,n,e.maxRetryDelay)}});var Sr=w(function(As){Object.defineProperty(As,"__esModule",{value:!0});As.GaxiosInterceptorManager=void 0;class Ts extends Set{}As.GaxiosInterceptorManager=Ts});var Os=w(function(et){var ku=et&&et.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Ze;Object.defineProperty(et,"__esModule",{value:!0});et.Gaxios=void 0;var bu=ku(wr()),xu=G("https"),We=vr(),Ru=ws(),Ss=G("stream"),Cs=Sr(),Nu=async()=>globalThis.crypto?.randomUUID()||(await import("crypto")).randomUUID(),Pu=204;class Cr{agentCache=new Map;defaults;interceptors;constructor(e){this.defaults=e||{},this.interceptors={request:new Cs.GaxiosInterceptorManager,response:new Cs.GaxiosInterceptorManager}}fetch(...e){let t=e[0],r=e[1],n=void 0,s=new Headers;if(typeof t==="string")n=new URL(t);else if(t instanceof URL)n=t;else if(t&&t.url)n=new URL(t.url);if(t&&typeof t==="object"&&"headers"in t)Ze.mergeHeaders(s,t.headers);if(r)Ze.mergeHeaders(s,new Headers(r.headers));if(typeof t==="object"&&!(t instanceof URL))return this.request({...r,...t,headers:s,url:n});else return this.request({...r,headers:s,url:n})}async request(e={}){let t=await this.#n(e);return t=await this.#t(t),this.#r(this._request(t))}async _defaultAdapter(e){let t=e.fetchImplementation||this.defaults.fetchImplementation||await Ze.#c(),r={...e};delete r.data;let n=await t(e.url,r),s=await this.getResponseData(e,n);if(!Object.getOwnPropertyDescriptor(n,"data")?.configurable)Object.defineProperties(n,{data:{configurable:!0,writable:!0,enumerable:!0,value:s}});return Object.assign(n,{config:e,data:s})}async _request(e){try{let t;if(e.adapter)t=await e.adapter(e,this._defaultAdapter.bind(this));else t=await this._defaultAdapter(e);if(!e.validateStatus(t.status)){if(e.responseType==="stream"){let n=[];for await(let s of t.data)n.push(s);t.data=Buffer.concat(n.map((s)=>typeof s==="string"?Buffer.from(s):s)).toString("utf8")}let r=We.GaxiosError.extractAPIErrorFromResponse(t,`Request failed with status code ${t.status}`);throw new We.GaxiosError(r?.message,e,t,r)}return t}catch(t){let r;if(t instanceof We.GaxiosError)r=t;else if(t instanceof Error)r=new We.GaxiosError(t.message,e,void 0,t);else r=new We.GaxiosError("Unexpected Gaxios Error",e,void 0,t);let{shouldRetry:n,config:s}=await Ru.getRetryConfig(r);if(n&&s)return r.config.retryConfig.currentRetryAttempt=s.retryConfig.currentRetryAttempt,e.retryConfig=r.config?.retryConfig,this.#s(e),this._request(e);if(e.errorRedactor)e.errorRedactor(r);throw r}}async getResponseData(e,t){if(t.status===Pu)return"";if(e.maxContentLength&&t.headers.has("content-length")&&e.maxContentLength<Number.parseInt(t.headers?.get("content-length")||""))throw new We.GaxiosError("Response's `Content-Length` is over the limit.",e,Object.assign(t,{config:e}));switch(e.responseType){case"stream":return t.body;case"json":{let r=await t.text();try{return JSON.parse(r)}catch{return r}}case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"text":return t.text();default:return this.getResponseDataFromContentType(t)}}#e(e,t=[]){let r=new URL(e),n=[...t],s=(process.env.NO_PROXY??process.env.no_proxy)?.split(",")||[];for(let i of s)n.push(i.trim());for(let i of n)if(i instanceof RegExp){if(i.test(r.toString()))return!1}else if(i instanceof URL){if(i.origin===r.origin)return!1}else if(i.startsWith("*.")||i.startsWith(".")){let u=i.replace(/^\*\./,".");if(r.hostname.endsWith(u))return!1}else if(i===r.origin||i===r.hostname||i===r.href)return!1;return!0}async#t(e){let t=Promise.resolve(e);for(let r of this.interceptors.request.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#r(e){let t=Promise.resolve(e);for(let r of this.interceptors.response.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#n(e){let t=new Headers(this.defaults.headers);Ze.mergeHeaders(t,e.headers);let r=(0,bu.default)(!0,{},this.defaults,e);if(!r.url)throw Error("URL is required.");if(r.baseURL)r.url=new URL(r.url,r.baseURL);if(r.url=new URL(r.url),r.params)if(r.paramsSerializer){let i=r.paramsSerializer(r.params);if(i.startsWith("?"))i=i.slice(1);let u=r.url.toString().includes("?")?"&":"?";r.url=r.url+u+i}else{let i=r.url instanceof URL?r.url:new URL(r.url);for(let[u,h]of new URLSearchParams(r.params))i.searchParams.append(u,h);r.url=i}if(typeof e.maxContentLength==="number")r.size=e.maxContentLength;if(typeof e.maxRedirects==="number")r.follow=e.maxRedirects;let n=typeof r.data==="string"||r.data instanceof ArrayBuffer||r.data instanceof Blob||globalThis.File&&r.data instanceof File||r.data instanceof FormData||r.data instanceof Ss.Readable||r.data instanceof ReadableStream||r.data instanceof String||r.data instanceof URLSearchParams||ArrayBuffer.isView(r.data)||["Blob","File","FormData"].includes(r.data?.constructor?.name||"");if(r.multipart?.length){let i=await Nu();t.set("content-type",`multipart/related; boundary=${i}`),r.body=Ss.Readable.from(this.getMultipartRequest(r.multipart,i))}else if(n)r.body=r.data;else if(typeof r.data==="object")if(t.get("Content-Type")==="application/x-www-form-urlencoded")r.body=r.paramsSerializer?r.paramsSerializer(r.data):new URLSearchParams(r.data);else{if(!t.has("content-type"))t.set("content-type","application/json");r.body=JSON.stringify(r.data)}else if(r.data)r.body=r.data;if(r.validateStatus=r.validateStatus||this.validateStatus,r.responseType=r.responseType||"unknown",!t.has("accept")&&r.responseType==="json")t.set("accept","application/json");let s=r.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(r.agent);else if(s&&this.#e(r.url,r.noProxy)){let i=await Ze.#a();if(this.agentCache.has(s))r.agent=this.agentCache.get(s);else r.agent=new i(s,{cert:r.cert,key:r.key}),this.agentCache.set(s,r.agent)}else if(r.cert&&r.key)if(this.agentCache.has(r.key))r.agent=this.agentCache.get(r.key);else r.agent=new xu.Agent({cert:r.cert,key:r.key}),this.agentCache.set(r.key,r.agent);if(typeof r.errorRedactor!=="function"&&r.errorRedactor!==!1)r.errorRedactor=We.defaultErrorRedactor;if(r.body&&!("duplex"in r))r.duplex="half";return this.#s(r),Object.assign(r,{headers:t,url:r.url instanceof URL?r.url:new URL(r.url)})}#s(e){if(e.timeout){let t=AbortSignal.timeout(e.timeout);if(e.signal&&!e.signal.aborted)e.signal=AbortSignal.any([e.signal,t]);else e.signal=t}}validateStatus(e){return e>=200&&e<300}async getResponseDataFromContentType(e){let t=e.headers.get("Content-Type");if(t===null)return e.text();if(t=t.toLowerCase(),t.includes("application/json")){let r=await e.text();try{r=JSON.parse(r)}catch{}return r}else if(t.match(/^text\//))return e.text();else return e.blob()}async*getMultipartRequest(e,t){let r=`--${t}--`;for(let n of e){let s=n.headers.get("Content-Type")||"application/octet-stream";if(yield`--${t}\r
4
4
  Content-Type: ${s}\r
5
5
  \r
6
6
  `,typeof n.content==="string")yield n.content;else yield*n.content;yield`\r
7
- `}yield r}static#i;static#o;static async#a(){return this.#i||=(await import("./chunk-4cj3pz27.js").then((m)=>z(m.default))).HttpsProxyAgent,this.#i}static async#c(){let e=typeof window<"u"&&!!window;return this.#o||=e?window.fetch:(await import("node-fetch")).default,this.#o}static mergeHeaders(e,...t){e=e instanceof Headers?e:new Headers(e);for(let r of t)(r instanceof Headers?r:new Headers(r)).forEach((s,i)=>{i==="set-cookie"?e.append(i,s):e.set(i,s)});return e}}et.Gaxios=Cr;Ze=Cr});var ie=w(function(le){var Iu=le&&le.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),ju=le&&le.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Iu(t,e,r)};Object.defineProperty(le,"__esModule",{value:!0});le.instance=le.Gaxios=le.GaxiosError=void 0;le.request=Uu;var ks=Os();Object.defineProperty(le,"Gaxios",{enumerable:!0,get:function(){return ks.Gaxios}});var Du=vr();Object.defineProperty(le,"GaxiosError",{enumerable:!0,get:function(){return Du.GaxiosError}});ju(Sr(),le);le.instance=new ks.Gaxios;async function Uu(e){return le.instance.request(e)}});var Or=w(function(bs,jt){(function(e){var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,{ceil:n,floor:s}=Math,i="[BigNumber Error] ",u=i+"Number primitive has more than 15 significant digits: ",h=100000000000000,y=14,S=9007199254740991,A=[1,10,100,1000,1e4,1e5,1e6,1e7,1e8,1e9,10000000000,100000000000,1000000000000,10000000000000],k=1e7,N=1e9;function F(U){var D,B,X,C=v.prototype={constructor:v,toString:null,valueOf:null},ne=new v(1),Q=20,Z=4,he=-7,fe=21,Ke=-1e7,Se=1e7,Je=!1,ft=1,Le=0,fr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Ve="0123456789abcdefghijklmnopqrstuvwxyz",dr=!0;function v(o,a){var c,_,f,p,E,l,d,m,g=this;if(!(g instanceof v))return new v(o,a);if(a==null){if(o&&o._isBigNumber===!0){if(g.s=o.s,!o.c||o.e>Se)g.c=g.e=null;else if(o.e<Ke)g.c=[g.e=0];else g.e=o.e,g.c=o.c.slice();return}if((l=typeof o=="number")&&o*0==0){if(g.s=1/o<0?(o=-o,-1):1,o===~~o){for(p=0,E=o;E>=10;E/=10,p++);if(p>Se)g.c=g.e=null;else g.e=p,g.c=[o];return}m=String(o)}else{if(!r.test(m=String(o)))return X(g,m,l);g.s=m.charCodeAt(0)==45?(m=m.slice(1),-1):1}if((p=m.indexOf("."))>-1)m=m.replace(".","");if((E=m.search(/e/i))>0){if(p<0)p=E;p+=+m.slice(E+1),m=m.substring(0,E)}else if(p<0)p=m.length}else{if(b(a,2,Ve.length,"Base"),a==10&&dr)return g=new v(o),ye(g,Q+g.e+1,Z);if(m=String(o),l=typeof o=="number"){if(o*0!=0)return X(g,m,l,a);if(g.s=1/o<0?(m=m.slice(1),-1):1,v.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(u+o)}else g.s=m.charCodeAt(0)===45?(m=m.slice(1),-1):1;c=Ve.slice(0,a),p=E=0;for(d=m.length;E<d;E++)if(c.indexOf(_=m.charAt(E))<0){if(_=="."){if(E>p){p=d;continue}}else if(!f){if(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase())){f=!0,E=-1,p=0;continue}}return X(g,String(o),l,a)}if(l=!1,m=B(m,a,10,g.s),(p=m.indexOf("."))>-1)m=m.replace(".","");else p=m.length}for(E=0;m.charCodeAt(E)===48;E++);for(d=m.length;m.charCodeAt(--d)===48;);if(m=m.slice(E,++d)){if(d-=E,l&&v.DEBUG&&d>15&&(o>S||o!==s(o)))throw Error(u+g.s*o);if((p=p-E-1)>Se)g.c=g.e=null;else if(p<Ke)g.c=[g.e=0];else{if(g.e=p,g.c=[],E=(p+1)%y,p<0)E+=y;if(E<d){if(E)g.c.push(+m.slice(0,E));for(d-=y;E<d;)g.c.push(+m.slice(E,E+=y));E=y-(m=m.slice(E)).length}else E-=d;for(;E--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}v.clone=F,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(o){var a,c;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(a="DECIMAL_PLACES"))c=o[a],b(c,0,N,a),Q=c;if(o.hasOwnProperty(a="ROUNDING_MODE"))c=o[a],b(c,0,8,a),Z=c;if(o.hasOwnProperty(a="EXPONENTIAL_AT"))if(c=o[a],c&&c.pop)b(c[0],-N,0,a),b(c[1],0,N,a),he=c[0],fe=c[1];else b(c,-N,N,a),he=-(fe=c<0?-c:c);if(o.hasOwnProperty(a="RANGE"))if(c=o[a],c&&c.pop)b(c[0],-N,-1,a),b(c[1],1,N,a),Ke=c[0],Se=c[1];else if(b(c,-N,N,a),c)Ke=-(Se=c<0?-c:c);else throw Error(i+a+" cannot be zero: "+c);if(o.hasOwnProperty(a="CRYPTO"))if(c=o[a],c===!!c)if(c)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Je=c;else throw Je=!c,Error(i+"crypto unavailable");else Je=c;else throw Error(i+a+" not true or false: "+c);if(o.hasOwnProperty(a="MODULO_MODE"))c=o[a],b(c,0,9,a),ft=c;if(o.hasOwnProperty(a="POW_PRECISION"))c=o[a],b(c,0,N,a),Le=c;if(o.hasOwnProperty(a="FORMAT"))if(c=o[a],typeof c=="object")fr=c;else throw Error(i+a+" not an object: "+c);if(o.hasOwnProperty(a="ALPHABET"))if(c=o[a],typeof c=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(c))dr=c.slice(0,10)=="0123456789",Ve=c;else throw Error(i+a+" invalid: "+c)}else throw Error(i+"Object expected: "+o);return{DECIMAL_PLACES:Q,ROUNDING_MODE:Z,EXPONENTIAL_AT:[he,fe],RANGE:[Ke,Se],CRYPTO:Je,MODULO_MODE:ft,POW_PRECISION:Le,FORMAT:fr,ALPHABET:Ve}},v.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var a,c,{c:_,e:f,s:p}=o;e:if({}.toString.call(_)=="[object Array]"){if((p===1||p===-1)&&f>=-N&&f<=N&&f===s(f)){if(_[0]===0){if(f===0&&_.length===1)return!0;break e}if(a=(f+1)%y,a<1)a+=y;if(String(_[0]).length==a){for(a=0;a<_.length;a++)if(c=_[a],c<0||c>=h||c!==s(c))break e;if(c!==0)return!0}}}else if(_===null&&f===null&&(p===null||p===1||p===-1))return!0;throw Error(i+"Invalid BigNumber: "+o)},v.maximum=v.max=function(){return Qn(arguments,-1)},v.minimum=v.min=function(){return Qn(arguments,1)},v.random=function(){var o=9007199254740992,a=Math.random()*o&2097151?function(){return s(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(c){var _,f,p,E,l,d=0,m=[],g=new v(ne);if(c==null)c=Q;else b(c,0,N);if(E=n(c/y),Je)if(crypto.getRandomValues){_=crypto.getRandomValues(new Uint32Array(E*=2));for(;d<E;)if(l=_[d]*131072+(_[d+1]>>>11),l>=9000000000000000)f=crypto.getRandomValues(new Uint32Array(2)),_[d]=f[0],_[d+1]=f[1];else m.push(l%100000000000000),d+=2;d=E/2}else if(crypto.randomBytes){_=crypto.randomBytes(E*=7);for(;d<E;)if(l=(_[d]&31)*281474976710656+_[d+1]*1099511627776+_[d+2]*4294967296+_[d+3]*16777216+(_[d+4]<<16)+(_[d+5]<<8)+_[d+6],l>=9000000000000000)crypto.randomBytes(7).copy(_,d);else m.push(l%100000000000000),d+=7;d=E/7}else throw Je=!1,Error(i+"crypto unavailable");if(!Je){for(;d<E;)if(l=a(),l<9000000000000000)m[d++]=l%100000000000000}if(E=m[--d],c%=y,E&&c)l=A[y-c],m[d]=s(E/l)*l;for(;m[d]===0;m.pop(),d--);if(d<0)m=[p=0];else{for(p=-1;m[0]===0;m.splice(0,1),p-=y);for(d=1,l=m[0];l>=10;l/=10,d++);if(d<y)p-=y-d}return g.e=p,g.c=m,g}}(),v.sum=function(){var o=1,a=arguments,c=new v(a[0]);for(;o<a.length;)c=c.plus(a[o++]);return c},B=function(){var o="0123456789";function a(c,_,f,p){var E,l=[0],d,m=0,g=c.length;for(;m<g;){for(d=l.length;d--;l[d]*=_);l[0]+=p.indexOf(c.charAt(m++));for(E=0;E<l.length;E++)if(l[E]>f-1){if(l[E+1]==null)l[E+1]=0;l[E+1]+=l[E]/f|0,l[E]%=f}}return l.reverse()}return function(c,_,f,p,E){var l,d,m,g,T,R,P,L,ee=c.indexOf("."),se=Q,M=Z;if(ee>=0)g=Le,Le=0,c=c.replace(".",""),L=new v(_),R=L.pow(c.length-ee),Le=g,L.c=a(ce(x(R.c),R.e,"0"),10,f,o),L.e=L.c.length;P=a(c,_,f,E?(l=Ve,o):(l=o,Ve)),m=g=P.length;for(;P[--g]==0;P.pop());if(!P[0])return l.charAt(0);if(ee<0)--m;else R.c=P,R.e=m,R.s=p,R=D(R,L,se,M,f),P=R.c,T=R.r,m=R.e;if(d=m+se+1,ee=P[d],g=f/2,T=T||d<0||P[d+1]!=null,T=M<4?(ee!=null||T)&&(M==0||M==(R.s<0?3:2)):ee>g||ee==g&&(M==4||T||M==6&&P[d-1]&1||M==(R.s<0?8:7)),d<1||!P[0])c=T?ce(l.charAt(1),-se,l.charAt(0)):l.charAt(0);else{if(P.length=d,T){for(--f;++P[--d]>f;)if(P[d]=0,!d)++m,P=[1].concat(P)}for(g=P.length;!P[--g];);for(ee=0,c="";ee<=g;c+=l.charAt(P[ee++]));c=ce(c,m,l.charAt(0))}return c}}(),D=function(){function o(_,f,p){var E,l,d,m,g=0,T=_.length,R=f%k,P=f/k|0;for(_=_.slice();T--;)d=_[T]%k,m=_[T]/k|0,E=P*d+m*R,l=R*d+E%k*k+g,g=(l/p|0)+(E/k|0)+P*m,_[T]=l%p;if(g)_=[g].concat(_);return _}function a(_,f,p,E){var l,d;if(p!=E)d=p>E?1:-1;else for(l=d=0;l<p;l++)if(_[l]!=f[l]){d=_[l]>f[l]?1:-1;break}return d}function c(_,f,p,E){var l=0;for(;p--;)_[p]-=l,l=_[p]<f[p]?1:0,_[p]=l*E+_[p]-f[p];for(;!_[0]&&_.length>1;_.splice(0,1));}return function(_,f,p,E,l){var d,m,g,T,R,P,L,ee,se,M,K,ae,Nt,_r,yr,Re,dt,me=_.s==f.s?1:-1,ue=_.c,te=f.c;if(!ue||!ue[0]||!te||!te[0])return new v(!_.s||!f.s||(ue?te&&ue[0]==te[0]:!te)?NaN:ue&&ue[0]==0||!te?me*0:me/0);if(ee=new v(me),se=ee.c=[],m=_.e-f.e,me=p+m+1,!l)l=h,m=V(_.e/y)-V(f.e/y),me=me/y|0;for(g=0;te[g]==(ue[g]||0);g++);if(te[g]>(ue[g]||0))m--;if(me<0)se.push(1),T=!0;else{if(_r=ue.length,Re=te.length,g=0,me+=2,R=s(l/(te[0]+1)),R>1)te=o(te,R,l),ue=o(ue,R,l),Re=te.length,_r=ue.length;Nt=Re,M=ue.slice(0,Re),K=M.length;for(;K<Re;M[K++]=0);if(dt=te.slice(),dt=[0].concat(dt),yr=te[0],te[1]>=l/2)yr++;do{if(R=0,d=a(te,M,Re,K),d<0){if(ae=M[0],Re!=K)ae=ae*l+(M[1]||0);if(R=s(ae/yr),R>1){if(R>=l)R=l-1;P=o(te,R,l),L=P.length,K=M.length;while(a(P,M,L,K)==1)R--,c(P,Re<L?dt:te,L,l),L=P.length,d=1}else{if(R==0)d=R=1;P=te.slice(),L=P.length}if(L<K)P=[0].concat(P);if(c(M,P,K,l),K=M.length,d==-1)while(a(te,M,Re,K)<1)R++,c(M,Re<K?dt:te,K,l),K=M.length}else if(d===0)R++,M=[0];if(se[g++]=R,M[0])M[K++]=ue[Nt]||0;else M=[ue[Nt]],K=1}while((Nt++<_r||M[0]!=null)&&me--);if(T=M[0]!=null,!se[0])se.splice(0,1)}if(l==h){for(g=1,me=se[0];me>=10;me/=10,g++);ye(ee,p+(ee.e=g+m*y-1)+1,E,T)}else ee.e=m,ee.r=+T;return ee}}();function pr(o,a,c,_){var f,p,E,l,d;if(c==null)c=Z;else b(c,0,8);if(!o.c)return o.toString();if(f=o.c[0],E=o.e,a==null)d=x(o.c),d=_==1||_==2&&(E<=he||E>=fe)?re(d,E):ce(d,E,"0");else if(o=ye(new v(o),a,c),p=o.e,d=x(o.c),l=d.length,_==1||_==2&&(a<=p||p<=he)){for(;l<a;d+="0",l++);d=re(d,p)}else if(a-=E+(_===2&&p>E),d=ce(d,p,"0"),p+1>l){if(--a>0)for(d+=".";a--;d+="0");}else if(a+=p-l,a>0){if(p+1==l)d+=".";for(;a--;d+="0");}return o.s<0&&f?"-"+d:d}function Qn(o,a){var c,_,f=1,p=new v(o[0]);for(;f<o.length;f++)if(_=new v(o[f]),!_.s||(c=j(p,_))===a||c===0&&p.s===a)p=_;return p}function gr(o,a,c){var _=1,f=a.length;for(;!a[--f];a.pop());for(f=a[0];f>=10;f/=10,_++);if((c=_+c*y-1)>Se)o.c=o.e=null;else if(c<Ke)o.c=[o.e=0];else o.e=c,o.c=a;return o}X=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,a=/^([^.]+)\.$/,c=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(p,E,l,d){var m,g=l?E:E.replace(f,"");if(_.test(g))p.s=isNaN(g)?null:g<0?-1:1;else{if(!l){if(g=g.replace(o,function(T,R,P){return m=(P=P.toLowerCase())=="x"?16:P=="b"?2:8,!d||d==m?R:T}),d)m=d,g=g.replace(a,"$1").replace(c,"0.$1");if(E!=g)return new v(g,m)}if(v.DEBUG)throw Error(i+"Not a"+(d?" base "+d:"")+" number: "+E);p.s=null}p.c=p.e=null}}();function ye(o,a,c,_){var f,p,E,l,d,m,g,T=o.c,R=A;if(T){e:{for(f=1,l=T[0];l>=10;l/=10,f++);if(p=a-f,p<0)p+=y,E=a,d=T[m=0],g=s(d/R[f-E-1]%10);else if(m=n((p+1)/y),m>=T.length)if(_){for(;T.length<=m;T.push(0));d=g=0,f=1,p%=y,E=p-y+1}else break e;else{d=l=T[m];for(f=1;l>=10;l/=10,f++);p%=y,E=p-y+f,g=E<0?0:s(d/R[f-E-1]%10)}if(_=_||a<0||T[m+1]!=null||(E<0?d:d%R[f-E-1]),_=c<4?(g||_)&&(c==0||c==(o.s<0?3:2)):g>5||g==5&&(c==4||_||c==6&&(p>0?E>0?d/R[f-E]:0:T[m-1])%10&1||c==(o.s<0?8:7)),a<1||!T[0]){if(T.length=0,_)a-=o.e+1,T[0]=R[(y-a%y)%y],o.e=-a||0;else T[0]=o.e=0;return o}if(p==0)T.length=m,l=1,m--;else T.length=m+1,l=R[y-p],T[m]=E>0?s(d/R[f-E]%R[E])*l:0;if(_)for(;;)if(m==0){for(p=1,E=T[0];E>=10;E/=10,p++);E=T[0]+=l;for(l=1;E>=10;E/=10,l++);if(p!=l){if(o.e++,T[0]==h)T[0]=1}break}else{if(T[m]+=l,T[m]!=h)break;T[m--]=0,l=1}for(p=T.length;T[--p]===0;T.pop());}if(o.e>Se)o.c=o.e=null;else if(o.e<Ke)o.c=[o.e=0]}return o}function je(o){var a,c=o.e;if(c===null)return o.toString();return a=x(o.c),a=c<=he||c>=fe?re(a,c):ce(a,c,"0"),o.s<0?"-"+a:a}if(C.absoluteValue=C.abs=function(){var o=new v(this);if(o.s<0)o.s=1;return o},C.comparedTo=function(o,a){return j(this,new v(o,a))},C.decimalPlaces=C.dp=function(o,a){var c,_,f,p=this;if(o!=null){if(b(o,0,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o+p.e+1,a)}if(!(c=p.c))return null;if(_=((f=c.length-1)-V(this.e/y))*y,f=c[f])for(;f%10==0;f/=10,_--);if(_<0)_=0;return _},C.dividedBy=C.div=function(o,a){return D(this,new v(o,a),Q,Z)},C.dividedToIntegerBy=C.idiv=function(o,a){return D(this,new v(o,a),0,1)},C.exponentiatedBy=C.pow=function(o,a){var c,_,f,p,E,l,d,m,g,T=this;if(o=new v(o),o.c&&!o.isInteger())throw Error(i+"Exponent not an integer: "+je(o));if(a!=null)a=new v(a);if(l=o.e>14,!T.c||!T.c[0]||T.c[0]==1&&!T.e&&T.c.length==1||!o.c||!o.c[0])return g=new v(Math.pow(+je(T),l?o.s*(2-H(o)):+je(o))),a?g.mod(a):g;if(d=o.s<0,a){if(a.c?!a.c[0]:!a.s)return new v(NaN);if(_=!d&&T.isInteger()&&a.isInteger(),_)T=T.mod(a)}else if(o.e>9&&(T.e>0||T.e<-1||(T.e==0?T.c[0]>1||l&&T.c[1]>=240000000:T.c[0]<80000000000000||l&&T.c[0]<=99999750000000))){if(p=T.s<0&&H(o)?-0:0,T.e>-1)p=1/p;return new v(d?1/p:p)}else if(Le)p=n(Le/y+2);if(l){if(c=new v(0.5),d)o.s=1;m=H(o)}else f=Math.abs(+je(o)),m=f%2;g=new v(ne);for(;;){if(m){if(g=g.times(T),!g.c)break;if(p){if(g.c.length>p)g.c.length=p}else if(_)g=g.mod(a)}if(f){if(f=s(f/2),f===0)break;m=f%2}else if(o=o.times(c),ye(o,o.e+1,1),o.e>14)m=H(o);else{if(f=+je(o),f===0)break;m=f%2}if(T=T.times(T),p){if(T.c&&T.c.length>p)T.c.length=p}else if(_)T=T.mod(a)}if(_)return g;if(d)g=ne.div(g);return a?g.mod(a):p?ye(g,Le,Z,E):g},C.integerValue=function(o){var a=new v(this);if(o==null)o=Z;else b(o,0,8);return ye(a,a.e+1,o)},C.isEqualTo=C.eq=function(o,a){return j(this,new v(o,a))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(o,a){return j(this,new v(o,a))>0},C.isGreaterThanOrEqualTo=C.gte=function(o,a){return(a=j(this,new v(o,a)))===1||a===0},C.isInteger=function(){return!!this.c&&V(this.e/y)>this.c.length-2},C.isLessThan=C.lt=function(o,a){return j(this,new v(o,a))<0},C.isLessThanOrEqualTo=C.lte=function(o,a){return(a=j(this,new v(o,a)))===-1||a===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(o,a){var c,_,f,p,E=this,l=E.s;if(o=new v(o,a),a=o.s,!l||!a)return new v(NaN);if(l!=a)return o.s=-a,E.plus(o);var d=E.e/y,m=o.e/y,g=E.c,T=o.c;if(!d||!m){if(!g||!T)return g?(o.s=-a,o):new v(T?E:NaN);if(!g[0]||!T[0])return T[0]?(o.s=-a,o):new v(g[0]?E:Z==3?-0:0)}if(d=V(d),m=V(m),g=g.slice(),l=d-m){if(p=l<0)l=-l,f=g;else m=d,f=T;f.reverse();for(a=l;a--;f.push(0));f.reverse()}else{_=(p=(l=g.length)<(a=T.length))?l:a;for(l=a=0;a<_;a++)if(g[a]!=T[a]){p=g[a]<T[a];break}}if(p)f=g,g=T,T=f,o.s=-o.s;if(a=(_=T.length)-(c=g.length),a>0)for(;a--;g[c++]=0);a=h-1;for(;_>l;){if(g[--_]<T[_]){for(c=_;c&&!g[--c];g[c]=a);--g[c],g[_]+=h}g[_]-=T[_]}for(;g[0]==0;g.splice(0,1),--m);if(!g[0])return o.s=Z==3?-1:1,o.c=[o.e=0],o;return gr(o,g,m)},C.modulo=C.mod=function(o,a){var c,_,f=this;if(o=new v(o,a),!f.c||!o.s||o.c&&!o.c[0])return new v(NaN);else if(!o.c||f.c&&!f.c[0])return new v(f);if(ft==9)_=o.s,o.s=1,c=D(f,o,0,3),o.s=_,c.s*=_;else c=D(f,o,0,ft);if(o=f.minus(c.times(o)),!o.c[0]&&ft==1)o.s=f.s;return o},C.multipliedBy=C.times=function(o,a){var c,_,f,p,E,l,d,m,g,T,R,P,L,ee,se,M=this,K=M.c,ae=(o=new v(o,a)).c;if(!K||!ae||!K[0]||!ae[0]){if(!M.s||!o.s||K&&!K[0]&&!ae||ae&&!ae[0]&&!K)o.c=o.e=o.s=null;else if(o.s*=M.s,!K||!ae)o.c=o.e=null;else o.c=[0],o.e=0;return o}if(_=V(M.e/y)+V(o.e/y),o.s*=M.s,d=K.length,T=ae.length,d<T)L=K,K=ae,ae=L,f=d,d=T,T=f;for(f=d+T,L=[];f--;L.push(0));ee=h,se=k;for(f=T;--f>=0;){c=0,R=ae[f]%se,P=ae[f]/se|0;for(E=d,p=f+E;p>f;)m=K[--E]%se,g=K[E]/se|0,l=P*m+g*R,m=R*m+l%se*se+L[p]+c,c=(m/ee|0)+(l/se|0)+P*g,L[p--]=m%ee;L[p]=c}if(c)++_;else L.splice(0,1);return gr(o,L,_)},C.negated=function(){var o=new v(this);return o.s=-o.s||null,o},C.plus=function(o,a){var c,_=this,f=_.s;if(o=new v(o,a),a=o.s,!f||!a)return new v(NaN);if(f!=a)return o.s=-a,_.minus(o);var p=_.e/y,E=o.e/y,l=_.c,d=o.c;if(!p||!E){if(!l||!d)return new v(f/0);if(!l[0]||!d[0])return d[0]?o:new v(l[0]?_:f*0)}if(p=V(p),E=V(E),l=l.slice(),f=p-E){if(f>0)E=p,c=d;else f=-f,c=l;c.reverse();for(;f--;c.push(0));c.reverse()}if(f=l.length,a=d.length,f-a<0)c=d,d=l,l=c,a=f;for(f=0;a;)f=(l[--a]=l[a]+d[a]+f)/h|0,l[a]=h===l[a]?0:l[a]%h;if(f)l=[f].concat(l),++E;return gr(o,l,E)},C.precision=C.sd=function(o,a){var c,_,f,p=this;if(o!=null&&o!==!!o){if(b(o,1,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o,a)}if(!(c=p.c))return null;if(f=c.length-1,_=f*y+1,f=c[f]){for(;f%10==0;f/=10,_--);for(f=c[0];f>=10;f/=10,_++);}if(o&&p.e+1>_)_=p.e+1;return _},C.shiftedBy=function(o){return b(o,-S,S),this.times("1e"+o)},C.squareRoot=C.sqrt=function(){var o,a,c,_,f,p=this,{c:E,s:l,e:d}=p,m=Q+4,g=new v("0.5");if(l!==1||!E||!E[0])return new v(!l||l<0&&(!E||E[0])?NaN:E?p:1/0);if(l=Math.sqrt(+je(p)),l==0||l==1/0){if(a=x(E),(a.length+d)%2==0)a+="0";if(l=Math.sqrt(+a),d=V((d+1)/2)-(d<0||d%2),l==1/0)a="5e"+d;else a=l.toExponential(),a=a.slice(0,a.indexOf("e")+1)+d;c=new v(a)}else c=new v(l+"");if(c.c[0]){if(d=c.e,l=d+m,l<3)l=0;for(;;)if(f=c,c=g.times(f.plus(D(p,f,m,1))),x(f.c).slice(0,l)===(a=x(c.c)).slice(0,l)){if(c.e<d)--l;if(a=a.slice(l-3,l+1),a=="9999"||!_&&a=="4999"){if(!_){if(ye(f,f.e+Q+2,0),f.times(f).eq(p)){c=f;break}}m+=4,l+=4,_=1}else{if(!+a||!+a.slice(1)&&a.charAt(0)=="5")ye(c,c.e+Q+2,1),o=!c.times(c).eq(p);break}}}return ye(c,c.e+Q+1,Z,o)},C.toExponential=function(o,a){if(o!=null)b(o,0,N),o++;return pr(this,o,a,1)},C.toFixed=function(o,a){if(o!=null)b(o,0,N),o=o+this.e+1;return pr(this,o,a)},C.toFormat=function(o,a,c){var _,f=this;if(c==null)if(o!=null&&a&&typeof a=="object")c=a,a=null;else if(o&&typeof o=="object")c=o,o=a=null;else c=fr;else if(typeof c!="object")throw Error(i+"Argument not an object: "+c);if(_=f.toFixed(o,a),f.c){var p,E=_.split("."),l=+c.groupSize,d=+c.secondaryGroupSize,m=c.groupSeparator||"",g=E[0],T=E[1],R=f.s<0,P=R?g.slice(1):g,L=P.length;if(d)p=l,l=d,d=p,L-=p;if(l>0&&L>0){p=L%l||l,g=P.substr(0,p);for(;p<L;p+=l)g+=m+P.substr(p,l);if(d>0)g+=m+P.slice(p);if(R)g="-"+g}_=T?g+(c.decimalSeparator||"")+((d=+c.fractionGroupSize)?T.replace(new RegExp("\\d{"+d+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):T):g}return(c.prefix||"")+_+(c.suffix||"")},C.toFraction=function(o){var a,c,_,f,p,E,l,d,m,g,T,R,P=this,L=P.c;if(o!=null){if(l=new v(o),!l.isInteger()&&(l.c||l.s!==1)||l.lt(ne))throw Error(i+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+je(l))}if(!L)return new v(P);a=new v(ne),m=c=new v(ne),_=d=new v(ne),R=x(L),p=a.e=R.length-P.e-1,a.c[0]=A[(E=p%y)<0?y+E:E],o=!o||l.comparedTo(a)>0?p>0?a:m:l,E=Se,Se=1/0,l=new v(R),d.c[0]=0;for(;;){if(g=D(l,a,0,1),f=c.plus(g.times(_)),f.comparedTo(o)==1)break;c=_,_=f,m=d.plus(g.times(f=m)),d=f,a=l.minus(g.times(f=a)),l=f}return f=D(o.minus(c),_,0,1),d=d.plus(f.times(m)),c=c.plus(f.times(_)),d.s=m.s=P.s,p=p*2,T=D(m,_,p,Z).minus(P).abs().comparedTo(D(d,c,p,Z).minus(P).abs())<1?[m,_]:[d,c],Se=E,T},C.toNumber=function(){return+je(this)},C.toPrecision=function(o,a){if(o!=null)b(o,1,N);return pr(this,o,a,2)},C.toString=function(o){var a,c=this,_=c.s,f=c.e;if(f===null)if(_){if(a="Infinity",_<0)a="-"+a}else a="NaN";else{if(o==null)a=f<=he||f>=fe?re(x(c.c),f):ce(x(c.c),f,"0");else if(o===10&&dr)c=ye(new v(c),Q+f+1,Z),a=ce(x(c.c),c.e,"0");else b(o,2,Ve.length,"Base"),a=B(ce(x(c.c),f,"0"),10,o,_,!0);if(_<0&&c.c[0])a="-"+a}return a},C.valueOf=C.toJSON=function(){return je(this)},C._isBigNumber=!0,U!=null)v.set(U);return v}function V(U){var D=U|0;return U>0||U===D?D:D-1}function x(U){var D,B,X=1,C=U.length,ne=U[0]+"";for(;X<C;){D=U[X++]+"",B=y-D.length;for(;B--;D="0"+D);ne+=D}for(C=ne.length;ne.charCodeAt(--C)===48;);return ne.slice(0,C+1||1)}function j(U,D){var B,X,C=U.c,ne=D.c,Q=U.s,Z=D.s,he=U.e,fe=D.e;if(!Q||!Z)return null;if(B=C&&!C[0],X=ne&&!ne[0],B||X)return B?X?0:-Z:Q;if(Q!=Z)return Q;if(B=Q<0,X=he==fe,!C||!ne)return X?0:!C^B?1:-1;if(!X)return he>fe^B?1:-1;Z=(he=C.length)<(fe=ne.length)?he:fe;for(Q=0;Q<Z;Q++)if(C[Q]!=ne[Q])return C[Q]>ne[Q]^B?1:-1;return he==fe?0:he>fe^B?1:-1}function b(U,D,B,X){if(U<D||U>B||U!==s(U))throw Error(i+(X||"Argument")+(typeof U=="number"?U<D||U>B?" out of range: ":" not an integer: ":" not a primitive number: ")+String(U))}function H(U){var D=U.c.length-1;return V(U.e/y)==D&&U.c[D]%2!=0}function re(U,D){return(U.length>1?U.charAt(0)+"."+U.slice(1):U)+(D<0?"e":"e+")+D}function ce(U,D,B){var X,C;if(D<0){for(C=B+".";++D;C+=B);U=C+U}else if(X=U.length,++D>X){for(C=B,D-=X;--D;C+=B);U+=C}else if(D<X)U=U.slice(0,D)+"."+U.slice(D);return U}if(t=F(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd)define(function(){return t});else if(typeof jt<"u"&&jt.exports)jt.exports=t;else{if(!e)e=typeof self<"u"&&self?self:window;e.BigNumber=t}})(bs)});var Ps=w(function(cg,Ns){var xs=Or(),Rs=cg;(function(){function e(S){return S<10?"0"+S:S}var t=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,s,i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':"\\\"","\\":"\\\\"},u;function h(S){return r.lastIndex=0,r.test(S)?'"'+S.replace(r,function(A){var k=i[A];return typeof k==="string"?k:"\\u"+("0000"+A.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+S+'"'}function y(S,A){var k,N,F,V,x=n,j,b=A[S],H=b!=null&&(b instanceof xs||xs.isBigNumber(b));if(b&&typeof b==="object"&&typeof b.toJSON==="function")b=b.toJSON(S);if(typeof u==="function")b=u.call(A,S,b);switch(typeof b){case"string":if(H)return b;else return h(b);case"number":return isFinite(b)?String(b):"null";case"boolean":case"null":case"bigint":return String(b);case"object":if(!b)return"null";if(n+=s,j=[],Object.prototype.toString.apply(b)==="[object Array]"){V=b.length;for(k=0;k<V;k+=1)j[k]=y(k,b)||"null";return F=j.length===0?"[]":n?`[
7
+ `}yield r}static#i;static#o;static async#a(){return this.#i||=(await import("./chunk-mqr096rn.js").then((m)=>H(m.default))).HttpsProxyAgent,this.#i}static async#c(){let e=typeof window<"u"&&!!window;return this.#o||=e?window.fetch:(await import("node-fetch")).default,this.#o}static mergeHeaders(e,...t){e=e instanceof Headers?e:new Headers(e);for(let r of t)(r instanceof Headers?r:new Headers(r)).forEach((s,i)=>{i==="set-cookie"?e.append(i,s):e.set(i,s)});return e}}et.Gaxios=Cr;Ze=Cr});var ie=w(function(le){var Iu=le&&le.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),ju=le&&le.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Iu(t,e,r)};Object.defineProperty(le,"__esModule",{value:!0});le.instance=le.Gaxios=le.GaxiosError=void 0;le.request=Uu;var ks=Os();Object.defineProperty(le,"Gaxios",{enumerable:!0,get:function(){return ks.Gaxios}});var Du=vr();Object.defineProperty(le,"GaxiosError",{enumerable:!0,get:function(){return Du.GaxiosError}});ju(Sr(),le);le.instance=new ks.Gaxios;async function Uu(e){return le.instance.request(e)}});var Or=w(function(bs,jt){(function(e){var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,{ceil:n,floor:s}=Math,i="[BigNumber Error] ",u=i+"Number primitive has more than 15 significant digits: ",h=100000000000000,y=14,S=9007199254740991,A=[1,10,100,1000,1e4,1e5,1e6,1e7,1e8,1e9,10000000000,100000000000,1000000000000,10000000000000],k=1e7,N=1e9;function F(U){var D,B,X,C=v.prototype={constructor:v,toString:null,valueOf:null},ne=new v(1),Q=20,Z=4,he=-7,fe=21,Ke=-1e7,Se=1e7,Je=!1,ft=1,Le=0,fr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Ve="0123456789abcdefghijklmnopqrstuvwxyz",dr=!0;function v(o,a){var c,_,f,p,E,l,d,m,g=this;if(!(g instanceof v))return new v(o,a);if(a==null){if(o&&o._isBigNumber===!0){if(g.s=o.s,!o.c||o.e>Se)g.c=g.e=null;else if(o.e<Ke)g.c=[g.e=0];else g.e=o.e,g.c=o.c.slice();return}if((l=typeof o=="number")&&o*0==0){if(g.s=1/o<0?(o=-o,-1):1,o===~~o){for(p=0,E=o;E>=10;E/=10,p++);if(p>Se)g.c=g.e=null;else g.e=p,g.c=[o];return}m=String(o)}else{if(!r.test(m=String(o)))return X(g,m,l);g.s=m.charCodeAt(0)==45?(m=m.slice(1),-1):1}if((p=m.indexOf("."))>-1)m=m.replace(".","");if((E=m.search(/e/i))>0){if(p<0)p=E;p+=+m.slice(E+1),m=m.substring(0,E)}else if(p<0)p=m.length}else{if(b(a,2,Ve.length,"Base"),a==10&&dr)return g=new v(o),ye(g,Q+g.e+1,Z);if(m=String(o),l=typeof o=="number"){if(o*0!=0)return X(g,m,l,a);if(g.s=1/o<0?(m=m.slice(1),-1):1,v.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(u+o)}else g.s=m.charCodeAt(0)===45?(m=m.slice(1),-1):1;c=Ve.slice(0,a),p=E=0;for(d=m.length;E<d;E++)if(c.indexOf(_=m.charAt(E))<0){if(_=="."){if(E>p){p=d;continue}}else if(!f){if(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase())){f=!0,E=-1,p=0;continue}}return X(g,String(o),l,a)}if(l=!1,m=B(m,a,10,g.s),(p=m.indexOf("."))>-1)m=m.replace(".","");else p=m.length}for(E=0;m.charCodeAt(E)===48;E++);for(d=m.length;m.charCodeAt(--d)===48;);if(m=m.slice(E,++d)){if(d-=E,l&&v.DEBUG&&d>15&&(o>S||o!==s(o)))throw Error(u+g.s*o);if((p=p-E-1)>Se)g.c=g.e=null;else if(p<Ke)g.c=[g.e=0];else{if(g.e=p,g.c=[],E=(p+1)%y,p<0)E+=y;if(E<d){if(E)g.c.push(+m.slice(0,E));for(d-=y;E<d;)g.c.push(+m.slice(E,E+=y));E=y-(m=m.slice(E)).length}else E-=d;for(;E--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}v.clone=F,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(o){var a,c;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(a="DECIMAL_PLACES"))c=o[a],b(c,0,N,a),Q=c;if(o.hasOwnProperty(a="ROUNDING_MODE"))c=o[a],b(c,0,8,a),Z=c;if(o.hasOwnProperty(a="EXPONENTIAL_AT"))if(c=o[a],c&&c.pop)b(c[0],-N,0,a),b(c[1],0,N,a),he=c[0],fe=c[1];else b(c,-N,N,a),he=-(fe=c<0?-c:c);if(o.hasOwnProperty(a="RANGE"))if(c=o[a],c&&c.pop)b(c[0],-N,-1,a),b(c[1],1,N,a),Ke=c[0],Se=c[1];else if(b(c,-N,N,a),c)Ke=-(Se=c<0?-c:c);else throw Error(i+a+" cannot be zero: "+c);if(o.hasOwnProperty(a="CRYPTO"))if(c=o[a],c===!!c)if(c)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Je=c;else throw Je=!c,Error(i+"crypto unavailable");else Je=c;else throw Error(i+a+" not true or false: "+c);if(o.hasOwnProperty(a="MODULO_MODE"))c=o[a],b(c,0,9,a),ft=c;if(o.hasOwnProperty(a="POW_PRECISION"))c=o[a],b(c,0,N,a),Le=c;if(o.hasOwnProperty(a="FORMAT"))if(c=o[a],typeof c=="object")fr=c;else throw Error(i+a+" not an object: "+c);if(o.hasOwnProperty(a="ALPHABET"))if(c=o[a],typeof c=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(c))dr=c.slice(0,10)=="0123456789",Ve=c;else throw Error(i+a+" invalid: "+c)}else throw Error(i+"Object expected: "+o);return{DECIMAL_PLACES:Q,ROUNDING_MODE:Z,EXPONENTIAL_AT:[he,fe],RANGE:[Ke,Se],CRYPTO:Je,MODULO_MODE:ft,POW_PRECISION:Le,FORMAT:fr,ALPHABET:Ve}},v.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var a,c,{c:_,e:f,s:p}=o;e:if({}.toString.call(_)=="[object Array]"){if((p===1||p===-1)&&f>=-N&&f<=N&&f===s(f)){if(_[0]===0){if(f===0&&_.length===1)return!0;break e}if(a=(f+1)%y,a<1)a+=y;if(String(_[0]).length==a){for(a=0;a<_.length;a++)if(c=_[a],c<0||c>=h||c!==s(c))break e;if(c!==0)return!0}}}else if(_===null&&f===null&&(p===null||p===1||p===-1))return!0;throw Error(i+"Invalid BigNumber: "+o)},v.maximum=v.max=function(){return Qn(arguments,-1)},v.minimum=v.min=function(){return Qn(arguments,1)},v.random=function(){var o=9007199254740992,a=Math.random()*o&2097151?function(){return s(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(c){var _,f,p,E,l,d=0,m=[],g=new v(ne);if(c==null)c=Q;else b(c,0,N);if(E=n(c/y),Je)if(crypto.getRandomValues){_=crypto.getRandomValues(new Uint32Array(E*=2));for(;d<E;)if(l=_[d]*131072+(_[d+1]>>>11),l>=9000000000000000)f=crypto.getRandomValues(new Uint32Array(2)),_[d]=f[0],_[d+1]=f[1];else m.push(l%100000000000000),d+=2;d=E/2}else if(crypto.randomBytes){_=crypto.randomBytes(E*=7);for(;d<E;)if(l=(_[d]&31)*281474976710656+_[d+1]*1099511627776+_[d+2]*4294967296+_[d+3]*16777216+(_[d+4]<<16)+(_[d+5]<<8)+_[d+6],l>=9000000000000000)crypto.randomBytes(7).copy(_,d);else m.push(l%100000000000000),d+=7;d=E/7}else throw Je=!1,Error(i+"crypto unavailable");if(!Je){for(;d<E;)if(l=a(),l<9000000000000000)m[d++]=l%100000000000000}if(E=m[--d],c%=y,E&&c)l=A[y-c],m[d]=s(E/l)*l;for(;m[d]===0;m.pop(),d--);if(d<0)m=[p=0];else{for(p=-1;m[0]===0;m.splice(0,1),p-=y);for(d=1,l=m[0];l>=10;l/=10,d++);if(d<y)p-=y-d}return g.e=p,g.c=m,g}}(),v.sum=function(){var o=1,a=arguments,c=new v(a[0]);for(;o<a.length;)c=c.plus(a[o++]);return c},B=function(){var o="0123456789";function a(c,_,f,p){var E,l=[0],d,m=0,g=c.length;for(;m<g;){for(d=l.length;d--;l[d]*=_);l[0]+=p.indexOf(c.charAt(m++));for(E=0;E<l.length;E++)if(l[E]>f-1){if(l[E+1]==null)l[E+1]=0;l[E+1]+=l[E]/f|0,l[E]%=f}}return l.reverse()}return function(c,_,f,p,E){var l,d,m,g,T,R,P,L,ee=c.indexOf("."),se=Q,M=Z;if(ee>=0)g=Le,Le=0,c=c.replace(".",""),L=new v(_),R=L.pow(c.length-ee),Le=g,L.c=a(ce(x(R.c),R.e,"0"),10,f,o),L.e=L.c.length;P=a(c,_,f,E?(l=Ve,o):(l=o,Ve)),m=g=P.length;for(;P[--g]==0;P.pop());if(!P[0])return l.charAt(0);if(ee<0)--m;else R.c=P,R.e=m,R.s=p,R=D(R,L,se,M,f),P=R.c,T=R.r,m=R.e;if(d=m+se+1,ee=P[d],g=f/2,T=T||d<0||P[d+1]!=null,T=M<4?(ee!=null||T)&&(M==0||M==(R.s<0?3:2)):ee>g||ee==g&&(M==4||T||M==6&&P[d-1]&1||M==(R.s<0?8:7)),d<1||!P[0])c=T?ce(l.charAt(1),-se,l.charAt(0)):l.charAt(0);else{if(P.length=d,T){for(--f;++P[--d]>f;)if(P[d]=0,!d)++m,P=[1].concat(P)}for(g=P.length;!P[--g];);for(ee=0,c="";ee<=g;c+=l.charAt(P[ee++]));c=ce(c,m,l.charAt(0))}return c}}(),D=function(){function o(_,f,p){var E,l,d,m,g=0,T=_.length,R=f%k,P=f/k|0;for(_=_.slice();T--;)d=_[T]%k,m=_[T]/k|0,E=P*d+m*R,l=R*d+E%k*k+g,g=(l/p|0)+(E/k|0)+P*m,_[T]=l%p;if(g)_=[g].concat(_);return _}function a(_,f,p,E){var l,d;if(p!=E)d=p>E?1:-1;else for(l=d=0;l<p;l++)if(_[l]!=f[l]){d=_[l]>f[l]?1:-1;break}return d}function c(_,f,p,E){var l=0;for(;p--;)_[p]-=l,l=_[p]<f[p]?1:0,_[p]=l*E+_[p]-f[p];for(;!_[0]&&_.length>1;_.splice(0,1));}return function(_,f,p,E,l){var d,m,g,T,R,P,L,ee,se,M,J,ae,Nt,_r,yr,Re,dt,me=_.s==f.s?1:-1,ue=_.c,te=f.c;if(!ue||!ue[0]||!te||!te[0])return new v(!_.s||!f.s||(ue?te&&ue[0]==te[0]:!te)?NaN:ue&&ue[0]==0||!te?me*0:me/0);if(ee=new v(me),se=ee.c=[],m=_.e-f.e,me=p+m+1,!l)l=h,m=W(_.e/y)-W(f.e/y),me=me/y|0;for(g=0;te[g]==(ue[g]||0);g++);if(te[g]>(ue[g]||0))m--;if(me<0)se.push(1),T=!0;else{if(_r=ue.length,Re=te.length,g=0,me+=2,R=s(l/(te[0]+1)),R>1)te=o(te,R,l),ue=o(ue,R,l),Re=te.length,_r=ue.length;Nt=Re,M=ue.slice(0,Re),J=M.length;for(;J<Re;M[J++]=0);if(dt=te.slice(),dt=[0].concat(dt),yr=te[0],te[1]>=l/2)yr++;do{if(R=0,d=a(te,M,Re,J),d<0){if(ae=M[0],Re!=J)ae=ae*l+(M[1]||0);if(R=s(ae/yr),R>1){if(R>=l)R=l-1;P=o(te,R,l),L=P.length,J=M.length;while(a(P,M,L,J)==1)R--,c(P,Re<L?dt:te,L,l),L=P.length,d=1}else{if(R==0)d=R=1;P=te.slice(),L=P.length}if(L<J)P=[0].concat(P);if(c(M,P,J,l),J=M.length,d==-1)while(a(te,M,Re,J)<1)R++,c(M,Re<J?dt:te,J,l),J=M.length}else if(d===0)R++,M=[0];if(se[g++]=R,M[0])M[J++]=ue[Nt]||0;else M=[ue[Nt]],J=1}while((Nt++<_r||M[0]!=null)&&me--);if(T=M[0]!=null,!se[0])se.splice(0,1)}if(l==h){for(g=1,me=se[0];me>=10;me/=10,g++);ye(ee,p+(ee.e=g+m*y-1)+1,E,T)}else ee.e=m,ee.r=+T;return ee}}();function pr(o,a,c,_){var f,p,E,l,d;if(c==null)c=Z;else b(c,0,8);if(!o.c)return o.toString();if(f=o.c[0],E=o.e,a==null)d=x(o.c),d=_==1||_==2&&(E<=he||E>=fe)?re(d,E):ce(d,E,"0");else if(o=ye(new v(o),a,c),p=o.e,d=x(o.c),l=d.length,_==1||_==2&&(a<=p||p<=he)){for(;l<a;d+="0",l++);d=re(d,p)}else if(a-=E+(_===2&&p>E),d=ce(d,p,"0"),p+1>l){if(--a>0)for(d+=".";a--;d+="0");}else if(a+=p-l,a>0){if(p+1==l)d+=".";for(;a--;d+="0");}return o.s<0&&f?"-"+d:d}function Qn(o,a){var c,_,f=1,p=new v(o[0]);for(;f<o.length;f++)if(_=new v(o[f]),!_.s||(c=j(p,_))===a||c===0&&p.s===a)p=_;return p}function gr(o,a,c){var _=1,f=a.length;for(;!a[--f];a.pop());for(f=a[0];f>=10;f/=10,_++);if((c=_+c*y-1)>Se)o.c=o.e=null;else if(c<Ke)o.c=[o.e=0];else o.e=c,o.c=a;return o}X=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,a=/^([^.]+)\.$/,c=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(p,E,l,d){var m,g=l?E:E.replace(f,"");if(_.test(g))p.s=isNaN(g)?null:g<0?-1:1;else{if(!l){if(g=g.replace(o,function(T,R,P){return m=(P=P.toLowerCase())=="x"?16:P=="b"?2:8,!d||d==m?R:T}),d)m=d,g=g.replace(a,"$1").replace(c,"0.$1");if(E!=g)return new v(g,m)}if(v.DEBUG)throw Error(i+"Not a"+(d?" base "+d:"")+" number: "+E);p.s=null}p.c=p.e=null}}();function ye(o,a,c,_){var f,p,E,l,d,m,g,T=o.c,R=A;if(T){e:{for(f=1,l=T[0];l>=10;l/=10,f++);if(p=a-f,p<0)p+=y,E=a,d=T[m=0],g=s(d/R[f-E-1]%10);else if(m=n((p+1)/y),m>=T.length)if(_){for(;T.length<=m;T.push(0));d=g=0,f=1,p%=y,E=p-y+1}else break e;else{d=l=T[m];for(f=1;l>=10;l/=10,f++);p%=y,E=p-y+f,g=E<0?0:s(d/R[f-E-1]%10)}if(_=_||a<0||T[m+1]!=null||(E<0?d:d%R[f-E-1]),_=c<4?(g||_)&&(c==0||c==(o.s<0?3:2)):g>5||g==5&&(c==4||_||c==6&&(p>0?E>0?d/R[f-E]:0:T[m-1])%10&1||c==(o.s<0?8:7)),a<1||!T[0]){if(T.length=0,_)a-=o.e+1,T[0]=R[(y-a%y)%y],o.e=-a||0;else T[0]=o.e=0;return o}if(p==0)T.length=m,l=1,m--;else T.length=m+1,l=R[y-p],T[m]=E>0?s(d/R[f-E]%R[E])*l:0;if(_)for(;;)if(m==0){for(p=1,E=T[0];E>=10;E/=10,p++);E=T[0]+=l;for(l=1;E>=10;E/=10,l++);if(p!=l){if(o.e++,T[0]==h)T[0]=1}break}else{if(T[m]+=l,T[m]!=h)break;T[m--]=0,l=1}for(p=T.length;T[--p]===0;T.pop());}if(o.e>Se)o.c=o.e=null;else if(o.e<Ke)o.c=[o.e=0]}return o}function je(o){var a,c=o.e;if(c===null)return o.toString();return a=x(o.c),a=c<=he||c>=fe?re(a,c):ce(a,c,"0"),o.s<0?"-"+a:a}if(C.absoluteValue=C.abs=function(){var o=new v(this);if(o.s<0)o.s=1;return o},C.comparedTo=function(o,a){return j(this,new v(o,a))},C.decimalPlaces=C.dp=function(o,a){var c,_,f,p=this;if(o!=null){if(b(o,0,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o+p.e+1,a)}if(!(c=p.c))return null;if(_=((f=c.length-1)-W(this.e/y))*y,f=c[f])for(;f%10==0;f/=10,_--);if(_<0)_=0;return _},C.dividedBy=C.div=function(o,a){return D(this,new v(o,a),Q,Z)},C.dividedToIntegerBy=C.idiv=function(o,a){return D(this,new v(o,a),0,1)},C.exponentiatedBy=C.pow=function(o,a){var c,_,f,p,E,l,d,m,g,T=this;if(o=new v(o),o.c&&!o.isInteger())throw Error(i+"Exponent not an integer: "+je(o));if(a!=null)a=new v(a);if(l=o.e>14,!T.c||!T.c[0]||T.c[0]==1&&!T.e&&T.c.length==1||!o.c||!o.c[0])return g=new v(Math.pow(+je(T),l?o.s*(2-K(o)):+je(o))),a?g.mod(a):g;if(d=o.s<0,a){if(a.c?!a.c[0]:!a.s)return new v(NaN);if(_=!d&&T.isInteger()&&a.isInteger(),_)T=T.mod(a)}else if(o.e>9&&(T.e>0||T.e<-1||(T.e==0?T.c[0]>1||l&&T.c[1]>=240000000:T.c[0]<80000000000000||l&&T.c[0]<=99999750000000))){if(p=T.s<0&&K(o)?-0:0,T.e>-1)p=1/p;return new v(d?1/p:p)}else if(Le)p=n(Le/y+2);if(l){if(c=new v(0.5),d)o.s=1;m=K(o)}else f=Math.abs(+je(o)),m=f%2;g=new v(ne);for(;;){if(m){if(g=g.times(T),!g.c)break;if(p){if(g.c.length>p)g.c.length=p}else if(_)g=g.mod(a)}if(f){if(f=s(f/2),f===0)break;m=f%2}else if(o=o.times(c),ye(o,o.e+1,1),o.e>14)m=K(o);else{if(f=+je(o),f===0)break;m=f%2}if(T=T.times(T),p){if(T.c&&T.c.length>p)T.c.length=p}else if(_)T=T.mod(a)}if(_)return g;if(d)g=ne.div(g);return a?g.mod(a):p?ye(g,Le,Z,E):g},C.integerValue=function(o){var a=new v(this);if(o==null)o=Z;else b(o,0,8);return ye(a,a.e+1,o)},C.isEqualTo=C.eq=function(o,a){return j(this,new v(o,a))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(o,a){return j(this,new v(o,a))>0},C.isGreaterThanOrEqualTo=C.gte=function(o,a){return(a=j(this,new v(o,a)))===1||a===0},C.isInteger=function(){return!!this.c&&W(this.e/y)>this.c.length-2},C.isLessThan=C.lt=function(o,a){return j(this,new v(o,a))<0},C.isLessThanOrEqualTo=C.lte=function(o,a){return(a=j(this,new v(o,a)))===-1||a===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(o,a){var c,_,f,p,E=this,l=E.s;if(o=new v(o,a),a=o.s,!l||!a)return new v(NaN);if(l!=a)return o.s=-a,E.plus(o);var d=E.e/y,m=o.e/y,g=E.c,T=o.c;if(!d||!m){if(!g||!T)return g?(o.s=-a,o):new v(T?E:NaN);if(!g[0]||!T[0])return T[0]?(o.s=-a,o):new v(g[0]?E:Z==3?-0:0)}if(d=W(d),m=W(m),g=g.slice(),l=d-m){if(p=l<0)l=-l,f=g;else m=d,f=T;f.reverse();for(a=l;a--;f.push(0));f.reverse()}else{_=(p=(l=g.length)<(a=T.length))?l:a;for(l=a=0;a<_;a++)if(g[a]!=T[a]){p=g[a]<T[a];break}}if(p)f=g,g=T,T=f,o.s=-o.s;if(a=(_=T.length)-(c=g.length),a>0)for(;a--;g[c++]=0);a=h-1;for(;_>l;){if(g[--_]<T[_]){for(c=_;c&&!g[--c];g[c]=a);--g[c],g[_]+=h}g[_]-=T[_]}for(;g[0]==0;g.splice(0,1),--m);if(!g[0])return o.s=Z==3?-1:1,o.c=[o.e=0],o;return gr(o,g,m)},C.modulo=C.mod=function(o,a){var c,_,f=this;if(o=new v(o,a),!f.c||!o.s||o.c&&!o.c[0])return new v(NaN);else if(!o.c||f.c&&!f.c[0])return new v(f);if(ft==9)_=o.s,o.s=1,c=D(f,o,0,3),o.s=_,c.s*=_;else c=D(f,o,0,ft);if(o=f.minus(c.times(o)),!o.c[0]&&ft==1)o.s=f.s;return o},C.multipliedBy=C.times=function(o,a){var c,_,f,p,E,l,d,m,g,T,R,P,L,ee,se,M=this,J=M.c,ae=(o=new v(o,a)).c;if(!J||!ae||!J[0]||!ae[0]){if(!M.s||!o.s||J&&!J[0]&&!ae||ae&&!ae[0]&&!J)o.c=o.e=o.s=null;else if(o.s*=M.s,!J||!ae)o.c=o.e=null;else o.c=[0],o.e=0;return o}if(_=W(M.e/y)+W(o.e/y),o.s*=M.s,d=J.length,T=ae.length,d<T)L=J,J=ae,ae=L,f=d,d=T,T=f;for(f=d+T,L=[];f--;L.push(0));ee=h,se=k;for(f=T;--f>=0;){c=0,R=ae[f]%se,P=ae[f]/se|0;for(E=d,p=f+E;p>f;)m=J[--E]%se,g=J[E]/se|0,l=P*m+g*R,m=R*m+l%se*se+L[p]+c,c=(m/ee|0)+(l/se|0)+P*g,L[p--]=m%ee;L[p]=c}if(c)++_;else L.splice(0,1);return gr(o,L,_)},C.negated=function(){var o=new v(this);return o.s=-o.s||null,o},C.plus=function(o,a){var c,_=this,f=_.s;if(o=new v(o,a),a=o.s,!f||!a)return new v(NaN);if(f!=a)return o.s=-a,_.minus(o);var p=_.e/y,E=o.e/y,l=_.c,d=o.c;if(!p||!E){if(!l||!d)return new v(f/0);if(!l[0]||!d[0])return d[0]?o:new v(l[0]?_:f*0)}if(p=W(p),E=W(E),l=l.slice(),f=p-E){if(f>0)E=p,c=d;else f=-f,c=l;c.reverse();for(;f--;c.push(0));c.reverse()}if(f=l.length,a=d.length,f-a<0)c=d,d=l,l=c,a=f;for(f=0;a;)f=(l[--a]=l[a]+d[a]+f)/h|0,l[a]=h===l[a]?0:l[a]%h;if(f)l=[f].concat(l),++E;return gr(o,l,E)},C.precision=C.sd=function(o,a){var c,_,f,p=this;if(o!=null&&o!==!!o){if(b(o,1,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o,a)}if(!(c=p.c))return null;if(f=c.length-1,_=f*y+1,f=c[f]){for(;f%10==0;f/=10,_--);for(f=c[0];f>=10;f/=10,_++);}if(o&&p.e+1>_)_=p.e+1;return _},C.shiftedBy=function(o){return b(o,-S,S),this.times("1e"+o)},C.squareRoot=C.sqrt=function(){var o,a,c,_,f,p=this,{c:E,s:l,e:d}=p,m=Q+4,g=new v("0.5");if(l!==1||!E||!E[0])return new v(!l||l<0&&(!E||E[0])?NaN:E?p:1/0);if(l=Math.sqrt(+je(p)),l==0||l==1/0){if(a=x(E),(a.length+d)%2==0)a+="0";if(l=Math.sqrt(+a),d=W((d+1)/2)-(d<0||d%2),l==1/0)a="5e"+d;else a=l.toExponential(),a=a.slice(0,a.indexOf("e")+1)+d;c=new v(a)}else c=new v(l+"");if(c.c[0]){if(d=c.e,l=d+m,l<3)l=0;for(;;)if(f=c,c=g.times(f.plus(D(p,f,m,1))),x(f.c).slice(0,l)===(a=x(c.c)).slice(0,l)){if(c.e<d)--l;if(a=a.slice(l-3,l+1),a=="9999"||!_&&a=="4999"){if(!_){if(ye(f,f.e+Q+2,0),f.times(f).eq(p)){c=f;break}}m+=4,l+=4,_=1}else{if(!+a||!+a.slice(1)&&a.charAt(0)=="5")ye(c,c.e+Q+2,1),o=!c.times(c).eq(p);break}}}return ye(c,c.e+Q+1,Z,o)},C.toExponential=function(o,a){if(o!=null)b(o,0,N),o++;return pr(this,o,a,1)},C.toFixed=function(o,a){if(o!=null)b(o,0,N),o=o+this.e+1;return pr(this,o,a)},C.toFormat=function(o,a,c){var _,f=this;if(c==null)if(o!=null&&a&&typeof a=="object")c=a,a=null;else if(o&&typeof o=="object")c=o,o=a=null;else c=fr;else if(typeof c!="object")throw Error(i+"Argument not an object: "+c);if(_=f.toFixed(o,a),f.c){var p,E=_.split("."),l=+c.groupSize,d=+c.secondaryGroupSize,m=c.groupSeparator||"",g=E[0],T=E[1],R=f.s<0,P=R?g.slice(1):g,L=P.length;if(d)p=l,l=d,d=p,L-=p;if(l>0&&L>0){p=L%l||l,g=P.substr(0,p);for(;p<L;p+=l)g+=m+P.substr(p,l);if(d>0)g+=m+P.slice(p);if(R)g="-"+g}_=T?g+(c.decimalSeparator||"")+((d=+c.fractionGroupSize)?T.replace(new RegExp("\\d{"+d+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):T):g}return(c.prefix||"")+_+(c.suffix||"")},C.toFraction=function(o){var a,c,_,f,p,E,l,d,m,g,T,R,P=this,L=P.c;if(o!=null){if(l=new v(o),!l.isInteger()&&(l.c||l.s!==1)||l.lt(ne))throw Error(i+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+je(l))}if(!L)return new v(P);a=new v(ne),m=c=new v(ne),_=d=new v(ne),R=x(L),p=a.e=R.length-P.e-1,a.c[0]=A[(E=p%y)<0?y+E:E],o=!o||l.comparedTo(a)>0?p>0?a:m:l,E=Se,Se=1/0,l=new v(R),d.c[0]=0;for(;;){if(g=D(l,a,0,1),f=c.plus(g.times(_)),f.comparedTo(o)==1)break;c=_,_=f,m=d.plus(g.times(f=m)),d=f,a=l.minus(g.times(f=a)),l=f}return f=D(o.minus(c),_,0,1),d=d.plus(f.times(m)),c=c.plus(f.times(_)),d.s=m.s=P.s,p=p*2,T=D(m,_,p,Z).minus(P).abs().comparedTo(D(d,c,p,Z).minus(P).abs())<1?[m,_]:[d,c],Se=E,T},C.toNumber=function(){return+je(this)},C.toPrecision=function(o,a){if(o!=null)b(o,1,N);return pr(this,o,a,2)},C.toString=function(o){var a,c=this,_=c.s,f=c.e;if(f===null)if(_){if(a="Infinity",_<0)a="-"+a}else a="NaN";else{if(o==null)a=f<=he||f>=fe?re(x(c.c),f):ce(x(c.c),f,"0");else if(o===10&&dr)c=ye(new v(c),Q+f+1,Z),a=ce(x(c.c),c.e,"0");else b(o,2,Ve.length,"Base"),a=B(ce(x(c.c),f,"0"),10,o,_,!0);if(_<0&&c.c[0])a="-"+a}return a},C.valueOf=C.toJSON=function(){return je(this)},C._isBigNumber=!0,U!=null)v.set(U);return v}function W(U){var D=U|0;return U>0||U===D?D:D-1}function x(U){var D,B,X=1,C=U.length,ne=U[0]+"";for(;X<C;){D=U[X++]+"",B=y-D.length;for(;B--;D="0"+D);ne+=D}for(C=ne.length;ne.charCodeAt(--C)===48;);return ne.slice(0,C+1||1)}function j(U,D){var B,X,C=U.c,ne=D.c,Q=U.s,Z=D.s,he=U.e,fe=D.e;if(!Q||!Z)return null;if(B=C&&!C[0],X=ne&&!ne[0],B||X)return B?X?0:-Z:Q;if(Q!=Z)return Q;if(B=Q<0,X=he==fe,!C||!ne)return X?0:!C^B?1:-1;if(!X)return he>fe^B?1:-1;Z=(he=C.length)<(fe=ne.length)?he:fe;for(Q=0;Q<Z;Q++)if(C[Q]!=ne[Q])return C[Q]>ne[Q]^B?1:-1;return he==fe?0:he>fe^B?1:-1}function b(U,D,B,X){if(U<D||U>B||U!==s(U))throw Error(i+(X||"Argument")+(typeof U=="number"?U<D||U>B?" out of range: ":" not an integer: ":" not a primitive number: ")+String(U))}function K(U){var D=U.c.length-1;return W(U.e/y)==D&&U.c[D]%2!=0}function re(U,D){return(U.length>1?U.charAt(0)+"."+U.slice(1):U)+(D<0?"e":"e+")+D}function ce(U,D,B){var X,C;if(D<0){for(C=B+".";++D;C+=B);U=C+U}else if(X=U.length,++D>X){for(C=B,D-=X;--D;C+=B);U+=C}else if(D<X)U=U.slice(0,D)+"."+U.slice(D);return U}if(t=F(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd)define(function(){return t});else if(typeof jt<"u"&&jt.exports)jt.exports=t;else{if(!e)e=typeof self<"u"&&self?self:window;e.BigNumber=t}})(bs)});var Ps=w(function(cg,Ns){var xs=Or(),Rs=cg;(function(){function e(S){return S<10?"0"+S:S}var t=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,s,i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':"\\\"","\\":"\\\\"},u;function h(S){return r.lastIndex=0,r.test(S)?'"'+S.replace(r,function(A){var k=i[A];return typeof k==="string"?k:"\\u"+("0000"+A.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+S+'"'}function y(S,A){var k,N,F,W,x=n,j,b=A[S],K=b!=null&&(b instanceof xs||xs.isBigNumber(b));if(b&&typeof b==="object"&&typeof b.toJSON==="function")b=b.toJSON(S);if(typeof u==="function")b=u.call(A,S,b);switch(typeof b){case"string":if(K)return b;else return h(b);case"number":return isFinite(b)?String(b):"null";case"boolean":case"null":case"bigint":return String(b);case"object":if(!b)return"null";if(n+=s,j=[],Object.prototype.toString.apply(b)==="[object Array]"){W=b.length;for(k=0;k<W;k+=1)j[k]=y(k,b)||"null";return F=j.length===0?"[]":n?`[
8
8
  `+n+j.join(`,
9
9
  `+n)+`
10
- `+x+"]":"["+j.join(",")+"]",n=x,F}if(u&&typeof u==="object"){V=u.length;for(k=0;k<V;k+=1)if(typeof u[k]==="string"){if(N=u[k],F=y(N,b),F)j.push(h(N)+(n?": ":":")+F)}}else Object.keys(b).forEach(function(re){var ce=y(re,b);if(ce)j.push(h(re)+(n?": ":":")+ce)});return F=j.length===0?"{}":n?`{
10
+ `+x+"]":"["+j.join(",")+"]",n=x,F}if(u&&typeof u==="object"){W=u.length;for(k=0;k<W;k+=1)if(typeof u[k]==="string"){if(N=u[k],F=y(N,b),F)j.push(h(N)+(n?": ":":")+F)}}else Object.keys(b).forEach(function(re){var ce=y(re,b);if(ce)j.push(h(re)+(n?": ":":")+ce)});return F=j.length===0?"{}":n?`{
11
11
  `+n+j.join(`,
12
12
  `+n)+`
13
13
  `+x+"}":"{"+j.join(",")+"}",n=x,F}}if(typeof Rs.stringify!=="function")Rs.stringify=function(S,A,k){var N;if(n="",s="",typeof k==="number")for(N=0;N<k;N+=1)s+=" ";else if(typeof k==="string")s=k;if(u=A,A&&typeof A!=="function"&&(typeof A!=="object"||typeof A.length!=="number"))throw Error("JSON.stringify");return y("",{"":S})}})()});var js=w(function(ug,Is){var Dt=null,qu=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,Fu=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/,Mu=function(e){var t={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(e!==void 0&&e!==null){if(e.strict===!0)t.strict=!0;if(e.storeAsString===!0)t.storeAsString=!0;if(t.alwaysParseAsBig=e.alwaysParseAsBig===!0?e.alwaysParseAsBig:!1,t.useNativeBigInt=e.useNativeBigInt===!0?e.useNativeBigInt:!1,typeof e.constructorAction<"u")if(e.constructorAction==="error"||e.constructorAction==="ignore"||e.constructorAction==="preserve")t.constructorAction=e.constructorAction;else throw Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${e.constructorAction}`);if(typeof e.protoAction<"u")if(e.protoAction==="error"||e.protoAction==="ignore"||e.protoAction==="preserve")t.protoAction=e.protoAction;else throw Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${e.protoAction}`)}var r,n,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
14
- `,r:"\r",t:"\t"},i,u=function(x){throw{name:"SyntaxError",message:x,at:r,text:i}},h=function(x){if(x&&x!==n)u("Expected '"+x+"' instead of '"+n+"'");return n=i.charAt(r),r+=1,n},y=function(){var x,j="";if(n==="-")j="-",h("-");while(n>="0"&&n<="9")j+=n,h();if(n==="."){j+=".";while(h()&&n>="0"&&n<="9")j+=n}if(n==="e"||n==="E"){if(j+=n,h(),n==="-"||n==="+")j+=n,h();while(n>="0"&&n<="9")j+=n,h()}if(x=+j,!isFinite(x))u("Bad number");else{if(Dt==null)Dt=Or();if(j.length>15)return t.storeAsString?j:t.useNativeBigInt?BigInt(j):new Dt(j);else return!t.alwaysParseAsBig?x:t.useNativeBigInt?BigInt(x):new Dt(x)}},S=function(){var x,j,b="",H;if(n==='"'){var re=r;while(h()){if(n==='"'){if(r-1>re)b+=i.substring(re,r-1);return h(),b}if(n==="\\"){if(r-1>re)b+=i.substring(re,r-1);if(h(),n==="u"){H=0;for(j=0;j<4;j+=1){if(x=parseInt(h(),16),!isFinite(x))break;H=H*16+x}b+=String.fromCharCode(H)}else if(typeof s[n]==="string")b+=s[n];else break;re=r}}}u("Bad string")},A=function(){while(n&&n<=" ")h()},k=function(){switch(n){case"t":return h("t"),h("r"),h("u"),h("e"),!0;case"f":return h("f"),h("a"),h("l"),h("s"),h("e"),!1;case"n":return h("n"),h("u"),h("l"),h("l"),null}u("Unexpected '"+n+"'")},N,F=function(){var x=[];if(n==="["){if(h("["),A(),n==="]")return h("]"),x;while(n){if(x.push(N()),A(),n==="]")return h("]"),x;h(","),A()}}u("Bad array")},V=function(){var x,j=Object.create(null);if(n==="{"){if(h("{"),A(),n==="}")return h("}"),j;while(n){if(x=S(),A(),h(":"),t.strict===!0&&Object.hasOwnProperty.call(j,x))u('Duplicate key "'+x+'"');if(qu.test(x)===!0)if(t.protoAction==="error")u("Object contains forbidden prototype property");else if(t.protoAction==="ignore")N();else j[x]=N();else if(Fu.test(x)===!0)if(t.constructorAction==="error")u("Object contains forbidden constructor property");else if(t.constructorAction==="ignore")N();else j[x]=N();else j[x]=N();if(A(),n==="}")return h("}"),j;h(","),A()}}u("Bad object")};return N=function(){switch(A(),n){case"{":return V();case"[":return F();case'"':return S();case"-":return y();default:return n>="0"&&n<="9"?y():k()}},function(x,j){var b;if(i=x+"",r=0,n=" ",b=N(),A(),n)u("Syntax error");return typeof j==="function"?function H(re,ce){var U,D,B=re[ce];if(B&&typeof B==="object")Object.keys(B).forEach(function(X){if(D=H(B,X),D!==void 0)B[X]=D;else delete B[X]});return j.call(re,ce,B)}({"":b},""):b}};Is.exports=Mu});var qs=w(function(lg,Ut){var Ds=Ps().stringify,Us=js();Ut.exports=function(e){return{parse:Us(e),stringify:Ds}};Ut.exports.parse=Us();Ut.exports.stringify=Ds});var kr=w(function($s){Object.defineProperty($s,"__esModule",{value:!0});$s.GCE_LINUX_BIOS_PATHS=void 0;$s.isGoogleCloudServerless=Ls;$s.isGoogleComputeEngineLinux=Gs;$s.isGoogleComputeEngineMACAddress=Bs;$s.isGoogleComputeEngine=Hs;$s.detectGCPResidency=Gu;var Fs=G("fs"),Ms=G("os");$s.GCE_LINUX_BIOS_PATHS={BIOS_DATE:"/sys/class/dmi/id/bios_date",BIOS_VENDOR:"/sys/class/dmi/id/bios_vendor"};var Lu=/^42:01/;function Ls(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function Gs(){if(Ms.platform()!=="linux")return!1;try{Fs.statSync($s.GCE_LINUX_BIOS_PATHS.BIOS_DATE);let e=Fs.readFileSync($s.GCE_LINUX_BIOS_PATHS.BIOS_VENDOR,"utf8");return/Google/.test(e)}catch{return!1}}function Bs(){let e=Ms.networkInterfaces();for(let t of Object.values(e)){if(!t)continue;for(let{mac:r}of t)if(Lu.test(r))return!0}return!1}function Hs(){return Gs()||Bs()}function Gu(){return Ls()||Hs()}});var Vs=w(function(Ks){Object.defineProperty(Ks,"__esModule",{value:!0});Ks.Colours=void 0;class W{static enabled=!1;static reset="";static bright="";static dim="";static red="";static green="";static yellow="";static blue="";static magenta="";static cyan="";static white="";static grey="";static isEnabled(e){return e&&e.isTTY&&(typeof e.getColorDepth==="function"?e.getColorDepth()>2:!0)}static refresh(){if(W.enabled=W.isEnabled(process?.stderr),!this.enabled)W.reset="",W.bright="",W.dim="",W.red="",W.green="",W.yellow="",W.blue="",W.magenta="",W.cyan="",W.white="",W.grey="";else W.reset="\x1B[0m",W.bright="\x1B[1m",W.dim="\x1B[2m",W.red="\x1B[31m",W.green="\x1B[32m",W.yellow="\x1B[33m",W.blue="\x1B[34m",W.magenta="\x1B[35m",W.cyan="\x1B[36m",W.white="\x1B[37m",W.grey="\x1B[90m"}}Ks.Colours=W;W.refresh()});var Xs=w(function(Ys){Object.defineProperty(Ys,"__esModule",{value:!0});Ys.LogSeverity=void 0;var Ws;(function(e){e.DEFAULT="DEFAULT",e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR"})(Ws||(Ys.LogSeverity=Ws={}))});var si=w(function(Y){var Vu=Y&&Y.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Wu=Y&&Y.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Qs=Y&&Y.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")Vu(r,t,n[s])}return Wu(r,t),r}}();Object.defineProperty(Y,"__esModule",{value:!0});Y.env=Y.DebugLogBackendBase=Y.placeholder=Y.AdhocDebugLogger=void 0;Y.getNodeBackend=br;Y.getDebugBackend=zu;Y.getStructuredBackend=Xu;Y.setBackend=Qu;Y.log=ni;var Yu=G("events"),pt=Qs(G("process")),Zs=Qs(G("util")),de=Vs(),De=Xs();class Ft extends Yu.EventEmitter{namespace;upstream;func;constructor(e,t){super();this.namespace=e,this.upstream=t,this.func=Object.assign(this.invoke.bind(this),{instance:this,on:(r,n)=>this.on(r,n)}),this.func.debug=(...r)=>this.invokeSeverity(De.LogSeverity.DEBUG,...r),this.func.info=(...r)=>this.invokeSeverity(De.LogSeverity.INFO,...r),this.func.warn=(...r)=>this.invokeSeverity(De.LogSeverity.WARNING,...r),this.func.error=(...r)=>this.invokeSeverity(De.LogSeverity.ERROR,...r),this.func.sublog=(r)=>ni(r,this.func)}invoke(e,...t){if(this.upstream)try{this.upstream(e,...t)}catch(r){}try{this.emit("log",e,t)}catch(r){}}invokeSeverity(e,...t){this.invoke({severity:e},...t)}}Y.AdhocDebugLogger=Ft;Y.placeholder=new Ft("",()=>{}).func;class gt{cached=new Map;filters=[];filtersSet=!1;constructor(){let e=pt.env[Y.env.nodeEnables]??"*";if(e==="all")e="*";this.filters=e.split(",")}log(e,t,...r){try{if(!this.filtersSet)this.setFilters(),this.filtersSet=!0;let n=this.cached.get(e);if(!n)n=this.makeLogger(e),this.cached.set(e,n);n(t,...r)}catch(n){console.error(n)}}}Y.DebugLogBackendBase=gt;class ei extends gt{enabledRegexp=/.*/g;isEnabled(e){return this.enabledRegexp.test(e)}makeLogger(e){if(!this.enabledRegexp.test(e))return()=>{};return(t,...r)=>{let n=`${de.Colours.green}${e}${de.Colours.reset}`,s=`${de.Colours.yellow}${pt.pid}${de.Colours.reset}`,i;switch(t.severity){case De.LogSeverity.ERROR:i=`${de.Colours.red}${t.severity}${de.Colours.reset}`;break;case De.LogSeverity.INFO:i=`${de.Colours.magenta}${t.severity}${de.Colours.reset}`;break;case De.LogSeverity.WARNING:i=`${de.Colours.yellow}${t.severity}${de.Colours.reset}`;break;default:i=t.severity??De.LogSeverity.DEFAULT;break}let u=Zs.formatWithOptions({colors:de.Colours.enabled},...r),h=Object.assign({},t);delete h.severity;let y=Object.getOwnPropertyNames(h).length?JSON.stringify(h):"",S=y?`${de.Colours.grey}${y}${de.Colours.reset}`:"";console.error("%s [%s|%s] %s%s",s,n,i,u,y?` ${S}`:"")}}setFilters(){let t=this.filters.join(",").replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^");this.enabledRegexp=new RegExp(`^${t}$`,"i")}}function br(){return new ei}class ti extends gt{debugPkg;constructor(e){super();this.debugPkg=e}makeLogger(e){let t=this.debugPkg(e);return(r,...n)=>{t(n[0],...n.slice(1))}}setFilters(){let e=pt.env.NODE_DEBUG??"";pt.env.NODE_DEBUG=`${e}${e?",":""}${this.filters.join(",")}`}}function zu(e){return new ti(e)}class ri extends gt{upstream;constructor(e){super();this.upstream=e??void 0}makeLogger(e){let t=this.upstream?.makeLogger(e);return(r,...n)=>{let s=r.severity??De.LogSeverity.INFO,i=Object.assign({severity:s,message:Zs.format(...n)},r),u=JSON.stringify(i);if(t)t(r,u);else console.log("%s",u)}}setFilters(){this.upstream?.setFilters()}}function Xu(e){return new ri(e)}Y.env={nodeEnables:"GOOGLE_SDK_NODE_LOGGING"};var xr=new Map,Ce=void 0;function Qu(e){Ce=e,xr.clear()}function ni(e,t){if(!Ce){if(!pt.env[Y.env.nodeEnables])return Y.placeholder}if(!e)return Y.placeholder;if(t)e=`${t.instance.namespace}:${e}`;let r=xr.get(e);if(r)return r.func;if(Ce===null)return Y.placeholder;else if(Ce===void 0)Ce=br();let n=(()=>{let s=void 0;return new Ft(e,(u,...h)=>{if(s!==Ce){if(Ce===null)return;else if(Ce===void 0)Ce=br();s=Ce}Ce?.log(e,u,...h)})})();return xr.set(e,n),n.func}});var ii=w(function(Ye){var Zu=Ye&&Ye.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),el=Ye&&Ye.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Zu(t,e,r)};Object.defineProperty(Ye,"__esModule",{value:!0});el(si(),Ye)});var yt=w(function(I){var ai=I&&I.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),tl=I&&I.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),rl=I&&I.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")ai(r,t,n[s])}return tl(r,t),r}}(),nl=I&&I.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))ai(t,e,r)};Object.defineProperty(I,"__esModule",{value:!0});I.gcpResidencyCache=I.METADATA_SERVER_DETECTION=I.HEADERS=I.HEADER_VALUE=I.HEADER_NAME=I.SECONDARY_HOST_ADDRESS=I.HOST_ADDRESS=I.BASE_PATH=void 0;I.instance=ul;I.project=ll;I.universe=hl;I.bulk=fl;I.isAvailable=pl;I.resetIsAvailableCache=gl;I.getGCPResidency=Pr;I.setGCPResidency=ci;I.requestTimeout=ui;var Rr=ie(),sl=qs(),il=kr(),ol=rl(ii());I.BASE_PATH="/computeMetadata/v1";I.HOST_ADDRESS="http://169.254.169.254";I.SECONDARY_HOST_ADDRESS="http://metadata.google.internal.";I.HEADER_NAME="Metadata-Flavor";I.HEADER_VALUE="Google";I.HEADERS=Object.freeze({[I.HEADER_NAME]:I.HEADER_VALUE});var oi=ol.log("gcp-metadata");I.METADATA_SERVER_DETECTION=Object.freeze({"assume-present":"don't try to ping the metadata server, but assume it's present",none:"don't try to ping the metadata server, but don't try to use it either","bios-only":"treat the result of a BIOS probe as canonical (don't fall back to pinging)","ping-only":"skip the BIOS probe, and go straight to pinging"});function Nr(e){if(!e)e=process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST||I.HOST_ADDRESS;if(!/^https?:\/\//.test(e))e=`http://${e}`;return new URL(I.BASE_PATH,e).href}function al(e){Object.keys(e).forEach((t)=>{switch(t){case"params":case"property":case"headers":break;case"qs":throw Error("'qs' is not a valid configuration option. Please use 'params' instead.");default:throw Error(`'${t}' is not a valid configuration option.`)}})}async function _t(e,t={},r=3,n=!1){let s=new Headers(I.HEADERS),i="",u={};if(typeof e==="object"){let k=e;new Headers(k.headers).forEach((N,F)=>s.set(F,N)),i=k.metadataKey,u=k.params||u,r=k.noResponseRetries||r,n=k.fastFail||n}else i=e;if(typeof t==="string")i+=`/${t}`;else{if(al(t),t.property)i+=`/${t.property}`;new Headers(t.headers).forEach((k,N)=>s.set(N,k)),u=t.params||u}let h=n?cl:Rr.request,y={url:`${Nr()}/${i}`,headers:s,retryConfig:{noResponseRetries:r},params:u,responseType:"text",timeout:ui()};oi.info("instance request %j",y);let S=await h(y);oi.info("instance metadata is %s",S.data);let A=S.headers.get(I.HEADER_NAME);if(A!==I.HEADER_VALUE)throw RangeError(`Invalid response from metadata service: incorrect ${I.HEADER_NAME} header. Expected '${I.HEADER_VALUE}', got ${A?`'${A}'`:"no header"}`);if(typeof S.data==="string")try{return sl.parse(S.data)}catch{}return S.data}async function cl(e){let t={...e,url:e.url?.toString().replace(Nr(),Nr(I.SECONDARY_HOST_ADDRESS))},r=Rr.request(e),n=Rr.request(t);return Promise.any([r,n])}function ul(e){return _t("instance",e)}function ll(e){return _t("project",e)}function hl(e){return _t("universe",e)}async function fl(e){let t={};return await Promise.all(e.map((r)=>(async()=>{let n=await _t(r),s=r.metadataKey;t[s]=n})())),t}function dl(){return process.env.DETECT_GCP_RETRIES?Number(process.env.DETECT_GCP_RETRIES):0}var Mt;async function pl(){if(process.env.METADATA_SERVER_DETECTION){let e=process.env.METADATA_SERVER_DETECTION.trim().toLocaleLowerCase();if(!(e in I.METADATA_SERVER_DETECTION))throw RangeError(`Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${e}\`, but it should be \`${Object.keys(I.METADATA_SERVER_DETECTION).join("`, `")}\`, or unset`);switch(e){case"assume-present":return!0;case"none":return!1;case"bios-only":return Pr();case"ping-only":}}try{if(Mt===void 0)Mt=_t("instance",void 0,dl(),!(process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST));return await Mt,!0}catch(e){let t=e;if(process.env.DEBUG_AUTH)console.info(t);if(t.type==="request-timeout")return!1;if(t.response&&t.response.status===404)return!1;else{if(!(t.response&&t.response.status===404)&&(!t.code||!["EHOSTDOWN","EHOSTUNREACH","ENETUNREACH","ENOENT","ENOTFOUND","ECONNREFUSED"].includes(t.code.toString()))){let r="UNKNOWN";if(t.code)r=t.code.toString();process.emitWarning(`received unexpected error = ${t.message} code = ${r}`,"MetadataLookupWarning")}return!1}}}function gl(){Mt=void 0}I.gcpResidencyCache=null;function Pr(){if(I.gcpResidencyCache===null)ci();return I.gcpResidencyCache}function ci(e=null){I.gcpResidencyCache=e!==null?e:il.detectGCPResidency()}function ui(){return Pr()?0:3000}nl(kr(),I)});var hi=w(function(vl){vl.byteLength=yl;vl.toByteArray=El;vl.fromByteArray=Al;var Ne=[],Te=[],_l=typeof Uint8Array<"u"?Uint8Array:Array,Ir="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ge=0,jr=Ir.length;Ge<jr;++Ge)Ne[Ge]=Ir[Ge],Te[Ir.charCodeAt(Ge)]=Ge;var Ge,jr;Te[45]=62;Te[95]=63;function li(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");if(r===-1)r=t;var n=r===t?0:4-r%4;return[r,n]}function yl(e){var t=li(e),r=t[0],n=t[1];return(r+n)*3/4-n}function ml(e,t,r){return(t+r)*3/4-r}function El(e){var t,r=li(e),n=r[0],s=r[1],i=new _l(ml(e,n,s)),u=0,h=s>0?n-4:n,y;for(y=0;y<h;y+=4)t=Te[e.charCodeAt(y)]<<18|Te[e.charCodeAt(y+1)]<<12|Te[e.charCodeAt(y+2)]<<6|Te[e.charCodeAt(y+3)],i[u++]=t>>16&255,i[u++]=t>>8&255,i[u++]=t&255;if(s===2)t=Te[e.charCodeAt(y)]<<2|Te[e.charCodeAt(y+1)]>>4,i[u++]=t&255;if(s===1)t=Te[e.charCodeAt(y)]<<10|Te[e.charCodeAt(y+1)]<<4|Te[e.charCodeAt(y+2)]>>2,i[u++]=t>>8&255,i[u++]=t&255;return i}function wl(e){return Ne[e>>18&63]+Ne[e>>12&63]+Ne[e>>6&63]+Ne[e&63]}function Tl(e,t,r){var n,s=[];for(var i=t;i<r;i+=3)n=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(e[i+2]&255),s.push(wl(n));return s.join("")}function Al(e){var t,r=e.length,n=r%3,s=[],i=16383;for(var u=0,h=r-n;u<h;u+=i)s.push(Tl(e,u,u+i>h?h:u+i));if(n===1)t=e[r-1],s.push(Ne[t>>2]+Ne[t<<4&63]+"==");else if(n===2)t=(e[r-2]<<8)+e[r-1],s.push(Ne[t>>10]+Ne[t>>4&63]+Ne[t<<2&63]+"=");return s.join("")}});var Dr=w(function(fi){Object.defineProperty(fi,"__esModule",{value:!0});fi.fromArrayBufferToHex=kl;function kl(e){return Array.from(new Uint8Array(e)).map((r)=>r.toString(16).padStart(2,"0")).join("")}});var gi=w(function(di){Object.defineProperty(di,"__esModule",{value:!0});di.BrowserCrypto=void 0;var tt=hi(),xl=Dr();class Lt{constructor(){if(typeof window>"u"||window.crypto===void 0||window.crypto.subtle===void 0)throw Error("SubtleCrypto not found. Make sure it's an https:// website.")}async sha256DigestBase64(e){let t=new TextEncoder().encode(e),r=await window.crypto.subtle.digest("SHA-256",t);return tt.fromByteArray(new Uint8Array(r))}randomBytesBase64(e){let t=new Uint8Array(e);return window.crypto.getRandomValues(t),tt.fromByteArray(t)}static padBase64(e){while(e.length%4!==0)e+="=";return e}async verify(e,t,r){let n={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},s=new TextEncoder().encode(t),i=tt.toByteArray(Lt.padBase64(r)),u=await window.crypto.subtle.importKey("jwk",e,n,!0,["verify"]);return await window.crypto.subtle.verify(n,u,Buffer.from(i),s)}async sign(e,t){let r={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},n=new TextEncoder().encode(t),s=await window.crypto.subtle.importKey("jwk",e,r,!0,["sign"]),i=await window.crypto.subtle.sign(r,s,n);return tt.fromByteArray(new Uint8Array(i))}decodeBase64StringUtf8(e){let t=tt.toByteArray(Lt.padBase64(e));return new TextDecoder().decode(t)}encodeBase64StringUtf8(e){let t=new TextEncoder().encode(e);return tt.fromByteArray(t)}async sha256DigestHex(e){let t=new TextEncoder().encode(e),r=await window.crypto.subtle.digest("SHA-256",t);return xl.fromArrayBufferToHex(r)}async signWithHmacSha256(e,t){let r=typeof e==="string"?e:String.fromCharCode(...new Uint16Array(e)),n=new TextEncoder,s=await window.crypto.subtle.importKey("raw",n.encode(r),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return window.crypto.subtle.sign("HMAC",s,n.encode(t))}}di.BrowserCrypto=Lt});var Ei=w(function(yi){Object.defineProperty(yi,"__esModule",{value:!0});yi.NodeCrypto=void 0;var rt=G("crypto");class _i{async sha256DigestBase64(e){return rt.createHash("sha256").update(e).digest("base64")}randomBytesBase64(e){return rt.randomBytes(e).toString("base64")}async verify(e,t,r){let n=rt.createVerify("RSA-SHA256");return n.update(t),n.end(),n.verify(e,r,"base64")}async sign(e,t){let r=rt.createSign("RSA-SHA256");return r.update(t),r.end(),r.sign(e,"base64")}decodeBase64StringUtf8(e){return Buffer.from(e,"base64").toString("utf-8")}encodeBase64StringUtf8(e){return Buffer.from(e,"utf-8").toString("base64")}async sha256DigestHex(e){return rt.createHash("sha256").update(e).digest("hex")}async signWithHmacSha256(e,t){let r=typeof e==="string"?e:Nl(e);return Rl(rt.createHmac("sha256",r).update(t).digest())}}yi.NodeCrypto=_i;function Rl(e){let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let n=0;n<e.length;++n)r[n]=e[n];return t}function Nl(e){return Buffer.from(e)}});var mt=w(function(Ue){var Pl=Ue&&Ue.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Il=Ue&&Ue.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Pl(t,e,r)};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.createCrypto=Ul;Ue.hasBrowserCrypto=wi;var jl=gi(),Dl=Ei();Il(Dr(),Ue);function Ul(){if(wi())return new jl.BrowserCrypto;return new Dl.NodeCrypto}function wi(){return typeof window<"u"&&typeof window.crypto<"u"&&typeof window.crypto.subtle<"u"}});var nt=w(function(Ur,Ai){/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Gt=G("buffer"),Pe=Gt.Buffer;function Ti(e,t){for(var r in e)t[r]=e[r]}if(Pe.from&&Pe.alloc&&Pe.allocUnsafe&&Pe.allocUnsafeSlow)Ai.exports=Gt;else Ti(Gt,Ur),Ur.Buffer=ze;function ze(e,t,r){return Pe(e,t,r)}ze.prototype=Object.create(Pe.prototype);Ti(Pe,ze);ze.from=function(e,t,r){if(typeof e==="number")throw TypeError("Argument must not be a number");return Pe(e,t,r)};ze.alloc=function(e,t,r){if(typeof e!=="number")throw TypeError("Argument must be a number");var n=Pe(e);if(t!==void 0)if(typeof r==="string")n.fill(t,r);else n.fill(t);else n.fill(0);return n};ze.allocUnsafe=function(e){if(typeof e!=="number")throw TypeError("Argument must be a number");return Pe(e)};ze.allocUnsafeSlow=function(e){if(typeof e!=="number")throw TypeError("Argument must be a number");return Gt.SlowBuffer(e)}});var Si=w(function(Ag,vi){function qr(e){var t=(e/8|0)+(e%8===0?0:1);return t}var ql={ES256:qr(256),ES384:qr(384),ES512:qr(521)};function Fl(e){var t=ql[e];if(t)return t;throw Error('Unknown algorithm "'+e+'"')}vi.exports=Fl});var Fr=w(function(vg,Ri){var Bt=nt().Buffer,Oi=Si(),Ht=128,ki=0,Ml=32,Ll=16,Gl=2,bi=Ll|Ml|ki<<6,$t=Gl|ki<<6;function Bl(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function xi(e){if(Bt.isBuffer(e))return e;else if(typeof e==="string")return Bt.from(e,"base64");throw TypeError("ECDSA signature must be a Base64 string or a Buffer")}function Hl(e,t){e=xi(e);var r=Oi(t),n=r+1,s=e.length,i=0;if(e[i++]!==bi)throw Error('Could not find expected "seq"');var u=e[i++];if(u===(Ht|1))u=e[i++];if(s-i<u)throw Error('"seq" specified length of "'+u+'", only "'+(s-i)+'" remaining');if(e[i++]!==$t)throw Error('Could not find expected "int" for "r"');var h=e[i++];if(s-i-2<h)throw Error('"r" specified length of "'+h+'", only "'+(s-i-2)+'" available');if(n<h)throw Error('"r" specified length of "'+h+'", max of "'+n+'" is acceptable');var y=i;if(i+=h,e[i++]!==$t)throw Error('Could not find expected "int" for "s"');var S=e[i++];if(s-i!==S)throw Error('"s" specified length of "'+S+'", expected "'+(s-i)+'"');if(n<S)throw Error('"s" specified length of "'+S+'", max of "'+n+'" is acceptable');var A=i;if(i+=S,i!==s)throw Error('Expected to consume entire buffer, but "'+(s-i)+'" bytes remain');var k=r-h,N=r-S,F=Bt.allocUnsafe(k+h+N+S);for(i=0;i<k;++i)F[i]=0;e.copy(F,i,y+Math.max(-k,0),y+h),i=r;for(var V=i;i<V+N;++i)F[i]=0;return e.copy(F,i,A+Math.max(-N,0),A+S),F=F.toString("base64"),F=Bl(F),F}function Ci(e,t,r){var n=0;while(t+n<r&&e[t+n]===0)++n;var s=e[t+n]>=Ht;if(s)--n;return n}function $l(e,t){e=xi(e);var r=Oi(t),n=e.length;if(n!==r*2)throw TypeError('"'+t+'" signatures must be "'+r*2+'" bytes, saw "'+n+'"');var s=Ci(e,0,r),i=Ci(e,r,e.length),u=r-s,h=r-i,y=2+u+1+1+h,S=y<Ht,A=Bt.allocUnsafe((S?2:3)+y),k=0;if(A[k++]=bi,S)A[k++]=y;else A[k++]=Ht|1,A[k++]=y&255;if(A[k++]=$t,A[k++]=u,s<0)A[k++]=0,k+=e.copy(A,k,0,r);else k+=e.copy(A,k,s,r);if(A[k++]=$t,A[k++]=h,i<0)A[k++]=0,e.copy(A,k,r);else e.copy(A,k,r+i);return A}Ri.exports={derToJose:Hl,joseToDer:$l}});var Oe=w(function(ji){Object.defineProperty(ji,"__esModule",{value:!0});ji.LRUCache=void 0;ji.snakeToCamel=Pi;ji.originalOrCamelOptions=Wl;ji.removeUndefinedValuesInObject=Yl;ji.isValidFile=zl;ji.getWellKnownCertificateConfigFileLocation=Xl;var Kl=G("fs"),Jl=G("os"),Mr=G("path"),Vl="certificate_config.json",Ni="gcloud";function Pi(e){return e.replace(/([_][^_])/g,(t)=>t.slice(1).toUpperCase())}function Wl(e){function t(r){let n=e||{};return n[r]??n[Pi(r)]}return{get:t}}class Ii{capacity;#e=new Map;maxAge;constructor(e){this.capacity=e.capacity,this.maxAge=e.maxAge}#t(e,t){this.#e.delete(e),this.#e.set(e,{value:t,lastAccessed:Date.now()})}set(e,t){this.#t(e,t),this.#r()}get(e){let t=this.#e.get(e);if(!t)return;return this.#t(e,t.value),this.#r(),t.value}#r(){let e=this.maxAge?Date.now()-this.maxAge:0,t=this.#e.entries().next();while(!t.done&&(this.#e.size>this.capacity||t.value[1].lastAccessed<e))this.#e.delete(t.value[0]),t=this.#e.entries().next()}}ji.LRUCache=Ii;function Yl(e){return Object.entries(e).forEach(([t,r])=>{if(r===void 0||r==="undefined")delete e[t]}),e}async function zl(e){try{return(await Kl.promises.lstat(e)).isFile()}catch(t){return!1}}function Xl(){let e=process.env.CLOUDSDK_CONFIG||(Ql()?Mr.join(process.env.APPDATA||"",Ni):Mr.join(process.env.HOME||"",".config",Ni));return Mr.join(e,Vl)}function Ql(){return Jl.platform().startsWith("win")}});var Fi=w(function(Ui){Object.defineProperty(Ui,"__esModule",{value:!0});Ui.Colours=void 0;class q{static isEnabled(e){return e&&e.isTTY&&(typeof e.getColorDepth==="function"?e.getColorDepth()>2:!0)}static refresh(){if(q.enabled=q.isEnabled(process===null||process===void 0?void 0:process.stderr),!this.enabled)q.reset="",q.bright="",q.dim="",q.red="",q.green="",q.yellow="",q.blue="",q.magenta="",q.cyan="",q.white="",q.grey="";else q.reset="\x1B[0m",q.bright="\x1B[1m",q.dim="\x1B[2m",q.red="\x1B[31m",q.green="\x1B[32m",q.yellow="\x1B[33m",q.blue="\x1B[34m",q.magenta="\x1B[35m",q.cyan="\x1B[36m",q.white="\x1B[37m",q.grey="\x1B[90m"}}Ui.Colours=q;q.enabled=!1;q.reset="";q.bright="";q.dim="";q.red="";q.green="";q.yellow="";q.blue="";q.magenta="";q.cyan="";q.white="";q.grey="";q.refresh()});var Ki=w(function(J){var sh=J&&J.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),ih=J&&J.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Mi=J&&J.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")sh(r,t,n[s])}return ih(r,t),r}}();Object.defineProperty(J,"__esModule",{value:!0});J.env=J.DebugLogBackendBase=J.placeholder=J.AdhocDebugLogger=J.LogSeverity=void 0;J.getNodeBackend=Lr;J.getDebugBackend=ah;J.getStructuredBackend=ch;J.setBackend=uh;J.log=$i;var oh=G("events"),Et=Mi(G("process")),Li=Mi(G("util")),pe=Fi(),ke;(function(e){e.DEFAULT="DEFAULT",e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR"})(ke||(J.LogSeverity=ke={}));class Kt extends oh.EventEmitter{constructor(e,t){super();this.namespace=e,this.upstream=t,this.func=Object.assign(this.invoke.bind(this),{instance:this,on:(r,n)=>this.on(r,n)}),this.func.debug=(...r)=>this.invokeSeverity(ke.DEBUG,...r),this.func.info=(...r)=>this.invokeSeverity(ke.INFO,...r),this.func.warn=(...r)=>this.invokeSeverity(ke.WARNING,...r),this.func.error=(...r)=>this.invokeSeverity(ke.ERROR,...r),this.func.sublog=(r)=>$i(r,this.func)}invoke(e,...t){if(this.upstream)try{this.upstream(e,...t)}catch(r){}try{this.emit("log",e,t)}catch(r){}}invokeSeverity(e,...t){this.invoke({severity:e},...t)}}J.AdhocDebugLogger=Kt;J.placeholder=new Kt("",()=>{}).func;class wt{constructor(){var e;this.cached=new Map,this.filters=[],this.filtersSet=!1;let t=(e=Et.env[J.env.nodeEnables])!==null&&e!==void 0?e:"*";if(t==="all")t="*";this.filters=t.split(",")}log(e,t,...r){try{if(!this.filtersSet)this.setFilters(),this.filtersSet=!0;let n=this.cached.get(e);if(!n)n=this.makeLogger(e),this.cached.set(e,n);n(t,...r)}catch(n){console.error(n)}}}J.DebugLogBackendBase=wt;class Gi extends wt{constructor(){super(...arguments);this.enabledRegexp=/.*/g}isEnabled(e){return this.enabledRegexp.test(e)}makeLogger(e){if(!this.enabledRegexp.test(e))return()=>{};return(t,...r)=>{var n;let s=`${pe.Colours.green}${e}${pe.Colours.reset}`,i=`${pe.Colours.yellow}${Et.pid}${pe.Colours.reset}`,u;switch(t.severity){case ke.ERROR:u=`${pe.Colours.red}${t.severity}${pe.Colours.reset}`;break;case ke.INFO:u=`${pe.Colours.magenta}${t.severity}${pe.Colours.reset}`;break;case ke.WARNING:u=`${pe.Colours.yellow}${t.severity}${pe.Colours.reset}`;break;default:u=(n=t.severity)!==null&&n!==void 0?n:ke.DEFAULT;break}let h=Li.formatWithOptions({colors:pe.Colours.enabled},...r),y=Object.assign({},t);delete y.severity;let S=Object.getOwnPropertyNames(y).length?JSON.stringify(y):"",A=S?`${pe.Colours.grey}${S}${pe.Colours.reset}`:"";console.error("%s [%s|%s] %s%s",i,s,u,h,S?` ${A}`:"")}}setFilters(){let t=this.filters.join(",").replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^");this.enabledRegexp=new RegExp(`^${t}$`,"i")}}function Lr(){return new Gi}class Bi extends wt{constructor(e){super();this.debugPkg=e}makeLogger(e){let t=this.debugPkg(e);return(r,...n)=>{t(n[0],...n.slice(1))}}setFilters(){var e;let t=(e=Et.env.NODE_DEBUG)!==null&&e!==void 0?e:"";Et.env.NODE_DEBUG=`${t}${t?",":""}${this.filters.join(",")}`}}function ah(e){return new Bi(e)}class Hi extends wt{constructor(e){var t;super();this.upstream=(t=e)!==null&&t!==void 0?t:void 0}makeLogger(e){var t;let r=(t=this.upstream)===null||t===void 0?void 0:t.makeLogger(e);return(n,...s)=>{var i;let u=(i=n.severity)!==null&&i!==void 0?i:ke.INFO,h=Object.assign({severity:u,message:Li.format(...s)},n),y=JSON.stringify(h);if(r)r(n,y);else console.log("%s",y)}}setFilters(){var e;(e=this.upstream)===null||e===void 0||e.setFilters()}}function ch(e){return new Hi(e)}J.env={nodeEnables:"GOOGLE_SDK_NODE_LOGGING"};var Gr=new Map,ge=void 0;function uh(e){ge=e,Gr.clear()}function $i(e,t){if(!ge){if(!Et.env[J.env.nodeEnables])return J.placeholder}if(!e)return J.placeholder;if(t)e=`${t.instance.namespace}:${e}`;let r=Gr.get(e);if(r)return r.func;if(ge===null)return J.placeholder;else if(ge===void 0)ge=Lr();let n=(()=>{let s=void 0;return new Kt(e,(u,...h)=>{if(s!==ge){if(ge===null)return;else if(ge===void 0)ge=Lr();s=ge}ge===null||ge===void 0||ge.log(e,u,...h)})})();return Gr.set(e,n),n.func}});var Ji=w(function(Xe){var lh=Xe&&Xe.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),hh=Xe&&Xe.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))lh(t,e,r)};Object.defineProperty(Xe,"__esModule",{value:!0});hh(Ki(),Xe)});var Vi=w(function(bg,fh){fh.exports={name:"google-auth-library",version:"10.9.1",author:"Google Inc.",description:"Google APIs Authentication Client Library for Node.js",engines:{node:">=18"},main:"./build/src/index.js",types:"./build/src/index.d.ts",repository:{type:"git",directory:"core/packages/google-auth-library-nodejs",url:"https://github.com/googleapis/google-cloud-node.git"},keywords:["google","api","google apis","client","client library"],dependencies:{"base64-js":"^1.3.0","ecdsa-sig-formatter":"^1.0.11",gaxios:"^7.1.4","gcp-metadata":"8.1.2","google-logging-utils":"1.1.3",jws:"^4.0.0"},devDependencies:{"@types/base64-js":"^1.2.5","@types/jws":"^3.1.0","@types/mocha":"^10.0.10","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","assert-rejects":"^1.0.0",c8:"^10.1.3",codecov:"^3.8.3",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1",keypair:"^1.0.4",mocha:"^11.1.0",mv:"^2.1.1",ncp:"^2.0.0",nock:"^14.0.5","null-loader":"^4.0.1",puppeteer:"^24.0.0",sinon:"21.0.3","ts-loader":"^9.5.2",typescript:"5.8.3",webpack:"^5.97.1","webpack-cli":"^6.0.1"},files:["build/src","!build/src/**/*.map"],scripts:{test:"c8 mocha build/test",clean:"gts clean",prepare:"npm run compile",lint:"gts check --no-inline-config",compile:"tsc -p .",fix:"gts fix",pretest:"npm run compile -- --sourceMap",docs:"jsdoc -c .jsdoc.js","samples-setup":"cd samples/ && npm link ../ && npm run setup && cd ../","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","system-test":"mocha build/system-test --timeout 60000","presystem-test":"npm run compile -- --sourceMap",webpack:"webpack","browser-test":"karma start",prelint:"cd samples; npm link ../; npm install"},license:"Apache-2.0",homepage:"https://github.com/googleapis/google-cloud-node/tree/main/core/packages/google-auth-library-nodejs"}});var Br=w(function(zi){Object.defineProperty(zi,"__esModule",{value:!0});zi.USER_AGENT=zi.PRODUCT_NAME=zi.pkg=void 0;var Wi=Vi();zi.pkg=Wi;var Yi="google-api-nodejs-client";zi.PRODUCT_NAME=Yi;var dh=`${Yi}/${Wi.version}`;zi.USER_AGENT=dh});var _e=w(function(Qi){Object.defineProperty(Qi,"__esModule",{value:!0});Qi.AuthClient=Qi.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=Qi.DEFAULT_UNIVERSE=void 0;var _h=G("events"),Hr=ie(),yh=Oe(),mh=Ji(),$r=Br();Qi.DEFAULT_UNIVERSE="googleapis.com";Qi.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=300000;class oe extends _h.EventEmitter{apiKey;projectId;quotaProjectId;transporter;credentials={};eagerRefreshThresholdMillis=Qi.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS;forceRefreshOnFailure=!1;universeDomain=Qi.DEFAULT_UNIVERSE;static RequestMethodNameSymbol=Symbol("request method name");static RequestLogIdSymbol=Symbol("request log id");constructor(e={}){super();let t=yh.originalOrCamelOptions(e);if(this.apiKey=e.apiKey,this.projectId=t.get("project_id")??null,this.quotaProjectId=t.get("quota_project_id"),this.credentials=t.get("credentials")??{},this.universeDomain=t.get("universe_domain")??Qi.DEFAULT_UNIVERSE,this.transporter=e.transporter??new Hr.Gaxios(e.transporterOptions),t.get("useAuthRequestParameters")!==!1)this.transporter.interceptors.request.add(oe.DEFAULT_REQUEST_INTERCEPTOR),this.transporter.interceptors.response.add(oe.DEFAULT_RESPONSE_INTERCEPTOR);if(e.eagerRefreshThresholdMillis)this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis;this.forceRefreshOnFailure=e.forceRefreshOnFailure??!1}fetch(...e){let t=e[0],r=e[1],n=void 0,s=new Headers;if(typeof t==="string")n=new URL(t);else if(t instanceof URL)n=t;else if(t&&t.url)n=new URL(t.url);if(t&&typeof t==="object"&&"headers"in t)Hr.Gaxios.mergeHeaders(s,t.headers);if(r)Hr.Gaxios.mergeHeaders(s,new Headers(r.headers));if(typeof t==="object"&&!(t instanceof URL))return this.request({...r,...t,headers:s,url:n});else return this.request({...r,headers:s,url:n})}setCredentials(e){this.credentials=e}addSharedMetadataHeaders(e){if(!e.has("x-goog-user-project")&&this.quotaProjectId)e.set("x-goog-user-project",this.quotaProjectId);return e}addUserProjectAndAuthHeaders(e,t){let r=t.get("x-goog-user-project"),n=t.get("authorization");if(r)e.set("x-goog-user-project",r);if(n)e.set("authorization",n);return e}static log=mh.log("auth");static DEFAULT_REQUEST_INTERCEPTOR={resolved:async(e)=>{if(!e.headers.has("x-goog-api-client")){let r=process.version.replace(/^v/,"");e.headers.set("x-goog-api-client",`gl-node/${r}`)}let t=e.headers.get("User-Agent");if(!t)e.headers.set("User-Agent",$r.USER_AGENT);else if(!t.includes(`${$r.PRODUCT_NAME}/`))e.headers.set("User-Agent",`${t} ${$r.USER_AGENT}`);try{let r=e,n=r[oe.RequestMethodNameSymbol],s=`${Math.floor(Math.random()*1000)}`;r[oe.RequestLogIdSymbol]=s;let i={url:e.url,headers:e.headers};if(n)oe.log.info("%s [%s] request %j",n,s,i);else oe.log.info("[%s] request %j",s,i)}catch(r){}return e}};static DEFAULT_RESPONSE_INTERCEPTOR={resolved:async(e)=>{try{let t=e.config,r=t[oe.RequestMethodNameSymbol],n=t[oe.RequestLogIdSymbol];if(r)oe.log.info("%s [%s] response %j",r,n,e.data);else oe.log.info("[%s] response %j",n,e.data)}catch(t){}return e},rejected:async(e)=>{try{let t=e.config,r=t[oe.RequestMethodNameSymbol],n=t[oe.RequestLogIdSymbol];if(r)oe.log.info("%s [%s] error %j",r,n,e.response?.data);else oe.log.error("[%s] error %j",n,e.response?.data)}catch(t){}throw e}};static setMethodName(e,t){try{let r=e;r[oe.RequestMethodNameSymbol]=t}catch(r){}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}Qi.AuthClient=oe});var Jr=w(function(ro){Object.defineProperty(ro,"__esModule",{value:!0});ro.LoginTicket=void 0;class to{envelope;payload;constructor(e,t){this.envelope=e,this.payload=t}getEnvelope(){return this.envelope}getPayload(){return this.payload}getUserId(){let e=this.getPayload();if(e&&e.sub)return e.sub;return null}getAttributes(){return{envelope:this.getEnvelope(),payload:this.getPayload()}}}ro.LoginTicket=to});var Be=w(function(ao){Object.defineProperty(ao,"__esModule",{value:!0});ao.OAuth2Client=ao.ClientAuthentication=ao.CertificateFormat=ao.CodeChallengeMethod=void 0;var oo=ie(),Eh=G("querystring"),wh=G("stream"),Th=Fr(),so=Oe(),Vr=mt(),st=_e(),Ah=Jr(),io;(function(e){e.Plain="plain",e.S256="S256"})(io||(ao.CodeChallengeMethod=io={}));var qe;(function(e){e.PEM="PEM",e.JWK="JWK"})(qe||(ao.CertificateFormat=qe={}));var Tt;(function(e){e.ClientSecretPost="ClientSecretPost",e.ClientSecretBasic="ClientSecretBasic",e.None="None"})(Tt||(ao.ClientAuthentication=Tt={}));class Ae extends st.AuthClient{redirectUri;certificateCache={};certificateExpiry=null;certificateCacheFormat=qe.PEM;refreshTokenPromises=new Map;endpoints;issuers;clientAuthentication;_clientId;_clientSecret;refreshHandler;constructor(e={},t,r){super(typeof e==="object"?e:{});if(typeof e!=="object")e={clientId:e,clientSecret:t,redirectUri:r};this._clientId=e.clientId||e.client_id,this._clientSecret=e.clientSecret||e.client_secret,this.redirectUri=e.redirectUri||e.redirect_uris?.[0],this.endpoints={tokenInfoUrl:"https://oauth2.googleapis.com/tokeninfo",oauth2AuthBaseUrl:"https://accounts.google.com/o/oauth2/v2/auth",oauth2TokenUrl:"https://oauth2.googleapis.com/token",oauth2RevokeUrl:"https://oauth2.googleapis.com/revoke",oauth2FederatedSignonPemCertsUrl:"https://www.googleapis.com/oauth2/v1/certs",oauth2FederatedSignonJwkCertsUrl:"https://www.googleapis.com/oauth2/v3/certs",oauth2IapPublicKeyUrl:"https://www.gstatic.com/iap/verify/public_key",...e.endpoints},this.clientAuthentication=e.clientAuthentication||Tt.ClientSecretPost,this.issuers=e.issuers||["accounts.google.com","https://accounts.google.com",this.universeDomain]}static GOOGLE_TOKEN_INFO_URL="https://oauth2.googleapis.com/tokeninfo";static CLOCK_SKEW_SECS_=300;static DEFAULT_MAX_TOKEN_LIFETIME_SECS_=86400;generateAuthUrl(e={}){if(e.code_challenge_method&&!e.code_challenge)throw Error("If a code_challenge_method is provided, code_challenge must be included.");if(e.response_type=e.response_type||"code",e.client_id=e.client_id||this._clientId,e.redirect_uri=e.redirect_uri||this.redirectUri,Array.isArray(e.scope))e.scope=e.scope.join(" ");return this.endpoints.oauth2AuthBaseUrl.toString()+"?"+Eh.stringify(e)}generateCodeVerifier(){throw Error("generateCodeVerifier is removed, please use generateCodeVerifierAsync instead.")}async generateCodeVerifierAsync(){let e=Vr.createCrypto(),r=e.randomBytesBase64(96).replace(/\+/g,"~").replace(/=/g,"_").replace(/\//g,"-"),s=(await e.sha256DigestBase64(r)).split("=")[0].replace(/\+/g,"-").replace(/\//g,"_");return{codeVerifier:r,codeChallenge:s}}getToken(e,t){let r=typeof e==="string"?{code:e}:e;if(t)this.getTokenAsync(r).then((n)=>t(null,n.tokens,n.res),(n)=>t(n,null,n.response));else return this.getTokenAsync(r)}async getTokenAsync(e){let t=this.endpoints.oauth2TokenUrl.toString(),r=new Headers,n={client_id:e.client_id||this._clientId,code_verifier:e.codeVerifier,code:e.code,grant_type:"authorization_code",redirect_uri:e.redirect_uri||this.redirectUri};if(this.clientAuthentication===Tt.ClientSecretBasic){let h=Buffer.from(`${this._clientId}:${this._clientSecret}`);r.set("authorization",`Basic ${h.toString("base64")}`)}if(this.clientAuthentication===Tt.ClientSecretPost)n.client_secret=this._clientSecret;let s={...Ae.RETRY_CONFIG,method:"POST",url:t,data:new URLSearchParams(so.removeUndefinedValuesInObject(n)),headers:r};st.AuthClient.setMethodName(s,"getTokenAsync");let i=await this.transporter.request(s),u=i.data;if(i.data&&i.data.expires_in)u.expiry_date=new Date().getTime()+i.data.expires_in*1000,delete u.expires_in;return this.emit("tokens",u),{tokens:u,res:i}}async refreshToken(e){if(!e)return this.refreshTokenNoCache(e);if(this.refreshTokenPromises.has(e))return this.refreshTokenPromises.get(e);let t=this.refreshTokenNoCache(e).then((r)=>(this.refreshTokenPromises.delete(e),r),(r)=>{throw this.refreshTokenPromises.delete(e),r});return this.refreshTokenPromises.set(e,t),t}async refreshTokenNoCache(e){if(!e)throw Error("No refresh token is set.");let t=this.endpoints.oauth2TokenUrl.toString(),r={refresh_token:e,client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token"},n;try{let i={...Ae.RETRY_CONFIG,method:"POST",url:t,data:new URLSearchParams(so.removeUndefinedValuesInObject(r))};st.AuthClient.setMethodName(i,"refreshTokenNoCache"),n=await this.transporter.request(i)}catch(i){if(i instanceof oo.GaxiosError&&i.message==="invalid_grant"&&i.response?.data&&/ReAuth/i.test(i.response.data.error_description))i.message=JSON.stringify(i.response.data);throw i}let s=n.data;if(n.data&&n.data.expires_in)s.expiry_date=new Date().getTime()+n.data.expires_in*1000,delete s.expires_in;return this.emit("tokens",s),{tokens:s,res:n}}refreshAccessToken(e){if(e)this.refreshAccessTokenAsync().then((t)=>e(null,t.credentials,t.res),e);else return this.refreshAccessTokenAsync()}async refreshAccessTokenAsync(){let e=await this.refreshToken(this.credentials.refresh_token),t=e.tokens;return t.refresh_token=this.credentials.refresh_token,this.credentials=t,{credentials:this.credentials,res:e.res}}getAccessToken(e){if(e)this.getAccessTokenAsync().then((t)=>e(null,t.token,t.res),e);else return this.getAccessTokenAsync()}async getAccessTokenAsync(){if(!this.credentials.access_token||this.isTokenExpiring()){if(!this.credentials.refresh_token)if(this.refreshHandler){let r=await this.processAndValidateRefreshHandler();if(r?.access_token)return this.setCredentials(r),{token:this.credentials.access_token}}else throw Error("No refresh token or refresh handler callback is set.");let t=await this.refreshAccessTokenAsync();if(!t.credentials||t.credentials&&!t.credentials.access_token)throw Error("Could not refresh access token.");return{token:t.credentials.access_token,res:t.res}}else return{token:this.credentials.access_token}}async getRequestHeaders(e){return(await this.getRequestMetadataAsync(e)).headers}async getRequestMetadataAsync(e){let t=this.credentials;if(!t.access_token&&!t.refresh_token&&!this.apiKey&&!this.refreshHandler)throw Error("No access, refresh token, API key or refresh handler callback is set.");if(t.access_token&&!this.isTokenExpiring()){t.token_type=t.token_type||"Bearer";let u=new Headers({authorization:t.token_type+" "+t.access_token});return{headers:this.addSharedMetadataHeaders(u)}}if(this.refreshHandler){let u=await this.processAndValidateRefreshHandler();if(u?.access_token){this.setCredentials(u);let h=new Headers({authorization:"Bearer "+this.credentials.access_token});return{headers:this.addSharedMetadataHeaders(h)}}}if(this.apiKey)return{headers:new Headers({"X-Goog-Api-Key":this.apiKey})};let r=null,n=null;try{r=await this.refreshToken(t.refresh_token),n=r.tokens}catch(u){let h=u;if(h.response&&(h.response.status===403||h.response.status===404))h.message=`Could not refresh access token: ${h.message}`;throw h}let s=this.credentials;s.token_type=s.token_type||"Bearer",n.refresh_token=s.refresh_token,this.credentials=n;let i=new Headers({authorization:s.token_type+" "+n.access_token});return{headers:this.addSharedMetadataHeaders(i),res:r.res}}static getRevokeTokenUrl(e){return new Ae().getRevokeTokenURL(e).toString()}getRevokeTokenURL(e){let t=new URL(this.endpoints.oauth2RevokeUrl);return t.searchParams.append("token",e),t}revokeToken(e,t){let r={...Ae.RETRY_CONFIG,url:this.getRevokeTokenURL(e).toString(),method:"POST"};if(st.AuthClient.setMethodName(r,"revokeToken"),t)this.transporter.request(r).then((n)=>t(null,n),t);else return this.transporter.request(r)}revokeCredentials(e){if(e)this.revokeCredentialsAsync().then((t)=>e(null,t),e);else return this.revokeCredentialsAsync()}async revokeCredentialsAsync(){let e=this.credentials.access_token;if(this.credentials={},e)return this.revokeToken(e);else throw Error("No access token to revoke.")}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){try{let r=await this.getRequestMetadataAsync();if(e.headers=oo.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,r.headers),this.apiKey)e.headers.set("X-Goog-Api-Key",this.apiKey);return await this.transporter.request(e)}catch(r){let n=r.response;if(n){let s=n.status,i=this.credentials&&this.credentials.access_token&&this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure),u=this.credentials&&this.credentials.access_token&&!this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure)&&this.refreshHandler,h=n.config.data instanceof wh.Readable,y=s===401||s===403;if(!t&&y&&!h&&i)return await this.refreshAccessTokenAsync(),this.requestAsync(e,!0);else if(!t&&y&&!h&&u){let S=await this.processAndValidateRefreshHandler();if(S?.access_token)this.setCredentials(S);return this.requestAsync(e,!0)}}throw r}}verifyIdToken(e,t){if(t&&typeof t!=="function")throw Error("This method accepts an options object as the first parameter, which includes the idToken, audience, and maxExpiry.");if(t)this.verifyIdTokenAsync(e).then((r)=>t(null,r),t);else return this.verifyIdTokenAsync(e)}async verifyIdTokenAsync(e){if(!e.idToken)throw Error("The verifyIdToken method requires an ID Token");let t=await this.getFederatedSignonCertsAsync();return await this.verifySignedJwtWithCertsAsync(e.idToken,t.certs,e.audience,this.issuers,e.maxExpiry)}async getTokenInfo(e){let{data:t}=await this.transporter.request({...Ae.RETRY_CONFIG,method:"POST",headers:{"content-type":"application/x-www-form-urlencoded;charset=UTF-8",authorization:`Bearer ${e}`},url:this.endpoints.tokenInfoUrl.toString()}),r=Object.assign({expiry_date:new Date().getTime()+t.expires_in*1000,scopes:t.scope.split(" ")},t);return delete r.expires_in,delete r.scope,r}getFederatedSignonCerts(e){if(e)this.getFederatedSignonCertsAsync().then((t)=>e(null,t.certs,t.res),e);else return this.getFederatedSignonCertsAsync()}async getFederatedSignonCertsAsync(){let e=new Date().getTime(),t=Vr.hasBrowserCrypto()?qe.JWK:qe.PEM;if(this.certificateExpiry&&e<this.certificateExpiry.getTime()&&this.certificateCacheFormat===t)return{certs:this.certificateCache,format:t};let r,n;switch(t){case qe.PEM:n=this.endpoints.oauth2FederatedSignonPemCertsUrl.toString();break;case qe.JWK:n=this.endpoints.oauth2FederatedSignonJwkCertsUrl.toString();break;default:throw Error(`Unsupported certificate format ${t}`)}try{let y={...Ae.RETRY_CONFIG,url:n};st.AuthClient.setMethodName(y,"getFederatedSignonCertsAsync"),r=await this.transporter.request(y)}catch(y){if(y instanceof Error)y.message=`Failed to retrieve verification certificates: ${y.message}`;throw y}let s=r?.headers.get("cache-control"),i=-1;if(s){let y=/max-age=(?<maxAge>[0-9]+)/.exec(s)?.groups?.maxAge;if(y)i=Number(y)*1000}let u={};switch(t){case qe.PEM:u=r.data;break;case qe.JWK:for(let y of r.data.keys)u[y.kid]=y;break;default:throw Error(`Unsupported certificate format ${t}`)}let h=new Date;return this.certificateExpiry=i===-1?null:new Date(h.getTime()+i),this.certificateCache=u,this.certificateCacheFormat=t,{certs:u,format:t,res:r}}getIapPublicKeys(e){if(e)this.getIapPublicKeysAsync().then((t)=>e(null,t.pubkeys,t.res),e);else return this.getIapPublicKeysAsync()}async getIapPublicKeysAsync(){let e,t=this.endpoints.oauth2IapPublicKeyUrl.toString();try{let r={...Ae.RETRY_CONFIG,url:t};st.AuthClient.setMethodName(r,"getIapPublicKeysAsync"),e=await this.transporter.request(r)}catch(r){if(r instanceof Error)r.message=`Failed to retrieve verification certificates: ${r.message}`;throw r}return{pubkeys:e.data,res:e}}verifySignedJwtWithCerts(){throw Error("verifySignedJwtWithCerts is removed, please use verifySignedJwtWithCertsAsync instead.")}async verifySignedJwtWithCertsAsync(e,t,r,n,s){let i=Vr.createCrypto();if(!s)s=Ae.DEFAULT_MAX_TOKEN_LIFETIME_SECS_;let u=e.split(".");if(u.length!==3)throw Error("Wrong number of segments in token: "+e);let h=u[0]+"."+u[1],y=u[2],S,A;try{S=JSON.parse(i.decodeBase64StringUtf8(u[0]))}catch(H){if(H instanceof Error)H.message=`Can't parse token envelope: ${u[0]}': ${H.message}`;throw H}if(!S)throw Error("Can't parse token envelope: "+u[0]);try{A=JSON.parse(i.decodeBase64StringUtf8(u[1]))}catch(H){if(H instanceof Error)H.message=`Can't parse token payload '${u[0]}`;throw H}if(!A)throw Error("Can't parse token payload: "+u[1]);if(!Object.prototype.hasOwnProperty.call(t,S.kid))throw Error("No pem found for envelope: "+JSON.stringify(S));let k=t[S.kid];if(S.alg==="ES256")y=Th.joseToDer(y,"ES256").toString("base64");if(!await i.verify(k,h,y))throw Error("Invalid token signature: "+e);if(!A.iat)throw Error("No issue time in token: "+JSON.stringify(A));if(!A.exp)throw Error("No expiration time in token: "+JSON.stringify(A));let F=Number(A.iat);if(isNaN(F))throw Error("iat field using invalid format");let V=Number(A.exp);if(isNaN(V))throw Error("exp field using invalid format");let x=new Date().getTime()/1000;if(V>=x+s)throw Error("Expiration time too far in future: "+JSON.stringify(A));let j=F-Ae.CLOCK_SKEW_SECS_,b=V+Ae.CLOCK_SKEW_SECS_;if(x<j)throw Error("Token used too early, "+x+" < "+j+": "+JSON.stringify(A));if(x>b)throw Error("Token used too late, "+x+" > "+b+": "+JSON.stringify(A));if(n&&n.indexOf(A.iss)<0)throw Error("Invalid issuer, expected one of ["+n+"], but got "+A.iss);if(typeof r<"u"&&r!==null){let H=A.aud,re=!1;if(r.constructor===Array)re=r.indexOf(H)>-1;else re=H===r;if(!re)throw Error("Wrong recipient, payload audience != requiredAudience")}return new Ah.LoginTicket(S,A)}async processAndValidateRefreshHandler(){if(this.refreshHandler){let e=await this.refreshHandler();if(!e.access_token)throw Error("No access token is returned by the refreshHandler callback.");return e}return}isTokenExpiring(){let e=this.credentials.expiry_date;return e?e<=new Date().getTime()+this.eagerRefreshThresholdMillis:!1}}ao.OAuth2Client=Ae});var Wr=w(function(ho){Object.defineProperty(ho,"__esModule",{value:!0});ho.Compute=void 0;var Oh=ie(),uo=yt(),kh=Be();class lo extends kh.OAuth2Client{serviceAccountEmail;scopes;constructor(e={}){super(e);this.credentials={expiry_date:1,refresh_token:"compute-placeholder"},this.serviceAccountEmail=e.serviceAccountEmail||"default",this.scopes=Array.isArray(e.scopes)?e.scopes:e.scopes?[e.scopes]:[]}async refreshTokenNoCache(){let e=`service-accounts/${this.serviceAccountEmail}/token`,t;try{let n={property:e};if(this.scopes.length>0)n.params={scopes:this.scopes.join(",")};t=await uo.instance(n)}catch(n){if(n instanceof Oh.GaxiosError)n.message=`Could not refresh access token: ${n.message}`,this.wrapError(n);throw n}let r=t;if(t&&t.expires_in)r.expiry_date=new Date().getTime()+t.expires_in*1000,delete r.expires_in;return this.emit("tokens",r),{tokens:r,res:null}}async fetchIdToken(e){let t=`service-accounts/${this.serviceAccountEmail}/identity?format=full&audience=${e}`,r;try{r=await uo.instance({property:t})}catch(n){if(n instanceof Error)n.message=`Could not fetch ID token: ${n.message}`;throw n}return r}wrapError(e){let t=e.response;if(t&&t.status){if(e.status=t.status,t.status===403)e.message="A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified: "+e.message;else if(t.status===404)e.message="A Not Found error was returned while attempting to retrieve an accesstoken for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have any permission scopes specified: "+e.message}}}ho.Compute=lo});var Yr=w(function(go){Object.defineProperty(go,"__esModule",{value:!0});go.IdTokenClient=void 0;var bh=Be();class po extends bh.OAuth2Client{targetAudience;idTokenProvider;constructor(e){super(e);this.targetAudience=e.targetAudience,this.idTokenProvider=e.idTokenProvider}async getRequestMetadataAsync(){if(!this.credentials.id_token||!this.credentials.expiry_date||this.isTokenExpiring()){let t=await this.idTokenProvider.fetchIdToken(this.targetAudience);this.credentials={id_token:t,expiry_date:this.getIdTokenExpiryDate(t)}}return{headers:new Headers({authorization:"Bearer "+this.credentials.id_token})}}getIdTokenExpiryDate(e){let t=e.split(".")[1];if(t)return JSON.parse(Buffer.from(t,"base64").toString("ascii")).exp*1000}}go.IdTokenClient=po});var zr=w(function(mo){Object.defineProperty(mo,"__esModule",{value:!0});mo.GCPEnv=void 0;mo.clear=xh;mo.getEnv=Rh;var yo=yt(),Ie;(function(e){e.APP_ENGINE="APP_ENGINE",e.KUBERNETES_ENGINE="KUBERNETES_ENGINE",e.CLOUD_FUNCTIONS="CLOUD_FUNCTIONS",e.COMPUTE_ENGINE="COMPUTE_ENGINE",e.CLOUD_RUN="CLOUD_RUN",e.CLOUD_RUN_JOBS="CLOUD_RUN_JOBS",e.NONE="NONE"})(Ie||(mo.GCPEnv=Ie={}));var At;function xh(){At=void 0}async function Rh(){if(At)return At;return At=Nh(),At}async function Nh(){let e=Ie.NONE;if(Ph())e=Ie.APP_ENGINE;else if(Ih())e=Ie.CLOUD_FUNCTIONS;else if(await qh())if(await Uh())e=Ie.KUBERNETES_ENGINE;else if(jh())e=Ie.CLOUD_RUN;else if(Dh())e=Ie.CLOUD_RUN_JOBS;else e=Ie.COMPUTE_ENGINE;else e=Ie.NONE;return e}function Ph(){return!!(process.env.GAE_SERVICE||process.env.GAE_MODULE_NAME)}function Ih(){return!!(process.env.FUNCTION_NAME||process.env.FUNCTION_TARGET)}function jh(){return!!process.env.K_CONFIGURATION}function Dh(){return!!process.env.CLOUD_RUN_JOB}async function Uh(){try{return await yo.instance("attributes/cluster-name"),!0}catch(e){return!1}}async function qh(){return yo.isAvailable()}});var Xr=w(function(Ug,wo){var Jt=nt().Buffer,Lh=G("stream"),Gh=G("util");function Vt(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=Jt.alloc(0),this;if(typeof e.pipe==="function")return this.buffer=Jt.alloc(0),e.pipe(this),this;if(e.length||typeof e==="object")return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw TypeError("Unexpected data type ("+typeof e+")")}Gh.inherits(Vt,Lh);Vt.prototype.write=function(t){this.buffer=Jt.concat([this.buffer,Jt.from(t)]),this.emit("data",t)};Vt.prototype.end=function(t){if(t)this.write(t);this.emit("end",t),this.emit("close"),this.writable=!1,this.readable=!1};wo.exports=Vt});var Ao=w(function(qg,To){var vt=G("buffer").Buffer,Qr=G("buffer").SlowBuffer;To.exports=Wt;function Wt(e,t){if(!vt.isBuffer(e)||!vt.isBuffer(t))return!1;if(e.length!==t.length)return!1;var r=0;for(var n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}Wt.install=function(){vt.prototype.equal=Qr.prototype.equal=function(t){return Wt(this,t)}};var Bh=vt.prototype.equal,Hh=Qr.prototype.equal;Wt.restore=function(){vt.prototype.equal=Bh,Qr.prototype.equal=Hh}});var rn=w(function(Fg,No){var ot=nt().Buffer,ve=G("crypto"),So=Fr(),vo=G("util"),$h=`"%s" is not a valid algorithm.
14
+ `,r:"\r",t:"\t"},i,u=function(x){throw{name:"SyntaxError",message:x,at:r,text:i}},h=function(x){if(x&&x!==n)u("Expected '"+x+"' instead of '"+n+"'");return n=i.charAt(r),r+=1,n},y=function(){var x,j="";if(n==="-")j="-",h("-");while(n>="0"&&n<="9")j+=n,h();if(n==="."){j+=".";while(h()&&n>="0"&&n<="9")j+=n}if(n==="e"||n==="E"){if(j+=n,h(),n==="-"||n==="+")j+=n,h();while(n>="0"&&n<="9")j+=n,h()}if(x=+j,!isFinite(x))u("Bad number");else{if(Dt==null)Dt=Or();if(j.length>15)return t.storeAsString?j:t.useNativeBigInt?BigInt(j):new Dt(j);else return!t.alwaysParseAsBig?x:t.useNativeBigInt?BigInt(x):new Dt(x)}},S=function(){var x,j,b="",K;if(n==='"'){var re=r;while(h()){if(n==='"'){if(r-1>re)b+=i.substring(re,r-1);return h(),b}if(n==="\\"){if(r-1>re)b+=i.substring(re,r-1);if(h(),n==="u"){K=0;for(j=0;j<4;j+=1){if(x=parseInt(h(),16),!isFinite(x))break;K=K*16+x}b+=String.fromCharCode(K)}else if(typeof s[n]==="string")b+=s[n];else break;re=r}}}u("Bad string")},A=function(){while(n&&n<=" ")h()},k=function(){switch(n){case"t":return h("t"),h("r"),h("u"),h("e"),!0;case"f":return h("f"),h("a"),h("l"),h("s"),h("e"),!1;case"n":return h("n"),h("u"),h("l"),h("l"),null}u("Unexpected '"+n+"'")},N,F=function(){var x=[];if(n==="["){if(h("["),A(),n==="]")return h("]"),x;while(n){if(x.push(N()),A(),n==="]")return h("]"),x;h(","),A()}}u("Bad array")},W=function(){var x,j=Object.create(null);if(n==="{"){if(h("{"),A(),n==="}")return h("}"),j;while(n){if(x=S(),A(),h(":"),t.strict===!0&&Object.hasOwnProperty.call(j,x))u('Duplicate key "'+x+'"');if(qu.test(x)===!0)if(t.protoAction==="error")u("Object contains forbidden prototype property");else if(t.protoAction==="ignore")N();else j[x]=N();else if(Fu.test(x)===!0)if(t.constructorAction==="error")u("Object contains forbidden constructor property");else if(t.constructorAction==="ignore")N();else j[x]=N();else j[x]=N();if(A(),n==="}")return h("}"),j;h(","),A()}}u("Bad object")};return N=function(){switch(A(),n){case"{":return W();case"[":return F();case'"':return S();case"-":return y();default:return n>="0"&&n<="9"?y():k()}},function(x,j){var b;if(i=x+"",r=0,n=" ",b=N(),A(),n)u("Syntax error");return typeof j==="function"?function K(re,ce){var U,D,B=re[ce];if(B&&typeof B==="object")Object.keys(B).forEach(function(X){if(D=K(B,X),D!==void 0)B[X]=D;else delete B[X]});return j.call(re,ce,B)}({"":b},""):b}};Is.exports=Mu});var qs=w(function(lg,Ut){var Ds=Ps().stringify,Us=js();Ut.exports=function(e){return{parse:Us(e),stringify:Ds}};Ut.exports.parse=Us();Ut.exports.stringify=Ds});var kr=w(function($s){Object.defineProperty($s,"__esModule",{value:!0});$s.GCE_LINUX_BIOS_PATHS=void 0;$s.isGoogleCloudServerless=Ls;$s.isGoogleComputeEngineLinux=Gs;$s.isGoogleComputeEngineMACAddress=Bs;$s.isGoogleComputeEngine=Hs;$s.detectGCPResidency=Gu;var Fs=G("fs"),Ms=G("os");$s.GCE_LINUX_BIOS_PATHS={BIOS_DATE:"/sys/class/dmi/id/bios_date",BIOS_VENDOR:"/sys/class/dmi/id/bios_vendor"};var Lu=/^42:01/;function Ls(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function Gs(){if(Ms.platform()!=="linux")return!1;try{Fs.statSync($s.GCE_LINUX_BIOS_PATHS.BIOS_DATE);let e=Fs.readFileSync($s.GCE_LINUX_BIOS_PATHS.BIOS_VENDOR,"utf8");return/Google/.test(e)}catch{return!1}}function Bs(){let e=Ms.networkInterfaces();for(let t of Object.values(e)){if(!t)continue;for(let{mac:r}of t)if(Lu.test(r))return!0}return!1}function Hs(){return Gs()||Bs()}function Gu(){return Ls()||Hs()}});var Vs=w(function(Ks){Object.defineProperty(Ks,"__esModule",{value:!0});Ks.Colours=void 0;class Y{static enabled=!1;static reset="";static bright="";static dim="";static red="";static green="";static yellow="";static blue="";static magenta="";static cyan="";static white="";static grey="";static isEnabled(e){return e&&e.isTTY&&(typeof e.getColorDepth==="function"?e.getColorDepth()>2:!0)}static refresh(){if(Y.enabled=Y.isEnabled(process?.stderr),!this.enabled)Y.reset="",Y.bright="",Y.dim="",Y.red="",Y.green="",Y.yellow="",Y.blue="",Y.magenta="",Y.cyan="",Y.white="",Y.grey="";else Y.reset="\x1B[0m",Y.bright="\x1B[1m",Y.dim="\x1B[2m",Y.red="\x1B[31m",Y.green="\x1B[32m",Y.yellow="\x1B[33m",Y.blue="\x1B[34m",Y.magenta="\x1B[35m",Y.cyan="\x1B[36m",Y.white="\x1B[37m",Y.grey="\x1B[90m"}}Ks.Colours=Y;Y.refresh()});var Xs=w(function(Ys){Object.defineProperty(Ys,"__esModule",{value:!0});Ys.LogSeverity=void 0;var Ws;(function(e){e.DEFAULT="DEFAULT",e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR"})(Ws||(Ys.LogSeverity=Ws={}))});var si=w(function(z){var Vu=z&&z.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Wu=z&&z.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Qs=z&&z.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")Vu(r,t,n[s])}return Wu(r,t),r}}();Object.defineProperty(z,"__esModule",{value:!0});z.env=z.DebugLogBackendBase=z.placeholder=z.AdhocDebugLogger=void 0;z.getNodeBackend=br;z.getDebugBackend=zu;z.getStructuredBackend=Xu;z.setBackend=Qu;z.log=ni;var Yu=G("events"),pt=Qs(G("process")),Zs=Qs(G("util")),de=Vs(),De=Xs();class Ft extends Yu.EventEmitter{namespace;upstream;func;constructor(e,t){super();this.namespace=e,this.upstream=t,this.func=Object.assign(this.invoke.bind(this),{instance:this,on:(r,n)=>this.on(r,n)}),this.func.debug=(...r)=>this.invokeSeverity(De.LogSeverity.DEBUG,...r),this.func.info=(...r)=>this.invokeSeverity(De.LogSeverity.INFO,...r),this.func.warn=(...r)=>this.invokeSeverity(De.LogSeverity.WARNING,...r),this.func.error=(...r)=>this.invokeSeverity(De.LogSeverity.ERROR,...r),this.func.sublog=(r)=>ni(r,this.func)}invoke(e,...t){if(this.upstream)try{this.upstream(e,...t)}catch(r){}try{this.emit("log",e,t)}catch(r){}}invokeSeverity(e,...t){this.invoke({severity:e},...t)}}z.AdhocDebugLogger=Ft;z.placeholder=new Ft("",()=>{}).func;class gt{cached=new Map;filters=[];filtersSet=!1;constructor(){let e=pt.env[z.env.nodeEnables]??"*";if(e==="all")e="*";this.filters=e.split(",")}log(e,t,...r){try{if(!this.filtersSet)this.setFilters(),this.filtersSet=!0;let n=this.cached.get(e);if(!n)n=this.makeLogger(e),this.cached.set(e,n);n(t,...r)}catch(n){console.error(n)}}}z.DebugLogBackendBase=gt;class ei extends gt{enabledRegexp=/.*/g;isEnabled(e){return this.enabledRegexp.test(e)}makeLogger(e){if(!this.enabledRegexp.test(e))return()=>{};return(t,...r)=>{let n=`${de.Colours.green}${e}${de.Colours.reset}`,s=`${de.Colours.yellow}${pt.pid}${de.Colours.reset}`,i;switch(t.severity){case De.LogSeverity.ERROR:i=`${de.Colours.red}${t.severity}${de.Colours.reset}`;break;case De.LogSeverity.INFO:i=`${de.Colours.magenta}${t.severity}${de.Colours.reset}`;break;case De.LogSeverity.WARNING:i=`${de.Colours.yellow}${t.severity}${de.Colours.reset}`;break;default:i=t.severity??De.LogSeverity.DEFAULT;break}let u=Zs.formatWithOptions({colors:de.Colours.enabled},...r),h=Object.assign({},t);delete h.severity;let y=Object.getOwnPropertyNames(h).length?JSON.stringify(h):"",S=y?`${de.Colours.grey}${y}${de.Colours.reset}`:"";console.error("%s [%s|%s] %s%s",s,n,i,u,y?` ${S}`:"")}}setFilters(){let t=this.filters.join(",").replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^");this.enabledRegexp=new RegExp(`^${t}$`,"i")}}function br(){return new ei}class ti extends gt{debugPkg;constructor(e){super();this.debugPkg=e}makeLogger(e){let t=this.debugPkg(e);return(r,...n)=>{t(n[0],...n.slice(1))}}setFilters(){let e=pt.env.NODE_DEBUG??"";pt.env.NODE_DEBUG=`${e}${e?",":""}${this.filters.join(",")}`}}function zu(e){return new ti(e)}class ri extends gt{upstream;constructor(e){super();this.upstream=e??void 0}makeLogger(e){let t=this.upstream?.makeLogger(e);return(r,...n)=>{let s=r.severity??De.LogSeverity.INFO,i=Object.assign({severity:s,message:Zs.format(...n)},r),u=JSON.stringify(i);if(t)t(r,u);else console.log("%s",u)}}setFilters(){this.upstream?.setFilters()}}function Xu(e){return new ri(e)}z.env={nodeEnables:"GOOGLE_SDK_NODE_LOGGING"};var xr=new Map,Ce=void 0;function Qu(e){Ce=e,xr.clear()}function ni(e,t){if(!Ce){if(!pt.env[z.env.nodeEnables])return z.placeholder}if(!e)return z.placeholder;if(t)e=`${t.instance.namespace}:${e}`;let r=xr.get(e);if(r)return r.func;if(Ce===null)return z.placeholder;else if(Ce===void 0)Ce=br();let n=(()=>{let s=void 0;return new Ft(e,(u,...h)=>{if(s!==Ce){if(Ce===null)return;else if(Ce===void 0)Ce=br();s=Ce}Ce?.log(e,u,...h)})})();return xr.set(e,n),n.func}});var ii=w(function(Ye){var Zu=Ye&&Ye.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),el=Ye&&Ye.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Zu(t,e,r)};Object.defineProperty(Ye,"__esModule",{value:!0});el(si(),Ye)});var yt=w(function(I){var ai=I&&I.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),tl=I&&I.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),rl=I&&I.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")ai(r,t,n[s])}return tl(r,t),r}}(),nl=I&&I.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))ai(t,e,r)};Object.defineProperty(I,"__esModule",{value:!0});I.gcpResidencyCache=I.METADATA_SERVER_DETECTION=I.HEADERS=I.HEADER_VALUE=I.HEADER_NAME=I.SECONDARY_HOST_ADDRESS=I.HOST_ADDRESS=I.BASE_PATH=void 0;I.instance=ul;I.project=ll;I.universe=hl;I.bulk=fl;I.isAvailable=pl;I.resetIsAvailableCache=gl;I.getGCPResidency=Pr;I.setGCPResidency=ci;I.requestTimeout=ui;var Rr=ie(),sl=qs(),il=kr(),ol=rl(ii());I.BASE_PATH="/computeMetadata/v1";I.HOST_ADDRESS="http://169.254.169.254";I.SECONDARY_HOST_ADDRESS="http://metadata.google.internal.";I.HEADER_NAME="Metadata-Flavor";I.HEADER_VALUE="Google";I.HEADERS=Object.freeze({[I.HEADER_NAME]:I.HEADER_VALUE});var oi=ol.log("gcp-metadata");I.METADATA_SERVER_DETECTION=Object.freeze({"assume-present":"don't try to ping the metadata server, but assume it's present",none:"don't try to ping the metadata server, but don't try to use it either","bios-only":"treat the result of a BIOS probe as canonical (don't fall back to pinging)","ping-only":"skip the BIOS probe, and go straight to pinging"});function Nr(e){if(!e)e=process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST||I.HOST_ADDRESS;if(!/^https?:\/\//.test(e))e=`http://${e}`;return new URL(I.BASE_PATH,e).href}function al(e){Object.keys(e).forEach((t)=>{switch(t){case"params":case"property":case"headers":break;case"qs":throw Error("'qs' is not a valid configuration option. Please use 'params' instead.");default:throw Error(`'${t}' is not a valid configuration option.`)}})}async function _t(e,t={},r=3,n=!1){let s=new Headers(I.HEADERS),i="",u={};if(typeof e==="object"){let k=e;new Headers(k.headers).forEach((N,F)=>s.set(F,N)),i=k.metadataKey,u=k.params||u,r=k.noResponseRetries||r,n=k.fastFail||n}else i=e;if(typeof t==="string")i+=`/${t}`;else{if(al(t),t.property)i+=`/${t.property}`;new Headers(t.headers).forEach((k,N)=>s.set(N,k)),u=t.params||u}let h=n?cl:Rr.request,y={url:`${Nr()}/${i}`,headers:s,retryConfig:{noResponseRetries:r},params:u,responseType:"text",timeout:ui()};oi.info("instance request %j",y);let S=await h(y);oi.info("instance metadata is %s",S.data);let A=S.headers.get(I.HEADER_NAME);if(A!==I.HEADER_VALUE)throw RangeError(`Invalid response from metadata service: incorrect ${I.HEADER_NAME} header. Expected '${I.HEADER_VALUE}', got ${A?`'${A}'`:"no header"}`);if(typeof S.data==="string")try{return sl.parse(S.data)}catch{}return S.data}async function cl(e){let t={...e,url:e.url?.toString().replace(Nr(),Nr(I.SECONDARY_HOST_ADDRESS))},r=Rr.request(e),n=Rr.request(t);return Promise.any([r,n])}function ul(e){return _t("instance",e)}function ll(e){return _t("project",e)}function hl(e){return _t("universe",e)}async function fl(e){let t={};return await Promise.all(e.map((r)=>(async()=>{let n=await _t(r),s=r.metadataKey;t[s]=n})())),t}function dl(){return process.env.DETECT_GCP_RETRIES?Number(process.env.DETECT_GCP_RETRIES):0}var Mt;async function pl(){if(process.env.METADATA_SERVER_DETECTION){let e=process.env.METADATA_SERVER_DETECTION.trim().toLocaleLowerCase();if(!(e in I.METADATA_SERVER_DETECTION))throw RangeError(`Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${e}\`, but it should be \`${Object.keys(I.METADATA_SERVER_DETECTION).join("`, `")}\`, or unset`);switch(e){case"assume-present":return!0;case"none":return!1;case"bios-only":return Pr();case"ping-only":}}try{if(Mt===void 0)Mt=_t("instance",void 0,dl(),!(process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST));return await Mt,!0}catch(e){let t=e;if(process.env.DEBUG_AUTH)console.info(t);if(t.type==="request-timeout")return!1;if(t.response&&t.response.status===404)return!1;else{if(!(t.response&&t.response.status===404)&&(!t.code||!["EHOSTDOWN","EHOSTUNREACH","ENETUNREACH","ENOENT","ENOTFOUND","ECONNREFUSED"].includes(t.code.toString()))){let r="UNKNOWN";if(t.code)r=t.code.toString();process.emitWarning(`received unexpected error = ${t.message} code = ${r}`,"MetadataLookupWarning")}return!1}}}function gl(){Mt=void 0}I.gcpResidencyCache=null;function Pr(){if(I.gcpResidencyCache===null)ci();return I.gcpResidencyCache}function ci(e=null){I.gcpResidencyCache=e!==null?e:il.detectGCPResidency()}function ui(){return Pr()?0:3000}nl(kr(),I)});var hi=w(function(vl){vl.byteLength=yl;vl.toByteArray=El;vl.fromByteArray=Al;var Ne=[],Te=[],_l=typeof Uint8Array<"u"?Uint8Array:Array,Ir="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ge=0,jr=Ir.length;Ge<jr;++Ge)Ne[Ge]=Ir[Ge],Te[Ir.charCodeAt(Ge)]=Ge;var Ge,jr;Te[45]=62;Te[95]=63;function li(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");if(r===-1)r=t;var n=r===t?0:4-r%4;return[r,n]}function yl(e){var t=li(e),r=t[0],n=t[1];return(r+n)*3/4-n}function ml(e,t,r){return(t+r)*3/4-r}function El(e){var t,r=li(e),n=r[0],s=r[1],i=new _l(ml(e,n,s)),u=0,h=s>0?n-4:n,y;for(y=0;y<h;y+=4)t=Te[e.charCodeAt(y)]<<18|Te[e.charCodeAt(y+1)]<<12|Te[e.charCodeAt(y+2)]<<6|Te[e.charCodeAt(y+3)],i[u++]=t>>16&255,i[u++]=t>>8&255,i[u++]=t&255;if(s===2)t=Te[e.charCodeAt(y)]<<2|Te[e.charCodeAt(y+1)]>>4,i[u++]=t&255;if(s===1)t=Te[e.charCodeAt(y)]<<10|Te[e.charCodeAt(y+1)]<<4|Te[e.charCodeAt(y+2)]>>2,i[u++]=t>>8&255,i[u++]=t&255;return i}function wl(e){return Ne[e>>18&63]+Ne[e>>12&63]+Ne[e>>6&63]+Ne[e&63]}function Tl(e,t,r){var n,s=[];for(var i=t;i<r;i+=3)n=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(e[i+2]&255),s.push(wl(n));return s.join("")}function Al(e){var t,r=e.length,n=r%3,s=[],i=16383;for(var u=0,h=r-n;u<h;u+=i)s.push(Tl(e,u,u+i>h?h:u+i));if(n===1)t=e[r-1],s.push(Ne[t>>2]+Ne[t<<4&63]+"==");else if(n===2)t=(e[r-2]<<8)+e[r-1],s.push(Ne[t>>10]+Ne[t>>4&63]+Ne[t<<2&63]+"=");return s.join("")}});var Dr=w(function(fi){Object.defineProperty(fi,"__esModule",{value:!0});fi.fromArrayBufferToHex=kl;function kl(e){return Array.from(new Uint8Array(e)).map((r)=>r.toString(16).padStart(2,"0")).join("")}});var gi=w(function(di){Object.defineProperty(di,"__esModule",{value:!0});di.BrowserCrypto=void 0;var tt=hi(),xl=Dr();class Lt{constructor(){if(typeof window>"u"||window.crypto===void 0||window.crypto.subtle===void 0)throw Error("SubtleCrypto not found. Make sure it's an https:// website.")}async sha256DigestBase64(e){let t=new TextEncoder().encode(e),r=await window.crypto.subtle.digest("SHA-256",t);return tt.fromByteArray(new Uint8Array(r))}randomBytesBase64(e){let t=new Uint8Array(e);return window.crypto.getRandomValues(t),tt.fromByteArray(t)}static padBase64(e){while(e.length%4!==0)e+="=";return e}async verify(e,t,r){let n={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},s=new TextEncoder().encode(t),i=tt.toByteArray(Lt.padBase64(r)),u=await window.crypto.subtle.importKey("jwk",e,n,!0,["verify"]);return await window.crypto.subtle.verify(n,u,Buffer.from(i),s)}async sign(e,t){let r={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},n=new TextEncoder().encode(t),s=await window.crypto.subtle.importKey("jwk",e,r,!0,["sign"]),i=await window.crypto.subtle.sign(r,s,n);return tt.fromByteArray(new Uint8Array(i))}decodeBase64StringUtf8(e){let t=tt.toByteArray(Lt.padBase64(e));return new TextDecoder().decode(t)}encodeBase64StringUtf8(e){let t=new TextEncoder().encode(e);return tt.fromByteArray(t)}async sha256DigestHex(e){let t=new TextEncoder().encode(e),r=await window.crypto.subtle.digest("SHA-256",t);return xl.fromArrayBufferToHex(r)}async signWithHmacSha256(e,t){let r=typeof e==="string"?e:String.fromCharCode(...new Uint16Array(e)),n=new TextEncoder,s=await window.crypto.subtle.importKey("raw",n.encode(r),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return window.crypto.subtle.sign("HMAC",s,n.encode(t))}}di.BrowserCrypto=Lt});var Ei=w(function(yi){Object.defineProperty(yi,"__esModule",{value:!0});yi.NodeCrypto=void 0;var rt=G("crypto");class _i{async sha256DigestBase64(e){return rt.createHash("sha256").update(e).digest("base64")}randomBytesBase64(e){return rt.randomBytes(e).toString("base64")}async verify(e,t,r){let n=rt.createVerify("RSA-SHA256");return n.update(t),n.end(),n.verify(e,r,"base64")}async sign(e,t){let r=rt.createSign("RSA-SHA256");return r.update(t),r.end(),r.sign(e,"base64")}decodeBase64StringUtf8(e){return Buffer.from(e,"base64").toString("utf-8")}encodeBase64StringUtf8(e){return Buffer.from(e,"utf-8").toString("base64")}async sha256DigestHex(e){return rt.createHash("sha256").update(e).digest("hex")}async signWithHmacSha256(e,t){let r=typeof e==="string"?e:Nl(e);return Rl(rt.createHmac("sha256",r).update(t).digest())}}yi.NodeCrypto=_i;function Rl(e){let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let n=0;n<e.length;++n)r[n]=e[n];return t}function Nl(e){return Buffer.from(e)}});var mt=w(function(Ue){var Pl=Ue&&Ue.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Il=Ue&&Ue.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Pl(t,e,r)};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.createCrypto=Ul;Ue.hasBrowserCrypto=wi;var jl=gi(),Dl=Ei();Il(Dr(),Ue);function Ul(){if(wi())return new jl.BrowserCrypto;return new Dl.NodeCrypto}function wi(){return typeof window<"u"&&typeof window.crypto<"u"&&typeof window.crypto.subtle<"u"}});var nt=w(function(Ur,Ai){/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Gt=G("buffer"),Pe=Gt.Buffer;function Ti(e,t){for(var r in e)t[r]=e[r]}if(Pe.from&&Pe.alloc&&Pe.allocUnsafe&&Pe.allocUnsafeSlow)Ai.exports=Gt;else Ti(Gt,Ur),Ur.Buffer=ze;function ze(e,t,r){return Pe(e,t,r)}ze.prototype=Object.create(Pe.prototype);Ti(Pe,ze);ze.from=function(e,t,r){if(typeof e==="number")throw TypeError("Argument must not be a number");return Pe(e,t,r)};ze.alloc=function(e,t,r){if(typeof e!=="number")throw TypeError("Argument must be a number");var n=Pe(e);if(t!==void 0)if(typeof r==="string")n.fill(t,r);else n.fill(t);else n.fill(0);return n};ze.allocUnsafe=function(e){if(typeof e!=="number")throw TypeError("Argument must be a number");return Pe(e)};ze.allocUnsafeSlow=function(e){if(typeof e!=="number")throw TypeError("Argument must be a number");return Gt.SlowBuffer(e)}});var Si=w(function(Ag,vi){function qr(e){var t=(e/8|0)+(e%8===0?0:1);return t}var ql={ES256:qr(256),ES384:qr(384),ES512:qr(521)};function Fl(e){var t=ql[e];if(t)return t;throw Error('Unknown algorithm "'+e+'"')}vi.exports=Fl});var Fr=w(function(vg,Ri){var Bt=nt().Buffer,Oi=Si(),Ht=128,ki=0,Ml=32,Ll=16,Gl=2,bi=Ll|Ml|ki<<6,$t=Gl|ki<<6;function Bl(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function xi(e){if(Bt.isBuffer(e))return e;else if(typeof e==="string")return Bt.from(e,"base64");throw TypeError("ECDSA signature must be a Base64 string or a Buffer")}function Hl(e,t){e=xi(e);var r=Oi(t),n=r+1,s=e.length,i=0;if(e[i++]!==bi)throw Error('Could not find expected "seq"');var u=e[i++];if(u===(Ht|1))u=e[i++];if(s-i<u)throw Error('"seq" specified length of "'+u+'", only "'+(s-i)+'" remaining');if(e[i++]!==$t)throw Error('Could not find expected "int" for "r"');var h=e[i++];if(s-i-2<h)throw Error('"r" specified length of "'+h+'", only "'+(s-i-2)+'" available');if(n<h)throw Error('"r" specified length of "'+h+'", max of "'+n+'" is acceptable');var y=i;if(i+=h,e[i++]!==$t)throw Error('Could not find expected "int" for "s"');var S=e[i++];if(s-i!==S)throw Error('"s" specified length of "'+S+'", expected "'+(s-i)+'"');if(n<S)throw Error('"s" specified length of "'+S+'", max of "'+n+'" is acceptable');var A=i;if(i+=S,i!==s)throw Error('Expected to consume entire buffer, but "'+(s-i)+'" bytes remain');var k=r-h,N=r-S,F=Bt.allocUnsafe(k+h+N+S);for(i=0;i<k;++i)F[i]=0;e.copy(F,i,y+Math.max(-k,0),y+h),i=r;for(var W=i;i<W+N;++i)F[i]=0;return e.copy(F,i,A+Math.max(-N,0),A+S),F=F.toString("base64"),F=Bl(F),F}function Ci(e,t,r){var n=0;while(t+n<r&&e[t+n]===0)++n;var s=e[t+n]>=Ht;if(s)--n;return n}function $l(e,t){e=xi(e);var r=Oi(t),n=e.length;if(n!==r*2)throw TypeError('"'+t+'" signatures must be "'+r*2+'" bytes, saw "'+n+'"');var s=Ci(e,0,r),i=Ci(e,r,e.length),u=r-s,h=r-i,y=2+u+1+1+h,S=y<Ht,A=Bt.allocUnsafe((S?2:3)+y),k=0;if(A[k++]=bi,S)A[k++]=y;else A[k++]=Ht|1,A[k++]=y&255;if(A[k++]=$t,A[k++]=u,s<0)A[k++]=0,k+=e.copy(A,k,0,r);else k+=e.copy(A,k,s,r);if(A[k++]=$t,A[k++]=h,i<0)A[k++]=0,e.copy(A,k,r);else e.copy(A,k,r+i);return A}Ri.exports={derToJose:Hl,joseToDer:$l}});var Oe=w(function(ji){Object.defineProperty(ji,"__esModule",{value:!0});ji.LRUCache=void 0;ji.snakeToCamel=Pi;ji.originalOrCamelOptions=Wl;ji.removeUndefinedValuesInObject=Yl;ji.isValidFile=zl;ji.getWellKnownCertificateConfigFileLocation=Xl;var Kl=G("fs"),Jl=G("os"),Mr=G("path"),Vl="certificate_config.json",Ni="gcloud";function Pi(e){return e.replace(/([_][^_])/g,(t)=>t.slice(1).toUpperCase())}function Wl(e){function t(r){let n=e||{};return n[r]??n[Pi(r)]}return{get:t}}class Ii{capacity;#e=new Map;maxAge;constructor(e){this.capacity=e.capacity,this.maxAge=e.maxAge}#t(e,t){this.#e.delete(e),this.#e.set(e,{value:t,lastAccessed:Date.now()})}set(e,t){this.#t(e,t),this.#r()}get(e){let t=this.#e.get(e);if(!t)return;return this.#t(e,t.value),this.#r(),t.value}#r(){let e=this.maxAge?Date.now()-this.maxAge:0,t=this.#e.entries().next();while(!t.done&&(this.#e.size>this.capacity||t.value[1].lastAccessed<e))this.#e.delete(t.value[0]),t=this.#e.entries().next()}}ji.LRUCache=Ii;function Yl(e){return Object.entries(e).forEach(([t,r])=>{if(r===void 0||r==="undefined")delete e[t]}),e}async function zl(e){try{return(await Kl.promises.lstat(e)).isFile()}catch(t){return!1}}function Xl(){let e=process.env.CLOUDSDK_CONFIG||(Ql()?Mr.join(process.env.APPDATA||"",Ni):Mr.join(process.env.HOME||"",".config",Ni));return Mr.join(e,Vl)}function Ql(){return Jl.platform().startsWith("win")}});var Fi=w(function(Ui){Object.defineProperty(Ui,"__esModule",{value:!0});Ui.Colours=void 0;class q{static isEnabled(e){return e&&e.isTTY&&(typeof e.getColorDepth==="function"?e.getColorDepth()>2:!0)}static refresh(){if(q.enabled=q.isEnabled(process===null||process===void 0?void 0:process.stderr),!this.enabled)q.reset="",q.bright="",q.dim="",q.red="",q.green="",q.yellow="",q.blue="",q.magenta="",q.cyan="",q.white="",q.grey="";else q.reset="\x1B[0m",q.bright="\x1B[1m",q.dim="\x1B[2m",q.red="\x1B[31m",q.green="\x1B[32m",q.yellow="\x1B[33m",q.blue="\x1B[34m",q.magenta="\x1B[35m",q.cyan="\x1B[36m",q.white="\x1B[37m",q.grey="\x1B[90m"}}Ui.Colours=q;q.enabled=!1;q.reset="";q.bright="";q.dim="";q.red="";q.green="";q.yellow="";q.blue="";q.magenta="";q.cyan="";q.white="";q.grey="";q.refresh()});var Ki=w(function(V){var sh=V&&V.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),ih=V&&V.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Mi=V&&V.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")sh(r,t,n[s])}return ih(r,t),r}}();Object.defineProperty(V,"__esModule",{value:!0});V.env=V.DebugLogBackendBase=V.placeholder=V.AdhocDebugLogger=V.LogSeverity=void 0;V.getNodeBackend=Lr;V.getDebugBackend=ah;V.getStructuredBackend=ch;V.setBackend=uh;V.log=$i;var oh=G("events"),Et=Mi(G("process")),Li=Mi(G("util")),pe=Fi(),ke;(function(e){e.DEFAULT="DEFAULT",e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR"})(ke||(V.LogSeverity=ke={}));class Kt extends oh.EventEmitter{constructor(e,t){super();this.namespace=e,this.upstream=t,this.func=Object.assign(this.invoke.bind(this),{instance:this,on:(r,n)=>this.on(r,n)}),this.func.debug=(...r)=>this.invokeSeverity(ke.DEBUG,...r),this.func.info=(...r)=>this.invokeSeverity(ke.INFO,...r),this.func.warn=(...r)=>this.invokeSeverity(ke.WARNING,...r),this.func.error=(...r)=>this.invokeSeverity(ke.ERROR,...r),this.func.sublog=(r)=>$i(r,this.func)}invoke(e,...t){if(this.upstream)try{this.upstream(e,...t)}catch(r){}try{this.emit("log",e,t)}catch(r){}}invokeSeverity(e,...t){this.invoke({severity:e},...t)}}V.AdhocDebugLogger=Kt;V.placeholder=new Kt("",()=>{}).func;class wt{constructor(){var e;this.cached=new Map,this.filters=[],this.filtersSet=!1;let t=(e=Et.env[V.env.nodeEnables])!==null&&e!==void 0?e:"*";if(t==="all")t="*";this.filters=t.split(",")}log(e,t,...r){try{if(!this.filtersSet)this.setFilters(),this.filtersSet=!0;let n=this.cached.get(e);if(!n)n=this.makeLogger(e),this.cached.set(e,n);n(t,...r)}catch(n){console.error(n)}}}V.DebugLogBackendBase=wt;class Gi extends wt{constructor(){super(...arguments);this.enabledRegexp=/.*/g}isEnabled(e){return this.enabledRegexp.test(e)}makeLogger(e){if(!this.enabledRegexp.test(e))return()=>{};return(t,...r)=>{var n;let s=`${pe.Colours.green}${e}${pe.Colours.reset}`,i=`${pe.Colours.yellow}${Et.pid}${pe.Colours.reset}`,u;switch(t.severity){case ke.ERROR:u=`${pe.Colours.red}${t.severity}${pe.Colours.reset}`;break;case ke.INFO:u=`${pe.Colours.magenta}${t.severity}${pe.Colours.reset}`;break;case ke.WARNING:u=`${pe.Colours.yellow}${t.severity}${pe.Colours.reset}`;break;default:u=(n=t.severity)!==null&&n!==void 0?n:ke.DEFAULT;break}let h=Li.formatWithOptions({colors:pe.Colours.enabled},...r),y=Object.assign({},t);delete y.severity;let S=Object.getOwnPropertyNames(y).length?JSON.stringify(y):"",A=S?`${pe.Colours.grey}${S}${pe.Colours.reset}`:"";console.error("%s [%s|%s] %s%s",i,s,u,h,S?` ${A}`:"")}}setFilters(){let t=this.filters.join(",").replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^");this.enabledRegexp=new RegExp(`^${t}$`,"i")}}function Lr(){return new Gi}class Bi extends wt{constructor(e){super();this.debugPkg=e}makeLogger(e){let t=this.debugPkg(e);return(r,...n)=>{t(n[0],...n.slice(1))}}setFilters(){var e;let t=(e=Et.env.NODE_DEBUG)!==null&&e!==void 0?e:"";Et.env.NODE_DEBUG=`${t}${t?",":""}${this.filters.join(",")}`}}function ah(e){return new Bi(e)}class Hi extends wt{constructor(e){var t;super();this.upstream=(t=e)!==null&&t!==void 0?t:void 0}makeLogger(e){var t;let r=(t=this.upstream)===null||t===void 0?void 0:t.makeLogger(e);return(n,...s)=>{var i;let u=(i=n.severity)!==null&&i!==void 0?i:ke.INFO,h=Object.assign({severity:u,message:Li.format(...s)},n),y=JSON.stringify(h);if(r)r(n,y);else console.log("%s",y)}}setFilters(){var e;(e=this.upstream)===null||e===void 0||e.setFilters()}}function ch(e){return new Hi(e)}V.env={nodeEnables:"GOOGLE_SDK_NODE_LOGGING"};var Gr=new Map,ge=void 0;function uh(e){ge=e,Gr.clear()}function $i(e,t){if(!ge){if(!Et.env[V.env.nodeEnables])return V.placeholder}if(!e)return V.placeholder;if(t)e=`${t.instance.namespace}:${e}`;let r=Gr.get(e);if(r)return r.func;if(ge===null)return V.placeholder;else if(ge===void 0)ge=Lr();let n=(()=>{let s=void 0;return new Kt(e,(u,...h)=>{if(s!==ge){if(ge===null)return;else if(ge===void 0)ge=Lr();s=ge}ge===null||ge===void 0||ge.log(e,u,...h)})})();return Gr.set(e,n),n.func}});var Ji=w(function(Xe){var lh=Xe&&Xe.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),hh=Xe&&Xe.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))lh(t,e,r)};Object.defineProperty(Xe,"__esModule",{value:!0});hh(Ki(),Xe)});var Vi=w(function(bg,fh){fh.exports={name:"google-auth-library",version:"10.9.1",author:"Google Inc.",description:"Google APIs Authentication Client Library for Node.js",engines:{node:">=18"},main:"./build/src/index.js",types:"./build/src/index.d.ts",repository:{type:"git",directory:"core/packages/google-auth-library-nodejs",url:"https://github.com/googleapis/google-cloud-node.git"},keywords:["google","api","google apis","client","client library"],dependencies:{"base64-js":"^1.3.0","ecdsa-sig-formatter":"^1.0.11",gaxios:"^7.1.4","gcp-metadata":"8.1.2","google-logging-utils":"1.1.3",jws:"^4.0.0"},devDependencies:{"@types/base64-js":"^1.2.5","@types/jws":"^3.1.0","@types/mocha":"^10.0.10","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","assert-rejects":"^1.0.0",c8:"^10.1.3",codecov:"^3.8.3",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1",keypair:"^1.0.4",mocha:"^11.1.0",mv:"^2.1.1",ncp:"^2.0.0",nock:"^14.0.5","null-loader":"^4.0.1",puppeteer:"^24.0.0",sinon:"21.0.3","ts-loader":"^9.5.2",typescript:"5.8.3",webpack:"^5.97.1","webpack-cli":"^6.0.1"},files:["build/src","!build/src/**/*.map"],scripts:{test:"c8 mocha build/test",clean:"gts clean",prepare:"npm run compile",lint:"gts check --no-inline-config",compile:"tsc -p .",fix:"gts fix",pretest:"npm run compile -- --sourceMap",docs:"jsdoc -c .jsdoc.js","samples-setup":"cd samples/ && npm link ../ && npm run setup && cd ../","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","system-test":"mocha build/system-test --timeout 60000","presystem-test":"npm run compile -- --sourceMap",webpack:"webpack","browser-test":"karma start",prelint:"cd samples; npm link ../; npm install"},license:"Apache-2.0",homepage:"https://github.com/googleapis/google-cloud-node/tree/main/core/packages/google-auth-library-nodejs"}});var Br=w(function(zi){Object.defineProperty(zi,"__esModule",{value:!0});zi.USER_AGENT=zi.PRODUCT_NAME=zi.pkg=void 0;var Wi=Vi();zi.pkg=Wi;var Yi="google-api-nodejs-client";zi.PRODUCT_NAME=Yi;var dh=`${Yi}/${Wi.version}`;zi.USER_AGENT=dh});var _e=w(function(Qi){Object.defineProperty(Qi,"__esModule",{value:!0});Qi.AuthClient=Qi.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=Qi.DEFAULT_UNIVERSE=void 0;var _h=G("events"),Hr=ie(),yh=Oe(),mh=Ji(),$r=Br();Qi.DEFAULT_UNIVERSE="googleapis.com";Qi.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=300000;class oe extends _h.EventEmitter{apiKey;projectId;quotaProjectId;transporter;credentials={};eagerRefreshThresholdMillis=Qi.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS;forceRefreshOnFailure=!1;universeDomain=Qi.DEFAULT_UNIVERSE;static RequestMethodNameSymbol=Symbol("request method name");static RequestLogIdSymbol=Symbol("request log id");constructor(e={}){super();let t=yh.originalOrCamelOptions(e);if(this.apiKey=e.apiKey,this.projectId=t.get("project_id")??null,this.quotaProjectId=t.get("quota_project_id"),this.credentials=t.get("credentials")??{},this.universeDomain=t.get("universe_domain")??Qi.DEFAULT_UNIVERSE,this.transporter=e.transporter??new Hr.Gaxios(e.transporterOptions),t.get("useAuthRequestParameters")!==!1)this.transporter.interceptors.request.add(oe.DEFAULT_REQUEST_INTERCEPTOR),this.transporter.interceptors.response.add(oe.DEFAULT_RESPONSE_INTERCEPTOR);if(e.eagerRefreshThresholdMillis)this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis;this.forceRefreshOnFailure=e.forceRefreshOnFailure??!1}fetch(...e){let t=e[0],r=e[1],n=void 0,s=new Headers;if(typeof t==="string")n=new URL(t);else if(t instanceof URL)n=t;else if(t&&t.url)n=new URL(t.url);if(t&&typeof t==="object"&&"headers"in t)Hr.Gaxios.mergeHeaders(s,t.headers);if(r)Hr.Gaxios.mergeHeaders(s,new Headers(r.headers));if(typeof t==="object"&&!(t instanceof URL))return this.request({...r,...t,headers:s,url:n});else return this.request({...r,headers:s,url:n})}setCredentials(e){this.credentials=e}addSharedMetadataHeaders(e){if(!e.has("x-goog-user-project")&&this.quotaProjectId)e.set("x-goog-user-project",this.quotaProjectId);return e}addUserProjectAndAuthHeaders(e,t){let r=t.get("x-goog-user-project"),n=t.get("authorization");if(r)e.set("x-goog-user-project",r);if(n)e.set("authorization",n);return e}static log=mh.log("auth");static DEFAULT_REQUEST_INTERCEPTOR={resolved:async(e)=>{if(!e.headers.has("x-goog-api-client")){let r=process.version.replace(/^v/,"");e.headers.set("x-goog-api-client",`gl-node/${r}`)}let t=e.headers.get("User-Agent");if(!t)e.headers.set("User-Agent",$r.USER_AGENT);else if(!t.includes(`${$r.PRODUCT_NAME}/`))e.headers.set("User-Agent",`${t} ${$r.USER_AGENT}`);try{let r=e,n=r[oe.RequestMethodNameSymbol],s=`${Math.floor(Math.random()*1000)}`;r[oe.RequestLogIdSymbol]=s;let i={url:e.url,headers:e.headers};if(n)oe.log.info("%s [%s] request %j",n,s,i);else oe.log.info("[%s] request %j",s,i)}catch(r){}return e}};static DEFAULT_RESPONSE_INTERCEPTOR={resolved:async(e)=>{try{let t=e.config,r=t[oe.RequestMethodNameSymbol],n=t[oe.RequestLogIdSymbol];if(r)oe.log.info("%s [%s] response %j",r,n,e.data);else oe.log.info("[%s] response %j",n,e.data)}catch(t){}return e},rejected:async(e)=>{try{let t=e.config,r=t[oe.RequestMethodNameSymbol],n=t[oe.RequestLogIdSymbol];if(r)oe.log.info("%s [%s] error %j",r,n,e.response?.data);else oe.log.error("[%s] error %j",n,e.response?.data)}catch(t){}throw e}};static setMethodName(e,t){try{let r=e;r[oe.RequestMethodNameSymbol]=t}catch(r){}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}Qi.AuthClient=oe});var Jr=w(function(ro){Object.defineProperty(ro,"__esModule",{value:!0});ro.LoginTicket=void 0;class to{envelope;payload;constructor(e,t){this.envelope=e,this.payload=t}getEnvelope(){return this.envelope}getPayload(){return this.payload}getUserId(){let e=this.getPayload();if(e&&e.sub)return e.sub;return null}getAttributes(){return{envelope:this.getEnvelope(),payload:this.getPayload()}}}ro.LoginTicket=to});var Be=w(function(ao){Object.defineProperty(ao,"__esModule",{value:!0});ao.OAuth2Client=ao.ClientAuthentication=ao.CertificateFormat=ao.CodeChallengeMethod=void 0;var oo=ie(),Eh=G("querystring"),wh=G("stream"),Th=Fr(),so=Oe(),Vr=mt(),st=_e(),Ah=Jr(),io;(function(e){e.Plain="plain",e.S256="S256"})(io||(ao.CodeChallengeMethod=io={}));var qe;(function(e){e.PEM="PEM",e.JWK="JWK"})(qe||(ao.CertificateFormat=qe={}));var Tt;(function(e){e.ClientSecretPost="ClientSecretPost",e.ClientSecretBasic="ClientSecretBasic",e.None="None"})(Tt||(ao.ClientAuthentication=Tt={}));class Ae extends st.AuthClient{redirectUri;certificateCache={};certificateExpiry=null;certificateCacheFormat=qe.PEM;refreshTokenPromises=new Map;endpoints;issuers;clientAuthentication;_clientId;_clientSecret;refreshHandler;constructor(e={},t,r){super(typeof e==="object"?e:{});if(typeof e!=="object")e={clientId:e,clientSecret:t,redirectUri:r};this._clientId=e.clientId||e.client_id,this._clientSecret=e.clientSecret||e.client_secret,this.redirectUri=e.redirectUri||e.redirect_uris?.[0],this.endpoints={tokenInfoUrl:"https://oauth2.googleapis.com/tokeninfo",oauth2AuthBaseUrl:"https://accounts.google.com/o/oauth2/v2/auth",oauth2TokenUrl:"https://oauth2.googleapis.com/token",oauth2RevokeUrl:"https://oauth2.googleapis.com/revoke",oauth2FederatedSignonPemCertsUrl:"https://www.googleapis.com/oauth2/v1/certs",oauth2FederatedSignonJwkCertsUrl:"https://www.googleapis.com/oauth2/v3/certs",oauth2IapPublicKeyUrl:"https://www.gstatic.com/iap/verify/public_key",...e.endpoints},this.clientAuthentication=e.clientAuthentication||Tt.ClientSecretPost,this.issuers=e.issuers||["accounts.google.com","https://accounts.google.com",this.universeDomain]}static GOOGLE_TOKEN_INFO_URL="https://oauth2.googleapis.com/tokeninfo";static CLOCK_SKEW_SECS_=300;static DEFAULT_MAX_TOKEN_LIFETIME_SECS_=86400;generateAuthUrl(e={}){if(e.code_challenge_method&&!e.code_challenge)throw Error("If a code_challenge_method is provided, code_challenge must be included.");if(e.response_type=e.response_type||"code",e.client_id=e.client_id||this._clientId,e.redirect_uri=e.redirect_uri||this.redirectUri,Array.isArray(e.scope))e.scope=e.scope.join(" ");return this.endpoints.oauth2AuthBaseUrl.toString()+"?"+Eh.stringify(e)}generateCodeVerifier(){throw Error("generateCodeVerifier is removed, please use generateCodeVerifierAsync instead.")}async generateCodeVerifierAsync(){let e=Vr.createCrypto(),r=e.randomBytesBase64(96).replace(/\+/g,"~").replace(/=/g,"_").replace(/\//g,"-"),s=(await e.sha256DigestBase64(r)).split("=")[0].replace(/\+/g,"-").replace(/\//g,"_");return{codeVerifier:r,codeChallenge:s}}getToken(e,t){let r=typeof e==="string"?{code:e}:e;if(t)this.getTokenAsync(r).then((n)=>t(null,n.tokens,n.res),(n)=>t(n,null,n.response));else return this.getTokenAsync(r)}async getTokenAsync(e){let t=this.endpoints.oauth2TokenUrl.toString(),r=new Headers,n={client_id:e.client_id||this._clientId,code_verifier:e.codeVerifier,code:e.code,grant_type:"authorization_code",redirect_uri:e.redirect_uri||this.redirectUri};if(this.clientAuthentication===Tt.ClientSecretBasic){let h=Buffer.from(`${this._clientId}:${this._clientSecret}`);r.set("authorization",`Basic ${h.toString("base64")}`)}if(this.clientAuthentication===Tt.ClientSecretPost)n.client_secret=this._clientSecret;let s={...Ae.RETRY_CONFIG,method:"POST",url:t,data:new URLSearchParams(so.removeUndefinedValuesInObject(n)),headers:r};st.AuthClient.setMethodName(s,"getTokenAsync");let i=await this.transporter.request(s),u=i.data;if(i.data&&i.data.expires_in)u.expiry_date=new Date().getTime()+i.data.expires_in*1000,delete u.expires_in;return this.emit("tokens",u),{tokens:u,res:i}}async refreshToken(e){if(!e)return this.refreshTokenNoCache(e);if(this.refreshTokenPromises.has(e))return this.refreshTokenPromises.get(e);let t=this.refreshTokenNoCache(e).then((r)=>(this.refreshTokenPromises.delete(e),r),(r)=>{throw this.refreshTokenPromises.delete(e),r});return this.refreshTokenPromises.set(e,t),t}async refreshTokenNoCache(e){if(!e)throw Error("No refresh token is set.");let t=this.endpoints.oauth2TokenUrl.toString(),r={refresh_token:e,client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token"},n;try{let i={...Ae.RETRY_CONFIG,method:"POST",url:t,data:new URLSearchParams(so.removeUndefinedValuesInObject(r))};st.AuthClient.setMethodName(i,"refreshTokenNoCache"),n=await this.transporter.request(i)}catch(i){if(i instanceof oo.GaxiosError&&i.message==="invalid_grant"&&i.response?.data&&/ReAuth/i.test(i.response.data.error_description))i.message=JSON.stringify(i.response.data);throw i}let s=n.data;if(n.data&&n.data.expires_in)s.expiry_date=new Date().getTime()+n.data.expires_in*1000,delete s.expires_in;return this.emit("tokens",s),{tokens:s,res:n}}refreshAccessToken(e){if(e)this.refreshAccessTokenAsync().then((t)=>e(null,t.credentials,t.res),e);else return this.refreshAccessTokenAsync()}async refreshAccessTokenAsync(){let e=await this.refreshToken(this.credentials.refresh_token),t=e.tokens;return t.refresh_token=this.credentials.refresh_token,this.credentials=t,{credentials:this.credentials,res:e.res}}getAccessToken(e){if(e)this.getAccessTokenAsync().then((t)=>e(null,t.token,t.res),e);else return this.getAccessTokenAsync()}async getAccessTokenAsync(){if(!this.credentials.access_token||this.isTokenExpiring()){if(!this.credentials.refresh_token)if(this.refreshHandler){let r=await this.processAndValidateRefreshHandler();if(r?.access_token)return this.setCredentials(r),{token:this.credentials.access_token}}else throw Error("No refresh token or refresh handler callback is set.");let t=await this.refreshAccessTokenAsync();if(!t.credentials||t.credentials&&!t.credentials.access_token)throw Error("Could not refresh access token.");return{token:t.credentials.access_token,res:t.res}}else return{token:this.credentials.access_token}}async getRequestHeaders(e){return(await this.getRequestMetadataAsync(e)).headers}async getRequestMetadataAsync(e){let t=this.credentials;if(!t.access_token&&!t.refresh_token&&!this.apiKey&&!this.refreshHandler)throw Error("No access, refresh token, API key or refresh handler callback is set.");if(t.access_token&&!this.isTokenExpiring()){t.token_type=t.token_type||"Bearer";let u=new Headers({authorization:t.token_type+" "+t.access_token});return{headers:this.addSharedMetadataHeaders(u)}}if(this.refreshHandler){let u=await this.processAndValidateRefreshHandler();if(u?.access_token){this.setCredentials(u);let h=new Headers({authorization:"Bearer "+this.credentials.access_token});return{headers:this.addSharedMetadataHeaders(h)}}}if(this.apiKey)return{headers:new Headers({"X-Goog-Api-Key":this.apiKey})};let r=null,n=null;try{r=await this.refreshToken(t.refresh_token),n=r.tokens}catch(u){let h=u;if(h.response&&(h.response.status===403||h.response.status===404))h.message=`Could not refresh access token: ${h.message}`;throw h}let s=this.credentials;s.token_type=s.token_type||"Bearer",n.refresh_token=s.refresh_token,this.credentials=n;let i=new Headers({authorization:s.token_type+" "+n.access_token});return{headers:this.addSharedMetadataHeaders(i),res:r.res}}static getRevokeTokenUrl(e){return new Ae().getRevokeTokenURL(e).toString()}getRevokeTokenURL(e){let t=new URL(this.endpoints.oauth2RevokeUrl);return t.searchParams.append("token",e),t}revokeToken(e,t){let r={...Ae.RETRY_CONFIG,url:this.getRevokeTokenURL(e).toString(),method:"POST"};if(st.AuthClient.setMethodName(r,"revokeToken"),t)this.transporter.request(r).then((n)=>t(null,n),t);else return this.transporter.request(r)}revokeCredentials(e){if(e)this.revokeCredentialsAsync().then((t)=>e(null,t),e);else return this.revokeCredentialsAsync()}async revokeCredentialsAsync(){let e=this.credentials.access_token;if(this.credentials={},e)return this.revokeToken(e);else throw Error("No access token to revoke.")}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){try{let r=await this.getRequestMetadataAsync();if(e.headers=oo.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,r.headers),this.apiKey)e.headers.set("X-Goog-Api-Key",this.apiKey);return await this.transporter.request(e)}catch(r){let n=r.response;if(n){let s=n.status,i=this.credentials&&this.credentials.access_token&&this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure),u=this.credentials&&this.credentials.access_token&&!this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure)&&this.refreshHandler,h=n.config.data instanceof wh.Readable,y=s===401||s===403;if(!t&&y&&!h&&i)return await this.refreshAccessTokenAsync(),this.requestAsync(e,!0);else if(!t&&y&&!h&&u){let S=await this.processAndValidateRefreshHandler();if(S?.access_token)this.setCredentials(S);return this.requestAsync(e,!0)}}throw r}}verifyIdToken(e,t){if(t&&typeof t!=="function")throw Error("This method accepts an options object as the first parameter, which includes the idToken, audience, and maxExpiry.");if(t)this.verifyIdTokenAsync(e).then((r)=>t(null,r),t);else return this.verifyIdTokenAsync(e)}async verifyIdTokenAsync(e){if(!e.idToken)throw Error("The verifyIdToken method requires an ID Token");let t=await this.getFederatedSignonCertsAsync();return await this.verifySignedJwtWithCertsAsync(e.idToken,t.certs,e.audience,this.issuers,e.maxExpiry)}async getTokenInfo(e){let{data:t}=await this.transporter.request({...Ae.RETRY_CONFIG,method:"POST",headers:{"content-type":"application/x-www-form-urlencoded;charset=UTF-8",authorization:`Bearer ${e}`},url:this.endpoints.tokenInfoUrl.toString()}),r=Object.assign({expiry_date:new Date().getTime()+t.expires_in*1000,scopes:t.scope.split(" ")},t);return delete r.expires_in,delete r.scope,r}getFederatedSignonCerts(e){if(e)this.getFederatedSignonCertsAsync().then((t)=>e(null,t.certs,t.res),e);else return this.getFederatedSignonCertsAsync()}async getFederatedSignonCertsAsync(){let e=new Date().getTime(),t=Vr.hasBrowserCrypto()?qe.JWK:qe.PEM;if(this.certificateExpiry&&e<this.certificateExpiry.getTime()&&this.certificateCacheFormat===t)return{certs:this.certificateCache,format:t};let r,n;switch(t){case qe.PEM:n=this.endpoints.oauth2FederatedSignonPemCertsUrl.toString();break;case qe.JWK:n=this.endpoints.oauth2FederatedSignonJwkCertsUrl.toString();break;default:throw Error(`Unsupported certificate format ${t}`)}try{let y={...Ae.RETRY_CONFIG,url:n};st.AuthClient.setMethodName(y,"getFederatedSignonCertsAsync"),r=await this.transporter.request(y)}catch(y){if(y instanceof Error)y.message=`Failed to retrieve verification certificates: ${y.message}`;throw y}let s=r?.headers.get("cache-control"),i=-1;if(s){let y=/max-age=(?<maxAge>[0-9]+)/.exec(s)?.groups?.maxAge;if(y)i=Number(y)*1000}let u={};switch(t){case qe.PEM:u=r.data;break;case qe.JWK:for(let y of r.data.keys)u[y.kid]=y;break;default:throw Error(`Unsupported certificate format ${t}`)}let h=new Date;return this.certificateExpiry=i===-1?null:new Date(h.getTime()+i),this.certificateCache=u,this.certificateCacheFormat=t,{certs:u,format:t,res:r}}getIapPublicKeys(e){if(e)this.getIapPublicKeysAsync().then((t)=>e(null,t.pubkeys,t.res),e);else return this.getIapPublicKeysAsync()}async getIapPublicKeysAsync(){let e,t=this.endpoints.oauth2IapPublicKeyUrl.toString();try{let r={...Ae.RETRY_CONFIG,url:t};st.AuthClient.setMethodName(r,"getIapPublicKeysAsync"),e=await this.transporter.request(r)}catch(r){if(r instanceof Error)r.message=`Failed to retrieve verification certificates: ${r.message}`;throw r}return{pubkeys:e.data,res:e}}verifySignedJwtWithCerts(){throw Error("verifySignedJwtWithCerts is removed, please use verifySignedJwtWithCertsAsync instead.")}async verifySignedJwtWithCertsAsync(e,t,r,n,s){let i=Vr.createCrypto();if(!s)s=Ae.DEFAULT_MAX_TOKEN_LIFETIME_SECS_;let u=e.split(".");if(u.length!==3)throw Error("Wrong number of segments in token: "+e);let h=u[0]+"."+u[1],y=u[2],S,A;try{S=JSON.parse(i.decodeBase64StringUtf8(u[0]))}catch(K){if(K instanceof Error)K.message=`Can't parse token envelope: ${u[0]}': ${K.message}`;throw K}if(!S)throw Error("Can't parse token envelope: "+u[0]);try{A=JSON.parse(i.decodeBase64StringUtf8(u[1]))}catch(K){if(K instanceof Error)K.message=`Can't parse token payload '${u[0]}`;throw K}if(!A)throw Error("Can't parse token payload: "+u[1]);if(!Object.prototype.hasOwnProperty.call(t,S.kid))throw Error("No pem found for envelope: "+JSON.stringify(S));let k=t[S.kid];if(S.alg==="ES256")y=Th.joseToDer(y,"ES256").toString("base64");if(!await i.verify(k,h,y))throw Error("Invalid token signature: "+e);if(!A.iat)throw Error("No issue time in token: "+JSON.stringify(A));if(!A.exp)throw Error("No expiration time in token: "+JSON.stringify(A));let F=Number(A.iat);if(isNaN(F))throw Error("iat field using invalid format");let W=Number(A.exp);if(isNaN(W))throw Error("exp field using invalid format");let x=new Date().getTime()/1000;if(W>=x+s)throw Error("Expiration time too far in future: "+JSON.stringify(A));let j=F-Ae.CLOCK_SKEW_SECS_,b=W+Ae.CLOCK_SKEW_SECS_;if(x<j)throw Error("Token used too early, "+x+" < "+j+": "+JSON.stringify(A));if(x>b)throw Error("Token used too late, "+x+" > "+b+": "+JSON.stringify(A));if(n&&n.indexOf(A.iss)<0)throw Error("Invalid issuer, expected one of ["+n+"], but got "+A.iss);if(typeof r<"u"&&r!==null){let K=A.aud,re=!1;if(r.constructor===Array)re=r.indexOf(K)>-1;else re=K===r;if(!re)throw Error("Wrong recipient, payload audience != requiredAudience")}return new Ah.LoginTicket(S,A)}async processAndValidateRefreshHandler(){if(this.refreshHandler){let e=await this.refreshHandler();if(!e.access_token)throw Error("No access token is returned by the refreshHandler callback.");return e}return}isTokenExpiring(){let e=this.credentials.expiry_date;return e?e<=new Date().getTime()+this.eagerRefreshThresholdMillis:!1}}ao.OAuth2Client=Ae});var Wr=w(function(ho){Object.defineProperty(ho,"__esModule",{value:!0});ho.Compute=void 0;var Oh=ie(),uo=yt(),kh=Be();class lo extends kh.OAuth2Client{serviceAccountEmail;scopes;constructor(e={}){super(e);this.credentials={expiry_date:1,refresh_token:"compute-placeholder"},this.serviceAccountEmail=e.serviceAccountEmail||"default",this.scopes=Array.isArray(e.scopes)?e.scopes:e.scopes?[e.scopes]:[]}async refreshTokenNoCache(){let e=`service-accounts/${this.serviceAccountEmail}/token`,t;try{let n={property:e};if(this.scopes.length>0)n.params={scopes:this.scopes.join(",")};t=await uo.instance(n)}catch(n){if(n instanceof Oh.GaxiosError)n.message=`Could not refresh access token: ${n.message}`,this.wrapError(n);throw n}let r=t;if(t&&t.expires_in)r.expiry_date=new Date().getTime()+t.expires_in*1000,delete r.expires_in;return this.emit("tokens",r),{tokens:r,res:null}}async fetchIdToken(e){let t=`service-accounts/${this.serviceAccountEmail}/identity?format=full&audience=${e}`,r;try{r=await uo.instance({property:t})}catch(n){if(n instanceof Error)n.message=`Could not fetch ID token: ${n.message}`;throw n}return r}wrapError(e){let t=e.response;if(t&&t.status){if(e.status=t.status,t.status===403)e.message="A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified: "+e.message;else if(t.status===404)e.message="A Not Found error was returned while attempting to retrieve an accesstoken for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have any permission scopes specified: "+e.message}}}ho.Compute=lo});var Yr=w(function(go){Object.defineProperty(go,"__esModule",{value:!0});go.IdTokenClient=void 0;var bh=Be();class po extends bh.OAuth2Client{targetAudience;idTokenProvider;constructor(e){super(e);this.targetAudience=e.targetAudience,this.idTokenProvider=e.idTokenProvider}async getRequestMetadataAsync(){if(!this.credentials.id_token||!this.credentials.expiry_date||this.isTokenExpiring()){let t=await this.idTokenProvider.fetchIdToken(this.targetAudience);this.credentials={id_token:t,expiry_date:this.getIdTokenExpiryDate(t)}}return{headers:new Headers({authorization:"Bearer "+this.credentials.id_token})}}getIdTokenExpiryDate(e){let t=e.split(".")[1];if(t)return JSON.parse(Buffer.from(t,"base64").toString("ascii")).exp*1000}}go.IdTokenClient=po});var zr=w(function(mo){Object.defineProperty(mo,"__esModule",{value:!0});mo.GCPEnv=void 0;mo.clear=xh;mo.getEnv=Rh;var yo=yt(),Ie;(function(e){e.APP_ENGINE="APP_ENGINE",e.KUBERNETES_ENGINE="KUBERNETES_ENGINE",e.CLOUD_FUNCTIONS="CLOUD_FUNCTIONS",e.COMPUTE_ENGINE="COMPUTE_ENGINE",e.CLOUD_RUN="CLOUD_RUN",e.CLOUD_RUN_JOBS="CLOUD_RUN_JOBS",e.NONE="NONE"})(Ie||(mo.GCPEnv=Ie={}));var At;function xh(){At=void 0}async function Rh(){if(At)return At;return At=Nh(),At}async function Nh(){let e=Ie.NONE;if(Ph())e=Ie.APP_ENGINE;else if(Ih())e=Ie.CLOUD_FUNCTIONS;else if(await qh())if(await Uh())e=Ie.KUBERNETES_ENGINE;else if(jh())e=Ie.CLOUD_RUN;else if(Dh())e=Ie.CLOUD_RUN_JOBS;else e=Ie.COMPUTE_ENGINE;else e=Ie.NONE;return e}function Ph(){return!!(process.env.GAE_SERVICE||process.env.GAE_MODULE_NAME)}function Ih(){return!!(process.env.FUNCTION_NAME||process.env.FUNCTION_TARGET)}function jh(){return!!process.env.K_CONFIGURATION}function Dh(){return!!process.env.CLOUD_RUN_JOB}async function Uh(){try{return await yo.instance("attributes/cluster-name"),!0}catch(e){return!1}}async function qh(){return yo.isAvailable()}});var Xr=w(function(Ug,wo){var Jt=nt().Buffer,Lh=G("stream"),Gh=G("util");function Vt(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=Jt.alloc(0),this;if(typeof e.pipe==="function")return this.buffer=Jt.alloc(0),e.pipe(this),this;if(e.length||typeof e==="object")return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw TypeError("Unexpected data type ("+typeof e+")")}Gh.inherits(Vt,Lh);Vt.prototype.write=function(t){this.buffer=Jt.concat([this.buffer,Jt.from(t)]),this.emit("data",t)};Vt.prototype.end=function(t){if(t)this.write(t);this.emit("end",t),this.emit("close"),this.writable=!1,this.readable=!1};wo.exports=Vt});var Ao=w(function(qg,To){var vt=G("buffer").Buffer,Qr=G("buffer").SlowBuffer;To.exports=Wt;function Wt(e,t){if(!vt.isBuffer(e)||!vt.isBuffer(t))return!1;if(e.length!==t.length)return!1;var r=0;for(var n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}Wt.install=function(){vt.prototype.equal=Qr.prototype.equal=function(t){return Wt(this,t)}};var Bh=vt.prototype.equal,Hh=Qr.prototype.equal;Wt.restore=function(){vt.prototype.equal=Bh,Qr.prototype.equal=Hh}});var rn=w(function(Fg,No){var ot=nt().Buffer,ve=G("crypto"),So=Fr(),vo=G("util"),$h=`"%s" is not a valid algorithm.
15
15
  Supported algorithms are:
16
- "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".`,St="secret must be a string or buffer",it="key must be a string or a buffer",Kh="key must be a string, a buffer or an object",en=typeof ve.createPublicKey==="function";if(en)it+=" or a KeyObject",St+="or a KeyObject";function Co(e){if(ot.isBuffer(e))return;if(typeof e==="string")return;if(!en)throw be(it);if(typeof e!=="object")throw be(it);if(typeof e.type!=="string")throw be(it);if(typeof e.asymmetricKeyType!=="string")throw be(it);if(typeof e.export!=="function")throw be(it)}function Oo(e){if(ot.isBuffer(e))return;if(typeof e==="string")return;if(typeof e==="object")return;throw be(Kh)}function Jh(e){if(ot.isBuffer(e))return;if(typeof e==="string")return e;if(!en)throw be(St);if(typeof e!=="object")throw be(St);if(e.type!=="secret")throw be(St);if(typeof e.export!=="function")throw be(St)}function tn(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function ko(e){e=e.toString();var t=4-e.length%4;if(t!==4)for(var r=0;r<t;++r)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function be(e){var t=[].slice.call(arguments,1),r=vo.format.bind(vo,e).apply(null,t);return TypeError(r)}function Vh(e){return ot.isBuffer(e)||typeof e==="string"}function Ct(e){if(!Vh(e))e=JSON.stringify(e);return e}function bo(e){return function(r,n){Jh(n),r=Ct(r);var s=ve.createHmac("sha"+e,n),i=(s.update(r),s.digest("base64"));return tn(i)}}var Zr,Wh="timingSafeEqual"in ve?function(t,r){if(t.byteLength!==r.byteLength)return!1;return ve.timingSafeEqual(t,r)}:function(t,r){if(!Zr)Zr=Ao();return Zr(t,r)};function Yh(e){return function(r,n,s){var i=bo(e)(r,s);return Wh(ot.from(n),ot.from(i))}}function xo(e){return function(r,n){Oo(n),r=Ct(r);var s=ve.createSign("RSA-SHA"+e),i=(s.update(r),s.sign(n,"base64"));return tn(i)}}function Ro(e){return function(r,n,s){Co(s),r=Ct(r),n=ko(n);var i=ve.createVerify("RSA-SHA"+e);return i.update(r),i.verify(s,n,"base64")}}function zh(e){return function(r,n){Oo(n),r=Ct(r);var s=ve.createSign("RSA-SHA"+e),i=(s.update(r),s.sign({key:n,padding:ve.constants.RSA_PKCS1_PSS_PADDING,saltLength:ve.constants.RSA_PSS_SALTLEN_DIGEST},"base64"));return tn(i)}}function Xh(e){return function(r,n,s){Co(s),r=Ct(r),n=ko(n);var i=ve.createVerify("RSA-SHA"+e);return i.update(r),i.verify({key:s,padding:ve.constants.RSA_PKCS1_PSS_PADDING,saltLength:ve.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function Qh(e){var t=xo(e);return function(){var n=t.apply(null,arguments);return n=So.derToJose(n,"ES"+e),n}}function Zh(e){var t=Ro(e);return function(n,s,i){s=So.joseToDer(s,"ES"+e).toString("base64");var u=t(n,s,i);return u}}function ef(){return function(){return""}}function tf(){return function(t,r){return r===""}}No.exports=function(t){var r={hs:bo,rs:xo,ps:zh,es:Qh,none:ef},n={hs:Yh,rs:Ro,ps:Xh,es:Zh,none:tf},s=t.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!s)throw be($h,t);var i=(s[1]||s[3]).toLowerCase(),u=s[2];return{sign:r[i](u),verify:n[i](u)}}});var nn=w(function(Mg,Po){var rf=G("buffer").Buffer;Po.exports=function(t){if(typeof t==="string")return t;if(typeof t==="number"||rf.isBuffer(t))return t.toString();return JSON.stringify(t)}});var Fo=w(function(Lg,qo){var nf=nt().Buffer,Io=Xr(),sf=rn(),of=G("stream"),jo=nn(),sn=G("util");function Do(e,t){return nf.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function af(e,t,r){r=r||"utf8";var n=Do(jo(e),"binary"),s=Do(jo(t),r);return sn.format("%s.%s",n,s)}function Uo(e){var{header:t,payload:r}=e,n=e.secret||e.privateKey,s=e.encoding,i=sf(t.alg),u=af(t,r,s),h=i.sign(u,n);return sn.format("%s.%s",u,h)}function Yt(e){var t=e.secret;if(t=t==null?e.privateKey:t,t=t==null?e.key:t,/^hs/i.test(e.header.alg)===!0&&t==null)throw TypeError("secret must be a string or buffer or a KeyObject");var r=new Io(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=r,this.payload=new Io(e.payload),this.secret.once("close",function(){if(!this.payload.writable&&this.readable)this.sign()}.bind(this)),this.payload.once("close",function(){if(!this.secret.writable&&this.readable)this.sign()}.bind(this))}sn.inherits(Yt,of);Yt.prototype.sign=function(){try{var t=Uo({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",t),this.emit("data",t),this.emit("end"),this.readable=!1,t}catch(r){this.readable=!1,this.emit("error",r),this.emit("close")}};Yt.sign=Uo;qo.exports=Yt});var Wo=w(function(Gg,Vo){var Lo=nt().Buffer,Mo=Xr(),cf=rn(),uf=G("stream"),Go=nn(),lf=G("util"),hf=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function ff(e){return Object.prototype.toString.call(e)==="[object Object]"}function df(e){if(ff(e))return e;try{return JSON.parse(e)}catch(t){return}}function Bo(e){var t=e.split(".",1)[0];return df(Lo.from(t,"base64").toString("binary"))}function pf(e){return e.split(".",2).join(".")}function Ho(e){return e.split(".")[2]}function gf(e,t){t=t||"utf8";var r=e.split(".")[1];return Lo.from(r,"base64").toString(t)}function $o(e){return hf.test(e)&&!!Bo(e)}function Ko(e,t,r){if(!t){var n=Error("Missing algorithm parameter for jws.verify");throw n.code="MISSING_ALGORITHM",n}e=Go(e);var s=Ho(e),i=pf(e),u=cf(t);return u.verify(i,s,r)}function Jo(e,t){if(t=t||{},e=Go(e),!$o(e))return null;var r=Bo(e);if(!r)return null;var n=gf(e);if(r.typ==="JWT"||t.json)n=JSON.parse(n,t.encoding);return{header:r,payload:n,signature:Ho(e)}}function at(e){e=e||{};var t=e.secret;if(t=t==null?e.publicKey:t,t=t==null?e.key:t,/^hs/i.test(e.algorithm)===!0&&t==null)throw TypeError("secret must be a string or buffer or a KeyObject");var r=new Mo(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=r,this.signature=new Mo(e.signature),this.secret.once("close",function(){if(!this.signature.writable&&this.readable)this.verify()}.bind(this)),this.signature.once("close",function(){if(!this.secret.writable&&this.readable)this.verify()}.bind(this))}lf.inherits(at,uf);at.prototype.verify=function(){try{var t=Ko(this.signature.buffer,this.algorithm,this.key.buffer),r=Jo(this.signature.buffer,this.encoding);return this.emit("done",t,r),this.emit("data",t),this.emit("end"),this.readable=!1,t}catch(n){this.readable=!1,this.emit("error",n),this.emit("close")}};at.decode=Jo;at.isValid=$o;at.verify=Ko;Vo.exports=at});var on=w(function(yf){var Yo=Fo(),zt=Wo(),_f=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"];yf.ALGORITHMS=_f;yf.sign=Yo.sign;yf.verify=zt.verify;yf.decode=zt.decode;yf.isValid=zt.isValid;yf.createSign=function(t){return new Yo(t)};yf.createVerify=function(t){return new zt(t)}});var Qo=w(function(Xo){Object.defineProperty(Xo,"__esModule",{value:!0});Xo.buildPayloadForJwsSign=zo;Xo.getJwsSign=bf;var Cf=on(),Of="RS256",kf="https://oauth2.googleapis.com/token";function zo(e){let t=Math.floor(new Date().getTime()/1000);return{iss:e.iss,scope:e.scope,aud:kf,exp:t+3600,iat:t,sub:e.sub,...e.additionalClaims}}function bf(e){let t=zo(e);return Cf.sign({header:{alg:Of},payload:t,secret:e.key})}});var ea=w(function(Zo){Object.defineProperty(Zo,"__esModule",{value:!0});Zo.getToken=Df;var Nf=Qo(),Pf="https://oauth2.googleapis.com/token",If="urn:ietf:params:oauth:grant-type:jwt-bearer",jf=(e)=>({method:"POST",url:Pf,data:new URLSearchParams({grant_type:If,assertion:Nf.getJwsSign(e)}),responseType:"json",retryConfig:{httpMethodsToRetry:["POST"]}});async function Df(e){if(!e.transporter)throw Error("No transporter set.");try{let t=jf(e);return(await e.transporter.request(t)).data}catch(t){let r=t,n=r.response?.data;if(n?.error)r.message=`${n.error}: ${n.error_description}`;throw r}}});var sa=w(function(ra){Object.defineProperty(ra,"__esModule",{value:!0});ra.ErrorWithCode=void 0;class ta extends Error{code;constructor(e,t){super(e);this.code=t}}ra.ErrorWithCode=ta});var an=w(function(ha){Object.defineProperty(ha,"__esModule",{value:!0});ha.getCredentials=Mf;var qf=G("path"),ia=G("fs"),Ff=G("util"),Xt=sa(),oa=ia.readFile?Ff.promisify(ia.readFile):async()=>{throw new Xt.ErrorWithCode("use key rather than keyFile.","MISSING_CREDENTIALS")},He;(function(e){e.JSON=".json",e.DER=".der",e.CRT=".crt",e.PEM=".pem",e.P12=".p12",e.PFX=".pfx"})(He||(He={}));class aa{keyFilePath;constructor(e){this.keyFilePath=e}async getCredentials(){let e=await oa(this.keyFilePath,"utf8"),t;try{t=JSON.parse(e)}catch(s){throw Error(`Invalid JSON key file: ${s.message}`)}let r=t.private_key,n=t.client_email;if(!r||!n)throw new Xt.ErrorWithCode("private_key and client_email are required.","MISSING_CREDENTIALS");return{privateKey:r,clientEmail:n}}}class ca{keyFilePath;constructor(e){this.keyFilePath=e}async getCredentials(){return{privateKey:await oa(this.keyFilePath,"utf8")}}}class ua{async getCredentials(){throw new Xt.ErrorWithCode("*.p12 certificates are not supported after v6.1.2. Consider utilizing *.json format or converting *.p12 to *.pem using the OpenSSL CLI.","UNKNOWN_CERTIFICATE_TYPE")}}class la{static create(e){switch(qf.extname(e)){case He.JSON:return new aa(e);case He.DER:case He.CRT:case He.PEM:return new ca(e);case He.P12:case He.PFX:return new ua;default:throw new Xt.ErrorWithCode("Unknown certificate type. Type is determined based on file extension. Current supported extensions are *.json, and *.pem.","UNKNOWN_CERTIFICATE_TYPE")}}}async function Mf(e){return la.create(e).getCredentials()}});var ga=w(function(da){Object.defineProperty(da,"__esModule",{value:!0});da.TokenHandler=void 0;var Gf=ea(),Bf=an();class fa{token;tokenExpiresAt;inFlightRequest;tokenOptions;constructor(e){this.tokenOptions=e}async processCredentials(){if(!this.tokenOptions.key&&!this.tokenOptions.keyFile)throw Error("No key or keyFile set.");if(!this.tokenOptions.key&&this.tokenOptions.keyFile){let e=await Bf.getCredentials(this.tokenOptions.keyFile);this.tokenOptions.key=e.privateKey,this.tokenOptions.email=e.clientEmail}}isTokenExpiring(){if(!this.token||!this.tokenExpiresAt)return!0;let e=new Date().getTime(),t=this.tokenOptions.eagerRefreshThresholdMillis??0;return this.tokenExpiresAt<=e+t}hasExpired(){let e=new Date().getTime();if(this.token&&this.tokenExpiresAt)return new Date().getTime()>=this.tokenExpiresAt;return!0}async getToken(e){if(await this.processCredentials(),this.inFlightRequest&&!e)return this.inFlightRequest;if(this.token&&!this.isTokenExpiring()&&!e)return this.token;try{this.inFlightRequest=Gf.getToken(this.tokenOptions);let t=await this.inFlightRequest;return this.token=t,this.tokenExpiresAt=new Date().getTime()+(t.expires_in??0)*1000,t}finally{this.inFlightRequest=void 0}}}da.TokenHandler=fa});var ya=w(function(_a){Object.defineProperty(_a,"__esModule",{value:!0});_a.revokeToken=Kf;var Hf="https://oauth2.googleapis.com/revoke?token=",$f=!0;async function Kf(e,t){let r=Hf+e;return await t.request({url:r,retry:$f})}});var cn=w(function(wa){Object.defineProperty(wa,"__esModule",{value:!0});wa.GoogleToken=void 0;var Vf=ie(),ma=ga(),Wf=ya();class Ea{tokenOptions;tokenHandler;constructor(e){if(this.tokenOptions=e||{},this.tokenOptions.transporter=this.tokenOptions.transporter||{request:(t)=>Vf.request(t)},!this.tokenOptions.iss)this.tokenOptions.iss=this.tokenOptions.email;if(typeof this.tokenOptions.scope==="object")this.tokenOptions.scope=this.tokenOptions.scope.join(" ");this.tokenHandler=new ma.TokenHandler(this.tokenOptions)}get expiresAt(){return this.tokenHandler.tokenExpiresAt}get accessToken(){return this.tokenHandler.token?.access_token}get idToken(){return this.tokenHandler.token?.id_token}get tokenType(){return this.tokenHandler.token?.token_type}get refreshToken(){return this.tokenHandler.token?.refresh_token}hasExpired(){return this.tokenHandler.hasExpired()}isTokenExpiring(){return this.tokenHandler.isTokenExpiring()}getToken(e,t={forceRefresh:!1}){let r;if(typeof e==="function")r=e;else if(typeof e==="object")t=e;let n=this.tokenHandler.getToken(t.forceRefresh??!1);if(r)n.then((s)=>r(null,s),r);return n}revokeToken(e){if(!this.accessToken)return Promise.reject(Error("No token to revoke."));let t=Wf.revokeToken(this.accessToken,this.tokenOptions.transporter);if(e)t.then(()=>e(),e);this.tokenHandler=new ma.TokenHandler(this.tokenOptions)}get googleTokenOptions(){return this.tokenOptions}}wa.GoogleToken=Ea});var ln=w(function(va){Object.defineProperty(va,"__esModule",{value:!0});va.JWTAccess=void 0;var Yf=on(),zf=Oe(),Aa={alg:"RS256",typ:"JWT"};class un{email;key;keyId;projectId;eagerRefreshThresholdMillis;cache=new zf.LRUCache({capacity:500,maxAge:3600000});constructor(e,t,r,n){this.email=e,this.key=t,this.keyId=r,this.eagerRefreshThresholdMillis=n??300000}getCachedKey(e,t){let r=e;if(t&&Array.isArray(t)&&t.length)r=e?`${e}_${t.join("_")}`:`${t.join("_")}`;else if(typeof t==="string")r=e?`${e}_${t}`:t;if(!r)throw Error("Scopes or url must be provided");return r}getRequestHeaders(e,t,r){let n=this.getCachedKey(e,r),s=this.cache.get(n),i=Date.now();if(s&&s.expiration-i>this.eagerRefreshThresholdMillis)return new Headers(s.headers);let u=Math.floor(Date.now()/1000),h=un.getExpirationTime(u),y;if(Array.isArray(r))r=r.join(" ");if(r)y={iss:this.email,sub:this.email,scope:r,exp:h,iat:u};else y={iss:this.email,sub:this.email,aud:e,exp:h,iat:u};if(t){for(let F in y)if(t[F])throw Error(`The '${F}' property is not allowed when passing additionalClaims. This claim is included in the JWT by default.`)}let S=this.keyId?{...Aa,kid:this.keyId}:Aa,A=Object.assign(y,t),k=Yf.sign({header:S,payload:A,secret:this.key}),N=new Headers({authorization:`Bearer ${k}`});return this.cache.set(n,{expiration:h*1000,headers:N}),N}static getExpirationTime(e){return e+3600}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the service account auth settings.");if(!e.client_email)throw Error("The incoming JSON object does not contain a client_email field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id}fromStream(e,t){if(t)this.fromStreamAsync(e).then(()=>t(),t);else return this.fromStreamAsync(e)}fromStreamAsync(e){return new Promise((t,r)=>{if(!e)r(Error("Must pass in a stream containing the service account auth settings."));let n="";e.setEncoding("utf8").on("data",(s)=>n+=s).on("error",r).on("end",()=>{try{let s=JSON.parse(n);this.fromJSON(s),t()}catch(s){r(s)}})})}}va.JWTAccess=un});var fn=w(function(Oa){Object.defineProperty(Oa,"__esModule",{value:!0});Oa.JWT=void 0;var Ca=cn(),Xf=an(),Qf=ln(),Zf=Be(),Qt=_e();class hn extends Zf.OAuth2Client{email;keyFile;key;keyId;defaultScopes;scopes;scope;subject;gtoken;additionalClaims;useJWTAccessWithScope;defaultServicePath;access;constructor(e={}){super(e);this.email=e.email,this.keyFile=e.keyFile,this.key=e.key,this.keyId=e.keyId,this.scopes=e.scopes,this.subject=e.subject,this.additionalClaims=e.additionalClaims,this.credentials={refresh_token:"jwt-placeholder",expiry_date:1}}createScoped(e){let t=new hn(this);return t.scopes=e,t}async getRequestMetadataAsync(e){e=this.defaultServicePath?`https://${this.defaultServicePath}/`:e;let t=!this.hasUserScopes()&&e||this.useJWTAccessWithScope&&this.hasAnyScopes()||this.universeDomain!==Qt.DEFAULT_UNIVERSE;if(this.subject&&this.universeDomain!==Qt.DEFAULT_UNIVERSE)throw RangeError(`Service Account user is configured for the credential. Domain-wide delegation is not supported in universes other than ${Qt.DEFAULT_UNIVERSE}`);if(!this.apiKey&&t)if(this.additionalClaims&&this.additionalClaims.target_audience){let{tokens:r}=await this.refreshToken();return{headers:this.addSharedMetadataHeaders(new Headers({authorization:`Bearer ${r.id_token}`}))}}else{if(!this.access)this.access=new Qf.JWTAccess(this.email,this.key,this.keyId,this.eagerRefreshThresholdMillis);let r;if(this.hasUserScopes())r=this.scopes;else if(!e)r=this.defaultScopes;let n=this.useJWTAccessWithScope||this.universeDomain!==Qt.DEFAULT_UNIVERSE,s=await this.access.getRequestHeaders(e??void 0,this.additionalClaims,n?r:void 0);return{headers:this.addSharedMetadataHeaders(s)}}else if(this.hasAnyScopes()||this.apiKey)return super.getRequestMetadataAsync(e);else return{headers:new Headers}}async fetchIdToken(e){let t=new Ca.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:{target_audience:e},transporter:this.transporter});if(await t.getToken({forceRefresh:!0}),!t.idToken)throw Error("Unknown error: Failed to fetch ID token");return t.idToken}hasUserScopes(){if(!this.scopes)return!1;return this.scopes.length>0}hasAnyScopes(){if(this.scopes&&this.scopes.length>0)return!0;if(this.defaultScopes&&this.defaultScopes.length>0)return!0;return!1}authorize(e){if(e)this.authorizeAsync().then((t)=>e(null,t),e);else return this.authorizeAsync()}async authorizeAsync(){let e=await this.refreshToken();if(!e)throw Error("No result returned");return this.credentials=e.tokens,this.credentials.refresh_token="jwt-placeholder",this.key=this.gtoken.googleTokenOptions?.key,this.email=this.gtoken.googleTokenOptions?.iss,e.tokens}async refreshTokenNoCache(){let e=this.createGToken(),r={access_token:(await e.getToken({forceRefresh:this.isTokenExpiring()})).access_token,token_type:"Bearer",expiry_date:e.expiresAt,id_token:e.idToken};return this.emit("tokens",r),{res:null,tokens:r}}createGToken(){if(!this.gtoken)this.gtoken=new Ca.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:this.additionalClaims,transporter:this.transporter});return this.gtoken}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the service account auth settings.");if(!e.client_email)throw Error("The incoming JSON object does not contain a client_email field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(t)this.fromStreamAsync(e).then(()=>t(),t);else return this.fromStreamAsync(e)}fromStreamAsync(e){return new Promise((t,r)=>{if(!e)throw Error("Must pass in a stream containing the service account auth settings.");let n="";e.setEncoding("utf8").on("error",r).on("data",(s)=>n+=s).on("end",()=>{try{let s=JSON.parse(n);this.fromJSON(s),t()}catch(s){r(s)}})})}fromAPIKey(e){if(typeof e!=="string")throw Error("Must provide an API Key string.");this.apiKey=e}async getCredentials(){if(this.key)return{private_key:this.key,client_email:this.email};else if(this.keyFile){let e=this.createGToken(),t=await Xf.getCredentials(this.keyFile);return{private_key:t.privateKey,client_email:t.clientEmail}}throw Error("A key or a keyFile must be provided to getCredentials.")}}Oa.JWT=hn});var dn=w(function(ba){Object.defineProperty(ba,"__esModule",{value:!0});ba.UserRefreshClient=ba.USER_REFRESH_ACCOUNT_TYPE=void 0;var ed=Be(),td=_e();ba.USER_REFRESH_ACCOUNT_TYPE="authorized_user";class Zt extends ed.OAuth2Client{_refreshToken;constructor(e,t,r,n,s){let i=e&&typeof e==="object"?e:{clientId:e,clientSecret:t,refreshToken:r,eagerRefreshThresholdMillis:n,forceRefreshOnFailure:s};super(i);this._refreshToken=i.refreshToken,this.credentials.refresh_token=i.refreshToken}async refreshTokenNoCache(){return super.refreshTokenNoCache(this._refreshToken)}async fetchIdToken(e){let t={...Zt.RETRY_CONFIG,url:this.endpoints.oauth2TokenUrl,method:"POST",data:new URLSearchParams({client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token",refresh_token:this._refreshToken,target_audience:e}),responseType:"json"};return td.AuthClient.setMethodName(t,"fetchIdToken"),(await this.transporter.request(t)).data.id_token}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the user refresh token");if(e.type!=="authorized_user")throw Error('The incoming JSON object does not have the "authorized_user" type');if(!e.client_id)throw Error("The incoming JSON object does not contain a client_id field");if(!e.client_secret)throw Error("The incoming JSON object does not contain a client_secret field");if(!e.refresh_token)throw Error("The incoming JSON object does not contain a refresh_token field");this._clientId=e.client_id,this._clientSecret=e.client_secret,this._refreshToken=e.refresh_token,this.credentials.refresh_token=e.refresh_token,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(t)this.fromStreamAsync(e).then(()=>t(),t);else return this.fromStreamAsync(e)}async fromStreamAsync(e){return new Promise((t,r)=>{if(!e)return r(Error("Must pass in a stream containing the user refresh token."));let n="";e.setEncoding("utf8").on("error",r).on("data",(s)=>n+=s).on("end",()=>{try{let s=JSON.parse(n);return this.fromJSON(s),t()}catch(s){return r(s)}})})}static fromJSON(e){let t=new Zt;return t.fromJSON(e),t}}ba.UserRefreshClient=Zt});var pn=w(function(Na){Object.defineProperty(Na,"__esModule",{value:!0});Na.Impersonated=Na.IMPERSONATED_ACCOUNT_TYPE=void 0;var Ra=Be(),nd=ie(),sd=Oe();Na.IMPERSONATED_ACCOUNT_TYPE="impersonated_service_account";class Ot extends Ra.OAuth2Client{sourceClient;targetPrincipal;targetScopes;delegates;lifetime;endpoint;constructor(e={}){super(e);if(this.credentials={expiry_date:1,refresh_token:"impersonated-placeholder"},this.sourceClient=e.sourceClient??new Ra.OAuth2Client,this.targetPrincipal=e.targetPrincipal??"",this.delegates=e.delegates??[],this.targetScopes=e.targetScopes??[],this.lifetime=e.lifetime??3600,!sd.originalOrCamelOptions(e).get("universe_domain"))this.universeDomain=this.sourceClient.universeDomain;else if(this.sourceClient.universeDomain!==this.universeDomain)throw RangeError(`Universe domain ${this.sourceClient.universeDomain} in source credentials does not match ${this.universeDomain} universe domain set for impersonated credentials.`);this.endpoint=e.endpoint??`https://iamcredentials.${this.universeDomain}`}async sign(e){await this.sourceClient.getAccessToken();let t=`projects/-/serviceAccounts/${this.targetPrincipal}`,r=`${this.endpoint}/v1/${t}:signBlob`,n={delegates:this.delegates,payload:Buffer.from(e).toString("base64")};return(await this.sourceClient.request({...Ot.RETRY_CONFIG,url:r,data:n,method:"POST"})).data}getTargetPrincipal(){return this.targetPrincipal}async refreshToken(){try{await this.sourceClient.getAccessToken();let e="projects/-/serviceAccounts/"+this.targetPrincipal,t=`${this.endpoint}/v1/${e}:generateAccessToken`,r={delegates:this.delegates,scope:this.targetScopes,lifetime:this.lifetime+"s"},n=await this.sourceClient.request({...Ot.RETRY_CONFIG,url:t,data:r,method:"POST"}),s=n.data;return this.credentials.access_token=s.accessToken,this.credentials.expiry_date=Date.parse(s.expireTime),{tokens:this.credentials,res:n}}catch(e){if(!(e instanceof Error))throw e;let t=0,r="";if(e instanceof nd.GaxiosError)t=e?.response?.data?.error?.status,r=e?.response?.data?.error?.message;if(t&&r)throw e.message=`${t}: unable to impersonate: ${r}`,e;else throw e.message=`unable to impersonate: ${e}`,e}}async fetchIdToken(e,t){await this.sourceClient.getAccessToken();let r=`projects/-/serviceAccounts/${this.targetPrincipal}`,n=`${this.endpoint}/v1/${r}:generateIdToken`,s={delegates:this.delegates,audience:e,includeEmail:t?.includeEmail??!0,useEmailAzp:t?.includeEmail??!0};return(await this.sourceClient.request({...Ot.RETRY_CONFIG,url:n,data:s,method:"POST"})).data.token}}Na.Impersonated=Ot});var gn=w(function(ja){Object.defineProperty(ja,"__esModule",{value:!0});ja.OAuthClientAuthHandler=void 0;ja.getErrorFromOAuthErrorResponse=cd;var ct=ie(),od=mt(),ad=["PUT","POST","PATCH"];class Ia{#e=od.createCrypto();#t;transporter;constructor(e){if(e&&"clientId"in e)this.#t=e,this.transporter=new ct.Gaxios;else this.#t=e?.clientAuthentication,this.transporter=e?.transporter||new ct.Gaxios}applyClientAuthenticationOptions(e,t){if(e.headers=ct.Gaxios.mergeHeaders(e.headers),this.injectAuthenticatedHeaders(e,t),!t)this.injectAuthenticatedRequestBody(e)}injectAuthenticatedHeaders(e,t){if(t)e.headers=ct.Gaxios.mergeHeaders(e.headers,{authorization:`Bearer ${t}`});else if(this.#t?.confidentialClientType==="basic"){e.headers=ct.Gaxios.mergeHeaders(e.headers);let r=this.#t.clientId,n=this.#t.clientSecret||"",s=this.#e.encodeBase64StringUtf8(`${r}:${n}`);ct.Gaxios.mergeHeaders(e.headers,{authorization:`Basic ${s}`})}}injectAuthenticatedRequestBody(e){if(this.#t?.confidentialClientType==="request-body"){let t=(e.method||"GET").toUpperCase();if(!ad.includes(t))throw Error(`${t} HTTP method does not support ${this.#t.confidentialClientType} client authentication`);let n=new Headers(e.headers).get("content-type");if(n?.startsWith("application/x-www-form-urlencoded")||e.data instanceof URLSearchParams){let s=new URLSearchParams(e.data??"");s.append("client_id",this.#t.clientId),s.append("client_secret",this.#t.clientSecret||""),e.data=s}else if(n?.startsWith("application/json"))e.data=e.data||{},Object.assign(e.data,{client_id:this.#t.clientId,client_secret:this.#t.clientSecret||""});else throw Error(`${n} content-types are not supported with ${this.#t.confidentialClientType} client authentication`)}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}ja.OAuthClientAuthHandler=Ia;function cd(e,t){let{error:r,error_description:n,error_uri:s}=e,i=`Error code ${r}`;if(typeof n<"u")i+=`: ${n}`;if(typeof s<"u")i+=` - ${s}`;let u=Error(i);if(t){let h=Object.keys(t);if(t.stack)h.push("stack");h.forEach((y)=>{if(y!=="message")Object.defineProperty(u,y,{value:t[y],writable:!1,enumerable:!0})})}return u}});var er=w(function(qa){Object.defineProperty(qa,"__esModule",{value:!0});qa.StsCredentials=void 0;var ld=ie(),hd=_e(),Ua=gn(),fd=Oe();class _n extends Ua.OAuthClientAuthHandler{#e;constructor(e={tokenExchangeEndpoint:""},t){if(typeof e!=="object"||e instanceof URL)e={tokenExchangeEndpoint:e,clientAuthentication:t};super(e);this.#e=e.tokenExchangeEndpoint}async exchangeToken(e,t,r){let n={grant_type:e.grantType,resource:e.resource,audience:e.audience,scope:e.scope?.join(" "),requested_token_type:e.requestedTokenType,subject_token:e.subjectToken,subject_token_type:e.subjectTokenType,actor_token:e.actingParty?.actorToken,actor_token_type:e.actingParty?.actorTokenType,options:r&&JSON.stringify(r)},s={..._n.RETRY_CONFIG,url:this.#e.toString(),method:"POST",headers:t,data:new URLSearchParams(fd.removeUndefinedValuesInObject(n)),responseType:"json"};hd.AuthClient.setMethodName(s,"exchangeToken"),this.applyClientAuthenticationOptions(s);try{let i=await this.transporter.request(s),u=i.data;return u.res=i,u}catch(i){if(i instanceof ld.GaxiosError&&i.response)throw Ua.getErrorFromOAuthErrorResponse(i.response.data,i);throw i}}}qa.StsCredentials=_n});var $e=w(function(La){Object.defineProperty(La,"__esModule",{value:!0});La.BaseExternalAccountClient=La.CLOUD_RESOURCE_MANAGER=La.EXTERNAL_ACCOUNT_TYPE=La.EXPIRATION_TIME_OFFSET=void 0;var dd=ie(),pd=G("stream"),yn=_e(),gd=er(),Ma=Oe(),_d=Br(),yd="urn:ietf:params:oauth:grant-type:token-exchange",md="urn:ietf:params:oauth:token-type:access_token",mn="https://www.googleapis.com/auth/cloud-platform",Ed=3600;La.EXPIRATION_TIME_OFFSET=300000;La.EXTERNAL_ACCOUNT_TYPE="external_account";La.CLOUD_RESOURCE_MANAGER="https://cloudresourcemanager.googleapis.com/v1/projects/";var wd="//iam\\.googleapis\\.com/locations/[^/]+/workforcePools/[^/]+/providers/.+",Td="https://sts.{universeDomain}/v1/token";class tr extends yn.AuthClient{scopes;projectNumber;audience;subjectTokenType;stsCredential;clientAuth;credentialSourceType;cachedAccessToken;serviceAccountImpersonationUrl;serviceAccountImpersonationLifetime;workforcePoolUserProject;configLifetimeRequested;tokenUrl;cloudResourceManagerURL;supplierContext;#e=null;constructor(e){super(e);let t=Ma.originalOrCamelOptions(e),r=t.get("type");if(r&&r!==La.EXTERNAL_ACCOUNT_TYPE)throw Error(`Expected "${La.EXTERNAL_ACCOUNT_TYPE}" type but received "${e.type}"`);let n=t.get("client_id"),s=t.get("client_secret");this.tokenUrl=t.get("token_url")??Td.replace("{universeDomain}",this.universeDomain);let i=t.get("subject_token_type"),u=t.get("workforce_pool_user_project"),h=t.get("service_account_impersonation_url"),y=t.get("service_account_impersonation"),S=Ma.originalOrCamelOptions(y).get("token_lifetime_seconds");if(this.cloudResourceManagerURL=new URL(t.get("cloud_resource_manager_url")||`https://cloudresourcemanager.${this.universeDomain}/v1/projects/`),n)this.clientAuth={confidentialClientType:"basic",clientId:n,clientSecret:s};this.stsCredential=new gd.StsCredentials({tokenExchangeEndpoint:this.tokenUrl,clientAuthentication:this.clientAuth}),this.scopes=t.get("scopes")||[mn],this.cachedAccessToken=null,this.audience=t.get("audience"),this.subjectTokenType=i,this.workforcePoolUserProject=u;let A=new RegExp(wd);if(this.workforcePoolUserProject&&!this.audience.match(A))throw Error("workforcePoolUserProject should not be set for non-workforce pool credentials.");if(this.serviceAccountImpersonationUrl=h,this.serviceAccountImpersonationLifetime=S,this.serviceAccountImpersonationLifetime)this.configLifetimeRequested=!0;else this.configLifetimeRequested=!1,this.serviceAccountImpersonationLifetime=Ed;this.projectNumber=this.getProjectNumber(this.audience),this.supplierContext={audience:this.audience,subjectTokenType:this.subjectTokenType,transporter:this.transporter}}getServiceAccountEmail(){if(this.serviceAccountImpersonationUrl){if(this.serviceAccountImpersonationUrl.length>256)throw RangeError(`URL is too long: ${this.serviceAccountImpersonationUrl}`);return/serviceAccounts\/(?<email>[^:]+):generateAccessToken$/.exec(this.serviceAccountImpersonationUrl)?.groups?.email||null}return null}setCredentials(e){super.setCredentials(e),this.cachedAccessToken=e}async getAccessToken(){if(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async getProjectId(){let e=this.projectNumber||this.workforcePoolUserProject;if(this.projectId)return this.projectId;else if(e){let t=await this.getRequestHeaders(),r={...tr.RETRY_CONFIG,headers:t,url:`${this.cloudResourceManagerURL.toString()}${e}`,responseType:"json"};yn.AuthClient.setMethodName(r,"getProjectId");let n=await this.transporter.request(r);return this.projectId=n.data.projectId,this.projectId}return null}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=dd.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof pd.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){this.#e=this.#e||this.#t();try{return await this.#e}finally{this.#e=null}}async#t(){let e=await this.retrieveSubjectToken(),t={grantType:yd,audience:this.audience,requestedTokenType:md,subjectToken:e,subjectTokenType:this.subjectTokenType,scope:this.serviceAccountImpersonationUrl?[mn]:this.getScopesArray()},r=!this.clientAuth&&this.workforcePoolUserProject?{userProject:this.workforcePoolUserProject}:void 0,n=new Headers({"x-goog-api-client":this.getMetricsHeaderValue()}),s=await this.stsCredential.exchangeToken(t,n,r);if(this.serviceAccountImpersonationUrl)this.cachedAccessToken=await this.getImpersonatedAccessToken(s.access_token);else if(s.expires_in)this.cachedAccessToken={access_token:s.access_token,expiry_date:new Date().getTime()+s.expires_in*1000,res:s.res};else this.cachedAccessToken={access_token:s.access_token,res:s.res};return this.credentials={},Object.assign(this.credentials,this.cachedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedAccessToken.expiry_date,access_token:this.cachedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedAccessToken}getProjectNumber(e){let t=e.match(/\/projects\/([^/]+)/);if(!t)return null;return t[1]}async getImpersonatedAccessToken(e){let t={...tr.RETRY_CONFIG,url:this.serviceAccountImpersonationUrl,method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},data:{scope:this.getScopesArray(),lifetime:this.serviceAccountImpersonationLifetime+"s"},responseType:"json"};yn.AuthClient.setMethodName(t,"getImpersonatedAccessToken");let r=await this.transporter.request(t),n=r.data;return{access_token:n.accessToken,expiry_date:new Date(n.expireTime).getTime(),res:r}}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}getScopesArray(){if(typeof this.scopes==="string")return[this.scopes];return this.scopes||[mn]}getMetricsHeaderValue(){let e=process.version.replace(/^v/,""),t=this.serviceAccountImpersonationUrl!==void 0,r=this.credentialSourceType?this.credentialSourceType:"unknown";return`gl-node/${e} auth/${_d.pkg.version} google-byoid-sdk source/${r} sa-impersonation/${t} config-lifetime/${this.configLifetimeRequested}`}getTokenUrl(){return this.tokenUrl}}La.BaseExternalAccountClient=tr});var Ka=w(function(Ha){Object.defineProperty(Ha,"__esModule",{value:!0});Ha.FileSubjectTokenSupplier=void 0;var wn=G("util"),Tn=G("fs"),Sd=wn.promisify(Tn.readFile??(()=>{})),Cd=wn.promisify(Tn.realpath??(()=>{})),Od=wn.promisify(Tn.lstat??(()=>{}));class Ba{filePath;formatType;subjectTokenFieldName;constructor(e){this.filePath=e.filePath,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName}async getSubjectToken(){let e=this.filePath;try{if(e=await Cd(e),!(await Od(e)).isFile())throw Error()}catch(n){if(n instanceof Error)n.message=`The file at ${e} does not exist, or it is not a file. ${n.message}`;throw n}let t,r=await Sd(e,{encoding:"utf8"});if(this.formatType==="text")t=r;else if(this.formatType==="json"&&this.subjectTokenFieldName)t=JSON.parse(r)[this.subjectTokenFieldName];if(!t)throw Error("Unable to parse the subject_token from the credential_source file");return t}}Ha.FileSubjectTokenSupplier=Ba});var Ya=w(function(Va){Object.defineProperty(Va,"__esModule",{value:!0});Va.UrlSubjectTokenSupplier=void 0;var kd=_e();class Ja{url;headers;formatType;subjectTokenFieldName;additionalGaxiosOptions;constructor(e){this.url=e.url,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName,this.headers=e.headers,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getSubjectToken(e){let t={...this.additionalGaxiosOptions,url:this.url,method:"GET",headers:this.headers,responseType:this.formatType};kd.AuthClient.setMethodName(t,"getSubjectToken");let r;if(this.formatType==="text")r=(await e.transporter.request(t)).data;else if(this.formatType==="json"&&this.subjectTokenFieldName)r=(await e.transporter.request(t)).data[this.subjectTokenFieldName];if(!r)throw Error("Unable to parse the subject_token from the credential_source URL");return r}}Va.UrlSubjectTokenSupplier=Ja});var Za=w(function(Xa){Object.defineProperty(Xa,"__esModule",{value:!0});Xa.CertificateSubjectTokenSupplier=Xa.InvalidConfigurationError=Xa.CertificateSourceUnavailableError=Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE=void 0;var nr=Oe(),rr=G("fs"),sr=G("crypto"),bd=G("https");Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE="GOOGLE_API_CERTIFICATE_CONFIG";class Fe extends Error{constructor(e){super(e);this.name="CertificateSourceUnavailableError"}}Xa.CertificateSourceUnavailableError=Fe;class xe extends Error{constructor(e){super(e);this.name="InvalidConfigurationError"}}Xa.InvalidConfigurationError=xe;class za{certificateConfigPath;trustChainPath;cert;key;constructor(e){if(!e.useDefaultCertificateConfig&&!e.certificateConfigLocation)throw new xe("Either `useDefaultCertificateConfig` must be true or a `certificateConfigLocation` must be provided.");if(e.useDefaultCertificateConfig&&e.certificateConfigLocation)throw new xe("Both `useDefaultCertificateConfig` and `certificateConfigLocation` cannot be provided.");this.trustChainPath=e.trustChainPath,this.certificateConfigPath=e.certificateConfigLocation??""}async createMtlsHttpsAgent(){if(!this.key||!this.cert)throw new xe("Cannot create mTLS Agent with missing certificate or key");return new bd.Agent({key:this.key,cert:this.cert})}async getSubjectToken(){this.certificateConfigPath=await this.#e();let{certPath:e,keyPath:t}=await this.#t();return{cert:this.cert,key:this.key}=await this.#r(e,t),await this.#n(this.cert)}async#e(){let e=this.certificateConfigPath;if(e){if(await nr.isValidFile(e))return e;throw new Fe(`Provided certificate config path is invalid: ${e}`)}let t=process.env[Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE];if(t){if(await nr.isValidFile(t))return t;throw new Fe(`Path from environment variable "${Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" is invalid: ${t}`)}let r=nr.getWellKnownCertificateConfigFileLocation();if(await nr.isValidFile(r))return r;throw new Fe(`Could not find certificate configuration file. Searched override path, the "${Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" env var, and the gcloud path (${r}).`)}async#t(){let e=this.certificateConfigPath,t;try{t=await rr.promises.readFile(e,"utf8")}catch(r){throw new Fe(`Failed to read certificate config file at: ${e}`)}try{let r=JSON.parse(t),n=r?.cert_configs?.workload?.cert_path,s=r?.cert_configs?.workload?.key_path;if(!n||!s)throw new xe(`Certificate config file (${e}) is missing required "cert_path" or "key_path" in the workload config.`);return{certPath:n,keyPath:s}}catch(r){if(r instanceof xe)throw r;throw new xe(`Failed to parse certificate config from ${e}: ${r.message}`)}}async#r(e,t){let r,n;try{r=await rr.promises.readFile(e),new sr.X509Certificate(r)}catch(s){let i=s instanceof Error?s.message:String(s);throw new Fe(`Failed to read certificate file at ${e}: ${i}`)}try{n=await rr.promises.readFile(t),sr.createPrivateKey(n)}catch(s){let i=s instanceof Error?s.message:String(s);throw new Fe(`Failed to read private key file at ${t}: ${i}`)}return{cert:r,key:n}}async#n(e){let t=new sr.X509Certificate(e);if(!this.trustChainPath)return JSON.stringify([t.raw.toString("base64")]);try{let s=((await rr.promises.readFile(this.trustChainPath,"utf8")).match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g)??[]).map((h,y)=>{try{return new sr.X509Certificate(h)}catch(S){let A=S instanceof Error?S.message:String(S);throw new xe(`Failed to parse certificate at index ${y} in trust chain file ${this.trustChainPath}: ${A}`)}}),i=s.findIndex((h)=>t.raw.equals(h.raw)),u;if(i===-1)u=[t,...s];else if(i===0)u=s;else throw new xe(`Leaf certificate exists in the trust chain but is not the first entry (found at index ${i}).`);return JSON.stringify(u.map((h)=>h.raw.toString("base64")))}catch(r){if(r instanceof xe)throw r;let n=r instanceof Error?r.message:String(r);throw new Fe(`Failed to process certificate chain from ${this.trustChainPath}: ${n}`)}}}Xa.CertificateSubjectTokenSupplier=za});var Sn=w(function(rc){Object.defineProperty(rc,"__esModule",{value:!0});rc.IdentityPoolClient=void 0;var Nd=$e(),An=Oe(),Pd=Ka(),Id=Ya(),ec=Za(),jd=er(),tc=ie();class vn extends Nd.BaseExternalAccountClient{subjectTokenSupplier;constructor(e){super(e);let t=An.originalOrCamelOptions(e),r=t.get("credential_source"),n=t.get("subject_token_supplier");if(!r&&!n)throw Error("A credential source or subject token supplier must be specified.");if(r&&n)throw Error("Only one of credential source or subject token supplier can be specified.");if(n)this.subjectTokenSupplier=n,this.credentialSourceType="programmatic";else{let s=An.originalOrCamelOptions(r),i=An.originalOrCamelOptions(s.get("format")),u=i.get("type")||"text",h=i.get("subject_token_field_name");if(u!=="json"&&u!=="text")throw Error(`Invalid credential_source format "${u}"`);if(u==="json"&&!h)throw Error("Missing subject_token_field_name for JSON credential_source format");let y=s.get("file"),S=s.get("url"),A=s.get("certificate"),k=s.get("headers");if(y&&S||S&&A||y&&A)throw Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.');else if(y)this.credentialSourceType="file",this.subjectTokenSupplier=new Pd.FileSubjectTokenSupplier({filePath:y,formatType:u,subjectTokenFieldName:h});else if(S)this.credentialSourceType="url",this.subjectTokenSupplier=new Id.UrlSubjectTokenSupplier({url:S,formatType:u,subjectTokenFieldName:h,headers:k,additionalGaxiosOptions:vn.RETRY_CONFIG});else if(A){this.credentialSourceType="certificate";let N=new ec.CertificateSubjectTokenSupplier({useDefaultCertificateConfig:A.use_default_certificate_config,certificateConfigLocation:A.certificate_config_location,trustChainPath:A.trust_chain_path});this.subjectTokenSupplier=N}else throw Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.')}}async retrieveSubjectToken(){let e=await this.subjectTokenSupplier.getSubjectToken(this.supplierContext);if(this.subjectTokenSupplier instanceof ec.CertificateSubjectTokenSupplier){let t=await this.subjectTokenSupplier.createMtlsHttpsAgent();this.stsCredential=new jd.StsCredentials({tokenExchangeEndpoint:this.getTokenUrl(),clientAuthentication:this.clientAuth,transporter:new tc.Gaxios({agent:t})}),this.transporter=new tc.Gaxios({...this.transporter.defaults||{},agent:t})}return e}}rc.IdentityPoolClient=vn});var Cn=w(function(ac){Object.defineProperty(ac,"__esModule",{value:!0});ac.AwsRequestSigner=void 0;var or=ie(),ic=mt(),sc="AWS4-HMAC-SHA256",Dd="aws4_request";class oc{getCredentials;region;crypto;constructor(e,t){this.getCredentials=e,this.region=t,this.crypto=ic.createCrypto()}async getRequestOptions(e){if(!e.url)throw RangeError('"url" is required in "amzOptions"');let t=typeof e.data==="object"?JSON.stringify(e.data):e.data,r=e.url,n=e.method||"GET",s=e.body||t,i=e.headers,u=await this.getCredentials(),h=new URL(r);if(typeof s!=="string"&&s!==void 0)throw TypeError(`'requestPayload' is expected to be a string if provided. Got: ${s}`);let y=await qd({crypto:this.crypto,host:h.host,canonicalUri:h.pathname,canonicalQuerystring:h.search.slice(1),method:n,region:this.region,securityCredentials:u,requestPayload:s,additionalAmzHeaders:i}),S=or.Gaxios.mergeHeaders(y.amzDate?{"x-amz-date":y.amzDate}:{},{authorization:y.authorizationHeader,host:h.host},i||{});if(u.token)or.Gaxios.mergeHeaders(S,{"x-amz-security-token":u.token});let A={url:r,method:n,headers:S};if(s!==void 0)A.body=s;return A}}ac.AwsRequestSigner=oc;async function kt(e,t,r){return await e.signWithHmacSha256(t,r)}async function Ud(e,t,r,n,s){let i=await kt(e,`AWS4${t}`,r),u=await kt(e,i,n),h=await kt(e,u,s);return await kt(e,h,"aws4_request")}async function qd(e){let t=or.Gaxios.mergeHeaders(e.additionalAmzHeaders),r=e.requestPayload||"",n=e.host.split(".")[0],s=new Date,i=s.toISOString().replace(/[-:]/g,"").replace(/\.[0-9]+/,""),u=s.toISOString().replace(/[-]/g,"").replace(/T.*/,"");if(e.securityCredentials.token)t.set("x-amz-security-token",e.securityCredentials.token);let h=or.Gaxios.mergeHeaders({host:e.host},t.has("date")?{}:{"x-amz-date":i},t),y="",S=[...h.keys()].sort();S.forEach((H)=>{y+=`${H}:${h.get(H)}
16
+ "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".`,St="secret must be a string or buffer",it="key must be a string or a buffer",Kh="key must be a string, a buffer or an object",en=typeof ve.createPublicKey==="function";if(en)it+=" or a KeyObject",St+="or a KeyObject";function Co(e){if(ot.isBuffer(e))return;if(typeof e==="string")return;if(!en)throw be(it);if(typeof e!=="object")throw be(it);if(typeof e.type!=="string")throw be(it);if(typeof e.asymmetricKeyType!=="string")throw be(it);if(typeof e.export!=="function")throw be(it)}function Oo(e){if(ot.isBuffer(e))return;if(typeof e==="string")return;if(typeof e==="object")return;throw be(Kh)}function Jh(e){if(ot.isBuffer(e))return;if(typeof e==="string")return e;if(!en)throw be(St);if(typeof e!=="object")throw be(St);if(e.type!=="secret")throw be(St);if(typeof e.export!=="function")throw be(St)}function tn(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function ko(e){e=e.toString();var t=4-e.length%4;if(t!==4)for(var r=0;r<t;++r)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function be(e){var t=[].slice.call(arguments,1),r=vo.format.bind(vo,e).apply(null,t);return TypeError(r)}function Vh(e){return ot.isBuffer(e)||typeof e==="string"}function Ct(e){if(!Vh(e))e=JSON.stringify(e);return e}function bo(e){return function(r,n){Jh(n),r=Ct(r);var s=ve.createHmac("sha"+e,n),i=(s.update(r),s.digest("base64"));return tn(i)}}var Zr,Wh="timingSafeEqual"in ve?function(t,r){if(t.byteLength!==r.byteLength)return!1;return ve.timingSafeEqual(t,r)}:function(t,r){if(!Zr)Zr=Ao();return Zr(t,r)};function Yh(e){return function(r,n,s){var i=bo(e)(r,s);return Wh(ot.from(n),ot.from(i))}}function xo(e){return function(r,n){Oo(n),r=Ct(r);var s=ve.createSign("RSA-SHA"+e),i=(s.update(r),s.sign(n,"base64"));return tn(i)}}function Ro(e){return function(r,n,s){Co(s),r=Ct(r),n=ko(n);var i=ve.createVerify("RSA-SHA"+e);return i.update(r),i.verify(s,n,"base64")}}function zh(e){return function(r,n){Oo(n),r=Ct(r);var s=ve.createSign("RSA-SHA"+e),i=(s.update(r),s.sign({key:n,padding:ve.constants.RSA_PKCS1_PSS_PADDING,saltLength:ve.constants.RSA_PSS_SALTLEN_DIGEST},"base64"));return tn(i)}}function Xh(e){return function(r,n,s){Co(s),r=Ct(r),n=ko(n);var i=ve.createVerify("RSA-SHA"+e);return i.update(r),i.verify({key:s,padding:ve.constants.RSA_PKCS1_PSS_PADDING,saltLength:ve.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function Qh(e){var t=xo(e);return function(){var n=t.apply(null,arguments);return n=So.derToJose(n,"ES"+e),n}}function Zh(e){var t=Ro(e);return function(n,s,i){s=So.joseToDer(s,"ES"+e).toString("base64");var u=t(n,s,i);return u}}function ef(){return function(){return""}}function tf(){return function(t,r){return r===""}}No.exports=function(t){var r={hs:bo,rs:xo,ps:zh,es:Qh,none:ef},n={hs:Yh,rs:Ro,ps:Xh,es:Zh,none:tf},s=t.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!s)throw be($h,t);var i=(s[1]||s[3]).toLowerCase(),u=s[2];return{sign:r[i](u),verify:n[i](u)}}});var nn=w(function(Mg,Po){var rf=G("buffer").Buffer;Po.exports=function(t){if(typeof t==="string")return t;if(typeof t==="number"||rf.isBuffer(t))return t.toString();return JSON.stringify(t)}});var Fo=w(function(Lg,qo){var nf=nt().Buffer,Io=Xr(),sf=rn(),of=G("stream"),jo=nn(),sn=G("util");function Do(e,t){return nf.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function af(e,t,r){r=r||"utf8";var n=Do(jo(e),"binary"),s=Do(jo(t),r);return sn.format("%s.%s",n,s)}function Uo(e){var{header:t,payload:r}=e,n=e.secret||e.privateKey,s=e.encoding,i=sf(t.alg),u=af(t,r,s),h=i.sign(u,n);return sn.format("%s.%s",u,h)}function Yt(e){var t=e.secret;if(t=t==null?e.privateKey:t,t=t==null?e.key:t,/^hs/i.test(e.header.alg)===!0&&t==null)throw TypeError("secret must be a string or buffer or a KeyObject");var r=new Io(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=r,this.payload=new Io(e.payload),this.secret.once("close",function(){if(!this.payload.writable&&this.readable)this.sign()}.bind(this)),this.payload.once("close",function(){if(!this.secret.writable&&this.readable)this.sign()}.bind(this))}sn.inherits(Yt,of);Yt.prototype.sign=function(){try{var t=Uo({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",t),this.emit("data",t),this.emit("end"),this.readable=!1,t}catch(r){this.readable=!1,this.emit("error",r),this.emit("close")}};Yt.sign=Uo;qo.exports=Yt});var Wo=w(function(Gg,Vo){var Lo=nt().Buffer,Mo=Xr(),cf=rn(),uf=G("stream"),Go=nn(),lf=G("util"),hf=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function ff(e){return Object.prototype.toString.call(e)==="[object Object]"}function df(e){if(ff(e))return e;try{return JSON.parse(e)}catch(t){return}}function Bo(e){var t=e.split(".",1)[0];return df(Lo.from(t,"base64").toString("binary"))}function pf(e){return e.split(".",2).join(".")}function Ho(e){return e.split(".")[2]}function gf(e,t){t=t||"utf8";var r=e.split(".")[1];return Lo.from(r,"base64").toString(t)}function $o(e){return hf.test(e)&&!!Bo(e)}function Ko(e,t,r){if(!t){var n=Error("Missing algorithm parameter for jws.verify");throw n.code="MISSING_ALGORITHM",n}e=Go(e);var s=Ho(e),i=pf(e),u=cf(t);return u.verify(i,s,r)}function Jo(e,t){if(t=t||{},e=Go(e),!$o(e))return null;var r=Bo(e);if(!r)return null;var n=gf(e);if(r.typ==="JWT"||t.json)n=JSON.parse(n,t.encoding);return{header:r,payload:n,signature:Ho(e)}}function at(e){e=e||{};var t=e.secret;if(t=t==null?e.publicKey:t,t=t==null?e.key:t,/^hs/i.test(e.algorithm)===!0&&t==null)throw TypeError("secret must be a string or buffer or a KeyObject");var r=new Mo(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=r,this.signature=new Mo(e.signature),this.secret.once("close",function(){if(!this.signature.writable&&this.readable)this.verify()}.bind(this)),this.signature.once("close",function(){if(!this.secret.writable&&this.readable)this.verify()}.bind(this))}lf.inherits(at,uf);at.prototype.verify=function(){try{var t=Ko(this.signature.buffer,this.algorithm,this.key.buffer),r=Jo(this.signature.buffer,this.encoding);return this.emit("done",t,r),this.emit("data",t),this.emit("end"),this.readable=!1,t}catch(n){this.readable=!1,this.emit("error",n),this.emit("close")}};at.decode=Jo;at.isValid=$o;at.verify=Ko;Vo.exports=at});var on=w(function(yf){var Yo=Fo(),zt=Wo(),_f=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"];yf.ALGORITHMS=_f;yf.sign=Yo.sign;yf.verify=zt.verify;yf.decode=zt.decode;yf.isValid=zt.isValid;yf.createSign=function(t){return new Yo(t)};yf.createVerify=function(t){return new zt(t)}});var Qo=w(function(Xo){Object.defineProperty(Xo,"__esModule",{value:!0});Xo.buildPayloadForJwsSign=zo;Xo.getJwsSign=bf;var Cf=on(),Of="RS256",kf="https://oauth2.googleapis.com/token";function zo(e){let t=Math.floor(new Date().getTime()/1000);return{iss:e.iss,scope:e.scope,aud:kf,exp:t+3600,iat:t,sub:e.sub,...e.additionalClaims}}function bf(e){let t=zo(e);return Cf.sign({header:{alg:Of},payload:t,secret:e.key})}});var ea=w(function(Zo){Object.defineProperty(Zo,"__esModule",{value:!0});Zo.getToken=Df;var Nf=Qo(),Pf="https://oauth2.googleapis.com/token",If="urn:ietf:params:oauth:grant-type:jwt-bearer",jf=(e)=>({method:"POST",url:Pf,data:new URLSearchParams({grant_type:If,assertion:Nf.getJwsSign(e)}),responseType:"json",retryConfig:{httpMethodsToRetry:["POST"]}});async function Df(e){if(!e.transporter)throw Error("No transporter set.");try{let t=jf(e);return(await e.transporter.request(t)).data}catch(t){let r=t,n=r.response?.data;if(n?.error)r.message=`${n.error}: ${n.error_description}`;throw r}}});var sa=w(function(ra){Object.defineProperty(ra,"__esModule",{value:!0});ra.ErrorWithCode=void 0;class ta extends Error{code;constructor(e,t){super(e);this.code=t}}ra.ErrorWithCode=ta});var an=w(function(ha){Object.defineProperty(ha,"__esModule",{value:!0});ha.getCredentials=Mf;var qf=G("path"),ia=G("fs"),Ff=G("util"),Xt=sa(),oa=ia.readFile?Ff.promisify(ia.readFile):async()=>{throw new Xt.ErrorWithCode("use key rather than keyFile.","MISSING_CREDENTIALS")},He;(function(e){e.JSON=".json",e.DER=".der",e.CRT=".crt",e.PEM=".pem",e.P12=".p12",e.PFX=".pfx"})(He||(He={}));class aa{keyFilePath;constructor(e){this.keyFilePath=e}async getCredentials(){let e=await oa(this.keyFilePath,"utf8"),t;try{t=JSON.parse(e)}catch(s){throw Error(`Invalid JSON key file: ${s.message}`)}let r=t.private_key,n=t.client_email;if(!r||!n)throw new Xt.ErrorWithCode("private_key and client_email are required.","MISSING_CREDENTIALS");return{privateKey:r,clientEmail:n}}}class ca{keyFilePath;constructor(e){this.keyFilePath=e}async getCredentials(){return{privateKey:await oa(this.keyFilePath,"utf8")}}}class ua{async getCredentials(){throw new Xt.ErrorWithCode("*.p12 certificates are not supported after v6.1.2. Consider utilizing *.json format or converting *.p12 to *.pem using the OpenSSL CLI.","UNKNOWN_CERTIFICATE_TYPE")}}class la{static create(e){switch(qf.extname(e)){case He.JSON:return new aa(e);case He.DER:case He.CRT:case He.PEM:return new ca(e);case He.P12:case He.PFX:return new ua;default:throw new Xt.ErrorWithCode("Unknown certificate type. Type is determined based on file extension. Current supported extensions are *.json, and *.pem.","UNKNOWN_CERTIFICATE_TYPE")}}}async function Mf(e){return la.create(e).getCredentials()}});var ga=w(function(da){Object.defineProperty(da,"__esModule",{value:!0});da.TokenHandler=void 0;var Gf=ea(),Bf=an();class fa{token;tokenExpiresAt;inFlightRequest;tokenOptions;constructor(e){this.tokenOptions=e}async processCredentials(){if(!this.tokenOptions.key&&!this.tokenOptions.keyFile)throw Error("No key or keyFile set.");if(!this.tokenOptions.key&&this.tokenOptions.keyFile){let e=await Bf.getCredentials(this.tokenOptions.keyFile);this.tokenOptions.key=e.privateKey,this.tokenOptions.email=e.clientEmail}}isTokenExpiring(){if(!this.token||!this.tokenExpiresAt)return!0;let e=new Date().getTime(),t=this.tokenOptions.eagerRefreshThresholdMillis??0;return this.tokenExpiresAt<=e+t}hasExpired(){let e=new Date().getTime();if(this.token&&this.tokenExpiresAt)return new Date().getTime()>=this.tokenExpiresAt;return!0}async getToken(e){if(await this.processCredentials(),this.inFlightRequest&&!e)return this.inFlightRequest;if(this.token&&!this.isTokenExpiring()&&!e)return this.token;try{this.inFlightRequest=Gf.getToken(this.tokenOptions);let t=await this.inFlightRequest;return this.token=t,this.tokenExpiresAt=new Date().getTime()+(t.expires_in??0)*1000,t}finally{this.inFlightRequest=void 0}}}da.TokenHandler=fa});var ya=w(function(_a){Object.defineProperty(_a,"__esModule",{value:!0});_a.revokeToken=Kf;var Hf="https://oauth2.googleapis.com/revoke?token=",$f=!0;async function Kf(e,t){let r=Hf+e;return await t.request({url:r,retry:$f})}});var cn=w(function(wa){Object.defineProperty(wa,"__esModule",{value:!0});wa.GoogleToken=void 0;var Vf=ie(),ma=ga(),Wf=ya();class Ea{tokenOptions;tokenHandler;constructor(e){if(this.tokenOptions=e||{},this.tokenOptions.transporter=this.tokenOptions.transporter||{request:(t)=>Vf.request(t)},!this.tokenOptions.iss)this.tokenOptions.iss=this.tokenOptions.email;if(typeof this.tokenOptions.scope==="object")this.tokenOptions.scope=this.tokenOptions.scope.join(" ");this.tokenHandler=new ma.TokenHandler(this.tokenOptions)}get expiresAt(){return this.tokenHandler.tokenExpiresAt}get accessToken(){return this.tokenHandler.token?.access_token}get idToken(){return this.tokenHandler.token?.id_token}get tokenType(){return this.tokenHandler.token?.token_type}get refreshToken(){return this.tokenHandler.token?.refresh_token}hasExpired(){return this.tokenHandler.hasExpired()}isTokenExpiring(){return this.tokenHandler.isTokenExpiring()}getToken(e,t={forceRefresh:!1}){let r;if(typeof e==="function")r=e;else if(typeof e==="object")t=e;let n=this.tokenHandler.getToken(t.forceRefresh??!1);if(r)n.then((s)=>r(null,s),r);return n}revokeToken(e){if(!this.accessToken)return Promise.reject(Error("No token to revoke."));let t=Wf.revokeToken(this.accessToken,this.tokenOptions.transporter);if(e)t.then(()=>e(),e);this.tokenHandler=new ma.TokenHandler(this.tokenOptions)}get googleTokenOptions(){return this.tokenOptions}}wa.GoogleToken=Ea});var ln=w(function(va){Object.defineProperty(va,"__esModule",{value:!0});va.JWTAccess=void 0;var Yf=on(),zf=Oe(),Aa={alg:"RS256",typ:"JWT"};class un{email;key;keyId;projectId;eagerRefreshThresholdMillis;cache=new zf.LRUCache({capacity:500,maxAge:3600000});constructor(e,t,r,n){this.email=e,this.key=t,this.keyId=r,this.eagerRefreshThresholdMillis=n??300000}getCachedKey(e,t){let r=e;if(t&&Array.isArray(t)&&t.length)r=e?`${e}_${t.join("_")}`:`${t.join("_")}`;else if(typeof t==="string")r=e?`${e}_${t}`:t;if(!r)throw Error("Scopes or url must be provided");return r}getRequestHeaders(e,t,r){let n=this.getCachedKey(e,r),s=this.cache.get(n),i=Date.now();if(s&&s.expiration-i>this.eagerRefreshThresholdMillis)return new Headers(s.headers);let u=Math.floor(Date.now()/1000),h=un.getExpirationTime(u),y;if(Array.isArray(r))r=r.join(" ");if(r)y={iss:this.email,sub:this.email,scope:r,exp:h,iat:u};else y={iss:this.email,sub:this.email,aud:e,exp:h,iat:u};if(t){for(let F in y)if(t[F])throw Error(`The '${F}' property is not allowed when passing additionalClaims. This claim is included in the JWT by default.`)}let S=this.keyId?{...Aa,kid:this.keyId}:Aa,A=Object.assign(y,t),k=Yf.sign({header:S,payload:A,secret:this.key}),N=new Headers({authorization:`Bearer ${k}`});return this.cache.set(n,{expiration:h*1000,headers:N}),N}static getExpirationTime(e){return e+3600}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the service account auth settings.");if(!e.client_email)throw Error("The incoming JSON object does not contain a client_email field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id}fromStream(e,t){if(t)this.fromStreamAsync(e).then(()=>t(),t);else return this.fromStreamAsync(e)}fromStreamAsync(e){return new Promise((t,r)=>{if(!e)r(Error("Must pass in a stream containing the service account auth settings."));let n="";e.setEncoding("utf8").on("data",(s)=>n+=s).on("error",r).on("end",()=>{try{let s=JSON.parse(n);this.fromJSON(s),t()}catch(s){r(s)}})})}}va.JWTAccess=un});var fn=w(function(Oa){Object.defineProperty(Oa,"__esModule",{value:!0});Oa.JWT=void 0;var Ca=cn(),Xf=an(),Qf=ln(),Zf=Be(),Qt=_e();class hn extends Zf.OAuth2Client{email;keyFile;key;keyId;defaultScopes;scopes;scope;subject;gtoken;additionalClaims;useJWTAccessWithScope;defaultServicePath;access;constructor(e={}){super(e);this.email=e.email,this.keyFile=e.keyFile,this.key=e.key,this.keyId=e.keyId,this.scopes=e.scopes,this.subject=e.subject,this.additionalClaims=e.additionalClaims,this.credentials={refresh_token:"jwt-placeholder",expiry_date:1}}createScoped(e){let t=new hn(this);return t.scopes=e,t}async getRequestMetadataAsync(e){e=this.defaultServicePath?`https://${this.defaultServicePath}/`:e;let t=!this.hasUserScopes()&&e||this.useJWTAccessWithScope&&this.hasAnyScopes()||this.universeDomain!==Qt.DEFAULT_UNIVERSE;if(this.subject&&this.universeDomain!==Qt.DEFAULT_UNIVERSE)throw RangeError(`Service Account user is configured for the credential. Domain-wide delegation is not supported in universes other than ${Qt.DEFAULT_UNIVERSE}`);if(!this.apiKey&&t)if(this.additionalClaims&&this.additionalClaims.target_audience){let{tokens:r}=await this.refreshToken();return{headers:this.addSharedMetadataHeaders(new Headers({authorization:`Bearer ${r.id_token}`}))}}else{if(!this.access)this.access=new Qf.JWTAccess(this.email,this.key,this.keyId,this.eagerRefreshThresholdMillis);let r;if(this.hasUserScopes())r=this.scopes;else if(!e)r=this.defaultScopes;let n=this.useJWTAccessWithScope||this.universeDomain!==Qt.DEFAULT_UNIVERSE,s=await this.access.getRequestHeaders(e??void 0,this.additionalClaims,n?r:void 0);return{headers:this.addSharedMetadataHeaders(s)}}else if(this.hasAnyScopes()||this.apiKey)return super.getRequestMetadataAsync(e);else return{headers:new Headers}}async fetchIdToken(e){let t=new Ca.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:{target_audience:e},transporter:this.transporter});if(await t.getToken({forceRefresh:!0}),!t.idToken)throw Error("Unknown error: Failed to fetch ID token");return t.idToken}hasUserScopes(){if(!this.scopes)return!1;return this.scopes.length>0}hasAnyScopes(){if(this.scopes&&this.scopes.length>0)return!0;if(this.defaultScopes&&this.defaultScopes.length>0)return!0;return!1}authorize(e){if(e)this.authorizeAsync().then((t)=>e(null,t),e);else return this.authorizeAsync()}async authorizeAsync(){let e=await this.refreshToken();if(!e)throw Error("No result returned");return this.credentials=e.tokens,this.credentials.refresh_token="jwt-placeholder",this.key=this.gtoken.googleTokenOptions?.key,this.email=this.gtoken.googleTokenOptions?.iss,e.tokens}async refreshTokenNoCache(){let e=this.createGToken(),r={access_token:(await e.getToken({forceRefresh:this.isTokenExpiring()})).access_token,token_type:"Bearer",expiry_date:e.expiresAt,id_token:e.idToken};return this.emit("tokens",r),{res:null,tokens:r}}createGToken(){if(!this.gtoken)this.gtoken=new Ca.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:this.additionalClaims,transporter:this.transporter});return this.gtoken}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the service account auth settings.");if(!e.client_email)throw Error("The incoming JSON object does not contain a client_email field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(t)this.fromStreamAsync(e).then(()=>t(),t);else return this.fromStreamAsync(e)}fromStreamAsync(e){return new Promise((t,r)=>{if(!e)throw Error("Must pass in a stream containing the service account auth settings.");let n="";e.setEncoding("utf8").on("error",r).on("data",(s)=>n+=s).on("end",()=>{try{let s=JSON.parse(n);this.fromJSON(s),t()}catch(s){r(s)}})})}fromAPIKey(e){if(typeof e!=="string")throw Error("Must provide an API Key string.");this.apiKey=e}async getCredentials(){if(this.key)return{private_key:this.key,client_email:this.email};else if(this.keyFile){let e=this.createGToken(),t=await Xf.getCredentials(this.keyFile);return{private_key:t.privateKey,client_email:t.clientEmail}}throw Error("A key or a keyFile must be provided to getCredentials.")}}Oa.JWT=hn});var dn=w(function(ba){Object.defineProperty(ba,"__esModule",{value:!0});ba.UserRefreshClient=ba.USER_REFRESH_ACCOUNT_TYPE=void 0;var ed=Be(),td=_e();ba.USER_REFRESH_ACCOUNT_TYPE="authorized_user";class Zt extends ed.OAuth2Client{_refreshToken;constructor(e,t,r,n,s){let i=e&&typeof e==="object"?e:{clientId:e,clientSecret:t,refreshToken:r,eagerRefreshThresholdMillis:n,forceRefreshOnFailure:s};super(i);this._refreshToken=i.refreshToken,this.credentials.refresh_token=i.refreshToken}async refreshTokenNoCache(){return super.refreshTokenNoCache(this._refreshToken)}async fetchIdToken(e){let t={...Zt.RETRY_CONFIG,url:this.endpoints.oauth2TokenUrl,method:"POST",data:new URLSearchParams({client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token",refresh_token:this._refreshToken,target_audience:e}),responseType:"json"};return td.AuthClient.setMethodName(t,"fetchIdToken"),(await this.transporter.request(t)).data.id_token}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the user refresh token");if(e.type!=="authorized_user")throw Error('The incoming JSON object does not have the "authorized_user" type');if(!e.client_id)throw Error("The incoming JSON object does not contain a client_id field");if(!e.client_secret)throw Error("The incoming JSON object does not contain a client_secret field");if(!e.refresh_token)throw Error("The incoming JSON object does not contain a refresh_token field");this._clientId=e.client_id,this._clientSecret=e.client_secret,this._refreshToken=e.refresh_token,this.credentials.refresh_token=e.refresh_token,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(t)this.fromStreamAsync(e).then(()=>t(),t);else return this.fromStreamAsync(e)}async fromStreamAsync(e){return new Promise((t,r)=>{if(!e)return r(Error("Must pass in a stream containing the user refresh token."));let n="";e.setEncoding("utf8").on("error",r).on("data",(s)=>n+=s).on("end",()=>{try{let s=JSON.parse(n);return this.fromJSON(s),t()}catch(s){return r(s)}})})}static fromJSON(e){let t=new Zt;return t.fromJSON(e),t}}ba.UserRefreshClient=Zt});var pn=w(function(Na){Object.defineProperty(Na,"__esModule",{value:!0});Na.Impersonated=Na.IMPERSONATED_ACCOUNT_TYPE=void 0;var Ra=Be(),nd=ie(),sd=Oe();Na.IMPERSONATED_ACCOUNT_TYPE="impersonated_service_account";class Ot extends Ra.OAuth2Client{sourceClient;targetPrincipal;targetScopes;delegates;lifetime;endpoint;constructor(e={}){super(e);if(this.credentials={expiry_date:1,refresh_token:"impersonated-placeholder"},this.sourceClient=e.sourceClient??new Ra.OAuth2Client,this.targetPrincipal=e.targetPrincipal??"",this.delegates=e.delegates??[],this.targetScopes=e.targetScopes??[],this.lifetime=e.lifetime??3600,!sd.originalOrCamelOptions(e).get("universe_domain"))this.universeDomain=this.sourceClient.universeDomain;else if(this.sourceClient.universeDomain!==this.universeDomain)throw RangeError(`Universe domain ${this.sourceClient.universeDomain} in source credentials does not match ${this.universeDomain} universe domain set for impersonated credentials.`);this.endpoint=e.endpoint??`https://iamcredentials.${this.universeDomain}`}async sign(e){await this.sourceClient.getAccessToken();let t=`projects/-/serviceAccounts/${this.targetPrincipal}`,r=`${this.endpoint}/v1/${t}:signBlob`,n={delegates:this.delegates,payload:Buffer.from(e).toString("base64")};return(await this.sourceClient.request({...Ot.RETRY_CONFIG,url:r,data:n,method:"POST"})).data}getTargetPrincipal(){return this.targetPrincipal}async refreshToken(){try{await this.sourceClient.getAccessToken();let e="projects/-/serviceAccounts/"+this.targetPrincipal,t=`${this.endpoint}/v1/${e}:generateAccessToken`,r={delegates:this.delegates,scope:this.targetScopes,lifetime:this.lifetime+"s"},n=await this.sourceClient.request({...Ot.RETRY_CONFIG,url:t,data:r,method:"POST"}),s=n.data;return this.credentials.access_token=s.accessToken,this.credentials.expiry_date=Date.parse(s.expireTime),{tokens:this.credentials,res:n}}catch(e){if(!(e instanceof Error))throw e;let t=0,r="";if(e instanceof nd.GaxiosError)t=e?.response?.data?.error?.status,r=e?.response?.data?.error?.message;if(t&&r)throw e.message=`${t}: unable to impersonate: ${r}`,e;else throw e.message=`unable to impersonate: ${e}`,e}}async fetchIdToken(e,t){await this.sourceClient.getAccessToken();let r=`projects/-/serviceAccounts/${this.targetPrincipal}`,n=`${this.endpoint}/v1/${r}:generateIdToken`,s={delegates:this.delegates,audience:e,includeEmail:t?.includeEmail??!0,useEmailAzp:t?.includeEmail??!0};return(await this.sourceClient.request({...Ot.RETRY_CONFIG,url:n,data:s,method:"POST"})).data.token}}Na.Impersonated=Ot});var gn=w(function(ja){Object.defineProperty(ja,"__esModule",{value:!0});ja.OAuthClientAuthHandler=void 0;ja.getErrorFromOAuthErrorResponse=cd;var ct=ie(),od=mt(),ad=["PUT","POST","PATCH"];class Ia{#e=od.createCrypto();#t;transporter;constructor(e){if(e&&"clientId"in e)this.#t=e,this.transporter=new ct.Gaxios;else this.#t=e?.clientAuthentication,this.transporter=e?.transporter||new ct.Gaxios}applyClientAuthenticationOptions(e,t){if(e.headers=ct.Gaxios.mergeHeaders(e.headers),this.injectAuthenticatedHeaders(e,t),!t)this.injectAuthenticatedRequestBody(e)}injectAuthenticatedHeaders(e,t){if(t)e.headers=ct.Gaxios.mergeHeaders(e.headers,{authorization:`Bearer ${t}`});else if(this.#t?.confidentialClientType==="basic"){e.headers=ct.Gaxios.mergeHeaders(e.headers);let r=this.#t.clientId,n=this.#t.clientSecret||"",s=this.#e.encodeBase64StringUtf8(`${r}:${n}`);ct.Gaxios.mergeHeaders(e.headers,{authorization:`Basic ${s}`})}}injectAuthenticatedRequestBody(e){if(this.#t?.confidentialClientType==="request-body"){let t=(e.method||"GET").toUpperCase();if(!ad.includes(t))throw Error(`${t} HTTP method does not support ${this.#t.confidentialClientType} client authentication`);let n=new Headers(e.headers).get("content-type");if(n?.startsWith("application/x-www-form-urlencoded")||e.data instanceof URLSearchParams){let s=new URLSearchParams(e.data??"");s.append("client_id",this.#t.clientId),s.append("client_secret",this.#t.clientSecret||""),e.data=s}else if(n?.startsWith("application/json"))e.data=e.data||{},Object.assign(e.data,{client_id:this.#t.clientId,client_secret:this.#t.clientSecret||""});else throw Error(`${n} content-types are not supported with ${this.#t.confidentialClientType} client authentication`)}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}ja.OAuthClientAuthHandler=Ia;function cd(e,t){let{error:r,error_description:n,error_uri:s}=e,i=`Error code ${r}`;if(typeof n<"u")i+=`: ${n}`;if(typeof s<"u")i+=` - ${s}`;let u=Error(i);if(t){let h=Object.keys(t);if(t.stack)h.push("stack");h.forEach((y)=>{if(y!=="message")Object.defineProperty(u,y,{value:t[y],writable:!1,enumerable:!0})})}return u}});var er=w(function(qa){Object.defineProperty(qa,"__esModule",{value:!0});qa.StsCredentials=void 0;var ld=ie(),hd=_e(),Ua=gn(),fd=Oe();class _n extends Ua.OAuthClientAuthHandler{#e;constructor(e={tokenExchangeEndpoint:""},t){if(typeof e!=="object"||e instanceof URL)e={tokenExchangeEndpoint:e,clientAuthentication:t};super(e);this.#e=e.tokenExchangeEndpoint}async exchangeToken(e,t,r){let n={grant_type:e.grantType,resource:e.resource,audience:e.audience,scope:e.scope?.join(" "),requested_token_type:e.requestedTokenType,subject_token:e.subjectToken,subject_token_type:e.subjectTokenType,actor_token:e.actingParty?.actorToken,actor_token_type:e.actingParty?.actorTokenType,options:r&&JSON.stringify(r)},s={..._n.RETRY_CONFIG,url:this.#e.toString(),method:"POST",headers:t,data:new URLSearchParams(fd.removeUndefinedValuesInObject(n)),responseType:"json"};hd.AuthClient.setMethodName(s,"exchangeToken"),this.applyClientAuthenticationOptions(s);try{let i=await this.transporter.request(s),u=i.data;return u.res=i,u}catch(i){if(i instanceof ld.GaxiosError&&i.response)throw Ua.getErrorFromOAuthErrorResponse(i.response.data,i);throw i}}}qa.StsCredentials=_n});var $e=w(function(La){Object.defineProperty(La,"__esModule",{value:!0});La.BaseExternalAccountClient=La.CLOUD_RESOURCE_MANAGER=La.EXTERNAL_ACCOUNT_TYPE=La.EXPIRATION_TIME_OFFSET=void 0;var dd=ie(),pd=G("stream"),yn=_e(),gd=er(),Ma=Oe(),_d=Br(),yd="urn:ietf:params:oauth:grant-type:token-exchange",md="urn:ietf:params:oauth:token-type:access_token",mn="https://www.googleapis.com/auth/cloud-platform",Ed=3600;La.EXPIRATION_TIME_OFFSET=300000;La.EXTERNAL_ACCOUNT_TYPE="external_account";La.CLOUD_RESOURCE_MANAGER="https://cloudresourcemanager.googleapis.com/v1/projects/";var wd="//iam\\.googleapis\\.com/locations/[^/]+/workforcePools/[^/]+/providers/.+",Td="https://sts.{universeDomain}/v1/token";class tr extends yn.AuthClient{scopes;projectNumber;audience;subjectTokenType;stsCredential;clientAuth;credentialSourceType;cachedAccessToken;serviceAccountImpersonationUrl;serviceAccountImpersonationLifetime;workforcePoolUserProject;configLifetimeRequested;tokenUrl;cloudResourceManagerURL;supplierContext;#e=null;constructor(e){super(e);let t=Ma.originalOrCamelOptions(e),r=t.get("type");if(r&&r!==La.EXTERNAL_ACCOUNT_TYPE)throw Error(`Expected "${La.EXTERNAL_ACCOUNT_TYPE}" type but received "${e.type}"`);let n=t.get("client_id"),s=t.get("client_secret");this.tokenUrl=t.get("token_url")??Td.replace("{universeDomain}",this.universeDomain);let i=t.get("subject_token_type"),u=t.get("workforce_pool_user_project"),h=t.get("service_account_impersonation_url"),y=t.get("service_account_impersonation"),S=Ma.originalOrCamelOptions(y).get("token_lifetime_seconds");if(this.cloudResourceManagerURL=new URL(t.get("cloud_resource_manager_url")||`https://cloudresourcemanager.${this.universeDomain}/v1/projects/`),n)this.clientAuth={confidentialClientType:"basic",clientId:n,clientSecret:s};this.stsCredential=new gd.StsCredentials({tokenExchangeEndpoint:this.tokenUrl,clientAuthentication:this.clientAuth}),this.scopes=t.get("scopes")||[mn],this.cachedAccessToken=null,this.audience=t.get("audience"),this.subjectTokenType=i,this.workforcePoolUserProject=u;let A=new RegExp(wd);if(this.workforcePoolUserProject&&!this.audience.match(A))throw Error("workforcePoolUserProject should not be set for non-workforce pool credentials.");if(this.serviceAccountImpersonationUrl=h,this.serviceAccountImpersonationLifetime=S,this.serviceAccountImpersonationLifetime)this.configLifetimeRequested=!0;else this.configLifetimeRequested=!1,this.serviceAccountImpersonationLifetime=Ed;this.projectNumber=this.getProjectNumber(this.audience),this.supplierContext={audience:this.audience,subjectTokenType:this.subjectTokenType,transporter:this.transporter}}getServiceAccountEmail(){if(this.serviceAccountImpersonationUrl){if(this.serviceAccountImpersonationUrl.length>256)throw RangeError(`URL is too long: ${this.serviceAccountImpersonationUrl}`);return/serviceAccounts\/(?<email>[^:]+):generateAccessToken$/.exec(this.serviceAccountImpersonationUrl)?.groups?.email||null}return null}setCredentials(e){super.setCredentials(e),this.cachedAccessToken=e}async getAccessToken(){if(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async getProjectId(){let e=this.projectNumber||this.workforcePoolUserProject;if(this.projectId)return this.projectId;else if(e){let t=await this.getRequestHeaders(),r={...tr.RETRY_CONFIG,headers:t,url:`${this.cloudResourceManagerURL.toString()}${e}`,responseType:"json"};yn.AuthClient.setMethodName(r,"getProjectId");let n=await this.transporter.request(r);return this.projectId=n.data.projectId,this.projectId}return null}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=dd.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof pd.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){this.#e=this.#e||this.#t();try{return await this.#e}finally{this.#e=null}}async#t(){let e=await this.retrieveSubjectToken(),t={grantType:yd,audience:this.audience,requestedTokenType:md,subjectToken:e,subjectTokenType:this.subjectTokenType,scope:this.serviceAccountImpersonationUrl?[mn]:this.getScopesArray()},r=!this.clientAuth&&this.workforcePoolUserProject?{userProject:this.workforcePoolUserProject}:void 0,n=new Headers({"x-goog-api-client":this.getMetricsHeaderValue()}),s=await this.stsCredential.exchangeToken(t,n,r);if(this.serviceAccountImpersonationUrl)this.cachedAccessToken=await this.getImpersonatedAccessToken(s.access_token);else if(s.expires_in)this.cachedAccessToken={access_token:s.access_token,expiry_date:new Date().getTime()+s.expires_in*1000,res:s.res};else this.cachedAccessToken={access_token:s.access_token,res:s.res};return this.credentials={},Object.assign(this.credentials,this.cachedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedAccessToken.expiry_date,access_token:this.cachedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedAccessToken}getProjectNumber(e){let t=e.match(/\/projects\/([^/]+)/);if(!t)return null;return t[1]}async getImpersonatedAccessToken(e){let t={...tr.RETRY_CONFIG,url:this.serviceAccountImpersonationUrl,method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},data:{scope:this.getScopesArray(),lifetime:this.serviceAccountImpersonationLifetime+"s"},responseType:"json"};yn.AuthClient.setMethodName(t,"getImpersonatedAccessToken");let r=await this.transporter.request(t),n=r.data;return{access_token:n.accessToken,expiry_date:new Date(n.expireTime).getTime(),res:r}}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}getScopesArray(){if(typeof this.scopes==="string")return[this.scopes];return this.scopes||[mn]}getMetricsHeaderValue(){let e=process.version.replace(/^v/,""),t=this.serviceAccountImpersonationUrl!==void 0,r=this.credentialSourceType?this.credentialSourceType:"unknown";return`gl-node/${e} auth/${_d.pkg.version} google-byoid-sdk source/${r} sa-impersonation/${t} config-lifetime/${this.configLifetimeRequested}`}getTokenUrl(){return this.tokenUrl}}La.BaseExternalAccountClient=tr});var Ka=w(function(Ha){Object.defineProperty(Ha,"__esModule",{value:!0});Ha.FileSubjectTokenSupplier=void 0;var wn=G("util"),Tn=G("fs"),Sd=wn.promisify(Tn.readFile??(()=>{})),Cd=wn.promisify(Tn.realpath??(()=>{})),Od=wn.promisify(Tn.lstat??(()=>{}));class Ba{filePath;formatType;subjectTokenFieldName;constructor(e){this.filePath=e.filePath,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName}async getSubjectToken(){let e=this.filePath;try{if(e=await Cd(e),!(await Od(e)).isFile())throw Error()}catch(n){if(n instanceof Error)n.message=`The file at ${e} does not exist, or it is not a file. ${n.message}`;throw n}let t,r=await Sd(e,{encoding:"utf8"});if(this.formatType==="text")t=r;else if(this.formatType==="json"&&this.subjectTokenFieldName)t=JSON.parse(r)[this.subjectTokenFieldName];if(!t)throw Error("Unable to parse the subject_token from the credential_source file");return t}}Ha.FileSubjectTokenSupplier=Ba});var Ya=w(function(Va){Object.defineProperty(Va,"__esModule",{value:!0});Va.UrlSubjectTokenSupplier=void 0;var kd=_e();class Ja{url;headers;formatType;subjectTokenFieldName;additionalGaxiosOptions;constructor(e){this.url=e.url,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName,this.headers=e.headers,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getSubjectToken(e){let t={...this.additionalGaxiosOptions,url:this.url,method:"GET",headers:this.headers,responseType:this.formatType};kd.AuthClient.setMethodName(t,"getSubjectToken");let r;if(this.formatType==="text")r=(await e.transporter.request(t)).data;else if(this.formatType==="json"&&this.subjectTokenFieldName)r=(await e.transporter.request(t)).data[this.subjectTokenFieldName];if(!r)throw Error("Unable to parse the subject_token from the credential_source URL");return r}}Va.UrlSubjectTokenSupplier=Ja});var Za=w(function(Xa){Object.defineProperty(Xa,"__esModule",{value:!0});Xa.CertificateSubjectTokenSupplier=Xa.InvalidConfigurationError=Xa.CertificateSourceUnavailableError=Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE=void 0;var nr=Oe(),rr=G("fs"),sr=G("crypto"),bd=G("https");Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE="GOOGLE_API_CERTIFICATE_CONFIG";class Fe extends Error{constructor(e){super(e);this.name="CertificateSourceUnavailableError"}}Xa.CertificateSourceUnavailableError=Fe;class xe extends Error{constructor(e){super(e);this.name="InvalidConfigurationError"}}Xa.InvalidConfigurationError=xe;class za{certificateConfigPath;trustChainPath;cert;key;constructor(e){if(!e.useDefaultCertificateConfig&&!e.certificateConfigLocation)throw new xe("Either `useDefaultCertificateConfig` must be true or a `certificateConfigLocation` must be provided.");if(e.useDefaultCertificateConfig&&e.certificateConfigLocation)throw new xe("Both `useDefaultCertificateConfig` and `certificateConfigLocation` cannot be provided.");this.trustChainPath=e.trustChainPath,this.certificateConfigPath=e.certificateConfigLocation??""}async createMtlsHttpsAgent(){if(!this.key||!this.cert)throw new xe("Cannot create mTLS Agent with missing certificate or key");return new bd.Agent({key:this.key,cert:this.cert})}async getSubjectToken(){this.certificateConfigPath=await this.#e();let{certPath:e,keyPath:t}=await this.#t();return{cert:this.cert,key:this.key}=await this.#r(e,t),await this.#n(this.cert)}async#e(){let e=this.certificateConfigPath;if(e){if(await nr.isValidFile(e))return e;throw new Fe(`Provided certificate config path is invalid: ${e}`)}let t=process.env[Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE];if(t){if(await nr.isValidFile(t))return t;throw new Fe(`Path from environment variable "${Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" is invalid: ${t}`)}let r=nr.getWellKnownCertificateConfigFileLocation();if(await nr.isValidFile(r))return r;throw new Fe(`Could not find certificate configuration file. Searched override path, the "${Xa.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" env var, and the gcloud path (${r}).`)}async#t(){let e=this.certificateConfigPath,t;try{t=await rr.promises.readFile(e,"utf8")}catch(r){throw new Fe(`Failed to read certificate config file at: ${e}`)}try{let r=JSON.parse(t),n=r?.cert_configs?.workload?.cert_path,s=r?.cert_configs?.workload?.key_path;if(!n||!s)throw new xe(`Certificate config file (${e}) is missing required "cert_path" or "key_path" in the workload config.`);return{certPath:n,keyPath:s}}catch(r){if(r instanceof xe)throw r;throw new xe(`Failed to parse certificate config from ${e}: ${r.message}`)}}async#r(e,t){let r,n;try{r=await rr.promises.readFile(e),new sr.X509Certificate(r)}catch(s){let i=s instanceof Error?s.message:String(s);throw new Fe(`Failed to read certificate file at ${e}: ${i}`)}try{n=await rr.promises.readFile(t),sr.createPrivateKey(n)}catch(s){let i=s instanceof Error?s.message:String(s);throw new Fe(`Failed to read private key file at ${t}: ${i}`)}return{cert:r,key:n}}async#n(e){let t=new sr.X509Certificate(e);if(!this.trustChainPath)return JSON.stringify([t.raw.toString("base64")]);try{let s=((await rr.promises.readFile(this.trustChainPath,"utf8")).match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g)??[]).map((h,y)=>{try{return new sr.X509Certificate(h)}catch(S){let A=S instanceof Error?S.message:String(S);throw new xe(`Failed to parse certificate at index ${y} in trust chain file ${this.trustChainPath}: ${A}`)}}),i=s.findIndex((h)=>t.raw.equals(h.raw)),u;if(i===-1)u=[t,...s];else if(i===0)u=s;else throw new xe(`Leaf certificate exists in the trust chain but is not the first entry (found at index ${i}).`);return JSON.stringify(u.map((h)=>h.raw.toString("base64")))}catch(r){if(r instanceof xe)throw r;let n=r instanceof Error?r.message:String(r);throw new Fe(`Failed to process certificate chain from ${this.trustChainPath}: ${n}`)}}}Xa.CertificateSubjectTokenSupplier=za});var Sn=w(function(rc){Object.defineProperty(rc,"__esModule",{value:!0});rc.IdentityPoolClient=void 0;var Nd=$e(),An=Oe(),Pd=Ka(),Id=Ya(),ec=Za(),jd=er(),tc=ie();class vn extends Nd.BaseExternalAccountClient{subjectTokenSupplier;constructor(e){super(e);let t=An.originalOrCamelOptions(e),r=t.get("credential_source"),n=t.get("subject_token_supplier");if(!r&&!n)throw Error("A credential source or subject token supplier must be specified.");if(r&&n)throw Error("Only one of credential source or subject token supplier can be specified.");if(n)this.subjectTokenSupplier=n,this.credentialSourceType="programmatic";else{let s=An.originalOrCamelOptions(r),i=An.originalOrCamelOptions(s.get("format")),u=i.get("type")||"text",h=i.get("subject_token_field_name");if(u!=="json"&&u!=="text")throw Error(`Invalid credential_source format "${u}"`);if(u==="json"&&!h)throw Error("Missing subject_token_field_name for JSON credential_source format");let y=s.get("file"),S=s.get("url"),A=s.get("certificate"),k=s.get("headers");if(y&&S||S&&A||y&&A)throw Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.');else if(y)this.credentialSourceType="file",this.subjectTokenSupplier=new Pd.FileSubjectTokenSupplier({filePath:y,formatType:u,subjectTokenFieldName:h});else if(S)this.credentialSourceType="url",this.subjectTokenSupplier=new Id.UrlSubjectTokenSupplier({url:S,formatType:u,subjectTokenFieldName:h,headers:k,additionalGaxiosOptions:vn.RETRY_CONFIG});else if(A){this.credentialSourceType="certificate";let N=new ec.CertificateSubjectTokenSupplier({useDefaultCertificateConfig:A.use_default_certificate_config,certificateConfigLocation:A.certificate_config_location,trustChainPath:A.trust_chain_path});this.subjectTokenSupplier=N}else throw Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.')}}async retrieveSubjectToken(){let e=await this.subjectTokenSupplier.getSubjectToken(this.supplierContext);if(this.subjectTokenSupplier instanceof ec.CertificateSubjectTokenSupplier){let t=await this.subjectTokenSupplier.createMtlsHttpsAgent();this.stsCredential=new jd.StsCredentials({tokenExchangeEndpoint:this.getTokenUrl(),clientAuthentication:this.clientAuth,transporter:new tc.Gaxios({agent:t})}),this.transporter=new tc.Gaxios({...this.transporter.defaults||{},agent:t})}return e}}rc.IdentityPoolClient=vn});var Cn=w(function(ac){Object.defineProperty(ac,"__esModule",{value:!0});ac.AwsRequestSigner=void 0;var or=ie(),ic=mt(),sc="AWS4-HMAC-SHA256",Dd="aws4_request";class oc{getCredentials;region;crypto;constructor(e,t){this.getCredentials=e,this.region=t,this.crypto=ic.createCrypto()}async getRequestOptions(e){if(!e.url)throw RangeError('"url" is required in "amzOptions"');let t=typeof e.data==="object"?JSON.stringify(e.data):e.data,r=e.url,n=e.method||"GET",s=e.body||t,i=e.headers,u=await this.getCredentials(),h=new URL(r);if(typeof s!=="string"&&s!==void 0)throw TypeError(`'requestPayload' is expected to be a string if provided. Got: ${s}`);let y=await qd({crypto:this.crypto,host:h.host,canonicalUri:h.pathname,canonicalQuerystring:h.search.slice(1),method:n,region:this.region,securityCredentials:u,requestPayload:s,additionalAmzHeaders:i}),S=or.Gaxios.mergeHeaders(y.amzDate?{"x-amz-date":y.amzDate}:{},{authorization:y.authorizationHeader,host:h.host},i||{});if(u.token)or.Gaxios.mergeHeaders(S,{"x-amz-security-token":u.token});let A={url:r,method:n,headers:S};if(s!==void 0)A.body=s;return A}}ac.AwsRequestSigner=oc;async function kt(e,t,r){return await e.signWithHmacSha256(t,r)}async function Ud(e,t,r,n,s){let i=await kt(e,`AWS4${t}`,r),u=await kt(e,i,n),h=await kt(e,u,s);return await kt(e,h,"aws4_request")}async function qd(e){let t=or.Gaxios.mergeHeaders(e.additionalAmzHeaders),r=e.requestPayload||"",n=e.host.split(".")[0],s=new Date,i=s.toISOString().replace(/[-:]/g,"").replace(/\.[0-9]+/,""),u=s.toISOString().replace(/[-]/g,"").replace(/T.*/,"");if(e.securityCredentials.token)t.set("x-amz-security-token",e.securityCredentials.token);let h=or.Gaxios.mergeHeaders({host:e.host},t.has("date")?{}:{"x-amz-date":i},t),y="",S=[...h.keys()].sort();S.forEach((K)=>{y+=`${K}:${h.get(K)}
17
17
  `});let A=S.join(";"),k=await e.crypto.sha256DigestHex(r),N=`${e.method.toUpperCase()}
18
18
  ${e.canonicalUri}
19
19
  ${e.canonicalQuerystring}
20
20
  ${y}
21
21
  ${A}
22
- ${k}`,F=`${u}/${e.region}/${n}/${Dd}`,V=`${sc}
22
+ ${k}`,F=`${u}/${e.region}/${n}/${Dd}`,W=`${sc}
23
23
  ${i}
24
24
  ${F}
25
- `+await e.crypto.sha256DigestHex(N),x=await Ud(e.crypto,e.securityCredentials.secretAccessKey,u,e.region,n),j=await kt(e.crypto,x,V),b=`${sc} Credential=${e.securityCredentials.accessKeyId}/${F}, SignedHeaders=${A}, Signature=${ic.fromArrayBufferToHex(j)}`;return{amzDate:t.has("date")?void 0:i,authorizationHeader:b,canonicalQuerystring:e.canonicalQuerystring}}});var dc=w(function(lc){Object.defineProperty(lc,"__esModule",{value:!0});lc.DefaultAwsSecurityCredentialsSupplier=void 0;var ar=_e();class uc{regionUrl;securityCredentialsUrl;imdsV2SessionTokenUrl;additionalGaxiosOptions;constructor(e){this.regionUrl=e.regionUrl,this.securityCredentialsUrl=e.securityCredentialsUrl,this.imdsV2SessionTokenUrl=e.imdsV2SessionTokenUrl,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getAwsRegion(e){if(this.#n)return this.#n;let t=new Headers;if(!this.#n&&this.imdsV2SessionTokenUrl)t.set("x-aws-ec2-metadata-token",await this.#e(e.transporter));if(!this.regionUrl)throw RangeError('Unable to determine AWS region due to missing "options.credential_source.region_url"');let r={...this.additionalGaxiosOptions,url:this.regionUrl,method:"GET",responseType:"text",headers:t};ar.AuthClient.setMethodName(r,"getAwsRegion");let n=await e.transporter.request(r);return n.data.substr(0,n.data.length-1)}async getAwsSecurityCredentials(e){if(this.#s)return this.#s;let t=new Headers;if(this.imdsV2SessionTokenUrl)t.set("x-aws-ec2-metadata-token",await this.#e(e.transporter));let r=await this.#t(t,e.transporter),n=await this.#r(r,t,e.transporter);return{accessKeyId:n.AccessKeyId,secretAccessKey:n.SecretAccessKey,token:n.Token}}async#e(e){let t={...this.additionalGaxiosOptions,url:this.imdsV2SessionTokenUrl,method:"PUT",responseType:"text",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"300"}};return ar.AuthClient.setMethodName(t,"#getImdsV2SessionToken"),(await e.request(t)).data}async#t(e,t){if(!this.securityCredentialsUrl)throw Error('Unable to determine AWS role name due to missing "options.credential_source.url"');let r={...this.additionalGaxiosOptions,url:this.securityCredentialsUrl,method:"GET",responseType:"text",headers:e};return ar.AuthClient.setMethodName(r,"#getAwsRoleName"),(await t.request(r)).data}async#r(e,t,r){let n={...this.additionalGaxiosOptions,url:`${this.securityCredentialsUrl}/${e}`,headers:t,responseType:"json"};return ar.AuthClient.setMethodName(n,"#retrieveAwsSecurityCredentials"),(await r.request(n)).data}get#n(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||null}get#s(){if(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY)return{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,token:process.env.AWS_SESSION_TOKEN};return null}}lc.DefaultAwsSecurityCredentialsSupplier=uc});var On=w(function(gc){Object.defineProperty(gc,"__esModule",{value:!0});gc.AwsClient=void 0;var Fd=Cn(),Md=$e(),Ld=dc(),pc=Oe(),Gd=ie();class cr extends Md.BaseExternalAccountClient{environmentId;awsSecurityCredentialsSupplier;regionalCredVerificationUrl;awsRequestSigner;region;static#e="https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15";static AWS_EC2_METADATA_IPV4_ADDRESS="169.254.169.254";static AWS_EC2_METADATA_IPV6_ADDRESS="fd00:ec2::254";constructor(e){super(e);let t=pc.originalOrCamelOptions(e),r=t.get("credential_source"),n=t.get("aws_security_credentials_supplier");if(!r&&!n)throw Error("A credential source or AWS security credentials supplier must be specified.");if(r&&n)throw Error("Only one of credential source or AWS security credentials supplier can be specified.");if(n)this.awsSecurityCredentialsSupplier=n,this.regionalCredVerificationUrl=cr.#e,this.credentialSourceType="programmatic";else{let s=pc.originalOrCamelOptions(r);this.environmentId=s.get("environment_id");let i=s.get("region_url"),u=s.get("url"),h=s.get("imdsv2_session_token_url");this.awsSecurityCredentialsSupplier=new Ld.DefaultAwsSecurityCredentialsSupplier({regionUrl:i,securityCredentialsUrl:u,imdsV2SessionTokenUrl:h}),this.regionalCredVerificationUrl=s.get("regional_cred_verification_url"),this.credentialSourceType="aws",this.validateEnvironmentId()}this.awsRequestSigner=null,this.region=""}validateEnvironmentId(){let e=this.environmentId?.match(/^(aws)(\d+)$/);if(!e||!this.regionalCredVerificationUrl)throw Error('No valid AWS "credential_source" provided');else if(parseInt(e[2],10)!==1)throw Error(`aws version "${e[2]}" is not supported in the current build.`)}async retrieveSubjectToken(){if(!this.awsRequestSigner)this.region=await this.awsSecurityCredentialsSupplier.getAwsRegion(this.supplierContext),this.awsRequestSigner=new Fd.AwsRequestSigner(async()=>this.awsSecurityCredentialsSupplier.getAwsSecurityCredentials(this.supplierContext),this.region);let e=await this.awsRequestSigner.getRequestOptions({...cr.RETRY_CONFIG,url:this.regionalCredVerificationUrl.replace("{region}",this.region),method:"POST"}),t=[];return Gd.Gaxios.mergeHeaders({"x-goog-cloud-target-resource":this.audience},e.headers).forEach((n,s)=>t.push({key:s,value:n})),encodeURIComponent(JSON.stringify({url:e.url,method:e.method,headers:t}))}}gc.AwsClient=cr});var jn=w(function(Ec){Object.defineProperty(Ec,"__esModule",{value:!0});Ec.InvalidSubjectTokenError=Ec.InvalidMessageFieldError=Ec.InvalidCodeFieldError=Ec.InvalidTokenTypeFieldError=Ec.InvalidExpirationTimeFieldError=Ec.InvalidSuccessFieldError=Ec.InvalidVersionFieldError=Ec.ExecutableResponseError=Ec.ExecutableResponse=void 0;var ur="urn:ietf:params:oauth:token-type:saml2",kn="urn:ietf:params:oauth:token-type:id_token",bn="urn:ietf:params:oauth:token-type:jwt";class yc{version;success;expirationTime;tokenType;errorCode;errorMessage;subjectToken;constructor(e){if(!e.version)throw new xn("Executable response must contain a 'version' field.");if(e.success===void 0)throw new Rn("Executable response must contain a 'success' field.");if(this.version=e.version,this.success=e.success,this.success){if(this.expirationTime=e.expiration_time,this.tokenType=e.token_type,this.tokenType!==ur&&this.tokenType!==kn&&this.tokenType!==bn)throw new Nn(`Executable response must contain a 'token_type' field when successful and it must be one of ${kn}, ${bn}, or ${ur}.`);if(this.tokenType===ur){if(!e.saml_response)throw new lr(`Executable response must contain a 'saml_response' field when token_type=${ur}.`);this.subjectToken=e.saml_response}else{if(!e.id_token)throw new lr(`Executable response must contain a 'id_token' field when token_type=${kn} or ${bn}.`);this.subjectToken=e.id_token}}else{if(!e.code)throw new Pn("Executable response must contain a 'code' field when unsuccessful.");if(!e.message)throw new In("Executable response must contain a 'message' field when unsuccessful.");this.errorCode=e.code,this.errorMessage=e.message}}isValid(){return!this.isExpired()&&this.success}isExpired(){return this.expirationTime!==void 0&&this.expirationTime<Math.round(Date.now()/1000)}}Ec.ExecutableResponse=yc;class Me extends Error{constructor(e){super(e);Object.setPrototypeOf(this,new.target.prototype)}}Ec.ExecutableResponseError=Me;class xn extends Me{}Ec.InvalidVersionFieldError=xn;class Rn extends Me{}Ec.InvalidSuccessFieldError=Rn;class mc extends Me{}Ec.InvalidExpirationTimeFieldError=mc;class Nn extends Me{}Ec.InvalidTokenTypeFieldError=Nn;class Pn extends Me{}Ec.InvalidCodeFieldError=Pn;class In extends Me{}Ec.InvalidMessageFieldError=In;class lr extends Me{}Ec.InvalidSubjectTokenError=lr});var Fn=w(function(Tc){Object.defineProperty(Tc,"__esModule",{value:!0});Tc.PluggableAuthHandler=Tc.ExecutableError=void 0;var Qe=jn(),zd=G("child_process"),Dn=G("fs");class Un extends Error{code;constructor(e,t){super(`The executable failed with exit code: ${t} and error message: ${e}.`);this.code=t,Object.setPrototypeOf(this,new.target.prototype)}}Tc.ExecutableError=Un;class qn{commandComponents;timeoutMillis;outputFile;constructor(e){if(!e.command)throw Error("No command provided.");if(this.commandComponents=qn.parseCommand(e.command),this.timeoutMillis=e.timeoutMillis,!this.timeoutMillis)throw Error("No timeoutMillis provided.");this.outputFile=e.outputFile}retrieveResponseFromExecutable(e){return new Promise((t,r)=>{let n=zd.spawn(this.commandComponents[0],this.commandComponents.slice(1),{env:{...process.env,...Object.fromEntries(e)}}),s="";n.stdout.on("data",(u)=>{s+=u}),n.stderr.on("data",(u)=>{s+=u});let i=setTimeout(()=>(n.removeAllListeners(),n.kill(),r(Error("The executable failed to finish within the timeout specified."))),this.timeoutMillis);n.on("close",(u)=>{if(clearTimeout(i),u===0)try{let h=JSON.parse(s),y=new Qe.ExecutableResponse(h);return t(y)}catch(h){if(h instanceof Qe.ExecutableResponseError)return r(h);return r(new Qe.ExecutableResponseError(`The executable returned an invalid response: ${s}`))}else return r(new Un(s,u.toString()))})})}async retrieveCachedResponse(){if(!this.outputFile||this.outputFile.length===0)return;let e;try{e=await Dn.promises.realpath(this.outputFile)}catch{return}if(!(await Dn.promises.lstat(e)).isFile())return;let t=await Dn.promises.readFile(e,{encoding:"utf8"});if(t==="")return;try{let r=JSON.parse(t);if(new Qe.ExecutableResponse(r).isValid())return new Qe.ExecutableResponse(r);return}catch(r){if(r instanceof Qe.ExecutableResponseError)throw r;throw new Qe.ExecutableResponseError(`The output file contained an invalid response: ${t}`)}}static parseCommand(e){let t=e.match(/(?:[^\s"]+|"[^"]*")+/g);if(!t)throw Error(`Provided command: "${e}" could not be parsed.`);for(let r=0;r<t.length;r++)if(t[r][0]==='"'&&t[r].slice(-1)==='"')t[r]=t[r].slice(1,-1);return t}}Tc.PluggableAuthHandler=qn});var Ln=w(function(Mn){Object.defineProperty(Mn,"__esModule",{value:!0});Mn.PluggableAuthClient=Mn.ExecutableError=void 0;var Qd=$e(),Zd=jn(),Oc=Fn(),ep=Fn();Object.defineProperty(Mn,"ExecutableError",{enumerable:!0,get:function(){return ep.ExecutableError}});var tp=30000,vc=5000,Sc=120000,rp="GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES",Cc=1;class kc extends Qd.BaseExternalAccountClient{command;timeoutMillis;outputFile;handler;constructor(e){super(e);if(!e.credential_source.executable)throw Error('No valid Pluggable Auth "credential_source" provided.');if(this.command=e.credential_source.executable.command,!this.command)throw Error('No valid Pluggable Auth "credential_source" provided.');if(e.credential_source.executable.timeout_millis===void 0)this.timeoutMillis=tp;else if(this.timeoutMillis=e.credential_source.executable.timeout_millis,this.timeoutMillis<vc||this.timeoutMillis>Sc)throw Error(`Timeout must be between ${vc} and ${Sc} milliseconds.`);this.outputFile=e.credential_source.executable.output_file,this.handler=new Oc.PluggableAuthHandler({command:this.command,timeoutMillis:this.timeoutMillis,outputFile:this.outputFile}),this.credentialSourceType="executable"}async retrieveSubjectToken(){if(process.env[rp]!=="1")throw Error("Pluggable Auth executables need to be explicitly allowed to run by setting the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment Variable to 1.");let e=void 0;if(this.outputFile)e=await this.handler.retrieveCachedResponse();if(!e){let t=new Map;if(t.set("GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE",this.audience),t.set("GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE",this.subjectTokenType),t.set("GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE","0"),this.outputFile)t.set("GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE",this.outputFile);let r=this.getServiceAccountEmail();if(r)t.set("GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL",r);e=await this.handler.retrieveResponseFromExecutable(t)}if(e.version>Cc)throw Error(`Version of executable is not currently supported, maximum supported version is ${Cc}.`);if(!e.success)throw new Oc.ExecutableError(e.errorMessage,e.errorCode);if(this.outputFile){if(!e.expirationTime)throw new Zd.InvalidExpirationTimeFieldError("The executable response must contain the `expiration_time` field for successful responses when an output_file has been specified in the configuration.")}if(e.isExpired())throw Error("Executable response is expired.");return e.subjectToken}}Mn.PluggableAuthClient=kc});var Gn=w(function(Rc){Object.defineProperty(Rc,"__esModule",{value:!0});Rc.ExternalAccountClient=void 0;var np=$e(),sp=Sn(),ip=On(),op=Ln();class xc{constructor(){throw Error("ExternalAccountClients should be initialized via: ExternalAccountClient.fromJSON(), directly via explicit constructors, eg. new AwsClient(options), new IdentityPoolClient(options), newPluggableAuthClientOptions, or via new GoogleAuth(options).getClient()")}static fromJSON(e){if(e&&e.type===np.EXTERNAL_ACCOUNT_TYPE)if(e.credential_source?.environment_id)return new ip.AwsClient(e);else if(e.credential_source?.executable)return new op.PluggableAuthClient(e);else return new sp.IdentityPoolClient(e);else return null}}Rc.ExternalAccountClient=xc});var Hn=w(function(Uc){Object.defineProperty(Uc,"__esModule",{value:!0});Uc.ExternalAccountAuthorizedUserClient=Uc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=void 0;var Pc=_e(),Ic=gn(),jc=ie(),ap=G("stream"),cp=$e();Uc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE="external_account_authorized_user";var up="https://sts.{universeDomain}/v1/oauthtoken";class Bn extends Ic.OAuthClientAuthHandler{#e;constructor(e){super(e);this.#e=e.tokenRefreshEndpoint}async refreshToken(e,t){let r={...Bn.RETRY_CONFIG,url:this.#e,method:"POST",headers:t,data:new URLSearchParams({grant_type:"refresh_token",refresh_token:e}),responseType:"json"};Pc.AuthClient.setMethodName(r,"refreshToken"),this.applyClientAuthenticationOptions(r);try{let n=await this.transporter.request(r),s=n.data;return s.res=n,s}catch(n){if(n instanceof jc.GaxiosError&&n.response)throw Ic.getErrorFromOAuthErrorResponse(n.response.data,n);throw n}}}class Dc extends Pc.AuthClient{cachedAccessToken;externalAccountAuthorizedUserHandler;refreshToken;constructor(e){super(e);if(e.universe_domain)this.universeDomain=e.universe_domain;this.refreshToken=e.refresh_token;let t={confidentialClientType:"basic",clientId:e.client_id,clientSecret:e.client_secret};if(this.externalAccountAuthorizedUserHandler=new Bn({tokenRefreshEndpoint:e.token_url??up.replace("{universeDomain}",this.universeDomain),transporter:this.transporter,clientAuthentication:t}),this.cachedAccessToken=null,this.quotaProjectId=e.quota_project_id,typeof e?.eagerRefreshThresholdMillis!=="number")this.eagerRefreshThresholdMillis=cp.EXPIRATION_TIME_OFFSET;else this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis;this.forceRefreshOnFailure=!!e?.forceRefreshOnFailure}async getAccessToken(){if(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=jc.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof ap.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=await this.externalAccountAuthorizedUserHandler.refreshToken(this.refreshToken);if(this.cachedAccessToken={access_token:e.access_token,expiry_date:new Date().getTime()+e.expires_in*1000,res:e.res},e.refresh_token!==void 0)this.refreshToken=e.refresh_token;return this.cachedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}Uc.ExternalAccountAuthorizedUserClient=Dc});var Jn=w(function(Fc){Object.defineProperty(Fc,"__esModule",{value:!0});Fc.GdchClient=Fc.GDCH_SERVICE_ACCOUNT_TYPE=void 0;var hp=G("crypto"),fp=G("fs"),dp=G("https"),pp=Be(),gp=3600;Fc.GDCH_SERVICE_ACCOUNT_TYPE="gdch_service_account";class Kn extends pp.OAuth2Client{projectId;privateKeyId;privateKey;serviceIdentityName;tokenServerUri;caCertPath;apiAudience;lifetime;gdchOptions;caAgentPromise;cachedCaCertPath;lastCaCertReadTime=0;CA_CERT_TTL_MS=300000;constructor(e={}){super(e);this.gdchOptions=e,this.projectId=e.projectId||void 0,this.privateKeyId=e.privateKeyId,this.privateKey=e.privateKey,this.serviceIdentityName=e.serviceIdentityName,this.tokenServerUri=e.tokenServerUri,this.caCertPath=e.caCertPath,this.apiAudience=e.apiAudience,this.lifetime=e.lifetime||gp,this.credentials={refresh_token:"gdch-placeholder",expiry_date:1}}createWithGdchAudience(e){if(!e)throw Error("Audience cannot be null or empty for GDCH service account credentials.");return new Kn({...this.gdchOptions,projectId:this.projectId,privateKeyId:this.privateKeyId,privateKey:this.privateKey,serviceIdentityName:this.serviceIdentityName,tokenServerUri:this.tokenServerUri,caCertPath:this.caCertPath,lifetime:this.lifetime,apiAudience:e})}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the GDCH credentials settings.");if(e.type!==Fc.GDCH_SERVICE_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${Fc.GDCH_SERVICE_ACCOUNT_TYPE}" type`);if(e.format_version!=="1")throw Error("Only format version 1 is supported.");if(!e.project)throw Error("The incoming JSON object does not contain a project field");if(!e.private_key_id)throw Error("The incoming JSON object does not contain a private_key_id field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");if(!e.name)throw Error("The incoming JSON object does not contain a name field");if(!e.token_uri)throw Error("The incoming JSON object does not contain a token_uri field");this.projectId=e.project,this.privateKeyId=e.private_key_id,this.privateKey=e.private_key,this.serviceIdentityName=e.name,this.tokenServerUri=e.token_uri,this.caCertPath=e.ca_cert_path,this.gdchOptions={...this.gdchOptions,projectId:e.project,privateKeyId:e.private_key_id,privateKey:e.private_key,serviceIdentityName:e.name,tokenServerUri:e.token_uri,caCertPath:e.ca_cert_path}}async refreshTokenNoCache(){if(!this.apiAudience)throw Error("Audience cannot be null or empty for GDCH service account credentials. Specify the audience by calling createWithGdchAudience.");if(!this.privateKey)throw Error("Private key is not configured for GDCH credentials.");if(!this.privateKeyId)throw Error("Private key ID is not configured for GDCH credentials.");if(!this.projectId)throw Error("Project is not configured for GDCH credentials.");if(!this.serviceIdentityName)throw Error("Service identity name is not configured for GDCH credentials.");if(!this.tokenServerUri)throw Error("Token server URI is not configured for GDCH credentials.");let e=this.createAssertion(),t={audience:this.apiAudience,grant_type:"urn:ietf:params:oauth:token-type:token-exchange",requested_token_type:"urn:ietf:params:oauth:token-type:access_token",subject_token:e,subject_token_type:"urn:k8s:params:oauth:token-type:serviceaccount"},r={url:this.tokenServerUri,method:"POST",headers:{"Content-Type":"application/json"},data:t,responseType:"json",timeout:1e4,retry:!0,retryConfig:{httpMethodsToRetry:["POST"],statusCodesToRetry:[[500,599]],noResponseRetries:3}};if(this.caCertPath)r.agent=await this.getCaAgent();try{let n=await this.transporter.request(r),s=n.data;if(!s.access_token)throw Error("Token response did not contain an access_token.");if(!s.expires_in)throw Error("Token response did not contain an expires_in field.");let i={access_token:s.access_token,token_type:"STS-Bearer",expiry_date:Date.now()+s.expires_in*1000};return this.emit("tokens",i),{res:n,tokens:i}}catch(n){if(n&&n.config&&n.config.data)try{if(typeof n.config.data==="string"){let s=JSON.parse(n.config.data);if(s.subject_token)s.subject_token="***REDACTED***",n.config.data=JSON.stringify(s)}else if(typeof n.config.data==="object"&&n.config.data.subject_token)n.config.data.subject_token="***REDACTED***"}catch{}if(n instanceof Error)n.message=`Error getting access token for GDCH service account: ${n.message}, iss: ${this.serviceIdentityName}`;throw n}}createAssertion(){let e={alg:"ES256",typ:"JWT",kid:this.privateKeyId},t=`system:serviceaccount:${this.projectId}:${this.serviceIdentityName}`,r=Math.floor(Date.now()/1000),n={iss:t,sub:t,iat:r,exp:r+this.lifetime,aud:this.tokenServerUri},s=this.base64UrlEncode(JSON.stringify(e)),i=this.base64UrlEncode(JSON.stringify(n)),u=`${s}.${i}`,h=hp.sign("sha256",Buffer.from(u),{key:this.privateKey,dsaEncoding:"ieee-p1363"}),y=this.base64UrlEncode(h);return`${u}.${y}`}async requestAsync(e,t=!1){if(this.caCertPath&&!e.agent){let r=(e.url||"").toString();if(!r.includes("googleapis.com")&&!r.includes("google.com"))e.agent=await this.getCaAgent()}return super.requestAsync(e,t)}getCaAgent(){if(!this.caCertPath){this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0;return}let e=Date.now(),t=e-this.lastCaCertReadTime>this.CA_CERT_TTL_MS;if(this.caAgentPromise&&this.caCertPath===this.cachedCaCertPath&&!t)return this.caAgentPromise;this.cachedCaCertPath=this.caCertPath,this.lastCaCertReadTime=e;let r=this.caCertPath;return this.caAgentPromise=(async()=>{try{let n=await fp.promises.readFile(r);return new dp.Agent({ca:n})}catch(n){if(this.cachedCaCertPath===r)this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0;if(n instanceof Error)n.message=`Error reading certificate file from CA cert path, value '${r}': ${n.message}`;throw n}})(),this.caAgentPromise}toJSON(){return{...this,privateKey:this.privateKey?"***REDACTED***":void 0,_clientSecret:this._clientSecret?"***REDACTED***":void 0,apiKey:this.apiKey?"***REDACTED***":void 0,gdchOptions:this.gdchOptions?{...this.gdchOptions,privateKey:this.gdchOptions.privateKey?"***REDACTED***":void 0,clientSecret:this.gdchOptions.clientSecret?"***REDACTED***":void 0,client_secret:this.gdchOptions.client_secret?"***REDACTED***":void 0,apiKey:this.gdchOptions.apiKey?"***REDACTED***":void 0,credentials:this.gdchOptions.credentials?{...this.gdchOptions.credentials,access_token:this.gdchOptions.credentials.access_token?"***REDACTED***":void 0,refresh_token:this.gdchOptions.credentials.refresh_token?"***REDACTED***":void 0}:void 0}:void 0,credentials:{...this.credentials,access_token:this.credentials?.access_token?"***REDACTED***":void 0,refresh_token:this.credentials?.refresh_token?"***REDACTED***":void 0}}}[Symbol.for("nodejs.util.inspect.custom")](){return this.toJSON()}base64UrlEncode(e){return(typeof e==="string"?Buffer.from(e):e).toString("base64url")}}Fc.GdchClient=Kn});var Jc=w(function($c){Object.defineProperty($c,"__esModule",{value:!0});$c.GoogleAuth=$c.GoogleAuthExceptionMessages=void 0;var _p=G("child_process"),xt=G("fs"),yp=ie(),Rt=yt(),mp=G("os"),hr=G("path"),Ep=mt(),wp=Wr(),Tp=Yr(),Ap=zr(),ut=fn(),Gc=dn(),ht=pn(),vp=Gn(),bt=$e(),Vn=_e(),Bc=Hn(),Wn=Jn(),Lc=Oe();$c.GoogleAuthExceptionMessages={API_KEY_WITH_CREDENTIALS:"API Keys and Credentials are mutually exclusive authentication methods and cannot be used together.",NO_PROJECT_ID_FOUND:`Unable to detect a Project Id in the current environment.
25
+ `+await e.crypto.sha256DigestHex(N),x=await Ud(e.crypto,e.securityCredentials.secretAccessKey,u,e.region,n),j=await kt(e.crypto,x,W),b=`${sc} Credential=${e.securityCredentials.accessKeyId}/${F}, SignedHeaders=${A}, Signature=${ic.fromArrayBufferToHex(j)}`;return{amzDate:t.has("date")?void 0:i,authorizationHeader:b,canonicalQuerystring:e.canonicalQuerystring}}});var dc=w(function(lc){Object.defineProperty(lc,"__esModule",{value:!0});lc.DefaultAwsSecurityCredentialsSupplier=void 0;var ar=_e();class uc{regionUrl;securityCredentialsUrl;imdsV2SessionTokenUrl;additionalGaxiosOptions;constructor(e){this.regionUrl=e.regionUrl,this.securityCredentialsUrl=e.securityCredentialsUrl,this.imdsV2SessionTokenUrl=e.imdsV2SessionTokenUrl,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getAwsRegion(e){if(this.#n)return this.#n;let t=new Headers;if(!this.#n&&this.imdsV2SessionTokenUrl)t.set("x-aws-ec2-metadata-token",await this.#e(e.transporter));if(!this.regionUrl)throw RangeError('Unable to determine AWS region due to missing "options.credential_source.region_url"');let r={...this.additionalGaxiosOptions,url:this.regionUrl,method:"GET",responseType:"text",headers:t};ar.AuthClient.setMethodName(r,"getAwsRegion");let n=await e.transporter.request(r);return n.data.substr(0,n.data.length-1)}async getAwsSecurityCredentials(e){if(this.#s)return this.#s;let t=new Headers;if(this.imdsV2SessionTokenUrl)t.set("x-aws-ec2-metadata-token",await this.#e(e.transporter));let r=await this.#t(t,e.transporter),n=await this.#r(r,t,e.transporter);return{accessKeyId:n.AccessKeyId,secretAccessKey:n.SecretAccessKey,token:n.Token}}async#e(e){let t={...this.additionalGaxiosOptions,url:this.imdsV2SessionTokenUrl,method:"PUT",responseType:"text",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"300"}};return ar.AuthClient.setMethodName(t,"#getImdsV2SessionToken"),(await e.request(t)).data}async#t(e,t){if(!this.securityCredentialsUrl)throw Error('Unable to determine AWS role name due to missing "options.credential_source.url"');let r={...this.additionalGaxiosOptions,url:this.securityCredentialsUrl,method:"GET",responseType:"text",headers:e};return ar.AuthClient.setMethodName(r,"#getAwsRoleName"),(await t.request(r)).data}async#r(e,t,r){let n={...this.additionalGaxiosOptions,url:`${this.securityCredentialsUrl}/${e}`,headers:t,responseType:"json"};return ar.AuthClient.setMethodName(n,"#retrieveAwsSecurityCredentials"),(await r.request(n)).data}get#n(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||null}get#s(){if(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY)return{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,token:process.env.AWS_SESSION_TOKEN};return null}}lc.DefaultAwsSecurityCredentialsSupplier=uc});var On=w(function(gc){Object.defineProperty(gc,"__esModule",{value:!0});gc.AwsClient=void 0;var Fd=Cn(),Md=$e(),Ld=dc(),pc=Oe(),Gd=ie();class cr extends Md.BaseExternalAccountClient{environmentId;awsSecurityCredentialsSupplier;regionalCredVerificationUrl;awsRequestSigner;region;static#e="https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15";static AWS_EC2_METADATA_IPV4_ADDRESS="169.254.169.254";static AWS_EC2_METADATA_IPV6_ADDRESS="fd00:ec2::254";constructor(e){super(e);let t=pc.originalOrCamelOptions(e),r=t.get("credential_source"),n=t.get("aws_security_credentials_supplier");if(!r&&!n)throw Error("A credential source or AWS security credentials supplier must be specified.");if(r&&n)throw Error("Only one of credential source or AWS security credentials supplier can be specified.");if(n)this.awsSecurityCredentialsSupplier=n,this.regionalCredVerificationUrl=cr.#e,this.credentialSourceType="programmatic";else{let s=pc.originalOrCamelOptions(r);this.environmentId=s.get("environment_id");let i=s.get("region_url"),u=s.get("url"),h=s.get("imdsv2_session_token_url");this.awsSecurityCredentialsSupplier=new Ld.DefaultAwsSecurityCredentialsSupplier({regionUrl:i,securityCredentialsUrl:u,imdsV2SessionTokenUrl:h}),this.regionalCredVerificationUrl=s.get("regional_cred_verification_url"),this.credentialSourceType="aws",this.validateEnvironmentId()}this.awsRequestSigner=null,this.region=""}validateEnvironmentId(){let e=this.environmentId?.match(/^(aws)(\d+)$/);if(!e||!this.regionalCredVerificationUrl)throw Error('No valid AWS "credential_source" provided');else if(parseInt(e[2],10)!==1)throw Error(`aws version "${e[2]}" is not supported in the current build.`)}async retrieveSubjectToken(){if(!this.awsRequestSigner)this.region=await this.awsSecurityCredentialsSupplier.getAwsRegion(this.supplierContext),this.awsRequestSigner=new Fd.AwsRequestSigner(async()=>this.awsSecurityCredentialsSupplier.getAwsSecurityCredentials(this.supplierContext),this.region);let e=await this.awsRequestSigner.getRequestOptions({...cr.RETRY_CONFIG,url:this.regionalCredVerificationUrl.replace("{region}",this.region),method:"POST"}),t=[];return Gd.Gaxios.mergeHeaders({"x-goog-cloud-target-resource":this.audience},e.headers).forEach((n,s)=>t.push({key:s,value:n})),encodeURIComponent(JSON.stringify({url:e.url,method:e.method,headers:t}))}}gc.AwsClient=cr});var jn=w(function(Ec){Object.defineProperty(Ec,"__esModule",{value:!0});Ec.InvalidSubjectTokenError=Ec.InvalidMessageFieldError=Ec.InvalidCodeFieldError=Ec.InvalidTokenTypeFieldError=Ec.InvalidExpirationTimeFieldError=Ec.InvalidSuccessFieldError=Ec.InvalidVersionFieldError=Ec.ExecutableResponseError=Ec.ExecutableResponse=void 0;var ur="urn:ietf:params:oauth:token-type:saml2",kn="urn:ietf:params:oauth:token-type:id_token",bn="urn:ietf:params:oauth:token-type:jwt";class yc{version;success;expirationTime;tokenType;errorCode;errorMessage;subjectToken;constructor(e){if(!e.version)throw new xn("Executable response must contain a 'version' field.");if(e.success===void 0)throw new Rn("Executable response must contain a 'success' field.");if(this.version=e.version,this.success=e.success,this.success){if(this.expirationTime=e.expiration_time,this.tokenType=e.token_type,this.tokenType!==ur&&this.tokenType!==kn&&this.tokenType!==bn)throw new Nn(`Executable response must contain a 'token_type' field when successful and it must be one of ${kn}, ${bn}, or ${ur}.`);if(this.tokenType===ur){if(!e.saml_response)throw new lr(`Executable response must contain a 'saml_response' field when token_type=${ur}.`);this.subjectToken=e.saml_response}else{if(!e.id_token)throw new lr(`Executable response must contain a 'id_token' field when token_type=${kn} or ${bn}.`);this.subjectToken=e.id_token}}else{if(!e.code)throw new Pn("Executable response must contain a 'code' field when unsuccessful.");if(!e.message)throw new In("Executable response must contain a 'message' field when unsuccessful.");this.errorCode=e.code,this.errorMessage=e.message}}isValid(){return!this.isExpired()&&this.success}isExpired(){return this.expirationTime!==void 0&&this.expirationTime<Math.round(Date.now()/1000)}}Ec.ExecutableResponse=yc;class Me extends Error{constructor(e){super(e);Object.setPrototypeOf(this,new.target.prototype)}}Ec.ExecutableResponseError=Me;class xn extends Me{}Ec.InvalidVersionFieldError=xn;class Rn extends Me{}Ec.InvalidSuccessFieldError=Rn;class mc extends Me{}Ec.InvalidExpirationTimeFieldError=mc;class Nn extends Me{}Ec.InvalidTokenTypeFieldError=Nn;class Pn extends Me{}Ec.InvalidCodeFieldError=Pn;class In extends Me{}Ec.InvalidMessageFieldError=In;class lr extends Me{}Ec.InvalidSubjectTokenError=lr});var Fn=w(function(Tc){Object.defineProperty(Tc,"__esModule",{value:!0});Tc.PluggableAuthHandler=Tc.ExecutableError=void 0;var Qe=jn(),zd=G("child_process"),Dn=G("fs");class Un extends Error{code;constructor(e,t){super(`The executable failed with exit code: ${t} and error message: ${e}.`);this.code=t,Object.setPrototypeOf(this,new.target.prototype)}}Tc.ExecutableError=Un;class qn{commandComponents;timeoutMillis;outputFile;constructor(e){if(!e.command)throw Error("No command provided.");if(this.commandComponents=qn.parseCommand(e.command),this.timeoutMillis=e.timeoutMillis,!this.timeoutMillis)throw Error("No timeoutMillis provided.");this.outputFile=e.outputFile}retrieveResponseFromExecutable(e){return new Promise((t,r)=>{let n=zd.spawn(this.commandComponents[0],this.commandComponents.slice(1),{env:{...process.env,...Object.fromEntries(e)}}),s="";n.stdout.on("data",(u)=>{s+=u}),n.stderr.on("data",(u)=>{s+=u});let i=setTimeout(()=>(n.removeAllListeners(),n.kill(),r(Error("The executable failed to finish within the timeout specified."))),this.timeoutMillis);n.on("close",(u)=>{if(clearTimeout(i),u===0)try{let h=JSON.parse(s),y=new Qe.ExecutableResponse(h);return t(y)}catch(h){if(h instanceof Qe.ExecutableResponseError)return r(h);return r(new Qe.ExecutableResponseError(`The executable returned an invalid response: ${s}`))}else return r(new Un(s,u.toString()))})})}async retrieveCachedResponse(){if(!this.outputFile||this.outputFile.length===0)return;let e;try{e=await Dn.promises.realpath(this.outputFile)}catch{return}if(!(await Dn.promises.lstat(e)).isFile())return;let t=await Dn.promises.readFile(e,{encoding:"utf8"});if(t==="")return;try{let r=JSON.parse(t);if(new Qe.ExecutableResponse(r).isValid())return new Qe.ExecutableResponse(r);return}catch(r){if(r instanceof Qe.ExecutableResponseError)throw r;throw new Qe.ExecutableResponseError(`The output file contained an invalid response: ${t}`)}}static parseCommand(e){let t=e.match(/(?:[^\s"]+|"[^"]*")+/g);if(!t)throw Error(`Provided command: "${e}" could not be parsed.`);for(let r=0;r<t.length;r++)if(t[r][0]==='"'&&t[r].slice(-1)==='"')t[r]=t[r].slice(1,-1);return t}}Tc.PluggableAuthHandler=qn});var Ln=w(function(Mn){Object.defineProperty(Mn,"__esModule",{value:!0});Mn.PluggableAuthClient=Mn.ExecutableError=void 0;var Qd=$e(),Zd=jn(),Oc=Fn(),ep=Fn();Object.defineProperty(Mn,"ExecutableError",{enumerable:!0,get:function(){return ep.ExecutableError}});var tp=30000,vc=5000,Sc=120000,rp="GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES",Cc=1;class kc extends Qd.BaseExternalAccountClient{command;timeoutMillis;outputFile;handler;constructor(e){super(e);if(!e.credential_source.executable)throw Error('No valid Pluggable Auth "credential_source" provided.');if(this.command=e.credential_source.executable.command,!this.command)throw Error('No valid Pluggable Auth "credential_source" provided.');if(e.credential_source.executable.timeout_millis===void 0)this.timeoutMillis=tp;else if(this.timeoutMillis=e.credential_source.executable.timeout_millis,this.timeoutMillis<vc||this.timeoutMillis>Sc)throw Error(`Timeout must be between ${vc} and ${Sc} milliseconds.`);this.outputFile=e.credential_source.executable.output_file,this.handler=new Oc.PluggableAuthHandler({command:this.command,timeoutMillis:this.timeoutMillis,outputFile:this.outputFile}),this.credentialSourceType="executable"}async retrieveSubjectToken(){if(process.env[rp]!=="1")throw Error("Pluggable Auth executables need to be explicitly allowed to run by setting the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment Variable to 1.");let e=void 0;if(this.outputFile)e=await this.handler.retrieveCachedResponse();if(!e){let t=new Map;if(t.set("GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE",this.audience),t.set("GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE",this.subjectTokenType),t.set("GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE","0"),this.outputFile)t.set("GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE",this.outputFile);let r=this.getServiceAccountEmail();if(r)t.set("GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL",r);e=await this.handler.retrieveResponseFromExecutable(t)}if(e.version>Cc)throw Error(`Version of executable is not currently supported, maximum supported version is ${Cc}.`);if(!e.success)throw new Oc.ExecutableError(e.errorMessage,e.errorCode);if(this.outputFile){if(!e.expirationTime)throw new Zd.InvalidExpirationTimeFieldError("The executable response must contain the `expiration_time` field for successful responses when an output_file has been specified in the configuration.")}if(e.isExpired())throw Error("Executable response is expired.");return e.subjectToken}}Mn.PluggableAuthClient=kc});var Gn=w(function(Rc){Object.defineProperty(Rc,"__esModule",{value:!0});Rc.ExternalAccountClient=void 0;var np=$e(),sp=Sn(),ip=On(),op=Ln();class xc{constructor(){throw Error("ExternalAccountClients should be initialized via: ExternalAccountClient.fromJSON(), directly via explicit constructors, eg. new AwsClient(options), new IdentityPoolClient(options), newPluggableAuthClientOptions, or via new GoogleAuth(options).getClient()")}static fromJSON(e){if(e&&e.type===np.EXTERNAL_ACCOUNT_TYPE)if(e.credential_source?.environment_id)return new ip.AwsClient(e);else if(e.credential_source?.executable)return new op.PluggableAuthClient(e);else return new sp.IdentityPoolClient(e);else return null}}Rc.ExternalAccountClient=xc});var Hn=w(function(Uc){Object.defineProperty(Uc,"__esModule",{value:!0});Uc.ExternalAccountAuthorizedUserClient=Uc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=void 0;var Pc=_e(),Ic=gn(),jc=ie(),ap=G("stream"),cp=$e();Uc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE="external_account_authorized_user";var up="https://sts.{universeDomain}/v1/oauthtoken";class Bn extends Ic.OAuthClientAuthHandler{#e;constructor(e){super(e);this.#e=e.tokenRefreshEndpoint}async refreshToken(e,t){let r={...Bn.RETRY_CONFIG,url:this.#e,method:"POST",headers:t,data:new URLSearchParams({grant_type:"refresh_token",refresh_token:e}),responseType:"json"};Pc.AuthClient.setMethodName(r,"refreshToken"),this.applyClientAuthenticationOptions(r);try{let n=await this.transporter.request(r),s=n.data;return s.res=n,s}catch(n){if(n instanceof jc.GaxiosError&&n.response)throw Ic.getErrorFromOAuthErrorResponse(n.response.data,n);throw n}}}class Dc extends Pc.AuthClient{cachedAccessToken;externalAccountAuthorizedUserHandler;refreshToken;constructor(e){super(e);if(e.universe_domain)this.universeDomain=e.universe_domain;this.refreshToken=e.refresh_token;let t={confidentialClientType:"basic",clientId:e.client_id,clientSecret:e.client_secret};if(this.externalAccountAuthorizedUserHandler=new Bn({tokenRefreshEndpoint:e.token_url??up.replace("{universeDomain}",this.universeDomain),transporter:this.transporter,clientAuthentication:t}),this.cachedAccessToken=null,this.quotaProjectId=e.quota_project_id,typeof e?.eagerRefreshThresholdMillis!=="number")this.eagerRefreshThresholdMillis=cp.EXPIRATION_TIME_OFFSET;else this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis;this.forceRefreshOnFailure=!!e?.forceRefreshOnFailure}async getAccessToken(){if(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=jc.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof ap.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=await this.externalAccountAuthorizedUserHandler.refreshToken(this.refreshToken);if(this.cachedAccessToken={access_token:e.access_token,expiry_date:new Date().getTime()+e.expires_in*1000,res:e.res},e.refresh_token!==void 0)this.refreshToken=e.refresh_token;return this.cachedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}Uc.ExternalAccountAuthorizedUserClient=Dc});var Jn=w(function(Fc){Object.defineProperty(Fc,"__esModule",{value:!0});Fc.GdchClient=Fc.GDCH_SERVICE_ACCOUNT_TYPE=void 0;var hp=G("crypto"),fp=G("fs"),dp=G("https"),pp=Be(),gp=3600;Fc.GDCH_SERVICE_ACCOUNT_TYPE="gdch_service_account";class Kn extends pp.OAuth2Client{projectId;privateKeyId;privateKey;serviceIdentityName;tokenServerUri;caCertPath;apiAudience;lifetime;gdchOptions;caAgentPromise;cachedCaCertPath;lastCaCertReadTime=0;CA_CERT_TTL_MS=300000;constructor(e={}){super(e);this.gdchOptions=e,this.projectId=e.projectId||void 0,this.privateKeyId=e.privateKeyId,this.privateKey=e.privateKey,this.serviceIdentityName=e.serviceIdentityName,this.tokenServerUri=e.tokenServerUri,this.caCertPath=e.caCertPath,this.apiAudience=e.apiAudience,this.lifetime=e.lifetime||gp,this.credentials={refresh_token:"gdch-placeholder",expiry_date:1}}createWithGdchAudience(e){if(!e)throw Error("Audience cannot be null or empty for GDCH service account credentials.");return new Kn({...this.gdchOptions,projectId:this.projectId,privateKeyId:this.privateKeyId,privateKey:this.privateKey,serviceIdentityName:this.serviceIdentityName,tokenServerUri:this.tokenServerUri,caCertPath:this.caCertPath,lifetime:this.lifetime,apiAudience:e})}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the GDCH credentials settings.");if(e.type!==Fc.GDCH_SERVICE_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${Fc.GDCH_SERVICE_ACCOUNT_TYPE}" type`);if(e.format_version!=="1")throw Error("Only format version 1 is supported.");if(!e.project)throw Error("The incoming JSON object does not contain a project field");if(!e.private_key_id)throw Error("The incoming JSON object does not contain a private_key_id field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");if(!e.name)throw Error("The incoming JSON object does not contain a name field");if(!e.token_uri)throw Error("The incoming JSON object does not contain a token_uri field");this.projectId=e.project,this.privateKeyId=e.private_key_id,this.privateKey=e.private_key,this.serviceIdentityName=e.name,this.tokenServerUri=e.token_uri,this.caCertPath=e.ca_cert_path,this.gdchOptions={...this.gdchOptions,projectId:e.project,privateKeyId:e.private_key_id,privateKey:e.private_key,serviceIdentityName:e.name,tokenServerUri:e.token_uri,caCertPath:e.ca_cert_path}}async refreshTokenNoCache(){if(!this.apiAudience)throw Error("Audience cannot be null or empty for GDCH service account credentials. Specify the audience by calling createWithGdchAudience.");if(!this.privateKey)throw Error("Private key is not configured for GDCH credentials.");if(!this.privateKeyId)throw Error("Private key ID is not configured for GDCH credentials.");if(!this.projectId)throw Error("Project is not configured for GDCH credentials.");if(!this.serviceIdentityName)throw Error("Service identity name is not configured for GDCH credentials.");if(!this.tokenServerUri)throw Error("Token server URI is not configured for GDCH credentials.");let e=this.createAssertion(),t={audience:this.apiAudience,grant_type:"urn:ietf:params:oauth:token-type:token-exchange",requested_token_type:"urn:ietf:params:oauth:token-type:access_token",subject_token:e,subject_token_type:"urn:k8s:params:oauth:token-type:serviceaccount"},r={url:this.tokenServerUri,method:"POST",headers:{"Content-Type":"application/json"},data:t,responseType:"json",timeout:1e4,retry:!0,retryConfig:{httpMethodsToRetry:["POST"],statusCodesToRetry:[[500,599]],noResponseRetries:3}};if(this.caCertPath)r.agent=await this.getCaAgent();try{let n=await this.transporter.request(r),s=n.data;if(!s.access_token)throw Error("Token response did not contain an access_token.");if(!s.expires_in)throw Error("Token response did not contain an expires_in field.");let i={access_token:s.access_token,token_type:"STS-Bearer",expiry_date:Date.now()+s.expires_in*1000};return this.emit("tokens",i),{res:n,tokens:i}}catch(n){if(n&&n.config&&n.config.data)try{if(typeof n.config.data==="string"){let s=JSON.parse(n.config.data);if(s.subject_token)s.subject_token="***REDACTED***",n.config.data=JSON.stringify(s)}else if(typeof n.config.data==="object"&&n.config.data.subject_token)n.config.data.subject_token="***REDACTED***"}catch{}if(n instanceof Error)n.message=`Error getting access token for GDCH service account: ${n.message}, iss: ${this.serviceIdentityName}`;throw n}}createAssertion(){let e={alg:"ES256",typ:"JWT",kid:this.privateKeyId},t=`system:serviceaccount:${this.projectId}:${this.serviceIdentityName}`,r=Math.floor(Date.now()/1000),n={iss:t,sub:t,iat:r,exp:r+this.lifetime,aud:this.tokenServerUri},s=this.base64UrlEncode(JSON.stringify(e)),i=this.base64UrlEncode(JSON.stringify(n)),u=`${s}.${i}`,h=hp.sign("sha256",Buffer.from(u),{key:this.privateKey,dsaEncoding:"ieee-p1363"}),y=this.base64UrlEncode(h);return`${u}.${y}`}async requestAsync(e,t=!1){if(this.caCertPath&&!e.agent){let r=(e.url||"").toString();if(!r.includes("googleapis.com")&&!r.includes("google.com"))e.agent=await this.getCaAgent()}return super.requestAsync(e,t)}getCaAgent(){if(!this.caCertPath){this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0;return}let e=Date.now(),t=e-this.lastCaCertReadTime>this.CA_CERT_TTL_MS;if(this.caAgentPromise&&this.caCertPath===this.cachedCaCertPath&&!t)return this.caAgentPromise;this.cachedCaCertPath=this.caCertPath,this.lastCaCertReadTime=e;let r=this.caCertPath;return this.caAgentPromise=(async()=>{try{let n=await fp.promises.readFile(r);return new dp.Agent({ca:n})}catch(n){if(this.cachedCaCertPath===r)this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0;if(n instanceof Error)n.message=`Error reading certificate file from CA cert path, value '${r}': ${n.message}`;throw n}})(),this.caAgentPromise}toJSON(){return{...this,privateKey:this.privateKey?"***REDACTED***":void 0,_clientSecret:this._clientSecret?"***REDACTED***":void 0,apiKey:this.apiKey?"***REDACTED***":void 0,gdchOptions:this.gdchOptions?{...this.gdchOptions,privateKey:this.gdchOptions.privateKey?"***REDACTED***":void 0,clientSecret:this.gdchOptions.clientSecret?"***REDACTED***":void 0,client_secret:this.gdchOptions.client_secret?"***REDACTED***":void 0,apiKey:this.gdchOptions.apiKey?"***REDACTED***":void 0,credentials:this.gdchOptions.credentials?{...this.gdchOptions.credentials,access_token:this.gdchOptions.credentials.access_token?"***REDACTED***":void 0,refresh_token:this.gdchOptions.credentials.refresh_token?"***REDACTED***":void 0}:void 0}:void 0,credentials:{...this.credentials,access_token:this.credentials?.access_token?"***REDACTED***":void 0,refresh_token:this.credentials?.refresh_token?"***REDACTED***":void 0}}}[Symbol.for("nodejs.util.inspect.custom")](){return this.toJSON()}base64UrlEncode(e){return(typeof e==="string"?Buffer.from(e):e).toString("base64url")}}Fc.GdchClient=Kn});var Jc=w(function($c){Object.defineProperty($c,"__esModule",{value:!0});$c.GoogleAuth=$c.GoogleAuthExceptionMessages=void 0;var _p=G("child_process"),xt=G("fs"),yp=ie(),Rt=yt(),mp=G("os"),hr=G("path"),Ep=mt(),wp=Wr(),Tp=Yr(),Ap=zr(),ut=fn(),Gc=dn(),ht=pn(),vp=Gn(),bt=$e(),Vn=_e(),Bc=Hn(),Wn=Jn(),Lc=Oe();$c.GoogleAuthExceptionMessages={API_KEY_WITH_CREDENTIALS:"API Keys and Credentials are mutually exclusive authentication methods and cannot be used together.",NO_PROJECT_ID_FOUND:`Unable to detect a Project Id in the current environment.
26
26
  To learn more about authentication and Google APIs, visit:
27
27
  https://cloud.google.com/docs/authentication/getting-started`,NO_CREDENTIALS_FOUND:`Unable to find credentials in current environment.
28
28
  To learn more about authentication and Google APIs, visit:
29
29
  https://cloud.google.com/docs/authentication/getting-started`,NO_ADC_FOUND:"Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.",NO_UNIVERSE_DOMAIN_FOUND:`Unable to detect a Universe Domain in the current environment.
30
30
  To learn more about Universe Domain retrieval, visit:
31
- https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};class Hc{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#e=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(e={}){if(this._cachedProjectId=e.projectId||null,this.cachedCredential=e.authClient||null,this.keyFilename=e.keyFilename||e.keyFile,this.scopes=e.scopes,this.clientOptions=e.clientOptions||{},this.jsonContent=e.credentials||null,this.apiKey=e.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw RangeError($c.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);if(e.universeDomain)this.clientOptions.universeDomain=e.universeDomain}setGapicJWTValues(e){e.defaultServicePath=this.defaultServicePath,e.useJWTAccessWithScope=this.useJWTAccessWithScope,e.defaultScopes=this.defaultScopes}getProjectId(e){if(e)this.getProjectIdAsync().then((t)=>e(null,t),e);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(e){if(e instanceof Error&&e.message===$c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;else throw e}}async findAndCacheProjectId(){let e=null;if(e||=await this.getProductionProjectId(),e||=await this.getFileProjectId(),e||=await this.getDefaultServiceProjectId(),e||=await this.getGCEProjectId(),e||=await this.getExternalAccountClientProjectId(),e)return this._cachedProjectId=e,e;else throw Error($c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){if(this._cachedProjectId)return this._cachedProjectId;if(!this._findProjectIdPromise)this._findProjectIdPromise=this.findAndCacheProjectId();return this._findProjectIdPromise}async getUniverseDomainFromMetadataServer(){let e;try{e=await Rt.universe("universe-domain"),e||=Vn.DEFAULT_UNIVERSE}catch(t){if(t&&t?.response?.status===404)e=Vn.DEFAULT_UNIVERSE;else throw t}return e}async getUniverseDomain(){let e=Lc.originalOrCamelOptions(this.clientOptions).get("universe_domain");try{e??=(await this.getClient()).universeDomain}catch{e??=Vn.DEFAULT_UNIVERSE}return e}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(e={},t){let r;if(typeof e==="function")t=e;else r=e;if(t)this.getApplicationDefaultAsync(r).then((n)=>t(null,n.credential,n.projectId),t);else return this.getApplicationDefaultAsync(r)}async getApplicationDefaultAsync(e={}){if(this.cachedCredential)return await this.#t(this.cachedCredential,null);let t;if(t=await this._tryGetApplicationCredentialsFromEnvironmentVariable(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(t=await this._tryGetApplicationCredentialsFromWellKnownFile(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(await this._checkIsGCE())return e.scopes=this.getAnyScopes(),await this.#t(new wp.Compute(e));throw Error($c.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#t(e,t=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let r=await this.getProjectIdOptional();if(t)e.quotaProjectId=t;return this.cachedCredential=e,{credential:e,projectId:r}}async _checkIsGCE(){if(this.checkIsGCE===void 0)this.checkIsGCE=Rt.getGCPResidency()||await Rt.isAvailable();return this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(e){let t=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!t||t.length===0)return null;try{return await this._getApplicationCredentialsFromFilePath(t,e)}catch(r){if(r instanceof Error)r.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${r.message}`;throw r}}async _tryGetApplicationCredentialsFromWellKnownFile(e){let t=process.env.CLOUDSDK_CONFIG;if(!t)if(this._isWindows()){if(process.env.APPDATA)t=hr.join(process.env.APPDATA,"gcloud")}else{let s=process.env.HOME;if(s)t=hr.join(s,".config","gcloud")}if(!t)return null;let r=hr.join(t,"application_default_credentials.json");if(!xt.existsSync(r))return null;return await this._getApplicationCredentialsFromFilePath(r,e)}async _getApplicationCredentialsFromFilePath(e,t={}){if(!e||e.length===0)throw Error("The file path is invalid.");try{if(e=xt.realpathSync(e),!xt.lstatSync(e).isFile())throw Error()}catch(n){if(n instanceof Error)n.message=`The file at ${e} does not exist, or it is not a file. ${n.message}`;throw n}let r=xt.createReadStream(e);return this.fromStream(r,t)}fromImpersonatedJSON(e){if(!e)throw Error("Must pass in a JSON object containing an impersonated refresh token");if(e.type!==ht.IMPERSONATED_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${ht.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!e.source_credentials)throw Error("The incoming JSON object does not contain a source_credentials field");if(!e.service_account_impersonation_url)throw Error("The incoming JSON object does not contain a service_account_impersonation_url field");let t=this.fromJSON(e.source_credentials);if(e.service_account_impersonation_url?.length>256)throw RangeError(`Target principal is too long: ${e.service_account_impersonation_url}`);let r=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(e.service_account_impersonation_url)?.groups?.target;if(!r)throw RangeError(`Cannot extract target principal from ${e.service_account_impersonation_url}`);let n=(this.scopes||e.scopes||this.defaultScopes)??[];return new ht.Impersonated({...e,sourceClient:t,targetPrincipal:r,targetScopes:Array.isArray(n)?n:[n]})}fromJSON(e,t={}){let r,n=Lc.originalOrCamelOptions(t).get("universe_domain");if(e.type===Gc.USER_REFRESH_ACCOUNT_TYPE)r=new Gc.UserRefreshClient(t),r.fromJSON(e);else if(e.type===ht.IMPERSONATED_ACCOUNT_TYPE)r=this.fromImpersonatedJSON(e);else if(e.type===bt.EXTERNAL_ACCOUNT_TYPE)r=vp.ExternalAccountClient.fromJSON({...e,...t}),r.scopes=this.getAnyScopes();else if(e.type===Bc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE)r=new Bc.ExternalAccountAuthorizedUserClient({...e,...t});else if(e.type===Wn.GDCH_SERVICE_ACCOUNT_TYPE)r=new Wn.GdchClient(t),r.fromJSON(e);else t.scopes=this.scopes,r=new ut.JWT(t),this.setGapicJWTValues(r),r.fromJSON(e);if(n)r.universeDomain=n;return r}_cacheClientFromJSON(e,t){let r=this.fromJSON(e,t);return this.jsonContent=e,this.cachedCredential=r,r}fromStream(e,t={},r){let n={};if(typeof t==="function")r=t;else n=t;if(r)this.fromStreamAsync(e,n).then((s)=>r(null,s),r);else return this.fromStreamAsync(e,n)}fromStreamAsync(e,t){return new Promise((r,n)=>{if(!e)throw Error("Must pass in a stream containing the Google auth settings.");let s=[];e.setEncoding("utf8").on("error",n).on("data",(i)=>s.push(i)).on("end",()=>{try{try{let i=JSON.parse(s.join("")),u=this._cacheClientFromJSON(i,t);return r(u)}catch(i){if(!this.keyFilename)throw i;let u=new ut.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=u,this.setGapicJWTValues(u),r(u)}}catch(i){return n(i)}})})}fromAPIKey(e,t={}){return new ut.JWT({...t,apiKey:e})}_isWindows(){let e=mp.platform();if(e&&e.length>=3){if(e.substring(0,3).toLowerCase()==="win")return!0}return!1}async getDefaultServiceProjectId(){return new Promise((e)=>{_p.exec("gcloud config config-helper --format json",(t,r)=>{if(!t&&r)try{let n=JSON.parse(r).configuration.properties.core.project;e(n);return}catch(n){}e(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let t=await this.getClient();if(t&&t.projectId)return t.projectId}let e=await this._tryGetApplicationCredentialsFromEnvironmentVariable();if(e)return e.projectId;else return null}async getExternalAccountClientProjectId(){if(!this.jsonContent||this.jsonContent.type!==bt.EXTERNAL_ACCOUNT_TYPE)return null;return await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await Rt.project("project-id")}catch(e){return null}}getCredentials(e){if(e)this.getCredentialsAsync().then((t)=>e(null,t),e);else return this.getCredentialsAsync()}async getCredentialsAsync(){let e=await this.getClient();if(e instanceof ht.Impersonated)return{client_email:e.getTargetPrincipal()};if(e instanceof bt.BaseExternalAccountClient){let t=e.getServiceAccountEmail();if(t)return{client_email:t,universe_domain:e.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[t,r]=await Promise.all([Rt.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:t,universe_domain:r}}throw Error($c.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#e=this.#e||this.#r();try{let e=await this.#e;if(e instanceof Wn.GdchClient&&!e.apiAudience){let t=this.clientOptions,r=t.apiEndpoint||t.servicePath;if(r){let s=`${r.startsWith("http")?"":"https://"}${r}`.replace(/\/+$/,""),i=e.createWithGdchAudience(s);return this.cachedCredential=i,i}}return e}finally{this.#e=null}}async#r(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);else if(this.keyFilename){let e=hr.resolve(this.keyFilename),t=xt.createReadStream(e);return await this.fromStreamAsync(t,this.clientOptions)}else if(this.apiKey){let e=await this.fromAPIKey(this.apiKey,this.clientOptions);e.scopes=this.scopes;let{credential:t}=await this.#t(e);return t}else{let{credential:e}=await this.getApplicationDefaultAsync(this.clientOptions);return e}}async getIdTokenClient(e){let t=await this.getClient();if(!("fetchIdToken"in t))throw Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new Tp.IdTokenClient({targetAudience:e,idTokenProvider:t})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(e){return(await this.getClient()).getRequestHeaders(e)}async authorizeRequest(e={}){let t=e.url,n=await(await this.getClient()).getRequestHeaders(t);return e.headers=yp.Gaxios.mergeHeaders(e.headers,n),e}async fetch(...e){return(await this.getClient()).fetch(...e)}async request(e){return(await this.getClient()).request(e)}getEnv(){return Ap.getEnv()}async sign(e,t){let r=await this.getClient(),n=await this.getUniverseDomain();if(t=t||`https://iamcredentials.${n}/v1/projects/-/serviceAccounts/`,r instanceof ht.Impersonated)return(await r.sign(e)).signedBlob;let s=Ep.createCrypto();if(r instanceof ut.JWT&&r.key)return await s.sign(r.key,e);let i=await this.getCredentials();if(!i.client_email)throw Error("Cannot sign data without `client_email`.");return this.signBlob(s,i.client_email,e,t)}async signBlob(e,t,r,n){let s=new URL(n+`${t}:signBlob`);return(await this.request({method:"POST",url:s.href,data:{payload:e.encodeBase64StringUtf8(r)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}}$c.GoogleAuth=Hc});var zc=w(function(Wc){Object.defineProperty(Wc,"__esModule",{value:!0});Wc.IAMAuth=void 0;class Vc{selector;token;constructor(e,t){this.selector=e,this.token=t,this.selector=e,this.token=t}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}}Wc.IAMAuth=Vc});var eu=w(function(Qc){Object.defineProperty(Qc,"__esModule",{value:!0});Qc.DownscopedClient=Qc.EXPIRATION_TIME_OFFSET=Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var Sp=ie(),Cp=G("stream"),Yn=_e(),Op=er(),kp="urn:ietf:params:oauth:grant-type:token-exchange",bp="urn:ietf:params:oauth:token-type:access_token",xp="urn:ietf:params:oauth:token-type:access_token";Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=10;Qc.EXPIRATION_TIME_OFFSET=300000;class Xc extends Yn.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(e,t={accessBoundary:{accessBoundaryRules:[]}}){super(e instanceof Yn.AuthClient?{}:e);if(e instanceof Yn.AuthClient)this.authClient=e,this.credentialAccessBoundary=t;else this.authClient=e.authClient,this.credentialAccessBoundary=e.credentialAccessBoundary;if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw Error("At least one access boundary rule needs to be defined.");else if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw Error(`The provided access boundary has more than ${Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let r of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(r.availablePermissions.length===0)throw Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new Op.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(e){if(!e.expiry_date)throw Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(e),this.cachedDownscopedAccessToken=e}async getAccessToken(){if(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=Sp.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof Cp.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=(await this.authClient.getAccessToken()).token,t={grantType:kp,requestedTokenType:bp,subjectToken:e,subjectTokenType:xp},r=await this.stsCredential.exchangeToken(t,void 0,this.credentialAccessBoundary),n=this.authClient.credentials?.expiry_date||null,s=r.expires_in?new Date().getTime()+r.expires_in*1000:n;return this.cachedDownscopedAccessToken={access_token:r.access_token,expiry_date:s,res:r.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}Qc.DownscopedClient=Xc});var su=w(function(ru){Object.defineProperty(ru,"__esModule",{value:!0});ru.PassThroughClient=void 0;var Np=_e();class tu extends Np.AuthClient{async request(e){return this.transporter.request(e)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}}ru.PassThroughClient=tu});var fc=w(function(O){var Pp=O&&O.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Ip=O&&O.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Pp(t,e,r)};Object.defineProperty(O,"__esModule",{value:!0});O.GoogleAuth=O.auth=O.GDCH_SERVICE_ACCOUNT_TYPE=O.GdchClient=O.PassThroughClient=O.ExternalAccountAuthorizedUserClient=O.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=O.ExecutableError=O.PluggableAuthClient=O.DownscopedClient=O.BaseExternalAccountClient=O.ExternalAccountClient=O.IdentityPoolClient=O.AwsRequestSigner=O.AwsClient=O.UserRefreshClient=O.LoginTicket=O.ClientAuthentication=O.OAuth2Client=O.CodeChallengeMethod=O.Impersonated=O.JWT=O.JWTAccess=O.IdTokenClient=O.IAMAuth=O.GCPEnv=O.Compute=O.DEFAULT_UNIVERSE=O.AuthClient=O.gaxios=O.gcpMetadata=void 0;var iu=Jc();Object.defineProperty(O,"GoogleAuth",{enumerable:!0,get:function(){return iu.GoogleAuth}});O.gcpMetadata=yt();O.gaxios=ie();var ou=_e();Object.defineProperty(O,"AuthClient",{enumerable:!0,get:function(){return ou.AuthClient}});Object.defineProperty(O,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return ou.DEFAULT_UNIVERSE}});var jp=Wr();Object.defineProperty(O,"Compute",{enumerable:!0,get:function(){return jp.Compute}});var Dp=zr();Object.defineProperty(O,"GCPEnv",{enumerable:!0,get:function(){return Dp.GCPEnv}});var Up=zc();Object.defineProperty(O,"IAMAuth",{enumerable:!0,get:function(){return Up.IAMAuth}});var qp=Yr();Object.defineProperty(O,"IdTokenClient",{enumerable:!0,get:function(){return qp.IdTokenClient}});var Fp=ln();Object.defineProperty(O,"JWTAccess",{enumerable:!0,get:function(){return Fp.JWTAccess}});var Mp=fn();Object.defineProperty(O,"JWT",{enumerable:!0,get:function(){return Mp.JWT}});var Lp=pn();Object.defineProperty(O,"Impersonated",{enumerable:!0,get:function(){return Lp.Impersonated}});var Xn=Be();Object.defineProperty(O,"CodeChallengeMethod",{enumerable:!0,get:function(){return Xn.CodeChallengeMethod}});Object.defineProperty(O,"OAuth2Client",{enumerable:!0,get:function(){return Xn.OAuth2Client}});Object.defineProperty(O,"ClientAuthentication",{enumerable:!0,get:function(){return Xn.ClientAuthentication}});var Gp=Jr();Object.defineProperty(O,"LoginTicket",{enumerable:!0,get:function(){return Gp.LoginTicket}});var Bp=dn();Object.defineProperty(O,"UserRefreshClient",{enumerable:!0,get:function(){return Bp.UserRefreshClient}});var Hp=On();Object.defineProperty(O,"AwsClient",{enumerable:!0,get:function(){return Hp.AwsClient}});var $p=Cn();Object.defineProperty(O,"AwsRequestSigner",{enumerable:!0,get:function(){return $p.AwsRequestSigner}});var Kp=Sn();Object.defineProperty(O,"IdentityPoolClient",{enumerable:!0,get:function(){return Kp.IdentityPoolClient}});var Jp=Gn();Object.defineProperty(O,"ExternalAccountClient",{enumerable:!0,get:function(){return Jp.ExternalAccountClient}});var Vp=$e();Object.defineProperty(O,"BaseExternalAccountClient",{enumerable:!0,get:function(){return Vp.BaseExternalAccountClient}});var Wp=eu();Object.defineProperty(O,"DownscopedClient",{enumerable:!0,get:function(){return Wp.DownscopedClient}});var au=Ln();Object.defineProperty(O,"PluggableAuthClient",{enumerable:!0,get:function(){return au.PluggableAuthClient}});Object.defineProperty(O,"ExecutableError",{enumerable:!0,get:function(){return au.ExecutableError}});var cu=Hn();Object.defineProperty(O,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return cu.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}});Object.defineProperty(O,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return cu.ExternalAccountAuthorizedUserClient}});var Yp=su();Object.defineProperty(O,"PassThroughClient",{enumerable:!0,get:function(){return Yp.PassThroughClient}});var uu=Jn();Object.defineProperty(O,"GdchClient",{enumerable:!0,get:function(){return uu.GdchClient}});Object.defineProperty(O,"GDCH_SERVICE_ACCOUNT_TYPE",{enumerable:!0,get:function(){return uu.GDCH_SERVICE_ACCOUNT_TYPE}});Ip(cn(),O);var zp=new iu.GoogleAuth;O.auth=zp});
32
- export{wu,fc};
31
+ https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};class Hc{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#e=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(e={}){if(this._cachedProjectId=e.projectId||null,this.cachedCredential=e.authClient||null,this.keyFilename=e.keyFilename||e.keyFile,this.scopes=e.scopes,this.clientOptions=e.clientOptions||{},this.jsonContent=e.credentials||null,this.apiKey=e.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw RangeError($c.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);if(e.universeDomain)this.clientOptions.universeDomain=e.universeDomain}setGapicJWTValues(e){e.defaultServicePath=this.defaultServicePath,e.useJWTAccessWithScope=this.useJWTAccessWithScope,e.defaultScopes=this.defaultScopes}getProjectId(e){if(e)this.getProjectIdAsync().then((t)=>e(null,t),e);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(e){if(e instanceof Error&&e.message===$c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;else throw e}}async findAndCacheProjectId(){let e=null;if(e||=await this.getProductionProjectId(),e||=await this.getFileProjectId(),e||=await this.getDefaultServiceProjectId(),e||=await this.getGCEProjectId(),e||=await this.getExternalAccountClientProjectId(),e)return this._cachedProjectId=e,e;else throw Error($c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){if(this._cachedProjectId)return this._cachedProjectId;if(!this._findProjectIdPromise)this._findProjectIdPromise=this.findAndCacheProjectId();return this._findProjectIdPromise}async getUniverseDomainFromMetadataServer(){let e;try{e=await Rt.universe("universe-domain"),e||=Vn.DEFAULT_UNIVERSE}catch(t){if(t&&t?.response?.status===404)e=Vn.DEFAULT_UNIVERSE;else throw t}return e}async getUniverseDomain(){let e=Lc.originalOrCamelOptions(this.clientOptions).get("universe_domain");try{e??=(await this.getClient()).universeDomain}catch{e??=Vn.DEFAULT_UNIVERSE}return e}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(e={},t){let r;if(typeof e==="function")t=e;else r=e;if(t)this.getApplicationDefaultAsync(r).then((n)=>t(null,n.credential,n.projectId),t);else return this.getApplicationDefaultAsync(r)}async getApplicationDefaultAsync(e={}){if(this.cachedCredential)return await this.#t(this.cachedCredential,null);let t;if(t=await this._tryGetApplicationCredentialsFromEnvironmentVariable(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(t=await this._tryGetApplicationCredentialsFromWellKnownFile(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(await this._checkIsGCE())return e.scopes=this.getAnyScopes(),await this.#t(new wp.Compute(e));throw Error($c.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#t(e,t=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let r=await this.getProjectIdOptional();if(t)e.quotaProjectId=t;return this.cachedCredential=e,{credential:e,projectId:r}}async _checkIsGCE(){if(this.checkIsGCE===void 0)this.checkIsGCE=Rt.getGCPResidency()||await Rt.isAvailable();return this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(e){let t=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!t||t.length===0)return null;try{return await this._getApplicationCredentialsFromFilePath(t,e)}catch(r){if(r instanceof Error)r.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${r.message}`;throw r}}async _tryGetApplicationCredentialsFromWellKnownFile(e){let t=process.env.CLOUDSDK_CONFIG;if(!t)if(this._isWindows()){if(process.env.APPDATA)t=hr.join(process.env.APPDATA,"gcloud")}else{let s=process.env.HOME;if(s)t=hr.join(s,".config","gcloud")}if(!t)return null;let r=hr.join(t,"application_default_credentials.json");if(!xt.existsSync(r))return null;return await this._getApplicationCredentialsFromFilePath(r,e)}async _getApplicationCredentialsFromFilePath(e,t={}){if(!e||e.length===0)throw Error("The file path is invalid.");try{if(e=xt.realpathSync(e),!xt.lstatSync(e).isFile())throw Error()}catch(n){if(n instanceof Error)n.message=`The file at ${e} does not exist, or it is not a file. ${n.message}`;throw n}let r=xt.createReadStream(e);return this.fromStream(r,t)}fromImpersonatedJSON(e){if(!e)throw Error("Must pass in a JSON object containing an impersonated refresh token");if(e.type!==ht.IMPERSONATED_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${ht.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!e.source_credentials)throw Error("The incoming JSON object does not contain a source_credentials field");if(!e.service_account_impersonation_url)throw Error("The incoming JSON object does not contain a service_account_impersonation_url field");let t=this.fromJSON(e.source_credentials);if(e.service_account_impersonation_url?.length>256)throw RangeError(`Target principal is too long: ${e.service_account_impersonation_url}`);let r=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(e.service_account_impersonation_url)?.groups?.target;if(!r)throw RangeError(`Cannot extract target principal from ${e.service_account_impersonation_url}`);let n=(this.scopes||e.scopes||this.defaultScopes)??[];return new ht.Impersonated({...e,sourceClient:t,targetPrincipal:r,targetScopes:Array.isArray(n)?n:[n]})}fromJSON(e,t={}){let r,n=Lc.originalOrCamelOptions(t).get("universe_domain");if(e.type===Gc.USER_REFRESH_ACCOUNT_TYPE)r=new Gc.UserRefreshClient(t),r.fromJSON(e);else if(e.type===ht.IMPERSONATED_ACCOUNT_TYPE)r=this.fromImpersonatedJSON(e);else if(e.type===bt.EXTERNAL_ACCOUNT_TYPE)r=vp.ExternalAccountClient.fromJSON({...e,...t}),r.scopes=this.getAnyScopes();else if(e.type===Bc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE)r=new Bc.ExternalAccountAuthorizedUserClient({...e,...t});else if(e.type===Wn.GDCH_SERVICE_ACCOUNT_TYPE)r=new Wn.GdchClient(t),r.fromJSON(e);else t.scopes=this.scopes,r=new ut.JWT(t),this.setGapicJWTValues(r),r.fromJSON(e);if(n)r.universeDomain=n;return r}_cacheClientFromJSON(e,t){let r=this.fromJSON(e,t);return this.jsonContent=e,this.cachedCredential=r,r}fromStream(e,t={},r){let n={};if(typeof t==="function")r=t;else n=t;if(r)this.fromStreamAsync(e,n).then((s)=>r(null,s),r);else return this.fromStreamAsync(e,n)}fromStreamAsync(e,t){return new Promise((r,n)=>{if(!e)throw Error("Must pass in a stream containing the Google auth settings.");let s=[];e.setEncoding("utf8").on("error",n).on("data",(i)=>s.push(i)).on("end",()=>{try{try{let i=JSON.parse(s.join("")),u=this._cacheClientFromJSON(i,t);return r(u)}catch(i){if(!this.keyFilename)throw i;let u=new ut.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=u,this.setGapicJWTValues(u),r(u)}}catch(i){return n(i)}})})}fromAPIKey(e,t={}){return new ut.JWT({...t,apiKey:e})}_isWindows(){let e=mp.platform();if(e&&e.length>=3){if(e.substring(0,3).toLowerCase()==="win")return!0}return!1}async getDefaultServiceProjectId(){return new Promise((e)=>{_p.exec("gcloud config config-helper --format json",(t,r)=>{if(!t&&r)try{let n=JSON.parse(r).configuration.properties.core.project;e(n);return}catch(n){}e(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let t=await this.getClient();if(t&&t.projectId)return t.projectId}let e=await this._tryGetApplicationCredentialsFromEnvironmentVariable();if(e)return e.projectId;else return null}async getExternalAccountClientProjectId(){if(!this.jsonContent||this.jsonContent.type!==bt.EXTERNAL_ACCOUNT_TYPE)return null;return await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await Rt.project("project-id")}catch(e){return null}}getCredentials(e){if(e)this.getCredentialsAsync().then((t)=>e(null,t),e);else return this.getCredentialsAsync()}async getCredentialsAsync(){let e=await this.getClient();if(e instanceof ht.Impersonated)return{client_email:e.getTargetPrincipal()};if(e instanceof bt.BaseExternalAccountClient){let t=e.getServiceAccountEmail();if(t)return{client_email:t,universe_domain:e.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[t,r]=await Promise.all([Rt.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:t,universe_domain:r}}throw Error($c.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#e=this.#e||this.#r();try{let e=await this.#e;if(e instanceof Wn.GdchClient&&!e.apiAudience){let t=this.clientOptions,r=t.apiEndpoint||t.servicePath;if(r){let s=`${r.startsWith("http")?"":"https://"}${r}`.replace(/\/+$/,""),i=e.createWithGdchAudience(s);return this.cachedCredential=i,i}}return e}finally{this.#e=null}}async#r(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);else if(this.keyFilename){let e=hr.resolve(this.keyFilename),t=xt.createReadStream(e);return await this.fromStreamAsync(t,this.clientOptions)}else if(this.apiKey){let e=await this.fromAPIKey(this.apiKey,this.clientOptions);e.scopes=this.scopes;let{credential:t}=await this.#t(e);return t}else{let{credential:e}=await this.getApplicationDefaultAsync(this.clientOptions);return e}}async getIdTokenClient(e){let t=await this.getClient();if(!("fetchIdToken"in t))throw Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new Tp.IdTokenClient({targetAudience:e,idTokenProvider:t})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(e){return(await this.getClient()).getRequestHeaders(e)}async authorizeRequest(e={}){let t=e.url,n=await(await this.getClient()).getRequestHeaders(t);return e.headers=yp.Gaxios.mergeHeaders(e.headers,n),e}async fetch(...e){return(await this.getClient()).fetch(...e)}async request(e){return(await this.getClient()).request(e)}getEnv(){return Ap.getEnv()}async sign(e,t){let r=await this.getClient(),n=await this.getUniverseDomain();if(t=t||`https://iamcredentials.${n}/v1/projects/-/serviceAccounts/`,r instanceof ht.Impersonated)return(await r.sign(e)).signedBlob;let s=Ep.createCrypto();if(r instanceof ut.JWT&&r.key)return await s.sign(r.key,e);let i=await this.getCredentials();if(!i.client_email)throw Error("Cannot sign data without `client_email`.");return this.signBlob(s,i.client_email,e,t)}async signBlob(e,t,r,n){let s=new URL(n+`${t}:signBlob`);return(await this.request({method:"POST",url:s.href,data:{payload:e.encodeBase64StringUtf8(r)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}}$c.GoogleAuth=Hc});var zc=w(function(Wc){Object.defineProperty(Wc,"__esModule",{value:!0});Wc.IAMAuth=void 0;class Vc{selector;token;constructor(e,t){this.selector=e,this.token=t,this.selector=e,this.token=t}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}}Wc.IAMAuth=Vc});var eu=w(function(Qc){Object.defineProperty(Qc,"__esModule",{value:!0});Qc.DownscopedClient=Qc.EXPIRATION_TIME_OFFSET=Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var Sp=ie(),Cp=G("stream"),Yn=_e(),Op=er(),kp="urn:ietf:params:oauth:grant-type:token-exchange",bp="urn:ietf:params:oauth:token-type:access_token",xp="urn:ietf:params:oauth:token-type:access_token";Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=10;Qc.EXPIRATION_TIME_OFFSET=300000;class Xc extends Yn.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(e,t={accessBoundary:{accessBoundaryRules:[]}}){super(e instanceof Yn.AuthClient?{}:e);if(e instanceof Yn.AuthClient)this.authClient=e,this.credentialAccessBoundary=t;else this.authClient=e.authClient,this.credentialAccessBoundary=e.credentialAccessBoundary;if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw Error("At least one access boundary rule needs to be defined.");else if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw Error(`The provided access boundary has more than ${Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let r of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(r.availablePermissions.length===0)throw Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new Op.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(e){if(!e.expiry_date)throw Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(e),this.cachedDownscopedAccessToken=e}async getAccessToken(){if(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=Sp.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof Cp.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=(await this.authClient.getAccessToken()).token,t={grantType:kp,requestedTokenType:bp,subjectToken:e,subjectTokenType:xp},r=await this.stsCredential.exchangeToken(t,void 0,this.credentialAccessBoundary),n=this.authClient.credentials?.expiry_date||null,s=r.expires_in?new Date().getTime()+r.expires_in*1000:n;return this.cachedDownscopedAccessToken={access_token:r.access_token,expiry_date:s,res:r.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}Qc.DownscopedClient=Xc});var su=w(function(ru){Object.defineProperty(ru,"__esModule",{value:!0});ru.PassThroughClient=void 0;var Np=_e();class tu extends Np.AuthClient{async request(e){return this.transporter.request(e)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}}ru.PassThroughClient=tu});var hc=w(function(O){var Pp=O&&O.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Ip=O&&O.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Pp(t,e,r)};Object.defineProperty(O,"__esModule",{value:!0});O.GoogleAuth=O.auth=O.GDCH_SERVICE_ACCOUNT_TYPE=O.GdchClient=O.PassThroughClient=O.ExternalAccountAuthorizedUserClient=O.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=O.ExecutableError=O.PluggableAuthClient=O.DownscopedClient=O.BaseExternalAccountClient=O.ExternalAccountClient=O.IdentityPoolClient=O.AwsRequestSigner=O.AwsClient=O.UserRefreshClient=O.LoginTicket=O.ClientAuthentication=O.OAuth2Client=O.CodeChallengeMethod=O.Impersonated=O.JWT=O.JWTAccess=O.IdTokenClient=O.IAMAuth=O.GCPEnv=O.Compute=O.DEFAULT_UNIVERSE=O.AuthClient=O.gaxios=O.gcpMetadata=void 0;var iu=Jc();Object.defineProperty(O,"GoogleAuth",{enumerable:!0,get:function(){return iu.GoogleAuth}});O.gcpMetadata=yt();O.gaxios=ie();var ou=_e();Object.defineProperty(O,"AuthClient",{enumerable:!0,get:function(){return ou.AuthClient}});Object.defineProperty(O,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return ou.DEFAULT_UNIVERSE}});var jp=Wr();Object.defineProperty(O,"Compute",{enumerable:!0,get:function(){return jp.Compute}});var Dp=zr();Object.defineProperty(O,"GCPEnv",{enumerable:!0,get:function(){return Dp.GCPEnv}});var Up=zc();Object.defineProperty(O,"IAMAuth",{enumerable:!0,get:function(){return Up.IAMAuth}});var qp=Yr();Object.defineProperty(O,"IdTokenClient",{enumerable:!0,get:function(){return qp.IdTokenClient}});var Fp=ln();Object.defineProperty(O,"JWTAccess",{enumerable:!0,get:function(){return Fp.JWTAccess}});var Mp=fn();Object.defineProperty(O,"JWT",{enumerable:!0,get:function(){return Mp.JWT}});var Lp=pn();Object.defineProperty(O,"Impersonated",{enumerable:!0,get:function(){return Lp.Impersonated}});var Xn=Be();Object.defineProperty(O,"CodeChallengeMethod",{enumerable:!0,get:function(){return Xn.CodeChallengeMethod}});Object.defineProperty(O,"OAuth2Client",{enumerable:!0,get:function(){return Xn.OAuth2Client}});Object.defineProperty(O,"ClientAuthentication",{enumerable:!0,get:function(){return Xn.ClientAuthentication}});var Gp=Jr();Object.defineProperty(O,"LoginTicket",{enumerable:!0,get:function(){return Gp.LoginTicket}});var Bp=dn();Object.defineProperty(O,"UserRefreshClient",{enumerable:!0,get:function(){return Bp.UserRefreshClient}});var Hp=On();Object.defineProperty(O,"AwsClient",{enumerable:!0,get:function(){return Hp.AwsClient}});var $p=Cn();Object.defineProperty(O,"AwsRequestSigner",{enumerable:!0,get:function(){return $p.AwsRequestSigner}});var Kp=Sn();Object.defineProperty(O,"IdentityPoolClient",{enumerable:!0,get:function(){return Kp.IdentityPoolClient}});var Jp=Gn();Object.defineProperty(O,"ExternalAccountClient",{enumerable:!0,get:function(){return Jp.ExternalAccountClient}});var Vp=$e();Object.defineProperty(O,"BaseExternalAccountClient",{enumerable:!0,get:function(){return Vp.BaseExternalAccountClient}});var Wp=eu();Object.defineProperty(O,"DownscopedClient",{enumerable:!0,get:function(){return Wp.DownscopedClient}});var au=Ln();Object.defineProperty(O,"PluggableAuthClient",{enumerable:!0,get:function(){return au.PluggableAuthClient}});Object.defineProperty(O,"ExecutableError",{enumerable:!0,get:function(){return au.ExecutableError}});var cu=Hn();Object.defineProperty(O,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return cu.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}});Object.defineProperty(O,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return cu.ExternalAccountAuthorizedUserClient}});var Yp=su();Object.defineProperty(O,"PassThroughClient",{enumerable:!0,get:function(){return Yp.PassThroughClient}});var uu=Jn();Object.defineProperty(O,"GdchClient",{enumerable:!0,get:function(){return uu.GdchClient}});Object.defineProperty(O,"GDCH_SERVICE_ACCOUNT_TYPE",{enumerable:!0,get:function(){return uu.GDCH_SERVICE_ACCOUNT_TYPE}});Ip(cn(),O);var zp=new iu.GoogleAuth;O.auth=zp});
32
+ export{Eu,hc};