function t(t){const r=null!=t.match(/^https?:\/\//)?t:"https://"+t,e=t.startsWith("*.");if(!e&&t.includes("*"))throw new n("invalid-wildcard",'Invalid wildcard format. "*" may only be used as a subdomain');try{const{hostname:t,pathname:n}=new URL(r.replace("*.",""));return{hostname:t,pathname:n,isWildcard:e}}catch{if(0===t.length)throw new n("empty","Empty domain value");throw new n("invalid-format","Invalid domain format")}}class n extends Error{constructor(t,n){super(n),this.code=t}}function r(t,n){return[n?"*.":"",t].join("")}function e(t,n,r,e){return[e?"http://":"https://",r?"www.":"",t,n].join("")}function i(t){return t.endsWith("cleverapps.io")}function a(t){return i(t)&&t.split(".").length>3}function o(t,n){if(t.isPrimary)return-1;if(n.isPrimary)return 1;const r=s(t),e=s(n);return r.localeCompare(e)}function s(t){return t.hostname.split(".").reverse().join(".")+(t.isWildcard?".*":"")+t.pathPrefix}export{n as DomainParseError,e as getDomainUrl,r as getHostWithWildcard,i as isTestDomain,a as isTestDomainWithSubdomain,t as parseDomain,o as sortDomains};
//# sourceMappingURL=domain.js.map
