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