1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.__assetsPath("unified-ftp-detection-modal-i4p1by9d.js"),window.__assetsPath("use-service-du0qnyad.js"),window.__assetsPath("decorate-enfn96bc.js"),window.__assetsPath("rolldown-runtime-d7iuo4nk.js"),window.__assetsPath("preload-helper-nq9ya8gj.js"),window.__assetsPath("theme-init-script-ls3p1kq6.js"),window.__assetsPath("realtimelogging.api-ix6mwkbk.js"),window.__assetsPath("utils-iy375pv8.js"),window.__assetsPath("url-utils-hrx6lzl6.js"),window.__assetsPath("axios-lod6h7d2.js"),window.__assetsPath("datetime-hs2rtlqs.js"),window.__assetsPath("esm-doitckdw.js"),window.__assetsPath("vendor-react-g7dyc9sh.js"),window.__assetsPath("noop-ek2zzu4b.js"),window.__assetsPath("mobx.esm-f0vwoq6j.js"),window.__assetsPath("breakthrough-ftp-result-step-ltffauxk.js"),window.__assetsPath("container-with-confetti-hocmsu0v.js"),window.__assetsPath("vendor-lottie-bwjylx17.js"),window.__assetsPath("theme-styles-nm1jf25a.js"),window.__assetsPath("localization-e0yedzfc.js"),window.__assetsPath("use-t-j7erhf80.js"),window.__assetsPath("global-i7hkuitp.js"),window.__assetsPath("use-tracked-actions-ioprhw4k.js"),window.__assetsPath("service-hdvu6lax.js"),window.__assetsPath("chunk-ykonyawf-d9op6wi5.js"),window.__assetsPath("unified-ftp-detection-modal-loading-bi0k34dh.js"),window.__assetsPath("modal-bh7z57np.js"),window.__assetsPath("document-scroll-lock-kobamyl2.js"),window.__assetsPath("escape-u05nbg91.js"),window.__assetsPath("system-info-provider-bhyzh2oo.js"),window.__assetsPath("ai-ftp-detection.service-c91qxy48.js"),window.__assetsPath("decorate-param-hlx7gcuv.js"),window.__assetsPath("calendar-mutation-manager-pce3tekv.js"),window.__assetsPath("external-workout-provider-type-dg9puggf.js"),window.__assetsPath("common-f5hqgq8n.js"),window.__assetsPath("intensity-rating-lxanp3ir.js"),window.__assetsPath("tr-enums-mkpjjyqc.js"),window.__assetsPath("utils-abizfegz.js"),window.__assetsPath("utils-wdzjab4x.js"),window.__assetsPath("use-member-roles-n25t7jex.js"),window.__assetsPath("types-h917iux8.js"),window.__assetsPath("known-workout-ids-ew5otc3j.js"),window.__assetsPath("array-nopqwx42.js"),window.__assetsPath("math-m6aq0gyl.js"),window.__assetsPath("race-priority-iy8zkzeu.js"),window.__assetsPath("athlete-data-gkwl66jd.js"),window.__assetsPath("calendar-entity-collection-dyog0se6.js"),window.__assetsPath("calendar.api-gbjkiw11.js"),window.__assetsPath("health-summary.api-joytml7g.js"),window.__assetsPath("parse-iso-h709tymn.js"),window.__assetsPath("registry-dk1379p6.js"),window.__assetsPath("format-duration-kfe23uy3.js"),window.__assetsPath("weight-bn89u6xi.js"),window.__assetsPath("service-nnvfru1g.js"),window.__assetsPath("week-day-hejrvytq.js"),window.__assetsPath("week-day-kr26j8ds.js"),window.__assetsPath("to-finite-jy4ui09m.js"),window.__assetsPath("member-it15ycm9.js"),window.__assetsPath("consent-jyhz8trv.js"),window.__assetsPath("memberinfo.api-elihyac4.js"),window.__assetsPath("membersettings.api-jun41fnn.js"),window.__assetsPath("_define-property-gko8tqyo.js"),window.__assetsPath("async-mh6fav7f.js"),window.__assetsPath("message-bus-message-type-ocn4whfn.js"),window.__assetsPath("aiftpdetection.api-dwmfwafb.js"),window.__assetsPath("throw-error-co84y1se.js"),window.__assetsPath("plan-builder-amn1r6ku.js"),window.__assetsPath("flush-forward-state-manager-d189gube.js"),window.__assetsPath("shared-worker-messages-n5t3o8d2.js"),window.__assetsPath("service-hf25t4r2.js"),window.__assetsPath("v4-b10qahse.js"),window.__assetsPath("admincalendar.api-ms5n69n0.js"),window.__assetsPath("activitiesapi.api-03zdgza0.js"),window.__assetsPath("aiftp.api-ece0h64j.js"),window.__assetsPath("athlete-data-facade-wuoo3qod.js"),window.__assetsPath("location-service-m1uv4y1m.js"),window.__assetsPath("username-path-normalizer-ilyl92qz.js"),window.__assetsPath("dist-24hutsxa.js"),window.__assetsPath("ai-simulation-onboarding-index-owgtppu6.js"),window.__assetsPath("activity-association-bjvkyy4o.js"),window.__assetsPath("survey.api-cgqobfoq.js"),window.__assetsPath("use-ai-ftp-detection-service-ow9d7y8q.js"),window.__assetsPath("percentage-change-j4hfplgm.js"),window.__assetsPath("chunk-ylhfqmzr-pexr53q0.js"),window.__assetsPath("workout-card-idqjfqv4.js"),window.__assetsPath("shared-bh8fy55y.js"),window.__assetsPath("role-guard-bjjvgpqe.js"),window.__assetsPath("mobxreact.esm-fm260xcp.js"),window.__assetsPath("chunk-26-qb22-gs-enscfen1.js"),window.__assetsPath("chunk-3-wtd2-z4-b-kjyzuueb.js"),window.__assetsPath("chunk-a5-jr5-hvw-nniabsf5.js"),window.__assetsPath("chunk-6-kbskmus-o68p7wxm.js"),window.__assetsPath("chunk-75-xj4-vfq-ome3cftn.js"),window.__assetsPath("chunk-sk266-doe-mex93fuk.js"),window.__assetsPath("chunk-foeljpmn-i7k6eu01.js"),window.__assetsPath("chunk-ik536-ckb-nhodsfm4.js"),window.__assetsPath("chunk-jdcx55-th-d4niuz0v.js"),window.__assetsPath("chunk-ku6-nf3-t3-cammu3j5.js"),window.__assetsPath("chunk-p5-fpsmua-tzqbjr8m.js"),window.__assetsPath("chunk-qr2-ffcmf-hdknbxeu.js"),window.__assetsPath("chunk-ro6-zkvmz-hf2drgrl.js"),window.__assetsPath("ride-sync-brw1a63c.js"),window.__assetsPath("workout-card-image-euiv70nq.js"),window.__assetsPath("open-external-url-provider-bacvp3jy.js"),window.__assetsPath("animated-optimize-icon-evhntdn5.js"),window.__assetsPath("chunk-le25-cjyf-3j0wklxh.js"),window.__assetsPath("unique-id-kai83rao.js"),window.__assetsPath("ai-simulation-announcement-modal-ny6a5hp4.js"),window.__assetsPath("use-accessibility-announcement-service-eihtv9q5.js"),window.__assetsPath("accessibility-announcement.service-ja5spgho.js"),window.__assetsPath("beta-badge-idg7njmo.js"),window.__assetsPath("components-cnruh153.js"),window.__assetsPath("use-date-time-service-h4uetm6i.js"),window.__assetsPath("core-dkbwdx2s.js"),window.__assetsPath("use-localization-service-kjro5jtq.js"),window.__assetsPath("localization.service-on7zpu6u.js"),window.__assetsPath("use-member-service-icud9psv.js"),window.__assetsPath("notify-electron-modal-state-kox6qy9j.js"),window.__assetsPath("use-member-setting-c004qngr.js"),window.__assetsPath("use-member-settings-service-ea14uv5w.js"),window.__assetsPath("health-announcement-bestd3ar.js"),window.__assetsPath("connections-api-br3kl2pr.js"),window.__assetsPath("types-zyz4kmzr.js"),window.__assetsPath("use-can-offer-garmin-health-mx4slo0b.js"),window.__assetsPath("garmin-health-roles-o9pr2228.js"),window.__assetsPath("activitysync.api-mcdbmttw.js"),window.__assetsPath("coros-reconnect-modal-kq4xdemq.
1js"),window.__assetsPath("setting-reconnect-modal-hpebrsqy.js"),window.__assetsPath("provider-reconnect-modal-if1ib3fw.js"),window.__assetsPath("auto-focus-modal-title-nhp4dei5.js"),window.__assetsPath("rouvy-reconnect-modal-coign2fv.js"),window.__assetsPath("zwift-reconnect-modal-b4rmko7o.js"),window.__assetsPath("playground-plan-builder-page-nxj0egp2.js"),window.__assetsPath("custom-aggressiveness-opsbda57.js"),window.__assetsPath("side-panel-l3fp39in.js"),window.__assetsPath("route-paths-etna4hwu.js"),window.__assetsPath("calendar.context-hjr7fdrk.js"),window.__assetsPath("loading-fb0ep7q1.js"),window.__assetsPath("use-athlete-data-oflt5mob.js"),window.__assetsPath("translation-loader-j9y33xzi.js"),window.__assetsPath("use-mutation-manager-cq2saacs.js"),window.__assetsPath("accessibility-rc6thf4g.js"),window.__assetsPath("registration-fn6cjp5t.js"),window.__assetsPath("use-reduce-motion-jaq3cywt.js"),window.__assetsPath("drawer-stack-width-lwvuney4.js"),window.__assetsPath("safe-area-insets-h7ygr196.js"),window.__assetsPath("ui-service-oq4qavgc.js"),window.__assetsPath("observable-m8laumcd.js"),window.__assetsPath("top-banner-stack-d7kg226h.js"),window.__assetsPath("uniq-kqk7dcob.js"),window.__assetsPath("overview-k1shvn5e.js"),window.__assetsPath("default-adaptation-settings-hz9dfv5n.js"),window.__assetsPath("annotation-icon-ir9bybh3.js"),window.__assetsPath("chunk-5-zhideps-ldhnftov.js"),window.__assetsPath("chunk-6-ab6-cf2-u-jqqnp11h.js"),window.__assetsPath("chunk-f3-mml7-yn-ehk86wr4.js"),window.__assetsPath("day-accessible-name-fmiss7l5.js"),window.__assetsPath("container.provider-gjhjirfa.js"),window.__assetsPath("recurring-activity.viewmodel-fomxefax.js"),window.__assetsPath("banner.service-jnfjlod8.js"),window.__assetsPath("legacy-ios-version-orrui6c3.js"),window.__assetsPath("main-menu-state-b2prpvbg.js"),window.__assetsPath("health-slots-view-model-ipi0p4qm.js"),window.__assetsPath("health-connections-view-model-jzecm941.js"),window.__assetsPath("health-import-status-view-model-gfxajudu.js"),window.__assetsPath("live-chat-service-h13tpeyl.js"),window.__assetsPath("season-personal-records.cache-ofaay1o3.js"),window.__assetsPath("season-personal-records.api-jk7u1ae8.js"),window.__assetsPath("registration-bdip9ebx.js"),window.__assetsPath("ride-reconciliation-view-model.viewmodel-kdyli3rw.js"),window.__assetsPath("to-integer-fjh61c2k.js"),window.__assetsPath("member-settings-holsscrn.js"),window.__assetsPath("custom-plan-n1j6y3e6.js"),window.__assetsPath("plan-event-model-8kw7mf3k.js"),window.__assetsPath("validatable-form-gw1w5u0x.js"),window.__assetsPath("stress-estimate-type-nkddap4y.js"),window.__assetsPath("custom-plan-week-template-4zhgzppw.js"),window.__assetsPath("server-types-kwtexebe.js"),window.__assetsPath("date-mscm57iw.js"),window.__assetsPath("tri-util-bcpu49a3.js"),window.__assetsPath("without-c5edl7nb.js"),window.__assetsPath("training-day-selector-fs1iajst.js"),window.__assetsPath("box-shadow-iophtdmd.js"),window.__assetsPath("shared-htsgjmrx.js"),window.__assetsPath("drawer-hvuol7c6.js"),window.__assetsPath("button-wrappers-chxuc3zf.js"),window.__assetsPath("options-pextf5ki.js"),window.__assetsPath("workout-chart-icon-cj192m8j.js"),window.__assetsPath("chunk-hio6-diu6-j2nr2htu.js"),window.__assetsPath("chunk-betfkii3-kv7ogm74.js"),window.__assetsPath("lib-k98cfdag.js"),window.__assetsPath("aria-disabled-button-omaz70fc.js"),window.__assetsPath("days-away-nvqys58b.js"),window.__assetsPath("unrevealed-ai-workout-f1hy3t2q.js"),window.__assetsPath("generic-workout-image-byj1waas.js"),window.__assetsPath("ai-pending-overlay-oocp7e1q.js"),window.__assetsPath("workout-card-data-cc8ezekr.js"),window.__assetsPath("training-metric-labels-fbhut8sz.js"),window.__assetsPath("round-k4brff2i.js"),window.__assetsPath("chunk-munely25-h0h316vo.js"),window.__assetsPath("progression-details-oze3r4if.js"),window.__assetsPath("get-zone-and-level-title-dz8lcq4l.js"),window.__assetsPath("app-theme-provider-h1ail46i.js"),window.__assetsPath("app-container-styles-bk1gpibd.js"),window.__assetsPath("view-scope-icbnujh6.js"),window.__assetsPath("highcharts-a11y-kwdjmz8x.js"),window.__assetsPath("vendor-highcharts-a68y3eon.js"),window.__assetsPath("onboarding.api-h6neo3vb.js"),window.__assetsPath("use-workout-image-ou5fibih.js"),window.__assetsPath("create-workout-image-url-daes0073.js"),window.__assetsPath("sha1-hash-fro56c2w.js"),window.__assetsPath("fetch-outside-image-ek5qf31c.js"),window.__assetsPath("constants-ebmja9ts.js"),window.__assetsPath("plan-builder-utils-ck7emka7.js"),window.__assetsPath("custom-plan-experience-level-ianafq7i.js"),window.__assetsPath("pb-web-view-lwwnrcnx.js"),window.__assetsPath("redlightgreenlight.api-j3488aom.js"),window.__assetsPath("annotationcolor.api-f6nj79ea.js"),window.__assetsPath("calendarevents.api-e7yp2r52.js"),window.__assetsPath("custom-plan-volume-j84ig1qw.js"),window.__assetsPath("classnames-ekiueble.js"),window.__assetsPath("chunk-ehb7-vypc-h8vjx60f.js"),window.__assetsPath("box-button-el2hst4n.js"),window.__assetsPath("minimal-top-nav-che7yxqe.js"),window.__assetsPath("override-product-layout-lqxkwsiz.js"),window.__assetsPath("app-date-selector-n5otnr5q.js"),window.__assetsPath("rlgl-background-fsweriqr.js"),window.__assetsPath("save-message-l5qsxo6a.js"),window.__assetsPath("chunk-lobrjcex-bnoj212y.js"),window.__assetsPath("vendor-react-spring-dhnvt5f3.js"),window.__assetsPath("context-menu-option-k4801edh.js"),window.__assetsPath("context-menu-ksb0hags.js"),window.__assetsPath("race-priority-gf9hi0kc.js"),window.__assetsPath("utils-egakrxm2.js"),window.__assetsPath("chunk-2-ehfjcus-inysu5rl.js"),window.__assetsPath("chunk-2-kg3-c2-ll-niy5n668.js"),window.__assetsPath("chunk-5-bwlgdmr-k4rsl3ao.js"),window.__assetsPath("chunk-5-j2-gtwas-jsxlzwqa.js"),window.__assetsPath("chunk-btz7-q26-e-n54snfn1.js"),window.__assetsPath("chunk-eululb7
15-hqxhdmaq.js"),window.__assetsPath("chunk-jkotgdg4-osu4adtm.js"),window.__assetsPath("chunk-lkgrd4-f7-lnwtb2mh.js"),window.__assetsPath("chunk-lzy33-b4-e-l2tlc9o2.js"),window.__assetsPath("chunk-x4-uclbhy-m2f17l1m.js"),window.__assetsPath("chunk-zpwjg7-ix-d5cwydj7.js"),window.__assetsPath("vendor-d3-mzorl1t6.js"),window.__assetsPath("_base-assign-value-mvwkp0bh.js"),window.__assetsPath("index.esm-ov3fnq5p.js"),window.__assetsPath("subject-cgqbx6ub.js"),window.__assetsPath("playground-plan-builder-page.css-dzbq2vwf.css"),window.__assetsPath("schedule-itp6dbnh.js"),window.__assetsPath("last-visited-date-cjhxuhfr.js"),window.__assetsPath("error-message-k03ftg61.js"),window.__assetsPath("utils-my7xsaed.js"),window.__assetsPath("plan-navigation-header-g9dtvrwt.js"),window.__assetsPath("shared-ir97w568.js"),window.__assetsPath("plans.api-n5pnwxvm.js"),window.__assetsPath("phase-gcpfcucv.js"),window.__assetsPath("plan-category-gzies1g7.js"),window.__assetsPath("toggle-masters-plan-category-y8e76dtt.js"),window.__assetsPath("phases-mh3ro1qn.js"),window.__assetsPath("overview-bj73m8ob.js"),window.__assetsPath("chunk-fd6-vvpho-oec6b5ia.js"),window.__assetsPath("details-g84v6ew4.js"),window.__assetsPath("mixins-c7p4eml5.js")])))=>i.map(i=>d[i]); 2import{i as e,o as t}from"./rolldown-runtime-d7iuo4nk.js";import{d as n,f as r,g as i,t as a}from"./use-service-du0qnyad.js";import"./global-i7hkuitp.js";import{u as o}from"./utils-iy375pv8.js";import{t as s}from"./noop-ek2zzu4b.js";import{$ as c,et as l,rt as u,x as d}from"./athlete-data-gkwl66jd.js";import{l as f,n as p,s as m}from"./calendar.api-gbjkiw11.js";import"./member-it15ycm9.js";import{_ as h,g,l as _,r as ee,y as v}from"./mobx.esm-f0vwoq6j.js";import{a as te,r as ne}from"./vendor-react-g7dyc9sh.js";import{$ as re,Wt as y,Xt as b,mt as ie,qt as ae,xt as oe}from"./esm-doitckdw.js";import{n as x,t as S}from"./decorate-enfn96bc.js";import{t as C}from"./preload-helper-nq9ya8gj.js";import"./core-dkbwdx2s.js";import{c as se,f as ce,m as le,s as ue,u as de}from"./dist-24hutsxa.js";import{n as fe}from"./location-service-m1uv4y1m.js";import{n as pe}from"./system-info-provider-bhyzh2oo.js";import{n as me}from"./notify-electron-modal-state-kox6qy9j.js";import{t as he}from"./report-error-to-rum-d9oawj8z.js";import{t as w}from"./mobxreact.esm-fm260xcp.js";import{t as T}from"./shared-worker-messages-n5t3o8d2.js";import{n as ge,r as E}from"./types-h917iux8.js";import{n as _e,t as D}from"./message-bus-message-type-ocn4whfn.js";import{r as ve}from"./use-t-j7erhf80.js";import"./localization-e0yedzfc.js";import{t as ye}from"./use-member-roles-n25t7jex.js";import{n as O}from"./calendar-entity-collection-dyog0se6.js";import{t as be}from"./decorate-param-hlx7gcuv.js";import{t as xe}from"./v4-b10qahse.js";import{t as Se}from"./ai-simulation-onboarding-index-owgtppu6.js";import{n as Ce}from"./ai-ftp-detection.service-c91qxy48.js";import{t as we}from"./use-ai-ftp-detection-service-ow9d7y8q.js";import{n as Te}from"./unified-ftp-detection-modal-loading-bi0k34dh.js";import{D as Ee}from"./theme-styles-nm1jf25a.js";import{t as k}from"./use-member-setting-c004qngr.js";import"./accessibility-rc6thf4g.js";import{i as De}from"./use-reduce-motion-jaq3cywt.js";import{t as Oe}from"./use-accessibility-announcement-service-eihtv9q5.js";import{t as ke}from"./chunk-fd6-vvpho-oec6b5ia.js";import{a as Ae,i as je,n as Me,r as Ne,t as Pe}from"./shared-l9wk1dmt.js";import{t as Fe}from"./use-toast-notifications-service-h39qm96q.js";import{t as A}from"./route-with-title-m67ifujo.js";import{t as Ie}from"./app-container-styles-bk1gpibd.js";import{n as Le,t as Re}from"./plan-category-gzies1g7.js";import{n as j}from"./plan-route-config-p90v0f46.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function ze(e){let t=this.length,n=Math.trunc(e)||0;return n<0&&(n+=t),n<0||n>=t?void 0:this[n]}function Be(e){typeof Object.getOwnPropertyDescriptor(e,`at`)?.value!=`function`&&Object.defineProperty(e,`at`,{value:ze,writable:!0,enumerable:!1,
2configurable:!0})}Be(Array.prototype),Be(String.prototype);var Ve=class{get env(){return`development`}get appVersion(){return window.trainerRoad.applicationVersion}},M=t(te());function He(){let e=ce(),t=de(),n=a(fe);return(0,M.useEffect)(()=>{n.setNavigator(e)},[e,n]),(0,M.useEffect)(()=>{n.notifyLocationChanged(t)},[t,n]),null}var N=ne(),Ue=(0,M.lazy)(()=>C(()=>import(`./unified-ftp-detection-modal-i4p1by9d.js`).then(e=>({default:e.UnifiedFtpDetectionModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106]),import.meta.url)),We=class extends M.Component{constructor(...e){super(...e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`UnifiedFtpDetectionModal failed to load`,e,t),he(e,{componentStack:t.componentStack,boundary:`ai-ftp-modal-chunk`}),this.props.onError()}componentDidUpdate(e){this.state.hasError&&e.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}render(){return window.vitePreloadError||this.state.hasError?null:this.props.children}},Ge=w(function(){let e=we(),[t,n]=(0,M.useState)(()=>e.isOpen),[r,i]=(0,M.useState)(0),[a,o]=(0,M.useState)(!1),s=e.isOpen,c=(0,M.useCallback)(()=>e.closeModal(),[e]),l=(0,M.useCallback)(()=>{o(!0),e.abortModal()},[e]);return me(`ai-ftp-detection`,s&&!a),(0,M.useEffect)(()=>{if(typeof window>`u`||!e.isBreakthroughTester)return;e.maybeShowDevMockModal();let t=()=>e.maybeShowDevMockModal();return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e,e.isBreakthroughTester]),(0,M.useEffect)(()=>{s&&(n(!0),i(e=>e+1),o(!1))},[s]),!t&&!s?null:(0,N.jsx)(We,{onError:l,resetKey:r,children:(0,N.jsx)(M.Suspense,{fallback:s?(0,N.jsx)(Te,{onClose:c,isDismissible:e.flowType!==Ce.Breakthrough}):null,children:(0,N.jsx)(Ue,{})})})}),Ke=()=>{let{isReactNative:e,isElectron:t}=a(pe),{has:n}=ye(),[r,,i]=k(`hasSeenHealthAnnouncement`);return!e&&!t&&n(ge.HealthDataOperational)&&i&&!r},qe=(0,M.lazy)(()=>C(()=>import(`./ai-simulation-announcement-modal-ny6a5hp4.js`).then(e=>({default:e.AiSimulationAnnouncementModal})),__vite__mapDeps([107,1,2,3,4,5,6,7,8,9,10,11,12,13,14,108,109,21,78,110,26,27,28,84,85,19,20,86,39,40,87,88,89,90,44,91,92,93,94,95,96,97,98,99,100,101,102,111,112,113,53,49,38,54,55,56,114,115,31,36,52,116,29,117,118,119,104,24]),import.meta.url)),Je=(0,M.lazy)(()=>C(()=>import(`./health-announcement-bestd3ar.js`).then(e=>({default:e.HealthAnnouncement})),__vite__mapDeps([120,2,3,7,8,9,10,26,27,28,12,11,18,121,122,123,124,39,1,4,5,6,13,14,40,19,20,21,119,116,125,36,62,87]),import.meta.url)),Ye=e=>{let t=e.toLowerCase();return t.includes(`onboarding`)||t.includes(`plan-builder`)},Xe=()=>typeof navigator<`u`&&!!navigator.webdriver,Ze=e=>{let[t,n]=(0,M.useState)(e);return(0,M.useEffect)(()=>{e&&n(!0)},[e]),t},Qe=w(function(){let{has:e}=ye(),[t,,n]=k(`aiSimulationOnboardingIndex`),r=e(ge.ActiveMember)||e(ge.FreeAccount),i=Ze(r&&n&&t!==Se.Complete);return!r||!i?null:(0,N.jsx)(M.Suspense,{fallback:null,children:(0,N.jsx)(qe,{})})}),$e=w(function(){return Ze(Ke())?(0,N.jsx)(M.Suspense,{fallback:null,children:(0,N.jsx)(Je,{})}):null}),et=w(function(){let{pathname:e}=de();return Ze(!Xe()&&!Ye(e))?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Qe,{}),(0,N.jsx)($e,{})]}):null}),tt=(0,M.lazy)(()=>C(()=>import(`./coros-reconnect-modal-kq4xdemq.js`).then(e=>({default:e.CorosReconnectModal})),__vite__mapDeps([126,127,128,129,11,3,12,10,26,27,28,118,119,116,1,2,4,5,6,7,8,9,13,14,40,19,20,21]),import.meta.url)),nt=()=>{let[e,,t]=k(`corosNeedsReconnect`);return!t||!e?null:(0,N.jsx)(M.Suspense,{fallback:null,children:(0,N.jsx)(tt,{})})},rt=(0,M.lazy)(()=>C(()=>import(`./rouvy-reconnect-modal-coign2fv.js`).then(e=>({default:e.RouvyReconnectModal})),__vite__mapDeps([130,127,128,129,11,3,12,10,26,27,28,118,119,116,1,2,4,5,6,7,8,9,13,14,40,19,20,21]),import.meta.url)),it=()=>{let[e,,t]=k(`rouvyNeedsReconnect`);return!t||!e?null:(0,N.jsx)(M.Suspense,{fallback:null,children:(0,N.jsx)(rt,{})})},at=(0,M.lazy)(()=>C(()=>import(`./zwift-reconnect-modal-b4rmko7o.js`).then(e=>
2({default:e.ZwiftReconnectModal})),__vite__mapDeps([131,127,128,129,11,3,12,10,26,27,28,118,119,116,1,2,4,5,6,7,8,9,13,14,40,19,20,21]),import.meta.url)),ot=()=>{let[e,,t]=k(`zwiftNeedsReconnect`);return!t||!e?null:(0,N.jsx)(M.Suspense,{fallback:null,children:(0,N.jsx)(at,{})})},st=/; (iOS|Android)$/;function ct(e){if(typeof e==`string`)return st.exec(e.trim())?.[1]}function lt(){let e=De(),t=ct(window.tr?.appInfo?.platform)===`iOS`,n=e&&t?`textbox`:void 0;return(0,M.useMemo)(()=>({isScreenReader:e,nativeDateRole:n}),[e,n])}var ut=new Map([[`default`,{background:y.grey3,text:y.white}],[`success`,{background:y.grey3,text:y.white}],[`error`,{background:y.grey3,text:y.white}],[`info`,{background:y.grey3,text:y.white}]]);function dt(){let e=Fe(),t=Oe(),n=(0,M.useRef)(new Set);return(0,M.useEffect)(()=>{let r=n.current,i=new Set;for(let n of e.toasts){if(i.add(n.id),r.has(n.id)||(r.add(n.id),n.type!==`data`))continue;let e=n.data;if(typeof e.message!=`string`)continue;let a=e.message;typeof e.action?.label==`string`&&(a=`${a}. ${e.action.label}.`),t.announce(a,{priority:e.type===`error`?`assertive`:`polite`})}for(let e of r)i.has(e)||r.delete(e)}),(0,N.jsx)(mt,{"data-testid":`toast-stack`,children:e.toasts.map(e=>{if(e.type===`component`){let t=e.data;return(0,N.jsx)(ht,{animate:e.attributes?.animate,children:(0,N.jsx)(t,{...e.attributes})},e.id)}let t=e.data,n=ut.get(t.type),r=t.action?.label,i=typeof r==`string`?r:void 0;return(0,N.jsx)(ht,{animate:e.attributes?.animate,children:(0,N.jsxs)(Me,{id:e.attributes?.testId,colors:n,size:e.attributes?.maxWidth,onClick:t.action?.label?void 0:t.action?.onClick,children:[(0,N.jsxs)(Ae,{children:[t.icon&&(0,N.jsx)(Ne,{"aria-hidden":`true`,children:t.icon}),(0,N.jsx)(je,{children:t.message})]}),t.action?.label&&(0,N.jsx)(Pe,{children:(0,N.jsx)(re,{onClick:t.action.onClick,"aria-label":i,children:t.action.label})})]})},e.id)})})}var ft=w(dt),pt=ae` 3 0% { 4 translate: 0 10vh; 5 } 6 7 100% { 8 translate: 0 0; 9 } 10`,mt=b.div` 11 display: flex; 12 flex-direction: column; 13 align-items: center; 14 gap: 8px; 15 position: fixed; 16 width: 100vw; 17 bottom: 0; 18 left: 0; 19 z-index: 999; 20 pointer-events: none; 21`,ht=b.div` 22 pointer-events: auto; 23 animation: ${({animate:e})=>e?`1s`:`0s`} ${pt}; 24 @media not all and (min-device-width: 375px) and (max-device-width: 812px) and (-webkit-min-device-pixel-ratio: 3) { 25 padding-bottom: 16px; 26 } 27`,gt=b.div.attrs({className:`container`})` 28 ${Ie} 29 padding-top: 120px; 30 height: 100%; 31 display: flex; 32 flex-direction: column; 33 align-items: center; 34 gap: 16px; 35`,_t=b(ie).attrs({level:`large`})``,vt=b.a` 36 ${oe} 37 ${Ee} 38 font-size: 1.4rem; 39 margin-top: 4px; 40`,yt=b.div` 41 display: inline-flex; 42 align-items: center; 43 gap: 4px; 44`,bt=b(ke).attrs({size:14,"aria-hidden":!0})` 45 margin-top: 2px; 46`,xt=(0,M.lazy)(()=>C(()=>import(`./playground-plan-builder-page-nxj0egp2.js`),__vite__mapDeps([132,1,2,3,4,5,6,7,8,9,10,11,12,13,14,133,34,35,19,20,21,36,18,83,87,134,32,31,33,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,135,136,137,113,138,74,75,76,77,139,140,109,141,142,108,143,112,144,145,29,146,147,148,116,149,106,150,151,152,153,154,155,156,114,115,157,158,30,78,79,23,80,159,160,161,117,162,163,121,122,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,84,85,86,88,89,90,91,92,93,94,95,96,97,98,99,100,101,27,184,28,185,118,119,186,187,188,189,24,190,191,192,193,194,195,104,196,197,111,198,199,200,201,103,202,203,204,205,206,207,208,209,210,211,212,213,214,215,125,216,217,218,219,220,221,222,223,224,225,26,226,227,228,229,230,231,232,233,17,234,235,236,237,238,239,240,105,241,242,243,244,245,246,247,248,249]),import.meta.url)),St=(0,M.lazy)(()=>C(()=>import(`./schedule-itp6dbnh.js`),__vite__mapDeps([250,1,2,3,4,5,6,7,8,9,10,11,12,13,14,31,32,33,34,35,19,20,21,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,251,113,252,105,172,173,174,115,175,176,177,178,179,180,181,134,135,136,137,87,138,74,75,76,77,139,140,109,141,142,108,143,18,112,144,145,29,146,147,148,116,149,106,182,183,84,85,86,88,89,90,91,92,93,94,95,96,97,98,99,100,101,27,184,28,185,118,119,186,187,188,189,24,190,225,26,111,114,204,253,254,255,203,256,240]),import.meta.url)),P=(0,M.lazy)(()=>C(()=>import(`./phase-gcpfcucv.js`),__vite__mapDeps([257,1,2,3,4,5,6,7,8,9,10,11,12,13,14,137,87,113,21,252,19,20,105,258,161,29,139,116,40,259,111,112,53,49,38,54,55,56,114,115,31,36,52,18,77,254,255,203,65,83]),import.meta.url)),Ct=(0,M.lazy)(()=>C(()=>import(`./phases-mh3ro1qn.js`),__vite__mapDeps([260,1,2,3,4,5,6,7,8,9,10,11,12,13,14,113,21,112,53,49,38,54,55,56,29,19,20,139,87,253,254,18,77,255,203,83]),import.meta.url)),wt=(0,M.lazy)(()=>C(()=>import(`./overview-bj73m8ob.js`),__vite__mapDeps([261,1,2,3,4,5,6,7,8,9,10,11,12,13,14,113,21,103,31,29,57,58,40,59,60,61,62,55,18,19,20,139,87,255,203,77,262,83]),import.meta.url)),Tt=(0,M.lazy)(()=>C(()=>
46import(`./details-g84v6ew4.js`),__vite__mapDeps([263,1,2,3,4,5,6,7,8,9,10,11,12,13,14,137,87,113,21,252,19,20,105,34,35,36,264,18,84,85,86,39,40,88,89,90,44,91,92,93,94,95,96,97,98,99,100,101,193,33,37,38,41,42,43,45,31,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,68,69,70,71,141,109,142,108,143,194,195,104,24,196,197,111,112,114,115,116,198,170,153,154,199,200,201,103,29,161,139,119,259,77,254,255,203,256,262]),import.meta.url));function Et(){let{username:e}=le();return(0,N.jsx)(wt,{username:e})}function Dt(){let{username:e}=le();return(0,N.jsx)(Ct,{username:e})}var F=e=>e.replace(/^\/app\/plans\//,``),Ot=()=>{let e=ve();return(0,N.jsxs)(se,{children:[A({path:F(j.overview.path),title:e(`Training Plans - TrainerRoad`),element:(0,N.jsx)(Et,{})}),A({path:`${F(j.planBuilder.path)}/*`,title:e(`Plan Builder - TrainerRoad`),element:(0,N.jsx)(xt,{})}),A({path:F(j.phases.path),title:e(`Plan Phases - TrainerRoad`),element:(0,N.jsx)(Dt,{})}),A({path:F(j.base.path),title:e(`Base Phase - TrainerRoad`),element:(0,N.jsx)(P,{phaseOrCategory:Re.base})}),A({path:F(j.build.path),title:e(`Build Phase - TrainerRoad`),element:(0,N.jsx)(P,{phaseOrCategory:Re.build})}),A({path:F(j.specialty.path),title:e(`Specialty Phase - TrainerRoad`),element:(0,N.jsx)(P,{phaseOrCategory:Re.specialty})}),A({path:F(j.road.path),title:e(`Road Plans - TrainerRoad`),element:(0,N.jsx)(P,{phaseOrCategory:Le.Road})}),A({path:F(j.offRoad.path),title:e(`Off-Road Plans - TrainerRoad`),element:(0,N.jsx)(P,{phaseOrCategory:Le.OffRoad})}),A({path:F(j.triathlete.path),title:e(`Triathlete Plans - TrainerRoad`),element:(0,N.jsx)(P,{phaseOrCategory:Le.Triathlete})}),A({path:F(j.enthusiast.path),title:e(`Enthusiast Plans - TrainerRoad`),element:(0,N.jsx)(P,{phaseOrCategory:Le.Enthusiast})}),A({path:F(j.schedule.path),title:e(`Schedule Plan - TrainerRoad`),element:(0,N.jsx)(St,{})}),(0,N.jsx)(ue,{path:F(j.details.path),element:(0,N.jsx)(Tt,{})})]})},I=class extends Error{constructor(e,t){let n=new.target.prototype;super(`${e}: Status code '${t}'`),this.statusCode=t,this.__proto__=n}},kt=class extends Error{constructor(e=`A timeout occurred.`){let t=new.target.prototype;super(e),this.__proto__=t}},L=class extends Error{constructor(e=`An abort occurred.`){let t=new.target.prototype;super(e),this.__proto__=t}},At=class extends Error{constructor(e,t){let n=new.target.prototype;super(e),this.transport=t,this.errorType=`UnsupportedTransportError`,this.__proto__=n}},jt=class extends Error{constructor(e,t){let n=new.target.prototype;super(e),this.transport=t,this.errorType=`DisabledTransportError`,this.__proto__=n}},Mt=class extends Error{constructor(e,t){let n=new.target.prototype;super(e),this.transport=t,this.errorType=`FailedToStartTransportError`,this.__proto__=n}},Nt=class extends Error{constructor(e){let t=new.target.prototype;super(e),this.errorType=`FailedToNegotiateWithServerError`,this.__proto__=t}},Pt=class extends Error{constructor(e,t){let n=new.target.prototype;super(e),this.innerErrors=t,this.__proto__=n}},Ft=class{constructor(e,t,n){this.statusCode=e,this.statusText=t,this.content=n}},R=class{get(e,t){return this.send({...t,method:`GET`,url:e})}post(e,t){return this.send({...t,method:`POST`,url:e})}delete(e,t){return this.send({...t,method:`DELETE`,url:e})}getCookieString(e){return``}},z;(function(e){e[e.Trace=0]=`Trace`,e[e.Debug=1]=`Debug`,e[e.Information=2]=`Information`,e[e.Warning=3]=`Warning`,e[e.Error=4]=`Error`,e[e.Critical=5]=`Critical`,e[e.None=6]=`None`})(z||(z={}));var B=class{constructor(){}log(e,t){}};B.instance=new B;var It=`8.0.7`,V=class{static isRequired(e,t){if(e==null)throw Error(`The '${t}' argument is required.`)}static isNotEmpty(e,t){if(!e||e.match(/^\s*$/))throw Error(`The '${t}' argument should not be empty.`)}static isIn(e,t,n){if(!(e in t))throw Error(`Unknown ${n} value: ${e}.`)}},H=class e{static get isBrowser(){return!e.isNode&&typeof window==`object`&&typeof window.document==`object`}static get isWebWorker(){return!e.isNode&&typeof self==`object`&&`importScripts`in self}static get isReactNative(){return!e.isNode&&typeof window==`object`&&window.document===void 0}static get isNode(){return typeof process<`u`&&process.release&&process.release.name===`node`}};function U(e,t){let n=``;return W(e)?(n=`Binary data of length ${e.byteLength}`,t&&(n+=`. Content: '${Lt(e)}'`)):typeof e==`string`&&(n=`String data of length ${e.length}`,t&&(n+=`. Content: '${e}'`)),n}function Lt(e){let t=new Uint8Array(e),n=``;
46return t.forEach(e=>{n+=`0x${e<16?`0`:``}${e.toString(16)} `}),n.substr(0,n.length-1)}function W(e){return e&&typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||e.constructor&&e.constructor.name===`ArrayBuffer`)}async function Rt(e,t,n,r,i,a){let o={},[s,c]=G();o[s]=c,e.log(z.Trace,`(${t} transport) sending data. ${U(i,a.logMessageContent)}.`);let l=W(i)?`arraybuffer`:`text`,u=await n.post(r,{content:i,headers:{...o,...a.headers},responseType:l,timeout:a.timeout,withCredentials:a.withCredentials});e.log(z.Trace,`(${t} transport) request complete. Response status: ${u.statusCode}.`)}function zt(e){return e===void 0?new Vt(z.Information):e===null?B.instance:e.log===void 0?new Vt(e):e}var Bt=class{constructor(e,t){this._subject=e,this._observer=t}dispose(){let e=this._subject.observers.indexOf(this._observer);e>-1&&this._subject.observers.splice(e,1),this._subject.observers.length===0&&this._subject.cancelCallback&&this._subject.cancelCallback().catch(e=>{})}},Vt=class{constructor(e){this._minLevel=e,this.out=console}log(e,t){if(e>=this._minLevel){let n=`[${new Date().toISOString()}] ${z[e]}: ${t}`;switch(e){case z.Critical:case z.Error:this.out.error(n);break;case z.Warning:this.out.warn(n);break;case z.Information:this.out.info(n);break;default:this.out.log(n);break}}}};function G(){let e=`X-SignalR-User-Agent`;return H.isNode&&(e=`User-Agent`),[e,Ht(It,Ut(),Gt(),Wt())]}function Ht(e,t,n,r){let i=`Microsoft SignalR/`,a=e.split(`.`);return i+=`${a[0]}.${a[1]}`,i+=` (${e}; `,t&&t!==``?i+=`${t}; `:i+=`Unknown OS; `,i+=`${n}`,r?i+=`; ${r}`:i+=`; Unknown Runtime Version`,i+=`)`,i}function Ut(){if(H.isNode)switch(process.platform){case`win32`:return`Windows NT`;case`darwin`:return`macOS`;case`linux`:return`Linux`;default:return process.platform}else return``}function Wt(){if(H.isNode)return process.versions.node}function Gt(){return H.isNode?`NodeJS`:`Browser`}function Kt(e){return e.stack?e.stack:e.message?e.message:`${e}`}function qt(){if(typeof globalThis<`u`)return globalThis;if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global;throw Error(`could not find global`)}var Jt=class extends R{constructor(t){if(super(),this._logger=t,typeof fetch>`u`||H.isNode){let t=typeof __webpack_require__==`function`?__non_webpack_require__:e;this._jar=new(t(`tough-cookie`)).CookieJar,typeof fetch>`u`?this._fetchType=t(`node-fetch`):this._fetchType=fetch,this._fetchType=t(`fetch-cookie`)(this._fetchType,this._jar)}else this._fetchType=fetch.bind(qt());if(typeof AbortController>`u`){let t=typeof __webpack_require__==`function`?__non_webpack_require__:e;this._abortControllerType=t(`abort-controller`)}else this._abortControllerType=AbortController}async send(e){if(e.abortSignal&&e.abortSignal.aborted)throw new L;if(!e.method)throw Error(`No method defined.`);if(!e.url)throw Error(`No url defined.`);let t=new this._abortControllerType,n;e.abortSignal&&(e.abortSignal.onabort=()=>{t.abort(),n=new L});let r=null;if(e.timeout){let i=e.timeout;r=setTimeout(()=>{t.abort(),this._logger.log(z.Warning,`Timeout from HTTP request.`),n=new kt},i)}e.content===``&&(e.content=void 0),e.content&&(e.headers=e.headers||{},W(e.content)?e.headers[`Content-Type`]=`application/octet-stream`:e.headers[`Content-Type`]=`text/plain;charset=UTF-8`);let i;try{i=await this._fetchType(e.url,{body:e.content,cache:`no-cache`,credentials:e.withCredentials===!0?`include`:`same-origin`,headers:{"X-Requested-With":`XMLHttpRequest`,...e.headers},method:e.method,mode:`cors`,redirect:`follow`,signal:t.signal})}catch(e){throw n||(this._logger.log(z.Warning,`Error from HTTP request. ${e}.`),e)}finally{r&&clearTimeout(r),e.abortSignal&&(e.abortSignal.onabort=null)}if(!i.ok)throw new I(await Yt(i,`text`)||i.statusText,i.status);let a=await Yt(i,e.responseType);return new Ft(i.status,i.statusText,a)}getCookieString(e){let t=``;return H.isNode&&this._jar&&this._jar.getCookies(e,(e,n)=>t=n.join(`; `)),t}};function Yt(e,t){let n;switch(t){case`arraybuffer`:n=e.arrayBuffer();break;case`text`:n=e.text();break;case`blob`:case`document`:case`json`:throw Error(`${t} is not supported.`);default:n=e.text();break}return n}var Xt=class extends R{constructor(e){super(),this._logger=e}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new L):e.method?e.url?new Promise((t,n)=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),r.withCredentials=e.withCredentials===void 0?!0:e.withCredentials,r.setRequestHeader(`X-Requested-With`,`XMLHttpRequest`),e.content===``&&(e.content=void 0),e.content&&(W(e.content)?r.setRequestHeader(`Content-Type`,`application/octet-stream`):r.setRequestHeader(`Content-Type`,`text/plain;charset=UTF-8`));let i=e.headers;
46i&&Object.keys(i).forEach(e=>{r.setRequestHeader(e,i[e])}),e.responseType&&(r.responseType=e.responseType),e.abortSignal&&(e.abortSignal.onabort=()=>{r.abort(),n(new L)}),e.timeout&&(r.timeout=e.timeout),r.onload=()=>{e.abortSignal&&(e.abortSignal.onabort=null),r.status>=200&&r.status<300?t(new Ft(r.status,r.statusText,r.response||r.responseText)):n(new I(r.response||r.responseText||r.statusText,r.status))},r.onerror=()=>{this._logger.log(z.Warning,`Error from HTTP request. ${r.status}: ${r.statusText}.`),n(new I(r.statusText,r.status))},r.ontimeout=()=>{this._logger.log(z.Warning,`Timeout from HTTP request.`),n(new kt)},r.send(e.content)}):Promise.reject(Error(`No url defined.`)):Promise.reject(Error(`No method defined.`))}},Zt=class extends R{constructor(e){if(super(),typeof fetch<`u`||H.isNode)this._httpClient=new Jt(e);else if(typeof XMLHttpRequest<`u`)this._httpClient=new Xt(e);else throw Error(`No usable HttpClient found.`)}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new L):e.method?e.url?this._httpClient.send(e):Promise.reject(Error(`No url defined.`)):Promise.reject(Error(`No method defined.`))}getCookieString(e){return this._httpClient.getCookieString(e)}},K=class e{static write(t){return`${t}${e.RecordSeparator}`}static parse(t){if(t[t.length-1]!==e.RecordSeparator)throw Error(`Message is incomplete.`);let n=t.split(e.RecordSeparator);return n.pop(),n}};K.RecordSeparatorCode=30,K.RecordSeparator=String.fromCharCode(K.RecordSeparatorCode);var Qt=class{writeHandshakeRequest(e){return K.write(JSON.stringify(e))}parseHandshakeResponse(e){let t,n;if(W(e)){let r=new Uint8Array(e),i=r.indexOf(K.RecordSeparatorCode);
46if(i===-1)throw Error(`Message is incomplete.`);let a=i+1;t=String.fromCharCode.apply(null,Array.prototype.slice.call(r.slice(0,a))),n=r.byteLength>a?r.slice(a).buffer:null}else{let r=e,i=r.indexOf(K.RecordSeparator);if(i===-1)throw Error(`Message is incomplete.`);let a=i+1;t=r.substring(0,a),n=r.length>a?r.substring(a):null}let r=K.parse(t),i=JSON.parse(r[0]);if(i.type)throw Error(`Expected a handshake response from the server.`);return[n,i]}},q;(function(e){e[e.Invocation=1]=`Invocation`,e[e.StreamItem=2]=`StreamItem`,e[e.Completion=3]=`Completion`,e[e.StreamInvocation=4]=`StreamInvocation`,e[e.CancelInvocation=5]=`CancelInvocation`,e[e.Ping=6]=`Ping`,e[e.Close=7]=`Close`,e[e.Ack=8]=`Ack`,e[e.Sequence=9]=`Sequence`})(q||(q={}));var $t=class{constructor(){this.observers=[]}next(e){for(let t of this.observers)t.next(e)}error(e){for(let t of this.observers)t.error&&t.error(e)}complete(){for(let e of this.observers)e.complete&&e.complete()}subscribe(e){return this.observers.push(e),new Bt(this,e)}},en=class{constructor(e,t,n){this._bufferSize=1e5,this._messages=[],this._totalMessageCount=0,this._waitForSequenceMessage=!1,this._nextReceivingSequenceId=1,this._latestReceivedSequenceId=0,this._bufferedByteCount=0,this._reconnectInProgress=!1,this._protocol=e,this._connection=t,this._bufferSize=n}async _send(e){let t=this._protocol.writeMessage(e),n=Promise.resolve();if(this._isInvocationMessage(e)){this._totalMessageCount++;let e=()=>{},r=()=>{};W(t)?this._bufferedByteCount+=t.byteLength:this._bufferedByteCount+=t.length,this._bufferedByteCount>=this._bufferSize&&(n=new Promise((t,n)=>{e=t,r=n})),this._messages.push(new tn(t,this._totalMessageCount,e,r))}try{this._reconnectInProgress||await this._connection.send(t)}catch{this._disconnected()}await n}_ack(e){let t=-1;for(let n=0;n<this._messages.length;n++){let r=this._messages[n];if(r._id<=e.sequenceId)t=n,W(r._message)?this._bufferedByteCount-=r._message.byteLength:this._bufferedByteCount-=r._message.length,r._resolver();else if(this._bufferedByteCount<this._bufferSize)r._resolver();else break}t!==-1&&(this._messages=this._messages.slice(t+1))}_shouldProcessMessage(e){if(this._waitForSequenceMessage)return e.type===q.Sequence?(this._waitForSequenceMessage=!1,!0):!1;if(!this._isInvocationMessage(e))return!0;let t=this._nextReceivingSequenceId;return this._nextReceivingSequenceId++,t<=this._latestReceivedSequenceId?(t===this._latestReceivedSequenceId&&this._ackTimer(),!1):(this._latestReceivedSequenceId=t,this._ackTimer(),!0)}_resetSequence(e){if(e.sequenceId>this._nextReceivingSequenceId){this._connection.stop(Error(`Sequence ID greater than amount of messages we've received.`));return}this._nextReceivingSequenceId=e.sequenceId}_disconnected(){this._reconnectInProgress=!0,this._waitForSequenceMessage=!0}async _resend(){let e=this._messages.length===0?this._totalMessageCount+1:this._messages[0]._id;await this._connection.send(this._protocol.writeMessage({type:q.Sequence,sequenceId:e}));let t=this._messages;for(let e of t)await this._connection.send(e._message);this._reconnectInProgress=!1}_dispose(e){e??(e=Error(`Unable to reconnect to server.`));for(let t of this._messages)t._rejector(e)}_isInvocationMessage(e){switch(e.type){case q.Invocation:case q.StreamItem:case q.Completion:case q.StreamInvocation:case q.CancelInvocation:return!0;case q.Close:case q.Sequence:case q.Ping:case q.Ack:return!1}}_ackTimer(){this._ackTimerHandle===void 0&&(this._ackTimerHandle=setTimeout(async()=>{try{this._reconnectInProgress||await this._connection.send(this._protocol.writeMessage({type:q.Ack,sequenceId:this._latestReceivedSequenceId}))}catch{}clearTimeout(this._ackTimerHandle),this._ackTimerHandle=void 0},1e3))}},tn=class{constructor(e,t,n,r){this._message=e,this._id=t,this._resolver=n,this._rejector=r}},nn=30*1e3,rn=15*1e3,an=1e5,J;(function(e){e.Disconnected=`Disconnected`,e.Connecting=`Connecting`,e.Connected=`Connected`,e.Disconnecting=`Disconnecting`,e.Reconnecting=`Reconnecting`})(J||(J={}));var on=class e{static create(t,n,r,i,a,o,s){return new e(t,n,r,i,a,o,s)}constructor(e,t,n,r,i,a,o){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(z.Warning,`The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep`)},V.isRequired(e,`connection`),V.isRequired(t,`logger`),V.isRequired(n,`protocol`),this.serverTimeoutInMilliseconds=i??nn,this.keepAliveIntervalInMilliseconds=a??rn,this._statefulReconnectBufferSize=o??an,this._logger=t,this._protocol=n,this.connection=e,this._reconnectPolicy=r,this._handshakeProtocol=new Qt,this.connection.onreceive=e=>
46this._processIncomingData(e),this.connection.onclose=e=>this._connectionClosed(e),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=J.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:q.Ping})}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||``}set baseUrl(e){if(this._connectionState!==J.Disconnected&&this._connectionState!==J.Reconnecting)throw Error(`The HubConnection must be in the Disconnected or Reconnecting state to change the url.`);if(!e)throw Error(`The HubConnection url must be a valid url.`);this.connection.baseUrl=e}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==J.Disconnected)return Promise.reject(Error(`Cannot start a HubConnection that is not in the 'Disconnected' state.`));this._connectionState=J.Connecting,this._logger.log(z.Debug,`Starting HubConnection.`);try{await this._startInternal(),H.isBrowser&&window.document.addEventListener(`freeze`,this._freezeEventListener),this._connectionState=J.Connected,this._connectionStarted=!0,this._logger.log(z.Debug,`HubConnection connected successfully.`)}catch(e){return this._connectionState=J.Disconnected,this._logger.log(z.Debug,`HubConnection failed to start successfully because of error '${e}'.`),Promise.reject(e)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;let e=new Promise((e,t)=>{this._handshakeResolver=e,this._handshakeRejecter=t});await this.connection.start(this._protocol.transferFormat);try{let t=this._protocol.version;this.connection.features.reconnect||(t=1);let n={protocol:this._protocol.name,version:t};if(this._logger.log(z.Debug,`Sending handshake request.`),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(n)),this._logger.log(z.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await e,this._stopDuringStartError)throw this._stopDuringStartError;this.connection.features.reconnect&&(this._messageBuffer=new en(this._protocol,this.connection,this._statefulReconnectBufferSize),this.connection.features.disconnected=this._messageBuffer._disconnected.bind(this._messageBuffer),this.connection.features.resend=()=>{if(this._messageBuffer)return this._messageBuffer._resend()}),this.connection.features.inherentKeepAlive||await this._sendMessage(this._cachedPingMessage)}catch(e){throw this._logger.log(z.Debug,`Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(e),e}}async stop(){let e=this._startPromise;this.connection.features.reconnect=!1,this._stopPromise=this._stopInternal(),await this._stopPromise;try{await e}catch{}}_stopInternal(e){if(this._connectionState===J.Disconnected)return this._logger.log(z.Debug,`Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this._connectionState===J.Disconnecting)return this._logger.log(z.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;let t=this._connectionState;return this._connectionState=J.Disconnecting,this._logger.log(z.Debug,`Stopping HubConnection.`),this._reconnectDelayHandle?(this._logger.log(z.Debug,`Connection stopped during reconnect delay. Done reconnecting.`),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(t===J.Connected&&this._sendCloseMessage(),this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=e||new L(`The connection was stopped before the hub handshake could complete.`),this.connection.stop(e))}async _sendCloseMessage(){try{await this._sendWithProtocol(this._createCloseMessage())}catch{}}stream(e,...t){let[n,r]=this._replaceStreamingParams(t),i=this._createStreamInvocation(e,t,r),a,o=new $t;return o.cancelCallback=()=>{let e=this._createCancelInvocation(i.invocationId);return delete this._callbacks[i.invocationId],a.then(()=>this._sendWithProtocol(e))},this._callbacks[i.invocationId]=(e,t)=>{if(t){o.error(t);return}else e&&(e.type===q.Completion?e.error?o.error(Error(e.error)):o.complete():o.next(e.item))},a=this._sendWithProtocol(i).catch(e=>{o.error(e),delete this._callbacks[i.invocationId]}),this._launchStreams(n,a),o}_sendMessage(e){return this._resetKeepAliveInterval(),this.connection.send(e)}_sendWithProtocol(e){return this._messageBuffer?this._messageBuffer._send(e):this._sendMessage(this._protocol.writeMessage(e))}send(e,...t){let[n,r]=this._replaceStreamingParams(t),i=this._sendWithProtocol(this._createInvocation(e,t,!0,r));return this._launchStreams(n,i),i}invoke(e,...t){let[n,r]=this._replaceStreamingParams(t),i=this._createInvocation(e,t,!1,r);return new Promise((e,t)=>
46{this._callbacks[i.invocationId]=(n,r)=>{if(r){t(r);return}else n&&(n.type===q.Completion?n.error?t(Error(n.error)):e(n.result):t(Error(`Unexpected message type: ${n.type}`)))};let r=this._sendWithProtocol(i).catch(e=>{t(e),delete this._callbacks[i.invocationId]});this._launchStreams(n,r)})}on(e,t){!e||!t||(e=e.toLowerCase(),this._methods[e]||(this._methods[e]=[]),this._methods[e].indexOf(t)===-1&&this._methods[e].push(t))}off(e,t){if(!e)return;e=e.toLowerCase();let n=this._methods[e];if(n)if(t){let r=n.indexOf(t);r!==-1&&(n.splice(r,1),n.length===0&&delete this._methods[e])}else delete this._methods[e]}onclose(e){e&&this._closedCallbacks.push(e)}onreconnecting(e){e&&this._reconnectingCallbacks.push(e)}onreconnected(e){e&&this._reconnectedCallbacks.push(e)}_processIncomingData(e){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(e=this._processHandshakeResponse(e),this._receivedHandshakeResponse=!0),e){let t=this._protocol.parseMessages(e,this._logger);for(let e of t)if(!(this._messageBuffer&&!this._messageBuffer._shouldProcessMessage(e)))switch(e.type){case q.Invocation:this._invokeClientMethod(e).catch(e=>{this._logger.log(z.Error,`Invoke client method threw error: ${Kt(e)}`)});break;case q.StreamItem:case q.Completion:{let t=this._callbacks[e.invocationId];if(t){e.type===q.Completion&&delete this._callbacks[e.invocationId];try{t(e)}catch(e){this._logger.log(z.Error,`Stream callback threw error: ${Kt(e)}`)}}break}case q.Ping:break;case q.Close:{this._logger.log(z.Information,`Close message received from server.`);let t=e.error?Error(`Server returned an error on close: `+e.error):void 0;e.allowReconnect===!0?this.connection.stop(t):this._stopPromise=this._stopInternal(t);break}case q.Ack:this._messageBuffer&&this._messageBuffer._ack(e);break;case q.Sequence:this._messageBuffer&&this._messageBuffer._resetSequence(e);break;default:this._logger.log(z.Warning,`Invalid message type: ${e.type}.`);break}}this._resetTimeoutPeriod()}_processHandshakeResponse(e){let t,n;try{[n,t]=this._handshakeProtocol.parseHandshakeResponse(e)}catch(e){let t=`Error parsing handshake response: `+e;this._logger.log(z.Error,t);let n=Error(t);throw this._handshakeRejecter(n),n}if(t.error){let e=`Server returned handshake error: `+t.error;this._logger.log(z.Error,e);let n=Error(e);throw this._handshakeRejecter(n),n}else this._logger.log(z.Debug,`Server handshake complete.`);return this._handshakeResolver(),n}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=new Date().getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if((!this.connection.features||!this.connection.features.inherentKeepAlive)&&(this._timeoutHandle=setTimeout(()=>this.serverTimeout(),this.serverTimeoutInMilliseconds),this._pingServerHandle===void 0)){let e=this._nextKeepAlive-new Date().getTime();e<0&&(e=0),this._pingServerHandle=setTimeout(async()=>{if(this._connectionState===J.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}},e)}}serverTimeout(){this.connection.stop(Error(`Server timeout elapsed without receiving a message from the server.`))}async _invokeClientMethod(e){let t=e.target.toLowerCase(),n=this._methods[t];if(!n){this._logger.log(z.Warning,`No client method with the name '${t}' found.`),e.invocationId&&(this._logger.log(z.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),await this._sendWithProtocol(this._createCompletionMessage(e.invocationId,`Client didn't provide a result.`,null)));return}let r=n.slice(),i=!!e.invocationId,a,o,s;for(let n of r)try{let r=a;a=await n.apply(this,e.arguments),i&&a&&r&&(this._logger.log(z.Error,`Multiple results provided for '${t}'. Sending error to server.`),s=this._createCompletionMessage(e.invocationId,`Client provided multiple results.`,null)),o=void 0}catch(e){o=e,this._logger.log(z.Error,`A callback for the method '${t}' threw error '${e}'.`)}s?await this._sendWithProtocol(s):i?(o?s=this._createCompletionMessage(e.invocationId,`${o}`,null):a===void 0?(this._logger.log(z.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),s=this._createCompletionMessage(e.invocationId,`Client didn't provide a result.`,null)):s=this._createCompletionMessage(e.invocationId,null,a),await this._sendWithProtocol(s)):a&&this._logger.log(z.Error,`Result given for '${t}' method but server is not expecting a result.`)}_connectionClosed(e){this._logger.log(z.Debug,`HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||e||new L(`The underlying connection was closed before the hub handshake could complete.`),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(e||Error(`Invocation canceled due to the underlying connection being closed.`)),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===J.Disconnecting?this._completeClose(e):this._connectionState===J.Connected&&this._reconnectPolicy?this._reconnect(e):this._connectionState===J.Connected&&this._completeClose(e)}_completeClose(e){if(this._connectionStarted){this._connectionState=J.Disconnected,this._connectionStarted=!1,this._messageBuffer&&(this._messageBuffer._dispose(e??Error(`Connection closed.`)),this._messageBuffer=void 0),H.isBrowser&&window.document.removeEventListener(`freeze`,this._freezeEventListener);try{this._closedCallbacks.forEach(t=>t.apply(this,[e]))}catch(t){this._logger.log(z.Error,`An onclose callback called with error '${e}' threw error '${t}'.`)}}}async _reconnect(e){let t=Date.now(),n=0,r=e===void 0?Error(`Attempting to re
46connect due to a unknown error.`):e,i=this._getNextRetryDelay(n++,0,r);if(i===null){this._logger.log(z.Debug,`Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt.`),this._completeClose(e);return}if(this._connectionState=J.Reconnecting,e?this._logger.log(z.Information,`Connection reconnecting because of error '${e}'.`):this._logger.log(z.Information,`Connection reconnecting.`),this._reconnectingCallbacks.length!==0){try{this._reconnectingCallbacks.forEach(t=>t.apply(this,[e]))}catch(t){this._logger.log(z.Error,`An onreconnecting callback called with error '${e}' threw error '${t}'.`)}if(this._connectionState!==J.Reconnecting){this._logger.log(z.Debug,`Connection left the reconnecting state in onreconnecting callback. Done reconnecting.`);return}}for(;i!==null;){if(this._logger.log(z.Information,`Reconnect attempt number ${n} will start in ${i} ms.`),await new Promise(e=>{this._reconnectDelayHandle=setTimeout(e,i)}),this._reconnectDelayHandle=void 0,this._connectionState!==J.Reconnecting){this._logger.log(z.Debug,`Connection left the reconnecting state during reconnect delay. Done reconnecting.`);return}try{if(await this._startInternal(),this._connectionState=J.Connected,this._logger.log(z.Information,`HubConnection reconnected successfully.`),this._reconnectedCallbacks.length!==0)try{this._reconnectedCallbacks.forEach(e=>e.apply(this,[this.connection.connectionId]))}catch(e){this._logger.log(z.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`)}return}catch(e){if(this._logger.log(z.Information,`Reconnect attempt failed because of error '${e}'.`),this._connectionState!==J.Reconnecting){this._logger.log(z.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),this._connectionState===J.Disconnecting&&this._completeClose();return}r=e instanceof Error?e:Error(e.toString()),i=this._getNextRetryDelay(n++,Date.now()-t,r)}}this._logger.log(z.Information,`Reconnect retries have been exhausted after ${Date.now()-t} ms and ${n} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(e,t,n){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:t,previousRetryCount:e,retryReason:n})}catch(n){return this._logger.log(z.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${e}, ${t}) threw error '${n}'.`),null}}_cancelCallbacksWithError(e){let t=this._callbacks;this._callbacks={},Object.keys(t).forEach(n=>{let r=t[n];try{r(null,e)}catch(t){this._logger.log(z.Error,`Stream 'error' callback called with '${e}' threw error: ${Kt(t)}`)}})}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(e,t,n,r){if(n)return r.length===0?{arguments:t,target:e,type:q.Invocation}:{arguments:t,streamIds:r,target:e,type:q.Invocation};{let n=this._invocationId;return this._invocationId++,r.length===0?{arguments:t,invocationId:n.toString(),target:e,type:q.Invocation}:{arguments:t,invocationId:n.toString(),streamIds:r,target:e,type:q.Invocation}}}_launchStreams(e,t){if(e.length!==0){t||(t=Promise.resolve());for(let n in e)e[n].subscribe({complete:()=>{t=t.then(()=>this._sendWithProtocol(this._createCompletionMessage(n)))},error:e=>{let r;r=e instanceof Error?e.message:e&&e.toString?e.toString():`Unknown error`,t=t.then(()=>this._sendWithProtocol(this._createCompletionMessage(n,r)))},next:e=>{t=t.then(()=>this._sendWithProtocol(this._createStreamItemMessage(n,e)))}})}}_replaceStreamingParams(e){let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(this._isObservable(i)){let a=this._invocationId;this._invocationId++,t[a]=i,n.push(a.toString()),e.splice(r,1)}}return[t,n]}_isObservable(e){return e&&e.subscribe&&typeof e.subscribe==`function`}_createStreamInvocation(e,t,n){let r=this._invocationId;return this._invocationId++,n.length===0?{arguments:t,invocationId:r.toString(),target:e,type:q.StreamInvocation}:{arguments:t,invocationId:r.toString(),streamIds:n,target:e,type:q.StreamInvocation}}_createCancelInvocation(e){return{invocationId:e,type:q.CancelInvocation}}_createStreamItemMessage(e,t){return{invocationId:e,item:t,type:q.StreamItem}}_createCompletionMessage(e,t,n){return t?{error:t,invocationId:e,type:q.Completion}:{invocationId:e,result:n,type:q.Completion}}_createCloseMessage(){return{type:q.Close}}},sn=[0,2e3,1e4,3e4,null],cn=class{constructor(e){this._retryDelays=e===void 0?sn:[...e,null]}nextRetryDelayInMilliseconds(e){return this._retryDelays[e.previousRetryCount]}},Y=class{};Y.Authorization=`Authorization`,Y.Cookie=`Cookie`;var ln=class extends R{constructor(e,t){super(),this._innerClient=e,this._accessTokenFactory=t}async send(e){let t=!0;this._accessTokenFactory&&(!this._accessToken||e.url&&e.url.indexOf(`/negotiate?`)>0)&&(t=!1,this._accessToken=await this._accessTokenFactory()),this._setAuthorizationHeader(e);let n=await this._innerClient.send(e);return t&&n.statusCode===401&&this._accessTokenFactory?(this._accessToken=await this._accessTokenFactory(),this._setAuthorizationHeader(e),await this._innerClient.send(e)):n}_setAuthorizationHeader(e){e.headers||(e.headers={}),this._accessToken?e.headers[Y.Authorization]=`Bearer ${this._accessToken}`:this._accessTokenFactory&&e.headers[Y.Authorization]&&delete e.headers[Y.Authorization]}getCookieString(e){return this._innerClient.getCookieString(e)}},X;(function(e){e[e.None=0]=`None`,e[e.WebSockets=1]=`WebSockets`,e[e.ServerSentEvents=2]=`ServerSentEvents`,e[e.LongPolling=4]=`LongPolling`})(X||(X={}));var Z;(function(e){e[e.Text=1]=`Text`,e[e.Binary=2]=`Binary`})(Z||(Z={}));var un=class{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}},dn=class{get pollAborted(){return this._pollAbort.aborted}constructor(e,t,n){this._httpClient=e,this._logger=t,this._pollAbort=new un,this._options=n,this._running=!1,this.onreceive=null,this.onclose
46=null}async connect(e,t){if(V.isRequired(e,`url`),V.isRequired(t,`transferFormat`),V.isIn(t,Z,`transferFormat`),this._url=e,this._logger.log(z.Trace,`(LongPolling transport) Connecting.`),t===Z.Binary&&typeof XMLHttpRequest<`u`&&typeof new XMLHttpRequest().responseType!=`string`)throw Error(`Binary protocols over XmlHttpRequest not implementing advanced features are not supported.`);let[n,r]=G(),i={[n]:r,...this._options.headers},a={abortSignal:this._pollAbort.signal,headers:i,timeout:1e5,withCredentials:this._options.withCredentials};t===Z.Binary&&(a.responseType=`arraybuffer`);let o=`${e}&_=${Date.now()}`;this._logger.log(z.Trace,`(LongPolling transport) polling: ${o}.`);let s=await this._httpClient.get(o,a);s.statusCode===200?this._running=!0:(this._logger.log(z.Error,`(LongPolling transport) Unexpected response code: ${s.statusCode}.`),this._closeError=new I(s.statusText||``,s.statusCode),this._running=!1),this._receiving=this._poll(this._url,a)}async _poll(e,t){try{for(;this._running;)try{let n=`${e}&_=${Date.now()}`;this._logger.log(z.Trace,`(LongPolling transport) polling: ${n}.`);let r=await this._httpClient.get(n,t);r.statusCode===204?(this._logger.log(z.Information,`(LongPolling transport) Poll terminated by server.`),this._running=!1):r.statusCode===200?r.content?(this._logger.log(z.Trace,`(LongPolling transport) data received. ${U(r.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this._logger.log(z.Trace,`(LongPolling transport) Poll timed out, reissuing.`):(this._logger.log(z.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this._closeError=new I(r.statusText||``,r.statusCode),this._running=!1)}catch(e){this._running?e instanceof kt?this._logger.log(z.Trace,`(LongPolling transport) Poll timed out, reissuing.`):(this._closeError=e,this._running=!1):this._logger.log(z.Trace,`(LongPolling transport) Poll errored after shutdown: ${e.message}`)}}finally{this._logger.log(z.Trace,`(LongPolling transport) Polling complete.`),this.pollAborted||this._raiseOnClose()}}async send(e){return this._running?Rt(this._logger,`LongPolling`,this._httpClient,this._url,e,this._options):Promise.reject(Error(`Cannot send until the transport is connected`))}async stop(){this._logger.log(z.Trace,`(LongPolling transport) Stopping polling.`),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(z.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);let e={},[t,n]=G();e[t]=n;let r={headers:{...e,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials},i;try{await this._httpClient.delete(this._url,r)}catch(e){i=e}i?i instanceof I&&(i.statusCode===404?this._logger.log(z.Trace,`(LongPolling transport) A 404 response was returned from sending a DELETE request.`):this._logger.log(z.Trace,`(LongPolling transport) Error sending a DELETE request: ${i}`)):this._logger.log(z.Trace,`(LongPolling transport) DELETE request accepted.`)}finally{this._logger.log(z.Trace,`(LongPolling transport) Stop finished.`),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let e=`(LongPolling transport) Firing onclose event.`;this._closeError&&(e+=` Error: `+this._closeError),this._logger.log(z.Trace,e),this.onclose(this._closeError)}}},fn=class{constructor(e,t,n,r){this._httpClient=e,this._accessToken=t,this._logger=n,this._options=r,this.onreceive=null,this.onclose=null}async connect(e,t){return V.isRequired(e,`url`),V.isRequired(t,`transferFormat`),V.isIn(t,Z,`transferFormat`),this._logger.log(z.Trace,`(SSE transport) Connecting.`),this._url=e,this._accessToken&&(e+=(e.indexOf(`?`)<0?`?`:`&`)+`access_token=${encodeURIComponent(this._accessToken)}`),new Promise((n,r)=>{let i=!1;if(t!==Z.Text){r(Error(`The Server-Sent Events transport only supports the 'Text' transfer format`));return}let a;if(H.isBrowser||H.isWebWorker)a=new this._options.EventSource(e,{withCredentials:this._options.withCredentials});else{let t=this._httpClient.getCookieString(e),n={};n.Cookie=t;let[r,i]=G();n[r]=i,a=new this._options.EventSource(e,{withCredentials:this._options.withCredentials,headers:{...n,...this._options.headers}})}try{a.onmessage=e=>{if(this.onreceive)try{this._logger.log(z.Trace,`(SSE transport) data received. ${U(e.data,this._options.logMessageContent)}.`),this.onreceive(e.data)}catch(e){this._close(e);return}},a.onerror=e=>{i?this._close():r(Error(`EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky
46sessions are enabled.`))},a.onopen=()=>{this._logger.log(z.Information,`SSE connected to ${this._url}`),this._eventSource=a,i=!0,n()}}catch(e){r(e);return}})}async send(e){return this._eventSource?Rt(this._logger,`SSE`,this._httpClient,this._url,e,this._options):Promise.reject(Error(`Cannot send until the transport is connected`))}stop(){return this._close(),Promise.resolve()}_close(e){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(e))}},pn=class{constructor(e,t,n,r,i,a){this._logger=n,this._accessTokenFactory=t,this._logMessageContent=r,this._webSocketConstructor=i,this._httpClient=e,this.onreceive=null,this.onclose=null,this._headers=a}async connect(e,t){V.isRequired(e,`url`),V.isRequired(t,`transferFormat`),V.isIn(t,Z,`transferFormat`),this._logger.log(z.Trace,`(WebSockets transport) Connecting.`);let n;return this._accessTokenFactory&&(n=await this._accessTokenFactory()),new Promise((r,i)=>{e=e.replace(/^http/,`ws`);let a,o=this._httpClient.getCookieString(e),s=!1;if(H.isNode||H.isReactNative){let t={},[r,i]=G();t[r]=i,n&&(t[Y.Authorization]=`Bearer ${n}`),o&&(t[Y.Cookie]=o),a=new this._webSocketConstructor(e,void 0,{headers:{...t,...this._headers}})}else n&&(e+=(e.indexOf(`?`)<0?`?`:`&`)+`access_token=${encodeURIComponent(n)}`);a||(a=new this._webSocketConstructor(e)),t===Z.Binary&&(a.binaryType=`arraybuffer`),a.onopen=t=>{this._logger.log(z.Information,`WebSocket connected to ${e}.`),this._webSocket=a,s=!0,r()},a.onerror=e=>{let t=null;t=typeof ErrorEvent<`u`&&e instanceof ErrorEvent?e.error:`There was an error with the transport`,this._logger.log(z.Information,`(WebSockets transport) ${t}.`)},a.onmessage=e=>{if(this._logger.log(z.Trace,`(WebSockets transport) data received. ${U(e.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(e.data)}catch(e){this._close(e);return}},a.onclose=e=>{if(s)this._close(e);else{let t=null;t=typeof ErrorEvent<`u`&&e instanceof ErrorEvent?e.error:`WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.`,i(Error(t))}}})}send(e){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(z.Trace,`(WebSockets transport) sending data. ${U(e,this._logMessageContent)}.`),this._webSocket.send(e),Promise.resolve()):Promise.reject(`WebSocket is not in the OPEN state`)}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(e){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(z.Trace,`(WebSockets transport) socket closed.`),this.onclose&&(this._isCloseEvent(e)&&(e.wasClean===!1||e.code!==1e3)?this.onclose(Error(`WebSocket closed with status code: ${e.code} (${e.reason||`no reason given`}).`)):e instanceof Error?this.onclose(e):this.onclose())}_isCloseEvent(e){return e&&typeof e.wasClean==`boolean`&&typeof e.code==`number`}},mn=100,hn=class{constructor(t,n={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,V.isRequired(t,`url`),this._logger=zt(n.logger),this.baseUrl=this._resolveUrl(t),n=n||{},n.logMessageContent=n.logMessageContent===void 0?!1:n.logMessageContent,typeof n.withCredentials==`boolean`||n.withCredentials===void 0)n.withCredentials=n.withCredentials===void 0?!0:n.withCredentials;else throw Error(`withCredentials option was not a 'boolean' or 'undefined' value`);n.timeout=n.timeout===void 0?100*1e3:n.timeout;let r=null,i=null;if(H.isNode&&e!==void 0){let t=typeof __webpack_require__==`function`?__non_webpack_require__:e;r=t(`ws`),i=t(`eventsource`)}!H.isNode&&typeof WebSocket<`u`&&!n.WebSocket?n.WebSocket=WebSocket:H.isNode&&!n.WebSocket&&r&&(n.WebSocket=r),!H.isNode&&typeof EventSource<`u`&&!n.EventSource?n.EventSource=EventSource:H.isNode&&!n.EventSource&&i!==void 0&&(n.EventSource=i),this._httpClient=new ln(n.httpClient||new Zt(this._logger),n.accessTokenFactory),this._connectionState=`Disconnected`,this._connectionStarted=!1,this._options=n,this.onreceive=null,this.onclose
46=null}async start(e){if(e=e||Z.Binary,V.isIn(e,Z,`transferFormat`),this._logger.log(z.Debug,`Starting connection with transfer format '${Z[e]}'.`),this._connectionState!==`Disconnected`)return Promise.reject(Error(`Cannot start an HttpConnection that is not in the 'Disconnected' state.`));if(this._connectionState=`Connecting`,this._startInternalPromise=this._startInternal(e),await this._startInternalPromise,this._connectionState===`Disconnecting`){let e=`Failed to start the HttpConnection before stop() was called.`;return this._logger.log(z.Error,e),await this._stopPromise,Promise.reject(new L(e))}else if(this._connectionState!==`Connected`){let e=`HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!`;return this._logger.log(z.Error,e),Promise.reject(new L(e))}this._connectionStarted=!0}send(e){return this._connectionState===`Connected`?(this._sendQueue||(this._sendQueue=new _n(this.transport)),this._sendQueue.send(e)):Promise.reject(Error(`Cannot send data if the connection is not in the 'Connected' State.`))}async stop(e){if(this._connectionState===`Disconnected`)return this._logger.log(z.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`),Promise.resolve();if(this._connectionState===`Disconnecting`)return this._logger.log(z.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;this._connectionState=`Disconnecting`,this._stopPromise=new Promise(e=>{this._stopPromiseResolver=e}),await this._stopInternal(e),await this._stopPromise}async _stopInternal(e){this._stopError=e;try{await this._startInternalPromise}catch{}if(this.transport){try{await this.transport.stop()}catch(e){this._logger.log(z.Error,`HttpConnection.transport.stop() threw error '${e}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(z.Debug,`HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.`)}async _startInternal(e){let t=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory,this._httpClient._accessTokenFactory=this._accessTokenFactory;try{if(this._options.skipNegotiation)if(this._options.transport===X.WebSockets)this.transport=this._constructTransport(X.WebSockets),await this._startTransport(t,e);else throw Error(`Negotiation can only be skipped when using the WebSocket transport directly.`);else{let n=null,r=0;do{if(n=await this._getNegotiationResponse(t),this._connectionState===`Disconnecting`||this._connectionState===`Disconnected`)throw new L(`The connection was stopped during negotiation.`);if(n.error)throw Error(n.error);if(n.ProtocolVersion)throw Error(`Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.`);if(n.url&&(t=n.url),n.accessToken){let e=n.accessToken;this._accessTokenFactory=()=>e,this._httpClient._accessToken=e,this._httpClient._accessTokenFactory=void 0}r++}while(n.url&&r<mn);if(r===mn&&n.url)throw Error(`Negotiate redirection limit exceeded.`);await this._createTransport(t,this._options.transport,n,e)}this.transport instanceof dn&&(this.features.inherentKeepAlive=!0),this._connectionState===`Connecting`&&(this._logger.log(z.Debug,`The HttpConnection connected successfully.`),this._connectionState=`Connected`)}catch(e){return this._logger.log(z.Error,`Failed to start the connection: `+e),this._connectionState=`Disconnected`,this.transport=void 0,this._stopPromiseResolver(),Promise.reject(e)}}async _getNegotiationResponse(e){let t={},[n,r]=G();t[n]=r;let i=this._resolveNegotiateUrl(e);this._logger.log(z.Debug,`Sending negotiation request: ${i}.`);try{let e=await this._httpClient.post(i,{content:``,headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(e.statusCode!==200)return Promise.reject(Error(`Unexpected status code returned from negotiate '${e.statusCode}'`));let n=JSON.parse(e.content);return(!n.negotiateVersion||n.negotiateVersion<1)&&(n.connectionToken=n.connectionId),n.useStatefulReconnect&&this._options._useStatefulReconnect!==!0?Promise.reject(new Nt(`Client didn't negotiate Stateful Reconnect but the server did.`)):n}catch(e){let t=`Failed to complete negotiation with the server: `+e;return e instanceof I&&e.statusCode===404&&(t+=` Either this is not a SignalR endpoint or there is a proxy blocking the connection.`),this._logger.log(z.Error,t),Promise.reject(new Nt(t))}}_createConnectUrl(e,t){return t?e+(e.indexOf(`?`)===-1?`?`:`&`)+`id=${t}`:e}async _createTransport(e,t,n,r){let i=this._createConnectUrl(e,n.connectionToken);if(this._isITransport(t)){this._logger.log(z.Debug,`Connection was provided an instance of ITransport, using that directly.`),this.transport=t,await this._startTransport(i,r),this.connectionId=n.connectionId;return}let a=[],o=n.availableTransports||[],s=n;for(let n of o){let o=this._resolveTransportOrError(n,t,r,s?.useStatefulReconnect===!0);if(o instanceof Error)a.push(`${n.transport} failed:`),a.push(o);
46else if(this._isITransport(o)){if(this.transport=o,!s){try{s=await this._getNegotiationResponse(e)}catch(e){return Promise.reject(e)}i=this._createConnectUrl(e,s.connectionToken)}try{await this._startTransport(i,r),this.connectionId=s.connectionId;return}catch(e){if(this._logger.log(z.Error,`Failed to start the transport '${n.transport}': ${e}`),s=void 0,a.push(new Mt(`${n.transport} failed: ${e}`,X[n.transport])),this._connectionState!==`Connecting`){let e=`Failed to select transport before stop() was called.`;return this._logger.log(z.Debug,e),Promise.reject(new L(e))}}}}return a.length>0?Promise.reject(new Pt(`Unable to connect to the server with any of the available transports. ${a.join(` `)}`,a)):Promise.reject(Error(`None of the transports supported by the client are supported by the server.`))}_constructTransport(e){switch(e){case X.WebSockets:if(!this._options.WebSocket)throw Error(`'WebSocket' is not supported in your environment.`);return new pn(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case X.ServerSentEvents:if(!this._options.EventSource)throw Error(`'EventSource' is not supported in your environment.`);return new fn(this._httpClient,this._httpClient._accessToken,this._logger,this._options);case X.LongPolling:return new dn(this._httpClient,this._logger,this._options);default:throw Error(`Unknown transport: ${e}.`)}}_startTransport(e,t){return this.transport.onreceive=this.onreceive,this.features.reconnect?this.transport.onclose=async n=>{let r=!1;if(this.features.reconnect)try{this.features.disconnected(),await this.transport.connect(e,t),await this.features.resend()}catch{r=!0}else{this._stopConnection(n);return}r&&this._stopConnection(n)}:this.transport.onclose=e=>this._stopConnection(e),this.transport.connect(e,t)}_resolveTransportOrError(e,t,n,r){let i=X[e.transport];if(i==null)return this._logger.log(z.Debug,`Skipping transport '${e.transport}' because it is not supported by this client.`),Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);if(gn(t,i))if(e.transferFormats.map(e=>Z[e]).indexOf(n)>=0){if(i===X.WebSockets&&!this._options.WebSocket||i===X.ServerSentEvents&&!this._options.EventSource)return this._logger.log(z.Debug,`Skipping transport '${X[i]}' because it is not supported in your environment.'`),new At(`'${X[i]}' is not supported in your environment.`,i);this._logger.log(z.Debug,`Selecting transport '${X[i]}'.`);try{return this.features.reconnect=i===X.WebSockets?r:void 0,this._constructTransport(i)}catch(e){return e}}else return this._logger.log(z.Debug,`Skipping transport '${X[i]}' because it does not support the requested transfer format '${Z[n]}'.`),Error(`'${X[i]}' does not support ${Z[n]}.`);else return this._logger.log(z.Debug,`Skipping transport '${X[i]}' because it was disabled by the client.`),new jt(`'${X[i]}' is disabled by the client.`,i)}_isITransport(e){return e&&typeof e==`object`&&`connect`in e}_stopConnection(e){if(this._logger.log(z.Debug,`HttpConnection.stopConnection(${e}) called while in state ${this._connectionState}.`),this.transport=void 0,e=this._stopError||e,this._stopError=void 0,this._connectionState===`Disconnected`){this._logger.log(z.Debug,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is already in the disconnected state.`);return}if(this._connectionState===`Connecting`)throw this._logger.log(z.Warning,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is still in the connecting state.`),Error(`HttpConnection.stopConnection(${e}) was called while the connection is still in the connecting state.`);if(this._connectionState===`Disconnecting`&&this._stopPromiseResolver(),e?this._logger.log(z.Error,`Connection disconnected with error '${e}'.`):this._logger.log(z.Information,`Connection disconnected.`),this._sendQueue&&(this._sendQueue.stop().catch(e=>{this._logger.log(z.Error,`TransportSendQueue.stop() threw error '${e}'.`)}),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState=`Disconnected`,this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(e)}catch(t){this._logger.log(z.Error,`HttpConnection.onclose(${e}) threw error '${t}'.`)}}}_resolveUrl(e){if(e.lastIndexOf(`https://`,0)===0||e.lastIndexOf(`http://`,0)===0)return e;if(!H.isBrowser)throw Error(`Cannot resolve '${e}'.`);let t=window.document.createElement(`a`);return t.href=e,this._logger.log(z.Information,`Normalizing '${e}' to '${t.href}'.`),t.href}_resolveNegotiateUrl(e){let t=new URL(e);t.pathname.endsWith(`/`)?t.pathname+=`negotiate`:t.pathname+=`/negotiate`;let n=new URLSearchParams(t.searchParams);return n.has(`negotiateVersion`)||n.append(`negotiateVersion`,this._negotiateVersion.toString()),n.has(`useStatefulReconnect`)?n.get(`useStatefulReconnect`)===`true`&&(this._options._useStatefulReconnect=!0):this._options._useStatefulReconnect===!0&&n.append(`useStatefulReconnect`,`true`),t.search=n.toString(),t.toString()}};function gn(e,t){return!e||(t&e)!==0}var _n=class e{constructor(e){this._transport=e,this._buffer=[],this._executing=!0,this._sendBufferedData=new vn,this._transportResult=new vn,this._sendLoopPromise=this._sendLoop()}send(e){return this._bufferData(e),this._transportResult||(this._transportResult=new vn),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(e){if(this._buffer.length&&typeof this._buffer[0]!=typeof e)throw Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);this._buffer.push(e),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject(`Connection stopped.`);break}this._sendBufferedData=new vn;let t=this._transportResult;this._transportResult=void 0;let n=typeof this._buffer[0]==`string`?this._buffer.join(``):e._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(n),t.resolve()}catch(e){t.reject(e)}}}static _concatBuffers(e){let t=e.map(e=>e.byteLength).reduce((e,t)=>
46e+t),n=new Uint8Array(t),r=0;for(let t of e)n.set(new Uint8Array(t),r),r+=t.byteLength;return n.buffer}},vn=class{constructor(){this.promise=new Promise((e,t)=>[this._resolver,this._rejecter]=[e,t])}resolve(){this._resolver()}reject(e){this._rejecter(e)}},yn=`json`,bn=class{constructor(){this.name=yn,this.version=2,this.transferFormat=Z.Text}parseMessages(e,t){if(typeof e!=`string`)throw Error(`Invalid input for JSON hub protocol. Expected a string.`);if(!e)return[];t===null&&(t=B.instance);let n=K.parse(e),r=[];for(let e of n){let n=JSON.parse(e);if(typeof n.type!=`number`)throw Error(`Invalid payload.`);switch(n.type){case q.Invocation:this._isInvocationMessage(n);break;case q.StreamItem:this._isStreamItemMessage(n);break;case q.Completion:this._isCompletionMessage(n);break;case q.Ping:break;case q.Close:break;case q.Ack:this._isAckMessage(n);break;case q.Sequence:this._isSequenceMessage(n);break;default:t.log(z.Information,`Unknown message type '`+n.type+`' ignored.`);continue}r.push(n)}return r}writeMessage(e){return K.write(JSON.stringify(e))}_isInvocationMessage(e){this._assertNotEmptyString(e.target,`Invalid payload for Invocation message.`),e.invocationId!==void 0&&this._assertNotEmptyString(e.invocationId,`Invalid payload for Invocation message.`)}_isStreamItemMessage(e){if(this._assertNotEmptyString(e.invocationId,`Invalid payload for StreamItem message.`),e.item===void 0)throw Error(`Invalid payload for StreamItem message.`)}_isCompletionMessage(e){if(e.result&&e.error)throw Error(`Invalid payload for Completion message.`);!e.result&&e.error&&this._assertNotEmptyString(e.error,`Invalid payload for Completion message.`),this._assertNotEmptyString(e.invocationId,`Invalid payload for Completion message.`)}_isAckMessage(e){if(typeof e.sequenceId!=`number`)throw Error(`Invalid SequenceId for Ack message.`)}_isSequenceMessage(e){if(typeof e.sequenceId!=`number`)throw Error(`Invalid SequenceId for Sequence message.`)}_assertNotEmptyString(e,t){if(typeof e!=`string`||e===``)throw Error(t)}},xn={trace:z.Trace,debug:z.Debug,info:z.Information,information:z.Information,warn:z.Warning,warning:z.Warning,error:z.Error,critical:z.Critical,none:z.None};function Sn(e){let t=xn[e.toLowerCase()];if(t!==void 0)return t;throw Error(`Unknown log level: ${e}`)}var Cn=class{configureLogging(e){if(V.isRequired(e,`logging`),wn(e))this.logger=e;else if(typeof e==`string`){let t=Sn(e);this.logger=new Vt(t)}else this.logger=new Vt(e);return this}withUrl(e,t){return V.isRequired(e,`url`),V.isNotEmpty(e,`url`),this.url=e,typeof t==`object`?this.httpConnectionOptions={...this.httpConnectionOptions,...t}:this.httpConnectionOptions={...this.httpConnectionOptions,transport:t},this}withHubProtocol(e){return V.isRequired(e,`protocol`),this.protocol=e,this}withAutomaticReconnect(e){if(this.reconnectPolicy)throw Error(`A reconnectPolicy has already been set.`);return e?Array.isArray(e)?this.reconnectPolicy=new cn(e):this.reconnectPolicy=e:this.reconnectPolicy=new cn,this}withServerTimeout(e){return V.isRequired(e,`milliseconds`),this._serverTimeoutInMilliseconds=e,this}withKeepAliveInterval(e){return V.isRequired(e,`milliseconds`),this._keepAliveIntervalInMilliseconds=e,this}withStatefulReconnect(e){return this.httpConnectionOptions===void 0&&(this.httpConnectionOptions={}),this.httpConnectionOptions._useStatefulReconnect=!0,this._statefulReconnectBufferSize=e?.bufferSize,this}build(){let e=this.httpConnectionOptions||{};if(e.logger===void 0&&(e.logger=this.logger),!this.url)throw Error(`The 'HubConnectionBuilder.withUrl' method must be called before building the connection.`);let t=new hn(this.url,e);return on.create(t,this.logger||B.instance,this.protocol||new bn,this.reconnectPolicy,this._serverTimeoutInMilliseconds,this._keepAliveIntervalInMilliseconds,this._statefulReconnectBufferSize)}};function wn(e){return e.log!==void 0}var Tn=class{constructor(e){this._tag=e,this.debug=(e,...t)=>{console.debug(`[${this.tag}] ${e}`,...t)},this.log=(e,...t)=>{console.log(`[${this.tag}] ${e}`,...t)}}get tag(){return typeof this._tag==`function`?this._tag():this._tag}},En=class{constructor(e,t){this._tag=e,this._logLevel=t,this.debug=(e,...t)=>{console.debug(`[${this.tag}] ${e}`,...t)}}get tag(){return typeof this._tag==`function`?this._tag():this._tag}log(e,t){if(!(e<this._logLevel))switch(e){case z.Critical:case z.Error:console.error(`[${this.tag}] [${z[e]}] ${t}`);break;case z.Warning:console.warn(`[${this.tag}] [${z[e]}] ${t}`);break;case z.Information:console.info(`[${this.tag}] [${z[e]}] ${t}`);break;case z.Debug:console.debug(`[${this.tag}] [${z[e]}] ${t}`);break;case z.Trace:console.trace(`[${this.tag}] [${z[e]}] ${t}`);break;default:console.log(`[${this.tag}] [Unknown(${e})] ${t}`);break}}},Dn,On=3e4,kn=256,An=`_localEchoId`,Q=class extends _e{sendLocal(e){this._logger.debug(`Sending local message ${e.name}`);let t=`${this.id}:${++this._localEchoSeq}`;e[An]=t,this._registerPendingEcho(t),this.sendToSubscribers(e),this.postMessage({type:`signalr-message`,message:e})}_registerPendingEcho(e){let t=Date.now();for(let[e,n]of this._pendingLocalEchoes)n<=t&&this._pendingLocalEchoes.delete(e);
46if(this._pendingLocalEchoes.size>=kn){let e=this._pendingLocalEchoes.keys().next().value;e!==void 0&&this._pendingLocalEchoes.delete(e)}this._pendingLocalEchoes.set(e,t+On)}constructor(e){super(),this.memberService=e,this._logger=new Tn(()=>`MessageBus`),this.worker=null,this.port=null,this.id=xe(),this._pendingLocalEchoes=new Map,this._localEchoSeq=0,this.environmentName=window.trainerRoad.messageBusEnv,this._started=!1,this._status=T.Disconnected,this.handleWorkerMessage=e=>{try{switch(e.type){case`status`:this._status=e.status;break;case`signalr-message`:{let t=e.message[An];if(t!=null&&this._pendingLocalEchoes.delete(t))break;this._logger.debug(`Received message from worker: ${e.message.name}`),this.sendToSubscribers(e.message);break}default:break}}catch(e){console.error(`Error handling worker message:`,e)}},g(this),window.addEventListener(`beforeunload`,()=>{this.port&&(this.port.postMessage({type:`disconnect`}),this.port.close(),this.port=null),this.worker=null})}postMessage(e){if(this.port)try{this.port.postMessage(e)}catch(e){console.error(`Error posting message to shared worker:`,e)}}get status(){return this._status}get started(){return this._status===T.Connected}start(){return this._started||this.memberService.memberInfo===null?Promise.resolve():(this.worker=new SharedWorker(new URL(``+window.location.origin+`/app/assets/generated/react/assets/shared-worker-signal-connection-knm5tg2l.js`,``+import.meta.url),{type:`module`,credentials:`same-origin`}),this.port=this.worker.port,this.port.onmessage=e=>{try{this.handleWorkerMessage(e.data)}catch(e){console.error(`Error handling message from shared worker:`,e)}},this.port.start(),this._started=!0,this.postMessage({type:`init`,environment:this.environmentName,memberId:this.memberService.memberInfo.memberId}),Promise.resolve())}};S([h,x(`design:type`,Object)],Q.prototype,`_status`,void 0),S([_,x(`design:type`,Object),x(`design:paramtypes`,[])],Q.prototype,`status`,null),S([_,x(`design:type`,Object),x(`design:paramtypes`,[])],Q.prototype,`started`,null),S([ee,x(`design:type`,Object)],Q.prototype,`handleWorkerMessage`,void 0),Q=S([n(),be(0,r(E)),x(`design:paramtypes`,[typeof(Dn=E!==void 0&&E)==`function`?Dn:Object])],Q);var jn=class{constructor(e){this.callbacks=e,this._currentMemberId=null,this._processing=!1,this._buffer=[],this.handleMessage=async e=>{switch(e.name){case D.ActivityMatched:if(this._currentMemberId===null){console.warn(`Cannot fetch activity data: member ID is null`);break}try{let{id:t,oldActivityId:n,plannedId:r}=e.params,i={};if(t==null?i.plannedActivity=await d(r):i.activity=await p(this._currentMemberId,t),n!=null)try{i.oldMatchedActivity=await p(this._currentMemberId,n)}catch{}e.apiData=i}catch(t){console.error(`Failed to fetch activity data for message:`,e,t)}break;case D.PlannedActivityFlushForwardComplete:case D.PlannedActivityAdded:case D.PlannedActivityUpdated:if(this._currentMemberId===null){console.warn(`Cannot fetch planned activity data: member ID is null`);break}try{e.apiData=await d(e.params.stub.id)}catch(t){console.error(`Failed to fetch planned activity data for message:`,e,t)}break;case D.FlushForwardV2Complete:{let t=this._currentMemberId;if(t===null){console.warn(`Cannot fetch planned activity data: member ID is null`);break}try{e.apiData=await O([...e.params.plannedActivityIds],e=>m(t,e,!1))}catch(t){console.error(`Failed to fetch planned activity data for message:`,e,t)}break}case D.AnnotationAdded:case D.AnnotationUpdated:try{e.apiData=await c(e.params.stub.id)}catch(t){console.error(`Failed to fetch annotation data for message:`,e,t)}break;case D.EventAdded:case D.EventUpdated:if(this._currentMemberId===null){console.warn(`Cannot fetch event data: member ID is null`);break}try{e.apiData=await u(this._currentMemberId,e.params.id)}catch(t){console.error(`Failed to fetch event data for message:`,e,t)}break;case D.RecurrenceAdded:try{e.apiData=await f(e.params.stub.id,{})}catch(t){console.error(`Failed to fetch recurrence data for message:`,e,t)}break;case D.ReapplyPlan:{let t=this._currentMemberId;if(t===null){console.warn(`Cannot fetch reapply plan data: member ID is null`);break}try{e.apiData={plannedActivities:await O([...e.params.plannedActivities.added],e=>m(t,e)),annotations:await O([...e.params.annotations.added],e=>l(t,e))}}catch(t){console.error(`Failed to fetch reapply plan data for message:`,e,t)}break}case D.CalendarWeekCopied:if(this._currentMemberId===null){console.warn(`Cannot fetch week copy data: member ID is null`);break}try{e.apiData=await O([...e.params.plannedActivityIds],e=>m(this._currentMemberId,e))}catch(t){console.error(`Failed to fetch week copy data for message:`,e,t)}break;case D.CalendarWeekMoved:if(this._currentMemberId===null){console.warn(`Cannot fetch week move data: member ID is null`);break}try{e.apiData=await O([...e.params.movedActivityIds],e=>m(this._currentMemberId,e))}catch(t){console.error(`Failed to fetch week move data for message:`,e,t)}break;case D.CalendarWeekDeleted:break;case D.ActivityDetailsUpdated:if(this._currentMemberId===null){console.warn(`Cannot fetch activity data: member ID is null`);break}try{e.apiData=await p(this._currentMemberId,e.params.id,!1)}catch(t){console.error(`Failed to fetch activity data for message:`,e,t)}break;default:break}this.callbacks.onMessage(e)}}setCurrentUser(e){this._currentMemberId=e}async enqueue(e){this._buffer.push(e),await this.processBuffer()}async processBuffer(){if(!this._processing){this._processing=!0;try{for(;this._buffer.length>0;){let e=this._buffer.shift();try{await this.handleMessage(e)}catch(t){console.error(`Error processing message:`,e,t)}}}finally{this._processing=!1}}}},Mn=[0,1,2,5],Nn=class{constructor(e,t){this.callbacks=t,this._status=T.Disconnected,this._retryCount=0,this._retryTimeout=null,this._starting=!1,this._connectionDesired=!0,this._environment=null,this._currentMemberId=null,this._logger=new En(()=>`MessageBus`,z.Warning),this.messageReceived=async e=>{await this._messageProcessor.enqueue(e)},this.connectionClosed=e=>{console.debug(`SignalR Connection has been closed`,e),this._starting=!1,this.setStatus(T.Disconnected),this.setTimeoutToStart()},this.reconnected=e=>{console.debug(`SignalR Connection has been reconnected`,e),this._retryCount=0,this._retryTimeout!==null&&(clearTimeout(this._retryTimeout),this._retryTimeout=null),this.setStatus(T.Connected)},this.reconnecting=e=>{console.debug(`SignalR Connection reconnecting`,e),this.setStatus(T.Connecting)},this._messageProcessor=new jn(t),this._connection=new Cn().withUrl(e).withAutomaticReconnect({
46nextRetryDelayInMilliseconds:e=>Math.min(1e3*2**Math.min(5,e.previousRetryCount),3e4)}).configureLogging(this._logger).build(),this._connection.onreconnected(this.reconnected),this._connection.onreconnecting(this.reconnecting),this._connection.onclose(this.connectionClosed)}setEnvironment(e,t){this._connectionDesired=!0;let n=this._environment===null||this._environment!==e,r=this._currentMemberId!==null&&this._currentMemberId!==t;n&&(this._environment!==null&&(this._connection.off(`${this._environment}_receive`,this.messageReceived),this._connection.off(`${this._environment}_test`,this.messageReceived)),this._environment=e,this._connection.on(`${this._environment}_receive`,this.messageReceived),this._connection.on(`${this._environment}_test`,this.messageReceived)),this._messageProcessor.setCurrentUser(t),r?(console.debug(`Member ID changed from ${this._currentMemberId} to ${t}, reconnecting...`),this._currentMemberId=t,this.reconnect()):(this._currentMemberId=t,this.start())}get status(){return this._status}get started(){return this._status===T.Connected}async start(){if(this._connectionDesired&&(this._retryTimeout!==null&&(clearTimeout(this._retryTimeout),this._retryTimeout=null),!(this.started||this._starting))){this._starting=!0,this.setStatus(T.Connecting);try{await this._connection.start(),this.setStatus(T.Connected),this._retryCount=0,this._starting=!1}catch(e){console.error(`Error starting message bus connection`,e),this._starting=!1,this.setTimeoutToStart()}}}async stop(){this._connectionDesired=!1,this._retryTimeout!==null&&(clearTimeout(this._retryTimeout),this._retryTimeout=null),await this._connection.stop()}async reconnect(){try{await this._connection.stop(),this._retryCount=0,await this.start()}catch(e){console.error(`Error during reconnect:`,e),this.connectionClosed(e)}}resetRetryCount(){this._retryCount=0}get isConnecting(){return this._starting||this._retryTimeout!==null}clearRetryTimeout(){this._retryTimeout!==null&&(clearTimeout(this._retryTimeout),this._retryTimeout=null)}setTimeoutToStart(){if(!this._connectionDesired)return;this._retryTimeout!==null&&clearTimeout(this._retryTimeout);let e=Mn[Math.min(this._retryCount,Mn.length-1)];this._retryTimeout=setTimeout(()=>this.start(),e*1e3),++this._retryCount}setStatus(e){this._status=e,this.callbacks.onStatusChange(e)}},Pn,Fn,$=class extends _e{sendLocal(e){this.sendToSubscribers(e)}start(){return this.applyMember(this.memberService.memberInfo?.memberId??null),Promise.resolve()}applyMember(e){if(e===null){this._connectionManager.stop();return}this._connectionManager.setEnvironment(this.environmentName,e)}get status(){return this._status}get started(){return this._status===T.Connected}constructor(e){super(),this.memberService=e,this._logger=new En(()=>`MessageBus`,z.Warning),this._status=T.Disconnected,this.environmentName=window.trainerRoad.messageBusEnv,this.handleStatusChange=e=>{this.setStatus(e)},this.handleMessage=e=>{this.sendToSubscribers(e)},this._connectionManager=new Nn(`/app/api/signalr/productsite`,{onStatusChange:this.handleStatusChange,onMessage:this.handleMessage}),g(this),v(()=>this.memberService.memberInfo?.memberId??null,e=>this.applyMember(e),{fireImmediately:!0})}setStatus(e){this._status=e}};S([h,x(`design:type`,Object)],$.prototype,`_status`,void 0),S([_,x(`design:type`,Object),x(`design:paramtypes`,[])],$.prototype,`status`,null),S([_,x(`design:type`,Object),x(`design:paramtypes`,[])],$.prototype,`started`,null),S([ee,x(`design:type`,Function),x(`design:paramtypes`,[typeof(Fn=T!==void 0&&T)==`function`?Fn:Object]),x(`design:returntype`,void 0)],$.prototype,`setStatus`,null),$=S([n(),be(0,r(E)),x(`design:paramtypes`,[typeof(Pn=E!==void 0&&E)==`function`?Pn:Object])],$);function In(){return window.tr?.appInfo}var Ln=`/app/api/marketing/realtime-logging/info`,Rn=`tr:embedded-ready`,zn=`readyMs`,Bn=new Set([`blank`,`root`]),Vn=6e4,Hn=!1;function Un(e){if(Hn||typeof window>`u`||typeof PerformanceObserver>`u`)return;let{surface:t,sampleRate:n=1}=e;if(n<1&&Math.random()>=n)return;Hn=!0,Jn();let r=ar(window.location.pathname),i=window.__embeddedWasHidden===!0||document.visibilityState===`hidden`,a,o,s,c=0,l=0,u=0,d=0,f=0,p=0,m=document.readyState===`complete`?performance.now():1/0,h=()=>{m=performance.now()};m===1/0&&window.addEventListener(`load`,h,{once:!0});let g=new Set,_=PerformanceObserver.supportedEntryTypes??[],ee=[],v=(e,t)=>
46{if(_.includes(e))try{let n=new PerformanceObserver(e=>t(e.getEntries()));n.observe({type:e,buffered:!0}),ee.push({observer:n,handle:t}),g.add(e)}catch{}};v(`paint`,e=>{for(let t of e)t.name===`first-contentful-paint`&&(a=t.startTime)}),v(`largest-contentful-paint`,e=>{for(let t of e)s=t.startTime,!(t.startTime>Vn)&&(o=t.startTime)}),v(`layout-shift`,e=>{for(let t of e){if(t.hadRecentInput||t.startTime>m)continue;let e=t.startTime;d>0&&e-f<5e3&&e-p<1e3?d+=t.value:(d=t.value,f=e),p=e,d>u&&(u=d)}}),v(`longtask`,e=>{for(let t of e)t.startTime>m||(c+=1,l+=t.duration)});let te=!1,ne=()=>{if(te)return;te=!0,document.removeEventListener(`visibilitychange`,re),window.removeEventListener(`pagehide`,ne),window.removeEventListener(`load`,h);for(let{observer:e,handle:t}of ee){let n=e.takeRecords();n.length>0&&t(n),e.disconnect()}let e=performance.getEntriesByType(`navigation`)[0],n=e=>typeof e==`number`&&isFinite(e)?Math.round(e):void 0,d=e=>typeof e==`number`&&isFinite(e)&&e>0?Math.round(e):void 0,f=In();or({surface:t,host:er(f),route:Bn.has(r)?ar(window.location.pathname):r,appVersion:nr(),...Zn(f),hostArch:Kn,entryChunk:ir(),bootPaint:rr(),hiddenBeforeArm:i,fcp:n(a),lcp:n(o),lcpRaw:n(s),cls:g.has(`layout-shift`)?Math.round(u*1e3)/1e3:void 0,longTasksCount:g.has(`longtask`)?c:void 0,longTasksTotalMs:g.has(`longtask`)?n(l):void 0,ttfb:d(e?.responseStart),domInteractive:d(e?.domInteractive),domContentLoaded:d(e?.domContentLoadedEventEnd),load:d(e?.loadEventEnd),[zn]:Gn()})},re=()=>{document.visibilityState===`hidden`&&ne()};document.addEventListener(`visibilitychange`,re),window.addEventListener(`pagehide`,ne)}function Wn(){try{performance.mark(Rn)}catch{}return Gn()}function Gn(){try{let e=performance.getEntriesByName(Rn,`mark`)[0];return e?Math.round(e.startTime):void 0}catch{return}}var Kn,qn={"x86/64":`x64`,"x86/32":`ia32`,"arm/64":`arm64`,"arm/32":`arm`};async function Jn(){try{let e=await navigator.userAgentData?.getHighEntropyValues?.([`architecture`,`bitness`]);Kn=qn[`${e?.architecture}/${e?.bitness}`]}catch{}}var Yn=RegExp(`^(\\S+) (\\S+) (${Object.values(qn).join(`|`)})$`),Xn=/^(?:iOS|Android) ([^;\s]+)/;function Zn(e){switch(er(e)){case`electron`:{let t=Yn.exec($n(e?.osVersion));return t?{osFamily:t[1],osRelease:t[2],binaryArch:t[3]}:{}}case`reactnative`:return Qn(e);default:return{}}}function Qn(e){let t=ct(e?.platform);return t?{osFamily:t,osRelease:Xn.exec($n(e?.os))?.[1]}:{}}function $n(e){return typeof e==`string`?e.trim():``}function er(e){return e?.isElectron?`electron`:e?.isReactNative?`reactnative`:`web`}function tr(){return er(In())}function nr(){return In()?.version||void 0}function rr(){return document.querySelector(`.boot-spinner`)?`document`:`app`}function ir(){try{let e=Array.from(document.querySelectorAll(`script[type="module"][src]`));for(let t of e){let e=new URL(t.src).pathname;if(e.includes(`/assets/generated/react/`))return e.split(`/`).pop()||void 0}return}catch{return}}function ar(e){let t=new Set([`app`,`embedded`,`shell`]);return e.split(`/`).filter(Boolean).map(e=>e.toLowerCase()).find(e=>!t.has(e))??`root`}function or(e){let t=JSON.stringify({message:`web-vitals`,data:e});try{fetch(Ln,{method:`POST`,credentials:`same-origin`,keepalive:!0,headers:{"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`,...o()},body:t}).catch(()=>{})}catch{}}var sr=`scriptErrorRefreshCount`,cr=`vitePreloadErrorCount`,lr=`vitePreloadOnDemandReloadCount`;function ur(){try{return window.sessionStorage}catch{return null}}var dr=/^\d{1,15}$/;function fr(e){if(!e)return 6;try{let t=e.getItem(lr),n=t===null||t===``;if(!n&&!dr.test(t))return 6;let r=(n?0:parseInt(t,10))+1;return e.setItem(lr,r.toString()),r}catch{return 6}}var pr=(e,t)=>{if(e!=null)return e.length>t?e.slice(0,t):e};function mr(e,t){let n=1;try{if(t.storage){let e=t.storage.getItem(`vitePreloadErrorCount`)||`0`,r=parseInt(e,10);n=(Number.isFinite(r)&&r>=0?r:0)+1,t.storage.setItem(cr,n.toString())}}catch{}let r=e.payload?.message,i,a,o;try{i=e.payload?.name;let t=typeof r==`string`?r.match(/https?:\/\/[^\s)'"]+/):null;a=t?t[0]:void 0,o=pr(e.payload?.cause?.message,256)}catch{}return(n===1?t.warnLog:t.errorLog)({message:`vite preload error`,data:{refreshCount:n,errorMessage:pr(r,512),errorStack:pr(e.payload?.stack,1024),errorName:i,chunkUrl:a,causeMessage:o}}).catch(s),n}function hr(e,t){let n=t.storage===void 0?ur():t.storage;if(mr(e,{errorLog:t.errorLog,warnLog:t.warnLog,storage:n}),i())return;t.cancelBudgetReset();let r=fr(n);if(r<=5){window.vitePreloadError=e;let n=r**2*1e3;
46console.log(`Reloading page in ${n} ms due to script load error (attempt ${r})`);let i=t.reload;setTimeout(()=>{if(i){i();return}window.location.reload()},n)}else console.error(`Script load error:`,e)}export{Ve as A,ct as C,et as D,nt as E,Ge as O,lt as S,it as T,gt as _,mr as a,bt as b,tr as c,$ as d,jn as f,_t as g,Ot as h,hr as i,He as k,Wn as l,Tn as m,lr as n,ur as o,Q as p,sr as r,zn as s,cr as t,Un as u,vt as v,ot as w,ft as x,yt as y}; 47//# sourceMappingURL=product-e8ibq427.js.map
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.