!function e(t,r,n){function s(i,a){if(!r[i]){if(!t[i]){var d="function"==typeof require&&require;if(!a&&d)return d(i,!0);if(o)return o(i,!0);throw new Error("Cannot find module '"+i+"'")}var c=r[i]={exports:{}};t[i][0].call(c.exports,function(e){var r=t[i][1][e];return s(r?r:e)},c,c.exports,e,t,r,n)}return r[i].exports}for(var o="function"==typeof require&&require,i=0;ic;c++)if(e=d[c],i=this._events[e]){if(this._events[e]=s=[],t||n)for(p=0,l=i.length;l>p;p++)o=i[p],(t&&t!==o.callback&&t!==o.callback._callback||n&&n!==o.context)&&s.push(o);s.length||delete this._events[e]}return this},trigger:function(e){if(!this._events)return this;var t=s.call(arguments,1);if(!a(this,"trigger",e,t))return this;var r=this._events[e],n=this._events.all;return r&&d(r,t,this),n&&d(n,arguments,this),this}},i=/\s+/,a=function(e,t,r,n){if(!r)return!0;if("object"==typeof r){for(var s in r)e[t].apply(e,[s,r[s]].concat(n));return!1}if(i.test(r)){for(var o=r.split(i),a=0,d=o.length;d>a;a++)e[t].apply(e,[o[a]].concat(n));return!1}return!0},d=function(e,t,r){var n,s=-1,o=e.length,i=t[0],a=t[1],d=t[2];switch(t.length){case 0:for(;++s1&&(d+="&promo_sizes="+c.slice(1).join(",")),d+="&callback="+s,d+="&callback_uid="+encodeURIComponent(e+"|"+t.gptAdCode+"|"+r),a+d}var o=(e("../utils.js"),e("../bid_response.js"));DemandPartner=function(e){this.name=e},DemandPartner.prototype={name:null,validate:function(){return[]},callbackFuncName:function(){return"cosmjs.callbacks."+this.name},trackLoadStart:function(e){e.responseLoaded[this.name]=!1},markLoadEnd:function(e,t){e.responseLoaded[t]=!0}},n.prototype=new DemandPartner("an"),n.prototype.constructor=n,n.prototype.callback=function(e){function t(e){return''}var r=decodeURIComponent(e.callback_uid).split("|"),n=r[0],s=r[1];if(cosmjs.bids[s].bidRequest.responseLoaded[n]=!0,e){if(!e.result&&e.callback_uid){var i=decodeURIComponent(e.callback_uid).split("|");return void cosmjs.registerNonBidWhere({gptAdCode:i[1],demandPartners:{source:i[0]}})}if(e.result){var a=decodeURIComponent(e.callback_uid),d=a.split("|"),c=d[0],u=d[1],p=d[2];cosmjs.pushBid(new o(c,e.result.cpm/1e4,t(e),u,e.result.width,e.result.height),parseInt(p))}}},n.prototype.bid=function(e,t,r){var n=s(this.name,e,t,r,this.callbackFuncName(),cosmjs.utils.getAdSizes(e)),o=this;o.trackLoadStart(e),cosmjs.utils.loadScript(n,function(){o.markLoadEnd(e,o.name)},function(){o.markLoadEnd(e,o.name)})},n.prototype.validate=function(e){var t=[];return e.hasOwnProperty("tag_id")||t.push("tag_id not defined"),t},r.AnConnector=n,r.DemandPartner=DemandPartner},{"../bid_response.js":2,"../utils.js":21}],8:[function(e,t){function r(){}var n=e("./common.js"),s=e("../bid_response.js");r.prototype=new n.DemandPartner("cpx"),r.prototype.constructor=r,r.prototype.callback=function(e){function t(e){return''}function r(e){var t=.85;return e.result.cpm/1e4*t}var n=decodeURIComponent(e.callback_uid),o=n.split("&")[0];if(cosmjs.bids[o].bidRequest.responseLoaded.cpx=!0,!e)return void cosmjs.registerNonBidWhere({gptAdCode:o,demandPartners:{source:"cpx"}});if(!e.result)return void cosmjs.registerNonBidWhere({gptAdCode:o,demandPartners:{source:"cpx"}});if(0===e.result.cpm)return void cosmjs.registerNonBidWhere({gptAdCode:o,demandPartners:{source:"cpx"}});var i=t(e),a=r(e),d=Number(n.split("&")[1]);cosmjs.pushBid(new s("cpx",a,i,o,e.result.width,e.result.height),d)},r.prototype.bid=function(e,t,r){var n=e.gptAdCode+"&"+t,s="https:"==document.location.protocol,o="";o+=s?"https://ib.adnxs.com/jpt?":"http://optimizedby.brealtime.com/jpt?",o+="id=",o+=r.tag_id,o+="&size=",o+=e.sizes[0],o+="&referrer=",o+=encodeURIComponent(window.location.hostname+window.location.pathname),o+="&callback=",o+=this.callbackFuncName(),o+="&callback_uid="+encodeURIComponent(n);var i=this;i.trackLoadStart(e),cosmjs.utils.loadScript(o,function(){i.markLoadEnd(e,i.name)},function(){i.markLoadEnd(e,i.name)})},r.prototype.validate=function(e){var t=[];return e.source&&"cpx"===e.source||t.push("Invalid source config"),t},t.exports=new r},{"../bid_response.js":2,"./common.js":7}],9:[function(e,t){function r(){}{var n=e("./common.js");e("../bid_response.js")}r.prototype=new n.DemandPartner("cr"),r.prototype.constructor=r,r.prototype.globalBid=function(e,t){this.createBidIframe(e,t)},r.prototype.callback=function(e){function t(e){keys=[];for(var t in f)keys.push(t);return-1!==keys.indexOf(e)}function r(e){var t=[];for(var r in f)t.push(f[r]);return-1!==t.indexOf(e)}function n(e){for(var n in e){size=e[n];for(var s in cosmjs.bids)if(!t(s)&&!r(size)){var o=cosmjs.bids[s],a=!1;for(i=0;i");',u+="",u+="",u=u.replace("#ZONE ID#",e)}var a=Number(e.split("_")[1]),d=window[e],c=[];for(var u in cosmjs.bids)this.markLoadEnd(cosmjs.bids[u].bidRequest,this.name);if(!d||""===d)return void cosmjs.registerNonBidWhere({demandPartners:{source:"cr"}});var p=d.split(";"),l={72890:"728x90",300250:"300x250",300600:"300x600",160600:"160x600"},m={"728x90":"308908","300x250":"308909","300x600":"308910","160x600":"308911"},f={},h=[];for(i=0;i'}cosmjs.bids[t].bidRequest.responseLoaded.pm=!0;var d={},c=null;for(var u in o)if(o.hasOwnProperty(u)){if(null!==c)throw new Error("multiple ad units");c=u,d[u]={};var p,l=o[u].split(";");if(-1===o[u].indexOf("="))for(p=0;p",s+='',s+=""}function s(){var e=document.getElementsByTagName("head")[0],r=cosmjs.utils.createPixelIframe();e.insertBefore(r,e.firstChild);var s=r.contentWindow.document;return s.write(n(t,r.id)),s.close(),r.id}var o=this;s()},t.exports=new r},{"../bid_response.js":2,"./common.js":7}],13:[function(e,t){function r(){}var n=e("./common.js"),s=e("../bid_response.js");r.prototype=new n.DemandPartner("pp"),r.prototype.constructor=r,r.prototype.callback=function(e,t){if(cosmjs.bids[e.adCode].bidRequest.responseLoaded.pp=!0,!t)return void cosmjs.registerNonBidWhere({gptAdCode:e.adSlot,demandPartners:{source:"pp"}});var r=JSON.parse(t);if(!r.html)return void cosmjs.registerNonBidWhere({gptAdCode:e.adSlot,demandPartners:{source:"pp"}});if(0===r.bidCpm)return void cosmjs.registerNonBidWhere({gptAdCode:e.adSlot,demandPartners:{source:"pp"}});var n=parseInt(e.size.split("x")[0]),o=parseInt(e.size.split("x")[1]);cosmjs.pushBid(new s("pp",r.bidCpm,r.html,e.adCode,n,o),e.index)},r.prototype.validate=function(e){var t=[];return e.source&&"pp"===e.source||t.push("Invalid source config"),t},r.prototype.bid=function(e,t,r){function n(e,t,r,n){try{var s=null;window.ActiveXObject?s=new ActiveXObject("Microsoft.XMLHTTP"):window.XMLHttpRequest&&(s=new XMLHttpRequest),s.open(e,t,1),s.withCredentials=!0,s.onload=function(){200==s.status?r(s.responseText):errFunc()},s.onerror=n,s.send()}catch(o){console.log("network error")}}function s(){try{return window.top.location.href}catch(e){return window.location.href}}function o(e,t,r){for(var o,a=s(),d=document.referrer,c=document.documentElement.clientWidth,u=document.documentElement.clientHeight,p=(new Date).getTimezoneOffset(),l=navigator.language||navigator.browserLanguage||navigator.userLanguage||navigator.systemLanguage,m=0;m0&&(g=e.sizes[0]);var b="";e.position&&(b=e.position);var v="https:"==document.location.protocol,_=v?"https:":"http:",y=_+"//tag.contextweb.com/bid?ca=BID&cp="+f+"&ct="+h+"&cf="+g+"&dw="+c+"&cwu="+encodeURIComponent(a)+"&cwr="+encodeURIComponent(d)+"&if=0&tl=1&pxy="+b+"&cxy="+c+","+u+"&tz="+p+"&ln="+l,R={size:g,index:r,adCode:e.gptAdCode};i.trackLoadStart(e),n("GET",y,function(e){i.callback(R,e)},function(){cosmjs.bids[R.adCode].bidRequest.responseLoaded.pp=!0})}var i=this;o(e,r,t)},t.exports=new r},{"../bid_response.js":2,"./common.js":7}],14:[function(e,t){function r(){}function n(e,t,r,n,s,o){var i="https:"==document.location.protocol,a=(i?"https://":"http://")+"bidder.springserve.com/display/hbid",d="?sp="+n.sp_id,c=window.location.hostname;d+="&domain="+encodeURIComponent(c);var u=o[0][0],p=o[0][1];if(d+="&w="+u+"&h="+p,o.length>1){for(var l=[],m=1;m"),cosmjs.pushBid(new s(r,p.price,l,p.impid,p.w,p.h),Number(d)),u.push(p.impid)}a.length>u.length&&t(a,u)},r.prototype.validate=function(e){var t=[];return"svn"!==e.source&&t.push("Invalid source config"),t},t.exports=new r},{"../bid_response.js":2,"./common.js":7}],16:[function(e,t){function r(){}function n(e){var t=[];if(""===e)return t;for(var r=e.split(","),n=0;n'}var o=e("./common.js");r.prototype=new o.DemandPartner("yb"),r.prototype.constructor=r,r.prototype.globalBid=function(e){if("undefined"!=typeof yieldbot&&"function"==typeof yieldbot.getPageCriteria){for(var t in cosmjs.bids)this.trackLoadStart(cosmjs.bids[t].bidRequest);this.callback(yieldbot.getPageCriteria(),e)}else for(var r in cosmjs.bids)this.markLoadEnd(cosmjs.bids[r].bidRequest,this.name)},r.prototype.callback=function(e,t){for(var r in cosmjs.bids)this.markLoadEnd(cosmjs.bids[r].bidRequest,this.name);cosmjs.pushGlobalBid("yb",n(e),t)},t.exports=new r},{"./common.js":7}],17:[function(e,t,r){function n(){}{var s=e("./common.js");e("../bid_response.js")}n.prototype=new s.AnConnector("yh"),n.prototype.constructor=n,r.an=new n},{"../bid_response.js":2,"./common.js":7}],18:[function(e,t){DemandTagFilter=function(e){this.tagSizePriority=e},DemandTagFilter.prototype={tagSizePriority:[],filterDemandTags:function(e,t){var r=this.filterToAvailableSizes(e,t);return"object"==typeof this.tagSizePriority&&this.tagSizePriority.length>0?this.filterToPrioritySizeTags(r):this.dedupePartners(r)},filterToAvailableSizes:function(e,t){var r=e.map(function(e){return e.split("x")}),n=t.filter(function(e){var t=!1;if(e.height&&e.width)for(var n=0;n0?t[0].priority:-1;return r}function r(e,r){return t(e)>t(r)}for(var n=this,s=[],o=0;o2e3&&O&&console.log("src too long"),{src:r,cb:t}}function c(e,t,r){var n={type:e,data:t};return r&&(n.error=r),n.errorPixel=d(n),n}function u(e,t,n){var s=c(e,t,n);if(r(W.handleError,s),O)throw new Error(s.type+" "+JSON.stringify(s));(new Image).src=s.errorPixel.src}function p(e,t,n){var s=c(e,t,n);r(W.handleWarning,s),O?console.log(s.type+" "+JSON.stringify(s)):(new Image).src=s.errorPixel.src}function l(e,t){var r=100*X.price_buckets.increment,n=100*X.price_buckets.max,s=100*X.price_buckets.min,o=Math.min(Math.floor(e*t*100/r)*r,n);return s>o?null:o}function m(e){if(e.cosm_type=_(z.SERVER_CONFIG.cosm_type),"number"!=typeof z.SERVER_CONFIG.seller_id||z.SERVER_CONFIG.seller_id<=0)throw new Error("invalid seller_id");if(e.placement_group_id=z.SERVER_CONFIG.placement_group_id,e.seller_id=z.SERVER_CONFIG.seller_id,"object"==typeof z.SERVER_CONFIG.price_buckets&&("number"==typeof z.SERVER_CONFIG.price_buckets.increment&&z.SERVER_CONFIG.price_buckets.increment>0&&(e.price_buckets.increment=z.SERVER_CONFIG.price_buckets.increment),"number"==typeof z.SERVER_CONFIG.price_buckets.max&&z.SERVER_CONFIG.price_buckets.max>0&&(e.price_buckets.max=z.SERVER_CONFIG.price_buckets.max),"number"==typeof z.SERVER_CONFIG.price_buckets.min&&z.SERVER_CONFIG.price_buckets.min>=0&&(e.price_buckets.min=z.SERVER_CONFIG.price_buckets.min)),"number"==typeof z.SERVER_CONFIG.request_pixel_timeout_delta&&z.SERVER_CONFIG.request_pixel_timeout_delta>0&&(e.request_pixel_timeout_delta=z.SERVER_CONFIG.request_pixel_timeout_delta),Array.isArray(z.SERVER_CONFIG.sources))for(var t=z.SERVER_CONFIG.sources,r=0;r1)throw new Error("crs not a %");J[n.source]=n.crs}return"number"==typeof z.SERVER_CONFIG.base_timeout&&z.SERVER_CONFIG.base_timeout>0&&(e.base_timeout=z.SERVER_CONFIG.base_timeout),"boolean"==typeof z.SERVER_CONFIG.setupSlots&&(e.setupSlots=z.SERVER_CONFIG.setupSlots),"boolean"==typeof z.SERVER_CONFIG.initial_load&&(e.initialLoad=z.SERVER_CONFIG.initial_load),e}function f(e){for(var t in cosmjs.bids)if(cosmjs.bids.hasOwnProperty(t)){var r=cosmjs.bids[t];if(r.bidRequest.unit_id==e)return t}return""}function h(e,t){if(!t)return{};var r=t.adCode;return r?("IFRAME"==r.substr(1,6)&&(r=t.adCode.replace(/\"/g,"'")),{nbr:0,id:e,seatbid:[{seat:t.demandPartner,bid:[{ext:null,id:e,impid:e,crid:"",price:t.netPrice,adm:r,adomain:[null],dealid:"",height:t.height,width:t.width}]}],cur:"USD"}):{}}function g(e,t,r,n,s,o,i){var a=1e16*Math.random(),d=19,c=encodeURIComponent(o),u="google"===n?6:q.idmap[n],p="google"===n?1:i[n],l=M+"cb="+a+"&yh_id="+d+"&seller_id="+X.seller_id+"&channel_id="+X.placement_group_id+"&ad_code="+c+"&tag_id="+s+"&partner_id="+u+"&partner="+n+"&crs="+p+"×tamp="+(new Date).getTime()+"&width="+t+"&height="+r;return null!==e&&(l+="&bid_cpm="+e*p),l.length>2e3&&O&&console.log("src too long"),{src:l,cb:a}}function b(e,t){var n=t.demandPartner,s=t.adSlotID,o=g(t.price,t.width,t.height,n,e.unit_id,e.ad_code,J);return r(W.renderWinner,{ad_code:s,partner:n,winner:t,winnerPixel:o}),o.src}function v(e){function t(e){return X.sources.find(function(t){return t.source==e.demandPartner})}Z=setTimeout(n,X.request_pixel_timeout_delta);var r,s,o=f(e);if(cosmjs.bids[o]){for(var i=0;i";r.adCode=r.adCode+u}return h(e,r)}}function _(e){if(typeof e===V){var t=e.toLowerCase();e=-1!=F.indexOf(t)?t:"pro"}else e="pro";return e}function y(e){for(var t=[],r=[],n=0;n0){t.push("failed demand partner validation "+o.join(" "));break}r.push(s)}return{warning_messages:t,validSources:r}}function R(e,t,r){var n=w(Array.isArray(e)?e:[],r),s=w(Array.isArray(t)?t:[],r);for(var o in s.bids)s.bids.hasOwnProperty(o)&&(n.bids[o]=s.bids[o]);return{error_messages:n.error_messages.concat(s.error_messages),warning_messages:n.warning_messages.concat(s.warning_messages),bids:n.bids}}function w(e,t){function r(e,t){if(!e.hasOwnProperty(t))return{warning_messages:["no size key"+t],sizes:null};var r=e[t];if(!Array.isArray(r))return{warning_messages:["sizes must be array"],sizes:[]};for(var n=[],s=!0,o=[],i=0;i0&&d[1]>0||(o.push("invalid size"),s=!1)}catch(u){o.push("invalid size tuple"),a=!1}a&&n.push(c)}return{warning_messages:o,sizes:n}}for(var n={},s=[],o=[],i=0;ie?t-e:null}function C(e,t,r,n){var s,o,d={};for(s=0;s2e3&&O&&console.log("src too long"),{src:o,requestData:e,cb:n}}function N(){return Y++,et[Y]={},Y}var O=!1,A=e("./bids.js"),q=e("./demand_partners.js"),B=e("./backbone.events.js"),z=e("./config.js"),T=(e("./bid_response.js"),e("./no_bid_response.js")),G=e("./demand_tag_filter.js"),L=("https:"==location.protocol?"https:":"http:")+"//omni.springserve.com/hb",M=L+"?",D=L+"/error?",F=["pro","lite"],V="string",W={init:"init",doBidRequests:"doBidRequests",pushBid:"pushBid",pushGlobalBid:"pushGlobalBid",registerBid:"registerBid",registerGlobalBid:"registerGlobalBid",registerNonBidWhere:"registerNonBidWhere",refreshAds:"refreshAds",renderWinner:"renderWinner",renderGoogle:"renderGoogle",refreshBids:"refreshBids",sendRequestPixels:"sendRequestPixels",requestPixel:"requestPixel",handleError:"handleError",handleWarning:"handleWarning",loadAds:"loadAds"},U={cosm_type:"pro",price_buckets:{increment:.5,max:5,min:.5},base_timeout:2e3,request_pixel_timeout_delta:500,sources:[],globalSources:[],units:[],setupSlots:!1},H={config_error:"config_error",config_warning:"config_warning",listener_error:"listener_error",render_winner_error:"render_winner_error",setup_gpt_error:"setup_gpt_error",send_request_pixels:"send_request_pixels",display:"display"};"undefined"==typeof cosmjs&&(cosmjs={}),B._.extend(cosmjs,B.Events),Array.isArray(cosmjs.cmd)||(cosmjs.cmd=[]),cosmjs.utils=e("./utils.js"),cosmjs.callbacks=q.callbacks;var X,J={};cosmjs.bids={},cosmjs.globalDemandPartners=[];var Y=-1,K=null,Z=null,$=null,Q=null,et={},tt=null;CallbackManager=function(){},CallbackManager.prototype={callbacks:{},findOrMakeTagRef:function(e){return this.callbacks[e.toString()]||(this.callbacks[e.toString()]={tid:0,cb:function(){},done:!1}),this.callbacks[e.toString()]},registerCbId:function(e,t){this.findOrMakeTagRef(e).tid=t},registerCb:function(e,t){this.findOrMakeTagRef(e).cb=t},stopTimeout:function(e){clearTimeout(this.findOrMakeTagRef(e).tid)},executeCb:function(e){this.stopTimeout(e),this.findOrMakeTagRef(e).cb()},registerTimeout:function(e,t,r){this.findOrMakeTagRef(e).done=!1;var n=this;this.registerCb(e,t),this.registerCbId(e,setTimeout(function(){t(),n.findOrMakeTagRef(e).done=!0},r))}},callbackManager=new CallbackManager,cosmjs.registerNonBidWhere=function(e){function t(e,t){e.noBidResponses=e.noBidResponses||[],e.noBidResponses.push(new T(t.source,e.bidRequest.gptAdCode,e.bidRequest.divId)),s(e)}for(var r in cosmjs.bids)if(cosmjs.bids.hasOwnProperty(r))for(var n=cosmjs.bids[r],o=0;oY||O)&&(null!==Z&&(clearTimeout(Z),n()),X=t(U),J={},cosmjs.bids={},tt=null,null!==K&&clearTimeout(K),Q=null),0===cosmjs.auctionsRun&&(X=m(X),cosmjs.auctionsRun+=1);var s=[];"object"==typeof z.SERVER_CONFIG.demand_tag_sizes&&(s=z.SERVER_CONFIG.demand_tag_sizes);var o=new G(s),i=R(z.SERVER_CONFIG.units,[],o);if(i.error_messages.length>0)return void u(H.config_error,{error_messages:i.error_messages});i.warning_messages.length>0&&p(H.config_warning,{warning_messages:i.warning_messages}),cosmjs.bids=i.bids;var a=k(X.globalSources);if(a.error_messages.length>0)return void u(H.config_error,{error_messages:a.error_messages});a.warning_messages.length>0&&p(H.config_warning,{warning_messages:a.warning_messages}),cosmjs.globalDemandPartners=a.demandPartners;for(var d=0;d