const e=e=>{try{return new URL(e),!0}catch{return!1}},t=t=>{if(e(t))return t;try{if(t.includes(`.`)&&!t.includes(` `))return new URL(`https://${t}`).toString()}catch{}return t},n=t=>{if(e(t))return new URL(t);try{if(t.includes(`.`)&&!t.includes(` `))return new URL(`https://${t}`)}catch{}return null},r=t=>{if(e(t))return t;try{if(t.includes(`.`)&&!t.includes(` `))return new URL(`https://${t}`).toString()}catch{}return null},i=e=>{let t={};return new URL(e).searchParams.forEach(function(e,n){t[n]=e}),t},a=e=>{let t={};return new URL(e).searchParams.forEach(function(e,n){if(n in t){let r=t[n];Array.isArray(r)?r.push(e):t[n]=[r,e]}else t[n]=e}),t},o=e=>{if(!e)return{};try{let t=new URL(e).searchParams,n={};for(let[e,r]of t.entries())r&&r!==``&&(n[e]=r);return n}catch{return{}}},s=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_term`,`utm_content`,`ref`],c=(e,t)=>{if(!e)return``;try{let n=new URL(e);for(let[e,r]of Object.entries(t))r?n.searchParams.set(e,r.replace(`+`,` `)):n.searchParams.delete(e);return n.toString()}catch{return``}},l=[{display:`UTM Source`,key:`utm_source`,examples:`google, twitter`},{display:`UTM Medium`,key:`utm_medium`,examples:`social, email`},{display:`UTM Campaign`,key:`utm_campaign`,examples:`summer sale`},{display:`UTM Term`,key:`utm_term`,examples:`blue shoes`},{display:`UTM Content`,key:`utm_content`,examples:`logo link`},{display:`Referral (ref)`,key:`ref`,examples:`google, twitter`}],u=e=>{try{let t=new URL(e);return l.forEach(e=>t.searchParams.delete(e.key)),t.toString()}catch{return e}},d=e=>e?e.replace(/(^\w+:|^)\/\//,``).replace(`www.`,``).replace(/\/$/,``):``,f=(e,t,n)=>{if(t===`dub.co`)return e;let r=new URL(e.startsWith(`/`)?`https://dub.co${e}`:e);return n&&Object.entries(n).forEach(([e,t])=>{r.searchParams.set(e,t)}),r.toString()},p=e=>{try{let t=new URL(e,`https://dummy-base.local`),n=t.pathname+t.search;return n=n.startsWith(`/`)?n.slice(1):n,n}catch{return e}},m=e=>{try{let t=new URL(e);return`https://${t.hostname}${t.pathname}`}catch{return e}};function h(e,t){let n=new URL(e,typeof window<`u`?window.location.origin:`http://localhost`);return t&&Object.entries(t).forEach(([e,t])=>{t!=null&&t!==``&&n.searchParams.append(e,String(t))}),n.toString()}const g=e=>{try{let t=new URL(e).pathname.split(`.`).pop();return t?t.toUpperCase():null}catch{let t=e.split(`.`).pop()?.split(`?`)[0];return t?t.toUpperCase():null}};export{l as _,g as a,d as c,t as d,r as f,m as g,e as h,f as i,i as l,u as m,h as n,o,n as p,c as r,p as s,s as t,a as u};
//# sourceMappingURL=urls-ivBifiO_.mjs.map