/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/prebid_adikteev@0.24.0-pre/src/prebid.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{getGlobal}from"./prebidGlobal";import{flatten,uniques,isGptPubadsDefined,adUnitsFilter}from"./utils";import{videoAdUnit,hasNonVideoBidder}from"./video";import"polyfill";import{parse as parseURL,format as formatURL}from"./url";import{isValidePriceConfig}from"./cpmBucketManager";import{listenMessagesFromCreative}from"./secure-creatives";import{syncCookies}from"src/cookie.js";import{loadScript}from"./adloader";var $$PREBID_GLOBAL$$=getGlobal(),CONSTANTS=require("./constants.json"),utils=require("./utils.js"),bidmanager=require("./bidmanager.js"),adaptermanager=require("./adaptermanager"),bidfactory=require("./bidfactory"),events=require("./events"),adserver=require("./adserver.js"),targeting=require("./targeting.js"),objectType_function="function",objectType_undefined="undefined",objectType_object="object",BID_WON=CONSTANTS.EVENTS.BID_WON,SET_TARGETING=CONSTANTS.EVENTS.SET_TARGETING,auctionRunning=!1,bidRequestQueue=[],eventValidators={bidWon:checkDefinedPlacement};function processQue(){for(var e=0;e<$$PREBID_GLOBAL$$.que.length;e++)if(typeof $$PREBID_GLOBAL$$.que[e].called===objectType_undefined)try{$$PREBID_GLOBAL$$.que[e].call(),$$PREBID_GLOBAL$$.que[e].called=!0}catch(e){utils.logError("Error processing command :","prebid.js",e)}}function checkDefinedPlacement(e){var i=$$PREBID_GLOBAL$$._bidsRequested.map((e=>e.bids.map((e=>e.placementCode)))).reduce(flatten).filter(uniques);if(utils.contains(i,e))return!0;utils.logError('The "'+e+'" placement is not defined.')}function clearPlacements(){$$PREBID_GLOBAL$$._bidsRequested=[],$$PREBID_GLOBAL$$._bidsReceived=$$PREBID_GLOBAL$$._bidsReceived.filter((e=>!$$PREBID_GLOBAL$$._adUnitCodes.includes(e.adUnitCode)))}function setRenderSize(e,i,t){e.defaultView&&e.defaultView.frameElement&&(e.defaultView.frameElement.width=i,e.defaultView.frameElement.height=t)}$$PREBID_GLOBAL$$._bidsRequested=[],$$PREBID_GLOBAL$$._bidsReceived=[],$$PREBID_GLOBAL$$._adUnitCodes=[],$$PREBID_GLOBAL$$._winningBids=[],$$PREBID_GLOBAL$$._adsReceived=[],$$PREBID_GLOBAL$$._sendAllBids=!1,$$PREBID_GLOBAL$$.bidderSettings=$$PREBID_GLOBAL$$.bidderSettings||{},$$PREBID_GLOBAL$$.bidderTimeout=$$PREBID_GLOBAL$$.bidderTimeout||3e3,$$PREBID_GLOBAL$$.cbTimeout=$$PREBID_GLOBAL$$.cbTimeout||200,$$PREBID_GLOBAL$$.timeoutBuffer=200,$$PREBID_GLOBAL$$.logging=$$PREBID_GLOBAL$$.logging||!1,$$PREBID_GLOBAL$$.publisherDomain=$$PREBID_GLOBAL$$.publisherDomain||window.location.origin,$$PREBID_GLOBAL$$.libLoaded=!0,$$PREBID_GLOBAL$$.version="v$prebid.version$",utils.logInfo("Prebid.js v$prebid.version$ loaded"),$$PREBID_GLOBAL$$.adUnits=$$PREBID_GLOBAL$$.adUnits||[],$$PREBID_GLOBAL$$.cookieSyncDelay=$$PREBID_GLOBAL$$.cookieSyncDelay||100,$$PREBID_GLOBAL$$.que.push=function(e){if(typeof e===objectType_function)try{e.call()}catch(e){utils.logError("Error processing command :"+e.message)}else utils.logError("Commands written into $$PREBID_GLOBAL$$.que.push must wrapped in a function")},$$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCodeStr=function(e){if(utils.logInfo("Invoking $$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCodeStr",arguments),e){var i=$$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCode(e);return utils.transformAdServerTargetingObj(i)}utils.logMessage("Need to call getAdserverTargetingForAdUnitCodeStr with adunitCode")},$$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCode=function(e){return $$PREBID_GLOBAL$$.getAdserverTargeting(e)[e]},$$PREBID_GLOBAL$$.getAdserverTargeting=function(e){return utils.logInfo("Invoking $$PREBID_GLOBAL$$.getAdserverTargeting",arguments),targeting.getAllTargeting(e).map((e=>({[Object.keys(e)[0]]:e[Object.keys(e)[0]].map((e=>({[Object.keys(e)[0]]:e[Object.keys(e)[0]].join(", ")}))).reduce(((e,i)=>Object.assign(i,e)),{})}))).reduce((function(e,i){var t=Object.keys(i)[0];return e[t]=Object.assign({},e[t],i[t]),e}),{})},$$PREBID_GLOBAL$$.getBidResponses=function(){utils.logInfo("Invoking $$PREBID_GLOBAL$$.getBidResponses",arguments);const e=$$PREBID_GLOBAL$$._bidsReceived.filter(adUnitsFilter.bind(this,$$PREBID_GLOBAL$$._adUnitCodes)),i=e&&e.length&&e[e.length-1].requestId;return e.map((e=>e.adUnitCode)).filter(uniques).map((t=>e.filter((e=>e.requestId===i&&e.adUnitCode===t)))).filter((e=>e&&e[0]&&e[0].adUnitCode)).map((e=>({[e[0].adUnitCode]:{bids:e}}))).reduce(((e,i)=>Object.assign(e,i)),{})},$$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode=function(e){return{bids:$$PREBID_GLOBAL$$._bidsReceived.filter((i=>i.adUnitCode===e))}},$$PREBID_GLOBAL$$.setTargetingForGPTAsync=function(){utils.logInfo("Invoking $$PREBID_GLOBAL$$.setTargetingForGPTAsync",arguments),isGptPubadsDefined()?(targeting.resetPresetTargeting(),targeting.setTargeting(targeting.getAllTargeting()),events.emit(SET_TARGETING)):utils.logError("window.googletag is not defined on the page")},$$PREBID_GLOBAL$$.setTargetingForAst=function(){utils.logInfo("Invoking $$PREBID_GLOBAL$$.setTargetingForAn",arguments),targeting.isApntagDefined()?(targeting.setTargetingForAst(),events.emit(SET_TARGETING)):utils.logError("window.apntag is not defined on the page")},$$PREBID_GLOBAL$$.allBidsAvailable=function(){return utils.logInfo("Invoking $$PREBID_GLOBAL$$.allBidsAvailable",arguments),bidmanager.bidsBackAll()},$$PREBID_GLOBAL$$.renderAd=function(e,i){if(utils.logInfo("Invoking $$PREBID_GLOBAL$$.renderAd",arguments),utils.logMessage("Calling renderAd with adId :"+i),e&&i)try{const t=$$PREBID_GLOBAL$$._bidsReceived.find((e=>e.adId===i));if(t){t.ad=utils.replaceAuctionPrice(t.ad,t.cpm),t.url=utils.replaceAuctionPrice(t.url,t.cpm),$$PREBID_GLOBAL$$._winningBids.push(t),events.emit(BID_WON,t);const{height:r,width:n,ad:$,mediaType:o,adUrl:a,renderer:d}=t;d&&d.url?d.render(t):e===document&&!utils.inIframe()||"video"===o?utils.logError(`Error trying to write ad. Ad render call ad id ${i} was prevented from writing to the main document.`):$?(e.write($),e.close(),setRenderSize(e,n,r)):a?(e.write(`<IFRAME SRC="${a}" FRAMEBORDER="0" SCROLLING="no" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0" ALLOWTRANSPARENCY="true" WIDTH="${n}" HEIGHT="${r}"></IFRAME>`),e.close(),setRenderSize(e,n,r)):utils.logError("Error trying to write ad. No ad for bid response id: "+i)}else utils.logError("Error trying to write ad. Cannot find ad by given id : "+i)}catch(e){utils.logError("Error trying to write ad Id :"+i+" to the page:"+e.message)}else utils.logError("Error trying to write ad Id :"+i+" to the page. Missing document or adId")},$$PREBID_GLOBAL$$.removeAdUnit=function(e){if(utils.logInfo("Invoking $$PREBID_GLOBAL$$.removeAdUnit",arguments),e)for(var i=0;i<$$PREBID_GLOBAL$$.adUnits.length;i++)$$PREBID_GLOBAL$$.adUnits[i].code===e&&$$PREBID_GLOBAL$$.adUnits.splice(i,1)},$$PREBID_GLOBAL$$.clearAuction=function(){auctionRunning=!1,syncCookies($$PREBID_GLOBAL$$.cookieSyncDelay),utils.logMessage("Prebid auction cleared"),bidRequestQueue.length&&bidRequestQueue.shift()()},$$PREBID_GLOBAL$$.requestBids=function({bidsBackHandler:e,timeout:i,adUnits:t,adUnitCodes:r}={}){events.emit("requestBids");const n=$$PREBID_GLOBAL$$.cbTimeout=i||$$PREBID_GLOBAL$$.bidderTimeout;t=t||$$PREBID_GLOBAL$$.adUnits,utils.logInfo("Invoking $$PREBID_GLOBAL$$.requestBids",arguments),r&&r.length?t=t.filter((e=>r.includes(e.code))):r=t&&t.map((e=>e.code));if(t.filter(videoAdUnit).filter(hasNonVideoBidder).forEach((e=>{utils.logError(`adUnit ${e.code} has 'mediaType' set to 'video' but contains a bidder that doesn't support video. No Prebid demand requests will be triggered for this adUnit.`);for(let i=0;i<t.length;i++)t[i].code===e.code&&t.splice(i,1)})),auctionRunning)return void bidRequestQueue.push((()=>{$$PREBID_GLOBAL$$.requestBids({bidsBackHandler:e,timeout:n,adUnits:t,adUnitCodes:r})}));if(auctionRunning=!0,$$PREBID_GLOBAL$$._adUnitCodes=r,bidmanager.externalCallbackReset(),clearPlacements(),!t||0===t.length)return utils.logMessage("No adUnits configured. No bids requested."),typeof e===objectType_function&&bidmanager.addOneTimeCallback(e,!1),void bidmanager.executeCallback();const $=bidmanager.executeCallback.bind(bidmanager,!0),o=setTimeout($,n);typeof e===objectType_function&&bidmanager.addOneTimeCallback(e,o),adaptermanager.callBids({adUnits:t,adUnitCodes:r,cbTimeout:n}),0===$$PREBID_GLOBAL$$._bidsRequested.length&&bidmanager.executeCallback()},$$PREBID_GLOBAL$$.addAdUnits=function(e){utils.logInfo("Invoking $$PREBID_GLOBAL$$.addAdUnits",arguments),utils.isArray(e)?(e.forEach((e=>e.transactionId=utils.generateUUID())),$$PREBID_GLOBAL$$.adUnits.push.apply($$PREBID_GLOBAL$$.adUnits,e)):typeof e===objectType_object&&(e.transactionId=utils.generateUUID(),$$PREBID_GLOBAL$$.adUnits.push(e))},$$PREBID_GLOBAL$$.onEvent=function(e,i,t){utils.logInfo("Invoking $$PREBID_GLOBAL$$.onEvent",arguments),utils.isFn(i)?!t||eventValidators[e].call(null,t)?events.on(e,i,t):utils.logError('The id provided is not valid for event "'+e+'" and no handler was set.'):utils.logError('The event handler provided is not a function and was not set on event "'+e+'".')},$$PREBID_GLOBAL$$.offEvent=function(e,i,t){utils.logInfo("Invoking $$PREBID_GLOBAL$$.offEvent",arguments),t&&!eventValidators[e].call(null,t)||events.off(e,i,t)},$$PREBID_GLOBAL$$.addCallback=function(e,i){utils.logInfo("Invoking $$PREBID_GLOBAL$$.addCallback",arguments);var t=null;return e&&i&&typeof i===objectType_function?(t=utils.getUniqueIdentifierStr,bidmanager.addCallback(t,i,e),t):(utils.logError("error registering callback. Check method signature"),t)},$$PREBID_GLOBAL$$.removeCallback=function(){return null},$$PREBID_GLOBAL$$.registerBidAdapter=function(e,i){utils.logInfo("Invoking $$PREBID_GLOBAL$$.registerBidAdapter",arguments);try{adaptermanager.registerBidAdapter(e(),i)}catch(e){utils.logError("Error registering bidder adapter : "+e.message)}},$$PREBID_GLOBAL$$.registerAnalyticsAdapter=function(e){utils.logInfo("Invoking $$PREBID_GLOBAL$$.registerAnalyticsAdapter",arguments);try{adaptermanager.registerAnalyticsAdapter(e)}catch(e){utils.logError("Error registering analytics adapter : "+e.message)}},$$PREBID_GLOBAL$$.bidsAvailableForAdapter=function(e){utils.logInfo("Invoking $$PREBID_GLOBAL$$.bidsAvailableForAdapter",arguments),$$PREBID_GLOBAL$$._bidsRequested.find((i=>i.bidderCode===e)).bids.map((i=>Object.assign(i,bidfactory.createBid(1),{bidderCode:e,adUnitCode:i.placementCode}))).map((e=>$$PREBID_GLOBAL$$._bidsReceived.push(e)))},$$PREBID_GLOBAL$$.createBid=function(e){return utils.logInfo("Invoking $$PREBID_GLOBAL$$.createBid",arguments),bidfactory.createBid(e)},$$PREBID_GLOBAL$$.addBidResponse=function(e,i){utils.logInfo("Invoking $$PREBID_GLOBAL$$.addBidResponse",arguments),bidmanager.addBidResponse(e,i)},$$PREBID_GLOBAL$$.loadScript=function(e,i,t){utils.logInfo("Invoking $$PREBID_GLOBAL$$.loadScript",arguments),loadScript(e,i,t)},$$PREBID_GLOBAL$$.enableAnalytics=function(e){e&&!utils.isEmpty(e)?(utils.logInfo("Invoking $$PREBID_GLOBAL$$.enableAnalytics for: ",e),adaptermanager.enableAnalytics(e)):utils.logError("$$PREBID_GLOBAL$$.enableAnalytics should be called with option {}")},$$PREBID_GLOBAL$$.aliasBidder=function(e,i){utils.logInfo("Invoking $$PREBID_GLOBAL$$.aliasBidder",arguments),e&&i?adaptermanager.aliasBidAdapter(e,i):utils.logError("bidderCode and alias must be passed as arguments","$$PREBID_GLOBAL$$.aliasBidder")},$$PREBID_GLOBAL$$.setPriceGranularity=function(e){if(utils.logInfo("Invoking $$PREBID_GLOBAL$$.setPriceGranularity",arguments),e){if("string"==typeof e)bidmanager.setPriceGranularity(e);else if("object"==typeof e){if(!isValidePriceConfig(e))return void utils.logError("Invalid custom price value passed to `setPriceGranularity()`");bidmanager.setCustomPriceBucket(e),bidmanager.setPriceGranularity(CONSTANTS.GRANULARITY_OPTIONS.CUSTOM),utils.logMessage("Using custom price granularity")}}else utils.logError("Prebid Error: no value passed to `setPriceGranularity()`")},$$PREBID_GLOBAL$$.enableSendAllBids=function(){$$PREBID_GLOBAL$$._sendAllBids=!0},$$PREBID_GLOBAL$$.getAllWinningBids=function(){return $$PREBID_GLOBAL$$._winningBids},$$PREBID_GLOBAL$$.buildMasterVideoTagFromAdserverTag=function(e,i){utils.logInfo("Invoking $$PREBID_GLOBAL$$.buildMasterVideoTagFromAdserverTag",arguments);var t=parseURL(e);if(0===$$PREBID_GLOBAL$$._bidsReceived.length)return e;if("dfp"===i.adserver.toLowerCase()){var r=adserver.dfpAdserver(i,t);return r.verifyAdserverTag()||utils.logError("Invalid adserverTag, required google params are missing in query string"),r.appendQueryParams(),formatURL(r.urlComponents)}utils.logError("Only DFP adserver is supported")},$$PREBID_GLOBAL$$.setBidderSequence=function(e){e===CONSTANTS.ORDER.RANDOM&&adaptermanager.setBidderSequence(CONSTANTS.ORDER.RANDOM)},$$PREBID_GLOBAL$$.getHighestCpmBids=function(e){return targeting.getWinningBids(e)},$$PREBID_GLOBAL$$.setS2SConfig=function(e){if(!utils.contains(Object.keys(e),"accountId"))return void utils.logError("accountId missing in Server to Server config");if(!utils.contains(Object.keys(e),"bidders"))return void utils.logError("bidders missing in Server to Server config");const i=Object.assign({enabled:!1,endpoint:CONSTANTS.S2S.DEFAULT_ENDPOINT,timeout:1e3,maxBids:1,adapter:"prebidServer"},e);adaptermanager.setS2SConfig(i)},$$PREBID_GLOBAL$$.que.push((()=>listenMessagesFromCreative())),processQue();
//# sourceMappingURL=/sm/7849f4a229815bc641d9dd11eb03355130c8a5c6ceab7bd347e2f21511f9cf83.map