const e=require(`../../../API/API.cjs`),t=require(`../../../error-handling/logger.cjs`),n=require(`../../BlockchainEvent/BlockchainEvent.cjs`);var r=5e3,i=class{chainId;eventCategory;pollIntervalId;constructor(e,t){this.chainId=e,this.eventCategory=t}clear(){this.pollIntervalId!=null&&(clearInterval(this.pollIntervalId),this.pollIntervalId=void 0)}startUpdateListener(i,a,o){let s=a,c=async()=>{try{let{events:t,latestBlockNumber:r}=await e.API.getSnapshotServerEvents(this.chainId,this.eventCategory,s);t.length>0&&await i(t.map(e=>n.BlockchainEvent.fromSerialized(e))),r>=s&&(s=r+1,o(s))}catch(e){t.Logger.error(`Snapshot events poll error`,e)}};this.pollIntervalId=setInterval(c,r)}};exports.ClientEventHelper=i;