"use strict";module.exports=LongBits;var util=require("../util/minimal");function LongBits(t,i){this.lo=t>>>0,this.hi=i>>>0}var zero=LongBits.zero=new LongBits(0,0);zero.toNumber=function(){return 0},zero.zzEncode=zero.zzDecode=function(){return this},zero.length=function(){return 1};var zeroHash=LongBits.zeroHash="\0\0\0\0\0\0\0\0";LongBits.fromNumber=function(t){if(0===t)return zero;var i=t<0;i&&(t=-t);var o=t>>>0,r=(t-o)/0x100000000>>>0;return i&&(r=~r>>>0,o=~o>>>0,++o>0xffffffff&&(o=0,++r>0xffffffff&&(r=0))),new LongBits(o,r)},LongBits.from=function(t){if("number"==typeof t)return LongBits.fromNumber(t);if(util.isString(t))if(!util.Long)return LongBits.fromNumber(parseInt(t,10));else t=util.Long.fromString(t);return t.low||t.high?new LongBits(t.low>>>0,t.high>>>0):zero},LongBits.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var i=~this.lo+1>>>0,o=~this.hi>>>0;return i||(o=o+1>>>0),-(i+0x100000000*o)}return this.lo+0x100000000*this.hi},LongBits.prototype.toLong=function(t){return util.Long?new util.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}};var charCodeAt=String.prototype.charCodeAt;LongBits.fromHash=function(t){return t===zeroHash?zero:new LongBits((charCodeAt.call(t,0)|charCodeAt.call(t,1)<<8|charCodeAt.call(t,2)<<16|charCodeAt.call(t,3)<<24)>>>0,(charCodeAt.call(t,4)|charCodeAt.call(t,5)<<8|charCodeAt.call(t,6)<<16|charCodeAt.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,i=(this.lo>>>28|this.hi<<4)>>>0,o=this.hi>>>24;return 0===o?0===i?t<16384?t<128?1:2:t<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:o<128?9:10};