1import{a0 as R,s as V,x as Z,aN as W,a1 as v,a5 as P,c as u,A as r,bc as ee,bd as te,be as x,X as ae,a7 as oe,bf as o,aO as N,bg as I,a8 as ie,bh as B,z as T}from"#entry";import{O as D,u as se}from"./1fs1yw9t.js";import{u as ne}from"./D166tP5B.js";const ce="Something went wrong.",re="/",ue="/profile",le="/chapter-",pe=i=>i===re?R.Home:i.startsWith(ue)?R.Profile:D.matches(i)?i.includes(le)?R.Reader:R.BookPage:R.Catalog,G=()=>{try{const i=sessionStorage.getItem(x.ReactivationWidgetShownPlacements);return i?JSON.parse(i):[]}catch{return[]}},ve=i=>{try{sessionStorage.setItem(x.ReactivationWidgetShownPlacements,JSON.stringify([...G(),i]))}catch{}};function Pe(){const i=V(),{sendEvent:s}=Z(),{daysLeft:w}=W(),{context:l}=se(),c=v(P.ReactivationTrigger,()=>null),d=v(P.ReactivationSuccessProps,()=>null),m=u(()=>pe(i.path)),S=()=>({number:w.value,referer:window.location.href}),n=t=>({type:t,source:c.value,book_id:l.value.bookId,chapter_id:l.value.currentChapter?.id??null,...S()}),g=()=>({placement:m.value,...S()});return{setTrigger:t=>{c.value=t},captureSuccessProps:()=>{d.value=n(te.Success)},popupShown:t=>s(r.ReactivationPopupShown,n(t)),popupButtonClicked:(t,a)=>s(r.ReactivationPopupButtonClicked,{...n(t),button:a}),successShown:()=>s(r.ReactivationPopupShown,{...d.value}),successButtonClicked:t=>s(r.ReactivationPopupButtonClicked,{...d.value,button:t}),widgetShownOncePerPlacement:()=>{const t=m.value;G().includes(t)||(ve(t),s(r.ReactivationWidgetShown,g()))},widgetButtonClicked:t=>s(r.ReactivationWidgetButtonClicked,{...g(),button:t}),reactivateClicked:t=>s(r.ReactivateSubscriptionClicked,{source:t}),errorShown:t=>s(r.CancelFlowErrorShown,{source:ee.Reactivation,reason:t})}}const de=2,Re=3600*24*60,me="reactivation_request_failed",Se={[B.ReminderPopup]:N.ReactivationPopup,[B.Confirmation]:N.ReactivationConfirmation};function we(){const i=V(),{$subscriptionService:s,$toast:w}=ae(),{reactivationPrompt:l,hasReactivationPrompt:c,clearReactivationPrompt:d}=W(),{loaded:m,fetch:S}=ne(),n=Pe(),g=v(P.AntiSkipVisible,()=>!1),t=oe(ie.ReactivationReminderProgress,{default:()=>null,maxAge:Re}),a=v(P.ReactivationStep,()=>o.None),f=v(P.ReactivationInProgress,()=>!1),C=v(P.ReactivationLastCountedBookPath,()=>null),k=u(()=>{const e=l.value;return e&&t.value?.baseTransactionId===e.base_transaction_id?t.value:null}),E=u(()=>k.value?.bookPageViews??0),h=u(()=>k.value?.isPopupDismissed??!1),K=u(()=>c.value&&a.value===o.ReminderPopup),L=u(()=>c.value&&a.value===o.Confirmation),F=u(()=>a.value===o.Success),M=u(()=>c.value&&h.value),_=e=>{const p=l.value;p&&(t.value={baseTransactionId:p.base_transaction_id,bookPageViews:E.value,isPopupDismissed:h.value,...e})},b=e=>D.matches(e),A=e=>{!b(e)||!c.value||h.value||g.value||a.value===o.None&&E.value>=de&&(n.setTrigger(I.ReaderPageView),a.value=o.ReminderPopup)},H=e=>{!b(e)&&a.value===o.ReminderPopup&&(a.value=o.None)},O=e=>{if(!b(e)){C.value=null;return}!c.value||h.value||C.value===e||(C.value=e,_({bookPageViews:E.value+1}))},U=()=>{T(()=>i.path,e=>{O(e),H(e),A(e)},{immediate:!0})},X=()=>{T(l,(e,p)=>{e&&!p&&(O(i.path),A(i.path)),!e&&a.value!==o.Success&&(a.value=o.None)})},J=()=>{U(),X()},$=()=>{a.value=o.None,_({isPopupDismissed:!0})},q=()=>{n.setTrigger(I.StickyWidget),a.value=o.Confirmation},z=()=>{a.value=o.None},Q=()=>{a.value=o.None},y=()=>{d(),t.value=null,C.value=null,a.value=o.None},j=e=>{n.errorShown(e instanceof Error?e.message:me),w.warning(ce)};return{isReminderPopupVisible:K,isConfirmationPopupVisible:L,isSuccessPopupVisible:F,isStickyWidgetVisible:M,isReactivating:f,initReactivationReminder:J,dismissReminderPopup:$,openConfirmationPopup:q,closeConfirmationPopup:z,closeSuccessPopup:Q,reactivateSubscription:async e=>{const p=l.value;if(!(!p||f.value)){n.reactivateClicked(Se[e]),f.value=!0;try{await s.reactivate(p.base_transaction_id,e),n.captureSuccessProps(),y(),a.value=o.Success,m.value&&S()}catch(Y){j(Y)}finally{f.value=!1}}},resetReactivationReminder:y}}export{Pe as a,we as u};
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.