PageSourceSearch

https://static.inworld.ai/466fe559/static/js/routes.BxxeKz8O.js

js inworld.ai collected 2026-10-01 09:04:14 UTC 53,918 bytes, 1 lines download raw bytes

1import{a as s,j as e,W as at}from"./vendor-core.DkahmlU8.js";import{bv as yn,cs as xn,ct as Sn,cu as bn,cv as En,cw as Cn,cx as ht,cy as Pn,aA as yt,cz as Dt,cA as Mt,cB as Tn,aW as Qt,cC as xt,T as Zt,b6 as _,b8 as P,b7 as A,ae as Rn,S as Ie,B as L,cD as bt,cE as In,cF as _n,Y as Et,x as An,w as Ln,cG as vn,cH as wn,cI as Dn,c8 as Mn,cJ as en,d as ie,cK as jt,cL as Nt,cM as Ot,R as Me,b as q,F as ot,c as G,cN as re,Z as tn,a6 as jn,K as it,n as le,cO as qe,cP as nn,cQ as Nn,h as On,as as sn,cR as Ct,f as St,e as we,o as De,A as kn,aH as mt,cS as kt,cT as Un,I as Gn,cU as Hn,cV as Ut,a as Vn,cW as rn,cX as Gt,cY as Fn,cg as Wn}from"./bootstrap.KUFis_Od.js";import{a as $n,S as Ht,O as Vt,P as Bn,R as Yn,E as zn,V as Kn,b as qn,c as Xn,u as lt,N as ct,L as ut,d as an,e as dt,f as Jn,g as Qn,F as Zn,h as es}from"./App.C7HhiLEI.js";import"./vendor-firebase.dbYXL2Q0.js";import{e as ts,i as ns,u as ss,g as Xe,a as on}from"./publicPlaygroundFetch.BGeXiLXr.js";import{i as rs,a as as}from"./PublicSignUpGateError.BRwMR1lz.js";import{a5 as ln,y as oe,a7 as os,x as ae,aI as is,c as Pt,b0 as Tt,a6 as Rt,ac as cn,s as ls}from"./vendor-mui-x.BZ8Y4adA.js";import{u as cs,a as us,D as ds,c as ps,S as ms,h as gs,b as fs,P as hs,d as ys,C as xs}from"./utilities.esm.BM6N2gYC.js";import{r as Ss}from"./modifiers.esm.BEf9NvgW.js";import{m as un,O as dn}from"./onboardingLocalForage.k21vxsul.js";import{u as bs,g as Es,L as Cs}from"./llmService.CkfjuM5v.js";import{u as Ps}from"./smartRouter.Crkk0gZK.js";import{A as F,p as Ts,i as Rs,a as Is,m as Ft,P as _s,b as As,S as Ls,L as vs,c as Wt,d as $t,e as ws,u as Ds,f as pn,g as Ms}from"./useRouterMock.DburWl4h.js";import{P as ge,M as gt,a as js}from"./types.CrUXJ4kA.js";import{D as Ns,u as Os,a as ks,C as st,E as Us,R as Gs,b as Hs,c as Bt,d as Vs,e as Fs}from"./RealtimePlaygroundForm.C-sOi3mD.js";import{u as Ws}from"./usePermissionHint.B8BJle88.js";import{u as $s}from"./useContainerWidth.CZfSAnXf.js";import{R as Bs}from"./index.D-naDE3K.js";import{u as Ys}from"./useRuntimeApiKeysManager.Op95Z1ZB.js";import{S as zs}from"./STTPlayground.BqEiblJI.js";import{A as Ks,u as qs,a as Xs}from"./VoicesTable.DuoJTFLo.js";import{T as Js}from"./TryApiDialog.D5TGW3rL.js";import{E as Qs}from"./EnhancedTTSPlayground.Db8zB4vh.js";import"./IntegrateDialog.CqbGcAfw.js";import"./SnippetWrapper.CbVuMNn4.js";import"./json.svidJjQ5.js";import"./unsupportedIterableToArray.BlAcjINT.js";import"./defineProperty.-oRdnHGo.js";import"./integrateCodeGeneration.XRoXJIE8.js";import"./RadioGroup.Bojetmf7.js";import"./ModelPropChip.02kMpO7T.js";import"./llmRouterUi.DJRGBF-B.js";import"./constants.BvjH4fNG.js";import"./ModelProviderLogos.CQZjbC_F.js";import"./formatters.BdPR_uL3.js";import"./ProviderPile.Bm3liWCG.js";import"./providerLogos.CeGAxwqD.js";import"./selectorSearch.BluBqtVK.js";import"./MarkdownContent.DCrWN5s9.js";import"./Slider.ne3tcn4S.js";import"./PickerDetails.DUQs_V4O.js";import"./PickerPopover.1QhFXFIz.js";import"./PremiumModelChip.DLZ0AHB9.js";import"./modelSearch.zot-_whi.js";import"./routerFormUtils.BksyTysO.js";import"./voiceTagColors.BLy7B0jP.js";import"./ModelDetailsCard.Bx1H_p97.js";import"./codeGeneration.BulUxKxl.js";import"./formPersistenceScheduler.H8Xo9JBh.js";import"./Typing.9tF5YVQn.js";import"./vendor-framer-motion.Y3sHRi5w.js";import"./settingsControl.CH1VtcL5.js";import"./constants.DXrIgJP9.js";import"./language_codes.pb.BsyMdoj2.js";import"./ttsService.BSEz1qGS.js";import"./useHasPaidAccess.BfxaqIME.js";import"./TTSModelSelectField.4U0XCAA_.js";import"./VoicePickerModal.BR6W_hLP.js";import"./localeCountry.BG_zbFy2.js";import"./InputTags.Da_QE0GH.js";import"./useTTSVoicesV1.DVLeyPnE.js";import"./utils.BpN2_kOR.js";import"./debounce.H_SneSgF.js";import"./voicePickerPersistence.QQ5o5Gv0.js";import"./VoiceSelectField.NT3Ql6jt.js";import"./languages.CzJjrKs_.js";import"./LightCodeEditor.DAuRz2ea.js";import"./MobileSettingsSheet.QCH_Rhoy.js";import"./LanguageSelectField.C42U10Ze.js";import"./LanguageFlagIcon.DJcRBypY.js";import"./languageOptionOrder.DXb3-FfN.js";import"./TermChips.D_LOeDFH.js";import"./useSTTWebSocket.QeF1q96e.js";import"./constants.B_1A8zvU.js";import"./ExperimentalChip.Brfhi8o1.js";import"./GetCodeDialog.o03iNvfi.js";import"./table.CshLM3h1.js";import"./audioGraph.CpHqc6uT.js";import"./markupAnalysis.DjVj_BZV.js";import"./useCreateVoiceOptions.VioGoVQ1.js";import"./voices.CrJAcJ38.js";import"./useQueries.DG8muCoH.js";import"./useVoiceCloneSampleLimits.CQWpV4AU.js";import"./PlayButton.BgRz8Wov.js";import"./constants.Cu5I1BJ2.js";import"./agentPrompt.ZxyTGmOE.js";import"./DirtyFormConfirmation.D8aSWot5.js";import"./wav.BSkAGuun.js";import"./audioBuffer.Bpb_aST-.js";import"./phonePickerInput.CEiDgklU.js";import"./flashLanguageGuard.BNorwvsu.js";import"./constants.D5hFlRLP.js";import"./ttsPlaygroundPrefill.CeOrPTrD.js";const Zs=({children:t})=>{const n=s.useMemo(()=>{const r=yn.FULL_STUDIO_AND_PORTAL_ACCESS,i=Cn[r];return{stateType:r,hasFeature:l=>bn(i,l),hasAnyFeature:l=>Sn(i,l),availableFeatures:xn(i),hasCustomerTierAccess:()=>!0,billingAccount:{name:"billingAccounts/public-demo"},quotaReport:{name:"billingAccounts/public-demo/quota-report",overageEnabled:!1},initialized:!0,loadError:!1,hasStateAccess:l=>(r&l)===l}},[]);return e.jsx(En.Provider,{value:n,children:t})},mn=t=>{var r;if(!t||t.isAnonymous)return!1;const n=(r=t.providerData)==null?void 0:r.some(i=>(i==null?void 0:i.providerId)==="github.com");return t.emailVerified||!!n},ft=t=>{mn(t)&&Qt()&&xt(!1)},er=({children:t})=>{const[n,r]=s.useState(()=>{var d,m;const h=(m=(d=yt)==null?void 0:d.currentUser)!=null?m:null;return ft(h),h}),[i,l]=s.useState(()=>ht.resolved);s.useEffect(()=>{let h=!1;ht.promise.then(()=>{var y,I,b,E;if(h)return;const m=(E=(b=(y=Pn())==null?void 0:y.getCurrentUser())!=null?b:(I=yt)==null?void 0:I.currentUser)!=null?E:null;ft(m),l(!0),r(m)});const d=m=>{ft(m),r(m!=null?m:null)};return Dt.subscribe(d),()=>{h=!0,Dt.unsubscribe(d)}},[]);const u=mn(n),g=!!(n!=null&&n.emailVerified),C=s.useMemo(()=>{var I,b,E,f,x;const h={initialized:i,signedIn:u,emailVerified:g,fetching:!1,setInitialized:()=>{},signOut:async()=>{},signIn:async()=>{},authStatus:u?Mt.RegularUser:Mt.Unauthenticated},d={email:(I=n==null?void 0:n.email)!=null?I:"[email protected]",displayName:(b=n==null?void 0:n.displayName)!=null?b:"Demo User",userId:"users/public-demo"}
1,m={workspaces:[],landingWorkspace:void 0,fetchingWorkspaces:!1},y={name:"users/public-demo",email:d.email,displayName:d.displayName};return{auth:h,userData:d,userWorkspace:m,internal:!1,firebaseUser:n,setFirebaseUser:()=>{},firebaseUserIdentity:{id:(E=n==null?void 0:n.uid)!=null?E:"public-demo",email:d.email,imageUrl:(f=n==null?void 0:n.photoURL)!=null?f:"",creationTime:(x=n==null?void 0:n.metadata)==null?void 0:x.creationTime},setFirebaseUserIdentity:()=>{},inworldUser:y,shareableCharacterRedirect:void 0,fetchingUser:!1,setInworldUser:()=>{},setShareableCharacterRedirect:()=>{},clearErrors:()=>{},getInworldUser:async()=>({data:y}),updateUser:async()=>{},acceptToS:async()=>{},updateMarketingConsent:async()=>{},deleteUser:async()=>{},isNewUser:!1,updateOnboardingSurvey:async()=>{}}},[n,i,u,g]);return e.jsx(Tn.Provider,{value:C,children:t})},tr=["nav","header",'[role="navigation"]',".MuiDrawer-paper",".MuiDrawer-root",".NavDrawer",".TopNavBar",".WorkspaceSwitcher",'[data-public-gate="navigate"]'].join(", "),nr=['[data-
1public-gate="allow"]',".MuiDialog-root",".MuiPopover-root",".MuiMenu-root"].join(", "),sr=/^\/(?:v2\/|tts-playground|llm-playground|stt-playground|realtime-playground|voice-studio|workspaces|routers|settings|billing)/,rr=['button[aria-label="Integrate"]','button[aria-label="Try API"]','button[aria-label="Get Code"]','button[aria-label="Create Voice"]','button[aria-label="Upload audio file"]','button[aria-label="Panel settings"]','[aria-label="Create Router"]','[aria-label="Create router"]','[data-public-gate="navigate"]'].join(", "),ar=({onBlocked:t})=>(s.useEffect(()=>{const n=r=>{var C;const i=r.target;if(!i||!(i instanceof Element))return;const l=i.closest("a[href]");if(l&&sr.test((C=l.getAttribute("href"))!=null?C:"")){r.preventDefault(),r.stopPropagation(),t();return}if(i.closest(rr)){r.preventDefault(),r.stopPropagation(),t();return}i.closest(nr)||!i.closest(tr)||!i.closest(["a","button","label","input","select","textarea",'[role="button"]','[role="switch"]','[role="checkbox"]','[role="radio"]',".MuiSwitch-root",".MuiCheckbox-root",".MuiRadio-root"].join(", "))||(r.preventDefault(),r.stopPropagation(),t())};return document.addEventListener("click",n,!0),document.addEventListener("mousedown",n,!0),()=>{document.removeEventListener("click",n,!0),document.removeEventListener("mousedown",n,!0)}},[t]),null);async function or(){const t=await ts();return{workspaceName:t.workspace.startsWith("workspaces/")?t.workspace:`workspaces/${t.workspace}`}}const ir=({open:t,reason:n,feature:r,attemptsAtConversion:i,dismissible:l,onClose:u,heading:g,subheading:C})=>{const{signedIn:h}=Zt(),d=s.useRef(!1),m=`public_${r}`;s.useEffect(()=>{t&&_(A.PUBLIC_PLAYGROUND_GATE_HIT,P.PublicPlayground,{feature:r,reason:n,signup_source:m})},[t,r,n,m]),s.useEffect(()=>{!h||!t||d.current||(d.current=!0,_(A.PUBLIC_PLAYGROUND_SIGNED_UP,P.PublicPlayground,{feature:r,attemptsAtConversion:i,signup_source:m}))},[h,t,r,i,m]);const y=h?"Welcome to Inworld":g,I=h?"Setting up your account, hang tight…":C;return e.jsx(Rn,{className:"SignUpGateModal",controlled:!0,open:t,onClose:()=>{!l||h||(_(A.PUBLIC_PLAYGROUND_GATE_DISMISSED,P.PublicPlayground,{feature:r,reason:n,signup_source:m}),u==null||u())},dismissible:h?!1:!!l,multilineTitle:!0,size:"md",titleComponent:e.jsxs(Ie,{spacing:1,children:[e.jsx(oe,{variant:"h4",component:"p",children:y}),e.jsx(oe,{variant:"body2",sx:{color:"text.secondary"},children:I})]}),children:h?e.jsxs(Ie,{spacing:2,sx:{alignItems:"center",py:4},children:[e.jsx(ln,{size:32}),e.jsx(oe,{variant:"body2",sx:{color:"text.secondary"},children:"Setting up your account…"})]}):e.jsx(L,{sx:{"& > .MuiBox-root":{boxShadow:"none"}},children:e.jsx($n,{hideTerms:!1})})})};function It(t){return`${In}${t}`}function rt(t){if(typeof window=="undefined")return 0;const n=window.localStorage.getItem(It(t));if(!n)return 0;const r=Number.parseInt(n,10);return Number.isFinite(r)&&r>=0?r:0}function Yt(t,n){typeof window!="undefined"&&window.localStorage.setItem(It(t),Str
1ing(n))}function gn(t){return rt(t)<bt[t]}function lr(t){const n=bt[t],[r,i]=s.useState(()=>rt(t));s.useEffect(()=>{if(typeof window=="undefined")return;const g=It(t),C=h=>{h.key===g&&i(rt(t))};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[t]);const l=s.useCallback(()=>{const g=rt(t)+1;return Yt(t,g),i(g),g},[t]),u=s.useCallback(()=>{Yt(t,0),i(0)},[t]);return s.useMemo(()=>({attemptsUsed:r,attemptsRemaining:Math.max(0,n-r),canAttempt:r<n,limit:n,consumeAttempt:l,reset:u}),[r,n,l,u])}function fn(t){return`${_n}${t}`}function hn(){if(typeof window=="undefined")return null;try{return window.sessionStorage}catch(t){return null}}function cr(t){const n=hn();if(!n)return null;const r=n.getItem(fn(t));if(!r)return null;try{return JSON.parse(r)}catch(i){return null}}function ur(t){var n;(n=hn())==null||n.removeItem(fn(t))}const dr=1e4;function pr({feature:t,armed:n,onRedirected:r}){const i=Et(),{signedIn:l,initialized:u}=Zt(),g=s.useRef(!1),C=s.useRef(!1),h=!Qt(),{data:d,isLoading:m}=An(50,void 0,u&&l&&h),y=s.useCallback(()=>{ur(t)},[t]),I=s.useCallback((b,E)=>{g.current||(g.current=!0,_(A.PUBLIC_PLAYGROUND_CONTINUED_POST_SIGNUP,P.PublicPlayground,{feature:t,stateRehydrated:cr(t)!==null,signup_source:`public_${t}`}),i(`/workspaces/${b}/${E}`,{replace:!0}),r==null||r())},[t,i,r]);s.useEffect(()=>{var f;if(!u||!l||m||g.current||C.current)return;const b=(f=d==null?void 0:d.workspaces)==null?void 0:f[0];if(!(b!=null&&b.name))return;const E=Ln(b.name);E&&(C.current=!0,y(),I(E,vn[t]))},[t,n,u,l,m,d==null?void 0:d.workspaces,y,I]),s.useEffect(()=>{var E,f;if(!u||!l||g.current||(f=(E=d==null?void 0:d.workspaces)==null?void 0:E[0])!=null&&f.name)return;const b=window.setTimeout(()=>{g.current||(_(A.PUBLIC_PLAYGROUND_POST_SIGNUP_STALL,P.PublicPlayground,{feature:t}),wn("Still setting up your account — hang tight.",{id:`public-playground:${t}:post-signup-stall`,duration:8e3}))},dr);return()=>window.clearTimeout(b)},[n,u,l,d==null?void 0:d.workspaces,t])}const mr={tts:"/tts-playground",llm:"/llm-playground",stt:"/stt-playground",realtime:"/realtime-playground"},gr="Sign up to keep creating",fr="Log in and experience the full Inworld AI suite.",hr=3,yr=({feature:t})=>(pr({feature:t,armed:!0}),null),xr=({onClick:t})=>e.jsx(L,{component:"div","data-public-gate":"allow",sx:{position:"fixed",top:"0.5rem",right:"1rem",zIndex:n=>n.zIndex.appBar+2},children:e.jsx(ie,{"aria-label":"Sign up",size:"small",onClick:t,children:"Sign up"})}),Sr={isVisible:!1,config:null,handleDismiss:()=>{},handleCTA:()=>{},suppress:()=>()=>{}},pt=({feature:t,children:n})=>{const r=lr(t),[i,l]=s.useState(!1),[u,g]=s.useState(null),[C,h]=s.useState(!1),[d,m]=s.useState(!1),[y,I]=s.useState("freemium");s.useEffect(()=>{let f=!1;return(async()=>{var X,w,O;if(await ht.promise,f)return;const x=(w=(X=yt)==null?void 0:X.currentUser)!=null?w:null,N=(O=x==null?void 0:x.providerData)==null?void 0:O.some(U=>(U==null?void 0:U.providerId)==="github.com");if(x&&!x.isAnonymous&&(x.emailVerified||N)){window.location.href=mr[t];return}h(!0)})(),()=>{f=!0}},[t]);const b=s.useRef(r.attemptsUsed);s.useEffect(()=>{b.current=r.attemptsUsed},[r.attemptsUsed]);const E=s.useCallback(f=>{I(f),m(!0)},[]);return s.useEffect(()=>{try{window.sessionStorage.setItem(Dn,t)}catch(f){}},[t]),s.useEffect(()=>{const f=bt[t];return jt(t),xt(!0),ns(),Nt(()=>{const x=b.current+1;return x>f?!1:(b.current=x,r.consumeAttempt(),!0)}),Ot(()=>E("freemium")),()=>{jt(null),xt(!1),Nt(null),Ot(null),ss()}},[t,r,E]),s.useEffect(()=>{let f=!1,x=null,N=0;const X=O=>{var W,J;if(!O||typeof O!="object")return;const U=O;return(J=U.status)!=null?J:(W=U.response)==null?void 0:W.status},w=async()=>{N+=1;try{await or(),f||l(!0)}catch(O){if(f)return;if(X(O)===429){g("rate_limit");return}if(N>=hr){g("unavailable");return}x=setTimeout(()=>{w()},1500)}};return w(),()=>{f=!0,x&&clearTimeout(x)}},[E]),s.useEffect(()=>{_(A.PUBLIC_PLAYGROUND_VIEWED,P.PublicPlayground,{feature:t})},[t]),s.useEffect(()=>{const f=x=>{const N=x.reason;(N instanceof en||rs(N))&&(x.preventDefault(),E("freemium"))};return window.addEventListener("unhandledrejection",f),()=>window.removeEventListener("unhandledrejection",f)},[E]),u?u==="rate_limit"?e.jsx(Ht,{title:"Too many requests",message:"Please wait a while, then try again."}):e.jsx(Ht,{}):!C||!i?e.jsx(Vt,{source:"PublicPlaygroundRootLayout",fullscreen:!0}):e.jsx(L,{component:"div",className:"PublicPlaygroundRootLayout","data-feature":t,sx:{dis
1play:"flex",flexDirection:"column",minHeight:"100vh",'& [aria-label="Account menu"], & .SidebarAccountTrigger':{display:"none"}},children:e.jsx(er,{children:e.jsx(Zs,{children:e.jsx(Bn.Provider,{value:Sr,children:e.jsx(Yn,{children:e.jsx(zn,{children:e.jsx(Kn,{children:e.jsx(qn,{children:e.jsx(Xn,{children:e.jsxs(Mn,{children:[e.jsx(s.Suspense,{fallback:e.jsx(Vt,{source:"PublicPlaygroundRootLayoutSuspense",fullscreen:!0}),children:n}),e.jsx(xr,{onClick:()=>E("freemium")}),e.jsx(ar,{onBlocked:()=>E("freemium")}),e.jsx(yr,{feature:t}),e.jsx(L,{component:"div","data-public-gate":"allow",children:e.jsx(ir,{open:d,reason:y,feature:t,attemptsAtConversion:r.attemptsUsed,dismissible:!0,onClose:()=>m(!1),heading:gr,subheading:fr})})]})})})})})})})})})})},br=({onAddPanel:t})=>{const n=s.useCallback(r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t())},[t]);return e.jsx(os,{title:"Click to add another model or router for comparison",placement:"left",children:e.jsxs(L,{component:"div",className:"AddPanelStrip",role:"button",tabIndex:0,"aria-label":"Add comparison panel",onClick:t,onKeyDown:n,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:.75,width:"2rem",flexShrink:0,alignSelf:"stretch",borderRadius:Me.md,border:"1px solid",borderColor:r=>ae(r.palette.primary.main,.25),backgroundColor:r=>ae(r.palette.primary.main,.06),color:r=>ae(r.palette.primary.main,.5),cursor:"pointer",transition:"background 0.15s, color 0.15s, border-color 0.15s","&:hover, &:focus-visible":{backgroundColor:r=>ae(r.palette.primary.main,.14),borderColor:"primary.main",color:"primary.main"}},children:[e.jsx(q,{icon:G.faPlus,style:{fontSize:ot.sm}}),e.jsx(oe,{variant:"caption",sx:{writingMode:"vertical-rl",textOrientation:"mixed",letterSpacing:"0.05em",userSelect:"none",color:"inherit"},children:"Add model or router"})]})})},Er=["Tell me something interesting about yourself","I need help with my recent order","Can you explain what a derivative is in simple terms?","Guide me through a 2-minute breathing meditation","Tell me a quick fairytale","What's the difference between REST and GraphQL?"],Cr=({onSelect:t})=>e.jsx(L,{component:"div",sx:{overflowX:"auto",flexShrink:0,background:"background.surface.light"},children:e.jsx(Ie,{direction:"row",sx:{px:"0.5rem",py:1,gap:.75,width:"max-content"},children:Er.map(n=>e.jsx(is,{label:n,onClick:()=>t(n),size:"small",sx:r=>({borderRadius:Me.full,fontSize:ot.sm,height:"1.75rem",cursor:"pointer",border:`1px solid ${r.palette.divider}`,backgroundColor:r.palette.background.surface.main,"&:hover":{backgroundColor:r.palette.action.hover}})},n))})});function Pr(t=re){return(n,r)=>{if(r.type===F.SET_PANEL_MODEL){const i=n.panels.find(u=>u.id===r.panelId),l=(i==null?void 0:i.type)===ge.MODEL?i.modelId:void 0;if(l&&l!==r.modelId)return t(),n}return Ts(n,r)}}const Tr={primaryRuntimeKey:{workspace:"",encodedKey:"public-playground",key:"",secret:""},isLoading:!1,error:null,listRuntimeApiKeys:async()=>null,generateRuntimeApiKey:async()=>null,generateIntegrateRuntimeApiKey:async()=>null,clearRuntimeApiKey:()=>{}},Rr=()=>{var me,ve,Be,tt,nt;const t=(me=Xe())!=null?me:qe,n=tn(),r=Et(),i=Pt(),{auth:l}=jn(),{hasNoCredits:u,creditsBalance:g,pricingTier:C,billingAccountId:h,isAddCreditsDialogOpen:d,openAddCreditsDialog:m,closeAddCreditsDialog:y,handlePurchaseCredits:I,isPurchaseLoading:b,autoReloadActive:E}=lt(),f=!0,[x,N]=s.useState(!1),[X,w]=s.useState(!1),[O,U]=s.useState(!1),W=s.useRef(null),J=it(le.STUDIO_V2_PLAYGROUNDS_HIGHLIGHT_INTEGRATE),D=(()=>{if(!J.enabled)return!1;try{const a=J.payload;if((a==null?void 0:a.type)==="json"&&a.value)return!!JSON.parse(a.value).router}catch(a){}return!1})(),Ee=u?e.jsx(ct,{icon:G.faCommentDots,message:"To continue using LLM playground, add credits or upgrade.",component:P.LLMPlayground,onBuyCredits:m,pricingTier:C,billingAccountId:h}):null,_e=(tt=(Be=(ve=l==null?void 0:l.currentUser)==null?void 0:ve.email)==null?void 0:Be.replaceAll("@","_"))!=null?tt:"test_user",{data:ce=[],isFetching:Ce,isError:Pe,refetch:je}=bs(t),Te=s.useMemo(()=>Pr(),[]),[c,S]=s.useReducer(Te,Rs),$=s.useMemo(()=>{const a=new Set(ce.map(o=>`${o.provider}/${o.model}`));return Es(Cs.PUBLIC_PLAYGROUND_DEFAULT).filter(o=>a.has(o))},[ce]),fe=!Ce&&(Pe||$.length===0),ee=s.useRef(!1);s.useEffect(()=>{!t||ee.current||$.length===0||(ee.current=!0,$.slice(0,2).forEach(a=>{S({type:F.ADD_MODEL_PANEL,modelId:a})}))},[$,t]);const he=s.useRef(!1);s.useEffect(()=>{if(he.current)return;const a=Math.min(2,$.length);if(!(a===0||c.panels.length<a)){he.current=!0;for(const o of c.panels)S({type:F.UPDATE_ENGINE_SETTINGS,panelId:o.id,engineSettings:{...o.engineSettings,reasoningEffort:{value:"EFFORT_NONE",enabled:!0}}})}},[$.length,c.panels]);const ue=s.useRef(!1),z=s.useRef(null);s.useEffect(()=>{var M,se;if(ue.current)return;const a=(M=n.state)==null?void 0:M.routerName,o=(se=n.state)==null?void 0:se.routerDisplayName;if(!a||c.panels.length===0)return;ue.current=!0,z.current=a;const p=o||a,T=c.panels.find(v=>v.type===ge.MODEL?!v.modelId:!v.routerName);T?S({type:F.SET_PANEL_ROUTER,panelId:T.id,routerName:a,routerDisplayName:p,conditionFields:{}}):c.panels.length<gt?S({type:F.ADD_ROUTER_PANEL,routerName:a,routerDisplayName:p,conditionFields:{}}):S({type:F.SET_PANEL_ROUTER,panelId:c.panels[c.panels.length-1].id,routerName:a,routerDisplayName:p,conditionFields:{}}),r(n.pathname,{replace:!0,state:{}})},[n.state,c.panels,S,r,n.pathname]);const ye=s.useRef(!1);s.useEffect(()=>{var p;if(ye.current)return;const a=(p=n.state)==null?void 0:p.modelId;if(!a||c.panels.length===0)return;ye.current=!0;const o=c.panels.find(T=>T.type===ge.MODEL?!T.modelId:!T.routerName);o?S({type:F.SET_PANEL_MODEL,panelId:o.id,modelId:a}):c.panels.length<gt?S({type:F.ADD_MODEL_PANEL,modelId:a}):S({type:F.SET_PANEL_MODEL,panelId:c.panels[c.panels.length-1].id,modelId:a}),r(n.pathname,{replace:!0,state:{}})},[n.state,c.panels,S,r,n.pathname]),s.useEffect(()=>{t&&(c.panels.some(a=>a.isLoading)||Is(t,c))},[t,c]),s.useEffect(()=>{const a=new WeakSet,o=new MutationObserver(()=>{document.querySelectorAll('[aria-label="Filter by provider"]').forEach(p=>{if(a.has(p))return;a.add(p);const T=p.querySelector('[data-filter-id="my-routers"]'),M=p.querySelector('[data-filter-id="all"]');T&&(T.style.display="none"),M==null||M.click()})});return o.observe(document.body,{childList:!0,subtree:!0}),()=>o.disconnect()},[]);const{data:H}=Ps({workspace:"",pageSize:100,pageToken:""}),B=s.useMemo(()=>{var a;return((a=H==null?void 0:H.routers)!=null?a:[]).map(o=>{var R,Y,Z,Ye,ze,Ke,Se,_t,At,Lt,vt,wt;const p=[],T=V=>
1{V==null||V.forEach(k=>{k.content&&p.push(k.content)})};T((R=o.defaults)==null?void 0:R.messageTemplates);const M=V=>{V==null||V.forEach(k=>{var be;return T((be=k.variant)==null?void 0:be.messageTemplates)})};(Y=o.routes)==null||Y.forEach(V=>{var k;return M((k=V.route)==null?void 0:k.variants)}),M((Z=o.defaultRoute)==null?void 0:Z.variants);const v=[...(ze=(Ye=o.defaultRoute)==null?void 0:Ye.variants)!=null?ze:[],...((Ke=o.routes)!=null?Ke:[]).flatMap(V=>{var k,be;return(be=(k=V.route)==null?void 0:k.variants)!=null?be:[]})].map(V=>{var k,be;return(be=(k=V.variant)==null?void 0:k.webSearch)==null?void 0:be.engine}).find(Boolean);return{name:(Se=o.name)!=null?Se:"",displayName:o.displayName||o.name||"",routes:o.routes,defaultRoute:o.defaultRoute,hasSystemPrompt:(At=(_t=o.defaults)==null?void 0:_t.messageTemplates)==null?void 0:At.some(V=>{var k;return((k=V.role)==null?void 0:k.toLowerCase())==="system"}),systemPromptContent:(wt=(vt=(Lt=o.defaults)==null?void 0:Lt.messageTemplates)==null?void 0:vt.find(V=>{var k;return((k=V.role)==null?void 0:k.toLowerCase())==="system"}))==null?void 0:wt.content,allTemplateContents:p,...v&&{webSearchEngine:v}}})},[H]);s.useEffect(()=>{if(!B.length&&!H)return;const a=new Set(B.map(o=>o.name));z.current&&a.has(z.current)&&(z.current=null),c.panels.forEach(o=>{if(o.type!==ge.ROUTER)return;const p=o.routerName;p&&p!==z.current&&(a.has(p)||S({type:F.SET_PANEL_MODEL,panelId:o.id,modelId:""}))})},[B,H,c.panels,S]);const xe=s.useMemo(()=>{const a=new Set,o=/\{\{(\w+)\}\}/g;for(const p of c.panels){let T;for(;(T=o.exec(p.systemPrompt))!==null;)a.add(T[1])}return Array.from(a).sort().join("\0")},[c.panels]),Q=s.useRef(c.variables);Q.current=c.variables,s.useEffect(()=>{if(!xe)return;const a=Q.current,o=xe.split("\0").filter(p=>!(p in a));o.length>0&&S({type:F.SET_VARIABLES,variables:{...a,...Object.fromEntries(o.map(p=>[p,""]))}})},[xe,S]);const K=s.useRef(new Map),de=s.useCallback((a,o)=>{K.current.set(a,o)},[]),Re=s.useCallback(a=>{K.current.delete(a)},[]),j=s.useRef(new Map),pe=s.useCallback((a,o)=>{j.current.set(a,o)},[]),Je=s.useCallback(a=>{j.current.delete(a)},[]),Ne=s.useCallback(a=>{Ft(a),S({type:F.CANCEL_PANEL_STREAMING,panelId:a});const o=j.current.get(a);o&&o()},[S]),Oe=s.useRef(0);s.useEffect(()=>{const a=o=>{if(o.key==="Escape"){const p=Date.now();if(p-Oe.current<1e3)return;let T=!1;for(const M of c.panels)if(M.isLoading){Ft(M.id),S({type:F.CANCEL_PANEL_STREAMING,panelId:M.id});const se=j.current.get(M.id);se&&se(),T=!0}T&&(Oe.current=p,o.preventDefault())}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[c.panels,S]);const ke=c.panels.some(a=>a.isLoading),Ue=s.useRef(!1);s.useEffect(()=>{if(ke){Ue.current=!0;return}Ue.current&&D&&!localStorage.getItem("llm-playground-showed-integrate")&&(Ue.current=!1,localStorage.setItem("llm-playground-showed-integrate","true"),w(!0),U(!0))},[ke,D]),s.useEffect(()=>(O&&(W.current=setTimeout(()=>{U(!1)},1e4)),()=>{W.current&&clearTimeout(W.current)}),[O]);const Ge=s.useCallback(()=>{U(!1),W.current&&clearTimeout(W.current)},[]),He=s.useCallback(a=>{var M,se;const o=c.panels.filter(v=>v.type===ge.MODEL?!!v.modelId:!!v.routerName);if(o.length===0)return;const p=o.filter(v=>v.type===ge.MODEL).length,T=o.filter(v=>v.type===ge.ROUTER).length;_(A.LLM_PLAYGROUND_SENT_MESSAGE,P.LLMPlayground,{text_length:a.length,previous_message_count:(se=(M=c.panels[0])==null?void 0:M.messages.length)!=null?se:0,model_count:p,router_count:T,has_system_prompt:c.panels.some(v=>v.systemPrompt.trim()!==""),has_prompt_variables:Object.keys(c.variables).length>0,has_web_search:c.panels.some(v=>v.engineSettings.webSearch.enabled),is_system_prompt_synced:c.systemPromptSyncSourceId!==null}),_(A.PUBLIC_PLAYGROUND_GENERATED,P.LLMPlayground,{feature:"llm",panel_count:o.length});for(const v of o){v.type===ge.ROUTER&&un(dn.ROUTER_TESTED);const R=K.current.get(v.id);R&&R(a)}},[c.panels,c.variables,c.systemPromptSyncSourceId]),Qe=s.useCallback((a,o)=>{S({type:F.REMOVE_LAST_EXCHANGE,panelId:a});const p=K.current.get(a);p&&p(o,{replaceLastExchange:!0})},[S]),Ve=s.useCallback(()=>{let a="";for(const o of c.panels){const p=o.messages[o.messages.length-1];if(!(p!=null&&p.wasCancelled))continue;const T=[...o.messages].reverse().find(M=>M.role===js.MESSAGE_ROLE_USER);if(T){a=T.content;break}}if(a)for(const o of c.panels){const p=o.messages[o.messages.length-1];if(!(p!=null&&p.wasCancelled))continue;S({type:F.REMOVE_LAST_EXCHANGE,panelId:o.id});const T=K.current.get(o.id);T&&T(a,{replaceLastExchange:!0})}},[c.panels,S]),te=s.useMemo(()=>({state:c,dispatch:S,sendMessageToAllPanels:He,cancelPanelRequest:Ne,retryLastMessage:Ve,editLastUserMessage:Qe,models:ce,workspace:t!=null?t:"",userName:_e}),[c,S,He,Ne,Ve,Qe,ce,t,_e]),Ae=s.useCallback(()=>{S({type:F.ADD_MODEL_PANEL})},[S]),Le=cs(us(hs,{activationConstraint:{distance:5}})),[Ze,Fe]=s.useState(null),ne=s.useCallback(a=>{Fe(String(a.active.id))},[]),et=s.useCallback(a=>{Fe(null);const{active:o,over:p}=a;p&&o.id!==p.id&&S({type:F.REORDER_PANELS,activeId:String(o.id),overId:String(p.id)})},[S]),We=s.useCallback(()=>{Fe(null)},[]),$e=Ze&&(nt=c.panels.find(a=>a.id===Ze))!=null?nt:null;return e.jsxs(_s.Provider,{value:te,children:[e.jsx(ut,{disablePadding:!0,customWrapperSX:{padding:"0",display:"flex",flexDirection:"column",height:`calc(100vh - ${nn} - ${an}
1)`},EnhancedPageHeaderProps:{title:"Router Playground",description:"Test your routers and models with prompts. Compare responses, latency, and cost.",sx:{"& > div":{flexDirection:"row"},"& .page-header-column:first-child":{justifyContent:"flex-start"},"& .page-header-column:last-child":{justifyContent:"flex-end"},"& .MuiButton-root":{"&:focus-visible":{...St(i)}}},primaryAction:e.jsxs(Ie,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(ie,{intent:"secondary","aria-label":"Explore Models",component:sn,to:`/workspaces/${t}/models`,state:{from:"playground"},startIcon:e.jsx(q,{icon:G.faCube}),sx:{display:{xs:"none",sm:"flex"}},children:"Explore Models"}),e.jsx(ie,{intent:"secondary","aria-label":"Integrate",startIcon:e.jsx(q,{icon:G.faCode}),onClick:()=>{w(!1),N(!0),_(A.LLM_PLAYGROUND_CLICKED_INTEGRATE,P.LLMPlayground,{source:"header_button"})},sx:{display:{xs:"none",sm:"flex"}},children:"Integrate"}),e.jsx(ie,{"aria-label":"Create Router",startIcon:e.jsx(q,{icon:G.faPlus}),onClick:()=>{re()},sx:X?{"@keyframes integratePulse":{"0%, 100%":{transform:"scale(1)",boxShadow:"none"},"50%":{transform:"scale(1.05)",boxShadow:`0 0 12px ${ae(Ct.violet,.5)}`}},animation:"integratePulse 1.5s ease-in-out 0s 3"}:void 0,children:"Create Router"})]})},children:e.jsxs(L,{component:"div",className:"router-playground-container",sx:a=>({position:"relative",display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:a.palette.background.default}),children:[e.jsx(Nn.Provider,{value:Tr,children:e.jsxs(ds,{sensors:Le,collisionDetection:ps,onDragStart:ne,onDragEnd:et,onDragCancel:We,modifiers:[Ss],children:[e.jsx(ms,{items:c.panels.map(a=>a.id),strategy:gs,children:e.jsxs(As,{children:[c.panels.length===0&&Ce&&e.jsxs(Ie,{className:"PublicLLMModelsLoading",spacing:1.5,sx:{flex:1,alignItems:"center",alignSelf:"center"},children:[e.jsx(ln,{size:24}),e.jsx(oe,{color:"text.secondary",children:"Loading available models…"})]}),c.panels.length===0&&fe&&e.jsxs(Ie,{className:"PublicLLMModelsUnavailable",spacing:1.5,sx:{flex:1,alignItems:"center",alignSelf:"center"},children:[e.jsx(oe,{color:"text.secondary",children:"Models are unavailable right now."}),e.jsx(ie,{intent:"secondary","aria-label":"Retry loading models",onClick:()=>void je(),children:"Try again"})]}),c.panels.map(a=>e.jsx(Ir,{panel:a,routers:B,registerPanelChat:de,unregisterPanelChat:Re,registerPanelCancel:pe,unregisterPanelCancel:Je,hasPaidAccess:f,onBuyCreditsClick:m},a.id)),$.length>0&&c.panels.length<gt&&e.jsx(br,{onAddPanel:Ae})]})}),e.jsx(fs,{dropAnimation:{duration:150,easing:"ease"},children:$e?e.jsx(Lr,{panel:$e}):null})]})}),c.panels.length>0&&c.panels.every(a=>a.messages.length===0&&!a.isLoading)&&e.jsx(Cr,{onSelect:a=>{_(A.LLM_PLAYGROUND_CLICKED_STARTER_CHIP,P.LLMPlayground,{chip_text:a}),He(a)}}),X&&e.jsx(L,{component:"div",sx:{px:2,py:.5},children:e.jsx(Tt,{in:O,timeout:400,unmountOnExit:!0,children:e.jsxs(L,{component:"div",sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",py:.5,px:2,backdropFilter:"blur(8px)",backgroundColor:a=>a.palette.action.hover,borderRadius:Me.md},children:[e.jsxs(oe,{variant:"body2",sx:{color:"text.secondary",flex:1,textAlign:"center"},children:["Ready to start building?"," ",e.jsx(On,{"aria-label":"Create Router",component:"button",type:"button",color:"primary",onClick:()=>{Ge(),_(A.LLM_PLAYGROUND_CLICKED_INTEGRATE,P.LLMPlayground,{source:"cta_banner"}),re()},sx:{fontSize:ot.md,fontWeight:600,textDecoration:"none",background:"none",border:"none",padding:0,cursor:"pointer","&:hover":{textDecoration:"underline"}},children:"Create a router"})," ","to route to the best model for each request."]}),e.jsx(Rt,{"aria-label":"Dismiss",size:"small",onClick:Ge,sx:{ml:.5,p:.25,color:"text.secondary","&:hover":{color:"text.primary"}},children:e.jsx(q,{icon:G.faXmark,size:"xs"})})]})})}),e.jsx(Ls,{}),Ee]})}),e.jsx(vs,{open:x,onClose:()=>N(!1),workspace:t}),e.jsx(dt,{open:d,onClose:y,onPurchase:I,currentBalance:g,isLoading:b,autoReloadActive:E})]})},Ir=({panel:t,routers:n,registerPanelChat:r,unregisterPanelChat:i,registerPanelCancel:l,unregisterPanelCancel:u,hasPaidAccess:g,onBuyCreditsClick:C})=>{const{attributes:h,listeners:d,setNodeRef:m,transform:y,transition:I,isDragging:b}=ys({id:t.id}),E=cn(`(max-width: ${Wt})`),f={transform:xs.Transform.toString(y),transition:I,position:"relative",flex:E?"1 0 100%":`1 0 ${$t}`,minWidth:E?"100%":$t,display:"flex",flexDirection:"column",height:"100%"};if(b)return e.jsx("div",{ref:m,style:{...f,opacity:0,pointerEvents:"none"}});const x=t.type===ge.MODEL?e.jsx(_r,{panel:t,routers:n,registerPanelChat:r,unregisterPanelChat:i,registerPanelCancel:l,unregisterPanelCancel:u,hasPaidAccess:g,onBuyCreditsClick:C}):e.jsx(Ar,{panel:t,routers:n,registerPanelChat:r,unregisterPanelChat:i,registerPanelCancel:l,unregisterPanelCancel:u,hasPaidAccess:g,onBuyCreditsClick:C});return e.jsxs(L,{component:"div",ref:m,"data-panel-id":t.id,style:f,sx:{"&:has(.drag-handle-overlay:hover) .drag-handle-icon":{color:"text.primary"},[`@media (max-width: ${Wt})`]:{"& .drag-handle-overlay":{display:"none"},"&:first-of-type .router-panel":{borderLeft:"none"},"&:last-of-type .router-panel":{borderRight:"none"}}},children:[e.jsx(L,{component:"div",className:"drag-handle-overlay",...d,...h,"aria-label":"Drag to reorder panel",sx:{position:"absolute",top:0,left:0,width:"2.25rem",height:"3.5rem",zIndex:10,cursor:"grab",touchAction:"none",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:Me.sm,"&:active":{cursor:"grabbing"}}}),x]})},_r=at.memo(function({panel:n,routers:r,registerPanelChat:i,unregisterPanelChat:l,registerPanelCancel:u,unregisterPanelCancel:g,hasPaidAccess:C,onBuyCreditsClick:h}){const{sendPanelMessage:d,cancelRequest:m}=Ds(n),y=s.useCallback((I,b)=>{if(!gn("llm")){re();return}d(I,b)},[d]);return at.useEffect(()=>(i(n.id,y),u(n.id,m),()=>{l(n.id),g(n.id)}),[n.id,y,m,i,l,u,g]),e.jsx(pn,{panel:n,routers:r,onBuyCreditsClick:h,hasPaidAccess:C})}),Ar=at.memo(function({panel:n,routers:r,registerPanelChat:i,unregisterPanelChat:l,registerPanelCancel:u,unregisterPanelCancel:g,onBuyCreditsClick:C,hasPaidAccess:h}){const{sendRouterMessage:d,cancelRequest:m}=Ms(n,r),y=s.useCallback((I,b)=>{if(!gn("llm")){re();return}d(I,b)},[d]);return at.useEffect(()=>(i(n.id,y),u(n.id,m),()=>{l(n.id),g(n.id)}),[n.id,y,m,i,l,u,g]),e.jsx(pn,{panel:n,routers:r,onBuyCreditsClick:C,hasPaidAccess:h})}),Lr=({panel:t})=>
1e.jsx(L,{component:"div",sx:{display:"flex",flexDirection:"column",height:"100%",borderRadius:Me.sm,border:"1px solid",borderColor:"primary.main",overflow:"hidden",opacity:.9,boxShadow:we.lg,cursor:"grabbing"},children:e.jsx(ws,{panel:t})}),zt={semantic_vad:"Semantic VAD",server_vad:"Server VAD"};function Kt(){if(typeof window=="undefined")return 0;const t=window.localStorage.getItem(rn),n=t?Number.parseInt(t,10):0;return Number.isFinite(n)&&n>=0?n:0}function vr(t){typeof window!="undefined"&&window.localStorage.setItem(rn,String(t))}function wr(t,n){var i,l;const r=[];if(t.systemPrompt!==n.systemPrompt&&r.push("System prompt"),t.llmModel!==n.llmModel&&r.push(`Model: ${t.llmModel} → ${n.llmModel}`),t.ttsModel!==n.ttsModel&&r.push(`TTS model: ${t.ttsModel} → ${n.ttsModel}`),t.voice!==n.voice&&r.push(`Voice: ${t.voice} → ${n.voice}`),t.eagerness!==n.eagerness&&r.push(`Eagerness: ${t.eagerness} → ${n.eagerness}`),t.turnDetectionType!==n.turnDetectionType){const u=(i=zt[t.turnDetectionType])!=null?i:t.turnDetectionType,g=(l=zt[n.turnDetectionType])!=null?l:n.turnDetectionType;r.push(`Turn detection: ${u} → ${g}`)}if(t.transcriptionModel!==n.transcriptionModel&&r.push(`Transcription model: ${t.transcriptionModel} → ${n.transcriptionModel}`),JSON.stringify(t.outputModalities)!==JSON.stringify(n.outputModalities)){const u=t.outputModalities.join(", ")||"none",g=n.outputModalities.join(", ")||"none";r.push(`Output modalities: ${u} → ${g}`)}if(JSON.stringify(t.tools)!==JSON.stringify(n.tools)){const u=n.tools.length;r.push(`Tools updated (${u} tool${u!==1?"s":""})`)}return t.webSearchEnabled!==n.webSearchEnabled?r.push(`Web search: ${n.webSearchEnabled?"enabled":"disabled"}`):n.webSearchEnabled&&(t.webSearchEngine!==n.webSearchEngine&&r.push(`Web search engine: ${t.webSearchEngine} → ${n.webSearchEngine}`),t.searchContextSize!==n.searchContextSize&&r.push(`Search context: ${t.searchContextSize} → ${n.searchContextSize}`),t.webSearchMaxResults!==n.webSearchMaxResults&&r.push(`Max results: ${t.webSearchMaxResults} → ${n.webSearchMaxResults}`),t.webSearchMaxSteps!==n.webSearchMaxSteps&&r.push(`Max steps: ${t.webSearchMaxSteps} → ${n.webSearchMaxSteps}`)),r.length===0?"Session configuration updated":`Settings updated — ${r.join(", ")}`}const qt=ls(L)({display:"flex",padding:"1rem",flexDirection:"column",height:"100%",overflowY:"auto",overflowX:"visible"}),Xt=320,Jt=320,Dr=()=>e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",padding:"1.5rem"},children:e.jsx(oe,{color:"error",children:"Something went wrong in the conversation panel. Please reset and try again."})}),Mr=()=>{var M,se,v;const t=(M=Xe())!=null?M:qe,n=De(le.STUDIO_V2_REALTIME_LLM_TOOLS),r=De(le.STUDIO_V2_REALTIME_VOICE_PROFILE),i=De(le.STUDIO_V2_REALTIME_WEB_SEARCH),l=cn(R=>R.breakpoints.up("md")),u=Pt(),g=kn(),{reportError:C,hint:h}=Ws({permission:"microphone",useCase:"realtime",surface:"public",onShown:R=>{_(A.PERMISSION_HINT_SHOWN,P.RealtimePlayground,{use_case:"realtime",surface:"public",...R})}}),{primaryRuntimeKey:d,isLoading:m}=Ys(),{hasNoCredits:y,creditsBalance:I,pricingTier:b,billingAccountId:E,isAddCreditsDialogOpen:f,openAddCreditsDialog:x,closeAddCreditsDialog:N,handlePurchaseCredits:X,isPurchaseLoading:w,autoReloadActive:O}=lt(),U=s.useCallback(()=>re(),[]),W=s.useCallback(()=>re(),[]),J=y&&e.jsx(ct,{icon:G.faWaveform,message:"To continue using Realtime playground, add credits or upgrade.",component:P.RealtimePlayground,onBuyCredits:x,pricingTier:b,billingAccountId:E}),D=s.useRef(null),Ee=$s(D),[_e,ce]=s.useState(!1),[Ce,Pe]=s.useState("config"),[je,Te]=s.useState(!1),[c,S]=s.useState(!1),[$,fe]=s.useState(!1),ee=s.useRef(null),he=s.useRef(!1),ue=De(le.STUDIO_V2_PLAYGROUNDS_HIGHLIGHT_INTEGRATE),z=it(le.STUDIO_V2_PLAYGROUNDS_HIGHLIGHT_INTEGRATE),ye=s.useMemo(()=>{var R,Y;if(!ue||!z.enabled)return!1;try{return!!JSON.parse((Y=(R=z.payload)==null?void 0:R.value)!=null?Y:"{}").realtime}catch(Z){return!1}},[ue,z.enabled,(se=z.payload)==null?void 0:se.value]),H=Jn({defaultValues:{...Ns,llmModel:"groq/openai/gpt-oss-120b",voice:"Sarah"}}),{status:B,transcript:xe,error:Q,isAgentSpeaking:K,isPaused:de,transcriptLimitReached:Re,connect:j,disconnect:pe,resetToIdle:Je,pauseSession:Ne,resumeSession:Oe,updateSession:ke,sendTextMessage:Ue,clearTranscript:Ge,getAgentAnalyser:He}=Os({apiKey:(v=d==null?void 0:d.encodedKey)!=null?v:"proxy",authScheme:"bearer",includeLlmTools:n,enableVoiceProfile:r,enableWebSearch:i}),{isCapturing:Qe,startCapture:Ve,stopCapture:te,pauseCapture:Ae,resumeCapture:Le,getAnalyser:Ze}=ks(),Fe=B===st.CONNECTING||m,ne=B===st.CONNECTED,et=Fe||ne;s.useEffect(()=>{ne&&Le()},[ne,Le]),s.useEffect(()=>{y&&ne&&(te(),pe(),mt("You have run out of credits. The session has been disconnected.",{id:"realtime-no-credits-disconnect"}))},[y,ne,te,pe]),s.useEffect(()=>{B===st.ERROR&&te()},[B,te]),s.useEffect(()=>{if(!ne)return;const R=setInterval(()=>{const Y=Kt()+1;vr(Y),Y>=kt&&(te(),pe(),re())},1e3);return()=>clearInterval(R)},[ne,te,pe]),s.useEffect(()=>
1{Q&&(as(Q)||(g.invalidateQueries("billingInfo"),_(A.REALTIME_PLAYGROUND_CONNECTION_ERROR,P.RealtimePlayground,{error:Q||"Unknown error"}),mt(Q,{id:"realtime-playground-error-toast",maxWidth:"50rem"})))},[Q,g]),s.useEffect(()=>{Re&&mt("Transcript limit of 100 messages reached. Please reset and start a new session.",{id:"realtime-transcript-limit",duration:8e3})},[Re]),s.useEffect(()=>{if(K){he.current=!0;return}he.current&&ye&&!localStorage.getItem("realtime-playground-showed-integrate")&&(he.current=!1,localStorage.setItem("realtime-playground-showed-integrate","true"),S(!0),fe(!0))},[K,ye]);const We=s.useRef(!1);s.useEffect(()=>{K&&!We.current&&(We.current=!0,_(A.PUBLIC_PLAYGROUND_GENERATED,P.RealtimePlayground,{feature:"realtime"})),ne||(We.current=!1)},[K,ne]),s.useEffect(()=>($&&(ee.current=setTimeout(()=>{fe(!1)},1e4)),()=>{ee.current&&clearTimeout(ee.current)}),[$]);const $e=s.useCallback(()=>{fe(!1),ee.current&&clearTimeout(ee.current)},[]),[me,ve]=s.useState(null),Be=Qn({control:H.control}),tt=s.useMemo(()=>me?JSON.stringify(Be)!==me:!1,[me,Be]),nt=s.useCallback(async()=>{var ze,Ke;if(et)return;const R=on();if(R&&!R.realtime){re();return}if(Kt()>=kt){re();return}try{Un()}catch(Se){if(Se instanceof en)return;throw Se}const Y=void 0,Z=H.getValues();_(A.REALTIME_PLAYGROUND_START_SESSION,P.RealtimePlayground,{llm_model:Z.llmModel,tts_model:Z.ttsModel,voice:Z.voice,stt_eagerness:Z.eagerness,system_prompt:Z.systemPrompt,tools_count:(Ke=(ze=Z.tools)==null?void 0:ze.length)!=null?Ke:0}),ve(JSON.stringify(Z));let Ye;try{Ye=await Ve(),Ae()}catch(Se){C(Se)||console.error("[Realtime] Mic capture failed",Se)}await j(Z,Ye,Y),un(dn.REALTIME_TESTED),l||Pe("chat")},[et,H,j,Ve,Ae,l,C]),a=s.useCallback(()=>{de?(_(A.REALTIME_PLAYGROUND_RESUME,P.RealtimePlayground),Le(),Oe()):(_(A.REALTIME_PLAYGROUND_PAUSE,P.RealtimePlayground),Ae(),Ne())},[de,Ae,Le,Ne,Oe]),o=s.useCallback(()=>{const R=H.getValues();_(A.REALTIME_PLAYGROUND_UPDATE_SESSION,P.RealtimePlayground,{llm_model:R.llmModel,tts_model:R.ttsModel,voice:R.voice,stt_eagerness:R.eagerness});const Y=me?wr(JSON.parse(me),R):"Session configuration updated";ke(R,Y),ve(JSON.stringify(R))},[H,me,ke]),p=s.useCallback(()=>{_(A.REALTIME_PLAYGROUND_RESET,P.RealtimePlayground),te(),Je(),ve(null),Ge(),S(!1),l||Pe("config")},[te,Je,Ge,l]);s.useEffect(()=>()=>{te(),pe()},[te,pe]);const T=e.jsx(Us,{fallback:e.jsx(Dr,{}),children:e.jsx(Gs,{transcript:xe,connectionStatus:B,isConnecting:B===st.CONNECTING,isPaused:de,isCapturing:Qe&&!de,isAgentSpeaking:K,getAnalyser:He,getMicAnalyser:Ze,error:Q,onSendTextMessage:Ue,onUpdateSession:ne?o:void 0,hasUnsyncedChanges:tt,onTestAgent:nt,onReset:p,onPauseResume:a})});return e.jsxs(ut,{disablePadding:!0,customWrapperSX:{display:"flex",flexDirection:"column",height:`calc(100vh - ${nn} - ${an})`},EnhancedPageHeaderProps:{title:"Realtime Playground",description:"Have a live voice-to-voice conversation. Configure the model, voice, and session settings.",sx:{"& > div":{flexDirection:"row"},"& .page-header-column:first-child":{justifyContent:"flex-start"},"& .page-header-column:last-child":{justifyContent:"flex-end"},"& h1":{whiteSpace:"normal",overflow:"visible",textOverflow:"unset",textAlign:"left"},"& .MuiIconButton-root":{border:"1px solid",borderColor:"divider",height:"2.5rem",width:"2.5rem",[Vn]:Gn.md,"&:focus-visible":{...St(u)}},"& .MuiButton-root":{"&:focus-visible":{...St(u)}}},primaryAction:e.jsx(ie,{"aria-label":"Integrate",startIcon:e.jsx(q,{icon:G.faCode}),sx:{whiteSpace:"nowrap",display:{xs:"none",sm:"flex"},...c&&{"@keyframes integratePulse":{"0%, 100%":{transform:"scale(1)",boxShadow:"none"},"50%":{transform:"scale(1.05)",boxShadow:`0 0 12px ${ae(Ct.violet,.5)}`}},animation:"integratePulse 1.5s ease-in-out 3"}},onClick:()=>{S(!1),Te(!0),_(A.REALTIME_PLAYGROUND_CLICKED_INTEGRATE,P.RealtimePlayground,{source:"header_button"})},children:c?"Integrate Now!":"Integrate"})},children:[e.jsxs(Zn,{...H,children:[e.jsx(jr,{}),e.jsx(Hs,{open:je,onClose:()=>Te(!1),includeLlmTools:n,enableVoiceProfile:r,enableWebSearch:i,workspace:t}),e.jsx(dt,{open:f,onClose:N,onPurchase:X,currentBalance:I,isLoading:w,autoReloadActive:O}),e.jsx(Tt,{in:$,timeout:400,unmountOnExit:!0,children:e.jsxs(L,{component:"div",sx:{dis
1play:"flex",justifyContent:"center",alignItems:"center",width:"100%",py:.5,px:2,backdropFilter:"blur(8px)",backgroundColor:R=>R.palette.action.hover},children:[e.jsxs(oe,{variant:"body2",sx:{color:"text.secondary",flex:1,textAlign:"center"},children:["Ready to start building? Click on"," ",e.jsx(oe,{"aria-label":"Open Integrate dialog",component:"span",variant:"body2",color:"primary",onClick:()=>{Te(!0),$e(),_(A.REALTIME_PLAYGROUND_CLICKED_INTEGRATE,P.RealtimePlayground,{source:"cta_banner"})},sx:{cursor:"pointer",fontWeight:600},children:"Integrate"})," ","for ready-to-use prompts and code."]}),e.jsx(Rt,{"aria-label":"Dismiss",size:"small",onClick:$e,sx:{ml:.5,p:.25,color:"text.secondary","&:hover":{color:"text.primary"}},children:e.jsx(q,{icon:G.faXmark,size:"xs"})})]})}),e.jsx(L,{component:"div",ref:D,sx:{display:"flex",flex:1,position:"relative",overflow:"hidden"},children:l?e.jsxs(e.Fragment,{children:[e.jsxs(L,{component:"div",sx:{display:"flex",flexDirection:"column",flex:1,minWidth:Xt,height:"100%",borderRight:"1px solid",borderColor:"divider",overflow:"hidden",position:"relative"},children:[J,!y&&T]}),e.jsx(Bs,{className:"resizable",defaultSize:{width:384,height:"100%"},minWidth:Jt,maxWidth:Math.max(Ee-Xt,Jt),enable:{left:!0},handleComponent:{left:e.jsx(Vs,{className:_e?"dragging":""})},onResizeStart:()=>ce(!0),onResizeStop:()=>ce(!1),style:{width:384},children:e.jsx(qt,{sx:{width:"100%",padding:0},children:e.jsx(Bt,{workspace:t,showWebSearch:i,onWebSearchGated:U,onToolsGated:W})})})]}):e.jsxs(L,{component:"div",sx:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden"},children:[e.jsx(L,{component:"div",sx:{flexShrink:0,display:"flex",justifyContent:"center",px:1.5,py:.75,borderBottom:"1px solid",borderColor:"divider"},children:e.jsxs(Hn,{value:Ce,fullWidth:!0,exclusive:!0,onChange:(R,Y)=>Y&&Pe(Y),"aria-label":"Toggle between chat and config",sx:{height:"2.5rem","& .MuiToggleButton-root":{fontSize:ot.md,fontWeight:500,lineHeight:1.3,textTransform:"none",gap:"0.5rem",px:2}},children:[e.jsxs(Ut,{value:"config","aria-label":"Config",children:[e.jsx(q,{icon:G.faSlidersH}),"Config"]}),e.jsxs(Ut,{value:"chat","aria-label":"Chat",children:[e.jsx(q,{icon:G.faCommentDots}),"Chat"]})]})}),e.jsx(L,{component:"div",sx:{flex:1,overflow:"hidden",minHeight:0},children:Ce==="config"?e.jsx(qt,{sx:{width:"100%",paddingLeft:0,paddingRight:0},children:e.jsx(Bt,{workspace:t,showWebSearch:i,onWebSearchGated:U,onToolsGated:W})}):e.jsxs(L,{component:"div",sx:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:[J,!y&&T]})})]})})]}),h]})},jr=()=>(Fs(),null),Nr=12e3,Or=()=>{var J;const t=(J=Xe())!=null?J:qe,[n,r]=s.useState(!1),i=s.useCallback(()=>r(!1),[]),[l,u]=s.useState(!1),{hasNoCredits:g,creditsBalance:C,pricingTier:h,billingAccountId:d,isAddCreditsDialogOpen:m,openAddCreditsDialog:y,closeAddCreditsDialog:I,handlePurchaseCredits:b,isPurchaseLoading:E,autoReloadActive:f}=lt(),x=it(le.STUDIO_V2_PLAYGROUNDS_HIGHLIGHT_INTEGRATE),N=s.useMemo(()=>{var D;if(!x.enabled||!((D=x.payload)!=null&&D.value))return!1;try{return(typeof x.payload.value=="string"?JSON.parse(x.payload.value):x.payload.value).stt===!0}catch(Ee){return!1}},[x]),X=g?e.jsx(ct,{icon:G.faMicrophone,message:"To continue using STT playground, add credits or upgrade.",component:P.STTPlayground,onBuyCredits:y,pricingTier:h,billingAccountId:d}):null,w=s.useRef(void 0);s.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),s.useEffect(()=>{N||(w.current&&clearTimeout(w.current),u(!1))},[N]),s.useEffect(()=>{const D=on();D&&!D.stt&&re()},[]);const O=s.useCallback(()=>{_(A.PUBLIC_PLAYGROUND_GENERATED,P.STTPlayground,{feature:"stt"}),N&&(w.current&&clearTimeout(w.current),u(!0),w.current=setTimeout(()=>{u(!1)},Nr))},[N]),U=s.useCallback(()=>{w.current&&clearTimeout(w.current),u(!1),_(A.STT_PLAYGROUND_CLICKED_GET_CODE,P.STTPlayground),re()},[]),W=s.useCallback(()=>{},[]);return e.jsx(e.Fragment,{children:e.jsxs(ut,{EnhancedPageHeaderProps:{title:"STT Playground",description:"Record live or upload audio to transcribe across providers and models.",noColumnStack:!0,primaryAction:e.jsxs(L,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx(ie,{intent:"secondary","aria-label":"Configure STT",startIcon:e.jsx(q,{icon:G.faSliders}),onClick:()=>r(!0),sx:{display:{xs:"flex",md:"none"},whiteSpace:"nowrap"},children:"Config"}),e.jsx(ie,{"aria-label":"Integrate",startIcon:e.jsx(q,{icon:G.faCode}),onClick:U,sx:D=>({display:{xs:"none",sm:"flex"},...l&&{backgroundColor:"primary.dark",boxShadow:`${we.lg}, 0 0 0 4px ${ae(D.palette.primary.main,.22)}`,transform:"translateY(-1px)",animation:"sttIntegratePulse 1.55s ease-in-out infinite","&:hover":{backgroundColor:"primary.dark",boxShadow:`${we.lg}, 0 0 0 5px ${ae(D.palette.primary.main,.24)}`},"@keyframes sttIntegratePulse":{"0%":{transform:"translateY(0) scale(1)",boxShadow:`${we.md}, 0 0 0 0 ${ae(D.palette.primary.main,.34)}`},"55%":{transform:"translateY(-1px) scale(1.035)",boxShadow:`${we.lg}, 0 0 0 8px ${ae(D.palette.primary.main,.08)}`},"100%":{transform:"translateY(0) scale(1)",boxShadow:`${we.md}, 0 0 0 0 ${ae(D.palette.primary.main,0)}`}}}}),children:l?"Integrate This":"Integrate"})]})},disablePadding:!0,sx:{"& .page-content":{overflowY:"hidden"}},children:[e.jsx(zs,{mobileConfigOpen:n,onMobileConfigClose:i,workspace:t,onGetCodeClick:U,on
1HighlightIntegrateCta:O,integrateCtaHighlighted:l,getCodeOpen:!1,onGetCodeClose:W,noCreditsOverlay:X,isModelDisabledOverride:D=>!D.id.toLowerCase().startsWith(Gt),getDisabledTooltip:D=>D.id.toLowerCase().startsWith(Gt)?void 0:"Sign up to use this provider",surface:"public"}),e.jsx(dt,{open:m,onClose:I,onPurchase:b,currentBalance:C,isLoading:E,autoReloadActive:f})]})})},kr=()=>{var de,Re;const t=qs(),n=(de=Xe())!=null?de:qe,r=tn(),{setSelectedVoiceId:i,isGenerating:l,isStreamingInProgress:u,isPlaying:g}=Xs(),[C,h]=s.useState(!1),[d,m]=s.useState(!1),[y,I]=s.useState(!1),[b,E]=s.useState(!1),f=s.useRef(null),x=Pt(),N=De(le.STUDIO_V2_SHOW_GETTING_STARTED_TTS_PAGE),X=De(le.STUDIO_V2_TTS_PLAYGROUND_TRY_API_AS_PRIMARY_ACTION),w=it(le.STUDIO_V2_PLAYGROUNDS_HIGHLIGHT_INTEGRATE),O=(()=>{if(!w.enabled)return!1;try{const j=w.payload;if((j==null?void 0:j.type)==="json"&&j.value)return!!JSON.parse(j.value).tts}catch(j){}return!1})(),{isEnabled:U}=es(),{hasNoCredits:W,creditsBalance:J,pricingTier:D,billingAccountId:Ee,isAddCreditsDialogOpen:_e,openAddCreditsDialog:ce,closeAddCreditsDialog:Ce,handlePurchaseCredits:Pe,isPurchaseLoading:je,autoReloadActive:Te}=lt(),c=W?e.jsx(ct,{icon:G.faMicrophone,message:"To continue using TTS playground, add credits or upgrade.",component:P.TTSSPlayground,onBuyCredits:ce,pricingTier:D,billingAccountId:Ee}):null,S=s.useCallback(({intent:j})=>e.jsx(ie,{"aria-label":"Create Voice",startIcon:e.jsx(q,{icon:G.faPlus}),intent:j,component:sn,to:`/workspaces/${n}/tts-playground/create-voice`,onClick:()=>{_(A.CLICKED_TTS_CLONE_VOICE,P.TTSSPlayground)},children:"Create Voice"}),[n]),$=s.useCallback(({intent:j})=>e.jsx(ie,{"aria-label":"Integrate",startIcon:e.jsx(q,{icon:G.faCode}),intent:j,onClick:()=>{I(!1),m(!0),_(A.CLICKED_TTS_TRY_API,P.TTSSPlayground,{source:"header_button"})},sx:y?{"@keyframes integratePulse":{"0%, 100%":{transform:"scale(1)",boxShadow:"none"},"50%":{transform:"scale(1.05)",boxShadow:`0 0 12px ${ae(Ct.violet,.5)}`}},animation:"integratePulse 1.5s ease-in-out 3"}:void 0,children:y?"Integrate Now!":"Integrate"}),[y]),fe=N,ee=U,he=fe&&(X||!ee);let ue=null,z=null;he?(ue=e.jsx($,{intent:"primary"}),ee&&(z=e.jsx(S,{intent:"secondary"}))):ee&&(ue=e.jsx(S,{intent:"primary"}),fe&&(z=e.jsx($,{intent:"secondary"})));const ye=l||u||g,H=s.useRef(!1);s.useEffect(()=>{if(ye){H.current=!0;return}H.current&&O&&!localStorage.getItem("tts-playground-showed-integrate")&&(H.current=!1,localStorage.setItem("tts-playground-showed-integrate","true"),I(!0),E(!0))},[ye,O]);const B=s.useRef(!1);s.useEffect(()=>{if(l){B.current=!0;return}B.current&&(B.current=!1,_(A.PUBLIC_PLAYGROUND_GENERATED,P.TTSSPlayground,{feature:"tts"}))},[l]),s.useEffect(()=>(b&&(f.current=setTimeout(()=>{E(!1)},1e4)),()=>{f.current&&clearTimeout(f.current)}),[b]);const xe=s.useCallback(()=>{E(!1),f.current&&clearTimeout(f.current)},[]),Q=((Re=r==null?void 0:r.state)==null?void 0:Re.selectedVoiceId)||"",K=Et();return s.useEffect(()=>{Q&&(i(Q),K(r.pathname,{replace:!0,state:{}}))},[i,Q,K,r.pathname]),e.jsxs(ut,{sx:{"& .page-content":{overflowY:"hidden"}},EnhancedPageHeaderProps:{sx:{"& .page-header-column:first-child":{width:"unset",minWidth:"max-content"},"& .MuiTypography-body2":{whiteSpace:"nowrap"},[x.breakpoints.only("sm")]:{"& > div":{flexDirection:"row"},"& .page-header-column:last-child":{justifyContent:"flex-end"}},[x.breakpoints.only("xs")]:{"& > div":{flexDirection:"row","& .page-header-column:first-child":{justifyContent:"flex-start"},"& .page-header-column:last-child":{justifyContent:"flex-end"}}}},title:"TTS Playground",description:"Test text-to-speech with different voices, models, and settings.",primaryAction:e.jsxs(Ie,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(ie,{intent:"secondary","aria-label":"Voices & Settings",onClick:()=>h(!C),sx:{whiteSpace:"nowrap",display:["flex","flex","none"],"& svg":{marginRight:"0.5rem",marginLeft:"-0.25rem"}},children:"Voices & Settings"}),e.jsx(L,{component:"div",sx:{display:["none","none","flex"]},children:z}),e.jsx(L,{component:"div",sx:{display:["none","none","flex"]},children:ue}
1),e.jsx(L,{component:"div",sx:{display:["none","flex","none"]},children:e.jsx($,{intent:"primary"})})]})},disablePadding:!0,children:[e.jsx(Fn,{location:`/try/tts/${n}`,children:e.jsx(Wn,{path:":workspace",element:e.jsx(Qs,{mobileVoicesPanelOpen:C,setMobileVoicesPanelOpen:h,noCreditsOverlay:c,maxTextLength:t,disableHighlightWords:!0,integrateCta:y?e.jsx(Tt,{in:b,timeout:400,unmountOnExit:!0,children:e.jsxs(L,{component:"div",sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",py:.5,px:2,backdropFilter:"blur(8px)",backgroundColor:j=>j.palette.action.hover,borderRadius:Me.md},children:[e.jsxs(oe,{variant:"body2",sx:{color:"text.secondary",flex:1,textAlign:"center"},children:["Ready to start building? Click on"," ",e.jsx(oe,{"aria-label":"Open Integrate dialog",component:"span",variant:"body2",color:"primary",onClick:()=>{m(!0),xe(),_(A.CLICKED_TTS_TRY_API,P.TTSSPlayground,{source:"cta_banner"})},sx:{cursor:"pointer",fontWeight:600},children:"Integrate"})," ","for ready-to-use prompts and code."]}),e.jsx(Rt,{"aria-label":"Dismiss",size:"small",onClick:xe,sx:{ml:.5,p:.25,color:"text.secondary","&:hover":{color:"text.primary"}},children:e.jsx(q,{icon:G.faXmark,size:"xs"})})]})}):null})})}),e.jsx(Js,{open:d,onClose:()=>m(!1),workspace:n}),e.jsx(dt,{open:_e,onClose:Ce,onPurchase:Pe,currentBalance:J,isLoading:je,autoReloadActive:Te})]})},Ur=()=>{var n;const t=(n=Xe())!=null?n:qe;return e.jsx(Ks,{workspace:t,children:e.jsx(kr,{},t)},t)},Ro=()=>e.jsx(pt,{feature:"tts",children:e.jsx(Ur,{})}),Io=()=>e.jsx(pt,{feature:"llm",children:e.jsx(Rr,{})}),_o=()=>e.jsx(pt,{feature:"stt",children:e.jsx(Or,{})}),Ao=()=>e.jsx(pt,{feature:"realtime",children:e.jsx(Mr,{})});export{Io as PublicLLMRoute,Ao as PublicRealtimeRoute,_o as PublicSTTRoute,Ro as PublicTTSRoute};

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.