!function(a,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((a="undefined"!=typeof globalThis?globalThis:a||self).tldts={})}(this,(function(a){"use strict";function o(a,o){let e=0,i=a.length,s=!1;if(!o){if(a.startsWith("data:"))return null;for(;ee+1&&a.charCodeAt(i-1)<=32;)i-=1;if(47===a.charCodeAt(e)&&47===a.charCodeAt(e+1))e+=2;else{const o=a.indexOf(":/",e);if(-1!==o){const i=o-e,s=a.charCodeAt(e),n=a.charCodeAt(e+1),t=a.charCodeAt(e+2),r=a.charCodeAt(e+3),l=a.charCodeAt(e+4);if(5===i&&104===s&&116===n&&116===t&&112===r&&115===l);else if(4===i&&104===s&&116===n&&116===t&&112===r);else if(3===i&&119===s&&115===n&&115===t);else if(2===i&&119===s&&115===n);else for(let i=e;i=97&&o<=122||o>=48&&o<=57||46===o||45===o||43===o))return null}for(e=o+2;47===a.charCodeAt(e);)e+=1}}let o=-1,n=-1,t=-1;for(let r=e;r=65&&e<=90&&(s=!0)}if(-1!==o&&o>e&&oe&&te+1&&46===a.charCodeAt(i-1);)i-=1;const n=0!==e||i!==a.length?a.slice(e,i):a;return s?n.toLowerCase():n}function e(a){return a>=97&&a<=122||a>=48&&a<=57||a>127}function i(a){if(a.length>255)return!1;if(0===a.length)return!1;if(!e(a.charCodeAt(0))&&46!==a.charCodeAt(0)&&95!==a.charCodeAt(0))return!1;let o=-1,i=-1;const s=a.length;for(let n=0;n64||46===i||45===i||95===i)return!1;o=n}else if(!e(s)&&45!==s&&95!==s)return!1;i=s}return s-o-1<=63&&45!==i}const s=function({allowIcannDomains:a=!0,allowPrivateDomains:o=!1,detectIp:e=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:o,detectIp:e,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}({});function n(a,e,n,t,r){const l=function(a){return void 0===a?s:function({allowIcannDomains:a=!0,allowPrivateDomains:o=!1,detectIp:e=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:o,detectIp:e,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}(a)}(t);return"string"!=typeof a?r:(l.extractHostname?l.mixedInputs?r.hostname=o(a,i(a)):r.hostname=o(a,!1):r.hostname=a,0===e||null===r.hostname||l.detectIp&&(r.isIp=function(a){if(a.length<3)return!1;let o=a.startsWith("[")?1:0,e=a.length;if("]"===a[e-1]&&(e-=1),e-o>39)return!1;let i=!1;for(;o=48&&e<=57||e>=97&&e<=102||e>=65&&e<=90))return!1}return i}(u=r.hostname)||function(a){if(a.length<7)return!1;if(a.length>15)return!1;let o=0;for(let e=0;e57)return!1}return 3===o&&46!==a.charCodeAt(0)&&46!==a.charCodeAt(a.length-1)}(u),r.isIp)?r:l.validateHostname&&l.extractHostname&&!i(r.hostname)?(r.hostname=null,r):(n(r.hostname,l,r),2===e||null===r.publicSuffix?r:(r.domain=function(a,o,e){if(null!==e.validHosts){const a=e.validHosts;for(const e of a)if(function(a,o){return!!a.endsWith(o)&&(a.length===o.length||"."===a[a.length-o.length-1])}(o,e))return e}let i=0;if(o.startsWith("."))for(;i3){const o=a.length-1,i=a.charCodeAt(o),s=a.charCodeAt(o-1),n=a.charCodeAt(o-2),t=a.charCodeAt(o-3);if(109===i&&111===s&&99===n&&46===t)return e.isIcann=!0,e.isPrivate=!1,e.publicSuffix="com",!0;if(103===i&&114===s&&111===n&&46===t)return e.isIcann=!0,e.isPrivate=!1,e.publicSuffix="org",!0;if(117===i&&100===s&&101===n&&46===t)return e.isIcann=!0,e.isPrivate=!1,e.publicSuffix="edu",!0;if(118===i&&111===s&&103===n&&46===t)return e.isIcann=!0,e.isPrivate=!1,e.publicSuffix="gov",!0;if(116===i&&101===s&&110===n&&46===t)return e.isIcann=!0,e.isPrivate=!1,e.publicSuffix="net",!0;if(101===i&&100===s&&46===n)return e.isIcann=!0,e.isPrivate=!1,e.publicSuffix="de",!0}return!1}(a,o,e))return;const s=a.split("."),n=(o.allowPrivateDomains?2:0)|(o.allowIcannDomains?1:0),u=l(s,t,s.length-1,n);if(null!==u)return e.isIcann=u.isIcann,e.isPrivate=u.isPrivate,void(e.publicSuffix=s.slice(u.index+1).join("."));const m=l(s,r,s.length-1,n);if(null!==m)return e.isIcann=m.isIcann,e.isPrivate=m.isPrivate,void(e.publicSuffix=s.slice(m.index).join("."));e.isIcann=!1,e.isPrivate=!1,e.publicSuffix=null!==(i=s[s.length-1])&&void 0!==i?i:null}const m={domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,publicSuffix:null,subdomain:null};a.getDomain=function(a,o={}){var e;return(e=m).domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.publicSuffix=null,e.subdomain=null,n(a,3,u,o,m).domain},a.getDomainWithoutSuffix=function(a,o={}){var e;return(e=m).domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.publicSuffix=null,e.subdomain=null,n(a,5,u,o,m).domainWithoutSuffix},a.getHostname=function(a,o={}){var e;return(e=m).domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.publicSuffix=null,e.subdomain=null,n(a,0,u,o,m).hostname},a.getPublicSuffix=function(a,o={}){var e;return(e=m).domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.publicSuffix=null,e.subdomain=null,n(a,2,u,o,m).publicSuffix},a.getSubdomain=function(a,o={}){var e;return(e=m).domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.publicSuffix=null,e.subdomain=null,n(a,4,u,o,m).subdomain},a.parse=function(a,o={}){return n(a,5,u,o,{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,publicSuffix:null,subdomain:null})}})); //# sourceMappingURL=index.umd.min.js.map