UNPKG

sui-explorer-local

Version:
2 lines (1 loc) 11.1 kB
import{j as g}from"./jsx-runtime-ffb262ed.js";import{a as ne,c as ae}from"./index-dca19ccf.js";import{c as re}from"./clsx-0839fdbe.js";import{r as S}from"./index-76fb7be0.js";import{a as se}from"./index-d4ae957a.js";import{i as ie,f as oe,c as le,m as ue,a as ce,S as fe,H as me,v as D,s as de,b as pe,d as ge,e as he,g as ye,h as ve,r as Ae,j as O,k as we,l as xe,p as Ee,n as Se,o as W,q as be,u as H}from"./SVGVisualElement-4900b852.js";import{u as _e}from"./use-unmount-effect-01fa1bae.js";import{L as je}from"./LoadingIndicator-8720c7eb.js";const Te="https://apps-backend.sui.io";function Ie(){return{request:S.useCallback(async(t,n,a)=>{const r=await fetch(Ve(`${Te}/${t}`,n),a);if(!r.ok)throw new Error("Unexpected response");return r.json()},[])}}function Ve(e,t){if(t&&Object.keys(t).length>0){const n=new URLSearchParams(t);return`${e}?${n}`}return e}const De=e=>g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 16 16",...e,children:g.jsx("path",{fill:"currentColor",d:"M12.324 13.026a.446.446 0 0 0 .639 0 .446.446 0 0 0 0-.64L3.66 3.096a.457.457 0 0 0-.644 0 .46.46 0 0 0 0 .639l9.308 9.292Zm.505-1.778c1.563-1.074 2.513-2.492 2.513-3.115 0-1.09-2.9-4.662-7.347-4.662-.913 0-1.757.15-2.53.403l1.584 1.59c.301-.108.618-.173.951-.173a2.846 2.846 0 0 1 2.857 2.842c0 .333-.064.655-.182.95l2.154 2.165Zm-4.834 1.547c.961 0 1.853-.167 2.648-.446l-1.596-1.595a2.63 2.63 0 0 1-1.047.22 2.871 2.871 0 0 1-2.863-2.841c0-.376.08-.741.22-1.064l-2.094-2.1C1.625 6.06.653 7.504.653 8.133c0 1.085 2.959 4.662 7.342 4.662Zm1.74-4.775c0-.935-.757-1.692-1.697-1.692-.038 0-.081 0-.119.005l1.81 1.805c.006-.037.006-.075.006-.118Zm-3.491.075c0 .935.768 1.697 1.702 1.697.043 0 .08-.005.124-.01L6.249 7.96c-.005.043-.005.091-.005.134Z"})}),ke=De;try{EyeClose16.displayName="EyeClose16",EyeClose16.__docgenInfo={description:"",displayName:"EyeClose16",props:{}}}catch{}const Le=e=>g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...e,children:g.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"m4.75 16 2.746-3.493a2 2 0 0 1 3.09-.067L13 15.25m-2.085-2.427c1.037-1.32 2.482-3.188 2.576-3.31a2 2 0 0 1 3.094-.073L19 12.25m-12.25 7h10.5a2 2 0 0 0 2-2V6.75a2 2 0 0 0-2-2H6.75a2 2 0 0 0-2 2v10.5a2 2 0 0 0 2 2Z"})}),Ne=Le;try{NftTypeImage24.displayName="NftTypeImage24",NftTypeImage24.__docgenInfo={description:"",displayName:"NftTypeImage24",props:{}}}catch{}function Q(e,t,n){var a;if(typeof e=="string"){let r=document;t&&(ie(!!t.current),r=t.current),n?((a=n[e])!==null&&a!==void 0||(n[e]=r.querySelectorAll(e)),e=n[e]):e=r.querySelectorAll(e)}else e instanceof Element&&(e=[e]);return Array.from(e||[])}function qe(e,t){let n;const a=()=>{const{currentTime:r}=t,i=(r===null?0:r.value)/100;n!==i&&e(i),n=i};return oe.update(a,!0),()=>le(a)}const Ce=ue(()=>window.ScrollTimeline!==void 0);class J{constructor(t){this.animations=t.filter(Boolean)}then(t,n){return Promise.all(this.animations).then(t).catch(n)}getAll(t){return this.animations[0][t]}setAll(t,n){for(let a=0;a<this.animations.length;a++)this.animations[a][t]=n}attachTimeline(t){const n=this.animations.map(a=>{if(Ce()&&a.attachTimeline)a.attachTimeline(t);else return a.pause(),qe(r=>{a.time=a.duration*r},t)});return()=>{n.forEach((a,r)=>{a&&a(),this.animations[r].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}play(){this.runAll("play")}pause(){this.runAll("pause")}stop(){this.runAll("stop")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function Me(e){return typeof e=="object"&&!Array.isArray(e)}function Pe(e){const t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=ce(e)?new fe(t,{enableHardwareAcceleration:!1}):new me(t,{enableHardwareAcceleration:!0});n.mount(e),D.set(e,n)}function Re(e,t=100){const n=de({keyframes:[0,t],...e}),a=Math.min(pe(n),ge);return{type:"keyframes",ease:r=>n.next(a*r).value/t,duration:he(a)}}function F(e,t,n,a){var r;return typeof t=="number"?t:t.startsWith("-")||t.startsWith("+")?Math.max(0,e+parseFloat(t)):t==="<"?n:(r=a.get(t))!==null&&r!==void 0?r:e}const Ue=(e,t,n)=>{const a=t-e;return((n-e)%a+a)%a+e};function Be(e,t){return ye(e)?e[Ue(0,e.length,t)]:e}function He(e,t,n){for(let a=0;a<e.length;a++){const r=e[a];r.at>t&&r.at<n&&(Ae(e,r),a--)}}function Fe(e,t,n,a,r,s){He(e,r,s);for(let i=0;i<t.length;i++)e.push({value:t[i],at:ve(r,s,a[i]),easing:Be(n,i)})}function Ge(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}const Ke="easeInOut";function $e(e,{defaultTransition:t={},...n}={},a){const r=t.duration||.3,s=new Map,i=new Map,o={},u=new Map;let h=0,l=0,b=0;for(let y=0;y<e.length;y++){const f=e[y];if(typeof f=="string"){u.set(f,l);continue}else if(!Array.isArray(f)){u.set(f.name,F(l,f.at,h,u));continue}let[v,d,c={}]=f;c.at!==void 0&&(l=F(l,c.at,h,u));let p=0;const _=(A,w,E,T=0,I=0)=>{const m=Ze(A),{delay:V=0,times:j=we(m),type:Y="keyframes",...ee}=w;let{ease:L=t.ease||"easeOut",duration:x}=w;const N=typeof V=="function"?V(T,I):V,q=m.length;if(q<=2&&Y==="spring"){let R=100;if(q===2&&We(m)){const te=m[1]-m[0];R=Math.abs(te)}const U={...ee};x!==void 0&&(U.duration=Se(x));const B=Re(U,R);L=B.ease,x=B.duration}x??(x=r);const C=l+N,M=C+x;j.length===1&&j[0]===0&&(j[1]=1);const P=j.length-m.length;P>0&&xe(j,P),m.length===1&&m.unshift(null),Fe(E,m,L,j,C,M),p=Math.max(N+x,p),b=Math.max(M,b)};if(O(v)){const A=G(v,i);_(d,c,K("default",A))}else{const A=Q(v,a,o),w=A.length;for(let E=0;E<w;E++){d=d,c=c;const T=A[E],I=G(T,i);for(const m in d)_(d[m],ze(c,m),K(m,I),E,w)}}h=l,l+=p}return i.forEach((y,f)=>{for(const v in y){const d=y[v];d.sort(Ge);const c=[],p=[],_=[];for(let w=0;w<d.length;w++){const{at:E,value:T,easing:I}=d[w];c.push(T),p.push(Ee(0,b,E)),_.push(I||"easeOut")}p[0]!==0&&(p.unshift(0),c.unshift(c[0]),_.unshift(Ke)),p[p.length-1]!==1&&(p.push(1),c.push(null)),s.has(f)||s.set(f,{keyframes:{},transition:{}});const A=s.get(f);A.keyframes[v]=c,A.transition[v]={...t,duration:b,ease:_,times:p,...n}}}),s}function G(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function K(e,t){return t[e]||(t[e]=[]),t[e]}function Ze(e){return Array.isArray(e)?e:[e]}function ze(e,t){return e[t]?{...e,...e[t]}:{...e}}const Oe=e=>typeof e=="number",We=e=>e.every(Oe);function X(e,t,n,a){const r=Q(e,a),s=r.length,i=[];for(let o=0;o<s;o++){const u=r[o];D.has(u)||Pe(u);const h=D.get(u),l={...n};typeof l.delay=="function"&&(l.delay=l.delay(o,s)),i.push(...be(h,{...t,transition:l},{}))}return new J(i)}const Qe=e=>Array.isArray(e)&&Array.isArray(e[0]);function Je(e,t,n){const a=[];return $e(e,t,n).forEach(({keyframes:s,transition:i},o)=>{let u;O(o)?u=W(o,s.default,i.default):u=X(o,s,i),a.push(u)}),new J(a)}const Xe=e=>{function t(n,a,r){let s;return Qe(n)?s=Je(n,a,e):Me(a)?s=X(n,a,r,e):s=W(n,a,r),e&&e.animations.push(s),s}return t};function Ye(){const e=H(()=>({current:null,animations:[]})),t=H(()=>Xe(e));return _e(()=>{e.animations.forEach(n=>n.stop())}),[e,t]}const et=["image/jpeg","image/png","image/gif","image/bmp","image/webp","image/x-icon","application/pdf","image/tiff"];var k=(e=>(e.PASS="PASS",e.BLUR="BLUR",e.HIDE="HIDE",e))(k||{});const $={visibility:"PASS"},tt=e=>{if(!e)return!1;try{return new URL(e),!0}catch{return!1}};function nt({url:e="",enabled:t=!0}){const{request:n}=Ie();return se({queryKey:["image-mod",e,t],queryFn:async()=>{if(!tt(e)||!t)return $;const r=(await fetch(e,{method:"HEAD"})).headers.get("Content-Type");if(r&&et.includes(r))return n("image",{url:e})},placeholderData:$,staleTime:24*60*60*1e3,gcTime:1/0})}function at({src:e="",moderate:t=!0}){const[n,a]=S.useState("loading"),r=e==null?void 0:e.replace(/^ipfs:\/\//,"https://ipfs.io/ipfs/"),{data:s,isFetched:i}=nt({url:r,enabled:t}),o=S.useRef(null),u=()=>{o.current&&(o.current.onload=null,o.current.onerror=null,o.current=null)},h=S.useCallback(()=>{e||a("failed");const l=new Image;l.src=r,l.onload=()=>(!t||t&&i)&&a("loaded"),l.onerror=()=>a("failed"),o.current=l},[e,r,t,i]);return S.useLayoutEffect(()=>(h(),()=>u()),[h]),{moderation:s,url:r,status:n,ref:o}}const Z=ae(null,{variants:{rounded:{full:"rounded-full","2xl":"rounded-2xl",lg:"rounded-lg",xl:"rounded-xl",md:"rounded-md",sm:"rounded-sm",none:"rounded-none"},fit:{cover:"object-cover",contain:"object-contain",fill:"object-fill",none:"object-none",scaleDown:"object-scale-down"},size:{sm:"h-16 w-16",md:"h-24 w-24",lg:"h-32 w-32",full:"h-full w-full"},aspect:{square:"aspect-square"}},defaultVariants:{size:"full",rounded:"none",fit:"cover"}});function rt({status:e,size:t,rounded:n,alt:a,src:r,srcSet:s,fit:i,visibility:o,onClick:u,fadeIn:h,aspect:l,...b}){const[y,f]=Ye(),[v,d]=S.useState(!1);S.useEffect(()=>{o&&o!==k.PASS&&d(!0)},[o]);const c=h&&e==="loaded";return S.useEffect(()=>{c&&f(y.current,{opacity:1},{duration:.3})},[f,c,y]),g.jsxs("div",{ref:y,className:ne(Z({size:t,rounded:n,aspect:l}),"relative flex items-center justify-center bg-gray-40 text-gray-65",c&&"opacity-0"),children:[e==="loading"?g.jsx(je,{}):e==="loaded"?v&&g.jsx("div",{className:re("absolute z-20 flex h-full w-full items-center justify-center rounded-md bg-gray-100/30 text-center text-white backdrop-blur-md",o===k.HIDE&&"pointer-events-none cursor-not-allowed"),onClick:()=>d(!v),children:g.jsx(ke,{})}):e==="failed"?g.jsx(Ne,{}):null,e==="loaded"&&g.jsx("img",{alt:a,src:r,srcSet:s,className:Z({rounded:n,fit:i,size:t}),onClick:u,...b})]})}function z({src:e,moderate:t=!0,...n}){const{status:a,url:r,moderation:s}=at({src:e,moderate:t});return g.jsx(rt,{visibility:s==null?void 0:s.visibility,status:a,src:r,...n})}try{z.displayName="Image",z.__docgenInfo={description:"",displayName:"Image",props:{onClick:{defaultValue:null,description:"",name:"onClick",required:!1,type:{name:"(() => void)"}},moderate:{defaultValue:{value:"true"},description:"",name:"moderate",required:!1,type:{name:"boolean"}},src:{defaultValue:null,description:"",name:"src",required:!0,type:{name:"string"}},visibility:{defaultValue:null,description:"",name:"visibility",required:!1,type:{name:"enum",value:[{value:'"PASS"'},{value:'"BLUR"'},{value:'"HIDE"'}]}},fadeIn:{defaultValue:null,description:"",name:"fadeIn",required:!1,type:{name:"boolean"}},rounded:{defaultValue:null,description:"",name:"rounded",required:!1,type:{name:'"full" | "lg" | "xl" | "2xl" | "none" | "sm" | "md" | null'}},size:{defaultValue:null,description:"",name:"size",required:!1,type:{name:'"full" | "lg" | "sm" | "md" | null'}},fit:{defaultValue:null,description:"",name:"fit",required:!1,type:{name:'"none" | "fill" | "cover" | "contain" | "scaleDown" | null'}},aspect:{defaultValue:null,description:"",name:"aspect",required:!1,type:{name:'"square" | null'}}}}}catch{}export{z as I,k as V};