diff --git a/feature/revealable-api-key/assets/index-C1TMImW3.js b/feature/revealable-api-key/assets/index-DSvpWWmy.js similarity index 99% rename from feature/revealable-api-key/assets/index-C1TMImW3.js rename to feature/revealable-api-key/assets/index-DSvpWWmy.js index d1373007..420627ca 100644 --- a/feature/revealable-api-key/assets/index-C1TMImW3.js +++ b/feature/revealable-api-key/assets/index-DSvpWWmy.js @@ -727,7 +727,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho * https://github.com/lancedikson/bowser * MIT License | (c) Dustin Diaz 2012-2015 * MIT License | (c) Denis Demchenko 2015-2019 - */class wCe{static getParser(t,r=!1){if(typeof t!="string")throw new Error("UserAgent should be a string");return new i8(t,r)}static parse(t){return new i8(t).getResult()}static get BROWSER_MAP(){return Hz}static get ENGINE_MAP(){return Zs}static get OS_MAP(){return Pn}static get PLATFORMS_MAP(){return Er}}var xCe=Object.defineProperty,SCe=(e,t,r)=>t in e?xCe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ll=(e,t,r)=>SCe(e,typeof t!="symbol"?t+"":t,r);const OCe=e=>(e==null?void 0:e.type)===oj.INVALID_ARGUMENT,CCe=e=>(e==null?void 0:e.type)===oj.INVALID_SHORT_URL_DELETION,PCe=e=>!!e&&typeof e=="object"&&["type","detail","title","status"].every(t=>t in e),Ci=e=>PCe(e)?e:void 0,wA=e=>"error"in e,uo=({errorData:e,fallbackMessage:t})=>v.jsxs(v.Fragment,{children:[(e==null?void 0:e.detail)??t,OCe(e)&&v.jsxs("p",{className:"mb-0",children:["Invalid elements: [",e.invalidElements.join(", "),"]"]})]}),Wu=({style:e,className:t,...r})=>v.jsx("button",{type:"button",className:Te("border-0",t),style:{backgroundColor:"inherit",fontWeight:"inherit",color:"inherit",...e},...r}),Gz=M.createContext(""),ECe=Gz.Provider,jl=()=>M.useContext(Gz),Kz=M.createContext(void 0),{Provider:xA}=Kz,Jb=()=>M.useContext(Kz),TCe=5,SA=()=>{const[e,t]=M.useState([]),r=M.useMemo(()=>e.length>=TCe,[e.length]),n=M.useCallback(s=>!r&&t(c=>[...c,s]),[r]),i=M.useCallback(s=>!r&&e.every(c=>c.name!==s),[e,r]),a=M.useCallback(s=>t(c=>c.filter(l=>l!==s)),[]),o=M.useCallback(()=>t([]),[]);return{itemsToCompare:e,addItemToCompare:n,removeItemToCompare:a,clearItemsToCompare:o,canAddItemWithName:i}},OA=({className:e,type:t})=>{const r=jl(),n=Jb(),i=M.useMemo(()=>n?encodeURIComponent(n.itemsToCompare.map(c=>c.query).join(",")):"",[n]);if(!n||n.itemsToCompare.length===0)return null;const{itemsToCompare:a,clearItemsToCompare:o,removeItemToCompare:s}=n;return v.jsx("div",{className:Te("top-sticky",e),children:v.jsxs(Sr,{bodyClassName:"d-md-flex gap-3 align-items-center",children:[v.jsx("ul",{className:"d-flex flex-wrap gap-1 flex-grow-1 p-0 m-0",children:a.map((c,l)=>{var h;return v.jsxs("li",{className:Te("badge pe-1",{"bg-secondary":!((h=c.style)!=null&&h.backgroundColor)}),style:c.style,children:[c.name,v.jsx(Wu,{"aria-label":`Remove ${c.name}`,className:"fw-bold fs-6",onClick:()=>s(c),children:"×"})]},`${c.name}_${l}`)})}),v.jsxs("div",{className:"d-flex mt-3 mt-md-0",children:[v.jsxs(Lt,{outline:!0,color:"primary",className:"flex-grow-1 indivisible",disabled:a.length<2,tag:Xt,to:`${r}/${t}/compare-visits?${t}=${i}`,children:[v.jsx(He,{icon:X0,fixedWidth:!0,className:"me-1"}),"Compare (",a.length,"/5) »"]}),v.jsx(Lt,{"aria-label":"Close compare",outline:!0,color:"secondary",className:"ms-2 fw-bold",onClick:o,children:"×"})]})]})})},jCe=(e,{maxVersion:t,minVersion:r})=>{const n=!r||yP(e,r,">=");return(!t||yP(e,t,"<="))&&n},Yz={shortUrlVisitsDeletion:{minVersion:"3.6.0"},orphanVisitsDeletion:{minVersion:"3.7.0"},deviceLongUrls:{maxVersion:"3.*.*"},shortUrlRedirectRules:{minVersion:"4.0.0"},qrCodeColors:{minVersion:"4.0.0"},urlValidation:{maxVersion:"3.*.*"},ipRedirectCondition:{minVersion:"4.2.0"},geolocationRedirectCondition:{minVersion:"4.3.0"},filterShortUrlsByDomain:{minVersion:"4.3.0"}};Object.freeze(Yz);const Do=(e,t)=>jCe(t==="latest"?"999.99.99":t,Yz[e]),Zz=e=>({deviceLongUrls:Do("deviceLongUrls",e),shortUrlVisitsDeletion:Do("shortUrlVisitsDeletion",e),orphanVisitsDeletion:Do("orphanVisitsDeletion",e),shortUrlRedirectRules:Do("shortUrlRedirectRules",e),qrCodeColors:Do("qrCodeColors",e),urlValidation:Do("urlValidation",e),ipRedirectCondition:Do("ipRedirectCondition",e),geolocationRedirectCondition:Do("geolocationRedirectCondition",e),filterShortUrlsByDomain:Do("filterShortUrlsByDomain",e)}),Xz=M.createContext(Zz("0.0.0")),ACe=Xz.Provider,kCe=e=>M.useMemo(()=>Zz(e),[e]),Ca=e=>M.useContext(Xz)[e],ad="DEFAULT",Gg=({className:e="",placement:t,children:r})=>{const n=_i();return v.jsxs(v.Fragment,{children:[v.jsx("span",{className:e,ref:n,children:v.jsx(He,{icon:wT})}),v.jsx(Oi,{target:n,placement:t,children:r})]})},Qz=e=>t=>{t.preventDefault(),e()},CA=(e,t,r=1)=>sj(r,e+1).map(t),RCe=e=>Array.isArray(e)&&e.length===0||typeof e=="string"&&e===""||typeof e=="object"&&Object.keys(e).length===0,vu=e=>e!=null&&!RCe(e),pO=e=>e||null,YE=e=>e?"true":"false",mO=e=>e===void 0?void 0:YE(e),vO=({isLast:e,...t})=>v.jsx(Yie,{...t,required:!1,type:"url",placeholder:"No redirect",className:e?"mb-0":""}),NCe=({isOpen:e,toggle:t,domain:r,editDomainRedirects:n})=>{var i,a,o;const[s,c]=M.useState(((i=r.redirects)==null?void 0:i.baseUrlRedirect)??""),[l,h]=M.useState(((a=r.redirects)==null?void 0:a.regular404Redirect)??""),[p,g]=M.useState(((o=r.redirects)==null?void 0:o.invalidShortUrlRedirect)??""),_=Qz(async()=>n({domain:r.domain,redirects:{baseUrlRedirect:pO(s),regular404Redirect:pO(l),invalidShortUrlRedirect:pO(p)}}).then(t));return v.jsx(Ji,{isOpen:e,toggle:t,centered:!0,children:v.jsxs("form",{name:"domainRedirectsModal",onSubmit:_,children:[v.jsxs(Sl,{toggle:t,children:["Edit redirects for ",v.jsx("b",{children:r.domain})]}),v.jsxs(as,{children:[v.jsxs(vO,{value:s,onChange:c,children:[v.jsxs(Gg,{className:"me-2",placement:"bottom",children:["Visitors accessing the base url, as in ",v.jsxs("b",{children:["https://",r.domain,"/"]}),", will be redirected to this URL."]}),"Base URL"]}),v.jsxs(vO,{value:l,onChange:h,children:[v.jsxs(Gg,{className:"me-2",placement:"bottom",children:["Visitors accessing a url not matching a short URL pattern, as in ",v.jsxs("b",{children:["https://",r.domain,"/???/[...]"]}),", will be redirected to this URL."]}),"Regular 404"]}),v.jsxs(vO,{value:p,isLast:!0,onChange:g,children:[v.jsx(Gg,{className:"me-2",placement:"bottom",children:"Visitors accessing a url matching a short URL pattern, but not matching an existing short code, will be redirected to this URL."}),"Invalid short URL"]})]}),v.jsxs(Hu,{children:[v.jsx(Lt,{color:"link",type:"button",onClick:t,children:"Cancel"}),v.jsx(Lt,{color:"primary",children:"Save"})]})]})})},MCe=({domain:e,editDomainRedirects:t})=>{const[r,n]=ir(),i=jl(),a=Jb(),o=Ca("filterShortUrlsByDomain");return v.jsxs(lb,{children:[v.jsxs(Ze,{tag:Xt,to:`${i}/domain/${e.domain}${e.isDefault?`_${ad}`:""}/visits`,children:[v.jsx(He,{icon:_T,fixedWidth:!0})," Visit stats"]}),v.jsxs(Ze,{disabled:!a||!a.canAddItemWithName(e.domain),onClick:()=>a==null?void 0:a.addItemToCompare({name:e.domain,query:e.domain}),children:[v.jsx(He,{icon:X0,fixedWidth:!0})," Compare visits"]}),o&&v.jsxs(Ze,{tag:Xt,to:`${i}/list-short-urls/1?domain=${e.isDefault?ad:e.domain}`,children:[v.jsx(He,{icon:yT,fixedWidth:!0})," Short URLs"]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{onClick:n,children:[v.jsx(He,{icon:bT,fixedWidth:!0})," Edit redirects"]}),v.jsx(NCe,{domain:e,isOpen:r,toggle:n,editDomainRedirects:t})]})},LCe=(e,t)=>{const r=n=>i=>{i.event.composedPath().some(({classList:a})=>a==null?void 0:a.contains("visits-table"))||document.querySelector(".modal")||n()};return Boe({delta:40,onSwipedLeft:r(t),onSwipedRight:r(e)})},ICe=(e,t)=>{const[r,n]=M.useState(t),i=M.useCallback(a=>{const{location:o,history:s}=window,c=h7(o.search);c[e]=a,s.pushState(null,"",`${o.pathname}?${sb(c)}`),n(a)},[e]);return[r,i]},PA=e=>{const t=hd();return M.useMemo(()=>{var r;return((r=t[e])==null?void 0:r.split(",").filter(Boolean))??[]},[e,t])},DCe=()=>{const e=fo();return M.useCallback(()=>e(-1),[e])},EA=(e,t)=>{const r=M.useCallback(()=>t(`(max-width: ${e}px)`).matches,[t,e]),[n,i]=M.useState(r());return M.useEffect(()=>{const a=()=>i(r());return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[r]),n},$Ce=(e,t,r)=>{M.useEffect(()=>{if(!r)return()=>{};const n=i=>i.key===e&&t();return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[r,t,e])},FCe=({status:e,matchMedia:t=window.matchMedia})=>{const r=_i(),n=EA(991,t);return e==="validating"?v.jsx(He,{fixedWidth:!0,icon:gT,spin:!0}):v.jsxs(v.Fragment,{children:[v.jsx("span",{ref:r,children:e==="valid"?v.jsx(He,{fixedWidth:!0,icon:vp,className:"text-muted"}):v.jsx(He,{fixedWidth:!0,icon:kO,className:"text-danger"})}),v.jsx(Oi,{target:r,placement:n?"right":"left",autohide:e==="valid",children:e==="valid"?"Congratulations! This domain is properly configured.":v.jsxs("span",{children:["Oops! There is some missing configuration, and short URLs shared with this domain will not work.",v.jsx("br",{}),"Check the ",v.jsx(Gn,{href:"https://slnk.to/multi-domain-docs",children:"documentation"})," in order to find out what is missing."]})})]})},gO=({fallback:e})=>v.jsxs("span",{className:"text-muted",children:[!e&&v.jsx("small",{children:"No redirect"}),e&&v.jsxs(v.Fragment,{children:[e," ",v.jsx("small",{children:"(as fallback)"})]})]}),BCe=()=>v.jsxs(v.Fragment,{children:[v.jsx(He,{fixedWidth:!0,icon:cY,className:"text-primary",id:"defaultDomainIcon"}),v.jsx(Oi,{target:"defaultDomainIcon",placement:"right",children:"Default domain"})]}),UCe=({domain:e,editDomainRedirects:t,checkDomainHealth:r,defaultRedirects:n})=>{const{domain:i,isDefault:a,redirects:o,status:s}=e;return M.useEffect(()=>{r(e.domain)},[r,e.domain]),v.jsxs("tr",{className:"responsive-table__row",children:[v.jsx("td",{className:"responsive-table__cell","data-th":"Is default domain",children:a&&v.jsx(BCe,{})}),v.jsx("th",{className:"responsive-table__cell","data-th":"Domain",children:i}),v.jsx("td",{className:"responsive-table__cell","data-th":"Base path redirect",children:(o==null?void 0:o.baseUrlRedirect)??v.jsx(gO,{fallback:n==null?void 0:n.baseUrlRedirect})}),v.jsx("td",{className:"responsive-table__cell","data-th":"Regular 404 redirect",children:(o==null?void 0:o.regular404Redirect)??v.jsx(gO,{fallback:n==null?void 0:n.regular404Redirect})}),v.jsx("td",{className:"responsive-table__cell","data-th":"Invalid short URL redirect",children:(o==null?void 0:o.invalidShortUrlRedirect)??v.jsx(gO,{fallback:n==null?void 0:n.invalidShortUrlRedirect})}),v.jsx("td",{className:"responsive-table__cell text-lg-center","data-th":"Status",children:v.jsx(FCe,{status:s})}),v.jsx("td",{className:"responsive-table__cell text-end",children:v.jsx(MCe,{domain:e,editDomainRedirects:t})})]})},a8=[{value:"Is default domain",isHidden:!0},{value:"Domain",isHidden:!1},{value:"Base path redirect",isHidden:!1},{value:"Regular 404 redirect",isHidden:!1},{value:"Invalid short URL redirect",isHidden:!1},{value:"Domain status",isHidden:!0},{value:"Options",isHidden:!0}],zCe=({domainsList:e,filterDomains:t,editDomainRedirects:r,checkDomainHealth:n})=>{var i;const{filteredDomains:a,defaultRedirects:o,loading:s,error:c,errorData:l}=e,h=o??((i=a.find(({isDefault:g})=>g))==null?void 0:i.redirects),p=SA();return s?v.jsx(Lu,{loading:!0}):v.jsxs(xA,{value:p,children:[v.jsx(ob,{className:"mb-3",onChange:t}),v.jsx(OA,{type:"domains",className:"mb-3"}),c?v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:l,fallbackMessage:"Error loading domains :("})}):v.jsx(Sr,{children:v.jsxs("table",{className:"table table-hover responsive-table mb-0",children:[v.jsx("thead",{className:"responsive-table__header",children:v.jsx("tr",{children:a8.map((g,_)=>v.jsx("th",{children:v.jsx("span",{className:g.isHidden?"sr-only":void 0,children:g.value})},_))})}),v.jsxs("tbody",{children:[a.length<1&&v.jsx("tr",{children:v.jsx("td",{colSpan:a8.length,className:"text-center",children:"No results found"})}),a.map(g=>v.jsx(UCe,{domain:g,editDomainRedirects:r,checkDomainHealth:n,defaultRedirects:h},g.domain))]})]})})]})},Vr=(e,t)=>D7(e,t,{serializeError:r=>r}),VCe="shlink/domainRedirects/EDIT_DOMAIN_REDIRECTS",WCe=e=>Vr(VCe,async({domain:t,redirects:r})=>{const n=await e().editDomainRedirects({domain:t,...r});return{domain:t,redirects:n}}),jg="shlink/domainsList",Ag={domains:[],filteredDomains:[],loading:!1,error:!1},o8=({domain:e,redirects:t})=>r=>r.domain!==e?r:{...r,redirects:t},s8=(e,t)=>r=>r.domain!==e?r:{...r,status:t},qCe=(e,t,r)=>{const n=Vr(`${jg}/listDomains`,async()=>{const{data:s,defaultRedirects:c}=await e().listDomains();return{domains:s.map(l=>({...l,status:"validating"})),defaultRedirects:c}}),i=Vr(`${jg}/checkDomainHealth`,async s=>{try{const{status:c}=await e().health({domain:s});return{domain:s,status:c==="pass"?"valid":"invalid"}}catch{return{domain:s,status:"invalid"}}}),a=An(`${jg}/filterDomains`),{reducer:o}=Tr({name:jg,initialState:Ag,reducers:{},extraReducers:s=>{s.addCase(n.pending,()=>({...Ag,loading:!0})),s.addCase(n.rejected,(c,{error:l})=>({...Ag,error:!0,errorData:Ci(l)})),s.addCase(n.fulfilled,(c,{payload:l})=>({...Ag,...l,filteredDomains:l.domains})),s.addCase(i.fulfilled,({domains:c,filteredDomains:l,...h},{payload:p})=>({...h,domains:c.map(s8(p.domain,p.status)),filteredDomains:l.map(s8(p.domain,p.status))})),s.addCase(a,(c,{payload:l})=>({...c,filteredDomains:c.domains.filter(({domain:h})=>h.toLowerCase().match(l.toLowerCase()))})),s.addCase(t.fulfilled,(c,{payload:l})=>({...c,domains:c.domains.map(o8(l)),filteredDomains:c.filteredDomains.map(o8(l))})),s.addCase(r.fulfilled,(c,{payload:l})=>{l.domain===null||c.domains.some(h=>h.domain===l.domain)||c.domains.push({domain:l.domain,status:"validating",isDefault:!1,redirects:{baseUrlRedirect:null,regular404Redirect:null,invalidShortUrlRedirect:null}})})}});return{reducer:o,listDomains:n,checkDomainHealth:i,filterDomains:a}},HCe=(e,t)=>{e.serviceFactory("ManageDomains",()=>zCe),e.decorator("ManageDomains",t(["domainsList"],["filterDomains","editDomainRedirects","checkDomainHealth"])),e.serviceFactory("domainsListReducerCreator",qCe,"apiClientFactory","editDomainRedirects","createShortUrl"),e.serviceFactory("domainsListReducer",r=>r.reducer,"domainsListReducerCreator"),e.serviceFactory("listDomains",r=>r.listDomains,"domainsListReducerCreator"),e.serviceFactory("filterDomains",r=>r.filterDomains,"domainsListReducerCreator"),e.serviceFactory("editDomainRedirects",WCe,"apiClientFactory"),e.serviceFactory("checkDomainHealth",r=>r.checkDomainHealth,"domainsListReducerCreator")},l8="shlink/mercure",GCe={loading:!0,error:!1},KCe=e=>{const t=Vr(`${l8}/loadMercureInfo`,n=>{if(n&&n.realTimeUpdates&&!n.realTimeUpdates.enabled)throw new Error("Real time updates not enabled");return e().mercureInfo()}),{reducer:r}=Tr({name:l8,initialState:GCe,reducers:{},extraReducers:n=>{n.addCase(t.pending,i=>({...i,loading:!0,error:!1})),n.addCase(t.rejected,i=>({...i,loading:!1,error:!0})),n.addCase(t.fulfilled,(i,{payload:a})=>({...a,loading:!1,error:!1}))}});return{loadMercureInfo:t,reducer:r}},YCe=e=>{e.serviceFactory("mercureInfoReducerCreator",KCe,"apiClientFactory"),e.serviceFactory("mercureInfoReducer",t=>t.reducer,"mercureInfoReducerCreator"),e.serviceFactory("loadMercureInfo",t=>t.loadMercureInfo,"mercureInfoReducerCreator")};function ur(e){return M.useMemo(()=>e,[e])}function cr(e,t){return(r,n=globalThis.console)=>(t.forEach(i=>{const a=r[i];e[i]=a}),e)}const ZCe=(e,t,r,n)=>{const{mercureHubUrl:i,token:a,loading:o,error:s}=e;if(o||s||!i)return;const c=({data:p})=>r(JSON.parse(p)),l=({status:p})=>p===401&&n(),h=t.map(p=>{const g=new URL(i);g.searchParams.append("topic",p);const _=new Voe.EventSourcePolyfill(g,{headers:{Authorization:`Bearer ${a}`}});return _.onmessage=c,_.onerror=l,_});return()=>h.forEach(p=>p.close())};function ka(e,t){const r=new Set;return n=>{const{createNewVisits:i,loadMercureInfo:a,mercureInfo:o}=n,s=cd();return M.useEffect(()=>{const{interval:c}=o,l=_=>c?r.add(_):i([_]),h=t(s),p=ZCe(o,h,l,a);if(!c)return p;const g=setInterval(()=>{i([...r]),r.clear()},c*1e3*60);return()=>{clearInterval(g),p==null||p()}},[i,a,o,s]),v.jsx(e,{...n})}}class Rn{}ll(Rn,"visits","https://shlink.io/new-visit"),ll(Rn,"orphanVisits","https://shlink.io/new-orphan-visit"),ll(Rn,"shortUrlVisits",e=>`https://shlink.io/new-visit/${e}`);const Ed=An("shlink/visitCreation/createNewVisits",e=>({payload:{createdVisits:e}})),dp=(e,t,r)=>r==null?e.shortCode===t&&!e.domain:e.shortCode===t&&e.domain===r,XCe=(e,t)=>!e.domain&&t===ad?!0:e.domain===t,QCe=(e,t)=>{const r=(t==null?void 0:t.validateUrls)??!1;return e?{longUrl:e.longUrl,tags:e.tags,title:e.title??void 0,domain:e.domain??void 0,validSince:e.meta.validSince??void 0,validUntil:e.meta.validUntil??void 0,maxVisits:e.meta.maxVisits??void 0,crawlable:e.crawlable,forwardQuery:e.forwardQuery,deviceLongUrls:e.deviceLongUrls&&{android:e.deviceLongUrls.android??void 0,ios:e.deviceLongUrls.ios??void 0,desktop:e.deviceLongUrls.desktop??void 0},validateUrl:r}:{longUrl:"",validateUrl:r}},Jz=e=>e.replaceAll("/","__"),TA=e=>e.replaceAll("__","/"),jA=({domain:e,shortCode:t})=>`${e??ad}__${Jz(t)}`,eV=e=>{const[t,r]=e.split(/__(.+)/);if(!r)throw new Error(`It was not possible to parse domain and short code from "${e}"`);return{domain:t===ad?null:t,shortCode:TA(r)}},AA="shlink/shortUrlDeletion",u8={shortCode:"",loading:!1,deleted:!1,error:!1},JCe=e=>Vr(`${AA}/deleteShortUrl`,async({shortCode:t,domain:r})=>(await e().deleteShortUrl({shortCode:t,domain:r}),{shortCode:t,domain:r})),tV=An(`${AA}/shortUrlDeleted`),ePe=e=>{const{actions:t,reducer:r}=Tr({name:AA,initialState:u8,reducers:{resetDeleteShortUrl:()=>u8},extraReducers:i=>{i.addCase(e.pending,a=>({...a,loading:!0,error:!1,deleted:!1})),i.addCase(e.rejected,(a,{error:o})=>({...a,errorData:Ci(o),loading:!1,error:!0,deleted:!1})),i.addCase(e.fulfilled,(a,{payload:o})=>({...a,shortCode:o.shortCode,loading:!1,error:!1,deleted:!0}))}}),{resetDeleteShortUrl:n}=t;return{reducer:r,resetDeleteShortUrl:n}},rV="shlink/shortUrlsList",nV=5,tPe={loading:!0,error:!1},rPe=e=>Vr(`${rV}/listShortUrls`,t=>e().listShortUrls(t??{})),nPe=(e,t,r)=>Tr({name:rV,initialState:tPe,reducers:{},extraReducers:n=>{n.addCase(e.pending,i=>({...i,loading:!0,error:!1})),n.addCase(e.rejected,()=>({loading:!1,error:!0})),n.addCase(e.fulfilled,(i,{payload:a})=>({loading:!1,error:!1,shortUrls:a})),n.addCase(r.fulfilled,(i,{payload:a})=>{i.shortUrls&&(i.shortUrls.data=[a,...i.shortUrls.data.slice(0,nV-1)],i.shortUrls.pagination.totalItems+=1)}),n.addCase(t.fulfilled,(i,{payload:a})=>{i.shortUrls&&(i.shortUrls.data=i.shortUrls.data.map(o=>{const{shortCode:s,domain:c}=a;return dp(o,s,c)?a:o}))}),n.addCase(tV,(i,{payload:a})=>{i.shortUrls&&(i.shortUrls.data=i.shortUrls.data.filter(o=>!dp(o,a.shortCode,a.domain)),i.shortUrls.pagination.totalItems-=1)}),n.addCase(Ed,(i,{payload:a})=>{i.shortUrls&&(i.shortUrls.data=i.shortUrls.data.map(o=>{var s;return((s=a.createdVisits.findLast(({shortUrl:c})=>c&&dp(o,c.shortCode,c.domain)))==null?void 0:s.shortUrl)??o}))})}}),iPe=new Intl.NumberFormat("en-US"),Or=e=>iPe.format(Number(e)),c8=10,aPe=e=>Math.ceil(e/c8)*c8,ZE=({children:e,title:t,link:r,tooltip:n})=>{const i=_i();return v.jsxs(v.Fragment,{children:[v.jsxs(Qi,{innerRef:i,className:"highlight-card",body:!0,tag:Xt,to:r,children:[v.jsx(He,{size:"3x",className:"highlight-card__link-icon",icon:nse}),v.jsx(r7,{className:"lh-sm fw-semibold text-uppercase fs-5 highlight-card__title",children:t}),v.jsx(t7,{className:"fs-2 fw-semibold lh-sm",children:e})]}),n&&v.jsx(Oi,{target:i,placement:"bottom",children:n})]})},f8=({loading:e,excludeBots:t,visitsSummary:r,...n})=>v.jsx(ZE,{tooltip:r.bots!==void 0?v.jsxs(v.Fragment,{children:[t?"Plus":"Including"," ",v.jsx("strong",{children:Or(r.bots)})," potential bot visits"]}):void 0,...n,children:e?"Loading...":Or(t&&r.nonBots!==void 0?r.nonBots:r.total)}),d8=({children:e,titleLinkText:t,titleLink:r,title:n})=>v.jsxs(Qi,{children:[v.jsxs(Sm,{className:"d-flex justify-content-between align-items-center",children:[v.jsx("span",{className:"d-sm-none",children:n}),v.jsx("h5",{className:"d-none d-sm-inline m-0",children:n}),v.jsxs(Xt,{to:r,children:[t," »"]})]}),v.jsx(xm,{children:e})]}),iV=ka(({shortUrlsList:e,listShortUrls:t,tagsList:r,loadVisitsOverview:n,visitsOverview:i})=>{const{ShortUrlsTable:a,CreateShortUrl:o}=ur(iV),{loading:s,shortUrls:c}=e,{loading:l}=r,{loading:h,nonOrphanVisits:p,orphanVisits:g}=i,_=jl(),b=fo(),w=Nn("visits");return M.useEffect(()=>{t({itemsPerPage:nV,orderBy:{field:"dateCreated",dir:"DESC"}}),n()},[t,n]),v.jsxs(v.Fragment,{children:[v.jsxs(Za,{children:[v.jsx("div",{className:"col-lg-6 col-xl-3 mb-3",children:v.jsx(f8,{title:"Visits",link:`${_}/non-orphan-visits`,excludeBots:(w==null?void 0:w.excludeBots)??!1,loading:h,visitsSummary:p})}),v.jsx("div",{className:"col-lg-6 col-xl-3 mb-3",children:v.jsx(f8,{title:"Orphan visits",link:`${_}/orphan-visits`,excludeBots:(w==null?void 0:w.excludeBots)??!1,loading:h,visitsSummary:g})}),v.jsx("div",{className:"col-lg-6 col-xl-3 mb-3",children:v.jsx(ZE,{title:"Short URLs",link:`${_}/list-short-urls/1`,children:s?"Loading...":Or((c==null?void 0:c.pagination.totalItems)??0)})}),v.jsx("div",{className:"col-lg-6 col-xl-3 mb-3",children:v.jsx(ZE,{title:"Tags",link:`${_}/manage-tags`,children:l?"Loading...":Or(r.tags.length)})})]}),v.jsxs("div",{className:"d-flex flex-column gap-3",children:[v.jsx(d8,{title:"Create a short URL",titleLinkText:"Advanced options",titleLink:`${_}/create-short-url`,children:v.jsx(o,{basicMode:!0})}),v.jsx(d8,{title:"Recently created URLs",titleLinkText:"See all",titleLink:`${_}/list-short-urls/1`,children:v.jsx(a,{shortUrlsList:e,className:"mb-0",onTagClick:x=>b(`${_}/list-short-urls/1?tags=${encodeURIComponent(x)}`)})})]})]})},()=>[Rn.visits,Rn.orphanVisits]),oPe=cr(iV,["ShortUrlsTable","CreateShortUrl"]);function sPe(e,t){e.factory("Overview",oPe),e.decorator("Overview",t(["shortUrlsList","tagsList","mercureInfo","visitsOverview"],["listShortUrls","createNewVisits","loadMercureInfo","loadVisitsOverview"]))}const aV="shlink/setShortUrlRedirectRules",h8={saving:!1,saved:!1,error:!1},lPe=e=>Vr(`${aV}/setShortUrlRedirectRules`,({shortUrl:t,data:r})=>{const{shortCode:n,domain:i}=t;return e().setShortUrlRedirectRules({shortCode:n,domain:i},r)}),uPe=e=>{const{reducer:t,actions:r}=Tr({name:aV,initialState:h8,reducers:{resetSetRules:()=>h8},extraReducers:i=>{i.addCase(e.pending,()=>({saving:!0,saved:!1,error:!1})),i.addCase(e.rejected,(a,{error:o})=>({saving:!1,saved:!1,error:!0,errorData:Ci(o)})),i.addCase(e.fulfilled,()=>({saving:!1,error:!1,saved:!0}))}}),{resetSetRules:n}=r;return{reducer:t,resetSetRules:n}},oV="shlink/getShortUrlRedirectRules",cPe={loading:!0,error:!1},fPe=e=>Vr(`${oV}/getShortUrlRedirectRules`,({shortCode:t,domain:r})=>e().getShortUrlRedirectRules({shortCode:t,domain:r})),dPe=e=>Tr({name:oV,initialState:cPe,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({loading:!0,error:!1})),t.addCase(e.rejected,()=>({loading:!1,error:!0})),t.addCase(e.fulfilled,(r,{payload:n})=>({loading:!1,error:!1,...n}))}});function sn(e){e.preventDefault()}function Al(e){e.stopPropagation()}function sV(){const e=new Map;return[function(t,r){e.get(t)&&e.get(t).forEach(n=>{n(r)})},function(t,r){const n=e.get(t)??[];n.push(r),e.set(t,n)}]}var[lV,uV]=sV();function hPe(e,t){return e.source===t.source&&e.flags.split("").sort().join("")===t.flags.split("").sort().join("")}function bf(e,t,r=!0,n=["__key"]){if(e===t)return!0;if(typeof t=="object"&&typeof e=="object"&&e!==null&&t!==null){if(e instanceof Map||e instanceof Set)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return hPe(e,t);if(e===null||t===null)return!1;const i=e,a=t;if(Object.keys(i).length!==Object.keys(a).length)return!1;for(const o of n)if((o in i||o in a)&&i[o]!==a[o])return!1;for(const o in i)if(!(o in a)||i[o]!==a[o]&&!r||r&&!bf(i[o],a[o],r,n))return!1;return!0}return!1}function cV(e){return e.split(" ").filter(t=>t)}function Td(e){return{x:e.clientX,y:e.clientY}}Array();var kA=typeof window<"u",gn=new WeakMap,co=new WeakMap;function p8(){return kA?"ontouchstart"in window||navigator.maxTouchPoints>0:!1}var pPe={activeDescendant:void 0,affectedNodes:[],coordinates:{x:0,y:0},currentTargetValue:void 0,on:uV,emit:lV,newActiveDescendant:void 0,originalZIndex:void 0,pointerSelection:!1,preventEnter:!1,rootUserSelect:void 0,nodePointerdown:void 0,longPress:!1,scrolling:!1,longPressTimeout:void 0,remapJustFinished:!1,selectedNodes:[],selectedParent:void 0,preventSynthDrag:!1,pointerDown:void 0},Ve=pPe,vl=!1,m8,v8,yO,od=!1,fm=!1;function mPe(){Ve={activeDescendant:void 0,affectedNodes:[],coordinates:{x:0,y:0},on:uV,emit:lV,currentTargetValue:void 0,originalZIndex:void 0,pointerId:void 0,preventEnter:!1,remapJustFinished:!1,selectedNodes:[],nodePointerdown:void 0,rootUserSelect:void 0,preventSynthDrag:!1,scrolling:!1,selectedParent:void 0,pointerSelection:!1,synthScrollDirection:void 0,draggedNodeDisplay:void 0,synthDragScrolling:!1,longPress:!1,pointerDown:void 0,longPressTimeout:void 0}}function fV(e){return Object.assign(Ve,e),e.initialParent.data.emit("dragStarted",Ve),vl=!1,Ve.emit("dragStarted",Ve),Ve}function vPe(e){Ve.activeState&&rs(Ve.activeState.parent,void 0,Ve),Ve.selectedState&&ul(Ve.selectedState.nodes,Ve.selectedState.parent,Ve),Ve.selectedState=Ve.activeState=void 0,e.pointerType==="mouse"?fm=!0:(e.pointerType==="touch"||e.pointerType==="pen")&&(fm=!1)}function gPe(e){if(sn(e),Ve.pointerDown&&(Ve.pointerDown.node.el.draggable=!0),Ve.pointerDown=void 0,!io(Ve))return;const t=Ve.currentParent.data.config;io(Ve)&&t.handleEnd(Ve)}function yPe(e){e.key==="Escape"&&(Ve.selectedState&&ul(Ve.selectedState.nodes,Ve.selectedState.parent,Ve),Ve.activeState&&rs(Ve.activeState.parent,void 0,Ve),Ve.selectedState=Ve.activeState=void 0)}function bPe(e){if(!no(Ve))return;vl=!0;const t=Ve.initialParent.data.config.handleEnd;t(Ve)}function _Pe(e){no(Ve)&&sn(e)}function wPe(e){if(!Ve.pointerDown||!Ve.pointerDown.validated)return;const t=Ve.pointerDown.parent.data.config;if(!(fm||e.pointerType==="mouse"))if(!io(Ve)&&(od||!od&&!t.nativeDrag)){if(sn(e),t.longPress&&!Ve.longPress){clearTimeout(Ve.longPressTimeout),Ve.longPress=!1;return}const r=t.draggedNodes(Ve.pointerDown);t.dragstartClasses(Ve.pointerDown.node,r,t,!0);const n=XPe(Ve.pointerDown.node,Ve.pointerDown.parent,e,Ve,r);Ve.rootUserSelect=window.getComputedStyle(document.documentElement).userSelect,document.body.style.userSelect="none",g8(e,n)}else io(Ve)&&g8(e,Ve)}function xPe({parent:e,getValues:t,setValues:r,config:n={}}){var i,a,o;if(!kA)return;if(od=p8(),!m8){m8=dm(document,{dragover:_Pe,pointerdown:vPe,pointerup:gPe,keydown:yPe,drop:bPe,pointermove:wPe,pointercancel:ci(n.handlePointercancel),touchmove:p=>{no(Ve)&&p.cancelable&&sn(p)}});const h=document.createElement("div");mV(h,{"aria-live":"polite","aria-atomic":"true","data-dnd-live-region":"true"}),Object.assign(h.style,{position:"absolute",top:"0px",left:"-9999px",width:"1px",height:"1px",padding:"0",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.appendChild(h)}v8||(v8=dm(window,{resize:()=>{od=p8()}})),pV(e);const[s,c]=sV(),l={getValues:t,setValues:r,config:{dragDropEffect:n.dragDropEffect??"move",dragEffectAllowed:n.dragEffectAllowed??"move",draggedNodes:LPe,dragstartClasses:FPe,handleNodeKeydown:UPe,handleParentKeydown:zPe,handleDragstart:DPe,handleNodeDragover:eEe,handleParentDragover:tEe,handleNodeDrop:WPe,handleNodeFocus:qPe,handleNodeBlur:HPe,handlePointercancel:KPe,handleEnd:YPe,handleDragend:GPe,handleParentFocus:OPe,handleNodePointerup:ZPe,handleNodePointerover:VPe,handleParentPointerover:rEe,handleParentScroll:IPe,handleNodePointerdown:$Pe,handleNodeDragenter:nEe,handleNodeDragleave:iEe,handleParentDrop:PPe,multiDrag:n.multiDrag??!1,nativeDrag:n.nativeDrag??!0,performSort:SPe,performTransfer:CPe,root:n.root??document,setupNode:TPe,setupNodeRemap:vV,reapplyDragClasses:jPe,tearDownNode:kPe,tearDownNodeRemap:APe,remapFinished:NPe,threshold:{horizontal:0,vertical:0},...n},enabledNodes:[],abortControllers:{},privateClasses:[],on:c,emit:s};new MutationObserver(RPe).observe(e,{childList:!0}),gn.set(e,l),(i=n.plugins)==null||i.forEach(h=>{var p,g;(g=(p=h(e))==null?void 0:p.tearDown)==null||g.call(p)}),(a=n.plugins)==null||a.forEach(h=>{var p,g;(g=(p=h(e))==null?void 0:p.tearDown)==null||g.call(p)}),(o=n.plugins)==null||o.forEach(h=>{var p,g;(g=(p=h(e))==null?void 0:p.setup)==null||g.call(p)}),EPe(e,l),e_(e,!0)}function dV(e,t,r,n,i,a){const{x:o,y:s}=Td(r),c=e.el.getBoundingClientRect();return{affectedNodes:[],ascendingDirection:!1,clonedDraggedEls:[],coordinates:{x:o,y:s},draggedNode:{el:e.el,data:e.data},draggedNodes:n,incomingDirection:void 0,initialIndex:e.data.index,initialParent:{el:t.el,data:t.data},currentParent:{el:t.el,data:t.data},longPress:t.data.config.longPress??!1,longPressTimeout:void 0,currentTargetValue:e.data.value,scrollEls:[],startLeft:i||o-c.left,startTop:a||s-c.top,targetIndex:e.data.index,transferred:!1}}function SPe({parent:e,draggedNodes:t,targetNodes:r}){e_(e.el);const n=t.map(c=>c.data.value),i=sd(e.el,e.data),a=t[0].data.index,o=[...e.data.enabledNodes],s=[...i.filter(c=>!n.some(l=>bf(c,l)))];s.splice(r[0].data.index,0,...n),"draggedNode"in Ve&&(Ve.currentTargetValue=r[0].data.value),XE(e.el,e.data,[...s]),e.data.config.onSort&&e.data.config.onSort({parent:{el:e.el,data:e.data},previousValues:[...i],previousNodes:[...o],nodes:[...e.data.enabledNodes],values:[...s],draggedNodes:t,previousPosition:a,position:r[0].data.index,targetNodes:r,state:Ve})}function rs(e,t,r){var n;const i=e.data.config.activeDescendantClass;if(r.activeState&&(xa([r.activeState.node.el],i),r.activeState.parent.el!==e.el&&r.activeState.parent.el.setAttribute("aria-activedescendant","")),!t){(n=r.activeState)==null||n.parent.el.setAttribute("aria-activedescendant",""),r.activeState=void 0;return}r.activeState={node:t,parent:e},Au([t.el],i),r.activeState.parent.el.setAttribute("aria-activedescendant",r.activeState.node.el.id)}function ul(e,t,r){const n=t.data.config.selectedClass;if(!r.selectedState)return;const i=Array.from(e);xa(e.map(a=>a.el),n);for(const a of i){a.el.setAttribute("aria-selected","false");const o=r.selectedState.nodes.findIndex(s=>s.el===a.el);o!==-1&&r.selectedState.nodes.splice(o,1)}hV(t)}function Ou(e,t,r,n,i=!1){n.pointerSelection=i;for(const o of t)o.el.setAttribute("aria-selected","true"),Au([o.el],e.data.config.selectedClass,!0);n.selectedState={nodes:t,parent:e};const a=t.map(o=>o.el.getAttribute("aria-label"));if(a.length===0){n.selectedState=void 0,hV(e);return}rs(e,r,n),Kg(e,`${a.join(", ")} ready for dragging. Use arrow keys to navigate. Press enter to drop ${a.join(", ")}.`)}function Kg(e,t){const r=document.querySelector('[data-dnd-live-region="true"]');r&&(r.id=e.el.id+"-live-region",r.textContent=t)}function hV(e){const t=document.getElementById(e.el.id+"-live-region");t&&(t.textContent="")}function OPe(e,t){const r=e.targetData.parent.data.enabledNodes[0];r&&(t.selectedState&&t.selectedState.parent.el!==e.targetData.parent.el?rs(e.targetData.parent,r,t):t.selectedState||rs(e.targetData.parent,r,t))}function CPe({currentParent:e,targetParent:t,initialParent:r,draggedNodes:n,initialIndex:i,targetNodes:a,state:o}){e_(r.el);const s=n.map(g=>g.data.value),c=[...sd(e.el,e.data).filter(g=>!s.some(_=>bf(g,_)))],l=sd(t.el,t.data),h=r.el===t.el&&t.data.config.sortable===!1;let p;a.length?(h?p=i:t.data.config.sortable===!1?p=t.data.enabledNodes.length:p=a[0].data.index,l.splice(p,0,...s)):(p=h?i:t.data.enabledNodes.length,l.splice(p,0,...s)),XE(e.el,e.data,c),XE(t.el,t.data,l),t.data.config.onTransfer&&t.data.config.onTransfer({sourceParent:e,targetParent:t,initialParent:r,draggedNodes:n,targetIndex:p,state:o,targetNodes:a}),e.data.config.onTransfer&&e.data.config.onTransfer({sourceParent:e,targetParent:t,initialParent:r,draggedNodes:n,targetIndex:p,state:o,targetNodes:a||[]})}function sd(e,t){return[...t.getValues(e)]}function XE(e,t,r){t.setValues(r,e)}function PPe(e,t){Al(e.e),vl=!0;const r=t.initialParent.data.config.handleEnd;r(t)}function pV(e){const t=gn.get(e);t&&t.abortControllers.mainParent&&t.abortControllers.mainParent.abort()}function no(e){return"draggedNode"in e&&!!e.draggedNode}function io(e){return"synthDragging"in e&&!!e.synthDragging}function EPe(e,t){t.abortControllers.mainParent=dm(e,{keydown:Ih(t.config.handleParentKeydown),dragover:Ih(t.config.handleParentDragover),handleParentPointerover:t.config.handleParentPointerover,scroll:Ih(t.config.handleParentScroll),drop:Ih(t.config.handleParentDrop),hasNestedParent:r=>{const n=gn.get(r.target);n&&(n.nestedParent=r.detail.parent)},focus:Ih(t.config.handleParentFocus)}),t.config.externalDragHandle&&t.config.externalDragHandle.el&&t.config.externalDragHandle.callback&&(t.abortControllers.externalDragHandle=dm(t.config.externalDragHandle.el,{pointerdown:r=>{if(!t.config.externalDragHandle||!t.config.externalDragHandle.callback)return;const n=t.config.externalDragHandle.callback();if(!r_(n)){console.warn("No draggable item found from external drag handle callback");return}const i=co.get(n);if(!i)return;const a=n.parentNode;if(!(a instanceof HTMLElement))return;const o=gn.get(a);o&&(Ve.pointerDown={parent:{el:a,data:o},node:{el:n,data:i},validated:!0},n.draggable=!0)}})),e.id&&mV(e,{role:"listbox",tabindex:"0","aria-multiselectable":t.config.multiDrag?"true":"false","aria-activedescendant":"","aria-describedby":e.id+"-live-region"})}function mV(e,t){for(const r in t)e.setAttribute(r,t[r])}function TPe(e){var t;const r=e.parent.data.config;e.node.data.abortControllers.mainNode=dm(e.node.el,{keydown:ci(r.handleNodeKeydown),dragstart:ci(r.handleDragstart),dragover:ci(r.handleNodeDragover),dragenter:ci(r.handleNodeDragenter),dragleave:ci(r.handleNodeDragleave),dragend:ci(r.handleDragend),drop:ci(r.handleNodeDrop),focus:ci(r.handleNodeFocus),blur:ci(r.handleNodeBlur),pointerup:ci(r.handleNodePointerup),pointercancel:ci(r.handlePointercancel),pointerdown:ci(r.handleNodePointerdown),handleNodePointerover:r.handleNodePointerover,touchmove:n=>{no(Ve)&&n.cancelable&&sn(n)},contextmenu:n=>{od&&sn(n)}}),e.node.el.setAttribute("role","option"),e.node.el.setAttribute("aria-selected","false"),e.node.el.draggable=!0,r.reapplyDragClasses(e.node.el,e.parent.data),(t=e.parent.data.config.plugins)==null||t.forEach(n=>{var i,a;(a=(i=n(e.parent.el))==null?void 0:i.setupNode)==null||a.call(i,e)})}function vV(e){var t;co.set(e.node.el,e.node.data),(t=e.parent.data.config.plugins)==null||t.forEach(r=>{var n,i;(i=(n=r(e.parent.el))==null?void 0:n.setupNodeRemap)==null||i.call(n,e)})}function jPe(e,t){if(!no(Ve))return;const r=io(Ve)?t.config.synthDropZoneClass:t.config.dropZoneClass;Ve.draggedNode.el===e&&Au([e],r,!0)}function APe(e){var t;(t=e.parent.data.config.plugins)==null||t.forEach(r=>{var n,i;(i=(n=r(e.parent.el))==null?void 0:n.tearDownNodeRemap)==null||i.call(n,e)})}function kPe(e){var t,r,n,i,a;(t=e.parent.data.config.plugins)==null||t.forEach(o=>{var s,c;(c=(s=o(e.parent.el))==null?void 0:s.tearDownNode)==null||c.call(s,e)}),e.node.el.draggable=!1,(n=(r=e.node.data)==null?void 0:r.abortControllers)!=null&&n.mainNode&&((a=(i=e.node.data)==null?void 0:i.abortControllers)==null||a.mainNode.abort())}function RPe(e){if(e.length===1&&e[0].addedNodes.length===1&&!(e[0].addedNodes[0]instanceof HTMLElement))return;const t=e[0].target;if(!(t instanceof HTMLElement))return;const r=document.querySelectorAll('[aria-selected="true"]'),n=gn.get(t);if(n){for(let i=0;i_.data.value===p.value);g&&(g.el=l)}s.push({el:l,data:p}),(t||!h)&&a.setupNode({parent:{el:e,data:n},node:{el:l,data:p}}),vV({parent:{el:e,data:n},node:{el:l,data:p}})}gn.set(e,{...n,enabledNodes:s}),a.remapFinished(n),(r=n.config.plugins)==null||r.forEach(c=>{var l,h;(h=(l=c(e))==null?void 0:l.remapFinished)==null||h.call(l)})}function NPe(){Ve.remapJustFinished=!0,"draggedNode"in Ve&&(Ve.affectedNodes=[])}function MPe(e){return!!e.targetData.parent.data.config.nativeDrag}function LPe(e){var t;if(e.parent.data.config.multiDrag){if(Ve.selectedState)return[e.node,...(t=Ve.selectedState)==null?void 0:t.nodes.filter(r=>r.el!==e.node.el)]}else return[e.node];return[]}function IPe(e){no(Ve)&&(Ve.emit("scrollStarted",Ve),!io(Ve)&&(Ve.preventEnter=!0,yO&&clearTimeout(yO),yO=setTimeout(()=>{Ve.preventEnter=!1,Ve.emit("scrollEnded",Ve)},100)))}function DPe(e,t){const r=e.targetData.parent.data.config;if(!r.nativeDrag||!MPe(e)||!gV({x:e.e.clientX,y:e.e.clientY,node:e.targetData.node,config:r})){sn(e.e);return}const n=r.draggedNodes({parent:e.targetData.parent,node:e.targetData.node});r.dragstartClasses(e.targetData.node,n,r);const i=BPe(e,n);r.onDragstart&&r.onDragstart({parent:e.targetData.parent,values:sd(e.targetData.parent.el,e.targetData.parent.data),draggedNode:i.draggedNode,draggedNodes:i.draggedNodes,position:i.initialIndex,state:i})}function $Pe(e,t){var r,n;if(Al(e.e),t.pointerDown={parent:e.targetData.parent,node:e.targetData.node,validated:!1},e.e.pointerType==="mouse"?fm=!0:(e.e.pointerType==="touch"||e.e.pointerType==="pen")&&(fm=!1),!gV({x:e.e.clientX,y:e.e.clientY,node:e.targetData.node,config:e.targetData.parent.data.config}))return;t.pointerDown={parent:e.targetData.parent,node:e.targetData.node,validated:!0},QPe(e,t,e.targetData.node);const i=e.targetData.parent.data;let a=[e.targetData.node];const o=e.e.ctrlKey||e.e.metaKey,s=e.e.shiftKey,c=e.targetData.node;if(o&&i.config.multiDrag){t.selectedState?t.selectedState.nodes.findIndex(l=>l.el===c.el)===-1?a=[...t.selectedState.nodes,c]:a=t.selectedState.nodes.filter(l=>l.el!==c.el):a=[c],Ou(e.targetData.parent,a,e.targetData.node,t,!0);return}if(s&&i.config.multiDrag){const l=e.targetData.parent.data.enabledNodes;if(t.selectedState&&t.activeState)if(t.selectedState.parent.el!==e.targetData.parent.el){ul(t.selectedState.nodes,t.selectedState.parent,t),t.selectedState=void 0;for(let h=0;h<=c.data.index;h++)a.push(l[h])}else{const[h,p]=t.activeState.node.data.indexl.el===e.targetData.node.el)===-1&&(t.selectedState.parent.el!==e.targetData.parent.el?ul(t.selectedState.nodes,e.targetData.parent,t):i.config.multiDrag&&od?a.push(...t.selectedState.nodes):ul(t.selectedState.nodes,e.targetData.parent,t),Ou(e.targetData.parent,a,e.targetData.node,t,!0)):Ou(e.targetData.parent,[e.targetData.node],e.targetData.node,t,!0)}function FPe(e,t,r,n=!1){Au(t.map(i=>i.el),n?r.synthDraggingClass:r.draggingClass),setTimeout(()=>{xa(t.map(i=>i.el),n?r.synthDraggingClass:r.draggingClass),Au(t.map(i=>i.el),n?r.synthDragPlaceholderClass:r.dragPlaceholderClass),Au(t.map(i=>i.el),n?r.synthDropZoneClass:r.dropZoneClass),xa(t.map(i=>i.el),r.activeDescendantClass),xa(t.map(i=>i.el),r.selectedClass)})}function BPe(e,t){Al(e.e);const r=fV(dV(e.targetData.node,e.targetData.parent,e.e,t));if(e.e.dataTransfer){const n=e.targetData.parent.data.config;e.e.dataTransfer.dropEffect=n.dragDropEffect,e.e.dataTransfer.effectAllowed=n.dragEffectAllowed;let i;if(n.dragImage)i=n.dragImage(e,t);else{if(n.multiDrag){const a=document.createElement("div");for(const s of t){const c=s.el.cloneNode(!0);c.style.pointerEvents="none",c.id=s.el.id+"-clone",a.append(c)}const{width:o}=t[0].el.getBoundingClientRect();Object.assign(a.style,{display:"flex",flexDirection:"column",width:`${o}px`,position:"absolute",pointerEvents:"none",zIndex:"9999",left:"-9999px"}),i=a}else{e.e.dataTransfer.setDragImage(e.targetData.node.el,e.e.offsetX,e.e.offsetY);const a=e.targetData.node.el.style.zIndex;return r.originalZIndex=a,e.targetData.node.el.style.zIndex="9999",r}document.body.appendChild(i)}e.e.dataTransfer.setDragImage(i,e.e.offsetX,e.e.offsetY),setTimeout(()=>{i==null||i.remove()})}return r}function gV({x:e,y:t,node:r,config:n}){if(n.externalDragHandle)return!1;if(!n.dragHandle)return!0;const i=r.el.querySelectorAll(n.dragHandle);if(!i)return!1;const a=n.root.elementFromPoint(e,t);if(!a)return!1;for(const o of Array.from(i))if(a===o||o.contains(a))return!0;return!1}function UPe(e){}function zPe(e,t){var r;const n=(r=t.activeState)==null?void 0:r.node;if(!n)return;const i=e.targetData.parent.data,a=i.enabledNodes;if(!(e.e.target instanceof HTMLElement))return;const o=a.findIndex(s=>s.el===n.el);if(o!==-1){if(["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(e.e.key)){e.e.target===e.targetData.parent.el&&sn(e.e);const s=e.e.key==="ArrowDown"||e.e.key==="ArrowRight"?o+1:o-1;if(s<0||s>=a.length)return;const c=a[s];rs(e.targetData.parent,c,t)}else if(e.e.key===" ")e.e.target===e.targetData.parent.el&&sn(e.e),t.selectedState&&t.selectedState.nodes.includes(n)?Ou(e.targetData.parent,t.selectedState.nodes.filter(s=>s.el!==n.el),n,t):Ou(e.targetData.parent,[n],n,t);else if(e.e.key==="Enter"&&t.selectedState)if(t.selectedState.parent.el===e.targetData.parent.el&&t.activeState){if(t.selectedState.nodes[0].el===t.activeState.node.el){Kg(e.targetData.parent,"Cannot drop item on itself");return}t.newActiveDescendant=t.selectedState.nodes[0],i.config.performSort({parent:e.targetData.parent,draggedNodes:t.selectedState.nodes,targetNodes:[t.activeState.node]}),ul([],e.targetData.parent,t),Kg(e.targetData.parent,"Drop successful")}else t.activeState&&t.selectedState.parent.el!==e.targetData.parent.el&&bV({currentParent:e.targetData.parent,targetParent:t.selectedState.parent,initialParent:t.selectedState.parent,draggedNodes:t.selectedState.nodes,state:t})&&(i.config.performTransfer({currentParent:t.selectedState.parent,targetParent:e.targetData.parent,initialParent:t.selectedState.parent,draggedNodes:t.selectedState.nodes,initialIndex:t.selectedState.nodes[0].data.index,state:t,targetNodes:[t.activeState.node]}),t.newActiveDescendant=t.selectedState.nodes[0],Ou(e.targetData.parent,[],void 0,t),Kg(e.targetData.parent,"Drop successful"))}}function VPe(e){e.detail.targetData.parent.el===e.detail.state.currentParent.el?_V(e.detail,e.detail.state):t_(e.detail,e.detail.state)}function WPe(e,t){const r=e.targetData.parent.data.config;r.nativeDrag&&(Al(e.e),vl=!0,r.handleEnd(t))}function qPe(e){e.e.target!==e.e.currentTarget&&Ve.pointerDown&&(Ve.pointerDown.node.el.draggable=!1)}function HPe(e){e.e.target!==e.e.currentTarget&&Ve.pointerDown&&(Ve.pointerDown.node.el.draggable=!0)}function GPe(e,t){const r=e.targetData.parent.data.config;if(r.nativeDrag){if(sn(e.e),Al(e.e),vl){vl=!1;return}r.handleEnd(t)}}function KPe(e,t){var r;if(!io(t))return;if(sn(e.e),vl){vl=!1;return}const n=(r=gn.get(t.initialParent.el))==null?void 0:r.config;n!=null&&n.onDragend&&n.onDragend({parent:t.currentParent,values:sd(t.currentParent.el,t.currentParent.data),draggedNode:t.draggedNode,draggedNodes:t.draggedNodes,state:t}),n==null||n.handleEnd(t)}function YPe(e){var t,r,n,i,a,o;e.draggedNode&&(e.draggedNode.el.draggable=!0),document.body.style.userSelect=e.rootUserSelect||"",io(e)&&(document.documentElement.style.overscrollBehavior=e.rootOverScrollBehavior||"",document.documentElement.style.touchAction=e.rootTouchAction||""),io(e)&&yV(e),"longPressTimeout"in e&&e.longPressTimeout&&clearTimeout(e.longPressTimeout);const s=(t=gn.get(e.initialParent.el))==null?void 0:t.config,c=io(e),l=c?s==null?void 0:s.synthDropZoneClass:s==null?void 0:s.dropZoneClass;e.originalZIndex!==void 0&&(e.draggedNode.el.style.zIndex=e.originalZIndex),xa(e.draggedNodes.map(h=>h.el),l),xa(e.draggedNodes.map(h=>h.el),(n=(r=e.initialParent.data)==null?void 0:r.config)==null?void 0:n.longPressClass),xa(e.draggedNodes.map(h=>h.el),c?e.initialParent.data.config.synthDragPlaceholderClass:(a=(i=e.initialParent.data)==null?void 0:i.config)==null?void 0:a.dragPlaceholderClass),c&&e.clonedDraggedNode.remove(),ul(e.draggedNodes,e.currentParent,e),rs(e.currentParent,void 0,e),mPe(),e.selectedState=void 0,(o=s==null?void 0:s.onDragend)==null||o.call(s,{parent:e.currentParent,values:sd(e.currentParent.el,e.currentParent.data),draggedNode:e.draggedNode,draggedNodes:e.draggedNodes,state:e}),e.emit("dragEnded",e)}function ZPe(e,t){Al(e.e),!t.pointerSelection&&t.selectedState&&ul(t.selectedState.nodes,e.targetData.parent,t);const r=e.targetData.parent.data.config;t.pointerSelection=!1,"longPressTimeout"in t&&t.longPressTimeout&&clearTimeout(t.longPressTimeout),xa(e.targetData.parent.data.enabledNodes.map(n=>n.el),r.longPressClass),no(t)&&r.handleEnd(t)}function XPe(e,t,r,n,i){var a,o;const s=t.data.config;let c,l=e.el.style.display,h;if(s.synthDragImage)h=s.synthDragImage(e,t,r,i),c=h.dragImage,c.setAttribute("popover","manual"),c.id="dnd-dragged-node-clone",l=c.style.display,Object.assign(c.style,{position:"absolute",zIndex:9999,pointerEvents:"none",margin:0,willChange:"transform",overflow:"hidden",display:"none"});else if(!s.multiDrag||i.length===1)c=e.el.cloneNode(!0),c.id="dnd-dragged-node-clone",l=c.style.display,c.setAttribute("popover","manual"),Object.assign(c.style,{position:"absolute",height:e.el.getBoundingClientRect().height+"px",width:e.el.getBoundingClientRect().width+"px",overflow:"hidden",margin:0,willChange:"transform",pointerEvents:"none",zIndex:9999});else{const _=document.createElement("div");_.setAttribute("popover","manual");for(const b of i){const w=b.el.cloneNode(!0);w.style.pointerEvents="none",w.style.margin="0",_.append(w)}l=_.style.display,_.id="dnd-dragged-node-clone",c=_,Object.assign(c.style,{display:"flex",flexDirection:"column",position:"absolute",overflow:"hidden",margin:0,padding:0,pointerEvents:"none",zIndex:9999})}c.style.position="absolute",t.el.appendChild(c),c.showPopover();const p={clonedDraggedEls:[],clonedDraggedNode:c,draggedNodeDisplay:l,synthDragScrolling:!1,synthDragging:!0,rootScrollWidth:(a=document.scrollingElement)==null?void 0:a.scrollWidth,rootScrollHeight:(o=document.scrollingElement)==null?void 0:o.scrollHeight,rootOverScrollBehavior:document.documentElement.style.overscrollBehavior,rootTouchAction:document.documentElement.style.touchAction};document.documentElement.style.overscrollBehavior="none",document.documentElement.style.touchAction="none";const g=fV({...dV(e,t,r,i,h==null?void 0:h.offsetX,h==null?void 0:h.offsetY),...p});return g.clonedDraggedNode.style.display=g.draggedNodeDisplay||"",g}function QPe(e,t,r){const n=e.targetData.parent.data.config;n.longPress&&(t.longPressTimeout=setTimeout(()=>{t&&(t.longPress=!0,n.longPressClass&&e.e.cancelable&&Au([r.el],n.longPressClass),sn(e.e))},n.longPressDuration||200))}function JPe(e,t){t.longPressClass&&xa(e.draggedNodes.map(r=>r.el),t==null?void 0:t.longPressClass)}function yV(e,t=!0,r=!0){t&&e.animationFrameIdX!==void 0&&(cancelAnimationFrame(e.animationFrameIdX),e.animationFrameIdX=void 0),r&&e.animationFrameIdY!==void 0&&(cancelAnimationFrame(e.animationFrameIdY),e.animationFrameIdY=void 0),!e.animationFrameIdX&&!e.animationFrameIdY&&(e.preventEnter=!1)}function RA(e,t,r=0,n=0){const{x:i,y:a}=Td(e);t.coordinates.y=a,t.coordinates.x=i;const o=t.startLeft??0,s=t.startTop??0,c=i-o+window.scrollX,l=a-s+window.scrollY;t.clonedDraggedNode.style.transform=`translate(${c+r}px, ${l+n}px)`,e.cancelable&&sn(e),JPe(t,t.initialParent.data.config)}function g8(e,t){RA(e,t);const r=Td(e);fEe(r,e,t);const n=dEe(r);if(!n){document.dispatchEvent(new CustomEvent("handleRootPointerover",{detail:{e,state:t}}));return}const i={e,targetData:n,state:t};"node"in n?n.node.el.dispatchEvent(new CustomEvent("handleNodePointerover",{detail:i})):n.parent.el.dispatchEvent(new CustomEvent("handleParentPointerover",{detail:i}))}function eEe(e,t){var r;if(!e.targetData.parent.data.config.nativeDrag)return;const{x:n,y:i}=Td(e.e);t.coordinates.y=i,t.coordinates.x=n,sn(e.e),Al(e.e),e.targetData.parent.el===((r=t.currentParent)==null?void 0:r.el)?_V(e,t):t_(e,t)}function tEe(e,t){e.targetData.parent.data.config.nativeDrag&&(sn(e.e),Al(e.e),Object.assign(Td(e.e)),t_(e,t))}function rEe(e){e.detail.targetData.parent.el!==e.detail.state.currentParent.el&&t_(e.detail,e.detail.state)}function bV({currentParent:e,targetParent:t,initialParent:r,draggedNodes:n,state:i}){if(t.el===e.el)return!1;const a=t.data.config;if(n[0].el.contains(t.el)||a.dropZone===!1)return!1;const o=r.data.config;return a.accepts?a.accepts(t,r,e,i):!(!a.group||a.group!==o.group)}function nEe(e,t){sn(e.e)}function iEe(e,t){sn(e.e)}function aEe(e,t,r,n){var i;if(t.affectedNodes.map(p=>p.data.value).includes(e.targetData.node.data.value))return!1;if(t.remapJustFinished)return t.remapJustFinished=!1,(e.targetData.node.data.value===t.currentTargetValue||t.draggedNodes.map(p=>p.el).includes(e.targetData.node.el))&&(t.currentTargetValue=e.targetData.node.data.value),!1;if(t.preventEnter)return!1;if(t.draggedNodes.map(p=>p.el).includes(e.targetData.node.el))return t.currentTargetValue=void 0,!1;if(e.targetData.node.data.value===t.currentTargetValue||e.targetData.parent.el!==((i=t.currentParent)==null?void 0:i.el)||e.targetData.parent.data.config.sortable===!1||e.targetData.node.el.contains(t.draggedNodes[0].el))return!1;const a=e.targetData.node.el.getBoundingClientRect(),o=t.draggedNode.el.getBoundingClientRect(),s=a.y-o.y,c=a.x-o.x;let l;Math.abs(s)>Math.abs(c)?l=s>0?"above":"below":l=c>0?"left":"right";const h=t.currentParent.data.config.threshold;switch(l){case"left":if(r>a.x+a.width*h.horizontal)return t.incomingDirection="left",!0;break;case"right":if(ra.y+a.height*h.vertical)return t.incomingDirection="above",!0;break;case"below":if(ne.targetData.node.data.index?[e.targetData.node.data.index,t.draggedNode.data.index]:[t.draggedNode.data.index,e.targetData.node.data.index];t.targetIndex=e.targetData.node.data.index,t.affectedNodes=e.targetData.parent.data.enabledNodes.filter(a=>i[0]<=a.data.index&&a.data.index<=i[1]&&a.el!==t.draggedNode.el),e.targetData.parent.data.config.performSort({parent:e.targetData.parent,draggedNodes:t.draggedNodes,targetNodes:[e.targetData.node]})}function ci(e){function t(r){const n=co.get(r);if(!n)return;const i=gn.get(r.parentNode);if(i)return{node:{el:r,data:n},parent:{el:r.parentNode,data:i}}}return r=>{const n=t(r.currentTarget);if(n)return e({e:r,targetData:n},Ve)}}function t_(e,t){e.e.preventDefault(),bV({currentParent:t.currentParent,targetParent:e.targetData.parent,initialParent:t.initialParent,draggedNodes:t.draggedNodes,state:t})&&(e.targetData.parent.data.config.performTransfer({currentParent:t.currentParent,targetParent:e.targetData.parent,initialParent:t.initialParent,draggedNodes:t.draggedNodes,initialIndex:t.initialIndex,state:t,targetNodes:"node"in e.targetData?[e.targetData.node]:[]}),t.currentParent=e.targetData.parent,t.transferred=!0)}function Ih(e){function t(r){const n=gn.get(r);if(n)return{parent:{el:r,data:n}}}return r=>{const n=t(r.currentTarget);if(n)return e({e:r,targetData:n},Ve)}}function Au(e,t,r=!1){function n(i,a){co.set(i,a)}for(const i of e){const a=co.get(i),o=oEe(i,t,a,r);o&&n(i,o)}}function oEe(e,t,r,n=!1){if(!t)return;const i=cV(t);if(!i.length||i.includes("longPress"))return;if(!r){e.classList.add(...i);return}const a=[];for(const o of i)e.classList.contains(o)?e.classList.contains(o)&&n===!1&&a.push(o):e.classList.add(o);return r.privateClasses=a,r}function xa(e,t){if(!t)return;const r=cV(t);if(r.length)for(const n of e){if(!r_(n)){n.classList.remove(...r);continue}const i=co.get(n)||gn.get(n);if(i)for(const a of r)i.privateClasses.includes(a)||n.classList.remove(a)}}function sEe(e,t,r,n,i){if(e===document.scrollingElement){const a=e.scrollLeft>0;return{right:e.scrollLeft+window.innerWidth<(i.rootScrollWidth||0)&&t.clientX>e.clientWidth*(1-.1),left:a&&t.clientXn.left+o*(1-.1)&&s0}}return{right:!1,left:!1}}function lEe(e,t,r,n){if(e===document.scrollingElement)return{down:t.clientY>e.clientHeight*(1-.1),up:t.clientYn.top+a*(1-.1)&&o0}}return{down:!1,up:!1}}function uEe(e,t,r,n=!0){r.preventEnter=!0;const i=n?5:-5;function a(o){o.scrollBy({left:i}),RA(t,r,i,0),r.animationFrameIdX=requestAnimationFrame(a.bind(null,o))}r.animationFrameIdX=requestAnimationFrame(a.bind(null,e))}function cEe(e,t,r,n=!0){r.preventEnter=!0;const i=n?-5:5;function a(){e.scrollBy({top:i}),RA(t,r,0,i),r.animationFrameIdY=requestAnimationFrame(a)}r.animationFrameIdY=requestAnimationFrame(a)}function fEe(e,t,r){yV(r);const n={x:null,y:null},i=document.elementsFromPoint(e.x,e.y);for(const a of i){if(n.x&&n.y)break;if(!(a instanceof HTMLElement))continue;const o=a.getBoundingClientRect(),s=window.getComputedStyle(a);if(!n.x){const{left:c,right:l}=sEe(a,t,s,o,r);(c||l)&&(n.x=a,uEe(a,t,r,l))}if(!n.y){const{up:c,down:l}=lEe(a,t,s,o);(c||l)&&(n.y=a,cEe(a,t,r,c))}}}function dEe(e){let t=document.elementFromPoint(e.x,e.y);if(!r_(t))return;let r,n=!0;for(;t&&n;){if(co.has(t)||gn.has(t)){n=!1,r=gn.has(t);break}t=t.parentNode}if(r){const i=gn.get(t);return i?{parent:{el:t,data:i}}:void 0}else{const i=co.get(t);if(!i)return;const a=gn.get(t.parentNode);return a?{node:{el:t,data:i},parent:{el:t.parentNode,data:a}}:void 0}}function r_(e){return e instanceof HTMLElement&&e.parentNode instanceof HTMLElement}function dm(e,t){const r=new AbortController;for(const n in t){const i=t[n];e.addEventListener(n,i,{signal:r.signal,passive:!1,capture:n==="focus"||n==="blur"})}return r}function hEe(e){if(e instanceof HTMLElement)return e;if("current"in e&&e.current instanceof HTMLElement)return e.current;console.warn("Invalid parent element",e)}function pEe(e,t){const r=hEe(e);r&&t(r)}var I0=new WeakMap;function mEe(e){const t=I0.get(e);return t?t[0]:(console.warn("No values found for parent element"),[])}function vEe(e,t){const r=I0.get(t);r&&r[1](e),I0.set(t,[e,r[1]])}function gEe(e,t){return r=>{I0.set(r,t),xPe({parent:r,getValues:mEe,setValues:vEe,config:e})}}function y8(e){kA&&(Array.isArray(e)||(e=[e]),e.forEach(t=>{const{parent:r,state:n,...i}=t;pEe(r,gEe(i,n))}))}function yEe(e,t={}){const r=M.useRef(null),[n,i]=M.useState(e);function a(o={}){y8({parent:r,state:[n,i],...o})}return M.useEffect(()=>{y8({parent:r,state:[n,i],...t})},[n]),M.useEffect(()=>()=>{r.current&&pV(r.current)},[]),[r,n,i,a]}const n_=()=>{const e=fo(),t=jl(),r=hd(),n=M.useMemo(()=>{const{orderBy:a,tags:o,excludeBots:s,excludeMaxVisitsReached:c,excludePastValidUntil:l,...h}=r,p=a?Jie(a):void 0,g=(o==null?void 0:o.split(","))??[];return{...h,orderBy:p,tags:g,excludeBots:s!==void 0?s==="true":void 0,excludeMaxVisitsReached:c!==void 0?c==="true":void 0,excludePastValidUntil:l!==void 0?l==="true":void 0}},[r]),i=M.useCallback(a=>{const o={...n,...a},{orderBy:s,tags:c,excludeBots:l,excludeMaxVisitsReached:h,excludePastValidUntil:p,...g}=o,_={...g,orderBy:s&&Qie(s),tags:c.length>0?c.join(","):void 0,excludeBots:mO(l),excludeMaxVisitsReached:mO(h),excludePastValidUntil:mO(p)},b=sb(_),w=b?`?${b}`:"";e(`${t}/list-short-urls/1${w}`)},[n,e,t]);return[n,i]},NA=()=>{const{domain:e}=hd(),{shortCode:t=""}=cd();return M.useMemo(()=>({shortCode:TA(t),domain:e}),[e,t])},i_=()=>{const e=DCe();return v.jsx(Lt,{color:"link",size:"lg",className:"p-0 me-3",onClick:e,"aria-label":"Go back",children:v.jsx(He,{icon:CY})})},bEe={AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia",BA:"Bosnia and Herzegovina",BW:"Botswana",BR:"Brazil",IO:"British Indian Ocean Territory",VG:"British Virgin Islands",BN:"Brunei",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos Islands",CO:"Colombia",KM:"Comoros",CK:"Cook Islands",CR:"Costa Rica",HR:"Croatia",CU:"Cuba",CW:"Curacao",CY:"Cyprus",CZ:"Czech Republic",CD:"Democratic Republic of the Congo",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",TL:"East Timor",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",PF:"French Polynesia",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",CI:"Ivory Coast",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",XK:"Kosovo",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Laos",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia",MD:"Moldova",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",AN:"Netherlands Antilles",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",KP:"North Korea",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestine",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",CG:"Republic of the Congo",RE:"Reunion",RO:"Romania",RU:"Russia",RW:"Rwanda",BL:"Saint Barthelemy",SH:"Saint Helena",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",KR:"South Korea",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syria",TW:"Taiwan",TJ:"Tajikistan",TZ:"Tanzania",TH:"Thailand",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",VI:"U.S. Virgin Islands",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VA:"Vatican",VE:"Venezuela",VN:"Vietnam",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},_Ee={android:"Android",ios:"iOS",desktop:"Desktop"},wEe=({deviceType:e,onDeviceTypeChange:t})=>{const r=M.useId();return v.jsxs("div",{children:[v.jsx("label",{htmlFor:r,children:"Device type:"}),v.jsxs("select",{id:r,className:"form-select",value:e,onChange:n=>t(n.target.value),required:!0,children:[!e&&v.jsx("option",{value:"",children:"- Select type -"}),Object.entries(_Ee).map(([n,i])=>v.jsx("option",{value:n,children:i},n))]})]})},MA=({value:e,onValueChange:t,label:r,placeholder:n})=>{const i=M.useId();return v.jsxs("div",{children:[v.jsxs("label",{htmlFor:i,children:[r,":"]}),v.jsx(Zr,{id:i,value:e??"",onChange:a=>t(a.target.value),placeholder:n,required:!0})]})},xEe=({language:e,onLanguageChange:t})=>v.jsx(MA,{value:e,onValueChange:t,label:"Language",placeholder:"en-US / en"}),SEe=({name:e,value:t,onNameChange:r,onValueChange:n})=>{const i=M.useId(),a=M.useId();return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{htmlFor:i,children:"Param name:"}),v.jsx(Zr,{id:i,value:e??"",onChange:o=>r(o.target.value),placeholder:"hello",required:!0})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:a,children:"Param value:"}),v.jsx(Zr,{id:a,value:t??"",onChange:o=>n(o.target.value),placeholder:"world",required:!0})]})]})},OEe=({ipAddress:e,onIpAddressChange:t})=>v.jsx(MA,{value:e,onValueChange:t,label:"IP address",placeholder:"192.168.1.10"}),CEe=({countryCode:e,onCountryCodeChange:t})=>{const r=M.useId();return v.jsxs("div",{children:[v.jsx("label",{htmlFor:r,children:"Country:"}),v.jsxs("select",{id:r,className:"form-select",value:e,onChange:n=>t(n.target.value),required:!0,children:[!e&&v.jsx("option",{value:"",children:"- Select country -"}),Object.entries(bEe).map(([n,i])=>v.jsx("option",{value:n,children:i},n))]})]})},PEe=({cityName:e,onCityNameChange:t})=>v.jsx(MA,{value:e,onValueChange:t,label:"City name",placeholder:"New York"}),EEe=({condition:e,onConditionChange:t,onDelete:r})=>{const n=M.useId(),i=M.useCallback(h=>t({type:h,matchValue:"",matchKey:null}),[t]),a=M.useCallback(h=>t({...e,matchValue:h}),[e,t]),o=M.useCallback(h=>t({...e,matchKey:h}),[e,t]),s=Ca("ipRedirectCondition"),c=Ca("geolocationRedirectCondition"),l=M.useMemo(()=>{const h={device:"Device type",language:"Language","query-param":"Query param"};return s&&(h["ip-address"]="IP address"),c&&(h["geolocation-country-code"]="Country (geolocation)",h["geolocation-city-name"]="City name (geolocation)"),h},[c,s]);return v.jsxs("div",{className:"redirect-rule-modal__condition rounded p-3 h-100 d-flex flex-column gap-2 position-relative",children:[v.jsxs("div",{children:[v.jsx(Lt,{outline:!0,size:"sm",type:"button","aria-label":"Remove condition",onClick:r,className:"position-absolute rounded-circle redirect-rule-modal__remove-condition-button",children:v.jsx(He,{icon:ST,className:"redirect-rule-modal__remove-condition-button-icon"})}),v.jsx("label",{htmlFor:n,children:"Type:"}),v.jsx("select",{id:n,className:"form-select flex-grow-1",value:e.type,onChange:h=>i(h.target.value),children:Object.entries(l).map(([h,p])=>v.jsx("option",{value:h,children:p},h))})]}),e.type==="device"&&v.jsx(wEe,{deviceType:e.matchValue,onDeviceTypeChange:a}),e.type==="language"&&v.jsx(xEe,{language:e.matchValue,onLanguageChange:a}),e.type==="query-param"&&v.jsx(SEe,{value:e.matchValue,name:e.matchKey??"",onNameChange:o,onValueChange:a}),e.type==="ip-address"&&v.jsx(OEe,{ipAddress:e.matchValue,onIpAddressChange:a}),e.type==="geolocation-country-code"&&v.jsx(CEe,{countryCode:e.matchValue,onCountryCodeChange:a}),e.type==="geolocation-city-name"&&v.jsx(PEe,{cityName:e.matchValue,onCityNameChange:a})]})},wV=({isOpen:e,toggle:t,onSave:r,initialData:n})=>{const[i,a]=M.useState(n??{longUrl:"",conditions:[]}),o=M.useCallback(_=>{_.preventDefault(),_.stopPropagation(),i&&r(i),t()},[r,i,t]),s=M.useCallback(()=>a(({longUrl:_,conditions:b})=>({longUrl:_,conditions:[...b,{type:"device",matchValue:"",matchKey:null}]})),[]),c=M.useCallback((_,b)=>a(({longUrl:w,conditions:x})=>{const S=[...x];return S[_]=b,{longUrl:w,conditions:S}}),[]),l=M.useCallback(_=>a(({longUrl:b,conditions:w})=>{const x=[...w];return x.splice(_,1),{longUrl:b,conditions:x}}),[]),h=_i(),p=M.useCallback(()=>{var _;return(_=h==null?void 0:h.current)==null?void 0:_.focus()},[h]),g=M.useCallback(()=>a(n??{longUrl:"",conditions:[]}),[n]);return v.jsx(Ji,{size:"xl",isOpen:e,toggle:t,centered:!0,onOpened:p,onClosed:g,children:v.jsxs("form",{onSubmit:o,children:[v.jsx(Sl,{toggle:t,className:"sticky-top redirect-rule-modal__header",children:"Redirect rule"}),v.jsxs(as,{children:[v.jsx("label",{htmlFor:"longUrl",className:"fw-bold",children:"Long URL:"}),v.jsx(Zr,{id:"longUrl",type:"url",placeholder:"https://www.example.com",value:i.longUrl,onChange:_=>a(b=>({...b,longUrl:_.target.value})),required:!0,innerRef:h}),v.jsx("hr",{}),v.jsxs("div",{className:"d-flex justify-content-between",children:[v.jsx("b",{children:"Conditions:"}),v.jsx(Lt,{outline:!0,size:"sm",type:"button","aria-label":"Add condition",onClick:s,children:v.jsx(He,{icon:gm})})]}),i.conditions.length===0&&v.jsx("div",{className:"text-center",children:v.jsx("i",{children:"Add conditions..."})}),i.conditions.length>0&&v.jsx(Za,{className:"redirect-rule-modal__conditions-row",children:i.conditions.map((_,b)=>v.jsx("div",{className:"col-lg-6 col-xl-4 mt-4",children:v.jsx(EEe,{condition:_,onConditionChange:w=>c(b,w),onDelete:()=>l(b)})},`${b}_${_.type}`))})]}),v.jsxs(Hu,{className:"sticky-bottom redirect-rule-modal__footer",children:[v.jsx(Lt,{type:"button",color:"link",onClick:t,children:"Cancel"}),v.jsx(Lt,{color:"primary",disabled:i.conditions.length===0,children:"Confirm"})]})]})})},TEe=({priority:e,isLast:t,redirectRule:r,onDelete:n,onMoveUp:i,onMoveDown:a,onUpdate:o})=>{const[s,c]=ir();return v.jsxs(Sr,{children:[v.jsxs("div",{className:"d-flex align-content-center gap-3",children:[v.jsx("div",{className:"d-flex flex-column my-auto drag-n-drop-handler d-none d-md-block",style:{cursor:"grab"},children:v.jsx(He,{icon:kY})}),v.jsxs("div",{className:"d-flex flex-column my-auto",children:[v.jsx(Lt,{outline:!0,color:"secondary",size:"sm","aria-label":`Move rule with priority ${e} up`,disabled:e===1,onClick:i,className:"rounded-0 rounded-top",style:{marginBottom:"-1px"},children:v.jsx(He,{icon:qY})}),v.jsx(Lt,{outline:!0,color:"secondary",size:"sm","aria-label":`Move rule with priority ${e} down`,disabled:t,onClick:a,className:"rounded-0 rounded-bottom",children:v.jsx(He,{icon:UY})})]}),v.jsxs("div",{className:"flex-grow-1",children:[v.jsxs("div",{className:"mb-2",children:[v.jsx("b",{children:"Long URL:"})," ",v.jsx(Gn,{href:r.longUrl,"data-testid":"rule-long-url"})]}),v.jsxs("div",{className:"d-flex flex-column flex-lg-row gap-2",children:[v.jsx("b",{children:"Conditions:"}),r.conditions.map((l,h)=>v.jsxs("div",{className:"badge bg-secondary",children:[l.type==="device"&&v.jsxs(v.Fragment,{children:["Device is ",l.matchValue]}),l.type==="language"&&v.jsxs(v.Fragment,{children:[l.matchValue," language is accepted"]}),l.type==="query-param"&&v.jsxs(v.Fragment,{children:["Query string contains ",l.matchKey,"=",l.matchValue]}),l.type==="ip-address"&&v.jsxs(v.Fragment,{children:["IP address matches ",l.matchValue]}),l.type==="geolocation-country-code"&&v.jsxs(v.Fragment,{children:["Country code is ",l.matchValue]}),l.type==="geolocation-city-name"&&v.jsxs(v.Fragment,{children:["City name is ",l.matchValue]})]},`${l.type}_${h}`))]})]}),v.jsxs("div",{className:"d-flex flex-column flex-sm-row gap-1 my-auto",children:[v.jsx(Lt,{outline:!0,color:"secondary",size:"sm","aria-label":`Edit rule with priority ${e}`,onClick:c,children:v.jsx(He,{icon:$$})}),v.jsx(Lt,{outline:!0,color:"danger",size:"sm","aria-label":`Delete rule with priority ${e}`,onClick:n,children:v.jsx(He,{icon:tY})})]})]}),v.jsx(wV,{onSave:o,isOpen:s,toggle:c,initialData:r})]})},jEe=({shortUrlRedirectRules:e,getShortUrlRedirectRules:t,getShortUrlsDetails:r,shortUrlsDetails:n,setShortUrlRedirectRules:i,shortUrlRedirectRulesSaving:a,resetSetRules:o})=>{const s=NA(),{shortUrls:c}=n,l=s&&(c==null?void 0:c.get(s)),[h,p,g]=yEe([],{dragHandle:".drag-n-drop-handler",dropZoneClass:"opacity-25"}),{saving:_,saved:b,errorData:w}=a,[x,S]=ir(),C=M.useCallback(U=>g((B=[])=>[...B,U]),[g]),P=M.useCallback(U=>g((B=[])=>{const W=[...B];return W.splice(U,1),W}),[g]),T=M.useCallback((U,B)=>g((W=[])=>{const q=[...W];return q[U]=B,q}),[g]),A=M.useCallback((U,B)=>g((W=[])=>{if(!W[B])return W;const q=[...W],J=q[B];return q[B]=q[U],q[U]=J,q}),[g]),j=M.useCallback(U=>A(U,U-1),[A]),N=M.useCallback(U=>A(U,U+1),[A]),$=M.useCallback(U=>{U.preventDefault(),p&&i({shortUrl:s,data:{redirectRules:p}})},[s,p,i]);return M.useEffect(()=>(t(s),r([s]),o),[t,r,s,o]),M.useEffect(()=>{e.redirectRules&&g(e.redirectRules)},[g,e.redirectRules]),v.jsxs("div",{className:"d-flex flex-column gap-3",children:[v.jsx("header",{children:v.jsxs(Qi,{body:!0,children:[v.jsxs("h2",{className:"d-sm-flex justify-content-between align-items-center mb-0",children:[v.jsx(i_,{}),v.jsxs("div",{className:"text-center flex-grow-1",children:[n.loading&&v.jsx(v.Fragment,{children:"Loading..."}),!n.loading&&v.jsxs("small",{children:["Redirect rules for ",v.jsx(Gn,{href:(l==null?void 0:l.shortUrl)??""})]})]})]}),v.jsx("hr",{}),v.jsxs("div",{children:[v.jsx("p",{className:"mb-2",children:"Configure dynamic conditions that will be checked at runtime."}),"If no conditions match, visitors will be redirected to: ",v.jsx(Gn,{href:e.defaultLongUrl??""})]})]})}),v.jsx("div",{children:v.jsxs(Lt,{outline:!0,color:"primary",onClick:S,children:[v.jsx(He,{icon:gm,className:"me-1"})," Add rule"]})}),v.jsxs("form",{onSubmit:$,children:[e.loading&&v.jsx(Lu,{loading:!0}),p.length===0&&!e.loading&&v.jsx(Sr,{className:"text-center",children:v.jsx("i",{children:"This short URL has no dynamic redirect rules"})}),v.jsx("div",{className:"d-flex flex-column gap-2",ref:h,children:p.map((U,B)=>v.jsx(TEe,{redirectRule:U,priority:B+1,isLast:B===p.length-1,onDelete:()=>P(B),onMoveUp:()=>j(B),onMoveDown:()=>N(B),onUpdate:W=>T(B,W)},`${U.longUrl}_${B}`))}),v.jsx("div",{className:"text-center mt-3",children:v.jsx(Lt,{outline:!0,color:"primary",className:"btn-sm-block",disabled:_,"data-testid":"save-button",children:_?"Saving...":"Save rules"})})]}),w&&v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:w,fallbackMessage:"An error occurred while saving short URL redirect rules :("})}),b&&v.jsx(gi,{type:"success",children:"Redirect rules properly saved."}),v.jsx(wV,{isOpen:x,toggle:S,onSave:C})]})},AEe=(e,t)=>{e.serviceFactory("ShortUrlRedirectRules",()=>jEe),e.decorator("ShortUrlRedirectRules",t(["shortUrlRedirectRules","shortUrlsDetails","shortUrlRedirectRulesSaving"],["getShortUrlRedirectRules","getShortUrlsDetails","setShortUrlRedirectRules","resetSetRules"])),e.serviceFactory("getShortUrlRedirectRules",fPe,"apiClientFactory"),e.serviceFactory("setShortUrlRedirectRules",lPe,"apiClientFactory"),e.serviceFactory("resetSetRules",r=>r.resetSetRules,"setShortUrlRedirectRulesReducerCreator"),e.serviceFactory("shortUrlRedirectRulesReducerCreator",dPe,"getShortUrlRedirectRules"),e.serviceFactory("shortUrlRedirectRulesReducer",r=>r.reducer,"shortUrlRedirectRulesReducerCreator"),e.serviceFactory("setShortUrlRedirectRulesReducerCreator",uPe,"setShortUrlRedirectRules"),e.serviceFactory("setShortUrlRedirectRulesReducer",r=>r.reducer,"setShortUrlRedirectRulesReducerCreator")},kEe=e=>({longUrl:"",tags:[],customSlug:"",title:void 0,shortCodeLength:void 0,domain:"",validSince:void 0,validUntil:void 0,maxVisits:void 0,findIfExists:!1,validateUrl:(e==null?void 0:e.validateUrls)??!1,forwardQuery:(e==null?void 0:e.forwardQuery)??!0}),xV=({createShortUrl:e,shortUrlCreation:t,resetCreateShortUrl:r,basicMode:n=!1})=>{const{ShortUrlForm:i,CreateShortUrlResult:a}=ur(xV),o=Nn("shortUrlCreation"),s=M.useMemo(()=>kEe(o),[o]);return v.jsxs(v.Fragment,{children:[v.jsx(i,{initialState:s,saving:t.saving,basicMode:n,onSave:async c=>(r(),e(c))}),v.jsx(a,{creation:t,resetCreateShortUrl:r,canBeClosed:n})]})},REe=cr(xV,["ShortUrlForm","CreateShortUrlResult"]),SV=({shortUrlsDetails:e,getShortUrlsDetails:t,shortUrlEdition:r,editShortUrl:n})=>{const{ShortUrlForm:i}=ur(SV),a=NA(),{loading:o,error:s,errorData:c,shortUrls:l}=e,h=a&&(l==null?void 0:l.get(a)),{saving:p,saved:g,error:_,errorData:b}=r,w=Nn("shortUrlCreation"),x=M.useMemo(()=>QCe(h,w),[h,w]);return M.useEffect(()=>{a&&t([a])},[t,a]),o?v.jsx(Lu,{loading:!0}):s?v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:c,fallbackMessage:"An error occurred while loading short URL detail :("})}):v.jsxs(v.Fragment,{children:[v.jsx("header",{className:"mb-3",children:v.jsx(Qi,{body:!0,children:v.jsxs("h2",{className:"d-sm-flex justify-content-between align-items-center mb-0",children:[v.jsx(i_,{}),v.jsx("div",{className:"text-center flex-grow-1",children:v.jsxs("small",{children:["Edit ",v.jsx(Gn,{href:(h==null?void 0:h.shortUrl)??""})]})})]})})}),v.jsx(i,{initialState:x,saving:p,onSave:async S=>{h&&n({...h,data:S})}}),g&&_&&v.jsx(gi,{type:"error",className:"mt-3",children:v.jsx(uo,{errorData:b,fallbackMessage:"An error occurred while updating short URL :("})}),g&&!_&&v.jsx(gi,{type:"success",className:"mt-3",children:"Short URL properly edited."})]})},NEe=cr(SV,["ShortUrlForm"]),OV=({text:e,onCopy:t},r=navigator)=>{var n;return(n=r.clipboard)==null?void 0:n.writeText(e).then(()=>t==null?void 0:t(e,!0)).catch(()=>t==null?void 0:t(e,!1))},CV=({creation:e,resetCreateShortUrl:t,canBeClosed:r=!1})=>{const{useTimeoutToggle:n}=ur(CV),[i,a]=n(),{error:o,saved:s}=e;if(M.useEffect(()=>{t()},[t]),o)return v.jsxs(gi,{type:"error",className:"mt-3",children:[r&&v.jsx(He,{"data-testid":"error-close-button",icon:kO,className:"float-end pointer",onClick:t}),v.jsx(uo,{errorData:e.errorData,fallbackMessage:"An error occurred while creating the URL :("})]});if(!s)return null;const{shortUrl:c}=e.result;return v.jsxs(gi,{type:"success",className:"mt-3",children:[r&&v.jsx(He,{"data-testid":"success-close-button",icon:kO,className:"float-end pointer",onClick:t}),v.jsxs("span",{children:[v.jsx("b",{children:"Great!"})," The short URL is ",v.jsx("b",{children:c})]}),v.jsxs("button",{className:"btn btn-light btn-sm create-short-url-result__copy-btn",id:"copyBtn",type:"button",onClick:()=>OV({text:c,onCopy:a}),children:[v.jsx(He,{icon:K7})," Copy ",v.jsxs("span",{className:"sr-only",children:[c," to clipboard"]})]}),v.jsx(ab,{placement:"left",isOpen:i,target:"copyBtn",children:"Copied!"})]})},MEe=cr(CV,["useTimeoutToggle"]),bO="delete",LEe=({shortUrl:e,toggle:t,isOpen:r,shortUrlDeletion:n,resetDeleteShortUrl:i,deleteShortUrl:a,shortUrlDeleted:o})=>{const[s,c]=M.useState("");M.useEffect(()=>i,[i]);const{loading:l,error:h,deleted:p,errorData:g}=n,_=M.useCallback(()=>{i(),t()},[i,t]),b=M.useCallback(w=>(w.preventDefault(),a(e).then(x=>!wA(x)&&t())),[a,e,t]);return v.jsx(Ji,{isOpen:r,toggle:_,centered:!0,onClosed:()=>p&&o(e),children:v.jsxs("form",{onSubmit:b,children:[v.jsx(Sl,{toggle:_,children:v.jsx("span",{className:"text-danger",children:"Delete short URL"})}),v.jsxs(as,{children:[v.jsxs("p",{children:[v.jsx("b",{className:"text-danger",children:"Caution!"})," You are about to delete a short URL."]}),v.jsx("p",{children:"This action cannot be undone. Once you have deleted it, all the visits stats will be lost."}),v.jsxs("p",{children:["Write ",v.jsx("b",{children:bO})," to confirm deletion."]}),v.jsx("input",{type:"text",className:"form-control",placeholder:`Insert ${bO}`,value:s,onChange:w=>c(w.target.value)}),h&&v.jsx(gi,{type:CCe(g)?"warning":"error",small:!0,className:"mt-2",children:v.jsx(uo,{errorData:g,fallbackMessage:"Something went wrong while deleting the URL :("})})]}),v.jsxs(Hu,{children:[v.jsx("button",{type:"button",className:"btn btn-link",onClick:_,children:"Cancel"}),v.jsx("button",{type:"submit",className:"btn btn-danger",disabled:s!==bO||l,children:l?"Deleting...":"Delete"})]})]})})},PV=({amount:e=0,loading:t=!1,...r})=>v.jsxs(Lt,{...r,outline:!0,color:"primary",disabled:t,children:[v.jsx(He,{icon:oY})," ",t?"Exporting...":v.jsxs(v.Fragment,{children:["Export (",Or(e),")"]})]}),b8=20,EV=({amount:e=0})=>{const{apiClientFactory:t,ReportExporter:r}=ur(EV),[{tags:n,search:i,startDate:a,endDate:o,orderBy:s,tagsMode:c}]=n_(),[l,,h,p]=ir(),g=M.useCallback(async()=>{const _=e/b8,b=async(x=1)=>{const{data:S}=await t().listShortUrls({page:`${x}`,tags:n,searchTerm:i,startDate:a,endDate:o,orderBy:s,tagsMode:c,itemsPerPage:b8});return x>=_?S:S.concat(await b(x+1))};h();const w=await b();r.exportShortUrls(w.map(x=>{var S;const{hostname:C,pathname:P}=new URL(x.shortUrl),T=P.substring(1);return{createdAt:x.dateCreated,domain:C,shortCode:T,shortUrl:x.shortUrl,longUrl:x.longUrl,title:x.title??"",tags:x.tags.join("|"),visits:((S=x==null?void 0:x.visitsSummary)==null?void 0:S.total)??x.visitsCount??0}})),p()},[e,t,o,s,r,i,a,h,p,n,c]);return v.jsx(PV,{loading:l,className:"btn-md-block",amount:e,onClick:g})},IEe=cr(EV,["apiClientFactory","ReportExporter"]),TV=({text:e,onCopy:t,copyToClipboard:r=OV})=>v.jsx(Wu,{className:"ms-2 p-0","aria-label":`Copy ${e} to clipboard`,onClick:()=>r({text:e,onCopy:t}),children:v.jsx(He,{icon:K7,className:"fs-5"})}),_8=e=>e&&e.startsWith("#")?e.substring(1):e,DEe=(e,{color:t,bgColor:r,...n})=>{const i=`${e}/qr-code`,a=sb({...n,color:_8(t),bgColor:_8(r)});return`${i}${a?`?${a}`:""}`},$Ee=6,w8="0123456789ABCDEF",FEe=128;function BEe(){return`#${CA($Ee,()=>w8[Math.floor(Math.random()*w8.length)]).join("")}`}function UEe(e,t,r){return Math.round(Math.sqrt(.299*e**2+.587*t**2+.114*r**2))}function jV(e){const[t,r,n]=(e.match(/../g)??[]).map(i=>parseInt(i,16)||0);return UEe(t,r,n)>=FEe}const AV=M.forwardRef(({name:e,color:t,onChange:r,className:n},i)=>v.jsxs("div",{className:Te("p-0 position-relative",n),style:{backgroundColor:t,borderColor:t},children:[v.jsx(He,{icon:_Y,className:"position-absolute top-50 start-50 translate-middle",style:{color:jV(t.substring(1))?"#000":"fff"}}),v.jsx(Zr,{className:"form-control-color opacity-0",type:"color",value:t,onChange:a=>r(a.target.value),innerRef:i,name:e,"aria-label":e})]})),zEe=({color:e,onChange:t,name:r})=>{const n=_i();return v.jsxs(Om,{children:[v.jsx(AV,{name:r,color:e,onChange:t,className:"input-group-text",ref:n}),v.jsx(Zr,{readOnly:!0,value:e,onClick:()=>{var i;return(i=n.current)==null?void 0:i.click()},"aria-label":r,"data-testid":"text-input"})]})},D0=({label:e,...t})=>v.jsx(Lt,{outline:!0,color:"link",style:{color:"var(--input-text-color)",borderColor:"var(--border-color)"},"aria-label":e,title:e,...t}),x8=({name:e,color:t,initialColor:r,onChange:n})=>v.jsx(v.Fragment,{children:t===void 0?v.jsx(D0,{className:"text-start fst-italic w-100",onClick:()=>n(r),children:v.jsxs("span",{className:"indivisible",children:["Customize ",e]})}):v.jsxs("div",{className:"d-flex gap-1 w-100",children:[v.jsx(zEe,{color:t,onChange:n,name:e}),v.jsx(D0,{label:`Default ${e}`,onClick:()=>n(void 0),children:v.jsx(He,{icon:xT})})]})}),S8=({name:e,value:t,step:r,min:n,max:i,onChange:a,initial:o=n})=>{const s=M.useId();return v.jsx(v.Fragment,{children:t===void 0?v.jsxs(D0,{className:"text-start fst-italic w-100",onClick:()=>a(o),children:["Customize ",e]}):v.jsxs("div",{className:"d-flex gap-1 w-100",children:[v.jsxs("div",{className:"d-flex flex-column flex-grow-1",children:[v.jsxs("label",{htmlFor:s,className:"text-capitalize",children:[e,": ",t,"px"]}),v.jsx("input",{id:s,type:"range",className:"form-control-range",value:t,step:r,min:n,max:i,onChange:c=>a(Number(c.target.value))})]}),v.jsx(D0,{label:`Default ${e}`,onClick:()=>a(void 0),children:v.jsx(He,{icon:xT})})]})})},VEe=({errorCorrection:e,onChange:t})=>v.jsxs(os,{text:e?`Error correction (${e})`:v.jsx("i",{children:"Default error correction"}),dropdownClassName:"w-100",children:[v.jsx(Ze,{active:!e,onClick:()=>t(void 0),children:"Default"}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{active:e==="L",onClick:()=>t("L"),children:[v.jsx("b",{children:"L"}),"ow"]}),v.jsxs(Ze,{active:e==="M",onClick:()=>t("M"),children:[v.jsx("b",{children:"M"}),"edium"]}),v.jsxs(Ze,{active:e==="Q",onClick:()=>t("Q"),children:[v.jsx("b",{children:"Q"}),"uartile"]}),v.jsxs(Ze,{active:e==="H",onClick:()=>t("H"),children:[v.jsx("b",{children:"H"}),"igh"]})]}),WEe=({format:e,onChange:t})=>v.jsxs(os,{text:e?`Format (${e})`:v.jsx("i",{children:"Default format"}),dropdownClassName:"w-100",children:[v.jsx(Ze,{active:!e,onClick:()=>t(void 0),children:"Default"}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{active:e==="png",onClick:()=>t("png"),children:"PNG"}),v.jsx(Ze,{active:e==="svg",onClick:()=>t("svg"),children:"SVG"})]}),kV=({shortUrl:{shortUrl:e,shortCode:t},toggle:r,isOpen:n})=>{const{ImageDownloader:i}=ur(kV),[a,o]=M.useState(),[s,c]=M.useState(),[l,h]=M.useState(),[p,g]=M.useState(),[_,b]=M.useState(),[w,x]=M.useState(),S=Ca("qrCodeColors"),C=M.useMemo(()=>DEe(e,{size:a,format:l,margin:s,errorCorrection:p,color:_,bgColor:w}),[e,a,l,s,p,_,w]);return v.jsxs(Ji,{isOpen:n,toggle:r,centered:!0,size:"lg",children:[v.jsxs(Sl,{toggle:r,children:["QR code for ",v.jsx(Gn,{href:e,children:e})]}),v.jsxs(as,{className:"d-flex flex-column-reverse flex-lg-row gap-3",children:[v.jsx("div",{className:"flex-grow-1 d-flex align-items-center justify-content-around text-center",children:v.jsx("img",{src:C,alt:"QR code",className:"shadow",style:{maxWidth:"100%"}})}),v.jsxs("div",{className:"d-flex flex-column gap-2 qr-code-modal__controls",children:[v.jsx(S8,{name:"size",value:a,onChange:o,step:10,min:50,max:1e3,initial:300}),v.jsx(S8,{name:"margin",value:s,onChange:c,step:1,min:0,max:100}),v.jsx(WEe,{format:l,onChange:h}),v.jsx(VEe,{errorCorrection:p,onChange:g}),S&&v.jsxs(v.Fragment,{children:[v.jsx(x8,{name:"color",initialColor:"#000000",color:_,onChange:b}),v.jsx(x8,{name:"background",initialColor:"#ffffff",color:w,onChange:x})]}),v.jsx("div",{className:"mt-auto",children:v.jsxs(Lt,{block:!0,color:"primary",onClick:()=>{i.saveImage(C,`${t}-qr-code.${l??"png"}`).catch(()=>{})},children:["Download ",v.jsx(He,{icon:B$,className:"ms-1"})]})})]})]}),v.jsx(Hu,{className:"sticky-bottom justify-content-around",style:{backgroundColor:"var(--primary-color)",zIndex:"1"},children:v.jsxs("div",{className:"text-center",children:[v.jsx(Gn,{href:C}),v.jsx(TV,{text:C})]})})]})},qEe=cr(kV,["ImageDownloader"]),HEe="yyyy-MM-dd",RV="yyyy-MM-dd HH:mm",gl=()=>new Date,LA=e=>typeof e!="string",IA=(e,t)=>!e||!LA(e)?e:t?ky(e,t):wle(e),yl=e=>IA(e,void 0),nl=e=>IA(e,HEe),hm=e=>IA(e,RV),vi=e=>LA(e)?e:hl(e),Um=(e,t,r)=>{const n=vi(e),i=t&&vi(t),a=r&&vi(r);if(i&&a)try{return Ole(n,{start:i,end:a})}catch{return!1}return i?_P(n,i)||Sle(n,i):a?_P(n,a)||Ry(n,a):!0},su=(e,t)=>_P(e,t)||Ry(e,t),$0=({date:e,format:t=RV,relative:r=!1})=>{const n=LA(e)?e:hl(e);return v.jsx("time",{dateTime:`${xle(n)}000`,children:r?`${_le(gl(),n)} ago`:ky(n,t)})},GEe=(e,{shortCode:t,domain:r},n)=>{const i=r?`?domain=${r}`:"";return`${e}/short-code/${Jz(t)}/${n}${i}`},hp=({shortUrl:e,suffix:t,asLink:r,children:n,...i})=>{const a=jl();return!r||!e?v.jsx("span",{...i,children:n}):v.jsx(Xt,{to:GEe(a,e,t),...i,children:n})},KEe=e=>{const{meta:t,visitsCount:r,visitsSummary:n}=e,{maxVisits:i,validSince:a,validUntil:o}=t,s=(n==null?void 0:n.total)??r??0;return i&&s>=i?{icon:eZ,className:"text-danger",description:v.jsxs(v.Fragment,{children:["This short URL cannot be currently visited because it has reached the maximum amount of ",v.jsx("b",{children:i})," visit",i>1?"s":"","."]})}:o&&Ry(vi(o),gl())?{icon:tR,className:"text-danger",description:v.jsxs(v.Fragment,{children:["This short URL cannot be visited since ",v.jsx("b",{className:"indivisible",children:hm(vi(o))}),"."]})}:a&&Ry(gl(),vi(a))?{icon:tR,className:"text-warning",description:v.jsxs(v.Fragment,{children:["This short URL will start working on ",v.jsx("b",{className:"indivisible",children:hm(vi(a))}),"."]})}:{icon:vp,className:"text-primary",description:"This short URL can be visited normally."}},YEe=({shortUrl:e})=>{const t=_i(),{icon:r,className:n,description:i}=KEe(e);return v.jsxs(v.Fragment,{children:[v.jsx("span",{style:{cursor:i?"help":void 0},ref:t,children:v.jsx(He,{icon:r,className:n})}),v.jsx(Oi,{target:t,placement:"bottom",children:i})]})},NV=({visitsCount:e,shortUrl:t,active:r=!1,asLink:n=!1})=>{const i=_i(),{maxVisits:a,validSince:o,validUntil:s}=(t==null?void 0:t.meta)??{},c=!!a||!!o||!!s,l=v.jsx(hp,{shortUrl:t,suffix:"visits",asLink:n,children:v.jsx("strong",{className:Te("short-url-visits-count__amount",{"short-url-visits-count__amount--big":r}),children:Or(e)})});return c?v.jsxs(v.Fragment,{children:[v.jsxs("span",{className:"indivisible",children:[l,v.jsxs("small",{className:"short-urls-visits-count__max-visits-control",ref:i,children:[a&&v.jsxs(v.Fragment,{children:[" / ",Or(a)]}),v.jsx("sup",{className:"ms-1",children:v.jsx(He,{icon:wT})})]})]}),v.jsx(Oi,{target:i,placement:"bottom",children:v.jsxs("ul",{className:"list-unstyled mb-0",children:[a&&v.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept more than ",v.jsx("b",{children:Or(a)})," visit",a===1?"":"s","."]}),o&&v.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept visits before ",v.jsx("b",{className:"indivisible",children:hm(vi(o))}),"."]}),s&&v.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept visits after ",v.jsx("b",{className:"indivisible",children:hm(vi(s))}),"."]})]})})]}):l},ZEe=e=>!!e.onClose,XEe=e=>!!e.onClick,a_=e=>{const{text:t,children:r,className:n,colorGenerator:i}=e,a=XEe(e),o=a?Wu:"span",s=M.useMemo(()=>i.stylesForKey(t),[t,i]);return v.jsxs(o,{className:Te("badge tag fw-bold",n,{pointer:a}),style:s,onClick:a?e.onClick:void 0,children:[r??t,ZEe(e)&&v.jsx(Wu,{"aria-label":`Remove ${t}`,className:"bg-transparent ms-1 opacity-100 p-0 fw-bold tag__close",onClick:e.onClose,children:"×"})]})},QEe=({tags:e,onTagClick:t,colorGenerator:r})=>e.length===0?v.jsx("i",{className:"indivisible",children:v.jsx("small",{children:"No tags"})}):v.jsx(v.Fragment,{children:e.map(n=>v.jsx(a_,{text:n,colorGenerator:r,onClick:()=>t==null?void 0:t(n)},n))}),MV=({shortUrl:e,onTagClick:t})=>{var r,n,i,a;const{ShortUrlsRowMenu:o,ColorGenerator:s,useTimeoutToggle:c}=ur(MV),[l,h]=c(),[p,g]=c(!1,500),_=M.useRef(!0),[{excludeBots:b}]=n_(),w=Nn("visits"),x=b??(w==null?void 0:w.excludeBots);return M.useEffect(()=>{_.current||g(),_.current=!1},[(r=e.visitsSummary)==null?void 0:r.total,(n=e.visitsSummary)==null?void 0:n.nonBots,e.visitsCount,g]),v.jsxs("tr",{className:"responsive-table__row",children:[v.jsx("td",{className:"indivisible short-urls-row__cell responsive-table__cell","data-th":"Created at",children:v.jsx($0,{date:e.dateCreated})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Short URL",children:v.jsxs("span",{className:"position-relative short-urls-row__cell--indivisible",children:[v.jsx("span",{className:"short-urls-row__short-url-wrapper",children:v.jsx(Gn,{href:e.shortUrl})}),v.jsx(TV,{text:e.shortUrl,onCopy:h}),v.jsx("span",{role:"status",className:"badge bg-warning text-black short-urls-row__copy-hint",hidden:!l,children:"Copied short URL!"})]})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell short-urls-row__cell--break","data-th":`${e.title?"Title":"Long URL"}`,children:v.jsx(Gn,{href:e.longUrl,children:e.title??e.longUrl})}),e.title&&v.jsx("td",{className:"short-urls-row__cell responsive-table__cell short-urls-row__cell--break d-lg-none","data-th":"Long URL",children:v.jsx(Gn,{href:e.longUrl})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Tags",children:v.jsx(QEe,{tags:e.tags,colorGenerator:s,onTagClick:t})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell text-lg-end","data-th":"Visits",children:v.jsx(NV,{visitsCount:(x?(i=e.visitsSummary)==null?void 0:i.nonBots:(a=e.visitsSummary)==null?void 0:a.total)??e.visitsCount??0,shortUrl:e,active:p,asLink:!0})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Status",children:v.jsxs("div",{className:"d-flex gap-2",children:[v.jsx(YEe,{shortUrl:e}),e.hasRedirectRules&&v.jsx(hp,{asLink:!0,shortUrl:e,suffix:"redirect-rules",title:"This short URL has dynamic redirect rules",children:v.jsx(He,{icon:V$})})]})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell text-end",children:v.jsx(o,{shortUrl:e})})]})},JEe=cr(MV,["ShortUrlsRowMenu","ColorGenerator","useTimeoutToggle"]),LV=({shortUrl:e,deleteShortUrl:t,shortUrlDeleted:r})=>{const{DeleteShortUrlModal:n,QrCodeModal:i}=ur(LV),[a,,o,s]=ir(),[c,,l,h]=ir(),p=Jb(),g=Ca("shortUrlRedirectRules"),{confirmDeletions:_=!0}=Nn("shortUrlsList",{}),b=M.useCallback(async()=>{const w=await t(e);wA(w)||r(e)},[t,e,r]);return v.jsxs(lb,{minWidth:g?220:190,children:[v.jsxs(Ze,{tag:hp,shortUrl:e,suffix:"visits",asLink:!0,children:[v.jsx(He,{icon:_T,fixedWidth:!0})," Visit stats"]}),p&&v.jsxs(v.Fragment,{children:[v.jsxs(Ze,{disabled:!p.canAddItemWithName(e.shortUrl),onClick:()=>p.addItemToCompare({name:e.shortUrl,query:jA(e)}),children:[v.jsx(He,{icon:X0,fixedWidth:!0})," Compare visits"]}),v.jsx(Ze,{divider:!0,tag:"hr"})]}),v.jsxs(Ze,{tag:hp,shortUrl:e,suffix:"edit",asLink:!0,children:[v.jsx(He,{icon:bT,fixedWidth:!0})," Edit short URL"]}),g&&v.jsxs(Ze,{tag:hp,shortUrl:e,suffix:"redirect-rules",asLink:!0,children:[v.jsx(He,{icon:V$,fixedWidth:!0})," Manage redirect rules"]}),v.jsxs(Ze,{onClick:o,children:[v.jsx(He,{icon:XY,fixedWidth:!0})," QR code"]}),v.jsx(i,{shortUrl:e,isOpen:a,toggle:s}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{className:"dropdown-item--danger",onClick:_?l:b,children:[v.jsx(He,{icon:D$,fixedWidth:!0})," Delete short URL"]}),v.jsx(n,{shortUrl:e,deleteShortUrl:t,shortUrlDeleted:r,isOpen:c,toggle:h})]})},eTe=cr(LV,["DeleteShortUrlModal","QrCodeModal"]),IV="shlink/shortUrlCreation",O8={saving:!1,saved:!1,error:!1},tTe=e=>Vr(`${IV}/createShortUrl`,t=>e().createShortUrl(t)),rTe=e=>{const{reducer:t,actions:r}=Tr({name:IV,initialState:O8,reducers:{resetCreateShortUrl:()=>O8},extraReducers:i=>{i.addCase(e.pending,()=>({saving:!0,saved:!1,error:!1})),i.addCase(e.rejected,(a,{error:o})=>({saving:!1,saved:!1,error:!0,errorData:Ci(o)})),i.addCase(e.fulfilled,(a,{payload:o})=>({result:o,saving:!1,saved:!0,error:!1}))}}),{resetCreateShortUrl:n}=r;return{reducer:t,resetCreateShortUrl:n}},DV="shlink/shortUrlEdition",nTe={saving:!1,saved:!1,error:!1},iTe=e=>Vr(`${DV}/editShortUrl`,({shortCode:t,domain:r,data:n})=>e().updateShortUrl({shortCode:t,domain:r},n)),aTe=e=>Tr({name:DV,initialState:nTe,reducers:{},extraReducers:t=>{t.addCase(e.pending,r=>({...r,saving:!0,error:!1,saved:!1})),t.addCase(e.rejected,(r,{error:n})=>({...r,saving:!1,error:!0,saved:!1,errorData:Ci(n)})),t.addCase(e.fulfilled,(r,{payload:n})=>({shortUrl:n,saving:!1,error:!1,saved:!0}))}}),C8="shlink/shortUrlsDetails",P8={loading:!1,error:!1},oTe=e=>{const t=Vr(`${C8}/getShortUrlsDetails`,async(n,{getState:i})=>{const{shortUrlsList:a}=i(),o=await Promise.all(n.map(async s=>{var c;const{shortCode:l,domain:h}=s,p=(c=a==null?void 0:a.shortUrls)==null?void 0:c.data.find(g=>dp(g,l,h));return[s,p??await e().getShortUrl({shortCode:l,domain:h})]}));return new Map(o)}),{reducer:r}=Tr({name:C8,initialState:P8,reducers:{},extraReducers:n=>{n.addCase(t.pending,()=>({loading:!0,error:!1})),n.addCase(t.rejected,(i,{error:a})=>({loading:!1,error:!0,errorData:Ci(a)})),n.addCase(t.fulfilled,(i,{payload:a})=>({...P8,shortUrls:a}))}});return{reducer:r,getShortUrlsDetails:t}},sTe=({domains:e,value:t,onChange:r})=>{const[n,,i,a]=ir(),o=!t,s=M.useCallback(()=>{r(""),a()},[r,a]),c=M.useCallback(()=>{r(""),i()},[r,i]);return n?v.jsxs(Om,{children:[v.jsx(Zr,{value:t??"",placeholder:"Domain",onChange:l=>r(l.target.value)}),v.jsx(Lt,{id:"backToDropdown",outline:!0,type:"button",className:"domains-dropdown__back-btn","aria-label":"Back to domains list",onClick:s,children:v.jsx(He,{icon:AY})}),v.jsx(Oi,{target:"backToDropdown",placement:"left",trigger:"hover",children:"Existing domains"})]}):v.jsxs(os,{text:o?"Domain":`Domain: ${t}`,className:o?"domains-dropdown__toggle-btn":"domains-dropdown__toggle-btn--active",children:[e.map(({domain:l,isDefault:h})=>v.jsxs(Ze,{active:(t===l||h)&&o,onClick:()=>r(l),className:"d-flex justify-content-between align-items-center",children:[l,h&&v.jsx("span",{className:"text-muted",children:"default"})]},l)),v.jsx(Ze,{divider:!0}),v.jsx(Ze,{onClick:c,children:v.jsx("i",{children:"New domain"})})]})},_O=({icon:e,className:t,...r})=>{const n=_i();return v.jsxs("div",{className:"icon-input-container",children:[v.jsx(Zr,{className:Te("icon-input-container__input",t),innerRef:n,...r}),v.jsx(He,{icon:e,fixedWidth:!0,className:"icon-input-container__icon",onClick:()=>{var i;return(i=n.current)==null?void 0:i.focus()}})]})},lTe=({minDate:e,maxDate:t,value:r,onChange:n,withTime:i=!1,...a})=>{const o=M.useCallback(({target:c})=>{if(!c.value){n==null||n(null);return}n==null||n(vi(c.value))},[n]),s=M.useMemo(()=>i?hm:nl,[i]);return v.jsx(Zr,{...a,type:i?"datetime-local":"date",value:s(r)??"",max:s(t)??void 0,min:s(e)??void 0,onChange:o})},F0=({label:e,id:t,...r})=>{const n=M.useId();return v.jsxs(v.Fragment,{children:[v.jsxs("label",{htmlFor:t??n,className:"mb-1",children:[e,":"]}),v.jsx(lTe,{id:t??n,...r})]})},wO=({children:e,infoTooltip:t,checked:r,onChange:n})=>v.jsxs("p",{children:[v.jsx(d7,{inline:!0,checked:r,className:t?"me-2":"",onChange:n,children:e}),t&&v.jsx(Gg,{placement:"right",children:t})]}),uTe=({isOpen:e,toggle:t})=>v.jsxs(Ji,{isOpen:e,toggle:t,centered:!0,size:"lg",children:[v.jsx(Sl,{toggle:t,children:"Info"}),v.jsxs(as,{children:[v.jsxs("p",{children:["When the ",v.jsx("b",{children:v.jsx("i",{children:'"Use existing URL if found"'})})," checkbox is checked, the server will return an existing short URL if it matches provided params."]}),v.jsx("p",{children:"These are the checks performed by Shlink in order to determine if an existing short URL should be returned:"}),v.jsxs("ul",{children:[v.jsx("li",{children:"When only the long URL is provided: The most recent match will be returned, or a new short URL will be created if none is found."}),v.jsxs("li",{children:["When long URL and custom slug and/or domain are provided: Same as in previous case, but it will try to match the short URL using both the long URL and the slug, the long URL and the domain, or the three of them.",v.jsx("br",{}),"If the slug is being used by another long URL, an error will be returned."]}),v.jsx("li",{children:"When other params are provided: Same as in previous cases, but it will try to match existing short URLs with all provided data. If any of them does not match, a new short URL will be created"})]})]})]}),cTe=()=>{const[e,t]=ir();return v.jsxs(v.Fragment,{children:[v.jsx(Wu,{className:"p-0",title:"What does this mean?",onClick:t,children:v.jsx(He,{icon:wT})}),v.jsx(uTe,{isOpen:e,toggle:t})]})},kg=e=>typeof e=="string"?hl(e):e,fTe=e=>"shortCodeLength"in e&&"customSlug"in e&&"domain"in e,$V=({basicMode:e=!1,saving:t,onSave:r,initialState:n,tagsList:i,domainsList:a})=>{var o,s,c;const{TagsSelector:l}=ur($V),[h,p]=M.useState(n),g=fTe(h),_=Ca("deviceLongUrls"),b=Ca("urlValidation"),w=b||g,x=M.useCallback(()=>p(n),[n]),S=M.useCallback((j,N)=>vu(j)?j:vu(N)?null:void 0,[]),C=M.useCallback((j,N)=>p(({deviceLongUrls:$={},...U})=>{var B;return{...U,deviceLongUrls:{...$,[j]:S(N,(B=n.deviceLongUrls)==null?void 0:B[j])}}}),[n.deviceLongUrls,S]),P=M.useCallback(j=>p(N=>({...N,tags:j})),[]),T=M.useCallback(async j=>(j.preventDefault(),r(h).then(N=>g&&!wA(N)&&x()).catch(()=>{})),[g,r,x,h]),A=M.useMemo(()=>v.jsxs("div",{className:"d-flex flex-column gap-3",children:[v.jsx(Zr,{bsSize:"lg",type:"url",placeholder:"URL to be shortened",required:!0,value:h.longUrl,onChange:j=>p(N=>({...N,longUrl:j.target.value}))}),v.jsxs("div",{className:Te("d-flex flex-column flex-lg-row gap-3",{"mb-3":e}),children:[e&&g&&v.jsx("div",{className:"w-100 w-lg-50",children:v.jsx(Zr,{bsSize:"lg",placeholder:"Custom slug",value:h.customSlug??"",onChange:j=>p(N=>({...N,customSlug:j.target.value}))})}),v.jsx("div",{className:Te("w-100",{"w-lg-50":e}),children:v.jsx(l,{tags:i.tags,selectedTags:h.tags??[],onChange:P})})]})]}),[l,e,P,g,h,i.tags]);return v.jsxs("form",{name:"shortUrlForm",className:"short-url-form",onSubmit:T,children:[e&&A,!e&&v.jsxs(v.Fragment,{children:[v.jsxs(Za,{children:[v.jsx("div",{className:Te("mb-3",{"col-sm-6":_,"col-12":!_}),children:v.jsx(Sr,{title:"Main options",children:A})}),_&&v.jsx("div",{className:"col-sm-6 mb-3",children:v.jsxs(Sr,{title:"Device-specific long URLs",bodyClassName:"d-flex flex-column gap-3",children:[v.jsx(_O,{type:"url",icon:Ule,placeholder:"Android-specific redirection",value:((o=h.deviceLongUrls)==null?void 0:o.android)??"",onChange:({target:j})=>C("android",j.value)}),v.jsx(_O,{type:"url",icon:Ble,placeholder:"iOS-specific redirection",value:((s=h.deviceLongUrls)==null?void 0:s.ios)??"",onChange:({target:j})=>C("ios",j.value)}),v.jsx(_O,{type:"url",icon:tZ,placeholder:"Desktop-specific redirection",value:((c=h.deviceLongUrls)==null?void 0:c.desktop)??"",onChange:({target:j})=>C("desktop",j.value)})]})})]}),v.jsxs(Za,{children:[v.jsx("div",{className:"col-sm-6 mb-3",children:v.jsxs(Sr,{title:"Customize the short URL",bodyClassName:"d-flex flex-column gap-3",children:[v.jsx(Zr,{placeholder:"Title",value:h.title??"",onChange:({target:j})=>p(N=>({...N,title:S(j.value,n.title)}))}),g&&v.jsxs(v.Fragment,{children:[v.jsxs(Za,{children:[v.jsx("div",{className:"col-lg-6 mb-3 mb-lg-0",children:v.jsx(Zr,{placeholder:"Custom slug",value:h.customSlug??"",onChange:j=>p(N=>({...N,customSlug:j.target.value})),disabled:vu(h.shortCodeLength)})}),v.jsx("div",{className:"col-lg-6",children:v.jsx(Zr,{type:"number",placeholder:"Short code length",value:h.shortCodeLength??"",onChange:j=>p(N=>({...N,shortCodeLength:j.target.value})),min:4,disabled:vu(h.customSlug)})})]}),v.jsx(sTe,{value:h.domain,onChange:j=>p(N=>({...N,domain:j})),domains:a.domains})]})]})}),v.jsx("div",{className:"col-sm-6 mb-3",children:v.jsxs(Sr,{title:"Limit access to the short URL",children:[v.jsxs("div",{className:"row mb-3",children:[v.jsx("div",{className:"col-lg-6",children:v.jsx(F0,{label:"Enabled since",withTime:!0,maxDate:h.validUntil?kg(h.validUntil):void 0,value:h.validSince?kg(h.validSince):null,onChange:j=>p(N=>({...N,validSince:yl(j)}))})}),v.jsx("div",{className:"col-lg-6 mt-3 mt-lg-0",children:v.jsx(F0,{label:"Enabled until",withTime:!0,minDate:h.validSince?kg(h.validSince):void 0,value:h.validUntil?kg(h.validUntil):null,onChange:j=>p(N=>({...N,validUntil:yl(j)}))})})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:"maxVisits",className:"mb-1",children:"Maximum visits allowed:"}),v.jsx(Zr,{id:"maxVisits",type:"number",min:1,placeholder:"25...",value:h.maxVisits??"",onChange:j=>p(N=>({...N,maxVisits:vu(j.target.value)?Number(j.target.value):null}))})]})]})})]}),v.jsxs(Za,{children:[w&&v.jsx("div",{className:"col-sm-6 mb-3",children:v.jsxs(Sr,{title:"Extra checks",children:[b&&v.jsx(wO,{infoTooltip:"If checked, Shlink will try to reach the long URL, failing in case it's not publicly accessible.",checked:h.validateUrl,onChange:j=>p(N=>({...N,validateUrl:j})),children:"Validate URL"}),g&&v.jsxs("p",{children:[v.jsx(d7,{inline:!0,className:"me-2",checked:h.findIfExists,onChange:j=>p(N=>({...N,findIfExists:j})),children:"Use existing URL if found"}),v.jsx(cTe,{})]})]})}),v.jsx("div",{className:Te("mb-3",{"col-sm-6":w}),children:v.jsxs(Sr,{title:"Configure behavior",children:[v.jsx(wO,{infoTooltip:"This short URL will be included in the robots.txt for your Shlink instance, allowing web crawlers (like Google) to index it.",checked:h.crawlable,onChange:j=>p(N=>({...N,crawlable:j})),children:"Make it crawlable"}),v.jsx(wO,{infoTooltip:"When this short URL is visited, any query params appended to it will be forwarded to the long URL.",checked:h.forwardQuery,onChange:j=>p(N=>({...N,forwardQuery:j})),children:"Forward query params on redirect"})]})})]})]}),v.jsx("div",{className:"text-center",children:v.jsx(Lt,{outline:!0,color:"primary",disabled:t||!h.longUrl,className:"btn-xs-block",children:t?"Saving...":"Save"})})]})},dTe=cr($V,["TagsSelector"]),o_="all",FV={today:"Today",yesterday:"Yesterday",last7Days:"Last 7 days",last30Days:"Last 30 days",last90Days:"Last 90 days",last180Days:"Last 180 days",last365Days:"Last 365 days",[o_]:void 0},BV=Object.keys(FV),hTe=e=>!e||!e.startDate&&!e.endDate,B0=e=>typeof e=="string"&&BV.includes(e),pTe=BV.filter(e=>e!==o_),E8=e=>e?vi(e):null,UV=(e,t)=>({startDate:E8(e),endDate:E8(t)}),mTe=e=>{if(!(!e||hTe(e)))return e.startDate&&!e.endDate?`Since ${nl(e.startDate)}`:!e.startDate&&e.endDate?`Until ${nl(e.endDate)}`:`${nl(e.startDate)} - ${nl(e.endDate)}`},zV=e=>{if(!(!e||e===o_))return B0(e)?FV[e]:mTe(e)},Vi=e=>Fu(Ny(gl(),e)),Xc=e=>({startDate:e,endDate:jf(gl())}),VV=e=>{var t;return((t=[[()=>e==="today",()=>Xc(Fu(gl()))],[()=>e==="yesterday",()=>({startDate:Vi(1),endDate:jf(Ny(gl(),1))})],[()=>e==="last7Days",()=>Xc(Vi(7))],[()=>e==="last30Days",()=>Xc(Vi(30))],[()=>e==="last90Days",()=>Xc(Vi(90))],[()=>e==="last180Days",()=>Xc(Vi(180))],[()=>e==="last365Days",()=>Xc(Vi(365))]].find(([r])=>r()))==null?void 0:t[1]())??{}},vTe=e=>{var t;const r=vi(e);return((t=[[()=>su(Fu(gl()),r),"today"],[()=>su(Vi(1),r),"yesterday"],[()=>su(Vi(7),r),"last7Days"],[()=>su(Vi(30),r),"last30Days"],[()=>su(Vi(90),r),"last90Days"],[()=>su(Vi(180),r),"last180Days"],[()=>su(Vi(365),r),"last365Days"]].find(([n])=>n()))==null?void 0:t[1])??o_},WV=e=>B0(e)?VV(e):e,qV=e=>!!(e&&e.startDate),gTe=({startDate:e,endDate:t})=>{const r=Q7(jf(t??new Date),Fu(e))+1,n=Ny(Fu(e),r),i=Ny(jf(e),1);return{startDate:n,endDate:i}},yTe=e=>{if(qV(e))return Q7(e.endDate??new Date,e.startDate)},bTe=({active:e,allText:t,onChange:r})=>v.jsxs(v.Fragment,{children:[v.jsx(Ze,{active:e==="all",onClick:()=>r("all"),children:t}),v.jsx(Ze,{divider:!0,tag:"hr"}),pTe.map(n=>v.jsx(Ze,{active:e===n,onClick:()=>r(n),children:zV(n)},n))]}),_Te=({startDate:e,endDate:t,disabled:r=!1,onStartDateChange:n,onEndDateChange:i})=>v.jsxs("div",{className:"row",children:[v.jsx("div",{className:"col-md-6",children:v.jsx(F0,{label:"Since",value:e,maxDate:t??void 0,disabled:r,onChange:n})}),v.jsx("div",{className:"col-md-6 mt-3 mt-md-0",children:v.jsx(F0,{label:"Until",value:t,minDate:e??void 0,disabled:r,onChange:a=>i(a&&jf(a))})})]}),DA=({onDatesChange:e,dateRangeOrInterval:t,defaultText:r,disabled:n})=>{const i=M.useMemo(()=>zV(t)??r,[t,r]),[a,o]=M.useMemo(()=>B0(t)?[void 0,t]:[t,void 0],[t]),s=M.useCallback(c=>{B0(c)?e(VV(c),c):e(c)},[e]);return v.jsxs(os,{disabled:n,text:i,children:[v.jsx(bTe,{allText:r,active:o,onChange:s}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx("div",{className:"px-3 py-1",children:v.jsx(_Te,{...a,onStartDateChange:c=>s({...a,startDate:c}),onEndDateChange:c=>s({...a,endDate:c})})})]})},wTe={dateCreated:"Created at",shortCode:"Short URL",longUrl:"Long URL",title:"Title",visits:"Visits"},xTe=({onChange:e,selected:t={},className:r,domains:n})=>{const i=Ca("filterShortUrlsByDomain"),{excludeBots:a=!1,excludeMaxVisitsReached:o=!1,excludePastValidUntil:s=!1,domain:c}=t,l=M.useCallback(p=>e({...t,...p}),[e,t]),h=M.useCallback(p=>l({[p]:!(t!=null&&t[p])}),[l,t]);return v.jsxs(os,{text:"Filters",dropdownClassName:r,end:!0,minWidth:250,children:[v.jsx(Ze,{header:!0,"aria-hidden":!0,children:"Visits:"}),v.jsx(Ze,{active:a,onClick:()=>h("excludeBots"),children:"Ignore visits from bots"}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{header:!0,"aria-hidden":!0,children:"Short URLs:"}),v.jsx(Ze,{active:o,onClick:()=>h("excludeMaxVisitsReached"),children:"Exclude with visits reached"}),v.jsx(Ze,{active:s,onClick:()=>h("excludePastValidUntil"),children:"Exclude enabled in the past"}),i&&v.jsxs(v.Fragment,{children:[v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{header:!0,"aria-hidden":!0,children:["Domain: ",!n&&v.jsx("i",{children:"loading..."})]}),n==null?void 0:n.map(p=>{const g=p.isDefault?ad:p.domain,_=c===g;return v.jsx(Ze,{active:_,onClick:()=>l({domain:_?void 0:g}),children:p.domain},p.domain)})]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{disabled:t.excludeBots===void 0&&t.excludeMaxVisitsReached===void 0&&t.excludePastValidUntil===void 0&&t.domain===void 0,onClick:()=>e({excludeBots:void 0,excludeMaxVisitsReached:void 0,excludePastValidUntil:void 0,domain:void 0}),className:"fst-italic",children:"Reset to defaults"})]})},HV=({className:e,shortUrlsAmount:t,order:r,handleOrderBy:n,tagsList:i,domainsList:a})=>{const{ExportShortUrlsBtn:o,TagsSelector:s}=ur(HV),[{search:c,tags:l,startDate:h,endDate:p,excludeBots:g,excludeMaxVisitsReached:_,excludePastValidUntil:b,domain:w,tagsMode:x="any"},S]=n_(),C=Nn("visits"),[P,T]=M.useState(),A=M.useCallback(({startDate:U,endDate:B},W)=>{S({startDate:yl(U)??void 0,endDate:yl(B)??void 0}),T(W)},[S]),j=M.useCallback(U=>S({search:U||void 0}),[S]),N=M.useCallback(U=>S({tags:U}),[S]),$=M.useCallback(()=>S({tagsMode:x==="any"?"all":"any"}),[x,S]);return v.jsxs("div",{className:Te("short-urls-filtering-bar-container",e),children:[v.jsx(ob,{initialValue:c,onChange:j}),v.jsxs(Om,{className:"mt-3",children:[v.jsx(s,{immutable:!0,placeholder:"With tags...",tags:i.tags,selectedTags:l,onChange:N}),l.length>1&&v.jsxs(v.Fragment,{children:[v.jsx(Lt,{outline:!0,color:"secondary",onClick:$,id:"tagsModeBtn","aria-label":"Change tags mode",children:v.jsx(He,{className:"short-urls-filtering-bar__tags-icon",icon:x==="all"?F$:TY})}),v.jsx(Oi,{target:"tagsModeBtn",placement:"left",children:x==="all"?"With all the tags.":"With any of the tags."})]})]}),v.jsxs(Za,{className:"flex-lg-row-reverse",children:[v.jsx("div",{className:"col-lg-8 col-xl-6 mt-3",children:v.jsxs("div",{className:"d-md-flex",children:[v.jsx("div",{className:"flex-grow-1",children:v.jsx(DA,{defaultText:"All short URLs",dateRangeOrInterval:P??UV(h,p),onDatesChange:A})}),v.jsx(xTe,{className:"ms-0 ms-md-2 mt-3 mt-md-0",selected:{excludeBots:g??(C==null?void 0:C.excludeBots),excludeMaxVisitsReached:_,excludePastValidUntil:b,domain:w},onChange:S,domains:a.loading?void 0:a.domains})]})}),v.jsx("div",{className:"col-6 col-lg-4 col-xl-6 mt-3",children:v.jsx(o,{amount:t})}),v.jsx("div",{className:"col-6 d-lg-none mt-3",children:v.jsx(Em,{prefixed:!1,items:wTe,order:r,onChange:n})})]})]})},STe=cr(HV,["ExportShortUrlsBtn","TagsSelector"]);function pp({currentOrder:e,field:t,className:r="ms-1"}){return!e.dir||e.field!==t?null:v.jsx(He,{icon:e.dir==="ASC"?bY:RY,className:r})}const Qc=2,QE="...",GV=(e,t)=>{const r=sj(Math.max(Qc,e-Qc),Math.min(t-1,e+Qc)+1);return e-Qc>Qc&&r.unshift(QE),e+Qce===QE,KV=e=>pm(e)?e:Or(e),YV=(e,t)=>pm(e)?`${e}_${t}`:`${e}`,OTe=({paginator:e,currentQueryString:t=""})=>{const{currentPage:r=0,pagesCount:n=0}=e??{},i=jl(),a=s=>`${i}/list-short-urls/${s}${t}`;if(n<=1)return v.jsx("div",{className:"pb-3"});const o=()=>GV(r,n).map((s,c)=>v.jsx(Pu,{disabled:pm(s),active:r===s,children:v.jsx(Eu,{tag:Xt,to:a(s),children:KV(s)})},YV(s,c)));return v.jsxs(QT,{className:"sticky-card-paginator py-3",listClassName:"flex-wrap justify-content-center mb-0",children:[v.jsx(Pu,{disabled:r===1,children:v.jsx(Eu,{previous:!0,tag:Xt,to:a(r-1)})}),o(),v.jsx(Pu,{disabled:r>=n,children:v.jsx(Eu,{next:!0,tag:Xt,to:a(r+1)})})]})},CTe={field:"dateCreated",dir:"DESC"},ZV=ka(({listShortUrls:e,shortUrlsList:t})=>{var r,n,i;const{ShortUrlsTable:a,ShortUrlsFilteringBar:o}=ur(ZV),{page:s}=cd(),c=bn(),[{tags:l,search:h,startDate:p,endDate:g,orderBy:_,tagsMode:b,excludeBots:w,excludePastValidUntil:x,excludeMaxVisitsReached:S,domain:C},P]=n_(),T=lj(),[A,j]=M.useState(_??((r=T.shortUrlsList)==null?void 0:r.defaultOrdering)??CTe),{pagination:N}=(t==null?void 0:t.shortUrls)??{},$=M.useMemo(()=>{var re;return w??((re=T.visits)==null?void 0:re.excludeBots)},[w,(n=T.visits)==null?void 0:n.excludeBots]),U=M.useCallback((re,oe)=>{P({orderBy:{field:re,dir:oe}}),j({field:re,dir:oe})},[P]),B=re=>()=>U(re,Pm(re,A.field,A.dir)),W=re=>v.jsx(pp,{currentOrder:A,field:re}),q=M.useCallback(re=>P({tags:[...new Set([...l,re])]}),[l,P]),J=M.useCallback(({field:re,dir:oe})=>$&&re==="visits"?{field:"nonBotVisits",dir:oe}:{field:re,dir:oe},[$]),Q=SA();return M.useEffect(()=>{e({page:s,searchTerm:h,tags:l,startDate:p,endDate:g,orderBy:J(A),tagsMode:b,excludePastValidUntil:x,excludeMaxVisitsReached:S,domain:C})},[e,J,s,h,l,p,g,A,b,x,S,C]),v.jsxs(xA,{value:Q,children:[v.jsx(o,{shortUrlsAmount:(i=t.shortUrls)==null?void 0:i.pagination.totalItems,order:A,handleOrderBy:U,className:"mb-3"}),v.jsx(OA,{type:"short-urls",className:"mb-3"}),v.jsxs(Qi,{body:!0,className:Te({"pb-0":!t.loading}),children:[v.jsx(a,{shortUrlsList:t,orderByColumn:B,renderOrderIcon:W,onTagClick:q}),!t.loading&&v.jsx(OTe,{paginator:N,currentQueryString:c.search})]})]})},()=>[Rn.visits]),PTe=cr(ZV,["ShortUrlsTable","ShortUrlsFilteringBar"]),ETe=({shortUrlsList:e,onTagClick:t,ShortUrlsRow:r})=>{const{error:n,loading:i,shortUrls:a}=e;return n?v.jsx("tr",{children:v.jsx("td",{colSpan:6,className:"text-center table-danger text-dark",children:"Something went wrong while loading short URLs :("})}):i?v.jsx("tr",{children:v.jsx("td",{colSpan:6,className:"text-center",children:"Loading..."})}):!i&&(!a||a.data.length===0)?v.jsx("tr",{children:v.jsx("td",{colSpan:6,className:"text-center",children:"No results found"})}):a==null?void 0:a.data.map(o=>v.jsx(r,{shortUrl:o,onTagClick:t},o.shortUrl))},XV=({orderByColumn:e,renderOrderIcon:t,shortUrlsList:r,onTagClick:n,className:i})=>{const{ShortUrlsRow:a}=ur(XV),o=Te({"short-urls-table__header-cell--with-action":!!e}),s=Te("short-urls-table__header-cell",o),c=Te("table table-hover responsive-table short-urls-table",i);return v.jsxs("table",{className:c,children:[v.jsx("thead",{className:"responsive-table__header short-urls-table__header",children:v.jsxs("tr",{children:[v.jsxs("th",{className:s,onClick:e==null?void 0:e("dateCreated"),children:["Created at ",t==null?void 0:t("dateCreated")]}),v.jsxs("th",{className:s,onClick:e==null?void 0:e("shortCode"),children:["Short URL ",t==null?void 0:t("shortCode")]}),v.jsxs("th",{className:"short-urls-table__header-cell",children:[v.jsxs(Wu,{className:Te("p-0",o),onClick:e==null?void 0:e("title"),children:["Title ",t==null?void 0:t("title")]}),"  /  ",v.jsxs(Wu,{className:Te("p-0",o),onClick:e==null?void 0:e("longUrl"),children:[v.jsx("span",{className:"indivisible",children:"Long URL"})," ",t==null?void 0:t("longUrl")]})]}),v.jsx("th",{className:"short-urls-table__header-cell",children:"Tags"}),v.jsx("th",{className:s,onClick:e==null?void 0:e("visits"),children:v.jsxs("span",{className:"indivisible",children:["Visits ",t==null?void 0:t("visits")]})}),v.jsx("th",{className:"short-urls-table__header-cell",colSpan:2,"aria-hidden":!0})]})}),v.jsx("tbody",{children:v.jsx(ETe,{ShortUrlsRow:a,shortUrlsList:r,onTagClick:n})})]})},TTe=cr(XV,["ShortUrlsRow"]),jTe=(e,t)=>{e.factory("ShortUrlsList",PTe),e.decorator("ShortUrlsList",t(["mercureInfo","shortUrlsList"],["listShortUrls","createNewVisits","loadMercureInfo"])),e.factory("ShortUrlsTable",TTe),e.factory("ShortUrlsRow",JEe),e.factory("CreateShortUrlResult",MEe),e.factory("ShortUrlsRowMenu",eTe),e.decorator("ShortUrlsRowMenu",t(null,["shortUrlDeleted","deleteShortUrl"])),e.factory("ShortUrlForm",dTe),e.decorator("ShortUrlForm",t(["tagsList","domainsList"])),e.factory("CreateShortUrl",REe),e.decorator("CreateShortUrl",t(["shortUrlCreation"],["createShortUrl","resetCreateShortUrl"])),e.factory("EditShortUrl",NEe),e.decorator("EditShortUrl",t(["shortUrlsDetails","shortUrlEdition"],["getShortUrlsDetails","editShortUrl"])),e.serviceFactory("DeleteShortUrlModal",()=>LEe),e.decorator("DeleteShortUrlModal",t(["shortUrlDeletion"],["resetDeleteShortUrl"])),e.factory("QrCodeModal",qEe),e.factory("ExportShortUrlsBtn",IEe),e.factory("ShortUrlsFilteringBar",STe),e.decorator("ShortUrlsFilteringBar",t(["tagsList","domainsList"])),e.serviceFactory("shortUrlsListReducerCreator",nPe,"listShortUrls","editShortUrl","createShortUrl"),e.serviceFactory("shortUrlsListReducer",r=>r.reducer,"shortUrlsListReducerCreator"),e.serviceFactory("shortUrlCreationReducerCreator",rTe,"createShortUrl"),e.serviceFactory("shortUrlCreationReducer",r=>r.reducer,"shortUrlCreationReducerCreator"),e.serviceFactory("shortUrlEditionReducerCreator",aTe,"editShortUrl"),e.serviceFactory("shortUrlEditionReducer",r=>r.reducer,"shortUrlEditionReducerCreator"),e.serviceFactory("shortUrlDeletionReducerCreator",ePe,"deleteShortUrl"),e.serviceFactory("shortUrlDeletionReducer",r=>r.reducer,"shortUrlDeletionReducerCreator"),e.serviceFactory("shortUrlsDetailsReducerCreator",oTe,"apiClientFactory"),e.serviceFactory("shortUrlsDetailsReducer",r=>r.reducer,"shortUrlsDetailsReducerCreator"),e.serviceFactory("listShortUrls",rPe,"apiClientFactory"),e.serviceFactory("createShortUrl",tTe,"apiClientFactory"),e.serviceFactory("resetCreateShortUrl",r=>r.resetCreateShortUrl,"shortUrlCreationReducerCreator"),e.serviceFactory("deleteShortUrl",JCe,"apiClientFactory"),e.serviceFactory("resetDeleteShortUrl",r=>r.resetDeleteShortUrl,"shortUrlDeletionReducerCreator"),e.serviceFactory("shortUrlDeleted",()=>tV),e.serviceFactory("getShortUrlsDetails",r=>r.getShortUrlsDetails,"shortUrlsDetailsReducerCreator"),e.serviceFactory("editShortUrl",iTe,"apiClientFactory")},ATe=({tag:e,toggle:t,isOpen:r,deleteTag:n,tagDelete:i,tagDeleted:a})=>{const{deleting:o,error:s,deleted:c,errorData:l}=i;return v.jsxs(Ji,{toggle:t,isOpen:r,centered:!0,onClosed:()=>c&&a(e),children:[v.jsx(Sl,{toggle:t,className:"text-danger",children:"Delete tag"}),v.jsxs(as,{children:["Are you sure you want to delete tag ",v.jsx("b",{children:e}),"?",s&&v.jsx(gi,{type:"error",small:!0,className:"mt-2",children:v.jsx(uo,{errorData:l,fallbackMessage:"Something went wrong while deleting the tag :("})})]}),v.jsxs(Hu,{children:[v.jsx(Lt,{color:"link",onClick:t,children:"Cancel"}),v.jsx(Lt,{color:"danger",disabled:o,onClick:async()=>{await n(e),t()},children:o?"Deleting tag...":"Delete tag"})]})]})},QV=({tag:e,editTag:t,toggle:r,tagEdited:n,isOpen:i,tagEdit:a})=>{const{ColorGenerator:o}=ur(QV),[s,c]=M.useState(e),[l,h]=M.useState(o.getColorForKey(e)),{editing:p,error:g,edited:_,errorData:b}=a,w=Qz(async()=>{await t({oldName:e,newName:s,color:l}),r()}),x=M.useCallback(()=>_&&n({oldName:e,newName:s,color:l}),[l,_,s,e,n]);return v.jsx(Ji,{isOpen:i,toggle:r,centered:!0,onClosed:x,children:v.jsxs("form",{name:"editTag",onSubmit:w,children:[v.jsx(Sl,{toggle:r,children:"Edit tag"}),v.jsxs(as,{children:[v.jsxs(Om,{children:[v.jsx(AV,{color:l,onChange:h,className:"input-group-text",name:"tag-color"}),v.jsx(Zr,{value:s,placeholder:"Tag",required:!0,onChange:({target:S})=>c(S.value)})]}),g&&v.jsx(gi,{type:"error",small:!0,className:"mt-2",children:v.jsx(uo,{errorData:b,fallbackMessage:"Something went wrong while editing the tag :("})})]}),v.jsxs(Hu,{children:[v.jsx(Lt,{type:"button",color:"link",onClick:r,children:"Cancel"}),v.jsx(Lt,{color:"primary",disabled:p,children:p?"Saving...":"Save"})]})]})})},kTe=cr(QV,["ColorGenerator"]),RTe=/\s+/g,JV=e=>e.trim().toLowerCase().replace(RTe,"-"),eW=({color:e})=>v.jsx("div",{style:{backgroundColor:e},className:"color-bullet"}),tW=({tag:e,colorGenerator:t})=>v.jsx(eW,{color:t.getColorForKey(e)});let T8=1;const rW="Tag not found",nW="Add tag",NTe=e=>e!==rW,MTe=e=>e===nW,j8=e=>(T8+=1,{label:e,value:`${e}${T8}`}),LTe=e=>({tag:t,onClick:r})=>v.jsx(a_,{colorGenerator:e,text:t.label,className:"react-tags__tag",onClose:r}),ITe=(e,t)=>({option:r,classNames:n,...i})=>{var a;const o=NTe(r.label),s=MTe(r.label);return v.jsx("div",{className:Te(n.option,{[n.optionIsActive]:o&&r.active,"react-tags__listbox-option--not-selectable":!o}),...i,children:o?v.jsxs(v.Fragment,{children:[!s&&v.jsx(tW,{tag:`${r.label}`,colorGenerator:e}),s?v.jsxs("i",{children:['Add "',JV(((a=t.current)==null?void 0:a.input.value)??""),'"']}):r.label]}):v.jsx("i",{children:r.label})})},iW=({selectedTags:e,onChange:t,placeholder:r,tags:n,immutable:i=!1})=>{const{ColorGenerator:a}=ur(iW),o=Nn("shortUrlCreation"),s=(o==null?void 0:o.tagFilteringMode)??"startsWith",c=_i();return v.jsx(Fue,{ref:c,selected:e.map(j8),suggestions:n.filter(l=>!e.includes(l)).map(j8),renderTag:LTe(a),renderOption:ITe(a,c),activateFirstOption:!0,allowNew:!i,newOptionText:nW,noOptionsText:rW,placeholderText:r??"Add tags to the URL",delimiterKeys:["Enter",","],suggestionsTransform:(l,h)=>{const p=l.toLowerCase().trim();return p.length<1?[]:[...h.filter(({label:g})=>s==="includes"?g.includes(p):g.startsWith(p))].slice(0,5)},onDelete:l=>{const h=[...e];h.splice(l,1),t(h)},onAdd:({label:l})=>t([...new Set([...e,...l.split(",").map(JV)])])})},DTe=cr(iW,["ColorGenerator"]),JE="shlink/tagDelete",$Te={deleting:!1,deleted:!1,error:!1},aW=An(`${JE}/tagDeleted`),FTe=e=>{const t=Vr(`${JE}/deleteTag`,async n=>{await e().deleteTags([n])}),{reducer:r}=Tr({name:JE,initialState:$Te,reducers:{},extraReducers:n=>{n.addCase(t.pending,()=>({deleting:!0,deleted:!1,error:!1})),n.addCase(t.rejected,(i,{error:a})=>({deleting:!1,deleted:!1,error:!0,errorData:Ci(a)})),n.addCase(t.fulfilled,()=>({deleting:!1,deleted:!0,error:!1}))}});return{reducer:r,deleteTag:t}},$A="shlink/tagEdit",BTe={editing:!1,edited:!1,error:!1},oW=An(`${$A}/tagEdited`),UTe=(e,t)=>Vr(`${$A}/editTag`,async({oldName:r,newName:n,color:i})=>(await e().editTag({oldName:r,newName:n}),t.setColorForKey(n,i),{oldName:r,newName:n,color:i})),zTe=e=>Tr({name:$A,initialState:BTe,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({editing:!0,edited:!1,error:!1})),t.addCase(e.rejected,(r,{error:n})=>({editing:!1,edited:!1,error:!0,errorData:Ci(n)})),t.addCase(e.fulfilled,(r,{payload:n})=>{const{oldName:i,newName:a}=n;return{oldName:i,newName:a,editing:!1,edited:!0,error:!1}})}}),FA="shlink/tagsList",xO={tags:[],filteredTags:[],stats:{},loading:!1,error:!1},A8=(e,t)=>r=>r===e?t:r,k8=(e,t)=>e.filter(r=>r!==t),VTe=(e,t)=>e.reduce((r,[n,i])=>{if(!r[n])return r;const{bots:a,nonBots:o}=i,s=r[n];return{...r,[n]:{...s,visitsSummary:s.visitsSummary&&{total:s.visitsSummary.total+a+o,bots:s.visitsSummary.bots+a,nonBots:s.visitsSummary.nonBots+o},visitsCount:(s.visitsCount??0)+a+o}}},{...t}),WTe=e=>Object.entries(e.reduce((t,{shortUrl:r,visit:n})=>(r==null||r.tags.forEach(i=>{t[i]||(t[i]={bots:0,nonBots:0}),n.potentialBot?t[i].bots+=1:t[i].nonBots+=1}),t),{})),qTe=e=>Vr(`${FA}/listTags`,async()=>{const{data:t}=await e().tagsStats(),r=t.reduce((n,{tag:i,...a})=>(n[i]=a,n),{});return{tags:Object.keys(r),stats:r}}),sW=An(`${FA}/filterTags`),HTe=(e,t)=>Tr({name:FA,initialState:xO,reducers:{},extraReducers:r=>{r.addCase(sW,(n,{payload:i})=>({...n,filteredTags:n.tags.filter(a=>a.toLowerCase().match(i.toLowerCase()))})),r.addCase(e.pending,n=>({...n,loading:!0,error:!1})),r.addCase(e.rejected,(n,{error:i})=>({...xO,error:!0,errorData:Ci(i)})),r.addCase(e.fulfilled,(n,{payload:i})=>({...xO,stats:i.stats,tags:i.tags,filteredTags:i.tags})),r.addCase(aW,({tags:n,filteredTags:i,...a},{payload:o})=>({...a,tags:k8(n,o),filteredTags:k8(i,o)})),r.addCase(oW,({tags:n,filteredTags:i,stats:a,...o},{payload:s})=>({...o,stats:{...a,[s.newName]:a[s.oldName]},tags:n.map(A8(s.oldName,s.newName)).sort(),filteredTags:i.map(A8(s.oldName,s.newName)).sort()})),r.addCase(Ed,(n,{payload:i})=>({...n,stats:VTe(WTe(i.createdVisits),n.stats)})),r.addCase(t.fulfilled,({tags:n,...i},{payload:a})=>({...i,tags:n.concat(a.tags.filter(o=>!n.includes(o)))}))}}),GTe={tag:"Tag",shortUrls:"Short URLs",visits:"Visits"},lW=ka(({filterTags:e,tagsList:t})=>{var r,n;const{TagsTable:i}=ur(lW),a=lj(),[o,s]=M.useState(((r=a.tags)==null?void 0:r.defaultOrdering)??{}),c=M.useMemo(()=>{const h=t.filteredTags.map(p=>{var g,_,b;const w=t.stats[p],x=((g=a.visits)!=null&&g.excludeBots?(_=w==null?void 0:w.visitsSummary)==null?void 0:_.nonBots:(b=w==null?void 0:w.visitsSummary)==null?void 0:b.total)??(w==null?void 0:w.visitsCount)??0;return{tag:p,visits:x,shortUrls:(w==null?void 0:w.shortUrlsCount)??0}});return v7(h,o)},[o,(n=a.visits)==null?void 0:n.excludeBots,t.filteredTags,t.stats]),l=SA();return t.loading?v.jsx(Lu,{loading:!0}):t.error?v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:t.errorData,fallbackMessage:"Error loading tags :("})}):v.jsxs(xA,{value:l,children:[v.jsx(ob,{className:"mb-3",onChange:e}),v.jsx(Za,{className:"mb-3",children:v.jsx("div",{className:"col-lg-6 offset-lg-6",children:v.jsx(Em,{items:GTe,order:o,onChange:(h,p)=>s({field:h,dir:p})})})}),v.jsx(OA,{type:"tags",className:"mb-3"}),v.jsx(i,{sortedTags:c,currentOrder:o,orderByColumn:h=>()=>{const p=Pm(h,o.field,o.dir);s({field:p?h:void 0,dir:p})}})]})},()=>[Rn.visits]),KTe=cr(lW,["TagsTable"]),BA=({pagesCount:e,currentPage:t,onPageChange:r,centered:n=!0})=>{const i=M.useCallback(a=>!pm(a)&&r(a),[r]);return e<2?null:v.jsxs(QT,{listClassName:Te("flex-wrap mb-0 simple-paginator",{"justify-content-center":n}),children:[v.jsx(Pu,{disabled:t<=1,children:v.jsx(Eu,{previous:!0,tag:"span",onClick:()=>i(t-1)})}),GV(t,e).map((a,o)=>v.jsx(Pu,{disabled:pm(a),active:t===a,children:v.jsx(Eu,{role:"link",tag:"span",onClick:()=>i(a),children:KV(a)})},YV(a,o))),v.jsx(Pu,{disabled:t>=e,children:v.jsx(Eu,{next:!0,tag:"span",onClick:()=>i(t+1)})})]})},YTe=20,uW=({sortedTags:e,orderByColumn:t,currentOrder:r})=>{const{TagsTableRow:n}=ur(uW),i=M.useRef(!0),{page:a=1}=hd(),[o,s]=ICe("page",Number(a)),c=M.useCallback(g=>{s(g),scrollTo(0,0)},[s]),l=pf(e,YTe),h=l.length>1,p=l[o-1]??[];return M.useEffect(()=>{i.current||c(1),i.current=!1},[c,e]),v.jsxs(Sr,{bodyClassName:h?"pb-1":"",children:[v.jsxs("table",{className:"table table-hover responsive-table mb-0",children:[v.jsxs("thead",{className:"responsive-table__header",children:[v.jsxs("tr",{children:[v.jsxs("th",{className:"tags-table__header-cell",onClick:t("tag"),children:["Tag ",v.jsx(pp,{currentOrder:r,field:"tag"})]}),v.jsxs("th",{className:"tags-table__header-cell text-lg-end",onClick:t("shortUrls"),children:["Short URLs ",v.jsx(pp,{currentOrder:r,field:"shortUrls"})]}),v.jsxs("th",{className:"tags-table__header-cell text-lg-end",onClick:t("visits"),children:["Visits ",v.jsx(pp,{currentOrder:r,field:"visits"})]}),v.jsx("th",{className:"tags-table__header-cell",children:v.jsx("span",{className:"sr-only",children:"Options"})})]}),v.jsx("tr",{children:v.jsx("th",{"aria-hidden":!0,colSpan:4,className:"p-0 border-top-0"})})]}),v.jsxs("tbody",{children:[p.length===0&&v.jsx("tr",{children:v.jsx("td",{colSpan:4,className:"text-center",children:"No tags found"})}),p.map(g=>v.jsx(n,{tag:g},g.tag))]})]}),h&&v.jsx("div",{className:"sticky-card-paginator",children:v.jsx(BA,{pagesCount:l.length,currentPage:o,onPageChange:c})})]},o)},ZTe=cr(uW,["TagsTableRow"]),cW=({tag:e})=>{const{DeleteTagConfirmModal:t,EditTagModal:r,ColorGenerator:n}=ur(cW),[i,a]=ir(),[o,s]=ir(),c=jl(),l=Jb();return v.jsxs("tr",{className:"responsive-table__row",children:[v.jsxs("th",{className:"responsive-table__cell","data-th":"Tag",children:[v.jsx(tW,{tag:e.tag,colorGenerator:n})," ",e.tag]}),v.jsx("td",{className:"responsive-table__cell text-lg-end","data-th":"Short URLs",children:v.jsx(Xt,{to:`${c}/list-short-urls/1?tags=${encodeURIComponent(e.tag)}`,children:Or(e.shortUrls)})}),v.jsx("td",{className:"responsive-table__cell text-lg-end","data-th":"Visits",children:v.jsx(Xt,{to:`${c}/tag/${e.tag}/visits`,children:Or(e.visits)})}),v.jsx("td",{className:"responsive-table__cell text-lg-end",children:v.jsxs(lb,{children:[v.jsxs(Ze,{onClick:s,children:[v.jsx(He,{icon:$$,fixedWidth:!0,className:"me-1"})," Edit"]}),v.jsxs(Ze,{disabled:!l||!l.canAddItemWithName(e.tag),onClick:()=>l==null?void 0:l.addItemToCompare({name:e.tag,query:e.tag,style:n.stylesForKey(e.tag)}),children:[v.jsx(He,{icon:X0,fixedWidth:!0})," Compare visits"]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{className:"dropdown-item--danger",onClick:a,children:[v.jsx(He,{icon:OY,fixedWidth:!0,className:"me-1"})," Delete tag"]})]})}),v.jsx(r,{tag:e.tag,toggle:s,isOpen:o}),v.jsx(t,{tag:e.tag,toggle:a,isOpen:i})]})},XTe=cr(cW,["DeleteTagConfirmModal","EditTagModal","ColorGenerator"]),QTe=(e,t)=>{e.factory("TagsSelector",DTe),e.serviceFactory("DeleteTagConfirmModal",()=>ATe),e.decorator("DeleteTagConfirmModal",t(["tagDelete"],["deleteTag","tagDeleted"])),e.factory("EditTagModal",kTe),e.decorator("EditTagModal",t(["tagEdit"],["editTag","tagEdited"])),e.factory("TagsTableRow",XTe),e.factory("TagsTable",ZTe),e.factory("TagsList",KTe),e.decorator("TagsList",t(["tagsList","mercureInfo"],["filterTags","createNewVisits","loadMercureInfo"])),e.serviceFactory("tagEditReducerCreator",zTe,"editTag"),e.serviceFactory("tagEditReducer",r=>r.reducer,"tagEditReducerCreator"),e.serviceFactory("tagDeleteReducerCreator",FTe,"apiClientFactory"),e.serviceFactory("tagDeleteReducer",r=>r.reducer,"tagDeleteReducerCreator"),e.serviceFactory("tagsListReducerCreator",HTe,"listTags","createShortUrl"),e.serviceFactory("tagsListReducer",r=>r.reducer,"tagsListReducerCreator"),e.serviceFactory("listTags",qTe,"apiClientFactory"),e.serviceFactory("filterTags",()=>sW),e.serviceFactory("deleteTag",r=>r.deleteTag,"tagDeleteReducerCreator"),e.serviceFactory("tagDeleted",()=>aW),e.serviceFactory("editTag",UTe,"apiClientFactory","ColorGenerator"),e.serviceFactory("tagEdited",()=>oW)},JTe=new cB,eje=e=>JTe.parse(e),R8=e=>e.toLowerCase().trim();class tje{constructor(t){ll(this,"colors"),ll(this,"lights");var r;this.storage=t,this.colors=((r=this.storage)==null?void 0:r.getTagColors())??{},this.lights={}}getColorForKey(t){const r=R8(t);return this.colors[r]||this.setColorForKey(r,BEe())}setColorForKey(t,r){var n;const i=R8(t);return this.colors[i]=r,(n=this.storage)==null||n.storeTagColors(this.colors),r}stylesForKey(t){const r=this.getColorForKey(t);return{backgroundColor:r,color:this.isLightColor(r)?"#222":"#fff"}}isLightColor(t){const r=t.substring(1);return this.lights[r]===void 0&&(this.lights[r]=jV(r)),this.lights[r]}}const fW=({document:e},t,r)=>{const n=e.createElement("a");n.setAttribute("href",t),n.setAttribute("download",r),n.style.visibility="hidden",e.body.appendChild(n),n.click(),e.body.removeChild(n)},rje=(e,t,r)=>{const n=new Blob([t],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(n);fW(e,i,r)};class nje{constructor(t,r){this.fetch=t,this.window=r}async saveImage(t,r){const n=await this.fetch(t).then(a=>a.blob()),i=URL.createObjectURL(n);fW(this.window,i,r)}}class ije{constructor(t,r){ll(this,"exportVisits",(n,i)=>{i.length&&this.exportCsv(n,i)}),ll(this,"exportShortUrls",n=>{n.length&&this.exportCsv("short_urls.csv",n)}),ll(this,"exportCsv",(n,i)=>{const a=this.jsonToCsv(i);rje(this.window,a,n)}),this.window=t,this.jsonToCsv=r}}function aje(e){e.constant("window",window),e.constant("fetch",window.fetch.bind(window)),e.service("ImageDownloader",nje,"fetch","window"),e.service("ColorGenerator",tje,"TagColorsStorage"),e.constant("jsonToCsv",eje),e.service("ReportExporter",ije,"window","jsonToCsv"),e.serviceFactory("useTimeoutToggle",()=>p7)}const zm=({visits:e,shortUrl:t,children:r,title:n})=>v.jsx("header",{children:v.jsxs(Qi,{body:!0,children:[v.jsxs("h2",{className:"d-flex justify-content-between align-items-center mb-0",children:[v.jsx(i_,{}),v.jsx("span",{className:"text-center d-none d-sm-block",children:v.jsx("small",{children:n})}),v.jsxs("span",{className:"badge badge-main ms-3",children:["Visits:"," ",v.jsx(NV,{visitsCount:e.length,shortUrl:t})]})]}),v.jsx("h3",{className:"text-center d-block d-sm-none mb-0 mt-3",children:v.jsx("small",{children:n})}),r&&v.jsx("div",{className:"mt-md-2",children:r})]})}),s_=({children:e,className:t})=>v.jsx("div",{className:Te("d-flex justify-content-between align-items-center",t),children:e}),dW=({title:e,footer:t,children:r})=>v.jsxs(Qi,{role:"document",children:[v.jsx(Sm,{className:"chart-card__header",children:e}),v.jsx(xm,{children:r}),t&&v.jsx(e7,{className:"chart-card__footer--sticky",children:t})]}),hW=M.createContext(null),{Provider:Dke}=hW,UA=e=>{const t=M.useContext(hW)??void 0,r=M.useMemo(()=>t?{}:{width:"100%",height:e},[e,t]);return{ChartWrapper:t?M.Fragment:Cpe,dimensions:t,wrapperDimensions:r}},pW={color:"white",background:"rgb(0 0 0 / .9)",border:"none",borderRadius:"5px"},oje={marginBottom:"5px",fontWeight:"bold"},mW={contentStyle:pW,labelStyle:oje,itemStyle:{padding:0}},N8=["#97BBCD","#F7464A","#46BFBD","#FDB45C","#949FB1","#57A773","#414066","#08B2E3","#B6C454","#DCDCDC","#463730"],vW=e=>N8[e%N8.length],U0=()=>Tm()?"#46e587":"#1DAA58",sje=()=>Tm()?"rgba(70, 229, 135, 0.4)":"rgba(29, 170, 88, 0.4)",lje=({chartData:e,showNumbers:t})=>v.jsx("ul",{className:"doughnut-chart-legend",children:e.map(({name:r,color:n,value:i})=>v.jsxs("li",{className:"doughnut-chart-legend__item d-flex",children:[v.jsx("div",{className:"doughnut-chart-legend__item-color",style:{backgroundColor:n}}),v.jsxs("small",{className:"doughnut-chart-legend__item-text flex-fill",children:[r,t&&v.jsxs("b",{children:[" (",Or(i),")"]})]})]},r))}),M8=e=>M.useMemo(()=>Object.entries(e).map(([t,r],n)=>({name:t,value:r,color:vW(n)})),[e]),uje=({stats:e,prevStats:t,showNumbersInLegend:r})=>{const n=M8(e),i=M8(t),a=i.length>0,o=Tm()?nae:rae,{ChartWrapper:s,dimensions:c,wrapperDimensions:l}=UA(300);return v.jsxs("div",{className:"row align-items-center",children:[v.jsx("div",{className:"col-sm-12 col-md-7",children:v.jsx("div",{style:l,children:v.jsx(s,{children:v.jsxs(YOe,{...c,children:[v.jsx(zi,{formatter:Or,contentStyle:pW,itemStyle:{color:"white"}}),v.jsx(lo,{data:n,dataKey:"value",nameKey:"name",startAngle:360,endAngle:0,outerRadius:"100%",innerRadius:a?"65%":"50%",animationBegin:0,children:n.map((h,p)=>v.jsx(al,{fill:h.color,stroke:o},`${h.name}-${p}`))}),a&&v.jsx(lo,{data:i,dataKey:"value",nameKey:"name",startAngle:360,endAngle:0,outerRadius:"55%",innerRadius:"20%",animationBegin:0,stroke:o,fill:U0()})]})})})}),v.jsx("div",{className:"col-sm-12 col-md-5",children:v.jsx(lje,{chartData:n,showNumbers:r})})]})},L8=({title:e,...t})=>{const[r,n]=ir(!1);return v.jsx(dW,{title:v.jsxs(s_,{children:[e,v.jsx("div",{children:v.jsx(Xo,{checked:r,onChange:n,children:"Show numbers"})})]}),children:v.jsx(uje,{...t,showNumbersInLegend:r})})},cje=M.forwardRef(({visitsGroups:e},t)=>{const r=M.useMemo(()=>Object.entries(e),[e]);return r.length===0?null:v.jsx("ul",{className:"list-unstyled mb-0 mt-2 d-flex flex-wrap justify-content-center gap-3",ref:t,children:r.map(([n,i],a)=>v.jsxs("li",{className:"d-inline",children:[v.jsx(eW,{color:gW(i)}),v.jsxs("strong",{children:[n," (",Or(i.length),")"]})]},`${n}${a}`))})}),fje={monthly:"Month",weekly:"Week",daily:"Day",hourly:"Hour"},dje={hourly:e=>({hours:e}),daily:e=>({days:e}),weekly:e=>({weeks:e}),monthly:e=>({months:e})},hje={hourly:pse,daily:mb,weekly:hse,monthly:Ay},zA={hourly:e=>ky(e,"yyyy-MM-dd HH:00"),daily:e=>nl(e),weekly(e){const t=nl(jp(e)),r=nl(xse(e));return`${t} - ${r}`},monthly:e=>ky(e,"yyyy-MM")},pje=e=>{var t;const r=Object.values(e).filter(o=>o.length>0);if(r.length===0)return"monthly";const n=new Date,i=r.map(o=>hl(o[o.length-1].date)),a=X7(i);return((t=[[()=>mb(n,a)<=2,"hourly"],[()=>Ay(n,a)<=1,"daily"],[()=>Ay(n,a)<=6,"weekly"]].find(([o])=>o()))==null?void 0:t[1])??"monthly"},mje=(e,t)=>Object.keys(t).reduce((r,n)=>(r[n]=U7(t[n],i=>zA[e](hl(i.date))),r),{}),vje=(e,t)=>t.reduce((r,n)=>{const i=zA[e](hl(n.date));return r[i]=r[i]??[],r[i].push(n),r},{}),gje=(e,t)=>{const r=Object.values(t).filter(h=>h.length>0).map(h=>[...h].reverse());if(r.length===0)return[];const n=hje[e],i=zA[e],a=dje[e],o=r.flat(),s=hl(o[0].date),c=hl(o[o.length-1].date),l=n(c,s)||1;return[{formattedDate:i(s),date:s},...CA(l,h=>{const p=sse(s,a(h));return{formattedDate:i(p),date:p}})]},gW=e=>{if(e.color)return e.color;const t={main:Cp,highlighted:cP,previous:U0()};return e.type?t[e.type]:Cp},I8=(e,t)=>M.useMemo(()=>Object.values(e).find(r=>r.type===t)??[],[e,t]),yje=(e,t,r)=>{const n=I8(e,"main"),i=I8(e,"highlighted"),a=M.useMemo(()=>r?vje(t,n):{},[r,t,n]),o=M.useCallback((s,{payload:c})=>{const l=a[c.formattedDate]??[];r==null||r(l===i?[]:l)},[a,i,r]);return r&&{cursor:"pointer",onClick:o}},D8=e=>{var t,r;return(r=(t=e.activePayload)==null?void 0:t[0])==null?void 0:r.payload},yW=({visitsGroups:e,setSelectedVisits:t,matchMedia:r,onDateRangeChange:n})=>{const[i,a]=M.useState(pje(e)),o=EA(767,r??window.matchMedia),s=M.useMemo(()=>{const q=mje(i,e),J=Object.keys(q);return gje(i,e).map(({formattedDate:Q,date:re})=>({date:re,formattedDate:Q,...J.reduce((oe,ue)=>(oe[ue]=q[ue][Q]??0,oe),{})}))},[i,e]),c=yje(e,i,t),[l,h,,p]=ir(),g=_i(),_=M.useId(),b=_i(),[w,x]=M.useState(o?300:400);M.useLayoutEffect(()=>{if(!l)return x(o?300:400),()=>{};const q=new ResizeObserver(()=>{const{height:J}=g.current.getBoundingClientRect(),{height:Q}=b.current.getBoundingClientRect();x(J-Q-48)});return q.observe(g.current),q.observe(b.current),()=>q.disconnect()},[g,l,o,b]),$Ce("Escape",p,l);const{ChartWrapper:S,dimensions:C,wrapperDimensions:P}=UA(w),[T,A]=M.useState(),[j,N]=M.useState(),$=M.useCallback(()=>{A(void 0),N(void 0)},[]),U=M.useCallback((q,J)=>{const Q=D8(q);J.button===0&&Q&&A(Q)},[]),B=M.useCallback(q=>{const J=D8(q);T&&J&&N(J)},[T]),W=M.useCallback(()=>{if(!T||!j)return;const q=[T.date,j.date],J=cse(q),Q=X7(q);$(),n({startDate:J,endDate:Q})},[n,$,j,T]);return v.jsxs(Qi,{className:Te({"fixed-top fixed-bottom":l}),"data-testid":"line-chart-card",children:[v.jsxs(Sm,{role:"heading","aria-level":4,className:"d-flex justify-content-between align-items-center",children:["Visits over time",v.jsxs("div",{className:"d-flex align-content-center gap-1",children:[v.jsx(Lt,{"aria-label":l?"Collapse":"Expand","aria-expanded":l,"aria-controls":_,size:"sm",color:"link",onClick:h,children:v.jsx(He,{icon:l?rY:JY})}),v.jsxs(Cm,{className:"d-flex align-items-center",children:[v.jsx(is,{caret:!0,color:"link",className:"btn-sm p-0",children:"Group by"}),v.jsx(xl,{end:!0,children:Object.entries(fje).map(([q,J])=>v.jsx(Ze,{active:i===q,onClick:()=>a(q),children:J},q))})]})]})]}),v.jsxs(xm,{innerRef:g,id:_,children:[v.jsx(S,{...P,children:v.jsxs(KOe,{className:"user-select-none",data:s,...C,onMouseDown:U,onMouseMove:B,onMouseUp:W,children:[v.jsx(Cd,{dataKey:"formattedDate"}),v.jsx(Pd,{tickFormatter:Or,yAxisId:"1"}),v.jsx(zi,{formatter:Or,...mW}),v.jsx(vA,{strokeOpacity:Tm()?.1:.9}),Object.entries(e).map(([q,J])=>J.length>0&&v.jsx(Od,{yAxisId:"1",dataKey:q,type:"monotone",stroke:gW(J),strokeWidth:2,activeDot:J.type==="previous"?void 0:c,strokeDasharray:J.type==="previous"?"8 3":void 0},q)),T&&j&&v.jsx(Fm,{yAxisId:"1",x1:T.formattedDate,x2:j.formattedDate})]})}),v.jsx(cje,{visitsGroups:e,ref:b})]})]})},bje=({toggleClassName:e,ranges:t,value:r,setValue:n})=>v.jsxs(Cm,{children:[v.jsx(is,{caret:!0,color:"link",className:e,children:"Paginate"}),v.jsxs(xl,{end:!0,children:[t.map(i=>v.jsxs(Ze,{active:i===r,onClick:()=>n(i),children:[v.jsx("b",{children:i})," items per page"]},i)),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{disabled:r===1/0,onClick:()=>n(1/0),children:v.jsx("i",{children:"Clear pagination"})})]})]}),$8=e=>e.startsWith("hidden_"),_je=({stats:e,prevStats:t,highlightedStats:r,highlightedLabel:n,max:i,onClick:a})=>{const o=M.useMemo(()=>Object.entries(e).map(([p,g])=>{const _=(r==null?void 0:r[p])??0,b=(t==null?void 0:t[p])??0,w=$8(p);return{name:p,amount:Math.max(g,b),nonHighlightedAmount:w?null:g-_,highlightedAmount:w?null:_,prevAmount:w?null:b}}),[e,t,r]),s=M.useMemo(()=>{const p=o.reduce((g,{name:_})=>g>_.length?g:_.length,0);return Math.min(150,p*7)},[o]),{ChartWrapper:c,dimensions:l,wrapperDimensions:h}=UA(Math.max(300,o.length*(t?44:22)));return v.jsx(c,{...h,children:v.jsxs(ZOe,{layout:"vertical",data:o,barCategoryGap:3,...l,children:[v.jsx(Cd,{type:"number",dataKey:"amount",tickFormatter:Or,domain:i?[0,i]:void 0}),v.jsx(Pd,{type:"category",dataKey:"name",width:s,interval:0,style:{fontSize:".8rem"},tickFormatter:p=>$8(p)?"":p}),v.jsx(vA,{strokeOpacity:Tm()?.05:.9}),v.jsx(zi,{filterNull:!0,...mW,formatter:(p,g)=>[Or(p),g==="highlightedAmount"?n:g==="prevAmount"?"Previous period":r?"Non-selected":"Visits"]}),v.jsx(Ho,{dataKey:"nonHighlightedAmount",stackId:"main",cursor:"pointer",fill:Cp,onClick:({name:p})=>a==null?void 0:a(p),children:o.map(p=>v.jsx(al,{fill:eae,stroke:Cp,strokeWidth:2},p.name))}),r&&v.jsx(Ho,{dataKey:"highlightedAmount",stackId:"main",cursor:"pointer",fill:cP,onClick:({name:p})=>a==null?void 0:a(p),children:o.map(p=>v.jsx(al,{fill:tae,stroke:cP,strokeWidth:2},p.name))}),t&&v.jsx(Ho,{dataKey:"prevAmount",fill:U0(),children:o.map(p=>v.jsx(al,{fill:sje(),stroke:U0(),strokeWidth:2},p.name))})]})})},wje=e=>typeof e=="string"?e.toLowerCase():e,xje=([e])=>e,Sje=([,e])=>e,Rg=({stats:e,prevStats:t,highlightedStats:r,title:n,sortingItems:i,extraHeaderContent:a,withPagination:o=!0,...s})=>{const[c,l]=M.useState({}),[h,p]=M.useState(1),[g,_]=M.useState(50),b=M.useCallback(($,U)=>{const B=Object.entries($),W=c.field?joe(B,([q,J])=>wje(c.field===Object.keys(U)[0]?q:J)):B;return!c.dir||c.dir==="ASC"?W:[...W].reverse()},[c.dir,c.field]),w=M.useCallback($=>{const U=$[h-1];if(h<$.length)return U;const B=$[0].length;return[...U,...CA(B-U.length,W=>[`hidden_${W}`,0])]},[h]),x=M.useCallback($=>v.jsx(BA,{currentPage:h,pagesCount:$,onPageChange:p}),[h]),S=M.useCallback(($,U,B,W)=>{const q=b($,U),J=q.map(xje),Q=B&&Object.entries({...FN(J,J.map(()=>0)),...B}),re=W&&Object.entries({...FN(J,J.map(()=>0)),...W});if(q.length<=g)return{currentPageStats:Object.fromEntries(q),currentPageHighlightedStats:Q&&Object.fromEntries(Q),currentPagePrevStats:re&&Object.fromEntries(re)};const oe=pf(q,g),ue=Q&&pf(Q,g),ae=re&&pf(re,g);return{currentPageStats:Object.fromEntries(w(oe)),currentPageHighlightedStats:ue&&Object.fromEntries(w(ue)),currentPagePrevStats:ae&&Object.fromEntries(w(ae)),pagination:x(oe.length),max:aPe(Math.max(...q.map(Sje)))}},[w,b,g,x]),{currentPageStats:C,currentPagePrevStats:P,currentPageHighlightedStats:T,pagination:A,max:j}=M.useMemo(()=>S(e,i,r&&Object.keys(r).length>0?r:void 0,t&&Object.keys(t).length>0?t:void 0),[S,r,t,i,e]),N=M.useMemo(()=>Object.keys(C),[C]);return v.jsx(dW,{title:v.jsxs(s_,{children:[n,v.jsxs("div",{className:"d-flex gap-3",children:[a==null?void 0:a(A?N:void 0),o&&Object.keys(e).length>50&&v.jsx(bje,{toggleClassName:"btn-sm p-0",ranges:[50,100,200,500],value:g,setValue:$=>{_($),p(1)}}),v.jsx(Em,{isButton:!1,right:!0,items:i,order:c,onChange:($,U)=>{l({field:$,dir:U}),p(1)}})]})]}),footer:A,children:v.jsx(_je,{stats:C,prevStats:P,highlightedStats:T,max:j,...s})})},VA=e=>e.type!==void 0,Oje=e=>e.type!==void 0,Cje=e=>{const t=z7(e,r=>VA(r.visit)?"orphanVisits":"nonOrphanVisits");return{orphanVisits:[],nonOrphanVisits:[],...t}},bW=(e,{shortCode:t,domain:r},{endDate:n,startDate:i}={})=>e.filter(({shortUrl:a,visit:o})=>a&&dp(a,t,r)&&Um(o.date,i,n)),_W=(e,t,{endDate:r,startDate:n}={})=>e.filter(({shortUrl:i,visit:a})=>i&&XCe(i,t)&&Um(a.date,n,r)),wW=(e,t,{endDate:r,startDate:n}={})=>e.filter(({shortUrl:i,visit:a})=>(i==null?void 0:i.tags.includes(t))&&Um(a.date,n,r)),Ng=(e,t)=>U7(e,r=>r[t]),Pje=e=>{const t=((e==null?void 0:e.startDate)&&yl(e==null?void 0:e.startDate))??void 0,r=((e==null?void 0:e.endDate)&&yl(e==null?void 0:e.endDate))??void 0;return{startDate:t,endDate:r}},eT=({filter:e,dateRange:t})=>{const{startDate:r,endDate:n}=Pje(t),i=(e==null?void 0:e.excludeBots)||void 0;return{startDate:r,endDate:n,excludeBots:i}},Eje=e=>qV(e.dateRange),Tje=({dateRange:e,...t})=>({...t,dateRange:gTe(e)}),F8=(e,t)=>{if(!(!t||!(e in t)))return t[e]&&yl(t[e])||""},xW=()=>{const e=fo(),t=hd(),{startDate:r,endDate:n,orphanVisitsType:i,excludeBots:a,loadPrevInterval:o,...s}=t,c=M.useMemo(()=>({dateRange:r!=null||n!=null?UV(r,n):void 0,visitsFilter:{orphanVisitsType:i,excludeBots:a!==void 0?a==="true":void 0},loadPrevInterval:o!==void 0?o==="true":void 0}),[n,a,o,i,r]),l=M.useCallback(h=>{const{dateRange:p,visitsFilter:g={},loadPrevInterval:_}=pb(c,h),{excludeBots:b,orphanVisitsType:w}=g,x={...s,startDate:F8("startDate",p),endDate:F8("endDate",p),excludeBots:b===void 0?void 0:YE(b),orphanVisitsType:w,loadPrevInterval:_===void 0?void 0:YE(_)},S=sb(x),C=S?`?${S}`:"";e(C,{replace:!0,relative:"route"})},[c,e,s]);return[c,l]},jje=()=>v.jsx(mCe,{attribution:'© OpenStreetMap contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),Aje=e=>{if(e.length===0)return{};if(e.length>1)return{bounds:e.map(({latLong:r})=>r)};const[{latLong:t}]=e;return{zoom:10,center:t}},SW=({toggle:e,isOpen:t,title:r,locations:n=[]})=>v.jsx(Ji,{toggle:e,isOpen:t,className:"map-modal__modal",contentClassName:"map-modal__modal-content",children:v.jsxs(as,{className:"map-modal__modal-body",children:[v.jsxs(s_,{className:"map-modal__modal-title fs-4",children:[r,v.jsx("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:e})]}),v.jsxs(dCe,{...Aje(n),children:[v.jsx(jje,{}),n.map(({cityName:i,latLong:a,count:o},s)=>v.jsx(hCe,{position:a,children:v.jsxs(pCe,{children:[v.jsx("b",{children:o})," visit",o>1?"s":""," from ",v.jsx("b",{children:i})]})},s))]})]})}),kje=({modalTitle:e,activeCities:t,locations:r=[]})=>{const[n,,i,a]=ir(),[o,s]=ir(),[c,l]=M.useState([]),h=M.useCallback(p=>{l(p?r.filter(p):r),i()},[r,i]);return v.jsxs(v.Fragment,{children:[!t&&v.jsx(Lt,{color:"link",className:"p-0",onClick:()=>h(),"aria-label":"Show in map",title:"Show in map",children:v.jsx(He,{icon:AO})}),t&&v.jsxs(wl,{isOpen:o,toggle:s,children:[v.jsx(is,{color:"link",className:"p-0",title:"Show in map",children:v.jsx(He,{icon:AO})}),v.jsxs(xl,{end:!0,children:[v.jsx(Ze,{onClick:()=>h(),children:"Show all locations"}),v.jsx(Ze,{onClick:()=>h(({cityName:p})=>t.includes(p)),children:"Show locations in current page"})]})]}),v.jsx(SW,{toggle:a,isOpen:n,title:e,locations:c})]})},OW=({onChange:e,selected:t={},className:r,isOrphanVisits:n=!1,withPrevInterval:i=!1,disabled:a})=>{const{orphanVisitsType:o,excludeBots:s=!1,loadPrevInterval:c=!1}=t,l=g=>({active:o===g,onClick:()=>e({...t,orphanVisitsType:g===o?void 0:g})}),h=M.useCallback(()=>e({...t,excludeBots:!s}),[s,e,t]),p=M.useCallback(()=>e({...t,loadPrevInterval:!c}),[c,e,t]);return v.jsxs(os,{disabled:a,text:"More",dropdownClassName:r,end:!0,minWidth:250,children:[i&&v.jsxs(v.Fragment,{children:[v.jsx(Ze,{active:c,onClick:p,children:"Compare with previous period"}),v.jsx(Ze,{divider:!0,tag:"hr"})]}),v.jsx(Ze,{header:!0,"aria-hidden":!0,children:"Bots:"}),v.jsx(Ze,{active:s,onClick:h,children:"Exclude potential bots"}),n&&v.jsxs(v.Fragment,{children:[v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{header:!0,"aria-hidden":!0,children:"Orphan visits type:"}),v.jsx(Ze,{...l("base_url"),children:"Base URL"}),v.jsx(Ze,{...l("invalid_short_url"),children:"Invalid short URL"}),v.jsx(Ze,{...l("regular_404"),children:"Regular 404"})]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{disabled:t.excludeBots===void 0&&t.loadPrevInterval===void 0&&t.orphanVisitsType===void 0,onClick:()=>e({excludeBots:void 0,loadPrevInterval:void 0,orphanVisitsType:void 0}),children:v.jsx("i",{children:"Reset to defaults"})})]})},CW=({info:e})=>{const{loading:t,errorData:r,progress:n}=e;return v.jsxs(v.Fragment,{children:[t&&n===null&&v.jsx(Lu,{loading:!0}),t&&n!==null&&v.jsxs(Lu,{loading:!0,children:["This is going to take a while... :S",v.jsx(a7,{value:n,striped:n>=100,className:"mt-3"})]}),r&&v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:r,fallbackMessage:"An error occurred while loading visits :("})})]})},Yg=({children:e,showFallback:t})=>v.jsxs(v.Fragment,{children:[t&&v.jsx(Lu,{className:"mt-3",children:"There are no visits matching current filter"}),!t&&v.jsx(v.Fragment,{children:e})]}),Rje=({visitsDeletion:e,deleteVisits:t})=>{const{deleting:r}=e,[n,,i]=ir();return v.jsx(Sr,{title:v.jsx("span",{className:"text-danger fw-bold",children:"Danger zone"}),children:v.jsxs(s_,{children:[v.jsxs("dl",{className:"m-0 me-3",children:[v.jsx("dt",{children:"Delete visits."}),v.jsxs("dd",{className:"m-0",children:["This will delete ",v.jsx("b",{children:"all"})," visits, not only the ones matching current filter."]})]}),!n&&v.jsx(Lt,{color:"danger",className:"indivisible",onClick:i,children:"Delete visits"}),n&&v.jsxs(Lt,{color:"danger",disabled:r,className:"indivisible",onClick:t,innerRef:a=>{a==null||a.focus()},children:[!r&&v.jsx(v.Fragment,{children:"Click again to confirm"}),r&&v.jsx(v.Fragment,{children:"Deleting..."})]})]})})},Mg="Others",Nje=["Android Browser","Chrome","Chromium","Firefox","Internet Explorer","Microsoft Edge","Opera","Safari","Samsung Internet for Android","Vivaldi","WeChat"],Mje=e=>{if(!vu(e))return{browser:Mg,os:Mg};const{browser:{name:t},os:{name:r}}=wCe.parse(e);return{os:r??Mg,browser:t&&Nje.includes(t)?t:Mg}},Lje=e=>{var t;return vu(e)?((t=e.split("/")[e.includes("://")?2:0])==null?void 0:t.split(":")[0])??"":"Direct"},PW=(e,t)=>e[t]!==void 0,B8=e=>typeof e=="number"?e:e?parseFloat(e):0,Ije=(e,{os:t})=>{e[t]=(e[t]||0)+1},Dje=(e,{browser:t})=>{e[t]=(e[t]||0)+1},$je=(e,{referer:t})=>{e[t]=(e[t]||0)+1},EW=e=>(t,r)=>{const n=PW(r,e)?r[e]:"Unknown";t[n]=(t[n]||0)+1},Fje=EW("country"),Bje=EW("city"),Uje=(e,t)=>{if(!PW(t,"city")||t.city==="Unknown")return;const{city:r,latitude:n,longitude:i}=t,a=e[r]||{cityName:r,count:0,latLong:[B8(n),B8(i)]};a.count+=1,e[r]=a},zje=(e,t)=>{if(!Oje(t))return;const{visitedUrl:r}=t;e[r]=(e[r]||0)+1},tT=e=>e.reduce((t,r)=>(Ije(t.os,r),Dje(t.browsers,r),$je(t.referrers,r),Fje(t.countries,r),Bje(t.cities,r),Uje(t.citiesForMap,r),zje(t.visitedUrls,r),t),{os:{},browsers:{},referrers:{},countries:{},cities:{},citiesForMap:{},visitedUrls:{}}),z0=e=>e.map(t=>{const{userAgent:r,date:n,referer:i,visitLocation:a,potentialBot:o}=t;return{date:n,potentialBot:o,userAgent:r,...Mje(r),referer:Lje(i),country:(a==null?void 0:a.countryName)||"Unknown",city:(a==null?void 0:a.cityName)||"Unknown",latitude:a==null?void 0:a.latitude,longitude:a==null?void 0:a.longitude,visitedUrl:t.visitedUrl,type:VA(t)?t.type:void 0}}),Vje=Object.freeze(Object.defineProperty({__proto__:null,normalizeVisits:z0,processStatsFromVisits:tT},Symbol.toStringTag,{value:"Module"})),Yh=20,Wje=({browser:e,os:t,referer:r,country:n,city:i,userAgent:a,...o},s,c)=>{const l=c?a:`${n} ${i}`;return`${e} ${t} ${r} ${l} ${o.visitedUrl}`.toLowerCase().includes(s.toLowerCase())},qje=(e,t,r)=>t.filter(n=>Wje(n,e,r)),Hje=(e,t)=>v7(t,e),Gje=({visits:e,searchTerm:t,order:r,searchInRawUserAgent:n})=>{const i=t?qje(t,e,n):[...e],a=Hje(r,i),o=a.length;return{visitsGroups:pf(a,Yh),total:o}},Ha="visits-table__header-cell visits-table__sticky",Kje=({visits:e,selectedVisits:t=[],setSelectedVisits:r,matchMedia:n=window.matchMedia})=>{var i;const a=EA(767,n),[o,s]=M.useState(),c=M.useCallback($=>{s($),x(1),r([])},[r]),[l,h]=M.useState({}),[p,g]=ir(),_=M.useCallback(()=>{g(),h({})},[g]),b=M.useMemo(()=>Gje({visits:e,searchTerm:o,order:l,searchInRawUserAgent:p}),[e,o,l,p]),[w,x]=M.useState(1),S=w*Yh,C=S-Yh,P=M.useMemo(()=>{var $,U;return!!((U=($=b.visitsGroups[w-1])==null?void 0:$[0])!=null&&U.visitedUrl)},[w,b.visitsGroups]),T=6+Number(P)+(p?1:2),A=b.total>0,j=$=>h({field:$,dir:Pm($,l.field,l.dir)}),N=$=>v.jsx(pp,{currentOrder:l,field:$,className:"visits-table__header-icon"});return v.jsx(Sr,{className:"mt-3",bodyClassName:"p-0 pb-1",title:v.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:["Visits list",v.jsx(Xo,{checked:p,onChange:_,children:"Show user agent"})]}),children:v.jsx("div",{className:"table-responsive-md",children:v.jsxs("table",{className:Te("table table-sm position-relative m-0 visits-table",{"table-hover":A}),children:[v.jsxs("thead",{className:"visits-table__header",children:[v.jsxs("tr",{children:[v.jsxs("th",{className:`${Ha} text-center`,onClick:()=>r(t.length0})})]}),v.jsxs("th",{className:`${Ha} text-center`,onClick:()=>j("potentialBot"),children:[v.jsx("span",{className:"sr-only",children:"Is bot"}),v.jsx(He,{icon:rR}),N("potentialBot")]}),v.jsxs("th",{className:Ha,onClick:()=>j("date"),children:["Date",N("date")]}),v.jsxs("th",{className:Ha,onClick:()=>j("country"),children:["Country",N("country")]}),v.jsxs("th",{className:Ha,onClick:()=>j("city"),children:["City",N("city")]}),p?v.jsxs("th",{className:Ha,onClick:()=>j("userAgent"),children:["User agent",N("userAgent")]}):v.jsxs(v.Fragment,{children:[v.jsxs("th",{className:Ha,onClick:()=>j("browser"),children:["Browser",N("browser")]}),v.jsxs("th",{className:Ha,onClick:()=>j("os"),children:["OS",N("os")]})]}),v.jsxs("th",{className:Ha,onClick:()=>j("referer"),children:["Referrer",N("referer")]}),P&&v.jsxs("th",{className:Ha,onClick:()=>j("visitedUrl"),children:["Visited URL",N("visitedUrl")]})]}),v.jsx("tr",{children:v.jsx("td",{colSpan:T,className:"p-0",children:v.jsx(ob,{noBorder:!0,large:!1,onChange:c})})})]}),v.jsxs("tbody",{children:[!A&&v.jsx("tr",{children:v.jsx("td",{colSpan:T,className:"text-center",children:"There are no visits matching current filter"})}),(i=b.visitsGroups[w-1])==null?void 0:i.map(($,U)=>{const B=t.includes($);return v.jsxs("tr",{style:{cursor:"pointer"},className:Te({"table-active":B}),onClick:()=>r(B?t.filter(W=>W!==$):[...t,$]),children:[v.jsx("td",{className:"text-center",children:B&&v.jsx(He,{icon:vp,className:"text-primary"})}),v.jsx("td",{className:"text-center",children:$.potentialBot&&v.jsxs(v.Fragment,{children:[v.jsx(He,{icon:rR,id:`botIcon${U}`}),v.jsx(Oi,{placement:"right",target:`botIcon${U}`,children:"Potentially a visit from a bot or crawler"})]})}),v.jsx("td",{children:v.jsx($0,{date:$.date})}),v.jsx("td",{children:$.country}),v.jsx("td",{children:$.city}),p?v.jsx("td",{children:$.userAgent}):v.jsxs(v.Fragment,{children:[v.jsx("td",{children:$.browser}),v.jsx("td",{children:$.os})]}),v.jsx("td",{children:$.referer}),$.visitedUrl&&v.jsx("td",{children:$.visitedUrl})]},U)})]}),b.total>Yh&&v.jsx("tfoot",{children:v.jsx("tr",{children:v.jsx("td",{colSpan:T,className:"visits-table__footer-cell visits-table__sticky",children:v.jsxs("div",{className:"d-flex flex-column flex-md-row justify-content-between align-items-center gap-3 p-2",children:[v.jsx(BA,{pagesCount:Math.ceil(b.total/Yh),currentPage:w,onPageChange:x,centered:a}),v.jsxs("div",{children:["Visits ",v.jsx("b",{children:Or(C+1)})," to"," ",v.jsx("b",{children:Or(Math.min(S,b.total))})," of"," ",v.jsx("b",{children:Or(b.total)})]})]})})})})]})})})},Xs={byTime:{title:"By time",subPath:"by-time",icon:iY},byContext:{title:"By context",subPath:"by-context",icon:_T},byLocation:{title:"By location",subPath:"by-location",icon:AO},list:{title:"List",subPath:"list",icon:yT},options:{title:"Options",subPath:"options",icon:z$,shouldRender:({deletion:e})=>!!e}};Object.freeze(Xs);const SO=({display:e})=>e&&v.jsx("div",{className:"mt-3 mx-auto w-75",children:v.jsx(Sr,{children:v.jsxs("div",{className:"d-flex gap-2",children:[v.jsx(He,{icon:nZ,className:"mt-1"}),v.jsx("i",{children:"Could not calculate previous period because selected one does not have a strictly defined start date."})]})})}),Vm=e=>{const{children:t,visitsInfo:r,getVisits:n,cancelGetVisits:i,deletion:a,exportCsv:o,isOrphanVisits:s=!1}=e,{visits:c,prevVisits:l,loading:h,errorData:p,fallbackInterval:g}=r,[{dateRange:_,visitsFilter:b,loadPrevInterval:w},x]=xW(),S=Nn("visits"),[C,P]=M.useState(),T=M.useCallback(({startDate:G,endDate:le},ie)=>{x({dateRange:{startDate:G??void 0,endDate:le??void 0}}),P(ie)},[x]),[A,j]=M.useState(g??(S==null?void 0:S.defaultInterval)??"last30Days"),[N,$]=M.useState([]),[U,B]=M.useState(),W=M.useRef(!0),{search:q}=bn(),J=M.useCallback(G=>G?`../${G}${q}`:q,[q]),Q=M.useMemo(()=>z0(c),[c]),re=M.useMemo(()=>l&&z0(l),[l]),{os:oe,browsers:ue,referrers:ae,countries:K,cities:H,citiesForMap:V,visitedUrls:ne}=M.useMemo(()=>tT(Q),[Q]),X=M.useMemo(()=>tT(re??[]),[re]),se=M.useMemo(()=>Object.fromEntries([["Visits",Object.assign(Q,{type:"main"})],re&&["Previous period",Object.assign(re,{type:"previous"})],N.length>0&&[U??"Selected",Object.assign(N,{type:"highlighted"})]].filter(Boolean)),[U,N,re,Q]),ce=M.useMemo(()=>({...b,excludeBots:b.excludeBots??(S==null?void 0:S.excludeBots),loadPrevInterval:w??(S==null?void 0:S.loadPrevInterval)}),[w,b,S==null?void 0:S.excludeBots,S==null?void 0:S.loadPrevInterval]),de=M.useMemo(()=>Object.values(V),[V]),be=M.useRef(void 0),I=M.useCallback(G=>{be.current=void 0,$(G)},[]),F=M.useCallback((G,le)=>{const ie=`${G}_${le}`;be.current===ie?($([]),B(void 0),be.current=void 0):($(Q.filter(he=>he[G]===le)),B(le),be.current=ie)},[Q]);return M.useEffect(()=>i,[i]),M.useEffect(()=>{const G=_??WV(A),{loadPrevInterval:le,...ie}=ce,he={doIntervalFallback:W.current,loadPrevInterval:le};n({dateRange:G,filter:ie},he),I([]),W.current=!1},[A,_,n,ce,I]),M.useEffect(()=>{g&&A===((S==null?void 0:S.defaultInterval)??"last30Days")&&j(g)},[A,g,S==null?void 0:S.defaultInterval]),v.jsxs(v.Fragment,{children:[t,v.jsx("section",{className:"mt-3",children:v.jsxs("div",{className:"row flex-md-row-reverse",children:[v.jsx("div",{className:"col-lg-7 col-xl-6",children:v.jsxs("div",{className:"d-md-flex",children:[v.jsx("div",{className:"flex-grow-1",children:v.jsx(DA,{disabled:h,dateRangeOrInterval:C??_??A,defaultText:"All visits",onDatesChange:T})}),v.jsx(OW,{disabled:h,className:"ms-0 ms-md-2 mt-3 mt-md-0",isOrphanVisits:s,withPrevInterval:!0,selected:ce,onChange:({loadPrevInterval:G,...le})=>x({visitsFilter:le,loadPrevInterval:G})})]})}),c.length>0&&v.jsx("div",{className:"col-lg-5 col-xl-6 mt-3 mt-lg-0",children:v.jsxs("div",{className:"d-flex",children:[v.jsx(PV,{className:"btn-md-block",amount:Q.length,onClick:()=>o(Q)}),v.jsxs(Lt,{outline:!0,disabled:N.length===0,className:"btn-md-block ms-2",onClick:()=>I([]),children:["Clear selection ",N.length>0&&v.jsxs(v.Fragment,{children:["(",Or(N.length),")"]})]})]})})]})}),v.jsxs("section",{className:"mt-3",children:[v.jsx(CW,{info:r}),!h&&!p&&v.jsxs(v.Fragment,{children:[v.jsx(m7,{fill:!0,children:Object.values(Xs).map(({title:G,icon:le,subPath:ie,shouldRender:he},Oe)=>!he||he(e)?v.jsxs(rp,{to:J(ie),replace:!0,children:[v.jsx(He,{icon:le}),v.jsx("span",{className:"ms-2 d-none d-lg-inline",children:G})]},Oe):void 0).filter(Boolean)}),v.jsx(Za,{children:v.jsxs(G0,{children:[v.jsx(Ot,{path:Xs.byTime.subPath,element:v.jsxs(Yg,{showFallback:c.length===0,children:[v.jsx("div",{className:"col-12 mt-3","data-testid":"line-chart-container",children:v.jsx(yW,{visitsGroups:se,setSelectedVisits:I,onDateRangeChange:T})}),v.jsx(SO,{display:!!ce.loadPrevInterval&&!l})]})}),v.jsx(Ot,{path:Xs.byContext.subPath,element:v.jsxs(Yg,{showFallback:c.length===0,children:[v.jsx("div",{className:Te("mt-3 col-lg-6",{"col-xl-4":!s}),children:v.jsx(L8,{title:"Operating systems",stats:oe,prevStats:X.os})}),v.jsx("div",{className:Te("mt-3 col-lg-6",{"col-xl-4":!s}),children:v.jsx(L8,{title:"Browsers",stats:ue,prevStats:X.browsers})}),v.jsx("div",{className:Te("mt-3",{"col-xl-4":!s,"col-lg-6":s}),children:v.jsx(Rg,{title:"Referrers",withPagination:!1,stats:ae,prevStats:X.referrers,highlightedStats:Ng(N,"referer"),highlightedLabel:U,sortingItems:{name:"Referrer name",amount:"Visits amount"},onClick:G=>F("referer",G)})}),s&&v.jsx("div",{className:"mt-3 col-lg-6",children:v.jsx(Rg,{title:"Visited URLs",stats:ne,prevStats:X.visitedUrls,highlightedStats:Ng(N,"visitedUrl"),highlightedLabel:U,sortingItems:{visitedUrl:"Visited URL",amount:"Visits amount"},onClick:G=>F("visitedUrl",G)})}),v.jsx("div",{className:"col-12",children:v.jsx(SO,{display:!!ce.loadPrevInterval&&!l})})]})}),v.jsx(Ot,{path:Xs.byLocation.subPath,element:v.jsxs(Yg,{showFallback:c.length===0,children:[v.jsx("div",{className:"col-lg-6 mt-3",children:v.jsx(Rg,{title:"Countries",stats:K,prevStats:X.countries,highlightedStats:Ng(N,"country"),highlightedLabel:U,sortingItems:{name:"Country name",amount:"Visits amount"},onClick:G=>F("country",G)})}),v.jsx("div",{className:"col-lg-6 mt-3",children:v.jsx(Rg,{title:"Cities",stats:H,prevStats:X.cities,highlightedStats:Ng(N,"city"),highlightedLabel:U,extraHeaderContent:G=>de.length>0&&v.jsx(kje,{modalTitle:"Cities",locations:de,activeCities:G}),sortingItems:{name:"City name",amount:"Visits amount"},onClick:G=>F("city",G)})}),v.jsx("div",{className:"col-12",children:v.jsx(SO,{display:!!ce.loadPrevInterval&&!l})})]})}),v.jsx(Ot,{path:Xs.list.subPath,element:v.jsx("div",{className:"col-12",children:v.jsx(Kje,{visits:Q,selectedVisits:N,setSelectedVisits:I})})}),a&&v.jsx(Ot,{path:Xs.options.subPath,element:v.jsx("div",{className:"col-12 mt-3",children:v.jsx(Rje,{...a})})}),v.jsx(Ot,{path:"*",element:v.jsx(uT,{replace:!0,to:J(Xs.byTime.subPath)})})]})})]})]})]})},TW=ka(({getDomainVisits:e,domainVisits:t,cancelGetDomainVisits:r})=>{const{ReportExporter:n}=ur(TW),{domain:i=""}=cd(),[a,o=a]=i.split("_"),s=M.useCallback((l,h)=>e({domain:o,options:h,params:l}),[o,e]),c=M.useCallback(l=>n.exportVisits(`domain_${a}_visits.csv`,l),[a,n]);return v.jsx(Vm,{getVisits:s,cancelGetVisits:r,visitsInfo:t,exportCsv:c,children:v.jsx(zm,{visits:t.visits,title:`"${a}" visits`})})},()=>[Rn.visits]),Yje=cr(TW,["ReportExporter"]),jW=ka(({getNonOrphanVisits:e,nonOrphanVisits:t,cancelGetNonOrphanVisits:r})=>{const{ReportExporter:n}=ur(jW),i=M.useCallback(o=>n.exportVisits("non_orphan_visits.csv",o),[n]),a=M.useCallback((o,s)=>e({options:s,params:o}),[e]);return v.jsx(Vm,{getVisits:a,cancelGetVisits:r,visitsInfo:t,exportCsv:i,children:v.jsx(zm,{title:"Non-orphan visits",visits:t.visits})})},()=>[Rn.visits]),Zje=cr(jW,["ReportExporter"]),AW=ka(({getOrphanVisits:e,orphanVisits:t,cancelGetOrphanVisits:r,deleteOrphanVisits:n,orphanVisitsDeletion:i})=>{const a=Ca("orphanVisitsDeletion"),{ReportExporter:o}=ur(AW),s=M.useCallback(h=>o.exportVisits("orphan_visits.csv",h),[o]),c=M.useCallback((h,p)=>{var g;return e({options:p,params:h,orphanVisitsType:(g=h.filter)==null?void 0:g.orphanVisitsType})},[e]),l=M.useMemo(()=>a?{deleteVisits:n,visitsDeletion:i}:void 0,[n,i,a]);return v.jsx(Vm,{getVisits:c,cancelGetVisits:r,visitsInfo:t,exportCsv:s,deletion:l,isOrphanVisits:!0,children:v.jsx(zm,{title:"Orphan visits",visits:t.visits})})},()=>[Rn.orphanVisits]),Xje=cr(AW,["ReportExporter"]),U8=5e3,Qje=2,Jje=4,eAe=({currentPage:e,pagesCount:t})=>e>=t,tAe=(e,t)=>t*100/e,kW=({visitsLoader:e,shouldCancel:t,progressChanged:r,batchSize:n})=>{const i=async(o,s)=>Promise.all(s.map(async c=>e({...o,page:c,itemsPerPage:U8}).then(({data:l})=>l))).then(c=>c.flat()),a=async(o,s,c=0)=>{if(t())return[];const l=await i(o,s[c]);return r(tAe(s.length,c+1)),c{const{pagination:s,data:c}=await e({...o,page:1,itemsPerPage:U8});if(eAe(s))return c;const l=sj(Qje,s.pagesCount+1),h=pf(l,n);return s.pagesCount-1>n&&r(0),c.concat(await a(o,h))}},Wm=(e,t)=>async r=>e?t({page:1,itemsPerPage:1,excludeBots:r}).then(({data:n})=>n[0]):Promise.resolve(void 0),qm=({typePrefix:e,createLoaders:t,shouldCancel:r})=>{const n=An(`${e}/progressChanged`),i=An(`${e}/fallbackToInterval`),a=Vr(e,async(o,{getState:s,dispatch:c})=>{var l;const{params:h,options:p}=o,{visitsLoader:g,lastVisitLoader:_}=t(o),b=yTe(h.dateRange),w=eT(h),x=p.loadPrevInterval&&Eje(h)?eT(Tje(h)):void 0,S=Jje/(x?2:1),C=x?{main:0,prev:0}:{main:0},P=($,U)=>{C[$]=U;const B=Object.values(C),W=B.reduce((q,J)=>q+J,0);c(n(W/B.length))},T=kW({visitsLoader:g,shouldCancel:()=>r(s),progressChanged:$=>P("main",$),batchSize:S}),[A,j,N]=await Promise.all([T(w),_((l=h.filter)==null?void 0:l.excludeBots),x?T(x).then($=>$.map(U=>{if(b===void 0)return U;const{date:B,...W}=U,q=fj(vi(B),b);return{...W,date:yl(q)}})):Promise.resolve(void 0)]);return!A.length&&j&&c(i(vTe(j.date))),{...o,visits:A,prevVisits:N}});return Object.assign(a,{progressChanged:n,fallbackToInterval:i})},Hm=({name:e,asyncThunkCreator:t,initialState:r,filterCreatedVisits:n,extraReducers:i})=>{const{pending:a,rejected:o,fulfilled:s,progressChanged:c,fallbackToInterval:l}=t,{reducer:h,actions:p}=Tr({name:e,initialState:r,reducers:{cancelGetVisits:_=>({..._,cancelLoad:!0})},extraReducers:_=>{_.addCase(a,()=>({...r,loading:!0})),_.addCase(o,(b,{error:w})=>({...r,errorData:Ci(w)??null})),_.addCase(s,(b,{payload:w})=>({...b,...w,loading:!1,progress:null,errorData:null})),_.addCase(c,(b,{payload:w})=>({...b,progress:w})),_.addCase(l,(b,{payload:w})=>({...b,fallbackInterval:w})),_.addCase(Ed,(b,{payload:w})=>{const{visits:x}=b,S=n(b,w.createdVisits).map(({visit:C})=>C);return S.length?{...b,visits:[...S,...x]}:b}),i==null||i(_)}}),{cancelGetVisits:g}=p;return{reducer:h,cancelGetVisits:g}},RW="shlink/domainVisits",rAe={visits:[],domain:"",loading:!1,cancelLoad:!1,errorData:null,progress:null},nAe=e=>qm({typePrefix:`${RW}/getDomainVisits`,createLoaders:({domain:t,options:r})=>{const n=e(),{doIntervalFallback:i=!1}=r,a=s=>n.getDomainVisits(t,s),o=Wm(i,s=>n.getDomainVisits(t,s));return{visitsLoader:a,lastVisitLoader:o}},shouldCancel:t=>t().domainVisits.cancelLoad}),iAe=e=>Hm({name:RW,initialState:rAe,asyncThunkCreator:e,filterCreatedVisits:({domain:t,params:r},n)=>_W(n,t,r==null?void 0:r.dateRange)}),NW="shlink/orphanVisits",aAe={visits:[],loading:!1,cancelLoad:!1,errorData:null,progress:null},oAe=e=>qm({typePrefix:`${NW}/getNonOrphanVisits`,createLoaders:({options:t})=>{const r=e(),{doIntervalFallback:n=!1}=t,i=async o=>r.getNonOrphanVisits(o),a=Wm(n,o=>r.getNonOrphanVisits(o));return{visitsLoader:i,lastVisitLoader:a}},shouldCancel:t=>t().orphanVisits.cancelLoad}),sAe=e=>Hm({name:NW,initialState:aAe,asyncThunkCreator:e,filterCreatedVisits:({params:t},r)=>{const{startDate:n,endDate:i}=(t==null?void 0:t.dateRange)??{};return r.filter(({visit:a})=>Um(a.date,n,i))}}),MW="shlink/orphanVisits",lAe={visits:[],loading:!1,cancelLoad:!1,errorData:null,progress:null},uAe=(e,t)=>!t||t===e.type,cAe=({data:e,...t},r)=>{const n=e.filter(i=>VA(i)&&uAe(i,r));return{...t,data:n}},fAe=e=>qm({typePrefix:`${MW}/getOrphanVisits`,createLoaders:({orphanVisitsType:t,options:r})=>{const n=e(),{doIntervalFallback:i=!1}=r,a=async s=>n.getOrphanVisits({...s,type:t}).then(c=>cAe(c,t)),o=Wm(i,s=>n.getOrphanVisits(s));return{visitsLoader:a,lastVisitLoader:o}},shouldCancel:t=>t().orphanVisits.cancelLoad}),dAe=(e,t)=>Hm({name:MW,initialState:lAe,asyncThunkCreator:e,extraReducers:r=>{r.addCase(t.fulfilled,n=>({...n,visits:[]}))},filterCreatedVisits:({params:r},n)=>{const{startDate:i,endDate:a}=(r==null?void 0:r.dateRange)??{};return n.filter(({visit:o,shortUrl:s})=>!s&&Um(o.date,i,a))}}),LW="shlink/orphanVisitsDeletion",z8={deletedVisits:0,deleting:!1,error:!1},hAe=e=>Vr(`${LW}/deleteOrphanVisits`,()=>e().deleteOrphanVisits()),pAe=e=>Tr({name:LW,initialState:z8,reducers:{},extraReducers:t=>{t.addCase(e.pending,r=>({...r,deleting:!0,error:!1})),t.addCase(e.rejected,(r,{error:n})=>({...r,deleting:!1,error:!0,errorData:Ci(n)})),t.addCase(e.fulfilled,(r,{payload:n})=>{const{deletedVisits:i}=n;return{...z8,deletedVisits:i}})}}),IW="shlink/shortUrlVisits",mAe={visits:[],shortCode:"",loading:!1,errorData:null,cancelLoad:!1,progress:null},vAe=e=>qm({typePrefix:`${IW}/getShortUrlVisits`,createLoaders:({shortCode:t,domain:r,options:n})=>{const i=e(),{doIntervalFallback:a=!1}=n,o=c=>i.getShortUrlVisits({shortCode:t,domain:r},c),s=Wm(a,c=>i.getShortUrlVisits({shortCode:t,domain:r},c));return{visitsLoader:o,lastVisitLoader:s}},shouldCancel:t=>t().shortUrlVisits.cancelLoad}),gAe=(e,t)=>Hm({name:IW,initialState:mAe,asyncThunkCreator:e,extraReducers:r=>{r.addCase(t.fulfilled,(n,{payload:i})=>n.shortCode===i.shortCode&&n.domain===i.domain?{...n,visits:[]}:n)},filterCreatedVisits:({shortCode:r,domain:n,params:i},a)=>bW(a,{shortCode:r,domain:n},i==null?void 0:i.dateRange)}),DW="shlink/shortUrlVisitsDeletion",V8={shortCode:"",deletedVisits:0,deleting:!1,error:!1},yAe=e=>Vr(`${DW}/deleteShortUrlVisits`,async({shortCode:t,domain:r})=>({...await e().deleteShortUrlVisits({shortCode:t,domain:r}),shortCode:t,domain:r})),bAe=e=>Tr({name:DW,initialState:V8,reducers:{},extraReducers:t=>{t.addCase(e.pending,r=>({...r,deleting:!0,error:!1})),t.addCase(e.rejected,(r,{error:n})=>({...r,deleting:!1,error:!0,errorData:Ci(n)})),t.addCase(e.fulfilled,(r,{payload:n})=>{const{shortCode:i,domain:a,deletedVisits:o}=n;return{...V8,shortCode:i,domain:a,deletedVisits:o}})}}),$W="shlink/tagVisits",_Ae={visits:[],tag:"",loading:!1,cancelLoad:!1,errorData:null,progress:null},wAe=e=>qm({typePrefix:`${$W}/getTagVisits`,createLoaders:({tag:t,options:r})=>{const n=e(),{doIntervalFallback:i=!1}=r,a=s=>n.getTagVisits(t,s),o=Wm(i,async s=>n.getTagVisits(t,s));return{visitsLoader:a,lastVisitLoader:o}},shouldCancel:t=>t().tagVisits.cancelLoad}),xAe=e=>Hm({name:$W,initialState:_Ae,asyncThunkCreator:e,filterCreatedVisits:({tag:t,params:r},n)=>wW(n,t,r==null?void 0:r.dateRange)}),FW="shlink/visitsOverview",Lg={nonOrphanVisits:{total:0},orphanVisits:{total:0},loading:!1,error:!1},W8=e=>e.filter(({visit:t})=>t.potentialBot).length,SAe=e=>Vr(`${FW}/loadVisitsOverview`,()=>e().getVisitsOverview().then(({nonOrphanVisits:t,visitsCount:r=0,orphanVisits:n,orphanVisitsCount:i=0})=>({nonOrphanVisits:{total:(t==null?void 0:t.total)??r,nonBots:t==null?void 0:t.nonBots,bots:t==null?void 0:t.bots},orphanVisits:{total:(n==null?void 0:n.total)??i,nonBots:n==null?void 0:n.nonBots,bots:n==null?void 0:n.bots}}))),OAe=e=>Tr({name:FW,initialState:Lg,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({...Lg,loading:!0})),t.addCase(e.rejected,()=>({...Lg,error:!0})),t.addCase(e.fulfilled,(r,{payload:n})=>({...Lg,...n})),t.addCase(Ed,({nonOrphanVisits:r,orphanVisits:n,...i},{payload:a})=>{const{nonOrphanVisits:o,orphanVisits:s}=Cje(a.createdVisits),c=o.length,l=W8(o),h=c-l,p=s.length,g=W8(s),_=p-g;return{...i,nonOrphanVisits:{total:r.total+c,bots:r.bots&&r.bots+l,nonBots:r.nonBots&&r.nonBots+h},orphanVisits:{total:n.total+p,bots:n.bots&&n.bots+g,nonBots:n.nonBots&&n.nonBots+_}}})}}),CAe=({shortUrl:e,loading:t,shortUrlVisits:r})=>{const{visits:n}=r,i=(e==null?void 0:e.shortUrl)??"",a=(e==null?void 0:e.longUrl)??"",o=e==null?void 0:e.title;return v.jsxs(zm,{title:v.jsxs(v.Fragment,{children:["Visits for ",v.jsx(Gn,{href:i})]}),visits:n,shortUrl:e,children:[v.jsx("hr",{}),v.jsxs("div",{children:["Created: ",e?v.jsxs("span",{children:[v.jsx("b",{id:"created",className:"short-url-visits-header__created-at",children:v.jsx($0,{date:e.dateCreated,relative:!0})}),v.jsx(Oi,{placement:"bottom",target:"created",children:v.jsx($0,{date:e.dateCreated})})]}):v.jsx("small",{children:"Loading..."})]}),v.jsxs("div",{className:"long-url-container",children:[`${o?"Title":"Long URL"}: `,t&&v.jsx("small",{children:"Loading..."}),!t&&v.jsx(Gn,{href:a,children:o??a})]})]})},BW=ka(({shortUrlVisits:e,shortUrlVisitsDeletion:t,shortUrlsDetails:r,getShortUrlVisits:n,getShortUrlsDetails:i,deleteShortUrlVisits:a,cancelGetShortUrlVisits:o})=>{const s=Ca("shortUrlVisitsDeletion"),{ReportExporter:c}=ur(BW),l=NA(),h=M.useMemo(()=>{var b;return(b=r.shortUrls)==null?void 0:b.get(l)},[l,r.shortUrls]),p=M.useCallback((b,w)=>n({...l,options:w,params:b}),[n,l]),g=M.useCallback(b=>c.exportVisits(`short-url_${h==null?void 0:h.shortUrl.replace(/https?:\/\//g,"")}_visits.csv`,b),[c,h==null?void 0:h.shortUrl]),_=M.useMemo(()=>s?{deleteVisits:()=>a(l),visitsDeletion:t}:void 0,[a,l,t,s]);return M.useEffect(()=>{i([l])},[l,i]),v.jsx(Vm,{getVisits:p,cancelGetVisits:o,visitsInfo:e,exportCsv:g,deletion:_,children:v.jsx(CAe,{shortUrl:h,loading:r.loading,shortUrlVisits:e})})},e=>e.shortCode?[Rn.shortUrlVisits(TA(e.shortCode))]:[]),PAe=cr(BW,["ReportExporter"]),EAe=({tagVisits:e,colorGenerator:t})=>{const{visits:r,tag:n}=e;return v.jsx(zm,{title:v.jsxs("span",{className:"d-flex align-items-center justify-content-center",children:[v.jsx("span",{className:"me-2",children:"Visits for"}),v.jsx(a_,{text:n,colorGenerator:t})]}),visits:r})},UW=ka(({getTagVisits:e,tagVisits:t,cancelGetTagVisits:r})=>{const{ColorGenerator:n,ReportExporter:i}=ur(UW),{tag:a=""}=cd(),o=M.useCallback((c,l)=>e({tag:a,params:c,options:l}),[e,a]),s=M.useCallback(c=>i.exportVisits(`tag_${a}_visits.csv`,c),[i,a]);return v.jsx(Vm,{getVisits:o,cancelGetVisits:r,visitsInfo:t,exportCsv:s,children:v.jsx(EAe,{tagVisits:t,colorGenerator:n})})},()=>[Rn.visits]),TAe=cr(UW,["ColorGenerator","ReportExporter"]),WA=({title:e,colors:t,getVisitsForComparison:r,visitsComparisonInfo:n,cancelGetVisitsComparison:i})=>{const{loading:a,visitsGroups:o}=n,s=Nn("visits"),c=M.useMemo(()=>Object.keys(o).reduce((C,P,T)=>(C[P]=Object.assign(z0(o[P]),{color:(t==null?void 0:t[P])??vW(T)}),C),{}),[t,o]),l=M.useMemo(()=>Object.values(o).every(C=>C.length===0),[o]),[{dateRange:h,visitsFilter:p},g]=xW(),[_,b]=M.useState(),w=M.useCallback(({startDate:C,endDate:P},T)=>{g({dateRange:{startDate:C??void 0,endDate:P??void 0}}),b(T)},[g]),[x]=M.useState(()=>h??(s==null?void 0:s.defaultInterval)??"last30Days"),S=M.useMemo(()=>({...p,excludeBots:p.excludeBots??(s==null?void 0:s.excludeBots)}),[p,s==null?void 0:s.excludeBots]);return M.useEffect(()=>{const C=h??WV(x);return r({params:{dateRange:C,filter:S}}),i},[i,h,r,x,S]),v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"mb-3",children:v.jsxs(Sr,{bodyClassName:"d-flex",children:[v.jsx(i_,{}),v.jsx("h3",{className:"mb-0 flex-grow-1 text-center",children:e})]})}),v.jsx("div",{className:"col-lg-7 col-xl-6 offset-lg-5 offset-xl-6 mb-3",children:v.jsxs("div",{className:"d-md-flex",children:[v.jsx("div",{className:"flex-grow-1",children:v.jsx(DA,{disabled:a,defaultText:"All visits",dateRangeOrInterval:_??h??x,onDatesChange:w})}),v.jsx(OW,{disabled:a,className:"ms-0 ms-md-2 mt-3 mt-md-0",selected:S,onChange:({orphanVisitsType:C,excludeBots:P})=>g({visitsFilter:{orphanVisitsType:C,excludeBots:P}})})]})}),v.jsx(CW,{info:n}),!a&&v.jsx(Yg,{showFallback:l,children:v.jsx(yW,{visitsGroups:c,onDateRangeChange:w})})]})},jAe=ka(({getDomainVisitsForComparison:e,domainVisitsComparison:t,cancelGetDomainVisitsComparison:r})=>{const n=PA("domains"),i=M.useCallback(a=>e({...a,domains:n}),[n,e]);return v.jsx(WA,{title:`Comparing "${n.join('", "')}"`,getVisitsForComparison:i,visitsComparisonInfo:t,cancelGetVisitsComparison:r})},()=>[Rn.visits]),AAe=({visitsLoaders:e,shouldCancel:t,progressChanged:r})=>{const n=Object.keys(e),i=Math.max(1,Math.round(4/n.length)),a=Object.fromEntries(n.map(c=>[c,0])),o=(c,l)=>{a[c]=l;const h=Object.values(a),p=h.reduce((g,_)=>g+_,0);r(p/h.length)},s=Object.entries(e).map(([c,l])=>[c,kW({visitsLoader:l,batchSize:i,shouldCancel:t,progressChanged:h=>o(c,h)})]);return async c=>{const l=await Promise.all(s.map(async([h,p])=>{const g=await p(c);return[h,g]}));return Object.fromEntries(l)}},qA=({typePrefix:e,createLoaders:t,shouldCancel:r})=>{const n=An(`${e}/progressChanged`),i=Vr(e,async(a,{getState:o,dispatch:s})=>{const c=t(a),l=await AAe({visitsLoaders:c,shouldCancel:()=>r(o),progressChanged:h=>s(n(h))})(eT(a.params));return{...a,visitsGroups:l}});return Object.assign(i,{progressChanged:n})},HA=({name:e,asyncThunkCreator:t,initialState:r,filterCreatedVisitsForGroup:n})=>{const{pending:i,rejected:a,fulfilled:o,progressChanged:s}=t,{reducer:c,actions:l}=Tr({name:e,initialState:r,reducers:{cancelGetVisits:p=>({...p,cancelLoad:!0})},extraReducers:p=>{p.addCase(i,()=>({...r,loading:!0})),p.addCase(a,(g,{error:_})=>({...r,errorData:Ci(_)??null})),p.addCase(o,(g,{payload:_})=>({...g,..._,loading:!1,progress:null,errorData:null})),p.addCase(s,(g,{payload:_})=>({...g,progress:_})),p.addCase(Ed,(g,{payload:_})=>{const{visitsGroups:b,...w}=g,x=Object.keys(b).map(C=>{const P=n({...w,groupKey:C},_.createdVisits).map(({visit:T})=>T);return[C,[...P,...b[C]]]}),S=Object.fromEntries(x);return{...w,visitsGroups:S}})}}),{cancelGetVisits:h}=l;return{reducer:c,cancelGetVisits:h}},zW="shlink/domainVisitsComparison",kAe={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},RAe=e=>qA({typePrefix:`${zW}/getDomainVisitsForComparison`,createLoaders:({domains:t})=>{const r=e(),n=t.map(i=>[i,a=>r.getDomainVisits(i,a)]);return Object.fromEntries(n)},shouldCancel:t=>t().domainVisitsComparison.cancelLoad}),NAe=e=>HA({name:zW,initialState:kAe,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:r},n)=>_W(n,t,r==null?void 0:r.dateRange)}),VW="shlink/shortUrlVisitsComparison",MAe={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},LAe=e=>qA({typePrefix:`${VW}/getShortUrlVisitsForComparison`,createLoaders:({shortUrls:t})=>{const r=e(),n=t.map(i=>[jA(i),a=>r.getShortUrlVisits(i,a)]);return Object.fromEntries(n)},shouldCancel:t=>t().shortUrlVisitsComparison.cancelLoad}),IAe=e=>HA({name:VW,initialState:MAe,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:r},n)=>bW(n,eV(t),r==null?void 0:r.dateRange)}),WW="shlink/tagVisitsComparison",DAe={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},$Ae=e=>qA({typePrefix:`${WW}/getTagVisitsForComparison`,createLoaders:({tags:t})=>{const r=e(),n=t.map(i=>[i,a=>r.getTagVisits(i,a)]);return Object.fromEntries(n)},shouldCancel:t=>t().tagVisitsComparison.cancelLoad}),FAe=e=>HA({name:WW,initialState:DAe,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:r},n)=>wW(n,t,r==null?void 0:r.dateRange)}),BAe=ka(({getShortUrlVisitsForComparison:e,shortUrlVisitsComparison:t,cancelGetShortUrlVisitsComparison:r,shortUrlsDetails:n,getShortUrlsDetails:i})=>{const a=PA("short-urls"),o=M.useMemo(()=>a.map(eV),[a]),s=M.useCallback(h=>e({...h,shortUrls:o}),[e,o]),c=M.useMemo(()=>{var h;return[...((h=n.shortUrls)==null?void 0:h.values())??[]]},[n.shortUrls]),l=M.useMemo(()=>{const{visitsGroups:h,loading:p,...g}=t,_=c.reduce((b,w)=>(b[w.shortUrl]=h[jA(w)]??[],b),{});return{...g,visitsGroups:_,loading:p||n.loading}},[t,n.loading,c]);return M.useEffect(()=>{o.length>0&&i(o)},[i,o]),v.jsx(WA,{title:v.jsx("span",{"data-testid":"title",children:n.loading?"Loading...":`Comparing ${c.length} short URLs`}),getVisitsForComparison:s,visitsComparisonInfo:l,cancelGetVisitsComparison:r})},()=>[Rn.visits]),qW=ka(({getTagVisitsForComparison:e,tagVisitsComparison:t,cancelGetTagVisitsComparison:r})=>{const{ColorGenerator:n}=ur(qW),i=PA("tags"),a=M.useCallback(c=>e({...c,tags:i}),[e,i]),{visitsGroups:o}=t,s=M.useMemo(()=>Object.keys(o).reduce((c,l)=>(c[l]=n.getColorForKey(l),c),{}),[n,o]);return v.jsx(WA,{title:v.jsxs(v.Fragment,{children:["Comparing ",i.map(c=>v.jsx(a_,{colorGenerator:n,text:c},c))]}),getVisitsForComparison:a,visitsComparisonInfo:t,cancelGetVisitsComparison:r,colors:s})},()=>[Rn.visits]),UAe=cr(qW,["ColorGenerator"]),zAe=(e,t)=>{const r=(n,i)=>t([...n,"mercureInfo"],[...i,"createNewVisits","loadMercureInfo"]);e.serviceFactory("MapModal",()=>SW),e.factory("ShortUrlVisits",PAe),e.decorator("ShortUrlVisits",t(["shortUrlVisits","shortUrlVisitsDeletion","shortUrlsDetails","mercureInfo"],["getShortUrlVisits","deleteShortUrlVisits","getShortUrlsDetails","cancelGetShortUrlVisits","createNewVisits","loadMercureInfo"])),e.factory("TagVisits",TAe),e.decorator("TagVisits",r(["tagVisits"],["getTagVisits","cancelGetTagVisits"])),e.factory("TagVisitsComparison",UAe),e.decorator("TagVisitsComparison",r(["tagVisitsComparison"],["getTagVisitsForComparison","cancelGetTagVisitsForComparison"])),e.serviceFactory("DomainVisitsComparison",()=>jAe),e.decorator("DomainVisitsComparison",r(["domainVisitsComparison"],["getDomainVisitsForComparison","cancelGetDomainVisitsForComparison"])),e.serviceFactory("ShortUrlVisitsComparison",()=>BAe),e.decorator("ShortUrlVisitsComparison",r(["shortUrlVisitsComparison","shortUrlsDetails"],["getShortUrlVisitsForComparison","cancelGetShortUrlVisitsForComparison","getShortUrlsDetails"])),e.factory("DomainVisits",Yje),e.decorator("DomainVisits",r(["domainVisits"],["getDomainVisits","cancelGetDomainVisits"])),e.factory("OrphanVisits",Xje),e.decorator("OrphanVisits",r(["orphanVisits","orphanVisitsDeletion"],["getOrphanVisits","cancelGetOrphanVisits","deleteOrphanVisits"])),e.factory("NonOrphanVisits",Zje),e.decorator("NonOrphanVisits",r(["nonOrphanVisits"],["getNonOrphanVisits","cancelGetNonOrphanVisits"])),e.serviceFactory("VisitsParser",()=>Vje),e.serviceFactory("getShortUrlVisits",vAe,"apiClientFactory"),e.serviceFactory("cancelGetShortUrlVisits",n=>n.cancelGetVisits,"shortUrlVisitsReducerCreator"),e.serviceFactory("getShortUrlVisitsForComparison",LAe,"apiClientFactory"),e.serviceFactory("cancelGetShortUrlVisitsForComparison",n=>n.cancelGetVisits,"shortUrlVisitsComparisonReducerCreator"),e.serviceFactory("deleteShortUrlVisits",yAe,"apiClientFactory"),e.serviceFactory("getTagVisits",wAe,"apiClientFactory"),e.serviceFactory("cancelGetTagVisits",n=>n.cancelGetVisits,"tagVisitsReducerCreator"),e.serviceFactory("getTagVisitsForComparison",$Ae,"apiClientFactory"),e.serviceFactory("cancelGetTagVisitsForComparison",n=>n.cancelGetVisits,"tagVisitsComparisonReducerCreator"),e.serviceFactory("getDomainVisits",nAe,"apiClientFactory"),e.serviceFactory("cancelGetDomainVisits",n=>n.cancelGetVisits,"domainVisitsReducerCreator"),e.serviceFactory("getDomainVisitsForComparison",RAe,"apiClientFactory"),e.serviceFactory("cancelGetDomainVisitsForComparison",n=>n.cancelGetVisits,"domainVisitsComparisonReducerCreator"),e.serviceFactory("getOrphanVisits",fAe,"apiClientFactory"),e.serviceFactory("cancelGetOrphanVisits",n=>n.cancelGetVisits,"orphanVisitsReducerCreator"),e.serviceFactory("deleteOrphanVisits",hAe,"apiClientFactory"),e.serviceFactory("getNonOrphanVisits",oAe,"apiClientFactory"),e.serviceFactory("cancelGetNonOrphanVisits",n=>n.cancelGetVisits,"nonOrphanVisitsReducerCreator"),e.serviceFactory("createNewVisits",()=>Ed),e.serviceFactory("loadVisitsOverview",SAe,"apiClientFactory"),e.serviceFactory("visitsOverviewReducerCreator",OAe,"loadVisitsOverview"),e.serviceFactory("visitsOverviewReducer",n=>n.reducer,"visitsOverviewReducerCreator"),e.serviceFactory("domainVisitsReducerCreator",iAe,"getDomainVisits"),e.serviceFactory("domainVisitsReducer",n=>n.reducer,"domainVisitsReducerCreator"),e.serviceFactory("nonOrphanVisitsReducerCreator",sAe,"getNonOrphanVisits"),e.serviceFactory("nonOrphanVisitsReducer",n=>n.reducer,"nonOrphanVisitsReducerCreator"),e.serviceFactory("orphanVisitsReducerCreator",dAe,"getOrphanVisits","deleteOrphanVisits"),e.serviceFactory("orphanVisitsReducer",n=>n.reducer,"orphanVisitsReducerCreator"),e.serviceFactory("orphanVisitsDeletionReducerCreator",pAe,"deleteOrphanVisits"),e.serviceFactory("orphanVisitsDeletionReducer",n=>n.reducer,"orphanVisitsDeletionReducerCreator"),e.serviceFactory("shortUrlVisitsReducerCreator",gAe,"getShortUrlVisits","deleteShortUrlVisits"),e.serviceFactory("shortUrlVisitsReducer",n=>n.reducer,"shortUrlVisitsReducerCreator"),e.serviceFactory("shortUrlVisitsDeletionReducerCreator",bAe,"deleteShortUrlVisits"),e.serviceFactory("shortUrlVisitsDeletionReducer",n=>n.reducer,"shortUrlVisitsDeletionReducerCreator"),e.serviceFactory("tagVisitsReducerCreator",xAe,"getTagVisits"),e.serviceFactory("tagVisitsReducer",n=>n.reducer,"tagVisitsReducerCreator"),e.serviceFactory("tagVisitsComparisonReducerCreator",FAe,"getTagVisitsForComparison"),e.serviceFactory("tagVisitsComparisonReducer",n=>n.reducer,"tagVisitsComparisonReducerCreator"),e.serviceFactory("domainVisitsComparisonReducerCreator",NAe,"getDomainVisitsForComparison"),e.serviceFactory("domainVisitsComparisonReducer",n=>n.reducer,"domainVisitsComparisonReducerCreator"),e.serviceFactory("shortUrlVisitsComparisonReducerCreator",IAe,"getShortUrlVisitsForComparison"),e.serviceFactory("shortUrlVisitsComparisonReducer",n=>n.reducer,"shortUrlVisitsComparisonReducerCreator")},Dh=({children:e,to:t,className:r,...n})=>v.jsx(Y0,{className:({isActive:i})=>Te("aside-menu__item",r,{"aside-menu__item--selected":i}),to:t,...n,children:e}),VAe=({routePrefix:e,showOnMobile:t=!1})=>{const{pathname:r}=bn(),n=Te("aside-menu",{"aside-menu--hidden":!t}),i=a=>`${e}${a}`;return v.jsx("aside",{className:n,children:v.jsxs("nav",{className:"nav flex-column aside-menu__nav",children:[v.jsxs(Dh,{to:i("/overview"),children:[v.jsx(He,{fixedWidth:!0,icon:IY}),v.jsx("span",{className:"aside-menu__item-text",children:"Overview"})]}),v.jsxs(Dh,{to:i("/list-short-urls/1"),className:Te({"aside-menu__item--selected":r.match("/list-short-urls")!==null}),children:[v.jsx(He,{fixedWidth:!0,icon:yT}),v.jsx("span",{className:"aside-menu__item-text",children:"List short URLs"})]}),v.jsxs(Dh,{to:i("/create-short-url"),children:[v.jsx(He,{fixedWidth:!0,icon:zY,flip:"horizontal"}),v.jsx("span",{className:"aside-menu__item-text",children:"Create short URL"})]}),v.jsxs(Dh,{to:i("/manage-tags"),children:[v.jsx(He,{fixedWidth:!0,icon:F$}),v.jsx("span",{className:"aside-menu__item-text",children:"Manage tags"})]}),v.jsxs(Dh,{to:i("/manage-domains"),children:[v.jsx(He,{fixedWidth:!0,icon:pY}),v.jsx("span",{className:"aside-menu__item-text",children:"Manage domains"})]})]})})},HW=({createNotFound:e})=>{const{TagsList:t,ShortUrlsList:r,CreateShortUrl:n,ShortUrlVisits:i,TagVisits:a,DomainVisits:o,OrphanVisits:s,NonOrphanVisits:c,Overview:l,EditShortUrl:h,ManageDomains:p,TagVisitsComparison:g,DomainVisitsComparison:_,ShortUrlVisitsComparison:b,ShortUrlRedirectRules:w}=ur(HW),x=bn(),S=jl(),[C,P,T,A]=ir();M.useEffect(()=>A(),[x,A]);const j=Te("shlink-layout__burger-icon",{"shlink-layout__burger-icon--active":C}),N=LCe(T,A),$=Ca("shortUrlRedirectRules");return v.jsxs(v.Fragment,{children:[v.jsx(He,{icon:lY,className:j,onClick:P}),v.jsx("div",{...N,className:"shlink-layout__swipeable",children:v.jsxs("div",{className:"shlink-layout__swipeable-inner",children:[v.jsx(VAe,{routePrefix:S,showOnMobile:C}),v.jsx("div",{className:"shlink-layout__container",onPointerDown:()=>A(),children:v.jsx("div",{className:"container-xl",children:v.jsxs(G0,{children:[v.jsx(Ot,{index:!0,element:v.jsx(uT,{replace:!0,to:"overview"})}),v.jsx(Ot,{path:"/overview",element:v.jsx(l,{})}),v.jsx(Ot,{path:"/list-short-urls/:page",element:v.jsx(r,{})}),v.jsx(Ot,{path:"/create-short-url",element:v.jsx(n,{})}),v.jsx(Ot,{path:"/short-code/:shortCode/visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(i,{})},U))}),v.jsx(Ot,{path:"/short-code/:shortCode/edit",element:v.jsx(h,{})}),$&&v.jsx(Ot,{path:"/short-code/:shortCode/redirect-rules",element:v.jsx(w,{})}),v.jsx(Ot,{path:"/short-urls/compare-visits",element:v.jsx(b,{})}),v.jsx(Ot,{path:"/tag/:tag/visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(a,{})},U))}),v.jsx(Ot,{path:"/tags/compare-visits",element:v.jsx(g,{})}),v.jsx(Ot,{path:"/domain/:domain/visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(o,{})},U))}),v.jsx(Ot,{path:"/orphan-visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(s,{})},U))}),v.jsx(Ot,{path:"/non-orphan-visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(c,{})},U))}),v.jsx(Ot,{path:"/manage-tags",element:v.jsx(t,{})}),v.jsx(Ot,{path:"/manage-domains",element:v.jsx(p,{})}),v.jsx(Ot,{path:"/domains/compare-visits",element:v.jsx(_,{})}),e&&v.jsx(Ot,{path:"*",element:e("/list-short-urls/1")})]})})})]})})]})},WAe=cr(HW,["TagsList","ShortUrlsList","CreateShortUrl","ShortUrlVisits","TagVisits","DomainVisits","OrphanVisits","NonOrphanVisits","Overview","EditShortUrl","ManageDomains","TagVisitsComparison","DomainVisitsComparison","ShortUrlVisitsComparison","ShortUrlRedirectRules"]),qAe=e=>L7({devTools:!1,reducer:nj({mercureInfo:e.mercureInfoReducer,shortUrlsList:e.shortUrlsListReducer,shortUrlCreation:e.shortUrlCreationReducer,shortUrlDeletion:e.shortUrlDeletionReducer,shortUrlEdition:e.shortUrlEditionReducer,shortUrlsDetails:e.shortUrlsDetailsReducer,shortUrlVisits:e.shortUrlVisitsReducer,shortUrlVisitsDeletion:e.shortUrlVisitsDeletionReducer,shortUrlVisitsComparison:e.shortUrlVisitsComparisonReducer,tagVisits:e.tagVisitsReducer,tagVisitsComparison:e.tagVisitsComparisonReducer,domainVisits:e.domainVisitsReducer,domainVisitsComparison:e.domainVisitsComparisonReducer,orphanVisits:e.orphanVisitsReducer,orphanVisitsDeletion:e.orphanVisitsDeletionReducer,nonOrphanVisits:e.nonOrphanVisitsReducer,tagsList:e.tagsListReducer,tagDelete:e.tagDeleteReducer,tagEdit:e.tagEditReducer,domainsList:e.domainsListReducer,visitsOverview:e.visitsOverviewReducer,shortUrlRedirectRules:e.shortUrlRedirectRulesReducer,shortUrlRedirectRulesSaving:e.setShortUrlRedirectRulesReducer}),middleware:t=>t({immutableCheck:!1,serializableCheck:!1})}),HAe=e=>{e.factory("Main",WAe),e.factory("store",qAe)},Ra=new N$,{container:GAe}=Ra,KAe=e=>t=>Object.fromEntries(e.map(r=>[r,t[r]])),YAe=(e,t)=>(...r)=>e[t](...r),ZAe=(e,t)=>({...e,[t]:YAe(GAe,t)}),jd=(e,t=[])=>o$(e?KAe(e):null,t.reduce(ZAe,{}));HAe(Ra);jTe(Ra,jd);QTe(Ra,jd);zAe(Ra,jd);YCe(Ra);HCe(Ra,jd);sPe(Ra,jd);aje(Ra);AEe(Ra,jd);let q8;const XAe=e=>({serverVersion:t,apiClient:r,settings:n,routesPrefix:i="",createNotFound:a,tagColorsStorage:o})=>{const s=kCe(t),c=M.useRef(void 0),[l,h]=M.useState(),p=qu(),g=M.useMemo(()=>p?M.Fragment:_$,[p]);return M.useEffect(()=>{q8=r,e.value("apiClientFactory",()=>q8),o&&e.value("TagColorsStorage",o);const{container:_}=e,{Main:b,store:w,loadMercureInfo:x,listTags:S,listDomains:C}=_;c.current=v.jsx(b,{createNotFound:a}),h(w),w.dispatch(x(n)),w.dispatch(S()),w.dispatch(C())},[r,a,n,o]),l?v.jsx(s$,{store:l,children:v.jsx(G7,{value:n??{},children:v.jsx(ACe,{value:s,children:v.jsx(ECe,{value:i,children:v.jsx(g,{children:c.current})})})})}):v.jsx(v.Fragment,{})},QAe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",JAe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",e3e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",t3e=()=>{delete n8.Icon.Default.prototype._getIconUrl,n8.Icon.Default.mergeOptions({iconRetinaUrl:JAe,iconUrl:QAe,shadowUrl:e3e})};t3e();const r3e=XAe(Ra);function V0(e){return t=>{const{resetSelectedServer:r}=t;return M.useEffect(()=>{r()},[r]),v.jsx(e,{...t})}}let n3e=class extends M.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){const{console:r=globalThis.console}=this.props;r.error(t)}render(){const{hasError:t}=this.state,{location:r=globalThis.location}=this.props;if(t)return v.jsxs(x7,{title:"Oops! This is awkward :S",children:[v.jsx("p",{children:"It seems that something went wrong. Try refreshing the page or just click this button."}),v.jsx("br",{}),v.jsx(Yi,{size:"lg",onClick:()=>r.reload(),children:"Take me back"})]});const{children:n}=this.props;return n}};const i3e=({id:e,name:t})=>v.jsxs(Xt,{to:`/server/${e}`,className:Te("servers-list__server-item","tw:flex tw:items-center tw:justify-between tw:gap-x-2 tw:px-4 tw:py-3","tw:rounded-none tw:hover:bg-lm-secondary tw:hover:dark:bg-dm-secondary","tw:border-b tw:last:border-0 tw:border-lm-border tw:dark:border-dm-border"),children:[v.jsx("span",{className:"tw:truncate",children:t}),v.jsx(He,{icon:GY})]}),GW=({servers:e,borderless:t})=>v.jsx(v.Fragment,{children:e.length>0&&v.jsx("div",{"data-testid":"list",className:Te("tw:w-full tw:border-lm-border tw:dark:border-dm-border","tw:md:max-h-56 tw:md:overflow-y-auto tw:-mb-1 tw:scroll-thin",{"tw:border-y":!t}),children:e.map(({id:r,name:n})=>v.jsx(i3e,{id:r,name:n},r))})}),KW=({color:e=Cp,className:t})=>v.jsx("svg",{className:t,viewBox:"0 0 512 512",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:v.jsxs("g",{fill:e,children:[v.jsx("path",{d:" M 23.71 85.08 C 17.22 49.81 49.44 14.86 85.08 18.12 C 118.83 19.21 145.72 53.33 139.45 86.37 C 155.64 102.30 171.32 118.83 187.87 134.36 C 198.32 111.73 208.84 89.12 219.57 66.62 C 226.05 53.84 243.47 48.74 255.73 56.27 C 263.76 62.10 270.34 69.69 277.25 76.75 C 286.28 86.61 285.72 102.89 276.31 112.31 C 223.38 165.37 170.38 218.37 117.35 271.34 C 107.72 280.99 91.01 281.25 81.11 271.86 C 74.39 264.94 66.82 258.69 61.24 250.77 C 53.72 238.52 58.85 221.07 71.64 214.62 C 94.11 203.87 116.72 193.38 139.33 182.91 C 123.81 166.36 107.30 150.68 91.37 134.49 C 60.20 140.28 27.37 116.78 23.71 85.08 Z"}),v.jsx("path",{d:" M 205.21 201.23 C 225.32 181.36 260.88 181.11 281.14 200.86 C 299.25 218.75 317.37 236.65 335.10 254.93 C 356.73 278.01 352.01 318.70 326.03 336.56 C 320.07 330.47 313.73 324.65 308.12 318.28 C 323.86 309.39 328.76 286.18 316.63 272.39 C 301.73 256.95 286.30 242.03 271.24 226.75 C 264.49 219.65 256.80 212.00 246.37 211.52 C 224.65 208.64 205.52 233.36 214.49 253.58 C 221.09 266.81 234.22 275.12 243.62 286.24 C 240.43 295.96 238.09 306.13 238.29 316.46 C 225.55 304.29 213.16 291.73 200.89 279.09 C 180.97 257.57 183.10 220.45 205.21 201.23 Z"}),v.jsx("path",{d:" M 273.90 352.07 C 252.28 328.99 256.98 288.31 282.96 270.46 C 288.93 276.54 295.26 282.36 300.88 288.72 C 285.14 297.62 280.23 320.82 292.38 334.61 C 307.27 350.05 322.70 364.96 337.75 380.25 C 344.51 387.35 352.20 395.00 362.64 395.48 C 384.35 398.37 403.49 373.64 394.51 353.42 C 387.92 340.18 374.78 331.88 365.38 320.76 C 368.56 311.04 370.91 300.86 370.71 290.54 C 383.45 302.70 395.84 315.27 408.11 327.91 C 428.03 349.43 425.90 386.55 403.78 405.77 C 383.68 425.64 348.13 425.89 327.86 406.14 C 309.75 388.25 291.60 370.37 273.90 352.07 Z"}),v.jsx("path",{d:" M 422.11 403.83 C 431.96 394.07 441.60 384.06 451.66 374.51 C 460.90 383.74 471.89 392.70 474.89 406.11 C 480.16 429.97 484.08 454.13 488.76 478.12 C 490.00 483.41 484.47 488.29 479.35 486.63 C 454.66 481.52 429.55 478.12 405.14 471.84 C 393.17 467.97 385.20 457.75 376.55 449.27 C 386.39 439.49 396.13 429.60 406.06 419.91 C 416.37 433.45 435.74 414.00 422.11 403.83 Z"})]})}),a3e=({servers:e})=>{const t=fo(),r=Object.values(e),n=r.length>0;return M.useEffect(()=>{const i=r.find(({autoConnect:a})=>a);i&&t(`/server/${i.id}`)},[r,t]),v.jsx("div",{className:"tw:w-full",children:v.jsx(mi,{className:"tw:mx-auto tw:max-w-[720px] tw:overflow-hidden",children:v.jsxs("div",{className:"tw:flex tw:flex-col tw:md:flex-row",children:[v.jsx("div",{className:"tw:p-6 tw:hidden tw:md:flex tw:items-center tw:w-[40%]",children:v.jsx("div",{className:"tw:w-full",children:v.jsx(KW,{})})}),v.jsxs("div",{className:"tw:md:border-l tw:border-lm-border tw:dark:border-dm-border tw:flex-grow",children:[v.jsx("h1",{className:Te("tw:p-4 tw:text-center tw:border-lm-border tw:dark:border-dm-border",{"tw:border-b":!n}),children:"Welcome!"}),n?v.jsx(GW,{servers:r}):v.jsxs("div",{className:"tw:p-6 tw:text-center tw:flex tw:flex-col tw:gap-12 tw:text-xl",children:[v.jsx("p",{children:"This application will help you manage your Shlink servers."}),v.jsx("p",{children:v.jsxs(Yi,{to:"/server/create",size:"lg",inline:!0,children:[v.jsx(He,{icon:gm})," Add a server"]})}),v.jsx("p",{children:v.jsx(Gn,{href:"https://shlink.io/documentation",children:v.jsxs("small",{children:[v.jsx("span",{className:"tw:mr-2",children:"Learn more about Shlink"}),v.jsx(He,{icon:EY})]})})})]})]})]})})})},YW=()=>{const{ServersDropdown:e}=Ta(YW),[t,r,,n]=ir(),i=bn(),{pathname:a}=i;M.useEffect(n,[i,n]);const o="/settings";return v.jsxs(kF,{color:"primary",dark:!0,fixed:"top",expand:"md",className:"tw:text-white tw:bg-lm-brand tw:dark:bg-dm-brand",children:[v.jsxs(RF,{tag:Xt,to:"/",children:[v.jsx(KW,{className:"tw:inline tw:w-7 tw:mr-1",color:"white"})," Shlink"]}),v.jsx(NF,{onClick:r,children:v.jsx(He,{icon:WY,className:Te("tw:transition-transform tw:duration-300",{"tw:rotate-180":t})})}),v.jsx(KT,{navbar:!0,isOpen:t,children:v.jsxs($T,{navbar:!0,className:"tw:ml-auto",children:[v.jsx(FT,{children:v.jsxs(BT,{tag:Xt,to:o,active:a.startsWith(o),children:[v.jsx(He,{icon:ZY}),"  Settings"]})}),v.jsx(e,{})]})})]})},o3e=ja(YW,["ServersDropdown"]),s3e=({children:e})=>{const t=bn();return M.useEffect(()=>{scrollTo(0,0)},[t]),v.jsx(v.Fragment,{children:e})},ZW=V7(e=>e,e=>{try{return yP(e,e,"=")}catch{return!1}}),XW=e=>ZW(e)?`v${e}`:e,QW=(e,t="latest")=>ZW(e)?e:t,l3e="%_VERSION_%",u3e=e=>XW(QW(e)),H8=({project:e,version:t})=>v.jsx(Gn,{href:`https://github.com/shlinkio/${e}/releases/${t}`,className:"tw:text-gray-500",children:v.jsx("b",{children:t})}),c3e=({selectedServer:e,clientVersion:t=l3e})=>{const r=u3e(t);return v.jsxs("small",{className:"tw:text-gray-500",children:[vT(e)&&v.jsxs(v.Fragment,{children:["Server: ",v.jsx(H8,{project:"shlink",version:e.printableVersion})," - "]}),"Client: ",v.jsx(H8,{project:"shlink-web-client",version:r})]})},f3e=({selectedServer:e})=>v.jsx("div",{className:Te("tw:text-center",{"tw:md:ml-(--aside-menu-width)":vT(e)}),children:v.jsx(c3e,{selectedServer:e})}),Ad=({children:e,className:t})=>v.jsx("div",{className:Te("tw:container tw:mx-auto tw:p-5 tw:pt-8 tw:max-md:p-0 tw:max-md:py-4",t),children:e});function JW(e){const t=r=>{const{ServerError:n}=Ta(t),i=cd(),{selectServer:a,selectedServer:o}=r;return M.useEffect(()=>{i.serverId&&a(i.serverId)},[i.serverId,a]),o?KK(o)?v.jsx(n,{}):v.jsx(e,{...r}):v.jsx(Ad,{children:v.jsx(_7,{loading:!0})})};return t}const eq=JW(M.memo(({selectedServer:e,settings:t})=>{const{buildShlinkApiClient:r,TagColorsStorage:n,ShlinkWebComponent:i,ServerError:a}=Ta(eq);if(!vT(e))return v.jsx(a,{});const o=`/server/${e.id}`;return v.jsx(i,{serverVersion:e.version,apiClient:r(e),settings:t,routesPrefix:o,tagColorsStorage:n,createNotFound:s=>v.jsx(S7,{to:`${o}${s}`,children:"List short URLs"})})})),d3e=ja(eq,["buildShlinkApiClient","TagColorsStorage","ShlinkWebComponent","ServerError"]),h3e=(e,t)=>{e.constant("window",window),e.constant("console",console),e.constant("fetch",window.fetch.bind(window)),e.service("HttpClient",Soe,"fetch"),e.serviceFactory("ScrollToTop",()=>s3e),e.factory("MainHeader",o3e),e.serviceFactory("Home",()=>a3e),e.decorator("Home",V0),e.decorator("Home",t(["servers"],["resetSelectedServer"])),e.serviceFactory("ShlinkWebComponent",()=>r3e),e.factory("ShlinkWebComponentContainer",d3e),e.decorator("ShlinkWebComponentContainer",t(["selectedServer","settings"],["selectServer"])),e.serviceFactory("ShlinkVersionsContainer",()=>f3e),e.decorator("ShlinkVersionsContainer",t(["selectedServer"])),e.serviceFactory("ErrorHandler",()=>n3e)},tq=()=>{const e=fo();return M.useCallback(()=>e(-1),[e])};function p3e(e){let t=e.url;try{const{host:r,pathname:n}=new URL(t);t=r;const i=n.substring(1);i.length>0&&(t=`${t} ${i}`)}catch{}return`${e.name} ${t}`.toLowerCase().replace(/[^a-zA-Z0-9-_.~]/g,"-")}function m3e(e){const t={};return e.forEach(r=>{t[r.id]=r}),t}const v3e=(e,{url:t,apiKey:r})=>e.some(n=>n.url===t&&n.apiKey===r);function g3e(e,t){const r=Object.values(e),{duplicatedServers:n=[],newServers:i=[]}=z7(t,a=>v3e(r,a)?"duplicatedServers":"newServers");return{duplicatedServers:n,newServers:i}}function W0(e,t){const r=new Set(Object.keys(e)),n=[];return t.forEach(i=>{const a=p3e(i);let o=a,s=1;for(;r.has(o);)o=`${a}-${s}`,s++;n.push({...i,id:o}),r.add(o)}),n}const rq=({open:e,duplicatedServers:t,onClose:r,onConfirm:n})=>{const i=t.length>1;return v.jsxs(b7,{size:"lg",title:`Duplicated server${i?"s":""}`,open:e,onClose:r,onConfirm:n,confirmText:`Save duplicate${i?"s":""}`,cancelText:i?"Ignore duplicates":"Discard",children:[v.jsx("p",{children:i?"The next servers already exist:":"There is already a server with:"}),v.jsx("ul",{className:"tw:list-disc tw:mt-4",children:t.map(({url:a,apiKey:o},s)=>i?v.jsxs("li",{children:[v.jsx("b",{children:a})," - ",v.jsx("b",{children:o})]},s):v.jsxs(M.Fragment,{children:[v.jsxs("li",{children:["URL: ",v.jsx("b",{children:a})]}),v.jsxs("li",{children:["API key: ",v.jsx("b",{children:o})]})]},s))}),v.jsxs("span",{children:[i?"Do you want to save duplicated servers":"Do you want to save this server","?"]})]})},y3e=e=>t=>{t.preventDefault(),e()},nq=({onSubmit:e,initialValues:t,children:r,title:n})=>{const[i,a]=M.useState((t==null?void 0:t.name)??""),[o,s]=M.useState((t==null?void 0:t.url)??""),[c,l]=M.useState((t==null?void 0:t.apiKey)??""),h=y3e(()=>e({name:i,url:o,apiKey:c}));return v.jsxs("form",{name:"serverForm",onSubmit:h,children:[v.jsxs(ub,{className:"tw:mb-4",bodyClassName:"tw:flex tw:flex-col tw:gap-y-3",title:n,children:[v.jsx(bN,{label:"Name",value:i,onChange:p=>a(p.target.value),required:!0}),v.jsx(bN,{label:"URL",type:"url",value:o,onChange:p=>s(p.target.value),required:!0}),v.jsx(dae,{label:"API key",value:c,onChange:p=>l(p.target.value),required:!0})]}),v.jsx("div",{className:"tw:flex tw:items-center tw:justify-end tw:gap-x-2",children:r})]})},G8=4e3,K8=({variant:e})=>v.jsx("div",{className:"tw:mt-4",children:v.jsxs(w7,{variant:e,children:[e==="success"&&"Servers properly imported. You can now select one from the list :)",e==="error"&&"The servers could not be imported. Make sure the format is correct."]})}),iq=({servers:e,createServers:t})=>{const{ImportServersBtn:r,useTimeoutToggle:n}=Ta(iq),i=fo(),a=tq(),o=!!Object.keys(e).length,[s,c]=n(!1,G8),[l,h]=n(!1,G8),[p,g]=ir(),[_,b]=M.useState(),w=M.useCallback(S=>{const[C]=W0(e,[S]);t([C]),i(`/server/${C.id}`)},[t,i,e]),x=M.useCallback(S=>{b(S),Object.values(e).some(({url:P,apiKey:T})=>S.url===P&&S.apiKey===T)?g():w(S)},[w,e,g]);return v.jsxs(Ad,{children:[v.jsxs(nq,{title:"Add new server",onSubmit:x,children:[!o&&v.jsx(r,{tooltipPlacement:"top",onImport:c,onError:h}),o&&v.jsx(Yi,{type:"button",variant:"secondary",onClick:a,children:"Cancel"}),v.jsx(Yi,{type:"submit",children:"Create server"})]}),s&&v.jsx(K8,{variant:"success"}),l&&v.jsx(K8,{variant:"error"}),v.jsx(rq,{open:p,duplicatedServers:_?[_]:[],onClose:a,onConfirm:()=>_&&w(_)})]})},b3e=ja(iq,["ImportServersBtn","useTimeoutToggle"]),aq=({server:e,children:t})=>{const{DeleteServerModal:r}=Ta(aq),[n,,i,a]=ir(),o=fo(),s=M.useCallback(c=>{a(),c&&o("/")},[a,o]);return v.jsxs(v.Fragment,{children:[v.jsx("button",{type:"button",className:"tw:text-danger tw:hover:underline",onClick:i,children:t}),v.jsx(r,{server:e,open:n,onClose:s})]})},_3e=ja(aq,["DeleteServerModal"]),w3e=({server:e,onClose:t,open:r,deleteServer:n})=>{const i=M.useCallback(a=>{a==="confirm"&&n(e)},[n,e]);return v.jsx(b7,{open:r,title:"Remove server",variant:"danger",onClose:()=>t(!1),onConfirm:()=>t(!0),onClosed:i,confirmText:"Delete",children:v.jsxs("div",{className:"tw:flex tw:flex-col tw:gap-y-4",children:[v.jsxs("p",{children:["Are you sure you want to remove ",v.jsx("b",{children:e?e.name:""}),"?"]}),v.jsx("p",{children:v.jsx("i",{children:"No data will be deleted, only the access to this server will be removed from this device. You can create it again at any moment."})})]})})},x3e=JW(({editServer:e,selectedServer:t,selectServer:r})=>{const n=tq(),{reconnect:i}=hd();if(!Zh(t))return null;const a=o=>{e(t.id,o),i==="true"&&r(t.id),n()};return v.jsx(Ad,{children:v.jsxs(nq,{title:v.jsxs(v.Fragment,{children:['Edit "',t.name,'"']}),initialValues:t,onSubmit:a,children:[v.jsx(Yi,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),v.jsx(Yi,{children:"Save"})]})})}),S3e=ja(x3e,["ServerError"]),oq=({createServers:e,servers:t,children:r,onImport:n,onError:i=()=>{},tooltipPlacement:a="bottom",className:o=""})=>{const{ServersImporter:s}=Ta(oq),c=_i(),[l,h]=M.useState([]),[p,,g,_]=ir(),b=M.useRef(!1),w=M.useCallback(async({target:C})=>{var P;return s.importServersFromFile((P=C.files)==null?void 0:P[0]).then(T=>{const{duplicatedServers:A,newServers:j}=g3e(t,T);b.current=j.length>0,e(W0(t,j)),A.length>0?(h(A),g()):n==null||n()}).then(()=>{C.value=null}).catch(i)},[e,i,n,t,s,g]),x=M.useCallback(()=>{e(W0(t,l)),_(),n==null||n()},[e,l,_,n,t]),S=M.useCallback(()=>{_(),b.current&&(n==null||n())},[_,n]);return v.jsxs(v.Fragment,{children:[v.jsxs(Yi,{type:"button",variant:"secondary",id:"importBtn",className:o,onClick:()=>{var C;return(C=c.current)==null?void 0:C.click()},children:[v.jsx(He,{icon:gY,fixedWidth:!0})," ",r??"Import from file"]}),v.jsxs(Oi,{placement:a,target:"importBtn",children:["You can create servers by importing a CSV file with ",v.jsx("b",{children:"name"}),", ",v.jsx("b",{children:"apiKey"})," and ",v.jsx("b",{children:"url"})," columns."]}),v.jsx("input",{type:"file",accept:".csv",className:"tw:hidden","aria-hidden":!0,ref:c,onChange:w,"data-testid":"csv-file-input"}),v.jsx(rq,{open:p,duplicatedServers:l,onClose:S,onConfirm:x})]})},O3e=ja(oq,["ServersImporter"]),sq=({servers:e,selectedServer:t})=>{const{DeleteServerButton:r}=Ta(sq);return v.jsx(Ad,{children:v.jsxs("div",{className:"tw:flex tw:flex-col tw:items-center tw:gap-y-4 tw:md:gap-y-8",children:[v.jsxs(_7,{className:"tw:w-full tw:lg:w-[80%]",variant:"error",children:[!Zh(t)&&"Could not find this Shlink server.",Zh(t)&&v.jsxs(v.Fragment,{children:[v.jsx("p",{children:"Oops! Could not connect to this Shlink server."}),"Make sure you have internet connection, and the server is properly configured and on-line."]})]}),v.jsxs("p",{className:"tw:text-xl",children:["These are the Shlink servers currently configured. Choose one of them or ",v.jsx(Xt,{to:"/server/create",children:"add a new one"}),"."]}),v.jsx(mi,{className:"tw:w-full tw:max-w-100 tw:overflow-hidden",children:v.jsx(GW,{borderless:!0,servers:Object.values(e)})}),Zh(t)&&v.jsxs("p",{className:"tw:text-xl",children:["Alternatively, if you think you may have misconfigured this server, you can ",v.jsx(r,{server:t,children:"remove it"})," or ",v.jsx(Xt,{to:`/server/${t.id}/edit?reconnect=true`,children:"edit it"}),"."]})]})})},C3e=ja(sq,["DeleteServerButton"]),P3e=4e3,lq=({servers:e})=>{const{ServersExporter:t,ImportServersBtn:r,useTimeoutToggle:n,ManageServersRow:i}=Ta(lq),[a,o]=M.useState(""),s=M.useMemo(()=>Object.values(e),[e]),c=M.useMemo(()=>s.filter(({name:g,url:_})=>`${g} ${_}`.toLowerCase().match(a.toLowerCase())),[s,a]),l=s.some(({autoConnect:g})=>!!g),[h,p]=n(!1,P3e);return v.jsxs(Ad,{className:"tw:flex tw:flex-col tw:gap-y-4",children:[v.jsx(pae,{onChange:o}),v.jsxs("div",{className:"tw:flex tw:flex-col tw:md:flex-row tw:gap-2",children:[v.jsxs("div",{className:"tw:flex tw:gap-2",children:[v.jsx(r,{className:"tw:flex-grow",onError:p,children:"Import servers"}),c.length>0&&v.jsxs(Yi,{variant:"secondary",className:"tw:flex-grow",onClick:async()=>t.exportServers(),children:[v.jsx(He,{icon:B$})," Export servers"]})]}),v.jsxs(Yi,{className:"tw:md:ml-auto",to:"/server/create",children:[v.jsx(He,{icon:gm})," Add a server"]})]}),v.jsx(ub,{className:"card",children:v.jsxs(di,{header:v.jsxs(di.Row,{children:[l&&v.jsx(di.Cell,{className:"tw:w-[35px]",children:v.jsx("span",{className:"tw:sr-only",children:"Auto-connect"})}),v.jsx(di.Cell,{children:"Name"}),v.jsx(di.Cell,{children:"Base URL"}),v.jsx(di.Cell,{children:v.jsx("span",{className:"sr-only",children:"Options"})})]}),children:[!c.length&&v.jsx(di.Row,{className:"tw:text-center",children:v.jsx(di.Cell,{colSpan:4,children:"No servers found."})}),c.map(g=>v.jsx(i,{server:g,hasAutoConnect:l},g.id))]})}),h&&v.jsx("div",{children:v.jsx(w7,{variant:"error",children:"The servers could not be imported. Make sure the format is correct."})})]})},E3e=ja(lq,["ServersExporter","ImportServersBtn","useTimeoutToggle","ManageServersRow"]),uq=({server:e,hasAutoConnect:t})=>{const{ManageServersRowDropdown:r}=Ta(uq);return v.jsxs(di.Row,{className:"tw:relative",children:[t&&v.jsx(di.Cell,{columnName:"Auto-connect",children:e.autoConnect&&v.jsxs(v.Fragment,{children:[v.jsx(He,{icon:vp,className:"tw:text-brand",id:"autoConnectIcon"}),v.jsx(Oi,{target:"autoConnectIcon",placement:"right",children:"Auto-connect to this server"})]})}),v.jsx(di.Cell,{className:"tw:font-bold",columnName:"Name",children:v.jsx(Xt,{to:`/server/${e.id}`,children:e.name})}),v.jsx(di.Cell,{columnName:"Base URL",className:"tw:max-lg:border-b-0",children:e.url}),v.jsx(di.Cell,{className:"tw:text-right tw:max-lg:absolute tw:right-0 tw:-top-1 tw:mx-lg:pt-0",children:v.jsx(r,{server:e})})]})},T3e=ja(uq,["ManageServersRowDropdown"]),cq=({server:e,setAutoConnect:t})=>{const{DeleteServerModal:r}=Ta(cq),[n,,i,a]=ir(),o=`/server/${e.id}`,{autoConnect:s}=e,c=s?mY:ise;return v.jsxs(lb,{minWidth:s?210:170,children:[v.jsxs(Ze,{tag:Xt,to:o,children:[v.jsx(He,{icon:hY,fixedWidth:!0})," Connect"]}),v.jsxs(Ze,{tag:Xt,to:`${o}/edit`,children:[v.jsx(He,{icon:bT,fixedWidth:!0})," Edit server"]}),v.jsxs(Ze,{onClick:()=>t(e,!s),children:[v.jsx(He,{icon:c,fixedWidth:!0})," ",s?"Do not a":"A","uto-connect"]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{className:"tw:text-danger",onClick:i,children:[v.jsx(He,{icon:D$,fixedWidth:!0})," Remove server"]}),v.jsx(r,{server:e,open:n,onClose:a})]})},j3e=ja(cq,["DeleteServerModal"]),fq=(e,t)=>D7(e,t,{serializeError:r=>r}),A3e={},{actions:k3e,reducer:R3e}=Tr({name:"shlink/servers",initialState:A3e,reducers:{editServer:{prepare:(e,t)=>({payload:{serverId:e,serverData:t}}),reducer:(e,{payload:t})=>{const{serverId:r,serverData:n}=t;return e[r]?{...e,[r]:{...e[r],...n}}:e}},deleteServer:(e,{payload:t})=>(delete e[t.id],e),setAutoConnect:{prepare:({id:e},t)=>({payload:{serverId:e,autoConnect:t}}),reducer:(e,{payload:t})=>{const{serverId:r,autoConnect:n}=t;return e[r]?n?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,{...a,autoConnect:i===r}])):{...e,[r]:{...e[r],autoConnect:n}}:e}},createServers:{prepare:e=>({payload:m3e(e)}),reducer:(e,{payload:t})=>({...e,...t})}}}),{editServer:N3e,deleteServer:M3e,setAutoConnect:L3e,createServers:dq}=k3e,I3e=R3e,D3e=e=>W0({},Array.isArray(e)?e.filter(I$):[]),$3e=e=>fq("shlink/remoteServers/fetchServers",async(t,{dispatch:r})=>{const n=await e.jsonRequest(`${Qg.homepage}/servers.json`),i=D3e(n);r(dq(i))}),GA="shlink/selectedServer",F3e="1.0.0",B3e="999.999.999",U3e="latest",z3e=e=>QW(e===U3e?B3e:e,F3e),V3e=V7(e=>`${e.id}_${e.url}_${e.apiKey}`,async(e,t)=>t().then(({version:r})=>({version:z3e(r),printableVersion:XW(r)}))),Y8=null,KA=An(`${GA}/resetSelectedServer`),W3e=e=>fq(`${GA}/selectServer`,async(t,{dispatch:r,getState:n})=>{r(KA());const{servers:i}=n(),a=i[t];if(!a)return{serverNotFound:!0};try{const o=e(a),{version:s,printableVersion:c}=await V3e(a,()=>o.health());return{...a,version:s,printableVersion:c}}catch{return{...a,serverNotReachable:!0}}}),q3e=e=>Tr({name:GA,initialState:Y8,reducers:{},extraReducers:t=>{t.addCase(KA,()=>Y8),t.addCase(e.fulfilled,(r,{payload:n})=>n)}}),H3e=({servers:e,selectedServer:t})=>{const r=Object.values(e),n=()=>r.length===0?v.jsxs(Ze,{tag:Xt,to:"/server/create",children:[v.jsx(He,{icon:gm})," ",v.jsx("span",{className:"tw:ml-1",children:"Add a server"})]}):v.jsxs(v.Fragment,{children:[r.map(({name:i,id:a})=>v.jsx(Ze,{tag:Xt,to:`/server/${a}`,active:YK(t)===a,children:i},a)),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{tag:Xt,to:"/manage-servers",children:[v.jsx(He,{icon:eR})," ",v.jsx("span",{className:"tw:ml-1",children:"Manage servers"})]})]});return v.jsxs(Cm,{nav:!0,inNavbar:!0,children:[v.jsxs(is,{nav:!0,caret:!0,children:[v.jsx(He,{icon:eR})," ",v.jsx("span",{className:"tw:ml-1",children:"Servers"})]}),v.jsx(xl,{end:!0,classNam:"tw:right-0",children:n()})]})},G3e=({document:e},t,r)=>{const n=e.createElement("a");n.setAttribute("href",t),n.setAttribute("download",r),n.style.visibility="hidden",e.body.appendChild(n),n.click(),e.body.removeChild(n)},K3e=(e,t,r)=>{const n=new Blob([t],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(n);G3e(e,i,r)},Y3e="shlink-servers.csv";class Z3e{constructor(t,r,n){Bc(this,"exportServers",async()=>{const t=Object.values(this.storage.get("servers")??{}).map(ZK);try{const r=this.jsonToCsv(t);K3e(this.window,r,Y3e)}catch(r){console.error(r)}});this.storage=t,this.window=r,this.jsonToCsv=n}}const X3e=e=>typeof e.url=="string"&&typeof e.apiKey=="string"&&typeof e.name=="string",Q3e=e=>Array.isArray(e)&&e.every(X3e);class J3e{constructor(t){this.csvToJson=t}async importServersFromFile(t){if(!t)throw new Error("No file provided");const r=await t.text(),n=await this.csvToJson(r);if(!Q3e(n))throw new Error("Provided file does not have the right format.");return n}}const eke=(e,t)=>{e.factory("ManageServers",E3e),e.decorator("ManageServers",V0),e.decorator("ManageServers",t(["selectedServer","servers"],["resetSelectedServer"])),e.factory("ManageServersRow",T3e),e.factory("ManageServersRowDropdown",j3e),e.decorator("ManageServersRowDropdown",t(null,["setAutoConnect"])),e.factory("CreateServer",b3e),e.decorator("CreateServer",V0),e.decorator("CreateServer",t(["selectedServer","servers"],["createServers","resetSelectedServer"])),e.factory("EditServer",S3e),e.decorator("EditServer",t(["selectedServer"],["editServer","selectServer","resetSelectedServer"])),e.serviceFactory("ServersDropdown",()=>H3e),e.decorator("ServersDropdown",t(["servers","selectedServer"])),e.serviceFactory("DeleteServerModal",()=>w3e),e.decorator("DeleteServerModal",t(null,["deleteServer"])),e.factory("DeleteServerButton",_3e),e.factory("ImportServersBtn",O3e),e.decorator("ImportServersBtn",t(["servers"],["createServers"])),e.factory("ServerError",C3e),e.decorator("ServerError",t(["servers","selectedServer"])),e.service("ServersImporter",J3e,"csvToJson"),e.service("ServersExporter",Z3e,"Storage","window","jsonToCsv"),e.serviceFactory("selectServer",W3e,"buildShlinkApiClient","loadMercureInfo"),e.serviceFactory("createServers",()=>dq),e.serviceFactory("deleteServer",()=>M3e),e.serviceFactory("editServer",()=>N3e),e.serviceFactory("setAutoConnect",()=>L3e),e.serviceFactory("fetchServers",$3e,"HttpClient"),e.serviceFactory("resetSelectedServer",()=>KA),e.serviceFactory("selectedServerReducerCreator",q3e,"selectServer"),e.serviceFactory("selectedServerReducer",r=>r.reducer,"selectedServerReducerCreator")},hq={field:"dateCreated",dir:"DESC"},tke={realTimeUpdates:{enabled:!0},shortUrlCreation:{validateUrls:!1},ui:{theme:JT()},visits:{defaultInterval:"last30Days"},shortUrlsList:{defaultOrdering:hq}},{reducer:rke,actions:nke}=Tr({name:"shlink/settings",initialState:tke,reducers:{setSettings:(e,{payload:t})=>pb(e,t)}}),{setSettings:ike}=nke,ake=rke,oke=({settings:e,setSettings:t})=>v.jsx(Ad,{children:v.jsx(tse,{settings:e,updateSettings:t,defaultShortUrlsListOrdering:hq})}),ske=(e,t)=>{e.serviceFactory("Settings",()=>oke),e.decorator("Settings",V0),e.decorator("Settings",t(["settings"],["setSettings","resetSelectedServer"])),e.serviceFactory("setSettings",()=>ike)};var OO,Z8;function lke(){return Z8||(Z8=1,OO=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(n,i,a){r.o(n,i)||Object.defineProperty(n,i,{enumerable:!0,get:a})},r.r=function(n){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,i){if(1&i&&(n=r(n)),8&i||4&i&&typeof n=="object"&&n&&n.__esModule)return n;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:n}),2&i&&typeof n!="string")for(var o in n)r.d(a,o,(function(s){return n[s]}).bind(null,o));return a},r.n=function(n){var i=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(i,"a",i),i},r.o=function(n,i){return Object.prototype.hasOwnProperty.call(n,i)},r.p="",r(r.s=32)}([function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(r=window)}e.exports=r},function(e,t,r){var n=r(6),i=Object.keys||function(b){var w=[];for(var x in b)w.push(x);return w};e.exports=p;var a=r(5);a.inherits=r(2);var o=r(23),s=r(14);a.inherits(p,o);for(var c=i(s.prototype),l=0;lt in e?xCe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ll=(e,t,r)=>SCe(e,typeof t!="symbol"?t+"":t,r);const OCe=e=>(e==null?void 0:e.type)===oj.INVALID_ARGUMENT,CCe=e=>(e==null?void 0:e.type)===oj.INVALID_SHORT_URL_DELETION,PCe=e=>!!e&&typeof e=="object"&&["type","detail","title","status"].every(t=>t in e),Ci=e=>PCe(e)?e:void 0,wA=e=>"error"in e,uo=({errorData:e,fallbackMessage:t})=>v.jsxs(v.Fragment,{children:[(e==null?void 0:e.detail)??t,OCe(e)&&v.jsxs("p",{className:"mb-0",children:["Invalid elements: [",e.invalidElements.join(", "),"]"]})]}),Wu=({style:e,className:t,...r})=>v.jsx("button",{type:"button",className:Te("border-0",t),style:{backgroundColor:"inherit",fontWeight:"inherit",color:"inherit",...e},...r}),Gz=M.createContext(""),ECe=Gz.Provider,jl=()=>M.useContext(Gz),Kz=M.createContext(void 0),{Provider:xA}=Kz,Jb=()=>M.useContext(Kz),TCe=5,SA=()=>{const[e,t]=M.useState([]),r=M.useMemo(()=>e.length>=TCe,[e.length]),n=M.useCallback(s=>!r&&t(c=>[...c,s]),[r]),i=M.useCallback(s=>!r&&e.every(c=>c.name!==s),[e,r]),a=M.useCallback(s=>t(c=>c.filter(l=>l!==s)),[]),o=M.useCallback(()=>t([]),[]);return{itemsToCompare:e,addItemToCompare:n,removeItemToCompare:a,clearItemsToCompare:o,canAddItemWithName:i}},OA=({className:e,type:t})=>{const r=jl(),n=Jb(),i=M.useMemo(()=>n?encodeURIComponent(n.itemsToCompare.map(c=>c.query).join(",")):"",[n]);if(!n||n.itemsToCompare.length===0)return null;const{itemsToCompare:a,clearItemsToCompare:o,removeItemToCompare:s}=n;return v.jsx("div",{className:Te("top-sticky",e),children:v.jsxs(Sr,{bodyClassName:"d-md-flex gap-3 align-items-center",children:[v.jsx("ul",{className:"d-flex flex-wrap gap-1 flex-grow-1 p-0 m-0",children:a.map((c,l)=>{var h;return v.jsxs("li",{className:Te("badge pe-1",{"bg-secondary":!((h=c.style)!=null&&h.backgroundColor)}),style:c.style,children:[c.name,v.jsx(Wu,{"aria-label":`Remove ${c.name}`,className:"fw-bold fs-6",onClick:()=>s(c),children:"×"})]},`${c.name}_${l}`)})}),v.jsxs("div",{className:"d-flex mt-3 mt-md-0",children:[v.jsxs(Lt,{outline:!0,color:"primary",className:"flex-grow-1 indivisible",disabled:a.length<2,tag:Xt,to:`${r}/${t}/compare-visits?${t}=${i}`,children:[v.jsx(He,{icon:X0,fixedWidth:!0,className:"me-1"}),"Compare (",a.length,"/5) »"]}),v.jsx(Lt,{"aria-label":"Close compare",outline:!0,color:"secondary",className:"ms-2 fw-bold",onClick:o,children:"×"})]})]})})},jCe=(e,{maxVersion:t,minVersion:r})=>{const n=!r||yP(e,r,">=");return(!t||yP(e,t,"<="))&&n},Yz={shortUrlVisitsDeletion:{minVersion:"3.6.0"},orphanVisitsDeletion:{minVersion:"3.7.0"},deviceLongUrls:{maxVersion:"3.*.*"},shortUrlRedirectRules:{minVersion:"4.0.0"},qrCodeColors:{minVersion:"4.0.0"},urlValidation:{maxVersion:"3.*.*"},ipRedirectCondition:{minVersion:"4.2.0"},geolocationRedirectCondition:{minVersion:"4.3.0"},filterShortUrlsByDomain:{minVersion:"4.3.0"}};Object.freeze(Yz);const Do=(e,t)=>jCe(t==="latest"?"999.99.99":t,Yz[e]),Zz=e=>({deviceLongUrls:Do("deviceLongUrls",e),shortUrlVisitsDeletion:Do("shortUrlVisitsDeletion",e),orphanVisitsDeletion:Do("orphanVisitsDeletion",e),shortUrlRedirectRules:Do("shortUrlRedirectRules",e),qrCodeColors:Do("qrCodeColors",e),urlValidation:Do("urlValidation",e),ipRedirectCondition:Do("ipRedirectCondition",e),geolocationRedirectCondition:Do("geolocationRedirectCondition",e),filterShortUrlsByDomain:Do("filterShortUrlsByDomain",e)}),Xz=M.createContext(Zz("0.0.0")),ACe=Xz.Provider,kCe=e=>M.useMemo(()=>Zz(e),[e]),Ca=e=>M.useContext(Xz)[e],ad="DEFAULT",Gg=({className:e="",placement:t,children:r})=>{const n=_i();return v.jsxs(v.Fragment,{children:[v.jsx("span",{className:e,ref:n,children:v.jsx(He,{icon:wT})}),v.jsx(Oi,{target:n,placement:t,children:r})]})},Qz=e=>t=>{t.preventDefault(),e()},CA=(e,t,r=1)=>sj(r,e+1).map(t),RCe=e=>Array.isArray(e)&&e.length===0||typeof e=="string"&&e===""||typeof e=="object"&&Object.keys(e).length===0,vu=e=>e!=null&&!RCe(e),pO=e=>e||null,YE=e=>e?"true":"false",mO=e=>e===void 0?void 0:YE(e),vO=({isLast:e,...t})=>v.jsx(Yie,{...t,required:!1,type:"url",placeholder:"No redirect",className:e?"mb-0":""}),NCe=({isOpen:e,toggle:t,domain:r,editDomainRedirects:n})=>{var i,a,o;const[s,c]=M.useState(((i=r.redirects)==null?void 0:i.baseUrlRedirect)??""),[l,h]=M.useState(((a=r.redirects)==null?void 0:a.regular404Redirect)??""),[p,g]=M.useState(((o=r.redirects)==null?void 0:o.invalidShortUrlRedirect)??""),_=Qz(async()=>n({domain:r.domain,redirects:{baseUrlRedirect:pO(s),regular404Redirect:pO(l),invalidShortUrlRedirect:pO(p)}}).then(t));return v.jsx(Ji,{isOpen:e,toggle:t,centered:!0,children:v.jsxs("form",{name:"domainRedirectsModal",onSubmit:_,children:[v.jsxs(Sl,{toggle:t,children:["Edit redirects for ",v.jsx("b",{children:r.domain})]}),v.jsxs(as,{children:[v.jsxs(vO,{value:s,onChange:c,children:[v.jsxs(Gg,{className:"me-2",placement:"bottom",children:["Visitors accessing the base url, as in ",v.jsxs("b",{children:["https://",r.domain,"/"]}),", will be redirected to this URL."]}),"Base URL"]}),v.jsxs(vO,{value:l,onChange:h,children:[v.jsxs(Gg,{className:"me-2",placement:"bottom",children:["Visitors accessing a url not matching a short URL pattern, as in ",v.jsxs("b",{children:["https://",r.domain,"/???/[...]"]}),", will be redirected to this URL."]}),"Regular 404"]}),v.jsxs(vO,{value:p,isLast:!0,onChange:g,children:[v.jsx(Gg,{className:"me-2",placement:"bottom",children:"Visitors accessing a url matching a short URL pattern, but not matching an existing short code, will be redirected to this URL."}),"Invalid short URL"]})]}),v.jsxs(Hu,{children:[v.jsx(Lt,{color:"link",type:"button",onClick:t,children:"Cancel"}),v.jsx(Lt,{color:"primary",children:"Save"})]})]})})},MCe=({domain:e,editDomainRedirects:t})=>{const[r,n]=ir(),i=jl(),a=Jb(),o=Ca("filterShortUrlsByDomain");return v.jsxs(lb,{children:[v.jsxs(Ze,{tag:Xt,to:`${i}/domain/${e.domain}${e.isDefault?`_${ad}`:""}/visits`,children:[v.jsx(He,{icon:_T,fixedWidth:!0})," Visit stats"]}),v.jsxs(Ze,{disabled:!a||!a.canAddItemWithName(e.domain),onClick:()=>a==null?void 0:a.addItemToCompare({name:e.domain,query:e.domain}),children:[v.jsx(He,{icon:X0,fixedWidth:!0})," Compare visits"]}),o&&v.jsxs(Ze,{tag:Xt,to:`${i}/list-short-urls/1?domain=${e.isDefault?ad:e.domain}`,children:[v.jsx(He,{icon:yT,fixedWidth:!0})," Short URLs"]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{onClick:n,children:[v.jsx(He,{icon:bT,fixedWidth:!0})," Edit redirects"]}),v.jsx(NCe,{domain:e,isOpen:r,toggle:n,editDomainRedirects:t})]})},LCe=(e,t)=>{const r=n=>i=>{i.event.composedPath().some(({classList:a})=>a==null?void 0:a.contains("visits-table"))||document.querySelector(".modal")||n()};return Boe({delta:40,onSwipedLeft:r(t),onSwipedRight:r(e)})},ICe=(e,t)=>{const[r,n]=M.useState(t),i=M.useCallback(a=>{const{location:o,history:s}=window,c=h7(o.search);c[e]=a,s.pushState(null,"",`${o.pathname}?${sb(c)}`),n(a)},[e]);return[r,i]},PA=e=>{const t=hd();return M.useMemo(()=>{var r;return((r=t[e])==null?void 0:r.split(",").filter(Boolean))??[]},[e,t])},DCe=()=>{const e=fo();return M.useCallback(()=>e(-1),[e])},EA=(e,t)=>{const r=M.useCallback(()=>t(`(max-width: ${e}px)`).matches,[t,e]),[n,i]=M.useState(r());return M.useEffect(()=>{const a=()=>i(r());return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[r]),n},$Ce=(e,t,r)=>{M.useEffect(()=>{if(!r)return()=>{};const n=i=>i.key===e&&t();return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[r,t,e])},FCe=({status:e,matchMedia:t=window.matchMedia})=>{const r=_i(),n=EA(991,t);return e==="validating"?v.jsx(He,{fixedWidth:!0,icon:gT,spin:!0}):v.jsxs(v.Fragment,{children:[v.jsx("span",{ref:r,children:e==="valid"?v.jsx(He,{fixedWidth:!0,icon:vp,className:"text-muted"}):v.jsx(He,{fixedWidth:!0,icon:kO,className:"text-danger"})}),v.jsx(Oi,{target:r,placement:n?"right":"left",autohide:e==="valid",children:e==="valid"?"Congratulations! This domain is properly configured.":v.jsxs("span",{children:["Oops! There is some missing configuration, and short URLs shared with this domain will not work.",v.jsx("br",{}),"Check the ",v.jsx(Gn,{href:"https://slnk.to/multi-domain-docs",children:"documentation"})," in order to find out what is missing."]})})]})},gO=({fallback:e})=>v.jsxs("span",{className:"text-muted",children:[!e&&v.jsx("small",{children:"No redirect"}),e&&v.jsxs(v.Fragment,{children:[e," ",v.jsx("small",{children:"(as fallback)"})]})]}),BCe=()=>v.jsxs(v.Fragment,{children:[v.jsx(He,{fixedWidth:!0,icon:cY,className:"text-primary",id:"defaultDomainIcon"}),v.jsx(Oi,{target:"defaultDomainIcon",placement:"right",children:"Default domain"})]}),UCe=({domain:e,editDomainRedirects:t,checkDomainHealth:r,defaultRedirects:n})=>{const{domain:i,isDefault:a,redirects:o,status:s}=e;return M.useEffect(()=>{r(e.domain)},[r,e.domain]),v.jsxs("tr",{className:"responsive-table__row",children:[v.jsx("td",{className:"responsive-table__cell","data-th":"Is default domain",children:a&&v.jsx(BCe,{})}),v.jsx("th",{className:"responsive-table__cell","data-th":"Domain",children:i}),v.jsx("td",{className:"responsive-table__cell","data-th":"Base path redirect",children:(o==null?void 0:o.baseUrlRedirect)??v.jsx(gO,{fallback:n==null?void 0:n.baseUrlRedirect})}),v.jsx("td",{className:"responsive-table__cell","data-th":"Regular 404 redirect",children:(o==null?void 0:o.regular404Redirect)??v.jsx(gO,{fallback:n==null?void 0:n.regular404Redirect})}),v.jsx("td",{className:"responsive-table__cell","data-th":"Invalid short URL redirect",children:(o==null?void 0:o.invalidShortUrlRedirect)??v.jsx(gO,{fallback:n==null?void 0:n.invalidShortUrlRedirect})}),v.jsx("td",{className:"responsive-table__cell text-lg-center","data-th":"Status",children:v.jsx(FCe,{status:s})}),v.jsx("td",{className:"responsive-table__cell text-end",children:v.jsx(MCe,{domain:e,editDomainRedirects:t})})]})},a8=[{value:"Is default domain",isHidden:!0},{value:"Domain",isHidden:!1},{value:"Base path redirect",isHidden:!1},{value:"Regular 404 redirect",isHidden:!1},{value:"Invalid short URL redirect",isHidden:!1},{value:"Domain status",isHidden:!0},{value:"Options",isHidden:!0}],zCe=({domainsList:e,filterDomains:t,editDomainRedirects:r,checkDomainHealth:n})=>{var i;const{filteredDomains:a,defaultRedirects:o,loading:s,error:c,errorData:l}=e,h=o??((i=a.find(({isDefault:g})=>g))==null?void 0:i.redirects),p=SA();return s?v.jsx(Lu,{loading:!0}):v.jsxs(xA,{value:p,children:[v.jsx(ob,{className:"mb-3",onChange:t}),v.jsx(OA,{type:"domains",className:"mb-3"}),c?v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:l,fallbackMessage:"Error loading domains :("})}):v.jsx(Sr,{children:v.jsxs("table",{className:"table table-hover responsive-table mb-0",children:[v.jsx("thead",{className:"responsive-table__header",children:v.jsx("tr",{children:a8.map((g,_)=>v.jsx("th",{children:v.jsx("span",{className:g.isHidden?"sr-only":void 0,children:g.value})},_))})}),v.jsxs("tbody",{children:[a.length<1&&v.jsx("tr",{children:v.jsx("td",{colSpan:a8.length,className:"text-center",children:"No results found"})}),a.map(g=>v.jsx(UCe,{domain:g,editDomainRedirects:r,checkDomainHealth:n,defaultRedirects:h},g.domain))]})]})})]})},Vr=(e,t)=>D7(e,t,{serializeError:r=>r}),VCe="shlink/domainRedirects/EDIT_DOMAIN_REDIRECTS",WCe=e=>Vr(VCe,async({domain:t,redirects:r})=>{const n=await e().editDomainRedirects({domain:t,...r});return{domain:t,redirects:n}}),jg="shlink/domainsList",Ag={domains:[],filteredDomains:[],loading:!1,error:!1},o8=({domain:e,redirects:t})=>r=>r.domain!==e?r:{...r,redirects:t},s8=(e,t)=>r=>r.domain!==e?r:{...r,status:t},qCe=(e,t,r)=>{const n=Vr(`${jg}/listDomains`,async()=>{const{data:s,defaultRedirects:c}=await e().listDomains();return{domains:s.map(l=>({...l,status:"validating"})),defaultRedirects:c}}),i=Vr(`${jg}/checkDomainHealth`,async s=>{try{const{status:c}=await e().health({domain:s});return{domain:s,status:c==="pass"?"valid":"invalid"}}catch{return{domain:s,status:"invalid"}}}),a=An(`${jg}/filterDomains`),{reducer:o}=Tr({name:jg,initialState:Ag,reducers:{},extraReducers:s=>{s.addCase(n.pending,()=>({...Ag,loading:!0})),s.addCase(n.rejected,(c,{error:l})=>({...Ag,error:!0,errorData:Ci(l)})),s.addCase(n.fulfilled,(c,{payload:l})=>({...Ag,...l,filteredDomains:l.domains})),s.addCase(i.fulfilled,({domains:c,filteredDomains:l,...h},{payload:p})=>({...h,domains:c.map(s8(p.domain,p.status)),filteredDomains:l.map(s8(p.domain,p.status))})),s.addCase(a,(c,{payload:l})=>({...c,filteredDomains:c.domains.filter(({domain:h})=>h.toLowerCase().match(l.toLowerCase()))})),s.addCase(t.fulfilled,(c,{payload:l})=>({...c,domains:c.domains.map(o8(l)),filteredDomains:c.filteredDomains.map(o8(l))})),s.addCase(r.fulfilled,(c,{payload:l})=>{l.domain===null||c.domains.some(h=>h.domain===l.domain)||c.domains.push({domain:l.domain,status:"validating",isDefault:!1,redirects:{baseUrlRedirect:null,regular404Redirect:null,invalidShortUrlRedirect:null}})})}});return{reducer:o,listDomains:n,checkDomainHealth:i,filterDomains:a}},HCe=(e,t)=>{e.serviceFactory("ManageDomains",()=>zCe),e.decorator("ManageDomains",t(["domainsList"],["filterDomains","editDomainRedirects","checkDomainHealth"])),e.serviceFactory("domainsListReducerCreator",qCe,"apiClientFactory","editDomainRedirects","createShortUrl"),e.serviceFactory("domainsListReducer",r=>r.reducer,"domainsListReducerCreator"),e.serviceFactory("listDomains",r=>r.listDomains,"domainsListReducerCreator"),e.serviceFactory("filterDomains",r=>r.filterDomains,"domainsListReducerCreator"),e.serviceFactory("editDomainRedirects",WCe,"apiClientFactory"),e.serviceFactory("checkDomainHealth",r=>r.checkDomainHealth,"domainsListReducerCreator")},l8="shlink/mercure",GCe={loading:!0,error:!1},KCe=e=>{const t=Vr(`${l8}/loadMercureInfo`,n=>{if(n&&n.realTimeUpdates&&!n.realTimeUpdates.enabled)throw new Error("Real time updates not enabled");return e().mercureInfo()}),{reducer:r}=Tr({name:l8,initialState:GCe,reducers:{},extraReducers:n=>{n.addCase(t.pending,i=>({...i,loading:!0,error:!1})),n.addCase(t.rejected,i=>({...i,loading:!1,error:!0})),n.addCase(t.fulfilled,(i,{payload:a})=>({...a,loading:!1,error:!1}))}});return{loadMercureInfo:t,reducer:r}},YCe=e=>{e.serviceFactory("mercureInfoReducerCreator",KCe,"apiClientFactory"),e.serviceFactory("mercureInfoReducer",t=>t.reducer,"mercureInfoReducerCreator"),e.serviceFactory("loadMercureInfo",t=>t.loadMercureInfo,"mercureInfoReducerCreator")};function ur(e){return M.useMemo(()=>e,[e])}function cr(e,t){return(r,n=globalThis.console)=>(t.forEach(i=>{const a=r[i];e[i]=a}),e)}const ZCe=(e,t,r,n)=>{const{mercureHubUrl:i,token:a,loading:o,error:s}=e;if(o||s||!i)return;const c=({data:p})=>r(JSON.parse(p)),l=({status:p})=>p===401&&n(),h=t.map(p=>{const g=new URL(i);g.searchParams.append("topic",p);const _=new Voe.EventSourcePolyfill(g,{headers:{Authorization:`Bearer ${a}`}});return _.onmessage=c,_.onerror=l,_});return()=>h.forEach(p=>p.close())};function ka(e,t){const r=new Set;return n=>{const{createNewVisits:i,loadMercureInfo:a,mercureInfo:o}=n,s=cd();return M.useEffect(()=>{const{interval:c}=o,l=_=>c?r.add(_):i([_]),h=t(s),p=ZCe(o,h,l,a);if(!c)return p;const g=setInterval(()=>{i([...r]),r.clear()},c*1e3*60);return()=>{clearInterval(g),p==null||p()}},[i,a,o,s]),v.jsx(e,{...n})}}class Rn{}ll(Rn,"visits","https://shlink.io/new-visit"),ll(Rn,"orphanVisits","https://shlink.io/new-orphan-visit"),ll(Rn,"shortUrlVisits",e=>`https://shlink.io/new-visit/${e}`);const Ed=An("shlink/visitCreation/createNewVisits",e=>({payload:{createdVisits:e}})),dp=(e,t,r)=>r==null?e.shortCode===t&&!e.domain:e.shortCode===t&&e.domain===r,XCe=(e,t)=>!e.domain&&t===ad?!0:e.domain===t,QCe=(e,t)=>{const r=(t==null?void 0:t.validateUrls)??!1;return e?{longUrl:e.longUrl,tags:e.tags,title:e.title??void 0,domain:e.domain??void 0,validSince:e.meta.validSince??void 0,validUntil:e.meta.validUntil??void 0,maxVisits:e.meta.maxVisits??void 0,crawlable:e.crawlable,forwardQuery:e.forwardQuery,deviceLongUrls:e.deviceLongUrls&&{android:e.deviceLongUrls.android??void 0,ios:e.deviceLongUrls.ios??void 0,desktop:e.deviceLongUrls.desktop??void 0},validateUrl:r}:{longUrl:"",validateUrl:r}},Jz=e=>e.replaceAll("/","__"),TA=e=>e.replaceAll("__","/"),jA=({domain:e,shortCode:t})=>`${e??ad}__${Jz(t)}`,eV=e=>{const[t,r]=e.split(/__(.+)/);if(!r)throw new Error(`It was not possible to parse domain and short code from "${e}"`);return{domain:t===ad?null:t,shortCode:TA(r)}},AA="shlink/shortUrlDeletion",u8={shortCode:"",loading:!1,deleted:!1,error:!1},JCe=e=>Vr(`${AA}/deleteShortUrl`,async({shortCode:t,domain:r})=>(await e().deleteShortUrl({shortCode:t,domain:r}),{shortCode:t,domain:r})),tV=An(`${AA}/shortUrlDeleted`),ePe=e=>{const{actions:t,reducer:r}=Tr({name:AA,initialState:u8,reducers:{resetDeleteShortUrl:()=>u8},extraReducers:i=>{i.addCase(e.pending,a=>({...a,loading:!0,error:!1,deleted:!1})),i.addCase(e.rejected,(a,{error:o})=>({...a,errorData:Ci(o),loading:!1,error:!0,deleted:!1})),i.addCase(e.fulfilled,(a,{payload:o})=>({...a,shortCode:o.shortCode,loading:!1,error:!1,deleted:!0}))}}),{resetDeleteShortUrl:n}=t;return{reducer:r,resetDeleteShortUrl:n}},rV="shlink/shortUrlsList",nV=5,tPe={loading:!0,error:!1},rPe=e=>Vr(`${rV}/listShortUrls`,t=>e().listShortUrls(t??{})),nPe=(e,t,r)=>Tr({name:rV,initialState:tPe,reducers:{},extraReducers:n=>{n.addCase(e.pending,i=>({...i,loading:!0,error:!1})),n.addCase(e.rejected,()=>({loading:!1,error:!0})),n.addCase(e.fulfilled,(i,{payload:a})=>({loading:!1,error:!1,shortUrls:a})),n.addCase(r.fulfilled,(i,{payload:a})=>{i.shortUrls&&(i.shortUrls.data=[a,...i.shortUrls.data.slice(0,nV-1)],i.shortUrls.pagination.totalItems+=1)}),n.addCase(t.fulfilled,(i,{payload:a})=>{i.shortUrls&&(i.shortUrls.data=i.shortUrls.data.map(o=>{const{shortCode:s,domain:c}=a;return dp(o,s,c)?a:o}))}),n.addCase(tV,(i,{payload:a})=>{i.shortUrls&&(i.shortUrls.data=i.shortUrls.data.filter(o=>!dp(o,a.shortCode,a.domain)),i.shortUrls.pagination.totalItems-=1)}),n.addCase(Ed,(i,{payload:a})=>{i.shortUrls&&(i.shortUrls.data=i.shortUrls.data.map(o=>{var s;return((s=a.createdVisits.findLast(({shortUrl:c})=>c&&dp(o,c.shortCode,c.domain)))==null?void 0:s.shortUrl)??o}))})}}),iPe=new Intl.NumberFormat("en-US"),Or=e=>iPe.format(Number(e)),c8=10,aPe=e=>Math.ceil(e/c8)*c8,ZE=({children:e,title:t,link:r,tooltip:n})=>{const i=_i();return v.jsxs(v.Fragment,{children:[v.jsxs(Qi,{innerRef:i,className:"highlight-card",body:!0,tag:Xt,to:r,children:[v.jsx(He,{size:"3x",className:"highlight-card__link-icon",icon:nse}),v.jsx(r7,{className:"lh-sm fw-semibold text-uppercase fs-5 highlight-card__title",children:t}),v.jsx(t7,{className:"fs-2 fw-semibold lh-sm",children:e})]}),n&&v.jsx(Oi,{target:i,placement:"bottom",children:n})]})},f8=({loading:e,excludeBots:t,visitsSummary:r,...n})=>v.jsx(ZE,{tooltip:r.bots!==void 0?v.jsxs(v.Fragment,{children:[t?"Plus":"Including"," ",v.jsx("strong",{children:Or(r.bots)})," potential bot visits"]}):void 0,...n,children:e?"Loading...":Or(t&&r.nonBots!==void 0?r.nonBots:r.total)}),d8=({children:e,titleLinkText:t,titleLink:r,title:n})=>v.jsxs(Qi,{children:[v.jsxs(Sm,{className:"d-flex justify-content-between align-items-center",children:[v.jsx("span",{className:"d-sm-none",children:n}),v.jsx("h5",{className:"d-none d-sm-inline m-0",children:n}),v.jsxs(Xt,{to:r,children:[t," »"]})]}),v.jsx(xm,{children:e})]}),iV=ka(({shortUrlsList:e,listShortUrls:t,tagsList:r,loadVisitsOverview:n,visitsOverview:i})=>{const{ShortUrlsTable:a,CreateShortUrl:o}=ur(iV),{loading:s,shortUrls:c}=e,{loading:l}=r,{loading:h,nonOrphanVisits:p,orphanVisits:g}=i,_=jl(),b=fo(),w=Nn("visits");return M.useEffect(()=>{t({itemsPerPage:nV,orderBy:{field:"dateCreated",dir:"DESC"}}),n()},[t,n]),v.jsxs(v.Fragment,{children:[v.jsxs(Za,{children:[v.jsx("div",{className:"col-lg-6 col-xl-3 mb-3",children:v.jsx(f8,{title:"Visits",link:`${_}/non-orphan-visits`,excludeBots:(w==null?void 0:w.excludeBots)??!1,loading:h,visitsSummary:p})}),v.jsx("div",{className:"col-lg-6 col-xl-3 mb-3",children:v.jsx(f8,{title:"Orphan visits",link:`${_}/orphan-visits`,excludeBots:(w==null?void 0:w.excludeBots)??!1,loading:h,visitsSummary:g})}),v.jsx("div",{className:"col-lg-6 col-xl-3 mb-3",children:v.jsx(ZE,{title:"Short URLs",link:`${_}/list-short-urls/1`,children:s?"Loading...":Or((c==null?void 0:c.pagination.totalItems)??0)})}),v.jsx("div",{className:"col-lg-6 col-xl-3 mb-3",children:v.jsx(ZE,{title:"Tags",link:`${_}/manage-tags`,children:l?"Loading...":Or(r.tags.length)})})]}),v.jsxs("div",{className:"d-flex flex-column gap-3",children:[v.jsx(d8,{title:"Create a short URL",titleLinkText:"Advanced options",titleLink:`${_}/create-short-url`,children:v.jsx(o,{basicMode:!0})}),v.jsx(d8,{title:"Recently created URLs",titleLinkText:"See all",titleLink:`${_}/list-short-urls/1`,children:v.jsx(a,{shortUrlsList:e,className:"mb-0",onTagClick:x=>b(`${_}/list-short-urls/1?tags=${encodeURIComponent(x)}`)})})]})]})},()=>[Rn.visits,Rn.orphanVisits]),oPe=cr(iV,["ShortUrlsTable","CreateShortUrl"]);function sPe(e,t){e.factory("Overview",oPe),e.decorator("Overview",t(["shortUrlsList","tagsList","mercureInfo","visitsOverview"],["listShortUrls","createNewVisits","loadMercureInfo","loadVisitsOverview"]))}const aV="shlink/setShortUrlRedirectRules",h8={saving:!1,saved:!1,error:!1},lPe=e=>Vr(`${aV}/setShortUrlRedirectRules`,({shortUrl:t,data:r})=>{const{shortCode:n,domain:i}=t;return e().setShortUrlRedirectRules({shortCode:n,domain:i},r)}),uPe=e=>{const{reducer:t,actions:r}=Tr({name:aV,initialState:h8,reducers:{resetSetRules:()=>h8},extraReducers:i=>{i.addCase(e.pending,()=>({saving:!0,saved:!1,error:!1})),i.addCase(e.rejected,(a,{error:o})=>({saving:!1,saved:!1,error:!0,errorData:Ci(o)})),i.addCase(e.fulfilled,()=>({saving:!1,error:!1,saved:!0}))}}),{resetSetRules:n}=r;return{reducer:t,resetSetRules:n}},oV="shlink/getShortUrlRedirectRules",cPe={loading:!0,error:!1},fPe=e=>Vr(`${oV}/getShortUrlRedirectRules`,({shortCode:t,domain:r})=>e().getShortUrlRedirectRules({shortCode:t,domain:r})),dPe=e=>Tr({name:oV,initialState:cPe,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({loading:!0,error:!1})),t.addCase(e.rejected,()=>({loading:!1,error:!0})),t.addCase(e.fulfilled,(r,{payload:n})=>({loading:!1,error:!1,...n}))}});function sn(e){e.preventDefault()}function Al(e){e.stopPropagation()}function sV(){const e=new Map;return[function(t,r){e.get(t)&&e.get(t).forEach(n=>{n(r)})},function(t,r){const n=e.get(t)??[];n.push(r),e.set(t,n)}]}var[lV,uV]=sV();function hPe(e,t){return e.source===t.source&&e.flags.split("").sort().join("")===t.flags.split("").sort().join("")}function bf(e,t,r=!0,n=["__key"]){if(e===t)return!0;if(typeof t=="object"&&typeof e=="object"&&e!==null&&t!==null){if(e instanceof Map||e instanceof Set)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return hPe(e,t);if(e===null||t===null)return!1;const i=e,a=t;if(Object.keys(i).length!==Object.keys(a).length)return!1;for(const o of n)if((o in i||o in a)&&i[o]!==a[o])return!1;for(const o in i)if(!(o in a)||i[o]!==a[o]&&!r||r&&!bf(i[o],a[o],r,n))return!1;return!0}return!1}function cV(e){return e.split(" ").filter(t=>t)}function Td(e){return{x:e.clientX,y:e.clientY}}Array();var kA=typeof window<"u",gn=new WeakMap,co=new WeakMap;function p8(){return kA?"ontouchstart"in window||navigator.maxTouchPoints>0:!1}var pPe={activeDescendant:void 0,affectedNodes:[],coordinates:{x:0,y:0},currentTargetValue:void 0,on:uV,emit:lV,newActiveDescendant:void 0,originalZIndex:void 0,pointerSelection:!1,preventEnter:!1,rootUserSelect:void 0,nodePointerdown:void 0,longPress:!1,scrolling:!1,longPressTimeout:void 0,remapJustFinished:!1,selectedNodes:[],selectedParent:void 0,preventSynthDrag:!1,pointerDown:void 0},Ve=pPe,vl=!1,m8,v8,yO,od=!1,fm=!1;function mPe(){Ve={activeDescendant:void 0,affectedNodes:[],coordinates:{x:0,y:0},on:uV,emit:lV,currentTargetValue:void 0,originalZIndex:void 0,pointerId:void 0,preventEnter:!1,remapJustFinished:!1,selectedNodes:[],nodePointerdown:void 0,rootUserSelect:void 0,preventSynthDrag:!1,scrolling:!1,selectedParent:void 0,pointerSelection:!1,synthScrollDirection:void 0,draggedNodeDisplay:void 0,synthDragScrolling:!1,longPress:!1,pointerDown:void 0,longPressTimeout:void 0}}function fV(e){return Object.assign(Ve,e),e.initialParent.data.emit("dragStarted",Ve),vl=!1,Ve.emit("dragStarted",Ve),Ve}function vPe(e){Ve.activeState&&rs(Ve.activeState.parent,void 0,Ve),Ve.selectedState&&ul(Ve.selectedState.nodes,Ve.selectedState.parent,Ve),Ve.selectedState=Ve.activeState=void 0,e.pointerType==="mouse"?fm=!0:(e.pointerType==="touch"||e.pointerType==="pen")&&(fm=!1)}function gPe(e){if(sn(e),Ve.pointerDown&&(Ve.pointerDown.node.el.draggable=!0),Ve.pointerDown=void 0,!io(Ve))return;const t=Ve.currentParent.data.config;io(Ve)&&t.handleEnd(Ve)}function yPe(e){e.key==="Escape"&&(Ve.selectedState&&ul(Ve.selectedState.nodes,Ve.selectedState.parent,Ve),Ve.activeState&&rs(Ve.activeState.parent,void 0,Ve),Ve.selectedState=Ve.activeState=void 0)}function bPe(e){if(!no(Ve))return;vl=!0;const t=Ve.initialParent.data.config.handleEnd;t(Ve)}function _Pe(e){no(Ve)&&sn(e)}function wPe(e){if(!Ve.pointerDown||!Ve.pointerDown.validated)return;const t=Ve.pointerDown.parent.data.config;if(!(fm||e.pointerType==="mouse"))if(!io(Ve)&&(od||!od&&!t.nativeDrag)){if(sn(e),t.longPress&&!Ve.longPress){clearTimeout(Ve.longPressTimeout),Ve.longPress=!1;return}const r=t.draggedNodes(Ve.pointerDown);t.dragstartClasses(Ve.pointerDown.node,r,t,!0);const n=XPe(Ve.pointerDown.node,Ve.pointerDown.parent,e,Ve,r);Ve.rootUserSelect=window.getComputedStyle(document.documentElement).userSelect,document.body.style.userSelect="none",g8(e,n)}else io(Ve)&&g8(e,Ve)}function xPe({parent:e,getValues:t,setValues:r,config:n={}}){var i,a,o;if(!kA)return;if(od=p8(),!m8){m8=dm(document,{dragover:_Pe,pointerdown:vPe,pointerup:gPe,keydown:yPe,drop:bPe,pointermove:wPe,pointercancel:ci(n.handlePointercancel),touchmove:p=>{no(Ve)&&p.cancelable&&sn(p)}});const h=document.createElement("div");mV(h,{"aria-live":"polite","aria-atomic":"true","data-dnd-live-region":"true"}),Object.assign(h.style,{position:"absolute",top:"0px",left:"-9999px",width:"1px",height:"1px",padding:"0",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.appendChild(h)}v8||(v8=dm(window,{resize:()=>{od=p8()}})),pV(e);const[s,c]=sV(),l={getValues:t,setValues:r,config:{dragDropEffect:n.dragDropEffect??"move",dragEffectAllowed:n.dragEffectAllowed??"move",draggedNodes:LPe,dragstartClasses:FPe,handleNodeKeydown:UPe,handleParentKeydown:zPe,handleDragstart:DPe,handleNodeDragover:eEe,handleParentDragover:tEe,handleNodeDrop:WPe,handleNodeFocus:qPe,handleNodeBlur:HPe,handlePointercancel:KPe,handleEnd:YPe,handleDragend:GPe,handleParentFocus:OPe,handleNodePointerup:ZPe,handleNodePointerover:VPe,handleParentPointerover:rEe,handleParentScroll:IPe,handleNodePointerdown:$Pe,handleNodeDragenter:nEe,handleNodeDragleave:iEe,handleParentDrop:PPe,multiDrag:n.multiDrag??!1,nativeDrag:n.nativeDrag??!0,performSort:SPe,performTransfer:CPe,root:n.root??document,setupNode:TPe,setupNodeRemap:vV,reapplyDragClasses:jPe,tearDownNode:kPe,tearDownNodeRemap:APe,remapFinished:NPe,threshold:{horizontal:0,vertical:0},...n},enabledNodes:[],abortControllers:{},privateClasses:[],on:c,emit:s};new MutationObserver(RPe).observe(e,{childList:!0}),gn.set(e,l),(i=n.plugins)==null||i.forEach(h=>{var p,g;(g=(p=h(e))==null?void 0:p.tearDown)==null||g.call(p)}),(a=n.plugins)==null||a.forEach(h=>{var p,g;(g=(p=h(e))==null?void 0:p.tearDown)==null||g.call(p)}),(o=n.plugins)==null||o.forEach(h=>{var p,g;(g=(p=h(e))==null?void 0:p.setup)==null||g.call(p)}),EPe(e,l),e_(e,!0)}function dV(e,t,r,n,i,a){const{x:o,y:s}=Td(r),c=e.el.getBoundingClientRect();return{affectedNodes:[],ascendingDirection:!1,clonedDraggedEls:[],coordinates:{x:o,y:s},draggedNode:{el:e.el,data:e.data},draggedNodes:n,incomingDirection:void 0,initialIndex:e.data.index,initialParent:{el:t.el,data:t.data},currentParent:{el:t.el,data:t.data},longPress:t.data.config.longPress??!1,longPressTimeout:void 0,currentTargetValue:e.data.value,scrollEls:[],startLeft:i||o-c.left,startTop:a||s-c.top,targetIndex:e.data.index,transferred:!1}}function SPe({parent:e,draggedNodes:t,targetNodes:r}){e_(e.el);const n=t.map(c=>c.data.value),i=sd(e.el,e.data),a=t[0].data.index,o=[...e.data.enabledNodes],s=[...i.filter(c=>!n.some(l=>bf(c,l)))];s.splice(r[0].data.index,0,...n),"draggedNode"in Ve&&(Ve.currentTargetValue=r[0].data.value),XE(e.el,e.data,[...s]),e.data.config.onSort&&e.data.config.onSort({parent:{el:e.el,data:e.data},previousValues:[...i],previousNodes:[...o],nodes:[...e.data.enabledNodes],values:[...s],draggedNodes:t,previousPosition:a,position:r[0].data.index,targetNodes:r,state:Ve})}function rs(e,t,r){var n;const i=e.data.config.activeDescendantClass;if(r.activeState&&(xa([r.activeState.node.el],i),r.activeState.parent.el!==e.el&&r.activeState.parent.el.setAttribute("aria-activedescendant","")),!t){(n=r.activeState)==null||n.parent.el.setAttribute("aria-activedescendant",""),r.activeState=void 0;return}r.activeState={node:t,parent:e},Au([t.el],i),r.activeState.parent.el.setAttribute("aria-activedescendant",r.activeState.node.el.id)}function ul(e,t,r){const n=t.data.config.selectedClass;if(!r.selectedState)return;const i=Array.from(e);xa(e.map(a=>a.el),n);for(const a of i){a.el.setAttribute("aria-selected","false");const o=r.selectedState.nodes.findIndex(s=>s.el===a.el);o!==-1&&r.selectedState.nodes.splice(o,1)}hV(t)}function Ou(e,t,r,n,i=!1){n.pointerSelection=i;for(const o of t)o.el.setAttribute("aria-selected","true"),Au([o.el],e.data.config.selectedClass,!0);n.selectedState={nodes:t,parent:e};const a=t.map(o=>o.el.getAttribute("aria-label"));if(a.length===0){n.selectedState=void 0,hV(e);return}rs(e,r,n),Kg(e,`${a.join(", ")} ready for dragging. Use arrow keys to navigate. Press enter to drop ${a.join(", ")}.`)}function Kg(e,t){const r=document.querySelector('[data-dnd-live-region="true"]');r&&(r.id=e.el.id+"-live-region",r.textContent=t)}function hV(e){const t=document.getElementById(e.el.id+"-live-region");t&&(t.textContent="")}function OPe(e,t){const r=e.targetData.parent.data.enabledNodes[0];r&&(t.selectedState&&t.selectedState.parent.el!==e.targetData.parent.el?rs(e.targetData.parent,r,t):t.selectedState||rs(e.targetData.parent,r,t))}function CPe({currentParent:e,targetParent:t,initialParent:r,draggedNodes:n,initialIndex:i,targetNodes:a,state:o}){e_(r.el);const s=n.map(g=>g.data.value),c=[...sd(e.el,e.data).filter(g=>!s.some(_=>bf(g,_)))],l=sd(t.el,t.data),h=r.el===t.el&&t.data.config.sortable===!1;let p;a.length?(h?p=i:t.data.config.sortable===!1?p=t.data.enabledNodes.length:p=a[0].data.index,l.splice(p,0,...s)):(p=h?i:t.data.enabledNodes.length,l.splice(p,0,...s)),XE(e.el,e.data,c),XE(t.el,t.data,l),t.data.config.onTransfer&&t.data.config.onTransfer({sourceParent:e,targetParent:t,initialParent:r,draggedNodes:n,targetIndex:p,state:o,targetNodes:a}),e.data.config.onTransfer&&e.data.config.onTransfer({sourceParent:e,targetParent:t,initialParent:r,draggedNodes:n,targetIndex:p,state:o,targetNodes:a||[]})}function sd(e,t){return[...t.getValues(e)]}function XE(e,t,r){t.setValues(r,e)}function PPe(e,t){Al(e.e),vl=!0;const r=t.initialParent.data.config.handleEnd;r(t)}function pV(e){const t=gn.get(e);t&&t.abortControllers.mainParent&&t.abortControllers.mainParent.abort()}function no(e){return"draggedNode"in e&&!!e.draggedNode}function io(e){return"synthDragging"in e&&!!e.synthDragging}function EPe(e,t){t.abortControllers.mainParent=dm(e,{keydown:Ih(t.config.handleParentKeydown),dragover:Ih(t.config.handleParentDragover),handleParentPointerover:t.config.handleParentPointerover,scroll:Ih(t.config.handleParentScroll),drop:Ih(t.config.handleParentDrop),hasNestedParent:r=>{const n=gn.get(r.target);n&&(n.nestedParent=r.detail.parent)},focus:Ih(t.config.handleParentFocus)}),t.config.externalDragHandle&&t.config.externalDragHandle.el&&t.config.externalDragHandle.callback&&(t.abortControllers.externalDragHandle=dm(t.config.externalDragHandle.el,{pointerdown:r=>{if(!t.config.externalDragHandle||!t.config.externalDragHandle.callback)return;const n=t.config.externalDragHandle.callback();if(!r_(n)){console.warn("No draggable item found from external drag handle callback");return}const i=co.get(n);if(!i)return;const a=n.parentNode;if(!(a instanceof HTMLElement))return;const o=gn.get(a);o&&(Ve.pointerDown={parent:{el:a,data:o},node:{el:n,data:i},validated:!0},n.draggable=!0)}})),e.id&&mV(e,{role:"listbox",tabindex:"0","aria-multiselectable":t.config.multiDrag?"true":"false","aria-activedescendant":"","aria-describedby":e.id+"-live-region"})}function mV(e,t){for(const r in t)e.setAttribute(r,t[r])}function TPe(e){var t;const r=e.parent.data.config;e.node.data.abortControllers.mainNode=dm(e.node.el,{keydown:ci(r.handleNodeKeydown),dragstart:ci(r.handleDragstart),dragover:ci(r.handleNodeDragover),dragenter:ci(r.handleNodeDragenter),dragleave:ci(r.handleNodeDragleave),dragend:ci(r.handleDragend),drop:ci(r.handleNodeDrop),focus:ci(r.handleNodeFocus),blur:ci(r.handleNodeBlur),pointerup:ci(r.handleNodePointerup),pointercancel:ci(r.handlePointercancel),pointerdown:ci(r.handleNodePointerdown),handleNodePointerover:r.handleNodePointerover,touchmove:n=>{no(Ve)&&n.cancelable&&sn(n)},contextmenu:n=>{od&&sn(n)}}),e.node.el.setAttribute("role","option"),e.node.el.setAttribute("aria-selected","false"),e.node.el.draggable=!0,r.reapplyDragClasses(e.node.el,e.parent.data),(t=e.parent.data.config.plugins)==null||t.forEach(n=>{var i,a;(a=(i=n(e.parent.el))==null?void 0:i.setupNode)==null||a.call(i,e)})}function vV(e){var t;co.set(e.node.el,e.node.data),(t=e.parent.data.config.plugins)==null||t.forEach(r=>{var n,i;(i=(n=r(e.parent.el))==null?void 0:n.setupNodeRemap)==null||i.call(n,e)})}function jPe(e,t){if(!no(Ve))return;const r=io(Ve)?t.config.synthDropZoneClass:t.config.dropZoneClass;Ve.draggedNode.el===e&&Au([e],r,!0)}function APe(e){var t;(t=e.parent.data.config.plugins)==null||t.forEach(r=>{var n,i;(i=(n=r(e.parent.el))==null?void 0:n.tearDownNodeRemap)==null||i.call(n,e)})}function kPe(e){var t,r,n,i,a;(t=e.parent.data.config.plugins)==null||t.forEach(o=>{var s,c;(c=(s=o(e.parent.el))==null?void 0:s.tearDownNode)==null||c.call(s,e)}),e.node.el.draggable=!1,(n=(r=e.node.data)==null?void 0:r.abortControllers)!=null&&n.mainNode&&((a=(i=e.node.data)==null?void 0:i.abortControllers)==null||a.mainNode.abort())}function RPe(e){if(e.length===1&&e[0].addedNodes.length===1&&!(e[0].addedNodes[0]instanceof HTMLElement))return;const t=e[0].target;if(!(t instanceof HTMLElement))return;const r=document.querySelectorAll('[aria-selected="true"]'),n=gn.get(t);if(n){for(let i=0;i_.data.value===p.value);g&&(g.el=l)}s.push({el:l,data:p}),(t||!h)&&a.setupNode({parent:{el:e,data:n},node:{el:l,data:p}}),vV({parent:{el:e,data:n},node:{el:l,data:p}})}gn.set(e,{...n,enabledNodes:s}),a.remapFinished(n),(r=n.config.plugins)==null||r.forEach(c=>{var l,h;(h=(l=c(e))==null?void 0:l.remapFinished)==null||h.call(l)})}function NPe(){Ve.remapJustFinished=!0,"draggedNode"in Ve&&(Ve.affectedNodes=[])}function MPe(e){return!!e.targetData.parent.data.config.nativeDrag}function LPe(e){var t;if(e.parent.data.config.multiDrag){if(Ve.selectedState)return[e.node,...(t=Ve.selectedState)==null?void 0:t.nodes.filter(r=>r.el!==e.node.el)]}else return[e.node];return[]}function IPe(e){no(Ve)&&(Ve.emit("scrollStarted",Ve),!io(Ve)&&(Ve.preventEnter=!0,yO&&clearTimeout(yO),yO=setTimeout(()=>{Ve.preventEnter=!1,Ve.emit("scrollEnded",Ve)},100)))}function DPe(e,t){const r=e.targetData.parent.data.config;if(!r.nativeDrag||!MPe(e)||!gV({x:e.e.clientX,y:e.e.clientY,node:e.targetData.node,config:r})){sn(e.e);return}const n=r.draggedNodes({parent:e.targetData.parent,node:e.targetData.node});r.dragstartClasses(e.targetData.node,n,r);const i=BPe(e,n);r.onDragstart&&r.onDragstart({parent:e.targetData.parent,values:sd(e.targetData.parent.el,e.targetData.parent.data),draggedNode:i.draggedNode,draggedNodes:i.draggedNodes,position:i.initialIndex,state:i})}function $Pe(e,t){var r,n;if(Al(e.e),t.pointerDown={parent:e.targetData.parent,node:e.targetData.node,validated:!1},e.e.pointerType==="mouse"?fm=!0:(e.e.pointerType==="touch"||e.e.pointerType==="pen")&&(fm=!1),!gV({x:e.e.clientX,y:e.e.clientY,node:e.targetData.node,config:e.targetData.parent.data.config}))return;t.pointerDown={parent:e.targetData.parent,node:e.targetData.node,validated:!0},QPe(e,t,e.targetData.node);const i=e.targetData.parent.data;let a=[e.targetData.node];const o=e.e.ctrlKey||e.e.metaKey,s=e.e.shiftKey,c=e.targetData.node;if(o&&i.config.multiDrag){t.selectedState?t.selectedState.nodes.findIndex(l=>l.el===c.el)===-1?a=[...t.selectedState.nodes,c]:a=t.selectedState.nodes.filter(l=>l.el!==c.el):a=[c],Ou(e.targetData.parent,a,e.targetData.node,t,!0);return}if(s&&i.config.multiDrag){const l=e.targetData.parent.data.enabledNodes;if(t.selectedState&&t.activeState)if(t.selectedState.parent.el!==e.targetData.parent.el){ul(t.selectedState.nodes,t.selectedState.parent,t),t.selectedState=void 0;for(let h=0;h<=c.data.index;h++)a.push(l[h])}else{const[h,p]=t.activeState.node.data.indexl.el===e.targetData.node.el)===-1&&(t.selectedState.parent.el!==e.targetData.parent.el?ul(t.selectedState.nodes,e.targetData.parent,t):i.config.multiDrag&&od?a.push(...t.selectedState.nodes):ul(t.selectedState.nodes,e.targetData.parent,t),Ou(e.targetData.parent,a,e.targetData.node,t,!0)):Ou(e.targetData.parent,[e.targetData.node],e.targetData.node,t,!0)}function FPe(e,t,r,n=!1){Au(t.map(i=>i.el),n?r.synthDraggingClass:r.draggingClass),setTimeout(()=>{xa(t.map(i=>i.el),n?r.synthDraggingClass:r.draggingClass),Au(t.map(i=>i.el),n?r.synthDragPlaceholderClass:r.dragPlaceholderClass),Au(t.map(i=>i.el),n?r.synthDropZoneClass:r.dropZoneClass),xa(t.map(i=>i.el),r.activeDescendantClass),xa(t.map(i=>i.el),r.selectedClass)})}function BPe(e,t){Al(e.e);const r=fV(dV(e.targetData.node,e.targetData.parent,e.e,t));if(e.e.dataTransfer){const n=e.targetData.parent.data.config;e.e.dataTransfer.dropEffect=n.dragDropEffect,e.e.dataTransfer.effectAllowed=n.dragEffectAllowed;let i;if(n.dragImage)i=n.dragImage(e,t);else{if(n.multiDrag){const a=document.createElement("div");for(const s of t){const c=s.el.cloneNode(!0);c.style.pointerEvents="none",c.id=s.el.id+"-clone",a.append(c)}const{width:o}=t[0].el.getBoundingClientRect();Object.assign(a.style,{display:"flex",flexDirection:"column",width:`${o}px`,position:"absolute",pointerEvents:"none",zIndex:"9999",left:"-9999px"}),i=a}else{e.e.dataTransfer.setDragImage(e.targetData.node.el,e.e.offsetX,e.e.offsetY);const a=e.targetData.node.el.style.zIndex;return r.originalZIndex=a,e.targetData.node.el.style.zIndex="9999",r}document.body.appendChild(i)}e.e.dataTransfer.setDragImage(i,e.e.offsetX,e.e.offsetY),setTimeout(()=>{i==null||i.remove()})}return r}function gV({x:e,y:t,node:r,config:n}){if(n.externalDragHandle)return!1;if(!n.dragHandle)return!0;const i=r.el.querySelectorAll(n.dragHandle);if(!i)return!1;const a=n.root.elementFromPoint(e,t);if(!a)return!1;for(const o of Array.from(i))if(a===o||o.contains(a))return!0;return!1}function UPe(e){}function zPe(e,t){var r;const n=(r=t.activeState)==null?void 0:r.node;if(!n)return;const i=e.targetData.parent.data,a=i.enabledNodes;if(!(e.e.target instanceof HTMLElement))return;const o=a.findIndex(s=>s.el===n.el);if(o!==-1){if(["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(e.e.key)){e.e.target===e.targetData.parent.el&&sn(e.e);const s=e.e.key==="ArrowDown"||e.e.key==="ArrowRight"?o+1:o-1;if(s<0||s>=a.length)return;const c=a[s];rs(e.targetData.parent,c,t)}else if(e.e.key===" ")e.e.target===e.targetData.parent.el&&sn(e.e),t.selectedState&&t.selectedState.nodes.includes(n)?Ou(e.targetData.parent,t.selectedState.nodes.filter(s=>s.el!==n.el),n,t):Ou(e.targetData.parent,[n],n,t);else if(e.e.key==="Enter"&&t.selectedState)if(t.selectedState.parent.el===e.targetData.parent.el&&t.activeState){if(t.selectedState.nodes[0].el===t.activeState.node.el){Kg(e.targetData.parent,"Cannot drop item on itself");return}t.newActiveDescendant=t.selectedState.nodes[0],i.config.performSort({parent:e.targetData.parent,draggedNodes:t.selectedState.nodes,targetNodes:[t.activeState.node]}),ul([],e.targetData.parent,t),Kg(e.targetData.parent,"Drop successful")}else t.activeState&&t.selectedState.parent.el!==e.targetData.parent.el&&bV({currentParent:e.targetData.parent,targetParent:t.selectedState.parent,initialParent:t.selectedState.parent,draggedNodes:t.selectedState.nodes,state:t})&&(i.config.performTransfer({currentParent:t.selectedState.parent,targetParent:e.targetData.parent,initialParent:t.selectedState.parent,draggedNodes:t.selectedState.nodes,initialIndex:t.selectedState.nodes[0].data.index,state:t,targetNodes:[t.activeState.node]}),t.newActiveDescendant=t.selectedState.nodes[0],Ou(e.targetData.parent,[],void 0,t),Kg(e.targetData.parent,"Drop successful"))}}function VPe(e){e.detail.targetData.parent.el===e.detail.state.currentParent.el?_V(e.detail,e.detail.state):t_(e.detail,e.detail.state)}function WPe(e,t){const r=e.targetData.parent.data.config;r.nativeDrag&&(Al(e.e),vl=!0,r.handleEnd(t))}function qPe(e){e.e.target!==e.e.currentTarget&&Ve.pointerDown&&(Ve.pointerDown.node.el.draggable=!1)}function HPe(e){e.e.target!==e.e.currentTarget&&Ve.pointerDown&&(Ve.pointerDown.node.el.draggable=!0)}function GPe(e,t){const r=e.targetData.parent.data.config;if(r.nativeDrag){if(sn(e.e),Al(e.e),vl){vl=!1;return}r.handleEnd(t)}}function KPe(e,t){var r;if(!io(t))return;if(sn(e.e),vl){vl=!1;return}const n=(r=gn.get(t.initialParent.el))==null?void 0:r.config;n!=null&&n.onDragend&&n.onDragend({parent:t.currentParent,values:sd(t.currentParent.el,t.currentParent.data),draggedNode:t.draggedNode,draggedNodes:t.draggedNodes,state:t}),n==null||n.handleEnd(t)}function YPe(e){var t,r,n,i,a,o;e.draggedNode&&(e.draggedNode.el.draggable=!0),document.body.style.userSelect=e.rootUserSelect||"",io(e)&&(document.documentElement.style.overscrollBehavior=e.rootOverScrollBehavior||"",document.documentElement.style.touchAction=e.rootTouchAction||""),io(e)&&yV(e),"longPressTimeout"in e&&e.longPressTimeout&&clearTimeout(e.longPressTimeout);const s=(t=gn.get(e.initialParent.el))==null?void 0:t.config,c=io(e),l=c?s==null?void 0:s.synthDropZoneClass:s==null?void 0:s.dropZoneClass;e.originalZIndex!==void 0&&(e.draggedNode.el.style.zIndex=e.originalZIndex),xa(e.draggedNodes.map(h=>h.el),l),xa(e.draggedNodes.map(h=>h.el),(n=(r=e.initialParent.data)==null?void 0:r.config)==null?void 0:n.longPressClass),xa(e.draggedNodes.map(h=>h.el),c?e.initialParent.data.config.synthDragPlaceholderClass:(a=(i=e.initialParent.data)==null?void 0:i.config)==null?void 0:a.dragPlaceholderClass),c&&e.clonedDraggedNode.remove(),ul(e.draggedNodes,e.currentParent,e),rs(e.currentParent,void 0,e),mPe(),e.selectedState=void 0,(o=s==null?void 0:s.onDragend)==null||o.call(s,{parent:e.currentParent,values:sd(e.currentParent.el,e.currentParent.data),draggedNode:e.draggedNode,draggedNodes:e.draggedNodes,state:e}),e.emit("dragEnded",e)}function ZPe(e,t){Al(e.e),!t.pointerSelection&&t.selectedState&&ul(t.selectedState.nodes,e.targetData.parent,t);const r=e.targetData.parent.data.config;t.pointerSelection=!1,"longPressTimeout"in t&&t.longPressTimeout&&clearTimeout(t.longPressTimeout),xa(e.targetData.parent.data.enabledNodes.map(n=>n.el),r.longPressClass),no(t)&&r.handleEnd(t)}function XPe(e,t,r,n,i){var a,o;const s=t.data.config;let c,l=e.el.style.display,h;if(s.synthDragImage)h=s.synthDragImage(e,t,r,i),c=h.dragImage,c.setAttribute("popover","manual"),c.id="dnd-dragged-node-clone",l=c.style.display,Object.assign(c.style,{position:"absolute",zIndex:9999,pointerEvents:"none",margin:0,willChange:"transform",overflow:"hidden",display:"none"});else if(!s.multiDrag||i.length===1)c=e.el.cloneNode(!0),c.id="dnd-dragged-node-clone",l=c.style.display,c.setAttribute("popover","manual"),Object.assign(c.style,{position:"absolute",height:e.el.getBoundingClientRect().height+"px",width:e.el.getBoundingClientRect().width+"px",overflow:"hidden",margin:0,willChange:"transform",pointerEvents:"none",zIndex:9999});else{const _=document.createElement("div");_.setAttribute("popover","manual");for(const b of i){const w=b.el.cloneNode(!0);w.style.pointerEvents="none",w.style.margin="0",_.append(w)}l=_.style.display,_.id="dnd-dragged-node-clone",c=_,Object.assign(c.style,{display:"flex",flexDirection:"column",position:"absolute",overflow:"hidden",margin:0,padding:0,pointerEvents:"none",zIndex:9999})}c.style.position="absolute",t.el.appendChild(c),c.showPopover();const p={clonedDraggedEls:[],clonedDraggedNode:c,draggedNodeDisplay:l,synthDragScrolling:!1,synthDragging:!0,rootScrollWidth:(a=document.scrollingElement)==null?void 0:a.scrollWidth,rootScrollHeight:(o=document.scrollingElement)==null?void 0:o.scrollHeight,rootOverScrollBehavior:document.documentElement.style.overscrollBehavior,rootTouchAction:document.documentElement.style.touchAction};document.documentElement.style.overscrollBehavior="none",document.documentElement.style.touchAction="none";const g=fV({...dV(e,t,r,i,h==null?void 0:h.offsetX,h==null?void 0:h.offsetY),...p});return g.clonedDraggedNode.style.display=g.draggedNodeDisplay||"",g}function QPe(e,t,r){const n=e.targetData.parent.data.config;n.longPress&&(t.longPressTimeout=setTimeout(()=>{t&&(t.longPress=!0,n.longPressClass&&e.e.cancelable&&Au([r.el],n.longPressClass),sn(e.e))},n.longPressDuration||200))}function JPe(e,t){t.longPressClass&&xa(e.draggedNodes.map(r=>r.el),t==null?void 0:t.longPressClass)}function yV(e,t=!0,r=!0){t&&e.animationFrameIdX!==void 0&&(cancelAnimationFrame(e.animationFrameIdX),e.animationFrameIdX=void 0),r&&e.animationFrameIdY!==void 0&&(cancelAnimationFrame(e.animationFrameIdY),e.animationFrameIdY=void 0),!e.animationFrameIdX&&!e.animationFrameIdY&&(e.preventEnter=!1)}function RA(e,t,r=0,n=0){const{x:i,y:a}=Td(e);t.coordinates.y=a,t.coordinates.x=i;const o=t.startLeft??0,s=t.startTop??0,c=i-o+window.scrollX,l=a-s+window.scrollY;t.clonedDraggedNode.style.transform=`translate(${c+r}px, ${l+n}px)`,e.cancelable&&sn(e),JPe(t,t.initialParent.data.config)}function g8(e,t){RA(e,t);const r=Td(e);fEe(r,e,t);const n=dEe(r);if(!n){document.dispatchEvent(new CustomEvent("handleRootPointerover",{detail:{e,state:t}}));return}const i={e,targetData:n,state:t};"node"in n?n.node.el.dispatchEvent(new CustomEvent("handleNodePointerover",{detail:i})):n.parent.el.dispatchEvent(new CustomEvent("handleParentPointerover",{detail:i}))}function eEe(e,t){var r;if(!e.targetData.parent.data.config.nativeDrag)return;const{x:n,y:i}=Td(e.e);t.coordinates.y=i,t.coordinates.x=n,sn(e.e),Al(e.e),e.targetData.parent.el===((r=t.currentParent)==null?void 0:r.el)?_V(e,t):t_(e,t)}function tEe(e,t){e.targetData.parent.data.config.nativeDrag&&(sn(e.e),Al(e.e),Object.assign(Td(e.e)),t_(e,t))}function rEe(e){e.detail.targetData.parent.el!==e.detail.state.currentParent.el&&t_(e.detail,e.detail.state)}function bV({currentParent:e,targetParent:t,initialParent:r,draggedNodes:n,state:i}){if(t.el===e.el)return!1;const a=t.data.config;if(n[0].el.contains(t.el)||a.dropZone===!1)return!1;const o=r.data.config;return a.accepts?a.accepts(t,r,e,i):!(!a.group||a.group!==o.group)}function nEe(e,t){sn(e.e)}function iEe(e,t){sn(e.e)}function aEe(e,t,r,n){var i;if(t.affectedNodes.map(p=>p.data.value).includes(e.targetData.node.data.value))return!1;if(t.remapJustFinished)return t.remapJustFinished=!1,(e.targetData.node.data.value===t.currentTargetValue||t.draggedNodes.map(p=>p.el).includes(e.targetData.node.el))&&(t.currentTargetValue=e.targetData.node.data.value),!1;if(t.preventEnter)return!1;if(t.draggedNodes.map(p=>p.el).includes(e.targetData.node.el))return t.currentTargetValue=void 0,!1;if(e.targetData.node.data.value===t.currentTargetValue||e.targetData.parent.el!==((i=t.currentParent)==null?void 0:i.el)||e.targetData.parent.data.config.sortable===!1||e.targetData.node.el.contains(t.draggedNodes[0].el))return!1;const a=e.targetData.node.el.getBoundingClientRect(),o=t.draggedNode.el.getBoundingClientRect(),s=a.y-o.y,c=a.x-o.x;let l;Math.abs(s)>Math.abs(c)?l=s>0?"above":"below":l=c>0?"left":"right";const h=t.currentParent.data.config.threshold;switch(l){case"left":if(r>a.x+a.width*h.horizontal)return t.incomingDirection="left",!0;break;case"right":if(ra.y+a.height*h.vertical)return t.incomingDirection="above",!0;break;case"below":if(ne.targetData.node.data.index?[e.targetData.node.data.index,t.draggedNode.data.index]:[t.draggedNode.data.index,e.targetData.node.data.index];t.targetIndex=e.targetData.node.data.index,t.affectedNodes=e.targetData.parent.data.enabledNodes.filter(a=>i[0]<=a.data.index&&a.data.index<=i[1]&&a.el!==t.draggedNode.el),e.targetData.parent.data.config.performSort({parent:e.targetData.parent,draggedNodes:t.draggedNodes,targetNodes:[e.targetData.node]})}function ci(e){function t(r){const n=co.get(r);if(!n)return;const i=gn.get(r.parentNode);if(i)return{node:{el:r,data:n},parent:{el:r.parentNode,data:i}}}return r=>{const n=t(r.currentTarget);if(n)return e({e:r,targetData:n},Ve)}}function t_(e,t){e.e.preventDefault(),bV({currentParent:t.currentParent,targetParent:e.targetData.parent,initialParent:t.initialParent,draggedNodes:t.draggedNodes,state:t})&&(e.targetData.parent.data.config.performTransfer({currentParent:t.currentParent,targetParent:e.targetData.parent,initialParent:t.initialParent,draggedNodes:t.draggedNodes,initialIndex:t.initialIndex,state:t,targetNodes:"node"in e.targetData?[e.targetData.node]:[]}),t.currentParent=e.targetData.parent,t.transferred=!0)}function Ih(e){function t(r){const n=gn.get(r);if(n)return{parent:{el:r,data:n}}}return r=>{const n=t(r.currentTarget);if(n)return e({e:r,targetData:n},Ve)}}function Au(e,t,r=!1){function n(i,a){co.set(i,a)}for(const i of e){const a=co.get(i),o=oEe(i,t,a,r);o&&n(i,o)}}function oEe(e,t,r,n=!1){if(!t)return;const i=cV(t);if(!i.length||i.includes("longPress"))return;if(!r){e.classList.add(...i);return}const a=[];for(const o of i)e.classList.contains(o)?e.classList.contains(o)&&n===!1&&a.push(o):e.classList.add(o);return r.privateClasses=a,r}function xa(e,t){if(!t)return;const r=cV(t);if(r.length)for(const n of e){if(!r_(n)){n.classList.remove(...r);continue}const i=co.get(n)||gn.get(n);if(i)for(const a of r)i.privateClasses.includes(a)||n.classList.remove(a)}}function sEe(e,t,r,n,i){if(e===document.scrollingElement){const a=e.scrollLeft>0;return{right:e.scrollLeft+window.innerWidth<(i.rootScrollWidth||0)&&t.clientX>e.clientWidth*(1-.1),left:a&&t.clientXn.left+o*(1-.1)&&s0}}return{right:!1,left:!1}}function lEe(e,t,r,n){if(e===document.scrollingElement)return{down:t.clientY>e.clientHeight*(1-.1),up:t.clientYn.top+a*(1-.1)&&o0}}return{down:!1,up:!1}}function uEe(e,t,r,n=!0){r.preventEnter=!0;const i=n?5:-5;function a(o){o.scrollBy({left:i}),RA(t,r,i,0),r.animationFrameIdX=requestAnimationFrame(a.bind(null,o))}r.animationFrameIdX=requestAnimationFrame(a.bind(null,e))}function cEe(e,t,r,n=!0){r.preventEnter=!0;const i=n?-5:5;function a(){e.scrollBy({top:i}),RA(t,r,0,i),r.animationFrameIdY=requestAnimationFrame(a)}r.animationFrameIdY=requestAnimationFrame(a)}function fEe(e,t,r){yV(r);const n={x:null,y:null},i=document.elementsFromPoint(e.x,e.y);for(const a of i){if(n.x&&n.y)break;if(!(a instanceof HTMLElement))continue;const o=a.getBoundingClientRect(),s=window.getComputedStyle(a);if(!n.x){const{left:c,right:l}=sEe(a,t,s,o,r);(c||l)&&(n.x=a,uEe(a,t,r,l))}if(!n.y){const{up:c,down:l}=lEe(a,t,s,o);(c||l)&&(n.y=a,cEe(a,t,r,c))}}}function dEe(e){let t=document.elementFromPoint(e.x,e.y);if(!r_(t))return;let r,n=!0;for(;t&&n;){if(co.has(t)||gn.has(t)){n=!1,r=gn.has(t);break}t=t.parentNode}if(r){const i=gn.get(t);return i?{parent:{el:t,data:i}}:void 0}else{const i=co.get(t);if(!i)return;const a=gn.get(t.parentNode);return a?{node:{el:t,data:i},parent:{el:t.parentNode,data:a}}:void 0}}function r_(e){return e instanceof HTMLElement&&e.parentNode instanceof HTMLElement}function dm(e,t){const r=new AbortController;for(const n in t){const i=t[n];e.addEventListener(n,i,{signal:r.signal,passive:!1,capture:n==="focus"||n==="blur"})}return r}function hEe(e){if(e instanceof HTMLElement)return e;if("current"in e&&e.current instanceof HTMLElement)return e.current;console.warn("Invalid parent element",e)}function pEe(e,t){const r=hEe(e);r&&t(r)}var I0=new WeakMap;function mEe(e){const t=I0.get(e);return t?t[0]:(console.warn("No values found for parent element"),[])}function vEe(e,t){const r=I0.get(t);r&&r[1](e),I0.set(t,[e,r[1]])}function gEe(e,t){return r=>{I0.set(r,t),xPe({parent:r,getValues:mEe,setValues:vEe,config:e})}}function y8(e){kA&&(Array.isArray(e)||(e=[e]),e.forEach(t=>{const{parent:r,state:n,...i}=t;pEe(r,gEe(i,n))}))}function yEe(e,t={}){const r=M.useRef(null),[n,i]=M.useState(e);function a(o={}){y8({parent:r,state:[n,i],...o})}return M.useEffect(()=>{y8({parent:r,state:[n,i],...t})},[n]),M.useEffect(()=>()=>{r.current&&pV(r.current)},[]),[r,n,i,a]}const n_=()=>{const e=fo(),t=jl(),r=hd(),n=M.useMemo(()=>{const{orderBy:a,tags:o,excludeBots:s,excludeMaxVisitsReached:c,excludePastValidUntil:l,...h}=r,p=a?Jie(a):void 0,g=(o==null?void 0:o.split(","))??[];return{...h,orderBy:p,tags:g,excludeBots:s!==void 0?s==="true":void 0,excludeMaxVisitsReached:c!==void 0?c==="true":void 0,excludePastValidUntil:l!==void 0?l==="true":void 0}},[r]),i=M.useCallback(a=>{const o={...n,...a},{orderBy:s,tags:c,excludeBots:l,excludeMaxVisitsReached:h,excludePastValidUntil:p,...g}=o,_={...g,orderBy:s&&Qie(s),tags:c.length>0?c.join(","):void 0,excludeBots:mO(l),excludeMaxVisitsReached:mO(h),excludePastValidUntil:mO(p)},b=sb(_),w=b?`?${b}`:"";e(`${t}/list-short-urls/1${w}`)},[n,e,t]);return[n,i]},NA=()=>{const{domain:e}=hd(),{shortCode:t=""}=cd();return M.useMemo(()=>({shortCode:TA(t),domain:e}),[e,t])},i_=()=>{const e=DCe();return v.jsx(Lt,{color:"link",size:"lg",className:"p-0 me-3",onClick:e,"aria-label":"Go back",children:v.jsx(He,{icon:CY})})},bEe={AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia",BA:"Bosnia and Herzegovina",BW:"Botswana",BR:"Brazil",IO:"British Indian Ocean Territory",VG:"British Virgin Islands",BN:"Brunei",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos Islands",CO:"Colombia",KM:"Comoros",CK:"Cook Islands",CR:"Costa Rica",HR:"Croatia",CU:"Cuba",CW:"Curacao",CY:"Cyprus",CZ:"Czech Republic",CD:"Democratic Republic of the Congo",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",TL:"East Timor",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",PF:"French Polynesia",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",CI:"Ivory Coast",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",XK:"Kosovo",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Laos",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia",MD:"Moldova",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",AN:"Netherlands Antilles",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",KP:"North Korea",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestine",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",CG:"Republic of the Congo",RE:"Reunion",RO:"Romania",RU:"Russia",RW:"Rwanda",BL:"Saint Barthelemy",SH:"Saint Helena",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",KR:"South Korea",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syria",TW:"Taiwan",TJ:"Tajikistan",TZ:"Tanzania",TH:"Thailand",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",VI:"U.S. Virgin Islands",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VA:"Vatican",VE:"Venezuela",VN:"Vietnam",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},_Ee={android:"Android",ios:"iOS",desktop:"Desktop"},wEe=({deviceType:e,onDeviceTypeChange:t})=>{const r=M.useId();return v.jsxs("div",{children:[v.jsx("label",{htmlFor:r,children:"Device type:"}),v.jsxs("select",{id:r,className:"form-select",value:e,onChange:n=>t(n.target.value),required:!0,children:[!e&&v.jsx("option",{value:"",children:"- Select type -"}),Object.entries(_Ee).map(([n,i])=>v.jsx("option",{value:n,children:i},n))]})]})},MA=({value:e,onValueChange:t,label:r,placeholder:n})=>{const i=M.useId();return v.jsxs("div",{children:[v.jsxs("label",{htmlFor:i,children:[r,":"]}),v.jsx(Zr,{id:i,value:e??"",onChange:a=>t(a.target.value),placeholder:n,required:!0})]})},xEe=({language:e,onLanguageChange:t})=>v.jsx(MA,{value:e,onValueChange:t,label:"Language",placeholder:"en-US / en"}),SEe=({name:e,value:t,onNameChange:r,onValueChange:n})=>{const i=M.useId(),a=M.useId();return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{htmlFor:i,children:"Param name:"}),v.jsx(Zr,{id:i,value:e??"",onChange:o=>r(o.target.value),placeholder:"hello",required:!0})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:a,children:"Param value:"}),v.jsx(Zr,{id:a,value:t??"",onChange:o=>n(o.target.value),placeholder:"world",required:!0})]})]})},OEe=({ipAddress:e,onIpAddressChange:t})=>v.jsx(MA,{value:e,onValueChange:t,label:"IP address",placeholder:"192.168.1.10"}),CEe=({countryCode:e,onCountryCodeChange:t})=>{const r=M.useId();return v.jsxs("div",{children:[v.jsx("label",{htmlFor:r,children:"Country:"}),v.jsxs("select",{id:r,className:"form-select",value:e,onChange:n=>t(n.target.value),required:!0,children:[!e&&v.jsx("option",{value:"",children:"- Select country -"}),Object.entries(bEe).map(([n,i])=>v.jsx("option",{value:n,children:i},n))]})]})},PEe=({cityName:e,onCityNameChange:t})=>v.jsx(MA,{value:e,onValueChange:t,label:"City name",placeholder:"New York"}),EEe=({condition:e,onConditionChange:t,onDelete:r})=>{const n=M.useId(),i=M.useCallback(h=>t({type:h,matchValue:"",matchKey:null}),[t]),a=M.useCallback(h=>t({...e,matchValue:h}),[e,t]),o=M.useCallback(h=>t({...e,matchKey:h}),[e,t]),s=Ca("ipRedirectCondition"),c=Ca("geolocationRedirectCondition"),l=M.useMemo(()=>{const h={device:"Device type",language:"Language","query-param":"Query param"};return s&&(h["ip-address"]="IP address"),c&&(h["geolocation-country-code"]="Country (geolocation)",h["geolocation-city-name"]="City name (geolocation)"),h},[c,s]);return v.jsxs("div",{className:"redirect-rule-modal__condition rounded p-3 h-100 d-flex flex-column gap-2 position-relative",children:[v.jsxs("div",{children:[v.jsx(Lt,{outline:!0,size:"sm",type:"button","aria-label":"Remove condition",onClick:r,className:"position-absolute rounded-circle redirect-rule-modal__remove-condition-button",children:v.jsx(He,{icon:ST,className:"redirect-rule-modal__remove-condition-button-icon"})}),v.jsx("label",{htmlFor:n,children:"Type:"}),v.jsx("select",{id:n,className:"form-select flex-grow-1",value:e.type,onChange:h=>i(h.target.value),children:Object.entries(l).map(([h,p])=>v.jsx("option",{value:h,children:p},h))})]}),e.type==="device"&&v.jsx(wEe,{deviceType:e.matchValue,onDeviceTypeChange:a}),e.type==="language"&&v.jsx(xEe,{language:e.matchValue,onLanguageChange:a}),e.type==="query-param"&&v.jsx(SEe,{value:e.matchValue,name:e.matchKey??"",onNameChange:o,onValueChange:a}),e.type==="ip-address"&&v.jsx(OEe,{ipAddress:e.matchValue,onIpAddressChange:a}),e.type==="geolocation-country-code"&&v.jsx(CEe,{countryCode:e.matchValue,onCountryCodeChange:a}),e.type==="geolocation-city-name"&&v.jsx(PEe,{cityName:e.matchValue,onCityNameChange:a})]})},wV=({isOpen:e,toggle:t,onSave:r,initialData:n})=>{const[i,a]=M.useState(n??{longUrl:"",conditions:[]}),o=M.useCallback(_=>{_.preventDefault(),_.stopPropagation(),i&&r(i),t()},[r,i,t]),s=M.useCallback(()=>a(({longUrl:_,conditions:b})=>({longUrl:_,conditions:[...b,{type:"device",matchValue:"",matchKey:null}]})),[]),c=M.useCallback((_,b)=>a(({longUrl:w,conditions:x})=>{const S=[...x];return S[_]=b,{longUrl:w,conditions:S}}),[]),l=M.useCallback(_=>a(({longUrl:b,conditions:w})=>{const x=[...w];return x.splice(_,1),{longUrl:b,conditions:x}}),[]),h=_i(),p=M.useCallback(()=>{var _;return(_=h==null?void 0:h.current)==null?void 0:_.focus()},[h]),g=M.useCallback(()=>a(n??{longUrl:"",conditions:[]}),[n]);return v.jsx(Ji,{size:"xl",isOpen:e,toggle:t,centered:!0,onOpened:p,onClosed:g,children:v.jsxs("form",{onSubmit:o,children:[v.jsx(Sl,{toggle:t,className:"sticky-top redirect-rule-modal__header",children:"Redirect rule"}),v.jsxs(as,{children:[v.jsx("label",{htmlFor:"longUrl",className:"fw-bold",children:"Long URL:"}),v.jsx(Zr,{id:"longUrl",type:"url",placeholder:"https://www.example.com",value:i.longUrl,onChange:_=>a(b=>({...b,longUrl:_.target.value})),required:!0,innerRef:h}),v.jsx("hr",{}),v.jsxs("div",{className:"d-flex justify-content-between",children:[v.jsx("b",{children:"Conditions:"}),v.jsx(Lt,{outline:!0,size:"sm",type:"button","aria-label":"Add condition",onClick:s,children:v.jsx(He,{icon:gm})})]}),i.conditions.length===0&&v.jsx("div",{className:"text-center",children:v.jsx("i",{children:"Add conditions..."})}),i.conditions.length>0&&v.jsx(Za,{className:"redirect-rule-modal__conditions-row",children:i.conditions.map((_,b)=>v.jsx("div",{className:"col-lg-6 col-xl-4 mt-4",children:v.jsx(EEe,{condition:_,onConditionChange:w=>c(b,w),onDelete:()=>l(b)})},`${b}_${_.type}`))})]}),v.jsxs(Hu,{className:"sticky-bottom redirect-rule-modal__footer",children:[v.jsx(Lt,{type:"button",color:"link",onClick:t,children:"Cancel"}),v.jsx(Lt,{color:"primary",disabled:i.conditions.length===0,children:"Confirm"})]})]})})},TEe=({priority:e,isLast:t,redirectRule:r,onDelete:n,onMoveUp:i,onMoveDown:a,onUpdate:o})=>{const[s,c]=ir();return v.jsxs(Sr,{children:[v.jsxs("div",{className:"d-flex align-content-center gap-3",children:[v.jsx("div",{className:"d-flex flex-column my-auto drag-n-drop-handler d-none d-md-block",style:{cursor:"grab"},children:v.jsx(He,{icon:kY})}),v.jsxs("div",{className:"d-flex flex-column my-auto",children:[v.jsx(Lt,{outline:!0,color:"secondary",size:"sm","aria-label":`Move rule with priority ${e} up`,disabled:e===1,onClick:i,className:"rounded-0 rounded-top",style:{marginBottom:"-1px"},children:v.jsx(He,{icon:qY})}),v.jsx(Lt,{outline:!0,color:"secondary",size:"sm","aria-label":`Move rule with priority ${e} down`,disabled:t,onClick:a,className:"rounded-0 rounded-bottom",children:v.jsx(He,{icon:UY})})]}),v.jsxs("div",{className:"flex-grow-1",children:[v.jsxs("div",{className:"mb-2",children:[v.jsx("b",{children:"Long URL:"})," ",v.jsx(Gn,{href:r.longUrl,"data-testid":"rule-long-url"})]}),v.jsxs("div",{className:"d-flex flex-column flex-lg-row gap-2",children:[v.jsx("b",{children:"Conditions:"}),r.conditions.map((l,h)=>v.jsxs("div",{className:"badge bg-secondary",children:[l.type==="device"&&v.jsxs(v.Fragment,{children:["Device is ",l.matchValue]}),l.type==="language"&&v.jsxs(v.Fragment,{children:[l.matchValue," language is accepted"]}),l.type==="query-param"&&v.jsxs(v.Fragment,{children:["Query string contains ",l.matchKey,"=",l.matchValue]}),l.type==="ip-address"&&v.jsxs(v.Fragment,{children:["IP address matches ",l.matchValue]}),l.type==="geolocation-country-code"&&v.jsxs(v.Fragment,{children:["Country code is ",l.matchValue]}),l.type==="geolocation-city-name"&&v.jsxs(v.Fragment,{children:["City name is ",l.matchValue]})]},`${l.type}_${h}`))]})]}),v.jsxs("div",{className:"d-flex flex-column flex-sm-row gap-1 my-auto",children:[v.jsx(Lt,{outline:!0,color:"secondary",size:"sm","aria-label":`Edit rule with priority ${e}`,onClick:c,children:v.jsx(He,{icon:$$})}),v.jsx(Lt,{outline:!0,color:"danger",size:"sm","aria-label":`Delete rule with priority ${e}`,onClick:n,children:v.jsx(He,{icon:tY})})]})]}),v.jsx(wV,{onSave:o,isOpen:s,toggle:c,initialData:r})]})},jEe=({shortUrlRedirectRules:e,getShortUrlRedirectRules:t,getShortUrlsDetails:r,shortUrlsDetails:n,setShortUrlRedirectRules:i,shortUrlRedirectRulesSaving:a,resetSetRules:o})=>{const s=NA(),{shortUrls:c}=n,l=s&&(c==null?void 0:c.get(s)),[h,p,g]=yEe([],{dragHandle:".drag-n-drop-handler",dropZoneClass:"opacity-25"}),{saving:_,saved:b,errorData:w}=a,[x,S]=ir(),C=M.useCallback(U=>g((B=[])=>[...B,U]),[g]),P=M.useCallback(U=>g((B=[])=>{const W=[...B];return W.splice(U,1),W}),[g]),T=M.useCallback((U,B)=>g((W=[])=>{const q=[...W];return q[U]=B,q}),[g]),A=M.useCallback((U,B)=>g((W=[])=>{if(!W[B])return W;const q=[...W],J=q[B];return q[B]=q[U],q[U]=J,q}),[g]),j=M.useCallback(U=>A(U,U-1),[A]),N=M.useCallback(U=>A(U,U+1),[A]),$=M.useCallback(U=>{U.preventDefault(),p&&i({shortUrl:s,data:{redirectRules:p}})},[s,p,i]);return M.useEffect(()=>(t(s),r([s]),o),[t,r,s,o]),M.useEffect(()=>{e.redirectRules&&g(e.redirectRules)},[g,e.redirectRules]),v.jsxs("div",{className:"d-flex flex-column gap-3",children:[v.jsx("header",{children:v.jsxs(Qi,{body:!0,children:[v.jsxs("h2",{className:"d-sm-flex justify-content-between align-items-center mb-0",children:[v.jsx(i_,{}),v.jsxs("div",{className:"text-center flex-grow-1",children:[n.loading&&v.jsx(v.Fragment,{children:"Loading..."}),!n.loading&&v.jsxs("small",{children:["Redirect rules for ",v.jsx(Gn,{href:(l==null?void 0:l.shortUrl)??""})]})]})]}),v.jsx("hr",{}),v.jsxs("div",{children:[v.jsx("p",{className:"mb-2",children:"Configure dynamic conditions that will be checked at runtime."}),"If no conditions match, visitors will be redirected to: ",v.jsx(Gn,{href:e.defaultLongUrl??""})]})]})}),v.jsx("div",{children:v.jsxs(Lt,{outline:!0,color:"primary",onClick:S,children:[v.jsx(He,{icon:gm,className:"me-1"})," Add rule"]})}),v.jsxs("form",{onSubmit:$,children:[e.loading&&v.jsx(Lu,{loading:!0}),p.length===0&&!e.loading&&v.jsx(Sr,{className:"text-center",children:v.jsx("i",{children:"This short URL has no dynamic redirect rules"})}),v.jsx("div",{className:"d-flex flex-column gap-2",ref:h,children:p.map((U,B)=>v.jsx(TEe,{redirectRule:U,priority:B+1,isLast:B===p.length-1,onDelete:()=>P(B),onMoveUp:()=>j(B),onMoveDown:()=>N(B),onUpdate:W=>T(B,W)},`${U.longUrl}_${B}`))}),v.jsx("div",{className:"text-center mt-3",children:v.jsx(Lt,{outline:!0,color:"primary",className:"btn-sm-block",disabled:_,"data-testid":"save-button",children:_?"Saving...":"Save rules"})})]}),w&&v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:w,fallbackMessage:"An error occurred while saving short URL redirect rules :("})}),b&&v.jsx(gi,{type:"success",children:"Redirect rules properly saved."}),v.jsx(wV,{isOpen:x,toggle:S,onSave:C})]})},AEe=(e,t)=>{e.serviceFactory("ShortUrlRedirectRules",()=>jEe),e.decorator("ShortUrlRedirectRules",t(["shortUrlRedirectRules","shortUrlsDetails","shortUrlRedirectRulesSaving"],["getShortUrlRedirectRules","getShortUrlsDetails","setShortUrlRedirectRules","resetSetRules"])),e.serviceFactory("getShortUrlRedirectRules",fPe,"apiClientFactory"),e.serviceFactory("setShortUrlRedirectRules",lPe,"apiClientFactory"),e.serviceFactory("resetSetRules",r=>r.resetSetRules,"setShortUrlRedirectRulesReducerCreator"),e.serviceFactory("shortUrlRedirectRulesReducerCreator",dPe,"getShortUrlRedirectRules"),e.serviceFactory("shortUrlRedirectRulesReducer",r=>r.reducer,"shortUrlRedirectRulesReducerCreator"),e.serviceFactory("setShortUrlRedirectRulesReducerCreator",uPe,"setShortUrlRedirectRules"),e.serviceFactory("setShortUrlRedirectRulesReducer",r=>r.reducer,"setShortUrlRedirectRulesReducerCreator")},kEe=e=>({longUrl:"",tags:[],customSlug:"",title:void 0,shortCodeLength:void 0,domain:"",validSince:void 0,validUntil:void 0,maxVisits:void 0,findIfExists:!1,validateUrl:(e==null?void 0:e.validateUrls)??!1,forwardQuery:(e==null?void 0:e.forwardQuery)??!0}),xV=({createShortUrl:e,shortUrlCreation:t,resetCreateShortUrl:r,basicMode:n=!1})=>{const{ShortUrlForm:i,CreateShortUrlResult:a}=ur(xV),o=Nn("shortUrlCreation"),s=M.useMemo(()=>kEe(o),[o]);return v.jsxs(v.Fragment,{children:[v.jsx(i,{initialState:s,saving:t.saving,basicMode:n,onSave:async c=>(r(),e(c))}),v.jsx(a,{creation:t,resetCreateShortUrl:r,canBeClosed:n})]})},REe=cr(xV,["ShortUrlForm","CreateShortUrlResult"]),SV=({shortUrlsDetails:e,getShortUrlsDetails:t,shortUrlEdition:r,editShortUrl:n})=>{const{ShortUrlForm:i}=ur(SV),a=NA(),{loading:o,error:s,errorData:c,shortUrls:l}=e,h=a&&(l==null?void 0:l.get(a)),{saving:p,saved:g,error:_,errorData:b}=r,w=Nn("shortUrlCreation"),x=M.useMemo(()=>QCe(h,w),[h,w]);return M.useEffect(()=>{a&&t([a])},[t,a]),o?v.jsx(Lu,{loading:!0}):s?v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:c,fallbackMessage:"An error occurred while loading short URL detail :("})}):v.jsxs(v.Fragment,{children:[v.jsx("header",{className:"mb-3",children:v.jsx(Qi,{body:!0,children:v.jsxs("h2",{className:"d-sm-flex justify-content-between align-items-center mb-0",children:[v.jsx(i_,{}),v.jsx("div",{className:"text-center flex-grow-1",children:v.jsxs("small",{children:["Edit ",v.jsx(Gn,{href:(h==null?void 0:h.shortUrl)??""})]})})]})})}),v.jsx(i,{initialState:x,saving:p,onSave:async S=>{h&&n({...h,data:S})}}),g&&_&&v.jsx(gi,{type:"error",className:"mt-3",children:v.jsx(uo,{errorData:b,fallbackMessage:"An error occurred while updating short URL :("})}),g&&!_&&v.jsx(gi,{type:"success",className:"mt-3",children:"Short URL properly edited."})]})},NEe=cr(SV,["ShortUrlForm"]),OV=({text:e,onCopy:t},r=navigator)=>{var n;return(n=r.clipboard)==null?void 0:n.writeText(e).then(()=>t==null?void 0:t(e,!0)).catch(()=>t==null?void 0:t(e,!1))},CV=({creation:e,resetCreateShortUrl:t,canBeClosed:r=!1})=>{const{useTimeoutToggle:n}=ur(CV),[i,a]=n(),{error:o,saved:s}=e;if(M.useEffect(()=>{t()},[t]),o)return v.jsxs(gi,{type:"error",className:"mt-3",children:[r&&v.jsx(He,{"data-testid":"error-close-button",icon:kO,className:"float-end pointer",onClick:t}),v.jsx(uo,{errorData:e.errorData,fallbackMessage:"An error occurred while creating the URL :("})]});if(!s)return null;const{shortUrl:c}=e.result;return v.jsxs(gi,{type:"success",className:"mt-3",children:[r&&v.jsx(He,{"data-testid":"success-close-button",icon:kO,className:"float-end pointer",onClick:t}),v.jsxs("span",{children:[v.jsx("b",{children:"Great!"})," The short URL is ",v.jsx("b",{children:c})]}),v.jsxs("button",{className:"btn btn-light btn-sm create-short-url-result__copy-btn",id:"copyBtn",type:"button",onClick:()=>OV({text:c,onCopy:a}),children:[v.jsx(He,{icon:K7})," Copy ",v.jsxs("span",{className:"sr-only",children:[c," to clipboard"]})]}),v.jsx(ab,{placement:"left",isOpen:i,target:"copyBtn",children:"Copied!"})]})},MEe=cr(CV,["useTimeoutToggle"]),bO="delete",LEe=({shortUrl:e,toggle:t,isOpen:r,shortUrlDeletion:n,resetDeleteShortUrl:i,deleteShortUrl:a,shortUrlDeleted:o})=>{const[s,c]=M.useState("");M.useEffect(()=>i,[i]);const{loading:l,error:h,deleted:p,errorData:g}=n,_=M.useCallback(()=>{i(),t()},[i,t]),b=M.useCallback(w=>(w.preventDefault(),a(e).then(x=>!wA(x)&&t())),[a,e,t]);return v.jsx(Ji,{isOpen:r,toggle:_,centered:!0,onClosed:()=>p&&o(e),children:v.jsxs("form",{onSubmit:b,children:[v.jsx(Sl,{toggle:_,children:v.jsx("span",{className:"text-danger",children:"Delete short URL"})}),v.jsxs(as,{children:[v.jsxs("p",{children:[v.jsx("b",{className:"text-danger",children:"Caution!"})," You are about to delete a short URL."]}),v.jsx("p",{children:"This action cannot be undone. Once you have deleted it, all the visits stats will be lost."}),v.jsxs("p",{children:["Write ",v.jsx("b",{children:bO})," to confirm deletion."]}),v.jsx("input",{type:"text",className:"form-control",placeholder:`Insert ${bO}`,value:s,onChange:w=>c(w.target.value)}),h&&v.jsx(gi,{type:CCe(g)?"warning":"error",small:!0,className:"mt-2",children:v.jsx(uo,{errorData:g,fallbackMessage:"Something went wrong while deleting the URL :("})})]}),v.jsxs(Hu,{children:[v.jsx("button",{type:"button",className:"btn btn-link",onClick:_,children:"Cancel"}),v.jsx("button",{type:"submit",className:"btn btn-danger",disabled:s!==bO||l,children:l?"Deleting...":"Delete"})]})]})})},PV=({amount:e=0,loading:t=!1,...r})=>v.jsxs(Lt,{...r,outline:!0,color:"primary",disabled:t,children:[v.jsx(He,{icon:oY})," ",t?"Exporting...":v.jsxs(v.Fragment,{children:["Export (",Or(e),")"]})]}),b8=20,EV=({amount:e=0})=>{const{apiClientFactory:t,ReportExporter:r}=ur(EV),[{tags:n,search:i,startDate:a,endDate:o,orderBy:s,tagsMode:c}]=n_(),[l,,h,p]=ir(),g=M.useCallback(async()=>{const _=e/b8,b=async(x=1)=>{const{data:S}=await t().listShortUrls({page:`${x}`,tags:n,searchTerm:i,startDate:a,endDate:o,orderBy:s,tagsMode:c,itemsPerPage:b8});return x>=_?S:S.concat(await b(x+1))};h();const w=await b();r.exportShortUrls(w.map(x=>{var S;const{hostname:C,pathname:P}=new URL(x.shortUrl),T=P.substring(1);return{createdAt:x.dateCreated,domain:C,shortCode:T,shortUrl:x.shortUrl,longUrl:x.longUrl,title:x.title??"",tags:x.tags.join("|"),visits:((S=x==null?void 0:x.visitsSummary)==null?void 0:S.total)??x.visitsCount??0}})),p()},[e,t,o,s,r,i,a,h,p,n,c]);return v.jsx(PV,{loading:l,className:"btn-md-block",amount:e,onClick:g})},IEe=cr(EV,["apiClientFactory","ReportExporter"]),TV=({text:e,onCopy:t,copyToClipboard:r=OV})=>v.jsx(Wu,{className:"ms-2 p-0","aria-label":`Copy ${e} to clipboard`,onClick:()=>r({text:e,onCopy:t}),children:v.jsx(He,{icon:K7,className:"fs-5"})}),_8=e=>e&&e.startsWith("#")?e.substring(1):e,DEe=(e,{color:t,bgColor:r,...n})=>{const i=`${e}/qr-code`,a=sb({...n,color:_8(t),bgColor:_8(r)});return`${i}${a?`?${a}`:""}`},$Ee=6,w8="0123456789ABCDEF",FEe=128;function BEe(){return`#${CA($Ee,()=>w8[Math.floor(Math.random()*w8.length)]).join("")}`}function UEe(e,t,r){return Math.round(Math.sqrt(.299*e**2+.587*t**2+.114*r**2))}function jV(e){const[t,r,n]=(e.match(/../g)??[]).map(i=>parseInt(i,16)||0);return UEe(t,r,n)>=FEe}const AV=M.forwardRef(({name:e,color:t,onChange:r,className:n},i)=>v.jsxs("div",{className:Te("p-0 position-relative",n),style:{backgroundColor:t,borderColor:t},children:[v.jsx(He,{icon:_Y,className:"position-absolute top-50 start-50 translate-middle",style:{color:jV(t.substring(1))?"#000":"fff"}}),v.jsx(Zr,{className:"form-control-color opacity-0",type:"color",value:t,onChange:a=>r(a.target.value),innerRef:i,name:e,"aria-label":e})]})),zEe=({color:e,onChange:t,name:r})=>{const n=_i();return v.jsxs(Om,{children:[v.jsx(AV,{name:r,color:e,onChange:t,className:"input-group-text",ref:n}),v.jsx(Zr,{readOnly:!0,value:e,onClick:()=>{var i;return(i=n.current)==null?void 0:i.click()},"aria-label":r,"data-testid":"text-input"})]})},D0=({label:e,...t})=>v.jsx(Lt,{outline:!0,color:"link",style:{color:"var(--input-text-color)",borderColor:"var(--border-color)"},"aria-label":e,title:e,...t}),x8=({name:e,color:t,initialColor:r,onChange:n})=>v.jsx(v.Fragment,{children:t===void 0?v.jsx(D0,{className:"text-start fst-italic w-100",onClick:()=>n(r),children:v.jsxs("span",{className:"indivisible",children:["Customize ",e]})}):v.jsxs("div",{className:"d-flex gap-1 w-100",children:[v.jsx(zEe,{color:t,onChange:n,name:e}),v.jsx(D0,{label:`Default ${e}`,onClick:()=>n(void 0),children:v.jsx(He,{icon:xT})})]})}),S8=({name:e,value:t,step:r,min:n,max:i,onChange:a,initial:o=n})=>{const s=M.useId();return v.jsx(v.Fragment,{children:t===void 0?v.jsxs(D0,{className:"text-start fst-italic w-100",onClick:()=>a(o),children:["Customize ",e]}):v.jsxs("div",{className:"d-flex gap-1 w-100",children:[v.jsxs("div",{className:"d-flex flex-column flex-grow-1",children:[v.jsxs("label",{htmlFor:s,className:"text-capitalize",children:[e,": ",t,"px"]}),v.jsx("input",{id:s,type:"range",className:"form-control-range",value:t,step:r,min:n,max:i,onChange:c=>a(Number(c.target.value))})]}),v.jsx(D0,{label:`Default ${e}`,onClick:()=>a(void 0),children:v.jsx(He,{icon:xT})})]})})},VEe=({errorCorrection:e,onChange:t})=>v.jsxs(os,{text:e?`Error correction (${e})`:v.jsx("i",{children:"Default error correction"}),dropdownClassName:"w-100",children:[v.jsx(Ze,{active:!e,onClick:()=>t(void 0),children:"Default"}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{active:e==="L",onClick:()=>t("L"),children:[v.jsx("b",{children:"L"}),"ow"]}),v.jsxs(Ze,{active:e==="M",onClick:()=>t("M"),children:[v.jsx("b",{children:"M"}),"edium"]}),v.jsxs(Ze,{active:e==="Q",onClick:()=>t("Q"),children:[v.jsx("b",{children:"Q"}),"uartile"]}),v.jsxs(Ze,{active:e==="H",onClick:()=>t("H"),children:[v.jsx("b",{children:"H"}),"igh"]})]}),WEe=({format:e,onChange:t})=>v.jsxs(os,{text:e?`Format (${e})`:v.jsx("i",{children:"Default format"}),dropdownClassName:"w-100",children:[v.jsx(Ze,{active:!e,onClick:()=>t(void 0),children:"Default"}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{active:e==="png",onClick:()=>t("png"),children:"PNG"}),v.jsx(Ze,{active:e==="svg",onClick:()=>t("svg"),children:"SVG"})]}),kV=({shortUrl:{shortUrl:e,shortCode:t},toggle:r,isOpen:n})=>{const{ImageDownloader:i}=ur(kV),[a,o]=M.useState(),[s,c]=M.useState(),[l,h]=M.useState(),[p,g]=M.useState(),[_,b]=M.useState(),[w,x]=M.useState(),S=Ca("qrCodeColors"),C=M.useMemo(()=>DEe(e,{size:a,format:l,margin:s,errorCorrection:p,color:_,bgColor:w}),[e,a,l,s,p,_,w]);return v.jsxs(Ji,{isOpen:n,toggle:r,centered:!0,size:"lg",children:[v.jsxs(Sl,{toggle:r,children:["QR code for ",v.jsx(Gn,{href:e,children:e})]}),v.jsxs(as,{className:"d-flex flex-column-reverse flex-lg-row gap-3",children:[v.jsx("div",{className:"flex-grow-1 d-flex align-items-center justify-content-around text-center",children:v.jsx("img",{src:C,alt:"QR code",className:"shadow",style:{maxWidth:"100%"}})}),v.jsxs("div",{className:"d-flex flex-column gap-2 qr-code-modal__controls",children:[v.jsx(S8,{name:"size",value:a,onChange:o,step:10,min:50,max:1e3,initial:300}),v.jsx(S8,{name:"margin",value:s,onChange:c,step:1,min:0,max:100}),v.jsx(WEe,{format:l,onChange:h}),v.jsx(VEe,{errorCorrection:p,onChange:g}),S&&v.jsxs(v.Fragment,{children:[v.jsx(x8,{name:"color",initialColor:"#000000",color:_,onChange:b}),v.jsx(x8,{name:"background",initialColor:"#ffffff",color:w,onChange:x})]}),v.jsx("div",{className:"mt-auto",children:v.jsxs(Lt,{block:!0,color:"primary",onClick:()=>{i.saveImage(C,`${t}-qr-code.${l??"png"}`).catch(()=>{})},children:["Download ",v.jsx(He,{icon:B$,className:"ms-1"})]})})]})]}),v.jsx(Hu,{className:"sticky-bottom justify-content-around",style:{backgroundColor:"var(--primary-color)",zIndex:"1"},children:v.jsxs("div",{className:"text-center",children:[v.jsx(Gn,{href:C}),v.jsx(TV,{text:C})]})})]})},qEe=cr(kV,["ImageDownloader"]),HEe="yyyy-MM-dd",RV="yyyy-MM-dd HH:mm",gl=()=>new Date,LA=e=>typeof e!="string",IA=(e,t)=>!e||!LA(e)?e:t?ky(e,t):wle(e),yl=e=>IA(e,void 0),nl=e=>IA(e,HEe),hm=e=>IA(e,RV),vi=e=>LA(e)?e:hl(e),Um=(e,t,r)=>{const n=vi(e),i=t&&vi(t),a=r&&vi(r);if(i&&a)try{return Ole(n,{start:i,end:a})}catch{return!1}return i?_P(n,i)||Sle(n,i):a?_P(n,a)||Ry(n,a):!0},su=(e,t)=>_P(e,t)||Ry(e,t),$0=({date:e,format:t=RV,relative:r=!1})=>{const n=LA(e)?e:hl(e);return v.jsx("time",{dateTime:`${xle(n)}000`,children:r?`${_le(gl(),n)} ago`:ky(n,t)})},GEe=(e,{shortCode:t,domain:r},n)=>{const i=r?`?domain=${r}`:"";return`${e}/short-code/${Jz(t)}/${n}${i}`},hp=({shortUrl:e,suffix:t,asLink:r,children:n,...i})=>{const a=jl();return!r||!e?v.jsx("span",{...i,children:n}):v.jsx(Xt,{to:GEe(a,e,t),...i,children:n})},KEe=e=>{const{meta:t,visitsCount:r,visitsSummary:n}=e,{maxVisits:i,validSince:a,validUntil:o}=t,s=(n==null?void 0:n.total)??r??0;return i&&s>=i?{icon:eZ,className:"text-danger",description:v.jsxs(v.Fragment,{children:["This short URL cannot be currently visited because it has reached the maximum amount of ",v.jsx("b",{children:i})," visit",i>1?"s":"","."]})}:o&&Ry(vi(o),gl())?{icon:tR,className:"text-danger",description:v.jsxs(v.Fragment,{children:["This short URL cannot be visited since ",v.jsx("b",{className:"indivisible",children:hm(vi(o))}),"."]})}:a&&Ry(gl(),vi(a))?{icon:tR,className:"text-warning",description:v.jsxs(v.Fragment,{children:["This short URL will start working on ",v.jsx("b",{className:"indivisible",children:hm(vi(a))}),"."]})}:{icon:vp,className:"text-primary",description:"This short URL can be visited normally."}},YEe=({shortUrl:e})=>{const t=_i(),{icon:r,className:n,description:i}=KEe(e);return v.jsxs(v.Fragment,{children:[v.jsx("span",{style:{cursor:i?"help":void 0},ref:t,children:v.jsx(He,{icon:r,className:n})}),v.jsx(Oi,{target:t,placement:"bottom",children:i})]})},NV=({visitsCount:e,shortUrl:t,active:r=!1,asLink:n=!1})=>{const i=_i(),{maxVisits:a,validSince:o,validUntil:s}=(t==null?void 0:t.meta)??{},c=!!a||!!o||!!s,l=v.jsx(hp,{shortUrl:t,suffix:"visits",asLink:n,children:v.jsx("strong",{className:Te("short-url-visits-count__amount",{"short-url-visits-count__amount--big":r}),children:Or(e)})});return c?v.jsxs(v.Fragment,{children:[v.jsxs("span",{className:"indivisible",children:[l,v.jsxs("small",{className:"short-urls-visits-count__max-visits-control",ref:i,children:[a&&v.jsxs(v.Fragment,{children:[" / ",Or(a)]}),v.jsx("sup",{className:"ms-1",children:v.jsx(He,{icon:wT})})]})]}),v.jsx(Oi,{target:i,placement:"bottom",children:v.jsxs("ul",{className:"list-unstyled mb-0",children:[a&&v.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept more than ",v.jsx("b",{children:Or(a)})," visit",a===1?"":"s","."]}),o&&v.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept visits before ",v.jsx("b",{className:"indivisible",children:hm(vi(o))}),"."]}),s&&v.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept visits after ",v.jsx("b",{className:"indivisible",children:hm(vi(s))}),"."]})]})})]}):l},ZEe=e=>!!e.onClose,XEe=e=>!!e.onClick,a_=e=>{const{text:t,children:r,className:n,colorGenerator:i}=e,a=XEe(e),o=a?Wu:"span",s=M.useMemo(()=>i.stylesForKey(t),[t,i]);return v.jsxs(o,{className:Te("badge tag fw-bold",n,{pointer:a}),style:s,onClick:a?e.onClick:void 0,children:[r??t,ZEe(e)&&v.jsx(Wu,{"aria-label":`Remove ${t}`,className:"bg-transparent ms-1 opacity-100 p-0 fw-bold tag__close",onClick:e.onClose,children:"×"})]})},QEe=({tags:e,onTagClick:t,colorGenerator:r})=>e.length===0?v.jsx("i",{className:"indivisible",children:v.jsx("small",{children:"No tags"})}):v.jsx(v.Fragment,{children:e.map(n=>v.jsx(a_,{text:n,colorGenerator:r,onClick:()=>t==null?void 0:t(n)},n))}),MV=({shortUrl:e,onTagClick:t})=>{var r,n,i,a;const{ShortUrlsRowMenu:o,ColorGenerator:s,useTimeoutToggle:c}=ur(MV),[l,h]=c(),[p,g]=c(!1,500),_=M.useRef(!0),[{excludeBots:b}]=n_(),w=Nn("visits"),x=b??(w==null?void 0:w.excludeBots);return M.useEffect(()=>{_.current||g(),_.current=!1},[(r=e.visitsSummary)==null?void 0:r.total,(n=e.visitsSummary)==null?void 0:n.nonBots,e.visitsCount,g]),v.jsxs("tr",{className:"responsive-table__row",children:[v.jsx("td",{className:"indivisible short-urls-row__cell responsive-table__cell","data-th":"Created at",children:v.jsx($0,{date:e.dateCreated})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Short URL",children:v.jsxs("span",{className:"position-relative short-urls-row__cell--indivisible",children:[v.jsx("span",{className:"short-urls-row__short-url-wrapper",children:v.jsx(Gn,{href:e.shortUrl})}),v.jsx(TV,{text:e.shortUrl,onCopy:h}),v.jsx("span",{role:"status",className:"badge bg-warning text-black short-urls-row__copy-hint",hidden:!l,children:"Copied short URL!"})]})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell short-urls-row__cell--break","data-th":`${e.title?"Title":"Long URL"}`,children:v.jsx(Gn,{href:e.longUrl,children:e.title??e.longUrl})}),e.title&&v.jsx("td",{className:"short-urls-row__cell responsive-table__cell short-urls-row__cell--break d-lg-none","data-th":"Long URL",children:v.jsx(Gn,{href:e.longUrl})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Tags",children:v.jsx(QEe,{tags:e.tags,colorGenerator:s,onTagClick:t})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell text-lg-end","data-th":"Visits",children:v.jsx(NV,{visitsCount:(x?(i=e.visitsSummary)==null?void 0:i.nonBots:(a=e.visitsSummary)==null?void 0:a.total)??e.visitsCount??0,shortUrl:e,active:p,asLink:!0})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Status",children:v.jsxs("div",{className:"d-flex gap-2",children:[v.jsx(YEe,{shortUrl:e}),e.hasRedirectRules&&v.jsx(hp,{asLink:!0,shortUrl:e,suffix:"redirect-rules",title:"This short URL has dynamic redirect rules",children:v.jsx(He,{icon:V$})})]})}),v.jsx("td",{className:"responsive-table__cell short-urls-row__cell text-end",children:v.jsx(o,{shortUrl:e})})]})},JEe=cr(MV,["ShortUrlsRowMenu","ColorGenerator","useTimeoutToggle"]),LV=({shortUrl:e,deleteShortUrl:t,shortUrlDeleted:r})=>{const{DeleteShortUrlModal:n,QrCodeModal:i}=ur(LV),[a,,o,s]=ir(),[c,,l,h]=ir(),p=Jb(),g=Ca("shortUrlRedirectRules"),{confirmDeletions:_=!0}=Nn("shortUrlsList",{}),b=M.useCallback(async()=>{const w=await t(e);wA(w)||r(e)},[t,e,r]);return v.jsxs(lb,{minWidth:g?220:190,children:[v.jsxs(Ze,{tag:hp,shortUrl:e,suffix:"visits",asLink:!0,children:[v.jsx(He,{icon:_T,fixedWidth:!0})," Visit stats"]}),p&&v.jsxs(v.Fragment,{children:[v.jsxs(Ze,{disabled:!p.canAddItemWithName(e.shortUrl),onClick:()=>p.addItemToCompare({name:e.shortUrl,query:jA(e)}),children:[v.jsx(He,{icon:X0,fixedWidth:!0})," Compare visits"]}),v.jsx(Ze,{divider:!0,tag:"hr"})]}),v.jsxs(Ze,{tag:hp,shortUrl:e,suffix:"edit",asLink:!0,children:[v.jsx(He,{icon:bT,fixedWidth:!0})," Edit short URL"]}),g&&v.jsxs(Ze,{tag:hp,shortUrl:e,suffix:"redirect-rules",asLink:!0,children:[v.jsx(He,{icon:V$,fixedWidth:!0})," Manage redirect rules"]}),v.jsxs(Ze,{onClick:o,children:[v.jsx(He,{icon:XY,fixedWidth:!0})," QR code"]}),v.jsx(i,{shortUrl:e,isOpen:a,toggle:s}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{className:"dropdown-item--danger",onClick:_?l:b,children:[v.jsx(He,{icon:D$,fixedWidth:!0})," Delete short URL"]}),v.jsx(n,{shortUrl:e,deleteShortUrl:t,shortUrlDeleted:r,isOpen:c,toggle:h})]})},eTe=cr(LV,["DeleteShortUrlModal","QrCodeModal"]),IV="shlink/shortUrlCreation",O8={saving:!1,saved:!1,error:!1},tTe=e=>Vr(`${IV}/createShortUrl`,t=>e().createShortUrl(t)),rTe=e=>{const{reducer:t,actions:r}=Tr({name:IV,initialState:O8,reducers:{resetCreateShortUrl:()=>O8},extraReducers:i=>{i.addCase(e.pending,()=>({saving:!0,saved:!1,error:!1})),i.addCase(e.rejected,(a,{error:o})=>({saving:!1,saved:!1,error:!0,errorData:Ci(o)})),i.addCase(e.fulfilled,(a,{payload:o})=>({result:o,saving:!1,saved:!0,error:!1}))}}),{resetCreateShortUrl:n}=r;return{reducer:t,resetCreateShortUrl:n}},DV="shlink/shortUrlEdition",nTe={saving:!1,saved:!1,error:!1},iTe=e=>Vr(`${DV}/editShortUrl`,({shortCode:t,domain:r,data:n})=>e().updateShortUrl({shortCode:t,domain:r},n)),aTe=e=>Tr({name:DV,initialState:nTe,reducers:{},extraReducers:t=>{t.addCase(e.pending,r=>({...r,saving:!0,error:!1,saved:!1})),t.addCase(e.rejected,(r,{error:n})=>({...r,saving:!1,error:!0,saved:!1,errorData:Ci(n)})),t.addCase(e.fulfilled,(r,{payload:n})=>({shortUrl:n,saving:!1,error:!1,saved:!0}))}}),C8="shlink/shortUrlsDetails",P8={loading:!1,error:!1},oTe=e=>{const t=Vr(`${C8}/getShortUrlsDetails`,async(n,{getState:i})=>{const{shortUrlsList:a}=i(),o=await Promise.all(n.map(async s=>{var c;const{shortCode:l,domain:h}=s,p=(c=a==null?void 0:a.shortUrls)==null?void 0:c.data.find(g=>dp(g,l,h));return[s,p??await e().getShortUrl({shortCode:l,domain:h})]}));return new Map(o)}),{reducer:r}=Tr({name:C8,initialState:P8,reducers:{},extraReducers:n=>{n.addCase(t.pending,()=>({loading:!0,error:!1})),n.addCase(t.rejected,(i,{error:a})=>({loading:!1,error:!0,errorData:Ci(a)})),n.addCase(t.fulfilled,(i,{payload:a})=>({...P8,shortUrls:a}))}});return{reducer:r,getShortUrlsDetails:t}},sTe=({domains:e,value:t,onChange:r})=>{const[n,,i,a]=ir(),o=!t,s=M.useCallback(()=>{r(""),a()},[r,a]),c=M.useCallback(()=>{r(""),i()},[r,i]);return n?v.jsxs(Om,{children:[v.jsx(Zr,{value:t??"",placeholder:"Domain",onChange:l=>r(l.target.value)}),v.jsx(Lt,{id:"backToDropdown",outline:!0,type:"button",className:"domains-dropdown__back-btn","aria-label":"Back to domains list",onClick:s,children:v.jsx(He,{icon:AY})}),v.jsx(Oi,{target:"backToDropdown",placement:"left",trigger:"hover",children:"Existing domains"})]}):v.jsxs(os,{text:o?"Domain":`Domain: ${t}`,className:o?"domains-dropdown__toggle-btn":"domains-dropdown__toggle-btn--active",children:[e.map(({domain:l,isDefault:h})=>v.jsxs(Ze,{active:(t===l||h)&&o,onClick:()=>r(l),className:"d-flex justify-content-between align-items-center",children:[l,h&&v.jsx("span",{className:"text-muted",children:"default"})]},l)),v.jsx(Ze,{divider:!0}),v.jsx(Ze,{onClick:c,children:v.jsx("i",{children:"New domain"})})]})},_O=({icon:e,className:t,...r})=>{const n=_i();return v.jsxs("div",{className:"icon-input-container",children:[v.jsx(Zr,{className:Te("icon-input-container__input",t),innerRef:n,...r}),v.jsx(He,{icon:e,fixedWidth:!0,className:"icon-input-container__icon",onClick:()=>{var i;return(i=n.current)==null?void 0:i.focus()}})]})},lTe=({minDate:e,maxDate:t,value:r,onChange:n,withTime:i=!1,...a})=>{const o=M.useCallback(({target:c})=>{if(!c.value){n==null||n(null);return}n==null||n(vi(c.value))},[n]),s=M.useMemo(()=>i?hm:nl,[i]);return v.jsx(Zr,{...a,type:i?"datetime-local":"date",value:s(r)??"",max:s(t)??void 0,min:s(e)??void 0,onChange:o})},F0=({label:e,id:t,...r})=>{const n=M.useId();return v.jsxs(v.Fragment,{children:[v.jsxs("label",{htmlFor:t??n,className:"mb-1",children:[e,":"]}),v.jsx(lTe,{id:t??n,...r})]})},wO=({children:e,infoTooltip:t,checked:r,onChange:n})=>v.jsxs("p",{children:[v.jsx(d7,{inline:!0,checked:r,className:t?"me-2":"",onChange:n,children:e}),t&&v.jsx(Gg,{placement:"right",children:t})]}),uTe=({isOpen:e,toggle:t})=>v.jsxs(Ji,{isOpen:e,toggle:t,centered:!0,size:"lg",children:[v.jsx(Sl,{toggle:t,children:"Info"}),v.jsxs(as,{children:[v.jsxs("p",{children:["When the ",v.jsx("b",{children:v.jsx("i",{children:'"Use existing URL if found"'})})," checkbox is checked, the server will return an existing short URL if it matches provided params."]}),v.jsx("p",{children:"These are the checks performed by Shlink in order to determine if an existing short URL should be returned:"}),v.jsxs("ul",{children:[v.jsx("li",{children:"When only the long URL is provided: The most recent match will be returned, or a new short URL will be created if none is found."}),v.jsxs("li",{children:["When long URL and custom slug and/or domain are provided: Same as in previous case, but it will try to match the short URL using both the long URL and the slug, the long URL and the domain, or the three of them.",v.jsx("br",{}),"If the slug is being used by another long URL, an error will be returned."]}),v.jsx("li",{children:"When other params are provided: Same as in previous cases, but it will try to match existing short URLs with all provided data. If any of them does not match, a new short URL will be created"})]})]})]}),cTe=()=>{const[e,t]=ir();return v.jsxs(v.Fragment,{children:[v.jsx(Wu,{className:"p-0",title:"What does this mean?",onClick:t,children:v.jsx(He,{icon:wT})}),v.jsx(uTe,{isOpen:e,toggle:t})]})},kg=e=>typeof e=="string"?hl(e):e,fTe=e=>"shortCodeLength"in e&&"customSlug"in e&&"domain"in e,$V=({basicMode:e=!1,saving:t,onSave:r,initialState:n,tagsList:i,domainsList:a})=>{var o,s,c;const{TagsSelector:l}=ur($V),[h,p]=M.useState(n),g=fTe(h),_=Ca("deviceLongUrls"),b=Ca("urlValidation"),w=b||g,x=M.useCallback(()=>p(n),[n]),S=M.useCallback((j,N)=>vu(j)?j:vu(N)?null:void 0,[]),C=M.useCallback((j,N)=>p(({deviceLongUrls:$={},...U})=>{var B;return{...U,deviceLongUrls:{...$,[j]:S(N,(B=n.deviceLongUrls)==null?void 0:B[j])}}}),[n.deviceLongUrls,S]),P=M.useCallback(j=>p(N=>({...N,tags:j})),[]),T=M.useCallback(async j=>(j.preventDefault(),r(h).then(N=>g&&!wA(N)&&x()).catch(()=>{})),[g,r,x,h]),A=M.useMemo(()=>v.jsxs("div",{className:"d-flex flex-column gap-3",children:[v.jsx(Zr,{bsSize:"lg",type:"url",placeholder:"URL to be shortened",required:!0,value:h.longUrl,onChange:j=>p(N=>({...N,longUrl:j.target.value}))}),v.jsxs("div",{className:Te("d-flex flex-column flex-lg-row gap-3",{"mb-3":e}),children:[e&&g&&v.jsx("div",{className:"w-100 w-lg-50",children:v.jsx(Zr,{bsSize:"lg",placeholder:"Custom slug",value:h.customSlug??"",onChange:j=>p(N=>({...N,customSlug:j.target.value}))})}),v.jsx("div",{className:Te("w-100",{"w-lg-50":e}),children:v.jsx(l,{tags:i.tags,selectedTags:h.tags??[],onChange:P})})]})]}),[l,e,P,g,h,i.tags]);return v.jsxs("form",{name:"shortUrlForm",className:"short-url-form",onSubmit:T,children:[e&&A,!e&&v.jsxs(v.Fragment,{children:[v.jsxs(Za,{children:[v.jsx("div",{className:Te("mb-3",{"col-sm-6":_,"col-12":!_}),children:v.jsx(Sr,{title:"Main options",children:A})}),_&&v.jsx("div",{className:"col-sm-6 mb-3",children:v.jsxs(Sr,{title:"Device-specific long URLs",bodyClassName:"d-flex flex-column gap-3",children:[v.jsx(_O,{type:"url",icon:Ule,placeholder:"Android-specific redirection",value:((o=h.deviceLongUrls)==null?void 0:o.android)??"",onChange:({target:j})=>C("android",j.value)}),v.jsx(_O,{type:"url",icon:Ble,placeholder:"iOS-specific redirection",value:((s=h.deviceLongUrls)==null?void 0:s.ios)??"",onChange:({target:j})=>C("ios",j.value)}),v.jsx(_O,{type:"url",icon:tZ,placeholder:"Desktop-specific redirection",value:((c=h.deviceLongUrls)==null?void 0:c.desktop)??"",onChange:({target:j})=>C("desktop",j.value)})]})})]}),v.jsxs(Za,{children:[v.jsx("div",{className:"col-sm-6 mb-3",children:v.jsxs(Sr,{title:"Customize the short URL",bodyClassName:"d-flex flex-column gap-3",children:[v.jsx(Zr,{placeholder:"Title",value:h.title??"",onChange:({target:j})=>p(N=>({...N,title:S(j.value,n.title)}))}),g&&v.jsxs(v.Fragment,{children:[v.jsxs(Za,{children:[v.jsx("div",{className:"col-lg-6 mb-3 mb-lg-0",children:v.jsx(Zr,{placeholder:"Custom slug",value:h.customSlug??"",onChange:j=>p(N=>({...N,customSlug:j.target.value})),disabled:vu(h.shortCodeLength)})}),v.jsx("div",{className:"col-lg-6",children:v.jsx(Zr,{type:"number",placeholder:"Short code length",value:h.shortCodeLength??"",onChange:j=>p(N=>({...N,shortCodeLength:j.target.value})),min:4,disabled:vu(h.customSlug)})})]}),v.jsx(sTe,{value:h.domain,onChange:j=>p(N=>({...N,domain:j})),domains:a.domains})]})]})}),v.jsx("div",{className:"col-sm-6 mb-3",children:v.jsxs(Sr,{title:"Limit access to the short URL",children:[v.jsxs("div",{className:"row mb-3",children:[v.jsx("div",{className:"col-lg-6",children:v.jsx(F0,{label:"Enabled since",withTime:!0,maxDate:h.validUntil?kg(h.validUntil):void 0,value:h.validSince?kg(h.validSince):null,onChange:j=>p(N=>({...N,validSince:yl(j)}))})}),v.jsx("div",{className:"col-lg-6 mt-3 mt-lg-0",children:v.jsx(F0,{label:"Enabled until",withTime:!0,minDate:h.validSince?kg(h.validSince):void 0,value:h.validUntil?kg(h.validUntil):null,onChange:j=>p(N=>({...N,validUntil:yl(j)}))})})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:"maxVisits",className:"mb-1",children:"Maximum visits allowed:"}),v.jsx(Zr,{id:"maxVisits",type:"number",min:1,placeholder:"25...",value:h.maxVisits??"",onChange:j=>p(N=>({...N,maxVisits:vu(j.target.value)?Number(j.target.value):null}))})]})]})})]}),v.jsxs(Za,{children:[w&&v.jsx("div",{className:"col-sm-6 mb-3",children:v.jsxs(Sr,{title:"Extra checks",children:[b&&v.jsx(wO,{infoTooltip:"If checked, Shlink will try to reach the long URL, failing in case it's not publicly accessible.",checked:h.validateUrl,onChange:j=>p(N=>({...N,validateUrl:j})),children:"Validate URL"}),g&&v.jsxs("p",{children:[v.jsx(d7,{inline:!0,className:"me-2",checked:h.findIfExists,onChange:j=>p(N=>({...N,findIfExists:j})),children:"Use existing URL if found"}),v.jsx(cTe,{})]})]})}),v.jsx("div",{className:Te("mb-3",{"col-sm-6":w}),children:v.jsxs(Sr,{title:"Configure behavior",children:[v.jsx(wO,{infoTooltip:"This short URL will be included in the robots.txt for your Shlink instance, allowing web crawlers (like Google) to index it.",checked:h.crawlable,onChange:j=>p(N=>({...N,crawlable:j})),children:"Make it crawlable"}),v.jsx(wO,{infoTooltip:"When this short URL is visited, any query params appended to it will be forwarded to the long URL.",checked:h.forwardQuery,onChange:j=>p(N=>({...N,forwardQuery:j})),children:"Forward query params on redirect"})]})})]})]}),v.jsx("div",{className:"text-center",children:v.jsx(Lt,{outline:!0,color:"primary",disabled:t||!h.longUrl,className:"btn-xs-block",children:t?"Saving...":"Save"})})]})},dTe=cr($V,["TagsSelector"]),o_="all",FV={today:"Today",yesterday:"Yesterday",last7Days:"Last 7 days",last30Days:"Last 30 days",last90Days:"Last 90 days",last180Days:"Last 180 days",last365Days:"Last 365 days",[o_]:void 0},BV=Object.keys(FV),hTe=e=>!e||!e.startDate&&!e.endDate,B0=e=>typeof e=="string"&&BV.includes(e),pTe=BV.filter(e=>e!==o_),E8=e=>e?vi(e):null,UV=(e,t)=>({startDate:E8(e),endDate:E8(t)}),mTe=e=>{if(!(!e||hTe(e)))return e.startDate&&!e.endDate?`Since ${nl(e.startDate)}`:!e.startDate&&e.endDate?`Until ${nl(e.endDate)}`:`${nl(e.startDate)} - ${nl(e.endDate)}`},zV=e=>{if(!(!e||e===o_))return B0(e)?FV[e]:mTe(e)},Vi=e=>Fu(Ny(gl(),e)),Xc=e=>({startDate:e,endDate:jf(gl())}),VV=e=>{var t;return((t=[[()=>e==="today",()=>Xc(Fu(gl()))],[()=>e==="yesterday",()=>({startDate:Vi(1),endDate:jf(Ny(gl(),1))})],[()=>e==="last7Days",()=>Xc(Vi(7))],[()=>e==="last30Days",()=>Xc(Vi(30))],[()=>e==="last90Days",()=>Xc(Vi(90))],[()=>e==="last180Days",()=>Xc(Vi(180))],[()=>e==="last365Days",()=>Xc(Vi(365))]].find(([r])=>r()))==null?void 0:t[1]())??{}},vTe=e=>{var t;const r=vi(e);return((t=[[()=>su(Fu(gl()),r),"today"],[()=>su(Vi(1),r),"yesterday"],[()=>su(Vi(7),r),"last7Days"],[()=>su(Vi(30),r),"last30Days"],[()=>su(Vi(90),r),"last90Days"],[()=>su(Vi(180),r),"last180Days"],[()=>su(Vi(365),r),"last365Days"]].find(([n])=>n()))==null?void 0:t[1])??o_},WV=e=>B0(e)?VV(e):e,qV=e=>!!(e&&e.startDate),gTe=({startDate:e,endDate:t})=>{const r=Q7(jf(t??new Date),Fu(e))+1,n=Ny(Fu(e),r),i=Ny(jf(e),1);return{startDate:n,endDate:i}},yTe=e=>{if(qV(e))return Q7(e.endDate??new Date,e.startDate)},bTe=({active:e,allText:t,onChange:r})=>v.jsxs(v.Fragment,{children:[v.jsx(Ze,{active:e==="all",onClick:()=>r("all"),children:t}),v.jsx(Ze,{divider:!0,tag:"hr"}),pTe.map(n=>v.jsx(Ze,{active:e===n,onClick:()=>r(n),children:zV(n)},n))]}),_Te=({startDate:e,endDate:t,disabled:r=!1,onStartDateChange:n,onEndDateChange:i})=>v.jsxs("div",{className:"row",children:[v.jsx("div",{className:"col-md-6",children:v.jsx(F0,{label:"Since",value:e,maxDate:t??void 0,disabled:r,onChange:n})}),v.jsx("div",{className:"col-md-6 mt-3 mt-md-0",children:v.jsx(F0,{label:"Until",value:t,minDate:e??void 0,disabled:r,onChange:a=>i(a&&jf(a))})})]}),DA=({onDatesChange:e,dateRangeOrInterval:t,defaultText:r,disabled:n})=>{const i=M.useMemo(()=>zV(t)??r,[t,r]),[a,o]=M.useMemo(()=>B0(t)?[void 0,t]:[t,void 0],[t]),s=M.useCallback(c=>{B0(c)?e(VV(c),c):e(c)},[e]);return v.jsxs(os,{disabled:n,text:i,children:[v.jsx(bTe,{allText:r,active:o,onChange:s}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx("div",{className:"px-3 py-1",children:v.jsx(_Te,{...a,onStartDateChange:c=>s({...a,startDate:c}),onEndDateChange:c=>s({...a,endDate:c})})})]})},wTe={dateCreated:"Created at",shortCode:"Short URL",longUrl:"Long URL",title:"Title",visits:"Visits"},xTe=({onChange:e,selected:t={},className:r,domains:n})=>{const i=Ca("filterShortUrlsByDomain"),{excludeBots:a=!1,excludeMaxVisitsReached:o=!1,excludePastValidUntil:s=!1,domain:c}=t,l=M.useCallback(p=>e({...t,...p}),[e,t]),h=M.useCallback(p=>l({[p]:!(t!=null&&t[p])}),[l,t]);return v.jsxs(os,{text:"Filters",dropdownClassName:r,end:!0,minWidth:250,children:[v.jsx(Ze,{header:!0,"aria-hidden":!0,children:"Visits:"}),v.jsx(Ze,{active:a,onClick:()=>h("excludeBots"),children:"Ignore visits from bots"}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{header:!0,"aria-hidden":!0,children:"Short URLs:"}),v.jsx(Ze,{active:o,onClick:()=>h("excludeMaxVisitsReached"),children:"Exclude with visits reached"}),v.jsx(Ze,{active:s,onClick:()=>h("excludePastValidUntil"),children:"Exclude enabled in the past"}),i&&v.jsxs(v.Fragment,{children:[v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{header:!0,"aria-hidden":!0,children:["Domain: ",!n&&v.jsx("i",{children:"loading..."})]}),n==null?void 0:n.map(p=>{const g=p.isDefault?ad:p.domain,_=c===g;return v.jsx(Ze,{active:_,onClick:()=>l({domain:_?void 0:g}),children:p.domain},p.domain)})]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{disabled:t.excludeBots===void 0&&t.excludeMaxVisitsReached===void 0&&t.excludePastValidUntil===void 0&&t.domain===void 0,onClick:()=>e({excludeBots:void 0,excludeMaxVisitsReached:void 0,excludePastValidUntil:void 0,domain:void 0}),className:"fst-italic",children:"Reset to defaults"})]})},HV=({className:e,shortUrlsAmount:t,order:r,handleOrderBy:n,tagsList:i,domainsList:a})=>{const{ExportShortUrlsBtn:o,TagsSelector:s}=ur(HV),[{search:c,tags:l,startDate:h,endDate:p,excludeBots:g,excludeMaxVisitsReached:_,excludePastValidUntil:b,domain:w,tagsMode:x="any"},S]=n_(),C=Nn("visits"),[P,T]=M.useState(),A=M.useCallback(({startDate:U,endDate:B},W)=>{S({startDate:yl(U)??void 0,endDate:yl(B)??void 0}),T(W)},[S]),j=M.useCallback(U=>S({search:U||void 0}),[S]),N=M.useCallback(U=>S({tags:U}),[S]),$=M.useCallback(()=>S({tagsMode:x==="any"?"all":"any"}),[x,S]);return v.jsxs("div",{className:Te("short-urls-filtering-bar-container",e),children:[v.jsx(ob,{initialValue:c,onChange:j}),v.jsxs(Om,{className:"mt-3",children:[v.jsx(s,{immutable:!0,placeholder:"With tags...",tags:i.tags,selectedTags:l,onChange:N}),l.length>1&&v.jsxs(v.Fragment,{children:[v.jsx(Lt,{outline:!0,color:"secondary",onClick:$,id:"tagsModeBtn","aria-label":"Change tags mode",children:v.jsx(He,{className:"short-urls-filtering-bar__tags-icon",icon:x==="all"?F$:TY})}),v.jsx(Oi,{target:"tagsModeBtn",placement:"left",children:x==="all"?"With all the tags.":"With any of the tags."})]})]}),v.jsxs(Za,{className:"flex-lg-row-reverse",children:[v.jsx("div",{className:"col-lg-8 col-xl-6 mt-3",children:v.jsxs("div",{className:"d-md-flex",children:[v.jsx("div",{className:"flex-grow-1",children:v.jsx(DA,{defaultText:"All short URLs",dateRangeOrInterval:P??UV(h,p),onDatesChange:A})}),v.jsx(xTe,{className:"ms-0 ms-md-2 mt-3 mt-md-0",selected:{excludeBots:g??(C==null?void 0:C.excludeBots),excludeMaxVisitsReached:_,excludePastValidUntil:b,domain:w},onChange:S,domains:a.loading?void 0:a.domains})]})}),v.jsx("div",{className:"col-6 col-lg-4 col-xl-6 mt-3",children:v.jsx(o,{amount:t})}),v.jsx("div",{className:"col-6 d-lg-none mt-3",children:v.jsx(Em,{prefixed:!1,items:wTe,order:r,onChange:n})})]})]})},STe=cr(HV,["ExportShortUrlsBtn","TagsSelector"]);function pp({currentOrder:e,field:t,className:r="ms-1"}){return!e.dir||e.field!==t?null:v.jsx(He,{icon:e.dir==="ASC"?bY:RY,className:r})}const Qc=2,QE="...",GV=(e,t)=>{const r=sj(Math.max(Qc,e-Qc),Math.min(t-1,e+Qc)+1);return e-Qc>Qc&&r.unshift(QE),e+Qce===QE,KV=e=>pm(e)?e:Or(e),YV=(e,t)=>pm(e)?`${e}_${t}`:`${e}`,OTe=({paginator:e,currentQueryString:t=""})=>{const{currentPage:r=0,pagesCount:n=0}=e??{},i=jl(),a=s=>`${i}/list-short-urls/${s}${t}`;if(n<=1)return v.jsx("div",{className:"pb-3"});const o=()=>GV(r,n).map((s,c)=>v.jsx(Pu,{disabled:pm(s),active:r===s,children:v.jsx(Eu,{tag:Xt,to:a(s),children:KV(s)})},YV(s,c)));return v.jsxs(QT,{className:"sticky-card-paginator py-3",listClassName:"flex-wrap justify-content-center mb-0",children:[v.jsx(Pu,{disabled:r===1,children:v.jsx(Eu,{previous:!0,tag:Xt,to:a(r-1)})}),o(),v.jsx(Pu,{disabled:r>=n,children:v.jsx(Eu,{next:!0,tag:Xt,to:a(r+1)})})]})},CTe={field:"dateCreated",dir:"DESC"},ZV=ka(({listShortUrls:e,shortUrlsList:t})=>{var r,n,i;const{ShortUrlsTable:a,ShortUrlsFilteringBar:o}=ur(ZV),{page:s}=cd(),c=bn(),[{tags:l,search:h,startDate:p,endDate:g,orderBy:_,tagsMode:b,excludeBots:w,excludePastValidUntil:x,excludeMaxVisitsReached:S,domain:C},P]=n_(),T=lj(),[A,j]=M.useState(_??((r=T.shortUrlsList)==null?void 0:r.defaultOrdering)??CTe),{pagination:N}=(t==null?void 0:t.shortUrls)??{},$=M.useMemo(()=>{var re;return w??((re=T.visits)==null?void 0:re.excludeBots)},[w,(n=T.visits)==null?void 0:n.excludeBots]),U=M.useCallback((re,oe)=>{P({orderBy:{field:re,dir:oe}}),j({field:re,dir:oe})},[P]),B=re=>()=>U(re,Pm(re,A.field,A.dir)),W=re=>v.jsx(pp,{currentOrder:A,field:re}),q=M.useCallback(re=>P({tags:[...new Set([...l,re])]}),[l,P]),J=M.useCallback(({field:re,dir:oe})=>$&&re==="visits"?{field:"nonBotVisits",dir:oe}:{field:re,dir:oe},[$]),Q=SA();return M.useEffect(()=>{e({page:s,searchTerm:h,tags:l,startDate:p,endDate:g,orderBy:J(A),tagsMode:b,excludePastValidUntil:x,excludeMaxVisitsReached:S,domain:C})},[e,J,s,h,l,p,g,A,b,x,S,C]),v.jsxs(xA,{value:Q,children:[v.jsx(o,{shortUrlsAmount:(i=t.shortUrls)==null?void 0:i.pagination.totalItems,order:A,handleOrderBy:U,className:"mb-3"}),v.jsx(OA,{type:"short-urls",className:"mb-3"}),v.jsxs(Qi,{body:!0,className:Te({"pb-0":!t.loading}),children:[v.jsx(a,{shortUrlsList:t,orderByColumn:B,renderOrderIcon:W,onTagClick:q}),!t.loading&&v.jsx(OTe,{paginator:N,currentQueryString:c.search})]})]})},()=>[Rn.visits]),PTe=cr(ZV,["ShortUrlsTable","ShortUrlsFilteringBar"]),ETe=({shortUrlsList:e,onTagClick:t,ShortUrlsRow:r})=>{const{error:n,loading:i,shortUrls:a}=e;return n?v.jsx("tr",{children:v.jsx("td",{colSpan:6,className:"text-center table-danger text-dark",children:"Something went wrong while loading short URLs :("})}):i?v.jsx("tr",{children:v.jsx("td",{colSpan:6,className:"text-center",children:"Loading..."})}):!i&&(!a||a.data.length===0)?v.jsx("tr",{children:v.jsx("td",{colSpan:6,className:"text-center",children:"No results found"})}):a==null?void 0:a.data.map(o=>v.jsx(r,{shortUrl:o,onTagClick:t},o.shortUrl))},XV=({orderByColumn:e,renderOrderIcon:t,shortUrlsList:r,onTagClick:n,className:i})=>{const{ShortUrlsRow:a}=ur(XV),o=Te({"short-urls-table__header-cell--with-action":!!e}),s=Te("short-urls-table__header-cell",o),c=Te("table table-hover responsive-table short-urls-table",i);return v.jsxs("table",{className:c,children:[v.jsx("thead",{className:"responsive-table__header short-urls-table__header",children:v.jsxs("tr",{children:[v.jsxs("th",{className:s,onClick:e==null?void 0:e("dateCreated"),children:["Created at ",t==null?void 0:t("dateCreated")]}),v.jsxs("th",{className:s,onClick:e==null?void 0:e("shortCode"),children:["Short URL ",t==null?void 0:t("shortCode")]}),v.jsxs("th",{className:"short-urls-table__header-cell",children:[v.jsxs(Wu,{className:Te("p-0",o),onClick:e==null?void 0:e("title"),children:["Title ",t==null?void 0:t("title")]}),"  /  ",v.jsxs(Wu,{className:Te("p-0",o),onClick:e==null?void 0:e("longUrl"),children:[v.jsx("span",{className:"indivisible",children:"Long URL"})," ",t==null?void 0:t("longUrl")]})]}),v.jsx("th",{className:"short-urls-table__header-cell",children:"Tags"}),v.jsx("th",{className:s,onClick:e==null?void 0:e("visits"),children:v.jsxs("span",{className:"indivisible",children:["Visits ",t==null?void 0:t("visits")]})}),v.jsx("th",{className:"short-urls-table__header-cell",colSpan:2,"aria-hidden":!0})]})}),v.jsx("tbody",{children:v.jsx(ETe,{ShortUrlsRow:a,shortUrlsList:r,onTagClick:n})})]})},TTe=cr(XV,["ShortUrlsRow"]),jTe=(e,t)=>{e.factory("ShortUrlsList",PTe),e.decorator("ShortUrlsList",t(["mercureInfo","shortUrlsList"],["listShortUrls","createNewVisits","loadMercureInfo"])),e.factory("ShortUrlsTable",TTe),e.factory("ShortUrlsRow",JEe),e.factory("CreateShortUrlResult",MEe),e.factory("ShortUrlsRowMenu",eTe),e.decorator("ShortUrlsRowMenu",t(null,["shortUrlDeleted","deleteShortUrl"])),e.factory("ShortUrlForm",dTe),e.decorator("ShortUrlForm",t(["tagsList","domainsList"])),e.factory("CreateShortUrl",REe),e.decorator("CreateShortUrl",t(["shortUrlCreation"],["createShortUrl","resetCreateShortUrl"])),e.factory("EditShortUrl",NEe),e.decorator("EditShortUrl",t(["shortUrlsDetails","shortUrlEdition"],["getShortUrlsDetails","editShortUrl"])),e.serviceFactory("DeleteShortUrlModal",()=>LEe),e.decorator("DeleteShortUrlModal",t(["shortUrlDeletion"],["resetDeleteShortUrl"])),e.factory("QrCodeModal",qEe),e.factory("ExportShortUrlsBtn",IEe),e.factory("ShortUrlsFilteringBar",STe),e.decorator("ShortUrlsFilteringBar",t(["tagsList","domainsList"])),e.serviceFactory("shortUrlsListReducerCreator",nPe,"listShortUrls","editShortUrl","createShortUrl"),e.serviceFactory("shortUrlsListReducer",r=>r.reducer,"shortUrlsListReducerCreator"),e.serviceFactory("shortUrlCreationReducerCreator",rTe,"createShortUrl"),e.serviceFactory("shortUrlCreationReducer",r=>r.reducer,"shortUrlCreationReducerCreator"),e.serviceFactory("shortUrlEditionReducerCreator",aTe,"editShortUrl"),e.serviceFactory("shortUrlEditionReducer",r=>r.reducer,"shortUrlEditionReducerCreator"),e.serviceFactory("shortUrlDeletionReducerCreator",ePe,"deleteShortUrl"),e.serviceFactory("shortUrlDeletionReducer",r=>r.reducer,"shortUrlDeletionReducerCreator"),e.serviceFactory("shortUrlsDetailsReducerCreator",oTe,"apiClientFactory"),e.serviceFactory("shortUrlsDetailsReducer",r=>r.reducer,"shortUrlsDetailsReducerCreator"),e.serviceFactory("listShortUrls",rPe,"apiClientFactory"),e.serviceFactory("createShortUrl",tTe,"apiClientFactory"),e.serviceFactory("resetCreateShortUrl",r=>r.resetCreateShortUrl,"shortUrlCreationReducerCreator"),e.serviceFactory("deleteShortUrl",JCe,"apiClientFactory"),e.serviceFactory("resetDeleteShortUrl",r=>r.resetDeleteShortUrl,"shortUrlDeletionReducerCreator"),e.serviceFactory("shortUrlDeleted",()=>tV),e.serviceFactory("getShortUrlsDetails",r=>r.getShortUrlsDetails,"shortUrlsDetailsReducerCreator"),e.serviceFactory("editShortUrl",iTe,"apiClientFactory")},ATe=({tag:e,toggle:t,isOpen:r,deleteTag:n,tagDelete:i,tagDeleted:a})=>{const{deleting:o,error:s,deleted:c,errorData:l}=i;return v.jsxs(Ji,{toggle:t,isOpen:r,centered:!0,onClosed:()=>c&&a(e),children:[v.jsx(Sl,{toggle:t,className:"text-danger",children:"Delete tag"}),v.jsxs(as,{children:["Are you sure you want to delete tag ",v.jsx("b",{children:e}),"?",s&&v.jsx(gi,{type:"error",small:!0,className:"mt-2",children:v.jsx(uo,{errorData:l,fallbackMessage:"Something went wrong while deleting the tag :("})})]}),v.jsxs(Hu,{children:[v.jsx(Lt,{color:"link",onClick:t,children:"Cancel"}),v.jsx(Lt,{color:"danger",disabled:o,onClick:async()=>{await n(e),t()},children:o?"Deleting tag...":"Delete tag"})]})]})},QV=({tag:e,editTag:t,toggle:r,tagEdited:n,isOpen:i,tagEdit:a})=>{const{ColorGenerator:o}=ur(QV),[s,c]=M.useState(e),[l,h]=M.useState(o.getColorForKey(e)),{editing:p,error:g,edited:_,errorData:b}=a,w=Qz(async()=>{await t({oldName:e,newName:s,color:l}),r()}),x=M.useCallback(()=>_&&n({oldName:e,newName:s,color:l}),[l,_,s,e,n]);return v.jsx(Ji,{isOpen:i,toggle:r,centered:!0,onClosed:x,children:v.jsxs("form",{name:"editTag",onSubmit:w,children:[v.jsx(Sl,{toggle:r,children:"Edit tag"}),v.jsxs(as,{children:[v.jsxs(Om,{children:[v.jsx(AV,{color:l,onChange:h,className:"input-group-text",name:"tag-color"}),v.jsx(Zr,{value:s,placeholder:"Tag",required:!0,onChange:({target:S})=>c(S.value)})]}),g&&v.jsx(gi,{type:"error",small:!0,className:"mt-2",children:v.jsx(uo,{errorData:b,fallbackMessage:"Something went wrong while editing the tag :("})})]}),v.jsxs(Hu,{children:[v.jsx(Lt,{type:"button",color:"link",onClick:r,children:"Cancel"}),v.jsx(Lt,{color:"primary",disabled:p,children:p?"Saving...":"Save"})]})]})})},kTe=cr(QV,["ColorGenerator"]),RTe=/\s+/g,JV=e=>e.trim().toLowerCase().replace(RTe,"-"),eW=({color:e})=>v.jsx("div",{style:{backgroundColor:e},className:"color-bullet"}),tW=({tag:e,colorGenerator:t})=>v.jsx(eW,{color:t.getColorForKey(e)});let T8=1;const rW="Tag not found",nW="Add tag",NTe=e=>e!==rW,MTe=e=>e===nW,j8=e=>(T8+=1,{label:e,value:`${e}${T8}`}),LTe=e=>({tag:t,onClick:r})=>v.jsx(a_,{colorGenerator:e,text:t.label,className:"react-tags__tag",onClose:r}),ITe=(e,t)=>({option:r,classNames:n,...i})=>{var a;const o=NTe(r.label),s=MTe(r.label);return v.jsx("div",{className:Te(n.option,{[n.optionIsActive]:o&&r.active,"react-tags__listbox-option--not-selectable":!o}),...i,children:o?v.jsxs(v.Fragment,{children:[!s&&v.jsx(tW,{tag:`${r.label}`,colorGenerator:e}),s?v.jsxs("i",{children:['Add "',JV(((a=t.current)==null?void 0:a.input.value)??""),'"']}):r.label]}):v.jsx("i",{children:r.label})})},iW=({selectedTags:e,onChange:t,placeholder:r,tags:n,immutable:i=!1})=>{const{ColorGenerator:a}=ur(iW),o=Nn("shortUrlCreation"),s=(o==null?void 0:o.tagFilteringMode)??"startsWith",c=_i();return v.jsx(Fue,{ref:c,selected:e.map(j8),suggestions:n.filter(l=>!e.includes(l)).map(j8),renderTag:LTe(a),renderOption:ITe(a,c),activateFirstOption:!0,allowNew:!i,newOptionText:nW,noOptionsText:rW,placeholderText:r??"Add tags to the URL",delimiterKeys:["Enter",","],suggestionsTransform:(l,h)=>{const p=l.toLowerCase().trim();return p.length<1?[]:[...h.filter(({label:g})=>s==="includes"?g.includes(p):g.startsWith(p))].slice(0,5)},onDelete:l=>{const h=[...e];h.splice(l,1),t(h)},onAdd:({label:l})=>t([...new Set([...e,...l.split(",").map(JV)])])})},DTe=cr(iW,["ColorGenerator"]),JE="shlink/tagDelete",$Te={deleting:!1,deleted:!1,error:!1},aW=An(`${JE}/tagDeleted`),FTe=e=>{const t=Vr(`${JE}/deleteTag`,async n=>{await e().deleteTags([n])}),{reducer:r}=Tr({name:JE,initialState:$Te,reducers:{},extraReducers:n=>{n.addCase(t.pending,()=>({deleting:!0,deleted:!1,error:!1})),n.addCase(t.rejected,(i,{error:a})=>({deleting:!1,deleted:!1,error:!0,errorData:Ci(a)})),n.addCase(t.fulfilled,()=>({deleting:!1,deleted:!0,error:!1}))}});return{reducer:r,deleteTag:t}},$A="shlink/tagEdit",BTe={editing:!1,edited:!1,error:!1},oW=An(`${$A}/tagEdited`),UTe=(e,t)=>Vr(`${$A}/editTag`,async({oldName:r,newName:n,color:i})=>(await e().editTag({oldName:r,newName:n}),t.setColorForKey(n,i),{oldName:r,newName:n,color:i})),zTe=e=>Tr({name:$A,initialState:BTe,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({editing:!0,edited:!1,error:!1})),t.addCase(e.rejected,(r,{error:n})=>({editing:!1,edited:!1,error:!0,errorData:Ci(n)})),t.addCase(e.fulfilled,(r,{payload:n})=>{const{oldName:i,newName:a}=n;return{oldName:i,newName:a,editing:!1,edited:!0,error:!1}})}}),FA="shlink/tagsList",xO={tags:[],filteredTags:[],stats:{},loading:!1,error:!1},A8=(e,t)=>r=>r===e?t:r,k8=(e,t)=>e.filter(r=>r!==t),VTe=(e,t)=>e.reduce((r,[n,i])=>{if(!r[n])return r;const{bots:a,nonBots:o}=i,s=r[n];return{...r,[n]:{...s,visitsSummary:s.visitsSummary&&{total:s.visitsSummary.total+a+o,bots:s.visitsSummary.bots+a,nonBots:s.visitsSummary.nonBots+o},visitsCount:(s.visitsCount??0)+a+o}}},{...t}),WTe=e=>Object.entries(e.reduce((t,{shortUrl:r,visit:n})=>(r==null||r.tags.forEach(i=>{t[i]||(t[i]={bots:0,nonBots:0}),n.potentialBot?t[i].bots+=1:t[i].nonBots+=1}),t),{})),qTe=e=>Vr(`${FA}/listTags`,async()=>{const{data:t}=await e().tagsStats(),r=t.reduce((n,{tag:i,...a})=>(n[i]=a,n),{});return{tags:Object.keys(r),stats:r}}),sW=An(`${FA}/filterTags`),HTe=(e,t)=>Tr({name:FA,initialState:xO,reducers:{},extraReducers:r=>{r.addCase(sW,(n,{payload:i})=>({...n,filteredTags:n.tags.filter(a=>a.toLowerCase().match(i.toLowerCase()))})),r.addCase(e.pending,n=>({...n,loading:!0,error:!1})),r.addCase(e.rejected,(n,{error:i})=>({...xO,error:!0,errorData:Ci(i)})),r.addCase(e.fulfilled,(n,{payload:i})=>({...xO,stats:i.stats,tags:i.tags,filteredTags:i.tags})),r.addCase(aW,({tags:n,filteredTags:i,...a},{payload:o})=>({...a,tags:k8(n,o),filteredTags:k8(i,o)})),r.addCase(oW,({tags:n,filteredTags:i,stats:a,...o},{payload:s})=>({...o,stats:{...a,[s.newName]:a[s.oldName]},tags:n.map(A8(s.oldName,s.newName)).sort(),filteredTags:i.map(A8(s.oldName,s.newName)).sort()})),r.addCase(Ed,(n,{payload:i})=>({...n,stats:VTe(WTe(i.createdVisits),n.stats)})),r.addCase(t.fulfilled,({tags:n,...i},{payload:a})=>({...i,tags:n.concat(a.tags.filter(o=>!n.includes(o)))}))}}),GTe={tag:"Tag",shortUrls:"Short URLs",visits:"Visits"},lW=ka(({filterTags:e,tagsList:t})=>{var r,n;const{TagsTable:i}=ur(lW),a=lj(),[o,s]=M.useState(((r=a.tags)==null?void 0:r.defaultOrdering)??{}),c=M.useMemo(()=>{const h=t.filteredTags.map(p=>{var g,_,b;const w=t.stats[p],x=((g=a.visits)!=null&&g.excludeBots?(_=w==null?void 0:w.visitsSummary)==null?void 0:_.nonBots:(b=w==null?void 0:w.visitsSummary)==null?void 0:b.total)??(w==null?void 0:w.visitsCount)??0;return{tag:p,visits:x,shortUrls:(w==null?void 0:w.shortUrlsCount)??0}});return v7(h,o)},[o,(n=a.visits)==null?void 0:n.excludeBots,t.filteredTags,t.stats]),l=SA();return t.loading?v.jsx(Lu,{loading:!0}):t.error?v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:t.errorData,fallbackMessage:"Error loading tags :("})}):v.jsxs(xA,{value:l,children:[v.jsx(ob,{className:"mb-3",onChange:e}),v.jsx(Za,{className:"mb-3",children:v.jsx("div",{className:"col-lg-6 offset-lg-6",children:v.jsx(Em,{items:GTe,order:o,onChange:(h,p)=>s({field:h,dir:p})})})}),v.jsx(OA,{type:"tags",className:"mb-3"}),v.jsx(i,{sortedTags:c,currentOrder:o,orderByColumn:h=>()=>{const p=Pm(h,o.field,o.dir);s({field:p?h:void 0,dir:p})}})]})},()=>[Rn.visits]),KTe=cr(lW,["TagsTable"]),BA=({pagesCount:e,currentPage:t,onPageChange:r,centered:n=!0})=>{const i=M.useCallback(a=>!pm(a)&&r(a),[r]);return e<2?null:v.jsxs(QT,{listClassName:Te("flex-wrap mb-0 simple-paginator",{"justify-content-center":n}),children:[v.jsx(Pu,{disabled:t<=1,children:v.jsx(Eu,{previous:!0,tag:"span",onClick:()=>i(t-1)})}),GV(t,e).map((a,o)=>v.jsx(Pu,{disabled:pm(a),active:t===a,children:v.jsx(Eu,{role:"link",tag:"span",onClick:()=>i(a),children:KV(a)})},YV(a,o))),v.jsx(Pu,{disabled:t>=e,children:v.jsx(Eu,{next:!0,tag:"span",onClick:()=>i(t+1)})})]})},YTe=20,uW=({sortedTags:e,orderByColumn:t,currentOrder:r})=>{const{TagsTableRow:n}=ur(uW),i=M.useRef(!0),{page:a=1}=hd(),[o,s]=ICe("page",Number(a)),c=M.useCallback(g=>{s(g),scrollTo(0,0)},[s]),l=pf(e,YTe),h=l.length>1,p=l[o-1]??[];return M.useEffect(()=>{i.current||c(1),i.current=!1},[c,e]),v.jsxs(Sr,{bodyClassName:h?"pb-1":"",children:[v.jsxs("table",{className:"table table-hover responsive-table mb-0",children:[v.jsxs("thead",{className:"responsive-table__header",children:[v.jsxs("tr",{children:[v.jsxs("th",{className:"tags-table__header-cell",onClick:t("tag"),children:["Tag ",v.jsx(pp,{currentOrder:r,field:"tag"})]}),v.jsxs("th",{className:"tags-table__header-cell text-lg-end",onClick:t("shortUrls"),children:["Short URLs ",v.jsx(pp,{currentOrder:r,field:"shortUrls"})]}),v.jsxs("th",{className:"tags-table__header-cell text-lg-end",onClick:t("visits"),children:["Visits ",v.jsx(pp,{currentOrder:r,field:"visits"})]}),v.jsx("th",{className:"tags-table__header-cell",children:v.jsx("span",{className:"sr-only",children:"Options"})})]}),v.jsx("tr",{children:v.jsx("th",{"aria-hidden":!0,colSpan:4,className:"p-0 border-top-0"})})]}),v.jsxs("tbody",{children:[p.length===0&&v.jsx("tr",{children:v.jsx("td",{colSpan:4,className:"text-center",children:"No tags found"})}),p.map(g=>v.jsx(n,{tag:g},g.tag))]})]}),h&&v.jsx("div",{className:"sticky-card-paginator",children:v.jsx(BA,{pagesCount:l.length,currentPage:o,onPageChange:c})})]},o)},ZTe=cr(uW,["TagsTableRow"]),cW=({tag:e})=>{const{DeleteTagConfirmModal:t,EditTagModal:r,ColorGenerator:n}=ur(cW),[i,a]=ir(),[o,s]=ir(),c=jl(),l=Jb();return v.jsxs("tr",{className:"responsive-table__row",children:[v.jsxs("th",{className:"responsive-table__cell","data-th":"Tag",children:[v.jsx(tW,{tag:e.tag,colorGenerator:n})," ",e.tag]}),v.jsx("td",{className:"responsive-table__cell text-lg-end","data-th":"Short URLs",children:v.jsx(Xt,{to:`${c}/list-short-urls/1?tags=${encodeURIComponent(e.tag)}`,children:Or(e.shortUrls)})}),v.jsx("td",{className:"responsive-table__cell text-lg-end","data-th":"Visits",children:v.jsx(Xt,{to:`${c}/tag/${e.tag}/visits`,children:Or(e.visits)})}),v.jsx("td",{className:"responsive-table__cell text-lg-end",children:v.jsxs(lb,{children:[v.jsxs(Ze,{onClick:s,children:[v.jsx(He,{icon:$$,fixedWidth:!0,className:"me-1"})," Edit"]}),v.jsxs(Ze,{disabled:!l||!l.canAddItemWithName(e.tag),onClick:()=>l==null?void 0:l.addItemToCompare({name:e.tag,query:e.tag,style:n.stylesForKey(e.tag)}),children:[v.jsx(He,{icon:X0,fixedWidth:!0})," Compare visits"]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{className:"dropdown-item--danger",onClick:a,children:[v.jsx(He,{icon:OY,fixedWidth:!0,className:"me-1"})," Delete tag"]})]})}),v.jsx(r,{tag:e.tag,toggle:s,isOpen:o}),v.jsx(t,{tag:e.tag,toggle:a,isOpen:i})]})},XTe=cr(cW,["DeleteTagConfirmModal","EditTagModal","ColorGenerator"]),QTe=(e,t)=>{e.factory("TagsSelector",DTe),e.serviceFactory("DeleteTagConfirmModal",()=>ATe),e.decorator("DeleteTagConfirmModal",t(["tagDelete"],["deleteTag","tagDeleted"])),e.factory("EditTagModal",kTe),e.decorator("EditTagModal",t(["tagEdit"],["editTag","tagEdited"])),e.factory("TagsTableRow",XTe),e.factory("TagsTable",ZTe),e.factory("TagsList",KTe),e.decorator("TagsList",t(["tagsList","mercureInfo"],["filterTags","createNewVisits","loadMercureInfo"])),e.serviceFactory("tagEditReducerCreator",zTe,"editTag"),e.serviceFactory("tagEditReducer",r=>r.reducer,"tagEditReducerCreator"),e.serviceFactory("tagDeleteReducerCreator",FTe,"apiClientFactory"),e.serviceFactory("tagDeleteReducer",r=>r.reducer,"tagDeleteReducerCreator"),e.serviceFactory("tagsListReducerCreator",HTe,"listTags","createShortUrl"),e.serviceFactory("tagsListReducer",r=>r.reducer,"tagsListReducerCreator"),e.serviceFactory("listTags",qTe,"apiClientFactory"),e.serviceFactory("filterTags",()=>sW),e.serviceFactory("deleteTag",r=>r.deleteTag,"tagDeleteReducerCreator"),e.serviceFactory("tagDeleted",()=>aW),e.serviceFactory("editTag",UTe,"apiClientFactory","ColorGenerator"),e.serviceFactory("tagEdited",()=>oW)},JTe=new cB,eje=e=>JTe.parse(e),R8=e=>e.toLowerCase().trim();class tje{constructor(t){ll(this,"colors"),ll(this,"lights");var r;this.storage=t,this.colors=((r=this.storage)==null?void 0:r.getTagColors())??{},this.lights={}}getColorForKey(t){const r=R8(t);return this.colors[r]||this.setColorForKey(r,BEe())}setColorForKey(t,r){var n;const i=R8(t);return this.colors[i]=r,(n=this.storage)==null||n.storeTagColors(this.colors),r}stylesForKey(t){const r=this.getColorForKey(t);return{backgroundColor:r,color:this.isLightColor(r)?"#222":"#fff"}}isLightColor(t){const r=t.substring(1);return this.lights[r]===void 0&&(this.lights[r]=jV(r)),this.lights[r]}}const fW=({document:e},t,r)=>{const n=e.createElement("a");n.setAttribute("href",t),n.setAttribute("download",r),n.style.visibility="hidden",e.body.appendChild(n),n.click(),e.body.removeChild(n)},rje=(e,t,r)=>{const n=new Blob([t],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(n);fW(e,i,r)};class nje{constructor(t,r){this.fetch=t,this.window=r}async saveImage(t,r){const n=await this.fetch(t).then(a=>a.blob()),i=URL.createObjectURL(n);fW(this.window,i,r)}}class ije{constructor(t,r){ll(this,"exportVisits",(n,i)=>{i.length&&this.exportCsv(n,i)}),ll(this,"exportShortUrls",n=>{n.length&&this.exportCsv("short_urls.csv",n)}),ll(this,"exportCsv",(n,i)=>{const a=this.jsonToCsv(i);rje(this.window,a,n)}),this.window=t,this.jsonToCsv=r}}function aje(e){e.constant("window",window),e.constant("fetch",window.fetch.bind(window)),e.service("ImageDownloader",nje,"fetch","window"),e.service("ColorGenerator",tje,"TagColorsStorage"),e.constant("jsonToCsv",eje),e.service("ReportExporter",ije,"window","jsonToCsv"),e.serviceFactory("useTimeoutToggle",()=>p7)}const zm=({visits:e,shortUrl:t,children:r,title:n})=>v.jsx("header",{children:v.jsxs(Qi,{body:!0,children:[v.jsxs("h2",{className:"d-flex justify-content-between align-items-center mb-0",children:[v.jsx(i_,{}),v.jsx("span",{className:"text-center d-none d-sm-block",children:v.jsx("small",{children:n})}),v.jsxs("span",{className:"badge badge-main ms-3",children:["Visits:"," ",v.jsx(NV,{visitsCount:e.length,shortUrl:t})]})]}),v.jsx("h3",{className:"text-center d-block d-sm-none mb-0 mt-3",children:v.jsx("small",{children:n})}),r&&v.jsx("div",{className:"mt-md-2",children:r})]})}),s_=({children:e,className:t})=>v.jsx("div",{className:Te("d-flex justify-content-between align-items-center",t),children:e}),dW=({title:e,footer:t,children:r})=>v.jsxs(Qi,{role:"document",children:[v.jsx(Sm,{className:"chart-card__header",children:e}),v.jsx(xm,{children:r}),t&&v.jsx(e7,{className:"chart-card__footer--sticky",children:t})]}),hW=M.createContext(null),{Provider:Dke}=hW,UA=e=>{const t=M.useContext(hW)??void 0,r=M.useMemo(()=>t?{}:{width:"100%",height:e},[e,t]);return{ChartWrapper:t?M.Fragment:Cpe,dimensions:t,wrapperDimensions:r}},pW={color:"white",background:"rgb(0 0 0 / .9)",border:"none",borderRadius:"5px"},oje={marginBottom:"5px",fontWeight:"bold"},mW={contentStyle:pW,labelStyle:oje,itemStyle:{padding:0}},N8=["#97BBCD","#F7464A","#46BFBD","#FDB45C","#949FB1","#57A773","#414066","#08B2E3","#B6C454","#DCDCDC","#463730"],vW=e=>N8[e%N8.length],U0=()=>Tm()?"#46e587":"#1DAA58",sje=()=>Tm()?"rgba(70, 229, 135, 0.4)":"rgba(29, 170, 88, 0.4)",lje=({chartData:e,showNumbers:t})=>v.jsx("ul",{className:"doughnut-chart-legend",children:e.map(({name:r,color:n,value:i})=>v.jsxs("li",{className:"doughnut-chart-legend__item d-flex",children:[v.jsx("div",{className:"doughnut-chart-legend__item-color",style:{backgroundColor:n}}),v.jsxs("small",{className:"doughnut-chart-legend__item-text flex-fill",children:[r,t&&v.jsxs("b",{children:[" (",Or(i),")"]})]})]},r))}),M8=e=>M.useMemo(()=>Object.entries(e).map(([t,r],n)=>({name:t,value:r,color:vW(n)})),[e]),uje=({stats:e,prevStats:t,showNumbersInLegend:r})=>{const n=M8(e),i=M8(t),a=i.length>0,o=Tm()?nae:rae,{ChartWrapper:s,dimensions:c,wrapperDimensions:l}=UA(300);return v.jsxs("div",{className:"row align-items-center",children:[v.jsx("div",{className:"col-sm-12 col-md-7",children:v.jsx("div",{style:l,children:v.jsx(s,{children:v.jsxs(YOe,{...c,children:[v.jsx(zi,{formatter:Or,contentStyle:pW,itemStyle:{color:"white"}}),v.jsx(lo,{data:n,dataKey:"value",nameKey:"name",startAngle:360,endAngle:0,outerRadius:"100%",innerRadius:a?"65%":"50%",animationBegin:0,children:n.map((h,p)=>v.jsx(al,{fill:h.color,stroke:o},`${h.name}-${p}`))}),a&&v.jsx(lo,{data:i,dataKey:"value",nameKey:"name",startAngle:360,endAngle:0,outerRadius:"55%",innerRadius:"20%",animationBegin:0,stroke:o,fill:U0()})]})})})}),v.jsx("div",{className:"col-sm-12 col-md-5",children:v.jsx(lje,{chartData:n,showNumbers:r})})]})},L8=({title:e,...t})=>{const[r,n]=ir(!1);return v.jsx(dW,{title:v.jsxs(s_,{children:[e,v.jsx("div",{children:v.jsx(Xo,{checked:r,onChange:n,children:"Show numbers"})})]}),children:v.jsx(uje,{...t,showNumbersInLegend:r})})},cje=M.forwardRef(({visitsGroups:e},t)=>{const r=M.useMemo(()=>Object.entries(e),[e]);return r.length===0?null:v.jsx("ul",{className:"list-unstyled mb-0 mt-2 d-flex flex-wrap justify-content-center gap-3",ref:t,children:r.map(([n,i],a)=>v.jsxs("li",{className:"d-inline",children:[v.jsx(eW,{color:gW(i)}),v.jsxs("strong",{children:[n," (",Or(i.length),")"]})]},`${n}${a}`))})}),fje={monthly:"Month",weekly:"Week",daily:"Day",hourly:"Hour"},dje={hourly:e=>({hours:e}),daily:e=>({days:e}),weekly:e=>({weeks:e}),monthly:e=>({months:e})},hje={hourly:pse,daily:mb,weekly:hse,monthly:Ay},zA={hourly:e=>ky(e,"yyyy-MM-dd HH:00"),daily:e=>nl(e),weekly(e){const t=nl(jp(e)),r=nl(xse(e));return`${t} - ${r}`},monthly:e=>ky(e,"yyyy-MM")},pje=e=>{var t;const r=Object.values(e).filter(o=>o.length>0);if(r.length===0)return"monthly";const n=new Date,i=r.map(o=>hl(o[o.length-1].date)),a=X7(i);return((t=[[()=>mb(n,a)<=2,"hourly"],[()=>Ay(n,a)<=1,"daily"],[()=>Ay(n,a)<=6,"weekly"]].find(([o])=>o()))==null?void 0:t[1])??"monthly"},mje=(e,t)=>Object.keys(t).reduce((r,n)=>(r[n]=U7(t[n],i=>zA[e](hl(i.date))),r),{}),vje=(e,t)=>t.reduce((r,n)=>{const i=zA[e](hl(n.date));return r[i]=r[i]??[],r[i].push(n),r},{}),gje=(e,t)=>{const r=Object.values(t).filter(h=>h.length>0).map(h=>[...h].reverse());if(r.length===0)return[];const n=hje[e],i=zA[e],a=dje[e],o=r.flat(),s=hl(o[0].date),c=hl(o[o.length-1].date),l=n(c,s)||1;return[{formattedDate:i(s),date:s},...CA(l,h=>{const p=sse(s,a(h));return{formattedDate:i(p),date:p}})]},gW=e=>{if(e.color)return e.color;const t={main:Cp,highlighted:cP,previous:U0()};return e.type?t[e.type]:Cp},I8=(e,t)=>M.useMemo(()=>Object.values(e).find(r=>r.type===t)??[],[e,t]),yje=(e,t,r)=>{const n=I8(e,"main"),i=I8(e,"highlighted"),a=M.useMemo(()=>r?vje(t,n):{},[r,t,n]),o=M.useCallback((s,{payload:c})=>{const l=a[c.formattedDate]??[];r==null||r(l===i?[]:l)},[a,i,r]);return r&&{cursor:"pointer",onClick:o}},D8=e=>{var t,r;return(r=(t=e.activePayload)==null?void 0:t[0])==null?void 0:r.payload},yW=({visitsGroups:e,setSelectedVisits:t,matchMedia:r,onDateRangeChange:n})=>{const[i,a]=M.useState(pje(e)),o=EA(767,r??window.matchMedia),s=M.useMemo(()=>{const q=mje(i,e),J=Object.keys(q);return gje(i,e).map(({formattedDate:Q,date:re})=>({date:re,formattedDate:Q,...J.reduce((oe,ue)=>(oe[ue]=q[ue][Q]??0,oe),{})}))},[i,e]),c=yje(e,i,t),[l,h,,p]=ir(),g=_i(),_=M.useId(),b=_i(),[w,x]=M.useState(o?300:400);M.useLayoutEffect(()=>{if(!l)return x(o?300:400),()=>{};const q=new ResizeObserver(()=>{const{height:J}=g.current.getBoundingClientRect(),{height:Q}=b.current.getBoundingClientRect();x(J-Q-48)});return q.observe(g.current),q.observe(b.current),()=>q.disconnect()},[g,l,o,b]),$Ce("Escape",p,l);const{ChartWrapper:S,dimensions:C,wrapperDimensions:P}=UA(w),[T,A]=M.useState(),[j,N]=M.useState(),$=M.useCallback(()=>{A(void 0),N(void 0)},[]),U=M.useCallback((q,J)=>{const Q=D8(q);J.button===0&&Q&&A(Q)},[]),B=M.useCallback(q=>{const J=D8(q);T&&J&&N(J)},[T]),W=M.useCallback(()=>{if(!T||!j)return;const q=[T.date,j.date],J=cse(q),Q=X7(q);$(),n({startDate:J,endDate:Q})},[n,$,j,T]);return v.jsxs(Qi,{className:Te({"fixed-top fixed-bottom":l}),"data-testid":"line-chart-card",children:[v.jsxs(Sm,{role:"heading","aria-level":4,className:"d-flex justify-content-between align-items-center",children:["Visits over time",v.jsxs("div",{className:"d-flex align-content-center gap-1",children:[v.jsx(Lt,{"aria-label":l?"Collapse":"Expand","aria-expanded":l,"aria-controls":_,size:"sm",color:"link",onClick:h,children:v.jsx(He,{icon:l?rY:JY})}),v.jsxs(Cm,{className:"d-flex align-items-center",children:[v.jsx(is,{caret:!0,color:"link",className:"btn-sm p-0",children:"Group by"}),v.jsx(xl,{end:!0,children:Object.entries(fje).map(([q,J])=>v.jsx(Ze,{active:i===q,onClick:()=>a(q),children:J},q))})]})]})]}),v.jsxs(xm,{innerRef:g,id:_,children:[v.jsx(S,{...P,children:v.jsxs(KOe,{className:"user-select-none",data:s,...C,onMouseDown:U,onMouseMove:B,onMouseUp:W,children:[v.jsx(Cd,{dataKey:"formattedDate"}),v.jsx(Pd,{tickFormatter:Or,yAxisId:"1"}),v.jsx(zi,{formatter:Or,...mW}),v.jsx(vA,{strokeOpacity:Tm()?.1:.9}),Object.entries(e).map(([q,J])=>J.length>0&&v.jsx(Od,{yAxisId:"1",dataKey:q,type:"monotone",stroke:gW(J),strokeWidth:2,activeDot:J.type==="previous"?void 0:c,strokeDasharray:J.type==="previous"?"8 3":void 0},q)),T&&j&&v.jsx(Fm,{yAxisId:"1",x1:T.formattedDate,x2:j.formattedDate})]})}),v.jsx(cje,{visitsGroups:e,ref:b})]})]})},bje=({toggleClassName:e,ranges:t,value:r,setValue:n})=>v.jsxs(Cm,{children:[v.jsx(is,{caret:!0,color:"link",className:e,children:"Paginate"}),v.jsxs(xl,{end:!0,children:[t.map(i=>v.jsxs(Ze,{active:i===r,onClick:()=>n(i),children:[v.jsx("b",{children:i})," items per page"]},i)),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{disabled:r===1/0,onClick:()=>n(1/0),children:v.jsx("i",{children:"Clear pagination"})})]})]}),$8=e=>e.startsWith("hidden_"),_je=({stats:e,prevStats:t,highlightedStats:r,highlightedLabel:n,max:i,onClick:a})=>{const o=M.useMemo(()=>Object.entries(e).map(([p,g])=>{const _=(r==null?void 0:r[p])??0,b=(t==null?void 0:t[p])??0,w=$8(p);return{name:p,amount:Math.max(g,b),nonHighlightedAmount:w?null:g-_,highlightedAmount:w?null:_,prevAmount:w?null:b}}),[e,t,r]),s=M.useMemo(()=>{const p=o.reduce((g,{name:_})=>g>_.length?g:_.length,0);return Math.min(150,p*7)},[o]),{ChartWrapper:c,dimensions:l,wrapperDimensions:h}=UA(Math.max(300,o.length*(t?44:22)));return v.jsx(c,{...h,children:v.jsxs(ZOe,{layout:"vertical",data:o,barCategoryGap:3,...l,children:[v.jsx(Cd,{type:"number",dataKey:"amount",tickFormatter:Or,domain:i?[0,i]:void 0}),v.jsx(Pd,{type:"category",dataKey:"name",width:s,interval:0,style:{fontSize:".8rem"},tickFormatter:p=>$8(p)?"":p}),v.jsx(vA,{strokeOpacity:Tm()?.05:.9}),v.jsx(zi,{filterNull:!0,...mW,formatter:(p,g)=>[Or(p),g==="highlightedAmount"?n:g==="prevAmount"?"Previous period":r?"Non-selected":"Visits"]}),v.jsx(Ho,{dataKey:"nonHighlightedAmount",stackId:"main",cursor:"pointer",fill:Cp,onClick:({name:p})=>a==null?void 0:a(p),children:o.map(p=>v.jsx(al,{fill:eae,stroke:Cp,strokeWidth:2},p.name))}),r&&v.jsx(Ho,{dataKey:"highlightedAmount",stackId:"main",cursor:"pointer",fill:cP,onClick:({name:p})=>a==null?void 0:a(p),children:o.map(p=>v.jsx(al,{fill:tae,stroke:cP,strokeWidth:2},p.name))}),t&&v.jsx(Ho,{dataKey:"prevAmount",fill:U0(),children:o.map(p=>v.jsx(al,{fill:sje(),stroke:U0(),strokeWidth:2},p.name))})]})})},wje=e=>typeof e=="string"?e.toLowerCase():e,xje=([e])=>e,Sje=([,e])=>e,Rg=({stats:e,prevStats:t,highlightedStats:r,title:n,sortingItems:i,extraHeaderContent:a,withPagination:o=!0,...s})=>{const[c,l]=M.useState({}),[h,p]=M.useState(1),[g,_]=M.useState(50),b=M.useCallback(($,U)=>{const B=Object.entries($),W=c.field?joe(B,([q,J])=>wje(c.field===Object.keys(U)[0]?q:J)):B;return!c.dir||c.dir==="ASC"?W:[...W].reverse()},[c.dir,c.field]),w=M.useCallback($=>{const U=$[h-1];if(h<$.length)return U;const B=$[0].length;return[...U,...CA(B-U.length,W=>[`hidden_${W}`,0])]},[h]),x=M.useCallback($=>v.jsx(BA,{currentPage:h,pagesCount:$,onPageChange:p}),[h]),S=M.useCallback(($,U,B,W)=>{const q=b($,U),J=q.map(xje),Q=B&&Object.entries({...FN(J,J.map(()=>0)),...B}),re=W&&Object.entries({...FN(J,J.map(()=>0)),...W});if(q.length<=g)return{currentPageStats:Object.fromEntries(q),currentPageHighlightedStats:Q&&Object.fromEntries(Q),currentPagePrevStats:re&&Object.fromEntries(re)};const oe=pf(q,g),ue=Q&&pf(Q,g),ae=re&&pf(re,g);return{currentPageStats:Object.fromEntries(w(oe)),currentPageHighlightedStats:ue&&Object.fromEntries(w(ue)),currentPagePrevStats:ae&&Object.fromEntries(w(ae)),pagination:x(oe.length),max:aPe(Math.max(...q.map(Sje)))}},[w,b,g,x]),{currentPageStats:C,currentPagePrevStats:P,currentPageHighlightedStats:T,pagination:A,max:j}=M.useMemo(()=>S(e,i,r&&Object.keys(r).length>0?r:void 0,t&&Object.keys(t).length>0?t:void 0),[S,r,t,i,e]),N=M.useMemo(()=>Object.keys(C),[C]);return v.jsx(dW,{title:v.jsxs(s_,{children:[n,v.jsxs("div",{className:"d-flex gap-3",children:[a==null?void 0:a(A?N:void 0),o&&Object.keys(e).length>50&&v.jsx(bje,{toggleClassName:"btn-sm p-0",ranges:[50,100,200,500],value:g,setValue:$=>{_($),p(1)}}),v.jsx(Em,{isButton:!1,right:!0,items:i,order:c,onChange:($,U)=>{l({field:$,dir:U}),p(1)}})]})]}),footer:A,children:v.jsx(_je,{stats:C,prevStats:P,highlightedStats:T,max:j,...s})})},VA=e=>e.type!==void 0,Oje=e=>e.type!==void 0,Cje=e=>{const t=z7(e,r=>VA(r.visit)?"orphanVisits":"nonOrphanVisits");return{orphanVisits:[],nonOrphanVisits:[],...t}},bW=(e,{shortCode:t,domain:r},{endDate:n,startDate:i}={})=>e.filter(({shortUrl:a,visit:o})=>a&&dp(a,t,r)&&Um(o.date,i,n)),_W=(e,t,{endDate:r,startDate:n}={})=>e.filter(({shortUrl:i,visit:a})=>i&&XCe(i,t)&&Um(a.date,n,r)),wW=(e,t,{endDate:r,startDate:n}={})=>e.filter(({shortUrl:i,visit:a})=>(i==null?void 0:i.tags.includes(t))&&Um(a.date,n,r)),Ng=(e,t)=>U7(e,r=>r[t]),Pje=e=>{const t=((e==null?void 0:e.startDate)&&yl(e==null?void 0:e.startDate))??void 0,r=((e==null?void 0:e.endDate)&&yl(e==null?void 0:e.endDate))??void 0;return{startDate:t,endDate:r}},eT=({filter:e,dateRange:t})=>{const{startDate:r,endDate:n}=Pje(t),i=(e==null?void 0:e.excludeBots)||void 0;return{startDate:r,endDate:n,excludeBots:i}},Eje=e=>qV(e.dateRange),Tje=({dateRange:e,...t})=>({...t,dateRange:gTe(e)}),F8=(e,t)=>{if(!(!t||!(e in t)))return t[e]&&yl(t[e])||""},xW=()=>{const e=fo(),t=hd(),{startDate:r,endDate:n,orphanVisitsType:i,excludeBots:a,loadPrevInterval:o,...s}=t,c=M.useMemo(()=>({dateRange:r!=null||n!=null?UV(r,n):void 0,visitsFilter:{orphanVisitsType:i,excludeBots:a!==void 0?a==="true":void 0},loadPrevInterval:o!==void 0?o==="true":void 0}),[n,a,o,i,r]),l=M.useCallback(h=>{const{dateRange:p,visitsFilter:g={},loadPrevInterval:_}=pb(c,h),{excludeBots:b,orphanVisitsType:w}=g,x={...s,startDate:F8("startDate",p),endDate:F8("endDate",p),excludeBots:b===void 0?void 0:YE(b),orphanVisitsType:w,loadPrevInterval:_===void 0?void 0:YE(_)},S=sb(x),C=S?`?${S}`:"";e(C,{replace:!0,relative:"route"})},[c,e,s]);return[c,l]},jje=()=>v.jsx(mCe,{attribution:'© OpenStreetMap contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),Aje=e=>{if(e.length===0)return{};if(e.length>1)return{bounds:e.map(({latLong:r})=>r)};const[{latLong:t}]=e;return{zoom:10,center:t}},SW=({toggle:e,isOpen:t,title:r,locations:n=[]})=>v.jsx(Ji,{toggle:e,isOpen:t,className:"map-modal__modal",contentClassName:"map-modal__modal-content",children:v.jsxs(as,{className:"map-modal__modal-body",children:[v.jsxs(s_,{className:"map-modal__modal-title fs-4",children:[r,v.jsx("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:e})]}),v.jsxs(dCe,{...Aje(n),children:[v.jsx(jje,{}),n.map(({cityName:i,latLong:a,count:o},s)=>v.jsx(hCe,{position:a,children:v.jsxs(pCe,{children:[v.jsx("b",{children:o})," visit",o>1?"s":""," from ",v.jsx("b",{children:i})]})},s))]})]})}),kje=({modalTitle:e,activeCities:t,locations:r=[]})=>{const[n,,i,a]=ir(),[o,s]=ir(),[c,l]=M.useState([]),h=M.useCallback(p=>{l(p?r.filter(p):r),i()},[r,i]);return v.jsxs(v.Fragment,{children:[!t&&v.jsx(Lt,{color:"link",className:"p-0",onClick:()=>h(),"aria-label":"Show in map",title:"Show in map",children:v.jsx(He,{icon:AO})}),t&&v.jsxs(wl,{isOpen:o,toggle:s,children:[v.jsx(is,{color:"link",className:"p-0",title:"Show in map",children:v.jsx(He,{icon:AO})}),v.jsxs(xl,{end:!0,children:[v.jsx(Ze,{onClick:()=>h(),children:"Show all locations"}),v.jsx(Ze,{onClick:()=>h(({cityName:p})=>t.includes(p)),children:"Show locations in current page"})]})]}),v.jsx(SW,{toggle:a,isOpen:n,title:e,locations:c})]})},OW=({onChange:e,selected:t={},className:r,isOrphanVisits:n=!1,withPrevInterval:i=!1,disabled:a})=>{const{orphanVisitsType:o,excludeBots:s=!1,loadPrevInterval:c=!1}=t,l=g=>({active:o===g,onClick:()=>e({...t,orphanVisitsType:g===o?void 0:g})}),h=M.useCallback(()=>e({...t,excludeBots:!s}),[s,e,t]),p=M.useCallback(()=>e({...t,loadPrevInterval:!c}),[c,e,t]);return v.jsxs(os,{disabled:a,text:"More",dropdownClassName:r,end:!0,minWidth:250,children:[i&&v.jsxs(v.Fragment,{children:[v.jsx(Ze,{active:c,onClick:p,children:"Compare with previous period"}),v.jsx(Ze,{divider:!0,tag:"hr"})]}),v.jsx(Ze,{header:!0,"aria-hidden":!0,children:"Bots:"}),v.jsx(Ze,{active:s,onClick:h,children:"Exclude potential bots"}),n&&v.jsxs(v.Fragment,{children:[v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{header:!0,"aria-hidden":!0,children:"Orphan visits type:"}),v.jsx(Ze,{...l("base_url"),children:"Base URL"}),v.jsx(Ze,{...l("invalid_short_url"),children:"Invalid short URL"}),v.jsx(Ze,{...l("regular_404"),children:"Regular 404"})]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsx(Ze,{disabled:t.excludeBots===void 0&&t.loadPrevInterval===void 0&&t.orphanVisitsType===void 0,onClick:()=>e({excludeBots:void 0,loadPrevInterval:void 0,orphanVisitsType:void 0}),children:v.jsx("i",{children:"Reset to defaults"})})]})},CW=({info:e})=>{const{loading:t,errorData:r,progress:n}=e;return v.jsxs(v.Fragment,{children:[t&&n===null&&v.jsx(Lu,{loading:!0}),t&&n!==null&&v.jsxs(Lu,{loading:!0,children:["This is going to take a while... :S",v.jsx(a7,{value:n,striped:n>=100,className:"mt-3"})]}),r&&v.jsx(gi,{type:"error",children:v.jsx(uo,{errorData:r,fallbackMessage:"An error occurred while loading visits :("})})]})},Yg=({children:e,showFallback:t})=>v.jsxs(v.Fragment,{children:[t&&v.jsx(Lu,{className:"mt-3",children:"There are no visits matching current filter"}),!t&&v.jsx(v.Fragment,{children:e})]}),Rje=({visitsDeletion:e,deleteVisits:t})=>{const{deleting:r}=e,[n,,i]=ir();return v.jsx(Sr,{title:v.jsx("span",{className:"text-danger fw-bold",children:"Danger zone"}),children:v.jsxs(s_,{children:[v.jsxs("dl",{className:"m-0 me-3",children:[v.jsx("dt",{children:"Delete visits."}),v.jsxs("dd",{className:"m-0",children:["This will delete ",v.jsx("b",{children:"all"})," visits, not only the ones matching current filter."]})]}),!n&&v.jsx(Lt,{color:"danger",className:"indivisible",onClick:i,children:"Delete visits"}),n&&v.jsxs(Lt,{color:"danger",disabled:r,className:"indivisible",onClick:t,innerRef:a=>{a==null||a.focus()},children:[!r&&v.jsx(v.Fragment,{children:"Click again to confirm"}),r&&v.jsx(v.Fragment,{children:"Deleting..."})]})]})})},Mg="Others",Nje=["Android Browser","Chrome","Chromium","Firefox","Internet Explorer","Microsoft Edge","Opera","Safari","Samsung Internet for Android","Vivaldi","WeChat"],Mje=e=>{if(!vu(e))return{browser:Mg,os:Mg};const{browser:{name:t},os:{name:r}}=wCe.parse(e);return{os:r??Mg,browser:t&&Nje.includes(t)?t:Mg}},Lje=e=>{var t;return vu(e)?((t=e.split("/")[e.includes("://")?2:0])==null?void 0:t.split(":")[0])??"":"Direct"},PW=(e,t)=>e[t]!==void 0,B8=e=>typeof e=="number"?e:e?parseFloat(e):0,Ije=(e,{os:t})=>{e[t]=(e[t]||0)+1},Dje=(e,{browser:t})=>{e[t]=(e[t]||0)+1},$je=(e,{referer:t})=>{e[t]=(e[t]||0)+1},EW=e=>(t,r)=>{const n=PW(r,e)?r[e]:"Unknown";t[n]=(t[n]||0)+1},Fje=EW("country"),Bje=EW("city"),Uje=(e,t)=>{if(!PW(t,"city")||t.city==="Unknown")return;const{city:r,latitude:n,longitude:i}=t,a=e[r]||{cityName:r,count:0,latLong:[B8(n),B8(i)]};a.count+=1,e[r]=a},zje=(e,t)=>{if(!Oje(t))return;const{visitedUrl:r}=t;e[r]=(e[r]||0)+1},tT=e=>e.reduce((t,r)=>(Ije(t.os,r),Dje(t.browsers,r),$je(t.referrers,r),Fje(t.countries,r),Bje(t.cities,r),Uje(t.citiesForMap,r),zje(t.visitedUrls,r),t),{os:{},browsers:{},referrers:{},countries:{},cities:{},citiesForMap:{},visitedUrls:{}}),z0=e=>e.map(t=>{const{userAgent:r,date:n,referer:i,visitLocation:a,potentialBot:o}=t;return{date:n,potentialBot:o,userAgent:r,...Mje(r),referer:Lje(i),country:(a==null?void 0:a.countryName)||"Unknown",city:(a==null?void 0:a.cityName)||"Unknown",latitude:a==null?void 0:a.latitude,longitude:a==null?void 0:a.longitude,visitedUrl:t.visitedUrl,type:VA(t)?t.type:void 0}}),Vje=Object.freeze(Object.defineProperty({__proto__:null,normalizeVisits:z0,processStatsFromVisits:tT},Symbol.toStringTag,{value:"Module"})),Yh=20,Wje=({browser:e,os:t,referer:r,country:n,city:i,userAgent:a,...o},s,c)=>{const l=c?a:`${n} ${i}`;return`${e} ${t} ${r} ${l} ${o.visitedUrl}`.toLowerCase().includes(s.toLowerCase())},qje=(e,t,r)=>t.filter(n=>Wje(n,e,r)),Hje=(e,t)=>v7(t,e),Gje=({visits:e,searchTerm:t,order:r,searchInRawUserAgent:n})=>{const i=t?qje(t,e,n):[...e],a=Hje(r,i),o=a.length;return{visitsGroups:pf(a,Yh),total:o}},Ha="visits-table__header-cell visits-table__sticky",Kje=({visits:e,selectedVisits:t=[],setSelectedVisits:r,matchMedia:n=window.matchMedia})=>{var i;const a=EA(767,n),[o,s]=M.useState(),c=M.useCallback($=>{s($),x(1),r([])},[r]),[l,h]=M.useState({}),[p,g]=ir(),_=M.useCallback(()=>{g(),h({})},[g]),b=M.useMemo(()=>Gje({visits:e,searchTerm:o,order:l,searchInRawUserAgent:p}),[e,o,l,p]),[w,x]=M.useState(1),S=w*Yh,C=S-Yh,P=M.useMemo(()=>{var $,U;return!!((U=($=b.visitsGroups[w-1])==null?void 0:$[0])!=null&&U.visitedUrl)},[w,b.visitsGroups]),T=6+Number(P)+(p?1:2),A=b.total>0,j=$=>h({field:$,dir:Pm($,l.field,l.dir)}),N=$=>v.jsx(pp,{currentOrder:l,field:$,className:"visits-table__header-icon"});return v.jsx(Sr,{className:"mt-3",bodyClassName:"p-0 pb-1",title:v.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:["Visits list",v.jsx(Xo,{checked:p,onChange:_,children:"Show user agent"})]}),children:v.jsx("div",{className:"table-responsive-md",children:v.jsxs("table",{className:Te("table table-sm position-relative m-0 visits-table",{"table-hover":A}),children:[v.jsxs("thead",{className:"visits-table__header",children:[v.jsxs("tr",{children:[v.jsxs("th",{className:`${Ha} text-center`,onClick:()=>r(t.length0})})]}),v.jsxs("th",{className:`${Ha} text-center`,onClick:()=>j("potentialBot"),children:[v.jsx("span",{className:"sr-only",children:"Is bot"}),v.jsx(He,{icon:rR}),N("potentialBot")]}),v.jsxs("th",{className:Ha,onClick:()=>j("date"),children:["Date",N("date")]}),v.jsxs("th",{className:Ha,onClick:()=>j("country"),children:["Country",N("country")]}),v.jsxs("th",{className:Ha,onClick:()=>j("city"),children:["City",N("city")]}),p?v.jsxs("th",{className:Ha,onClick:()=>j("userAgent"),children:["User agent",N("userAgent")]}):v.jsxs(v.Fragment,{children:[v.jsxs("th",{className:Ha,onClick:()=>j("browser"),children:["Browser",N("browser")]}),v.jsxs("th",{className:Ha,onClick:()=>j("os"),children:["OS",N("os")]})]}),v.jsxs("th",{className:Ha,onClick:()=>j("referer"),children:["Referrer",N("referer")]}),P&&v.jsxs("th",{className:Ha,onClick:()=>j("visitedUrl"),children:["Visited URL",N("visitedUrl")]})]}),v.jsx("tr",{children:v.jsx("td",{colSpan:T,className:"p-0",children:v.jsx(ob,{noBorder:!0,large:!1,onChange:c})})})]}),v.jsxs("tbody",{children:[!A&&v.jsx("tr",{children:v.jsx("td",{colSpan:T,className:"text-center",children:"There are no visits matching current filter"})}),(i=b.visitsGroups[w-1])==null?void 0:i.map(($,U)=>{const B=t.includes($);return v.jsxs("tr",{style:{cursor:"pointer"},className:Te({"table-active":B}),onClick:()=>r(B?t.filter(W=>W!==$):[...t,$]),children:[v.jsx("td",{className:"text-center",children:B&&v.jsx(He,{icon:vp,className:"text-primary"})}),v.jsx("td",{className:"text-center",children:$.potentialBot&&v.jsxs(v.Fragment,{children:[v.jsx(He,{icon:rR,id:`botIcon${U}`}),v.jsx(Oi,{placement:"right",target:`botIcon${U}`,children:"Potentially a visit from a bot or crawler"})]})}),v.jsx("td",{children:v.jsx($0,{date:$.date})}),v.jsx("td",{children:$.country}),v.jsx("td",{children:$.city}),p?v.jsx("td",{children:$.userAgent}):v.jsxs(v.Fragment,{children:[v.jsx("td",{children:$.browser}),v.jsx("td",{children:$.os})]}),v.jsx("td",{children:$.referer}),$.visitedUrl&&v.jsx("td",{children:$.visitedUrl})]},U)})]}),b.total>Yh&&v.jsx("tfoot",{children:v.jsx("tr",{children:v.jsx("td",{colSpan:T,className:"visits-table__footer-cell visits-table__sticky",children:v.jsxs("div",{className:"d-flex flex-column flex-md-row justify-content-between align-items-center gap-3 p-2",children:[v.jsx(BA,{pagesCount:Math.ceil(b.total/Yh),currentPage:w,onPageChange:x,centered:a}),v.jsxs("div",{children:["Visits ",v.jsx("b",{children:Or(C+1)})," to"," ",v.jsx("b",{children:Or(Math.min(S,b.total))})," of"," ",v.jsx("b",{children:Or(b.total)})]})]})})})})]})})})},Xs={byTime:{title:"By time",subPath:"by-time",icon:iY},byContext:{title:"By context",subPath:"by-context",icon:_T},byLocation:{title:"By location",subPath:"by-location",icon:AO},list:{title:"List",subPath:"list",icon:yT},options:{title:"Options",subPath:"options",icon:z$,shouldRender:({deletion:e})=>!!e}};Object.freeze(Xs);const SO=({display:e})=>e&&v.jsx("div",{className:"mt-3 mx-auto w-75",children:v.jsx(Sr,{children:v.jsxs("div",{className:"d-flex gap-2",children:[v.jsx(He,{icon:nZ,className:"mt-1"}),v.jsx("i",{children:"Could not calculate previous period because selected one does not have a strictly defined start date."})]})})}),Vm=e=>{const{children:t,visitsInfo:r,getVisits:n,cancelGetVisits:i,deletion:a,exportCsv:o,isOrphanVisits:s=!1}=e,{visits:c,prevVisits:l,loading:h,errorData:p,fallbackInterval:g}=r,[{dateRange:_,visitsFilter:b,loadPrevInterval:w},x]=xW(),S=Nn("visits"),[C,P]=M.useState(),T=M.useCallback(({startDate:G,endDate:le},ie)=>{x({dateRange:{startDate:G??void 0,endDate:le??void 0}}),P(ie)},[x]),[A,j]=M.useState(g??(S==null?void 0:S.defaultInterval)??"last30Days"),[N,$]=M.useState([]),[U,B]=M.useState(),W=M.useRef(!0),{search:q}=bn(),J=M.useCallback(G=>G?`../${G}${q}`:q,[q]),Q=M.useMemo(()=>z0(c),[c]),re=M.useMemo(()=>l&&z0(l),[l]),{os:oe,browsers:ue,referrers:ae,countries:K,cities:H,citiesForMap:V,visitedUrls:ne}=M.useMemo(()=>tT(Q),[Q]),X=M.useMemo(()=>tT(re??[]),[re]),se=M.useMemo(()=>Object.fromEntries([["Visits",Object.assign(Q,{type:"main"})],re&&["Previous period",Object.assign(re,{type:"previous"})],N.length>0&&[U??"Selected",Object.assign(N,{type:"highlighted"})]].filter(Boolean)),[U,N,re,Q]),ce=M.useMemo(()=>({...b,excludeBots:b.excludeBots??(S==null?void 0:S.excludeBots),loadPrevInterval:w??(S==null?void 0:S.loadPrevInterval)}),[w,b,S==null?void 0:S.excludeBots,S==null?void 0:S.loadPrevInterval]),de=M.useMemo(()=>Object.values(V),[V]),be=M.useRef(void 0),I=M.useCallback(G=>{be.current=void 0,$(G)},[]),F=M.useCallback((G,le)=>{const ie=`${G}_${le}`;be.current===ie?($([]),B(void 0),be.current=void 0):($(Q.filter(he=>he[G]===le)),B(le),be.current=ie)},[Q]);return M.useEffect(()=>i,[i]),M.useEffect(()=>{const G=_??WV(A),{loadPrevInterval:le,...ie}=ce,he={doIntervalFallback:W.current,loadPrevInterval:le};n({dateRange:G,filter:ie},he),I([]),W.current=!1},[A,_,n,ce,I]),M.useEffect(()=>{g&&A===((S==null?void 0:S.defaultInterval)??"last30Days")&&j(g)},[A,g,S==null?void 0:S.defaultInterval]),v.jsxs(v.Fragment,{children:[t,v.jsx("section",{className:"mt-3",children:v.jsxs("div",{className:"row flex-md-row-reverse",children:[v.jsx("div",{className:"col-lg-7 col-xl-6",children:v.jsxs("div",{className:"d-md-flex",children:[v.jsx("div",{className:"flex-grow-1",children:v.jsx(DA,{disabled:h,dateRangeOrInterval:C??_??A,defaultText:"All visits",onDatesChange:T})}),v.jsx(OW,{disabled:h,className:"ms-0 ms-md-2 mt-3 mt-md-0",isOrphanVisits:s,withPrevInterval:!0,selected:ce,onChange:({loadPrevInterval:G,...le})=>x({visitsFilter:le,loadPrevInterval:G})})]})}),c.length>0&&v.jsx("div",{className:"col-lg-5 col-xl-6 mt-3 mt-lg-0",children:v.jsxs("div",{className:"d-flex",children:[v.jsx(PV,{className:"btn-md-block",amount:Q.length,onClick:()=>o(Q)}),v.jsxs(Lt,{outline:!0,disabled:N.length===0,className:"btn-md-block ms-2",onClick:()=>I([]),children:["Clear selection ",N.length>0&&v.jsxs(v.Fragment,{children:["(",Or(N.length),")"]})]})]})})]})}),v.jsxs("section",{className:"mt-3",children:[v.jsx(CW,{info:r}),!h&&!p&&v.jsxs(v.Fragment,{children:[v.jsx(m7,{fill:!0,children:Object.values(Xs).map(({title:G,icon:le,subPath:ie,shouldRender:he},Oe)=>!he||he(e)?v.jsxs(rp,{to:J(ie),replace:!0,children:[v.jsx(He,{icon:le}),v.jsx("span",{className:"ms-2 d-none d-lg-inline",children:G})]},Oe):void 0).filter(Boolean)}),v.jsx(Za,{children:v.jsxs(G0,{children:[v.jsx(Ot,{path:Xs.byTime.subPath,element:v.jsxs(Yg,{showFallback:c.length===0,children:[v.jsx("div",{className:"col-12 mt-3","data-testid":"line-chart-container",children:v.jsx(yW,{visitsGroups:se,setSelectedVisits:I,onDateRangeChange:T})}),v.jsx(SO,{display:!!ce.loadPrevInterval&&!l})]})}),v.jsx(Ot,{path:Xs.byContext.subPath,element:v.jsxs(Yg,{showFallback:c.length===0,children:[v.jsx("div",{className:Te("mt-3 col-lg-6",{"col-xl-4":!s}),children:v.jsx(L8,{title:"Operating systems",stats:oe,prevStats:X.os})}),v.jsx("div",{className:Te("mt-3 col-lg-6",{"col-xl-4":!s}),children:v.jsx(L8,{title:"Browsers",stats:ue,prevStats:X.browsers})}),v.jsx("div",{className:Te("mt-3",{"col-xl-4":!s,"col-lg-6":s}),children:v.jsx(Rg,{title:"Referrers",withPagination:!1,stats:ae,prevStats:X.referrers,highlightedStats:Ng(N,"referer"),highlightedLabel:U,sortingItems:{name:"Referrer name",amount:"Visits amount"},onClick:G=>F("referer",G)})}),s&&v.jsx("div",{className:"mt-3 col-lg-6",children:v.jsx(Rg,{title:"Visited URLs",stats:ne,prevStats:X.visitedUrls,highlightedStats:Ng(N,"visitedUrl"),highlightedLabel:U,sortingItems:{visitedUrl:"Visited URL",amount:"Visits amount"},onClick:G=>F("visitedUrl",G)})}),v.jsx("div",{className:"col-12",children:v.jsx(SO,{display:!!ce.loadPrevInterval&&!l})})]})}),v.jsx(Ot,{path:Xs.byLocation.subPath,element:v.jsxs(Yg,{showFallback:c.length===0,children:[v.jsx("div",{className:"col-lg-6 mt-3",children:v.jsx(Rg,{title:"Countries",stats:K,prevStats:X.countries,highlightedStats:Ng(N,"country"),highlightedLabel:U,sortingItems:{name:"Country name",amount:"Visits amount"},onClick:G=>F("country",G)})}),v.jsx("div",{className:"col-lg-6 mt-3",children:v.jsx(Rg,{title:"Cities",stats:H,prevStats:X.cities,highlightedStats:Ng(N,"city"),highlightedLabel:U,extraHeaderContent:G=>de.length>0&&v.jsx(kje,{modalTitle:"Cities",locations:de,activeCities:G}),sortingItems:{name:"City name",amount:"Visits amount"},onClick:G=>F("city",G)})}),v.jsx("div",{className:"col-12",children:v.jsx(SO,{display:!!ce.loadPrevInterval&&!l})})]})}),v.jsx(Ot,{path:Xs.list.subPath,element:v.jsx("div",{className:"col-12",children:v.jsx(Kje,{visits:Q,selectedVisits:N,setSelectedVisits:I})})}),a&&v.jsx(Ot,{path:Xs.options.subPath,element:v.jsx("div",{className:"col-12 mt-3",children:v.jsx(Rje,{...a})})}),v.jsx(Ot,{path:"*",element:v.jsx(uT,{replace:!0,to:J(Xs.byTime.subPath)})})]})})]})]})]})},TW=ka(({getDomainVisits:e,domainVisits:t,cancelGetDomainVisits:r})=>{const{ReportExporter:n}=ur(TW),{domain:i=""}=cd(),[a,o=a]=i.split("_"),s=M.useCallback((l,h)=>e({domain:o,options:h,params:l}),[o,e]),c=M.useCallback(l=>n.exportVisits(`domain_${a}_visits.csv`,l),[a,n]);return v.jsx(Vm,{getVisits:s,cancelGetVisits:r,visitsInfo:t,exportCsv:c,children:v.jsx(zm,{visits:t.visits,title:`"${a}" visits`})})},()=>[Rn.visits]),Yje=cr(TW,["ReportExporter"]),jW=ka(({getNonOrphanVisits:e,nonOrphanVisits:t,cancelGetNonOrphanVisits:r})=>{const{ReportExporter:n}=ur(jW),i=M.useCallback(o=>n.exportVisits("non_orphan_visits.csv",o),[n]),a=M.useCallback((o,s)=>e({options:s,params:o}),[e]);return v.jsx(Vm,{getVisits:a,cancelGetVisits:r,visitsInfo:t,exportCsv:i,children:v.jsx(zm,{title:"Non-orphan visits",visits:t.visits})})},()=>[Rn.visits]),Zje=cr(jW,["ReportExporter"]),AW=ka(({getOrphanVisits:e,orphanVisits:t,cancelGetOrphanVisits:r,deleteOrphanVisits:n,orphanVisitsDeletion:i})=>{const a=Ca("orphanVisitsDeletion"),{ReportExporter:o}=ur(AW),s=M.useCallback(h=>o.exportVisits("orphan_visits.csv",h),[o]),c=M.useCallback((h,p)=>{var g;return e({options:p,params:h,orphanVisitsType:(g=h.filter)==null?void 0:g.orphanVisitsType})},[e]),l=M.useMemo(()=>a?{deleteVisits:n,visitsDeletion:i}:void 0,[n,i,a]);return v.jsx(Vm,{getVisits:c,cancelGetVisits:r,visitsInfo:t,exportCsv:s,deletion:l,isOrphanVisits:!0,children:v.jsx(zm,{title:"Orphan visits",visits:t.visits})})},()=>[Rn.orphanVisits]),Xje=cr(AW,["ReportExporter"]),U8=5e3,Qje=2,Jje=4,eAe=({currentPage:e,pagesCount:t})=>e>=t,tAe=(e,t)=>t*100/e,kW=({visitsLoader:e,shouldCancel:t,progressChanged:r,batchSize:n})=>{const i=async(o,s)=>Promise.all(s.map(async c=>e({...o,page:c,itemsPerPage:U8}).then(({data:l})=>l))).then(c=>c.flat()),a=async(o,s,c=0)=>{if(t())return[];const l=await i(o,s[c]);return r(tAe(s.length,c+1)),c{const{pagination:s,data:c}=await e({...o,page:1,itemsPerPage:U8});if(eAe(s))return c;const l=sj(Qje,s.pagesCount+1),h=pf(l,n);return s.pagesCount-1>n&&r(0),c.concat(await a(o,h))}},Wm=(e,t)=>async r=>e?t({page:1,itemsPerPage:1,excludeBots:r}).then(({data:n})=>n[0]):Promise.resolve(void 0),qm=({typePrefix:e,createLoaders:t,shouldCancel:r})=>{const n=An(`${e}/progressChanged`),i=An(`${e}/fallbackToInterval`),a=Vr(e,async(o,{getState:s,dispatch:c})=>{var l;const{params:h,options:p}=o,{visitsLoader:g,lastVisitLoader:_}=t(o),b=yTe(h.dateRange),w=eT(h),x=p.loadPrevInterval&&Eje(h)?eT(Tje(h)):void 0,S=Jje/(x?2:1),C=x?{main:0,prev:0}:{main:0},P=($,U)=>{C[$]=U;const B=Object.values(C),W=B.reduce((q,J)=>q+J,0);c(n(W/B.length))},T=kW({visitsLoader:g,shouldCancel:()=>r(s),progressChanged:$=>P("main",$),batchSize:S}),[A,j,N]=await Promise.all([T(w),_((l=h.filter)==null?void 0:l.excludeBots),x?T(x).then($=>$.map(U=>{if(b===void 0)return U;const{date:B,...W}=U,q=fj(vi(B),b);return{...W,date:yl(q)}})):Promise.resolve(void 0)]);return!A.length&&j&&c(i(vTe(j.date))),{...o,visits:A,prevVisits:N}});return Object.assign(a,{progressChanged:n,fallbackToInterval:i})},Hm=({name:e,asyncThunkCreator:t,initialState:r,filterCreatedVisits:n,extraReducers:i})=>{const{pending:a,rejected:o,fulfilled:s,progressChanged:c,fallbackToInterval:l}=t,{reducer:h,actions:p}=Tr({name:e,initialState:r,reducers:{cancelGetVisits:_=>({..._,cancelLoad:!0})},extraReducers:_=>{_.addCase(a,()=>({...r,loading:!0})),_.addCase(o,(b,{error:w})=>({...r,errorData:Ci(w)??null})),_.addCase(s,(b,{payload:w})=>({...b,...w,loading:!1,progress:null,errorData:null})),_.addCase(c,(b,{payload:w})=>({...b,progress:w})),_.addCase(l,(b,{payload:w})=>({...b,fallbackInterval:w})),_.addCase(Ed,(b,{payload:w})=>{const{visits:x}=b,S=n(b,w.createdVisits).map(({visit:C})=>C);return S.length?{...b,visits:[...S,...x]}:b}),i==null||i(_)}}),{cancelGetVisits:g}=p;return{reducer:h,cancelGetVisits:g}},RW="shlink/domainVisits",rAe={visits:[],domain:"",loading:!1,cancelLoad:!1,errorData:null,progress:null},nAe=e=>qm({typePrefix:`${RW}/getDomainVisits`,createLoaders:({domain:t,options:r})=>{const n=e(),{doIntervalFallback:i=!1}=r,a=s=>n.getDomainVisits(t,s),o=Wm(i,s=>n.getDomainVisits(t,s));return{visitsLoader:a,lastVisitLoader:o}},shouldCancel:t=>t().domainVisits.cancelLoad}),iAe=e=>Hm({name:RW,initialState:rAe,asyncThunkCreator:e,filterCreatedVisits:({domain:t,params:r},n)=>_W(n,t,r==null?void 0:r.dateRange)}),NW="shlink/orphanVisits",aAe={visits:[],loading:!1,cancelLoad:!1,errorData:null,progress:null},oAe=e=>qm({typePrefix:`${NW}/getNonOrphanVisits`,createLoaders:({options:t})=>{const r=e(),{doIntervalFallback:n=!1}=t,i=async o=>r.getNonOrphanVisits(o),a=Wm(n,o=>r.getNonOrphanVisits(o));return{visitsLoader:i,lastVisitLoader:a}},shouldCancel:t=>t().orphanVisits.cancelLoad}),sAe=e=>Hm({name:NW,initialState:aAe,asyncThunkCreator:e,filterCreatedVisits:({params:t},r)=>{const{startDate:n,endDate:i}=(t==null?void 0:t.dateRange)??{};return r.filter(({visit:a})=>Um(a.date,n,i))}}),MW="shlink/orphanVisits",lAe={visits:[],loading:!1,cancelLoad:!1,errorData:null,progress:null},uAe=(e,t)=>!t||t===e.type,cAe=({data:e,...t},r)=>{const n=e.filter(i=>VA(i)&&uAe(i,r));return{...t,data:n}},fAe=e=>qm({typePrefix:`${MW}/getOrphanVisits`,createLoaders:({orphanVisitsType:t,options:r})=>{const n=e(),{doIntervalFallback:i=!1}=r,a=async s=>n.getOrphanVisits({...s,type:t}).then(c=>cAe(c,t)),o=Wm(i,s=>n.getOrphanVisits(s));return{visitsLoader:a,lastVisitLoader:o}},shouldCancel:t=>t().orphanVisits.cancelLoad}),dAe=(e,t)=>Hm({name:MW,initialState:lAe,asyncThunkCreator:e,extraReducers:r=>{r.addCase(t.fulfilled,n=>({...n,visits:[]}))},filterCreatedVisits:({params:r},n)=>{const{startDate:i,endDate:a}=(r==null?void 0:r.dateRange)??{};return n.filter(({visit:o,shortUrl:s})=>!s&&Um(o.date,i,a))}}),LW="shlink/orphanVisitsDeletion",z8={deletedVisits:0,deleting:!1,error:!1},hAe=e=>Vr(`${LW}/deleteOrphanVisits`,()=>e().deleteOrphanVisits()),pAe=e=>Tr({name:LW,initialState:z8,reducers:{},extraReducers:t=>{t.addCase(e.pending,r=>({...r,deleting:!0,error:!1})),t.addCase(e.rejected,(r,{error:n})=>({...r,deleting:!1,error:!0,errorData:Ci(n)})),t.addCase(e.fulfilled,(r,{payload:n})=>{const{deletedVisits:i}=n;return{...z8,deletedVisits:i}})}}),IW="shlink/shortUrlVisits",mAe={visits:[],shortCode:"",loading:!1,errorData:null,cancelLoad:!1,progress:null},vAe=e=>qm({typePrefix:`${IW}/getShortUrlVisits`,createLoaders:({shortCode:t,domain:r,options:n})=>{const i=e(),{doIntervalFallback:a=!1}=n,o=c=>i.getShortUrlVisits({shortCode:t,domain:r},c),s=Wm(a,c=>i.getShortUrlVisits({shortCode:t,domain:r},c));return{visitsLoader:o,lastVisitLoader:s}},shouldCancel:t=>t().shortUrlVisits.cancelLoad}),gAe=(e,t)=>Hm({name:IW,initialState:mAe,asyncThunkCreator:e,extraReducers:r=>{r.addCase(t.fulfilled,(n,{payload:i})=>n.shortCode===i.shortCode&&n.domain===i.domain?{...n,visits:[]}:n)},filterCreatedVisits:({shortCode:r,domain:n,params:i},a)=>bW(a,{shortCode:r,domain:n},i==null?void 0:i.dateRange)}),DW="shlink/shortUrlVisitsDeletion",V8={shortCode:"",deletedVisits:0,deleting:!1,error:!1},yAe=e=>Vr(`${DW}/deleteShortUrlVisits`,async({shortCode:t,domain:r})=>({...await e().deleteShortUrlVisits({shortCode:t,domain:r}),shortCode:t,domain:r})),bAe=e=>Tr({name:DW,initialState:V8,reducers:{},extraReducers:t=>{t.addCase(e.pending,r=>({...r,deleting:!0,error:!1})),t.addCase(e.rejected,(r,{error:n})=>({...r,deleting:!1,error:!0,errorData:Ci(n)})),t.addCase(e.fulfilled,(r,{payload:n})=>{const{shortCode:i,domain:a,deletedVisits:o}=n;return{...V8,shortCode:i,domain:a,deletedVisits:o}})}}),$W="shlink/tagVisits",_Ae={visits:[],tag:"",loading:!1,cancelLoad:!1,errorData:null,progress:null},wAe=e=>qm({typePrefix:`${$W}/getTagVisits`,createLoaders:({tag:t,options:r})=>{const n=e(),{doIntervalFallback:i=!1}=r,a=s=>n.getTagVisits(t,s),o=Wm(i,async s=>n.getTagVisits(t,s));return{visitsLoader:a,lastVisitLoader:o}},shouldCancel:t=>t().tagVisits.cancelLoad}),xAe=e=>Hm({name:$W,initialState:_Ae,asyncThunkCreator:e,filterCreatedVisits:({tag:t,params:r},n)=>wW(n,t,r==null?void 0:r.dateRange)}),FW="shlink/visitsOverview",Lg={nonOrphanVisits:{total:0},orphanVisits:{total:0},loading:!1,error:!1},W8=e=>e.filter(({visit:t})=>t.potentialBot).length,SAe=e=>Vr(`${FW}/loadVisitsOverview`,()=>e().getVisitsOverview().then(({nonOrphanVisits:t,visitsCount:r=0,orphanVisits:n,orphanVisitsCount:i=0})=>({nonOrphanVisits:{total:(t==null?void 0:t.total)??r,nonBots:t==null?void 0:t.nonBots,bots:t==null?void 0:t.bots},orphanVisits:{total:(n==null?void 0:n.total)??i,nonBots:n==null?void 0:n.nonBots,bots:n==null?void 0:n.bots}}))),OAe=e=>Tr({name:FW,initialState:Lg,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({...Lg,loading:!0})),t.addCase(e.rejected,()=>({...Lg,error:!0})),t.addCase(e.fulfilled,(r,{payload:n})=>({...Lg,...n})),t.addCase(Ed,({nonOrphanVisits:r,orphanVisits:n,...i},{payload:a})=>{const{nonOrphanVisits:o,orphanVisits:s}=Cje(a.createdVisits),c=o.length,l=W8(o),h=c-l,p=s.length,g=W8(s),_=p-g;return{...i,nonOrphanVisits:{total:r.total+c,bots:r.bots&&r.bots+l,nonBots:r.nonBots&&r.nonBots+h},orphanVisits:{total:n.total+p,bots:n.bots&&n.bots+g,nonBots:n.nonBots&&n.nonBots+_}}})}}),CAe=({shortUrl:e,loading:t,shortUrlVisits:r})=>{const{visits:n}=r,i=(e==null?void 0:e.shortUrl)??"",a=(e==null?void 0:e.longUrl)??"",o=e==null?void 0:e.title;return v.jsxs(zm,{title:v.jsxs(v.Fragment,{children:["Visits for ",v.jsx(Gn,{href:i})]}),visits:n,shortUrl:e,children:[v.jsx("hr",{}),v.jsxs("div",{children:["Created: ",e?v.jsxs("span",{children:[v.jsx("b",{id:"created",className:"short-url-visits-header__created-at",children:v.jsx($0,{date:e.dateCreated,relative:!0})}),v.jsx(Oi,{placement:"bottom",target:"created",children:v.jsx($0,{date:e.dateCreated})})]}):v.jsx("small",{children:"Loading..."})]}),v.jsxs("div",{className:"long-url-container",children:[`${o?"Title":"Long URL"}: `,t&&v.jsx("small",{children:"Loading..."}),!t&&v.jsx(Gn,{href:a,children:o??a})]})]})},BW=ka(({shortUrlVisits:e,shortUrlVisitsDeletion:t,shortUrlsDetails:r,getShortUrlVisits:n,getShortUrlsDetails:i,deleteShortUrlVisits:a,cancelGetShortUrlVisits:o})=>{const s=Ca("shortUrlVisitsDeletion"),{ReportExporter:c}=ur(BW),l=NA(),h=M.useMemo(()=>{var b;return(b=r.shortUrls)==null?void 0:b.get(l)},[l,r.shortUrls]),p=M.useCallback((b,w)=>n({...l,options:w,params:b}),[n,l]),g=M.useCallback(b=>c.exportVisits(`short-url_${h==null?void 0:h.shortUrl.replace(/https?:\/\//g,"")}_visits.csv`,b),[c,h==null?void 0:h.shortUrl]),_=M.useMemo(()=>s?{deleteVisits:()=>a(l),visitsDeletion:t}:void 0,[a,l,t,s]);return M.useEffect(()=>{i([l])},[l,i]),v.jsx(Vm,{getVisits:p,cancelGetVisits:o,visitsInfo:e,exportCsv:g,deletion:_,children:v.jsx(CAe,{shortUrl:h,loading:r.loading,shortUrlVisits:e})})},e=>e.shortCode?[Rn.shortUrlVisits(TA(e.shortCode))]:[]),PAe=cr(BW,["ReportExporter"]),EAe=({tagVisits:e,colorGenerator:t})=>{const{visits:r,tag:n}=e;return v.jsx(zm,{title:v.jsxs("span",{className:"d-flex align-items-center justify-content-center",children:[v.jsx("span",{className:"me-2",children:"Visits for"}),v.jsx(a_,{text:n,colorGenerator:t})]}),visits:r})},UW=ka(({getTagVisits:e,tagVisits:t,cancelGetTagVisits:r})=>{const{ColorGenerator:n,ReportExporter:i}=ur(UW),{tag:a=""}=cd(),o=M.useCallback((c,l)=>e({tag:a,params:c,options:l}),[e,a]),s=M.useCallback(c=>i.exportVisits(`tag_${a}_visits.csv`,c),[i,a]);return v.jsx(Vm,{getVisits:o,cancelGetVisits:r,visitsInfo:t,exportCsv:s,children:v.jsx(EAe,{tagVisits:t,colorGenerator:n})})},()=>[Rn.visits]),TAe=cr(UW,["ColorGenerator","ReportExporter"]),WA=({title:e,colors:t,getVisitsForComparison:r,visitsComparisonInfo:n,cancelGetVisitsComparison:i})=>{const{loading:a,visitsGroups:o}=n,s=Nn("visits"),c=M.useMemo(()=>Object.keys(o).reduce((C,P,T)=>(C[P]=Object.assign(z0(o[P]),{color:(t==null?void 0:t[P])??vW(T)}),C),{}),[t,o]),l=M.useMemo(()=>Object.values(o).every(C=>C.length===0),[o]),[{dateRange:h,visitsFilter:p},g]=xW(),[_,b]=M.useState(),w=M.useCallback(({startDate:C,endDate:P},T)=>{g({dateRange:{startDate:C??void 0,endDate:P??void 0}}),b(T)},[g]),[x]=M.useState(()=>h??(s==null?void 0:s.defaultInterval)??"last30Days"),S=M.useMemo(()=>({...p,excludeBots:p.excludeBots??(s==null?void 0:s.excludeBots)}),[p,s==null?void 0:s.excludeBots]);return M.useEffect(()=>{const C=h??WV(x);return r({params:{dateRange:C,filter:S}}),i},[i,h,r,x,S]),v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"mb-3",children:v.jsxs(Sr,{bodyClassName:"d-flex",children:[v.jsx(i_,{}),v.jsx("h3",{className:"mb-0 flex-grow-1 text-center",children:e})]})}),v.jsx("div",{className:"col-lg-7 col-xl-6 offset-lg-5 offset-xl-6 mb-3",children:v.jsxs("div",{className:"d-md-flex",children:[v.jsx("div",{className:"flex-grow-1",children:v.jsx(DA,{disabled:a,defaultText:"All visits",dateRangeOrInterval:_??h??x,onDatesChange:w})}),v.jsx(OW,{disabled:a,className:"ms-0 ms-md-2 mt-3 mt-md-0",selected:S,onChange:({orphanVisitsType:C,excludeBots:P})=>g({visitsFilter:{orphanVisitsType:C,excludeBots:P}})})]})}),v.jsx(CW,{info:n}),!a&&v.jsx(Yg,{showFallback:l,children:v.jsx(yW,{visitsGroups:c,onDateRangeChange:w})})]})},jAe=ka(({getDomainVisitsForComparison:e,domainVisitsComparison:t,cancelGetDomainVisitsComparison:r})=>{const n=PA("domains"),i=M.useCallback(a=>e({...a,domains:n}),[n,e]);return v.jsx(WA,{title:`Comparing "${n.join('", "')}"`,getVisitsForComparison:i,visitsComparisonInfo:t,cancelGetVisitsComparison:r})},()=>[Rn.visits]),AAe=({visitsLoaders:e,shouldCancel:t,progressChanged:r})=>{const n=Object.keys(e),i=Math.max(1,Math.round(4/n.length)),a=Object.fromEntries(n.map(c=>[c,0])),o=(c,l)=>{a[c]=l;const h=Object.values(a),p=h.reduce((g,_)=>g+_,0);r(p/h.length)},s=Object.entries(e).map(([c,l])=>[c,kW({visitsLoader:l,batchSize:i,shouldCancel:t,progressChanged:h=>o(c,h)})]);return async c=>{const l=await Promise.all(s.map(async([h,p])=>{const g=await p(c);return[h,g]}));return Object.fromEntries(l)}},qA=({typePrefix:e,createLoaders:t,shouldCancel:r})=>{const n=An(`${e}/progressChanged`),i=Vr(e,async(a,{getState:o,dispatch:s})=>{const c=t(a),l=await AAe({visitsLoaders:c,shouldCancel:()=>r(o),progressChanged:h=>s(n(h))})(eT(a.params));return{...a,visitsGroups:l}});return Object.assign(i,{progressChanged:n})},HA=({name:e,asyncThunkCreator:t,initialState:r,filterCreatedVisitsForGroup:n})=>{const{pending:i,rejected:a,fulfilled:o,progressChanged:s}=t,{reducer:c,actions:l}=Tr({name:e,initialState:r,reducers:{cancelGetVisits:p=>({...p,cancelLoad:!0})},extraReducers:p=>{p.addCase(i,()=>({...r,loading:!0})),p.addCase(a,(g,{error:_})=>({...r,errorData:Ci(_)??null})),p.addCase(o,(g,{payload:_})=>({...g,..._,loading:!1,progress:null,errorData:null})),p.addCase(s,(g,{payload:_})=>({...g,progress:_})),p.addCase(Ed,(g,{payload:_})=>{const{visitsGroups:b,...w}=g,x=Object.keys(b).map(C=>{const P=n({...w,groupKey:C},_.createdVisits).map(({visit:T})=>T);return[C,[...P,...b[C]]]}),S=Object.fromEntries(x);return{...w,visitsGroups:S}})}}),{cancelGetVisits:h}=l;return{reducer:c,cancelGetVisits:h}},zW="shlink/domainVisitsComparison",kAe={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},RAe=e=>qA({typePrefix:`${zW}/getDomainVisitsForComparison`,createLoaders:({domains:t})=>{const r=e(),n=t.map(i=>[i,a=>r.getDomainVisits(i,a)]);return Object.fromEntries(n)},shouldCancel:t=>t().domainVisitsComparison.cancelLoad}),NAe=e=>HA({name:zW,initialState:kAe,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:r},n)=>_W(n,t,r==null?void 0:r.dateRange)}),VW="shlink/shortUrlVisitsComparison",MAe={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},LAe=e=>qA({typePrefix:`${VW}/getShortUrlVisitsForComparison`,createLoaders:({shortUrls:t})=>{const r=e(),n=t.map(i=>[jA(i),a=>r.getShortUrlVisits(i,a)]);return Object.fromEntries(n)},shouldCancel:t=>t().shortUrlVisitsComparison.cancelLoad}),IAe=e=>HA({name:VW,initialState:MAe,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:r},n)=>bW(n,eV(t),r==null?void 0:r.dateRange)}),WW="shlink/tagVisitsComparison",DAe={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},$Ae=e=>qA({typePrefix:`${WW}/getTagVisitsForComparison`,createLoaders:({tags:t})=>{const r=e(),n=t.map(i=>[i,a=>r.getTagVisits(i,a)]);return Object.fromEntries(n)},shouldCancel:t=>t().tagVisitsComparison.cancelLoad}),FAe=e=>HA({name:WW,initialState:DAe,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:r},n)=>wW(n,t,r==null?void 0:r.dateRange)}),BAe=ka(({getShortUrlVisitsForComparison:e,shortUrlVisitsComparison:t,cancelGetShortUrlVisitsComparison:r,shortUrlsDetails:n,getShortUrlsDetails:i})=>{const a=PA("short-urls"),o=M.useMemo(()=>a.map(eV),[a]),s=M.useCallback(h=>e({...h,shortUrls:o}),[e,o]),c=M.useMemo(()=>{var h;return[...((h=n.shortUrls)==null?void 0:h.values())??[]]},[n.shortUrls]),l=M.useMemo(()=>{const{visitsGroups:h,loading:p,...g}=t,_=c.reduce((b,w)=>(b[w.shortUrl]=h[jA(w)]??[],b),{});return{...g,visitsGroups:_,loading:p||n.loading}},[t,n.loading,c]);return M.useEffect(()=>{o.length>0&&i(o)},[i,o]),v.jsx(WA,{title:v.jsx("span",{"data-testid":"title",children:n.loading?"Loading...":`Comparing ${c.length} short URLs`}),getVisitsForComparison:s,visitsComparisonInfo:l,cancelGetVisitsComparison:r})},()=>[Rn.visits]),qW=ka(({getTagVisitsForComparison:e,tagVisitsComparison:t,cancelGetTagVisitsComparison:r})=>{const{ColorGenerator:n}=ur(qW),i=PA("tags"),a=M.useCallback(c=>e({...c,tags:i}),[e,i]),{visitsGroups:o}=t,s=M.useMemo(()=>Object.keys(o).reduce((c,l)=>(c[l]=n.getColorForKey(l),c),{}),[n,o]);return v.jsx(WA,{title:v.jsxs(v.Fragment,{children:["Comparing ",i.map(c=>v.jsx(a_,{colorGenerator:n,text:c},c))]}),getVisitsForComparison:a,visitsComparisonInfo:t,cancelGetVisitsComparison:r,colors:s})},()=>[Rn.visits]),UAe=cr(qW,["ColorGenerator"]),zAe=(e,t)=>{const r=(n,i)=>t([...n,"mercureInfo"],[...i,"createNewVisits","loadMercureInfo"]);e.serviceFactory("MapModal",()=>SW),e.factory("ShortUrlVisits",PAe),e.decorator("ShortUrlVisits",t(["shortUrlVisits","shortUrlVisitsDeletion","shortUrlsDetails","mercureInfo"],["getShortUrlVisits","deleteShortUrlVisits","getShortUrlsDetails","cancelGetShortUrlVisits","createNewVisits","loadMercureInfo"])),e.factory("TagVisits",TAe),e.decorator("TagVisits",r(["tagVisits"],["getTagVisits","cancelGetTagVisits"])),e.factory("TagVisitsComparison",UAe),e.decorator("TagVisitsComparison",r(["tagVisitsComparison"],["getTagVisitsForComparison","cancelGetTagVisitsForComparison"])),e.serviceFactory("DomainVisitsComparison",()=>jAe),e.decorator("DomainVisitsComparison",r(["domainVisitsComparison"],["getDomainVisitsForComparison","cancelGetDomainVisitsForComparison"])),e.serviceFactory("ShortUrlVisitsComparison",()=>BAe),e.decorator("ShortUrlVisitsComparison",r(["shortUrlVisitsComparison","shortUrlsDetails"],["getShortUrlVisitsForComparison","cancelGetShortUrlVisitsForComparison","getShortUrlsDetails"])),e.factory("DomainVisits",Yje),e.decorator("DomainVisits",r(["domainVisits"],["getDomainVisits","cancelGetDomainVisits"])),e.factory("OrphanVisits",Xje),e.decorator("OrphanVisits",r(["orphanVisits","orphanVisitsDeletion"],["getOrphanVisits","cancelGetOrphanVisits","deleteOrphanVisits"])),e.factory("NonOrphanVisits",Zje),e.decorator("NonOrphanVisits",r(["nonOrphanVisits"],["getNonOrphanVisits","cancelGetNonOrphanVisits"])),e.serviceFactory("VisitsParser",()=>Vje),e.serviceFactory("getShortUrlVisits",vAe,"apiClientFactory"),e.serviceFactory("cancelGetShortUrlVisits",n=>n.cancelGetVisits,"shortUrlVisitsReducerCreator"),e.serviceFactory("getShortUrlVisitsForComparison",LAe,"apiClientFactory"),e.serviceFactory("cancelGetShortUrlVisitsForComparison",n=>n.cancelGetVisits,"shortUrlVisitsComparisonReducerCreator"),e.serviceFactory("deleteShortUrlVisits",yAe,"apiClientFactory"),e.serviceFactory("getTagVisits",wAe,"apiClientFactory"),e.serviceFactory("cancelGetTagVisits",n=>n.cancelGetVisits,"tagVisitsReducerCreator"),e.serviceFactory("getTagVisitsForComparison",$Ae,"apiClientFactory"),e.serviceFactory("cancelGetTagVisitsForComparison",n=>n.cancelGetVisits,"tagVisitsComparisonReducerCreator"),e.serviceFactory("getDomainVisits",nAe,"apiClientFactory"),e.serviceFactory("cancelGetDomainVisits",n=>n.cancelGetVisits,"domainVisitsReducerCreator"),e.serviceFactory("getDomainVisitsForComparison",RAe,"apiClientFactory"),e.serviceFactory("cancelGetDomainVisitsForComparison",n=>n.cancelGetVisits,"domainVisitsComparisonReducerCreator"),e.serviceFactory("getOrphanVisits",fAe,"apiClientFactory"),e.serviceFactory("cancelGetOrphanVisits",n=>n.cancelGetVisits,"orphanVisitsReducerCreator"),e.serviceFactory("deleteOrphanVisits",hAe,"apiClientFactory"),e.serviceFactory("getNonOrphanVisits",oAe,"apiClientFactory"),e.serviceFactory("cancelGetNonOrphanVisits",n=>n.cancelGetVisits,"nonOrphanVisitsReducerCreator"),e.serviceFactory("createNewVisits",()=>Ed),e.serviceFactory("loadVisitsOverview",SAe,"apiClientFactory"),e.serviceFactory("visitsOverviewReducerCreator",OAe,"loadVisitsOverview"),e.serviceFactory("visitsOverviewReducer",n=>n.reducer,"visitsOverviewReducerCreator"),e.serviceFactory("domainVisitsReducerCreator",iAe,"getDomainVisits"),e.serviceFactory("domainVisitsReducer",n=>n.reducer,"domainVisitsReducerCreator"),e.serviceFactory("nonOrphanVisitsReducerCreator",sAe,"getNonOrphanVisits"),e.serviceFactory("nonOrphanVisitsReducer",n=>n.reducer,"nonOrphanVisitsReducerCreator"),e.serviceFactory("orphanVisitsReducerCreator",dAe,"getOrphanVisits","deleteOrphanVisits"),e.serviceFactory("orphanVisitsReducer",n=>n.reducer,"orphanVisitsReducerCreator"),e.serviceFactory("orphanVisitsDeletionReducerCreator",pAe,"deleteOrphanVisits"),e.serviceFactory("orphanVisitsDeletionReducer",n=>n.reducer,"orphanVisitsDeletionReducerCreator"),e.serviceFactory("shortUrlVisitsReducerCreator",gAe,"getShortUrlVisits","deleteShortUrlVisits"),e.serviceFactory("shortUrlVisitsReducer",n=>n.reducer,"shortUrlVisitsReducerCreator"),e.serviceFactory("shortUrlVisitsDeletionReducerCreator",bAe,"deleteShortUrlVisits"),e.serviceFactory("shortUrlVisitsDeletionReducer",n=>n.reducer,"shortUrlVisitsDeletionReducerCreator"),e.serviceFactory("tagVisitsReducerCreator",xAe,"getTagVisits"),e.serviceFactory("tagVisitsReducer",n=>n.reducer,"tagVisitsReducerCreator"),e.serviceFactory("tagVisitsComparisonReducerCreator",FAe,"getTagVisitsForComparison"),e.serviceFactory("tagVisitsComparisonReducer",n=>n.reducer,"tagVisitsComparisonReducerCreator"),e.serviceFactory("domainVisitsComparisonReducerCreator",NAe,"getDomainVisitsForComparison"),e.serviceFactory("domainVisitsComparisonReducer",n=>n.reducer,"domainVisitsComparisonReducerCreator"),e.serviceFactory("shortUrlVisitsComparisonReducerCreator",IAe,"getShortUrlVisitsForComparison"),e.serviceFactory("shortUrlVisitsComparisonReducer",n=>n.reducer,"shortUrlVisitsComparisonReducerCreator")},Dh=({children:e,to:t,className:r,...n})=>v.jsx(Y0,{className:({isActive:i})=>Te("aside-menu__item",r,{"aside-menu__item--selected":i}),to:t,...n,children:e}),VAe=({routePrefix:e,showOnMobile:t=!1})=>{const{pathname:r}=bn(),n=Te("aside-menu",{"aside-menu--hidden":!t}),i=a=>`${e}${a}`;return v.jsx("aside",{className:n,children:v.jsxs("nav",{className:"nav flex-column aside-menu__nav",children:[v.jsxs(Dh,{to:i("/overview"),children:[v.jsx(He,{fixedWidth:!0,icon:IY}),v.jsx("span",{className:"aside-menu__item-text",children:"Overview"})]}),v.jsxs(Dh,{to:i("/list-short-urls/1"),className:Te({"aside-menu__item--selected":r.match("/list-short-urls")!==null}),children:[v.jsx(He,{fixedWidth:!0,icon:yT}),v.jsx("span",{className:"aside-menu__item-text",children:"List short URLs"})]}),v.jsxs(Dh,{to:i("/create-short-url"),children:[v.jsx(He,{fixedWidth:!0,icon:zY,flip:"horizontal"}),v.jsx("span",{className:"aside-menu__item-text",children:"Create short URL"})]}),v.jsxs(Dh,{to:i("/manage-tags"),children:[v.jsx(He,{fixedWidth:!0,icon:F$}),v.jsx("span",{className:"aside-menu__item-text",children:"Manage tags"})]}),v.jsxs(Dh,{to:i("/manage-domains"),children:[v.jsx(He,{fixedWidth:!0,icon:pY}),v.jsx("span",{className:"aside-menu__item-text",children:"Manage domains"})]})]})})},HW=({createNotFound:e})=>{const{TagsList:t,ShortUrlsList:r,CreateShortUrl:n,ShortUrlVisits:i,TagVisits:a,DomainVisits:o,OrphanVisits:s,NonOrphanVisits:c,Overview:l,EditShortUrl:h,ManageDomains:p,TagVisitsComparison:g,DomainVisitsComparison:_,ShortUrlVisitsComparison:b,ShortUrlRedirectRules:w}=ur(HW),x=bn(),S=jl(),[C,P,T,A]=ir();M.useEffect(()=>A(),[x,A]);const j=Te("shlink-layout__burger-icon",{"shlink-layout__burger-icon--active":C}),N=LCe(T,A),$=Ca("shortUrlRedirectRules");return v.jsxs(v.Fragment,{children:[v.jsx(He,{icon:lY,className:j,onClick:P}),v.jsx("div",{...N,className:"shlink-layout__swipeable",children:v.jsxs("div",{className:"shlink-layout__swipeable-inner",children:[v.jsx(VAe,{routePrefix:S,showOnMobile:C}),v.jsx("div",{className:"shlink-layout__container",onPointerDown:()=>A(),children:v.jsx("div",{className:"container-xl",children:v.jsxs(G0,{children:[v.jsx(Ot,{index:!0,element:v.jsx(uT,{replace:!0,to:"overview"})}),v.jsx(Ot,{path:"/overview",element:v.jsx(l,{})}),v.jsx(Ot,{path:"/list-short-urls/:page",element:v.jsx(r,{})}),v.jsx(Ot,{path:"/create-short-url",element:v.jsx(n,{})}),v.jsx(Ot,{path:"/short-code/:shortCode/visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(i,{})},U))}),v.jsx(Ot,{path:"/short-code/:shortCode/edit",element:v.jsx(h,{})}),$&&v.jsx(Ot,{path:"/short-code/:shortCode/redirect-rules",element:v.jsx(w,{})}),v.jsx(Ot,{path:"/short-urls/compare-visits",element:v.jsx(b,{})}),v.jsx(Ot,{path:"/tag/:tag/visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(a,{})},U))}),v.jsx(Ot,{path:"/tags/compare-visits",element:v.jsx(g,{})}),v.jsx(Ot,{path:"/domain/:domain/visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(o,{})},U))}),v.jsx(Ot,{path:"/orphan-visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(s,{})},U))}),v.jsx(Ot,{path:"/non-orphan-visits",children:["","*"].map(U=>v.jsx(Ot,{path:U,element:v.jsx(c,{})},U))}),v.jsx(Ot,{path:"/manage-tags",element:v.jsx(t,{})}),v.jsx(Ot,{path:"/manage-domains",element:v.jsx(p,{})}),v.jsx(Ot,{path:"/domains/compare-visits",element:v.jsx(_,{})}),e&&v.jsx(Ot,{path:"*",element:e("/list-short-urls/1")})]})})})]})})]})},WAe=cr(HW,["TagsList","ShortUrlsList","CreateShortUrl","ShortUrlVisits","TagVisits","DomainVisits","OrphanVisits","NonOrphanVisits","Overview","EditShortUrl","ManageDomains","TagVisitsComparison","DomainVisitsComparison","ShortUrlVisitsComparison","ShortUrlRedirectRules"]),qAe=e=>L7({devTools:!1,reducer:nj({mercureInfo:e.mercureInfoReducer,shortUrlsList:e.shortUrlsListReducer,shortUrlCreation:e.shortUrlCreationReducer,shortUrlDeletion:e.shortUrlDeletionReducer,shortUrlEdition:e.shortUrlEditionReducer,shortUrlsDetails:e.shortUrlsDetailsReducer,shortUrlVisits:e.shortUrlVisitsReducer,shortUrlVisitsDeletion:e.shortUrlVisitsDeletionReducer,shortUrlVisitsComparison:e.shortUrlVisitsComparisonReducer,tagVisits:e.tagVisitsReducer,tagVisitsComparison:e.tagVisitsComparisonReducer,domainVisits:e.domainVisitsReducer,domainVisitsComparison:e.domainVisitsComparisonReducer,orphanVisits:e.orphanVisitsReducer,orphanVisitsDeletion:e.orphanVisitsDeletionReducer,nonOrphanVisits:e.nonOrphanVisitsReducer,tagsList:e.tagsListReducer,tagDelete:e.tagDeleteReducer,tagEdit:e.tagEditReducer,domainsList:e.domainsListReducer,visitsOverview:e.visitsOverviewReducer,shortUrlRedirectRules:e.shortUrlRedirectRulesReducer,shortUrlRedirectRulesSaving:e.setShortUrlRedirectRulesReducer}),middleware:t=>t({immutableCheck:!1,serializableCheck:!1})}),HAe=e=>{e.factory("Main",WAe),e.factory("store",qAe)},Ra=new N$,{container:GAe}=Ra,KAe=e=>t=>Object.fromEntries(e.map(r=>[r,t[r]])),YAe=(e,t)=>(...r)=>e[t](...r),ZAe=(e,t)=>({...e,[t]:YAe(GAe,t)}),jd=(e,t=[])=>o$(e?KAe(e):null,t.reduce(ZAe,{}));HAe(Ra);jTe(Ra,jd);QTe(Ra,jd);zAe(Ra,jd);YCe(Ra);HCe(Ra,jd);sPe(Ra,jd);aje(Ra);AEe(Ra,jd);let q8;const XAe=e=>({serverVersion:t,apiClient:r,settings:n,routesPrefix:i="",createNotFound:a,tagColorsStorage:o})=>{const s=kCe(t),c=M.useRef(void 0),[l,h]=M.useState(),p=qu(),g=M.useMemo(()=>p?M.Fragment:_$,[p]);return M.useEffect(()=>{q8=r,e.value("apiClientFactory",()=>q8),o&&e.value("TagColorsStorage",o);const{container:_}=e,{Main:b,store:w,loadMercureInfo:x,listTags:S,listDomains:C}=_;c.current=v.jsx(b,{createNotFound:a}),h(w),w.dispatch(x(n)),w.dispatch(S()),w.dispatch(C())},[r,a,n,o]),l?v.jsx(s$,{store:l,children:v.jsx(G7,{value:n??{},children:v.jsx(ACe,{value:s,children:v.jsx(ECe,{value:i,children:v.jsx(g,{children:c.current})})})})}):v.jsx(v.Fragment,{})},QAe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",JAe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",e3e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",t3e=()=>{delete n8.Icon.Default.prototype._getIconUrl,n8.Icon.Default.mergeOptions({iconRetinaUrl:JAe,iconUrl:QAe,shadowUrl:e3e})};t3e();const r3e=XAe(Ra);function V0(e){return t=>{const{resetSelectedServer:r}=t;return M.useEffect(()=>{r()},[r]),v.jsx(e,{...t})}}let n3e=class extends M.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){const{console:r=globalThis.console}=this.props;r.error(t)}render(){const{hasError:t}=this.state,{location:r=globalThis.location}=this.props;if(t)return v.jsxs(x7,{title:"Oops! This is awkward :S",children:[v.jsx("p",{children:"It seems that something went wrong. Try refreshing the page or just click this button."}),v.jsx("br",{}),v.jsx(Yi,{size:"lg",onClick:()=>r.reload(),children:"Take me back"})]});const{children:n}=this.props;return n}};const i3e=({id:e,name:t})=>v.jsxs(Xt,{to:`/server/${e}`,className:Te("servers-list__server-item","tw:flex tw:items-center tw:justify-between tw:gap-x-2 tw:px-4 tw:py-3","tw:rounded-none tw:hover:bg-lm-secondary tw:hover:dark:bg-dm-secondary","tw:border-b tw:last:border-0 tw:border-lm-border tw:dark:border-dm-border"),children:[v.jsx("span",{className:"tw:truncate",children:t}),v.jsx(He,{icon:GY})]}),GW=({servers:e,borderless:t})=>v.jsx(v.Fragment,{children:e.length>0&&v.jsx("div",{"data-testid":"list",className:Te("tw:w-full tw:border-lm-border tw:dark:border-dm-border","tw:md:max-h-56 tw:md:overflow-y-auto tw:-mb-1 tw:scroll-thin",{"tw:border-y":!t}),children:e.map(({id:r,name:n})=>v.jsx(i3e,{id:r,name:n},r))})}),KW=({color:e=Cp,className:t})=>v.jsx("svg",{className:t,viewBox:"0 0 512 512",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:v.jsxs("g",{fill:e,children:[v.jsx("path",{d:" M 23.71 85.08 C 17.22 49.81 49.44 14.86 85.08 18.12 C 118.83 19.21 145.72 53.33 139.45 86.37 C 155.64 102.30 171.32 118.83 187.87 134.36 C 198.32 111.73 208.84 89.12 219.57 66.62 C 226.05 53.84 243.47 48.74 255.73 56.27 C 263.76 62.10 270.34 69.69 277.25 76.75 C 286.28 86.61 285.72 102.89 276.31 112.31 C 223.38 165.37 170.38 218.37 117.35 271.34 C 107.72 280.99 91.01 281.25 81.11 271.86 C 74.39 264.94 66.82 258.69 61.24 250.77 C 53.72 238.52 58.85 221.07 71.64 214.62 C 94.11 203.87 116.72 193.38 139.33 182.91 C 123.81 166.36 107.30 150.68 91.37 134.49 C 60.20 140.28 27.37 116.78 23.71 85.08 Z"}),v.jsx("path",{d:" M 205.21 201.23 C 225.32 181.36 260.88 181.11 281.14 200.86 C 299.25 218.75 317.37 236.65 335.10 254.93 C 356.73 278.01 352.01 318.70 326.03 336.56 C 320.07 330.47 313.73 324.65 308.12 318.28 C 323.86 309.39 328.76 286.18 316.63 272.39 C 301.73 256.95 286.30 242.03 271.24 226.75 C 264.49 219.65 256.80 212.00 246.37 211.52 C 224.65 208.64 205.52 233.36 214.49 253.58 C 221.09 266.81 234.22 275.12 243.62 286.24 C 240.43 295.96 238.09 306.13 238.29 316.46 C 225.55 304.29 213.16 291.73 200.89 279.09 C 180.97 257.57 183.10 220.45 205.21 201.23 Z"}),v.jsx("path",{d:" M 273.90 352.07 C 252.28 328.99 256.98 288.31 282.96 270.46 C 288.93 276.54 295.26 282.36 300.88 288.72 C 285.14 297.62 280.23 320.82 292.38 334.61 C 307.27 350.05 322.70 364.96 337.75 380.25 C 344.51 387.35 352.20 395.00 362.64 395.48 C 384.35 398.37 403.49 373.64 394.51 353.42 C 387.92 340.18 374.78 331.88 365.38 320.76 C 368.56 311.04 370.91 300.86 370.71 290.54 C 383.45 302.70 395.84 315.27 408.11 327.91 C 428.03 349.43 425.90 386.55 403.78 405.77 C 383.68 425.64 348.13 425.89 327.86 406.14 C 309.75 388.25 291.60 370.37 273.90 352.07 Z"}),v.jsx("path",{d:" M 422.11 403.83 C 431.96 394.07 441.60 384.06 451.66 374.51 C 460.90 383.74 471.89 392.70 474.89 406.11 C 480.16 429.97 484.08 454.13 488.76 478.12 C 490.00 483.41 484.47 488.29 479.35 486.63 C 454.66 481.52 429.55 478.12 405.14 471.84 C 393.17 467.97 385.20 457.75 376.55 449.27 C 386.39 439.49 396.13 429.60 406.06 419.91 C 416.37 433.45 435.74 414.00 422.11 403.83 Z"})]})}),a3e=({servers:e})=>{const t=fo(),r=Object.values(e),n=r.length>0;return M.useEffect(()=>{const i=r.find(({autoConnect:a})=>a);i&&t(`/server/${i.id}`)},[r,t]),v.jsx("div",{className:"tw:w-full",children:v.jsx(mi,{className:"tw:mx-auto tw:max-w-[720px] tw:overflow-hidden",children:v.jsxs("div",{className:"tw:flex tw:flex-col tw:md:flex-row",children:[v.jsx("div",{className:"tw:p-6 tw:hidden tw:md:flex tw:items-center tw:w-[40%]",children:v.jsx("div",{className:"tw:w-full",children:v.jsx(KW,{})})}),v.jsxs("div",{className:"tw:md:border-l tw:border-lm-border tw:dark:border-dm-border tw:flex-grow",children:[v.jsx("h1",{className:Te("tw:p-4 tw:text-center tw:border-lm-border tw:dark:border-dm-border",{"tw:border-b":!n}),children:"Welcome!"}),n?v.jsx(GW,{servers:r}):v.jsxs("div",{className:"tw:p-6 tw:text-center tw:flex tw:flex-col tw:gap-12 tw:text-xl",children:[v.jsx("p",{children:"This application will help you manage your Shlink servers."}),v.jsx("p",{children:v.jsxs(Yi,{to:"/server/create",size:"lg",inline:!0,children:[v.jsx(He,{icon:gm})," Add a server"]})}),v.jsx("p",{children:v.jsx(Gn,{href:"https://shlink.io/documentation",children:v.jsxs("small",{children:[v.jsx("span",{className:"tw:mr-2",children:"Learn more about Shlink"}),v.jsx(He,{icon:EY})]})})})]})]})]})})})},YW=()=>{const{ServersDropdown:e}=Ta(YW),[t,r,,n]=ir(),i=bn(),{pathname:a}=i;M.useEffect(n,[i,n]);const o="/settings";return v.jsxs(kF,{color:"primary",dark:!0,fixed:"top",expand:"md",className:"tw:text-white tw:bg-lm-brand tw:dark:bg-dm-brand",children:[v.jsxs(RF,{tag:Xt,to:"/",children:[v.jsx(KW,{className:"tw:inline tw:w-7 tw:mr-1",color:"white"})," Shlink"]}),v.jsx(NF,{onClick:r,children:v.jsx(He,{icon:WY,className:Te("tw:transition-transform tw:duration-300",{"tw:rotate-180":t})})}),v.jsx(KT,{navbar:!0,isOpen:t,children:v.jsxs($T,{navbar:!0,className:"tw:ml-auto",children:[v.jsx(FT,{children:v.jsxs(BT,{tag:Xt,to:o,active:a.startsWith(o),children:[v.jsx(He,{icon:ZY}),"  Settings"]})}),v.jsx(e,{})]})})]})},o3e=ja(YW,["ServersDropdown"]),s3e=({children:e})=>{const t=bn();return M.useEffect(()=>{scrollTo(0,0)},[t]),v.jsx(v.Fragment,{children:e})},ZW=V7(e=>e,e=>{try{return yP(e,e,"=")}catch{return!1}}),XW=e=>ZW(e)?`v${e}`:e,QW=(e,t="latest")=>ZW(e)?e:t,l3e="%_VERSION_%",u3e=e=>XW(QW(e)),H8=({project:e,version:t})=>v.jsx(Gn,{href:`https://github.com/shlinkio/${e}/releases/${t}`,className:"tw:text-gray-500",children:v.jsx("b",{children:t})}),c3e=({selectedServer:e,clientVersion:t=l3e})=>{const r=u3e(t);return v.jsxs("small",{className:"tw:text-gray-500",children:[vT(e)&&v.jsxs(v.Fragment,{children:["Server: ",v.jsx(H8,{project:"shlink",version:e.printableVersion})," - "]}),"Client: ",v.jsx(H8,{project:"shlink-web-client",version:r})]})},f3e=({selectedServer:e})=>v.jsx("div",{className:Te("tw:text-center",{"tw:md:ml-(--aside-menu-width)":vT(e)}),children:v.jsx(c3e,{selectedServer:e})}),Ad=({children:e,className:t})=>v.jsx("div",{className:Te("tw:container tw:mx-auto tw:p-5 tw:pt-8 tw:max-md:p-0 tw:max-md:py-4",t),children:e});function JW(e){const t=r=>{const{ServerError:n}=Ta(t),i=cd(),{selectServer:a,selectedServer:o}=r;return M.useEffect(()=>{i.serverId&&a(i.serverId)},[i.serverId,a]),o?KK(o)?v.jsx(n,{}):v.jsx(e,{...r}):v.jsx(Ad,{children:v.jsx(_7,{loading:!0})})};return t}const eq=JW(M.memo(({selectedServer:e,settings:t})=>{const{buildShlinkApiClient:r,TagColorsStorage:n,ShlinkWebComponent:i,ServerError:a}=Ta(eq);if(!vT(e))return v.jsx(a,{});const o=`/server/${e.id}`;return v.jsx(i,{serverVersion:e.version,apiClient:r(e),settings:t,routesPrefix:o,tagColorsStorage:n,createNotFound:s=>v.jsx(S7,{to:`${o}${s}`,children:"List short URLs"})})})),d3e=ja(eq,["buildShlinkApiClient","TagColorsStorage","ShlinkWebComponent","ServerError"]),h3e=(e,t)=>{e.constant("window",window),e.constant("console",console),e.constant("fetch",window.fetch.bind(window)),e.service("HttpClient",Soe,"fetch"),e.serviceFactory("ScrollToTop",()=>s3e),e.factory("MainHeader",o3e),e.serviceFactory("Home",()=>a3e),e.decorator("Home",V0),e.decorator("Home",t(["servers"],["resetSelectedServer"])),e.serviceFactory("ShlinkWebComponent",()=>r3e),e.factory("ShlinkWebComponentContainer",d3e),e.decorator("ShlinkWebComponentContainer",t(["selectedServer","settings"],["selectServer"])),e.serviceFactory("ShlinkVersionsContainer",()=>f3e),e.decorator("ShlinkVersionsContainer",t(["selectedServer"])),e.serviceFactory("ErrorHandler",()=>n3e)},tq=()=>{const e=fo();return M.useCallback(()=>e(-1),[e])};function p3e(e){let t=e.url;try{const{host:r,pathname:n}=new URL(t);t=r;const i=n.substring(1);i.length>0&&(t=`${t} ${i}`)}catch{}return`${e.name} ${t}`.toLowerCase().replace(/[^a-zA-Z0-9-_.~]/g,"-")}function m3e(e){const t={};return e.forEach(r=>{t[r.id]=r}),t}const v3e=(e,{url:t,apiKey:r})=>e.some(n=>n.url===t&&n.apiKey===r);function g3e(e,t){const r=Object.values(e),{duplicatedServers:n=[],newServers:i=[]}=z7(t,a=>v3e(r,a)?"duplicatedServers":"newServers");return{duplicatedServers:n,newServers:i}}function W0(e,t){const r=new Set(Object.keys(e)),n=[];return t.forEach(i=>{const a=p3e(i);let o=a,s=1;for(;r.has(o);)o=`${a}-${s}`,s++;n.push({...i,id:o}),r.add(o)}),n}const rq=({open:e,duplicatedServers:t,onClose:r,onConfirm:n})=>{const i=t.length>1;return v.jsxs(b7,{size:"lg",title:`Duplicated server${i?"s":""}`,open:e,onClose:r,onConfirm:n,confirmText:`Save duplicate${i?"s":""}`,cancelText:i?"Ignore duplicates":"Discard",children:[v.jsx("p",{children:i?"The next servers already exist:":"There is already a server with:"}),v.jsx("ul",{className:"tw:list-disc tw:mt-4",children:t.map(({url:a,apiKey:o},s)=>i?v.jsxs("li",{children:[v.jsx("b",{children:a})," - ",v.jsx("b",{children:o})]},s):v.jsxs(M.Fragment,{children:[v.jsxs("li",{children:["URL: ",v.jsx("b",{children:a})]}),v.jsxs("li",{children:["API key: ",v.jsx("b",{children:o})]})]},s))}),v.jsxs("span",{children:[i?"Do you want to save duplicated servers":"Do you want to save this server","?"]})]})},y3e=e=>t=>{t.preventDefault(),e()},nq=({onSubmit:e,initialValues:t,children:r,title:n})=>{const[i,a]=M.useState((t==null?void 0:t.name)??""),[o,s]=M.useState((t==null?void 0:t.url)??""),[c,l]=M.useState((t==null?void 0:t.apiKey)??""),h=y3e(()=>e({name:i,url:o,apiKey:c}));return v.jsxs("form",{name:"serverForm",onSubmit:h,children:[v.jsxs(ub,{className:"tw:mb-4",bodyClassName:"tw:flex tw:flex-col tw:gap-y-3",title:n,children:[v.jsx(bN,{label:"Name",value:i,onChange:p=>a(p.target.value),required:!0}),v.jsx(bN,{label:"URL",type:"url",value:o,onChange:p=>s(p.target.value),required:!0}),v.jsx(dae,{label:"API key",value:c,onChange:p=>l(p.target.value),required:!0})]}),v.jsx("div",{className:"tw:flex tw:items-center tw:justify-end tw:gap-x-2",children:r})]})},G8=4e3,K8=({variant:e})=>v.jsx("div",{className:"tw:mt-4",children:v.jsxs(w7,{variant:e,children:[e==="success"&&"Servers properly imported. You can now select one from the list :)",e==="error"&&"The servers could not be imported. Make sure the format is correct."]})}),iq=({servers:e,createServers:t})=>{const{ImportServersBtn:r,useTimeoutToggle:n}=Ta(iq),i=fo(),a=tq(),o=!!Object.keys(e).length,[s,c]=n(!1,G8),[l,h]=n(!1,G8),[p,g]=ir(),[_,b]=M.useState(),w=M.useCallback(S=>{const[C]=W0(e,[S]);t([C]),i(`/server/${C.id}`)},[t,i,e]),x=M.useCallback(S=>{b(S),Object.values(e).some(({url:P,apiKey:T})=>S.url===P&&S.apiKey===T)?g():w(S)},[w,e,g]);return v.jsxs(Ad,{children:[v.jsxs(nq,{title:"Add new server",onSubmit:x,children:[!o&&v.jsx(r,{tooltipPlacement:"top",onImport:c,onError:h}),o&&v.jsx(Yi,{variant:"secondary",onClick:a,children:"Cancel"}),v.jsx(Yi,{type:"submit",children:"Create server"})]}),s&&v.jsx(K8,{variant:"success"}),l&&v.jsx(K8,{variant:"error"}),v.jsx(rq,{open:p,duplicatedServers:_?[_]:[],onClose:a,onConfirm:()=>_&&w(_)})]})},b3e=ja(iq,["ImportServersBtn","useTimeoutToggle"]),aq=({server:e,children:t})=>{const{DeleteServerModal:r}=Ta(aq),[n,,i,a]=ir(),o=fo(),s=M.useCallback(c=>{a(),c&&o("/")},[a,o]);return v.jsxs(v.Fragment,{children:[v.jsx("button",{type:"button",className:"tw:text-danger tw:hover:underline",onClick:i,children:t}),v.jsx(r,{server:e,open:n,onClose:s})]})},_3e=ja(aq,["DeleteServerModal"]),w3e=({server:e,onClose:t,open:r,deleteServer:n})=>{const i=M.useCallback(a=>{a==="confirm"&&n(e)},[n,e]);return v.jsx(b7,{open:r,title:"Remove server",variant:"danger",onClose:()=>t(!1),onConfirm:()=>t(!0),onClosed:i,confirmText:"Delete",children:v.jsxs("div",{className:"tw:flex tw:flex-col tw:gap-y-4",children:[v.jsxs("p",{children:["Are you sure you want to remove ",v.jsx("b",{children:e?e.name:""}),"?"]}),v.jsx("p",{children:v.jsx("i",{children:"No data will be deleted, only the access to this server will be removed from this device. You can create it again at any moment."})})]})})},x3e=JW(({editServer:e,selectedServer:t,selectServer:r})=>{const n=tq(),{reconnect:i}=hd();if(!Zh(t))return null;const a=o=>{e(t.id,o),i==="true"&&r(t.id),n()};return v.jsx(Ad,{children:v.jsxs(nq,{title:v.jsxs(v.Fragment,{children:['Edit "',t.name,'"']}),initialValues:t,onSubmit:a,children:[v.jsx(Yi,{variant:"secondary",onClick:n,children:"Cancel"}),v.jsx(Yi,{type:"submit",children:"Save"})]})})}),S3e=ja(x3e,["ServerError"]),oq=({createServers:e,servers:t,children:r,onImport:n,onError:i=()=>{},tooltipPlacement:a="bottom",className:o=""})=>{const{ServersImporter:s}=Ta(oq),c=_i(),[l,h]=M.useState([]),[p,,g,_]=ir(),b=M.useRef(!1),w=M.useCallback(async({target:C})=>{var P;return s.importServersFromFile((P=C.files)==null?void 0:P[0]).then(T=>{const{duplicatedServers:A,newServers:j}=g3e(t,T);b.current=j.length>0,e(W0(t,j)),A.length>0?(h(A),g()):n==null||n()}).then(()=>{C.value=null}).catch(i)},[e,i,n,t,s,g]),x=M.useCallback(()=>{e(W0(t,l)),_(),n==null||n()},[e,l,_,n,t]),S=M.useCallback(()=>{_(),b.current&&(n==null||n())},[_,n]);return v.jsxs(v.Fragment,{children:[v.jsxs(Yi,{variant:"secondary",id:"importBtn",className:o,onClick:()=>{var C;return(C=c.current)==null?void 0:C.click()},children:[v.jsx(He,{icon:gY,fixedWidth:!0})," ",r??"Import from file"]}),v.jsxs(Oi,{placement:a,target:"importBtn",children:["You can create servers by importing a CSV file with ",v.jsx("b",{children:"name"}),", ",v.jsx("b",{children:"apiKey"})," and ",v.jsx("b",{children:"url"})," columns."]}),v.jsx("input",{type:"file",accept:".csv",className:"tw:hidden","aria-hidden":!0,ref:c,onChange:w,"data-testid":"csv-file-input"}),v.jsx(rq,{open:p,duplicatedServers:l,onClose:S,onConfirm:x})]})},O3e=ja(oq,["ServersImporter"]),sq=({servers:e,selectedServer:t})=>{const{DeleteServerButton:r}=Ta(sq);return v.jsx(Ad,{children:v.jsxs("div",{className:"tw:flex tw:flex-col tw:items-center tw:gap-y-4 tw:md:gap-y-8",children:[v.jsxs(_7,{className:"tw:w-full tw:lg:w-[80%]",variant:"error",children:[!Zh(t)&&"Could not find this Shlink server.",Zh(t)&&v.jsxs(v.Fragment,{children:[v.jsx("p",{children:"Oops! Could not connect to this Shlink server."}),"Make sure you have internet connection, and the server is properly configured and on-line."]})]}),v.jsxs("p",{className:"tw:text-xl",children:["These are the Shlink servers currently configured. Choose one of them or ",v.jsx(Xt,{to:"/server/create",children:"add a new one"}),"."]}),v.jsx(mi,{className:"tw:w-full tw:max-w-100 tw:overflow-hidden",children:v.jsx(GW,{borderless:!0,servers:Object.values(e)})}),Zh(t)&&v.jsxs("p",{className:"tw:text-xl",children:["Alternatively, if you think you may have misconfigured this server, you can ",v.jsx(r,{server:t,children:"remove it"})," or ",v.jsx(Xt,{to:`/server/${t.id}/edit?reconnect=true`,children:"edit it"}),"."]})]})})},C3e=ja(sq,["DeleteServerButton"]),P3e=4e3,lq=({servers:e})=>{const{ServersExporter:t,ImportServersBtn:r,useTimeoutToggle:n,ManageServersRow:i}=Ta(lq),[a,o]=M.useState(""),s=M.useMemo(()=>Object.values(e),[e]),c=M.useMemo(()=>s.filter(({name:g,url:_})=>`${g} ${_}`.toLowerCase().match(a.toLowerCase())),[s,a]),l=s.some(({autoConnect:g})=>!!g),[h,p]=n(!1,P3e);return v.jsxs(Ad,{className:"tw:flex tw:flex-col tw:gap-y-4",children:[v.jsx(pae,{onChange:o}),v.jsxs("div",{className:"tw:flex tw:flex-col tw:md:flex-row tw:gap-2",children:[v.jsxs("div",{className:"tw:flex tw:gap-2",children:[v.jsx(r,{className:"tw:flex-grow",onError:p,children:"Import servers"}),c.length>0&&v.jsxs(Yi,{variant:"secondary",className:"tw:flex-grow",onClick:async()=>t.exportServers(),children:[v.jsx(He,{icon:B$})," Export servers"]})]}),v.jsxs(Yi,{className:"tw:md:ml-auto",to:"/server/create",children:[v.jsx(He,{icon:gm})," Add a server"]})]}),v.jsx(ub,{className:"card",children:v.jsxs(di,{header:v.jsxs(di.Row,{children:[l&&v.jsx(di.Cell,{className:"tw:w-[35px]",children:v.jsx("span",{className:"tw:sr-only",children:"Auto-connect"})}),v.jsx(di.Cell,{children:"Name"}),v.jsx(di.Cell,{children:"Base URL"}),v.jsx(di.Cell,{children:v.jsx("span",{className:"sr-only",children:"Options"})})]}),children:[!c.length&&v.jsx(di.Row,{className:"tw:text-center",children:v.jsx(di.Cell,{colSpan:4,children:"No servers found."})}),c.map(g=>v.jsx(i,{server:g,hasAutoConnect:l},g.id))]})}),h&&v.jsx("div",{children:v.jsx(w7,{variant:"error",children:"The servers could not be imported. Make sure the format is correct."})})]})},E3e=ja(lq,["ServersExporter","ImportServersBtn","useTimeoutToggle","ManageServersRow"]),uq=({server:e,hasAutoConnect:t})=>{const{ManageServersRowDropdown:r}=Ta(uq);return v.jsxs(di.Row,{className:"tw:relative",children:[t&&v.jsx(di.Cell,{columnName:"Auto-connect",children:e.autoConnect&&v.jsxs(v.Fragment,{children:[v.jsx(He,{icon:vp,className:"tw:text-brand",id:"autoConnectIcon"}),v.jsx(Oi,{target:"autoConnectIcon",placement:"right",children:"Auto-connect to this server"})]})}),v.jsx(di.Cell,{className:"tw:font-bold",columnName:"Name",children:v.jsx(Xt,{to:`/server/${e.id}`,children:e.name})}),v.jsx(di.Cell,{columnName:"Base URL",className:"tw:max-lg:border-b-0",children:e.url}),v.jsx(di.Cell,{className:"tw:text-right tw:max-lg:absolute tw:right-0 tw:-top-1 tw:mx-lg:pt-0",children:v.jsx(r,{server:e})})]})},T3e=ja(uq,["ManageServersRowDropdown"]),cq=({server:e,setAutoConnect:t})=>{const{DeleteServerModal:r}=Ta(cq),[n,,i,a]=ir(),o=`/server/${e.id}`,{autoConnect:s}=e,c=s?mY:ise;return v.jsxs(lb,{minWidth:s?210:170,children:[v.jsxs(Ze,{tag:Xt,to:o,children:[v.jsx(He,{icon:hY,fixedWidth:!0})," Connect"]}),v.jsxs(Ze,{tag:Xt,to:`${o}/edit`,children:[v.jsx(He,{icon:bT,fixedWidth:!0})," Edit server"]}),v.jsxs(Ze,{onClick:()=>t(e,!s),children:[v.jsx(He,{icon:c,fixedWidth:!0})," ",s?"Do not a":"A","uto-connect"]}),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{className:"tw:text-danger",onClick:i,children:[v.jsx(He,{icon:D$,fixedWidth:!0})," Remove server"]}),v.jsx(r,{server:e,open:n,onClose:a})]})},j3e=ja(cq,["DeleteServerModal"]),fq=(e,t)=>D7(e,t,{serializeError:r=>r}),A3e={},{actions:k3e,reducer:R3e}=Tr({name:"shlink/servers",initialState:A3e,reducers:{editServer:{prepare:(e,t)=>({payload:{serverId:e,serverData:t}}),reducer:(e,{payload:t})=>{const{serverId:r,serverData:n}=t;return e[r]?{...e,[r]:{...e[r],...n}}:e}},deleteServer:(e,{payload:t})=>(delete e[t.id],e),setAutoConnect:{prepare:({id:e},t)=>({payload:{serverId:e,autoConnect:t}}),reducer:(e,{payload:t})=>{const{serverId:r,autoConnect:n}=t;return e[r]?n?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,{...a,autoConnect:i===r}])):{...e,[r]:{...e[r],autoConnect:n}}:e}},createServers:{prepare:e=>({payload:m3e(e)}),reducer:(e,{payload:t})=>({...e,...t})}}}),{editServer:N3e,deleteServer:M3e,setAutoConnect:L3e,createServers:dq}=k3e,I3e=R3e,D3e=e=>W0({},Array.isArray(e)?e.filter(I$):[]),$3e=e=>fq("shlink/remoteServers/fetchServers",async(t,{dispatch:r})=>{const n=await e.jsonRequest(`${Qg.homepage}/servers.json`),i=D3e(n);r(dq(i))}),GA="shlink/selectedServer",F3e="1.0.0",B3e="999.999.999",U3e="latest",z3e=e=>QW(e===U3e?B3e:e,F3e),V3e=V7(e=>`${e.id}_${e.url}_${e.apiKey}`,async(e,t)=>t().then(({version:r})=>({version:z3e(r),printableVersion:XW(r)}))),Y8=null,KA=An(`${GA}/resetSelectedServer`),W3e=e=>fq(`${GA}/selectServer`,async(t,{dispatch:r,getState:n})=>{r(KA());const{servers:i}=n(),a=i[t];if(!a)return{serverNotFound:!0};try{const o=e(a),{version:s,printableVersion:c}=await V3e(a,()=>o.health());return{...a,version:s,printableVersion:c}}catch{return{...a,serverNotReachable:!0}}}),q3e=e=>Tr({name:GA,initialState:Y8,reducers:{},extraReducers:t=>{t.addCase(KA,()=>Y8),t.addCase(e.fulfilled,(r,{payload:n})=>n)}}),H3e=({servers:e,selectedServer:t})=>{const r=Object.values(e),n=()=>r.length===0?v.jsxs(Ze,{tag:Xt,to:"/server/create",children:[v.jsx(He,{icon:gm})," ",v.jsx("span",{className:"tw:ml-1",children:"Add a server"})]}):v.jsxs(v.Fragment,{children:[r.map(({name:i,id:a})=>v.jsx(Ze,{tag:Xt,to:`/server/${a}`,active:YK(t)===a,children:i},a)),v.jsx(Ze,{divider:!0,tag:"hr"}),v.jsxs(Ze,{tag:Xt,to:"/manage-servers",children:[v.jsx(He,{icon:eR})," ",v.jsx("span",{className:"tw:ml-1",children:"Manage servers"})]})]});return v.jsxs(Cm,{nav:!0,inNavbar:!0,children:[v.jsxs(is,{nav:!0,caret:!0,children:[v.jsx(He,{icon:eR})," ",v.jsx("span",{className:"tw:ml-1",children:"Servers"})]}),v.jsx(xl,{end:!0,classNam:"tw:right-0",children:n()})]})},G3e=({document:e},t,r)=>{const n=e.createElement("a");n.setAttribute("href",t),n.setAttribute("download",r),n.style.visibility="hidden",e.body.appendChild(n),n.click(),e.body.removeChild(n)},K3e=(e,t,r)=>{const n=new Blob([t],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(n);G3e(e,i,r)},Y3e="shlink-servers.csv";class Z3e{constructor(t,r,n){Bc(this,"exportServers",async()=>{const t=Object.values(this.storage.get("servers")??{}).map(ZK);try{const r=this.jsonToCsv(t);K3e(this.window,r,Y3e)}catch(r){console.error(r)}});this.storage=t,this.window=r,this.jsonToCsv=n}}const X3e=e=>typeof e.url=="string"&&typeof e.apiKey=="string"&&typeof e.name=="string",Q3e=e=>Array.isArray(e)&&e.every(X3e);class J3e{constructor(t){this.csvToJson=t}async importServersFromFile(t){if(!t)throw new Error("No file provided");const r=await t.text(),n=await this.csvToJson(r);if(!Q3e(n))throw new Error("Provided file does not have the right format.");return n}}const eke=(e,t)=>{e.factory("ManageServers",E3e),e.decorator("ManageServers",V0),e.decorator("ManageServers",t(["selectedServer","servers"],["resetSelectedServer"])),e.factory("ManageServersRow",T3e),e.factory("ManageServersRowDropdown",j3e),e.decorator("ManageServersRowDropdown",t(null,["setAutoConnect"])),e.factory("CreateServer",b3e),e.decorator("CreateServer",V0),e.decorator("CreateServer",t(["selectedServer","servers"],["createServers","resetSelectedServer"])),e.factory("EditServer",S3e),e.decorator("EditServer",t(["selectedServer"],["editServer","selectServer","resetSelectedServer"])),e.serviceFactory("ServersDropdown",()=>H3e),e.decorator("ServersDropdown",t(["servers","selectedServer"])),e.serviceFactory("DeleteServerModal",()=>w3e),e.decorator("DeleteServerModal",t(null,["deleteServer"])),e.factory("DeleteServerButton",_3e),e.factory("ImportServersBtn",O3e),e.decorator("ImportServersBtn",t(["servers"],["createServers"])),e.factory("ServerError",C3e),e.decorator("ServerError",t(["servers","selectedServer"])),e.service("ServersImporter",J3e,"csvToJson"),e.service("ServersExporter",Z3e,"Storage","window","jsonToCsv"),e.serviceFactory("selectServer",W3e,"buildShlinkApiClient","loadMercureInfo"),e.serviceFactory("createServers",()=>dq),e.serviceFactory("deleteServer",()=>M3e),e.serviceFactory("editServer",()=>N3e),e.serviceFactory("setAutoConnect",()=>L3e),e.serviceFactory("fetchServers",$3e,"HttpClient"),e.serviceFactory("resetSelectedServer",()=>KA),e.serviceFactory("selectedServerReducerCreator",q3e,"selectServer"),e.serviceFactory("selectedServerReducer",r=>r.reducer,"selectedServerReducerCreator")},hq={field:"dateCreated",dir:"DESC"},tke={realTimeUpdates:{enabled:!0},shortUrlCreation:{validateUrls:!1},ui:{theme:JT()},visits:{defaultInterval:"last30Days"},shortUrlsList:{defaultOrdering:hq}},{reducer:rke,actions:nke}=Tr({name:"shlink/settings",initialState:tke,reducers:{setSettings:(e,{payload:t})=>pb(e,t)}}),{setSettings:ike}=nke,ake=rke,oke=({settings:e,setSettings:t})=>v.jsx(Ad,{children:v.jsx(tse,{settings:e,updateSettings:t,defaultShortUrlsListOrdering:hq})}),ske=(e,t)=>{e.serviceFactory("Settings",()=>oke),e.decorator("Settings",V0),e.decorator("Settings",t(["settings"],["setSettings","resetSelectedServer"])),e.serviceFactory("setSettings",()=>ike)};var OO,Z8;function lke(){return Z8||(Z8=1,OO=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(n,i,a){r.o(n,i)||Object.defineProperty(n,i,{enumerable:!0,get:a})},r.r=function(n){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,i){if(1&i&&(n=r(n)),8&i||4&i&&typeof n=="object"&&n&&n.__esModule)return n;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:n}),2&i&&typeof n!="string")for(var o in n)r.d(a,o,(function(s){return n[s]}).bind(null,o));return a},r.n=function(n){var i=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(i,"a",i),i},r.o=function(n,i){return Object.prototype.hasOwnProperty.call(n,i)},r.p="",r(r.s=32)}([function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(r=window)}e.exports=r},function(e,t,r){var n=r(6),i=Object.keys||function(b){var w=[];for(var x in b)w.push(x);return w};e.exports=p;var a=r(5);a.inherits=r(2);var o=r(23),s=r(14);a.inherits(p,o);for(var c=i(s.prototype),l=0;l diff --git a/feature/revealable-api-key/index.html b/feature/revealable-api-key/index.html index f0850edd..22c5e4f2 100644 --- a/feature/revealable-api-key/index.html +++ b/feature/revealable-api-key/index.html @@ -79,7 +79,7 @@ Shlink — The URL shortener - + diff --git a/feature/revealable-api-key/service-worker.js b/feature/revealable-api-key/service-worker.js index 467b68b3..9297a950 100644 --- a/feature/revealable-api-key/service-worker.js +++ b/feature/revealable-api-key/service-worker.js @@ -1,2 +1,2 @@ try{self["workbox:core:7.2.0"]&&_()}catch{}const G=(s,...e)=>{let t=s;return e.length>0&&(t+=` :: ${JSON.stringify(e)}`),t},Q=G;class l extends Error{constructor(e,t){const n=Q(e,t);super(n),this.name=e,this.details=t}}const j=new Set;function z(s){j.add(s)}const d={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:typeof registration<"u"?registration.scope:""},E=s=>[d.prefix,s,d.suffix].filter(e=>e&&e.length>0).join("-"),J=s=>{for(const e of Object.keys(d))s(e)},x={updateDetails:s=>{J(e=>{typeof s[e]=="string"&&(d[e]=s[e])})},getGoogleAnalyticsName:s=>s||E(d.googleAnalytics),getPrecacheName:s=>s||E(d.precache),getPrefix:()=>d.prefix,getRuntimeName:s=>s||E(d.runtime),getSuffix:()=>d.suffix};function K(s,e){const t=new URL(s);for(const n of e)t.searchParams.delete(n);return t.href}async function X(s,e,t,n){const a=K(e.url,t);if(e.url===a)return s.match(e,n);const r=Object.assign(Object.assign({},n),{ignoreSearch:!0}),i=await s.keys(e,r);for(const c of i){const o=K(c.url,t);if(a===o)return s.match(c,n)}}let m;function Y(){if(m===void 0){const s=new Response("");if("body"in s)try{new Response(s.body),m=!0}catch{m=!1}m=!1}return m}function q(s){s.then(()=>{})}class Z{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}async function ee(){for(const s of j)await s()}const te=s=>new URL(String(s),location.href).href.replace(new RegExp(`^${location.origin}`),"");function se(s){return new Promise(e=>setTimeout(e,s))}function A(s,e){const t=e();return s.waitUntil(t),t}async function ne(s,e){let t=null;if(s.url&&(t=new URL(s.url).origin),t!==self.location.origin)throw new l("cross-origin-copy-response",{origin:t});const n=s.clone(),r={headers:new Headers(n.headers),status:n.status,statusText:n.statusText},i=Y()?n.body:await n.blob();return new Response(i,r)}function ae(){self.addEventListener("activate",()=>self.clients.claim())}const re=(s,e)=>e.some(t=>s instanceof t);let O,S;function ie(){return O||(O=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ce(){return S||(S=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const F=new WeakMap,k=new WeakMap,H=new WeakMap,D=new WeakMap,I=new WeakMap;function oe(s){const e=new Promise((t,n)=>{const a=()=>{s.removeEventListener("success",r),s.removeEventListener("error",i)},r=()=>{t(f(s.result)),a()},i=()=>{n(s.error),a()};s.addEventListener("success",r),s.addEventListener("error",i)});return e.then(t=>{t instanceof IDBCursor&&F.set(t,s)}).catch(()=>{}),I.set(e,s),e}function he(s){if(k.has(s))return;const e=new Promise((t,n)=>{const a=()=>{s.removeEventListener("complete",r),s.removeEventListener("error",i),s.removeEventListener("abort",i)},r=()=>{t(),a()},i=()=>{n(s.error||new DOMException("AbortError","AbortError")),a()};s.addEventListener("complete",r),s.addEventListener("error",i),s.addEventListener("abort",i)});k.set(s,e)}let P={get(s,e,t){if(s instanceof IDBTransaction){if(e==="done")return k.get(s);if(e==="objectStoreNames")return s.objectStoreNames||H.get(s);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return f(s[e])},set(s,e,t){return s[e]=t,!0},has(s,e){return s instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in s}};function le(s){P=s(P)}function ue(s){return s===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const n=s.call(L(this),e,...t);return H.set(n,e.sort?e.sort():[e]),f(n)}:ce().includes(s)?function(...e){return s.apply(L(this),e),f(F.get(this))}:function(...e){return f(s.apply(L(this),e))}}function de(s){return typeof s=="function"?ue(s):(s instanceof IDBTransaction&&he(s),re(s,ie())?new Proxy(s,P):s)}function f(s){if(s instanceof IDBRequest)return oe(s);if(D.has(s))return D.get(s);const e=de(s);return e!==s&&(D.set(s,e),I.set(e,s)),e}const L=s=>I.get(s);function fe(s,e,{blocked:t,upgrade:n,blocking:a,terminated:r}={}){const i=indexedDB.open(s,e),c=f(i);return n&&i.addEventListener("upgradeneeded",o=>{n(f(i.result),o.oldVersion,o.newVersion,f(i.transaction),o)}),t&&i.addEventListener("blocked",o=>t(o.oldVersion,o.newVersion,o)),c.then(o=>{r&&o.addEventListener("close",()=>r()),a&&o.addEventListener("versionchange",h=>a(h.oldVersion,h.newVersion,h))}).catch(()=>{}),c}function pe(s,{blocked:e}={}){const t=indexedDB.deleteDatabase(s);return e&&t.addEventListener("blocked",n=>e(n.oldVersion,n)),f(t).then(()=>{})}const ge=["get","getKey","getAll","getAllKeys","count"],me=["put","add","delete","clear"],U=new Map;function W(s,e){if(!(s instanceof IDBDatabase&&!(e in s)&&typeof e=="string"))return;if(U.get(e))return U.get(e);const t=e.replace(/FromIndex$/,""),n=e!==t,a=me.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(a||ge.includes(t)))return;const r=async function(i,...c){const o=this.transaction(i,a?"readwrite":"readonly");let h=o.store;return n&&(h=h.index(c.shift())),(await Promise.all([h[t](...c),a&&o.done]))[0]};return U.set(e,r),r}le(s=>({...s,get:(e,t,n)=>W(e,t)||s.get(e,t,n),has:(e,t)=>!!W(e,t)||s.has(e,t)}));try{self["workbox:expiration:7.2.0"]&&_()}catch{}const ye="workbox-expiration",y="cache-entries",B=s=>{const e=new URL(s,location.href);return e.hash="",e.href};class we{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(y,{keyPath:"id"});t.createIndex("cacheName","cacheName",{unique:!1}),t.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&pe(this._cacheName)}async setTimestamp(e,t){e=B(e);const n={url:e,timestamp:t,cacheName:this._cacheName,id:this._getId(e)},r=(await this.getDb()).transaction(y,"readwrite",{durability:"relaxed"});await r.store.put(n),await r.done}async getTimestamp(e){const n=await(await this.getDb()).get(y,this._getId(e));return n==null?void 0:n.timestamp}async expireEntries(e,t){const n=await this.getDb();let a=await n.transaction(y).store.index("timestamp").openCursor(null,"prev");const r=[];let i=0;for(;a;){const o=a.value;o.cacheName===this._cacheName&&(e&&o.timestamp=t?r.push(a.value):i++),a=await a.continue()}const c=[];for(const o of r)await n.delete(y,o.id),c.push(o.url);return c}_getId(e){return this._cacheName+"|"+B(e)}async getDb(){return this._db||(this._db=await fe(ye,1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db}}class _e{constructor(e,t={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=t.maxEntries,this._maxAgeSeconds=t.maxAgeSeconds,this._matchOptions=t.matchOptions,this._cacheName=e,this._timestampModel=new we(e)}async expireEntries(){if(this._isRunning){this._rerunRequested=!0;return}this._isRunning=!0;const e=this._maxAgeSeconds?Date.now()-this._maxAgeSeconds*1e3:0,t=await this._timestampModel.expireEntries(e,this._maxEntries),n=await self.caches.open(this._cacheName);for(const a of t)await n.delete(a,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,q(this.expireEntries()))}async updateTimestamp(e){await this._timestampModel.setTimestamp(e,Date.now())}async isURLExpired(e){if(this._maxAgeSeconds){const t=await this._timestampModel.getTimestamp(e),n=Date.now()-this._maxAgeSeconds*1e3;return t!==void 0?t{if(!r)return null;const i=this._isResponseDateFresh(r),c=this._getCacheExpiration(a);q(c.expireEntries());const o=c.updateTimestamp(n.url);if(t)try{t.waitUntil(o)}catch{}return i?r:null},this.cacheDidUpdate=async({cacheName:t,request:n})=>{const a=this._getCacheExpiration(t);await a.updateTimestamp(n.url),await a.expireEntries()},this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&z(()=>this.deleteCacheAndMetadata())}_getCacheExpiration(e){if(e===x.getRuntimeName())throw new l("expire-custom-caches-only");let t=this._cacheExpirations.get(e);return t||(t=new _e(e,this._config),this._cacheExpirations.set(e,t)),t}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;const t=this._getDateHeaderTimestamp(e);if(t===null)return!0;const n=Date.now();return t>=n-this._maxAgeSeconds*1e3}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;const t=e.headers.get("date"),a=new Date(t).getTime();return isNaN(a)?null:a}async deleteCacheAndMetadata(){for(const[e,t]of this._cacheExpirations)await self.caches.delete(e),await t.delete();this._cacheExpirations=new Map}}try{self["workbox:precaching:7.2.0"]&&_()}catch{}const be="__WB_REVISION__";function Ce(s){if(!s)throw new l("add-to-cache-list-unexpected-type",{entry:s});if(typeof s=="string"){const r=new URL(s,location.href);return{cacheKey:r.href,url:r.href}}const{revision:e,url:t}=s;if(!t)throw new l("add-to-cache-list-unexpected-type",{entry:s});if(!e){const r=new URL(t,location.href);return{cacheKey:r.href,url:r.href}}const n=new URL(t,location.href),a=new URL(t,location.href);return n.searchParams.set(be,e),{cacheKey:n.href,url:a.href}}class xe{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:e,state:t})=>{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:n})=>{if(e.type==="install"&&t&&t.originalRequest&&t.originalRequest instanceof Request){const a=t.originalRequest.url;n?this.notUpdatedURLs.push(a):this.updatedURLs.push(a)}return n}}}class Ee{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:t,params:n})=>{const a=(n==null?void 0:n.cacheKey)||this._precacheController.getCacheKeyForURL(t.url);return a?new Request(a,{headers:t.headers}):t},this._precacheController=e}}try{self["workbox:strategies:7.2.0"]&&_()}catch{}function b(s){return typeof s=="string"?new Request(s):s}class De{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new Z,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(const n of this._plugins)this._pluginStateMap.set(n,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){const{event:t}=this;let n=b(e);if(n.mode==="navigate"&&t instanceof FetchEvent&&t.preloadResponse){const i=await t.preloadResponse;if(i)return i}const a=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const i of this.iterateCallbacks("requestWillFetch"))n=await i({request:n.clone(),event:t})}catch(i){if(i instanceof Error)throw new l("plugin-error-request-will-fetch",{thrownErrorMessage:i.message})}const r=n.clone();try{let i;i=await fetch(n,n.mode==="navigate"?void 0:this._strategy.fetchOptions);for(const c of this.iterateCallbacks("fetchDidSucceed"))i=await c({event:t,request:r,response:i});return i}catch(i){throw a&&await this.runCallbacks("fetchDidFail",{error:i,event:t,originalRequest:a.clone(),request:r.clone()}),i}}async fetchAndCachePut(e){const t=await this.fetch(e),n=t.clone();return this.waitUntil(this.cachePut(e,n)),t}async cacheMatch(e){const t=b(e);let n;const{cacheName:a,matchOptions:r}=this._strategy,i=await this.getCacheKey(t,"read"),c=Object.assign(Object.assign({},r),{cacheName:a});n=await caches.match(i,c);for(const o of this.iterateCallbacks("cachedResponseWillBeUsed"))n=await o({cacheName:a,matchOptions:r,cachedResponse:n,request:i,event:this.event})||void 0;return n}async cachePut(e,t){const n=b(e);await se(0);const a=await this.getCacheKey(n,"write");if(!t)throw new l("cache-put-with-no-response",{url:te(a.url)});const r=await this._ensureResponseSafeToCache(t);if(!r)return!1;const{cacheName:i,matchOptions:c}=this._strategy,o=await self.caches.open(i),h=this.hasCallback("cacheDidUpdate"),g=h?await X(o,a.clone(),["__WB_REVISION__"],c):null;try{await o.put(a,h?r.clone():r)}catch(u){if(u instanceof Error)throw u.name==="QuotaExceededError"&&await ee(),u}for(const u of this.iterateCallbacks("cacheDidUpdate"))await u({cacheName:i,oldResponse:g,newResponse:r.clone(),request:a,event:this.event});return!0}async getCacheKey(e,t){const n=`${e.url} | ${t}`;if(!this._cacheKeys[n]){let a=e;for(const r of this.iterateCallbacks("cacheKeyWillBeUsed"))a=b(await r({mode:t,request:a,event:this.event,params:this.params}));this._cacheKeys[n]=a}return this._cacheKeys[n]}hasCallback(e){for(const t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(const n of this.iterateCallbacks(e))await n(t)}*iterateCallbacks(e){for(const t of this._strategy.plugins)if(typeof t[e]=="function"){const n=this._pluginStateMap.get(t);yield r=>{const i=Object.assign(Object.assign({},r),{state:n});return t[e](i)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){let e;for(;e=this._extendLifetimePromises.shift();)await e}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,n=!1;for(const a of this.iterateCallbacks("cacheWillUpdate"))if(t=await a({request:this.request,response:t,event:this.event})||void 0,n=!0,!t)break;return n||t&&t.status!==200&&(t=void 0),t}}class V{constructor(e={}){this.cacheName=x.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){const[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});const t=e.event,n=typeof e.request=="string"?new Request(e.request):e.request,a="params"in e?e.params:void 0,r=new De(this,{event:t,request:n,params:a}),i=this._getResponse(r,n,t),c=this._awaitComplete(i,r,n,t);return[i,c]}async _getResponse(e,t,n){await e.runCallbacks("handlerWillStart",{event:n,request:t});let a;try{if(a=await this._handle(t,e),!a||a.type==="error")throw new l("no-response",{url:t.url})}catch(r){if(r instanceof Error){for(const i of e.iterateCallbacks("handlerDidError"))if(a=await i({error:r,event:n,request:t}),a)break}if(!a)throw r}for(const r of e.iterateCallbacks("handlerWillRespond"))a=await r({event:n,request:t,response:a});return a}async _awaitComplete(e,t,n,a){let r,i;try{r=await e}catch{}try{await t.runCallbacks("handlerDidRespond",{event:a,request:n,response:r}),await t.doneWaiting()}catch(c){c instanceof Error&&(i=c)}if(await t.runCallbacks("handlerDidComplete",{event:a,request:n,response:r,error:i}),t.destroy(),i)throw i}}class p extends V{constructor(e={}){e.cacheName=x.getPrecacheName(e.cacheName),super(e),this._fallbackToNetwork=e.fallbackToNetwork!==!1,this.plugins.push(p.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){const n=await t.cacheMatch(e);return n||(t.event&&t.event.type==="install"?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,t){let n;const a=t.params||{};if(this._fallbackToNetwork){const r=a.integrity,i=e.integrity,c=!i||i===r;n=await t.fetch(new Request(e,{integrity:e.mode!=="no-cors"?i||r:void 0})),r&&c&&e.mode!=="no-cors"&&(this._useDefaultCacheabilityPluginIfNeeded(),await t.cachePut(e,n.clone()))}else throw new l("missing-precache-entry",{cacheName:this.cacheName,url:e.url});return n}async _handleInstall(e,t){this._useDefaultCacheabilityPluginIfNeeded();const n=await t.fetch(e);if(!await t.cachePut(e,n.clone()))throw new l("bad-precaching-response",{url:e.url,status:n.status});return n}_useDefaultCacheabilityPluginIfNeeded(){let e=null,t=0;for(const[n,a]of this.plugins.entries())a!==p.copyRedirectedCacheableResponsesPlugin&&(a===p.defaultPrecacheCacheabilityPlugin&&(e=n),a.cacheWillUpdate&&t++);t===0?this.plugins.push(p.defaultPrecacheCacheabilityPlugin):t>1&&e!==null&&this.plugins.splice(e,1)}}p.defaultPrecacheCacheabilityPlugin={async cacheWillUpdate({response:s}){return!s||s.status>=400?null:s}};p.copyRedirectedCacheableResponsesPlugin={async cacheWillUpdate({response:s}){return s.redirected?await ne(s):s}};class Le{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:n=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new p({cacheName:x.getPrecacheName(e),plugins:[...t,new Ee({precacheController:this})],fallbackToNetwork:n}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this._installAndActiveListenersAdded=!0)}addToCacheList(e){const t=[];for(const n of e){typeof n=="string"?t.push(n):n&&n.revision===void 0&&t.push(n.url);const{cacheKey:a,url:r}=Ce(n),i=typeof n!="string"&&n.revision?"reload":"default";if(this._urlsToCacheKeys.has(r)&&this._urlsToCacheKeys.get(r)!==a)throw new l("add-to-cache-list-conflicting-entries",{firstEntry:this._urlsToCacheKeys.get(r),secondEntry:a});if(typeof n!="string"&&n.integrity){if(this._cacheKeysToIntegrities.has(a)&&this._cacheKeysToIntegrities.get(a)!==n.integrity)throw new l("add-to-cache-list-conflicting-integrities",{url:r});this._cacheKeysToIntegrities.set(a,n.integrity)}if(this._urlsToCacheKeys.set(r,a),this._urlsToCacheModes.set(r,i),t.length>0){const c=`Workbox is precaching URLs without revision info: ${t.join(", ")} -This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return A(e,async()=>{const t=new xe;this.strategy.plugins.push(t);for(const[r,i]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(i),o=this._urlsToCacheModes.get(r),h=new Request(r,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:i},request:h,event:e}))}const{updatedURLs:n,notUpdatedURLs:a}=t;return{updatedURLs:n,notUpdatedURLs:a}})}activate(e){return A(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),n=await t.keys(),a=new Set(this._urlsToCacheKeys.values()),r=[];for(const i of n)a.has(i.url)||(await t.delete(i),r.push(i.url));return{deletedURLs:r}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,n=this.getCacheKeyForURL(t);if(n)return(await self.caches.open(this.strategy.cacheName)).match(n)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new l("non-precached-url",{url:e});return n=>(n.request=new Request(e),n.params=Object.assign({cacheKey:t},n.params),this.strategy.handle(n))}}let T;const v=()=>(T||(T=new Le),T);try{self["workbox:routing:7.2.0"]&&_()}catch{}const $="GET",C=s=>s&&typeof s=="object"?s:{handle:s};class R{constructor(e,t,n=$){this.handler=C(t),this.match=e,this.method=n}setCatchHandler(e){this.catchHandler=C(e)}}class Ue extends R{constructor(e,t,n){const a=({url:r})=>{const i=e.exec(r.href);if(i&&!(r.origin!==location.origin&&i.index!==0))return i.slice(1)};super(a,t,n)}}class Te{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",e=>{const{request:t}=e,n=this.handleRequest({request:t,event:e});n&&e.respondWith(n)})}addCacheListener(){self.addEventListener("message",e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,n=Promise.all(t.urlsToCache.map(a=>{typeof a=="string"&&(a=[a]);const r=new Request(...a);return this.handleRequest({request:r,event:e})}));e.waitUntil(n),e.ports&&e.ports[0]&&n.then(()=>e.ports[0].postMessage(!0))}})}handleRequest({request:e,event:t}){const n=new URL(e.url,location.href);if(!n.protocol.startsWith("http"))return;const a=n.origin===location.origin,{params:r,route:i}=this.findMatchingRoute({event:t,request:e,sameOrigin:a,url:n});let c=i&&i.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let h;try{h=c.handle({url:n,request:e,event:t,params:r})}catch(u){h=Promise.reject(u)}const g=i&&i.catchHandler;return h instanceof Promise&&(this._catchHandler||g)&&(h=h.catch(async u=>{if(g)try{return await g.handle({url:n,request:e,event:t,params:r})}catch(N){N instanceof Error&&(u=N)}if(this._catchHandler)return this._catchHandler.handle({url:n,request:e,event:t});throw u})),h}findMatchingRoute({url:e,sameOrigin:t,request:n,event:a}){const r=this._routes.get(n.method)||[];for(const i of r){let c;const o=i.match({url:e,sameOrigin:t,request:n,event:a});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:i,params:c}}return{}}setDefaultHandler(e,t=$){this._defaultHandlerMap.set(t,C(e))}setCatchHandler(e){this._catchHandler=C(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new l("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new l("unregister-route-route-not-registered")}}let w;const ke=()=>(w||(w=new Te,w.addFetchListener(),w.addCacheListener()),w);function M(s,e,t){let n;if(typeof s=="string"){const r=new URL(s,location.href),i=({url:c})=>c.href===r.href;n=new R(i,e,t)}else if(s instanceof RegExp)n=new Ue(s,e,t);else if(typeof s=="function")n=new R(s,e,t);else if(s instanceof R)n=s;else throw new l("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return ke().registerRoute(n),n}function Pe(s,e=[]){for(const t of[...s.searchParams.keys()])e.some(n=>n.test(t))&&s.searchParams.delete(t);return s}function*Ie(s,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:n=!0,urlManipulation:a}={}){const r=new URL(s,location.href);r.hash="",yield r.href;const i=Pe(r,e);if(yield i.href,t&&i.pathname.endsWith("/")){const c=new URL(i.href);c.pathname+=t,yield c.href}if(n){const c=new URL(i.href);c.pathname+=".html",yield c.href}if(a){const c=a({url:r});for(const o of c)yield o.href}}class ve extends R{constructor(e,t){const n=({request:a})=>{const r=e.getURLsToCacheKeys();for(const i of Ie(a.url,t)){const c=r.get(i);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(n,e.strategy)}}function Me(s){const e=v(),t=new ve(e,s);M(t)}function Ne(s){return v().createHandlerBoundToURL(s)}function Ke(s){v().precache(s)}function Ae(s,e){Ke(s),Me(e)}const Oe={cacheWillUpdate:async({response:s})=>s.status===200||s.status===0?s:null};class Se extends V{constructor(e={}){super(e),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(Oe)}async _handle(e,t){const n=t.fetchAndCachePut(e).catch(()=>{});t.waitUntil(n);let a=await t.cacheMatch(e),r;if(!a)try{a=await n}catch(i){i instanceof Error&&(r=i)}if(!a)throw new l("no-response",{url:e.url,error:r});return a}}const We="/shlink-web-client/feature/revealable-api-key",Be={homepage:We};ae();Ae([{"revision":null,"url":"assets/index-C1TMImW3.js"},{"revision":null,"url":"assets/index-Dp6UzxzK.css"},{"revision":"64e2e6ff8737573ca9982335a97a1bd9","url":"index.html"},{"revision":"583b223ad8e20f05aaa64923d7db2e46","url":"icons/icon-1024x1024.png"},{"revision":"2dff586aaefa4c8d17f4c0bcbdef8b53","url":"icons/icon-114x114.png"},{"revision":"8e28257a68ef1c55bc68bfff80e1a310","url":"icons/icon-120x120.png"},{"revision":"0059b6f0c97fa871a5c29643b2857585","url":"icons/icon-128x128.png"},{"revision":"41478c2456281f61e54d714718743ecc","url":"icons/icon-144x144.png"},{"revision":"625251910295f33a578ae6d8117711c9","url":"icons/icon-150x150.png"},{"revision":"19b71508b1d05defe32cf16a7d453001","url":"icons/icon-152x152.png"},{"revision":"9d029a32a54ba3084c67acd5d74f8ac4","url":"icons/icon-160x160.png"},{"revision":"6ec104aeaf745f003ecdaef2edddce97","url":"icons/icon-167x167.png"},{"revision":"3e8169a112865ef0d76bba4e2dfd3a89","url":"icons/icon-16x16.png"},{"revision":"871d67907434ed0ddf5d2a6c220e09af","url":"icons/icon-180x180.png"},{"revision":"cee2529402074d73b2135e2ddee25f6b","url":"icons/icon-192x192.png"},{"revision":"85055b452284c0193142936dee7d2cd1","url":"icons/icon-196x196.png"},{"revision":"f471155dd70b99924422dd9dd87ea94d","url":"icons/icon-228x228.png"},{"revision":"20f0b51945ae3c973420e31d6b4d43c1","url":"icons/icon-24x24.png"},{"revision":"4d896c5c7025582605de31fb74f0316b","url":"icons/icon-256x256.png"},{"revision":"d99b49e5bcad41968313c3e132e7c661","url":"icons/icon-310x310.png"},{"revision":"4c9695cfb4cea403c1b66bbb7b4f7420","url":"icons/icon-32x32.png"},{"revision":"f9597636bef677327c3abc0fd1a743c4","url":"icons/icon-384x384.png"},{"revision":"f74edb9cc54ac938c1589876f8da9f21","url":"icons/icon-40x40.png"},{"revision":"52933970fac8498311687de13549b014","url":"icons/icon-48x48.png"},{"revision":"de22c0eb9e08d3576df5cedb568ca56b","url":"icons/icon-512x512.png"},{"revision":"40209a194f29b21882571c77bd2bd906","url":"icons/icon-60x60.png"},{"revision":"c8ba5a8c1da76d74c7bb21827fcf975c","url":"icons/icon-64x64.png"},{"revision":"ae3435baceb494f9c966e2c2c736ea35","url":"icons/icon-72x72.png"},{"revision":"850aa5b026fd1452af6c1ddd9d71850f","url":"icons/icon-76x76.png"},{"revision":"8c62535e6b7a498ece1f6c6ae62ede59","url":"icons/icon-96x96.png"},{"revision":"b12018eccf0fe1588f48a429c8467a3d","url":"manifest.json"}]);const je=new RegExp("/[^/?]+\\.[^/]+$");M(({request:s,url:e})=>!(s.mode!=="navigate"||e.pathname.startsWith("/_")||e.pathname.match(je)),Ne(`${Be.homepage}/index.html`));M(({url:s})=>s.origin===self.location.origin&&s.pathname.endsWith(".png"),new Se({cacheName:"images",plugins:[new Re({maxEntries:50})]}));self.addEventListener("message",s=>{s.data&&s.data.type==="SKIP_WAITING"&&self.skipWaiting()}); +This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return A(e,async()=>{const t=new xe;this.strategy.plugins.push(t);for(const[r,i]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(i),o=this._urlsToCacheModes.get(r),h=new Request(r,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:i},request:h,event:e}))}const{updatedURLs:n,notUpdatedURLs:a}=t;return{updatedURLs:n,notUpdatedURLs:a}})}activate(e){return A(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),n=await t.keys(),a=new Set(this._urlsToCacheKeys.values()),r=[];for(const i of n)a.has(i.url)||(await t.delete(i),r.push(i.url));return{deletedURLs:r}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,n=this.getCacheKeyForURL(t);if(n)return(await self.caches.open(this.strategy.cacheName)).match(n)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new l("non-precached-url",{url:e});return n=>(n.request=new Request(e),n.params=Object.assign({cacheKey:t},n.params),this.strategy.handle(n))}}let T;const v=()=>(T||(T=new Le),T);try{self["workbox:routing:7.2.0"]&&_()}catch{}const $="GET",C=s=>s&&typeof s=="object"?s:{handle:s};class R{constructor(e,t,n=$){this.handler=C(t),this.match=e,this.method=n}setCatchHandler(e){this.catchHandler=C(e)}}class Ue extends R{constructor(e,t,n){const a=({url:r})=>{const i=e.exec(r.href);if(i&&!(r.origin!==location.origin&&i.index!==0))return i.slice(1)};super(a,t,n)}}class Te{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",e=>{const{request:t}=e,n=this.handleRequest({request:t,event:e});n&&e.respondWith(n)})}addCacheListener(){self.addEventListener("message",e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,n=Promise.all(t.urlsToCache.map(a=>{typeof a=="string"&&(a=[a]);const r=new Request(...a);return this.handleRequest({request:r,event:e})}));e.waitUntil(n),e.ports&&e.ports[0]&&n.then(()=>e.ports[0].postMessage(!0))}})}handleRequest({request:e,event:t}){const n=new URL(e.url,location.href);if(!n.protocol.startsWith("http"))return;const a=n.origin===location.origin,{params:r,route:i}=this.findMatchingRoute({event:t,request:e,sameOrigin:a,url:n});let c=i&&i.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let h;try{h=c.handle({url:n,request:e,event:t,params:r})}catch(u){h=Promise.reject(u)}const g=i&&i.catchHandler;return h instanceof Promise&&(this._catchHandler||g)&&(h=h.catch(async u=>{if(g)try{return await g.handle({url:n,request:e,event:t,params:r})}catch(N){N instanceof Error&&(u=N)}if(this._catchHandler)return this._catchHandler.handle({url:n,request:e,event:t});throw u})),h}findMatchingRoute({url:e,sameOrigin:t,request:n,event:a}){const r=this._routes.get(n.method)||[];for(const i of r){let c;const o=i.match({url:e,sameOrigin:t,request:n,event:a});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:i,params:c}}return{}}setDefaultHandler(e,t=$){this._defaultHandlerMap.set(t,C(e))}setCatchHandler(e){this._catchHandler=C(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new l("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new l("unregister-route-route-not-registered")}}let w;const ke=()=>(w||(w=new Te,w.addFetchListener(),w.addCacheListener()),w);function M(s,e,t){let n;if(typeof s=="string"){const r=new URL(s,location.href),i=({url:c})=>c.href===r.href;n=new R(i,e,t)}else if(s instanceof RegExp)n=new Ue(s,e,t);else if(typeof s=="function")n=new R(s,e,t);else if(s instanceof R)n=s;else throw new l("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return ke().registerRoute(n),n}function Pe(s,e=[]){for(const t of[...s.searchParams.keys()])e.some(n=>n.test(t))&&s.searchParams.delete(t);return s}function*Ie(s,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:n=!0,urlManipulation:a}={}){const r=new URL(s,location.href);r.hash="",yield r.href;const i=Pe(r,e);if(yield i.href,t&&i.pathname.endsWith("/")){const c=new URL(i.href);c.pathname+=t,yield c.href}if(n){const c=new URL(i.href);c.pathname+=".html",yield c.href}if(a){const c=a({url:r});for(const o of c)yield o.href}}class ve extends R{constructor(e,t){const n=({request:a})=>{const r=e.getURLsToCacheKeys();for(const i of Ie(a.url,t)){const c=r.get(i);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(n,e.strategy)}}function Me(s){const e=v(),t=new ve(e,s);M(t)}function Ne(s){return v().createHandlerBoundToURL(s)}function Ke(s){v().precache(s)}function Ae(s,e){Ke(s),Me(e)}const Oe={cacheWillUpdate:async({response:s})=>s.status===200||s.status===0?s:null};class Se extends V{constructor(e={}){super(e),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(Oe)}async _handle(e,t){const n=t.fetchAndCachePut(e).catch(()=>{});t.waitUntil(n);let a=await t.cacheMatch(e),r;if(!a)try{a=await n}catch(i){i instanceof Error&&(r=i)}if(!a)throw new l("no-response",{url:e.url,error:r});return a}}const We="/shlink-web-client/feature/revealable-api-key",Be={homepage:We};ae();Ae([{"revision":null,"url":"assets/index-Dp6UzxzK.css"},{"revision":null,"url":"assets/index-DSvpWWmy.js"},{"revision":"e9347ae96498ae51b0da91ae2bea09c5","url":"index.html"},{"revision":"583b223ad8e20f05aaa64923d7db2e46","url":"icons/icon-1024x1024.png"},{"revision":"2dff586aaefa4c8d17f4c0bcbdef8b53","url":"icons/icon-114x114.png"},{"revision":"8e28257a68ef1c55bc68bfff80e1a310","url":"icons/icon-120x120.png"},{"revision":"0059b6f0c97fa871a5c29643b2857585","url":"icons/icon-128x128.png"},{"revision":"41478c2456281f61e54d714718743ecc","url":"icons/icon-144x144.png"},{"revision":"625251910295f33a578ae6d8117711c9","url":"icons/icon-150x150.png"},{"revision":"19b71508b1d05defe32cf16a7d453001","url":"icons/icon-152x152.png"},{"revision":"9d029a32a54ba3084c67acd5d74f8ac4","url":"icons/icon-160x160.png"},{"revision":"6ec104aeaf745f003ecdaef2edddce97","url":"icons/icon-167x167.png"},{"revision":"3e8169a112865ef0d76bba4e2dfd3a89","url":"icons/icon-16x16.png"},{"revision":"871d67907434ed0ddf5d2a6c220e09af","url":"icons/icon-180x180.png"},{"revision":"cee2529402074d73b2135e2ddee25f6b","url":"icons/icon-192x192.png"},{"revision":"85055b452284c0193142936dee7d2cd1","url":"icons/icon-196x196.png"},{"revision":"f471155dd70b99924422dd9dd87ea94d","url":"icons/icon-228x228.png"},{"revision":"20f0b51945ae3c973420e31d6b4d43c1","url":"icons/icon-24x24.png"},{"revision":"4d896c5c7025582605de31fb74f0316b","url":"icons/icon-256x256.png"},{"revision":"d99b49e5bcad41968313c3e132e7c661","url":"icons/icon-310x310.png"},{"revision":"4c9695cfb4cea403c1b66bbb7b4f7420","url":"icons/icon-32x32.png"},{"revision":"f9597636bef677327c3abc0fd1a743c4","url":"icons/icon-384x384.png"},{"revision":"f74edb9cc54ac938c1589876f8da9f21","url":"icons/icon-40x40.png"},{"revision":"52933970fac8498311687de13549b014","url":"icons/icon-48x48.png"},{"revision":"de22c0eb9e08d3576df5cedb568ca56b","url":"icons/icon-512x512.png"},{"revision":"40209a194f29b21882571c77bd2bd906","url":"icons/icon-60x60.png"},{"revision":"c8ba5a8c1da76d74c7bb21827fcf975c","url":"icons/icon-64x64.png"},{"revision":"ae3435baceb494f9c966e2c2c736ea35","url":"icons/icon-72x72.png"},{"revision":"850aa5b026fd1452af6c1ddd9d71850f","url":"icons/icon-76x76.png"},{"revision":"8c62535e6b7a498ece1f6c6ae62ede59","url":"icons/icon-96x96.png"},{"revision":"b12018eccf0fe1588f48a429c8467a3d","url":"manifest.json"}]);const je=new RegExp("/[^/?]+\\.[^/]+$");M(({request:s,url:e})=>!(s.mode!=="navigate"||e.pathname.startsWith("/_")||e.pathname.match(je)),Ne(`${Be.homepage}/index.html`));M(({url:s})=>s.origin===self.location.origin&&s.pathname.endsWith(".png"),new Se({cacheName:"images",plugins:[new Re({maxEntries:50})]}));self.addEventListener("message",s=>{s.data&&s.data.type==="SKIP_WAITING"&&self.skipWaiting()});