swc/crates/swc_bundler/tests/.cache/untrusted/1ce67ccc6ab0e15724ff1173e2a2c8e71a57085c.ts

6 lines
11 KiB
TypeScript
Raw Normal View History

// Loaded from https://cdn.esm.sh/v45/ipaddr.js@2.0.0/es2015/ipaddr.js
/* esm.sh - esbuild bundle(ipaddr.js@2.0.0) es2015 production */
var k=Object.create;var P=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var A=u=>P(u,"__esModule",{value:!0});var O=(u,a)=>()=>(a||u((a={exports:{}}).exports,a),a.exports);var D=(u,a,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of C(a))!S.call(u,c)&&c!=="default"&&P(u,c,{get:()=>a[c],enumerable:!(p=z(a,c))||p.enumerable});return u},j=u=>D(A(P(u!=null?k(M(u)):{},"default",u&&u.__esModule&&"default"in u?{get:()=>u.default,enumerable:!0}:{value:u,enumerable:!0})),u);var b=O((g,w)=>{(function(u){"use strict";let a="(0?\\d+|0x[a-f0-9]+)",p={fourOctet:new RegExp(`^${a}\\.${a}\\.${a}\\.${a}$`,"i"),threeOctet:new RegExp(`^${a}\\.${a}\\.${a}$`,"i"),twoOctet:new RegExp(`^${a}\\.${a}$`,"i"),longValue:new RegExp(`^${a}$`,"i")},c=new RegExp("^0[0-7]+$","i"),E=new RegExp("^0x[a-f0-9]+$","i"),d="%[0-9a-z]{1,}",I="(?:[0-9a-f]+::?)+",h={zoneIndex:new RegExp(d,"i"),native:new RegExp(`^(::)?(${I})?([0-9a-f]+)?(::)?(${d})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${a}\\.${a}\\.${a}\\.${a}(${d})?)$`,"i"),transitional:new RegExp(`^((?:${I})|(?:::)(?:${I})?)${a}\\.${a}\\.${a}\\.${a}(${d})?$`,"i")};function x(t,e){if(t.indexOf("::")!==t.lastIndexOf("::"))return null;let n=0,r=-1,i=(t.match(h.zoneIndex)||[])[0],o,f;for(i&&(i=i.substring(1),t=t.replace(/%.+$/,""));(r=t.indexOf(":",r+1))>=0;)n++;if(t.substr(0,2)==="::"&&n--,t.substr(-2,2)==="::"&&n--,n>e)return null;for(f=e-n,o=":";f--;)o+="0:";return t=t.replace("::",o),t[0]===":"&&(t=t.slice(1)),t[t.length-1]===":"&&(t=t.slice(0,-1)),e=function(){let m=t.split(":"),$=[];for(let v=0;v<m.length;v++)$.push(parseInt(m[v],16));return $}(),{parts:e,zoneId:i}}function y(t,e,n,r){if(t.length!==e.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let i=0,o;for(;r>0;){if(o=n-r,o<0&&(o=0),t[i]>>o!=e[i]>>o)return!1;r-=n,i+=1}return!0}function l(t){if(E.test(t))return parseInt(t,16);if(t[0]==="0"&&!isNaN(parseInt(t[1],10))){if(c.test(t))return parseInt(t,8);throw new Error(`ipaddr: cannot parse ${t} as octal`)}return parseInt(t,10)}function R(t,e){for(;t.length<e;)t=`0${t}`;return t}let s={};s.IPv4=function(){function t(e){if(e.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let n,r;for(n=0;n<e.length;n++)if(r=e[n],!(0<=r&&r<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=e}return t.prototype.SpecialRanges={unspecified:[[new t([0,0,0,0]),8]],broadcast:[[new t([255,255,255,255]),32]],multicast:[[new t([224,0,0,0]),4]],linkLocal:[[new t([169,254,0,0]),16]],loopback:[[new t([127,0,0,0]),8]],carrierGradeNat:[[new t([100,64,0,0]),10]],private:[[new t([10,0,0,0]),8],[new t([172,16,0,0]),12],[new t([192,168,0,0]),16]],reserved:[[new t([192,0,0,0]),24],[new t([192,0,2,0]),24],[new t([192,88,99,0]),24],[new t([198,51,100,0]),24],[new t([203,0,113,0]),24],[new t([240,0,0,0]),4]]},t.prototype.kind=function(){return"ipv4"},t.prototype.match=function(e,n){let r;if(n===void 0&&(r=e,e=r[0],n=r[1]),e.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return y(this.octets,e.octets,8,n)},t.prototype.prefixLengthFromSubnetMask=function(){let e=0,n=!1,r={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},i,o,f;for(i=3;i>=0;i-=1)if(o=this.octets[i],o in r){if(f=r[o],n&&f!==0)return null;f!==8&&(n=!0),e+=f}else return null;return 32-e},t.prototype.range=function(){return s.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){return this.octets.slice(0)},t.prototype.toIPv4MappedAddress=function(){return s.IPv6.parse(`::ffff:${this.toString()}`)},t.prototype.toNormalizedString=function(){return this.toString()},t.prototype.toString=function(){return this.octets.join(".")},t}(),s.IPv4.broadcastAddressFromCIDR=function(t){try{let e=this.parseCIDR(t),n=e[0].toByteArray(),r=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[],o=0;for(;o<4;)i.push(parseInt(n[o],10)|parseInt(r[o],10)^255),o++;return new this(i)}catch(e){throw new Error("ipaddr: the address does