1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,949892,t=>{"use strict";var e=t.i(40358);let s=(0,e.createServerReference)("7f84bdcf130ec50bd3cc3f1115271760a2e48dbe14",e.callServer,void 0,e.findSourceMapURL,"updateSubscriptionCancellation");t.s(["updateSubscriptionCancellation",0,s])},474970,t=>{"use strict";var e,s,r=t.i(691008),i=t.i(438188),n=t.i(448929),o=t.i(259430),a=t.i(572141),c=a.useLayoutEffect;class l{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){let e={value:t,next:null};if(this._current){this._last.next=e,this._last=e;return}this._current=e,this._last=e,this._active&&this.flush()}flush(){for(;this._current;){let t=this._current;this._process(t.value),this._current=t.next}this._last=null}}let u="xstate.init",d="xstate.stop";function h(t,e){return{type:`xstate.done.state.${t}`,output:e}}function p(t,e){return{type:`xstate.error.actor.${t}`,error:e,actorId:t}}function f(t){return{type:u,input:t}}function g(t){setTimeout(()=>{throw t})}let y="function"==typeof Symbol&&Symbol.observable||"@@observable";function m(t){if(I(t))return t;let e=[],s="";for(let r=0;r<t.length;r++){switch(t.charCodeAt(r)){case 92:s+=t[r+1],r++;continue;case 46:e.push(s),s="";continue}s+=t[r]}return e.push(s),e}function v(t){var e;return(e=t)&&"object"==typeof e&&"machine"in e&&"value"in e?t.value:"string"!=typeof t?t:function(t){if(1===t.length)return t[0];let e={},s=e;for(let e=0;e<t.length-1;e++)if(e===t.length-2)s[t[e]]=t[e+1];else{let r=s;s={},r[t[e]]=s}return e}(m(t))}function _(t,e){let s={},r=Object.keys(t);for(let i=0;i<r.length;i++){let n=r[i];s[n]=e(t[n],n,t,i)}return s}function b(t){var e;return void 0===t?[]:I(e=t)?e:[e]}function S(t,e,s,r){return"function"==typeof t?t({context:e,event:s,self:r}):t}function I(t){return Array.isArray(t)}function w(t){var e;return(I(e=t)?e:[e]).map(t=>void 0===t||"string"==typeof t?{target:t}:t)}function C(t){if(void 0!==t&&""!==t)return b(t)}function x(t,e,s){let r="object"==typeof t,i=r?t:void 0;return{next:(r?t.next:t)?.bind(i),error:(r?t.error:e)?.bind(i),complete:(r?t.complete:s)?.bind(i)}}function E(t,e){let s=e.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!s)return t.implementations.actors[e];let[,r,i]=s,n=t.getStateNodeById(i).config.invoke;return(Array.isArray(n)?n[r]:n).src}function k(t,e){return`${t.sessionId}.${e}`}let P=0,A=!1,T=((e={})[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e),O={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class R{constructor(t,e){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new l(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=T.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const s={...O,...e},{clock:r,logger:i,parent:n,syncSnapshot:o,id:a,systemId:c,inspect:u}=s;this.system=n?n.system:function(t,e){let s=new Map,r=new Map,i=new WeakMap,n=new Set,o={},{clock:a,logger:c}=e,l={schedule:(t,e,s,r,i=Math.random().toString(36).slice(2))=>{let n={source:t,target:e,event:s,delay:r,id:i,startedAt:Date.now()},c=k(t,i);u._snapshot._scheduledEvents[c]=n;let l=a.setTimeout(()=>{delete o[c],delete u._snapshot._scheduledEvents[c],u._relay(t,e,s)},r);o[c]=l},cancel:(t,e)=>{let s=k(t,e),r=o[s];delete o[s],delete u._snapshot._scheduledEvents[s],void 0!==r&&a.clearTimeout(r)},cancelAll:t=>{for(let e in u._snapshot._scheduledEvents){let s=u._snapshot._scheduledEvents[e];s.source===t&&l.cancel(t,s.id)}}},u={_snapshot:{_scheduledEvents:(e?.snapshot&&e.snapshot.scheduler)??{}},_bookId:()=>`x:${P++}`,_register:(t,e)=>(s.set(t,e),t),_unregister:t=>{s.delete(t.sessionId);let e=i.get(t);void 0!==e&&(r.delete(e),i.delete(t))},get:t=>r.get(t),getAll:()=>Object.fromEntries(r.entries()),_set:(t,e)=>{let s=r.get(t);if(s&&s!==e)throw Error(`Actor with system ID '${t}' already exists.`);r.set(t,e),i.set(e,t)},inspect:t=>{let e=x(t);return n.add(e),{unsubscribe(){n.delete(e)}}},_sendInspectionEvent:e=>{if(!n.size)return;let s={...e,rootId:t.sessionId};
1n.forEach(t=>t.next?.(s))},_relay:(t,e,s)=>{u._sendInspectionEvent({type:"@xstate.event",sourceRef:t,actorRef:e,event:s}),e._send(s)},scheduler:l,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{let t=u._snapshot._scheduledEvents;for(let e in u._snapshot._scheduledEvents={},t){let{source:s,target:r,event:i,delay:n,id:o}=t[e];l.schedule(s,r,i,n,o)}},_clock:a,_logger:c};return u}(this,{clock:r,logger:i}),u&&!n&&this.system.inspect(x(u)),this.sessionId=this.system._bookId(),this.id=a??this.sessionId,this.logger=e?.logger??this.system._logger,this.clock=e?.clock??this.system._clock,this._parent=n,this._syncSnapshot=o,this.options=s,this.src=s.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:t=>{this._deferred.push(t)},system:this.system,stopChild:t=>{if(t._parent!==this)throw Error(`Cannot stop child actor ${t.id} of ${this.id} because it is not a child`);t._stop()},emit:t=>{let e=this.eventListeners.get(t.type),s=this.eventListeners.get("*");if(e||s)for(let r of[...e?e.values():[],...s?s.values():[]])try{r(t)}catch(t){g(t)}},actionExecutor:t=>{let e=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:t.type,params:t.params}}),!t.exec)return;let e=A;try{A=!0,t.exec(t.info,t.params)}finally{A=e}};this._processingStatus===T.Running?e():this._deferred.push(e)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(e?.snapshot??e?.state),c&&"active"!==this._snapshot.status&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(t){this._snapshot={status:"error",output:void 0,error:t}}}update(t,e){let s;for(this._snapshot=t;s=this._deferred.shift();)try{s()}catch(e){this._deferred.length=0,this._snapshot={...t,status:"error",error:e}}switch(this._snapshot.status){case"active":for(let e of this.observers)try{e.next?.(t)}catch(t){g(t)}break;case"done":var r;for(let e of this.observers)try{e.next?.(t)}catch(t){g(t)}this._stopProcedure(),this._complete(),this._doneEvent=(r=this.id,{type:`xstate.done.actor.${r}`,output:this._snapshot.output,actorId:r}),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error)}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:e,snapshot:t})}subscribe(t,e,s){let r=x(t,e,s);if(this._processingStatus!==T.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{r.complete?.()}catch(t){g(t)}break;case"error":{let t=this._snapshot.error;if(r.error)try{r.error(t)}catch(t){g(t)}else g(t)}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(t,e){let s=this.eventListeners.get(t);s||(s=new Set,this.eventListeners.set(t,s));let r=e.bind(void 0);return s.add(r),{unsubscribe:()=>{s.delete(r)}}}select(t,e=Object.is){return{subscribe:s=>{let r=x(s),i=t(this.getSnapshot());return this.subscribe(s=>{let n=t(s);e(i,n)||(i=n,r.next?.(n))})},get:()=>t(this.getSnapshot())}}start(){if(this._processingStatus===T.Running)return this;this._syncSnapshot&&this.subscribe({next:t=>{"active"===t.status&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:t})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=T.Running;let t=f(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(t){return this._snapshot={...this._snapshot,status:"error",error:t},this._error(t),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let e,s;try{e=this.logic.transition(this._snapshot,t,this._actorScope)}catch(t){s={err:t}}if(s){let{err:t}=s;this._snapshot={...this._snapshot,status:"error",error:t},this._error(t);return}this.update(e,t),t.type===d&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===T.Stopped||((this.mailbox.clear(),this._processingStatus===T.NotStarted)?this._processingStatus=T.Stopped:this.mailbox.enqueue({type:d}
1)),this}stop(){if(this._parent)throw Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let t of this.observers)try{t.complete?.()}catch(t){g(t)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||g(t),this.eventListeners.clear();return}let e=!1;for(let s of this.observers){let r=s.error;e||=!r;try{r?.(t)}catch(t){g(t)}}this.observers.clear(),this.eventListeners.clear(),e&&g(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,p(this.id,t))}_stopProcedure(){return this._processingStatus!==T.Running||(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new l(this._process.bind(this)),this._processingStatus=T.Stopped,this.system._unregister(this)),this}_send(t){this._processingStatus!==T.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){let{devTools:e}=this.options;e&&("function"==typeof e?e:e=>{if("u"<typeof window)return;let s=function(){let e="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:t.g;if(e.__xstate__)return e.__xstate__}();s&&s.register(e)})(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[y](){return this}getSnapshot(){return this._snapshot}}function L(t,...[e]){return new R(t,e)}function $(t,e,s,r,{sendId:i}){return[e,{sendId:"function"==typeof i?i(s,r):i},void 0]}function M(t,e){t.defer(()=>{t.system.scheduler.cancel(t.self,e.sendId)})}function N(t){function e(t,e){}return e.type="xstate.cancel",e.sendId=t,e.resolve=$,e.execute=M,e}function U(t,e,s,r,{id:i,systemId:n,src:o,input:a,syncSnapshot:c}){let l,u,d="string"==typeof o?E(e.machine,o):o,h="function"==typeof i?i(s):i;return d&&(u="function"==typeof a?a({context:e.context,event:s.event,self:t.self}):a,l=L(d,{id:h,src:o,parent:t.self,syncSnapshot:c,systemId:n,input:u})),[tE(e,{children:{...e.children,[h]:l}}),{id:i,systemId:n,actorRef:l,src:o,input:u},void 0]}function D(t,{actorRef:e}){e&&t.defer(()=>{e._processingStatus!==T.Stopped&&e.start()})}function F(...[t,{id:e,systemId:s,input:r,syncSnapshot:i=!1}={}]){function n(t,e){}return n.type="xstate.spawnChild",n.id=e,n.systemId=s,n.src=t,n.input=r,n.syncSnapshot=i,n.resolve=U,n.execute=D,n}function j(t,e,s,r,{actorRef:i}){let n="function"==typeof i?i(s,r):i,o="string"==typeof n?e.children[n]:n,a=e.children;return o&&(a={...a},delete a[o.id]),[tE(e,{children:a}),o,void 0]}function B(t,e){if(e){if(!function t(e,s){let r=s.getSnapshot();if(r&&"children"in r)for(let s of Object.values(r.children))t(e,s);e.system._unregister(s)}(t,e),e._processingStatus!==T.Running)return void t.stopChild(e);t.defer(()=>{t.stopChild(e)})}}function G(t){function e(t,e){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=j,e.execute=B,e}function V(t,{context:e,event:s},{guards:r}){return r.every(r=>W(r,e,s,t))}function z(t){function e(t,e){return!1}return e.check=V,e.guards=t,e}function W(t,e,s,r){let{machine:i}=r,n="function"==typeof t,o=n?t:i.implementations.guards["string"==typeof t?t:t.type];if(!n&&!o)throw Error(`Guard '${"string"==typeof t?t:t.type}' is not implemented.'.`);if("function"!=typeof o)return W(o,e,s,r);let a={context:e,event:s},c=n||"string"==typeof t?void 0:"params"in t?"function"==typeof t.params?t.params({context:e,event:s}):t.params:void 0;return"check"in o?o.check(r,a,o):o(a,c)}function H(t){return"atomic"===t.type||"final"===t.type}function J(t){return Object.values(t.states).filter(t=>"history"!==t.type)}function q(t,e){let s=[];if(e===t)return s;let r=t.parent;for(;r&&r!==e;)s.push(r),r=r.parent;return s}function K(t){let e=new Set(t),s=Y(e);for(let t of e)if("compound"!==t.type||s.get(t)&&s.get(t).length){if("parallel"===t.type){for(let s of J(t))if("history"!==s.type&&!e.has(s))for(let t of tr(s))e.add(t)}}else tr(t).forEach(t=>e.add(t));for(let t of e){let s=t.parent;for(;s;)e.add(s),s=s.parent}return e}function Y(t){let e=new Map;for(let s of t)e.has(s)||e.set(s,[]),s.parent&&(e.has(s.parent)||e.set(s.parent,[]),e.get(s.parent).push(s));return e}function Q(t,e){return function t(e,s){let r=s.get(e);if(!r)return{};if("compound"===e.type){let t=r[0];if(!t)return{};if(H(t))return t.key}let i={};for(let e of r)i[e.key]=t(e,s);return i}(t,Y(K(e)))}function X(t,e){return"compound"===e.type?J(e).some(e=>"final"===e.type&&t.has(e)):"parallel"===e.type?J(e).every(e=>X(t,e)):"final"===e.type}let Z=t=>"#"===t[0];function tt(t,e,s){let r=C(s.target),i=s.reenter??!1,n=function(t,e){if(void 0!==e)return e.map(e=>{if("string"!=typeof e)return e;if(Z(e))return t.machine.getStateNodeById(e);let s="."===e[0];if(s&&!t.parent)return to(t,e.slice(1));let r=s?t.key+e:e;if(t.parent)try{return to(t.parent,r)}catch(e){throw Error(`Invalid transition definition for state node '${t.id}': 2${e.message}`)}throw Error(`Invalid target: "${e}" is not a valid target from the root node. Did you mean ".${e}"?`)})}(t,r),o={...s,actions:b(s.actions),guard:s.guard,target:n,source:t,reenter
2:i,eventType:e,toJSON:()=>({...o,source:`#${t.id}`,target:n?n.map(t=>`#${t.id}`):void 0})};return o}function te(t){let e=C(t.config.target);return e?{target:e.map(e=>"string"==typeof e?to(t.parent,e):e)}:"parallel"===t.parent.type?{target:[t.parent]}:t.parent.initial}function ts(t){return"history"===t.type}function tr(t){let e=ti(t);for(let s of e)for(let r of q(s,t))e.add(r);return e}function ti(t){let e=new Set;return!function t(s){if(!e.has(s)){if(e.add(s),"compound"===s.type)t(s.initial.target[0]);else if("parallel"===s.type)for(let e of J(s))t(e)}}(t),e}function tn(t,e){if(Z(e))return t.machine.getStateNodeById(e);if(!t.states)throw Error(`Unable to retrieve child state '${e}' from '${t.id}'; no child states exist.`);let s=t.states[e];if(!s)throw Error(`Child state '${e}' does not exist on '${t.id}'`);return s}function to(t,e){if("string"==typeof e&&Z(e))try{return t.machine.getStateNodeById(e)}catch{}let s=m(e).slice(),r=t;for(;s.length;){let t=s.shift();if(!t.length)break;r=tn(r,t)}return r}function ta(t,e){if("string"==typeof e){let s=t.states[e];if(!s)throw Error(`State '${e}' does not exist on '${t.id}'`);return[t,s]}let s=Object.keys(e),r=s.map(e=>tn(t,e)).filter(Boolean);return[t.machine.root,t].concat(r,s.reduce((s,r)=>{let i=tn(t,r);if(!i)return s;let n=ta(i,e[r]);return s.concat(n)},[]))}function tc(t,e){let s=t;for(;s.parent&&s.parent!==e;)s=s.parent;return s.parent===e}function tl(t,e,s){let r=new Set;for(let i of t){let t=!1,n=new Set;for(let o of r)if(function(t,e){let s=new Set(t),r=new Set(e);for(let t of s)if(r.has(t))return!0;for(let t of r)if(s.has(t))return!0;return!1}(th([i],e,s),th([o],e,s)))if(tc(i.source,o.source))n.add(o);else{t=!0;break}if(!t){for(let t of n)r.delete(t);r.add(i)}}return Array.from(r)}function tu(t,e){if(!t.target)return[];let s=new Set;for(let r of t.target)if(ts(r))if(e[r.id])for(let t of e[r.id])s.add(t);else for(let t of tu(te(r),e))s.add(t);else s.add(r);return[...s]}function td(t,e){let s=tu(t,e);if(!s)return;if(!t.reenter&&s.every(e=>e===t.source||tc(e,t.source)))return t.source;let r=function(t){let[e,...s]=t;for(let t of q(e,void 0))if(s.every(e=>tc(e,t)))return t}(s.concat(t.source));return r||(t.reenter?void 0:t.source.machine.root)}function th(t,e,s){let r=new Set;for(let i of t)if(i.target?.length){let t=td(i,s);for(let s of(i.reenter&&i.source===t&&r.add(t),e))tc(s,t)&&r.add(s)}return[...r]}function tp(t,e,s,r,i,n){let o=[];if(!t.length)return[e,o];let a=s.actionExecutor;s.actionExecutor=t=>{o.push(t),a(t)};try{let a=new Set(e._nodes),c=e.historyValue,l=tl(t,a,c),u=e;i||([u,c]=function(t,e,s,r,i,n,o,a){let c,l=t,u=th(r,i,n);for(let t of(u.sort((t,e)=>e.order-t.order),u))for(let e of function(t){return Object.keys(t.states).map(e=>t.states[e]).filter(t=>"history"===t.type)}(t)){let s;s="deep"===e.history?e=>H(e)&&tc(e,t):e=>e.parent===t,(c??={...n})[e.id]=Array.from(i).filter(s)}for(let t of u)l=ty(l,e,s,[...t.exit,...t.invoke.map(t=>G(t.id))],o,void 0),i.delete(t);return[l,c||n]}(u,r,s,l,a,c,n,s.actionExecutor)),u=ty(u,r,s,l.flatMap(t=>t.actions),n,void 0),u=function(t,e,s,r,i,n,o,a){let c=t,l=new Set,u=new Set;(function(t,e,s,r){for(let i of t){let t=td(i,e);for(let n of i.target||[])!ts(n)&&(i.source!==n||i.source!==t||i.reenter)&&(r.add(n),s.add(n)),tf(n,e,s,r);for(let n of tu(i,e)){let o=q(n,t);t?.type==="parallel"&&o.push(t),tg(r,e,s,o,!i.source.parent&&i.reenter?void 0:t)}}})(r,o,u,l),a&&u.add(t.machine.root);let d=new Set;for(let t of[...l].sort((t,e)=>t.order-e.order)){i.add(t);let r=[];for(let e of(r.push(...t.entry),t.invoke))r.push(F(e.src,{...e,syncSnapshot:!!e.onSnapshot}));if(u.has(t)){let e=t.initial.actions;r.push(...e)}if(c=ty(c,e,s,r,n,t.invoke.map(t=>t.id)),"final"===t.type){let r=t.parent,o=r?.type==="parallel"?r:r?.parent,a=o||t;for(r?.type==="compound"&&n.push(h(r.id,void 0!==t.output?S(t.output,c.context,e,s.self):void 0));o?.type==="parallel"&&!d.has(o)&&X(i,o);)d.add(o),n.push(h(o.id)),a=o,o=o.parent;if(o)continue;c=tE(c,{status:"done",output:function(t,e,s,r,i){if(void 0===r.output)return;let n=h(i.id,void 0!==i.output&&i.parent?S(i.output,t.context,e,s.self):void 0);return S(r.output,t.context,n,s.self)}(c,e,s,c.machine.root,a)})}}return c}(u,r,s,l,a,n,c,i);let d=[...a];"done"===u.status&&(u=ty(u,r,s,d.sort((t,e)=>e.order-t.order).flatMap(t=>t.exit),n,void 0));try{if(c===e.historyValue&&function(t,e){if(t.length!==e.size)return!1;for(let s of t)if(!e.has(s))return!1;return!0}(e._nodes,a))return[u,o];return[tE(u,{_nodes:d,historyValue:c}),o]}catch(t){throw t}}finally{s.actionExecutor=a}}function tf(t,e,s,r){var i,n,o,a;if(ts(t))if(e[t.id]){let o=e[t.id];for(let t of o)r.add(t),tf(t,e,s,r);for(let a of o){i=a,n=t.parent,tg(r,e,s,q(i,n))}}else{let i=te(t);for(let n of i.target)r.add(n),i===t.parent?.initial&&s.add(t.parent),tf(n,e,s,r);for(let n of i.target){o=n,a=t.parent,tg(r,e,s,q(o,a))}}else if("compound"===t.type){let[i]=t.initial.target;ts(i)||(r.add(i),s.add(i)),tf(i,e,s,r),tg(r,e,s,q(i,t))}else if("parallel"===t.type)for(let i of J(t).filter(t=>!ts(t)))[...r].some(t=>tc(t,i))||(ts(i)||(r.add(i),s.add(i)),tf(i,e,s,r))}function tg(t,e,s,r,i){for(let n of r)if((!i||tc(n,i))&&t.add(n),"parallel"===n.type)for(let r of J(n).filter(t=>!ts(t)))[...t].some(t=>tc(t,r))||(t.add(r),tf(r,e,s,t))}function ty(t,e,s,r,i,n){let o=n?[]:void 0,a=function t(e,s,r,i,n,o){let{machine:a}=e,c=e;for(let e of i){var l;let i="function"==typeof e,u=i?e:(l="string"==typeof e?e:e.type,a.implementations.actions[l]),d={context:c.context,event:s,self:r.self,system:r.system},h=i||"string"==typeof e?void 0:"params"in e?"function"==typeof e.params?e.params({context:c.context,event:s}):e.params:void 0;if(!u||!("resolve"in u)){r.actionExecutor({type:"string"==typeof e?e:"object"==typeof e?e.type:e.name||"(anonymous)",info:d,params:h,exec:u});continue}let[p,f,g]=u.resolve(r,c,d,h,u,n);c=p,"retryResolve"in u&&o?.push([u,f]),"execute"in u&&r.actionExecutor({type:u.type,info:d,params:f,exec:u.execute.bind(null,r,f)}),g&&(c=t(c,s,r,g,n,o))}return c}(t,e,s,r,{internalQueue:i,deferredActorIds:n},o);return o?.forEach(([t,e])=>{t.retryResolve(s,a,e)}),a}function tm(t,e,s,r){let i=t,n=[];function o(t,e,r){s.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:s.self,event:e,snapshot:t[0],_transitions:r}),n.push(t)}if(e.type===d)return o([i=tE(tv(i,e,s),{status:"stopped"}),[]],e,[]),{snapshot:i,microsteps:n};let a=e;if(a.type!==u){let e=a,c=e.type.startsWith("xstate.error.actor"),l=t_(e,i);if(c&&!l.length)return o([i=tE(t,{status:"error",error:e.error}),[]],e,[]),{snapshot:i,microsteps:n};let u=tp(l,t,s,a,!1,r);i=u[0],o(u,e,l)}let c=!0,l=t.machine.options?.maxIterations??1/0,h=0;for(;"active"===i.status;){if(++h>l)throw Error(`Infinite loop detected: the machine has processed more than ${l} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let t=c?function(t,e){let s=new Set;for(let r of t._nodes.filter(H))t:for(let i of[r].concat(q(r,void 0)))if(i.always){for(let r of i.always)if(void 0===r.guard||W(r.guard,t.context,e,t)){s.add(r);break t}}return tl(Array.from(s),new Set(t._nodes),t.historyValue)}
2(i,a):[],e=t.length?i:void 0;if(!t.length){if(!r.length)break;t=t_(a=r.shift(),i)}let n=tp(t,i,s,a,!1,r);c=(i=n[0])!==e,o(n,a,t)}return"active"!==i.status&&tv(i,a,s),{snapshot:i,microsteps:n}}function tv(t,e,s){return ty(t,e,s,Object.values(t.children).map(t=>G(t)),[],void 0)}function t_(t,e){return e.machine.getTransitionData(e,t)}let tb=function(t){return function t(e,s){let r=v(e),i=v(s);return"string"==typeof i?"string"==typeof r&&i===r:"string"==typeof r?r in i:Object.keys(r).every(e=>e in i&&t(r[e],i[e]))}(t,this.value)},tS=function(t){return this.tags.has(t)},tI=function(t){let e=this.machine.getTransitionData(this,t);return!!e?.length&&e.some(t=>void 0!==t.target||t.actions.length)},tw=function(){let{_nodes:t,tags:e,machine:s,getMeta:r,toJSON:i,can:n,hasTag:o,matches:a,...c}=this;return{...c,tags:Array.from(e)}},tC=function(){return this._nodes.reduce((t,e)=>(void 0!==e.meta&&(t[e.id]=e.meta),t),{})};function tx(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:Q(e.root,t._nodes),tags:new Set(t._nodes.flatMap(t=>t.tags)),children:t.children,historyValue:t.historyValue||{},matches:tb,hasTag:tS,can:tI,getMeta:tC,toJSON:tw}}function tE(t,e={}){return tx({...t,...e},t.machine)}function tk(t,e,s,r,{event:i,id:n,delay:o},{internalQueue:a}){let c,l=e.machine.implementations.delays;if("string"==typeof i)throw Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);let u="function"==typeof i?i(s,r):i;if("string"==typeof o){let t=l&&l[o];c="function"==typeof t?t(s,r):t}else c="function"==typeof o?o(s,r):o;return"number"!=typeof c&&a.push(u),[e,{event:u,id:n,delay:c},void 0]}function tP(t,e){let{event:s,delay:r,id:i}=e;if("number"==typeof r)return void t.defer(()=>{let e=t.self;t.system.scheduler.schedule(e,e,s,r,i)})}function tA(t,e){function s(t,e){}return s.type="xstate.raise",s.event=t,s.id=e?.id,s.delay=e?.delay,s.resolve=tk,s.execute=tP,s}t.i(127337);var tT=t.i(745549);let tO=(t,e)=>{e(t);let s=t.getSnapshot().children;s&&Object.values(s).forEach(t=>{tO(t,e)})};var tR=t.i(132781);function tL(t){return t.discountedPrice??t.dollarsPerMonth}function t$(t,e,s,r,{assignment:i}){if(!e.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let n={},o={context:e.context,event:s.event,spawn:function(t,{machine:e,context:s},r,i){return(n,o)=>{let a=((n,o)=>{if("string"!=typeof n)return L(n,{id:o?.id,parent:t.self,syncSnapshot:o?.syncSnapshot,input:o?.input,src:n,systemId:o?.systemId});{let a=E(e,n);if(!a)throw Error(`Actor logic '${n}' not implemented in machine '${e.id}'`);let c=L(a,{id:o?.id,parent:t.self,syncSnapshot:o?.syncSnapshot,input:"function"==typeof o?.input?o.input({context:s,event:r,self:t.self}):o?.input,src:n,systemId:o?.systemId});return i[c.id]=c,c}})(n,o);return i[a.id]=a,t.defer(()=>{a._processingStatus!==T.Stopped&&a.start()}),a}}(t,e,s.event,n),self:t.self,system:t.system},a={};if("function"==typeof i)a=i(o,r);else for(let t of Object.keys(i)){let e=i[t];a[t]="function"==typeof e?e(o,r):e}let c=Object.assign({},e.context,a);return[tE(e,{context:c,children:Object.keys(n).length?{...e.children,...n}:e.children}),void 0,void 0]}function tM(t){function e(t,e){}return e.type="xstate.assign",e.assignment=t,e.resolve=t$,e}let tN=new WeakMap;function tU(t,e,s){let r=tN.get(t);return r?e in r||(r[e]=s()):(r={[e]:s()},tN.set(t,r)),r[e]}let tD={},tF=t=>"string"==typeof t?{type:t}:"function"==typeof t?"resolve"in t?{type:t.type}:{type:t.name}:t;class tj{constructor(t,e){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=e._parent,this.key=e._key,this.machine=e._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join("."),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?_(this.config.states,(t,e)=>new tj(t,{_parent:this,_key:e,_machine:this.machine})):tD,"compound"===this.type&&!this.config.initial)throw Error(`No initial state specified for c
2ompound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=b(this.config.entry).slice(),this.exit=b(this.config.exit).slice(),this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=b(t.tags).slice()}_initialize(){this.transitions=function(t){let e=new Map;if(t.config.on)for(let s of Object.keys(t.config.on)){if(""===s)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let r=t.config.on[s];e.set(s,w(r).map(e=>tt(t,s,e)))}if(t.config.onDone){let s=`xstate.done.state.${t.id}`;e.set(s,w(t.config.onDone).map(e=>tt(t,s,e)))}for(let s of t.invoke){if(s.onDone){let r=`xstate.done.actor.${s.id}`;e.set(r,w(s.onDone).map(e=>tt(t,r,e)))}if(s.onError){let r=`xstate.error.actor.${s.id}`;e.set(r,w(s.onError).map(e=>tt(t,r,e)))}if(s.onSnapshot){let r=`xstate.snapshot.${s.id}`;e.set(r,w(s.onSnapshot).map(e=>tt(t,r,e)))}}for(let s of t.after){let t=e.get(s.eventType);t||(t=[],e.set(s.eventType,t)),t.push(s)}return e}(this),this.config.always&&(this.always=w(this.config.always).map(t=>tt(this,"",t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.t
2ype,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(tF),eventType:null,reenter:!1,meta:this.initial.meta,description:this.initial.description,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(tF),eventType:null,meta:this.initial.meta,description:this.initial.description})}:void 0,history:this.history,states:_(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(tF)})),entry:this.entry.map(tF),exit:this.exit.map(tF),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return tU(this,"invoke",()=>b(this.config.invoke).map((t,e)=>{var s,r;let{src:i,systemId:n}=t,o=t.id??(s=this.id,`${e}.${s}`),a="string"==typeof i?i:`xstate.invoke.${r=this.id,`${e}.${r}`}`;return{...t,src:a,id:o,systemId:n,toJSON(){let{onDone:e,onError:s,...r}=t;return{...r,type:"xstate.invoke",src:a,id:o}}}}))}get on(){return tU(this,"on",()=>[...this.transitions].flatMap(([t,e])=>e.map(e=>[t,e])).reduce((t,[e,s])=>(t[e]=t[e]||[],t[e].push(s),t),{}))}get after(){return tU(this,"delayedTransitions",()=>{var t;let e;return t=this,(e=t.config.after)?Object.keys(e).flatMap(s=>{var r;let i,n,o=e[s],a=Number.isNaN(+s)?s:+s,c=(r=t.id,n=(i={type:`xstate.after.${a}.${r}`}).type,t.entry.push(tA(i,{id:n,delay:a})),t.exit.push(N(n)),n);return b("string"==typeof o?{target:o}:o).map(t=>({...t,event:c,delay:a}))}).map(e=>{let{delay:s}=e;return{...tt(t,e.event,e),delay:s}}):[]})}get initial(){return tU(this,"initial",()=>(function(t,e){let s="string"==typeof e?t.states[e]:e?t.states[e.target]:void 0;if(!s&&e)throw Error(`Initial state node "${e}" not found on parent state node #${t.id}`);let r={source:t,actions:e&&"string"!=typeof e?b(e.actions):[],eventType:null,reenter:!1,target:s?[s]:[],meta:"object"==typeof e?e.meta:void 0,description:"object"==typeof e?e.description:void 0,toJSON:()=>({...r,source:`#${t.id}`,target:s?[`#${s.id}`]:[]})};return r})(this,this.config.initial))}next(t,e){let s,r=e.type,i=[];for(let n of tU(this,`candidates-${r}`,()=>{var t;let e,s;return t=this,e=t.transitions.get(r),s=[...t.transitions.keys()].filter(t=>t!==r&&function(t,e){if(e===t||"*"===e)return!0;if(!e.endsWith(".*"))return!1;let s=e.split("."),r=t.split(".");for(let t=0;t<s.length;t++){let e=s[t],i=r[t];if("*"===e)return t===s.length-1;if(e!==i)return!1}return!0}(r,t)).sort((t,e)=>e.length-t.length).flatMap(e=>t.transitions.get(e)),e?[...e,...s]:s})){let{guard:o}=n,a=t.context,c=!1;try{c=!o||W(o,a,e,t)}catch(e){let t="string"==typeof o?o:"object"==typeof o?o.type:void 0;throw Error(`Unable to evaluate guard ${t?`'${t}' `:""}in transition for event '${r}' in state node '${this.id}': 3${e.message}`)}if(c){i.push(...n.actions),s=n;break}}return s?[s]:void 0}get events(){return tU(this,"events",()=>{let{states:t}=this,e=new Set(this.ownEvents);if(t)for(let s of Object.keys(t)){let r=t[s];if(r.states)for(let t of r.events)e.add(`${t}`)}return Array.from(e)})}get ownEvents(){return Array.from(new Set(Object.keys(Object.fromEntries(this.transitions)).filter(t=>this.transitions.get(t).some(t=>!(!t.target&&!t.actions.length&&!t.reenter)))))}}class tB{constructor(t,e){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:e?.actors??{},actions:e?.actions??{},delays:e?.delays??{},guards:e?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new tj(t,{_key:this.id,_machine:this}),this.root._initialize(),function(t){let e=[],s=r=>{Object.values(r).forEach(r=>{if(r.config.route&&r.config.id){let s=r.config.id,i=r.config.route.guard,n=({event:t})=>t.to===`#${s}`,o={...r.config.route,guard:i?z([n,i]):n,target:`#${s}`};e.push(tt(t,"xstate.route",o))}r.states&&s(r.states)})};s(t.states),e.length>0&&t.transitions.set("xstate.route",e)}(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:e,guards:s,actors:r,delays:i}=this.implementations;return new tB(this.config,{actions:{...e,...t.actions},guards:{...s,...t.guards},actors:{...r,...t.actors},delays:{...i,...t.delays}})}resolveState(t){var e;let s,r=(s=K(ta(e=this.root,t.value)),Q(e,[...s])),i=K(ta(this.root,r));return tx({_nodes:[...i],context:t.context||{},children:{},status:X(i,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,s){return tm(t,e,s,[]).snapshot}microstep(t,e,s){return tm(t,e,s,[]).microsteps.map(([t])=>t)}getTransitionData(t,e){return function t(e,s,r,i){if("string"==typeof s){let t;return(t=tn(e,s).next(r,i))&&t.length?t:e.next(r,i)}if(1===Object.keys(s).length){let n,o;return(o=t(tn(e,(n=Object.keys(s))[0]),s[n[0]],r,i))&&o.length?o:e.next(r,i)}let n=[];for(let o of Object.keys(s)){let a=s[o];if(!a)continue;let c=t(tn(e,o),a,r,i);c&&n.push(...c)}return n.length?n:e.next(r,i)}(this.root,t.value,t,e)||[]}_getPreInitialState(t,e,s){let{context:r}=this.config,i=tx({context:"function"!=typeof r&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return"function"==typeof r?ty(i,e,t,[tM(({spawn:t,event:e,self:s})=>r({spawn:t,input:e.input,self:s}))],s,void 0):i}getInitialSnapshot(t,e){let s=f(e),r=[],i=tx({context:"function"!=typeof this.config.context&&this.config.context?this.config.context:{},_nodes:[this.root],children:{},status:"active"},this);try{var n,o;i=this._getPreInitialState(t,s,r);let[e]=(n=this.root,o=i,tp([{target:[...ti(n)],source:n,reenter:!0,actions:[],eventType:null,toJSON:null}],o,t,s,!0,r)),{snapshot:a}=tm(e,s,t,r);return a}catch(t){return tE(i,{status:"error",error:t})}}
3start(t){Object.values(t.children).forEach(t=>{"active"===t.getSnapshot().status&&t.start()})}getStateNodeById(t){let e=m(t),s=e.slice(1),r=Z(e[0])?e[0].slice(1):e[0],i=this.idMap.get(r);if(!i)throw Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return to(i,s)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,e){return function(t,e){let{_nodes:s,tags:r,machine:i,children:n,context:o,can:a,hasTag:c,matches:l,getMeta:u,toJSON:d,...h}=t,p={};for(let t in n){let s=n[t];p[t]={snapshot:s.getPersistedSnapshot(e),src:s.src,systemId:s.systemId,syncSnapshot:s._syncSnapshot}}return{...h,context:function t(e){let s;for(let r in e){let i=e[r];if(i&&"object"==typeof i)if("sessionId"in i&&"send"in i&&"ref"in i)(s??=Array.isArray(e)?e.slice():{...e})[r]={xstate$$type:1,id:i.id};else{let n=t(i);n!==i&&((s??=Array.isArray(e)?e.slice():{...e})[r]=n)}}return s??e}(o),children:p,historyValue:function(t){if("object"!=typeof t||null===t)return{};let e={};for(let s in t){let r=t[s];Array.isArray(r)&&(e[s]=r.map(t=>({id:t.id})))}return e}(h.historyValue)}}(t,e)}restoreSnapshot(t,e){let s={},r=t.children;Object.keys(r).forEach(t=>{let i=r[t],n=i.snapshot,o=i.src,a="string"==typeof o?E(this,o):o;if(!a)return;let c=L(a,{id:t,parent:e.self,syncSnapshot:i.syncSnapshot,snapshot:n,src:o,systemId:i.systemId});s[t]=c});let i=function(t,e){if(!e||"object"!=typeof e)return{};let s={};for(let r in e)for(let i of e[r]){let e=function(t,e){if(e instanceof tj)return e;try{return t.machine.getStateNodeById(e.id)}catch{}}(t,i);e&&(s[r]??=[],s[r].push(e))}return s}(this.root,t.historyValue),n=tx({...t,children:s,_nodes:Array.from(K(ta(this.root,t.value))),historyValue:i},this),o=new Set;return!function t(e,s){if(!o.has(e))for(let r in o.add(e),e){let i=e[r];if(i&&"object"==typeof i){if("xstate$$type"in i&&1===i.xstate$$type){e[r]=s[i.id];continue}t(i,s)}}}(n.context,s),n}}function tG(t,e,s,r,{event:i}){return[e,{event:"function"==typeof i?i(s,r):i},void 0]}function tV(t,{event:e}){t.defer(()=>t.emit(e))}function tz(t){function e(t,e){}return e.type="xstate.emit",e.event=t,e.resolve=tG,e.execute=tV,e}let tW=((s={}).Parent="#_parent",s.Internal="#_internal",s);function tH(t,e,s,r,{to:i,event:n,id:o,delay:a},c){let l,u,d=e.machine.implementations.delays;if("string"==typeof n)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${n}" }) instead`);let h="function"==typeof n?n(s,r):n;if("string"==typeof a){let t=d&&d[a];l="function"==typeof t?t(s,r):t}else l="function"==typeof a?a(s,r):a;let p="function"==typeof i?i(s,r):i;if("string"==typeof p){if(!(u=p===tW.Parent?t.self._parent:p===tW.Internal?t.self:p.startsWith("#_")?e.children[p.slice(2)]:c.deferredActorIds?.includes(p)?p:e.children[p]))throw Error(`Unable to send event to actor '${p}' from machine '${e.machine.id}'.`)}else u=p||t.self;return[e,{to:u,targetId:"string"==typeof p?p:void 0,event:h,id:o,delay:l},void 0]}function tJ(t,e,s){"string"==typeof s.to&&(s.to=e.children[s.to])}function tq(t,e){t.defer(()=>{let{to:s,event:r,delay:i,id:n}=e;"number"==typeof i?t.system.scheduler.schedule(t.self,s,r,i,n):t.system._relay(t.self,s,"xstate.error"===r.type?p(t.self.id,r.data):r)})}function tK(t,e,s){function r(t,e){}return r.type="xstate.sendTo",r.to=t,r.event=e,r.id=s?.id,r.delay=s?.delay,r.resolve=tH,r.retryResolve=tJ,r.execute=tq,r}function tY(t,e,s,r,{collect:i}){let n=[],o=function(t){n.push(t)};return o.assign=(...t)=>{n.push(tM(...t))},o.cancel=(...t)=>{n.push(N(...t))},o.raise=(...t)=>{n.push(tA(...t))},o.sendTo=(...t)=>{n.push(tK(...t))},o.sendParent=(...t)=>{n.push(function(t,e){return tK(tW.Parent,t,e)}(...t))},o.spawnChild=(...t)=>{n.push(F(...t))},o.stopChild=(...t)=>{n.push(G(...t))},o.emit=(...t)=>{n.push(tz(...t))},i({context:s.context,event:s.event,enqueue:o,check:t=>W(t,e.context,s.event,e),self:t.self,system:t.system},r),[e,void 0,n]}function tQ(t){function e(t,e){}return e.type="xstate.enqueueActions",e.collect=t,e.resolve=tY,e}function tX(t,e,s,r,{value:i,label:n}){return[e,{value:"function"==typeof i?i(s,r):i,label:n},void 0]}function tZ({logger:t},{value:e,label:s}){s?t(s,e):t(e)}function t0(t=({context:t,event:e})=>({context:t,event:e}),e){function s(t,e){}return s.type="xstate.log",s.value=t,s.label=e,s.resolve=tX,s.execute=tZ,s}let t1="xstate.promise.resolve",t4="xstate.promise.reject",t2=new WeakMap;function t9(t){return{config:t,transition:(t,e,s)=>{if("active"!==t.status)return t;switch(e.type){case t1:{let s=e.data;return{...t,status:"done",output:s,input:void 0}}case t4:return{...t,status:"error",error:e.data,input:void 0};case d:return t2.get(s.self)?.abort(),t2.delete(s.self),{...t,status:"stopped",input:void 0};default:return t}},start:(e,{self:s,system:r,emit:i})=>{if("active"!==e.status)return;let n=new AbortController;t2.set(s,n),Promise.resolve(t({input:e.input,system:r,self:s,signal:n.signal,emit:i})).then(t=>
3{"active"===s.getSnapshot().status&&(t2.delete(s),r._relay(s,s,{type:t1,data:t}))},t=>{"active"===s.getSnapshot().status&&(t2.delete(s),r._relay(s,s,{type:t4,data:t}))})},getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,input:e}),getPersistedSnapshot:t=>t,restoreSnapshot:t=>t}}let t5=(function t({schemas:e,actors:s,actions:r,guards:i,delays:n}){return{assign:tM,sendTo:tK,raise:tA,log:t0,cancel:N,stopChild:G,enqueueActions:tQ,emit:tz,spawnChild:F,createStateConfig:t=>t,createAction:t=>t,createMachine:t=>new tB({...t,schemas:e},{actors:s,actions:r,guards:i,delays:n}),extend:o=>t({schemas:e,actors:s,actions:{...r,...o.actions},guards:{...i,...o.guards},delays:{...n,...o.delays}})}})({types:{context:{},events:{},input:{}},guards:{isLoggedOut:({context:t})=>!t.user,isLoggedIn:({context:t})=>!!t.user,noSubscription:({context:t})=>!t.user?.subscriptionPlanId,hasSubscription:({context:t})=>!!t.user?.subscriptionPlanId,samePlan:({context:t})=>t.user?.subscriptionPlanId===t.selectedPlanId,differentPlan:({context:t})=>!!t.user?.subscriptionPlanId&&t.user.subscriptionPlanId!==t.selectedPlanId,isDeviceFlow:({context:t})=>!!t.deviceCode,isDirectFlow:({context:t})=>!t.deviceCode,isExplicitLogin:({context:t})=>"explicit_login"===t.authContext.type,isSubscribeFlow:({context:t})=>"subscribe_flow"===t.authContext.type,hasResumeSubscribe:({context:t})=>!!t.resumeSubscribePlanId,hasResumeAfterCheckout:({context:t})=>!!t.resumeAfterCheckout},actions:{setAuthContextSubscribeFlow:tM({authContext:()=>({type:"subscribe_flow"})}),setAuthContextExplicitLogin:tM({authContext:()=>({type:"explicit_login"})}),setAuthContextNone:tM({authContext:()=>({type:"none"})}),setPendingSwitch:tM({pendingSwitchFromPlanId:({context:t})=>t.user?.subscriptionPlanId}),clearPendingSwitch:tM({pendingSwitchFromPlanId:()=>void 0}),clearError:tM({errorMessage:()=>void 0})},actors:{stripeActor:t9(async()=>{throw Error("stripeActor not provided")}),deviceActor:t9(async()=>{throw Error("deviceActor not provided")}),planChangeActor:t9(async()=>{throw Error("planChangeActor not provided")}),upgradeCheckoutActor:t9(async()=>{throw Error("upgradeCheckoutActor not provided")}),cancellationActor:t9(async()=>{throw Error("cancellationActor not provided")})}}).createMachine({id:"subscription",initial:"idle",context:({input:t})=>({user:t.user,authContext:{type:"none"},deviceCode:t.deviceCode,selectedOrgId:t.selectedOrgId,allowBilling:!1,selectedPlanId:t.selectedPlanId,resumeSubscribePlanId:t.resumeSubscribePlanId,resumeAfterCheckout:t.resumeAfterCheckout,returnPath:t.returnPath}),states:{idle:{always:[{guard:"hasResumeAfterCheckout",target:"postPurchase",actions:[tM({resumeAfterCheckout:()=>void 0})]},{guard:"hasResumeSubscribe",target:"subscribeFlow",actions:[tM({selectedPlanId:({context:t})=>t.resumeSubscribePlanId,resumeSubscribePlanId:()=>void 0}),{type:"setAuthContextSubscribeFlow"}]}],on:{AUTH_SUCCESS:{actions:[tM({user:({context:t,event:e})=>({userId:e.userId??t.user?.userId,subscriptionPlanId:e.subscriptionPlanId})})]},CLICK_HAVE_ACCOUNT:{guard:"isLoggedOut",target:"authDialog",actions:[{type:"setAuthContextExplicitLogin"},{type:"clearError"}]},CLICK_SUBSCRIBE:{target:"subscribeFlow",actions:[{type:"setAuthContextSubscribeFlow"},tM({selectedPlanId:({event:t})=>t.planId}),{type:"clearError"}]},START_UPGRADE:{target:"upgradeCheckout",actions:[tM({selectedPlanId:({event:t})=>t.planId}),{type:"clearError"}]},START_DOWNGRADE:{target:"executingPlanChange",actions:[tM({selectedPlanId:({event:t})=>t.planId}),{type:"clearError"}]},OPEN_CANCEL_MODAL:{target:"confirmingCancellation",actions:[{type:"clearError"}]},RESUME_SUBSCRIPTION:{target:"executingResume",actions:[{type:"clearError"}]},DEVICE_CONNECT:{guard:z(["isLoggedIn","isDeviceFlow"]),target:"deviceAuthorize",actions:[{type:"clearError"}]}}},authDialog:{on:{AUTH_SUCCESS:{target:"authResolve",actions:[tM({user:({event:t})=>({userId:t.userId,subscriptionPlanId:t.subscriptionPlanId})})]},AUTH_CANCEL:{target:"idle",actions:[{type:"setAuthContextNone"}]},AUTH_FAILURE:{target:"idle",actions:[tM({errorMessage:({event:t})=>"AUTH_FAILURE"===t.type?t.message:"Unable to complete login. Please try again."}),{type:"setAuthContextNone"}]}}},authResolve:{always:[{guard:"isExplicitLogin",target:"idle",actions:[{type:"setAuthContextNone"}]},{guard:"isSubscribeFlow",target:"checkPlan",actions:[{type:"setAuthContextNone"}]},{target:"idle",actions:[{type:"setAuthContextNone"}]}]},subscribeFlow:{always:[{guard:"isLoggedOut",target:"authDialog"},{guard:"isLoggedIn",target:"checkPlan"}]},checkPlan:{always:[{guard:"noSubscription",target:"stripeCheckout"},{guard:"samePlan",target:"handleSamePlan"},{guard:"differentPlan",target:"confirmSwitch",actions:[{type:"setPendingSwitch"}]},{target:"idle"}]},handleSamePlan:{always:[{guard:"isDeviceFlow",target:"deviceAuthorize"},{guard:"isDirectFlow",target:"idle"}]},confirmSwitch:{on:{CONFIRM_SWITCH:{target:"executingPlanChange"},CANCEL_SWITCH:{target:"idle",actions:[{type:"clearPendingSwitch"}]}}},stripeCheckout:{invoke:{src:"stripeActor",input:({context:t})=>({subscriptionTypeId:t.selectedPlanId,deviceUserCode:t.deviceCode,orgId:t.selectedOrgId,returnPath:t.returnPath}),onDone:{target:"stripeCheckoutRedirecting",actions:[tM({stripeCheckoutUrl:({event:t})=>t.output})]},onError:{target:"idle",actions:[tM({errorMessage:({event:t})=>t.error instanceof Error?t.error.message:"Failed to create checkout session"})]}}},stripeCheckoutRedirecting:{},postPurchase:{on:{SUBSCRIPTION_CONFIRMED:{target:"postPurchaseConfirmed"}}},postPurchaseConfirmed:{always:[{guard:"isDeviceFlow",target:"deviceAuthorize"},{target:"terminal"}]},executingPlanChange:{invoke:{src:"planChangeActor",input:({context:t})=>({subscriptionTypeId:t.selectedPlanId,orgId:t.selectedOrgId}),onDone:{target:"postPlanChange",actions:[{type:"clearPendingSwitch"}]},onError:{target:"idle",actions:[tM({errorMessage:({event:t})=>t.error instanceof Error?t.error.message:"Failed to change subscription plan",pendingSwitchFromPlanId:()=>void 0})]}}},postPlanChange:{always:[{guard:"isDeviceFlow",target:"deviceAuthorize"},{target:"reloading"}]},upgradeCheckout:{invoke:{src:"upgradeCheckoutActor",input:({context:t})=>({subscriptionTypeId:t.selectedPlanId,orgId:t.selectedOrgId,returnPath:t.returnPath}),onDone:{target:"stripeCheckoutRedirecting",actions:[tM({stripeCheckoutUrl:({event:t})=>t.output})]},onError:{target:"idle",actions:[tM({errorMessage:({event:t})=>t.error instanceof Error?t.error.message:"Failed to start upgrade checkout"})]}}},confirmingCancellation:{on:{CONFIRM_CANCEL:"executingCancellation",CLOSE_CANCEL_MODAL:"idle"}},executingCancellation:{invoke:{src:"cancellationActor",input:({context:t})=>({cancelAtPeriodEnd:!0,orgId:t.selectedOrgId}),onDone:"reloading",onError:{target:"idle",actions:[tM({errorMessage:({event:t})=>t.error instanceof Error?t.error.message:"Failed to cancel subscription"})]}}},executingResume:{invoke:{src:"cancellationActor",input:({context:t})=>({cancelAtPeriodEnd:!1,orgId:t.selectedOrgId}),onDone:"reloading",onError:{target:"idle",actions:[tM({errorMessage:({event:t})=>t.error instanceof Error?t.error.message:"Failed to update subscription"})]}}},reloading:{},deviceAuthorize:{invoke:{src:"deviceActor",input:({context:t})=>({userCode:t.deviceCode,orgId:t.selectedOrgId,allowBilling:t.allowBilling}),onDone:"terminal",onError:{target:"idle",actions:[tM({errorMessage:({event:t})=>t.error instanceof Error?t.error.message:"Failed to approve device. The code may have expired."})]}}},terminal:{}},on:{STRIPE_SUCCESS:{target:".postPurchase"},STRIPE_CANCEL:{target:".idle",actions:[{type:"clearError"}]},CLEAR_ERROR:{actions:[{type:"clearError"}]},SELECT_ORG:{actions:tM({selectedOrgId:({event:t})=>t.orgId,allowBilling:()=>!1})},SET_ALLOW_BILLING:{actions:tM({allowBilling:({event:t})=>t.allowBilling})}}});var t7=t.i(506658),t3=t.i(166567),t8=t.i(40358);let t6=(0,t8.createServerReference)("7fde5b7bc6ca5dfd849259c7aa1fa3a51cfaddbe16",t8.callServer,void 0,t8.findSourceMapURL,"changeSubscriptionPlan");var et=t.i(949892);let ee=(0,t8.createServerReference)("7ffdcbc81413bdba4952830b12111506907591a150",t8.callServer,void 0,t8.findSourceMapURL,"approveDevice"),es=t9(async({input:t})=>{console.log("[sub] actor: stripeActor started",t);let e=await (0,t7.createSubscriptionCheckout)({subscriptionTypeId:t.subscriptionTypeId,deviceVerifyUserCode:t.deviceUserCode,orgId:t.orgId,returnPath:t.returnPath??"/manage-subscription"});if("success"!==e.status)throw console.log("[sub] actor: stripeActor failed",e),Error(e.message??"Failed to create checkout session");return console.log("[sub] actor: stripeActor got checkout URL"),e.data}),er=t9(async({input:t})=>{console.log("[sub] actor: deviceActor started",t);let e=await ee({userCode:t.userCode,orgId:t.orgId,allowBilling:t.allowBilling});if("success"===e.status&&e.data.approved)return void console.log("[sub] actor: deviceActor approved");throw Error("success"===e.status?function(t){switch(t){case"invali
3d_user_code":return"That device code was not recognized. Check the CLI output and try again.";case"expired_user_code":return"This device code has expired. Start login again from the CLI.";case"already_finalized":return"This device code has already been approved or denied.";case"no_access_to_org":return"You don't have access to the selected account. Pick another and try again.";default:return t??"Device approval failed"}}(e.data.reason):e.message??"Failed to approve device")}),ei=t9(async({input:t})=>{let e=await t6({subscriptionTypeId:t.subscriptionTypeId,orgId:t.orgId});if("success"!==e.status)throw Error(e.message??"Failed to change subscription plan")}),en=t9(async({input:t})=>{console.log("[sub] actor: upgradeCheckoutActor started",t);let e=await (0,t3.createSubscriptionUpgradeCheckout)({subscriptionTypeId:t.subscriptionTypeId,returnPath:t.returnPath??"/manage-subscription",orgId:t.orgId});if("success"!==e.status)throw console.log("[sub] actor: upgradeCheckoutActor failed",e),Error(e.message??"Failed to start upgrade checkout");return console.log("[sub] actor: upgradeCheckoutActor got checkout URL"),e.data}),eo=t9(async({input:t})=>{let e=await (0,et.updateSubscriptionCancellation)({cancelAtPeriodEnd:t.cancelAtPeriodEnd,orgId:t.orgId});if("success"!==e.status)throw Error(e.message??"Failed to update cancellation settings")});var ea=t.i(61933),ec=t.i(387071),el=t.i(142259);let eu=(0,t8.createServerReference)("7fa6adeb49b34efc9665c7ca8a05a40a8faa210be5",t8.callServer,void 0,t8.findSourceMapURL,"getDeviceBillingConsentInfo");var ed=t.i(920111);let eh="manage-subscription:pending-subscribe";function ep(){window.sessionStorage.removeItem(eh)}function ef(){let t=new URL(window.location.href);if(t.searchParams.has("session_id")){let e=t.searchParams.get("checkout");return{status:"success",checkout:"upgrade"===e||"subscription"===e?e:null,fromTierId:t.searchParams.get("from_tier"),targetTierId:t.searchParams.get("target_tier"),sessionId:t.searchParams.get("session_id")}}if(t.searchParams.has("subscription_canceled"))return{status:"canceled"}}let eg={showBillingCheckbox:!1,isPersonalOrg:!0,billingRequested:!1},ey={read:function(){let t=window.location.hash;if(t.startsWith("#subscribe=")){let e=decodeURIComponent(t.slice(11));if(e)return e}return window.sessionStorage.getItem(eh)??void 0},write:function(t){window.sessionStorage.setItem(eh,t)},clear:ep};t.s(["usePrivyAuthController",0,function({stateRef:t,send:e}){let{authenticated:s,getAccessToken:o}=(0,n.usePrivy)(),c=(0,a.useCallback)(()=>{let s=t.current,r=s.matches("authDialog"),i=s.matches("idle")&&!s.context.user;r||i?(async()=>{try{console.log("[sub] completeLogin: provisioning session"),await o();let t=await (0,ea.postLoginServerCallback)(void 0);if("success"!==t.status||!t.data?.success){let s="Unable to complete login. Please try again.";"success"===t.status?t.data&&"error"in t.data&&(s=t.data.error):s=t.message??s,await (0,el.clearSessionCookies)().catch(t=>{console.error("[sub] completeLogin: failed to clear cookies",t)}),ep(),e({type:"AUTH_FAILURE",message:s});return}let s=(0,ec.getSignupVerificationRedirect)(t.data,()=>`${window.location.pathname}${window.location.search}${window.location.hash}`);if(s){window.location.href=s;return}}catch(t){await (0,el.clearSessionCookies)().catch(t=>{console.error("[sub] completeLogin: failed to clear cookies after error",t)}),ep(),e({type:"AUTH_FAILURE",message:t instanceof Error?t.message:"Unable to complete login. Please try again."});return}let{authContext:s,selectedPlanId:r}=t.current.context;console.log("[sub] completeLogin: authContext",s,"planId",r),"subscribe_flow"===s.type&&r?(window.location.hash=`subscribe=${encodeURIComponent(r)}`,console.log("[sub] completeLogin: set hash, reloading")):console.log("[sub] completeLogin: reloading for fresh server data"),window.location.reload()})():console.log("[sub] completeLogin: ignored, machine in",s.value)},[o,e,t]),{login:l}=(0,r.useLogin)({onComplete:()=>c(),onError:()=>{ep(),e({type:"AUTH_CANCEL"})}}),{logout:u}=(0,i.useLogout)({onSuccess:()=>{(0,el.clearSessionCookies)().then(()=>window.location.reload()).catch(()=>window.location.reload())}}),d=(0,a.useCallback)(()=>{s?(console.log("[sub] authDialog: already authenticated, completing login"),c()):(console.log("[sub] authDialog: opening privy modal"),l())},[s,c,l]);return(0,a.useMemo)(()=>({openLoginFlow:d,logout:u}),[d,u])},"useSubscriptionManager",0,function({user:t,activeOrgSlug:e,availableTiers:s,deviceUserCode:r,planParam:i,memberships:n,orgHint:l,returnPath:u,subscribeIntent:d=ey,errorPresentation:h="toast"},p){let f=t?.subscription?.active,g=f?.subscriptionTypeId,y=t?.subscription?.expired,m=(0,o.useRouter)(),v=new URL(window.location.href).searchParams.get("user_code")??void 0,_=!!r||!!v,b=(0,a.useMemo)(()=>t5.provide({actors:{stripeActor:es,deviceActor:er,planChangeActor:ei,upgradeCheckoutActor:en,cancellationActor:eo}}),[]),[S]=(0,a.useState)(d.read),[I]=(0,a.useState)(()=>(function({planParam:t,availableTiers:e}){if(!t)return{kind:"ignored"};let s=e.find(e=>e.id===t);return s&&s.enabled?{kind:"preselect",tierId:s.id}:{kind:"ignored"}})({planParam:i,availableTiers:s})),w="preselect"===I.kind?I.tierId:null,C=S??w,[x]=(0,a.useState)(ef),E=(0,a.useMemo)(()=>(n??[]).filter(t=>t.hasActiveSubscription||t.apiCreditsBalance>0),[n]),k=(0,a.useMemo)(()=>(function({activeOrgSlug:t,memberships:e,connectableOrgs:s,isDeviceFlow:r,orgHint:i,orgIdFromUrl:n}){if(e.length){if(n){let t=e.find(t=>
3t.id===n);if(t&&(r||t.isPersonal))return t.id}if(r&&i){let t=e.find(t=>t.slug===i);if(t)return t.id}if(r&&t){let s=e.find(e=>e.slug===t);if(s)return s.id}if(r){let t=s.length>0?s:e,r=t.find(t=>t.isPersonal);if(r?.hasActiveSubscription)return r.id;let i=t.find(t=>t.hasActiveSubscription);return i?i.id:r?r.id:1===t.length?t[0].id:void 0}return e.find(t=>t.isPersonal)?.id}})({activeOrgSlug:e,memberships:n??[],connectableOrgs:E,isDeviceFlow:_,orgHint:l,orgIdFromUrl:new URL(window.location.href).searchParams.get("org_id")??void 0}),[e,_,E,n,l]),P=(0,a.useCallback)(t=>!!t&&(n?.find(e=>e.id===t)?.apiCreditsBalance??0)>0,[n]),A=(0,a.useCallback)(t=>!!t&&(n?.find(e=>e.id===t)?.hasActiveSubscription??!1),[n]),T=k?P(k):(t?.apiCreditsBalance??0)>0,O=!!k&&A(k),[R,$]=function(t,...[e]){return function(t,...[e]){let s=function(t,...[e]){let[[s,r],i]=(0,a.useState)(()=>{let s=L(t,e);return[t.config,s]});if(t.config!==s){let s=L(t,{...e,snapshot:r.getPersistedSnapshot({__unsafeAllowInlineActors:!0})});i([t.config,s]),r=s}return c(()=>{r.logic.implementations=t.implementations}),r}(t,e),r=(0,a.useCallback)(()=>s.getSnapshot(),[s]),i=(0,a.useCallback)(t=>{let{unsubscribe:e}=s.subscribe({next:t,error:t});return e},[s]),n=(0,tT.useSyncExternalStore)(i,r,r),o="status"in n?n:void 0;if(o?.status==="error")throw o.error;return(0,a.useEffect)(()=>(s.start(),()=>{let t,e;t=[],tO(s,e=>{t.push([e,e.getSnapshot()]),e.observers=new Set}),e=s.system.getSnapshot?.(),s.stop(),s.system._snapshot=e,t.forEach(([t,e])=>{t._processingStatus=0,t._snapshot=e})}),[s]),[n,s.send,s]}(t,e)}(b,{input:{user:t?{userId:t.userId,subscriptionPlanId:g}:void 0,deviceCode:r??v,resumeSubscribePlanId:S,resumeAfterCheckout:x?.status==="success",selectedPlanId:g,selectedOrgId:k,returnPath:u}}),M=(0,a.useCallback)(t=>{console.log("[sub] send:",t.type,t),$(t)},[$]);(0,a.useEffect)(()=>{console.log("[sub] state:",R.value,R.context)},[R]),(0,a.useEffect)(()=>{if(!S&&!x&&null===w)return;console.log("[sub] cleaning URL",{resumeSubscribePlanId:S,stripeReturn:x}),(S||x)&&d.clear();let t=new URL(window.location.href);t.searchParams.delete("plan"),t.searchParams.delete("session_id"),t.searchParams.delete("checkout"),t.searchParams.delete("from_tier"),t.searchParams.delete("target_tier"),t.searchParams.delete("subscription_canceled"),window.history.replaceState({},"",t.pathname+t.search)},[S,x,w,d]);let N=(0,a.useRef)(R);N.current=R;let U=p({stateRef:N,send:M}),D=(0,a.useRef)(!1);(0,a.useEffect)(()=>{R.matches("authDialog")&&!D.current&&(D.current=!0,U.openLoginFlow()),R.matches("authDialog")||(D.current=!1)},[R.value,U]);let F=U.logout,j=R.matches("authDialog"),B=f?.subscriptionTypeId??t?.subscription?.expired?.subscriptionTypeId??s.find(t=>20===t.dollarsPerMonth)?.id??s[1]?.id??s[0]?.id??null,[G,V]=(0,a.useState)(S??w??B),z=f?.subscriptionTypeId;(0,a.useEffect)(()=>{z&&!C&&V(z)},[z,C]);let W=s.find(t=>t.id===G)??s[0]??null,H=R.context.errorMessage??null,J=(0,a.useId)();(0,a.useEffect)(()=>{if(H&&"inline"!==h)return ed.toast.error(H,{duration:0,closeButton:!0,id:`subscription-management-error:${J}`}),()=>{ed.toast.dismiss(`subscription-management-error:${J}`)}},[H,J,h]);let q=R.matches("executingCancellation")?"cancel":R.matches("executingResume")?"resume":R.matches("executingPlanChange")||R.matches("upgradeCheckout")?`plan:${R.context.selectedPlanId}`:null,K=R.matches("stripeCheckout")||R.matches("stripeCheckoutRedirecting")||R.matches("subscribeFlow")||R.matches("upgradeCheckout")?R.context.selectedPlanId??null:null,Y=R.matches("postPurchase")&&x?.status==="success"&&"upgrade"===x.checkout&&!!x.fromTierId&&!!x.targetTierId&&!!f&&f.subscriptionTypeId!==x.fromTierId&&f.subscriptionTypeId!==x.targetTierId,Q=R.matches("postPurchase")&&x?.status==="success"&&"upgrade"===x.checkout&&!!x.targetTierId&&!Y&&f?.subscriptionTypeId!==x.targetTierId,X=R.matches("postPurchase")&&(!f||Q),Z=R.context.selectedOrgId?P(R.context.selectedOrgId):T,tt=R.context.selectedOrgId?A(R.context.selectedOrgId):O,te=R.matches("terminal")&&_,ts=R.matches("deviceAuthorize"),tr=null!==K||R.matches("executingPlanChange")||R.matches("executingCancellation")||R.matches("executingResume"),ti=_&&f&&W?.id===f.subscriptionTypeId,tn=(0,a.useRef)(!1);(0,a.useEffect)(()=>
3{if(R.matches("stripeCheckoutRedirecting")&&R.context.stripeCheckoutUrl&&!tn.current){console.log("[sub] effect: redirecting to stripe",R.context.stripeCheckoutUrl),tn.current=!0,d.clear();let t=s.find(t=>t.id===R.context.selectedPlanId);t&&(0,tR.trackGoogleAnalyticsBeginCheckout)(function({activeSubscription:t,tier:e}){let s=!!(t?.stripeSubscriptionId&&e.dollarsPerMonth>t.dollarsPerMonth),r=s?Math.max(tL(e)-(t?.dollarsPerMonth??0),0):tL(e);return{checkoutType:s?"subscription_upgrade":"subscription",value:r,items:[{item_id:e.id,item_name:s?`Upgrade to ${e.name}`:e.name,item_category:"subscription",...s?{item_variant:"upgrade"}:{},price:r,quantity:1}]}}({activeSubscription:f,tier:t})),window.location.href=R.context.stripeCheckoutUrl}},[f,s,R,d]),(0,a.useEffect)(()=>{if(!X)return;console.log("[sub] effect: starting post-checkout polling");let t=setInterval(()=>m.refresh(),2e3);return()=>clearInterval(t)},[X,m]);let to=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(R.matches("postPurchase")&&f&&!X){if(console.log("[sub] effect: subscription confirmed, sending SUBSCRIPTION_CONFIRMED"),!to.current&&!(x?.status==="success"&&x.sessionId?.startsWith("managed_upgrade_"))){var e;let r;to.current=!0;let i=x?.status==="success"&&"upgrade"===x.checkout&&x.fromTierId?s.find(t=>t.id===x.fromTierId):void 0;r=function({subscription:t,checkoutKind:e,transactionId:s,upgradeFromDollarsPerMonth:r}){let i=e??"subscription",n="subscription_upgrade"===i,o=n&&"number"==typeof r?Math.max(t.dollarsPerMonth-r,0):t.dollarsPerMonth;return{transactionId:s??t.stripeSubscriptionId??void 0,purchaseType:i,value:o,items:[{item_id:t.subscriptionTypeId,item_name:t.tier,item_category:"subscription",...n?{item_variant:"upgrade"}:{},price:o,quantity:1}]}}(e={subscription:f,transactionId:x?.status==="success"?x.sessionId??void 0:void 0,checkoutKind:x?.status==="success"&&x.checkout?`subscription${"upgrade"===x.checkout?"_upgrade":""}`:void 0,upgradeFromDollarsPerMonth:i?.dollarsPerMonth,userEmail:t?.email}),(0,tR.trackGoogleAnalyticsPurchase)(r),(0,tR.trackGoogleAdsConversion)({sendTo:0===e.subscription.dollarsPerMonth?tR.GOOGLE_ADS_FREE_SIGNUP_SEND_TO:tR.GOOGLE_ADS_SUBSCRIBE_SEND_TO,value:r.value,transactionId:r.transactionId,userEmail:e.userEmail})}M({type:"SUBSCRIPTION_CONFIRMED"})}},[R,f,X,M,x,s]),(0,a.useEffect)(()=>{R.matches("reloading")&&(console.log("[sub] effect: reloading page"),window.location.reload())},[R.value]);let ta=t=>{d.write(t),M({type:"CLICK_SUBSCRIBE",planId:t})},tc=(t=W)=>{t&&(f?.stripeSubscriptionId&&t.dollarsPerMonth>f.dollarsPerMonth?M({type:"START_UPGRADE",planId:t.id}):M({type:"START_DOWNGRADE",planId:t.id}))};(0,a.useEffect)(()=>{k&&!R.context.selectedOrgId&&M({type:"SELECT_ORG",orgId:k})},[k,R.context.selectedOrgId,M]);let tl=(0,a.useCallback)(t=>M({type:"SELECT_ORG",orgId:t}),[M]),[tu,td]=(0,a.useState)(eg),th=r??v,tp=R.context.selectedOrgId,tf=!!R.context.user;(0,a.useEffect)(()=>{if(td(eg),!_||!th||!tp||!tf)return;let t=!1;return eu({userCode:th,orgId:tp}).then(e=>{t||"success"!==e.status||td(e.data)}).catch(t=>{console.error("[sub] getDeviceBillingConsentInfo failed",t)}),()=>{t=!0}},[_,th,tp,tf]);let tg=(0,a.useCallback)(t=>M({type:"SET_ALLOW_BILLING",allowBilling:t}),[M]);return{isLoggedIn:!!R.context.user,loggingIn:j,login:()=>M({type:"CLICK_HAVE_ACCOUNT"}),logout:F,selectedTierId:G,setSelectedTierId:V,selectedTier:W,loadingTierId:K,managementAction:q,managementError:H,clearError:()=>M({type:"CLEAR_ERROR"}),deviceApproved:te,approvingDevice:ts,cancellationConfirmOpen:R.matches("confirmingCancellation")||R.matches("executingCancellation"),setCancellationConfirmOpen:t=>{M({type:t?"OPEN_CANCEL_MODAL":"CLOSE_CANCEL_MODAL"})},activeSubscription:f,isSubscriptionExpired:y,isBusy:tr,isSelectedTierActive:ti,waitingForSubscription:X,hasTopUpCredits:Z,hasSelectedOrgActiveSubscription:tt,isDeviceFlow:_,deviceUserCode:r??v,memberships:n??[],connectableOrgs:E,orgHint:l,selectedOrgId:R.context.selectedOrgId,setSelectedOrgId:tl,billingConsent:tu,allowBilling:R.context.allowBilling,setAllowBilling:tg,handleSubscribe:ta,handlePlanChange:tc,handleTierCta:t=>{let e=s.find(e=>e.id===t);if(!e)return;let r=f&&!y?f:null;if(V(t),r){if(r.subscriptionTypeId===t)return;tc(e)}else ta(t)},handleDeviceAction:()=>{ti?M({type:"DEVICE_CONNECT"}):f&&W?tc():W&&ta(W.id)},handleTopUpOnlyConnect:()=>{M({type:"DEVICE_CONNECT"})},handleCancellationUpdate:t=>{t?M({type:"CONFIRM_CANCEL"}):M({type:"RESUME_SUBSCRIPTION"})}}},"useWorkosAuthController",0,function(t){let e=(0,a.useCallback)(()=>{let t=window.location.pathname+window.location.search+window.location.hash;window.location.href=`/login?callbackUrl=${encodeURIComponent(t)}`},[]),s=(0,a.useCallback)(()=>{window.location.href="/api/auth/logout"},[]);return(0,a.useMemo)(()=>({openLoginFlow:e,logout:s}),[e,s])}],474970)}]);
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.