"use strict";async function processPendingOrders(r=!0){const e="processPendingOrders";for(let s=1;s<=3;s++)try{if(r){(0,broadcast_1.broadcastStatus)(e,"running");const r=s>1?` (attempt ${s}/3)`:"";(0,broadcast_1.broadcastLog)(e,`Starting processing pending orders${r}`)}await BinaryOrderService_1.BinaryOrderService.processPendingOrders(r);if(r){(0,broadcast_1.broadcastStatus)(e,"completed");(0,broadcast_1.broadcastLog)(e,"Processing pending orders completed","success")}return}catch(t){const a=3===s;console_1.logger.error("CRON",`Processing pending orders failed (attempt ${s}/3)`,t);if(a){if(r){(0,broadcast_1.broadcastStatus)(e,"failed");(0,broadcast_1.broadcastLog)(e,`Processing pending orders failed after 3 attempts: ${t.message}`,"error")}throw t}r&&(0,broadcast_1.broadcastLog)(e,`Attempt ${s} failed, retrying in 5s...`,"warning");await new Promise(r=>setTimeout(r,5e3))}}Object.defineProperty(exports,"__esModule",{value:!0});exports.processPendingOrders=processPendingOrders;const console_1=require("@b/utils/console"),BinaryOrderService_1=require("@b/api/exchange/binary/order/util/BinaryOrderService"),broadcast_1=require("../broadcast");