var a=t=>{try{return new URL(t),!0}catch{return!1}},l=t=>{if(a(t))return t;try{if(t.includes(".")&&!t.includes(" "))return new URL(`https://${t}`).toString()}catch{}return t},p=t=>{if(a(t))return new URL(t);try{if(t.includes(".")&&!t.includes(" "))return new URL(`https://${t}`)}catch{}return null},m=t=>{if(a(t))return t;try{if(t.includes(".")&&!t.includes(" "))return new URL(`https://${t}`).toString()}catch{}return null},g=t=>{let e={};return new URL(t).searchParams.forEach(function(r,n){e[n]=r}),e},h=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},i=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{}}},c=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref"],U=(t,e)=>{if(!t)return"";try{let r=new URL(t);for(let[n,s]of Object.entries(e))s?r.searchParams.set(n,s.replace("+"," ")):r.searchParams.delete(n);return r.toString()}catch{return""}},u=[{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"}],d=t=>Object.fromEntries(Object.entries(i(t)).filter(([e])=>c.includes(e))),f=t=>{try{let e=new URL(t);return u.forEach(r=>e.searchParams.delete(r.key)),e.toString()}catch{return t}},y=t=>t?t.replace(/(^\w+:|^)\/\//,"").replace("www.","").replace(/\/$/,""):"",w=(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,o])=>{n.searchParams.set(s,o)}),n.toString()},x=t=>{try{let e=new URL(t,"https://dummy-base.local"),r=e.pathname+e.search;return r=r.startsWith("/")?r.slice(1):r,r}catch{return t}},R=t=>{try{let e=new URL(t);return`https://${e.hostname}${e.pathname}`}catch{return t}};function L(t,e){let r=new URL(t,typeof window<"u"?window.location.origin:"http://localhost");return e&&Object.entries(e).forEach(([n,s])=>{s!=null&&s!==""&&r.searchParams.append(n,String(s))}),r.toString()}var b=t=>{var e;try{let n=new URL(t).pathname.split(".").pop();return n?n.toUpperCase():null}catch{let r=(e=t.split(".").pop())==null?void 0:e.split("?")[0];return r?r.toUpperCase():null}};export{a,l as b,p as c,m as d,g as e,h as f,i as g,c as h,U as i,u as j,d as k,f as l,y as m,w as n,x as o,R as p,L as q,b as r};
