// Turner XMP, Release Build, © 2007 Turner Broadcasting System, Inc. A Time Warner Company.  File: xmp_playlistapi, Version: 0.1.555.2010

xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.PatternDirective=function(aa,ba,ca){xmp.validateArguments(arguments,[xmp.STRING_TYPE,xmp.OBJECT_TYPE,xmp.OBJECT_TYPE],"PatternDirective.ctor");if(!xmp.isNonEmptyString(aa)){throw new xmp.util.internals.InvalidArgsError("Argument 'type' must be a non-empty string.");}
this._type=aa;this._metadataMap=new xmp.util.internals.MetadataMap(true);this._metadataMap._reInitialize(ba);this._parameters=ca;};xmp.playlistapi.internals.PatternDirective.prototype.getType=function(){return this._type;};xmp.playlistapi.internals.PatternDirective.prototype.getParameterArray=function(){return this._parameters;};xmp.playlistapi.internals.PatternDirective.prototype.getMetadata=function(da,ea){return this._metadataMap._get(da,ea);};xmp.playlistapi.internals.PatternDirective.prototype._findNamedContentNode=function(fa,ga,ha){var ia=this._findNamedContentNodeFromIterator(fa._getDataIterator(),ga,ha);if(ia===null){xmp.util.internals.CategoryLogger.create('PatternDirective').info('Did not find named content node: '+ha+', trying historical data.');ia=this._findNamedContentNodeFromIterator(fa._getHistoricalDataIterator(),ga,ha);}
return ia;};xmp.playlistapi.internals.PatternDirective.prototype._findNamedContentNodeFromIterator=function(ja,ka,la){ja.first();var ma=(la==='@Content');while(ja.hasNext()){var na=ja.next();if(!na.isValid()){continue;}
if(na.isContentType()&&na.getNodeType()._getParent()._isContentCompositeType()){if(ma){if(na._getPatternAddress().isSibling(ka._getPatternAddress(),true)){return na;}}
else{if(na.getNodeType()._getParent().getId()===la){var oa=na._getPatternAddress().getParent();if(oa.isSibling(ka._getPatternAddress(),true)){return na;}}}}}
return null;};xmp.createNamespace("xmp.playlistapi");xmp.playlistapi.AdPatternPlayList=function(pa,qa,ra,sa){xmp.validateArguments(arguments,[xmp.OBJECT_TYPE,xmp.OBJECT_TYPE,xmp.OBJECT_TYPE,xmp.OBJECT_TYPE],"AdPatternPlayList.ctor");if(!pa||!qa||!ra){throw new xmp.util.internals.InvalidArgsError("One or more constructor arguments is null.");}
this._LOOK_AHEAD_AND_BEHIND_MIN=7;this._LOOK_AHEAD_AND_BEHIND_MAX=100;this._MAX_NODE_POOL_SIZE=50;this._logger=new xmp.util.internals.CategoryLogger('AdPatternPlayList');this._lockedForModification=false;this._metadataMap=new xmp.util.internals.MetadataMap(true);this._listener=pa;this._adPatternRootNodeType=null;this._invariantRuleContextArray=null;this._ruleIdToFactoryMap={};this._ruleIdToRuleMap={};this._ruleSetRunContext=new xmp.playlistapi.RuleSetRunContext();this._lookAheadAndBehindCount=this._calculateLookAheadAndBehind();this._internalPlayListArray=[];this._historicalPlayListArray=[];this._lastNode=null;this._outStandingPlayableNodeArray=[];this._poolPlayableNodeArray=[];this._iteratator=new xmp.playlistapi.PlayListIterator(this);this._parameterMap=null;xmp.util.PlayableNode._staticInit();this._parameterMap=xmp.playlistapi.internals.ParameterMap.calcInitial(qa,sa);var ta=new xmp.playlistapi.internals.AdPatternBuilder(this._parameterMap);this._metadataMap._reInitialize(ta._extractOptionalMetaData(qa));this._adPatternRootNodeType=ta._build(qa);this._invariantRuleContextArray=ta._buildRuleContextArray(ra,null);this._logger.info('Constructed AdPatternPlayList');};xmp.playlistapi.AdPatternPlayList.prototype.getMetadata=function(ua,va){return this._metadataMap._get(ua,va);};xmp.playlistapi.AdPatternPlayList.prototype.setContentMetaResourceIds=function(wa){try{for(var i=0;i<wa.length;i++){if(typeof wa[i]!=='string'){throw new xmp.util.internals.InvalidArgsError("Argument 'contentMetaResourceIdArray' must be an array of strings.");}}
this._checkLockedForModification();this._lockForModification();var xa=new xmp.playlistapi.internals.PlayListBuilder(this,this._lastNode,this._adPatternRootNodeType,wa,this._listener);this._internalPlayListArray=xa._getOutput();}
finally{this._unlockForModification();}};xmp.playlistapi.AdPatternPlayList.prototype._getHistoricalDataIterator=function(){var ya=[];ya=ya.concat(this._historicalPlayListArray);ya=ya.concat(this._internalPlayListArray);return(new xmp.playlistapi.internals.SimplePlayListIterator(ya));};xmp.playlistapi.AdPatternPlayList.prototype.getIterator=function(){return this._iteratator;};xmp.playlistapi.AdPatternPlayList.prototype.getRuleIdArray=function(){var za=[];var Aa={};for(var i=0;i<this._invariantRuleContextArray.length;i++){var Ba=this._invariantRuleContextArray[i].getId();if(!Aa[Ba]){Aa[Ba]=Ba;za.push(Ba);}}
this._getPatternRuleIdsHelper(this._adPatternRootNodeType,za,Aa);return za;};xmp.playlistapi.AdPatternPlayList.prototype.loadRuleFactoryArray=function(Ca){xmp.validateArguments(arguments,[xmp.OBJECT_TYPE],"AdPatternPlayList.loadRuleFactoryArray");if(!Ca){throw new xmp.util.internals.InvalidArgsError("Argument 'ruleFactoryArray' cannot be null.");}
this._buildRuleIdToFactoryMap(Ca);if(this._logger.isDebugEnabled()){this._logger.debug('Loaded rule factories.');}};xmp.playlistapi.AdPatternPlayList.prototype.getLookAheadNodeArray=function(){return this._buildLookAheadArray();};xmp.playlistapi.AdPatternPlayList.prototype.getLookBehindNodeArray=function(){return this._buildLookBehindArray();};xmp.playlistapi.AdPatternPlayList.prototype._getParameterMapInternal=function(){return this._parameterMap;};xmp.playlistapi.AdPatternPlayList.prototype._findRule=function(Da){var Ea=this._ruleIdToRuleMap[Da];if(typeof Ea==="undefined"){var Fa=this._getFactory(Da);try{Ea=Fa.createRule(Da);}
catch(e){throw this._createExtensionGuardException(e,'RuleFactory.createRule');}
this._ruleIdToRuleMap[Da]=Ea;}
return Ea;};xmp.playlistapi.AdPatternPlayList.prototype._buildRuleIdToFactoryMap=function(Ga){for(var i=0;i<Ga.length;i++){var Ha=Ga[i];var Ia=null;try{Ia=Ha.getCreatableRuleIds();}
catch(e){throw this._createExtensionGuardException(e,'RuleFactory.getCreatableRuleIds');}
for(var j=0;j<Ia.length;j++){var Ja=Ia[j];if(!Ja||Ja.length===0){throw new xmp.playlistapi.internals.PlayListError("RuleFactory retured a rule ID that is null, undefined, or empty.");}
if(typeof this._ruleIdToFactoryMap[Ja]!=="undefined"){throw new xmp.playlistapi.internals.PlayListError("Rule "+Ja+" found in more than one factory.");}
this._ruleIdToFactoryMap[Ja]=Ha;}}
this._verifyRuleFactories();};xmp.playlistapi.AdPatternPlayList.prototype.addRuleFactory=function(Ka,La){this._ruleIdToFactoryMap[Ka]=La;};xmp.playlistapi.AdPatternPlayList.prototype._createExtensionGuardException=function(e,Ma){var Na='Error occurred while invoking extension method: '+Ma;this._logger.warn(Na,e);Na+=', Error data: ';Na+=xmp.extractErrorMessage(e);return new xmp.playlistapi.internals.PlayListError(Na);};xmp.playlistapi.AdPatternPlayList.prototype._calculateLookAheadAndBehind=function(){var Oa=xmp.util.SettingsManager.getInstance().getContextNode();var Pa=Oa.getNodeForPath('BasePlayer');var Qa=Pa.getInt('look ahead and behind count',this._LOOK_AHEAD_AND_BEHIND_MIN);if(Qa<this._LOOK_AHEAD_AND_BEHIND_MIN){Qa=this._LOOK_AHEAD_AND_BEHIND_MIN;}
else if(Qa>this._LOOK_AHEAD_AND_BEHIND_MAX){Qa=this._LOOK_AHEAD_AND_BEHIND_MAX;}
return Qa;};xmp.playlistapi.AdPatternPlayList.prototype._verifyRuleFactories=function(){this._verifyInvariantRuleFactories();this._verifyPlayableNodeTypeRuleFactoriesHelper(this._adPatternRootNodeType);};xmp.playlistapi.AdPatternPlayList.prototype._verifyInvariantRuleFactories=function(){for(var i=0;i<this._invariantRuleContextArray.length;i++){var Ra=this._invariantRuleContextArray[i].getId();this._getFactory(Ra);}};xmp.playlistapi.AdPatternPlayList.prototype._verifyPlayableNodeTypeRuleFactoriesHelper=function(Sa){if(Sa._isCompositeType()){var Ta=Sa._getChildCount();for(var i=0;i<Ta;i++){this._verifyPlayableNodeTypeRuleFactoriesHelper(Sa._getChild(i));}}
else{var Ua=Sa._getRuleContextArray();for(var j=0;j<Ua.length;j++){var Va=Ua[j].getId();this._getFactory(Va);}}};xmp.playlistapi.AdPatternPlayList.prototype._getFactory=function(Wa){var Xa=this._ruleIdToFactoryMap[Wa];if(!Xa){throw new xmp.playlistapi.internals.PlayListError("No factory defined for rule: "+Wa);}
return Xa;};xmp.playlistapi.AdPatternPlayList.prototype._getNextRuleFilteredPlayableNode=function(){var Ya=null;while(this._internalPlayListArray.length>0){var Za=this._internalPlayListArray.shift();this._historicalPlayListArray.push(Za);if(this._safeRunRulesForNode(Za)){this._addToOutstandingArray(Za);Ya=Za;break;}
else{this._returnNodeToPool(Za);}}
if(Ya!==null){this._lastNode=Ya;}
return Ya;};xmp.playlistapi.AdPatternPlayList.prototype._safeRunRulesForNode=function($a){try{return this._runRulesForNode($a);}
catch(e){var ab='Error occured running rules for node: '+xmp.util.PlayableNode.safeGetBestId($a);ab+='\nNode will be treated AS IF A RULE FAILED, skipped.';this._logger.warn(ab,e);return false;}};xmp.playlistapi.AdPatternPlayList.prototype._runRulesForNode=function(bb){if(bb._isEmptySlot()){if(this._logger.isDebugEnabled()){this._logger.debug('Node: '+bb.getBestId()+' IS AN EMPTY SLOT, FAILURE.');}
return false;}
var cb=this._buildRuleContextsForNode(bb);if(cb.length===0){if(this._logger.isDebugEnabled()){this._logger.debug('Node: '+bb.getBestId()+' HAS NO RULES, SUCCESS.');}
return true;}
this._ruleSetRunContext._initialize(bb);for(var i=0;i<cb.length;i++){var db=cb[i];this._ruleSetRunContext._setCurrentRuleContext(db);var eb=this._findRule(db.getId());var fb=false;try{fb=eb.isPlayable(this._ruleSetRunContext);}
catch(e){throw this._createExtensionGuardException(e,'Rule.isPlayable for rule: '+this._ruleSetRunContext.getCurrentRuleContext().getId());}
if(!fb){if(this._logger.isDebugEnabled()){this._logger.debug('Node: '+bb.getBestId()+', Rule ID: '+db.getId()+' FAILED.');}
return false;}
else{if(this._logger.isDebugEnabled()){this._logger.debug('Node: '+bb.getBestId()+', Rule ID: '+db.getId()+' SUCCEEDED.');}}}
if(this._logger.isDebugEnabled()){this._logger.debug('Node: '+bb.getBestId()+' ALL RULES SUCCEEDED.');}
return true;};xmp.playlistapi.AdPatternPlayList.prototype._buildLookAheadArray=function(){var gb=[];for(var i=0;i<this._lookAheadAndBehindCount;i++){if(i>=(this._internalPlayListArray.length)){break;}
gb.push(this._internalPlayListArray[i]);}
return gb;};xmp.playlistapi.AdPatternPlayList.prototype._buildLookBehindArray=function(){var hb=[];hb=hb.concat(this._outStandingPlayableNodeArray).reverse();return hb;};xmp.playlistapi.AdPatternPlayList.prototype._buildRuleContextsForNode=function(ib){var jb=this._getApplicableInvariantRuleContexts(ib.getNodeTypeName());jb=jb.concat(ib._getRuleArrayReference());return jb;};xmp.playlistapi.AdPatternPlayList.prototype._getApplicableInvariantRuleContexts=function(kb){var lb=[];for(var i=0;i<this._invariantRuleContextArray.length;i++){var mb=this._invariantRuleContextArray[i];if(mb.isApplicable(kb)){lb.push(mb);}}
return lb;};xmp.playlistapi.AdPatternPlayList.prototype._addToOutstandingArray=function(nb){this._outStandingPlayableNodeArray.push(nb);while(this._outStandingPlayableNodeArray.length>this._lookAheadAndBehindCount){this._returnNodeToPool(this._outStandingPlayableNodeArray.shift());}};xmp.playlistapi.AdPatternPlayList.prototype._getNodeFromPool=function(){var ob=new xmp.util.PlayableNode();ob._init();return ob;};xmp.playlistapi.AdPatternPlayList.prototype._returnNodeToPool=function(pb){this._poolPlayableNodeArray.push(pb);while(this._poolPlayableNodeArray.length>this._MAX_NODE_POOL_SIZE){var qb=this._poolPlayableNodeArray.shift();if(qb){qb._clear();}}};xmp.playlistapi.AdPatternPlayList.prototype._createNode=function(){return this._getNodeFromPool();};xmp.playlistapi.AdPatternPlayList.prototype._initializeNode=function(rb){try{this._listener.handleInitializePlayableNode(rb);}
catch(e){throw this._createExtensionGuardException(e,'PlayListListener.handleInitializePlayableNode');}};xmp.playlistapi.AdPatternPlayList.prototype._lockForModification=function(){this._lockedForModification=true;};xmp.playlistapi.AdPatternPlayList.prototype._unlockForModification=function(){this._lockedForModification=false;};xmp.playlistapi.AdPatternPlayList.prototype._checkLockedForModification=function(){if(this._lockedForModification){throw new xmp.playlistapi.internals.PlayListError("Cannot modify playlist while it is locked.");}};xmp.playlistapi.AdPatternPlayList.prototype._getPatternRuleIdsHelper=function(sb,tb,ub){if(sb._isCompositeType()){var vb=sb._getChildCount();for(var i=0;i<vb;i++){var wb=sb._getChild(i);this._getPatternRuleIdsHelper(wb,tb,ub);}}
else{var xb=sb._getRuleContextArray();for(var j=0;j<xb.length;j++){var yb=xb[j].getId();if(!ub[yb]){ub[yb]=yb;tb.push(yb);}}}};xmp.createNamespace("xmp.playlistapi");xmp.playlistapi.AdResourceOverrideContext=function(zb,Ab){this._node=zb;this._parameterMap=Ab;};xmp.playlistapi.AdResourceOverrideContext.prototype.getNode=function(){return this._node;};xmp.playlistapi.AdResourceOverrideContext.prototype.addResource=function(Bb){this._node.setMetaResource(Bb);};xmp.playlistapi.AdResourceOverrideContext.prototype.getResource=function(Cb){return this._node.getMetaResource(Cb);};xmp.playlistapi.AdResourceOverrideContext.prototype.copyMetaResourceBundleRefFrom=function(Db){this._node.reSetMetaResourceBundle(Db.getMetaResourceBundle());};xmp.playlistapi.AdResourceOverrideContext.prototype.copyMetaResourceBundleRefTo=function(Eb){Eb.reSetMetaResourceBundle(this._node.getMetaResourceBundle());};xmp.playlistapi.AdResourceOverrideContext.prototype.expandString=function(Fb){return this._parameterMap.expandString(Fb);};xmp.playlistapi.AdResourceOverrideContext.prototype.getNodeAssociatedResourceBundleType=function(){return this._node.getAssociatedResourceBundleType();};xmp.playlistapi.AdResourceOverrideContext.prototype.setNodeAssociatedResourceBundleType=function(Gb){this._node.setAssociatedResourceBundleType(Gb);};xmp.createNamespace("xmp.playlistapi");xmp.playlistapi.PlayListIterator=function(Hb){this._playList=Hb;this._currentNode=null;this._initialized=false;this._canAdvance=true;};xmp.playlistapi.PlayListIterator.prototype.first=function(){this._initialized=true;this._canAdvance=true;};xmp.playlistapi.PlayListIterator.prototype.next=function(){if(!this.hasNext()){throw new xmp.playlistapi.internals.PlayListError("Cannot call next if there are no more items to be returned, call 'hasNext' method to check.");}
this._canAdvance=true;return this._currentNode;};xmp.playlistapi.PlayListIterator.prototype.hasNext=function(){this._checkInitialized();if(this._canAdvance){this._currentNode=this._getNextCore();this._canAdvance=false;}
return(this._currentNode!==null);};xmp.playlistapi.PlayListIterator.prototype._getNextCore=function(){try{this._playList._checkLockedForModification();this._playList._lockForModification();return this._playList._getNextRuleFilteredPlayableNode();}
finally{this._playList._unlockForModification();}};xmp.playlistapi.PlayListIterator.prototype._checkInitialized=function(){if(!this._initialized){throw new xmp.playlistapi.internals.PlayListError("Iterator not initialized, call 'first' method.");}};xmp.createNamespace("xmp.playlistapi");xmp.playlistapi.PlayableNodeType=function(Ib,id,Jb){xmp.validateArguments(arguments,[xmp.OBJECT_TYPE,xmp.STRING_TYPE,xmp.STRING_TYPE],"PlayableNodeType.ctor");if(!xmp.isNonEmptyString(id)||!xmp.isNonEmptyString(Jb)){throw new xmp.util.internals.InvalidArgsError("PlayableNodeType requires non-empty 'id' and 'typeName'.");}
this._typeName=Jb;this._parent=null;this._id=id;this._directive=null;this._dataObject=Ib;};xmp.playlistapi.PlayableNodeType.getBaseNodeTypeName=function(Kb){if(!xmp.playlistapi.PlayableNodeType._typeMapNode){var Lb=xmp.util.SettingsManager.getInstance().getGlobalContextNode();xmp.playlistapi.PlayableNodeType._typeMapNode=Lb.getNodeForPath('nodeTypeMap');}
var Mb=xmp.playlistapi.PlayableNodeType._typeMapNode.getNodeForPath(Kb);var Nb=Mb.getString('baseType','DEFAULT');return Nb;};xmp.playlistapi.PlayableNodeType.prototype.getTypeName=function(){return this._typeName;};xmp.playlistapi.PlayableNodeType.prototype.getId=function(){return this._id;};xmp.playlistapi.PlayableNodeType.prototype.getDataObject=function(){return this._dataObject;};xmp.playlistapi.PlayableNodeType.prototype.getMetadata=function(Ob,Pb){return null;};xmp.playlistapi.PlayableNodeType.prototype._getChildCount=function(){return 0;};xmp.playlistapi.PlayableNodeType.prototype._getParent=function(){return this._parent;};xmp.playlistapi.PlayableNodeType.prototype._isCompositeType=function(){return false;};xmp.playlistapi.PlayableNodeType.prototype._isContentCompositeType=function(){return false;};xmp.playlistapi.PlayableNodeType.prototype.isContentType=function(){var Qb=xmp.playlistapi.PlayableNodeType.getBaseNodeTypeName(this.getTypeName());return Qb==='Content';};xmp.playlistapi.PlayableNodeType.prototype.isAdType=function(){var Rb=xmp.playlistapi.PlayableNodeType.getBaseNodeTypeName(this.getTypeName());return Rb==='Ad';};xmp.playlistapi.PlayableNodeType.prototype.isPromoType=function(){var Sb=xmp.playlistapi.PlayableNodeType.getBaseNodeTypeName(this.getTypeName());return Sb==='Promo';};xmp.playlistapi.PlayableNodeType.prototype._setParent=function(Tb){this._parent=Tb;};xmp.playlistapi.PlayableNodeType.prototype._handlePostBuild=function(){};xmp.playlistapi.PlayableNodeType.prototype._setDirective=function(Ub){this._directive=Ub;};xmp.playlistapi.PlayableNodeType.prototype._getDirective=function(){return this._directive;};xmp.createNamespace("xmp.playlistapi");xmp.playlistapi.ResouceBundle=function(){xmp.playlistapi.ResouceBundle.ctor.call(this);this._map={};};xmp.DERIVE_CLASS(xmp.util.Loadable,xmp.playlistapi.ResouceBundle);xmp.playlistapi.ResouceBundle.prototype.setMetaResource=function(Vb){if(this.getMetaResource(Vb.getType())!==null){throw new xmp.util.internals.InvalidArgsError('Node type already has a resource of type: '+Vb.getType());}
this._map[Vb.getType()]=Vb;};xmp.playlistapi.ResouceBundle.prototype.getMetaResource=function(Wb){var Xb=this._map[Wb];return(Xb)?Xb:null;};xmp.playlistapi.ResouceBundle.prototype.getResourceTypes=function(){return xmp.MapIterator.extractKeys(this._map);};xmp.playlistapi.ResouceBundle.prototype.getCount=function(){return(this.getResourceTypes().length);};xmp.playlistapi.ResouceBundle.prototype.clone=function(){var Yb=new xmp.playlistapi.ResouceBundle();for(var Zb=xmp.MapIterator.create(this._map);Zb.hasNext();Zb.next()){var $b=Zb.currentKey();var ac=this.getMetaResource($b);Yb.setMetaResource(ac._clone());}
return Yb;};xmp.playlistapi.ResouceBundle.prototype.getLoadableId=function(){return'ResouceBundle';};xmp.playlistapi.ResouceBundle.prototype.getErrorCount=function(){var bc=this.getResourceTypes();var cc=0;for(var i=0;i<bc.length;i++){var dc=bc[i];var ec=this.getMetaResource(dc);if(ec.isError()){cc++;}}
return cc;};xmp.createNamespace("xmp.playlistapi");xmp.playlistapi.Resource=function(id,fc,gc,hc){xmp.playlistapi.Resource.ctor.call(this);if(!gc){gc={};}
if(!hc){hc='default';}
xmp.validateArguments([id,fc,gc,hc],[xmp.STRING_TYPE,xmp.STRING_TYPE,xmp.OBJECT_TYPE,xmp.STRING_TYPE],"Resource.ctor");if(!(xmp.isNonEmptyString(id)&&xmp.isNonEmptyString(fc)&&xmp.isNonEmptyString(hc))){throw new xmp.util.internals.InvalidArgsError("Parameters 'id' and 'type' and 'dataType' must be non-empty strings.");}
this._id=id;this._type=fc;this._dataType=hc;this._metadataMap=new xmp.util.internals.MetadataMap(false);this._metadataMap._reInitialize(gc);this._companionAdId=-1;};xmp.DERIVE_CLASS(xmp.util.Loadable,xmp.playlistapi.Resource);xmp.playlistapi.Resource.prototype.getId=function(){return this._id;};xmp.playlistapi.Resource.prototype.setId=function(id){this._id=id;};xmp.playlistapi.Resource.prototype.getType=function(){return this._type;};xmp.playlistapi.Resource.prototype.getDataType=function(){return this._dataType;};xmp.playlistapi.Resource.prototype.setDataType=function(ic){this._dataType=ic;};xmp.playlistapi.Resource.prototype.getMetadata=function(jc,kc){return this._metadataMap._get(jc,kc);};xmp.playlistapi.Resource.prototype.setMetadata=function(lc,mc){this._metadataMap._set(lc,mc);};xmp.playlistapi.Resource.prototype.removeMetadata=function(nc){this._metadataMap._remove(nc);};xmp.playlistapi.Resource.prototype._clone=function(){return new xmp.playlistapi.Resource(this._id,this._type,this._metadataMap._getClonedWrappedMetadata(),this._dataType);};xmp.playlistapi.Resource.prototype.getLoadableId=function(){return this.getId();};xmp.playlistapi.Resource.prototype.getCompanionAdId=function(){return this._companionAdId;};xmp.playlistapi.Resource.prototype.setCompanionAdId=function(oc){this._companionAdId=oc;};xmp.createNamespace("xmp.playlistapi");xmp.playlistapi.RuleContext=function(id,pc,qc,rc){xmp.validateArguments(arguments,[xmp.STRING_TYPE,xmp.OBJECT_TYPE,xmp.OBJECT_TYPE,xmp.BOOLEAN_TYPE],"RuleContext.ctor");if(id===null||id.length===0){throw new xmp.util.internals.InvalidArgsError("RuleContext requires non-empty ID.");}
if(qc.length<1){throw new xmp.util.internals.InvalidArgsError("RuleContext at least one applicable type.");}
this._id=id;this._metadataMap=new xmp.util.internals.MetadataMap(rc);this._metadataMap._reInitialize(pc);this._applicableTypeArray=qc;};xmp.playlistapi.RuleContext.createDynamic=function(id,sc){return new xmp.playlistapi.RuleContext(id,sc,['dynamic'],true);};xmp.playlistapi.RuleContext.prototype.getId=function(){return this._id;};xmp.playlistapi.RuleContext.prototype.getMetadata=function(tc,uc){return this._metadataMap._get(tc,uc);};xmp.playlistapi.RuleContext.prototype.isApplicable=function(vc){if(vc.toLowerCase()==='all'){return true;}
for(var i=0;i<this._applicableTypeArray.length;i++){if(this._applicableTypeArray[i]===vc){return true;}}
return false;};xmp.createNamespace("xmp.playlistapi");xmp.playlistapi.RuleSetRunContext=function(){this._playableNode=null;this._currentRuleContext=null;};xmp.playlistapi.RuleSetRunContext.prototype.getPlayableNode=function(){return this._playableNode;};xmp.playlistapi.RuleSetRunContext.prototype.getCurrentRuleContext=function(){return this._currentRuleContext;};xmp.playlistapi.RuleSetRunContext.prototype._initialize=function(wc){this._playableNode=wc;this._currentRuleContext=null;};xmp.playlistapi.RuleSetRunContext.prototype._setCurrentRuleContext=function(xc){this._currentRuleContext=xc;};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.AdPatternBuilder=function(yc){xmp.validateArguments(arguments,[xmp.OBJECT_TYPE],"AdPatternBuilder.ctor");this._logger=new xmp.util.internals.CategoryLogger('AdPatternBuilder');this._COMPOSITE_TYPE_ARRAY=['Composite','ContentComposite'];this._patternMap=null;this._parameterMap=yc;};xmp.playlistapi.internals.AdPatternBuilder.prototype._build=function(zc){try{this._patternMap=zc.patternMap;if(!this._isComposite(zc.root)){throw new xmp.playlistapi.internals.PlayListError("Root of ad pattern must have type of one of the following: "+this._COMPOSITE_TYPE_ARRAY.join(', '));}
var Ac=this._buildHelper(zc.root,true);zc=null;return Ac;}
catch(e){e.stack=null;var Bc=new xmp.baseplayer.ApplicationError(e,'badAdPattern','AdPatternPlayList',[{label:'details',text:xmp.extractErrorMessage(e)}]);this._logger.warn(Bc.message,Bc);var Cc="Error building Ad Pattern with memento data";throw new xmp.playlistapi.internals.PlayListError(Cc);}};xmp.playlistapi.internals.AdPatternBuilder.prototype._isComposite=function(Dc){for(var i=0;i<this._COMPOSITE_TYPE_ARRAY.length;i++){if(Dc.type===this._COMPOSITE_TYPE_ARRAY[i]){return true;}}
return false;};xmp.playlistapi.internals.AdPatternBuilder.prototype._buildHelper=function(Ec,Fc){var Gc=null;if(this._isComposite(Ec)){var Hc=(typeof Ec.repeat==="number")?Ec.repeat:1;Gc=new xmp.playlistapi.internals[Ec.type+'PlayableNodeType'](Ec,(Fc?'/':this._calcId(Ec)),Ec.type,Ec.pattern,Hc);if(Gc._isDeferred()){Gc._setReadyToValidate(false);}
else{var Ic=this._patternMap[Gc._getPatternName()];this._buildChildren(Gc,Ic);}}
else{Gc=new xmp.playlistapi.internals.RuleSetPlayableNodeType(Ec,this._calcId(Ec),Ec.type,this._buildRuleContextArray(Ec.rules,Ec.type),this._extractOptionalMetaData(Ec));this._extractOptionalResources(Ec,Gc);this._extractOptionalDirective(Ec,Gc);}
Gc._handlePostBuild();return Gc;};xmp.playlistapi.internals.AdPatternBuilder.prototype._calcId=function(Jc){return(typeof(Jc.id)==='string')?Jc.id:Jc.type;};xmp.playlistapi.internals.AdPatternBuilder.prototype._extractOptionalDirective=function(Kc,Lc){var Mc=xmp.playlistapi.internals.PatternDirectiveFactory.create(Kc);Lc._setDirective(Mc);};xmp.playlistapi.internals.AdPatternBuilder.prototype._extractOptionalResources=function(Nc,Oc){if(typeof Nc.resources==='object'){for(var i=0;i<Nc.resources.length;i++){var Pc=Nc.resources[i];Oc.setMetaResource(this._buildMetaResource(Pc));}}};xmp.playlistapi.internals.AdPatternBuilder.prototype._buildChildren=function(Qc,Rc){for(var i=0;i<Rc.length;i++){var Sc=this._buildHelper(Rc[i],false);Qc._addChild(Sc);}};xmp.playlistapi.internals.AdPatternBuilder.prototype._buildDeferredContentComposite=function(Tc,Uc){this._buildChildren(Tc,Uc);Tc._setReadyToValidate(true);Tc._handlePostBuild();};xmp.playlistapi.internals.AdPatternBuilder.prototype._buildRuleContextArray=function(Vc,Wc){var Xc=[];if(typeof Vc==="object"){for(var i=0;i<Vc.length;i++){Xc.push(this._buildRuleContext(Vc[i],Wc));}}
return Xc;};xmp.playlistapi.internals.AdPatternBuilder.prototype._buildMetaResource=function(Yc){return new xmp.playlistapi.Resource(this._parameterMap.expandStringAndFixSlashes(Yc.id),Yc.type,this._extractOptionalMetaData(Yc),'default');};xmp.playlistapi.internals.AdPatternBuilder.prototype._buildRuleContext=function(Zc,$c){var ad=[];if($c!==null){ad.push($c);}
else{if(typeof Zc.nodeTypes==="object"){ad=ad.concat(Zc.nodeTypes);}}
return new xmp.playlistapi.RuleContext(this._parameterMap.expandString(Zc.id),this._extractOptionalMetaData(Zc),ad,true);};xmp.playlistapi.internals.AdPatternBuilder.prototype._extractOptionalMetaData=function(bd){var cd={};if(typeof bd.meta==="object"){for(var dd=xmp.MapIterator.create(bd.meta);dd.hasNext();dd.next()){var ed=dd.currentKey();var fd=this._parameterMap.expandString(dd.currentValue());cd[ed]=fd;}}
return cd;};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.CompositePlayableNodeType=function(gd,id,hd,jd,kd){xmp.validateArguments(arguments,[xmp.OBJECT_TYPE,xmp.STRING_TYPE,xmp.STRING_TYPE,xmp.STRING_TYPE,xmp.NUMBER_TYPE],"CompositePlayableNodeType.ctor");if(jd===null||jd.length===0){throw new xmp.util.internals.InvalidArgsError("CompositePlayableNodeType requires non-empty patternName.");}
if(kd<1){throw new xmp.util.internals.InvalidArgsError("CompositePlayableNodeType must have a repeat count of 1 or greater.");}
this._patternName=jd;this._repeatCount=kd;this._children=[];xmp.playlistapi.internals.CompositePlayableNodeType.ctor.call(this,gd,id,hd);};xmp.DERIVE_CLASS(xmp.playlistapi.PlayableNodeType,xmp.playlistapi.internals.CompositePlayableNodeType);xmp.playlistapi.internals.CompositePlayableNodeType.prototype._getRepeatCount=function(){return this._repeatCount;};xmp.playlistapi.internals.CompositePlayableNodeType.prototype._isDeferred=function(){return(this._patternName.toLowerCase()==='deferred');};xmp.playlistapi.internals.CompositePlayableNodeType.prototype._getPatternName=function(){return this._patternName;};xmp.playlistapi.internals.CompositePlayableNodeType.prototype._getChildCount=function(){return this._children.length;};xmp.playlistapi.internals.CompositePlayableNodeType.prototype._getChild=function(ld){xmp.validateArguments(arguments,[xmp.NUMBER_TYPE],"CompositePlayableNodeType._getChild");return this._children[ld];};xmp.playlistapi.internals.CompositePlayableNodeType.prototype._addChild=function(md){var nd=this._children.push(md);md._setParent(this);return nd;};xmp.playlistapi.internals.CompositePlayableNodeType.prototype._isCompositeType=function(){return true;};xmp.playlistapi.internals.CompositePlayableNodeType.prototype._removeAllChildren=function(){this._children=[];};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.ContentCompositePlayableNodeType=function(od,id,pd,qd,rd){xmp.playlistapi.internals.ContentCompositePlayableNodeType.ctor.call(this,od,id,pd,qd,rd);this._readyToValidate=true;};xmp.DERIVE_CLASS(xmp.playlistapi.internals.CompositePlayableNodeType,xmp.playlistapi.internals.ContentCompositePlayableNodeType);xmp.playlistapi.internals.ContentCompositePlayableNodeType.prototype._setReadyToValidate=function(sd){this._readyToValidate=sd;};xmp.playlistapi.internals.ContentCompositePlayableNodeType.prototype._handlePostBuild=function(){if(!this._readyToValidate){return;}
function throwContentChildException(){throw new xmp.playlistapi.internals.PlayListError("ContentCompositePlayableNodeType must have one and only one node of type 'Content' (can have other leaf node types as well); cannot contain composite node types.");}
var td=-1;var ud=this._getChildCount();for(var i=0;i<ud;i++){var vd=this._getChild(i);if(vd._isCompositeType()){throwContentChildException();}
if(vd.isContentType()){if(td===-1){td=i;}
else{throwContentChildException();}}}
if(td===-1){throwContentChildException();}};xmp.playlistapi.internals.ContentCompositePlayableNodeType.prototype._isContentCompositeType=function(){return true;};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.DefaultAdDataPatternDirective=function(wd,xd,yd){xmp.playlistapi.internals.DefaultAdDataPatternDirective.ctor.call(this,wd,xd,yd);};xmp.DERIVE_CLASS(xmp.playlistapi.internals.PatternDirective,xmp.playlistapi.internals.DefaultAdDataPatternDirective);xmp.playlistapi.internals.DefaultAdDataPatternDirective.prototype.doDirective=function(zd,Ad){var Bd=this.getMetadata('refId','');var Cd=this.getMetadata('defaultDataId','');if(Bd.length===0||Cd.length===0){throw new xmp.playlistapi.internals.PlayListError("Directive '"+this.getType()+"' requires metadata 'refId' and 'defaultDataId'.");}
var Dd=this._findNamedContentNode(zd,Ad,Bd);var Ed=Dd.getPlayableData().getDataObject().adDataMap;if(typeof Ed!=='object'){throw new xmp.playlistapi.internals.PlayListError("Did not find 'adDataMap' for content node: "+Dd.getBestId());}
var Fd=Ed[Cd];if(typeof Fd!=='object'){throw new xmp.playlistapi.internals.PlayListError("Did not find '"+Cd+"' in 'adDataMap' for content node: "+Dd.getBestId());}
var Gd=zd._getParameterMapInternal().clone();Gd.setOverrides(this.getParameterArray());Gd.addContextObject('video',Dd.getPlayableData().getDataObject());Gd.addContextObject('node',Ad.getNodeType().getDataObject());var Hd=new xmp.playlistapi.internals.AdPatternBuilder(Gd);if(typeof Fd.resources==='object'){for(var i=0;i<Fd.resources.length;i++){var Id=Fd.resources[i];Ad.setMetaResource(Hd._buildMetaResource(Id));}}
var Jd=Hd._extractOptionalMetaData(Fd);for(var Kd=xmp.MapIterator.create(Jd);Kd.hasNext();Kd.next()){var Ld=Kd.currentKey();var Md=Kd.currentValue();Ad.setMetadata(Ld,Md);}
Ad.setMetadata('__DIRECTIVE_PARAMETER_MAP__',Gd);};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.NullPatternDirective=function(){};xmp.playlistapi.internals.NullPatternDirective._flyWeight=new xmp.playlistapi.internals.NullPatternDirective();xmp.playlistapi.internals.NullPatternDirective.getNull=function(){return xmp.playlistapi.internals.NullPatternDirective._flyWeight;};xmp.playlistapi.internals.NullPatternDirective.prototype.getType=function(){return'Null';};xmp.playlistapi.internals.NullPatternDirective.prototype.doDirective=function(Nd,Od){};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.ParameterMap=function(){this._logger=new xmp.util.internals.CategoryLogger('ParameterMap');this._map={};this._contextObjectMap={};};xmp.playlistapi.internals.ParameterMap.calcInitial=function(Pd,Qd){xmp.validateArguments(arguments,[xmp.OBJECT_TYPE,xmp.OBJECT_TYPE],"ParameterMap.calcInitial");var Rd=new xmp.playlistapi.internals.ParameterMap();Rd.init(Pd);Rd.setOverrides(Qd);return Rd;};xmp.playlistapi.internals.ParameterMap.prototype.clone=function(){var Sd=new xmp.playlistapi.internals.ParameterMap();Sd._cloneInternal(this._map);return Sd;};xmp.playlistapi.internals.ParameterMap.prototype.init=function(Td){this._map=this._mapParameters((typeof Td.parameters==='object')?Td.parameters:[]);};xmp.playlistapi.internals.ParameterMap.prototype.setOverrides=function(Ud){this._validateParameters(Ud);for(var i=0;i<Ud.length;i++){var p=Ud[i];if(typeof this._map[p.name]==='undefined'){this._logger.warn('Pattern input parameter dropped, no default value in pattern: '+p.name);continue;}
this._map[p.name]=p.value;}};xmp.playlistapi.internals.ParameterMap.prototype.expandStringAndFixSlashes=function(Vd){var Wd='://';var Xd=this.expandString(Vd);var Yd='';var Zd=Xd;if(Xd.indexOf(Wd)>-1){var $d=Xd.split(Wd);Yd=$d[0]+Wd;Zd=$d[1];}
while(Zd.indexOf('//')>-1){Zd=Zd.replace(/\/\//g,'/');}
return Yd+Zd;};xmp.playlistapi.internals.ParameterMap.prototype.expandString=function(ae){if(typeof ae!=='string'){return ae;}
if(ae.indexOf('${')!==-1){var be=false;if(ae.indexOf('$${')!==-1){ae=ae.replace(/\$\$\{/g,'__PROTECT_DOLLAR_ESCAPE__');be=true;}
ae=ae.replace(/\$\{player./g,'${');for(var ce=xmp.MapIterator.create(this._map);ce.hasNext();ce.next()){var de=ce.currentKey();var ee=ce.currentValue();var fe='${'+de+'}';if(ae.indexOf(fe)!==-1){var ge=ae.split(fe);ae=ge.join(ee);}}
ae=this._makeContextObjectSubs(ae);if(be){ae=ae.replace(/__PROTECT_DOLLAR_ESCAPE__/g,'${');}}
return ae;};xmp.playlistapi.internals.ParameterMap.prototype._makeContextObjectSubs=function(he){var ie=0;var je=true;while(je){var ke=he.indexOf('${',ie);if(ke===-1){je=false;break;}
var le=he.indexOf('}',ke+1);if(le===-1){je=false;break;}
ie=le+1;var me=he.substr(0,ke);var ne=he.substr(le+1);var oe=he.substr(ke+2,le-ke-2);var pe=oe.indexOf('.');if(pe===-1){continue;}
var qe=oe.substr(0,pe);var re=oe.substr(pe+1);var se=this._contextObjectMap[qe];if(!se){continue;}
var te=null;try{te=xmp.util.JsonPath.evaluate(se,re);}
catch(e){te=null;this._logger.warn('Error evaluating JSON Path: '+re,e);}
if(te!==null){var ue=he.length;he=me+te+ne;ie+=(he.length-ue);}}
return he;};xmp.playlistapi.internals.ParameterMap.prototype.addContextObject=function(ve,we){this._contextObjectMap[ve]=we;};xmp.playlistapi.internals.ParameterMap.prototype._validateParameters=function(xe){for(var i=0;i<xe.length;i++){var p=xe[i];if(!((typeof p.name==='string')&&(p.name.length>0)&&(typeof p.value==='string'))){throw new xmp.playlistapi.internals.PlayListError("Parameters must have string 'name and 'value' properties.");}}};xmp.playlistapi.internals.ParameterMap.prototype._mapParameters=function(ye){this._validateParameters(ye);var ze={};for(var i=0;i<ye.length;i++){var p=ye[i];ze[p.name]=p.value;}
return ze;};xmp.playlistapi.internals.ParameterMap.prototype._cloneInternal=function(Ae){for(var Be=xmp.MapIterator.create(Ae);Be.hasNext();Be.next()){var Ce=Be.currentKey();var De=Be.currentValue();this._map[Ce]=De;}};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.PatternDirectiveFactory=function(){};xmp.playlistapi.internals.PatternDirectiveFactory._ctors=null;xmp.playlistapi.internals.PatternDirectiveFactory.create=function(Ee){if(xmp.playlistapi.internals.PatternDirectiveFactory._ctors===null){xmp.playlistapi.internals.PatternDirectiveFactory._ctors={};var Fe=xmp.playlistapi.internals.PatternDirectiveFactory._ctors;Fe.defaultAdData=xmp.playlistapi.internals.DefaultAdDataPatternDirective;}
if(typeof Ee.patternDirective==='object'){var Ge=xmp.playlistapi.internals.PatternDirectiveFactory._ctors[Ee.patternDirective.type];if(Ge){var He=Ee.patternDirective.parameters;He=(!He)?[]:He;var Ie=Ee.patternDirective.meta;Ie=(!Ie)?{}:Ie;return new Ge(Ee.patternDirective.type,Ie,He);}
else{throw new xmp.util.internals.InvalidArgsError('Unknown directive type: '+Ee.patternDirective.type);}}
else{return xmp.playlistapi.internals.NullPatternDirective.getNull();}};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.PlayListAddress=function(){this._array=[];};xmp.playlistapi.internals.PlayListAddress.prototype.getLength=function(){return this._array.length;};xmp.playlistapi.internals.PlayListAddress.prototype.clone=function(){var Je=new xmp.playlistapi.internals.PlayListAddress();Je._cloneInternal(this._array);return Je;};xmp.playlistapi.internals.PlayListAddress.prototype._cloneInternal=function(Ke){this._array=this._array.concat(Ke);};xmp.playlistapi.internals.PlayListAddress.prototype.getAtIndex=function(Le){return this._array[Le];};xmp.playlistapi.internals.PlayListAddress.prototype.shift=function(){return this._array.shift();};xmp.playlistapi.internals.PlayListAddress.prototype.push=function(Me){return this._array.push(Me);};xmp.playlistapi.internals.PlayListAddress.prototype.pop=function(){return this._array.pop();};xmp.playlistapi.internals.PlayListAddress.prototype.getParent=function(){var Ne=this.clone();Ne.pop();return Ne;};xmp.playlistapi.internals.PlayListAddress.prototype.isSibling=function(Oe,Pe){var Qe=this.getLength();if(Qe!==Oe.getLength()){return false;}
for(var i=0;i<Qe;i++){var Re=this.getAtIndex(i);var Se=Oe.getAtIndex(i);if(i<(Qe-1)){if(!Re.isEqual(Se)){return false;}}
else{if(Pe){if(Re.getRepeatIndex()!==Se.getRepeatIndex()){return false;}}}}
return true;};xmp.playlistapi.internals.PlayListAddress.prototype.asString=function(){var s='';var Te=this.getLength();for(var i=0;i<Te;i++){var Ue=this.getAtIndex(i);s+=Ue.asString();if(i!==(Te-1)){s+=',';}}
return s;};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.PlayListAddressPart=function(Ve,We){this._repeatIndex=Ve;this._childIndex=We;};xmp.playlistapi.internals.PlayListAddressPart.prototype.getRepeatIndex=function(){return this._repeatIndex;};xmp.playlistapi.internals.PlayListAddressPart.prototype.getChildIndex=function(){return this._childIndex;};xmp.playlistapi.internals.PlayListAddressPart.prototype.isEqual=function(Xe){return(Xe.getRepeatIndex()===this.getRepeatIndex()&&Xe.getChildIndex()===this.getChildIndex());};xmp.playlistapi.internals.PlayListAddressPart.prototype.asString=function(){return('['+this._repeatIndex+','+this._childIndex+']');};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.PlayListBuilder=function(Ye,Ze,$e,af,bf){try{this._STATE_TRAVERSE_TO_ADDRESS=0;this._STATE_TRAVERSE_TO_NEXT=1;this._STATE_BUILD=2;this._logger=new xmp.util.internals.CategoryLogger('PlayListBuilder');this._playList=Ye;this._playableDataProvider=bf;this._contentMetaResourceIdArray=[];this._playListDataArray=[];this._traverseToPatternAddress=new xmp.playlistapi.internals.PlayListAddress();this._build_state=this._STATE_TRAVERSE_TO_ADDRESS;this._assignPatternAddress=new xmp.playlistapi.internals.PlayListAddress();this._contentCompositeIdToContentNodeMap={};this._parentIdCounter=0;this._contentMetaResourceIdArray=this._contentMetaResourceIdArray.concat(af);if(Ze!==null){this._traverseToPatternAddress=Ze._getPatternAddress().clone();}
if(this._traverseToPatternAddress.getLength()===0){this._build_state=this._STATE_BUILD;}
this._buildHelper($e,0);this._initializeNodes();}
catch(e){var cf="Error building playlist with meta resource IDs";this._logger.warn(cf,e);cf+=", error = ";cf+=xmp.extractErrorMessage(e);throw new xmp.playlistapi.internals.PlayListError(cf);}};xmp.playlistapi.internals.PlayListBuilder.prototype._getOutput=function(){var df=[];for(var i=0;i<this._playListDataArray.length;i++){var ef=this._playListDataArray[i];var ff=ef[0];df.push(ff);}
if(this._logger.isDebugEnabled()){var gf='Node output: ';for(var j=0;j<df.length;j++){gf+=('('+j.toString()+') ');gf+=df[j].getBestId();gf+=('('+df[j]._getPatternAddress().asString()+')');if(j!==(df.length-1)){gf+=', ';}}
this._logger.debug(gf);}
return df;};xmp.playlistapi.internals.PlayListBuilder.prototype._buildHelper=function(hf,jf){if(hf._isCompositeType()){var kf=0;var lf=0;if(this._build_state===this._STATE_TRAVERSE_TO_ADDRESS){var mf=this._traverseToPatternAddress.shift();kf=mf.getRepeatIndex();lf=mf.getChildIndex();if(this._traverseToPatternAddress.getLength()===0){this._build_state=this._STATE_TRAVERSE_TO_NEXT;}}
if(this._build_state!==this._STATE_TRAVERSE_TO_ADDRESS&&hf._isDeferred()){hf=this._buildDeferredContentComposite(hf);}
var nf=hf._getRepeatCount();var of=hf._getChildCount();for(var pf=kf;pf<nf;pf++){if(this._contentMetaResourceIdArray.length===0){break;}
this._parentIdCounter++;if(this._build_state===this._STATE_BUILD){lf=0;}
for(var qf=lf;qf<of;qf++){var rf=hf._getChild(qf);this._assignPatternAddress.push(new xmp.playlistapi.internals.PlayListAddressPart(pf,qf));this._buildHelper(rf,this._parentIdCounter);this._assignPatternAddress.pop();}}}
else{if(this._build_state===this._STATE_BUILD){this._buildLeaf(hf,jf);}
else if(this._build_state===this._STATE_TRAVERSE_TO_NEXT){this._build_state=this._STATE_BUILD;}}};xmp.playlistapi.internals.PlayListBuilder.prototype._buildLeaf=function(sf,tf){var uf=this._playList._createNode();if(sf.isContentType()){if(this._contentMetaResourceIdArray.length===0){uf._mutateEmptySlot(true);uf._setData(new xmp.util.PlayableData('EMPTY_SLOT'));}
else{var vf=this._contentMetaResourceIdArray.shift();uf._linkData(this._playableDataProvider,vf);}}
uf._setNodeType(sf);uf._setPatternAddress(this._assignPatternAddress.clone());if(uf.isContentType()&&uf.getNodeType()._getParent()._isContentCompositeType()){uf.getPlayableData()._setCompositeMetaResourceId(uf.getPlayableData().getMetaResourceId());this._contentCompositeIdToContentNodeMap[tf.toString()]=uf;}
this._playListDataArray.push([uf,tf]);};xmp.playlistapi.internals.PlayListBuilder.prototype._initializeNodes=function(){for(var i=0;i<this._playListDataArray.length;i++){var wf=this._playListDataArray[i];var xf=wf[0];var yf=wf[1];try{xf.getNodeType()._getDirective().doDirective(this,xf);}
catch(e){var zf=new xmp.baseplayer.ApplicationError(e,'badAdPattern',null,[{label:'cause',text:e.message}]);this._logger.warn(zf.message,zf);}
if(xf.getPlayableData()===null){var Af=xf.getMetaResource('primary');xf._setData(new xmp.util.PlayableData((Af)?Af.getId():''));}
if(!xf.isContentType()&&xf.getNodeType()._getParent()._isContentCompositeType()){this._fixContentCompositeSibling(xf,yf);}
if(!xf._isEmptySlot()&&!xf.getPlayableData().isError()){this._playList._initializeNode(xf);}}};xmp.playlistapi.internals.PlayListBuilder.prototype._fixContentCompositeSibling=function(Bf,Cf){var Df=this._contentCompositeIdToContentNodeMap[Cf.toString()];if(Df._isEmptySlot()){Bf._mutateEmptySlot(true);}
Bf.getPlayableData()._setCompositeMetaResourceId(Df.getPlayableData().getCompositeMetaResourceId());};xmp.playlistapi.internals.PlayListBuilder.prototype._buildDeferredContentComposite=function(Ef){Ef._removeAllChildren();if(this._contentMetaResourceIdArray.length>0){var Ff=this._contentMetaResourceIdArray[0];var Gf=this._playableDataProvider._getPlayableData(Ff);var Hf=null;if(Gf.isError()){Hf=[{type:'Content'}];}
else{Hf=Gf.getDataObject().pattern;}
var If=new xmp.playlistapi.internals.AdPatternBuilder(this._playList._getParameterMapInternal());If._buildDeferredContentComposite(Ef,Hf);}
return Ef;};xmp.playlistapi.internals.PlayListBuilder.prototype._getParameterMapInternal=function(){return this._playList._getParameterMapInternal();};xmp.playlistapi.internals.PlayListBuilder.prototype._getPlayListDataArrayLength=function(){return this._playListDataArray.length;};xmp.playlistapi.internals.PlayListBuilder.prototype._getPlayListDataArrayItemAtIndex=function(Jf){var Kf=this._playListDataArray[Jf];return Kf[0];};xmp.playlistapi.internals.PlayListBuilder.prototype._getDataIterator=function(){return(new xmp.playlistapi.internals.PlayListBuilder.Iterator(this));};xmp.playlistapi.internals.PlayListBuilder.prototype._getHistoricalDataIterator=function(){return this._playList._getHistoricalDataIterator();};xmp.playlistapi.internals.PlayListBuilder.Iterator=function(Lf){this._playListBuilder=Lf;};xmp.playlistapi.internals.PlayListBuilder.Iterator.prototype.getLength=function(){return this._playListBuilder._getPlayListDataArrayLength();};xmp.playlistapi.internals.PlayListBuilder.Iterator.prototype.first=function(){this._curIndex=0;};xmp.playlistapi.internals.PlayListBuilder.Iterator.prototype.next=function(){var Mf=this._playListBuilder._getPlayListDataArrayItemAtIndex(this._curIndex);this._curIndex++;return Mf;};xmp.playlistapi.internals.PlayListBuilder.Iterator.prototype.hasNext=function(){return(this._curIndex<this.getLength());};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.PlayListError=function(Nf){this.name="xmp.playlistapi.internals.PlayListError";this.message=Nf;};xmp.DERIVE_CLASS(Error,xmp.playlistapi.internals.PlayListError);xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.RuleSetPlayableNodeType=function(Of,id,Pf,Qf,Rf){xmp.validateArguments(arguments,[xmp.OBJECT_TYPE,xmp.STRING_TYPE,xmp.STRING_TYPE,xmp.OBJECT_TYPE,xmp.OBJECT_TYPE],"RuleSetPlayableNodeType.ctor");this._metadataMap=new xmp.util.internals.MetadataMap(true);this._metadataMap._reInitialize(Rf);this._ruleContextArray=Qf;this._metaResourceBundle=new xmp.playlistapi.ResouceBundle();xmp.playlistapi.internals.RuleSetPlayableNodeType.ctor.call(this,Of,id,Pf);};xmp.DERIVE_CLASS(xmp.playlistapi.PlayableNodeType,xmp.playlistapi.internals.RuleSetPlayableNodeType);xmp.playlistapi.internals.RuleSetPlayableNodeType.prototype.setMetaResource=function(Sf){this._metaResourceBundle.setMetaResource(Sf);};xmp.playlistapi.internals.RuleSetPlayableNodeType.prototype.getMetaResource=function(Tf){return this._metaResourceBundle.getMetaResource(Tf);};xmp.playlistapi.internals.RuleSetPlayableNodeType.prototype.getMetaResourceBundle=function(){return this._metaResourceBundle;};xmp.playlistapi.internals.RuleSetPlayableNodeType.prototype.getMetadata=function(Uf,Vf){return this._metadataMap._get(Uf,Vf);};xmp.playlistapi.internals.RuleSetPlayableNodeType.prototype._getRuleContextArray=function(){return this._ruleContextArray;};xmp.playlistapi.internals.RuleSetPlayableNodeType.prototype._getMetadataMapRef=function(){return this._metadataMap;};xmp.createNamespace("xmp.playlistapi.internals");xmp.playlistapi.internals.SimplePlayListIterator=function(Wf){this._playListArray=Wf;this._curIndex=-1;};xmp.playlistapi.internals.SimplePlayListIterator.prototype.getLength=function(){return this._playListArray.length;};xmp.playlistapi.internals.SimplePlayListIterator.prototype.first=function(){this._curIndex=0;};xmp.playlistapi.internals.SimplePlayListIterator.prototype.next=function(){var Xf=this._playListArray[this._curIndex];this._curIndex++;return Xf;};xmp.playlistapi.internals.SimplePlayListIterator.prototype.hasNext=function(){return(this._curIndex<this.getLength());};