PageSourceSearch

https://app.cimanote.com/assets/CheckoutModal-CM54Ex3I.js

js cimanote.com collected 2026-10-08 06:27:38 UTC 7,113 bytes, 2 lines download raw bytes

1import{r as n,o as e}from"./vendor-DNZWwcBZ.js";import{E as L,a as A}from"./stripe-Bl8CX91V.js";import{a as I,_ as M,C as T,O as Y,R as D,s as v,as as R,at as B,ah as z}from"./index-bfDAdtxJ.js";import{g as F}from"./stripe-iejetf-r.js";import"./data-7Dt9MlTF.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"c2dbaa5fc406f9046009805c1ab35a7c3cd1ee39"};var s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="680be8a0-c022-4a3a-9e1a-be6e65a8835d",t._sentryDebugIdIdentifier="sentry-dbid-680be8a0-c022-4a3a-9e1a-be6e65a8835d")}catch{}})();function O(t){if(!t)return null;const s=new Date(t);return Number.isNaN(s.getTime())?null:s.toLocaleDateString(void 0,{day:"numeric",month:"long",year:"numeric"})}function $({interval:t="annual",source:s="billing_page",onClose:a}){const h=F(),[f,w]=n.useState(null),[y,l]=n.useState(null),g=I(r=>{var o;return(o=r.user)==null?void 0:o.id}),p=n.useRef(!1);n.useEffect(()=>{p.current||(p.current=!0,M(g,"checkout_opened",{interval:t,source:s}))},[g,t,s]);const{planState:C,trialEndsAt:E}=T(),S=Y(),P=D(),k=z[P],[_,b]=n.useState(!1),x=C==="trial"&&!_,u=O(E);return n.useEffect(()=>{const r=o=>{o.key==="Escape"&&a()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[a]),n.useEffect(()=>{x||(async()=>{const{data:{session:r}}=await v.auth.getSession();if(!r){console.warn("[CheckoutModal] getSession() returned null — user is not authenticated"),l("Your session has expired. Please sign out and sign back in.");return}const o=await R(),{data:d,error:j}=await v.functions.invoke("create-stripe-session",{body:{interval:t,countryHint:o},headers:{Authorization:`Bearer ${r.access_token}`}});if(j){const i=j.context,N=i==null?void 0:i.status;let m="";try{const c=await(i==null?void 0:i.json());m=(c==null?void 0:c.detail)??(c==null?void 0:c.error)??""}catch{}N===401?(console.warn("[CheckoutModal] 401 from create-stripe-session — detail:",m),l("Your session has expired. Please sign out and sign back in.")):(console.error("[CheckoutModal] create-stripe-session error — status:",N,"detail:",m),l("Could not start checkout. Please try again."));return}if(!(d!=null&&d.clientSecret)){console.error("[CheckoutModal] No clientSecret in response:",d),l("Could not start checkout. Please try again.");return}w(d.clientSecret)})()},[t,x]),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",onMouseDown:r=>{r.target===r.currentTarget&&a()},children:e.jsxs("div",{className:"bg-white dark:bg-[#0d1020] rounded-2xl border border-gray-200 dark:border-white/10 shadow-xl w-full max-w-xl overflow-hidden flex flex-col max-h-[90vh]",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 dark:border-white/10 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(B,{size:20,circular:!0}),e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Upgrade to Pro"}),e.jsx("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full bg-accent/10 text-accent border border-accent/20 capitalize",children:t})]}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"overflow-y-auto flex-1",children:h?y?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx("p",{className:"text-red-600 dark:text-red-400 mb-4 text-sm",children:y}),e.jsx("button",{onClick:a,className:"text-sm text-gray-500 dark:text-gray-400 underline",children:"Close"})]}):x?S?e.jsxs("div",{className:"p-8","data-testid":"checkout-annual-pitch",children:[e.jsx("p",{className:"text-sm text-gray-900 dark:text-gray-50 font-semibold leading-relaxed",children:t==="annual"?e.jsxs(e.Fragment,{children:["Cimanote Pro - ",k.annual,"/year, 2 months free."]}):e.jsxs(e.Fragment,{children:["Cimanote Pro - ",k.monthly,"/month."]})}),e.jsxs("p",{className:"mt-3 text-sm text-gray-700 dark:text-gray-200 leading-relaxed",children:["Your Pro access continues without interruption - your paid plan starts today",u?e.jsxs(e.Fragment,{children:[" and replaces the trial that would end ",u]}):null,"."]}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 rounded-lg text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",children:"Keep my free trial"}),e.jsx("button",{onClick:()=>b(!0),className:"px-4 py-2 rounded-lg text-sm font-medium bg-accent text-white hover:opacity-90 transition-opacity",children:"Continue"})]})]}):e.jsxs("div",{className:"p-8","data-testid":"checkout-trial-guard",children:[e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-200 leading-relaxed",children:u?e.jsxs(e.Fragment,{children:["You already have Pro ",e.jsxs("strong",{children:["free until ",u]}),". You do not need to pay anything today."]}):e.jsx(e.Fragment,{children:"You already have Pro free as part of your trial. You do not need to pay anything today."})}),e.jsx("p",{className:"mt-3 text-sm text-gray-700 dark:text-gray-200 leading-relaxed",children:"Are you sure you want to continue to checkout?"}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 rounded-lg text-sm font-medium bg-accent text-white hover:opacity-90 transition-opacity",children:"Keep my free trial"}),e.jsx("button",{onClick:()=>b(!0),className:"px-4 py-2 rounded-lg text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",children:"Continue to checkout"})]})]}):f?e.jsx(L,{stripe:h,options:{clientSecret:f},children:e.jsx(A,{})}):e.jsx("div",{className:"p-10 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-gray-400 dark:text-gray-500",children:[e.jsxs("svg",{className:"w-5 h-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.jsx("span",{className:"text-sm",children:"Loading checkout…"})]})}):e.jsxs("div",{className:"p-8 text-center",children:[e.jsxs("p",{className:"text-red-600 dark:text-red-400 mb-4 text-sm",children:["Stripe is not configured. Please set ",e.jsx("code",{className:"font-mono",children:"VITE_STRIPE_PUBLISHABLE_KEY"})," and redeploy."]}),e.jsx("button",{onClick:a,className:"text-sm text-gray-500 dark:text-gray-400 underline",children:"Close"})]})})]})})}export{$ as default};
2//# sourceMappingURL=CheckoutModal-CM54Ex3I.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.