PageSourceSearch

https://www.plumb-news.com/assets/useSignupRedirects-BSkdT_4N.js

js plumb-news.com collected 2026-10-02 00:54:51 UTC 5,179 bytes, 5 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8b635798-8117-5151-8907-27bdc9729d0f")}catch(e){}}();
3import{s as e}from"./jsx-runtime-D4ePz0Hl.js";import{t}from"./react-BXH-GOAS.js";import{D as n,M as r,N as i}from"./components-CDo3yjgw.js";import{t as a}from"./useGlobalModals-CJ1k8aJl.js";var o=`bhba`,s=e=>{let[t]=n(),r=t.get(`_bhba`)||void 0;return e||r},c=e(t(),1),l=function(e){return e.SIGNUP_REDIRECTS=`signup_redirects`,e.EMAIL=`email`,e.PODCAST_PLAYBACK=`beehiiv:podcast-playback`,e}({}),u=e=>e.match(/(iPad|iPhone|iPod)/g)!==null,d=(e,t)=>{if(!e.includes(`$slug`))return e;let n=t||(typeof window<`u`?window.location.pathname:``);if(n.startsWith(`/p/`)){let t=n.split(`/p/`)[1]?.split(`?`)[0];if(t)return e.replace(/\$slug/g,t)}return null},f=`signup_flow`,p=()=>{let e=i(),t=r(),{handleOpenModal:n}=a(),[o,s]=(0,c.useState)(),p=o?.steps?.length??0,m=(o?o?.currentIndex+1:0)/p*100,h=o?.steps?.[o?.nextIndex],g=o?.nextIndex===(o?.steps?.length??0),_=()=>{localStorage.removeItem(f)},v=(e,{overwriteExisting:t=!1}={})=>(typeof window>`u`||new URLSearchParams(window.location.search).forEach((n,r)=>{r!==`modal`&&(t||!e.searchParams.has(r))&&e.searchParams.set(r,n)}),e),y=(t,n)=>{setTimeout(()=>{if(u(navigator.userAgent))try{window.location.href=t}catch{window.location.href=t}else n??o?.openExternalLinkInSameTab?window.location.href=t:(window.open(t,`_blank`),e(`/`,{preventScrollReset:!0}))},1e3)},b=n=>{try{let r=n.steps.map(e=>{let n=d(e.url,t.pathname);return n?{...e,url:n}:null}).filter(e=>e!==null);if(r.length===0){e(`/`,{preventScrollReset:!0});return}let i=(()=>{if(typeof window>`u`)return`/`;let e=new URL(window.location.href);return e.searchParams.delete(`modal`),e.toString()})(),a=r;if(n?.redirect_back_to_start===!0&&i)try{a=[...r,{url:i,external:!1,modal_param:null}]}catch(e){console.error(`Error adding redirect back to start step:`,e),a=r}localStorage.setItem(f,JSON.stringify({id:n.id,startedAt:new Date().toISOString(),steps:a,currentIndex:0,nextIndex:1,openExternalLinkInSameTab:n.open_external_link_in_same_tab??!1,redirectBackToStart:n?.redirect_back_to_start??!1,showNavigation:n?.show_navigation??!1,startUrl:i}));try{let t=localStorage.getItem(l.EMAIL),i=t&&JSON.parse(t),a=r[0],o=new URL(a.url);if(i&&o.searchParams.set(`email`,i),v(o),n.subscriptionUuid&&o.searchParams.set(`sid`,n.subscriptionUuid),n.subscriberId&&o.searchParams.set(`subscriber_id`,n.subscriberId),a.external)y(o.href,n.open_external_link_in_same_tab);else{if(o.pathname===`/`&&o.search.includes(`modal`)){e(window.location.pathname+o.search,{preventScrollReset:!0});return}e(o.pathname+o.search,{preventScrollReset:!0})}}catch(t){console.error(`Error navigating to first step:`,t),e(`/`,{preventScrollReset:!0})}}catch(t){console.error(`Error starting signup flow redirects:`,t),e(`/`,{preventScrollReset:!0})}};return(0,c.useEffect)(()=>{try{let e=localStorage?.getItem(f);if(e)try{let t=JSON.parse(e),n=t.startedAt,r=new Date(n).getTime();new Date().getTime()-r>1e3*60*3?_():s(t)}catch(e){console.error(`Error parsing signup flow redirects:`,e),_()}else o&&s(void 0)}catch(e){console.error(`Error in signup flow effect:`,e)}},[t]),(0,c.useEffect)(()=>{try{if(o){let e=o.steps?.[o.currentIndex];if(!e)return;try{let n=new URL(e.url).pathname,r=new URLSearchParams(t.search);(e.modal_param?e.modal_param!==r.get(`modal`):!n.includes(t.pathname)||t.pathname===`/`&&n!==t.pathname)&&(_(),s(void 0))}catch(e){console.error(`Error checking current step:`,e),_(),s(void 0)}}}catch(e){console.error(`Error in signup flow navigation check:`,e)}},[o]),(0,c.useEffect)(()=>{o?.currentIndex===void 0||o?.steps?.length===void 0||(o?.currentIndex||0)>=(o?.steps?.length||0)-1&&_()},[o?.currentIndex,o?.steps?.length]),{currentStep:o?.steps?.[o?.currentIndex],nextStep:h,isInProgress:!!o&&!g,showNavigation:o?.showNavigation??!1,steps:o?.steps||[],progress:Number(m.toFixed(1)),startRedirects:e=>b(e),nextPage:()=>{if(!o)return;let r=o?.steps?.length-1;if(o?.nextIndex>r)_(),e(`/`,{preventScrollReset:!0});else{let r=localStorage.getItem(l.EMAIL),i=r&&JSON.parse(r),a=o?.steps?.[o?.nextIndex];if(a?.external)try{let n=d(a.url,t.pathname)||a.url,r=new URL(n);i&&r.searchParams.set(`email`,i),v(r),y(r.href),_(),o?.openExternalLinkInSameTab||e(`/`,{preventScrollReset:!0})}catch{_(),e(`/`,{preventScrollReset:!0})}else try{let r=d(a.url,t.pathname)||a.url,s=new URL(r);if(i&&s.searchParams.set(`email`,i),v(s),g)_();else{let e={currentIndex:o?.currentIndex+1,nextIndex:o?.nextIndex+1,steps:o?.steps,openExternalLinkInSameTab:o?.openExternalLinkInSameTab,redirectBackToStart:
3o?.redirectBackToStart??!1,showNavigation:o?.showNavigation??!1,startUrl:o?.startUrl??`/`};localStorage.setItem(f,JSON.stringify(e))}a?.modal_param?n(a.modal_param):e(s.pathname+s.search,{preventScrollReset:!0})}catch{_(),e(`/`,{preventScrollReset:!0})}}}}};export{s as i,l as n,o as r,p as t};
4//# sourceMappingURL=useSignupRedirects-BSkdT_4N.js.map
5//# debugId=8b635798-8117-5151-8907-27bdc9729d0f

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.