dd-trace 5.107.0 → 5.109.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 (66) hide show
  1. package/index.d.ts +22 -1
  2. package/package.json +6 -5
  3. package/packages/datadog-instrumentations/src/ai.js +43 -48
  4. package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js-context-methods.js +18 -0
  5. package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +111 -0
  6. package/packages/datadog-instrumentations/src/aws-sdk.js +3 -1
  7. package/packages/datadog-instrumentations/src/electron.js +1 -1
  8. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  9. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/aws-durable-execution-sdk-js.js +31 -0
  10. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
  11. package/packages/datadog-instrumentations/src/http/client.js +12 -2
  12. package/packages/datadog-instrumentations/src/ioredis.js +0 -1
  13. package/packages/datadog-instrumentations/src/iovalkey.js +1 -2
  14. package/packages/datadog-instrumentations/src/next.js +34 -0
  15. package/packages/datadog-instrumentations/src/openai.js +77 -18
  16. package/packages/datadog-instrumentations/src/redis.js +0 -1
  17. package/packages/datadog-instrumentations/src/vitest.js +60 -1
  18. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/checkpoint.js +31 -0
  19. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +55 -0
  20. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +114 -0
  21. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +128 -0
  22. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/index.js +19 -0
  23. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +224 -0
  24. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +43 -0
  25. package/packages/datadog-plugin-aws-sdk/src/base.js +1 -7
  26. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +100 -37
  27. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +44 -27
  28. package/packages/datadog-plugin-bullmq/src/filter.js +35 -0
  29. package/packages/datadog-plugin-bullmq/src/producer.js +84 -4
  30. package/packages/datadog-plugin-fs/src/index.js +1 -0
  31. package/packages/datadog-plugin-redis/src/index.js +1 -2
  32. package/packages/datadog-plugin-vitest/src/index.js +4 -1
  33. package/packages/dd-trace/src/aiguard/channels.js +0 -1
  34. package/packages/dd-trace/src/aiguard/index.js +11 -49
  35. package/packages/dd-trace/src/aiguard/integrations/evaluate.js +46 -0
  36. package/packages/dd-trace/src/aiguard/integrations/openai.js +66 -0
  37. package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +78 -0
  38. package/packages/{datadog-instrumentations/src/helpers/ai-messages.js → dd-trace/src/aiguard/messages/openai.js} +85 -193
  39. package/packages/dd-trace/src/aiguard/messages/vercel-ai.js +185 -0
  40. package/packages/dd-trace/src/appsec/channels.js +1 -0
  41. package/packages/dd-trace/src/appsec/downstream_requests.js +114 -60
  42. package/packages/dd-trace/src/appsec/iast/index.js +3 -2
  43. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +54 -12
  44. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +5 -1
  45. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +29 -4
  46. package/packages/dd-trace/src/appsec/rasp/ssrf.js +21 -12
  47. package/packages/dd-trace/src/appsec/reporter.js +1 -1
  48. package/packages/dd-trace/src/config/generated-config-types.d.ts +4 -0
  49. package/packages/dd-trace/src/config/supported-configurations.json +31 -2
  50. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +2 -0
  51. package/packages/dd-trace/src/dogstatsd.js +15 -8
  52. package/packages/dd-trace/src/exporters/agentless/index.js +7 -5
  53. package/packages/dd-trace/src/exporters/agentless/intake.js +43 -0
  54. package/packages/dd-trace/src/exporters/agentless/writer.js +5 -4
  55. package/packages/dd-trace/src/openfeature/flagging_provider.js +8 -1
  56. package/packages/dd-trace/src/plugins/ci_plugin.js +27 -2
  57. package/packages/dd-trace/src/plugins/index.js +3 -0
  58. package/packages/dd-trace/src/profiling/config.js +2 -0
  59. package/packages/dd-trace/src/profiling/profilers/events.js +26 -4
  60. package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
  61. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
  62. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
  63. package/vendor/dist/@datadog/sketches-js/index.js +1 -1
  64. package/vendor/dist/protobufjs/index.js +1 -1
  65. package/vendor/dist/protobufjs/minimal/index.js +1 -1
  66. package/packages/datadog-instrumentations/src/helpers/openai-ai-guard.js +0 -284
