@latticexyz/entrykit 2.2.18-88af9325733387259f29dfdafd2fdbc23f2ab499 → 2.2.18-8d0ce55e964e646a1c804c401df01c4deb866f30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- function Xt(e){return{...e,appName:e.appName??document.title,appIcon:e.appIcon??document.querySelector("link[rel~='icon']")?.getAttribute("href")??"/favico.ico"}}import{Root as Tr,DialogPortal as Ir,DialogContent as Mr}from"@radix-ui/react-dialog";import{forwardRef as Sr,useEffect as Pr,useRef as Ye,useState as _e}from"react";import Ar from"react-dom";var Te=`*, ::before, ::after {
1
+ function Gt(e){return{...e,appName:e.appName??document.title,appIcon:e.appIcon??document.querySelector("link[rel~='icon']")?.getAttribute("href")??"/favico.ico"}}import{Root as ir,DialogPortal as sr,DialogContent as lr}from"@radix-ui/react-dialog";import{forwardRef as Jt,useEffect as er,useRef as Re,useState as Ee}from"react";import tr from"react-dom";var Ce=`*, ::before, ::after {
2
2
  --tw-border-spacing-x: 0;
3
3
  --tw-border-spacing-y: 0;
4
4
  --tw-translate-x: 0;
@@ -569,22 +569,10 @@ video {
569
569
  position: relative;
570
570
  }
571
571
 
572
- .sticky {
573
- position: sticky;
574
- }
575
-
576
572
  .inset-0 {
577
573
  inset: 0px;
578
574
  }
579
575
 
580
- .bottom-0 {
581
- bottom: 0px;
582
- }
583
-
584
- .left-0 {
585
- left: 0px;
586
- }
587
-
588
576
  .right-0 {
589
577
  right: 0px;
590
578
  }
@@ -633,10 +621,6 @@ video {
633
621
  margin-left: -0.75rem;
634
622
  }
635
623
 
636
- .-mt-2 {
637
- margin-top: -0.5rem;
638
- }
639
-
640
624
  .block {
641
625
  display: block;
642
626
  }
@@ -665,14 +649,6 @@ video {
665
649
  display: contents;
666
650
  }
667
651
 
668
- .hidden {
669
- display: none;
670
- }
671
-
672
- .h-12 {
673
- height: 3rem;
674
- }
675
-
676
652
  .h-16 {
677
653
  height: 4rem;
678
654
  }
@@ -685,10 +661,6 @@ video {
685
661
  height: 1.5rem;
686
662
  }
687
663
 
688
- .h-64 {
689
- height: 16rem;
690
- }
691
-
692
664
  .h-\\[1\\.25em\\] {
693
665
  height: 1.25em;
694
666
  }
@@ -701,8 +673,8 @@ video {
701
673
  height: 100%;
702
674
  }
703
675
 
704
- .max-h-full {
705
- max-height: 100%;
676
+ .max-h-32 {
677
+ max-height: 8rem;
706
678
  }
707
679
 
708
680
  .min-h-\\[22rem\\] {
@@ -717,10 +689,6 @@ video {
717
689
  width: 4rem;
718
690
  }
719
691
 
720
- .w-24 {
721
- width: 6rem;
722
- }
723
-
724
692
  .w-28 {
725
693
  width: 7rem;
726
694
  }
@@ -765,26 +733,11 @@ video {
765
733
  flex-grow: 1;
766
734
  }
767
735
 
768
- .-translate-y-2 {
769
- --tw-translate-y: -0.5rem;
770
- transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
771
- }
772
-
773
- .-translate-y-4 {
774
- --tw-translate-y: -1rem;
775
- transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
776
- }
777
-
778
736
  .translate-x-2 {
779
737
  --tw-translate-x: 0.5rem;
780
738
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
781
739
  }
782
740
 
783
- .translate-y-0 {
784
- --tw-translate-y: 0px;
785
- transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
786
- }
787
-
788
741
  .scale-100 {
789
742
  --tw-scale-x: 1;
790
743
  --tw-scale-y: 1;
@@ -864,18 +817,17 @@ video {
864
817
  gap: 1.5rem;
865
818
  }
866
819
 
867
- .space-y-6 > :not([hidden]) ~ :not([hidden]) {
868
- --tw-space-y-reverse: 0;
869
- margin-top: calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));
870
- margin-bottom: calc(1.5rem * var(--tw-space-y-reverse));
871
- }
872
-
873
820
  .divide-y > :not([hidden]) ~ :not([hidden]) {
874
821
  --tw-divide-y-reverse: 0;
875
822
  border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
876
823
  border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
877
824
  }
878
825
 
826
+ .divide-neutral-700 > :not([hidden]) ~ :not([hidden]) {
827
+ --tw-divide-opacity: 1;
828
+ border-color: rgb(64 64 64 / var(--tw-divide-opacity));
829
+ }
830
+
879
831
  .divide-neutral-800 > :not([hidden]) ~ :not([hidden]) {
880
832
  --tw-divide-opacity: 1;
881
833
  border-color: rgb(38 38 38 / var(--tw-divide-opacity));
@@ -885,20 +837,24 @@ video {
885
837
  align-self: auto;
886
838
  }
887
839
 
840
+ .self-end {
841
+ align-self: flex-end;
842
+ }
843
+
888
844
  .self-center {
889
845
  align-self: center;
890
846
  }
891
847
 
892
- .overflow-auto {
893
- overflow: auto;
848
+ .overflow-y-scroll {
849
+ overflow-y: scroll;
894
850
  }
895
851
 
896
- .overflow-clip {
897
- overflow: clip;
852
+ .whitespace-break-spaces {
853
+ white-space: break-spaces;
898
854
  }
899
855
 
900
- .whitespace-pre-wrap {
901
- white-space: pre-wrap;
856
+ .break-all {
857
+ word-break: break-all;
902
858
  }
903
859
 
904
860
  .rounded-full {
@@ -913,11 +869,20 @@ video {
913
869
  border-width: 4px;
914
870
  }
915
871
 
872
+ .border-l-4 {
873
+ border-left-width: 4px;
874
+ }
875
+
916
876
  .border-neutral-300 {
917
877
  --tw-border-opacity: 1;
918
878
  border-color: rgb(212 212 212 / var(--tw-border-opacity));
919
879
  }
920
880
 
881
+ .border-red-500 {
882
+ --tw-border-opacity: 1;
883
+ border-color: rgb(239 68 68 / var(--tw-border-opacity));
884
+ }
885
+
921
886
  .border-transparent {
922
887
  border-color: transparent;
923
888
  }
@@ -926,20 +891,6 @@ video {
926
891
  background-color: rgb(0 0 0 / 0.1);
927
892
  }
928
893
 
929
- .bg-blue-600 {
930
- --tw-bg-opacity: 1;
931
- background-color: rgb(37 99 235 / var(--tw-bg-opacity));
932
- }
933
-
934
- .bg-blue-700 {
935
- --tw-bg-opacity: 1;
936
- background-color: rgb(29 78 216 / var(--tw-bg-opacity));
937
- }
938
-
939
- .bg-blue-700\\/60 {
940
- background-color: rgb(29 78 216 / 0.6);
941
- }
942
-
943
894
  .bg-neutral-100 {
944
895
  --tw-bg-opacity: 1;
945
896
  background-color: rgb(245 245 245 / var(--tw-bg-opacity));
@@ -974,18 +925,9 @@ video {
974
925
  background-color: rgb(234 88 12 / var(--tw-bg-opacity));
975
926
  }
976
927
 
977
- .bg-gradient-to-b {
978
- background-image: linear-gradient(to bottom, var(--tw-gradient-stops));
979
- }
980
-
981
- .from-transparent {
982
- --tw-gradient-from: transparent var(--tw-gradient-from-position);
983
- --tw-gradient-to: rgb(0 0 0 / 0) var(--tw-gradient-to-position);
984
- --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
985
- }
986
-
987
- .to-blue-700 {
988
- --tw-gradient-to: #1d4ed8 var(--tw-gradient-to-position);
928
+ .bg-red-100 {
929
+ --tw-bg-opacity: 1;
930
+ background-color: rgb(254 226 226 / var(--tw-bg-opacity));
989
931
  }
990
932
 
991
933
  .bg-cover {
@@ -1020,6 +962,10 @@ video {
1020
962
  padding: 1rem;
1021
963
  }
1022
964
 
965
+ .p-5 {
966
+ padding: 1.25rem;
967
+ }
968
+
1023
969
  .p-6 {
1024
970
  padding: 1.5rem;
1025
971
  }
@@ -1028,6 +974,11 @@ video {
1028
974
  padding: .75em;
1029
975
  }
1030
976
 
977
+ .px-3 {
978
+ padding-left: 0.75rem;
979
+ padding-right: 0.75rem;
980
+ }
981
+
1031
982
  .px-8 {
1032
983
  padding-left: 2rem;
1033
984
  padding-right: 2rem;
@@ -1043,14 +994,6 @@ video {
1043
994
  padding-bottom: 2rem;
1044
995
  }
1045
996
 
1046
- .pb-8 {
1047
- padding-bottom: 2rem;
1048
- }
1049
-
1050
- .pt-8 {
1051
- padding-top: 2rem;
1052
- }
1053
-
1054
997
  .text-left {
1055
998
  text-align: left;
1056
999
  }
@@ -1077,11 +1020,6 @@ video {
1077
1020
  line-height: 1.5rem;
1078
1021
  }
1079
1022
 
1080
- .text-lg {
1081
- font-size: 1.125rem;
1082
- line-height: 1.75rem;
1083
- }
1084
-
1085
1023
  .text-sm {
1086
1024
  font-size: 0.875rem;
1087
1025
  line-height: 1.25rem;
@@ -1092,14 +1030,14 @@ video {
1092
1030
  line-height: 1rem;
1093
1031
  }
1094
1032
 
1095
- .font-bold {
1096
- font-weight: 700;
1097
- }
1098
-
1099
1033
  .font-medium {
1100
1034
  font-weight: 500;
1101
1035
  }
1102
1036
 
1037
+ .font-semibold {
1038
+ font-weight: 600;
1039
+ }
1040
+
1103
1041
  .leading-none {
1104
1042
  line-height: 1;
1105
1043
  }
@@ -1118,11 +1056,26 @@ video {
1118
1056
  color: rgb(163 163 163 / var(--tw-text-opacity));
1119
1057
  }
1120
1058
 
1059
+ .text-neutral-500 {
1060
+ --tw-text-opacity: 1;
1061
+ color: rgb(115 115 115 / var(--tw-text-opacity));
1062
+ }
1063
+
1064
+ .text-neutral-700 {
1065
+ --tw-text-opacity: 1;
1066
+ color: rgb(64 64 64 / var(--tw-text-opacity));
1067
+ }
1068
+
1121
1069
  .text-orange-500 {
1122
1070
  --tw-text-opacity: 1;
1123
1071
  color: rgb(249 115 22 / var(--tw-text-opacity));
1124
1072
  }
1125
1073
 
1074
+ .text-red-900 {
1075
+ --tw-text-opacity: 1;
1076
+ color: rgb(127 29 29 / var(--tw-text-opacity));
1077
+ }
1078
+
1126
1079
  .text-transparent {
1127
1080
  color: transparent;
1128
1081
  }
@@ -1132,14 +1085,6 @@ video {
1132
1085
  color: rgb(255 255 255 / var(--tw-text-opacity));
1133
1086
  }
1134
1087
 
1135
- .text-white\\/20 {
1136
- color: rgb(255 255 255 / 0.2);
1137
- }
1138
-
1139
- .text-white\\/80 {
1140
- color: rgb(255 255 255 / 0.8);
1141
- }
1142
-
1143
1088
  .opacity-0 {
1144
1089
  opacity: 0;
1145
1090
  }
@@ -1267,11 +1212,6 @@ video {
1267
1212
  content: var(--tw-content);
1268
1213
  }
1269
1214
 
1270
- .hover\\:bg-blue-500:hover {
1271
- --tw-bg-opacity: 1;
1272
- background-color: rgb(59 130 246 / var(--tw-bg-opacity));
1273
- }
1274
-
1275
1215
  .hover\\:bg-neutral-200:hover {
1276
1216
  --tw-bg-opacity: 1;
1277
1217
  background-color: rgb(229 229 229 / var(--tw-bg-opacity));
@@ -1282,13 +1222,14 @@ video {
1282
1222
  background-color: rgb(251 146 60 / var(--tw-bg-opacity));
1283
1223
  }
1284
1224
 
1285
- .hover\\:text-white:hover {
1225
+ .hover\\:text-neutral-500:hover {
1286
1226
  --tw-text-opacity: 1;
1287
- color: rgb(255 255 255 / var(--tw-text-opacity));
1227
+ color: rgb(115 115 115 / var(--tw-text-opacity));
1288
1228
  }
1289
1229
 
1290
- .hover\\:text-white\\/40:hover {
1291
- color: rgb(255 255 255 / 0.4);
1230
+ .hover\\:text-white:hover {
1231
+ --tw-text-opacity: 1;
1232
+ color: rgb(255 255 255 / var(--tw-text-opacity));
1292
1233
  }
1293
1234
 
1294
1235
  .hover\\:brightness-125:hover {
@@ -1321,13 +1262,13 @@ video {
1321
1262
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
1322
1263
  }
1323
1264
 
1324
- .aria-busy\\:pointer-events-none[aria-busy="true"] {
1325
- pointer-events: none;
1265
+ .group:hover .group-hover\\:text-black {
1266
+ --tw-text-opacity: 1;
1267
+ color: rgb(0 0 0 / var(--tw-text-opacity));
1326
1268
  }
1327
1269
 
1328
- .aria-busy\\:bg-blue-500[aria-busy="true"] {
1329
- --tw-bg-opacity: 1;
1330
- background-color: rgb(59 130 246 / var(--tw-bg-opacity));
1270
+ .aria-busy\\:pointer-events-none[aria-busy="true"] {
1271
+ pointer-events: none;
1331
1272
  }
1332
1273
 
1333
1274
  .aria-disabled\\:pointer-events-none[aria-disabled="true"] {
@@ -1338,14 +1279,6 @@ video {
1338
1279
  opacity: 0.5;
1339
1280
  }
1340
1281
 
1341
- .group[aria-busy="true"] .group-aria-busy\\:inline {
1342
- display: inline;
1343
- }
1344
-
1345
- .group[aria-busy="true"] .group-aria-busy\\:hidden {
1346
- display: none;
1347
- }
1348
-
1349
1282
  .group\\/button[aria-busy="true"] .group-aria-busy\\/button\\:translate-x-0 {
1350
1283
  --tw-translate-x: 0px;
1351
1284
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
@@ -1426,10 +1359,25 @@ video {
1426
1359
  background-color: rgb(38 38 38 / var(--tw-bg-opacity));
1427
1360
  }
1428
1361
 
1362
+ .dark\\:bg-red-900:where([data-theme="dark"], [data-theme="dark"] *) {
1363
+ --tw-bg-opacity: 1;
1364
+ background-color: rgb(127 29 29 / var(--tw-bg-opacity));
1365
+ }
1366
+
1429
1367
  .dark\\:bg-white\\/10:where([data-theme="dark"], [data-theme="dark"] *) {
1430
1368
  background-color: rgb(255 255 255 / 0.1);
1431
1369
  }
1432
1370
 
1371
+ .dark\\:text-neutral-400:where([data-theme="dark"], [data-theme="dark"] *) {
1372
+ --tw-text-opacity: 1;
1373
+ color: rgb(163 163 163 / var(--tw-text-opacity));
1374
+ }
1375
+
1376
+ .dark\\:text-red-50:where([data-theme="dark"], [data-theme="dark"] *) {
1377
+ --tw-text-opacity: 1;
1378
+ color: rgb(254 242 242 / var(--tw-text-opacity));
1379
+ }
1380
+
1433
1381
  .dark\\:text-white:where([data-theme="dark"], [data-theme="dark"] *) {
1434
1382
  --tw-text-opacity: 1;
1435
1383
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -1439,7 +1387,12 @@ video {
1439
1387
  --tw-bg-opacity: 1;
1440
1388
  background-color: rgb(64 64 64 / var(--tw-bg-opacity));
1441
1389
  }
1442
- `;import{useResizeObserver as Ur}from"usehooks-ts";import{mergeRefs as Nr}from"react-merge-refs";import{createContext as jt,useContext as Zt}from"react";import{jsx as Jt}from"react/jsx-runtime";var Ie=jt(null);function Me({frame:e,children:t}){if(Zt(Ie))throw new Error("`FrameProvider` can only be used once.");return Jt(Ie.Provider,{value:{frame:e},children:t})}import{useMediaQuery as kr}from"usehooks-ts";import"@rainbow-me/rainbowkit/styles.css";import{createContext as wr,useContext as Qe}from"react";import{RainbowKitProvider as vr,midnightTheme as xr}from"@rainbow-me/rainbowkit";import{useChains as Cr}from"wagmi";import{transactionQueue as mr}from"@latticexyz/common/actions";import{createClient as ur,fallback as fr,http as Ke,keccak256 as gr,stringToHex as hr,webSocket as yr}from"viem";import{privateKeyToAccount as br}from"viem/accounts";import{createTransport as lr,numberToHex as dr,parseEther as cr}from"viem";import{entryPoint07Address as Le}from"viem/account-abstraction";import{formatUserOperationRequest as er}from"viem/account-abstraction";async function Oe(e){return er({callGasLimit:20000000n,preVerificationGas:200000n,verificationGasLimit:2000000n,paymasterVerificationGasLimit:200000n,paymasterPostOpGasLimit:200000n})}import{parseEventLogs as tr}from"viem";import{formatUserOperation as rr,toPackedUserOperation as or,getUserOperationHash as nr,entryPoint07Address as He,entryPoint07Abi as ze}from"viem/account-abstraction";import{waitForTransactionReceipt as ar,writeContract as ir}from"viem/actions";import{getAction as qe}from"viem/utils";async function Be({executor:e,rpcUserOp:t}){let r=rr(t),o=or(r),n=nr({userOperation:r,chainId:e.chain.id,entryPointVersion:"0.7",entryPointAddress:He}),a=await qe(e,ir,"writeContract")({abi:ze,address:He,functionName:"handleOps",args:[[o],e.account.address],chain:e.chain,account:e.account}),i=await qe(e,ar,"waitForTransactionReceipt")({hash:a});return{success:tr({logs:i.logs,abi:ze,eventName:"UserOperationEvent"})[0].args.success,userOpHash:n,receipt:i}}import Fe from"debug";var ge=Fe("mud:entrykit"),sr=Fe("mud:entrykit");ge.log=console.debug.bind(console);sr.log=console.error.bind(console);var T=ge.extend("quarry");import{setBalance as pr}from"viem/actions";function De({executor:e}){return()=>{T("using a local user op executor",e.account.address),e.chain.id===31337&&(T("setting executor balance"),pr(e.extend(()=>({mode:"anvil"})),{address:e.account.address,value:cr("100")}));let t=new Map;return lr({key:"userOpExecutor",type:"userOpExecutor",name:"User Operation Executor Transport",request:async({method:o,params:n})=>{if(o==="eth_chainId")return dr(e.chain.id);if(o==="eth_supportedEntryPoints")return[Le];if(o==="eth_sendUserOperation"){let[a,i]=n;if(i===Le){let l=await Be({executor:e,rpcUserOp:a});return t.set(l.userOpHash,l),l.userOpHash}}if(o==="eth_getUserOperationReceipt"){let[a]=n;return t.get(a)??null}if(o==="eth_estimateUserOperationGas")return await Oe(n);throw new Error("Method not implemented.")}})}}function Y(e){let t=e.rpcUrls.bundler?.http[0],r=t?Ke(t):e.id===31337?De({executor:ur({chain:e,transport:fr([yr(),Ke()]),account:br(gr(hr("local user op executor"))),pollingInterval:10}).extend(mr())}):null;if(!r)throw new Error(`Chain ${e.id} config did not include a bundler RPC URL.`);return r}import{jsx as Ge}from"react/jsx-runtime";var he=wr(null);function Ve({config:e,children:t}){if(Qe(he))throw new Error("`EntryKitProvider` can only be used once.");let n=Cr().find(({id:a})=>a===e.chainId);if(!n)throw new Error(`Could not find configured chain for chain ID ${e.chainId}.`);return Y(n),Ge(vr,{initialChain:0,appInfo:{appName:e.appName},theme:xr({borderRadius:"none"}),children:Ge(he.Provider,{value:{...e,chain:n},children:t})})}function s(){let e=Qe(he);if(!e)throw new Error("`useEntryKitConfig` can only be used within a `EntryKitProvider`.");return e}function We(){let{theme:e}=s(),t=kr("(prefers-color-scheme: dark)");return e??(t?"dark":"light")}import{jsx as B,jsxs as Rr}from"react/jsx-runtime";function Er({onSize:e,...t}){let r=Ye(null);return Ur({ref:r,onResize:e}),B("div",{ref:r,...t,style:{...t.style,display:"inline-grid"}})}var X=Sr(function({mode:t,children:r},o){let n=Ye(null),[a,i]=_e(!1),l=a?n.current:null,[c,f]=_e({width:void 0,height:void 0}),m=l?.contentDocument,d=We();Pr(()=>{m&&m.body.setAttribute("data-theme",d)},[m,d]);let p=t==="modal"?{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",zIndex:"2147483646"}:c.width&&c.height?{all:"unset",display:"inline-grid",width:`${c.width}px`,height:`${c.height}px`}:{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",opacity:0,pointerEvents:"none"};return B("iframe",{ref:Nr([o,n]),style:p,onLoad:()=>i(!0),srcDoc:"<!doctype html><title>\u2026</title>",children:m?Ar.createPortal(Rr(Me,{frame:l,children:[B("div",{children:t==="modal"?r:B(Er,{onSize:f,children:r})}),B("style",{dangerouslySetInnerHTML:{__html:Te}})]}),m.body):null})});import{twMerge as Xe}from"tailwind-merge";import{jsx as I,jsxs as Or}from"react/jsx-runtime";function $e({open:e,onOpenChange:t,children:r}){return I(Tr,{open:e,onOpenChange:t,children:I(Ir,{children:Or(X,{mode:"modal",children:[I("div",{className:Xe("fixed inset-0","bg-neutral-800/85","animate-in animate-duration-300 fade-in")}),I("div",{className:Xe("fixed inset-0","grid items-end sm:items-center","animate-in animate-duration-300 fade-in slide-in-from-bottom-16"),children:I("div",{children:I(Mr,{className:"outline-none w-full max-w-[26rem] mx-auto","aria-describedby":void 0,onOpenAutoFocus:o=>{o.preventDefault()},children:r})})})]})})})}import{useCallback as ye,useMemo as Hr}from"react";import{useStore as zr}from"zustand";import{createStore as qr}from"zustand/vanilla";var $=qr(()=>({open:!1}));function x(){let e=zr($,n=>n.open),t=ye(()=>{$.setState({open:!0})},[]),r=ye(()=>{$.setState({open:!1})},[]),o=ye(n=>{$.setState({open:n})},[]);return Hr(()=>({accountModalOpen:e,openAccountModal:t,closeAccountModal:r,toggleAccountModal:o}),[e,t,r,o])}import{twMerge as Ft}from"tailwind-merge";import{useAccount as Bn,useConnectorClient as Fn}from"wagmi";import{useAccount as Wr}from"wagmi";import{twMerge as L}from"tailwind-merge";import{twMerge as Br}from"tailwind-merge";import{jsx as je,jsxs as Fr}from"react/jsx-runtime";function S({className:e,...t}){return Fr("svg",{className:Br("-my-[0.125em] h-[1.25em] w-[1.25em] animate-spin",e),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",...t,children:[je("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),je("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}import{jsx as F,jsxs as Dr}from"react/jsx-runtime";var Lr=({variant:e="secondary"}={})=>L("group/button self-center leading-none outline-none border-4 border-transparent","transition hover:brightness-125 active:brightness-150","focus:border-orange-500","aria-disabled:pointer-events-none aria-busy:pointer-events-none","aria-disabled:opacity-50","p-[.75em] font-medium",{primary:L("bg-orange-600 text-white focus:border-yellow-400"),secondary:L("bg-neutral-700 text-white focus:border-orange-500"),tertiary:L("bg-neutral-800 text-white focus:border-orange-500")}[e]),y=({pending:e,variant:t,type:r,className:o,children:n,disabled:a,...i})=>F("button",{type:r||"button",className:L(Lr({variant:t,pending:e}),o),"aria-busy":e,"aria-disabled":a,disabled:a||e,...i,children:Dr("span",{className:"grid grid-cols-[1fr_auto_1fr] gap-2",children:[F("span",{className:"flex items-center justify-end text-[.75em]",children:F("span",{className:"transition opacity-0 translate-x-2 group-aria-busy/button:opacity-100 group-aria-busy/button:translate-x-0 duration-100 group-aria-busy/button:duration-300",children:F(S,{})})}),F("span",{children:n})]})});import{useConnectModal as _r}from"@rainbow-me/rainbowkit";import{twMerge as Kr}from"tailwind-merge";import{jsx as be,jsxs as Gr}from"react/jsx-runtime";function P({className:e,...t}){return Gr("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 8 8",fill:"currentColor",shapeRendering:"crispEdges",className:Kr("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...t,children:[be("path",{d:"M0 0h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm2-1h1v1H7zm0 1h1v1H7zM6 7h1v1H6zm1-2h1v1H7zm0-1h1v1H7zm0-1h1v1H7z"}),be("path",{d:"M2 2h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm1-3h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm0 1h1v1H5zm0 1h1v1H5zm0 1h1v1H5zM4 5h1v1H4zM3 5h1v1H3z",opacity:".5"}),be("path",{d:"M7 2h1v1H7zm0-1h1v1H7zM1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm1 0h1v1H6zm1 0h1v1H7z"})]})}import{useQuery as Qr}from"@tanstack/react-query";function j(e){return Qr({enabled:!!e,retry:!1,retryOnMount:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,queryKey:["preloadImage",e],queryFn:()=>new Promise((t,r)=>{if(!e)throw new Error("usePreloadImage: Must provide `url` to preload image.");let o=new Image;o.onload=()=>t(o),o.onerror=()=>r(new Error(`usePreloadImage: Could not load image.
1443
1390
 
1444
- URL: ${e}`)),o.src=e})})}import{jsx as Z,jsxs as Vr}from"react/jsx-runtime";function Ze(){let{appName:e,appIcon:t}=s(),{data:r,isLoading:o}=j(t);return Vr("div",{className:"flex-grow flex flex-col items-center justify-center gap-2",children:[Z("div",{className:"w-16 h-16 m-2",children:o?null:r?Z("img",{src:t,className:"w-full h-full object-cover"}):Z(P,{className:"w-full h-full text-orange-500 dark:bg-neutral-800"})}),Z("div",{className:"text-2xl text-white text-center",children:e})]})}import{twMerge as Yr}from"tailwind-merge";import{useEffect as Xr,useState as $r}from"react";import{jsx as J,jsxs as jr}from"react/jsx-runtime";function Je(){let e=Wr(),{openConnectModal:t,connectModalOpen:r}=_r(),[o,n]=$r(!1);return Xr(()=>{!r&&!o&&(t?.(),n(!0))},[r,o,t]),jr("div",{className:Yr("flex flex-col gap-6 p-6","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:[J("div",{className:"p-4",children:J(Ze,{})}),J("div",{className:"self-center flex flex-col gap-2 w-60",children:J(y,{variant:"secondary",className:"self-auto flex justify-center",disabled:e.status==="connecting",onClick:t,autoFocus:!0,children:"Connect wallet"},"create")})]})}import{useEffect as Et,useMemo as Hn,useRef as zn,useState as qn}from"react";import{twMerge as Ne}from"tailwind-merge";import{parseEther as Zr}from"viem";var N=Zr("0.01");import{useClient as so}from"wagmi";import{queryOptions as lo,useQuery as co}from"@tanstack/react-query";import{numberToHex as ro}from"viem";import{defineStore as Jr}from"@latticexyz/store";import{parseAbi as eo}from"viem";var we=eo(["error SpenderSystem_AlreadyRegistered(address spender, address user)","error SpenderSystem_HasOwnBalance(address spender)","function registerSpender(address spender)"]),to=Jr({namespaces:{root:{namespace:"",tables:{Allowance:{schema:{user:"address",allowance:"uint256"},key:["user"]},Grantor:{schema:{grantor:"address",allowance:"uint256"},key:["grantor"]},PassHolder:{schema:{user:"address",passId:"bytes32",lastRenewed:"uint256",lastClaimed:"uint256"},key:["user","passId"]},PassConfig:{schema:{passId:"bytes32",claimAmount:"uint256",claimInterval:"uint256",validityPeriod:"uint256",grantor:"address"},key:["passId"]},Spender:{schema:{spender:"address",user:"address"},key:["spender"]},SystemConfig:{schema:{entryPoint:"address"},key:[]}}}}}),M=to.namespaces.root.tables;import{getRecord as oo,getStaticDataLocation as no}from"@latticexyz/store/internal";import{getKeyTuple as ao}from"@latticexyz/protocol-parser/internal";import{setStorageAt as io}from"viem/actions";function h(e){let t=e.contracts??{};if("quarryPaymaster"in t&&t.quarryPaymaster!=null&&"address"in t.quarryPaymaster)return{type:"quarry",address:t.quarryPaymaster.address};if("paymaster"in t&&t.paymaster!=null&&"address"in t.paymaster)return{type:"simple",address:t.paymaster.address}}async function et({client:e,userAddress:t}){let r=h(e.chain);return r?.type!=="quarry"?null:(await oo(e,{address:r.address,table:M.Allowance,key:{user:t},blockTag:"pending"})).allowance}async function tt({client:e,userAddress:t,allowance:r}){let o=h(e.chain);if(o?.type!=="quarry")return;let n=no(M.Allowance.tableId,ao(M.Allowance,{user:t}));await io(e.extend(()=>({mode:"anvil"})),{address:o.address,index:n,value:ro(r,{size:32})})}function ve({client:e,userAddress:t}){let r=["getAllowance",e?.uid,t];return lo(e&&t?{queryKey:r,queryFn:()=>et({client:e,userAddress:t})}:{queryKey:r,enabled:!1})}function rt(e){let{chainId:t}=s(),r=so({chainId:t});return co(ve({client:r,userAddress:e}))}import{useClient as Ps}from"wagmi";import{queryOptions as mo,useQuery as Us}from"@tanstack/react-query";import{getRecord as po}from"@latticexyz/store/internal";async function ot({client:e,userAddress:t,sessionAddress:r}){let o=h(e.chain);return o?.type!=="quarry"?null:(await po(e,{address:o.address,table:M.Spender,key:{spender:r},blockTag:"pending"})).user.toLowerCase()===t.toLowerCase()}function nt({client:e,userAddress:t,sessionAddress:r}){let o=["getSpender",e?.uid,t,r];return mo(e&&t&&r?{queryKey:o,queryFn:()=>ot({client:e,userAddress:t,sessionAddress:r})}:{queryKey:o,enabled:!1})}import{useClient as Vs}from"wagmi";import{queryOptions as yo,useQuery as _s}from"@tanstack/react-query";import{getRecord as ho}from"@latticexyz/store/internal";import{resourceToHex as uo}from"@latticexyz/common";import{parseAbi as fo}from"viem";import go from"@latticexyz/world/mud.config";var at={pollingInterval:250},D=uo({type:"system",namespace:"",name:"unlimited"}),it=go.namespaces.world.tables,st=fo(["function registerDelegation(address delegatee, bytes32 delegationControlId, bytes initCallData)"]);async function lt({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){return(await ho(e,{address:t,table:it.UserDelegationControl,key:{delegator:r,delegatee:o},blockTag:"pending"})).delegationControlId===D}function dt({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){let n=["getDelegation",e?.uid,t,r,o];return yo(e&&r&&o?{queryKey:n,queryFn:()=>lt({client:e,worldAddress:t,userAddress:r,sessionAddress:o})}:{queryKey:n,enabled:!1})}import{queryOptions as Ao,useQuery as Uo,useQueryClient as No}from"@tanstack/react-query";import{useClient as Eo,useConfig as Ro}from"wagmi";import{useClient as dl}from"wagmi";import{queryOptions as Po,useQuery as ul}from"@tanstack/react-query";import{toSimpleSmartAccount as So}from"permissionless/accounts";import{isHex as xo}from"viem";import{createStore as bo}from"zustand/vanilla";import{persist as wo}from"zustand/middleware";var K=bo(wo(()=>({signers:{}}),{name:"mud:entrykit",partialize:({signers:e})=>({signers:e})}));function vo(e){e.key===K.persist.getOptions().name&&K.persist.rehydrate()}window.addEventListener("storage",vo);import{generatePrivateKey as Co,privateKeyToAccount as ko}from"viem/accounts";function ct(e){let t=e.toLowerCase(),r=K.getState().signers[t]??(()=>{let o=localStorage.getItem(`mud:appSigner:privateKey:${e.toLowerCase()}`)?.replace(/^"(.*)"$/,"$1"),n=xo(o)?o:Co();return K.setState(a=>({signers:{...a.signers,[t]:n}})),n})();return ko(r)}async function pt({client:e,userAddress:t}){let r=ct(t);return await So({client:e,owner:r})}function ee({client:e,userAddress:t}){let r=["getSessionAccount",e?.uid,t];return Po(e&&t?{queryKey:r,queryFn:()=>pt({client:e,userAddress:t}),staleTime:1/0,retry:!1}:{queryKey:r,enabled:!1})}import{getBalanceQueryOptions as To}from"wagmi/query";function Io({queryClient:e,config:t,client:r,userAddress:o,worldAddress:n}){let a=["getPrerequisites",r?.uid,o];return Ao(r&&o?{queryKey:a,async queryFn(){let i=h(r.chain),{address:l}=await e.fetchQuery(ee({client:r,userAddress:o})),[c,f,m,d]=await Promise.all([i?null:e.fetchQuery(To(t,{chainId:r.chain.id,address:l})),i?.type==="quarry"?e.fetchQuery(ve({client:r,userAddress:o})):null,i?.type==="quarry"?e.fetchQuery(nt({client:r,userAddress:o,sessionAddress:l})):null,e.fetchQuery(dt({client:r,worldAddress:n,userAddress:o,sessionAddress:l}))]),p=f==null||f>=N,g=m??!0,_=c==null||c.value>=N;return{sessionAddress:l,hasAllowance:p,isSpender:g,hasGasBalance:_,hasDelegation:d,complete:p&&g&&d}},retry:!1}:{queryKey:a,enabled:!1})}function O(e){let t=No(),r=Ro(),{chainId:o,worldAddress:n}=s(),a=Eo({chainId:o});return Uo(Io({queryClient:t,config:r,client:a,userAddress:e,worldAddress:n}),t)}import{useDisconnect as Bo}from"wagmi";import{useQuery as Mo}from"@tanstack/react-query";function te(e){let t=e?.toLowerCase();return Mo({enabled:!!t,queryKey:["ens",t],queryFn:async()=>{let r=await fetch(`https://api.ensideas.com/ens/resolve/${t}`).then(o=>o.json());return{address:r.address??void 0,name:r.name??void 0,displayName:r.displayName??void 0,avatar:r.avatar??void 0}}})}import{jsx as xe,jsxs as Oo}from"react/jsx-runtime";function H({hex:e}){return e.length<=10?xe("span",{title:e,children:e}):Oo("span",{title:e,children:[xe("span",{className:"after:select-none after:content-['\u2026']",children:e.slice(0,6)}),xe("span",{className:"tracking-[-1ch] text-transparent",children:e.slice(6,-4)}),e.slice(-4)]})}import{findCause as Ho}from"@latticexyz/common";import{createStore as zo}from"zustand/vanilla";var re=zo(()=>({lastId:0,errors:[]}));function oe({error:e,retry:t,dismiss:r}){if(!Ho(e,({name:o})=>o==="UserRejectedRequestError"))return re.setState(o=>{if(o.errors.some(a=>a.error===e))return{};let n=o.lastId+1;return{lastId:n,errors:[...o.errors,{id:n,error:e,dismiss:r?()=>{Ce(e),r()}:void 0,retry:t?async()=>{Ce(e),await t()}:void 0}]}}),()=>{Ce(e)}}function Ce(e){re.setState(t=>({errors:t.errors.filter(r=>r.error!==e)}))}import{useEffect as qo}from"react";function A(e){let{error:t,reset:r}=e;return qo(()=>{if(t)return oe({error:t,dismiss:r})},[t,r]),e}import{jsx as G,jsxs as ke}from"react/jsx-runtime";function mt({isActive:e,isExpanded:t,userAddress:r}){let{data:o}=te(r),{disconnect:n,isPending:a}=A(Bo()),{closeAccountModal:i}=x();return ke("div",{className:"flex flex-col gap-4",children:[ke("div",{className:"flex justify-between gap-4",children:[ke("div",{children:[G("div",{children:"Account"}),G("div",{className:"font-mono text-white",children:o?.name??G(H,{hex:r})})]}),G(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:a,onClick:()=>{i(),n()},children:"Sign out"})]}),t?G("p",{className:"text-sm",children:"Each of your onchain actions in this app is associated with your account."}):null]})}import{parseEther as Lo}from"viem";import{useMutation as Do,useQueryClient as Ko}from"@tanstack/react-query";import{http as Fo}from"viem";function ut(){return({chain:e})=>{if(!e)throw new Error("No chain provided to issuer transport.");let t="quarryPassIssuer"in e.rpcUrls?e.rpcUrls.quarryPassIssuer.http[0]:void 0;if(!t)throw new Error(`No \`quarryPassIssuer\` RPC URL found for chain ${e.id}.`);return Fo(t)({chain:e,retryCount:0})}}async function ft({chain:e,userAddress:t}){let r=ut()({chain:e});T("Issuing gas pass to",t),await r.request({method:"quarry_issuePass",params:["0x01",t]}),T("Claiming gas allowance for",t),await r.request({method:"quarry_claimAllowance",params:["0x01",t]})}import{useClient as Go}from"wagmi";function gt(){let e=Ko(),{chain:t}=s(),r=Go({chainId:t.id}),o=["claimGasPass",t.id];return Do({retry:0,mutationKey:o,mutationFn:async n=>{if(t.id===31337){if(!r)throw new Error("No client?");await tt({client:r,userAddress:n,allowance:Lo("1")})}else await ft({chain:t,userAddress:n});await Promise.all([e.invalidateQueries({queryKey:["getAllowance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])}})}import{twMerge as Qo}from"tailwind-merge";import{jsx as ne,jsxs as Vo}from"react/jsx-runtime";function ht({className:e,...t}){return Vo("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 263 428",fill:"currentColor",className:Qo("w-[0.6em] h-[1em]",e),...t,children:[ne("path",{d:"M132 321V428L263 243L132 321Z"}),ne("path",{d:"M0 243L132 321V428",fillOpacity:"0.5"}),ne("path",{d:"M132 0V296L263 218"}),ne("path",{d:"M0 218L132 296V0L0 218Z",fillOpacity:"0.5"})]})}import{formatEther as Wo}from"viem";function yt(e){let t=Wo(e),r=Math.floor(parseFloat(t)).toString().length;return parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:Math.max(0,6-r)})}import{formatEther as _o}from"viem";import{jsx as Yo,jsxs as Xo}from"react/jsx-runtime";function ae({wei:e}){return Xo("span",{className:"inline-flex items-center gap-1",title:_o(e),children:[yt(e)," ",Yo(ht,{})]})}import{useEffect as jo}from"react";import{useEffect as $o}from"react";function z(e){let{error:t,refetch:r}=e;return $o(()=>{if(t)return oe({error:t,retry:r,dismiss:()=>{}})},[t,r]),e}import{jsx as q,jsxs as Se}from"react/jsx-runtime";function bt({isActive:e,isExpanded:t,userAddress:r}){let o=z(rt(r)),n=A(gt());return jo(()=>{let a=setTimeout(()=>{e&&n.status==="idle"&&o.isSuccess&&o.data!=null&&o.data<N&&n.mutate(r)});return()=>clearTimeout(a)},[o.data,o.isSuccess,n,e,r]),Se("div",{className:"flex flex-col gap-4",children:[Se("div",{className:"flex justify-between gap-4",children:[Se("div",{children:[q("div",{children:"Allowance"}),q("div",{className:"font-mono text-white",children:o.data!=null?q(ae,{wei:o.data}):q(S,{className:"text-sm"})})]}),q(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:o.status==="pending"||n.status==="pending",onClick:()=>n.mutate(r),children:"Top up"})]}),t?q("p",{className:"text-sm",children:"Your allowance is used to pay for onchain computation."}):null]})}import{encodeFunctionData as vt}from"viem";import{useMutation as dn,useQueryClient as cn}from"@tanstack/react-query";import{getAction as Ae}from"viem/utils";import{sendUserOperation as pn,waitForUserOperationReceipt as mn}from"viem/account-abstraction";import{waitForTransactionReceipt as un}from"viem/actions";import{useClient as fn}from"wagmi";import{resourceToHex as xt}from"@latticexyz/common";import gn from"@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json";import{writeContract as an}from"viem/actions";import{getAction as sn}from"viem/utils";import{toHex as Zo}from"viem";import{signTypedData as Jo}from"viem/actions";import{callWithSignatureTypes as en}from"@latticexyz/world-module-callwithsignature/internal";import{getRecord as tn}from"@latticexyz/store/internal";import rn from"@latticexyz/world-module-callwithsignature/mud.config";import{hexToResource as on}from"@latticexyz/common";import{getAction as nn}from"viem/utils";async function wt({userClient:e,worldAddress:t,systemId:r,callData:o,nonce:n,client:a}){let i=n??(a?(await tn(a,{address:t,table:rn.tables.CallWithSignatureNonces,key:{signer:e.account.address},blockTag:"pending"})).nonce:0n),{namespace:l,name:c}=on(r);return await nn(e,Jo,"signTypedData")({account:e.account,domain:{verifyingContract:t,salt:Zo(e.chain.id,{size:32})},types:en,primaryType:"Call",message:{signer:e.account.address,systemNamespace:l,systemName:c,callData:o,nonce:i}})}import ln from"@latticexyz/world-module-callwithsignature/out/CallWithSignatureSystem.sol/CallWithSignatureSystem.abi.json";async function Pe({sessionClient:e,...t}){let r=await wt(t);return sn(e,an,"writeContract")({address:t.worldAddress,abi:ln,functionName:"callWithSignature",args:[t.userClient.account.address,t.systemId,t.callData,r]})}function Ct({userClient:e}){let t=cn(),{chainId:r,worldAddress:o}=s(),n=fn({chainId:r}),a=["setupSession",n?.chain.id,e.account.address];return dn({retry:0,mutationKey:a,mutationFn:async({sessionClient:i,registerSpender:l,registerDelegation:c})=>{if(!n)throw new Error("Client not ready.");let f=h(n.chain),m=i.account.address;if(console.log("setting up session"),e.account.type==="smart"){let d=[];if(l&&f?.type==="quarry"&&(console.log("registering spender"),d.push({to:f.address,abi:we,functionName:"registerSpender",args:[m]})),c&&(console.log("registering delegation"),d.push({to:o,abi:st,functionName:"registerDelegation",args:[m,D,"0x"]})),!d.length)return;console.log("setting up account with",d,e);let p=await Ae(e,pn,"sendUserOperation")({calls:d});console.log("got user op hash",p);let g=await Ae(e,mn,"waitForUserOperationReceipt")({hash:p});console.log("got user op receipt",g),g.success||console.error("not successful?",g)}else{let d=[];if(l&&f?.type==="quarry"){console.log("registering spender");let p=await Pe({client:n,userClient:e,sessionClient:i,worldAddress:f.address,systemId:xt({type:"system",namespace:"",name:"SpenderSystem"}),callData:vt({abi:we,functionName:"registerSpender",args:[m]})});console.log("got spender tx",p),d.push(p)}if(c){console.log("registering delegation");let p=await Pe({client:n,userClient:e,sessionClient:i,worldAddress:o,systemId:xt({type:"system",namespace:"",name:"Registration"}),callData:vt({abi:gn,functionName:"registerDelegation",args:[m,D,"0x"]})});console.log("got delegation tx",p),d.push(p)}if(!d.length)return;console.log("waiting for",d.length,"receipts");for(let p of d){let g=await Ae(n,un,"waitForTransactionReceipt")({hash:p});console.log("got tx receipt",g),g.status==="reverted"&&console.error("tx reverted?",g)}}await Promise.all([t.invalidateQueries({queryKey:["getSpender"]}),t.invalidateQueries({queryKey:["getDelegation"]}),t.invalidateQueries({queryKey:["getPrerequisites"]})])}})}import{useEffect as An}from"react";import{useClient as xn}from"wagmi";import{queryOptions as Cn,useQuery as kn,useQueryClient as Sn}from"@tanstack/react-query";import{smartAccountActions as bn}from"permissionless";import{callFrom as wn}from"@latticexyz/world/internal";import{createBundlerClient as hn}from"viem/account-abstraction";var yn=new Set([31337,17420,17069,690]);function kt(e){let t=e.chain??e.client?.chain,r=t?h(t):void 0;return hn({...at,paymaster:r?{getPaymasterData:async()=>({paymaster:r.address,paymasterData:"0x"})}:void 0,userOperation:{estimateFeesPerGas:t&&yn.has(t.id)?async()=>({maxFeePerGas:100000n,maxPriorityFeePerGas:0n}):void 0},...e})}async function St({userAddress:e,sessionAccount:t,worldAddress:r}){let o=t.client;if(!vn(o))throw new Error("Session account client had no associated chain.");let n=Y(o.chain);return kt({transport:n,client:o,account:t}).extend(bn).extend(wn({worldAddress:r,delegatorAddress:e,publicClient:o})).extend(()=>({userAddress:e}))}function vn(e){return e.chain!=null}function Pn({queryClient:e,client:t,userAddress:r,worldAddress:o}){let n=["getSessionClient",t?.uid,r,o];return Cn(r?{queryKey:n,async queryFn(){let a=await e.fetchQuery(ee({client:t,userAddress:r}));return await St({sessionAccount:a,userAddress:r,worldAddress:o})},staleTime:1/0,retry:!1}:{queryKey:n,enabled:!1})}function ie(e){let t=Sn(),{chainId:r,worldAddress:o}=s(),n=xn({chainId:r});return kn(Pn({queryClient:t,client:n,userAddress:e,worldAddress:o}))}import{jsx as Q,jsxs as Ue}from"react/jsx-runtime";function Pt({isActive:e,isExpanded:t,userClient:r,registerSpender:o,registerDelegation:n}){let a=z(ie(r.account.address)),i=A(Ct({userClient:r})),l=!n&&!n;return An(()=>{let c=setTimeout(()=>{e&&i.status==="idle"&&a.data&&!l&&i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n})});return()=>clearTimeout(c)},[l,e,n,o,a,i]),Ue("div",{className:"flex flex-col gap-4",children:[Ue("div",{className:"flex justify-between gap-4",children:[Ue("div",{children:[Q("div",{children:"Session"}),Q("div",{className:"font-mono text-white",children:l?"Enabled":"Set up"})]}),l?Q(y,{variant:"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,disabled:!0,children:"Enabled"}):Q(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:!a.data||i.status==="pending",onClick:a.data?()=>i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n}):void 0,children:"Enable"})]}),t?Q("p",{className:"text-sm",children:"You can perform actions in this app without interruptions for approvals."}):null]})}import{useBalance as In,useWatchBlockNumber as Mn}from"wagmi";var At={"1":{bridgeUrl:"https://relay.link/bridge/ethereum"},"10":{bridgeUrl:"https://relay.link/bridge/optimism"},"56":{bridgeUrl:"https://relay.link/bridge/bnb"},"100":{bridgeUrl:"https://relay.link/bridge/gnosis"},"111":{bridgeUrl:"https://testnets.relay.link/bridge/bob"},"137":{bridgeUrl:"https://relay.link/bridge/polygon"},"185":{bridgeUrl:"https://relay.link/bridge/mint"},"288":{bridgeUrl:"https://relay.link/bridge/boba"},"324":{bridgeUrl:"https://relay.link/bridge/zksync"},"360":{bridgeUrl:"https://relay.link/bridge/shape"},"480":{bridgeUrl:"https://relay.link/bridge/world-chain"},"690":{bridgeUrl:"https://relay.link/bridge/redstone"},"919":{bridgeUrl:"https://testnets.relay.link/bridge/mode-testnet"},"1101":{bridgeUrl:"https://relay.link/bridge/polygon-zkevm"},"1135":{bridgeUrl:"https://relay.link/bridge/lisk"},"1301":{bridgeUrl:"https://testnets.relay.link/bridge/unichain-sepolia"},"1329":{bridgeUrl:"https://relay.link/bridge/sei"},"1625":{bridgeUrl:"https://relay.link/bridge/gravity"},"1868":{bridgeUrl:"https://relay.link/bridge/soneium"},"1993":{bridgeUrl:"https://testnets.relay.link/bridge/b3"},"1996":{bridgeUrl:"https://relay.link/bridge/sanko"},"2741":{bridgeUrl:"https://relay.link/bridge/abstract"},"2911":{bridgeUrl:"https://relay.link/bridge/hychain"},"4202":{bridgeUrl:"https://testnets.relay.link/bridge/lisk-sepolia"},"4321":{bridgeUrl:"https://relay.link/bridge/echos"},"5000":{bridgeUrl:"https://relay.link/bridge/mantle"},"5112":{bridgeUrl:"https://relay.link/bridge/ham"},"7560":{bridgeUrl:"https://relay.link/bridge/cyber"},"7865":{bridgeUrl:"https://relay.link/bridge/powerloom"},"7897":{bridgeUrl:"https://relay.link/bridge/arena-z"},"8333":{bridgeUrl:"https://relay.link/bridge/B3"},"8453":{bridgeUrl:"https://relay.link/bridge/base"},"9897":{bridgeUrl:"https://testnets.relay.link/bridge/arena-z-testnet"},"11011":{bridgeUrl:"https://testnets.relay.link/bridge/shape-sepolia"},"11124":{bridgeUrl:"https://testnets.relay.link/bridge/abstract"},"13746":{bridgeUrl:"https://testnets.relay.link/bridge/game7-testnet"},"17000":{bridgeUrl:"https://testnets.relay.link/bridge/holesky"},"17069":{bridgeUrl:"https://testnets.relay.link/bridge/garnet"},"17071":{bridgeUrl:"https://relay.link/bridge/onchain-points"},"33139":{bridgeUrl:"https://relay.link/bridge/apechain"},"33979":{bridgeUrl:"https://relay.link/bridge/funki"},"34443":{bridgeUrl:"https://relay.link/bridge/mode"},"42161":{bridgeUrl:"https://relay.link/bridge/arbitrum"},"42170":{bridgeUrl:"https://relay.link/bridge/arbitrum-nova"},"43114":{bridgeUrl:"https://relay.link/bridge/avalanche"},"55244":{bridgeUrl:"https://relay.link/bridge/superposition"},"57073":{bridgeUrl:"https://relay.link/bridge/ink"},"59144":{bridgeUrl:"https://relay.link/bridge/linea"},"60808":{bridgeUrl:"https://relay.link/bridge/bob"},"70700":{bridgeUrl:"https://relay.link/bridge/apex"},"70701":{bridgeUrl:"https://relay.link/bridge/boss"},"70800":{bridgeUrl:"https://testnets.relay.link/bridge/apex-testnet"},"70805":{bridgeUrl:"https://testnets.relay.link/bridge/cloud"},"80002":{bridgeUrl:"https://testnets.relay.link/bridge/amoy"},"81457":{bridgeUrl:"https://relay.link/bridge/blast"},"84532":{bridgeUrl:"https://testnets.relay.link/bridge/base-sepolia"},"167009":{bridgeUrl:"https://testnets.relay.link/bridge/hekla"},"421614":{bridgeUrl:"https://testnets.relay.link/bridge/arbitrum-sepolia"},"534352":{bridgeUrl:"https://relay.link/bridge/scroll"},"543210":{bridgeUrl:"https://relay.link/bridge/zero-network"},"660279":{bridgeUrl:"https://relay.link/bridge/xai"},"911867":{bridgeUrl:"https://testnets.relay.link/bridge/odyssey"},"984122":{bridgeUrl:"https://relay.link/bridge/forma"},"1118190":{bridgeUrl:"https://testnets.relay.link/bridge/eclipse-testnet"},"3397901":{bridgeUrl:"https://testnets.relay.link/bridge/funki-testnet"},"4457845":{bridgeUrl:"https://testnets.relay.link/bridge/zero-sepolia"},"7777777":{bridgeUrl:"https://relay.link/bridge/zora"},"8253038":{bridgeUrl:"https://relay.link/bridge/bitcoin"},"9092725":{bridgeUrl:"https://testnets.relay.link/bridge/bitcoin-testnet4"},"9286185":{bridgeUrl:"https://relay.link/bridge/eclipse"},"11155111":{bridgeUrl:"https://testnets.relay.link/bridge/sepolia"},"11155420":{bridgeUrl:"https://testnets.relay.link/bridge/op-sepolia"},"666666666":{bridgeUrl:"https://relay.link/bridge/degen"},"792703809":{bridgeUrl:"https://relay.link/bridge/solana"},"888888888":{bridgeUrl:"https://relay.link/bridge/ancient8"},"999999999":{bridgeUrl:"https://testnets.relay.link/bridge/zora-sepolia"},"1380012617":{bridgeUrl:"https://relay.link/bridge/rari"},"1936682084":{bridgeUrl:"https://testnets.relay.link/bridge/solana-devnet"},"88153591557":{bridgeUrl:"https://testnets.relay.link/bridge/arbitrum-blueberry"}};import{useQueryClient as Nn,useMutation as En}from"@tanstack/react-query";import{setBalance as Rn}from"viem/actions";import{useClient as Tn}from"wagmi";function Ut(){let e=Nn(),{chainId:t}=s(),r=Tn({chainId:t});return En({retry:0,mutationKey:["setBalance",t],mutationFn:async o=>(r&&(await Rn({...r,mode:"anvil"},o),await Promise.all([e.invalidateQueries({queryKey:["balance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])),null)})}import{Fragment as On,jsx as w,jsxs as V}from"react/jsx-runtime";function Nt({isActive:e,isExpanded:t,sessionAddress:r}){let{chain:o}=s(),n=z(In({chainId:o.id,address:r}));Mn({onBlockNumber:()=>n.refetch()});let a=A(Ut()),i=At[o.id];return V("div",{className:"flex flex-col gap-4",children:[V("div",{className:"flex justify-between gap-4",children:[V("div",{children:[w("div",{children:"Gas balance"}),w("div",{className:"font-mono text-white",children:n.data!=null?w(ae,{wei:n.data.value}):w(S,{className:"text-sm"})})]}),o.id===31337?w(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending"||a.status==="pending",onClick:()=>a.mutate({address:r,value:N+(n.data?.value??0n)}),children:"Top up"}):i!=null?w("a",{href:`${i.bridgeUrl}?${new URLSearchParams({toAddress:r})}`,target:"_blank",rel:"noopener noreferrer",children:w(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending",children:"Top up"})}):null]}),t?V(On,{children:[w("p",{className:"text-sm",children:"Your session's gas balance is used to pay for onchain computation."}),V("p",{className:"text-sm",children:["Send funds to"," ",w("span",{className:"font-mono text-white",children:w(H,{hex:r})})," ","on ",o.name," to top up your session balance."]})]}):null]})}import{jsx as E}from"react/jsx-runtime";function Rt({userClient:e,initialUserAddress:t}){let{chain:r}=s(),o=h(r),n=e.account.address,{data:a,error:i}=O(n);Et(()=>{i&&console.error("Could not get prerequisites",i)},[i]);let{closeAccountModal:l}=x(),c=n!==t,f=zn(a);Et(()=>{a!=null&&(f.current==null&&(f.current=a),a.complete&&(c||!f.current.complete)&&l())},[l,c,a]);let{sessionAddress:m,hasAllowance:d,isSpender:p,hasDelegation:g,hasGasBalance:_}=a??{},U=Hn(()=>{if(!n)return[{id:"wallet",isComplete:!1,content:()=>null}];let u=[{id:"wallet",isComplete:!0,content:v=>E(mt,{...v,userAddress:n})}];return o?o.type==="quarry"&&u.push({id:"allowance",isComplete:!!d,content:v=>E(bt,{...v,userAddress:n})}):m!=null&&u.push({id:"gasBalance",isComplete:!!_,content:v=>E(Nt,{...v,sessionAddress:m})}),u.push({id:"session",isComplete:!!p&&!!g,content:v=>E(Pt,{...v,userClient:e,registerSpender:!p,registerDelegation:!g})}),u},[d,g,_,p,o,m,n,e]),[Ee]=qn(null),Wt=U.find(u=>u.content!=null&&!u.isComplete),me=U.filter(u=>u.isComplete),ue=(Ee!=null?U.find(u=>u.id===Ee):null)??Wt??(me.length<U.length?me.at(-1):null),Re=ue?U.indexOf(ue):-1;return E("div",{className:Ne("px-8 flex flex-col divide-y divide-neutral-800","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:U.map((u,v)=>{let fe=u===ue,_t=fe||me.length===U.length,Yt=!u.isComplete&&Re!==-1&&v>Re;return E("div",{className:Ne("py-8 flex flex-col justify-center",fe?"flex-grow":null),children:E("div",{className:Ne("flex flex-col",Yt?"opacity-30 pointer-events-none":null),children:u.content({isActive:fe,isExpanded:_t})})},u.id)})})}import{useRef as Ln}from"react";import{jsx as Tt}from"react/jsx-runtime";function It(){let{chainId:e}=s(),t=Fn({chainId:e}),{address:r}=Bn(),o=Ln(r);return t.status!=="success"?Tt(Je,{}):Tt(Rt,{userClient:t.data,initialUserAddress:o.current})}import{DialogClose as Yn,DialogTitle as Xn}from"@radix-ui/react-dialog";import{twMerge as Dn}from"tailwind-merge";import{jsx as Kn}from"react/jsx-runtime";function Mt({className:e,children:t,...r}){return Kn("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:Dn("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...r,children:t})}import{jsx as Ot}from"react/jsx-runtime";function Ht(e){return Ot(Mt,{strokeWidth:"2",stroke:"currentColor",...e,children:Ot("path",{d:"M6 18L18 6M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{ErrorBoundary as $n}from"react-error-boundary";import{wait as Gn}from"@latticexyz/common/utils";import{useEffect as Qn}from"react";import{twMerge as se}from"tailwind-merge";import{Fragment as Vn,jsx as b,jsxs as W}from"react/jsx-runtime";function le({error:e,retry:t,dismiss:r}){return Qn(()=>{e&&console.error(e)},[e]),W("div",{className:"pointer-events-none absolute inset-0 overflow-clip",children:[b("div",{className:se("absolute inset-0 bg-blue-700/60","transition duration-300",e?"opacity-100 pointer-events-auto":"opacity-0")}),b("div",{className:se("absolute inset-0 pb-8","transition duration-300",e?"translate-y-0 opacity-100 pointer-events-auto":"-translate-y-4 opacity-0"),children:e?b(Vn,{children:W("div",{className:"w-full max-h-full bg-blue-700 text-white/80 overflow-auto",children:[W("div",{className:"space-y-6 px-8 pt-8",children:[b("div",{className:"text-white text-lg font-bold",children:"Oops! It broke :("}),b("div",{className:"font-mono text-xs whitespace-pre-wrap",children:e.message.trim()}),b("div",{className:"text-sm",children:"See the console for more info."})]}),W("div",{className:"pointer-events-none sticky bottom-0 left-0 -mt-2",children:[b("div",{className:"w-full h-12 bg-gradient-to-b from-transparent to-blue-700"}),t?b("div",{className:"bg-blue-700 text-center",children:W("button",{type:"button",className:se("pointer-events-auto group w-24 p-1 -translate-y-2 transition","bg-blue-600 hover:bg-blue-500 aria-busy:bg-blue-500","text-white text-sm font-medium","aria-busy:pointer-events-none"),onClick:async o=>{o.currentTarget.ariaBusy="true",await Gn(500),t(),o.currentTarget&&(o.currentTarget.ariaBusy=null)},children:[b("span",{className:"group-aria-busy:hidden",children:"Retry"}),b("span",{className:"hidden group-aria-busy:inline",children:"Retrying\u2026"})]})}):r?b("div",{className:"bg-blue-700 text-center",children:b("button",{type:"button",className:se("pointer-events-auto group w-24 p-1 -translate-y-2 transition","bg-blue-600 hover:bg-blue-500 aria-busy:bg-blue-500","text-white text-sm font-medium","aria-busy:pointer-events-none"),onClick:r,children:"Dismiss"})}):null]})]})}):null})]})}import{jsx as zt}from"react/jsx-runtime";function qt({error:e,resetErrorBoundary:t}){return zt("div",{className:"h-64",children:zt(le,{error:e,retry:t})})}import{useStore as Wn}from"zustand";import{jsx as _n}from"react/jsx-runtime";function Bt(){let e=Wn(re,t=>t.errors.at(0));return _n(le,{error:e?.error,retry:e?.retry,dismiss:e?.dismiss})}import{jsx as C,jsxs as de}from"react/jsx-runtime";function Lt(){let{accountModalOpen:e,toggleAccountModal:t}=x();return de($e,{open:e,onOpenChange:t,children:[C(Xn,{className:"sr-only",children:"Connect with EntryKit"}),e?de("div",{className:Ft("relative py-2 ring-1","bg-neutral-900 text-neutral-400 ring-neutral-700/50","links:font-medium links:underline links:underline-offset-4","links:text-white","links:decoration-neutral-500 hover:links:decoration-orange-500"),children:[C("div",{className:"absolute top-0 right-0",children:C(Yn,{className:Ft("pointer-events-auto leading-none p-2 transition","text-white/20 hover:text-white/40"),title:"Close",children:C(Ht,{className:"m-0"})})}),de($n,{FallbackComponent:qt,children:[C(It,{}),C(Bt,{})]}),de("a",{href:"https://mud.dev",target:"_blank",rel:"noreferrer noopener",className:"group self-center p-3 flex items-center justify-center gap-2 links-unset text-sm font-mono transition text-neutral-400 hover:text-white",children:[C("span",{className:"block w-4 h-4",children:C(P,{className:"w-full h-full text-orange-500 group-hover:rotate-90 transition duration-300"})}),C("span",{children:"Powered by MUD"})]})]}):null]})}import{jsx as Zn,jsxs as Jn}from"react/jsx-runtime";function jn({config:e,children:t}){return Jn(Ve,{config:e,children:[t,Zn(Lt,{})]})}import{useAccount as ta}from"wagmi";import{twMerge as R}from"tailwind-merge";import{twMerge as Dt}from"tailwind-merge";import{Fragment as ea,jsx as ce,jsxs as Kt}from"react/jsx-runtime";function Gt({address:e}){let{data:t}=te(e),r=j(t?.avatar);return Kt(ea,{children:[Kt("span",{className:"flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center",children:[ce("img",{src:t?.avatar&&r.isSuccess?t.avatar:void 0,className:Dt("col-start-1 row-start-1","inline-flex w-full h-full rounded-full bg-black/10 dark:bg-white/10 bg-cover bg-no-repeat bg-center","transtion duration-300",r.isSuccess?"opacity-100":"opacity-0")}),ce(P,{className:Dt("col-start-1 row-start-1 text-orange-500","transition duration-300",t&&(!t.avatar||r.isError)?"opacity-100":"opacity-0")})]}),ce("span",{className:"flex-grow",children:t?.name??ce(H,{hex:e})})]})}import{useRef as ra}from"react";import{jsx as k,jsxs as Vt}from"react/jsx-runtime";var Qt=R("w-48 p-3 inline-flex outline-none transition","border border-transparent","text-base leading-none"),oa=R("bg-neutral-100 border-neutral-300 text-black","dark:bg-neutral-800 dark:border-neutral-700 dark:text-white"),na=R("cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700");function aa(){let{openAccountModal:e,accountModalOpen:t}=x(),{status:r,address:o}=ta(),n=ra(o),a=O(o),i=r==="connected"||r==="reconnecting"&&o,l=o!==n.current,c=a.isSuccess?a.data.complete:l?!1:i,f=(()=>{if(a.isSuccess){if(!a.data.hasAllowance)return"Top up";if(!a.data.hasDelegation||!a.data.isSpender)return"Set up"}return"Sign in"})();return k(X,{mode:"child",children:c?k("button",{type:"button",className:R(Qt,oa,na),onClick:e,children:k("span",{className:"flex-grow inline-flex gap-2.5 items-center text-left font-medium",children:o?k(Gt,{address:o}):null})},"connected"):Vt("button",{type:"button",className:R(Qt,"group","items-center justify-center gap-2.5","bg-orange-500 text-white font-medium","hover:bg-orange-400","active:bg-orange-600"),"aria-busy":t,onClick:e,children:[Vt("span",{className:"pointer-events-none inline-grid place-items-center -ml-3",children:[k("span",{className:R("col-start-1 row-start-1 leading-none","scale-100 opacity-100 transition duration-300","group-aria-busy:scale-125 group-aria-busy:opacity-0"),children:k(P,{})}),k("span",{"aria-hidden":!0,className:R("col-start-1 row-start-1","scale-50 opacity-0 transition duration-300 delay-50","group-aria-busy:scale-100 group-aria-busy:opacity-100"),children:k(S,{})})]}),k("span",{className:"font-medium",children:f})]},"sign in")})}import{useConnectorClient as ia}from"wagmi";function sa(){let{chainId:e}=s(),t=ia({chainId:e});t.error&&console.error("Error retrieving user client",t.error);let r=t.data?.account.address,o=O(r),n=ie(r);return t.isSuccess?!o.isSuccess||!o.data.complete?{...o,data:void 0}:n:{...t,data:void 0}}import{connectorsForWallets as da}from"@rainbow-me/rainbowkit";import{createConfig as ca}from"wagmi";import{getDefaultWallets as la}from"@rainbow-me/rainbowkit";function pe(e){let{wallets:t}=la();return[...t]}function pa(e){let t=pe(e),r=da(t,{appName:e.appName,projectId:e.walletConnectProjectId});return ca({connectors:r,chains:e.chains,transports:e.transports,pollingInterval:e.pollingInterval})}import{connectorsForWallets as ma}from"@rainbow-me/rainbowkit";function $m({wallets:e,...t}){return ma(e??pe(t),{appName:t.appName,projectId:t.walletConnectProjectId})}export{aa as AccountButton,jn as EntryKitProvider,pa as createWagmiConfig,Xt as defineConfig,$m as getConnectors,pe as getWallets,x as useAccountModal,s as useEntryKitConfig,sa as useSessionClient};
1391
+ .group:hover .dark\\:group-hover\\:text-white:where([data-theme="dark"], [data-theme="dark"] *) {
1392
+ --tw-text-opacity: 1;
1393
+ color: rgb(255 255 255 / var(--tw-text-opacity));
1394
+ }
1395
+ `;import{useResizeObserver as rr}from"usehooks-ts";import{mergeRefs as or}from"react-merge-refs";import{createContext as Vt,useContext as Wt}from"react";import{jsx as _t}from"react/jsx-runtime";var ke=Vt(null);function Se({frame:e,children:t}){if(Wt(ke))throw new Error("`FrameProvider` can only be used once.");return _t(ke.Provider,{value:{frame:e},children:t})}import{useMediaQuery as Zt}from"usehooks-ts";import"@rainbow-me/rainbowkit/styles.css";import{createContext as Yt,useContext as Pe}from"react";import{RainbowKitProvider as Xt,midnightTheme as jt}from"@rainbow-me/rainbowkit";import{useChains as $t}from"wagmi";import{jsx as Ae}from"react/jsx-runtime";var ae=Yt(null);function Ue({config:e,children:t}){if(Pe(ae))throw new Error("`EntryKitProvider` can only be used once.");let n=$t().find(({id:a})=>a===e.chainId);if(!n)throw new Error(`Could not find configured chain for chain ID ${e.chainId}.`);return Ae(Xt,{initialChain:0,appInfo:{appName:e.appName},theme:jt({borderRadius:"none"}),children:Ae(ae.Provider,{value:{...e,chain:n},children:t})})}function l(){let e=Pe(ae);if(!e)throw new Error("`useEntryKitConfig` can only be used within a `EntryKitProvider`.");return e}function Ne(){let{theme:e}=l(),t=Zt("(prefers-color-scheme: dark)");return e??(t?"dark":"light")}import{jsx as O,jsxs as ar}from"react/jsx-runtime";function nr({onSize:e,...t}){let r=Re(null);return rr({ref:r,onResize:e}),O("div",{ref:r,...t,style:{...t.style,display:"inline-grid"}})}var Q=Jt(function({mode:t,children:r},o){let n=Re(null),[a,i]=Ee(!1),s=a?n.current:null,[c,g]=Ee({width:void 0,height:void 0}),m=s?.contentDocument,d=Ne();er(()=>{m&&m.body.setAttribute("data-theme",d)},[m,d]);let p=t==="modal"?{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",zIndex:"2147483646"}:c.width&&c.height?{all:"unset",display:"inline-grid",width:`${c.width}px`,height:`${c.height}px`}:{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",opacity:0,pointerEvents:"none"};return O("iframe",{ref:or([o,n]),style:p,onLoad:()=>i(!0),srcDoc:"<!doctype html><title>\u2026</title>",children:m?tr.createPortal(ar(Se,{frame:s,children:[O("div",{children:t==="modal"?r:O(nr,{onSize:g,children:r})}),O("style",{dangerouslySetInnerHTML:{__html:Ce}})]}),m.body):null})});import{twMerge as Te}from"tailwind-merge";import{jsx as E,jsxs as dr}from"react/jsx-runtime";function Me({open:e,onOpenChange:t,children:r}){return E(ir,{open:e,onOpenChange:t,children:E(sr,{children:dr(Q,{mode:"modal",children:[E("div",{className:Te("fixed inset-0","bg-neutral-800/85","animate-in animate-duration-300 fade-in")}),E("div",{className:Te("fixed inset-0","grid items-end sm:items-center","animate-in animate-duration-300 fade-in slide-in-from-bottom-16"),children:E("div",{children:E(lr,{className:"outline-none w-full max-w-[26rem] mx-auto","aria-describedby":void 0,onOpenAutoFocus:o=>{o.preventDefault()},children:r})})})]})})})}import{useCallback as ie,useMemo as cr}from"react";import{useStore as pr}from"zustand";import{createStore as mr}from"zustand/vanilla";var V=mr(()=>({open:!1}));function v(){let e=pr(V,n=>n.open),t=ie(()=>{V.setState({open:!0})},[]),r=ie(()=>{V.setState({open:!1})},[]),o=ie(n=>{V.setState({open:n})},[]);return cr(()=>({accountModalOpen:e,openAccountModal:t,closeAccountModal:r,toggleAccountModal:o}),[e,t,r,o])}import{twMerge as It}from"tailwind-merge";import{useAccount as En,useConnectorClient as Rn}from"wagmi";import{useAccount as vr}from"wagmi";import{twMerge as q}from"tailwind-merge";import{twMerge as ur}from"tailwind-merge";import{jsx as Ie,jsxs as gr}from"react/jsx-runtime";function b({className:e,...t}){return gr("svg",{className:ur("-my-[0.125em] h-[1.25em] w-[1.25em] animate-spin",e),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",...t,children:[Ie("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Ie("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}import{jsx as z,jsxs as hr}from"react/jsx-runtime";var fr=({variant:e="secondary"}={})=>q("group/button self-center leading-none outline-none border-4 border-transparent","transition hover:brightness-125 active:brightness-150","focus:border-orange-500","aria-disabled:pointer-events-none aria-busy:pointer-events-none","aria-disabled:opacity-50","p-[.75em] font-medium",{primary:q("bg-orange-600 text-white focus:border-yellow-400"),secondary:q("bg-neutral-700 text-white focus:border-orange-500"),tertiary:q("bg-neutral-800 text-white focus:border-orange-500")}[e]),y=({pending:e,variant:t,type:r,className:o,children:n,disabled:a,...i})=>z("button",{type:r||"button",className:q(fr({variant:t,pending:e}),o),"aria-busy":e,"aria-disabled":a,disabled:a||e,...i,children:hr("span",{className:"grid grid-cols-[1fr_auto_1fr] gap-2",children:[z("span",{className:"flex items-center justify-end text-[.75em]",children:z("span",{className:"transition opacity-0 translate-x-2 group-aria-busy/button:opacity-100 group-aria-busy/button:translate-x-0 duration-100 group-aria-busy/button:duration-300",children:z(b,{})})}),z("span",{children:n})]})});import{useConnectModal as Cr}from"@rainbow-me/rainbowkit";import{twMerge as yr}from"tailwind-merge";import{jsx as se,jsxs as br}from"react/jsx-runtime";function S({className:e,...t}){return br("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 8 8",fill:"currentColor",shapeRendering:"crispEdges",className:yr("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...t,children:[se("path",{d:"M0 0h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm2-1h1v1H7zm0 1h1v1H7zM6 7h1v1H6zm1-2h1v1H7zm0-1h1v1H7zm0-1h1v1H7z"}),se("path",{d:"M2 2h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm1-3h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm0 1h1v1H5zm0 1h1v1H5zm0 1h1v1H5zM4 5h1v1H4zM3 5h1v1H3z",opacity:".5"}),se("path",{d:"M7 2h1v1H7zm0-1h1v1H7zM1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm1 0h1v1H6zm1 0h1v1H7z"})]})}import{useQuery as wr}from"@tanstack/react-query";function W(e){return wr({enabled:!!e,retry:!1,retryOnMount:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,queryKey:["preloadImage",e],queryFn:()=>new Promise((t,r)=>{if(!e)throw new Error("usePreloadImage: Must provide `url` to preload image.");let o=new Image;o.onload=()=>t(o),o.onerror=()=>r(new Error(`usePreloadImage: Could not load image.
1396
+
1397
+ URL: ${e}`)),o.src=e})})}import{jsx as _,jsxs as xr}from"react/jsx-runtime";function He(){let{appName:e,appIcon:t}=l(),{data:r,isLoading:o}=W(t);return xr("div",{className:"flex-grow flex flex-col items-center justify-center gap-2",children:[_("div",{className:"w-16 h-16 m-2",children:o?null:r?_("img",{src:t,className:"w-full h-full object-cover"}):_(S,{className:"w-full h-full text-orange-500 dark:bg-neutral-800"})}),_("div",{className:"text-2xl text-white text-center",children:e})]})}import{twMerge as kr}from"tailwind-merge";import{useEffect as Sr,useState as Ar}from"react";import{jsx as Y,jsxs as Pr}from"react/jsx-runtime";function Oe(){let e=vr(),{openConnectModal:t,connectModalOpen:r}=Cr(),[o,n]=Ar(!1);return Sr(()=>{!r&&!o&&(t?.(),n(!0))},[r,o,t]),Pr("div",{className:kr("flex flex-col gap-6 p-6","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:[Y("div",{className:"p-4",children:Y(He,{})}),Y("div",{className:"self-center flex flex-col gap-2 w-60",children:Y(y,{variant:"secondary",className:"self-auto flex justify-center",disabled:e.status==="connecting",onClick:t,autoFocus:!0,children:"Connect wallet"},"create")})]})}import{useEffect as Ct,useMemo as Pn,useRef as Un,useState as Nn}from"react";import{twMerge as be}from"tailwind-merge";import{parseEther as Ur}from"viem";var P=Ur("0.01");import{useClient as zr}from"wagmi";import{queryOptions as qr,useQuery as Br}from"@tanstack/react-query";import{numberToHex as Tr}from"viem";import{defineStore as Nr}from"@latticexyz/store";import{parseAbi as Er}from"viem";var le=Er(["error SpenderSystem_AlreadyRegistered(address spender, address user)","error SpenderSystem_HasOwnBalance(address spender)","function registerSpender(address spender)"]),Rr=Nr({namespaces:{root:{namespace:"",tables:{Allowance:{schema:{user:"address",allowance:"uint256"},key:["user"]},Grantor:{schema:{grantor:"address",allowance:"uint256"},key:["grantor"]},PassHolder:{schema:{user:"address",passId:"bytes32",lastRenewed:"uint256",lastClaimed:"uint256"},key:["user","passId"]},PassConfig:{schema:{passId:"bytes32",claimAmount:"uint256",claimInterval:"uint256",validityPeriod:"uint256",grantor:"address"},key:["passId"]},Spender:{schema:{spender:"address",user:"address"},key:["spender"]},SystemConfig:{schema:{entryPoint:"address"},key:[]}}}}}),R=Rr.namespaces.root.tables;import{getRecord as Mr,getStaticDataLocation as Ir}from"@latticexyz/store/internal";import{getKeyTuple as Hr}from"@latticexyz/protocol-parser/internal";import{setStorageAt as Or}from"viem/actions";function h(e){let t=e.contracts??{};if("quarryPaymaster"in t&&t.quarryPaymaster!=null&&"address"in t.quarryPaymaster)return{type:"quarry",address:t.quarryPaymaster.address};if("paymaster"in t&&t.paymaster!=null&&"address"in t.paymaster)return{type:"simple",address:t.paymaster.address}}async function ze({client:e,userAddress:t}){let r=h(e.chain);return r?.type!=="quarry"?null:(await Mr(e,{address:r.address,table:R.Allowance,key:{user:t},blockTag:"pending"})).allowance}async function qe({client:e,userAddress:t,allowance:r}){let o=h(e.chain);if(o?.type!=="quarry")return;let n=Ir(R.Allowance.tableId,Hr(R.Allowance,{user:t}));await Or(e.extend(()=>({mode:"anvil"})),{address:o.address,index:n,value:Tr(r,{size:32})})}function de({client:e,userAddress:t}){let r=["getAllowance",e?.chain.id,t];return qr(e&&t?{queryKey:r,queryFn:()=>ze({client:e,userAddress:t})}:{queryKey:r,enabled:!1})}function Be(e){let{chainId:t}=l(),r=zr({chainId:t});return Br(de({client:r,userAddress:e}))}import{useClient as Di}from"wagmi";import{queryOptions as Fr,useQuery as Qi}from"@tanstack/react-query";import{getRecord as Lr}from"@latticexyz/store/internal";async function Le({client:e,userAddress:t,sessionAddress:r}){let o=h(e.chain);return o?.type!=="quarry"?null:(await Lr(e,{address:o.address,table:R.Spender,key:{spender:r},blockTag:"pending"})).user.toLowerCase()===t.toLowerCase()}function Fe({client:e,userAddress:t,sessionAddress:r}){let o=["getSpender",e?.chain.id,t,r];return Fr(e&&t&&r?{queryKey:o,queryFn:()=>Le({client:e,userAddress:t,sessionAddress:r})}:{queryKey:o,enabled:!1})}import{useClient as ls}from"wagmi";import{queryOptions as Vr,useQuery as cs}from"@tanstack/react-query";import{getRecord as Qr}from"@latticexyz/store/internal";import{resourceToHex as Kr}from"@latticexyz/common";import{parseAbi as Dr}from"viem";import Gr from"@latticexyz/world/mud.config";var Ke={pollingInterval:250},B=Kr({type:"system",namespace:"",name:"unlimited"}),De=Gr.namespaces.world.tables,Ge=Dr(["function registerDelegation(address delegatee, bytes32 delegationControlId, bytes initCallData)"]);async function Qe({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){return(await Qr(e,{address:t,table:De.UserDelegationControl,key:{delegator:r,delegatee:o},blockTag:"pending"})).delegationControlId===B}function Ve({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){let n=["getDelegation",e?.chain.id,t,r,o];return Vr(e&&r&&o?{queryKey:n,queryFn:()=>Qe({client:e,worldAddress:t,userAddress:r,sessionAddress:o})}:{queryKey:n,enabled:!1})}import{queryOptions as ro,useQuery as oo,useQueryClient as no}from"@tanstack/react-query";import{useClient as ao,useConfig as io}from"wagmi";import{useClient as Jr}from"wagmi";import{queryOptions as eo,useQuery as to}from"@tanstack/react-query";import{toSimpleSmartAccount as Zr}from"permissionless/accounts";import{isHex as Xr}from"viem";import{createStore as Wr}from"zustand/vanilla";import{persist as _r}from"zustand/middleware";var L=Wr(_r(()=>({signers:{}}),{name:"mud:entrykit",partialize:({signers:e})=>({signers:e})}));function Yr(e){e.key===L.persist.getOptions().name&&L.persist.rehydrate()}window.addEventListener("storage",Yr);import{generatePrivateKey as jr,privateKeyToAccount as $r}from"viem/accounts";function We(e){let t=e.toLowerCase(),r=L.getState().signers[t]??(()=>{let o=localStorage.getItem(`mud:appSigner:privateKey:${e.toLowerCase()}`)?.replace(/^"(.*)"$/,"$1"),n=Xr(o)?o:jr();return L.setState(a=>({signers:{...a.signers,[t]:n}})),n})();return $r(r)}async function _e({client:e,userAddress:t}){let r=We(t);return await Zr({client:e,owner:r})}function ce({client:e,userAddress:t}){let r=["getSessionAccount",e?.chain.id,t];return eo(e&&t?{queryKey:r,queryFn:()=>_e({client:e,userAddress:t}),staleTime:1/0}:{queryKey:r,enabled:!1})}function Ye(e){let{chainId:t}=l(),r=Jr({chainId:t});return to(ce({userAddress:e,client:r}))}import{getBalanceQueryOptions as so}from"wagmi/query";function lo({queryClient:e,config:t,client:r,userAddress:o,worldAddress:n}){let a=["getPrerequisites",r?.chain.id,o];return ro(r&&o?{queryKey:a,queryFn:async()=>{let i=h(r.chain),{address:s}=await e.fetchQuery(ce({client:r,userAddress:o})),[c,g,m,d]=await Promise.all([i?null:e.fetchQuery(so(t,{chainId:r.chain.id,address:s})),i?.type==="quarry"?e.fetchQuery(de({client:r,userAddress:o})):null,i?.type==="quarry"?e.fetchQuery(Fe({client:r,userAddress:o,sessionAddress:s})):null,e.fetchQuery(Ve({client:r,worldAddress:n,userAddress:o,sessionAddress:s}))]),p=g==null||g>=P,f=m??!0,G=c==null||c.value>=P;return{sessionAddress:s,hasAllowance:p,isSpender:f,hasGasBalance:G,hasDelegation:d,complete:p&&f&&d}}}:{queryKey:a,enabled:!1})}function T(e){let t=no(),{chainId:r,worldAddress:o}=l(),n=io(),a=ao({chainId:r});return oo(lo({config:n,queryClient:t,client:a,userAddress:e,worldAddress:o}),t)}import{useDisconnect as mo}from"wagmi";import{useQuery as co}from"@tanstack/react-query";function X(e){let t=e?.toLowerCase();return co({enabled:!!t,queryKey:["ens",t],queryFn:async()=>{let r=await fetch(`https://api.ensideas.com/ens/resolve/${t}`).then(o=>o.json());return{address:r.address??void 0,name:r.name??void 0,displayName:r.displayName??void 0,avatar:r.avatar??void 0}}})}import{jsx as pe,jsxs as po}from"react/jsx-runtime";function M({hex:e}){return e.length<=10?pe("span",{title:e,children:e}):po("span",{title:e,children:[pe("span",{className:"after:select-none after:content-['\u2026']",children:e.slice(0,6)}),pe("span",{className:"tracking-[-1ch] text-transparent",children:e.slice(6,-4)}),e.slice(-4)]})}import{useEffect as uo}from"react";import{jsx as F,jsxs as me}from"react/jsx-runtime";function Xe({isActive:e,isExpanded:t,userAddress:r}){let{data:o,error:n}=X(r);uo(()=>{n&&console.log("Could not get ENS",n)},[n]);let{disconnect:a,isPending:i}=mo(),{closeAccountModal:s}=v();return me("div",{className:"flex flex-col gap-4",children:[me("div",{className:"flex justify-between gap-4",children:[me("div",{children:[F("div",{children:"Account"}),F("div",{className:"font-mono text-white",children:o?.name??F(M,{hex:r})})]}),F(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:i,onClick:()=>{s(),a()},children:"Sign out"})]}),t?F("p",{className:"text-sm",children:"Each of your onchain actions in this app is associated with your account."}):null]})}import{parseEther as ho}from"viem";import{useMutation as yo,useQueryClient as bo}from"@tanstack/react-query";import{http as go}from"viem";function je(){return({chain:e})=>{if(!e)throw new Error("No chain provided to issuer transport.");let t="quarryPassIssuer"in e.rpcUrls?e.rpcUrls.quarryPassIssuer.http[0]:void 0;if(!t)throw new Error(`No \`quarryPassIssuer\` RPC URL found for chain ${e.id}.`);return go(t)({chain:e,retryCount:0})}}import $e from"debug";var ue=$e("mud:entrykit"),fo=$e("mud:entrykit");ue.log=console.debug.bind(console);fo.log=console.error.bind(console);var I=ue.extend("quarry");async function Ze({chain:e,userAddress:t}){let r=je()({chain:e});I("Issuing gas pass to",t),await r.request({method:"quarry_issuePass",params:["0x01",t]}),I("Claiming gas allowance for",t),await r.request({method:"quarry_claimAllowance",params:["0x01",t]})}import{useClient as wo}from"wagmi";function Je(){let e=bo(),{chain:t}=l(),r=wo({chainId:t.id}),o=["claimGasPass",t.id];return yo({mutationKey:o,onError:n=>console.error(n),mutationFn:async n=>{if(t.id===31337){if(!r)throw new Error("No client?");await qe({client:r,userAddress:n,allowance:ho("1")})}else await Ze({chain:t,userAddress:n});await Promise.all([e.invalidateQueries({queryKey:["getAllowance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{twMerge as xo}from"tailwind-merge";import{jsx as j,jsxs as vo}from"react/jsx-runtime";function et({className:e,...t}){return vo("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 263 428",fill:"currentColor",className:xo("w-[0.6em] h-[1em]",e),...t,children:[j("path",{d:"M132 321V428L263 243L132 321Z"}),j("path",{d:"M0 243L132 321V428",fillOpacity:"0.5"}),j("path",{d:"M132 0V296L263 218"}),j("path",{d:"M0 218L132 296V0L0 218Z",fillOpacity:"0.5"})]})}import{formatEther as Co}from"viem";function tt(e){let t=Co(e),r=Math.floor(parseFloat(t)).toString().length;return parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:Math.max(0,6-r)})}import{formatEther as ko}from"viem";import{jsx as So,jsxs as Ao}from"react/jsx-runtime";function $({wei:e}){return Ao("span",{className:"inline-flex items-center gap-1",title:ko(e),children:[tt(e)," ",So(et,{})]})}import{useEffect as Po}from"react";import{jsx as H,jsxs as ge}from"react/jsx-runtime";function rt({isActive:e,isExpanded:t,userAddress:r}){let o=Be(r),n=Je();return Po(()=>{let a=setTimeout(()=>{e&&n.status==="idle"&&o.isSuccess&&o.data!=null&&o.data<P&&n.mutate(r)});return()=>clearTimeout(a)},[o.data,o.isSuccess,n,e,r]),ge("div",{className:"flex flex-col gap-4",children:[ge("div",{className:"flex justify-between gap-4",children:[ge("div",{children:[H("div",{children:"Allowance"}),H("div",{className:"font-mono text-white",children:o.data!=null?H($,{wei:o.data}):H(b,{className:"text-sm"})})]}),H(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:o.status==="pending"||n.status==="pending",onClick:()=>n.mutate(r),children:"Top up"})]}),t?H("p",{className:"text-sm",children:"Your allowance is used to pay for onchain computation."}):null]})}import{encodeFunctionData as nt}from"viem";import{useMutation as qo,useQueryClient as Bo}from"@tanstack/react-query";import{getAction as he}from"viem/utils";import{sendUserOperation as Lo,waitForUserOperationReceipt as Fo}from"viem/account-abstraction";import{waitForTransactionReceipt as Ko}from"viem/actions";import{useClient as Do}from"wagmi";import{resourceToHex as at}from"@latticexyz/common";import Go from"@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json";import{writeContract as Ho}from"viem/actions";import{getAction as Oo}from"viem/utils";import{toHex as Uo}from"viem";import{signTypedData as No}from"viem/actions";import{callWithSignatureTypes as Eo}from"@latticexyz/world-module-callwithsignature/internal";import{getRecord as Ro}from"@latticexyz/store/internal";import To from"@latticexyz/world-module-callwithsignature/mud.config";import{hexToResource as Mo}from"@latticexyz/common";import{getAction as Io}from"viem/utils";async function ot({userClient:e,worldAddress:t,systemId:r,callData:o,nonce:n,client:a}){let i=n??(a?(await Ro(a,{address:t,table:To.tables.CallWithSignatureNonces,key:{signer:e.account.address},blockTag:"pending"})).nonce:0n),{namespace:s,name:c}=Mo(r);return await Io(e,No,"signTypedData")({account:e.account,domain:{verifyingContract:t,salt:Uo(e.chain.id,{size:32})},types:Eo,primaryType:"Call",message:{signer:e.account.address,systemNamespace:s,systemName:c,callData:o,nonce:i}})}import zo from"@latticexyz/world-module-callwithsignature/out/CallWithSignatureSystem.sol/CallWithSignatureSystem.abi.json";async function fe({sessionClient:e,...t}){let r=await ot(t);return Oo(e,Ho,"writeContract")({address:t.worldAddress,abi:zo,functionName:"callWithSignature",args:[t.userClient.account.address,t.systemId,t.callData,r]})}function it({userClient:e}){let t=Bo(),{chainId:r,worldAddress:o}=l(),n=Do({chainId:r}),a=["setupSession",n?.chain.id,e.account.address];return qo({mutationKey:a,onError:i=>console.error(i),mutationFn:async({sessionClient:i,registerSpender:s,registerDelegation:c})=>{if(!n)throw new Error("Client not ready.");let g=h(n.chain),m=i.account.address;if(console.log("setting up session"),e.account.type==="smart"){let d=[];if(s&&g?.type==="quarry"&&(console.log("registering spender"),d.push({to:g.address,abi:le,functionName:"registerSpender",args:[m]})),c&&(console.log("registering delegation"),d.push({to:o,abi:Ge,functionName:"registerDelegation",args:[m,B,"0x"]})),!d.length)return;console.log("setting up account with",d,e);let p=await he(e,Lo,"sendUserOperation")({calls:d});console.log("got user op hash",p);let f=await he(e,Fo,"waitForUserOperationReceipt")({hash:p});console.log("got user op receipt",f),f.success||console.error("not successful?",f)}else{let d=[];if(s&&g?.type==="quarry"){console.log("registering spender");let p=await fe({client:n,userClient:e,sessionClient:i,worldAddress:g.address,systemId:at({type:"system",namespace:"",name:"SpenderSystem"}),callData:nt({abi:le,functionName:"registerSpender",args:[m]})});console.log("got spender tx",p),d.push(p)}if(c){console.log("registering delegation");let p=await fe({client:n,userClient:e,sessionClient:i,worldAddress:o,systemId:at({type:"system",namespace:"",name:"Registration"}),callData:nt({abi:Go,functionName:"registerDelegation",args:[m,B,"0x"]})});console.log("got delegation tx",p),d.push(p)}if(!d.length)return;console.log("waiting for",d.length,"receipts");for(let p of d){let f=await he(n,Ko,"waitForTransactionReceipt")({hash:p});console.log("got tx receipt",f),f.status==="reverted"&&console.error("tx reverted?",f)}}await Promise.all([t.invalidateQueries({queryKey:["getSpender"]}),t.invalidateQueries({queryKey:["getDelegation"]}),t.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{useEffect as bn}from"react";import{useClient as un}from"wagmi";import{queryOptions as gn,useQuery as fn}from"@tanstack/react-query";import{smartAccountActions as pn}from"permissionless";import{callFrom as mn}from"@latticexyz/world/internal";import{createBundlerClient as Qo}from"viem/account-abstraction";var Vo=new Set([31337,17420,17069,690]);function st(e){let t=e.chain??e.client?.chain,r=t?h(t):void 0;return Qo({...Ke,paymaster:r?{getPaymasterData:async()=>({paymaster:r.address,paymasterData:"0x"})}:void 0,userOperation:{estimateFeesPerGas:t&&Vo.has(t.id)?async()=>({maxFeePerGas:100000n,maxPriorityFeePerGas:0n}):void 0},...e})}import{transactionQueue as on}from"@latticexyz/common/actions";import{createClient as nn,fallback as an,http as ft,keccak256 as sn,stringToHex as ln,webSocket as dn}from"viem";import{privateKeyToAccount as cn}from"viem/accounts";import{createTransport as Jo,numberToHex as en,parseEther as tn}from"viem";import{entryPoint07Address as ut}from"viem/account-abstraction";import{formatUserOperationRequest as Wo}from"viem/account-abstraction";async function lt(e){return Wo({callGasLimit:20000000n,preVerificationGas:200000n,verificationGasLimit:2000000n,paymasterVerificationGasLimit:200000n,paymasterPostOpGasLimit:200000n})}import{parseEventLogs as _o}from"viem";import{formatUserOperation as Yo,toPackedUserOperation as Xo,getUserOperationHash as jo,entryPoint07Address as dt,entryPoint07Abi as ct}from"viem/account-abstraction";import{waitForTransactionReceipt as $o,writeContract as Zo}from"viem/actions";import{getAction as pt}from"viem/utils";async function mt({executor:e,rpcUserOp:t}){let r=Yo(t),o=Xo(r),n=jo({userOperation:r,chainId:e.chain.id,entryPointVersion:"0.7",entryPointAddress:dt}),a=await pt(e,Zo,"writeContract")({abi:ct,address:dt,functionName:"handleOps",args:[[o],e.account.address],chain:e.chain,account:e.account}),i=await pt(e,$o,"waitForTransactionReceipt")({hash:a});return{success:_o({logs:i.logs,abi:ct,eventName:"UserOperationEvent"})[0].args.success,userOpHash:n,receipt:i}}import{setBalance as rn}from"viem/actions";function gt({executor:e}){return()=>{I("using a local user op executor",e.account.address),e.chain.id===31337&&(I("setting executor balance"),rn(e.extend(()=>({mode:"anvil"})),{address:e.account.address,value:tn("100")}));let t=new Map;return Jo({key:"userOpExecutor",type:"userOpExecutor",name:"User Operation Executor Transport",request:async({method:o,params:n})=>{if(o==="eth_chainId")return en(e.chain.id);if(o==="eth_supportedEntryPoints")return[ut];if(o==="eth_sendUserOperation"){let[a,i]=n;if(i===ut){let s=await mt({executor:e,rpcUserOp:a});return t.set(s.userOpHash,s),s.userOpHash}}if(o==="eth_getUserOperationReceipt"){let[a]=n;return t.get(a)??null}if(o==="eth_estimateUserOperationGas")return await lt(n);throw new Error("Method not implemented.")}})}}function ht(e){let t=e.rpcUrls.bundler?.http[0],r=t?ft(t):e.id===31337?gt({executor:nn({chain:e,transport:an([dn(),ft()]),account:cn(sn(ln("local user op executor"))),pollingInterval:10}).extend(on())}):null;if(!r)throw new Error(`Chain ${e.id} config did not include a bundler RPC URL.`);return r}async function yt({client:e,userAddress:t,sessionAccount:r,worldAddress:o}){let n=ht(e.chain);return st({transport:n,client:e,account:r}).extend(pn).extend(mn({worldAddress:o,delegatorAddress:t,publicClient:e})).extend(()=>({userAddress:t}))}import{useEffect as hn}from"react";function yn({sessionAccount:e,client:t,userAddress:r,worldAddress:o}){let n=["getSessionClient",t?.uid,r,e?.address,o];return gn(t&&r&&e?{queryKey:n,queryFn:()=>yt({sessionAccount:e,client:t,userAddress:r,worldAddress:o}),staleTime:1/0}:{queryKey:n,enabled:!1})}function Z(e){let{chainId:t,worldAddress:r}=l(),o=un({chainId:t}),{data:n,error:a}=Ye(e);return hn(()=>{a&&console.error("Could not get session account",a)},[a]),fn(yn({sessionAccount:n,userAddress:e,client:o,worldAddress:r}))}import{jsx as K,jsxs as ye}from"react/jsx-runtime";function bt({isActive:e,isExpanded:t,userClient:r,registerSpender:o,registerDelegation:n}){let a=Z(r.account.address),i=it({userClient:r}),s=!n&&!n;return bn(()=>{let c=setTimeout(()=>{e&&i.status==="idle"&&a.data&&!s&&i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n})});return()=>clearTimeout(c)},[s,e,n,o,a,i]),ye("div",{className:"flex flex-col gap-4",children:[ye("div",{className:"flex justify-between gap-4",children:[ye("div",{children:[K("div",{children:"Session"}),K("div",{className:"font-mono text-white",children:s?"Enabled":"Set up"})]}),s?K(y,{variant:"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,disabled:!0,children:"Enabled"}):K(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:!a.data||i.status==="pending",onClick:a.data?()=>i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n}):void 0,children:"Enable"})]}),t?K("p",{className:"text-sm",children:"You can perform actions in this app without interruptions for approvals."}):null]})}import{useBalance as Sn}from"wagmi";var wt={"1":{bridgeUrl:"https://relay.link/bridge/ethereum"},"10":{bridgeUrl:"https://relay.link/bridge/optimism"},"56":{bridgeUrl:"https://relay.link/bridge/bnb"},"100":{bridgeUrl:"https://relay.link/bridge/gnosis"},"111":{bridgeUrl:"https://testnets.relay.link/bridge/bob"},"137":{bridgeUrl:"https://relay.link/bridge/polygon"},"185":{bridgeUrl:"https://relay.link/bridge/mint"},"288":{bridgeUrl:"https://relay.link/bridge/boba"},"324":{bridgeUrl:"https://relay.link/bridge/zksync"},"360":{bridgeUrl:"https://relay.link/bridge/shape"},"480":{bridgeUrl:"https://relay.link/bridge/world-chain"},"690":{bridgeUrl:"https://relay.link/bridge/redstone"},"919":{bridgeUrl:"https://testnets.relay.link/bridge/mode-testnet"},"1101":{bridgeUrl:"https://relay.link/bridge/polygon-zkevm"},"1135":{bridgeUrl:"https://relay.link/bridge/lisk"},"1301":{bridgeUrl:"https://testnets.relay.link/bridge/unichain-sepolia"},"1329":{bridgeUrl:"https://relay.link/bridge/sei"},"1625":{bridgeUrl:"https://relay.link/bridge/gravity"},"1868":{bridgeUrl:"https://relay.link/bridge/soneium"},"1993":{bridgeUrl:"https://testnets.relay.link/bridge/b3"},"1996":{bridgeUrl:"https://relay.link/bridge/sanko"},"2741":{bridgeUrl:"https://relay.link/bridge/abstract"},"2911":{bridgeUrl:"https://relay.link/bridge/hychain"},"4202":{bridgeUrl:"https://testnets.relay.link/bridge/lisk-sepolia"},"4321":{bridgeUrl:"https://relay.link/bridge/echos"},"5000":{bridgeUrl:"https://relay.link/bridge/mantle"},"5112":{bridgeUrl:"https://relay.link/bridge/ham"},"7560":{bridgeUrl:"https://relay.link/bridge/cyber"},"7865":{bridgeUrl:"https://relay.link/bridge/powerloom"},"7897":{bridgeUrl:"https://relay.link/bridge/arena-z"},"8333":{bridgeUrl:"https://relay.link/bridge/B3"},"8453":{bridgeUrl:"https://relay.link/bridge/base"},"9897":{bridgeUrl:"https://testnets.relay.link/bridge/arena-z-testnet"},"11011":{bridgeUrl:"https://testnets.relay.link/bridge/shape-sepolia"},"11124":{bridgeUrl:"https://testnets.relay.link/bridge/abstract"},"13746":{bridgeUrl:"https://testnets.relay.link/bridge/game7-testnet"},"17000":{bridgeUrl:"https://testnets.relay.link/bridge/holesky"},"17069":{bridgeUrl:"https://testnets.relay.link/bridge/garnet"},"17071":{bridgeUrl:"https://relay.link/bridge/onchain-points"},"33139":{bridgeUrl:"https://relay.link/bridge/apechain"},"33979":{bridgeUrl:"https://relay.link/bridge/funki"},"34443":{bridgeUrl:"https://relay.link/bridge/mode"},"42161":{bridgeUrl:"https://relay.link/bridge/arbitrum"},"42170":{bridgeUrl:"https://relay.link/bridge/arbitrum-nova"},"43114":{bridgeUrl:"https://relay.link/bridge/avalanche"},"55244":{bridgeUrl:"https://relay.link/bridge/superposition"},"57073":{bridgeUrl:"https://relay.link/bridge/ink"},"59144":{bridgeUrl:"https://relay.link/bridge/linea"},"60808":{bridgeUrl:"https://relay.link/bridge/bob"},"70700":{bridgeUrl:"https://relay.link/bridge/apex"},"70701":{bridgeUrl:"https://relay.link/bridge/boss"},"70800":{bridgeUrl:"https://testnets.relay.link/bridge/apex-testnet"},"70805":{bridgeUrl:"https://testnets.relay.link/bridge/cloud"},"80002":{bridgeUrl:"https://testnets.relay.link/bridge/amoy"},"81457":{bridgeUrl:"https://relay.link/bridge/blast"},"84532":{bridgeUrl:"https://testnets.relay.link/bridge/base-sepolia"},"167009":{bridgeUrl:"https://testnets.relay.link/bridge/hekla"},"421614":{bridgeUrl:"https://testnets.relay.link/bridge/arbitrum-sepolia"},"534352":{bridgeUrl:"https://relay.link/bridge/scroll"},"543210":{bridgeUrl:"https://relay.link/bridge/zero-network"},"660279":{bridgeUrl:"https://relay.link/bridge/xai"},"911867":{bridgeUrl:"https://testnets.relay.link/bridge/odyssey"},"984122":{bridgeUrl:"https://relay.link/bridge/forma"},"1118190":{bridgeUrl:"https://testnets.relay.link/bridge/eclipse-testnet"},"3397901":{bridgeUrl:"https://testnets.relay.link/bridge/funki-testnet"},"4457845":{bridgeUrl:"https://testnets.relay.link/bridge/zero-sepolia"},"7777777":{bridgeUrl:"https://relay.link/bridge/zora"},"8253038":{bridgeUrl:"https://relay.link/bridge/bitcoin"},"9092725":{bridgeUrl:"https://testnets.relay.link/bridge/bitcoin-testnet4"},"9286185":{bridgeUrl:"https://relay.link/bridge/eclipse"},"11155111":{bridgeUrl:"https://testnets.relay.link/bridge/sepolia"},"11155420":{bridgeUrl:"https://testnets.relay.link/bridge/op-sepolia"},"666666666":{bridgeUrl:"https://relay.link/bridge/degen"},"792703809":{bridgeUrl:"https://relay.link/bridge/solana"},"888888888":{bridgeUrl:"https://relay.link/bridge/ancient8"},"999999999":{bridgeUrl:"https://testnets.relay.link/bridge/zora-sepolia"},"1380012617":{bridgeUrl:"https://relay.link/bridge/rari"},"1936682084":{bridgeUrl:"https://testnets.relay.link/bridge/solana-devnet"},"88153591557":{bridgeUrl:"https://testnets.relay.link/bridge/arbitrum-blueberry"}};import{useQueryClient as xn,useMutation as vn}from"@tanstack/react-query";import{setBalance as Cn}from"viem/actions";import{useClient as kn}from"wagmi";function xt(){let e=xn(),{chainId:t}=l(),r=kn({chainId:t});return vn({mutationKey:["setBalance",t],onError:o=>console.error(o),mutationFn:async o=>(r&&(await Cn({...r,mode:"anvil"},o),await Promise.all([e.invalidateQueries({queryKey:["balance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])),null),retry:0})}import{Fragment as An,jsx as w,jsxs as D}from"react/jsx-runtime";function vt({isActive:e,isExpanded:t,sessionAddress:r}){let{chain:o}=l(),n=Sn({chainId:o.id,address:r,query:{refetchInterval:2e3}}),a=xt(),i=wt[o.id];return D("div",{className:"flex flex-col gap-4",children:[D("div",{className:"flex justify-between gap-4",children:[D("div",{children:[w("div",{children:"Gas balance"}),w("div",{className:"font-mono text-white",children:n.data!=null?w($,{wei:n.data.value}):w(b,{className:"text-sm"})})]}),o.id===31337?w(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending"||a.status==="pending",onClick:()=>a.mutate({address:r,value:P+(n.data?.value??0n)}),children:"Top up"}):i!=null?w("a",{href:`${i.bridgeUrl}?${new URLSearchParams({toAddress:r})}`,target:"_blank",rel:"noopener noreferrer",children:w(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending",children:"Top up"})}):null]}),t?D(An,{children:[w("p",{className:"text-sm",children:"Your session's gas balance is used to pay for onchain computation."}),D("p",{className:"text-sm",children:["Send funds to"," ",w("span",{className:"font-mono text-white",children:w(M,{hex:r})})," ","on ",o.name," to top up your session balance."]})]}):null]})}import{jsx as U}from"react/jsx-runtime";function kt({userClient:e,initialUserAddress:t}){let{chain:r}=l(),o=h(r),n=e.account.address,{data:a,error:i}=T(n);Ct(()=>{i&&console.error("Could not get prerequisites",i)},[i]);let{closeAccountModal:s}=v(),c=n!==t,g=Un(a);Ct(()=>{a!=null&&(g.current==null&&(g.current=a),a.complete&&(c||!g.current.complete)&&s())},[s,c,a]);let{sessionAddress:m,hasAllowance:d,isSpender:p,hasDelegation:f,hasGasBalance:G}=a??{},A=Pn(()=>{if(!n)return[{id:"wallet",isComplete:!1,content:()=>null}];let u=[{id:"wallet",isComplete:!0,content:x=>U(Xe,{...x,userAddress:n})}];return o?o.type==="quarry"&&u.push({id:"allowance",isComplete:!!d,content:x=>U(rt,{...x,userAddress:n})}):m!=null&&u.push({id:"gasBalance",isComplete:!!G,content:x=>U(vt,{...x,sessionAddress:m})}),u.push({id:"session",isComplete:!!p&&!!f,content:x=>U(bt,{...x,userClient:e,registerSpender:!p,registerDelegation:!f})}),u},[d,f,G,p,o,m,n,e]),[xe]=Nn(null),Ft=A.find(u=>u.content!=null&&!u.isComplete),re=A.filter(u=>u.isComplete),oe=(xe!=null?A.find(u=>u.id===xe):null)??Ft??(re.length<A.length?re.at(-1):null),ve=oe?A.indexOf(oe):-1;return U("div",{className:be("px-8 flex flex-col divide-y divide-neutral-800","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:A.map((u,x)=>{let ne=u===oe,Kt=ne||re.length===A.length,Dt=!u.isComplete&&ve!==-1&&x>ve;return U("div",{className:be("py-8 flex flex-col justify-center",ne?"flex-grow":null),children:U("div",{className:be("flex flex-col",Dt?"opacity-30 pointer-events-none":null),children:u.content({isActive:ne,isExpanded:Kt})})},u.id)})})}import{useRef as Tn}from"react";import{jsx as St}from"react/jsx-runtime";function At(){let{chainId:e}=l(),t=Rn({chainId:e}),{address:r}=En(),o=Tn(r);return t.status!=="success"?St(Oe,{}):St(kt,{userClient:t.data,initialUserAddress:o.current})}import{useState as zn}from"react";import{ErrorBoundary as qn}from"react-error-boundary";import{twMerge as Mn}from"tailwind-merge";import{BaseError as In,UserRejectedRequestError as Hn}from"viem";import{jsx as Pt,jsxs as On}from"react/jsx-runtime";function Ut({title:e,error:t}){if(!t||t instanceof In&&t.walk(n=>n instanceof Hn)!=null)return null;let r=e??"Error",o=typeof t=="string"?t:t instanceof Error?String(t):"Something unexpected happened.";return On("div",{className:Mn("text-sm border-l-4 border-red-500","bg-red-100 text-red-900","dark:bg-red-900 dark:text-red-50"),children:[Pt("div",{className:"p-3 font-semibold",children:r}),Pt("div",{className:"px-3 whitespace-break-spaces break-all max-h-32 overflow-y-scroll",children:o})]})}import{wait as Bn}from"@latticexyz/common/utils";import{twMerge as Ln}from"tailwind-merge";import{useIsMounted as Fn}from"usehooks-ts";import{jsx as J,jsxs as Nt}from"react/jsx-runtime";function Et({children:e}){let t=Fn(),[r,o]=zn(1);return J(qn,{fallbackRender:({error:n,resetErrorBoundary:a})=>Nt("div",{className:Ln("flex-grow flex flex-col justify-center p-5 gap-2"),children:[J(Ut,{error:n instanceof Error?n.stack??n.message:n}),r>0?Nt("button",{type:"button",onClick:async i=>{i.currentTarget.ariaBusy="true",await Bn(1e3),a(),t()&&(o(s=>s-1),i.currentTarget.ariaBusy=null)},className:"group aria-busy:pointer-events-none self-end flex items-center gap-1",children:[J(b,{className:"transition opacity-0 group-aria-busy:opacity-100 text-xs text-neutral-500 dark:text-neutral-400"}),J("span",{className:"text-sm text-neutral-500 dark:text-neutral-400 group-hover:text-black dark:group-hover:text-white",children:"Retry?"})]}):null]}),children:e})}import{DialogClose as Gn,DialogTitle as Qn}from"@radix-ui/react-dialog";import{twMerge as Kn}from"tailwind-merge";import{jsx as Dn}from"react/jsx-runtime";function Rt({className:e,children:t,...r}){return Dn("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:Kn("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...r,children:t})}import{jsx as Tt}from"react/jsx-runtime";function Mt(e){return Tt(Rt,{strokeWidth:"2",stroke:"currentColor",...e,children:Tt("path",{d:"M6 18L18 6M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as C,jsxs as we}from"react/jsx-runtime";function Ht(){let{accountModalOpen:e,toggleAccountModal:t}=v();return we(Me,{open:e,onOpenChange:t,children:[C(Qn,{className:"sr-only",children:"Connect with EntryKit"}),e?we("div",{className:It("relative py-2 ring-1","bg-neutral-900 text-neutral-400 ring-neutral-700/50 divide-neutral-700","links:font-medium links:underline links:underline-offset-4","links:text-white","links:decoration-neutral-500 hover:links:decoration-orange-500"),children:[C(Et,{children:C(At,{})}),we("a",{href:"https://mud.dev",target:"_blank",rel:"noreferrer noopener",className:"group self-center p-3 flex items-center justify-center gap-2 links-unset text-sm font-mono transition text-neutral-400 hover:text-white",children:[C("span",{className:"block w-4 h-4",children:C(S,{className:"w-full h-full text-orange-500 group-hover:rotate-90 transition duration-300"})}),C("span",{children:"Powered by MUD"})]}),C("div",{className:"absolute top-0 right-0",children:C(Gn,{className:It("pointer-events-auto leading-none p-2 transition","text-neutral-700 hover:text-neutral-500"),title:"Close",children:C(Mt,{className:"m-0"})})})]}):null]})}import{jsx as Wn,jsxs as _n}from"react/jsx-runtime";function Vn({config:e,children:t}){return _n(Ue,{config:e,children:[t,Wn(Ht,{})]})}import{useAccount as jn}from"wagmi";import{twMerge as N}from"tailwind-merge";import{twMerge as Ot}from"tailwind-merge";import{useEffect as Yn}from"react";import{Fragment as Xn,jsx as ee,jsxs as zt}from"react/jsx-runtime";function qt({address:e}){let{data:t,error:r}=X(e),o=W(t?.avatar);return Yn(()=>{r&&console.log("Could not get ENS",r)},[r]),zt(Xn,{children:[zt("span",{className:"flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center",children:[ee("img",{src:t?.avatar&&o.isSuccess?t.avatar:void 0,className:Ot("col-start-1 row-start-1","inline-flex w-full h-full rounded-full bg-black/10 dark:bg-white/10 bg-cover bg-no-repeat bg-center","transtion duration-300",o.isSuccess?"opacity-100":"opacity-0")}),ee(S,{className:Ot("col-start-1 row-start-1 text-orange-500","transition duration-300",t&&(!t.avatar||o.isError)?"opacity-100":"opacity-0")})]}),ee("span",{className:"flex-grow",children:t?.name??ee(M,{hex:e})})]})}import{useRef as $n}from"react";import{jsx as k,jsxs as Lt}from"react/jsx-runtime";var Bt=N("w-48 p-3 inline-flex outline-none transition","border border-transparent","text-base leading-none"),Zn=N("bg-neutral-100 border-neutral-300 text-black","dark:bg-neutral-800 dark:border-neutral-700 dark:text-white"),Jn=N("cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700");function ea(){let{openAccountModal:e,accountModalOpen:t}=v(),{status:r,address:o}=jn(),n=$n(o),a=T(o),i=r==="connected"||r==="reconnecting"&&o,s=o!==n.current,c=a.isSuccess?a.data.complete:s?!1:i,g=(()=>{if(a.isSuccess){if(!a.data.hasAllowance)return"Top up";if(!a.data.hasDelegation||!a.data.isSpender)return"Set up"}return"Sign in"})();return k(Q,{mode:"child",children:c?k("button",{type:"button",className:N(Bt,Zn,Jn),onClick:e,children:k("span",{className:"flex-grow inline-flex gap-2.5 items-center text-left font-medium",children:o?k(qt,{address:o}):null})},"connected"):Lt("button",{type:"button",className:N(Bt,"group","items-center justify-center gap-2.5","bg-orange-500 text-white font-medium","hover:bg-orange-400","active:bg-orange-600"),"aria-busy":t,onClick:e,children:[Lt("span",{className:"pointer-events-none inline-grid place-items-center -ml-3",children:[k("span",{className:N("col-start-1 row-start-1 leading-none","scale-100 opacity-100 transition duration-300","group-aria-busy:scale-125 group-aria-busy:opacity-0"),children:k(S,{})}),k("span",{"aria-hidden":!0,className:N("col-start-1 row-start-1","scale-50 opacity-0 transition duration-300 delay-50","group-aria-busy:scale-100 group-aria-busy:opacity-100"),children:k(b,{})})]}),k("span",{className:"font-medium",children:g})]},"sign in")})}import{useConnectorClient as ta}from"wagmi";function ra(){let{chainId:e}=l(),t=ta({chainId:e});t.error&&console.error("Error retrieving user client",t.error);let r=t.data?.account.address,o=T(r),n=Z(r);return t.isSuccess?!o.isSuccess||!o.data.complete?{...o,data:void 0}:n:{...t,data:void 0}}import{connectorsForWallets as na}from"@rainbow-me/rainbowkit";import{createConfig as aa}from"wagmi";import{getDefaultWallets as oa}from"@rainbow-me/rainbowkit";function te(e){let{wallets:t}=oa();return[...t]}function ia(e){let t=te(e),r=na(t,{appName:e.appName,projectId:e.walletConnectProjectId});return aa({connectors:r,chains:e.chains,transports:e.transports,pollingInterval:e.pollingInterval})}import{connectorsForWallets as sa}from"@rainbow-me/rainbowkit";function Am({wallets:e,...t}){return sa(e??te(t),{appName:t.appName,projectId:t.walletConnectProjectId})}export{ea as AccountButton,Vn as EntryKitProvider,ia as createWagmiConfig,Gt as defineConfig,Am as getConnectors,te as getWallets,v as useAccountModal,l as useEntryKitConfig,ra as useSessionClient};
1445
1398
  //# sourceMappingURL=internal.js.map