1import"./styles-CREPMQu3.js";import{I as e,a as t,U as s}from"./wallet-selector-CJxmKkox.js";import{w as n}from"./wallet-ui-BDQllbJT.js";import"./vendor-C4-Xx_9d.js";const a=new class{constructor(){this.chainStatsEndpoint="/api/chain-stats",this.requestTimeout=15e3,this.cache=new Map,this.cacheTTL=2500}async getChainStats(){const e="chain_stats",t=this.cache.get(e);if(t&&Date.now()-t.timestamp<this.cacheTTL)return t.data;try{const t=await fetch(this.chainStatsEndpoint,{method:"GET",headers:{"Content-Type":"application/json"},signal:AbortSignal.timeout(this.requestTimeout)});if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);const s=await t.json();return this.cache.set(e,{data:s,timestamp:Date.now()}),s}catch(s){if(t)return{...t.data,stale:!0,error:s.message};throw s}}formatStats(e){const t=void 0!==e.tpsFloat?e.tpsFloat:e.tps;let s="0.00";if(t){const e=Number(t);isNaN(e)||(s=e.toFixed(2))}return{height:Number(e.height).toLocaleString(),epoch:Number(e.epoch).toLocaleString(),epochHeight:Number(e.epochHeight).toLocaleString(),tps:s,totalSupply:this.formatSupply(e.totalSupply),version:e.version}}formatSupply(e){return`${(BigInt(e)/BigInt(10**18)).toLocaleString()} IOTX`}clearCache(){this.cache.clear()}};const i=new class{constructor(){this.ws=null,this.url=e.wsUrl,this.listeners={},this.reconnectAttempts=0,this.maxReconnectAttempts=10,this.reconnectDelay=1e3,this.connected=!1,this.subscriptions=new Set}connect(){return new Promise((e,t)=>{try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.connected=!0,this.reconnectAttempts=0,this.reconnectDelay=1e3,this.emit("connected"),e()},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onerror=e=>{this.emit("error",e),t(e)},this.ws.onclose=()=>{this.connected=!1,this.emit("disconnected"),this.attemptReconnect()}}catch(s){t(s)}})}attemptReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void this.emit("reconnect_failed");this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1),3e4);setTimeout(()=>{this.connect().catch(e=>{})},e)}subscribeNewHeads(e){this.on("newHeads",e),this.connected&&this.sendMessage({jsonrpc:"2.0",id:1,method:"eth_subscribe",params:["newHeads"]}),this.subscriptions.add("newHeads")}subscribePendingTransactions(e){this.on("pendingTransactions",e),this.connected&&this.sendMessage({jsonrpc:"2.0",id:2,method:"eth_subscribe",params:["newPendingTransactions"]}),this.subscriptions.add("newPendingTransactions")}sendMessage(e){if(this.connected)try{this.ws.send(JSON.stringify(e))}catch(t){}}handleMessage(e){try{const t=JSON.parse(e);if("eth_subscription"===t.method){const{subscription:e,result:s}=t.params;if(s&&s.number){const e=parseInt(s.number,16);this.emit("newHeads",{blockNumber:e,blockData:s})}else"string"==typeof s&&this.emit("pendingTransactions",{txHash:s})}else t.result}catch(t){}}on(e,t){return this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t),()=>{this.listeners[e]=this.listeners[e].filter(e=>e!==t)}}emit(e,t){this.listeners[e]&&this.listeners[e].forEach(e=>{try{e(t)}catch(s){}})}disconnect(){this.ws&&(this.ws.close(),this.ws=null),this.connected=!1,this.listeners={},this.subscriptions.clear()}isConnected(){return this.connected&&this.ws&&this.ws.readyState===WebSocket.OPEN}};const o=new class{constructor(e={}){this.stores=new Map,this.maxSize=e.maxSize||100,this.defaultTTL=e.defaultTTL||5e3,this.policies={chainMeta:{ttl:1e3,strategy:"ttl"},epochMeta:{ttl:3e3,strategy:"ttl"},delegates:{ttl:3e3,staleTTL:1e4,strategy:"stale-while-revalidate"},candidates:{ttl:3e3,staleTTL:1e4,strategy:"stale-while-revalidate"},iotxPrice:{ttl:6e4,strategy:"ttl"},tps:{ttl:1e4,strategy:"ttl"},general:{ttl:5e3,strategy:"ttl"}}}getPolicy(e){const t=e.split("_")[0];return this.policies[t]||this.policies.general}set(e,t,s=null){const n=this.getPolicy(e),a=s||n.ttl,i={value:t,timestamp:Date.now(),ttl:a,staleTTL:n.staleTTL||2*a,strategy:n.strategy,hits:0};return this.stores.set(e,i),this.stores.size>this.maxSize&&this.evictLRU(),i}get(e){const t=this.stores.get(e);if(!t)return null;const s=Date.now()-t.timestamp;switch(t.hits++,t.strategy){case"ttl":return s<t.ttl?{value:t.value,isStale:!1,isFresh:!0}:(this.stores.delete(e),null);case"stale-while-revalidate":return s<t.ttl?{value:t.value,isStale:!1,isFresh:!0}:s<t.staleTTL?{value:t.value,isStale:!0,isFresh:!1}:(this.stores.delete(e),null);default:return null}}has(e){const t=this.get(e);return t&&t.isFresh}delete(e){return this.stores.delete(e)}clear(){this.stores.clear()}clearPattern(e){const t=new RegExp(e),s=[];for(const n of this.stores.keys())t.test(n)&&s.push(n);
1return s.forEach(e=>this.stores.delete(e)),s.length}evictLRU(){let e=null,t=1/0,s=1/0;for(const[n,a]of this.stores.entries())a.hits<t?(e=n,t=a.hits,s=a.timestamp):a.hits===t&&a.timestamp<s&&(e=n,s=a.timestamp);e&&this.stores.delete(e)}getStats(){const e={size:this.stores.size,maxSize:this.maxSize,entries:[]};for(const[t,s]of this.stores.entries()){const n=Date.now()-s.timestamp,a=this.get(t);e.entries.push({key:t,age:n,ttl:s.ttl,hits:s.hits,strategy:s.strategy,status:a?a.isFresh?"fresh":"stale":"expired"})}return e}cleanup(){let e=0;for(const t of this.stores.keys()){this.get(t)||e++}return e}setPolicy(e,t){this.policies[e]={...this.policies.general,...t}}async getOrFetch(e,t){const s=this.get(e);if(s){if(s.isFresh)return s.value;if(s.isStale)return this.revalidate(e,t).catch(e=>{}),s.value}try{const s=await t();return this.set(e,s),s}catch(n){throw n}}async revalidate(e,t){try{const s=await t();return this.set(e,s),s}catch(s){throw s}}}({maxSize:100,defaultTTL:5e3}),r={numDelegates:24,numSubEpochs:15,numSubEpochsDardanelles:30,numSubEpochsWake:60,dardanellesHeight:1816201,wakeHeight:36893881};function l(e){if(e<=0)return 0;
1const{numDelegates:t,numSubEpochs:s,numSubEpochsDardanelles:n,numSubEpochsWake:a,dardanellesHeight:i,wakeHeight:o}=r;if(e<=i)return Math.floor((e-1)/t/s)+1;const d=l(i),h=c(d);if(e<=o)return d+Math.floor((e-h)/t/n);const u=l(o),g=c(u);return u+Math.floor((e-g)/t/a)}function c(e){if(e<=0)return 0;const{numDelegates:t,numSubEpochs:s,numSubEpochsDardanelles:n,numSubEpochsWake:a,dardanellesHeight:i,wakeHeight:o}=r,c=l(i);if(e<=c)return(e-1)*t*s+1;const d=(c-1)*t*s+1,h=l(o);if(e<=h)return d+(e-c)*t*n;return d+(h-c)*t*n+(e-h)*t*a}function d(e){return((t=c(e))<r.dardanellesHeight?r.numSubEpochs:t<r.wakeHeight?r.numSubEpochsDardanelles:r.numSubEpochsWake)*r.numDelegates;var t}const h=new class{constructor(){this.delegatesApiEndpoint="/api/delegates",this.cache=o,this.requestTimeout=15e3}async getCandidatesFromGrpc(e=0,t=200){const s=`candidates_${e}_${t}`;return await this.cache.getOrFetch(s,async()=>{let s;try{s=await fetch(`${this.delegatesApiEndpoint}?offset=${e}&limit=${t}`,{method:"GET",headers:{Accept:"application/json"},signal:AbortSignal.timeout(this.requestTimeout)})}catch(i){throw new Error(`delegates request failed: ${i.message}`)}if(!s.ok)throw new Error(`delegates request failed: HTTP ${s.status}`);const n=s.headers.get("content-type")||"";if(!n.includes("application/json"))throw new Error(`delegates request returned ${n||"unknown content type"}`);const a=await s.json();if(!Array.isArray(a.candidates))throw new Error("delegates response has no candidates array");if(0===a.candidates.length)throw new Error("delegates response is empty");return a})}detectSlowDelegates(e,t={}){const{blocksElapsedInEpoch:s,numActiveDelegates:n=r.numDelegates,activeSetComplete:a=!0}=t,i=(e=0,t=!1)=>({slow:[],stuck:[],expectedPerDelegate:e,reliable:t});if(!Number.isFinite(s)||s<0)return i();if(!a)return i();const o=e.filter(e=>e.isSelected);if(0===o.length||o.length>n)return i();const l=Math.floor(s/n);if(s<5*n)return i(l,!0);const c=[],d=[];o.forEach(e=>{const t=e.production||0,s=l-t;s>=8?d.push({...e,missedBlocks:s,message:`STUCK - ${t}/${l} blocks`}):s>=4&&c.push({...e,missedBlocks:s,message:`SLOW - ${t}/${l} blocks`})});const h=Math.floor((n-1)/3);return d.length+c.length>h?i(l,!1):{slow:c,stuck:d,expectedPerDelegate:l,reliable:!0}}clearCache(){this.cache.clear()}getCacheStats(){return{cacheSize:this.cache.size,entries:Array.from(this.cache.keys())}}};const u=new class{constructor(){this.cache=new Map,this.addressCache=new Map}iotexToHexAddress(e){if(!e||!e.startsWith("io1"))return e;if(this.addressCache.has(e))return this.addressCache.get(e);try{const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",s=e.slice(3),n=[];for(const e of s){const s=t.indexOf(e.toLowerCase());if(s<0)throw new Error("Invalid character in address");n.push(s)}let a=0,i=0;const o=[];for(const e of n)for(a=a<<5|e,i+=5;i>=8;)i-=8,o.push(a>>i&255);if(o.length>=20){const t="0x"+o.slice(0,20).map(e=>e.toString(16).padStart(2,"0")).join("");return this.addressCache.set(e,t),t}}catch(t){}return e}async getCurrentEpoch(){try{return(await h.getCandidatesFromGrpc()).epochNumber||0}catch(e){return 0}}parseDelegate(e,t,s){const n="active"===e.status,a=e.isBlockProducer;return{rank:t,name:e.name||`Delegate ${t}`,votes:e.totalWeightedVotes||"0",selfStakingTokens:e.selfStakingTokens||"0",address:e.operatorAddress||"",ownerAddress:e.ownerAddress||"",rewardAddress:e.rewardAddress||"",status:e.status||"inactive",isSelected:n,isEligible:!0===a,isNotEligible:!1===a,blockRewardShare:85,production:e.production||0,maxProduction:s}}async fetchDelegates(){const e="delegates_full",s=this.cache.get(e);if(s&&Date.now()-s.timestamp<1e3)return s.data;try{const t=await h.getCandidatesFromGrpc(),s=t.maxProduction||0,n=t.candidates.map((e,t)=>this.parseDelegate(e,e.rank||t+1,s)),{slow:a,stuck:i,expectedPerDelegate:o,reliable:r}=h.detectSlowDelegates(n,{blocksElapsedInEpoch:t.blocksElapsedInEpoch,numActiveDelegates:t.numActiveDelegates,activeSetComplete:t.activeSetComplete}),l=new Set(a.map(e=>e.rank)),c=new Set(i.map(e=>e.rank)),d=n.map(e=>({...e,isSlow:l.has(e.rank),isStuck:c.has(e.rank)}));i.length;const u={delegates:d,epochNumber:t.epochNumber,epochStartHeight:t.epochStartHeight,blocksElapsedInEpoch:t.blocksElapsedInEpoch,blocksPerEpoch:t.blocksPerEpoch,maxProduction:s,expectedPerDelegate:o,healthReliable:r,selectedCount:d.filter(e=>e.isSelected).length,slowDelegates:a,stuckDelegates:i,stale:!0===t.stale,updatedAt:(new Date).toISOString()};return this.cache.set(e,{data:u,timestamp:Date.now()}),u}catch(n){if(s){const e=Math.round((Date.now()-s.timestamp)/6e4);return e>=1&&t.setSuccess(`Showing delegate data from ${e} min ago`,5e3),{...s.data,stale:!0}}throw n}}formatVotes(e){try{if("bigint"==typeof e){return(Number(e)/1e18).toLocaleStr
1ing("en-US",{maximumFractionDigits:0,minimumFractionDigits:0})}if("string"==typeof e){return(parseFloat(e)/1e18).toLocaleString("en-US",{maximumFractionDigits:0,minimumFractionDigits:0})}return(parseFloat(e)||0).toLocaleString("en-US",{maximumFractionDigits:0,minimumFractionDigits:0})}catch(t){return"0"}}hexToIotexAddress(e){if(!e||!e.startsWith("0x"))return e;const t=`hex_${e}`;if(this.addressCache.has(t))return this.addressCache.get(t);try{const s="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n=e.slice(2).toLowerCase(),a=[];for(let e=0;e<n.length;e+=2)a.push(parseInt(n.substring(e,e+2),16));let i=0,o=0;const r=[];for(const e of a)for(i=i<<8|e,o+=8;o>=5;)o-=5,r.push(i>>o&31);o>0&&r.push(i<<5-o&31);const l="io",c=[...r],d=1^(e=>{const t=[996825010,642813549,513874426,1027748829,705979059];let s=1;for(const n of e){const e=s>>25;s=(33554431&s)<<5^n;for(let n=0;n<5;n++)e>>n&1&&(s^=t[n])}return s})([...(e=>{const t=[];for(const s of e)t.push(s.charCodeAt(0)>>5);t.push(0);for(const s of e)t.push(31&s.charCodeAt(0));return t})(l),...c,0,0,0,0,0,0]),h=[];for(let e=0;e<6;e++)h.push(d>>5*(5-e)&31);const u="io1"+[...r,...h].map(e=>s[e]).join("");return this.addressCache.set(t,u),u}catch(s){return e}}async getVoterBuckets(e){try{const t=await fetch("/api/voter-buckets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({voterAddress:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new Error(`HTTP ${t.status}`);const s=await t.json();if(s.error)throw new Error(s.error);return s.buckets||[]}catch(t){return[]}}clearCache(){this.cache.clear()}getCacheStats(){return{cacheSize:this.cache.size,entries:Array.from(this.cache.keys())}}};const g=new class{constructor(){this.updateIntervals={},this.isInitialized=!1}
1async init(){if(!this.isInitialized)try{try{await i.connect(),this.setupWebSocketListeners()}catch(e){}this.startPolling(),this.isInitialized=!0,t.setSuccess("Chain service initialized")}catch(e){throw t.setError("Failed to initialize chain data"),e}}setupWebSocketListeners(){i.subscribeNewHeads(e=>{const s=e.blockNumber;t.setState({blockHeight:s})}),i.on("disconnected",()=>{}),i.on("reconnect_failed",()=>{})}startPolling(){Object.keys(this.updateIntervals).length>0&&this.stopPolling(),this.updateBlockHeight(),this.updateIntervals.blockHeight=setInterval(()=>this.updateBlockHeight(),s.BLOCK_HEIGHT_POLL),this.updateTPS(),this.updateIntervals.tps=setInterval(()=>this.updateTPS(),s.TPS),this.updateDelegates(),this.updateIntervals.delegates=setInterval(()=>this.updateDelegates(),s.DELEGATES)}async updateDelegates(){try{const e=await u.fetchDelegates();t.setState({delegates:e.delegates,epochNumber:e.epochNumber,blocksPerEpoch:e.blocksPerEpoch,maxProduction:e.maxProduction,delegatesSlowNodes:e.slowDelegates?e.slowDelegates.length:0,delegatesStuckNodes:e.stuckDelegates?e.stuckDelegates.length:0,delegatesHealthReliable:!1!==e.healthReliable})}catch(e){}}async updateBlockHeight(){try{const e=await a.getChainStats();e&&e.height&&t.setState({blockHeight:parseInt(e.height),currentEpoch:parseInt(e.epoch||0),epochHeight:parseInt(e.epochHeight||0)})}catch(e){}}async updateTPS(){try{const e=await a.getChainStats();if(e&&void 0!==e.tps){const s=void 0!==e.tpsFloat?e.tpsFloat:e.tps;t.setState({tps:Number(s).toFixed(2)})}}catch(e){}}stopPolling(){Object.values(this.updateIntervals).forEach(e=>{clearInterval(e)}),this.updateIntervals={}}destroy(){this.stopPolling(),i.disconnect(),this.isInitialized=!1}async refreshAll(){t.setLoading(!0);try{const e=await Promise.allSettled([this.updateBlockHeight(),this.updateTPS()]),s=e.filter(e=>"rejected"===e.status),n=e.filter(e=>"fulfilled"===e.status);s.length===e.length?t.setError("Failed to refresh data"):s.length>0?t.setSuccess(`Refreshed ${n.length}/${e.length} data sources`):t.setSuccess("Data refreshed")}catch(e){t.setError("Failed to refresh data")}finally{t.setLoading(!1)}}};const p=new class{constructor(){this.unsubscribers=[],this.chainStatsInterval=null}async init(){await this.loadChainStats(),this.chainStatsInterval=setInterval(()=>this.loadChainStats(),2500),this.unsubscribers.push(t.subscribe("blockHeight",e=>this.updateBlockHeight(e))),this.unsubscribers.push(t.subscribe("tps",e=>this.updateTPS(e))),this.unsubscribers.push(t.subscribe("iotxPrice",e=>this.updatePrice(e))),this.unsubscribers.push(t.subscribe("delegates",e=>{this.updateDelegateCount(e),this.updateTotalVotes(e),this.updateProbatedDelegates(e),this.updateSlowDelegates(e)}))}async loadChainStats(){try{const e=a.formatStats(await a.getChainStats());this.updateChainStats(e)}catch(e){}}updateChainStats(e){this.updateElement("chainHeight",e.height),this.updateElement("chainEpoch",e.epoch),this.updateElement("chainEpochHeight",e.epochHeight),this.updateElement("chainTPS",e.tps);const t=Number(e.epochHeight.toString().replace(/,/g,""));this.updateEpochProgressBar(t);const s=parseFloat(e.tps)||0;this.updateTPSGauge(s)}updateEpochProgressBar(e){const s=document.getElementById("epochProgressBar");if(!s)return;const n=Number(e)||0,a=t.getState("blocksPerEpoch")||d(Number(t.getState("currentEpoch"))||0),i=a>0?Math.min(100,n/a*100):0;s.style.width=`${i}%`}updateTPSGauge(e){const t=document.getElementById("tpsNeedle"),s=document.querySelector(".gauge-fill");if(!t||!s)return;const n=Math.max(1,Math.min(2e3,e||1)),a=Math.log10(1),i=Math.log10(2e3),o=(Math.log10(n)-a)/(i-a),r=180*o-90;t.style.transform=`rotate(${r}deg)`;const l=141.4*o;s.style.strokeDashoffset=141.4-l}updateElement(e,t){const s=document.getElementById(e);s&&s.textContent!==t&&(s.textContent=t,this.pulse(s))}updateBlockHeight(e){const t=document.getElementById("blockHeight");t&&(t.textContent=e.toLocaleString(),this.pulse(t))}updateTPS(e){const t=document.getElementById("tps");t&&(t.textContent="number"==typeof e?e.toFixed(1):e,this.pulse(t))}updatePrice(e){const t=document.getElementById("iotxPrice");t&&(e&&e.toString().includes("$")?t.textContent=e:t.textContent="$"+(e||"0.00"))}updateDelegateCount(e){const t=document.getElementById("eligibleDelegateCount"),s=document.getElementById("totalDelegateCount");if(!t||!s||!e)return;const n=BigInt(2e6)*BigInt(1e18),a=e.filter(e=>BigInt(e.votes||"0")>=n&&!e.isProbated);t.textContent=a.length.toString(),s.textContent=`/ ${e.length}`,this.pulse(t)}updateTotalVotes(e){const t=document.getElementById("totalVotesNetwork");if(t&&e)try{const s=BigInt(2e6)*BigInt(1e18),n=e.filter(e=>BigInt(e.votes||"0")>=s&&!e.isProbated).sort((e,t)=>
1{const s=BigInt(e.votes||"0"),n=BigInt(t.votes||"0");return n>s?1:n<s?-1:0}).slice(0,100);let a=BigInt(0);n.forEach(e=>{a+=BigInt(e.votes||"0")});const i=Number(a)/1e18;let o;o=i>=1e9?(i/1e9).toFixed(2)+"B":i>=1e6?(i/1e6).toFixed(2)+"M":i>=1e3?(i/1e3).toFixed(2)+"K":i.toFixed(2),t.textContent=o,this.pulse(t)}catch(s){t.textContent="--"}}updateProbatedDelegates(e){const t=document.getElementById("probatedCard"),s=document.getElementById("probatedCount"),n=document.getElementById("probatedList");if(t&&s&&n&&e)try{const a=e.filter(e=>e.isProbated);if(0===a.length)t.classList.remove("status-warning"),t.classList.add("status-ok"),s.innerHTML='<i class="fas fa-check-circle status-ok-icon"></i>',n.textContent="All delegates active";else{t.classList.remove("status-ok"),t.classList.add("status-warning"),s.innerHTML=a.length.toString();const e=a.map(e=>e.name).join(", ");n.textContent=e,this.pulse(s)}}catch(a){}}updateSlowDelegates(e){const t=document.getElementById("slowDelegatesCard"),s=document.getElementById("slowDelegatesCount"),n=document.getElementById("slowDelegatesList");if(t&&s&&n&&e)try{const a=e.filter(e=>e.isSlow&&!e.isStuck),i=e.filter(e=>e.isStuck),o=a.length+i.length;if(0===o)t.classList.remove("status-warning"),t.classList.add("status-ok"),s.innerHTML='<i class="fas fa-check-circle status-ok-icon"></i>',n.textContent="All delegates on track";else{t.classList.remove("status-ok"),t.classList.add("status-warning"),s.innerHTML=o.toString();const e=[];i.length>0&&e.push(`Stuck: ${i.map(e=>e.name).join(", ")}`),a.length>0&&e.push(`Slow: ${a.map(e=>e.name).join(", ")}`),n.textContent=e.join(" | "),this.pulse(s)}}catch(a){}}pulse(e){e.style.color="#00ffff",setTimeout(()=>{e.style.color="#00ff96"},300)}destroy(){this.unsubscribers.forEach(e=>e())}};function m(e){return String(e??"").replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e]))}function f(e,t){return!t||t<=0?0:Math.min(100,Math.max(0,e/t*100))}const b=new class{constructor(){this.unsubscribers=[],this.lastUpdateTime=null,this.updateStatusInterval=null,this.currentPage=1,this.pageSize=100,this.lastBlockCounts=new Map,this.renderedSignature=null}async init(){await this.loadDelegates(),this.unsubscribers.push(t.subscribe("delegates",()=>{this.lastUpdateTime=new Date,this.updateDelegateValues()})),this.unsubscribers.push(t.subscribe("currentEpoch",()=>{this.updateRefreshStatus()})),this.unsubscribers.push(t.subscribe("epochHeight",()=>{this.updateRefreshStatus()})),this.unsubscribers.push(t.subscribe("delegatesSlowNodes",()=>{this.updateRefreshStatus()})),this.unsubscribers.push(t.subscribe("delegatesStuckNodes",()=>{this.updateRefreshStatus()})),this.updateStatusInterval=setInterval(()=>{this.updateRefreshStatus()},1e3)}async loadDelegates(){try{t.setLoading(!0);const e=await u.fetchDelegates();t.setState({delegates:e.delegates,epochNumber:e.epochNumber,blocksPerEpoch:e.blocksPerEpoch,maxProduction:e.maxProduction,delegatesSlowNodes:e.slowDelegates?e.slowDelegates.length:0,delegatesStuckNodes:e.stuckDelegates?e.stuckDelegates.length:0,delegatesHealthReliable:!1!==e.healthReliable}),this.currentPage=1,this.renderDelegates()}catch(e){t.setError("Failed to load delegates data")}finally{t.setLoading(!1)}}getPaginatedDelegates(){const e=t.getState("delegates");if(!e||0===e.length)return{delegates:[],totalPages:0};const s=Math.ceil(e.length/this.pageSize);this.currentPage=Math.min(Math.max(1,this.currentPage),Math.max(1,s));const n=(this.currentPage-1)*this.pageSize,a=n+this.pageSize;return{delegates:e.slice(n,a),totalPages:s,totalCount:e.length}}signatureOf(e){return e.map(e=>`${e.rank}:${e.address}`).join("|")}updateDelegateValues(){const e=document.getElementById("delegatesBody");if(!e)return;const{delegates:t}=this.getPaginatedDelegates();if(!t||0===t.length)return;if(this.signatureOf(t)!==this.renderedSignature)return void this.renderDelegates();e.querySelectorAll("tr").forEach((e,s)=>{if(s>=t.length)return;const n=t[s],a=e.querySelectorAll("td");if(a.length<4)return;const i="iotexlab"===n.name.toLowerCase(),o=n.isSelected;o&&n.isStuck?(e.style.borderLeft="3px solid #ff4757",e.classList.add("delegate-row-stuck"),e.classList.remove("delegate-row-slow"),i&&(e.style.background="rgba(255, 71, 87, 0.08)")):o&&n.isSlow?(e.style.borderLeft="3px solid #ff9500",e.classList.add("delegate-row-slow"),e.classList.remove("delegate-row-stuck"),i&&(e.style.background="rgba(255, 149, 0, 0.08)")):(e.classList.remove("delegate-row-slow","delegate-row-stuck"),i?(e.style.borderLeft="",e.style.background=""):e.style.borderLeft="");const r=u.formatVotes(n.votes),l=n.production||0,c=n.maxProduction||0,d=n.address||n.name,h=this.lastBlockCounts.get(d),g=void 0!==h&&h!==l;this.lastBlockCounts.set(d,l);const p=a[3];let m,b="status-selected",S="#00ff96";if(o&&n.isStuck?(b="status-selected status-stuck",S="#ff4757"):o&&n.isSlow&&(b="status-selected status-slow",S="#ff9500"),n.isProbated)m='\n <div class="delegate-status">\n <div class="status-label status-probated">PROBATED</div>\n </div>\n ';else if(n.isSelected){const e=f(l,c),t=o&&(n.isStuck||n.isSlow),s=t?`color: ${S};`:"",a=t?`color: ${S} !important; background: none !important; -webkit-text-fill-color: ${S} !important;`:"",i=g?" block-updated":"";let r="SELECTED";o&&n.isStuck?r+=" (stuck)":o&&n.isSlow&&(r+=" (slow)"),m=`\n <div class="delegate-status" style="${s}">\n <div class="status-label ${b}">${r}</div>\n <div class="progress-bar">\n <div class="progress-track">\n <div class="progress-fill" style="width: ${e}%; background: ${S} !important;"></div>\n </div>
1\n <span class="progress-text${i}" style="${a}">${l}/${c}</span>\n </div>\n </div>\n `}else m=n.isEligible?'\n <div class="delegate-status">\n <div class="status-label status-not-selected">NOT SELECTED</div>\n </div>\n ':n.isNotEligible?'\n <div class="delegate-status">\n <div class="status-label status-not-eligible">NOT ELIGIBLE</div>\n </div>\n ':'\n <div class="delegate-status">\n <div class="status-label status-not-selected">NOT SELECTED</div>\n </div>\n ';a[2].textContent=r,p.innerHTML=m;let w="status-not-selected",y="NOT SELECTED";if(n.isProbated?(w="status-probated",y="PROBATED"):n.isSelected?(w="status-selected",o&&n.isStuck?(w+=" status-stuck",y="SELECTED (stuck)"):o&&n.isSlow?(w+=" status-slow",y="SELECTED (slow)"):y="SELECTED"):n.isNotEligible&&(w="status-not-eligible",y="NOT ELIGIBLE"),a.length>6){const e=a[6];let t="";o&&n.isStuck?t="mobile-blocks-stuck":o&&n.isSlow&&(t="mobile-blocks-slow"),g&&(t+=" block-updated");const s=n.isSelected?`<span class="mobile-blocks ${t}">Blocks: ${l}/${c}</span>`:"";e.innerHTML=`\n <span class="status-label ${w}">${y}</span>\n ${s}\n `}}),this.updateRefreshStatus()}renderDelegates(){const e=document.getElementById("delegatesBody");if(document.getElementById("delegatesPagination"),!e)return;const{delegates:t,totalPages:s,totalCount:n}=this.getPaginatedDelegates();if(e.innerHTML="",!t||0===t.length)return e.innerHTML='<tr><td colspan="7" style="text-align: center; padding: 2rem;">Loading delegates...</td></tr>',this.renderedSignature=null,void this.renderPagination(0,0);t.forEach((t,s)=>{const n=document.createElement("tr");
1n.style.animation=`fadeInUp 0.5s ease-out ${Math.min(.5,.05*s)}s backwards`,t.isNotEligible&&n.classList.add("delegate-row-not-eligible");const a="iotexlab"===t.name.toLowerCase(),i=t.isSelected;i&&t.isStuck?(n.classList.add("delegate-row-stuck"),n.style.borderLeft="3px solid #ff4757",a&&n.classList.add("delegate-highlight")):i&&t.isSlow?(n.classList.add("delegate-row-slow"),n.style.borderLeft="3px solid #ff9500",a&&n.classList.add("delegate-highlight")):a&&n.classList.add("delegate-highlight");const o=u.formatVotes(t.votes),r=t.production||0,l=t.maxProduction||0,c=u.iotexToHexAddress(t.address),d=u.iotexToHexAddress(t.ownerAddress),h=e=>`${e.slice(0,4)}..${e.slice(-4)}`;let g="status-not-selected",p="NOT SELECTED";t.isProbated?(g="status-probated",p="PROBATED"):t.isSelected?(g="status-selected",p="SELECTED",i&&t.isStuck?(g+=" status-stuck",p+=" (stuck)"):i&&t.isSlow&&(g+=" status-slow",p+=" (slow)")):t.isNotEligible&&(g="status-not-eligible",p="NOT ELIGIBLE");const b=f(r,l),S=t.isSelected?`\n <div class="progress-bar">\n <div class="progress-track">\n <div class="progress-fill" style="width: ${b}%;"></div>\n </div>\n <span class="progress-text">${r}/${l}</span>\n </div>\n `:"",w=t.isSelected?`<span class="mobile-blocks">Blocks: ${r}/${l}</span>`:"",y=a?'<a href="/staking.html" class="validator-stake-btn">Stake</a>':"",E=m(t.name);n.innerHTML=`\n <td class="delegate-rank">#${t.rank}</td>\n <td class="delegate-name-cell">${E}${y}</td>\n <td class="delegate-votes">${o}</td>\n <td class="delegate-status-cell">\n <span class="status-label ${g}">${p}</span>\n ${S}\n ${w}\n </td>\n <td class="mobile-row mobile-header">\n <span class="mobile-rank ${i&&t.isStuck?"mobile-rank-stuck":i&&t.isSlow?"mobile-rank-slow":""}">#${t.rank}</span>\n <span class="mobile-name ${a?"iotexlab-name":""}">${E}${y}</span>\n <span class="mobile-votes">${o}</span>\n </td>\n <td class="mobile-row mobile-addresses">\n <a href="https://iotexscan.io/address/${encodeURIComponent(c)}" target="_blank" rel="noopener noreferrer" class="delegate-address-link" title="${m(c)}">OP: ${m(h(c))}</a>\n <a href="https://iotexscan.io/address/${encodeURIComponent(d)}" target="_blank" rel="noopener noreferrer" class="delegate-address-link" title="${m(d)}">OWN: ${m(h(d))}</a>\n </td>\n <td class="mobile-row mobile-status">\n <span class="status-label ${g}">${p}</span>\n ${w}\n </td>\n `,e.appendChild(n)}),this.renderedSignature=this.signatureOf(t),this.updateRefreshStatus(),this.renderPagination(s,n),this.ensureAnimation()}createPaginationElement(e,t){const s=(this.currentPage-1)*this.pageSize+1,n=Math.min(this.currentPage*this.pageSize,t),a=document.createElement("div");a.className="pagination-inline-container";const i=document.createElement("span");i.className="pagination-info-inline",i.textContent=`Showing ${s}-${n} of ${t} delegates`,i.style.cssText="\n color: #00ff96;\n white-space: nowrap;\n ",a.appendChild(i);const o=document.createElement("span");o.style.cssText="\n display: inline-flex;\n align-items: center;\n gap: 1rem;\n white-space: nowrap;\n ";const r=document.createElement("span");r.className="pagination-page-inline",r.textContent=`Page ${this.currentPage} of ${e}`,r.style.cssText="\n color: #00ff96;\n ",o.appendChild(r);const l=document.createElement("span");if(l.className="pagination-buttons-inline",l.style.cssText="\n display: inline-flex;\n gap: 0.5rem;\n align-items: center;\n ",this.currentPage>1){const e=document.createElement("button");e.textContent="â Prev",e.style.cssText="\n padding: 0.35rem 0.85rem;\n background: transparent;\n border: 1px solid #00ff96;\n color: #00ff96;\n border-radius: 3px;\n cursor: pointer;\n font-family: 'Space Mono', monospace;\n font-size: 1rem;\n transition: all 0.2s;\n ",e.onmouseover=e=>{e.target.style.background="rgba(0, 255, 150, 0.15)"},e.onmouseout=e=>{e.target.style.background="transparent"},e.onclick=()=>{this.currentPage--,this.renderDelegates()},l.appendChild(e)}if(this.currentPage<e){const e=document.createElement("button");e.textContent="Next â",e.style.cssText="\n padding: 0.35rem 0.85rem;\n background: transparent;\n border: 1px solid #00ff96;\n color: #00ff96;\n border-radius: 3px;\n cursor: pointer;\n font-family: 'Space Mono', monospace;\n font-size: 1rem;\n transition: all 0.2s;\n ",e.onmouseover=e=>{e.target.style.background="rgba(0, 255, 150, 0.15)"},e.onmouseout=e=>{e.target.style.background="transparent"},e.onclick=()=>{this.currentPage++,this.renderDelegates()},l.appendChild(e)}return o.appendChild(l),a.appendChild(o),a}renderPagination(e,t){const s=document.getElementById("delegatesPagination"),n=document.getElementById("delegatesPaginationTop");s&&(s.innerHTML="",s.appendChild(this.createPaginationElement(e,t))),n&&(n.innerHTML="",n.appendChild(this.createPaginationElement(e,t)))}updateRefreshStatus(){const e=document.getElementById("delegatesRefreshStatus");if(e)if(this.lastUpdateTime){const s=new Date,n=Math.floor((s-this.lastUpdateTime)/1e3),a=Math.floor(n/60);let i;i=a>0?`Updated ${a}m ago`:n>=5?`Updated ${n}s ago`:"Just updated";const o=t.getState("currentEpoch")||"--",r=t.getState("epochHeight")||0,l=t.getState("blocksPerEpoch")||d(Number(o)||0),c=t.getState("delegatesSlowNodes")||0,h=t.getState("delegatesStuckNodes")||0;let u;if(!1===t.getState("delegatesHealthReliable"))u='<span class="status-warning">node health unavailable</span>';else if(h>0){u=`${c>0?`<span class="status-warning">${c} slow â ï¸</span> | `:""}<span class="status-error">${h} stuck ð¨</span>`}else u=c>0?`<span class="status-warning">${c} slow â ï¸</span>`:"All nodes performing well â";e.innerHTML=`Epoch ${o} | Progress: ${r}/${l} | ${u} | ${i}`}else e.textContent="Loading...",e.style.color="#606080"}ensureAnimation(){if(document.getElementById("fadeInUpStyle"))return;const e=document.createElement("style");e.id="fadeInUpStyle",e.textContent="\n @keyframes fadeInUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n ",document.head.appendChild(e)}async refresh(){u.clearCache(),await this.loadDelegates(),t.setSuccess("Delegates data refreshed")}getDelegateByName(e){return t.getState("delegates").find(t=>t.name===e)}getDelegateByRank(e){return t.getState("delegates").find(t=>t.rank===e)}
1destroy(){this.unsubscribers.forEach(e=>e()),this.updateStatusInterval&&clearInterval(this.updateStatusInterval)}};const S=new class{constructor(){}async init(){}destroy(){}},w="80px",y="20px",E="1rem 1.5rem",k="4px",v=2e3,x="400px",$="0.9rem",L=3e3,T="#ff4444",C="#fff",D="#cc0000",I="#00ff96",P="#0a0e27",B="#00cc78",H="#4a9eff",N="#fff",M="#2d7dd2",A="0 4px 12px rgba(0, 0, 0, 0.3)",F="400px",R=300,O="ease-out",z="'Space Mono', monospace";async function j(){try{S.init(),p.init(),n.init(),document.getElementById("logoLink")?.addEventListener("click",e=>{e.preventDefault(),window.scrollTo({top:0,behavior:"smooth"})}),document.getElementById("viewDelegatesBtn")?.addEventListener("click",()=>{document.getElementById("delegates")?.scrollIntoView({behavior:"smooth"})}),document.getElementById("scrollIndicator")?.addEventListener("click",()=>{document.getElementById("stats")?.scrollIntoView({behavior:"smooth"})}),await g.init(),await b.init(),t.subscribe("error",e=>{e&&U(e,"error")}),t.subscribe("success",e=>{e&&U(e,"success")})}catch(e){t.setError("Failed to initialize application")}}function U(e,t="info"){const s=document.createElement("div");let n,a,i;if(s.className=`notification notification-${t}`,s.textContent=e,"error"===t?(n=T,a=C,i=D):"success"===t?(n=I,a=P,i=B):(n=H,a=N,i=M),s.style.cssText=`\n position: fixed;\n top: ${w};\n right: ${y};\n padding: ${E};\n border-radius: ${k};\n z-index: ${v};\n animation: slideInRight ${R}ms ${O};\n font-family: ${z};\n max-width: ${x};\n font-size: ${$};\n box-shadow: ${A};\n background: ${n};\n color: ${a};\n border: 1px solid ${i};\n `,document.body.appendChild(s),!document.getElementById("notificationAnimations")){const e=document.createElement("style");e.id="notificationAnimations",e.textContent=`\n @keyframes slideInRight {\n from {\n opacity: 0;\n transform: translateX(${F});\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n }\n\n @keyframes slideOutRight {\n from {\n opacity: 1;\n transform: translateX(0);\n }\n to {\n opacity: 0;\n transform: translateX(${F});\n }\n }\n `,document.head.appendChild(e)}setTimeout(()=>{s.style.animation=`slideOutRight ${R}ms ${O}`,setTimeout(()=>{s.remove()},R)},L)}function q(){const e=document.querySelector(".nav-toggle"),t=document.querySelector(".nav-links"),s=document.body;e&&t&&(e.addEventListener("click",()=>{e.classList.toggle("active"),t.classList.toggle("active"),s.style.overflow=t.classList.contains("active")?"hidden":""}),t.querySelectorAll("a").forEach(n=>{n.addEventListener("click",()=>{e.classList.remove("active"),t.classList.remove("active"),s.style.overflow=""})}),document.addEventListener("click",n=>{!t.classList.contains("active")||t.contains(n.target)||e.contains(n.target)||(e.classList.remove("active"),t.classList.remove("active"),s.style.overflow="")}))}function W(){const e=document.getElementById("navSearchInput");e&&e.addEventListener("keypress",t=>{"Enter"===t.key&&function(e){if(!e)return;const t=e.startsWith("io1")&&41===e.length,s=e.startsWith("0x")&&42===e.length&&/^0x[a-fA-F0-9]{40}$/.test(e);if(t||s)return void(window.location.href=`/address.html?address=${encodeURIComponent(e)}`);const n=parseInt(e,10);if(!isNaN(n)&&n>0)return void(window.location.href=`/address.html?bucket=${encodeURIComponent(n)}`);U("Please enter a valid address (0x... or io1...) or bucket ID","error")}(e.value.trim())})}window.addEventListener("error",e=>{t.setError("An unexpected error occurred")}),window.addEventListener("unhandledrejection",e=>{t.setError("An unexpected error occurred")}),document.addEventListener("visibilitychange",()=>{}),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",j):j(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",q):q(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",W):W();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.