function App(){
  const { BottomNav } = window.SpotureDesignSystem_f7ad96;
  const params = new URLSearchParams(location.search);
  const [authed, setAuthed] = React.useState(params.get('login') !== '1');
  const [tab, setTab] = React.useState(params.get('tab') || 'feed');
  const [screen, setScreen] = React.useState(params.get('screen') || null);
  const [screenProps, setScreenProps] = React.useState(params.get('user') ? { name: params.get('user') } : {});
  const [splash, setSplash] = React.useState(params.get('splash') === '1');
  const [onb, setOnb] = React.useState(params.get('onboarding') === '1');
  const [sanction, setSanction] = React.useState(params.get('sanction') || null);
  const [maint, setMaint] = React.useState(params.get('maintenance') || null);
  const mParam = params.get('mission');
  const [msn, setMsn] = React.useState({ status: mParam || 'progress', done: mParam && mParam !== 'progress' ? 3 : 1 });
  const tabKeys = ['feed', 'search', 'upload', 'notifications', 'profile'];
  const nav = (dest, extra) => { setScreenProps(extra || {}); if (tabKeys.includes(dest)) { setTab(dest); setScreen(null); } else setScreen(dest); };
  const guardedNav = (dest, extra) => { const g = window.__uploadGuard; if (g && dest !== 'upload') { g(dest); return; } nav(dest, extra); };
  if (maint) return <Maintenance kind={maint} onDismiss={() => setMaint(null)} />;
  if (splash) return <Splash hold={params.get('hold') === '1'} onDone={() => { setSplash(false); if (params.get('login') === '1') setOnb(true); }} />;
  if (onb) return <Onboarding start={params.get('step')} onDone={() => setOnb(false)} />;
  if (sanction) return <Suspended kind={sanction} onDismiss={() => setSanction(null)} onLogout={() => { location.search = '?login=1'; }} />;
  if (!authed) return <Login onDone={() => setAuthed(true)} />;
  const Tab = { feed: window.Feed, search: window.Search, upload: window.Upload, notifications: window.Notifications, profile: window.Profile }[tab];
  const Overlay = { editPost: window.EditPost, restaurantDetail: window.RestaurantDetail, settings: window.Settings, editProfile: window.EditProfile, socialAccounts: window.SocialAccounts, notices: window.Notices, missions: window.Missions, support: window.Support, supportTickets: window.SupportTickets, supportTicketDetail: window.SupportTicketDetail, deleteAccount: window.DeleteAccount, terms: (p) => <LegalDoc {...p} kind="terms" />, privacy: (p) => <LegalDoc {...p} kind="privacy" />, userProfile: window.UserProfile, blockedUsers: window.BlockedUsers, follows: window.Follows, collectionDetail: window.CollectionDetail, collectionDetailOther: (p) => <CollectionDetail {...p} other />, hotPlaces: window.HotPlaces, missionDetail: window.MissionDetail, missionPosts: window.MissionPosts, missionRejection: window.MissionRejection, myPosts: window.MyPosts, savedPlaces: window.SavedPlaces, uploadMission: (p) => <Upload {...p} mission />, publicCollections: window.PublicCollections, followsFollowing: (p) => <Follows {...p} initialTab="팔로잉" /> }[screen];
  const hideNav = screen === 'editPost' || screen === 'restaurantDetail' || screen === 'collectionDetail' || screen === 'collectionDetailOther' || screen === 'editProfile' || screen === 'deleteAccount' || screen === 'support' || screen === 'supportTickets' || screen === 'supportTicketDetail' || screen === 'savedPlaces';
  return (
    <React.Fragment>
      {Overlay ? <Overlay nav={nav} msn={msn} setMsn={setMsn} {...screenProps} /> : <Tab nav={nav} msn={msn} setMsn={setMsn} />}
      {!hideNav && <div style={{ position: 'absolute', left: 0, right: 0, bottom: 0, zIndex: 20, pointerEvents: 'none' }}><div style={{ pointerEvents: 'auto' }}><BottomNav active={tab} badge={2} onChange={guardedNav} /></div></div>}
    </React.Fragment>
  );
}
ReactDOM.createRoot(document.getElementById('root')).render(<App />);
