var a=t=>{try{return new URL(t),!0}catch{return!1}},i=t=>{if(a(t))return t;try{if(t.includes(".")&&!t.includes(" "))return new URL(`https://${t}`).toString()}catch{}return t},m=t=>{if(a(t))return t;try{if(t.includes(".")&&!t.includes(" "))return new URL(`https://${t}`).toString()}catch{}return null},u=t=>{let e={};return new URL(t).searchParams.forEach(function(r,n){e[n]=r}),e},g=t=>{let e={};return new URL(t).searchParams.forEach(function(r,n){if(n in e){let s=e[n];Array.isArray(s)?s.push(r):e[n]=[s,r]}else e[n]=r}),e},p=t=>{if(!t)return{};try{let e=new URL(t).searchParams,r={};for(let[n,s]of e.entries())s&&s!==""&&(r[n]=s);return r}catch{return{}}},l=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],f=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref"],d=(t,e)=>{if(!t)return"";try{let r=new URL(t);for(let[n,s]of Object.entries(e))s===""?r.searchParams.delete(n):r.searchParams.set(n,s);return r.toString()}catch{return""}},o=[{display:"UTM Source",key:"utm_source",examples:"twitter, facebook"},{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:"logolink"},{display:"Referral (ref)",key:"ref",examples:"twitter, facebook"}],U=t=>{try{let e=new URL(t);return o.forEach(r=>e.searchParams.delete(r.key)),e.toString()}catch{return t}},h=t=>t?t.replace(/(^\w+:|^)\/\//,"").replace("www.","").replace(/\/$/,""):"",y=(t,e,r)=>{if(e==="dub.co")return t;let n=new URL(t.startsWith("/")?`https://dub.co${t}`:t);return r&&Object.entries(r).forEach(([s,c])=>{n.searchParams.set(s,c)}),n.toString()};export{a,i as b,m as c,u as d,g as e,p as f,l as g,f as h,d as i,o as j,U as k,h as l,y as m};
