(function(){varr,t,n,e,i,o,a,s;t={},s=this,"undefined"!=typeofmodule&&null!==module&&module.exports?module.exports=t:s.ipaddr=t,a=function(r,t,n,e){vari,o;if(r.length!==t.length)thrownewError("ipaddr: cannot match CIDR for objects with different lengths");for(i=0;e>0;){if((o=n-e)<0&&(o=0),r[i]>>o!=t[i]>>o)return!1;e-=n,i+=1}return!0},t.subnetMatch=function(r,t,n){vare,i,o,a,s;null==n&&(n="unicast");for(oint)for(!(a=t[o])[0]||a[0]instanceofArray||(a=[a]),e=0,i=a.length;e<i;e++)if(s=a[e],r.kind()===s[0].kind()&&r.match.apply(r,s))returno;returnn},t.IPv4=function(){functionr(r){vart,n,e;if(4!==r.length)thrownewError("ipaddr: ipv4 octet count should be 4");for(t=0,n=r.length;t<n;t++)if(!(0<=(e=r[t])&&e<=255))thrownewError("ipaddr: ipv4 octet should fit in 8 bits");this.octets=r}returnr.prototype.kind=function(){return"ipv4"},r.prototype.toString=function(){returnthis.octets.join(".")},r.prototype.toNormalizedString=function(){returnthis.toString()},r.prototype.toByteArray=function(){returnthis.octets.slice(0)},r.prototype.match=function(r,t){varn;if(void0===t&&(r=(n=r)[0],t=n[1]),"ipv4"!==r.kind())thrownewError("ipaddr: cannot match ipv4 address with non-ipv4 one");returna(this.octets,r.octets,8,t)},r.prototype.SpecialRanges={unspecified:[[newr([0,0,0,0]),8]],broadcast:[[newr([255,255,255,255]),32]],multicast:[[newr([224,0,0,0]),4]],linkLocal:[[newr([169,254,0,0]),16]],loopback:[[newr([127,0,0,0]),8]],carrierGradeNat:[[newr([100,64,0,0]),10]],private:[[newr([10,0,0,0]),8],[newr([172,16,0,0]),12],[newr([192,168,0,0]),16]],reserved:[[newr([192,0,0,0]),24],[newr([192,0,2,0]),24],[newr([192,88,99,0]),24],[newr([198,51,100,0]),24],[newr([203,0,113,0]),24],[newr([240,0,0,0]),4]]},r.prototype.range=function(){returnt.subnetMatch(this,this.SpecialRanges)},r.prototype.toIPv4MappedAddress=function(){returnt.IPv6.parse("::ffff:"+this.toString())},r.prototype.prefixLengthFromSubnetMask=function(){varr,t,n,e,i,o,a;for(a={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r=0,i=!1,t=n=3;n>=0;t=n+=-1){if(!((e=this.octets[t])ina))returnnull;if(o=a[e],i&&0!==o)returnnull;8!==o&&(i=!0),r+=o}return32-r},r}(),n="(0?\\d+|0x[a-f0-9]+)",e={fourOctet:newRegExp("^"+n+"\\."+n+"\\."+n+"\\."+n+"$","i"),longValue:newRegExp("^"+n+"$","i")},t.IPv4.parser=function(r){vart,n,i,o,a;if(n=function(r){return"0"===r[0]&&"x"!==r[1]?parseInt(r,8):parseInt(r)},t=r.match(e.fourOctet))returnfunction(){varr,e,o,a;for(a=[],r=0,e=(o=t.slice(1,6)).length;r<e;r++)i=o[r],a.push(n(i));returna}();if(t=r.match(e.longValue)){if((a=n(t[1]))>4294967295||a<0)thrownewError("ipaddr: address outside defined range");returnfunction(){varr,t;for(t=[],o=r=0;r<=24;o=r+=8)t.push(a>>o&255);returnt}().reverse()}returnnull},t.IPv6=function(){functionr(r,t){varn,e,i,o,a,s;if(16===r.length)for(this.parts=[],n=e=0;e<=14;n=e+=2)this.parts.push(r[n]<<8|r[n+1]);else{if(8!==r.length)thrownewError("ipaddr: ipv6 part count should be 8 or 16");this.parts=r}for(i=0,o=(s=this.parts).length;i<o;i++)if(!(0<=(a=s[i])&&a<=65535))thrownewError("ipaddr: ipv6 part should fit in 16 bits");t&&(this.zoneId=t)}returnr.prototype.kind=function(){return"ipv6"},r.prototype.toString=function(){returnthis.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},r.prototype.toRFC5952String=function(){varr,t,n,e,i;for(e=/((^|:)(0(:|$)){2,})/g,i=this.toNormalizedString(),r=0,t=-1;n=e.exec(i);)n[0].length>t&&(r=n.index,t=n[0].length);returnt<0?i:i.substring(0,r)+"::"+i.substring(r+t)},r.prototype.toByteArray=function(){varr,t,n,e,i;for(r=[],t=0,n=(i=this.parts).length;t<n;t++)e=i[t],r.push(e>>8),r.push(255&e);returnr},r.prototype.toNormalizedString=function(){varr,t,n;returnr=function(){varr,n,e,i;for(i=[],r=0,n=(e=this.parts).length;r<n;r++)t=e[r],i.push(t.toString(16));returni}.call(this).join(":"),n="",this.zoneId&&(n="%"+this.zoneId),r+n},r.prototype.toFixedLengthString=function(){varr,t,n;returnr=function(){varr,n,e,i;for(i=[],r=0,n=(e=this.parts).length;r<n;r++)t=e[r],i.push(t.toString(16).padStart(4,"0"));returni}.call(this).join(":"),n=