@@ -1 +1 @@
1
- (()=>{var t={"./protobufjs/src/util sync recursive"(t){function webpackEmptyContext(t){var r=Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}webpackEmptyContext.keys=()=>[],webpackEmptyContext.resolve=webpackEmptyContext,webpackEmptyContext.id="./protobufjs/src/util sync recursive",t.exports=webpackEmptyContext},"./long/umd/index.js"(t,r){!function(e,i){function preferDefault(t){return t.default||t}"function"==typeof define&&define.amd?define([],function(){var t={};return i(t),preferDefault(t)}):(i(r),t.exports=preferDefault(r))}("u">typeof globalThis?globalThis:"u">typeof self&&self,function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=null;try{r=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Long(t,r,e){this.low=0|t,this.high=0|r,this.unsigned=!!e}function isLong(t){return!0===(t&&t.__isLong__)}function ctz32(t){var r=Math.clz32(t&-t);return t?31-r:r}Long.prototype.__isLong__,Object.defineProperty(Long.prototype,"__isLong__",{value:!0}),Long.isLong=isLong;var e={},i={};function fromInt(t,r){var n,o,s;if(r)return(t>>>=0,(s=0<=t&&t<256)&&(o=i[t]))?o:(n=fromBits(t,0,!0),s&&(i[t]=n),n);return(t|=0,(s=-128<=t&&t<128)&&(o=e[t]))?o:(n=fromBits(t,t<0?-1:0,!1),s&&(e[t]=n),n)}function fromNumber(t,r){if(isNaN(t))return r?a:h;if(r){if(t<0)return a;if(t>=s)return d}else{if(t<=-u)return m;if(t+1>=u)return p}return t<0?fromNumber(-t,r).neg():fromBits(t%o|0,t/o|0,r)}function fromBits(t,r,e){return new Long(t,r,e)}Long.fromInt=fromInt,Long.fromNumber=fromNumber,Long.fromBits=fromBits;var n=Math.pow;function fromString(t,r,e){if(0===t.length)throw Error("empty string");if("number"==typeof r?(e=r,r=!1):r=!!r,"NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return r?a:h;if((e=e||10)<2||36<e)throw RangeError("radix");if((i=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return fromString(t.substring(1),r,e).neg();for(var i,o=fromNumber(n(e,8)),s=h,u=0;u<t.length;u+=8){var f=Math.min(8,t.length-u),l=parseInt(t.substring(u,u+f),e);if(f<8){var c=fromNumber(n(e,f));s=s.mul(c).add(fromNumber(l))}else s=(s=s.mul(o)).add(fromNumber(l))}return s.unsigned=r,s}function fromValue(t,r){return"number"==typeof t?fromNumber(t,r):"string"==typeof t?fromString(t,r):fromBits(t.low,t.high,"boolean"==typeof r?r:t.unsigned)}Long.fromString=fromString,Long.fromValue=fromValue;var o=0x100000000,s=0xffffffffffffffff,u=0x8000000000000000,f=fromInt(0x1000000),h=fromInt(0);Long.ZERO=h;var a=fromInt(0,!0);Long.UZERO=a;var l=fromInt(1);Long.ONE=l;var c=fromInt(1,!0);Long.UONE=c;var g=fromInt(-1);Long.NEG_ONE=g;var p=fromBits(-1,0x7fffffff,!1);Long.MAX_VALUE=p;var d=fromBits(-1,-1,!0);Long.MAX_UNSIGNED_VALUE=d;var m=fromBits(0,-0x80000000,!1);Long.MIN_VALUE=m;var b=Long.prototype;b.toInt=function(){return this.unsigned?this.low>>>0:this.low},b.toNumber=function(){return this.unsigned?(this.high>>>0)*o+(this.low>>>0):this.high*o+(this.low>>>0)},b.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(!this.eq(m))return"-"+this.neg().toString(t);else{var r=fromNumber(t),e=this.div(r),i=e.mul(r).sub(this);return e.toString(t)+i.toInt().toString(t)}for(var o=fromNumber(n(t,6),this.unsigned),s=this,u="";;){var f=s.div(o),h=(s.sub(f.mul(o)).toInt()>>>0).toString(t);if((s=f).isZero())return h+u;for(;h.length<6;)h="0"+h;u=""+h+u}},b.getHighBits=function(){return this.high},b.getHighBitsUnsigned=function(){return this.high>>>0},b.getLowBits=function(){return this.low},b.getLowBitsUnsigned=function(){return this.low>>>0},b.getNumBitsAbs=function(){if(this.isNegative())return this.eq(m)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,r=31;r>0&&(t&1<<r)==0;r--);return 0!=this.high?r+33:r+1},b.isSafeInteger=function(){var t=this.high>>21;return!t||!this.unsigned&&-1===t&&(0!==this.low||-2097152!==this.high)},b.isZero=function(){return 0===this.high&&0===this.low},b.eqz=b.isZero,b.isNegative=function(){return!this.unsigned&&this.high<0},b.isPositive=function(){return this.unsigned||this.high>=0},b.isOdd=function(){return(1&this.low)==1},b.isEven=function(){return(1&this.low)==0},b.equals=function(t){return isLong(t)||(t=fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&this.high===t.high&&this.low===t.low},b.eq=b.equals,b.notEquals=function(t){return!this.eq(t)},b.neq=b.notEquals,b.ne=b.notEquals,b.lessThan=function(t){return 0>this.comp(t)},b.lt=b.lessThan,b.lessThanOrEqual=function(t){return 0>=this.comp(t)},b.lte=b.lessThanOrEqual,b.le=b.lessThanOrEqual,b.greaterThan=function(t){return this.comp(t)>0},b.gt=b.greaterThan,b.greaterThanOrEqual=function(t){return this.comp(t)>=0},b.gte=b.greaterThanOrEqual,b.ge=b.greaterThanOrEqual,b.compare=function(t){if(isLong(t)||(t=fromValue(t)),this.eq(t))return 0;var r=this.isNegative(),e=t.isNegative();return r&&!e?-1:!r&&e?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},b.comp=b.compare,b.negate=function(){return!this.unsigned&&this.eq(m)?m:this.not().add(l)},b.neg=b.negate,b.add=function(t){isLong(t)||(t=fromValue(t));var r,e,i=this.high>>>16,n=65535&this.high,o=this.low>>>16,s=65535&this.low,u=t.high>>>16,f=65535&t.high,h=t.low>>>16,a=65535&t.low,l=0,c=0;return r=0+((e=0+(s+a))>>>16),e&=65535,r+=o+h,c+=r>>>16,r&=65535,c+=n+f,l+=c>>>16,c&=65535,l+=i+u,fromBits(r<<16|e,(l&=65535)<<16|c,this.unsigned)},b.subtract=function(t){return isLong(t)||(t=fromValue(t)),this.add(t.neg())},b.sub=b.subtract,b.multiply=function(t){if(this.isZero())return this;if(isLong(t)||(t=fromValue(t)),r)return fromBits(r.mul(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned);if(t.isZero())return this.unsigned?a:h;if(this.eq(m))return t.isOdd()?m:h;if(t.eq(m))return this.isOdd()?m:h;if(this.isNegative())if(t.isNegative())return this.neg().mul(t.neg());else return this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(f)&&t.lt(f))return fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var e,i,n=this.high>>>16,o=65535&this.high,s=this.low>>>16,u=65535&this.low,l=t.high>>>16,c=65535&t.high,g=t.low>>>16,p=65535&t.low,d=0,b=0;return e=0+((i=0+u*p)>>>16),i&=65535,e+=s*p,b+=e>>>16,e&=65535,e+=u*g,b+=e>>>16,e&=65535,b+=o*p,d+=b>>>16,b&=65535,b+=s*g,d+=b>>>16,b&=65535,b+=u*c,d+=b>>>16,b&=65535,d+=n*p+o*g+s*c+u*l,fromBits(e<<16|i,(d&=65535)<<16|b,this.unsigned)},b.mul=b.multiply,b.divide=function(t){if(isLong(t)||(t=fromValue(t)),t.isZero())throw Error("division by zero");if(r){var e,i,o;return this.unsigned||-0x80000000!==this.high||-1!==t.low||-1!==t.high?fromBits((this.unsigned?r.div_u:r.div_s)(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned):this}if(this.isZero())return this.unsigned?a:h;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return a;if(t.gt(this.shru(1)))return c;o=a}else{if(this.eq(m))if(t.eq(l)||t.eq(g))return m;else return t.eq(m)?l:(e=this.shr(1).div(t).shl(1)).eq(h)?t.isNegative()?l:g:(i=this.sub(t.mul(e)),o=e.add(i.div(t)));if(t.eq(m))return this.unsigned?a:h;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=h}for(i=this;i.gte(t);){for(var s=Math.ceil(Math.log(e=Math.max(1,Math.floor(i.toNumber()/t.toNumber())))/Math.LN2),u=s<=48?1:n(2,s-48),f=fromNumber(e),p=f.mul(t);p.isNegative()||p.gt(i);)e-=u,p=(f=fromNumber(e,this.unsigned)).mul(t);f.isZero()&&(f=l),o=o.add(f),i=i.sub(p)}return o},b.div=b.divide,b.modulo=function(t){return(isLong(t)||(t=fromValue(t)),r)?fromBits((this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},b.mod=b.modulo,b.rem=b.modulo,b.not=function(){return fromBits(~this.low,~this.high,this.unsigned)},b.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},b.clz=b.countLeadingZeros,b.countTrailingZeros=function(){return this.low?ctz32(this.low):ctz32(this.high)+32},b.ctz=b.countTrailingZeros,b.and=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low&t.low,this.high&t.high,this.unsigned)},b.or=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low|t.low,this.high|t.high,this.unsigned)},b.xor=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low^t.low,this.high^t.high,this.unsigned)},b.shiftLeft=function(t){return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:t<32?fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):fromBits(0,this.low<<t-32,this.unsigned)},b.shl=b.shiftLeft,b.shiftRight=function(t){return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:t<32?fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},b.shr=b.shiftRight,b.shiftRightUnsigned=function(t){return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:t<32?fromBits(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):32===t?fromBits(this.high,0,this.unsigned):fromBits(this.high>>>t-32,0,this.unsigned)},b.shru=b.shiftRightUnsigned,b.shr_u=b.shiftRightUnsigned,b.rotateLeft=function(t){var r;return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:32===t?fromBits(this.high,this.low,this.unsigned):t<32?(r=32-t,fromBits(this.low<<t|this.high>>>r,this.high<<t|this.low>>>r,this.unsigned)):(t-=32,r=32-t,fromBits(this.high<<t|this.low>>>r,this.low<<t|this.high>>>r,this.unsigned))},b.rotl=b.rotateLeft,b.rotateRight=function(t){var r;return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:32===t?fromBits(this.high,this.low,this.unsigned):t<32?(r=32-t,fromBits(this.high<<r|this.low>>>t,this.low<<r|this.high>>>t,this.unsigned)):(t-=32,r=32-t,fromBits(this.low<<r|this.high>>>t,this.high<<r|this.low>>>t,this.unsigned))},b.rotr=b.rotateRight,b.toSigned=function(){return this.unsigned?fromBits(this.low,this.high,!1):this},b.toUnsigned=function(){return this.unsigned?this:fromBits(this.low,this.high,!0)},b.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},b.toBytesLE=function(){var t=this.high,r=this.low;return[255&r,r>>>8&255,r>>>16&255,r>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},b.toBytesBE=function(){var t=this.high,r=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,r>>>24,r>>>16&255,r>>>8&255,255&r]},Long.fromBytes=function(t,r,e){return e?Long.fromBytesLE(t,r):Long.fromBytesBE(t,r)},Long.fromBytesLE=function(t,r){return new Long(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)},Long.fromBytesBE=function(t,r){return new Long(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)},"function"==typeof BigInt&&(Long.fromBigInt=function(t,r){return fromBits(Number(BigInt.asIntN(32,t)),Number(BigInt.asIntN(32,t>>BigInt(32))),r)},Long.fromValue=function(t,r){return"bigint"==typeof t?Long.fromBigInt(t,r):fromValue(t,r)},b.toBigInt=function(){var t=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|t}),t.default=Long})},"./protobufjs/minimal.js"(t,r,e){"use strict";t.exports=e("./protobufjs/src/index-minimal.js")},"./protobufjs/src/index-minimal.js"(t,r,e){"use strict";function configure(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=e("./protobufjs/src/writer.js"),r.BufferWriter=e("./protobufjs/src/writer_buffer.js"),r.Reader=e("./protobufjs/src/reader.js"),r.BufferReader=e("./protobufjs/src/reader_buffer.js"),r.util=e("./protobufjs/src/util/minimal.js"),r.rpc=e("./protobufjs/src/rpc.js"),r.roots=e("./protobufjs/src/roots.js"),r.configure=configure,configure()},"./protobufjs/src/reader.js"(t,r,e){"use strict";t.exports=Reader;var i,n=e("./protobufjs/src/util/minimal.js"),o=n.LongBits,s=n.utf8;function indexOutOfRange(t,r){return RangeError("index out of range: "+t.pos+" + "+(r||1)+" > "+t.len)}function Reader(t){this.buf=t,this.pos=0,this.len=t.length}var u="u">typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new Reader(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new Reader(t);throw Error("illegal buffer")},create=function(){return n.Buffer?function(t){return(Reader.create=function(t){return n.Buffer.isBuffer(t)?new i(t):u(t)})(t)}:u};function readLongVarint(){var t=new o(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*r)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw indexOutOfRange(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*r)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*r)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*r+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw indexOutOfRange(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*r+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function readFixed32_end(t,r){return(t[r-4]|t[r-3]<<8|t[r-2]<<16|t[r-1]<<24)>>>0}function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new o(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader.create=create(),Reader.prototype._slice=n.Array.prototype.subarray||n.Array.prototype.slice,Reader.prototype.raw=function(t,r){return Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},Reader.prototype.uint32=function(){var t=this.buf,r=this.pos,e=(127&t[r])>>>0;if(t[r++]<128||(e=(e|(127&t[r])<<7)>>>0,t[r++]<128)||(e=(e|(127&t[r])<<14)>>>0,t[r++]<128)||(e=(e|(127&t[r])<<21)>>>0,t[r++]<128)||(e=(e|(15&t[r])<<28)>>>0,t[r++]<128))return this.pos=r,e;for(var i=0;i<5;++i){if(r>=this.len)throw this.pos=r,indexOutOfRange(this);if(t[r++]<128)return this.pos=r,e}throw this.pos=r,Error("invalid varint encoding")},Reader.prototype.tag=function(){var t=this.buf,r=this.pos,e=(127&t[r])>>>0;if(t[r++]<128||(e=(e|(127&t[r])<<7)>>>0,t[r++]<128)||(e=(e|(127&t[r])<<14)>>>0,t[r++]<128)||(e=(e|(127&t[r])<<21)>>>0,t[r++]<128))return this.pos=r,e;if(e=(e|(15&t[r])<<28)>>>0,t[r]<128&&(112&t[r])==0)return this.pos=r+1,e;throw this.pos=r+1,Error("invalid tag encoding")},Reader.prototype.int32=function(){return 0|this.uint32()},Reader.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)},Reader.prototype.bool=function(){for(var t,r=!1,e=0;e<10;++e){if(this.pos>=this.len)throw indexOutOfRange(this);if(127&(t=this.buf[this.pos++])&&(r=!0),t<128)return r}throw Error("invalid varint encoding")},Reader.prototype.fixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.sfixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return 0|readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.float=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var t=n.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},Reader.prototype.double=function(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var t=n.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},Reader.prototype.bytes=function(){var t=this.uint32(),r=this.pos,e=this.pos+t;if(e>this.len)throw indexOutOfRange(this,t);return this.pos=e,this.raw(r,e)},Reader.prototype.string=function(){var t=this.uint32(),r=this.pos,e=this.pos+t;if(e>this.len)throw indexOutOfRange(this,t);return this.pos=e,s.read(this.buf,r,e)},Reader.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw indexOutOfRange(this,t);this.pos+=t}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(128&this.buf[this.pos++]);return this},Reader.recursionLimit=n.recursionLimit,Reader.prototype.skipType=function(t,r,e){if(void 0===r&&(r=0),r>Reader.recursionLimit)throw Error("max depth exceeded");if(0===e)throw Error("illegal tag: field number 0");switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;;){var i=this.tag(),n=i>>>3;if(t=7&i,!n)throw Error("illegal tag: field number 0");if(4===t){if(void 0!==e&&n!==e)throw Error("invalid end group tag");break}this.skipType(t,r+1,n)}break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},Reader._configure=function(t){i=t,Reader.create=create(),i._configure();var r=n.Long?"toLong":"toNumber";n.merge(Reader.prototype,{int64:function(){return readLongVarint.call(this)[r](!1)},uint64:function(){return readLongVarint.call(this)[r](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[r](!1)},fixed64:function(){return readFixed64.call(this)[r](!0)},sfixed64:function(){return readFixed64.call(this)[r](!1)}})}},"./protobufjs/src/reader_buffer.js"(t,r,e){"use strict";t.exports=BufferReader;var i=e("./protobufjs/src/reader.js");(BufferReader.prototype=Object.create(i.prototype)).constructor=BufferReader;var n=e("./protobufjs/src/util/minimal.js");function BufferReader(t){i.call(this,t)}BufferReader._configure=function(){n.Buffer&&(BufferReader.prototype._slice=n.Buffer.prototype.slice)},BufferReader.prototype.raw=function(t,r){return t===r?n.Buffer.alloc(0):this._slice.call(this.buf,t,r)},BufferReader.prototype.string=function(){var t=this.uint32(),r=this.pos,e=this.pos+t;if(e>this.len)throw RangeError("index out of range: "+this.pos+" + "+t+" > "+this.len);return this.pos=e,this.buf.utf8Slice?this.buf.utf8Slice(r,e):this.buf.toString("utf-8",r,e)},BufferReader._configure()},"./protobufjs/src/roots.js"(t){"use strict";t.exports={}},"./protobufjs/src/rpc.js"(t,r,e){"use strict";r.Service=e("./protobufjs/src/rpc/service.js")},"./protobufjs/src/rpc/service.js"(t,r,e){"use strict";t.exports=Service;var i=e("./protobufjs/src/util/minimal.js");function Service(t,r,e){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");i.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=!!r,this.responseDelimited=!!e}(Service.prototype=Object.create(i.EventEmitter.prototype)).constructor=Service,Service.prototype.rpcCall=function rpcCall(t,r,e,n,o){if(!n)throw TypeError("request must be specified");var s=this;if(!o)return i.asPromise(rpcCall,s,t,r,e,n);if(!s.rpcImpl)return void setTimeout(function(){o(Error("already ended"))},0);try{return s.rpcImpl(t,r[s.requestDelimited?"encodeDelimited":"encode"](n).finish(),function(r,i){if(r)return s.emit("error",r,t),o(r);if(null===i)return void s.end(!0);if(!(i instanceof e))try{i=e[s.responseDelimited?"decodeDelimited":"decode"](i)}catch(r){return s.emit("error",r,t),o(r)}return s.emit("data",i,t),o(null,i)})}catch(r){s.emit("error",r,t),setTimeout(function(){o(r)},0);return}},Service.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},"./protobufjs/src/util/aspromise.js"(t){"use strict";t.exports=function asPromise(t,r){for(var e=Array(arguments.length-1),i=0,n=2,o=!0;n<arguments.length;)e[i++]=arguments[n++];return new Promise(function(n,s){e[i]=function(t){if(o)if(o=!1,t)s(t);else{for(var r=Array(arguments.length-1),e=0;e<r.length;)r[e++]=arguments[e];n.apply(null,r)}};try{t.apply(r||null,e)}catch(t){o&&(o=!1,s(t))}})}},"./protobufjs/src/util/base64.js"(t,r){"use strict";r.length=function(t){var r=t.length;if(!r)return 0;for(;r>0&&"="===t.charAt(r-1);)--r;return Math.floor(3*r/4)};for(var e=Array(64),i=Array(123),n=0;n<64;)i[e[n]=n<26?n+65:n<52?n+71:n<62?n-4:n-59|43]=n++;i[45]=62,i[95]=63,r.encode=function(t,r,i){for(var n,o=null,s=[],u=0,f=0;r<i;){var h=t[r++];switch(f){case 0:s[u++]=e[h>>2],n=(3&h)<<4,f=1;break;case 1:s[u++]=e[n|h>>4],n=(15&h)<<2,f=2;break;case 2:s[u++]=e[n|h>>6],s[u++]=e[63&h],f=0}u>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),u=0)}return(f&&(s[u++]=e[n],s[u++]=61,1===f&&(s[u++]=61)),o)?(u&&o.push(String.fromCharCode.apply(String,s.slice(0,u))),o.join("")):String.fromCharCode.apply(String,s.slice(0,u))};var o="invalid encoding";r.decode=function(t,r,e){for(var n,s=e,u=0,f=0;f<t.length;){var h=t.charCodeAt(f++);if(61===h&&u>1)break;if(void 0===(h=i[h]))throw Error(o);switch(u){case 0:n=h,u=1;break;case 1:r[e++]=n<<2|(48&h)>>4,n=h,u=2;break;case 2:r[e++]=(15&n)<<4|(60&h)>>2,n=h,u=3;break;case 3:r[e++]=(3&n)<<6|h,u=0}}if(1===u)throw Error(o);return e-s};var s=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,u=/[-_]/,f=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==)?|[A-Za-z0-9_-]{3}=?)?$/;r.test=function(t){return s.test(t)||u.test(t)&&f.test(t)}},"./protobufjs/src/util/eventemitter.js"(t){"use strict";function EventEmitter(){this._listeners=Object.create(null)}t.exports=EventEmitter,EventEmitter.prototype.on=function(t,r,e){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:r,ctx:e||this}),this},EventEmitter.prototype.off=function(t,r){if(void 0===t)this._listeners=Object.create(null);else if(void 0===r)this._listeners[t]=[];else{var e=this._listeners[t];if(!e)return this;for(var i=0;i<e.length;)e[i].fn===r?e.splice(i,1):++i}return this},EventEmitter.prototype.emit=function(t){var r=this._listeners[t];if(r){for(var e=[],i=1;i<arguments.length;)e.push(arguments[i++]);for(i=0;i<r.length;)r[i].fn.apply(r[i++].ctx,e)}return this}},"./protobufjs/src/util/float.js"(t){"use strict";function factory(t){if("u">typeof Float32Array)!function(){var r=new Float32Array([-0]),e=new Uint8Array(r.buffer),i=128===e[3];function writeFloat_f32_cpy(t,i,n){r[0]=t,i[n]=e[0],i[n+1]=e[1],i[n+2]=e[2],i[n+3]=e[3]}function writeFloat_f32_rev(t,i,n){r[0]=t,i[n]=e[3],i[n+1]=e[2],i[n+2]=e[1],i[n+3]=e[0]}function readFloat_f32_cpy(t,i){return e[0]=t[i],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],r[0]}function readFloat_f32_rev(t,i){return e[3]=t[i],e[2]=t[i+1],e[1]=t[i+2],e[0]=t[i+3],r[0]}t.writeFloatLE=i?writeFloat_f32_cpy:writeFloat_f32_rev,t.writeFloatBE=i?writeFloat_f32_rev:writeFloat_f32_cpy,t.readFloatLE=i?readFloat_f32_cpy:readFloat_f32_rev,t.readFloatBE=i?readFloat_f32_rev:readFloat_f32_cpy}();else{function writeFloat_ieee754(t,r,e,i){var n=+(r<0);if(n&&(r=-r),0===r)t(1/r>0?0:0x80000000,e,i);else if(isNaN(r))t(0x7fc00000,e,i);else if(r>34028234663852886e22)t((n<<31|0x7f800000)>>>0,e,i);else if(r<11754943508222875e-54)t((n<<31|Math.round(r/1401298464324817e-60))>>>0,e,i);else{var o=Math.floor(Math.log(r)/Math.LN2),s=8388607&Math.round(r*Math.pow(2,-o)*8388608);t((n<<31|o+127<<23|s)>>>0,e,i)}}function readFloat_ieee754(t,r,e){var i=t(r,e),n=(i>>31)*2+1,o=i>>>23&255,s=8388607&i;return 255===o?s?NaN:1/0*n:0===o?1401298464324817e-60*n*s:n*Math.pow(2,o-150)*(s+8388608)}t.writeFloatLE=writeFloat_ieee754.bind(null,writeUintLE),t.writeFloatBE=writeFloat_ieee754.bind(null,writeUintBE),t.readFloatLE=readFloat_ieee754.bind(null,readUintLE),t.readFloatBE=readFloat_ieee754.bind(null,readUintBE)}if("u">typeof Float64Array)!function(){var r=new Float64Array([-0]),e=new Uint8Array(r.buffer),i=128===e[7];function writeDouble_f64_cpy(t,i,n){r[0]=t,i[n]=e[0],i[n+1]=e[1],i[n+2]=e[2],i[n+3]=e[3],i[n+4]=e[4],i[n+5]=e[5],i[n+6]=e[6],i[n+7]=e[7]}function writeDouble_f64_rev(t,i,n){r[0]=t,i[n]=e[7],i[n+1]=e[6],i[n+2]=e[5],i[n+3]=e[4],i[n+4]=e[3],i[n+5]=e[2],i[n+6]=e[1],i[n+7]=e[0]}function readDouble_f64_cpy(t,i){return e[0]=t[i],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],e[4]=t[i+4],e[5]=t[i+5],e[6]=t[i+6],e[7]=t[i+7],r[0]}function readDouble_f64_rev(t,i){return e[7]=t[i],e[6]=t[i+1],e[5]=t[i+2],e[4]=t[i+3],e[3]=t[i+4],e[2]=t[i+5],e[1]=t[i+6],e[0]=t[i+7],r[0]}t.writeDoubleLE=i?writeDouble_f64_cpy:writeDouble_f64_rev,t.writeDoubleBE=i?writeDouble_f64_rev:writeDouble_f64_cpy,t.readDoubleLE=i?readDouble_f64_cpy:readDouble_f64_rev,t.readDoubleBE=i?readDouble_f64_rev:readDouble_f64_cpy}();else{function writeDouble_ieee754(t,r,e,i,n,o){var s,u=+(i<0);if(u&&(i=-i),0===i)t(0,n,o+r),t(1/i>0?0:0x80000000,n,o+e);else if(isNaN(i))t(0,n,o+r),t(0x7ff80000,n,o+e);else if(i>17976931348623157e292)t(0,n,o+r),t((u<<31|0x7ff00000)>>>0,n,o+e);else if(i<22250738585072014e-324)t((s=i/5e-324)>>>0,n,o+r),t((u<<31|s/0x100000000)>>>0,n,o+e);else{var f=Math.floor(Math.log(i)/Math.LN2);1024===f&&(f=1023),t(0x10000000000000*(s=i*Math.pow(2,-f))>>>0,n,o+r),t((u<<31|f+1023<<20|1048576*s&1048575)>>>0,n,o+e)}}function readDouble_ieee754(t,r,e,i,n){var o=t(i,n+r),s=t(i,n+e),u=(s>>31)*2+1,f=s>>>20&2047,h=0x100000000*(1048575&s)+o;return 2047===f?h?NaN:1/0*u:0===f?5e-324*u*h:u*Math.pow(2,f-1075)*(h+0x10000000000000)}t.writeDoubleLE=writeDouble_ieee754.bind(null,writeUintLE,0,4),t.writeDoubleBE=writeDouble_ieee754.bind(null,writeUintBE,4,0),t.readDoubleLE=readDouble_ieee754.bind(null,readUintLE,0,4),t.readDoubleBE=readDouble_ieee754.bind(null,readUintBE,4,0)}return t}function writeUintLE(t,r,e){r[e]=255&t,r[e+1]=t>>>8&255,r[e+2]=t>>>16&255,r[e+3]=t>>>24}function writeUintBE(t,r,e){r[e]=t>>>24,r[e+1]=t>>>16&255,r[e+2]=t>>>8&255,r[e+3]=255&t}function readUintLE(t,r){return(t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24)>>>0}function readUintBE(t,r){return(t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3])>>>0}t.exports=factory(factory)},"./protobufjs/src/util/inquire.js"(t,r,e){"use strict";t.exports=function inquire(t){try{var r=e("./protobufjs/src/util sync recursive")(t);if(r&&(r.length||Object.keys(r).length))return r;return null}catch(t){return null}}},"./protobufjs/src/util/longbits.js"(t,r,e){"use strict";t.exports=LongBits;var i=e("./protobufjs/src/util/minimal.js");function LongBits(t,r){this.lo=t>>>0,this.hi=r>>>0}var n=LongBits.zero=new LongBits(0,0);n.toNumber=function(){return 0},n.zzEncode=n.zzDecode=function(){return this},n.length=function(){return 1};var o=LongBits.zeroHash="\0\0\0\0\0\0\0\0";LongBits.fromNumber=function(t){if(0===t)return n;var r=t<0;r&&(t=-t);var e=t>>>0,i=(t-e)/0x100000000>>>0;return r&&(i=~i>>>0,e=~e>>>0,++e>0xffffffff&&(e=0,++i>0xffffffff&&(i=0))),new LongBits(e,i)},LongBits.from=function(t){if("number"==typeof t)return LongBits.fromNumber(t);if(i.isString(t))if(!i.Long)return LongBits.fromNumber(parseInt(t,10));else t=i.Long.fromString(t);return t.low||t.high?new LongBits(t.low>>>0,t.high>>>0):n},LongBits.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var r=~this.lo+1>>>0,e=~this.hi>>>0;return r||(e=e+1>>>0),-(r+0x100000000*e)}return this.lo+0x100000000*this.hi},LongBits.prototype.toLong=function(t){return i.Long?new i.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}};var s=String.prototype.charCodeAt;LongBits.fromHash=function(t){return t===o?n:new LongBits((s.call(t,0)|s.call(t,1)<<8|s.call(t,2)<<16|s.call(t,3)<<24)>>>0,(s.call(t,4)|s.call(t,5)<<8|s.call(t,6)<<16|s.call(t,7)<<24)>>>0)},LongBits.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},LongBits.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},LongBits.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},LongBits.prototype.length=function(){var t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return 0===e?0===r?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:e<128?9:10}},"./protobufjs/src/util/minimal.js"(t,r,e){"use strict";function isUnsafeProperty(t){return"__proto__"===t||"prototype"===t||"constructor"===t}function merge(t){var r="boolean"==typeof arguments[arguments.length-1],e=r?arguments.length-1:arguments.length;r=r&&arguments[arguments.length-1];for(var i=1;i<e;++i){var n=arguments[i];if(n)for(var o=Object.keys(n),s=0;s<o.length;++s)isUnsafeProperty(o[s])||void 0!==t[o[s]]&&r||(t[o[s]]=n[o[s]])}return t}function newError(t){function CustomError(t,r){if(!(this instanceof CustomError))return new CustomError(t,r);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,CustomError):Object.defineProperty(this,"stack",{value:Error().stack||""}),r&&merge(this,r)}return CustomError.prototype=Object.create(Error.prototype,{constructor:{value:CustomError,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return t},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),CustomError}r.asPromise=e("./protobufjs/src/util/aspromise.js"),r.base64=e("./protobufjs/src/util/base64.js"),r.EventEmitter=e("./protobufjs/src/util/eventemitter.js"),r.float=e("./protobufjs/src/util/float.js"),r.inquire=e("./protobufjs/src/util/inquire.js"),r.utf8=e("./protobufjs/src/util/utf8.js"),r.pool=e("./protobufjs/src/util/pool.js"),r.LongBits=e("./protobufjs/src/util/longbits.js"),r.isUnsafeProperty=isUnsafeProperty,r.isNode=!!("u">typeof global&&global&&global.process&&global.process.versions&&global.process.versions.node),r.global=r.isNode&&global||"u">typeof window&&window||"u">typeof self&&self||this,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},r.isString=function(t){return"string"==typeof t||t instanceof String},r.isObject=function(t){return t&&"object"==typeof t},r.isset=r.isSet=function(t,r){var e=t[r];return!!(null!=e&&t.hasOwnProperty(r))&&("object"!=typeof e||(Array.isArray(e)?e.length:Object.keys(e).length)>0)},r.Buffer=function(){try{var t=r.global.Buffer;return t.prototype.utf8Write?t:null}catch(t){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(t){return"number"==typeof t?r.Buffer?r._Buffer_allocUnsafe(t):new r.Array(t):r.Buffer?r._Buffer_from(t):"u"<typeof Uint8Array?t:new Uint8Array(t)},r.Array="u">typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||function(){try{var t=e("./long/umd/index.js");return t&&t.isLong?t:null}catch(t){return null}}(),r.key2Re=/^(?:true|false|0|1)$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\x00-\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(t){return t?r.LongBits.from(t).toHash():r.LongBits.zeroHash},r.longFromHash=function(t,e){var i=r.LongBits.fromHash(t);return r.Long?r.Long.fromBits(i.lo,i.hi,e):i.toNumber(!!e)},r.longFromKey=function(t,e){return r.key64Re.test(t)&&!r.key32Re.test(t)?r.longFromHash(t,e):t},r.boolFromKey=function(t){return"true"===t||"1"===t},r.merge=merge,r.nestingLimit=32,r.recursionLimit=100,r.makeProp=function(t,r,e){Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:void 0===e||e,configurable:!0,writable:!0})},r.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},r.newError=newError,r.ProtocolError=newError("ProtocolError"),r.oneOfGetter=function(t){for(var r={},e=0;e<t.length;++e)r[t[e]]=1;return function(){for(var t=Object.keys(this),e=t.length-1;e>-1;--e)if(1===r[t[e]]&&void 0!==this[t[e]]&&null!==this[t[e]])return t[e]}},r.oneOfSetter=function(t){return function(r){for(var e=0;e<t.length;++e)t[e]!==r&&delete this[t[e]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var t=r.Buffer;if(!t){r._Buffer_from=r._Buffer_allocUnsafe=null;return}r._Buffer_from=t.from!==Uint8Array.from&&t.from||function(r,e){return new t(r,e)},r._Buffer_allocUnsafe=t.allocUnsafe||function(r){return new t(r)}}},"./protobufjs/src/util/pool.js"(t){"use strict";t.exports=function pool(t,r,e){var i=e||8192,n=i>>>1,o=null,s=i;return function(e){if(e<1||e>n)return t(e);s+e>i&&(o=t(i),s=0);var u=r.call(o,s,s+=e);return 7&s&&(s=(7|s)+1),u}}},"./protobufjs/src/util/utf8.js"(t,r){"use strict";function utf8_read_js(t,r,e,i){for(var n=r;n<e;){var o=t[n++];if(o<=127)i+=String.fromCharCode(o);else if(o>=192&&o<224){var s=(31&o)<<6|63&t[n++];i+=s>=128?String.fromCharCode(s):"�"}else if(o>=224&&o<240){var u=(15&o)<<12|(63&t[n++])<<6|63&t[n++];i+=u>=2048?String.fromCharCode(u):"�"}else if(o>=240){var f=(7&o)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++];f<65536||f>1114111?i+="�":(f-=65536,i+=String.fromCharCode(55296+(f>>10)),i+=String.fromCharCode(56320+(1023&f)))}}return i}r.length=function(t){for(var r=0,e=0,i=0;i<t.length;++i)(e=t.charCodeAt(i))<128?r+=1:e<2048?r+=2:(64512&e)==55296&&(64512&t.charCodeAt(i+1))==56320?(++i,r+=4):r+=3;return r},r.read=function(t,r,e){if(e-r<1)return"";for(var i,n,o,s,u,f,h,a,l="",c=r;c+7<e;c+=8){if(i=t[c],n=t[c+1],o=t[c+2],s=t[c+3],u=t[c+4],f=t[c+5],(i|n|o|s|u|f|(h=t[c+6])|(a=t[c+7]))&128)return utf8_read_js(t,c,e,l);l+=String.fromCharCode(i,n,o,s,u,f,h,a)}for(;c<e;++c){if(128&(i=t[c]))return utf8_read_js(t,c,e,l);l+=String.fromCharCode(i)}return l},r.write=function(t,r,e){for(var i,n,o=e,s=0;s<t.length;++s)(i=t.charCodeAt(s))<128?r[e++]=i:(i<2048?r[e++]=i>>6|192:((64512&i)==55296&&(64512&(n=t.charCodeAt(s+1)))==56320?(i=65536+((1023&i)<<10)+(1023&n),++s,r[e++]=i>>18|240,r[e++]=i>>12&63|128):r[e++]=i>>12|224,r[e++]=i>>6&63|128),r[e++]=63&i|128);return e-o}},"./protobufjs/src/writer.js"(t,r,e){"use strict";t.exports=Writer;var i,n=e("./protobufjs/src/util/minimal.js"),o=n.LongBits,s=n.base64,u=n.utf8;function Op(t,r,e){this.fn=t,this.len=r,this.next=void 0,this.val=e}function noop(){}function State(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function Writer(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}var create=function(){return n.Buffer?function(){return(Writer.create=function(){return new i})()}:function(){return new Writer}};function writeByte(t,r,e){r[e]=255&t}function writeStringAscii(t,r,e){for(var i=0;i<t.length;)r[e++]=t.charCodeAt(i++)}function writeVarint32(t,r,e){for(;t>127;)r[e++]=127&t|128,t>>>=7;r[e]=t}function VarintOp(t,r){this.len=t,this.next=void 0,this.val=r}function writeVarint64(t,r,e){for(var i=t.lo,n=t.hi;n;)r[e++]=127&i|128,i=(i>>>7|n<<25)>>>0,n>>>=7;for(;i>127;)r[e++]=127&i|128,i>>>=7;r[e++]=i}function writeFixed32(t,r,e){r[e]=255&t,r[e+1]=t>>>8&255,r[e+2]=t>>>16&255,r[e+3]=t>>>24}Writer.create=create(),Writer.alloc=function(t){return new n.Array(t)},n.Array!==Array&&(Writer.alloc=n.pool(Writer.alloc,n.Array.prototype.subarray)),Writer.prototype._push=function(t,r,e){return this.tail=this.tail.next=new Op(t,r,e),this.len+=r,this},VarintOp.prototype=Object.create(Op.prototype),VarintOp.prototype.fn=writeVarint32,Writer.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new VarintOp((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<0x10000000?4:5,t)).len,this},Writer.prototype.int32=function(t){return(t|=0)<0?this._push(writeVarint64,10,o.fromNumber(t)):this.uint32(t)},Writer.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},Writer.prototype.uint64=function(t){var r=o.from(t);return this._push(writeVarint64,r.length(),r)},Writer.prototype.int64=Writer.prototype.uint64,Writer.prototype.sint64=function(t){var r=o.from(t).zzEncode();return this._push(writeVarint64,r.length(),r)},Writer.prototype.bool=function(t){return this._push(writeByte,1,+!!t)},Writer.prototype.fixed32=function(t){return this._push(writeFixed32,4,t>>>0)},Writer.prototype.sfixed32=Writer.prototype.fixed32,Writer.prototype.fixed64=function(t){var r=o.from(t);return this._push(writeFixed32,4,r.lo)._push(writeFixed32,4,r.hi)},Writer.prototype.sfixed64=Writer.prototype.fixed64,Writer.prototype.float=function(t){return this._push(n.float.writeFloatLE,4,t)},Writer.prototype.double=function(t){return this._push(n.float.writeDoubleLE,8,t)};var f=n.Array.prototype.set?function(t,r,e){r.set(t,e)}:function(t,r,e){for(var i=0;i<t.length;++i)r[e+i]=t[i]};Writer.prototype.bytes=function(t){var r=t.length>>>0;if(!r)return this._push(writeByte,1,0);if(n.isString(t)){var e=Writer.alloc(r=s.length(t));s.decode(t,e,0),t=e}return this.uint32(r)._push(f,r,t)},Writer.prototype.raw=function(t){var r=t.length>>>0;return r?this._push(f,r,t):this},Writer.prototype.string=function(t){var r=u.length(t);return r?this.uint32(r)._push(r===t.length?writeStringAscii:u.write,r,t):this._push(writeByte,1,0)},Writer.prototype.fork=function(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this},Writer.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop,0,0),this.len=0),this},Writer.prototype.ldelim=function(){var t=this.head,r=this.tail,e=this.len;return this.reset().uint32(e),e&&(this.tail.next=t.next,this.tail=r,this.len+=e),this},Writer.prototype.finish=function(){return this.finishInto(this.constructor.alloc(this.len),0)},Writer.prototype.finishInto=function(t,r){void 0===r&&(r=0);for(var e=this.head.next,i=r;e;)e.fn(e.val,t,i),i+=e.len,e=e.next;return t},Writer._configure=function(t){i=t,Writer.create=create(),i._configure()}},"./protobufjs/src/writer_buffer.js"(t,r,e){"use strict";t.exports=BufferWriter;var i=e("./protobufjs/src/writer.js");(BufferWriter.prototype=Object.create(i.prototype)).constructor=BufferWriter;var n=e("./protobufjs/src/util/minimal.js");function BufferWriter(){i.call(this)}function writeStringBufferAscii(t,r,e){for(var i=0;i<t.length;)r[e++]=t.charCodeAt(i++)}function writeStringBuffer(t,r,e){t.length<40?n.utf8.write(t,r,e):r.utf8Write?r.utf8Write(t,e):r.write(t,e)}BufferWriter._configure=function(){BufferWriter.alloc=n._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=n.Buffer&&n.Buffer.prototype instanceof Uint8Array&&"set"===n.Buffer.prototype.set.name?function(t,r,e){r.set(t,e)}:function(t,r,e){if(t.copy)t.copy(r,e,0,t.length);else for(var i=0;i<t.length;)r[e++]=t[i++]}},BufferWriter.prototype.bytes=function(t){n.isString(t)&&(t=n._Buffer_from(t,"base64"));var r=t.length>>>0;return this.uint32(r),r&&this._push(BufferWriter.writeBytesBuffer,r,t),this},BufferWriter.prototype.raw=function(t){var r=t.length>>>0;return r?this._push(BufferWriter.writeBytesBuffer,r,t):this},BufferWriter.prototype.string=function(t){var r=n.Buffer.byteLength(t);return this.uint32(r),r&&this._push(r===t.length&&r<40?writeStringBufferAscii:writeStringBuffer,r,t),this},BufferWriter._configure()}},r={};function __webpack_require__(e){var i=r[e];if(void 0!==i)return i.exports;var n=r[e]={exports:{}};return t[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r);var e=__webpack_require__("./protobufjs/minimal.js");module.exports=e})();
1
+ (()=>{var t={"./protobufjs/src/util sync recursive"(t){function webpackEmptyContext(t){var r=Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}webpackEmptyContext.keys=()=>[],webpackEmptyContext.resolve=webpackEmptyContext,webpackEmptyContext.id="./protobufjs/src/util sync recursive",t.exports=webpackEmptyContext},"./long/umd/index.js"(t,r){!function(e,i){function preferDefault(t){return t.default||t}"function"==typeof define&&define.amd?define([],function(){var t={};return i(t),preferDefault(t)}):(i(r),t.exports=preferDefault(r))}("u">typeof globalThis?globalThis:"u">typeof self&&self,function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=null;try{r=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Long(t,r,e){this.low=0|t,this.high=0|r,this.unsigned=!!e}function isLong(t){return!0===(t&&t.__isLong__)}function ctz32(t){var r=Math.clz32(t&-t);return t?31-r:r}Long.prototype.__isLong__,Object.defineProperty(Long.prototype,"__isLong__",{value:!0}),Long.isLong=isLong;var e={},i={};function fromInt(t,r){var n,o,s;if(r)return(t>>>=0,(s=0<=t&&t<256)&&(o=i[t]))?o:(n=fromBits(t,0,!0),s&&(i[t]=n),n);return(t|=0,(s=-128<=t&&t<128)&&(o=e[t]))?o:(n=fromBits(t,t<0?-1:0,!1),s&&(e[t]=n),n)}function fromNumber(t,r){if(isNaN(t))return r?a:h;if(r){if(t<0)return a;if(t>=s)return d}else{if(t<=-u)return m;if(t+1>=u)return p}return t<0?fromNumber(-t,r).neg():fromBits(t%o|0,t/o|0,r)}function fromBits(t,r,e){return new Long(t,r,e)}Long.fromInt=fromInt,Long.fromNumber=fromNumber,Long.fromBits=fromBits;var n=Math.pow;function fromString(t,r,e){if(0===t.length)throw Error("empty string");if("number"==typeof r?(e=r,r=!1):r=!!r,"NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return r?a:h;if((e=e||10)<2||36<e)throw RangeError("radix");if((i=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return fromString(t.substring(1),r,e).neg();for(var i,o=fromNumber(n(e,8)),s=h,u=0;u<t.length;u+=8){var f=Math.min(8,t.length-u),l=parseInt(t.substring(u,u+f),e);if(f<8){var c=fromNumber(n(e,f));s=s.mul(c).add(fromNumber(l))}else s=(s=s.mul(o)).add(fromNumber(l))}return s.unsigned=r,s}function fromValue(t,r){return"number"==typeof t?fromNumber(t,r):"string"==typeof t?fromString(t,r):fromBits(t.low,t.high,"boolean"==typeof r?r:t.unsigned)}Long.fromString=fromString,Long.fromValue=fromValue;var o=0x100000000,s=0xffffffffffffffff,u=0x8000000000000000,f=fromInt(0x1000000),h=fromInt(0);Long.ZERO=h;var a=fromInt(0,!0);Long.UZERO=a;var l=fromInt(1);Long.ONE=l;var c=fromInt(1,!0);Long.UONE=c;var g=fromInt(-1);Long.NEG_ONE=g;var p=fromBits(-1,0x7fffffff,!1);Long.MAX_VALUE=p;var d=fromBits(-1,-1,!0);Long.MAX_UNSIGNED_VALUE=d;var m=fromBits(0,-0x80000000,!1);Long.MIN_VALUE=m;var b=Long.prototype;b.toInt=function(){return this.unsigned?this.low>>>0:this.low},b.toNumber=function(){return this.unsigned?(this.high>>>0)*o+(this.low>>>0):this.high*o+(this.low>>>0)},b.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(!this.eq(m))return"-"+this.neg().toString(t);else{var r=fromNumber(t),e=this.div(r),i=e.mul(r).sub(this);return e.toString(t)+i.toInt().toString(t)}for(var o=fromNumber(n(t,6),this.unsigned),s=this,u="";;){var f=s.div(o),h=(s.sub(f.mul(o)).toInt()>>>0).toString(t);if((s=f).isZero())return h+u;for(;h.length<6;)h="0"+h;u=""+h+u}},b.getHighBits=function(){return this.high},b.getHighBitsUnsigned=function(){return this.high>>>0},b.getLowBits=function(){return this.low},b.getLowBitsUnsigned=function(){return this.low>>>0},b.getNumBitsAbs=function(){if(this.isNegative())return this.eq(m)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,r=31;r>0&&(t&1<<r)==0;r--);return 0!=this.high?r+33:r+1},b.isSafeInteger=function(){var t=this.high>>21;return!t||!this.unsigned&&-1===t&&(0!==this.low||-2097152!==this.high)},b.isZero=function(){return 0===this.high&&0===this.low},b.eqz=b.isZero,b.isNegative=function(){return!this.unsigned&&this.high<0},b.isPositive=function(){return this.unsigned||this.high>=0},b.isOdd=function(){return(1&this.low)==1},b.isEven=function(){return(1&this.low)==0},b.equals=function(t){return isLong(t)||(t=fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&this.high===t.high&&this.low===t.low},b.eq=b.equals,b.notEquals=function(t){return!this.eq(t)},b.neq=b.notEquals,b.ne=b.notEquals,b.lessThan=function(t){return 0>this.comp(t)},b.lt=b.lessThan,b.lessThanOrEqual=function(t){return 0>=this.comp(t)},b.lte=b.lessThanOrEqual,b.le=b.lessThanOrEqual,b.greaterThan=function(t){return this.comp(t)>0},b.gt=b.greaterThan,b.greaterThanOrEqual=function(t){return this.comp(t)>=0},b.gte=b.greaterThanOrEqual,b.ge=b.greaterThanOrEqual,b.compare=function(t){if(isLong(t)||(t=fromValue(t)),this.eq(t))return 0;var r=this.isNegative(),e=t.isNegative();return r&&!e?-1:!r&&e?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},b.comp=b.compare,b.negate=function(){return!this.unsigned&&this.eq(m)?m:this.not().add(l)},b.neg=b.negate,b.add=function(t){isLong(t)||(t=fromValue(t));var r,e,i=this.high>>>16,n=65535&this.high,o=this.low>>>16,s=65535&this.low,u=t.high>>>16,f=65535&t.high,h=t.low>>>16,a=65535&t.low,l=0,c=0;return r=0+((e=0+(s+a))>>>16),e&=65535,r+=o+h,c+=r>>>16,r&=65535,c+=n+f,l+=c>>>16,c&=65535,l+=i+u,fromBits(r<<16|e,(l&=65535)<<16|c,this.unsigned)},b.subtract=function(t){return isLong(t)||(t=fromValue(t)),this.add(t.neg())},b.sub=b.subtract,b.multiply=function(t){if(this.isZero())return this;if(isLong(t)||(t=fromValue(t)),r)return fromBits(r.mul(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned);if(t.isZero())return this.unsigned?a:h;if(this.eq(m))return t.isOdd()?m:h;if(t.eq(m))return this.isOdd()?m:h;if(this.isNegative())if(t.isNegative())return this.neg().mul(t.neg());else return this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(f)&&t.lt(f))return fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var e,i,n=this.high>>>16,o=65535&this.high,s=this.low>>>16,u=65535&this.low,l=t.high>>>16,c=65535&t.high,g=t.low>>>16,p=65535&t.low,d=0,b=0;return e=0+((i=0+u*p)>>>16),i&=65535,e+=s*p,b+=e>>>16,e&=65535,e+=u*g,b+=e>>>16,e&=65535,b+=o*p,d+=b>>>16,b&=65535,b+=s*g,d+=b>>>16,b&=65535,b+=u*c,d+=b>>>16,b&=65535,d+=n*p+o*g+s*c+u*l,fromBits(e<<16|i,(d&=65535)<<16|b,this.unsigned)},b.mul=b.multiply,b.divide=function(t){if(isLong(t)||(t=fromValue(t)),t.isZero())throw Error("division by zero");if(r){var e,i,o;return this.unsigned||-0x80000000!==this.high||-1!==t.low||-1!==t.high?fromBits((this.unsigned?r.div_u:r.div_s)(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned):this}if(this.isZero())return this.unsigned?a:h;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return a;if(t.gt(this.shru(1)))return c;o=a}else{if(this.eq(m))if(t.eq(l)||t.eq(g))return m;else return t.eq(m)?l:(e=this.shr(1).div(t).shl(1)).eq(h)?t.isNegative()?l:g:(i=this.sub(t.mul(e)),o=e.add(i.div(t)));if(t.eq(m))return this.unsigned?a:h;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=h}for(i=this;i.gte(t);){for(var s=Math.ceil(Math.log(e=Math.max(1,Math.floor(i.toNumber()/t.toNumber())))/Math.LN2),u=s<=48?1:n(2,s-48),f=fromNumber(e),p=f.mul(t);p.isNegative()||p.gt(i);)e-=u,p=(f=fromNumber(e,this.unsigned)).mul(t);f.isZero()&&(f=l),o=o.add(f),i=i.sub(p)}return o},b.div=b.divide,b.modulo=function(t){return(isLong(t)||(t=fromValue(t)),r)?fromBits((this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},b.mod=b.modulo,b.rem=b.modulo,b.not=function(){return fromBits(~this.low,~this.high,this.unsigned)},b.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},b.clz=b.countLeadingZeros,b.countTrailingZeros=function(){return this.low?ctz32(this.low):ctz32(this.high)+32},b.ctz=b.countTrailingZeros,b.and=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low&t.low,this.high&t.high,this.unsigned)},b.or=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low|t.low,this.high|t.high,this.unsigned)},b.xor=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low^t.low,this.high^t.high,this.unsigned)},b.shiftLeft=function(t){return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:t<32?fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):fromBits(0,this.low<<t-32,this.unsigned)},b.shl=b.shiftLeft,b.shiftRight=function(t){return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:t<32?fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},b.shr=b.shiftRight,b.shiftRightUnsigned=function(t){return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:t<32?fromBits(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):32===t?fromBits(this.high,0,this.unsigned):fromBits(this.high>>>t-32,0,this.unsigned)},b.shru=b.shiftRightUnsigned,b.shr_u=b.shiftRightUnsigned,b.rotateLeft=function(t){var r;return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:32===t?fromBits(this.high,this.low,this.unsigned):t<32?(r=32-t,fromBits(this.low<<t|this.high>>>r,this.high<<t|this.low>>>r,this.unsigned)):(t-=32,r=32-t,fromBits(this.high<<t|this.low>>>r,this.low<<t|this.high>>>r,this.unsigned))},b.rotl=b.rotateLeft,b.rotateRight=function(t){var r;return(isLong(t)&&(t=t.toInt()),0==(t&=63))?this:32===t?fromBits(this.high,this.low,this.unsigned):t<32?(r=32-t,fromBits(this.high<<r|this.low>>>t,this.low<<r|this.high>>>t,this.unsigned)):(t-=32,r=32-t,fromBits(this.low<<r|this.high>>>t,this.high<<r|this.low>>>t,this.unsigned))},b.rotr=b.rotateRight,b.toSigned=function(){return this.unsigned?fromBits(this.low,this.high,!1):this},b.toUnsigned=function(){return this.unsigned?this:fromBits(this.low,this.high,!0)},b.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},b.toBytesLE=function(){var t=this.high,r=this.low;return[255&r,r>>>8&255,r>>>16&255,r>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},b.toBytesBE=function(){var t=this.high,r=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,r>>>24,r>>>16&255,r>>>8&255,255&r]},Long.fromBytes=function(t,r,e){return e?Long.fromBytesLE(t,r):Long.fromBytesBE(t,r)},Long.fromBytesLE=function(t,r){return new Long(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)},Long.fromBytesBE=function(t,r){return new Long(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)},"function"==typeof BigInt&&(Long.fromBigInt=function(t,r){return fromBits(Number(BigInt.asIntN(32,t)),Number(BigInt.asIntN(32,t>>BigInt(32))),r)},Long.fromValue=function(t,r){return"bigint"==typeof t?Long.fromBigInt(t,r):fromValue(t,r)},b.toBigInt=function(){var t=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|t}),t.default=Long})},"./protobufjs/minimal.js"(t,r,e){"use strict";t.exports=e("./protobufjs/src/index-minimal.js")},"./protobufjs/src/index-minimal.js"(t,r,e){"use strict";function configure(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=e("./protobufjs/src/writer.js"),r.BufferWriter=e("./protobufjs/src/writer_buffer.js"),r.Reader=e("./protobufjs/src/reader.js"),r.BufferReader=e("./protobufjs/src/reader_buffer.js"),r.util=e("./protobufjs/src/util/minimal.js"),r.rpc=e("./protobufjs/src/rpc.js"),r.roots=e("./protobufjs/src/roots.js"),r.configure=configure,configure()},"./protobufjs/src/reader.js"(t,r,e){"use strict";t.exports=Reader;var i,n=e("./protobufjs/src/util/minimal.js"),o=n.LongBits,s=n.utf8;function indexOutOfRange(t,r){return RangeError("index out of range: "+t.pos+" + "+(r||1)+" > "+t.len)}function Reader(t){this.buf=t,this.pos=0,this.len=t.length,this.discardUnknown=Reader.discardUnknown}var u="u">typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new Reader(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new Reader(t);throw Error("illegal buffer")},create=function(){return n.Buffer?function(t){return(Reader.create=function(t){return n.Buffer.isBuffer(t)?new i(t):u(t)})(t)}:u};function readLongVarint(){var t=new o(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*r)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw indexOutOfRange(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*r)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*r)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*r+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw indexOutOfRange(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*r+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function readFixed32_end(t,r){return(t[r-4]|t[r-3]<<8|t[r-2]<<16|t[r-1]<<24)>>>0}function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new o(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader.create=create(),Reader.prototype._slice=n.Array.prototype.subarray||n.Array.prototype.slice,Reader.prototype.raw=function(t,r){return Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},Reader.prototype.uint32=function(){var t=this.buf,r=this.pos,e=(127&t[r])>>>0;if(t[r++]<128||(e=(e|(127&t[r])<<7)>>>0,t[r++]<128)||(e=(e|(127&t[r])<<14)>>>0,t[r++]<128)||(e=(e|(127&t[r])<<21)>>>0,t[r++]<128)||(e=(e|(15&t[r])<<28)>>>0,t[r++]<128))return this.pos=r,e;for(var i=0;i<5;++i){if(r>=this.len)throw this.pos=r,indexOutOfRange(this);if(t[r++]<128)return this.pos=r,e}throw this.pos=r,Error("invalid varint encoding")},Reader.prototype.tag=function(){var t=this.buf,r=this.pos,e=(127&t[r])>>>0;if(t[r++]<128||(e=(e|(127&t[r])<<7)>>>0,t[r++]<128)||(e=(e|(127&t[r])<<14)>>>0,t[r++]<128)||(e=(e|(127&t[r])<<21)>>>0,t[r++]<128))return this.pos=r,e;if(e=(e|(15&t[r])<<28)>>>0,t[r]<128&&(112&t[r])==0)return this.pos=r+1,e;throw this.pos=r+1,Error("invalid tag encoding")},Reader.prototype.int32=function(){return 0|this.uint32()},Reader.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)},Reader.prototype.bool=function(){for(var t,r=!1,e=0;e<10;++e){if(this.pos>=this.len)throw indexOutOfRange(this);if(127&(t=this.buf[this.pos++])&&(r=!0),t<128)return r}throw Error("invalid varint encoding")},Reader.prototype.fixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.sfixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return 0|readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.float=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var t=n.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},Reader.prototype.double=function(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var t=n.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},Reader.prototype.bytes=function(){var t=this.uint32(),r=this.pos,e=this.pos+t;if(e>this.len)throw indexOutOfRange(this,t);return this.pos=e,this.raw(r,e)},Reader.prototype.string=function(){var t=this.uint32(),r=this.pos,e=this.pos+t;if(e>this.len)throw indexOutOfRange(this,t);return this.pos=e,s.read(this.buf,r,e)},Reader.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw indexOutOfRange(this,t);this.pos+=t}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(128&this.buf[this.pos++]);return this},Reader.recursionLimit=n.recursionLimit,Reader.discardUnknown=!1,Reader.prototype.skipType=function(t,r,e){if(void 0===r&&(r=0),r>Reader.recursionLimit)throw Error("max depth exceeded");if(0===e)throw Error("illegal tag: field number 0");switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;;){var i=this.tag(),n=i>>>3;if(t=7&i,!n)throw Error("illegal tag: field number 0");if(4===t){if(void 0!==e&&n!==e)throw Error("invalid end group tag");break}this.skipType(t,r+1,n)}break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},Reader._configure=function(t){i=t,Reader.create=create(),i._configure();var r=n.Long?"toLong":"toNumber";n.merge(Reader.prototype,{int64:function(){return readLongVarint.call(this)[r](!1)},uint64:function(){return readLongVarint.call(this)[r](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[r](!1)},fixed64:function(){return readFixed64.call(this)[r](!0)},sfixed64:function(){return readFixed64.call(this)[r](!1)}})}},"./protobufjs/src/reader_buffer.js"(t,r,e){"use strict";t.exports=BufferReader;var i=e("./protobufjs/src/reader.js");(BufferReader.prototype=Object.create(i.prototype)).constructor=BufferReader;var n=e("./protobufjs/src/util/minimal.js");function BufferReader(t){i.call(this,t)}BufferReader._configure=function(){n.Buffer&&(BufferReader.prototype._slice=n.Buffer.prototype.slice)},BufferReader.prototype.raw=function(t,r){return t===r?n.Buffer.alloc(0):this._slice.call(this.buf,t,r)},BufferReader.prototype.string=function(){var t=this.uint32(),r=this.pos,e=this.pos+t;if(e>this.len)throw RangeError("index out of range: "+this.pos+" + "+t+" > "+this.len);return this.pos=e,this.buf.utf8Slice?this.buf.utf8Slice(r,e):this.buf.toString("utf-8",r,e)},BufferReader._configure()},"./protobufjs/src/roots.js"(t){"use strict";t.exports=Object.create(null)},"./protobufjs/src/rpc.js"(t,r,e){"use strict";r.Service=e("./protobufjs/src/rpc/service.js")},"./protobufjs/src/rpc/service.js"(t,r,e){"use strict";t.exports=Service;var i=e("./protobufjs/src/util/minimal.js");function Service(t,r,e){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");i.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=!!r,this.responseDelimited=!!e}(Service.prototype=Object.create(i.EventEmitter.prototype)).constructor=Service,Service.prototype.rpcCall=function rpcCall(t,r,e,n,o){if(!n)throw TypeError("request must be specified");var s=this;if(!o)return i.asPromise(rpcCall,s,t,r,e,n);if(!s.rpcImpl)return void setTimeout(function(){o(Error("already ended"))},0);try{return s.rpcImpl(t,r[s.requestDelimited?"encodeDelimited":"encode"](n).finish(),function(r,i){if(r)return s.emit("error",r,t),o(r);if(null===i)return void s.end(!0);if(!(i instanceof e))try{i=e[s.responseDelimited?"decodeDelimited":"decode"](i)}catch(r){return s.emit("error",r,t),o(r)}return s.emit("data",i,t),o(null,i)})}catch(r){s.emit("error",r,t),setTimeout(function(){o(r)},0);return}},Service.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},"./protobufjs/src/util/aspromise.js"(t){"use strict";t.exports=function asPromise(t,r){for(var e=Array(arguments.length-1),i=0,n=2,o=!0;n<arguments.length;)e[i++]=arguments[n++];return new Promise(function(n,s){e[i]=function(t){if(o)if(o=!1,t)s(t);else{for(var r=Array(arguments.length-1),e=0;e<r.length;)r[e++]=arguments[e];n.apply(null,r)}};try{t.apply(r||null,e)}catch(t){o&&(o=!1,s(t))}})}},"./protobufjs/src/util/base64.js"(t,r){"use strict";r.length=function(t){var r=t.length;if(!r)return 0;for(;r>0&&"="===t.charAt(r-1);)--r;return Math.floor(3*r/4)};for(var e=Array(64),i=Array(123),n=0;n<64;)i[e[n]=n<26?n+65:n<52?n+71:n<62?n-4:n-59|43]=n++;i[45]=62,i[95]=63,r.encode=function(t,r,i){for(var n,o=null,s=[],u=0,f=0;r<i;){var h=t[r++];switch(f){case 0:s[u++]=e[h>>2],n=(3&h)<<4,f=1;break;case 1:s[u++]=e[n|h>>4],n=(15&h)<<2,f=2;break;case 2:s[u++]=e[n|h>>6],s[u++]=e[63&h],f=0}u>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),u=0)}return(f&&(s[u++]=e[n],s[u++]=61,1===f&&(s[u++]=61)),o)?(u&&o.push(String.fromCharCode.apply(String,s.slice(0,u))),o.join("")):String.fromCharCode.apply(String,s.slice(0,u))};var o="invalid encoding";r.decode=function(t,r,e){for(var n,s=e,u=0,f=0;f<t.length;){var h=t.charCodeAt(f++);if(61===h&&u>1)break;if(void 0===(h=i[h]))throw Error(o);switch(u){case 0:n=h,u=1;break;case 1:r[e++]=n<<2|(48&h)>>4,n=h,u=2;break;case 2:r[e++]=(15&n)<<4|(60&h)>>2,n=h,u=3;break;case 3:r[e++]=(3&n)<<6|h,u=0}}if(1===u)throw Error(o);return e-s};var s=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,u=/[-_]/,f=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==)?|[A-Za-z0-9_-]{3}=?)?$/;r.test=function(t){return s.test(t)||u.test(t)&&f.test(t)}},"./protobufjs/src/util/eventemitter.js"(t){"use strict";function EventEmitter(){this._listeners=Object.create(null)}t.exports=EventEmitter,EventEmitter.prototype.on=function(t,r,e){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:r,ctx:e||this}),this},EventEmitter.prototype.off=function(t,r){if(void 0===t)this._listeners=Object.create(null);else if(void 0===r)this._listeners[t]=[];else{var e=this._listeners[t];if(!e)return this;for(var i=0;i<e.length;)e[i].fn===r?e.splice(i,1):++i}return this},EventEmitter.prototype.emit=function(t){var r=this._listeners[t];if(r){for(var e=[],i=1;i<arguments.length;)e.push(arguments[i++]);for(i=0;i<r.length;)r[i].fn.apply(r[i++].ctx,e)}return this}},"./protobufjs/src/util/float.js"(t){"use strict";function factory(t){if("u">typeof Float32Array)!function(){var r=new Float32Array([-0]),e=new Uint8Array(r.buffer),i=128===e[3];function writeFloat_f32_cpy(t,i,n){r[0]=t,i[n]=e[0],i[n+1]=e[1],i[n+2]=e[2],i[n+3]=e[3]}function writeFloat_f32_rev(t,i,n){r[0]=t,i[n]=e[3],i[n+1]=e[2],i[n+2]=e[1],i[n+3]=e[0]}function readFloat_f32_cpy(t,i){return e[0]=t[i],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],r[0]}function readFloat_f32_rev(t,i){return e[3]=t[i],e[2]=t[i+1],e[1]=t[i+2],e[0]=t[i+3],r[0]}t.writeFloatLE=i?writeFloat_f32_cpy:writeFloat_f32_rev,t.writeFloatBE=i?writeFloat_f32_rev:writeFloat_f32_cpy,t.readFloatLE=i?readFloat_f32_cpy:readFloat_f32_rev,t.readFloatBE=i?readFloat_f32_rev:readFloat_f32_cpy}();else{function writeFloat_ieee754(t,r,e,i){var n=+(r<0);if(n&&(r=-r),0===r)t(1/r>0?0:0x80000000,e,i);else if(isNaN(r))t(0x7fc00000,e,i);else if(r>34028234663852886e22)t((n<<31|0x7f800000)>>>0,e,i);else if(r<11754943508222875e-54)t((n<<31|Math.round(r/1401298464324817e-60))>>>0,e,i);else{var o=Math.floor(Math.log(r)/Math.LN2),s=8388607&Math.round(r*Math.pow(2,-o)*8388608);t((n<<31|o+127<<23|s)>>>0,e,i)}}function readFloat_ieee754(t,r,e){var i=t(r,e),n=(i>>31)*2+1,o=i>>>23&255,s=8388607&i;return 255===o?s?NaN:1/0*n:0===o?1401298464324817e-60*n*s:n*Math.pow(2,o-150)*(s+8388608)}t.writeFloatLE=writeFloat_ieee754.bind(null,writeUintLE),t.writeFloatBE=writeFloat_ieee754.bind(null,writeUintBE),t.readFloatLE=readFloat_ieee754.bind(null,readUintLE),t.readFloatBE=readFloat_ieee754.bind(null,readUintBE)}if("u">typeof Float64Array)!function(){var r=new Float64Array([-0]),e=new Uint8Array(r.buffer),i=128===e[7];function writeDouble_f64_cpy(t,i,n){r[0]=t,i[n]=e[0],i[n+1]=e[1],i[n+2]=e[2],i[n+3]=e[3],i[n+4]=e[4],i[n+5]=e[5],i[n+6]=e[6],i[n+7]=e[7]}function writeDouble_f64_rev(t,i,n){r[0]=t,i[n]=e[7],i[n+1]=e[6],i[n+2]=e[5],i[n+3]=e[4],i[n+4]=e[3],i[n+5]=e[2],i[n+6]=e[1],i[n+7]=e[0]}function readDouble_f64_cpy(t,i){return e[0]=t[i],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],e[4]=t[i+4],e[5]=t[i+5],e[6]=t[i+6],e[7]=t[i+7],r[0]}function readDouble_f64_rev(t,i){return e[7]=t[i],e[6]=t[i+1],e[5]=t[i+2],e[4]=t[i+3],e[3]=t[i+4],e[2]=t[i+5],e[1]=t[i+6],e[0]=t[i+7],r[0]}t.writeDoubleLE=i?writeDouble_f64_cpy:writeDouble_f64_rev,t.writeDoubleBE=i?writeDouble_f64_rev:writeDouble_f64_cpy,t.readDoubleLE=i?readDouble_f64_cpy:readDouble_f64_rev,t.readDoubleBE=i?readDouble_f64_rev:readDouble_f64_cpy}();else{function writeDouble_ieee754(t,r,e,i,n,o){var s,u=+(i<0);if(u&&(i=-i),0===i)t(0,n,o+r),t(1/i>0?0:0x80000000,n,o+e);else if(isNaN(i))t(0,n,o+r),t(0x7ff80000,n,o+e);else if(i>17976931348623157e292)t(0,n,o+r),t((u<<31|0x7ff00000)>>>0,n,o+e);else if(i<22250738585072014e-324)t((s=i/5e-324)>>>0,n,o+r),t((u<<31|s/0x100000000)>>>0,n,o+e);else{var f=Math.floor(Math.log(i)/Math.LN2);1024===f&&(f=1023),t(0x10000000000000*(s=i*Math.pow(2,-f))>>>0,n,o+r),t((u<<31|f+1023<<20|1048576*s&1048575)>>>0,n,o+e)}}function readDouble_ieee754(t,r,e,i,n){var o=t(i,n+r),s=t(i,n+e),u=(s>>31)*2+1,f=s>>>20&2047,h=0x100000000*(1048575&s)+o;return 2047===f?h?NaN:1/0*u:0===f?5e-324*u*h:u*Math.pow(2,f-1075)*(h+0x10000000000000)}t.writeDoubleLE=writeDouble_ieee754.bind(null,writeUintLE,0,4),t.writeDoubleBE=writeDouble_ieee754.bind(null,writeUintBE,4,0),t.readDoubleLE=readDouble_ieee754.bind(null,readUintLE,0,4),t.readDoubleBE=readDouble_ieee754.bind(null,readUintBE,4,0)}return t}function writeUintLE(t,r,e){r[e]=255&t,r[e+1]=t>>>8&255,r[e+2]=t>>>16&255,r[e+3]=t>>>24}function writeUintBE(t,r,e){r[e]=t>>>24,r[e+1]=t>>>16&255,r[e+2]=t>>>8&255,r[e+3]=255&t}function readUintLE(t,r){return(t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24)>>>0}function readUintBE(t,r){return(t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3])>>>0}t.exports=factory(factory)},"./protobufjs/src/util/inquire.js"(t,r,e){"use strict";t.exports=function inquire(t){try{var r=e("./protobufjs/src/util sync recursive")(t);if(r&&(r.length||Object.keys(r).length))return r;return null}catch(t){return null}}},"./protobufjs/src/util/longbits.js"(t,r,e){"use strict";t.exports=LongBits;var i=e("./protobufjs/src/util/minimal.js");function LongBits(t,r){this.lo=t>>>0,this.hi=r>>>0}var n=LongBits.zero=new LongBits(0,0);n.toNumber=function(){return 0},n.zzEncode=n.zzDecode=function(){return this},n.length=function(){return 1};var o=LongBits.zeroHash="\0\0\0\0\0\0\0\0";LongBits.fromNumber=function(t){if(0===t)return n;var r=t<0;r&&(t=-t);var e=t>>>0,i=(t-e)/0x100000000>>>0;return r&&(i=~i>>>0,e=~e>>>0,++e>0xffffffff&&(e=0,++i>0xffffffff&&(i=0))),new LongBits(e,i)},LongBits.from=function(t){if("number"==typeof t)return LongBits.fromNumber(t);if(i.isString(t))if(!i.Long)return LongBits.fromNumber(parseInt(t,10));else t=i.Long.fromString(t);return t.low||t.high?new LongBits(t.low>>>0,t.high>>>0):n},LongBits.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var r=~this.lo+1>>>0,e=~this.hi>>>0;return r||(e=e+1>>>0),-(r+0x100000000*e)}return this.lo+0x100000000*this.hi},LongBits.prototype.toLong=function(t){return i.Long?new i.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}};var s=String.prototype.charCodeAt;LongBits.fromHash=function(t){return t===o?n:new LongBits((s.call(t,0)|s.call(t,1)<<8|s.call(t,2)<<16|s.call(t,3)<<24)>>>0,(s.call(t,4)|s.call(t,5)<<8|s.call(t,6)<<16|s.call(t,7)<<24)>>>0)},LongBits.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},LongBits.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},LongBits.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},LongBits.prototype.length=function(){var t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return 0===e?0===r?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:e<128?9:10}},"./protobufjs/src/util/minimal.js"(t,r,e){"use strict";function isUnsafeProperty(t){return"__proto__"===t||"prototype"===t||"constructor"===t}function merge(t){var r="boolean"==typeof arguments[arguments.length-1],e=r?arguments.length-1:arguments.length;r=r&&arguments[arguments.length-1];for(var i=1;i<e;++i){var n=arguments[i];if(n)for(var o=Object.keys(n),s=0;s<o.length;++s)isUnsafeProperty(o[s])||void 0!==t[o[s]]&&r||(t[o[s]]=n[o[s]])}return t}function newError(t){function CustomError(t,r){if(!(this instanceof CustomError))return new CustomError(t,r);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,CustomError):Object.defineProperty(this,"stack",{value:Error().stack||""}),r&&merge(this,r)}return CustomError.prototype=Object.create(Error.prototype,{constructor:{value:CustomError,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return t},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),CustomError}r.asPromise=e("./protobufjs/src/util/aspromise.js"),r.base64=e("./protobufjs/src/util/base64.js"),r.EventEmitter=e("./protobufjs/src/util/eventemitter.js"),r.float=e("./protobufjs/src/util/float.js"),r.inquire=e("./protobufjs/src/util/inquire.js"),r.utf8=e("./protobufjs/src/util/utf8.js"),r.pool=e("./protobufjs/src/util/pool.js"),r.LongBits=e("./protobufjs/src/util/longbits.js"),r.isUnsafeProperty=isUnsafeProperty,r.isNode=!!("u">typeof global&&global&&global.process&&global.process.versions&&global.process.versions.node),r.global=r.isNode&&global||"u">typeof window&&window||"u">typeof self&&self||this,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},r.isString=function(t){return"string"==typeof t||t instanceof String},r.isObject=function(t){return t&&"object"==typeof t},r.isset=r.isSet=function(t,r){var e=t[r];return!!(null!=e&&Object.hasOwnProperty.call(t,r))&&("object"!=typeof e||(Array.isArray(e)?e.length:Object.keys(e).length)>0)},r.Buffer=function(){try{var t=r.global.Buffer;return t.prototype.utf8Write?t:null}catch(t){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(t){return"number"==typeof t?r.Buffer?r._Buffer_allocUnsafe(t):new r.Array(t):r.Buffer?r._Buffer_from(t):"u"<typeof Uint8Array?t:new Uint8Array(t)},r.Array="u">typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||function(){try{var t=e("./long/umd/index.js");return t&&t.isLong?t:null}catch(t){return null}}(),r.key2Re=/^(?:true|false|0|1)$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\x00-\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(t){return t?r.LongBits.from(t).toHash():r.LongBits.zeroHash},r.longFromHash=function(t,e){var i=r.LongBits.fromHash(t);return r.Long?r.Long.fromBits(i.lo,i.hi,e):i.toNumber(!!e)},r.longFromKey=function(t,e){return r.key64Re.test(t)&&!r.key32Re.test(t)?r.longFromHash(t,e):t},r.boolFromKey=function(t){return"true"===t||"1"===t},r.merge=merge,r.nestingLimit=32,r.recursionLimit=100,r.makeProp=function(t,r,e){Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:void 0===e||e,configurable:!0,writable:!0})},r.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},r.newError=newError,r.ProtocolError=newError("ProtocolError"),r.oneOfGetter=function(t){for(var r={},e=0;e<t.length;++e)r[t[e]]=1;return function(){for(var t=Object.keys(this),e=t.length-1;e>-1;--e)if(1===r[t[e]]&&void 0!==this[t[e]]&&null!==this[t[e]])return t[e]}},r.oneOfSetter=function(t){return function(r){for(var e=0;e<t.length;++e)t[e]!==r&&delete this[t[e]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var t=r.Buffer;if(!t){r._Buffer_from=r._Buffer_allocUnsafe=null;return}r._Buffer_from=t.from!==Uint8Array.from&&t.from||function(r,e){return new t(r,e)},r._Buffer_allocUnsafe=t.allocUnsafe||function(r){return new t(r)}}},"./protobufjs/src/util/pool.js"(t){"use strict";t.exports=function pool(t,r,e){var i=e||8192,n=i>>>1,o=null,s=i;return function(e){if(e<1||e>n)return t(e);s+e>i&&(o=t(i),s=0);var u=r.call(o,s,s+=e);return 7&s&&(s=(7|s)+1),u}}},"./protobufjs/src/util/utf8.js"(t,r){"use strict";function utf8_read_js(t,r,e,i){for(var n=r;n<e;){var o=t[n++];if(o<=127)i+=String.fromCharCode(o);else if(o>=192&&o<224){var s=(31&o)<<6|63&t[n++];i+=s>=128?String.fromCharCode(s):"�"}else if(o>=224&&o<240){var u=(15&o)<<12|(63&t[n++])<<6|63&t[n++];i+=u>=2048?String.fromCharCode(u):"�"}else if(o>=240){var f=(7&o)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++];f<65536||f>1114111?i+="�":(f-=65536,i+=String.fromCharCode(55296+(f>>10)),i+=String.fromCharCode(56320+(1023&f)))}}return i}r.length=function(t){for(var r=0,e=0,i=0;i<t.length;++i)(e=t.charCodeAt(i))<128?r+=1:e<2048?r+=2:(64512&e)==55296&&(64512&t.charCodeAt(i+1))==56320?(++i,r+=4):r+=3;return r},r.read=function(t,r,e){if(e-r<1)return"";for(var i,n,o,s,u,f,h,a,l="",c=r;c+7<e;c+=8){if(i=t[c],n=t[c+1],o=t[c+2],s=t[c+3],u=t[c+4],f=t[c+5],(i|n|o|s|u|f|(h=t[c+6])|(a=t[c+7]))&128)return utf8_read_js(t,c,e,l);l+=String.fromCharCode(i,n,o,s,u,f,h,a)}for(;c<e;++c){if(128&(i=t[c]))return utf8_read_js(t,c,e,l);l+=String.fromCharCode(i)}return l},r.write=function(t,r,e){for(var i,n,o=e,s=0;s<t.length;++s)(i=t.charCodeAt(s))<128?r[e++]=i:(i<2048?r[e++]=i>>6|192:((64512&i)==55296&&(64512&(n=t.charCodeAt(s+1)))==56320?(i=65536+((1023&i)<<10)+(1023&n),++s,r[e++]=i>>18|240,r[e++]=i>>12&63|128):r[e++]=i>>12|224,r[e++]=i>>6&63|128),r[e++]=63&i|128);return e-o}},"./protobufjs/src/writer.js"(t,r,e){"use strict";t.exports=Writer;var i,n=e("./protobufjs/src/util/minimal.js"),o=n.LongBits,s=n.base64,u=n.utf8;function Op(t,r,e){this.fn=t,this.len=r,this.next=void 0,this.val=e}function noop(){}function State(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function Writer(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}var create=function(){return n.Buffer?function(){return(Writer.create=function(){return new i})()}:function(){return new Writer}};function writeByte(t,r,e){r[e]=255&t}function writeStringAscii(t,r,e){for(var i=0;i<t.length;)r[e++]=t.charCodeAt(i++)}function writeVarint32(t,r,e){for(;t>127;)r[e++]=127&t|128,t>>>=7;r[e]=t}function VarintOp(t,r){this.len=t,this.next=void 0,this.val=r}function writeVarint64(t,r,e){for(var i=t.lo,n=t.hi;n;)r[e++]=127&i|128,i=(i>>>7|n<<25)>>>0,n>>>=7;for(;i>127;)r[e++]=127&i|128,i>>>=7;r[e++]=i}function writeFixed32(t,r,e){r[e]=255&t,r[e+1]=t>>>8&255,r[e+2]=t>>>16&255,r[e+3]=t>>>24}Writer.create=create(),Writer.alloc=function(t){return new n.Array(t)},n.Array!==Array&&(Writer.alloc=n.pool(Writer.alloc,n.Array.prototype.subarray)),Writer.prototype._push=function(t,r,e){return this.tail=this.tail.next=new Op(t,r,e),this.len+=r,this},VarintOp.prototype=Object.create(Op.prototype),VarintOp.prototype.fn=writeVarint32,Writer.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new VarintOp((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<0x10000000?4:5,t)).len,this},Writer.prototype.int32=function(t){return(t|=0)<0?this._push(writeVarint64,10,o.fromNumber(t)):this.uint32(t)},Writer.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},Writer.prototype.uint64=function(t){var r=o.from(t);return this._push(writeVarint64,r.length(),r)},Writer.prototype.int64=Writer.prototype.uint64,Writer.prototype.sint64=function(t){var r=o.from(t).zzEncode();return this._push(writeVarint64,r.length(),r)},Writer.prototype.bool=function(t){return this._push(writeByte,1,+!!t)},Writer.prototype.fixed32=function(t){return this._push(writeFixed32,4,t>>>0)},Writer.prototype.sfixed32=Writer.prototype.fixed32,Writer.prototype.fixed64=function(t){var r=o.from(t);return this._push(writeFixed32,4,r.lo)._push(writeFixed32,4,r.hi)},Writer.prototype.sfixed64=Writer.prototype.fixed64,Writer.prototype.float=function(t){return this._push(n.float.writeFloatLE,4,t)},Writer.prototype.double=function(t){return this._push(n.float.writeDoubleLE,8,t)};var f=n.Array.prototype.set?function(t,r,e){r.set(t,e)}:function(t,r,e){for(var i=0;i<t.length;++i)r[e+i]=t[i]};Writer.prototype.bytes=function(t){var r=t.length>>>0;if(!r)return this._push(writeByte,1,0);if(n.isString(t)){var e=Writer.alloc(r=s.length(t));s.decode(t,e,0),t=e}return this.uint32(r)._push(f,r,t)},Writer.prototype.raw=function(t){var r=t.length>>>0;return r?this._push(f,r,t):this},Writer.prototype.string=function(t){var r=u.length(t);return r?this.uint32(r)._push(r===t.length?writeStringAscii:u.write,r,t):this._push(writeByte,1,0)},Writer.prototype.fork=function(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this},Writer.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop,0,0),this.len=0),this},Writer.prototype.ldelim=function(){var t=this.head,r=this.tail,e=this.len;return this.reset().uint32(e),e&&(this.tail.next=t.next,this.tail=r,this.len+=e),this},Writer.prototype.finish=function(){return this.finishInto(this.constructor.alloc(this.len),0)},Writer.prototype.finishInto=function(t,r){void 0===r&&(r=0);for(var e=this.head.next,i=r;e;)e.fn(e.val,t,i),i+=e.len,e=e.next;return t},Writer._configure=function(t){i=t,Writer.create=create(),i._configure()}},"./protobufjs/src/writer_buffer.js"(t,r,e){"use strict";t.exports=BufferWriter;var i=e("./protobufjs/src/writer.js");(BufferWriter.prototype=Object.create(i.prototype)).constructor=BufferWriter;var n=e("./protobufjs/src/util/minimal.js");function BufferWriter(){i.call(this)}function writeStringBufferAscii(t,r,e){for(var i=0;i<t.length;)r[e++]=t.charCodeAt(i++)}function writeStringBuffer(t,r,e){t.length<40?n.utf8.write(t,r,e):r.utf8Write?r.utf8Write(t,e):r.write(t,e)}BufferWriter._configure=function(){BufferWriter.alloc=n._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=n.Buffer&&n.Buffer.prototype instanceof Uint8Array&&"set"===n.Buffer.prototype.set.name?function(t,r,e){r.set(t,e)}:function(t,r,e){if(t.copy)t.copy(r,e,0,t.length);else for(var i=0;i<t.length;)r[e++]=t[i++]}},BufferWriter.prototype.bytes=function(t){n.isString(t)&&(t=n._Buffer_from(t,"base64"));var r=t.length>>>0;return this.uint32(r),r&&this._push(BufferWriter.writeBytesBuffer,r,t),this},BufferWriter.prototype.raw=function(t){var r=t.length>>>0;return r?this._push(BufferWriter.writeBytesBuffer,r,t):this},BufferWriter.prototype.string=function(t){var r=n.Buffer.byteLength(t);return this.uint32(r),r&&this._push(r===t.length&&r<40?writeStringBufferAscii:writeStringBuffer,r,t),this},BufferWriter._configure()}},r={};function __webpack_require__(e){var i=r[e];if(void 0!==i)return i.exports;var n=r[e]={exports:{}};return t[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r);var e=__webpack_require__("./protobufjs/minimal.js");module.exports=e})();
@@ -1,284 +0,0 @@
1
- 'use strict'
2
-
3
- const dc = require('dc-polyfill')
4
- const shimmer = require('../../../datadog-shimmer')
5
- const {
6
- convertOpenAIResponseItemsToMessages,
7
- convertOpenAIResponsePromptToMessages,
8
- normalizeOpenAIChatMessages,
9
- } = require('./ai-messages')
10
-
11
- // TODO: this channel name is incorrect, instrumentations publish with THEIR name, not with their subscribers names.
12
- const aiguardChannel = dc.channel('dd-trace:ai:aiguard')
13
-
14
- /**
15
- * @typedef {object} ResourceHandler
16
- * @property {(callArgs: object) => (Array<object>|undefined)} getInputMessages
17
- * @property {(body: object) => Array<object>} getOutputMessages
18
- * @property {(inputMessages: Array<object>, outputMessages: Array<object>, parentSpan?: object)
19
- * => Promise<unknown>} publishOutputEvaluation
20
- */
21
-
22
- /**
23
- * @typedef {object} Guard
24
- * @property {ResourceHandler} handler
25
- * @property {Array<object>} inputMessages
26
- * @property {() => Promise<void>} getInputEval
27
- * @property {object} [parentSpan] - LLM span (`openai.request`) to nest `ai_guard` spans under.
28
- * Set by the instrumentation once the LLM span is active.
29
- */
30
-
31
- /**
32
- * Publishes already-converted AI-style messages to the AI Guard evaluation channel.
33
- *
34
- * Subscribers push async work into `pending` and abort `abortController` to block.
35
- *
36
- * @param {Array<object>} messages - AI-style messages to evaluate.
37
- * @param {object} [parentSpan] - LLM span to use as the `ai_guard` span's parent.
38
- * @returns {Promise<void>}
39
- */
40
- function publishEvaluation (messages, parentSpan) {
41
- const abortController = new AbortController()
42
- const ctx = { messages, integration: 'openai', parentSpan, abortController, pending: [] }
43
-
44
- aiguardChannel.publish(ctx)
45
-
46
- return Promise.all(ctx.pending).then(() => {
47
- if (abortController.signal.aborted) {
48
- throw abortController.signal.reason
49
- }
50
- })
51
- }
52
-
53
- /**
54
- * Extracts OpenAI input messages from a `chat.completions.create` call.
55
- *
56
- * @param {object} callArgs - First argument passed to the wrapped method
57
- * @returns {Array<object>|undefined}
58
- */
59
- function getChatCompletionsInputMessages (callArgs) {
60
- return normalizeOpenAIChatMessages(callArgs?.messages)
61
- }
62
-
63
- /**
64
- * Extracts OpenAI output messages from a `chat.completions.create` parsed body.
65
- * Includes any choice whose message carries content (including empty string),
66
- * `tool_calls`, a `refusal` field, or the deprecated `function_call` field. GPT-4o
67
- * emits `{content: null, refusal: "..."}` on policy refusals, and pre-tool-call
68
- * SDK paths still produce `function_call`-only output — AI Guard must still see them.
69
- *
70
- * @param {object} body - Parsed response body
71
- * @returns {Array<object>}
72
- */
73
- function getChatCompletionsOutputMessages (body) {
74
- const eligible = []
75
- const choices = Array.isArray(body?.choices) ? body.choices : []
76
- for (const choice of choices) {
77
- const message = choice?.message
78
- if (
79
- message?.content != null ||
80
- message?.tool_calls?.length ||
81
- message?.refusal != null ||
82
- message?.function_call != null
83
- ) {
84
- eligible.push(message)
85
- }
86
- }
87
- return normalizeOpenAIChatMessages(eligible) ?? []
88
- }
89
-
90
- /**
91
- * Publishes AI Guard After Model evaluation for `chat.completions` output.
92
- *
93
- * Chat completions may return multiple choices when `n > 1`. Screen every choice
94
- * concurrently so any unsafe assistant output rejects `.parse()`, regardless of
95
- * which choice the caller ends up using.
96
- *
97
- * @param {Array<object>} inputMessages
98
- * @param {Array<object>} outputMessages - One entry per choice
99
- * @param {object} [parentSpan]
100
- * @returns {Promise<Array<void>>}
101
- */
102
- function publishChatCompletionsOutputEvaluation (inputMessages, outputMessages, parentSpan) {
103
- const evals = []
104
- for (const message of outputMessages) {
105
- evals.push(publishEvaluation([...inputMessages, message], parentSpan))
106
- }
107
- return Promise.all(evals)
108
- }
109
-
110
- /**
111
- * Extracts OpenAI input messages from a `responses.create` call. The `instructions`
112
- * field is treated as a developer prompt — it directly steers model behavior and the
113
- * LLMObs OpenAI plugin already surfaces it as one — so AI Guard must screen it too.
114
- *
115
- * AI Guard `/evaluate` accepts a single leading system/developer message; if the
116
- * caller's `input` already begins with one, prepend the `instructions` text to its
117
- * content rather than emit a second developer turn.
118
- *
119
- * @param {object} callArgs - First argument passed to the wrapped method
120
- * @returns {Array<object>|undefined}
121
- */
122
- function getResponsesInputMessages (callArgs) {
123
- const messages = [
124
- ...convertOpenAIResponseItemsToMessages(callArgs?.input, 'user'),
125
- ...convertOpenAIResponsePromptToMessages(callArgs?.prompt),
126
- ]
127
-
128
- const instructions = typeof callArgs?.instructions === 'string' && callArgs.instructions.length
129
- ? callArgs.instructions
130
- : null
131
- if (!instructions) return messages.length ? messages : undefined
132
-
133
- const first = messages[0]
134
- if (first && (first.role === 'developer' || first.role === 'system')) {
135
- const merged = { role: 'developer', content: mergeInstructionsWithContent(instructions, first.content) }
136
- return [merged, ...messages.slice(1)]
137
- }
138
- return [{ role: 'developer', content: instructions }, ...messages]
139
- }
140
-
141
- /**
142
- * Merges Responses API instructions with an existing leading developer/system content value.
143
- *
144
- * @param {string} instructions
145
- * @param {string|Array<object>|undefined} content
146
- * @returns {string|Array<object>}
147
- */
148
- function mergeInstructionsWithContent (instructions, content) {
149
- if (Array.isArray(content)) return [{ type: 'text', text: instructions }, ...content]
150
- if (typeof content === 'string' && content.length) return `${instructions}\n\n${content}`
151
- return instructions
152
- }
153
-
154
- /**
155
- * Extracts OpenAI output messages from a `responses.create` parsed body.
156
- *
157
- * @param {object} body - Parsed response body
158
- * @returns {Array<object>}
159
- */
160
- function getResponsesOutputMessages (body) {
161
- return convertOpenAIResponseItemsToMessages(body?.output, 'assistant')
162
- }
163
-
164
- /**
165
- * Publishes AI Guard After Model evaluation for `responses` output.
166
- *
167
- * The Responses API returns a single conversation turn whose `output` items form one
168
- * coherent message (reasoning steps + final assistant message + tool calls + ...);
169
- * they are screened together as a single evaluation.
170
- *
171
- * @param {Array<object>} inputMessages
172
- * @param {Array<object>} outputMessages
173
- * @param {object} [parentSpan]
174
- * @returns {Promise<void>}
175
- */
176
- function publishResponsesOutputEvaluation (inputMessages, outputMessages, parentSpan) {
177
- return publishEvaluation([...inputMessages, ...outputMessages], parentSpan)
178
- }
179
-
180
- /**
181
- * Per-resource handlers describing how AI Guard reads inputs and screens outputs for
182
- * each LLM-prompt-accepting OpenAI endpoint. The keys also serve as the set of
183
- * resources eligible for AI Guard evaluation.
184
- *
185
- * @type {Record<string, ResourceHandler>}
186
- */
187
- const RESOURCE_HANDLERS = {
188
- 'chat.completions': {
189
- getInputMessages: getChatCompletionsInputMessages,
190
- getOutputMessages: getChatCompletionsOutputMessages,
191
- publishOutputEvaluation: publishChatCompletionsOutputEvaluation,
192
- },
193
- responses: {
194
- getInputMessages: getResponsesInputMessages,
195
- getOutputMessages: getResponsesOutputMessages,
196
- publishOutputEvaluation: publishResponsesOutputEvaluation,
197
- },
198
- }
199
-
200
- /**
201
- * Reports whether the AI Guard channel has subscribers. The OpenAI instrumentation
202
- * uses this to decide whether to take the AI Guard path at all.
203
- *
204
- * @returns {boolean}
205
- */
206
- function hasSubscribers () {
207
- return aiguardChannel.hasSubscribers
208
- }
209
-
210
- /**
211
- * Builds a guard handle when AI Guard is enabled and applicable to this call. The
212
- * handle binds the per-resource handler so downstream functions never re-dispatch
213
- * on `baseResource`. Returns null when AI Guard does not apply (no subscribers,
214
- * non-eligible resource, streaming, or no input messages).
215
- *
216
- * @param {string} baseResource - e.g. `'chat.completions'` or `'responses'`
217
- * @param {object} callArgs - First argument passed to the wrapped OpenAI method
218
- * @param {boolean} stream - Whether the caller asked for a streamed response
219
- * @returns {Guard|null}
220
- */
221
- function createGuard (baseResource, callArgs, stream) {
222
- // Streaming AI Guard support lands in a follow-up PR. For now, provider-level AI
223
- // Guard only evaluates non-streaming responses.
224
- if (stream || !aiguardChannel.hasSubscribers) return null
225
- const handler = RESOURCE_HANDLERS[baseResource]
226
- if (!handler) return null
227
-
228
- const inputMessages = handler.getInputMessages(callArgs)
229
- if (!inputMessages) return null
230
-
231
- let inputEvalPromise
232
- const guard = { handler, inputMessages, parentSpan: undefined }
233
- guard.getInputEval = () => (inputEvalPromise ??= publishEvaluation(inputMessages, guard.parentSpan))
234
- return guard
235
- }
236
-
237
- /**
238
- * Wraps `apiProm.asResponse` so callers that consume the raw `Response` object still
239
- * receive the Before Model verdict. After Model evaluation is not performed on this
240
- * path because the response body has not been parsed.
241
- *
242
- * @param {object} apiProm - APIPromise returned from the OpenAI SDK method
243
- * @param {Guard} guard
244
- */
245
- function wrapAsResponse (apiProm, guard) {
246
- if (typeof apiProm.asResponse !== 'function') return
247
- shimmer.wrap(apiProm, 'asResponse', origAsResponse => function (...args) {
248
- const responsePromise = origAsResponse.apply(this, args)
249
- return Promise.all([guard.getInputEval(), responsePromise]).then(([, response]) => response)
250
- })
251
- }
252
-
253
- /**
254
- * Gates the parsed-body promise on Before Model evaluation. Resolves to the SDK's
255
- * result only once the Before Model verdict is in.
256
- *
257
- * @param {Promise<unknown>} parsedPromise
258
- * @param {Guard} guard
259
- * @returns {Promise<unknown>}
260
- */
261
- function gateParse (parsedPromise, guard) {
262
- return Promise.all([guard.getInputEval(), parsedPromise]).then(([, result]) => result)
263
- }
264
-
265
- /**
266
- * Runs After Model evaluation against the response body.
267
- *
268
- * @param {Guard} guard
269
- * @param {object} body - Parsed OpenAI response body
270
- * @returns {Promise<unknown>}
271
- */
272
- function evaluateOutput (guard, body) {
273
- const outputMessages = guard.handler.getOutputMessages(body)
274
- if (!outputMessages.length) return Promise.resolve()
275
- return guard.handler.publishOutputEvaluation(guard.inputMessages, outputMessages, guard.parentSpan)
276
- }
277
-
278
- module.exports = {
279
- hasSubscribers,
280
- createGuard,
281
- wrapAsResponse,
282
- gateParse,
283
- evaluateOutput,
284
- }