"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.updateLiveBonusWinnerInfo=exports.normalizeMaybeArray=exports.getLiveBonusWinnerInfo=exports.getLiveBonusTask=void 0;var _constant=require("../utils/constant");function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var requestWithSdk=function(e,t){var r,n,o,i,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=null==e||null===(r=e.store)||void 0===r||null===(n=r.get)||void 0===n?void 0:n.call(r,"mainInfo.mode"),a=null==e||null===(o=e.store)||void 0===o||null===(i=o.get)||void 0===i?void 0:i.call(o,"jwtToken"),c=_objectSpread(_objectSpread({},u),{},{header:_objectSpread(_objectSpread({},u.header||{}),2===Number(s)&&a?{jwttoken:a}:{})});return e&&"function"==typeof e.requestStrict?e.requestStrict(t,c):e&&"function"==typeof e.request?e.request(t,c):Promise.reject(new Error("sdkInstance is required"))},normalizeMaybeArray=function(e){if(Array.isArray(e))return e;if(!e||"object"!==_typeof(e))return[];var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)});return t.length?t.sort(function(e,t){return Number(e)-Number(t)}).map(function(t){return e[t]}):[]};exports.normalizeMaybeArray=normalizeMaybeArray;var normalizeTask=function(e){var t=(null==e?void 0:e.ActivityBonusTask)||(null==e?void 0:e.ActivityBonusTaskViewPage)||(null==e?void 0:e.ActivityBonusTaskContext)||e;if(!t||"object"!==_typeof(t))return t;var r=Array.isArray(t.BonusList)?t.BonusList:normalizeMaybeArray(t.BonusList);return _objectSpread(_objectSpread({},t),{},{BonusList:r})},getLiveBonusTask=function(e){var t=e.sdkInstance,r=e.ActivityId,n=e.Id;return requestWithSdk(t,_constant.REQUEST_URL_MAP.GET_LIVE_BONUS_TASK,{method:"GET",data:{ActivityId:r,Id:n}}).then(normalizeTask)};exports.getLiveBonusTask=getLiveBonusTask;var getLiveBonusWinnerInfo=function(e){var t=e.sdkInstance,r=e.ActivityId,n=e.Id,o=e.BonusIndex,i=e.UserId;return requestWithSdk(t,_constant.REQUEST_URL_MAP.GET_LIVE_BONUS_WINNER_INFO,{method:"GET",data:{ActivityId:r,Id:n,BonusIndex:o,UserId:Number(i)}})};exports.getLiveBonusWinnerInfo=getLiveBonusWinnerInfo;var updateLiveBonusWinnerInfo=function(e){var t=e.sdkInstance,r=e.ActivityId,n=e.Id,o=e.BonusIndex,i=e.UserID,u=e.AwardTel,s=e.AwardAddress,a=e.ReceiverName,c=e.AwardEmail;return requestWithSdk(t,_constant.REQUEST_URL_MAP.UPDATE_LIVE_BONUS_WINNER_INFO,{method:"POST",data:{ActivityId:r,Id:n,BonusIndex:o,UserID:Number(i),AwardTel:u,AwardAddress:s,ReceiverName:a,AwardEmail:c}})};exports.updateLiveBonusWinnerInfo=updateLiveBonusWinnerInfo;