"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.BasePushProvider=void 0;const console_1=require("@b/utils/console");class BasePushProvider{constructor(e,o){this.name=e;this.config=o||this.loadConfigFromEnv()}filterValidTokens(e){return e.filter(e=>this.validateToken(e))}truncateText(e,o){return e.length<=o?e:e.substring(0,o-3)+"..."}buildPayload(e,o){return{notification:{title:this.truncateText(e.title,65),body:this.truncateText(e.body,240),image:e.imageUrl,icon:e.icon},data:e.data||{},android:(null==o?void 0:o.android)||{},apns:(null==o?void 0:o.ios)?{payload:{aps:{badge:o.ios.badge,sound:o.ios.sound||"default",contentAvailable:o.ios.contentAvailable,mutableContent:o.ios.mutableContent}}}:void 0,webpush:(null==o?void 0:o.web)?{notification:{icon:o.web.icon,badge:o.web.badge,vibrate:o.web.vibrate}}:void 0}}log(e,o){void 0!==o?console_1.logger.info(`Push:${this.name}`,e,o):console_1.logger.info(`Push:${this.name}`,e)}logError(e,o){console_1.logger.error(`Push:${this.name}`,e,o instanceof Error?o:new Error(JSON.stringify(o)))}}exports.BasePushProvider=BasePushProvider;