PageSourceSearch

https://www.app.dialiq.ai/assets/useSubscription-Dox3FWmQ.js

js dialiq.ai collected 2026-10-05 12:08:03 UTC 3,072 bytes, 1 lines download raw bytes

1import{u as l}from"./useQuery-DJGwccQx.js";import{u as y}from"./LoadingDialog-GQRdaTyp.js";import{u as w}from"./useMutation-B7RXGbO6.js";import{u,s}from"./AuthContext-CUEMrv_8.js";import{u as a}from"./BusinessContext-DC6RuTy1.js";function v(){const{getAuthToken:t}=u(),{id:e}=a();return l({queryKey:["subscription",e],queryFn:async()=>{const n=await t();if(!n)throw new Error("Authentication token not available");if(!e)throw new Error("Business ID not available");return await s.getSubscription(e,n)},enabled:!!e})}function k(){const{business:t}=a(),e=t?.vertical;return l({queryKey:["plans",e],queryFn:async()=>await s.getPlans(e)})}function m(){const{getAuthToken:t}=u(),{id:e}=a();return l({queryKey:["receipts",e],queryFn:async()=>{const n=await t();if(!n)throw new Error("Authentication token not available");if(!e)throw new Error("Business ID not available");return await s.getReceipts(e,n)},enabled:!!e})}function g(t=!0){const{getAuthToken:e}=u(),{id:n}=a();return l({queryKey:["upcomingInvoice",n],queryFn:async()=>{const o=await e();if(!o)throw new Error("Authentication token not available");if(!n)throw new Error("Business ID not available");return await s.getUpcomingInvoice(n,o)},enabled:!!n&&t})}function q(){const{getAuthToken:t}=u(),{id:e}=a(),n=y();return w({mutationFn:async o=>{const i=await t();if(!i)throw new Error("Authentication token not available");if(!e)throw new Error("Business ID not available");const c=`${window.location.origin}/subscription?checkout=success`,r=`${window.location.origin}/subscription?checkout=cancel`;return await s.createCheckoutSession(e,o,i,c,r)},onSuccess:()=>{n.invalidateQueries({queryKey:["subscription",e]}),n.invalidateQueries({queryKey:["receipts",e]})}})}function I(t=!1){const{getAuthToken:e}=u(),{id:n}=a(),o=w({mutationFn:async c=>{const r=await e();if(!r)throw new Error("Authentication token not available");if(!n)throw new Error("Business ID not available");return await s.createPortalSession(n,r,c)}});return{...o,handleOpenPortal:()=>{const c=t?{returnUrl:`${window.location.origin}/subscription`,flowType:"payment_method_update"}:void 0;o.mutate(c,{onSuccess:r=>{window.open(r.portal_url,"_blank","noopener,noreferrer")},onError:r=>{console.error("Failed to create portal session:",r)}})}}}function A(){const{getAuthToken:t}=u(),{id:e}=a(),n=y();return w({mutationFn:async o=>{const i=await t();if(!i)throw new Error("Authentication token not available");if(!e)throw new Error("Business ID not available");return await s.createTrialSubscription(e,o,i)},onSuccess:()=>{n.invalidateQueries({queryKey:["subscription",e]}),n.invalidateQueries({queryKey:["receipts",e]})}})}function E(){const{getAuthToken:t}=u(),{id:e}=a(),n=y();return w({mutationFn:async o=>{const i=await t();if(!i)throw new Error("Authentication token not available");if(!e)throw new Error("Business ID not available");return await s.changePlan(e,o,i)},onSuccess:()=>{n.invalidateQueries({queryKey:["subscription",e]}),n.invalidateQueries({queryKey:["receipts",e]})}})}export{I as a,k as b,m as c,g as d,A as e,q as f,E as g,v as u};

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