From 3bee073a0b66cdf791adc346f91aa9961d592c94 Mon Sep 17 00:00:00 2001 From: Jordy McNab Date: Thu, 7 Nov 2024 16:57:05 -0800 Subject: [PATCH] Updates --- assets/{index-CNB12zCh.js => index-CJbxUUxN.js} | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/{index-CNB12zCh.js => index-CJbxUUxN.js} (98%) diff --git a/assets/index-CNB12zCh.js b/assets/index-CJbxUUxN.js similarity index 98% rename from assets/index-CNB12zCh.js rename to assets/index-CJbxUUxN.js index 9c0efe0..4a0c191 100644 --- a/assets/index-CNB12zCh.js +++ b/assets/index-CJbxUUxN.js @@ -261,7 +261,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Zap=createLucideIcon("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),ErrorState=({error:e,onRetry:a})=>jsxRuntimeExports.jsx("div",{className:"h-full flex flex-col items-center justify-center p-6 animate-fade-in fill-both",children:jsxRuntimeExports.jsxs("div",{className:"w-full max-w-md mx-auto text-center space-y-6",children:[jsxRuntimeExports.jsxs("div",{className:"relative inline-flex",children:[jsxRuntimeExports.jsx("div",{className:"absolute inset-0 bg-destructive/20 rounded-full blur-xl animate-pulse"}),jsxRuntimeExports.jsx("div",{className:"relative bg-background border border-border rounded-full p-4",children:jsxRuntimeExports.jsx(CircleAlert,{className:"w-12 h-12 text-destructive animate-fade-in"})})]}),jsxRuntimeExports.jsxs("div",{className:"space-y-2 animate-slide-in-from-bottom delay-1 fill-both",children:[jsxRuntimeExports.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"Something went wrong"}),jsxRuntimeExports.jsx("p",{className:"text-muted-foreground text-base max-w-sm mx-auto break-words",children:e})]}),a&&jsxRuntimeExports.jsx(Button,{onClick:a,className:"animate-slide-in-from-bottom delay-2 fill-both bg-secondary hover:bg-secondary/90 transition-colors duration-200",children:"Try Again"})]})}),LoadingState=({message:e="Loading..."})=>jsxRuntimeExports.jsx("div",{className:"h-full flex flex-col items-center justify-center p-6 animate-fade-in fill-both",children:jsxRuntimeExports.jsxs("div",{className:"w-full max-w-md mx-auto text-center space-y-6",children:[jsxRuntimeExports.jsxs("div",{className:"relative inline-flex",children:[jsxRuntimeExports.jsx("div",{className:"absolute inset-0 bg-secondary/20 rounded-full blur-xl animate-pulse"}),jsxRuntimeExports.jsxs("div",{className:"relative",children:[jsxRuntimeExports.jsx("div",{className:"w-16 h-16 rounded-full border-4 border-secondary/30 border-t-secondary animate-spin"}),jsxRuntimeExports.jsx("div",{className:"absolute inset-0 w-16 h-16 rounded-full border-4 border-primary/20 border-b-primary animate-spin-reverse"}),jsxRuntimeExports.jsx("div",{className:"absolute inset-0 m-auto w-3 h-3 bg-primary rounded-full animate-pulse"})]})]}),jsxRuntimeExports.jsx("div",{className:"space-y-2 animate-slide-in-from-bottom delay-1 fill-both",children:jsxRuntimeExports.jsx("p",{className:"text-base font-medium text-foreground",children:e})})]})}),OnboardingScreen=({setScreen:e})=>{const[a,o]=reactExports.useState(!1),[c,h]=reactExports.useState(""),[d,j]=reactExports.useState(null);reactExports.useEffect(()=>{et()},[]);const et=async()=>{var nt;o(!0),h("Starting the initialization of Capsule Telegram Mini App Demo..."),j(null);try{if(_default.ready(),!_default.initDataUnsafe.user){j("Error during initialization: User data not found");return}const at=(nt=_default.initDataUnsafe.user)==null?void 0:nt.username;if(!at){j("Error during initialization: Username not found");return}h(`User authenticated successfully: ${at}`),await new Promise(gt=>setTimeout(gt,1e3)),h(`Checking Telegram cloud storage for existing wallet data associated with user ${at}...`);const ot=await retrieveChunkedData("userShare",h,j);ot?(h("Existing wallet data found. Setting up your wallet..."),await capsuleClient.setUserShare(ot),h("Initialization complete. Redirecting to the app..."),await new Promise(gt=>setTimeout(gt,1e3)),e("home")):(h(`No existing wallet data found for user ${at}. Proceeding with new wallet creation...`),await new Promise(gt=>setTimeout(gt,1e3)))}catch(at){j(`Initialization error: ${at instanceof Error?at.message:String(at)}. Please try again or contact support if the issue persists.`),await new Promise(ot=>setTimeout(ot,1e3)),clearChunkedStorage(h,j).catch(ot=>{console.error("Failed to clear storage:",ot)})}finally{o(!1),h("")}},rt=async()=>{var nt;o(!0),h("Generating a new wallet..."),j(null);try{const at=(nt=_default.initDataUnsafe.user)==null?void 0:nt.username;if(!at){j("Error: Username not found. Unable to create wallet.");return}const ot=`${at+crypto.randomUUID().split("-")[0]}@test.usecapsule.com`;h("Creating wallet with pre-generated identifier...");const gt=await capsuleClient.createWalletPreGen(WalletType.EVM,ot);h(`Wallet created successfully. Address: ${gt.address||"N/A"}`),await new Promise(wt=>setTimeout(wt,1e3)),h("Retrieving user wallet share...");const bt=await capsuleClient.getUserShare()||"";await new Promise(wt=>setTimeout(wt,1e3)),h("Wallet setup complete. Redirecting to the app..."),await new Promise(wt=>setTimeout(wt,1e3)),storeWithChunking("userShare",bt,j).catch(wt=>{console.error("Failed to store wallet data:",wt)}),await new Promise(wt=>setTimeout(wt,1e3)),e("home")}catch(at){j(`Error: ${at instanceof Error?at.message:String(at)}. Please try again or contact support.`)}finally{o(!1),h("")}};return d?jsxRuntimeExports.jsx(ErrorState,{error:d}):a?jsxRuntimeExports.jsx(LoadingState,{message:c}):jsxRuntimeExports.jsxs("div",{className:"h-full flex flex-col justify-between p-6 bg-background animate-fade-in fill-both",children:[jsxRuntimeExports.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[jsxRuntimeExports.jsxs("div",{className:"relative mb-8",children:[jsxRuntimeExports.jsx("div",{className:"absolute inset-0 bg-primary/20 rounded-full blur-xl animate-pulse"}),jsxRuntimeExports.jsx("div",{className:"relative w-24 h-24 text-primary transition-all duration-300 hover:scale-105 hover:rotate-3",children:jsxRuntimeExports.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-full h-full animate-slide-in-from-top fill-both",children:[jsxRuntimeExports.jsx("path",{d:"M21 12V7H5a2 2 0 0 1 0-4h14v4"}),jsxRuntimeExports.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h16v-5"}),jsxRuntimeExports.jsx("path",{d:"M18 12a2 2 0 0 0 0 4h4v-4Z"})]})})]}),jsxRuntimeExports.jsxs("div",{className:"text-center space-y-4 mb-12 animate-slide-in-from-bottom delay-1 fill-both",children:[jsxRuntimeExports.jsx("h1",{className:"text-4xl font-bold text-foreground",children:"Beyond Web3 Authentication"}),jsxRuntimeExports.jsx("p",{className:"text-lg text-muted-foreground max-w-sm",children:"Cross-app wallets that work everywhere"})]}),jsxRuntimeExports.jsxs("div",{className:"w-full max-w-sm space-y-4 animate-slide-in-from-bottom delay-2 fill-both",children:[jsxRuntimeExports.jsx("div",{className:"group bg-secondary/5 border border-secondary/20 rounded-lg p-4 transition-all duration-200 hover:bg-secondary/10",children:jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntimeExports.jsx("div",{className:"p-2 rounded-full bg-secondary/10 text-secondary",children:jsxRuntimeExports.jsx(Shield,{className:"w-5 h-5"})}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"font-medium text-foreground",children:"Enterprise Security"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Industry-leading MPC protection"})]})]})}),jsxRuntimeExports.jsx("div",{className:"group bg-primary/5 border border-primary/20 rounded-lg p-4 transition-all duration-200 hover:bg-primary/10",children:jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntimeExports.jsx("div",{className:"p-2 rounded-full bg-primary/10 text-primary",children:jsxRuntimeExports.jsx(CircleCheckBig,{className:"w-5 h-5"})}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"font-medium text-foreground",children:"Universal Access"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Cross-app compatibility built in"})]})]})}),jsxRuntimeExports.jsx("div",{className:"group bg-accent/5 border border-accent/20 rounded-lg p-4 transition-all duration-200 hover:bg-accent/10",children:jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntimeExports.jsx("div",{className:"p-2 rounded-full bg-accent/10 text-accent",children:jsxRuntimeExports.jsx(Wallet,{className:"w-5 h-5"})}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"font-medium text-foreground",children:"Start Instantly"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Ready to use in seconds"})]})]})})]})]}),jsxRuntimeExports.jsx("div",{className:"animate-slide-in-from-bottom delay-4 fill-both",children:jsxRuntimeExports.jsx(Button,{size:"lg",onClick:rt,className:"w-full h-14 bg-primary text-primary-foreground hover:bg-primary/90 transition-all duration-300 group",children:jsxRuntimeExports.jsxs("span",{className:"flex items-center gap-2",children:["Create Wallet",jsxRuntimeExports.jsx(Wallet,{className:"w-5 h-5 transition-transform duration-300 group-hover:rotate-6"})]})})})]})};function composeEventHandlers(e,a,{checkForDefaultPrevented:o=!0}={}){return function(h){if(e==null||e(h),o===!1||!h.defaultPrevented)return a==null?void 0:a(h)}}function createContext2(e,a){const o=reactExports.createContext(a),c=d=>{const{children:j,...et}=d,rt=reactExports.useMemo(()=>et,Object.values(et));return jsxRuntimeExports.jsx(o.Provider,{value:rt,children:j})};c.displayName=e+"Provider";function h(d){const j=reactExports.useContext(o);if(j)return j;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${e}\``)}return[c,h]}function createContextScope(e,a=[]){let o=[];function c(d,j){const et=reactExports.createContext(j),rt=o.length;o=[...o,j];const nt=ot=>{var Et;const{scope:gt,children:bt,...wt}=ot,$t=((Et=gt==null?void 0:gt[e])==null?void 0:Et[rt])||et,St=reactExports.useMemo(()=>wt,Object.values(wt));return jsxRuntimeExports.jsx($t.Provider,{value:St,children:bt})};nt.displayName=d+"Provider";function at(ot,gt){var $t;const bt=(($t=gt==null?void 0:gt[e])==null?void 0:$t[rt])||et,wt=reactExports.useContext(bt);if(wt)return wt;if(j!==void 0)return j;throw new Error(`\`${ot}\` must be used within \`${d}\``)}return[nt,at]}const h=()=>{const d=o.map(j=>reactExports.createContext(j));return function(et){const rt=(et==null?void 0:et[e])||d;return reactExports.useMemo(()=>({[`__scope${e}`]:{...et,[e]:rt}}),[et,rt])}};return h.scopeName=e,[c,composeContextScopes(h,...a)]}function composeContextScopes(...e){const a=e[0];if(e.length===1)return a;const o=()=>{const c=e.map(h=>({useScope:h(),scopeName:h.scopeName}));return function(d){const j=c.reduce((et,{useScope:rt,scopeName:nt})=>{const ot=rt(d)[`__scope${nt}`];return{...et,...ot}},{});return reactExports.useMemo(()=>({[`__scope${a.scopeName}`]:j}),[j])}};return o.scopeName=a.scopeName,o}var useLayoutEffect2=globalThis!=null&&globalThis.document?reactExports.useLayoutEffect:()=>{},useReactId=React$1.useId||(()=>{}),count$1=0;function useId(e){const[a,o]=reactExports.useState(useReactId());return useLayoutEffect2(()=>{e||o(c=>c??String(count$1++))},[e]),e||(a?`radix-${a}`:"")}function useCallbackRef$1(e){const a=reactExports.useRef(e);return reactExports.useEffect(()=>{a.current=e}),reactExports.useMemo(()=>(...o)=>{var c;return(c=a.current)==null?void 0:c.call(a,...o)},[])}function useControllableState({prop:e,defaultProp:a,onChange:o=()=>{}}){const[c,h]=useUncontrolledState({defaultProp:a,onChange:o}),d=e!==void 0,j=d?e:c,et=useCallbackRef$1(o),rt=reactExports.useCallback(nt=>{if(d){const ot=typeof nt=="function"?nt(e):nt;ot!==e&&et(ot)}else h(nt)},[d,e,h,et]);return[j,rt]}function useUncontrolledState({defaultProp:e,onChange:a}){const o=reactExports.useState(e),[c]=o,h=reactExports.useRef(c),d=useCallbackRef$1(a);return reactExports.useEffect(()=>{h.current!==c&&(d(c),h.current=c)},[c,h,d]),o}var NODES=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Primitive$1=NODES.reduce((e,a)=>{const o=reactExports.forwardRef((c,h)=>{const{asChild:d,...j}=c,et=d?Slot:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),jsxRuntimeExports.jsx(et,{...j,ref:h})});return o.displayName=`Primitive.${a}`,{...e,[a]:o}},{});function dispatchDiscreteCustomEvent(e,a){e&&reactDomExports.flushSync(()=>e.dispatchEvent(a))}function useEscapeKeydown(e,a=globalThis==null?void 0:globalThis.document){const o=useCallbackRef$1(e);reactExports.useEffect(()=>{const c=h=>{h.key==="Escape"&&o(h)};return a.addEventListener("keydown",c,{capture:!0}),()=>a.removeEventListener("keydown",c,{capture:!0})},[o,a])}var DISMISSABLE_LAYER_NAME="DismissableLayer",CONTEXT_UPDATE="dismissableLayer.update",POINTER_DOWN_OUTSIDE="dismissableLayer.pointerDownOutside",FOCUS_OUTSIDE="dismissableLayer.focusOutside",originalBodyPointerEvents,DismissableLayerContext=reactExports.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),DismissableLayer=reactExports.forwardRef((e,a)=>{const{disableOutsidePointerEvents:o=!1,onEscapeKeyDown:c,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:j,onDismiss:et,...rt}=e,nt=reactExports.useContext(DismissableLayerContext),[at,ot]=reactExports.useState(null),gt=(at==null?void 0:at.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,bt]=reactExports.useState({}),wt=useComposedRefs(a,zt=>ot(zt)),$t=Array.from(nt.layers),[St]=[...nt.layersWithOutsidePointerEventsDisabled].slice(-1),Et=$t.indexOf(St),_t=at?$t.indexOf(at):-1,At=nt.layersWithOutsidePointerEventsDisabled.size>0,Bt=_t>=Et,kt=usePointerDownOutside(zt=>{const Xt=zt.target,Wt=[...nt.branches].some(ir=>ir.contains(Xt));!Bt||Wt||(h==null||h(zt),j==null||j(zt),zt.defaultPrevented||et==null||et())},gt),jt=useFocusOutside(zt=>{const Xt=zt.target;[...nt.branches].some(ir=>ir.contains(Xt))||(d==null||d(zt),j==null||j(zt),zt.defaultPrevented||et==null||et())},gt);return useEscapeKeydown(zt=>{_t===nt.layers.size-1&&(c==null||c(zt),!zt.defaultPrevented&&et&&(zt.preventDefault(),et()))},gt),reactExports.useEffect(()=>{if(at)return o&&(nt.layersWithOutsidePointerEventsDisabled.size===0&&(originalBodyPointerEvents=gt.body.style.pointerEvents,gt.body.style.pointerEvents="none"),nt.layersWithOutsidePointerEventsDisabled.add(at)),nt.layers.add(at),dispatchUpdate(),()=>{o&&nt.layersWithOutsidePointerEventsDisabled.size===1&&(gt.body.style.pointerEvents=originalBodyPointerEvents)}},[at,gt,o,nt]),reactExports.useEffect(()=>()=>{at&&(nt.layers.delete(at),nt.layersWithOutsidePointerEventsDisabled.delete(at),dispatchUpdate())},[at,nt]),reactExports.useEffect(()=>{const zt=()=>bt({});return document.addEventListener(CONTEXT_UPDATE,zt),()=>document.removeEventListener(CONTEXT_UPDATE,zt)},[]),jsxRuntimeExports.jsx(Primitive$1.div,{...rt,ref:wt,style:{pointerEvents:At?Bt?"auto":"none":void 0,...e.style},onFocusCapture:composeEventHandlers(e.onFocusCapture,jt.onFocusCapture),onBlurCapture:composeEventHandlers(e.onBlurCapture,jt.onBlurCapture),onPointerDownCapture:composeEventHandlers(e.onPointerDownCapture,kt.onPointerDownCapture)})});DismissableLayer.displayName=DISMISSABLE_LAYER_NAME;var BRANCH_NAME="DismissableLayerBranch",DismissableLayerBranch=reactExports.forwardRef((e,a)=>{const o=reactExports.useContext(DismissableLayerContext),c=reactExports.useRef(null),h=useComposedRefs(a,c);return reactExports.useEffect(()=>{const d=c.current;if(d)return o.branches.add(d),()=>{o.branches.delete(d)}},[o.branches]),jsxRuntimeExports.jsx(Primitive$1.div,{...e,ref:h})});DismissableLayerBranch.displayName=BRANCH_NAME;function usePointerDownOutside(e,a=globalThis==null?void 0:globalThis.document){const o=useCallbackRef$1(e),c=reactExports.useRef(!1),h=reactExports.useRef(()=>{});return reactExports.useEffect(()=>{const d=et=>{if(et.target&&!c.current){let rt=function(){handleAndDispatchCustomEvent(POINTER_DOWN_OUTSIDE,o,nt,{discrete:!0})};const nt={originalEvent:et};et.pointerType==="touch"?(a.removeEventListener("click",h.current),h.current=rt,a.addEventListener("click",h.current,{once:!0})):rt()}else a.removeEventListener("click",h.current);c.current=!1},j=window.setTimeout(()=>{a.addEventListener("pointerdown",d)},0);return()=>{window.clearTimeout(j),a.removeEventListener("pointerdown",d),a.removeEventListener("click",h.current)}},[a,o]),{onPointerDownCapture:()=>c.current=!0}}function useFocusOutside(e,a=globalThis==null?void 0:globalThis.document){const o=useCallbackRef$1(e),c=reactExports.useRef(!1);return reactExports.useEffect(()=>{const h=d=>{d.target&&!c.current&&handleAndDispatchCustomEvent(FOCUS_OUTSIDE,o,{originalEvent:d},{discrete:!1})};return a.addEventListener("focusin",h),()=>a.removeEventListener("focusin",h)},[a,o]),{onFocusCapture:()=>c.current=!0,onBlurCapture:()=>c.current=!1}}function dispatchUpdate(){const e=new CustomEvent(CONTEXT_UPDATE);document.dispatchEvent(e)}function handleAndDispatchCustomEvent(e,a,o,{discrete:c}){const h=o.originalEvent.target,d=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:o});a&&h.addEventListener(e,a,{once:!0}),c?dispatchDiscreteCustomEvent(h,d):h.dispatchEvent(d)}var AUTOFOCUS_ON_MOUNT="focusScope.autoFocusOnMount",AUTOFOCUS_ON_UNMOUNT="focusScope.autoFocusOnUnmount",EVENT_OPTIONS={bubbles:!1,cancelable:!0},FOCUS_SCOPE_NAME="FocusScope",FocusScope=reactExports.forwardRef((e,a)=>{const{loop:o=!1,trapped:c=!1,onMountAutoFocus:h,onUnmountAutoFocus:d,...j}=e,[et,rt]=reactExports.useState(null),nt=useCallbackRef$1(h),at=useCallbackRef$1(d),ot=reactExports.useRef(null),gt=useComposedRefs(a,$t=>rt($t)),bt=reactExports.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;reactExports.useEffect(()=>{if(c){let $t=function(At){if(bt.paused||!et)return;const Bt=At.target;et.contains(Bt)?ot.current=Bt:focus(ot.current,{select:!0})},St=function(At){if(bt.paused||!et)return;const Bt=At.relatedTarget;Bt!==null&&(et.contains(Bt)||focus(ot.current,{select:!0}))},Et=function(At){if(document.activeElement===document.body)for(const kt of At)kt.removedNodes.length>0&&focus(et)};document.addEventListener("focusin",$t),document.addEventListener("focusout",St);const _t=new MutationObserver(Et);return et&&_t.observe(et,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",$t),document.removeEventListener("focusout",St),_t.disconnect()}}},[c,et,bt.paused]),reactExports.useEffect(()=>{if(et){focusScopesStack.add(bt);const $t=document.activeElement;if(!et.contains($t)){const Et=new CustomEvent(AUTOFOCUS_ON_MOUNT,EVENT_OPTIONS);et.addEventListener(AUTOFOCUS_ON_MOUNT,nt),et.dispatchEvent(Et),Et.defaultPrevented||(focusFirst(removeLinks(getTabbableCandidates(et)),{select:!0}),document.activeElement===$t&&focus(et))}return()=>{et.removeEventListener(AUTOFOCUS_ON_MOUNT,nt),setTimeout(()=>{const Et=new CustomEvent(AUTOFOCUS_ON_UNMOUNT,EVENT_OPTIONS);et.addEventListener(AUTOFOCUS_ON_UNMOUNT,at),et.dispatchEvent(Et),Et.defaultPrevented||focus($t??document.body,{select:!0}),et.removeEventListener(AUTOFOCUS_ON_UNMOUNT,at),focusScopesStack.remove(bt)},0)}}},[et,nt,at,bt]);const wt=reactExports.useCallback($t=>{if(!o&&!c||bt.paused)return;const St=$t.key==="Tab"&&!$t.altKey&&!$t.ctrlKey&&!$t.metaKey,Et=document.activeElement;if(St&&Et){const _t=$t.currentTarget,[At,Bt]=getTabbableEdges(_t);At&&Bt?!$t.shiftKey&&Et===Bt?($t.preventDefault(),o&&focus(At,{select:!0})):$t.shiftKey&&Et===At&&($t.preventDefault(),o&&focus(Bt,{select:!0})):Et===_t&&$t.preventDefault()}},[o,c,bt.paused]);return jsxRuntimeExports.jsx(Primitive$1.div,{tabIndex:-1,...j,ref:gt,onKeyDown:wt})});FocusScope.displayName=FOCUS_SCOPE_NAME;function focusFirst(e,{select:a=!1}={}){const o=document.activeElement;for(const c of e)if(focus(c,{select:a}),document.activeElement!==o)return}function getTabbableEdges(e){const a=getTabbableCandidates(e),o=findVisible(a,e),c=findVisible(a.reverse(),e);return[o,c]}function getTabbableCandidates(e){const a=[],o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:c=>{const h=c.tagName==="INPUT"&&c.type==="hidden";return c.disabled||c.hidden||h?NodeFilter.FILTER_SKIP:c.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;o.nextNode();)a.push(o.currentNode);return a}function findVisible(e,a){for(const o of e)if(!isHidden(o,{upTo:a}))return o}function isHidden(e,{upTo:a}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(a!==void 0&&e===a)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function isSelectableInput(e){return e instanceof HTMLInputElement&&"select"in e}function focus(e,{select:a=!1}={}){if(e&&e.focus){const o=document.activeElement;e.focus({preventScroll:!0}),e!==o&&isSelectableInput(e)&&a&&e.select()}}var focusScopesStack=createFocusScopesStack();function createFocusScopesStack(){let e=[];return{add(a){const o=e[0];a!==o&&(o==null||o.pause()),e=arrayRemove(e,a),e.unshift(a)},remove(a){var o;e=arrayRemove(e,a),(o=e[0])==null||o.resume()}}}function arrayRemove(e,a){const o=[...e],c=o.indexOf(a);return c!==-1&&o.splice(c,1),o}function removeLinks(e){return e.filter(a=>a.tagName!=="A")}var PORTAL_NAME$1="Portal",Portal$1=reactExports.forwardRef((e,a)=>{var et;const{container:o,...c}=e,[h,d]=reactExports.useState(!1);useLayoutEffect2(()=>d(!0),[]);const j=o||h&&((et=globalThis==null?void 0:globalThis.document)==null?void 0:et.body);return j?ReactDOM.createPortal(jsxRuntimeExports.jsx(Primitive$1.div,{...c,ref:a}),j):null});Portal$1.displayName=PORTAL_NAME$1;function useStateMachine(e,a){return reactExports.useReducer((o,c)=>a[o][c]??o,e)}var Presence=e=>{const{present:a,children:o}=e,c=usePresence(a),h=typeof o=="function"?o({present:c.isPresent}):reactExports.Children.only(o),d=useComposedRefs(c.ref,getElementRef(h));return typeof o=="function"||c.isPresent?reactExports.cloneElement(h,{ref:d}):null};Presence.displayName="Presence";function usePresence(e){const[a,o]=reactExports.useState(),c=reactExports.useRef({}),h=reactExports.useRef(e),d=reactExports.useRef("none"),j=e?"mounted":"unmounted",[et,rt]=useStateMachine(j,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return reactExports.useEffect(()=>{const nt=getAnimationName(c.current);d.current=et==="mounted"?nt:"none"},[et]),useLayoutEffect2(()=>{const nt=c.current,at=h.current;if(at!==e){const gt=d.current,bt=getAnimationName(nt);e?rt("MOUNT"):bt==="none"||(nt==null?void 0:nt.display)==="none"?rt("UNMOUNT"):rt(at&>!==bt?"ANIMATION_OUT":"UNMOUNT"),h.current=e}},[e,rt]),useLayoutEffect2(()=>{if(a){let nt;const at=a.ownerDocument.defaultView??window,ot=bt=>{const $t=getAnimationName(c.current).includes(bt.animationName);if(bt.target===a&&$t&&(rt("ANIMATION_END"),!h.current)){const St=a.style.animationFillMode;a.style.animationFillMode="forwards",nt=at.setTimeout(()=>{a.style.animationFillMode==="forwards"&&(a.style.animationFillMode=St)})}},gt=bt=>{bt.target===a&&(d.current=getAnimationName(c.current))};return a.addEventListener("animationstart",gt),a.addEventListener("animationcancel",ot),a.addEventListener("animationend",ot),()=>{at.clearTimeout(nt),a.removeEventListener("animationstart",gt),a.removeEventListener("animationcancel",ot),a.removeEventListener("animationend",ot)}}else rt("ANIMATION_END")},[a,rt]),{isPresent:["mounted","unmountSuspended"].includes(et),ref:reactExports.useCallback(nt=>{nt&&(c.current=getComputedStyle(nt)),o(nt)},[])}}function getAnimationName(e){return(e==null?void 0:e.animationName)||"none"}function getElementRef(e){var c,h;let a=(c=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:c.get,o=a&&"isReactWarning"in a&&a.isReactWarning;return o?e.ref:(a=(h=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:h.get,o=a&&"isReactWarning"in a&&a.isReactWarning,o?e.props.ref:e.props.ref||e.ref)}var count=0;function useFocusGuards(){reactExports.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??createFocusGuard()),document.body.insertAdjacentElement("beforeend",e[1]??createFocusGuard()),count++,()=>{count===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(a=>a.remove()),count--}},[])}function createFocusGuard(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var __assign$1=function(){return __assign$1=Object.assign||function(a){for(var o,c=1,h=arguments.length;c"u")return zeroGap;var a=getOffset(e),o=document.documentElement.clientWidth,c=window.innerWidth;return{left:a[0],top:a[1],right:a[2],gap:Math.max(0,c-o+a[2]-a[0])}},Style=styleSingleton(),lockAttribute="data-scroll-locked",getStyles=function(e,a,o,c){var h=e.left,d=e.top,j=e.right,et=e.gap;return o===void 0&&(o="margin"),` + */const Zap=createLucideIcon("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),ErrorState=({error:e,onRetry:a})=>jsxRuntimeExports.jsx("div",{className:"h-full flex flex-col items-center justify-center p-6 animate-fade-in fill-both",children:jsxRuntimeExports.jsxs("div",{className:"w-full max-w-md mx-auto text-center space-y-6",children:[jsxRuntimeExports.jsxs("div",{className:"relative inline-flex",children:[jsxRuntimeExports.jsx("div",{className:"absolute inset-0 bg-destructive/20 rounded-full blur-xl animate-pulse"}),jsxRuntimeExports.jsx("div",{className:"relative bg-background border border-border rounded-full p-4",children:jsxRuntimeExports.jsx(CircleAlert,{className:"w-12 h-12 text-destructive animate-fade-in"})})]}),jsxRuntimeExports.jsxs("div",{className:"space-y-2 animate-slide-in-from-bottom delay-1 fill-both",children:[jsxRuntimeExports.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"Something went wrong"}),jsxRuntimeExports.jsx("p",{className:"text-muted-foreground text-base max-w-sm mx-auto break-words",children:e})]}),a&&jsxRuntimeExports.jsx(Button,{onClick:a,className:"animate-slide-in-from-bottom delay-2 fill-both bg-secondary hover:bg-secondary/90 transition-colors duration-200",children:"Try Again"})]})}),LoadingState=({message:e="Loading..."})=>jsxRuntimeExports.jsx("div",{className:"h-full flex flex-col items-center justify-center p-6 animate-fade-in fill-both",children:jsxRuntimeExports.jsxs("div",{className:"w-full max-w-md mx-auto text-center space-y-6",children:[jsxRuntimeExports.jsxs("div",{className:"relative inline-flex",children:[jsxRuntimeExports.jsx("div",{className:"absolute inset-0 bg-secondary/20 rounded-full blur-xl animate-pulse"}),jsxRuntimeExports.jsxs("div",{className:"relative",children:[jsxRuntimeExports.jsx("div",{className:"w-16 h-16 rounded-full border-4 border-secondary/30 border-t-secondary animate-spin"}),jsxRuntimeExports.jsx("div",{className:"absolute inset-0 w-16 h-16 rounded-full border-4 border-primary/20 border-b-primary animate-spin-reverse"}),jsxRuntimeExports.jsx("div",{className:"absolute inset-0 m-auto w-3 h-3 bg-primary rounded-full animate-pulse"})]})]}),jsxRuntimeExports.jsx("div",{className:"space-y-2 animate-slide-in-from-bottom delay-1 fill-both",children:jsxRuntimeExports.jsx("p",{className:"text-base font-medium text-foreground",children:e})})]})}),OnboardingScreen=({setScreen:e})=>{const[a,o]=reactExports.useState(!1),[c,h]=reactExports.useState(""),[d,j]=reactExports.useState(null);reactExports.useEffect(()=>{et()},[]);const et=async()=>{var nt;o(!0),h("Starting the initialization of Capsule Telegram Mini App Demo..."),j(null);try{if(_default.ready(),!_default.initDataUnsafe.user){j("Error during initialization: User data not found");return}const at=(nt=_default.initDataUnsafe.user)==null?void 0:nt.username;if(!at){j("Error during initialization: Username not found");return}h(`User authenticated successfully: ${at}`),await new Promise(gt=>setTimeout(gt,1e3)),h(`Checking Telegram cloud storage for existing wallet data associated with user ${at}...`),await new Promise(gt=>setTimeout(gt,1e3));const ot=await retrieveChunkedData("userShare",h,j);ot?(h("Existing wallet data found. Setting up your wallet..."),await capsuleClient.setUserShare(ot),h("Initialization complete. Redirecting to the app..."),await new Promise(gt=>setTimeout(gt,1e3)),e("home")):(h(`No existing wallet data found for user ${at}. Proceeding with new wallet creation...`),await new Promise(gt=>setTimeout(gt,1e3)))}catch(at){j(`Initialization error: ${at instanceof Error?at.message:String(at)}. Please try again or contact support if the issue persists.`),await new Promise(ot=>setTimeout(ot,1e3)),j("Clearing storage and retrying initialization..."),await new Promise(ot=>setTimeout(ot,1e3)),clearChunkedStorage(h,j).catch(ot=>{console.error("Failed to clear storage:",ot)}),j("Storage cleared. Retry initialization...")}finally{o(!1),h("")}},rt=async()=>{var nt;o(!0),h("Generating a new wallet..."),j(null);try{const at=(nt=_default.initDataUnsafe.user)==null?void 0:nt.username;if(!at){j("Error: Username not found. Unable to create wallet.");return}const ot=`${at+crypto.randomUUID().split("-")[0]}@test.usecapsule.com`;h("Creating wallet with pre-generated identifier...");const gt=await capsuleClient.createWalletPreGen(WalletType.EVM,ot);h(`Wallet created successfully. Address: ${gt.address||"N/A"}`),await new Promise(wt=>setTimeout(wt,1e3)),h("Retrieving user wallet share...");const bt=await capsuleClient.getUserShare()||"";await new Promise(wt=>setTimeout(wt,1e3)),h("Wallet setup complete. Redirecting to the app..."),await new Promise(wt=>setTimeout(wt,1e3)),storeWithChunking("userShare",bt,j).catch(wt=>{console.error("Failed to store wallet data:",wt)}),await new Promise(wt=>setTimeout(wt,1e3)),e("home")}catch(at){j(`Error: ${at instanceof Error?at.message:String(at)}. Please try again or contact support.`)}finally{o(!1),h("")}};return d?jsxRuntimeExports.jsx(ErrorState,{error:d,onRetry:et}):a?jsxRuntimeExports.jsx(LoadingState,{message:c}):jsxRuntimeExports.jsxs("div",{className:"h-full flex flex-col justify-between p-6 bg-background animate-fade-in fill-both",children:[jsxRuntimeExports.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[jsxRuntimeExports.jsxs("div",{className:"relative mb-8",children:[jsxRuntimeExports.jsx("div",{className:"absolute inset-0 bg-primary/20 rounded-full blur-xl animate-pulse"}),jsxRuntimeExports.jsx("div",{className:"relative w-24 h-24 text-primary transition-all duration-300 hover:scale-105 hover:rotate-3",children:jsxRuntimeExports.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-full h-full animate-slide-in-from-top fill-both",children:[jsxRuntimeExports.jsx("path",{d:"M21 12V7H5a2 2 0 0 1 0-4h14v4"}),jsxRuntimeExports.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h16v-5"}),jsxRuntimeExports.jsx("path",{d:"M18 12a2 2 0 0 0 0 4h4v-4Z"})]})})]}),jsxRuntimeExports.jsxs("div",{className:"text-center space-y-4 mb-12 animate-slide-in-from-bottom delay-1 fill-both",children:[jsxRuntimeExports.jsx("h1",{className:"text-4xl font-bold text-foreground",children:"Beyond Web3 Authentication"}),jsxRuntimeExports.jsx("p",{className:"text-lg text-muted-foreground max-w-sm",children:"Cross-app wallets that work everywhere"})]}),jsxRuntimeExports.jsxs("div",{className:"w-full max-w-sm space-y-4 animate-slide-in-from-bottom delay-2 fill-both",children:[jsxRuntimeExports.jsx("div",{className:"group bg-secondary/5 border border-secondary/20 rounded-lg p-4 transition-all duration-200 hover:bg-secondary/10",children:jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntimeExports.jsx("div",{className:"p-2 rounded-full bg-secondary/10 text-secondary",children:jsxRuntimeExports.jsx(Shield,{className:"w-5 h-5"})}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"font-medium text-foreground",children:"Enterprise Security"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Industry-leading MPC protection"})]})]})}),jsxRuntimeExports.jsx("div",{className:"group bg-primary/5 border border-primary/20 rounded-lg p-4 transition-all duration-200 hover:bg-primary/10",children:jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntimeExports.jsx("div",{className:"p-2 rounded-full bg-primary/10 text-primary",children:jsxRuntimeExports.jsx(CircleCheckBig,{className:"w-5 h-5"})}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"font-medium text-foreground",children:"Universal Access"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Cross-app compatibility built in"})]})]})}),jsxRuntimeExports.jsx("div",{className:"group bg-accent/5 border border-accent/20 rounded-lg p-4 transition-all duration-200 hover:bg-accent/10",children:jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntimeExports.jsx("div",{className:"p-2 rounded-full bg-accent/10 text-accent",children:jsxRuntimeExports.jsx(Wallet,{className:"w-5 h-5"})}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"font-medium text-foreground",children:"Start Instantly"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Ready to use in seconds"})]})]})})]})]}),jsxRuntimeExports.jsx("div",{className:"animate-slide-in-from-bottom delay-4 fill-both",children:jsxRuntimeExports.jsx(Button,{size:"lg",onClick:rt,className:"w-full h-14 bg-primary text-primary-foreground hover:bg-primary/90 transition-all duration-300 group",children:jsxRuntimeExports.jsxs("span",{className:"flex items-center gap-2",children:["Create Wallet",jsxRuntimeExports.jsx(Wallet,{className:"w-5 h-5 transition-transform duration-300 group-hover:rotate-6"})]})})})]})};function composeEventHandlers(e,a,{checkForDefaultPrevented:o=!0}={}){return function(h){if(e==null||e(h),o===!1||!h.defaultPrevented)return a==null?void 0:a(h)}}function createContext2(e,a){const o=reactExports.createContext(a),c=d=>{const{children:j,...et}=d,rt=reactExports.useMemo(()=>et,Object.values(et));return jsxRuntimeExports.jsx(o.Provider,{value:rt,children:j})};c.displayName=e+"Provider";function h(d){const j=reactExports.useContext(o);if(j)return j;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${e}\``)}return[c,h]}function createContextScope(e,a=[]){let o=[];function c(d,j){const et=reactExports.createContext(j),rt=o.length;o=[...o,j];const nt=ot=>{var Et;const{scope:gt,children:bt,...wt}=ot,$t=((Et=gt==null?void 0:gt[e])==null?void 0:Et[rt])||et,St=reactExports.useMemo(()=>wt,Object.values(wt));return jsxRuntimeExports.jsx($t.Provider,{value:St,children:bt})};nt.displayName=d+"Provider";function at(ot,gt){var $t;const bt=(($t=gt==null?void 0:gt[e])==null?void 0:$t[rt])||et,wt=reactExports.useContext(bt);if(wt)return wt;if(j!==void 0)return j;throw new Error(`\`${ot}\` must be used within \`${d}\``)}return[nt,at]}const h=()=>{const d=o.map(j=>reactExports.createContext(j));return function(et){const rt=(et==null?void 0:et[e])||d;return reactExports.useMemo(()=>({[`__scope${e}`]:{...et,[e]:rt}}),[et,rt])}};return h.scopeName=e,[c,composeContextScopes(h,...a)]}function composeContextScopes(...e){const a=e[0];if(e.length===1)return a;const o=()=>{const c=e.map(h=>({useScope:h(),scopeName:h.scopeName}));return function(d){const j=c.reduce((et,{useScope:rt,scopeName:nt})=>{const ot=rt(d)[`__scope${nt}`];return{...et,...ot}},{});return reactExports.useMemo(()=>({[`__scope${a.scopeName}`]:j}),[j])}};return o.scopeName=a.scopeName,o}var useLayoutEffect2=globalThis!=null&&globalThis.document?reactExports.useLayoutEffect:()=>{},useReactId=React$1.useId||(()=>{}),count$1=0;function useId(e){const[a,o]=reactExports.useState(useReactId());return useLayoutEffect2(()=>{e||o(c=>c??String(count$1++))},[e]),e||(a?`radix-${a}`:"")}function useCallbackRef$1(e){const a=reactExports.useRef(e);return reactExports.useEffect(()=>{a.current=e}),reactExports.useMemo(()=>(...o)=>{var c;return(c=a.current)==null?void 0:c.call(a,...o)},[])}function useControllableState({prop:e,defaultProp:a,onChange:o=()=>{}}){const[c,h]=useUncontrolledState({defaultProp:a,onChange:o}),d=e!==void 0,j=d?e:c,et=useCallbackRef$1(o),rt=reactExports.useCallback(nt=>{if(d){const ot=typeof nt=="function"?nt(e):nt;ot!==e&&et(ot)}else h(nt)},[d,e,h,et]);return[j,rt]}function useUncontrolledState({defaultProp:e,onChange:a}){const o=reactExports.useState(e),[c]=o,h=reactExports.useRef(c),d=useCallbackRef$1(a);return reactExports.useEffect(()=>{h.current!==c&&(d(c),h.current=c)},[c,h,d]),o}var NODES=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Primitive$1=NODES.reduce((e,a)=>{const o=reactExports.forwardRef((c,h)=>{const{asChild:d,...j}=c,et=d?Slot:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),jsxRuntimeExports.jsx(et,{...j,ref:h})});return o.displayName=`Primitive.${a}`,{...e,[a]:o}},{});function dispatchDiscreteCustomEvent(e,a){e&&reactDomExports.flushSync(()=>e.dispatchEvent(a))}function useEscapeKeydown(e,a=globalThis==null?void 0:globalThis.document){const o=useCallbackRef$1(e);reactExports.useEffect(()=>{const c=h=>{h.key==="Escape"&&o(h)};return a.addEventListener("keydown",c,{capture:!0}),()=>a.removeEventListener("keydown",c,{capture:!0})},[o,a])}var DISMISSABLE_LAYER_NAME="DismissableLayer",CONTEXT_UPDATE="dismissableLayer.update",POINTER_DOWN_OUTSIDE="dismissableLayer.pointerDownOutside",FOCUS_OUTSIDE="dismissableLayer.focusOutside",originalBodyPointerEvents,DismissableLayerContext=reactExports.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),DismissableLayer=reactExports.forwardRef((e,a)=>{const{disableOutsidePointerEvents:o=!1,onEscapeKeyDown:c,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:j,onDismiss:et,...rt}=e,nt=reactExports.useContext(DismissableLayerContext),[at,ot]=reactExports.useState(null),gt=(at==null?void 0:at.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,bt]=reactExports.useState({}),wt=useComposedRefs(a,zt=>ot(zt)),$t=Array.from(nt.layers),[St]=[...nt.layersWithOutsidePointerEventsDisabled].slice(-1),Et=$t.indexOf(St),_t=at?$t.indexOf(at):-1,At=nt.layersWithOutsidePointerEventsDisabled.size>0,Bt=_t>=Et,kt=usePointerDownOutside(zt=>{const Xt=zt.target,Wt=[...nt.branches].some(ir=>ir.contains(Xt));!Bt||Wt||(h==null||h(zt),j==null||j(zt),zt.defaultPrevented||et==null||et())},gt),jt=useFocusOutside(zt=>{const Xt=zt.target;[...nt.branches].some(ir=>ir.contains(Xt))||(d==null||d(zt),j==null||j(zt),zt.defaultPrevented||et==null||et())},gt);return useEscapeKeydown(zt=>{_t===nt.layers.size-1&&(c==null||c(zt),!zt.defaultPrevented&&et&&(zt.preventDefault(),et()))},gt),reactExports.useEffect(()=>{if(at)return o&&(nt.layersWithOutsidePointerEventsDisabled.size===0&&(originalBodyPointerEvents=gt.body.style.pointerEvents,gt.body.style.pointerEvents="none"),nt.layersWithOutsidePointerEventsDisabled.add(at)),nt.layers.add(at),dispatchUpdate(),()=>{o&&nt.layersWithOutsidePointerEventsDisabled.size===1&&(gt.body.style.pointerEvents=originalBodyPointerEvents)}},[at,gt,o,nt]),reactExports.useEffect(()=>()=>{at&&(nt.layers.delete(at),nt.layersWithOutsidePointerEventsDisabled.delete(at),dispatchUpdate())},[at,nt]),reactExports.useEffect(()=>{const zt=()=>bt({});return document.addEventListener(CONTEXT_UPDATE,zt),()=>document.removeEventListener(CONTEXT_UPDATE,zt)},[]),jsxRuntimeExports.jsx(Primitive$1.div,{...rt,ref:wt,style:{pointerEvents:At?Bt?"auto":"none":void 0,...e.style},onFocusCapture:composeEventHandlers(e.onFocusCapture,jt.onFocusCapture),onBlurCapture:composeEventHandlers(e.onBlurCapture,jt.onBlurCapture),onPointerDownCapture:composeEventHandlers(e.onPointerDownCapture,kt.onPointerDownCapture)})});DismissableLayer.displayName=DISMISSABLE_LAYER_NAME;var BRANCH_NAME="DismissableLayerBranch",DismissableLayerBranch=reactExports.forwardRef((e,a)=>{const o=reactExports.useContext(DismissableLayerContext),c=reactExports.useRef(null),h=useComposedRefs(a,c);return reactExports.useEffect(()=>{const d=c.current;if(d)return o.branches.add(d),()=>{o.branches.delete(d)}},[o.branches]),jsxRuntimeExports.jsx(Primitive$1.div,{...e,ref:h})});DismissableLayerBranch.displayName=BRANCH_NAME;function usePointerDownOutside(e,a=globalThis==null?void 0:globalThis.document){const o=useCallbackRef$1(e),c=reactExports.useRef(!1),h=reactExports.useRef(()=>{});return reactExports.useEffect(()=>{const d=et=>{if(et.target&&!c.current){let rt=function(){handleAndDispatchCustomEvent(POINTER_DOWN_OUTSIDE,o,nt,{discrete:!0})};const nt={originalEvent:et};et.pointerType==="touch"?(a.removeEventListener("click",h.current),h.current=rt,a.addEventListener("click",h.current,{once:!0})):rt()}else a.removeEventListener("click",h.current);c.current=!1},j=window.setTimeout(()=>{a.addEventListener("pointerdown",d)},0);return()=>{window.clearTimeout(j),a.removeEventListener("pointerdown",d),a.removeEventListener("click",h.current)}},[a,o]),{onPointerDownCapture:()=>c.current=!0}}function useFocusOutside(e,a=globalThis==null?void 0:globalThis.document){const o=useCallbackRef$1(e),c=reactExports.useRef(!1);return reactExports.useEffect(()=>{const h=d=>{d.target&&!c.current&&handleAndDispatchCustomEvent(FOCUS_OUTSIDE,o,{originalEvent:d},{discrete:!1})};return a.addEventListener("focusin",h),()=>a.removeEventListener("focusin",h)},[a,o]),{onFocusCapture:()=>c.current=!0,onBlurCapture:()=>c.current=!1}}function dispatchUpdate(){const e=new CustomEvent(CONTEXT_UPDATE);document.dispatchEvent(e)}function handleAndDispatchCustomEvent(e,a,o,{discrete:c}){const h=o.originalEvent.target,d=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:o});a&&h.addEventListener(e,a,{once:!0}),c?dispatchDiscreteCustomEvent(h,d):h.dispatchEvent(d)}var AUTOFOCUS_ON_MOUNT="focusScope.autoFocusOnMount",AUTOFOCUS_ON_UNMOUNT="focusScope.autoFocusOnUnmount",EVENT_OPTIONS={bubbles:!1,cancelable:!0},FOCUS_SCOPE_NAME="FocusScope",FocusScope=reactExports.forwardRef((e,a)=>{const{loop:o=!1,trapped:c=!1,onMountAutoFocus:h,onUnmountAutoFocus:d,...j}=e,[et,rt]=reactExports.useState(null),nt=useCallbackRef$1(h),at=useCallbackRef$1(d),ot=reactExports.useRef(null),gt=useComposedRefs(a,$t=>rt($t)),bt=reactExports.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;reactExports.useEffect(()=>{if(c){let $t=function(At){if(bt.paused||!et)return;const Bt=At.target;et.contains(Bt)?ot.current=Bt:focus(ot.current,{select:!0})},St=function(At){if(bt.paused||!et)return;const Bt=At.relatedTarget;Bt!==null&&(et.contains(Bt)||focus(ot.current,{select:!0}))},Et=function(At){if(document.activeElement===document.body)for(const kt of At)kt.removedNodes.length>0&&focus(et)};document.addEventListener("focusin",$t),document.addEventListener("focusout",St);const _t=new MutationObserver(Et);return et&&_t.observe(et,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",$t),document.removeEventListener("focusout",St),_t.disconnect()}}},[c,et,bt.paused]),reactExports.useEffect(()=>{if(et){focusScopesStack.add(bt);const $t=document.activeElement;if(!et.contains($t)){const Et=new CustomEvent(AUTOFOCUS_ON_MOUNT,EVENT_OPTIONS);et.addEventListener(AUTOFOCUS_ON_MOUNT,nt),et.dispatchEvent(Et),Et.defaultPrevented||(focusFirst(removeLinks(getTabbableCandidates(et)),{select:!0}),document.activeElement===$t&&focus(et))}return()=>{et.removeEventListener(AUTOFOCUS_ON_MOUNT,nt),setTimeout(()=>{const Et=new CustomEvent(AUTOFOCUS_ON_UNMOUNT,EVENT_OPTIONS);et.addEventListener(AUTOFOCUS_ON_UNMOUNT,at),et.dispatchEvent(Et),Et.defaultPrevented||focus($t??document.body,{select:!0}),et.removeEventListener(AUTOFOCUS_ON_UNMOUNT,at),focusScopesStack.remove(bt)},0)}}},[et,nt,at,bt]);const wt=reactExports.useCallback($t=>{if(!o&&!c||bt.paused)return;const St=$t.key==="Tab"&&!$t.altKey&&!$t.ctrlKey&&!$t.metaKey,Et=document.activeElement;if(St&&Et){const _t=$t.currentTarget,[At,Bt]=getTabbableEdges(_t);At&&Bt?!$t.shiftKey&&Et===Bt?($t.preventDefault(),o&&focus(At,{select:!0})):$t.shiftKey&&Et===At&&($t.preventDefault(),o&&focus(Bt,{select:!0})):Et===_t&&$t.preventDefault()}},[o,c,bt.paused]);return jsxRuntimeExports.jsx(Primitive$1.div,{tabIndex:-1,...j,ref:gt,onKeyDown:wt})});FocusScope.displayName=FOCUS_SCOPE_NAME;function focusFirst(e,{select:a=!1}={}){const o=document.activeElement;for(const c of e)if(focus(c,{select:a}),document.activeElement!==o)return}function getTabbableEdges(e){const a=getTabbableCandidates(e),o=findVisible(a,e),c=findVisible(a.reverse(),e);return[o,c]}function getTabbableCandidates(e){const a=[],o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:c=>{const h=c.tagName==="INPUT"&&c.type==="hidden";return c.disabled||c.hidden||h?NodeFilter.FILTER_SKIP:c.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;o.nextNode();)a.push(o.currentNode);return a}function findVisible(e,a){for(const o of e)if(!isHidden(o,{upTo:a}))return o}function isHidden(e,{upTo:a}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(a!==void 0&&e===a)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function isSelectableInput(e){return e instanceof HTMLInputElement&&"select"in e}function focus(e,{select:a=!1}={}){if(e&&e.focus){const o=document.activeElement;e.focus({preventScroll:!0}),e!==o&&isSelectableInput(e)&&a&&e.select()}}var focusScopesStack=createFocusScopesStack();function createFocusScopesStack(){let e=[];return{add(a){const o=e[0];a!==o&&(o==null||o.pause()),e=arrayRemove(e,a),e.unshift(a)},remove(a){var o;e=arrayRemove(e,a),(o=e[0])==null||o.resume()}}}function arrayRemove(e,a){const o=[...e],c=o.indexOf(a);return c!==-1&&o.splice(c,1),o}function removeLinks(e){return e.filter(a=>a.tagName!=="A")}var PORTAL_NAME$1="Portal",Portal$1=reactExports.forwardRef((e,a)=>{var et;const{container:o,...c}=e,[h,d]=reactExports.useState(!1);useLayoutEffect2(()=>d(!0),[]);const j=o||h&&((et=globalThis==null?void 0:globalThis.document)==null?void 0:et.body);return j?ReactDOM.createPortal(jsxRuntimeExports.jsx(Primitive$1.div,{...c,ref:a}),j):null});Portal$1.displayName=PORTAL_NAME$1;function useStateMachine(e,a){return reactExports.useReducer((o,c)=>a[o][c]??o,e)}var Presence=e=>{const{present:a,children:o}=e,c=usePresence(a),h=typeof o=="function"?o({present:c.isPresent}):reactExports.Children.only(o),d=useComposedRefs(c.ref,getElementRef(h));return typeof o=="function"||c.isPresent?reactExports.cloneElement(h,{ref:d}):null};Presence.displayName="Presence";function usePresence(e){const[a,o]=reactExports.useState(),c=reactExports.useRef({}),h=reactExports.useRef(e),d=reactExports.useRef("none"),j=e?"mounted":"unmounted",[et,rt]=useStateMachine(j,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return reactExports.useEffect(()=>{const nt=getAnimationName(c.current);d.current=et==="mounted"?nt:"none"},[et]),useLayoutEffect2(()=>{const nt=c.current,at=h.current;if(at!==e){const gt=d.current,bt=getAnimationName(nt);e?rt("MOUNT"):bt==="none"||(nt==null?void 0:nt.display)==="none"?rt("UNMOUNT"):rt(at&>!==bt?"ANIMATION_OUT":"UNMOUNT"),h.current=e}},[e,rt]),useLayoutEffect2(()=>{if(a){let nt;const at=a.ownerDocument.defaultView??window,ot=bt=>{const $t=getAnimationName(c.current).includes(bt.animationName);if(bt.target===a&&$t&&(rt("ANIMATION_END"),!h.current)){const St=a.style.animationFillMode;a.style.animationFillMode="forwards",nt=at.setTimeout(()=>{a.style.animationFillMode==="forwards"&&(a.style.animationFillMode=St)})}},gt=bt=>{bt.target===a&&(d.current=getAnimationName(c.current))};return a.addEventListener("animationstart",gt),a.addEventListener("animationcancel",ot),a.addEventListener("animationend",ot),()=>{at.clearTimeout(nt),a.removeEventListener("animationstart",gt),a.removeEventListener("animationcancel",ot),a.removeEventListener("animationend",ot)}}else rt("ANIMATION_END")},[a,rt]),{isPresent:["mounted","unmountSuspended"].includes(et),ref:reactExports.useCallback(nt=>{nt&&(c.current=getComputedStyle(nt)),o(nt)},[])}}function getAnimationName(e){return(e==null?void 0:e.animationName)||"none"}function getElementRef(e){var c,h;let a=(c=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:c.get,o=a&&"isReactWarning"in a&&a.isReactWarning;return o?e.ref:(a=(h=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:h.get,o=a&&"isReactWarning"in a&&a.isReactWarning,o?e.props.ref:e.props.ref||e.ref)}var count=0;function useFocusGuards(){reactExports.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??createFocusGuard()),document.body.insertAdjacentElement("beforeend",e[1]??createFocusGuard()),count++,()=>{count===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(a=>a.remove()),count--}},[])}function createFocusGuard(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var __assign$1=function(){return __assign$1=Object.assign||function(a){for(var o,c=1,h=arguments.length;c"u")return zeroGap;var a=getOffset(e),o=document.documentElement.clientWidth,c=window.innerWidth;return{left:a[0],top:a[1],right:a[2],gap:Math.max(0,c-o+a[2]-a[0])}},Style=styleSingleton(),lockAttribute="data-scroll-locked",getStyles=function(e,a,o,c){var h=e.left,d=e.top,j=e.right,et=e.gap;return o===void 0&&(o="margin"),` .`.concat(noScrollbarsClassName,` { overflow: hidden `).concat(c,`; padding-right: `).concat(et,"px ").concat(c,`; diff --git a/index.html b/index.html index 90d74f3..9145131 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@ content="width=device-width, initial-scale=1.0" /> Capsule Telegram Mini App - +