text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.DnsOverHttpResolver=t():e.DnsOverHttpResolver=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([function(e,t,r){"use strict";var n=1e3,o=6e4,s=60*o,i=24*s;function c(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}e.exports=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*i;case"hours":case"hour":case"hrs":case"hr":case"h":return r*s;case"minutes":case"minute":case"mins":case"min":case"m":return r*o;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=i)return c(e,t,i,"day");if(t>=s)return c(e,t,s,"hour");if(t>=o)return c(e,t,o,"minute");if(t>=n)return c(e,t,n,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=i)return Math.round(e/i)+"d";if(t>=s)return Math.round(e/s)+"h";if(t>=o)return Math.round(e/o)+"m";if(t>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";var n=r(14),o="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),s=Object.prototype.toString,i=Array.prototype.concat,c=Object.defineProperty,u=c&&function(){var e={};try{for(var t in c(e,"x",{enumerable:!1,value:e}),e)return!1;return e.x===e}catch(r){return!1}}(),a=function(e,t,r,n){var o;(!(t in e)||"function"==typeof(o=n)&&"[object Function]"===s.call(o)&&n())&&(u?c(e,t,{configurable:!0,enumerable:!1,value:r,writable:!0}):e[t]=r)},l=function(e,t){var r=arguments.length>2?arguments[2]:{},s=n(t);o&&(s=i.call(s,Object.getOwnPropertySymbols(t)));for(var c=0;c<s.length;c+=1)a(e,s[c],t[s[c]],r[s[c]])};l.supportsDescriptors=!!u,e.exports=l},function(e,t,r){"use strict";var n=Object.prototype.toString;e.exports=function(e){var t=n.call(e),r="[object Arguments]"===t;return r||(r="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===n.call(e.callee)),r}},function(e,t,r){"use strict";"undefined"!=typeof self?e.exports=self:"undefined"!=typeof window?e.exports=window:e.exports=Function("return this")()},function(e,t,r){"use strict";(function(t){var n=r(3);e.exports=function(){return"object"==typeof t&&t&&t.Math===Math&&t.Array===Array?t:n}}).call(this,r(16))},function(e,t,r){e.exports=r(6)},function(e,t,r){"use strict";const n=r(7),o=n("dns-over-http-resolver");o.error=n("dns-over-http-resolver:error");const s=r(10),{buildResource:i,fetch:c,getCacheKey:u}=r(11);class a{constructor({maxCache:e=100}={}){this._cache=new s({max:e}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"]}getServers(){return this._servers}_getShuffledServers(){const e=[].concat(this._servers);for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),n=e[t];e[t]=e[r],e[r]=n}return e}setServers(e){this._servers=e}resolve(e,t="A"){switch(t){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error(t+" is not supported")}}async resolve4(e){const t=this._cache.get(u(e,"A"));if(t)return t;for(const n of this._getShuffledServers())try{const t=await c(i({serverResolver:n,hostname:e,recordType:"A"})),r=await t.json(),o=r.Answer.map(e=>e.data),s=Math.min(r.Answer.map(e=>e.TTL));return this._cache.set(u(e,"A"),o,{ttl:s}),o}catch(r){o.error(`${n} could not resolve ${e} record A`)}throw new Error(`Could not resolve ${e} record A`)}async resolve6(e){const t=this._cache.get(u(e,"AAAA"));if(t)return t;for(const n of this._getShuffledServers())try{const t=await c(i({serverResolver:n,hostname:e,recordType:"AAAA"})),r=await t.json(),o=r.Answer.map(e=>e.data),s=Math.min(r.Answer.map(e=>e.TTL));return this._cache.set(u(e,"AAAA"),o,{ttl:s}),o}catch(r){o.error(`${n} could not resolve ${e} record AAAA`)}throw new Error(`Could not resolve ${e} record AAAA`)}async resolveTxt(e){const t=this._cache.get(u(e,"TXT"));if(t)return t;for(const n of this._getShuffledServers())try{const t=await c(i({serverResolver:n,hostname:e,recordType:"TXT"})),r=await t.json(),o=r.Answer.map(e=>[e.data.replace(/['"]+/g,"")]),s=Math.min(r.Answer.map(e=>e.TTL));return this._cache.set(u(e,"TXT"),o,{ttl:s}),o}catch(r){o.error(`${n} could not resolve ${e} record TXT`)}throw new Error(`Could not resolve ${e} record TXT`)}}a.Resolver=a,e.exports=a},function(e,t,r){"use strict";(function(n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))}),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(r){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(r){}!e&&void 0!==n&&"env"in n&&(e={NODE_ENV:"production"}.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(9)(t);const{formatters:o}=e.exports;o.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}).call(this,r(8))},function(e,t,r){"use strict";var n,o,s=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function c(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{o="function"==typeof clearTimeout?clearTimeout:c}catch(e){o=c}}();var a,l=[],f=!1,h=-1;function p(){f&&a&&(f=!1,a.length?l=a.concat(l):h=-1,l.length&&d())}function d(){if(!f){var e=u(p);f=!0;for(var t=l.length;t;){for(a=l,l=[];++h<t;)a&&a[h].run();h=-1,t=l.length}a=null,f=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===c||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function y(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new m(e,t)),1!==l.length||f||u(d)},m.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=y,s.addListener=y,s.once=y,s.off=y,s.removeListener=y,s.removeAllListeners=y,s.emit=y,s.prependListener=y,s.prependOnceListener=y,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(e,t,r){"use strict";e.exports=function(e){function t(e){let r;function s(...e){if(!s.enabled)return;const n=s,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let c=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return r;c++;const s=t.formatters[o];if("function"==typeof s){const t=e[c];r=s.call(n,t),e.splice(c,1),c--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return s.namespace=e,s.enabled=t.enabled(e),s.useColors=t.useColors(),s.color=t.selectColor(e),s.destroy=n,s.extend=o,"function"==typeof t.init&&t.init(s),t.instances.push(s),s}function n(){const e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}function o(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(s),...t.skips.map(s).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(r=0;r<t.instances.length;r++){const e=t.instances[r];e.enabled=t.enabled(e.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(0),Object.keys(e).forEach(r=>{t[r]=e[r]}),t.instances=[],t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},function(e,t,r){"use strict";e.exports=i;var n=r(0),o=i.prototype,s=new Date%1e9;function i(e){e=e||{},this.id=e.id||(1e9*Math.random()>>>0)+s++,this.max=e.max||1/0,this.items=e.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(e.lastModified||new Date);for(var t,r,n=this.items.length;n--;)t=this.items[n],r=new Date(t.expires)-new Date,this._lookup[t.key]=t,r>0?this.expire(t.key,r):r<=0&&this.delete(t.key)}o.has=function(e){return e in this._lookup},o.get=function(e){if(!this.has(e))return null;var t=this._lookup[e];return t.refresh&&this.expire(e,t.refresh),this.items.splice(this.items.indexOf(t),1),this.items.push(t),t.value},o.meta=function(e){if(!this.has(e))return null;var t=this._lookup[e];return"meta"in t?t.meta:null},o.set=function(e,t,r){var n=this._lookup[e],o=this._lookup[e]={key:e,value:t};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,o)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(o),this.size++),r&&("ttl"in r&&this.expire(e,r.ttl),"meta"in r&&(o.meta=r.meta),r.refresh&&(o.refresh=r.ttl)),this},o.delete=function(e){var t=this._lookup[e];return!!t&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(t),1),clearTimeout(t.timeout),delete this._lookup[e],this.size--,this)},o.expire=function(e,t){var r=t||0,o=this._lookup[e];if(!o)return this;if("string"==typeof r&&(r=n(t)),"number"!=typeof r)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(o.timeout),o.timeout=setTimeout(this.delete.bind(this,o.key),r),o.expires=Number(new Date)+r,this},o.clear=function(){for(var e=this.items.length;e--;)this.delete(this.items[e].key);return this},o.toJSON=function(){for(var e,t=new Array(this.items.length),r=t.length;r--;)e=this.items[r],t[r]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:t}}},function(e,t,r){"use strict";const{default:n,Headers:o}=r(12);e.exports.buildResource=function({serverResolver:e,hostname:t,recordType:r}){return`${e}?name=${t}&type=${r}`},e.exports.fetch=function(e){return n(e,{headers:new o({accept:"application/dns-json"})})},e.exports.getCacheKey=function(e,t){return`${t}_${e}`}},function(e,t,r){"use strict";const n=r(13)();n.fetch&&n.Headers&&n.Request&&n.Response?(e.exports=function(...e){return n.fetch(...e)},e.exports.Headers=n.Headers,e.exports.Request=n.Request,e.exports.Response=n.Response,e.exports.default=e.exports):e.exports=r(18)},function(e,t,r){"use strict";var n=r(1),o=r(3),s=r(4),i=r(17),c=s(),u=function(){return c};n(u,{getPolyfill:s,implementation:o,shim:i}),e.exports=u},function(e,t,r){"use strict";var n=Array.prototype.slice,o=r(2),s=Object.keys,i=s?function(e){return s(e)}:r(15),c=Object.keys;i.shim=function(){Object.keys?function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2)||(Object.keys=function(e){return o(e)?c(n.call(e)):c(e)}):Object.keys=i;return Object.keys||i},e.exports=i},function(e,t,r){"use strict";var n;if(!Object.keys){var o=Object.prototype.hasOwnProperty,s=Object.prototype.toString,i=r(2),c=Object.prototype.propertyIsEnumerable,u=!c.call({toString:null},"toString"),a=c.call((function(){}),"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],f=function(e){var t=e.constructor;return t&&t.prototype===e},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!h["$"+e]&&o.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{f(window[e])}catch(t){return!0}}catch(t){return!0}return!1}();n=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===s.call(e),n=i(e),c=t&&"[object String]"===s.call(e),h=[];if(!t&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var d=a&&r;if(c&&e.length>0&&!o.call(e,0))for(var m=0;m<e.length;++m)h.push(String(m));if(n&&e.length>0)for(var y=0;y<e.length;++y)h.push(String(y));else for(var g in e)d&&"prototype"===g||!o.call(e,g)||h.push(String(g));if(u)for(var v=function(e){if("undefined"==typeof window||!p)return f(e);try{return f(e)}catch(t){return!1}}(e),C=0;C<l.length;++C)v&&"constructor"===l[C]||!o.call(e,l[C])||h.push(l[C]);return h}}e.exports=n},function(e,t,r){"use strict";var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(o){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,r){"use strict";var n=r(1),o=r(4);e.exports=function(){var e=o();if(n.supportsDescriptors){var t=Object.getOwnPropertyDescriptor(e,"globalThis");(!t||t.configurable&&(t.enumerable||t.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!1})}else"object"==typeof globalThis&&globalThis===e||(e.globalThis=e);return e}},function(e,t,r){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();e.exports=t=n.fetch,n.fetch&&(t.default=n.fetch.bind(n)),t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response}])}));