PageSourceSearch

https://static.inworld.ai/466fe559/static/js/OutOfTheBoxExperience.D5TALid6.js

js inworld.ai collected 2026-10-01 09:03:45 UTC 41,084 bytes, 1 lines download raw bytes

1import{a as c,j as a}from"./vendor-core.DkahmlU8.js";import{o as ke,n as Te,K as it,B as S,d as re,R as Le,b as ve,c as me,b6 as k,b7 as C,b8 as w,F as xe,aZ as Ft,L as Je,h as be,ap as lt,aq as pt,I as Lt,a as jt,X as Gt,eJ as ct,A as dt,a0 as Mt,Z as Ut,Y as Wt,Q as je,k as De,em as et,eK as Bt,w as tt,ci as Kt,dt as Vt,aj as Ge,ak as Me,bS as Ue,eL as ut,ae as mt,eH as Ht,eM as Fe,cI as at,eN as Xt,aH as Yt}from"./bootstrap.KUFis_Od.js";import{s as gt,b as rt,a as L,u as Tt,g as zt}from"./xstate-react.esm.Cyan9Gha.js";import{a as $t}from"./onboardingLocalForage.k21vxsul.js";import{aC as qt,g as ye,G as K,bQ as Qt,f as ht,L as Zt,bR as nt}from"./App.C7HhiLEI.js";import{O as r,P as j,U as v,A as le,a as ae,b as ge,u as Et}from"./useOnboardingFlow.CTCn9WeJ.js";import{ae as St,s as Jt,y as x,aI as ea,aK as ta,ag as aa,aN as Pe,aO as Ne,ac as ra,aM as na}from"./vendor-mui-x.BZ8Y4adA.js";import{h as sa,T as oa}from"./constants.DXrIgJP9.js";import{S as ia}from"./SnippetWrapper.CbVuMNn4.js";import{d as la,f as pa,a as ca}from"./utils.BpN2_kOR.js";import"./vendor-firebase.dbYXL2Q0.js";import"./language_codes.pb.BsyMdoj2.js";import"./json.svidJjQ5.js";import"./unsupportedIterableToArray.BlAcjINT.js";import"./defineProperty.-oRdnHGo.js";const da=new Set(["langchain","n8n"]),ft=e=>e.filter(t=>!da.has(t.toLowerCase())),ua=e=>{const t=[...new Set(e.split(",").map(u=>u.trim()).filter(Boolean))],s=new Set(["none","other"]),n=[];for(const u of ft(t)){const p=u.toLowerCase();s.has(p)||(s.add(p),n.push({value:p,label:u}))}return[{value:"none",label:"Not using any frameworks / integrations"},...n,{value:"other",label:"Other"}]},st={livekit:{label:"LiveKit",href:"https://docs.livekit.io/agents/models/tts/inworld/#plugin"},pipecat:{label:"Pipecat",href:"https://docs.pipecat.ai/api-reference/server/services/tts/inworld"},openclaw:{label:"OpenClaw",href:"https://docs.openclaw.ai/providers/inworld"},twilio:{label:"Twilio",href:"https://docs.inworld.ai/realtime/usage/twilio"}},yt=e=>[...new Set(e.map(t=>t.toLowerCase()))].flatMap(t=>Object.hasOwn(st,t)?[st[t]]:[]),ma=()=>{var s;const e=ke(Te.STUDIO_V2_NEW_ONBOARDING),t=it(Te.STUDIO_V2_NEW_ONBOARDING);return c.useMemo(()=>{var u,p;if(!e)return{enabled:!1,options:[]};const n=t.enabled?(p=(u=t.payload)==null?void 0:u.value)==null?void 0:p.trim():void 0;return n?{enabled:!0,options:ua(n)}:{enabled:!1,options:[]}},[e,t.enabled,(s=t.payload)==null?void 0:s.value])},ga=()=>{var s;const e=ke(Te.STUDIO_V2_NEW_ONBOARDING_FLOW_FEATURE_REDIRECTS),t=it(Te.STUDIO_V2_NEW_ONBOARDING_FLOW_FEATURE_REDIRECTS);return c.useMemo(()=>{var n;if(!e||!t.enabled||!((n=t.payload)!=null&&n.value))return{redirects:void 0,preferDeeplink:!1};try{const{preferDeeplink:u,...p}=JSON.parse(t.payload.value);return{redirects:typeof p=="object"&&p!==null?p:void 0,preferDeeplink:u===!0}}catch(u){return{redirects:void 0,preferDeeplink:!1}}},[e,t.enabled,(s=t.payload)==null?void 0:s.value])},We=({hasSelection:e,isFinalStep:t=!1,canSkip:s=!0,onBack:n,onNext:u,sx:p})=>{const o=!t&&s&&!e;return a.jsxs(S,{className:"OnboardingNavigation",sx:[{display:"flex",alignItems:"center",justifyContent:"center",gap:2,flexShrink:0},...Array.isArray(p)?p:[p]],children:[n&&a.jsx(re,{intent:"ghost",onClick:n,children:"Back"}),a.jsx(re,{intent:o?"secondary":"primary",onClick:u,children:t?"Finish":o?"Skip":"Next"})]})},Y="complete";function ue(e,t){return t.type==="NEXT"&&t.userType!==void 0||t.type==="SELECT_USER_TYPE"?t.userType:e.userType}function Ta(e,t){return t.type==="NEXT"&&t.productInterests!==void 0||t.type==="RESTORE"&&t.productInterests!==void 0?t.productInterests:e.productInterests}const ot=gt({guards:{isAppFrameworkStepDisabled:({context:e})=>{var t;return((t=e.disabledSteps)==null?void 0:t.includes(r.APP_FRAMEWORK))===!0},isBuildingApp:({context:e,event:t})=>ue(e,t)===v.BUILDING_APP,showAppFramework:({context:e,event:t})=>{var n;const s=ue(e,t);return(s===v.BUILDING_APP||s===v.OTHER)&&!((n=e.disabledSteps)!=null&&n.includes(r.APP_FRAMEWORK))},isPersonalUse:({context:e,event:t})=>ue(e,t)===v.PERSONAL,showFirstApiCall:({context:e,event:t})=>{var u;
1const s=ue(e,t),n=Ta(e,t);return(s===v.BUILDING_APP||s===v.OTHER)&&n.includes(j.TTS)&&!((u=e.disabledSteps)!=null&&u.includes(r.FIRST_API_CALL))},showInviteTeam:({context:e,event:t})=>ue(e,t)!==v.PERSONAL,isInviteTeamStepEnabled:({context:e})=>{var t;return!((t=e.disabledSteps)!=null&&t.includes(r.INVITE_TEAM))},showInviteTeamAndEnabled:({context:e,event:t})=>{var s;return ue(e,t)!==v.PERSONAL&&!((s=e.disabledSteps)!=null&&s.includes(r.INVITE_TEAM))},restoreToAppType:({event:e})=>e.type==="RESTORE"&&e.step===r.APP_TYPE,restoreToAppStage:({event:e})=>e.type==="RESTORE"&&e.step===r.APP_STAGE,restoreToProductInterest:({event:e})=>e.type==="RESTORE"&&e.step===r.PRODUCT_INTEREST,restoreToAppFramework:({event:e})=>e.type==="RESTORE"&&e.step===r.APP_FRAMEWORK,restoreToFirstApiCall:({event:e})=>e.type==="RESTORE"&&e.step===r.FIRST_API_CALL,restoreToInviteTeam:({event:e})=>e.type==="RESTORE"&&e.step===r.INVITE_TEAM}}).createMachine({id:"onboardingStep",initial:r.ORG_AND_ROLE,on:{SET_DISABLED_STEPS:{actions:L({disabledSteps:({event:e})=>e.disabledSteps})}},context:({input:e})=>{var t;return{userType:void 0,productInterests:[],disabledSteps:(t=e==null?void 0:e.disabledSteps)!=null?t:[r.INVITE_TEAM]}},states:{[r.ORG_AND_ROLE]:{meta:{description:"What describes you best?",title:"What describes you best?",selfContainedStep:!1},on:{RESTORE:[{target:r.APP_TYPE,guard:"restoreToAppType",actions:L({userType:({event:e})=>e.type==="RESTORE"?e.userType:void 0,productInterests:({event:e})=>{var t;return e.type==="RESTORE"?(t=e.productInterests)!=null?t:[]:[]}})},{target:r.APP_STAGE,guard:"restoreToAppStage",actions:L({userType:({event:e})=>e.type==="RESTORE"?e.userType:void 0,productInterests:({event:e})=>{var t;return e.type==="RESTORE"?(t=e.productInterests)!=null?t:[]:[]}})},{target:r.PRODUCT_INTEREST,guard:"restoreToProductInterest",actions:L({userType:({event:e})=>e.type==="RESTORE"?e.userType:void 0,productInterests:({event:e})=>{var t;return e.type==="RESTORE"?(t=e.productInterests)!=null?t:[]:[]}})},{target:r.APP_FRAMEWORK,guard:"restoreToAppFramework",actions:L({userType:({event:e})=>e.type==="RESTORE"?e.userType:void 0,productInterests:({event:e})=>{var t;return e.type==="RESTORE"?(t=e.productInterests)!=null?t:[]:[]}})},{target:r.FIRST_API_CALL,guard:"restoreToFirstApiCall",actions:L({userType:({event:e})=>e.type==="RESTORE"?e.userType:void 0,productInterests:({event:e})=>{var t;return e.type==="RESTORE"?(t=e.productInterests)!=null?t:[]:[]}})},{target:r.INVITE_TEAM,guard:"restoreToInviteTeam",actions:L({userType:({event:e})=>e.type==="RESTORE"?e.userType:void 0,productInterests:({event:e})=>{var t;return e.type==="RESTORE"?(t=e.productInterests)!=null?t:[]:[]}})}],NEXT:[{target:r.APP_TYPE,guard:"isBuildingApp",actions:L({userType:({event:e})=>e.type==="NEXT"?e.userType:void 0})},{target:r.PRODUCT_INTEREST,actions:L({userType:({event:e})=>e.type==="NEXT"?e.userType:void 0})}]}},[r.APP_TYPE]:{meta:{description:"What type of application?",title:"What type of application are you working on?",selfContainedStep:!1},on:{NEXT:{target:r.APP_STAGE},BACK:{target:r.ORG_AND_ROLE}}},[r.APP_STAGE]:{meta:{description:"Where is your app today?",title:"Where is your app today?",selfContainedStep:!1},on:{NEXT:{target:r.PRODUCT_INTEREST},BACK:{target:r.APP_TYPE}}},[r.PRODUCT_INTEREST]:{meta:{description:"What would you like to do with Inworld?",title:"What would you like to do with Inworld?",selfContainedStep:!1},on:{NEXT:[{target:r.APP_FRAMEWORK,guard:"showAppFramework",actions:L({productInterests:({context:e,event:t})=>t.type==="NEXT"&&t.productInterests?t.productInterests:e.productInterests})},{target:r.FIRST_API_CALL,guard:"showFirstApiCall",actions:L({productInterests:({context:e,event:t})=>t.type==="NEXT"&&t.productInterests?t.productInterests:e.productInterests})},{target:r.INVITE_TEAM,guard:"showInviteTeamAndEnabled",actions:L({productInterests:({context:e,event:t})=>t.type==="NEXT"&&t.productInterests?t.productInterests:e.productInterests})},{target:Y,actions:L({productInterests:({context:e,event:t})=>t.type==="NEXT"&&t.productInterests?t.productInterests:e.productInterests})}],BACK:[{target:r.APP_STAGE,guard:"isBuildingApp"},{target:r.ORG_AND_ROLE}]}},[r.APP_FRAMEWORK]:{always:[{target:r.FIRST_API_CALL,guard:rt(["isAppFrameworkStepDisabled","showFirstApiCall"])},{target:r.INVITE_TEAM,guard:rt(["isAppFrameworkStepDisabled","showInviteTeamAndEnabled"])},{target:Y,guard:"isAppFrameworkStepDisabled"}],meta:{description:"Any frameworks or integrations?",title:"Are you using any frameworks or integrations?",selfContainedStep:!1}
1,on:{NEXT:[{target:r.FIRST_API_CALL,guard:"showFirstApiCall"},{target:r.INVITE_TEAM,guard:"showInviteTeamAndEnabled"},{target:Y}],BACK:{target:r.PRODUCT_INTEREST}}},[r.FIRST_API_CALL]:{always:[{target:r.INVITE_TEAM,guard:({context:e})=>{var t,s;return((t=e.disabledSteps)==null?void 0:t.includes(r.FIRST_API_CALL))===!0&&!((s=e.disabledSteps)!=null&&s.includes(r.INVITE_TEAM))}},{target:Y,guard:({context:e})=>{var t;return((t=e.disabledSteps)==null?void 0:t.includes(r.FIRST_API_CALL))===!0}}],meta:{description:"Make your first API call",title:"Make your first API call",selfContainedStep:!0},on:{NEXT:[{target:r.INVITE_TEAM,guard:"isInviteTeamStepEnabled"},{target:Y}],BACK:[{target:r.APP_FRAMEWORK,guard:"showAppFramework"},{target:r.PRODUCT_INTEREST}]}},[r.INVITE_TEAM]:{meta:{description:"Invite your team",title:"Invite your team",selfContainedStep:!0},on:{NEXT:{target:Y},FINISH:{target:Y},SKIP:{target:Y},BACK:[{target:r.FIRST_API_CALL,guard:"showFirstApiCall"},{target:r.APP_FRAMEWORK,guard:"showAppFramework"},{target:r.PRODUCT_INTEREST}]}},[Y]:{type:"final",meta:{description:"Onboarding complete",title:"",selfContainedStep:!1}}}}),pe=Y,ha={[r.ORG_AND_ROLE]:{title:"What describes you best?",selfContainedStep:!1},[r.APP_TYPE]:{title:"What type of application are you working on?",selfContainedStep:!1},[r.APP_STAGE]:{title:"Where is your app today?",selfContainedStep:!1},[r.PRODUCT_INTEREST]:{title:"What would you like to do with Inworld?",selfContainedStep:!1},[r.APP_FRAMEWORK]:{title:"Are you using any frameworks or integrations?",selfContainedStep:!1},[r.FIRST_API_CALL]:{title:"Make your first API call",selfContainedStep:!0},[r.INVITE_TEAM]:{title:"Invite your team",selfContainedStep:!0}};function Ot(e){return ha[e]}function Ea(e){var t,s;return(s=(t=Ot(e))==null?void 0:t.title)!=null?s:""}function Sa(e){return e!==r.ORG_AND_ROLE&&e!==pe}const fa=[j.TTS,j.STT,j.STS,j.LLM_ROUTING],ya="${workspace}";function Re(e){if(!e)return!1;const t=e.split("?")[0].split("#")[0].replace(/\/+$/,"");return!/^\/(?:v2\/)?workspaces\/[^/]+$/.test(t)&&t!==""}function Oa(e,t,s,n,u){const p=T=>T.includes(ya)?t?T.replace(/\$\{workspace\}/g,t):"/workspaces":T,o=Re(n)?n:void 0;if(s){if(u&&o)return o;for(const T of fa)if(e!=null&&e.includes(T)&&s[T])return p(s[T]);if(o)return o;if(s.default)return p(s.default)}if(o)return o;
1const m=t?`/workspaces/${t}`:"";return(e==null?void 0:e.includes(j.TTS))?m?`${m}/tts-playground`:"/tts-playground":m||"/workspaces"}const It=St,Oe=Jt(re,{shouldForwardProp:e=>e!=="selected"})(({theme:e,selected:t})=>({display:"flex",alignItems:"flex-start",width:"100%",...e.typography.body2,justifyContent:"flex-start",textAlign:"left",padding:"0.75rem 1rem",borderRadius:Le.md,border:"1px solid",...qt(e,{selected:t}),userSelect:"none"})),Ia=({control:e,setValue:t,options:s,onSelectNone:n})=>{const u=ye({control:e,name:"appFrameworks"});return a.jsxs(S,{component:"div",children:[a.jsx(x,{variant:"body2",sx:{color:"text.secondary",mb:"0.75rem",display:"block"},children:"Select all that apply"}),a.jsx(K,{name:"appFrameworks",control:e,defaultValue:[],render:({field:p})=>{const{value:o=[],onChange:m}=p,y=T=>{if(T===le.NONE){m([le.NONE]),n==null||n();return}const i=o.filter(A=>A!==le.NONE),h=i.includes(T)?i.filter(A=>A!==T):[...i,T];m(h),T===le.OTHER&&!h.includes(le.OTHER)&&t("appFrameworkOther","")};return a.jsx(S,{component:"div",sx:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:s.map(T=>a.jsx(Oe,{intent:"ghost","aria-pressed":o.includes(T.value),selected:o.includes(T.value),onClick:()=>y(T.value),children:T.label},T.value))})}}),(u==null?void 0:u.includes(le.OTHER))&&a.jsx(S,{component:"div",sx:{mt:"0.75rem"},children:a.jsx(K,{name:"appFrameworkOther",control:e,render:({field:p})=>a.jsx(It,{className:"inworld-text-field",...p,fullWidth:!0,placeholder:"Please specify the framework or integration",size:"small",sx:{"& .MuiOutlinedInput-root":{"& .MuiOutlinedInput-input":{paddingTop:"0.25rem",paddingBottom:"0.25rem"}}}})})})]})},we=[{value:v.PERSONAL,label:"Personal use"},{value:v.CONTENT_CREATOR,label:"Content creator"},{value:v.BUILDING_APP,label:"Building an application"},{value:v.OTHER,label:"Other"}],_a=[{value:ae.AI_COMPANION,label:"AI companion"},{value:ae.EDUCATION,label:"Education / coaching"},{value:ae.GAME,label:"Game / entertainment"},{value:ae.CUSTOMER_SUPPORT,label:"Customer support"},{value:ae.BUSINESS,label:"Business application"},{value:ae.OTHER_CONSUMER,label:"Other consumer application"}],Aa=[{value:ge.EXPLORING,label:"Exploring / prototyping"},{value:ge.BETA,label:"In beta with early users"},{value:ge.PRODUCTION,label:"Live in production"},{value:ge.SCALING,label:"Scaling rapidly"}],Ra=[{value:j.TTS,label:"Text to Speech",description:"Generate audio from text, explore voices, and try instant voice cloning"},{value:j.STT,label:"Speech to Text",description:"Transcribe audio in realtime"},{value:j.STS,label:"Speech to Speech",description:"Have a realtime conversation with maximum naturalness and minimal latency"},{value:j.LLM_ROUTING,label:"LLM routing",description:"Route to the best models for your users"}],xa=({control:e,onSelect:t})=>a.jsx(S,{component:"div",children:a.jsx(K,{name:"appStage",control:e,render:({field:s})=>a.jsx(S,{component:"div",sx:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:Aa.map(n=>a.jsx(Oe,{intent:"ghost","aria-pressed":s.value===n.value,selected:s.value===n.value,onClick:()=>{s.onChange(n.value),t==null||t(n.value)},children:n.label},n.value))})})}),ba=({control:e,onSelect:t})=>a.jsx(S,{component:"div",children:a.jsx(K,{name:"appType",control:e,render:({field:s})=>a.jsx(S,{component:"div",sx:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:_a.map(n=>a.jsx(Oe,{intent:"ghost","aria-pressed":s.value===n.value,selected:s.value===n.value,onClick:()=>{s.onChange(n.value),t==null||t(n.value)},children:n.label},n.value))})})}),Pa={curl:"Run this curl command in a terminal to generate audio with TTS-2.",js:"Run this Node.js script to generate audio with TTS-2.",py:"Run this Python script to generate audio with TTS-2."},Na=({apiKey:e})=>{const[t,s]=c.useState("js"),n=c.useMemo(()=>[{id:"js",label:"Node",language:"javascript",build:la},{id:"py",label:"Python",language:"python",build:pa},{id:"curl",label:"curl",language:"bash",build:ca}].map(({build:u,...p})=>({...p,code:u(sa,oa.INWORLD_TTS_2,void 0,void 0,void 0,e||void 0)})),[e]);return a.jsx(S,{className:"ApiInstructions",sx:{minHeight:0,display:"flex",flexDirection:"column"},children:a.jsx(ia,{tabs:n,presentation:"docs",maxHeight:"45dvh",scrollRegionLabel:"API code examples",sx:{mb:0},onTabChange:s,description:Pa[t]})})},ka=({frameworks:e,isFinalStep:t,...s})=>{const[n,u]=c.useState(null),[p,o]=c.useState(!1),[m,y]=c.useState(null),[T,i]=c.useState(!1),h=yt(e),A=async()=>{k(C.ONBOARDING_CLICKED_GENERATE_API_KEY,w.OnboardingFlow),o(!0),y(null);try{u(await s.onGenerateKey())}catch(E){y("Failed to generate API key. Please try again.")}finally{o(!1)}},g=async()=>
1{if(n){y(null);try{await navigator.clipboard.writeText(n),i(!0),k(C.ONBOARDING_COPIED_API_KEY,w.OnboardingFlow)}catch(E){y("Could not copy the API key. Please try again.")}}};return a.jsxs(S,{className:"FirstApiCallStep",sx:{display:"flex",flexDirection:"column",gap:3,minHeight:0},children:[a.jsxs(S,{sx:{display:"flex",flexShrink:0,flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:2,p:2,border:1,borderColor:"divider",borderRadius:Le.md},children:[a.jsx(x,{variant:"body2",color:"text.secondary",children:n?"API key generated successfully":h.length>0?"Generate an Inworld API key to connect your integrations":"Generate an Inworld API key to try the example"}),n?a.jsx(re,{intent:"secondary",size:"small",onClick:g,startIcon:a.jsx(ve,{icon:me.faCopy}),children:T?"Copied":"Copy API key"}):a.jsx(re,{size:"small",loading:p,onClick:A,children:"Generate"})]}),m&&a.jsx(x,{role:"alert",variant:"body2",color:"error",children:m}),h.length>0?a.jsxs(a.Fragment,{children:[a.jsx(x,{color:"text.secondary",children:"Follow the guides for your selected integrations to connect Inworld to your app."}),a.jsx(S,{sx:{display:"flex",flexDirection:"column",gap:2,minHeight:0,overflow:"auto"},children:h.map(E=>a.jsxs(re,{intent:"secondary",href:E.href,target:"_blank",rel:"noopener noreferrer",endIcon:a.jsx(ve,{icon:me.faArrowUpRightFromSquare}),sx:{justifyContent:"space-between",p:2},children:[E.label," integration guide"]},E.href))})]}):a.jsx(Na,{apiKey:n}),a.jsx(We,{isFinalStep:t,hasSelection:!!n||h.length>0,onBack:s.onBack,onNext:s.onContinue})]})},Ca=({onSkip:e,onBack:t})=>{const[s,n]=c.useState([]),[u,p]=c.useState(""),o=c.useRef(null),m=g=>{const E=g.trim().replace(/,$/,"");E&&E.includes("@")&&!s.includes(E)&&n(P=>[...P,E])},y=g=>{g.key==="Enter"||g.key===","?(g.preventDefault(),m(u),p("")):g.key==="Backspace"&&u===""&&s.length>0&&n(E=>E.slice(0,-1))},T=g=>{g.preventDefault();const P=g.clipboardData.getData("text").split(/[,;\s]+/).map(N=>N.trim()).filter(N=>N.includes("@")&&!s.includes(N));P.length>0&&n(N=>[...N,...P]),p("")},i=()=>{u.trim()&&(m(u),p(""))},h=g=>{n(E=>E.filter((P,N)=>N!==g))},A=()=>{k(C.ONBOARDING_INVITED_TEAM,w.OnboardingFlow,{emails:s,emailCount:s.length}),e()};return a.jsxs(S,{component:"div",sx:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:[a.jsx(S,{component:"div",children:a.jsxs(S,{"aria-label":"Email input",component:"div",onClick:()=>{var g;return(g=o.current)==null?void 0:g.focus()},sx:{border:"1px solid",borderColor:"divider",borderRadius:Le.md,p:"0.75rem",minHeight:"120px",display:"flex",flexWrap:"wrap",gap:"0.5rem",alignContent:"flex-start",cursor:"text","&:focus-within":{borderColor:"primary.main"}},children:[s.map((g,E)=>a.jsx(ea,{label:g,onDelete:()=>h(E),size:"small",sx:{fontSize:xe.base,height:"28px"}},g)),a.jsx(ta,{inputRef:o,value:u,onChange:g=>p(g.target.value),onKeyDown:y,onPaste:T,onBlur:i,placeholder:s.length===0?"Enter email addresses":"",sx:{flex:1,minWidth:"150px",fontSize:xe.base}})]})}),a.jsx(We,{isFinalStep:!0,hasSelection:s.length>0,onBack:t,onNext:s.length>0?A:e,sx:{mt:1}})]})},wa=({control:e,errors:t,showGeofencingToS:s=!0,setValue:n,onSelect:u})=>{var o;const p=ye({control:e,name:"userType"});return c.useEffect(()=>{!s&&n&&n("terms",!0)},[s,n]),a.jsxs(S,{component:"div",className:"OrgAndRoleStep",children:[a.jsx(K,{name:"userType",control:e,rules:{required:"Please select an option"},render:({field:m})=>{var y,T,i;return a.jsx(S,{component:"div",sx:{mb:"1rem"},children:s?a.jsx(a.Fragment,{children:a.jsxs(Ft,{label:"Your role",children:[a.jsx(St,{select:!0,...m,value:(y=m.value)!=null?y:"",className:"inworld-text-field",fullWidth:!0,size:"small",error:!!(t!=null&&t.userType),slotProps:{select:{displayEmpty:!0,inputProps:{"aria-label":"Your role"},renderValue:h=>{var A;return h?(A=we.find(g=>g.value===h))==null?void 0:A.label:a.jsx(x,{component:"span",variant:"body2",color:"text.secondary",children:"Select your role"})}}},onChange:h=>{const A=h.target.value;m.onChange(A)},children:we.map(h=>a.jsx(aa,{value:h.value,children:h.label},h.value))}),((T=t==null?void 0:t.userType)==null?void 0:T.message)&&a.jsx(x,{variant:"caption",color:"error",sx:{mt:.5,display:"block"},children:t.userType.message})]})}
1):a.jsxs(S,{component:"div",sx:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[we.map(h=>a.jsx(Oe,{intent:"ghost","aria-pressed":m.value===h.value,selected:m.value===h.value,onClick:()=>{m.onChange(h.value),h.value!==v.OTHER&&(u==null||u(h.value))},children:h.label},h.value)),((i=t==null?void 0:t.userType)==null?void 0:i.message)&&a.jsx(x,{variant:"caption",color:"error",sx:{mt:.5,display:"block"},children:t.userType.message})]})})}}),p==="other"&&a.jsx(S,{component:"div",sx:{mt:"0.75rem"},children:a.jsx(K,{name:"userTypeOther",control:e,render:({field:m})=>a.jsx(It,{className:"inworld-text-field",...m,fullWidth:!0,placeholder:"Please describe your use case",size:"small"})})}),s&&a.jsxs(S,{component:"div",sx:{mt:"1.5rem",ml:0,pl:0},children:[a.jsx(Pe,{sx:{typography:"body2",display:"flex",alignItems:"flex-start",m:0,mb:2},control:a.jsx(K,{name:"marketing",control:e,render:({field:m})=>a.jsx(Ne,{disableRipple:!0,size:"small",sx:{p:0,mr:1.5,height:`calc(${xe.md} * ${Je.md})`,width:"1.25rem",flexShrink:0},checked:m.value,onChange:y=>m.onChange(y.target.checked)})}),label:a.jsx(x,{variant:"body2",sx:{maxWidth:"56ch",pl:0},children:"Receive product updates and promotions from Inworld."})}),a.jsx(Pe,{sx:{typography:"body2",display:"flex",alignItems:"flex-start",m:0},control:a.jsx(K,{name:"terms",control:e,rules:{required:"You must accept the terms to continue"},render:({field:m})=>a.jsx(Ne,{disableRipple:!0,size:"small",sx:{p:0,mr:1.5,height:`calc(${xe.md} * ${Je.md})`,width:"1.25rem",flexShrink:0},checked:m.value,onChange:y=>m.onChange(y.target.checked)})}),label:a.jsxs(x,{variant:"body2",sx:{maxWidth:"56ch",pl:0},children:["I agree that I have read Inworld AI's"," ",a.jsx(be,{color:"text.accent","aria-label":"Terms of Service",href:lt,target:"_blank",rel:"nofollow noopener noreferrer",children:"Terms of Service"})," ","and the"," ",a.jsx(be,{color:"text.accent","aria-label":"Privacy Policy",href:pt,target:"_blank",rel:"nofollow noopener noreferrer",children:"Privacy Policy"}),"."]})}),((o=t==null?void 0:t.terms)==null?void 0:o.message)&&a.jsx(x,{variant:"caption",color:"error",sx:{mt:.5,display:"block",pl:4},children:t.terms.message})]})]})},va={[j.TTS]:me.faVolumeHigh,[j.STT]:me.faMicrophone,[j.STS]:me.faWaveformLines,[j.LLM_ROUTING]:me.faShareNodes},Da=({control:e})=>{const t=Ra;return a.jsxs(S,{component:"div",className:"ProductInterestStep",children:[a.jsx(x,{variant:"body2",sx:{color:"text.secondary",mb:"0.75rem",display:"block"},children:"Select all that apply"}),a.jsx(K,{name:"productInterests",control:e,defaultValue:[],render:({field:s})=>{const{value:n=[],onChange:u}=s,p=o=>{const m=n.includes(o)?n.filter(y=>y!==o):[...n,o];u(m)};return a.jsx(S,{component:"div",sx:{display:"grid",gridAutoRows:"1fr",gridTemplateColumns:{xs:"1fr",sm:"repeat(2, minmax(0, 1fr))"},gap:1.5},children:t.map(o=>a.jsx(Oe,{intent:"ghost","aria-pressed":n.includes(o.value),selected:n.includes(o.value),onClick:()=>p(o.value),sx:{p:2},children:a.jsxs(S,{component:"span",children:[a.jsxs(S,{component:"span",sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[a.jsx(S,{component:"span",sx:{display:"flex",color:"text.accent",[jt]:Lt.xl},children:a.jsx(ve,{icon:va[o.value]})}),a.jsx(x,{component:"span",variant:"subtitle1",children:o.label})]}),o.description&&a.jsx(x,{variant:"body2",component:"span",sx:{color:"text.secondary",display:"block"},children:o.description})]})},o.value))})}})]})},Fa=["api.rt::x","api.ml::x","api.ops::x"],La=()=>{try{const e=globalThis.sessionStorage.getItem(nt);return e&&globalThis.sessionStorage.removeItem(nt),e}catch(e){return null}},ja=e=>e.replace(/\(ws=.*?\)$/,""),Ga=({onComplete:e})=>{var He,Xe,Ye,ze,$e,qe,Qe;Qt();const{enabled:t,options:s}=ma(),n=ra(l=>l.breakpoints.down("sm"),{noSsr:!0}),u=c.useMemo(()=>{const l=[r.INVITE_TEAM];return(!t||n)&&l.push(r.APP_FRAMEWORK),n&&l.push(r.FIRST_API_CALL),l},[t,n]),[p,o]=Tt(ot,{input:{disabledSteps:u}});c.useEffect(()=>{o({type:"SET_DISABLED_STEPS",disabledSteps:u})},[u,o]);const{redirects:m,preferDeeplink:y}
1=ga(),T=ke(Te.STUDIO_V2_SKIP_ONBOARDING_FOR_DEEPLINK),i=p.value,{workspace:h}=Gt(),A=ct(),g=dt(),E=h?Mt(h):(He=A.landingWorkspace)==null?void 0:He.name,P=Ut(),N=c.useRef((Xe=La())!=null?Xe:`${P.pathname}${P.search}${P.hash}`),z=Wt(),{acceptToS:ce,updateMarketingConsent:Ie}=je(),{saveOnboardingData:de,saveOnboardingProgress:Z,getOnboardingData:$,isLoading:he,showGeofencingToS:Ee}=Et(),b=T&&!((Ye=$())!=null&&Ye.forceFullFlow),[D,_e]=c.useState(Ee);c.useEffect(()=>{if(p.value!==r.ORG_AND_ROLE){D&&_e(!1);return}Ee&&!D&&_e(!0)},[p.value,Ee,D]);const V=D,[ne,Se]=c.useState(!1),[G,se]=c.useState(!1),M=c.useRef(!1),J=c.useRef(!1),H=c.useRef(null),{control:W,getValues:R,setValue:ee,reset:Be,trigger:Ke,formState:_t}=ht({mode:"onChange",defaultValues:{organizationName:"",userType:void 0,userTypeOther:"",terms:!1,marketing:!1,appType:ae.APP_TYPE_UNSPECIFIED,appStage:ge.APP_STAGE_UNSPECIFIED,productInterests:[],appFrameworks:[],appFrameworkOther:"",inviteEmails:[]}}),B=ye({control:W,name:"userType"}),F=ye({control:W,name:"productInterests"}),X=ye({control:W,name:"appFrameworks"}),At=Sa(i);c.useEffect(()=>{var O,f,U,q,d,I,_,fe,oe,Q,ie;if(he||J.current)return;const l=$();!l||l.complete||!l.currentStep||l.currentStep===r.ORG_AND_ROLE||(J.current=!0,Be({organizationName:(O=l.organizationName)!=null?O:"",userType:l.userType,userTypeOther:(f=l.userTypeOther)!=null?f:"",terms:(q=(U=l.terms)!=null?U:l.termsAccepted)!=null?q:!1,marketing:(d=l.marketing)!=null?d:!1,appType:(I=l.appType)!=null?I:ae.APP_TYPE_UNSPECIFIED,appStage:(_=l.appStage)!=null?_:ge.APP_STAGE_UNSPECIFIED,productInterests:(fe=l.productInterests)!=null?fe:[],appFrameworks:ft((oe=l.appFrameworks)!=null?oe:[]),appFrameworkOther:(Q=l.appFrameworkOther)!=null?Q:"",inviteEmails:(ie=l.inviteEmails)!=null?ie:[]}),o({type:"RESTORE",step:l.currentStep,userType:l.userType,productInterests:l.productInterests}))},[he,$,Be,o]),c.useEffect(()=>{i!==pe&&k(C.ONBOARDING_STEP_SHOWN,w.OnboardingFlow,{step:i})},[i]),c.useEffect(()=>{var f;if(i===pe)return;const l=$();if(i===r.ORG_AND_ROLE&&(l!=null&&l.currentStep)&&l.currentStep!==r.ORG_AND_ROLE)return;const O=R();Z({currentStep:i,userType:p.context.userType,productInterests:p.context.productInterests,organizationName:O.organizationName,userTypeOther:O.userTypeOther,terms:O.terms,termsAccepted:(f=l==null?void 0:l.termsAccepted)!=null?f:O.terms,marketing:O.marketing,appType:O.appType,appStage:O.appStage,appFrameworks:O.appFrameworks,appFrameworkOther:O.appFrameworkOther,inviteEmails:O.inviteEmails})},[i,p.context.userType,p.context.productInterests]);const Ce=c.useCallback(()=>{k(C.ONBOARDING_STEP_BACK,w.OnboardingFlow,{step:i}),o({type:"BACK"})},[o,i]),Rt=c.useCallback(l=>{var U;if(ee("userType",l),b&&Re(N.current)&&!M.current){M.current=!0,J.current=!0,k(C.ONBOARDING_STEP_CONTINUE,w.OnboardingFlow,{step:r.ORG_AND_ROLE,userType:l}),k(C.ONBOARDING_STEP_SKIP,w.OnboardingFlow,{step:r.ORG_AND_ROLE,autoSkippedForDeeplink:!0}),(U=H.current)==null||U.call(H,void 0,{autoSkippedForDeeplink:!0});return}const O=l===v.BUILDING_APP?r.APP_TYPE:r.PRODUCT_INTEREST,f=R();Z({termsAccepted:!0,currentStep:O,userType:l,userTypeOther:f.userTypeOther,organizationName:f.organizationName,marketing:f.marketing}),k(C.ONBOARDING_STEP_CONTINUE,w.OnboardingFlow,{step:r.ORG_AND_ROLE,userType:l}),o({type:"NEXT",userType:l})},[ee,o,R,Z,b]),xt=c.useCallback(l=>{ee("appType",l),k(C.ONBOARDING_STEP_CONTINUE,w.OnboardingFlow,{step:r.APP_TYPE,appType:l}),o({type:"NEXT"})},[ee,o]),bt=c.useCallback(l=>{ee("appStage",l),k(C.ONBOARDING_STEP_CONTINUE,w.OnboardingFlow,{step:r.APP_STAGE,appStage:l}),o({type:"NEXT"})},[ee,o]),Pt=c.useCallback(()=>{k(C.ONBOARDING_STEP_CONTINUE,w.OnboardingFlow,{step:r.APP_FRAMEWORK,appFrameworks:["none"]}),o({type:"NEXT"})},[o]),Nt=c.useCallback(async()=>{const l=await De(et.ListAuthScopes,{parent:E}),O=((l==null?void 0:l.authScopes)||[]).map(_=>_.name).filter(_=>!!_).map(ja),f=new Set(O),U=O.filter(_=>_.endsWith("::r")?!f.has(_.replace("::r","::rw")):!0),q=[...new Set([...Fa,...U])],d=await De(et.GenerateApiKey,{parent:E,scopes:q});if(!(d!=null&&d.key)||!(d!=null&&d.secret))throw new Error("API key generation failed");Bt(g,tt(E),d);const I=new TextEncoder().encode(`${d.key}:${d.secret}`);return Kt(I.slice().buffer)},[E,g]),Ae=c.useCallback(async(l,O)=>{var oe,Q,ie,Ze;const f=R(),U=(oe=l!=null?l:p.context.productInterests)!=null?oe:f.productInterests,q=((Q=f.appFrameworks)==null?void 0:Q.includes(le.OTHER))&&((ie=f.appFrameworkOther)==null?void 0:ie.trim()),d={complete:!0,checklistEligible:!0,termsAccepted:!0,organizationName:f.organizationName,userType:(Ze=p.context.userType)!=null?Ze:f.userType,userTypeOther:f.userTypeOther,terms:f.terms,marketing:f.marketing,appType:f.appType,appStage:f.appStage,productInterests:U,appFrameworks:f.appFrameworks,...q?{appFrameworkOther:f.appFrameworkOther.trim()}:{},inviteEmails:f.inviteEmails,...O!=null&&O.autoSkippedForDeeplink?{autoSkippedForDeeplink:!0}:{}};Se(!1),se(!0);try{await de(d,{throwOnError:!0})}catch(Wa){Se(!0),se(!1);return}(!V||O!=null&&O.autoSkippedForDeeplink)&&await ce().catch(()=>{});const I={};d.autoSkippedForDeeplink&&(I.autoSkippedForDeeplink=!0),d.userType!==void 0&&(I.userType=d.userType),d.userTypeOther!==void 0&&(I.userTypeOther=d.userTypeOther),d.appType!==void 0&&(I.appType=d.appType),d.appStage!==void 0&&(I.appStage=d.appStage),d.productInterests!==void 0&&(I.productInterests=d.productInterests),d.appFrameworks!==void 0&&(I.appFrameworks=d.appFrameworks),d.appFrameworkOther!==void 0&&(I.appFrameworkOther=d.appFrameworkOther),k(C.ONBOARDING_FINISHED,w.OnboardingFlow,I);const _={onboarding_completed_at:new Date().toISOString()};
1d.userType!==void 0&&(_.onboarding_user_type=d.userType),d.userTypeOther!==void 0&&(_.onboarding_user_type_other=d.userTypeOther),d.appType!==void 0&&(_.onboarding_app_type=d.appType),d.appStage!==void 0&&(_.onboarding_app_stage=d.appStage),d.productInterests!==void 0&&(_.onboarding_product_interests=d.productInterests),d.appFrameworks!==void 0&&(_.onboarding_app_frameworks=d.appFrameworks),d.appFrameworkOther!==void 0&&(_.onboarding_app_framework_other=d.appFrameworkOther),Vt(_);const fe=Oa(U,tt(E),m,N.current,y);e(),z(fe,{replace:!0})},[e,z,E,m,y,de,ce,V,R,p.context.userType,p.context.productInterests]);H.current=Ae,c.useEffect(()=>{i!==pe||M.current||(M.current=!0,Ae(p.context.productInterests))},[i,Ae,p.context.productInterests]);const kt=c.useCallback(async()=>{var f,U,q,d;if(i===r.ORG_AND_ROLE){if(!await Ke(V?["userType","terms"]:["userType"]))return;const _=$();if(!((_==null?void 0:_.termsAccepted)===!0)&&V)try{await ce(),await Ie(R().marketing),Ge.track(Me.TERMS_AND_CONDITIONS_ACCEPTED,{app:Ue.Studio}),setTimeout(ut,3e3)}catch(ie){console.error("Failed to accept ToS or update marketing:",ie);return}if(b&&Re(N.current)&&!M.current){M.current=!0,J.current=!0,k(C.ONBOARDING_STEP_CONTINUE,w.OnboardingFlow,{step:r.ORG_AND_ROLE,...B!==void 0?{userType:B}:{}}),k(C.ONBOARDING_STEP_SKIP,w.OnboardingFlow,{step:r.ORG_AND_ROLE,autoSkippedForDeeplink:!0}),(f=H.current)==null||f.call(H,void 0,{autoSkippedForDeeplink:!0});return}const oe=B===v.BUILDING_APP?r.APP_TYPE:r.PRODUCT_INTEREST,Q=R();Z({termsAccepted:!0,currentStep:oe,userType:B,userTypeOther:Q.userTypeOther,organizationName:Q.organizationName,marketing:Q.marketing})}const l=i===r.ORG_AND_ROLE?B!=null:i===r.PRODUCT_INTEREST?((U=F==null?void 0:F.length)!=null?U:0)>0:i===r.APP_FRAMEWORK?((q=X==null?void 0:X.length)!=null?q:0)>0:i===r.APP_TYPE?!!R("appType"):i===r.APP_STAGE?!!R("appStage"):!1;if(i!==r.ORG_AND_ROLE&&!l)k(C.ONBOARDING_STEP_SKIP,w.OnboardingFlow,{step:i});else{const I={step:i};i===r.ORG_AND_ROLE?(B!==void 0&&(I.userType=B),I.userTypeOther=(d=R().userTypeOther)!=null?d:""):i===r.APP_TYPE?I.appType=R("appType"):i===r.APP_STAGE?I.appStage=R("appStage"):i===r.PRODUCT_INTEREST?I.productInterests=F!=null?F:[]:i===r.APP_FRAMEWORK&&(I.appFrameworks=X!=null?X:[]),k(C.ONBOARDING_STEP_CONTINUE,w.OnboardingFlow,I)}i===r.ORG_AND_ROLE?o({type:"NEXT",userType:B}):i===r.PRODUCT_INTEREST?o({type:"NEXT",productInterests:F!=null?F:[]}):o({type:"NEXT"})},[i,o,B,F,X,ce,Ie,R,$,Z,Ke,V,b]),Ct=i===r.FIRST_API_CALL&&yt(R("appFrameworks")).length>0?"Connect your integrations":i!==pe?Ea(i):"",wt=($e=(ze=Ot(i))==null?void 0:ze.selfContainedStep)!=null?$e:!1,Ve=zt(ot,p,{type:"NEXT",userType:B,productInterests:F}).status==="done"||i===r.ORG_AND_ROLE&&b&&Re(N.current),vt=i===r.ORG_AND_ROLE?B!=null:i===r.PRODUCT_INTEREST?((qe=F==null?void 0:F.length)!=null?qe:0)>0:i===r.APP_FRAMEWORK?((Qe=X==null?void 0:X.length)!=null?Qe:0)>0:i===r.APP_TYPE?!!R("appType"):i===r.APP_STAGE?!!R("appStage"):!1,Dt=i===r.ORG_AND_ROLE&&!V&&B!==v.OTHER;return a.jsx(Zt,{leftHandNavDisabled:!0,fullWidth:!0,customWrapperSX:{backgroundColor:"background.default",height:"100%",maxWidth:"100%",p:0},children:a.jsx(mt,{controlled:!0,open:!0,onClose:()=>{},titleComponent:a.jsx(S,{component:"div"}),slotProps:{paper:{"aria-label":"Onboarding"}},dismissible:!1,dividers:!1,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialogContent-root":i===r.FIRST_API_CALL?{display:"flex",minHeight:0,overflow:"hidden"}:{},"& .inworld-dialog-header":l=>({padding:"2rem",maxHeight:"unset",[l.breakpoints.down("sm")]:{padding:"1rem"}}),"& .MuiBackdrop-root":{backgroundColor:l=>l.palette.background.surface.main},"& .MuiDialog-paper":{borderRadius:"0",maxWidth:"unset",maxHeight:"unset",height:"100vh",margin:0,width:"100%",boxShadow:"none",display:"flex",flexDirection:"column",backgroundColor:l=>l.palette.background.paper}},children:a.jsxs(S,{component:"div",sx:{p:[2,4],minHeight:0,flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:[(i===pe||ne)&&a.jsxs(S,{sx:{textAlign:"center"},children:[a.jsx(x,{role:ne?"alert":"status",children:ne?"Could not save your onboarding progress. Please try again.":"Finishing setup…"}),ne&&a.jsx(re,{loading:G,onClick:()=>void Ae(p.context.productInterests),sx:{mt:2},children:"Retry Finish"})]}),i!==pe&&!ne&&a.jsxs(Ht,{maxWidth:i===r.FIRST_API_CALL?"md":"sm",sx:i===r.FIRST_API_CALL?{display:"flex",flexDirection:"column",maxHeight:"100%",minHeight:0}:void 0,children:[a.jsx(x,{variant:"display1",component:"h2",sx:{flexShrink:0,textAlign:"left",mb:3},children:Ct}),i===r.ORG_AND_ROLE&&a.jsx(wa,{control:W,errors:_t.errors,showGeofencingToS:V,setValue:ee,onSelect:V?void 0:Rt}),i===r.APP_TYPE&&a.jsx(ba,{control:W,onSelect:xt}
1),i===r.APP_STAGE&&a.jsx(xa,{control:W,onSelect:bt}),i===r.PRODUCT_INTEREST&&a.jsx(Da,{control:W}),i===r.APP_FRAMEWORK&&a.jsx(Ia,{control:W,setValue:ee,options:s,onSelectNone:Pt}),i===r.FIRST_API_CALL&&a.jsx(ka,{isFinalStep:Ve,frameworks:R("appFrameworks"),onGenerateKey:Nt,onContinue:()=>o({type:"NEXT"}),onBack:Ce}),i===r.INVITE_TEAM&&a.jsx(Ca,{onSkip:()=>o({type:"FINISH"}),onBack:Ce}),!wt&&!Dt&&a.jsx(We,{isFinalStep:Ve,hasSelection:vt,canSkip:i!==r.ORG_AND_ROLE,onBack:At?Ce:void 0,onNext:kt,sx:{mt:3,justifyContent:"flex-end"}})]})]})})})},Ma=({isOpen:e,setIsOpen:t})=>{const{handleSubmit:s,control:n,watch:u}=ht(),p=u("terms"),{inworldUser:o,fetchingUser:m,acceptToS:y,updateMarketingConsent:T}=je(),i=(o==null?void 0:o.tosAcceptanceVersion)===Fe-1;c.useEffect(()=>{o&&(!o.tosAcceptanceVersion||o.tosAcceptanceVersion<+Fe)&&t(!0)},[o,t]);const h=()=>!1,A=async g=>{if(!g.terms)throw Error("ToS acceptance required to proceed");await y(),await T(g.marketing),t(!1),Ge.track(Me.TERMS_AND_CONDITIONS_ACCEPTED,{app:Ue.Studio}),setTimeout(ut,3e3)};return e?a.jsx(mt,{controlled:!0,open:!0,onClose:h,dismissible:!1,titleComponent:a.jsx(x,{variant:"display1",children:i?"We've updated our Terms and Conditions":"Terms and Conditions"}),size:"xs",dividers:!1,closeAfterTransition:!0,sx:{"& .MuiBackdrop-root":{backgroundColor:g=>g.palette.background.default,opacity:1},"& .inworld-dialog-header":{height:"unset",maxHeight:"unset",pr:"2rem",pt:"1.25rem",pl:"1.5rem"}},primary:{customComponent:a.jsx(re,{"aria-label":"Proceed",loading:m,onClick:s(A),disabled:!p,children:"Proceed"})},children:a.jsxs(S,{component:"form",sx:{py:"1.5rem"},children:[a.jsx(Pe,{sx:{display:"flex",alignItems:"flex-start",mb:2,mt:2},control:a.jsx(K,{defaultValue:!1,name:"marketing",control:n,render:g=>a.jsx(Ne,{defaultChecked:!1,sx:{py:0},required:!0,...g,checked:g.field.value,onChange:E=>g.field.onChange(E.target.checked)})}),label:a.jsx(x,{variant:"body2",sx:{maxWidth:"40ch"},children:"Receive product updates and promotions from Inworld."})}),a.jsx(Pe,{sx:{display:"flex",alignItems:"flex-start"},control:a.jsx(K,{defaultValue:!1,name:"terms",control:n,render:g=>a.jsx(Ne,{sx:{py:0},required:!0,...g,checked:g.field.value,onChange:E=>g.field.onChange(E.target.checked)})}),label:a.jsxs(x,{variant:"body2",sx:{maxWidth:"40ch"},children:["By checking this box I agree that I have read InworldAI's"," ",a.jsx(be,{"aria-label":"Terms of Service",href:lt,target:"_blank",rel:"nofollow noopener noreferrer",children:"Terms of Service"})," ","and the"," ",a.jsx(be,{"aria-label":"Privacy Policy",href:pt,target:"_blank",rel:"nofollow noopener noreferrer",children:"Privacy Policy"}),"."]})})]})}):null};var te=(e=>(e.loading="loading",e.tos="tos",e.onboarding="onboarding",e.complete="complete",e))(te||{});const Ua=gt({guards:{shouldShowOnboarding:({context:e})=>e.shouldShowOnboarding}}).createMachine({id:"outOfTheBoxExperience",initial:"loading",context:{shouldShowOnboarding:!1},states:{loading:{meta:{description:"Loading user data"},on:{TOS_REQUIRED:[{target:"onboarding",guard:"shouldShowOnboarding"},{target:"tos"}],USER_LOADED:[{target:"onboarding",guard:"shouldShowOnboarding"},{target:"complete"}]}},tos:{meta:{description:"Terms of Service acceptance modal"},on:{TOS_ACCEPTED:[{target:"onboarding",guard:"shouldShowOnboarding"},{target:"complete"}]}},onboarding:{meta:{description:"New user onboarding flow"},on:{ONBOARDING_COMPLETE:{target:"complete"}}},complete:{meta:{description:"Onboarding complete"},type:"final"}},on:{UPDATE_CONTEXT:{actions:L({shouldShowOnboarding:({context:e,event:t})=>{var s;return(s=t.shouldShowOnboarding)!=null?s:e.shouldShowOnboarding}})},SKIP_TO_COMPLETE:{target:".complete"}}}),rr=()=>{var Se;const{inworldUser:e,fetchingUser:t,acceptToS:s}=je(),n=ct(),[u,p]=c.useState(!n.fetchingWorkspaces);c.useEffect(()=>{n.fetchingWorkspaces||p(!0)},[n.fetchingWorkspaces]);const o=u||!n.fetchingWorkspaces,m=ke(Te.STUDIO_V2_NEW_ONBOARDING),{isOnboardingComplete:y,isLoading:T,getOnboardingData:i,saveOnboardingData:h}=Et(),[A,g]=c.useState(()=>new URLSearchParams(window.location.search).get("restartOnboarding")==="1"),E=c.useRef(!1);c.useEffect(()=>{if(!A||E.current||t||!e||T||!o)return;E.current=!0,(async()=>{var se,M,J,H;try{if(!m)throw new Error("The onboarding feature is disabled");const W=(H=(se=window.location.pathname.match(/\/workspaces\/([^/]+)/))==null?void 0:se[1])!=null?H:(J=(M=n.landingWorksp
1ace)==null?void 0:M.name)==null?void 0:J.split("/").pop();W&&await $t(W),await De(Xt.SetCustomUserSetting,{setting:{name:"users/me/settings/onboarding-checklist",value:JSON.stringify({manualSteps:{},dismissed:!1})}}),await h({complete:!1,currentStep:r.ORG_AND_ROLE,forceFullFlow:!0},{throwOnError:!0});const R=new URL(window.location.href);R.searchParams.delete("restartOnboarding"),window.location.replace(R.toString())}catch(W){g(!1),Yt("Could not restart onboarding. Check that the onboarding feature is enabled and try again.")}})()},[A,o,(Se=n.landingWorkspace)==null?void 0:Se.name,t,e,T,m,h]);const[P]=c.useState(()=>{try{return typeof window!="undefined"?window.sessionStorage.getItem(at):null}catch(G){return null}}),N=c.useRef(!1),z=e&&typeof(e==null?void 0:e.tosAcceptanceVersion)=="number"&&e.tosAcceptanceVersion<Fe,ce=!!e&&(e.tosAcceptanceVersion==null||e.tosAcceptanceVersion===0),Ie=!!(e!=null&&e.onboardingSurvey),de=i(),Z=!!de&&!de.complete&&!!de.currentStep,$=!P&&m&&(ce||Z)&&(T?!0:!y)&&(Z||!Ie&&!!e||!!z),he=dt(),[Ee,b]=Tt(Ua),D=Ee.value;c.useEffect(()=>{D===te.complete&&he.invalidateQueries(["billingInfo"])},[D,he]),c.useEffect(()=>{b({type:"UPDATE_CONTEXT",shouldShowOnboarding:$})},[b,$]),c.useEffect(()=>{if(!P||N.current||!e||t||T)return;N.current=!0;const G=()=>{try{window.sessionStorage.removeItem(at)}catch(M){}};(async()=>{let M=!z;if(z)try{await s(),M=!0}catch(J){}y||h({complete:!0,checklistEligible:!1,termsAccepted:M,autoSkippedForDeeplink:!0}),G(),b({type:"SKIP_TO_COMPLETE"})})()},[P,e,t,T,y,z,s,h,b]),c.useEffect(()=>{A||t||D!==te.loading||m&&T||P||(z&&!m?(Ge.track(Me.TERMS_AND_CONDITIONS_SHOWN,{app:Ue.Studio}),b({type:"TOS_REQUIRED"})):e&&b({type:"USER_LOADED"}))},[A,t,z,e,D,b,m,T,P]);const _e=c.useCallback(G=>{(typeof G=="function"?G(!0):G)||b({type:"TOS_ACCEPTED"})},[b]),V=c.useCallback(()=>{b({type:"ONBOARDING_COMPLETE"})},[b]),ne=!P&&(D===te.loading||D===te.tos);return a.jsxs(a.Fragment,{children:[a.jsx(na,{className:"OutOfTheBoxExperience",open:ne,sx:{backgroundColor:G=>G.palette.background.default,opacity:"1",zIndex:G=>G.zIndex.modal-1},transitionDuration:0}),D!==te.loading&&a.jsxs(a.Fragment,{children:[D===te.tos&&!m&&a.jsx(Ma,{isOpen:!0,setIsOpen:_e}),D===te.onboarding&&m&&o&&a.jsx(Ga,{onComplete:V})]})]})};export{rr as OutOfTheBoxExperience};

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.