PageSourceSearch

https://jango.ai/_next/static/chunks/e87260b38b055ce1.js?dpl=dpl_E4wMJdHW5s31njkpZzuQSNvBwLmh

js jango.ai collected 2026-10-05 15:36:31 UTC 26,691 bytes, 9 lines download raw bytes

1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="50cdb159-9d1f-b5d6-ecfd-3272a090e7e7")}catch(e){}}();
2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,788416,e=>{"use strict";var t=e.i(271645);let n="(max-width: 600px), (max-width: 932px) and (max-height: 500px) and (min-aspect-ratio: 3/2)";function r(e){let t=window.matchMedia(n);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function a(){return(0,t.useSyncExternalStore)(r,()=>window.matchMedia(n).matches,()=>!1)}e.s(["usePhoneLayout",()=>a])},10678,e=>{"use strict";let t=`
3  radial-gradient(ellipse at 26% 50%, rgba(74, 222, 128, 0.10) 0%, transparent 45%) fixed,
4  radial-gradient(ellipse at 85% 12%, rgba(34, 197, 94, 0.07) 0%, transparent 50%) fixed,
5  radial-gradient(ellipse at 55% 100%, rgba(34, 197, 94, 0.05) 0%, transparent 55%) fixed,
6  #000
7`;e.s(["TERM",0,{font:"var(--font-geist-mono), ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",accent:"#4ade80",bright:"#e8ffee",body:"#9ec9ad",muted:"#5fbf86",faint:"rgba(134, 239, 172, 0.35)",panelBg:"rgba(8, 18, 12, 0.72)",panelBorder:"rgba(74, 222, 128, 0.30)",panelGlow:"0 0 0 1px rgba(74,222,128,0.06), 0 0 26px rgba(74,222,128,0.14), inset 0 0 40px rgba(74,222,128,0.05)",divider:"rgba(74, 222, 128, 0.12)",warn:"#f5b34a",danger:"#ff6b6b"},"TERM_PAGE_BG",0,t])},968246,e=>{"use strict";async function t(e){let t=new TextEncoder().encode(e);return btoa(String.fromCharCode(...new Uint8Array(await crypto.subtle.digest("SHA-256",t)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}let n="jukebox_pending_oauth_flows";function r(){try{return JSON.parse(localStorage.getItem(n)||"{}")}catch{return{}}}function a(e){try{localStorage.setItem(n,JSON.stringify(e))}catch{}}function o(e){let t=Date.now(),n=!1;for(let[r,a]of Object.entries(e))(!a._savedAt||t-a._savedAt>6e5)&&(delete e[r],n=!0);return n&&a(e),e}function i(e){try{let t=o(r())[e];if(!t)return null;let{_savedAt:n,...a}=t;return a}catch{return null}}function l(e){try{let t=r();delete t[e],a(t)}catch{}}let c=new Set(["robinhood"]),s={robinhood:["jango.ai","www.jango.ai"]},d={"jango.ai":"https://www.jango.ai"};function u(){return`${d[window.location.hostname]??window.location.origin}/oauth/callback`}function h(e){let t;return c.has(e)&&"localhost"!==(t=window.location.hostname)&&"127.0.0.1"!==t&&!s[e]?.includes(window.location.hostname)}function p(e){return h(e)?"http://localhost:47815/oauth/callback":u()}function g(e){let t;try{t=new URL(e.trim())}catch{return{error:"That doesn't look like a full URL — copy the entire address, starting with http://localhost."}}let n=t.searchParams.get("error");if(n){let e=t.searchParams.get("error_description");return{error:`The provider returned an error: ${n}${e?` — ${e}`:""}`}}let r=t.searchParams.get("code"),a=t.searchParams.get("state");return r&&a?{code:r,state:a}:{error:"No authorization code in that URL — copy the popup's final address; it should contain ?code=…"}}async function b(e,n){let i;if(!e.exchange_ticket)return console.error("[OAuth] Backend did not provide an exchange ticket."),null;let l=e.client_id;if(!l)return console.error(`[OAuth] No client_id available. Backend registration_failed: ${!!e.registration_failed}. Registration endpoint: ${e.registration_endpoint}`),null;let c=crypto.randomUUID(),s=e.code_challenge_methods_supported,d=s?s.includes("S256"):!!e.registration_endpoint;console.log("[OAuth] buildOAuthUrl:",{ccm:s,registration_endpoint:e.registration_endpoint,supportsPkce:d,authorization_endpoint:e.authorization_endpoint});let u="";d&&(i=new Uint8Array(32),crypto.getRandomValues(i),u=btoa(String.fromCharCode(...i)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""));let h=new URL(e.authorization_endpoint);if(h.searchParams.set("response_type","code"),h.searchParams.set("client_id",l),h.searchParams.set("redirect_uri",e.callback_url),h.searchParams.set("state",c),d&&u){let e=await t(u);
7h.searchParams.set("code_challenge",e),h.searchParams.set("code_challenge_method","S256")}e.scopes_supported&&h.searchParams.set("scope",e.scopes_supported.join(" "));var p={exchange_ticket:e.exchange_ticket,code_verifier:u,service_slug:n,...e.request_id?{request_id:e.request_id}:{},...e.bot_id?{bot_id:e.bot_id}:{}};try{let e=o(r());e[c]={...p,_savedAt:Date.now()},a(e)}catch{}return h.toString()}function y(){let e=navigator.userAgent;if(/Instagram|FBAN|FBAV/.test(e))return!0;let t=navigator.userAgentData;return t?.mobile===!0||/iPhone|iPod|Android.*Mobile/.test(e)}function f(e,t){e.document.title=`Connecting ${t}`,e.document.body.replaceChildren(),e.document.body.style.cssText="margin:0;min-height:100vh;display:grid;place-items:center;font-family:ui-monospace,monospace;background:#06100a;color:#dff8e7;";let n=e.document.createElement("div");n.textContent=`Connecting ${t}...`,e.document.body.append(n)}function m(e){let t=window.open("","_blank","width=600,height=700");return t&&f(t,e),t}function w(e){let t,n,r,a,o,i=(r=(n=(t=window.screen).availLeft??0)+t.availWidth-600,a=Math.max(n,Math.min(window.screenX+window.outerWidth,r)),o=Math.max(t.availTop??0,window.screenY+40),window.open("","_blank",`popup,width=600,height=700,left=${a},top=${o}`));return i&&f(i,e),i}async function k(e,t,n=m(t)){let r=await b(e,t);return r?n&&!n.closed?(n.location.href=r,!0):null!==window.open(r,"_blank","width=600,height=700"):(n?.close(),!1)}e.s(["buildOAuthUrl",()=>b,"getPendingOAuthFlow",()=>i,"hostedCallbackUrl",()=>u,"isPhoneBrowser",()=>y,"needsManualCallback",()=>h,"oauthCallbackUrl",()=>p,"openBesidePlaceholder",()=>w,"openOAuthPopup",()=>k,"openOAuthPopupPlaceholder",()=>m,"parseManualCallbackUrl",()=>g,"removePendingOAuthFlow",()=>l])},659268,e=>{"use strict";var t=e.i(843476),n=e.i(271645),r=e.i(174080),a=e.i(968246),o=e.i(10678);function i({label:e,prepError:i,onStart:l,onSubmit:c,onCancel:s,zIndex:d=220}){let[u,h]=(0,n.useState)("intro"),[p,g]=(0,n.useState)(""),[b,y]=(0,n.useState)(!1),[f,m]=(0,n.useState)(null),w=(0,n.useRef)(null),[k,x]=(0,n.useState)(!1),[v]=(0,n.useState)(()=>"u">typeof navigator&&/^((?!chrome|chromium|crios|fxios|android).)*safari/i.test(navigator.userAgent)),[_]=(0,n.useState)(()=>"u">typeof navigator&&(0,a.isPhoneBrowser)());if((0,n.useEffect)(()=>{if(!k)return;let e=window.setInterval(()=>{w.current?.closed&&x(!1)},500);return()=>window.clearInterval(e)},[k]),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.stopPropagation(),b||s())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[b,s]),"u"<typeof document)return null;let E=()=>{if(b)return;let e=l();e?(w.current=e,x(!0),m(null),h("paste")):m("Your browser blocked the sign-in popup. Allow popups for this site and try again.")},T=async(e=p)=>{if(!b&&e.trim()){y(!0),m(null);try{let t=await c(e);t&&m(t)}catch(e){m(e instanceof Error?e.message:String(e))}finally{y(!1)}}},S={flexShrink:0,width:20,height:20,borderRadius:6,border:`1px solid ${o.TERM.panelBorder}`,display:"grid",placeItems:"center",fontSize:12,fontWeight:700,color:o.TERM.accent},j=e=>({flex:"1 1 auto",border:`1px solid ${o.TERM.panelBorder}`,background:e?"rgba(74,222,128,0.08)":"rgba(74,222,128,0.2)",color:e?o.TERM.muted:o.TERM.bright,borderRadius:8,padding:"10px 14px",fontSize:13,fontWeight:700,fontFamily:o.TERM.font,letterSpacing:.4,cursor:e?"default":"pointer",textShadow:"0 0 8px rgba(74,222,128,0.4)",transition:"all 140ms ease"}),C={border:`1px solid ${o.TERM.divider}`,background:"transparent",color:o.TERM.muted,borderRadius:8,padding:"10px 14px",fontSize:13,fontWeight:600,fontFamily:o.TERM.font,cursor:b?"default":"pointer",transition:"all 140ms ease"},M=e=>(0,t.jsx)("ol",{style:{margin:"0 0 16px",padding:0,listStyle:"none",display:"grid",gap:8},children:e.map(([e,n])=>(0,t.jsxs)("li",{style:{display:"flex",gap:10,fontSize:13.5,lineHeight:1.5},children:[(0,t.jsx)("span",{style:S,children:e}),(0,t.jsx)("span",{children:n})]},e))}),R=v?(0,t.jsxs)(t.Fragment,{children:["right-click the address at the top of that window and choose ",(0,t.jsx)("b",{style:{color:o.TERM.bright},children:"Copy Website Address"})]}):(0,t.jsxs)(t.Fragment,{children:["click its address bar (or press ",(0,t.jsx)("b",{style:{color:o.TERM.bright},children:"⌘L"}),") and copy the ",(0,t.jsx)("b",{style:{color:o.TERM.bright},children:"full address"})]}),P=[["1",(0,t.jsxs)(t.Fragment,{children:["A ",e," window will open — sign in and approve the connection (including any device verification)."]})],["2",(0,t.jsxs)(t.Fragment,{children:["When it finishes, that window will land on a ",(0,t.jsx)("b",{style:{color:o.TERM.bright},children:"“This site can’t be reached”"})," error page. ",(0,t.jsx)("b",{style:{color:o.TERM.bright},children:"That’s expected"})," — it means the approval worked."]})],["3",(0,t.jsxs)(t.Fragment,{children:["To copy it, ",R," (starts with ",(0,t.jsx)("span",{style:{color:o.TERM.accent},children:"http://localhost"}),"), then paste it back on this page."]})]],A=[["1",(0,t.jsxs)(t.Fragment,{children:["Approve the connection in the ",e," window (sign-in, c
7onsent, and any device verification)."]})],["2",(0,t.jsxs)(t.Fragment,{children:["It will end on a ",(0,t.jsx)("b",{style:{color:o.TERM.bright},children:"“This site can’t be reached”"})," page. That’s expected — the code is in the address bar."]})],["3",(0,t.jsxs)(t.Fragment,{children:["To copy it, ",R," (starts with ",(0,t.jsx)("span",{style:{color:o.TERM.accent},children:"http://localhost"}),"), then paste it below."]})]],O=i?"connection failed":_?"use a computer":"intro"===u?"before you connect":"one more step",I="paste"!==u||i?`link ${e}`:`finish linking ${e}`;return(0,r.createPortal)((0,t.jsx)("div",{style:{position:"fixed",inset:0,zIndex:d,background:"rgba(0,0,0,0.72)",backdropFilter:"blur(7px)",WebkitBackdropFilter:"blur(7px)",display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:o.TERM.font},children:(0,t.jsxs)("div",{role:"dialog","aria-label":`Connect ${e}`,style:{width:"intro"!==u||i||_?"min(520px, 100%)":"min(760px, 100%)",maxHeight:"calc(100vh - 48px)",overflowY:"auto",background:"rgba(8, 18, 12, 0.96)",border:`1px solid ${o.TERM.panelBorder}`,borderRadius:14,boxShadow:o.TERM.panelGlow,padding:"24px 26px",color:o.TERM.body},children:[(0,t.jsx)("div",{style:{fontSize:12,fontWeight:700,letterSpacing:"0.12em",textTransform:"uppercase",color:i?o.TERM.danger:o.TERM.warn,textShadow:i?"none":"0 0 8px rgba(245,179,74,0.35)",marginBottom:10},children:O}),(0,t.jsxs)("div",{style:{fontSize:19,fontWeight:700,color:o.TERM.bright,textShadow:"0 0 14px rgba(74,222,128,0.3)",marginBottom:12},children:[(0,t.jsx)("span",{style:{color:o.TERM.accent},children:"jango:~$"})," ",I]}),i?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{style:{fontSize:13,lineHeight:1.55,color:o.TERM.danger,marginBottom:16},children:i}),(0,t.jsx)("div",{style:{display:"flex",gap:10},children:(0,t.jsx)("button",{type:"button",onClick:s,style:j(!1),children:"close"})})]}):_?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{style:{fontSize:13.5,lineHeight:1.55,marginBottom:16},children:[e," can only be connected from a computer right now. Open Jango on your computer and connect it there."]}),(0,t.jsx)("div",{style:{display:"flex",gap:10},children:(0,t.jsx)("button",{type:"button",onClick:s,style:j(!1),children:"close"})})]}):"intro"===u?(0,t.jsxs)(t.Fragment,{children:[M(P),(0,t.jsx)("video",{src:"/robinhood-manual-handoff-demo.mp4",autoPlay:!0,loop:!0,muted:!0,playsInline:!0,style:{display:"block",width:"100%",aspectRatio:"1440 / 920",objectFit:"cover",background:"#000",borderRadius:8,border:`1px solid ${o.TERM.panelBorder}`,marginBottom:14}}),f&&(0,t.jsx)("div",{style:{fontSize:12.5,lineHeight:1.5,color:o.TERM.danger,marginBottom:12},children:f}),(0,t.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,t.jsx)("button",{type:"button",onClick:E,style:j(!1),children:"$ start auth flow"}),(0,t.jsx)("button",{type:"button",onClick:s,style:C,onMouseEnter:e=>{e.currentTarget.style.color=o.TERM.bright},onMouseLeave:e=>{e.currentTarget.style.color=o.TERM.muted},children:"cancel"})]})]}):(0,t.jsxs)(t.Fragment,{children:[M(A),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12.5,color:o.TERM.muted,marginBottom:12},children:[(0,t.jsx)("span",{style:{flex:"1 1 auto"},children:k?`${e} window is open.`:`${e} window closed. Didn't reach the error page?`}),(0,t.jsx)("button",{type:"button",onClick:()=>{k?w.current?.focus():E()},disabled:b,style:C,onMouseEnter:e=>{e.currentTarget.style.color=o.TERM.bright},onMouseLeave:e=>{e.currentTarget.style.color=o.TERM.muted},children:k?"show window":"reopen"})]}),(0,t.jsx)("input",{type:"text",value:p,onChange:e=>{g(e.target.value),m(null)},onKeyDown:e=>{"Enter"===e.key&&T()},onPaste:e=>{let t=e.clipboardData.getData("text");t.trim()&&(e.preventDefault(),g(t),T(t))},placeholder:"http://localhost:47815/oauth/callback?code=…",autoFocus:!0,spellCheck:!1,disabled:b,style:{width:"100%",boxSizing:"border-box",background:"rgba(74,222,128,0.06)",border:`1px solid ${f?o.TERM.danger:o.TERM.panelBorder}`,borderRadius:8,padding:"10px 12px",fontSize:13,fontFamily:o.TERM.font,color:o.TERM.bright,outline:"none",marginBottom:f?8:14}}),f&&(0,t.jsx)("div",{style:{fontSize:12.5,lineHeight:1.5,color:o.TERM.danger,marginBottom:12},children:f}),(0,t.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,t.jsx)("button",{type:"button",onClick:()=>void T(),disabled:b||!p.trim(),style:j(b||!p.trim()),children:b?"connecting…":"$ complete connection"}),(0,t.jsx)("button",{type:"button",onClick:s,disabled:b,style:C,onMouseEnter:e=>{e.currentTarget.style.color=o.TERM.bright},onMouseLeave:e=>{e.currentTarget.style.color=o.TERM.muted},children:"cancel"})]})]})]})}),document.body)}e.s(["OAuthManualHandoffModal",()=>i])},974740,e=>{"use strict";var t=e.i(107471),n=e.i(322452);let r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im95dWVxcnJkZnBwZXNkcHV2eGtwIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzI1ODI1MDUsImV4cCI6MjA4ODE1ODUwNX0.vGCj5KWqX9debvzZ2ytetLPR1sbpJP5wayasZhGWN5Y";function a(e){let a="u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`;return(async()=>{try{let{data:{session:o}}=await t.supabase.auth.getSession(),i={"Content-Type":"application/json",apikey:r};o?.access_token?i.Authorization=`Bearer ${o.access_token}`:i.Authorization=`Bearer ${r}`,await (0,n.supabaseUnaryFetch)("https://oyueqrrdfppesdpuvxkp.supabase.co/functions/v1/user-action-log",{method:"POST",headers:i,keepalive:!0,body:JSON.stringify({run_id:a,source:"frontend",action:e.action,status:e.status??null,bot_id:e.bot_id??null,client_session_id:e.client_session_id??null,payload:e.payload??{}})})}catch(e){console.warn("[logAction] failed",e)}})(),{run_id:a}}e.s(["logAction",()=>a])},961833,e=>{"use strict";var t=e.i(107471);async function n(e){let n=new Set,{data:{session:r}}=await t.supabase.auth.getSession(),a=r?.user?.id;if(!a||0===e.length)return{ok:!0,connected:n};let{data:o,error:i}=await t.supabase.from("mcps").select("id, slug").in("slug",[...e]);if(i)return{ok:!1,connected:n,error:i.message};if(!o?.length)return{ok:!0,connected:n};let{data:l,error:c}=await t.supabase.from("user_oauth_tokens").select("mcp_id").eq("user_uid",a).in("mcp_id",o.map(e=>e.id));if(c)return{ok:!1,connected:n,error:c.message};let s=new Set((l??[]).map(e=>e.mcp_id));return{ok:!0,connected:new Set(o.filter(e=>s.has(e.id)).map(e=>e.slug))}}e.s(["CONNECTIONS_STORAGE_KEY",0,"jango-connections-v1","fetchPersistedConnections",()=>n])},631908,910358,e=>{"use strict";var t=e.i(107471);async function n(e={}){let{data:r,error:a}=await t.supabase.functions.invoke("alpaca-paper-account",{body:{action:"claim",only_if_no_brokerage:!0===e.onlyIfNoBrokerage}});return a||!r?.success?{ok:!1,status:r?.status,error:"user_not_found"===r?.status?"Finish signing in before activating Paper Trading.":"Couldn’t connect Paper Trading. Try again."}:{ok:!0,status:r.status??"claimed",serviceSlug:r.service_slug??"alpaca-paper",ready:r.ready}}async function r(){try{let{data:e,error:n}=await t.supabase.functions.invoke("kalshi-demo-account",{body:{action:"claim"}});if(!n&&e?.success&&["claimed","restored","existing","installed"].includes(e.status??""))return{ok:!0,status:e.status,serviceSlug:"kalshi-demo"}}catch{}return{ok:!1,error:"Couldn’t prepare your demo account. Try again shortly."}}e.s(["claimPaperTradingAccount",()=>n],631908),e.s(["claimKalshiDemoAccount",()=>r],910358)},739223,e=>{"use strict";var t=e.i(843476),n=e.i(271645),r=e.i(107471),a=e.i(968246),o=e.i(659268),i=e.i(974740),l=e.i(961833),c=e.i(631908),s=e.i(910358);let d={robinhood:{category:"brokerage",label:"Robinhood"},webull:{category:"brokerage",label:"Webull"},public:{category:"brokerage",label:"Public"},ibkr:{category:"brokerage",label:"Interactive Brokers"},alpaca:{category:"brokerage",label:"Alpaca"},"alpaca-paper":{category:"brokerage",label:"Paper Trading"},x:{category:"ancillary",label:"X (Twitter)"},tiingo:{category:"ancillary",label:"Tiingo"},finnhub:{category:"ancillary",label:"Finnhub"},fmp:{category:"ancillary",label:"Financial Modeling Prep"},granola:{category:"ancillary",label:"Granola"},notion:{category:"ancillary",label:"Notion"},"mintmcp-gmail":{category:"ancillary",label:"Gmail"},"mintmcp-gcal":{category:"ancillary",label:"Google Calendar"},kalshi:{category:"prediction_market",label:"Kalshi"},"kalshi-demo":{category:"prediction_market",label:"Kalshi Demo"},polymarket:{category:"prediction_market",label:"Polymarket"},binance:{category:"crypto_exchange",label:"Binance.US"},phantom:{category:"onchain_wallet",label:"Phantom"}};function u(e){return e in d}function h(e){return!!u(e)&&"ancillary"!==d[e].category}function p(){return Object.fromEntries(Object.entries(d).map(([e,t])=>[e,{service:e,category:t.category,label:t.label,status:"none"}]))}async function g(e,t){let{data:n,error:o}=await r.supabase.auth.getUser();if(o||!n?.user)throw Error("Sign in first, then connect your account.");let{data:{session:l}}=await r.supabase.auth.getSession(),c=l?.access_token;if(!c)throw Error("Sign in first, then connect your account.");let{run_id:s}=(0,i.logAction)({action:"connect_accounts_oauth_click",payload:{service:e}}),{data:d,error:u}=await r.supabase.functions.invoke("bot-onboard",{body:{service:e,callback_url:(0,a.oauthCallbackUrl)(e),access_token:c,run_id:s},headers:{"x-run-id":s}});if(u){let e=u.context,n="";if(e)try{n=await e.clone().text()}catch{}throw Error(`Could not start the ${t} connection: ${n||u.message}`)}if(d?.status==="connected"||d?.status==="no_auth_required")return null;if(d?.status!=="auth_required"||!d.oauth)throw Error(d?.error||"Unexpected response from bot-onboard.");let h=await (0,a.buildOAuthUrl)(d.oauth,e);
7if(!h)throw Error("Could not build the authorization URL (no client_id).");return h}let b=(0,n.createContext)(null);function y({children:e}){let[h,y]=(0,n.useState)(p),f=(0,n.useRef)(null),m=(0,n.useRef)({}),[w,k]=(0,n.useState)(null),x=(0,n.useRef)(null),v=(0,n.useRef)(null),_=(0,n.useRef)(null),E=(0,n.useCallback)((e,t)=>{y(n=>({...n,[e]:{...n[e],status:t}}))},[]),T=(0,n.useCallback)(async()=>{let e=Object.keys(d),t=await (0,l.fetchPersistedConnections)(e);return t.ok&&y(n=>Object.fromEntries(e.map(e=>[e,{...n[e],status:t.connected.has(e)?"connected":"none"}]))),t},[]),S=(0,n.useCallback)(async()=>{await T()},[T]);(0,n.useEffect)(()=>{let e=setTimeout(()=>void T(),0),t=null,{data:{subscription:n}}=r.supabase.auth.onAuthStateChange((e,n)=>{let r=n?.user?.id??null;r!==f.current&&(f.current=r,y(p())),t&&clearTimeout(t),t=setTimeout(()=>void T(),0)});return()=>{n.unsubscribe(),e&&clearTimeout(e),e=null,t&&clearTimeout(t)}},[T]),(0,n.useEffect)(()=>{let e=async e=>{if("jukebox_oauth_complete"===e.type&&"string"==typeof e.service&&u(e.service)){let t=e.service;delete m.current[t];let n=await (0,l.fetchPersistedConnections)([t]);E(t,n.ok&&n.connected.has(t)?"connected":"broken")}else if("jukebox_oauth_error"===e.type)for(let e of Object.keys(m.current))delete m.current[e],E(e,"none")},t=new BroadcastChannel("jukebox_oauth");t.onmessage=t=>void e(t.data||{});let n=t=>{t.data?.type?.startsWith?.("jukebox_oauth_")&&e(t.data)};return window.addEventListener("message",n),()=>{t.close(),window.removeEventListener("message",n)}},[E]);let j=(0,n.useCallback)(async e=>{let{label:t}=d[e];if((0,a.needsManualCallback)(e))return _.current?.(),E(e,"connecting"),v.current=e,k({service:e,prepError:null}),new Promise(e=>{_.current=e});let n=window.open("","_blank","width=600,height=700");n&&(n.document.write(`<!doctype html><meta charset="utf-8"><title>Connecting ${t}</title><body style="font-family:ui-monospace,monospace;margin:0;display:grid;place-items:center;min-height:100vh;background:#04120a;color:#86efac"><div>Connecting ${t}…</div></body>`),n.document.close()),E(e,"connecting");let r=null;try{r=await g(e,t)}catch(t){throw n?.close(),E(e,"none"),t}if(null===r){n?.close(),E(e,"connected");return}if(n&&!n.closed)n.location.href=r;else if(!(n=window.open(r,"_blank","width=600,height=700")))throw E(e,"none"),Error("Your browser blocked the sign-in popup. Allow popups and try again.");m.current[e]=!0;let o=n,i=window.setInterval(()=>{o.closed&&(window.clearInterval(i),window.setTimeout(()=>{m.current[e]&&(delete m.current[e],E(e,"none"))},1500))},600)},[E]),C=(0,n.useCallback)(()=>{v.current=null,x.current=null,k(null);let e=_.current;_.current=null,e?.()},[]),M=(0,n.useCallback)(()=>{let e=w?.service;if(!e)return null;let{label:t}=d[e],n=(0,a.openBesidePlaceholder)(t);return n?(x.current=n,(async()=>{try{let r=await g(e,t);if(v.current!==e)return void n.close();if(null===r){n.close(),E(e,"connected"),C();return}m.current[e]=!0,n.closed||(n.location.href=r)}catch(t){if(n.close(),v.current!==e)return;k({service:e,prepError:t instanceof Error?t.message:String(t)})}})(),n):null},[C,w,E]),R=(0,n.useCallback)(async e=>{let t=(0,a.parseManualCallbackUrl)(e);if("error"in t)return t.error;let n=(0,a.getPendingOAuthFlow)(t.state);if(!n)return"This connection attempt has expired — cancel and click Connect again.";let{data:{session:o}}=await r.supabase.auth.getSession();if(!o?.access_token)return"You were signed out mid-flow. Sign in and try again.";let i=await fetch("/api/oauth/token",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.access_token}`},body:JSON.stringify({exchange_ticket:n.exchange_ticket,code:t.code,code_verifier:n.code_verifier})});if(!i.ok){let e="";try{e=(await i.json()).error??""}catch{}return`Token exchange failed (HTTP ${i.status})${e?`: ${e}`:""}`}let l=await i.json();if(!l.success)return l.error||"The connection could not be saved.";(0,a.removePendingOAuthFlow)(t.state);try{x.current?.close()}catch{}C();let c=new BroadcastChannel("jukebox_oauth");return c.postMessage({type:"jukebox_oauth_complete",service:n.service_slug}),c.close(),null},[C]),P=(0,n.useCallback)(()=>{let e=w?.service??null;try{x.current?.close()}catch{}C(),e&&(delete m.current[e],E(e,"none"))},[C,w,E]),A=(0,n.useCallback)(async e=>{E(e,"connecting");try{let{data:{session:t}}=await r.supabase.auth.getSession();if(!t?.user)throw Error("Sign in first, then connect your account.");let{run_id:n}=(0,i.logAction)({action:"managed_paper_trading_click",payload:{service:e}}),a="kalshi-demo"===e?await (0,s.claimKalshiDemoAccount)():await (0,c.claimPaperTradingAccount)({onlyIfNoBrokerage:!1});if(!a.ok)throw Error(a.error);E(e,"connected"),(0,i.logAction)({action:"managed_paper_trading_connected",payload:{parent_run_id:n,service:a.serviceSlug,status:a.status,ready:a.ready}})}catch(t){throw E(e,"none"),t}},[E]),O=(0,n.useCallback)(async e=>{if(!u(e))throw Error(`Unknown service: ${e}`);"alpaca-paper"===e||"kalshi-demo"===e?await A(e):await j(e)},[A,j]),I=(0,n.useCallback)(async e=>{if(e.length)try{let{data:{session:t}}=await r.supabase.auth.getSession(),n=t?.user?.id;if(!n)return;let{data:a}=await r.supabase.from("mcps").select("id").in("slug",e),o=(a??[]).map(e=>e.id);o.length&&await r.supabase.from("user_oauth_tokens").delete().eq("user_uid",n).in("mcp_id",o)}catch{}},[]),B=(0,n.useCallback)(async e=>{u(e)&&(E(e,"none"),await I([e]))},[E,I]),$=(0,n.useCallback)(e=>{let t=Object.values(h).filter(t=>t.category===e).map(e=>e.status);return t.includes("connected")?"connected":t.includes("connecting")?"connecting":t.includes("broken")?"broken":"none"},[h]),F=(0,n.useCallback)(e=>e.every(e=>"connected"===$(e)),[$]),z=(0,n.useMemo)(()=>({connections:h,connectService:O,disconnectService:B,refreshConnections:S,categoryStatus:$,isReady:F}),[h,O,B,S,$,F]);
7return(0,t.jsxs)(b.Provider,{value:z,children:[e,w&&(0,t.jsx)(o.OAuthManualHandoffModal,{label:d[w.service].label,prepError:w.prepError,onStart:M,onSubmit:R,onCancel:P,zIndex:2200})]})}let f={connections:p(),connectService:async()=>{},disconnectService:async()=>{},refreshConnections:async()=>{},categoryStatus:()=>"none",isReady:()=>!0};function m(){return(0,n.useContext)(b)??f}e.s(["CONNECTION_CATEGORY_LABEL",0,{brokerage:"brokerage",prediction_market:"prediction market",crypto_exchange:"crypto venue",onchain_wallet:"wallet",ancillary:"data & social"},"CONNECTION_SERVICES",0,d,"ConnectionsProvider",()=>y,"isConnectionService",()=>u,"isTradingVenueService",()=>h,"useConnections",()=>m])},440525,e=>{"use strict";var t=e.i(271645),n=e.i(788416);function r(){let e=(0,n.usePhoneLayout)();return(0,t.useLayoutEffect)(()=>{let t=window.visualViewport;if(!e||!t)return;let n=document.documentElement.style,r=0,a=["--phone-viewport-height","--phone-viewport-top","--phone-keyboard-inset"],o=()=>{if(r=0,1!==t.scale)return;let e=Math.max(0,window.innerHeight-t.height-t.offsetTop),o=[t.height,t.offsetTop,e],i=!1;if(a.forEach((e,t)=>{let r=`${o[t]}px`;n.getPropertyValue(e)!==r&&(n.setProperty(e,r),i=!0)}),!i||0===e)return;let l=document.activeElement;!(!(l instanceof HTMLInputElement)||!l.closest(".builder-view")||l.closest(".builder-phone-footer"))&&l.scrollIntoView({block:"nearest"})},i=()=>{r||(r=requestAnimationFrame(o))};return o(),t.addEventListener("resize",i),t.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i),()=>{cancelAnimationFrame(r),t.removeEventListener("resize",i),t.removeEventListener("scroll",i),window.removeEventListener("resize",i),a.forEach(e=>n.removeProperty(e))}},[e]),null}e.s(["PhoneViewport",()=>r])}]);
8
9//# debugId=50cdb159-9d1f-b5d6-ecfd-3272a090e7e7

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.