UNPKG

infusion

Version:

Infusion is an application framework for developing flexible stuff with JavaScript

21 lines 563 kB
/*! * infusion - v4.8.0 * * Build Info: * branch: HEAD * revision: 60d89fe69 * build date: 2025-01-15T10:41:57-05:00Z * includes: fluid-ui-options * excludes: jquery, jquery-ui */ /*! * Fluid Infusion v4.8.0 * * Infusion is distributed under the Educational Community License 2.0 and new BSD licenses: * http://wiki.fluidproject.org/display/fluid/Fluid+Licensing * * Copyright The Infusion copyright holders * See the AUTHORS.md file at the top-level directory of this distribution and at * https://github.com/fluid-project/infusion/raw/main/AUTHORS.md */ "use strict";var fluid=fluid||{};fluid.version="Infusion 4.8.0";fluid.Error=Error;fluid.environment={fluid:fluid};fluid.global=fluid.global||typeof window!=="undefined"?window:typeof self!=="undefined"?self:{};fluid.invokeLater=function(func){return setTimeout(func,0)};fluid.defeatLogging=true;fluid.activityTracing=false;fluid.activityTrace=[];var activityParser=/(%\w+)/g;fluid.renderActivityArgument=function(arg){if(fluid.isComponent(arg)){return fluid.dumpComponentAndPath(arg)}else{return arg}};fluid.renderOneActivity=function(activity,nowhile){var togo=nowhile===true?[]:[" while "];var message=activity.message;var index=activityParser.lastIndex=0;while(true){var match=activityParser.exec(message);if(match){var key=match[1].substring(1);togo.push(message.substring(index,match.index));togo.push(fluid.renderActivityArgument(activity.args[key]));index=activityParser.lastIndex}else{break}}if(index<message.length){togo.push(message.substring(index))}return togo};fluid.renderActivity=function(activityStack,renderer){renderer=renderer||fluid.renderOneActivity;return fluid.transform(activityStack,renderer)};fluid.singleThreadLocal=function(initFunc){var value=initFunc();return function(newValue){return newValue===undefined?value:value=newValue}};fluid.threadLocal=fluid.singleThreadLocal;fluid.globalThreadLocal=fluid.threadLocal((function(){return{}}));fluid.getActivityStack=function(){var root=fluid.globalThreadLocal();if(!root.activityStack){root.activityStack=[]}return root.activityStack};fluid.describeActivity=fluid.getActivityStack;fluid.logActivity=function(activity){activity=activity||fluid.describeActivity();var rendered=fluid.renderActivity(activity).reverse();if(rendered.length>0){fluid.log("Current activity: ");fluid.each(rendered,(function(args){fluid.log.apply(null,args)}))}};fluid.pushActivity=function(type,message,args){var record={type:type,message:message,args:args,time:(new Date).getTime()};if(fluid.activityTracing){fluid.activityTrace.push(record)}if(fluid.passLogLevel(fluid.logLevel.TRACE)){fluid.log.apply(null,fluid.renderOneActivity(record,true))}var activityStack=fluid.getActivityStack();activityStack.push(record)};fluid.popActivity=function(popframes){popframes=popframes||1;if(fluid.activityTracing){fluid.activityTrace.push({pop:popframes})}var activityStack=fluid.getActivityStack();var popped=activityStack.length-popframes;activityStack.length=popped<0?0:popped};fluid.FluidError=function(){var togo=Error.apply(this,arguments);this.message=togo.message;try{throw togo}catch(togo){this.stack=togo.stack}return this};fluid.FluidError.prototype=Object.create(Error.prototype);fluid.logFailure=function(args,activity){fluid.log.apply(null,[fluid.logLevel.FAIL,"ASSERTION FAILED: "].concat(args));fluid.logActivity(activity)};fluid.renderLoggingArg=function(arg){return arg===undefined?"undefined":fluid.isPrimitive(arg)||!fluid.isPlainObject(arg)?arg:JSON.stringify(arg)};fluid.builtinFail=function(args){var message=fluid.transform(args,fluid.renderLoggingArg).join("");throw new fluid.FluidError("Assertion failure - check console for more details: "+message)};fluid.fail=function(...messages){var activity=fluid.makeArray(fluid.describeActivity());fluid.popActivity(activity.length);if(fluid.failureEvent){fluid.failureEvent.fire(messages,activity)}else{fluid.logFailure(messages,activity);fluid.builtinFail(messages,activity)}};fluid.notrycatch=false;fluid.tryCatch=function(tryfun,catchfun,finallyfun){finallyfun=finallyfun||fluid.identity;if(fluid.notrycatch){var togo=tryfun();finallyfun();return togo}else{try{return tryfun()}catch(e){if(catchfun){catchfun(e)}else{throw e}}finally{finallyfun()}}};fluid.expect=function(name,target,members){fluid.transform(fluid.makeArray(members),(function(key){if(target[key]===undefined){fluid.fail(name+" missing required member "+key)}}))};fluid.isLogging=function(){return logLevelStack[0].priority>fluid.logLevel.IMPORTANT.priority};fluid.isLogLevel=function(arg){return fluid.isMarker(arg)&&arg.priority!==undefined};fluid.passLogLevel=function(testLogLevel){return testLogLevel.priority<=logLevelStack[0].priority};fluid.setLogging=function(enabled){var logLevel;if(typeof enabled==="boolean"){logLevel=fluid.logLevel[enabled?"INFO":"IMPORTANT"]}else if(fluid.isLogLevel(enabled)){logLevel=enabled}else{fluid.fail("Unrecognised fluid logging level ",enabled)}logLevelStack.unshift(logLevel);fluid.defeatLogging=!fluid.isLogging()};fluid.setLogLevel=fluid.setLogging;fluid.popLogging=function(){var togo=logLevelStack.length===1?logLevelStack[0]:logLevelStack.shift();fluid.defeatLogging=!fluid.isLogging();return togo};fluid.doBrowserLog=function(args){if(typeof console!=="undefined"){if(console.debug){console.debug.apply(console,args)}else if(typeof console.log==="function"){console.log.apply(console,args)}}};fluid.log=function(){var directArgs=fluid.makeArray(arguments);var userLogLevel=fluid.logLevel.INFO;if(fluid.isLogLevel(directArgs[0])){userLogLevel=directArgs.shift()}if(fluid.passLogLevel(userLogLevel)){fluid.loggingEvent.fire(directArgs)}};fluid.isValue=function(value){return value!==undefined&&value!==null};fluid.isPrimitive=function(value){var valueType=typeof value;return!value||valueType==="string"||valueType==="boolean"||valueType==="number"||valueType==="function"};fluid.isJQuery=function(totest){return Boolean(totest&&totest.jquery&&totest.constructor&&totest.constructor.prototype&&totest.constructor.prototype.jquery)};fluid.isArrayable=function(totest){return Boolean(totest)&&(Object.prototype.toString.call(totest)==="[object Array]"||fluid.isJQuery(totest))};fluid.isPlainObject=function(totest,strict){var string=Object.prototype.toString.call(totest);if(string==="[object Array]"){return!strict}else if(string!=="[object Object]"){return false}return!totest.constructor||!totest.constructor.prototype||Object.prototype.hasOwnProperty.call(totest.constructor.prototype,"isPrototypeOf")};fluid.typeCode=function(totest){return fluid.isPrimitive(totest)||!fluid.isPlainObject(totest)?"primitive":fluid.isArrayable(totest)?"array":"object"};fluid.isIoCReference=function(ref){return typeof ref==="string"&&ref.charAt(0)==="{"};fluid.isReferenceOrExpander=function(ref){return ref&&(fluid.isIoCReference(ref)||ref.expander)};fluid.isDOMNode=function(obj){return obj&&typeof obj.nodeType==="number"};fluid.isComponent=function(obj){return obj&&obj.constructor===fluid.componentConstructor};fluid.isUncopyable=function(totest){return fluid.isPrimitive(totest)||!fluid.isPlainObject(totest)};fluid.isApplicable=function(totest){return totest.apply&&typeof totest.apply==="function"};fluid.identity=function(arg){return arg};fluid.notImplemented=function(){fluid.fail("This operation is not implemented")};fluid.firstDefined=function(a,b){return a===undefined?b:a};fluid.freshContainer=function(tocopy){return fluid.isArrayable(tocopy)?[]:{}};fluid.testStrategyRecursion=function(funcName,segs){if(segs.length>fluid.strategyRecursionBailout){fluid.fail("Runaway recursion encountered in "+funcName+" - reached path depth of "+fluid.strategyRecursionBailout+" via path of "+segs.join(".")+"this object is probably circularly connected. Either adjust your object structure to remove the circularity or increase fluid.strategyRecursionBailout")}};fluid.copyRecurse=function(tocopy,segs){fluid.testStrategyRecursion("fluid.copy",segs);if(fluid.isUncopyable(tocopy)){return tocopy}else{return fluid.transform(tocopy,(function(value,key){segs.push(key);var togo=fluid.copyRecurse(value,segs);segs.pop();return togo}))}};fluid.copy=function(tocopy){return fluid.copyRecurse(tocopy,[])};fluid.extend=$.extend;fluid.makeArray=function(arg){var togo=[];if(arg!==null&&arg!==undefined){if(fluid.isPrimitive(arg)||fluid.isPlainObject(arg,true)||typeof arg.length!=="number"){togo.push(arg)}else{for(var i=0;i<arg.length;++i){togo[i]=arg[i]}}}return togo};fluid.pushArray=function(holder,member,topush){var array=holder[member]?holder[member]:holder[member]=[];if(Array.isArray(topush)){array.push.apply(array,topush)}else{array.push(topush)}};function transformInternal(source,togo,key,transformations){var transit=source[key];for(var j=0;j<transformations.length;++j){transit=transformations[j](transit,key)}if(transit!==fluid.NO_VALUE){togo[key]=transit}}fluid.transform=function(source,...transformations){if(fluid.isPrimitive(source)){return source}var togo=fluid.freshContainer(source);if(fluid.isArrayable(source)){for(var i=0;i<source.length;++i){transformInternal(source,togo,i,transformations)}}else{for(var key in source){transformInternal(source,togo,key,transformations)}}return togo};fluid.forEachInRange=function(array,start,end,func){for(var i=start;i<end;++i){func(array[i],i)}};fluid.peek=function(array){return array.length===0?undefined:array[array.length-1]};fluid.each=function(source,func){if(fluid.isArrayable(source)){for(var i=0;i<source.length;++i){func(source[i],i)}}else{for(var key in source){func(source[key],key)}}};fluid.make_find=function(find_if){var target=find_if?false:undefined;return function(source,func,deffolt){var disp;if(fluid.isArrayable(source)){for(var i=0;i<source.length;++i){disp=func(source[i],i);if(disp!==target){return find_if?source[i]:disp}}}else{for(var key in source){disp=func(source[key],key);if(disp!==target){return find_if?source[key]:disp}}}return deffolt}};fluid.find=fluid.make_find(false);fluid.find_if=fluid.make_find(true);fluid.remove_if=function(source,fn,target){if(fluid.isArrayable(source)){for(var i=source.length-1;i>=0;--i){if(fn(source[i],i)){if(target){target.unshift(source[i])}source.splice(i,1)}}}else{for(var key in source){if(fn(source[key],key)){if(target){target[key]=source[key]}delete source[key]}}}return target||source};fluid.generate=function(n,generator,applyFunc){var togo=[];for(var i=0;i<n;++i){togo[i]=applyFunc?generator(i):generator}return togo};fluid.iota=function(count,first){first=first||0;var togo=[];for(var i=0;i<count;++i){togo[togo.length]=first++}return togo};fluid.getMembers=function(holder,name){return fluid.transform(holder,(function(member){return fluid.get(member,name)}))};fluid.filterKeys=function(toFilter,keys,exclude){return fluid.remove_if($.extend({},toFilter),(function(value,key){return exclude^keys.indexOf(key)===-1}))};fluid.censorKeys=function(toCensor,keys){return fluid.filterKeys(toCensor,keys,true)};fluid.keys=function(obj){var togo=[];for(var key in obj){togo.push(key)}return togo};fluid.values=function(obj){var togo=[];for(var key in obj){togo.push(obj[key])}return togo};fluid.keyForValue=function(obj,value){return fluid.find(obj,(function(thisValue,key){if(value===thisValue){return key}}))};fluid.arrayToHash=function(array){var togo={};fluid.each(array,(function(el){togo[el]=true}));return togo};fluid.hashToArray=function(hash,keyName,func){var togo=[];fluid.each(hash,(function(el,key){var newEl=el;if(keyName!==undefined){newEl={};newEl[keyName]=key}if(func){newEl=func(newEl,el,key)||newEl}else if(newEl!==el){$.extend(true,newEl,el)}togo.push(newEl)}));return togo};fluid.flatten=function(array){var togo=[];fluid.each(array,(function(element){if(fluid.isArrayable(element)){togo=togo.concat(element)}else{togo.push(element)}}));return togo};fluid.clear=function(target){if(fluid.isArrayable(target)){target.length=0}else{for(var i in target){delete target[i]}}};fluid.compareStringLength=function(ascending){return ascending?function(a,b){return a.length-b.length}:function(a,b){return b.length-a.length}};fluid.parseInteger=function(string){return isFinite(string)&&string%1===0?Number(string):NaN};fluid.roundToDecimal=function(num,scale,method){scale=scale&&scale>=0?Math.round(scale):0;if(method==="ceil"||method==="floor"){return Number(Math[method](num+"e"+scale)+"e-"+scale)}else{var sign=num>=0?1:-1;return Number(sign*(Math.round(Math.abs(num)+"e"+scale)+"e-"+scale))}};fluid.debounce=function(func,wait,immediate){var timeout,result;return function(){var context=this,args=arguments;var later=function(){timeout=null;if(!immediate){result=func.apply(context,args)}};var callNow=immediate&&!timeout;clearTimeout(timeout);timeout=setTimeout(later,wait);if(callNow){result=func.apply(context,args)}return result}};fluid.freezeRecursive=function(tofreeze,segs){segs=segs||[];fluid.testStrategyRecursion("fluid.freezeRecursive",segs);if(fluid.isPlainObject(tofreeze)){fluid.each(tofreeze,(function(value,key){segs.push(key);fluid.freezeRecursive(value,segs);segs.pop()}));return Object.freeze(tofreeze)}else{return tofreeze}};fluid.marker=function(){};fluid.makeMarker=function(value,extra){var togo=Object.create(fluid.marker.prototype);togo.value=value;fluid.extend(togo,extra);return Object.freeze(togo)};fluid.NO_VALUE=fluid.makeMarker("NO_VALUE");fluid.EXPAND=fluid.makeMarker("EXPAND");fluid.isMarker=function(totest,type){if(!(totest instanceof fluid.marker)){return false}if(!type){return true}return totest.value===type.value};fluid.logLevelsSpec={FATAL:0,FAIL:5,WARN:10,IMPORTANT:12,INFO:15,TRACE:20};fluid.logLevel=fluid.transform(fluid.logLevelsSpec,(function(value,key){return fluid.makeMarker(key,{priority:value})}));var logLevelStack=[fluid.logLevel.IMPORTANT];fluid.model={};fluid.model.copyModel=function(target,source){fluid.clear(target);$.extend(true,target,source)};fluid.model.parseEL=function(EL){return EL===""?[]:String(EL).split(".")};fluid.model.composePath=function(prefix,suffix){return prefix===""?suffix:suffix===""?prefix:prefix+"."+suffix};fluid.model.composeSegments=function(){return fluid.makeArray(arguments).join(".")};fluid.lastDotIndex=function(path){return path.lastIndexOf(".")};fluid.model.getToTailPath=function(path){var lastdot=fluid.lastDotIndex(path);return lastdot===-1?"":path.substring(0,lastdot)};fluid.model.getTailPath=function(path){var lastdot=fluid.lastDotIndex(path);return path.substring(lastdot+1)};fluid.path=fluid.model.composeSegments;fluid.composePath=fluid.model.composePath;fluid.requireDataBinding=function(){fluid.fail("Please include DataBinding.js in order to operate complex model accessor configuration")};fluid.model.setWithStrategy=fluid.model.getWithStrategy=fluid.requireDataBinding;fluid.model.resolvePathSegment=function(root,segment,create,origEnv){if(!origEnv&&root.resolvePathSegment){var togo=root.resolvePathSegment(segment);if(togo!==undefined){return togo}}if(create&&root[segment]===undefined){return root[segment]={}}return root[segment]};fluid.model.parseToSegments=function(EL,parseEL,copy){return typeof EL==="number"||typeof EL==="string"?parseEL(EL):copy?fluid.makeArray(EL):EL};fluid.model.pathToSegments=function(EL,config){var parser=config&&config.parser?config.parser.parse:fluid.model.parseEL;return fluid.model.parseToSegments(EL,parser)};fluid.model.accessImpl=function(root,EL,newValue,config,initSegs,returnSegs,traverser){var segs=fluid.model.pathToSegments(EL,config);var initPos=0;if(initSegs){initPos=initSegs.length;segs=initSegs.concat(segs)}var uncess=newValue===fluid.NO_VALUE?0:1;root=traverser(root,segs,initPos,config,uncess);if(newValue===fluid.NO_VALUE){return returnSegs?{root:root,segs:segs}:root}else{root[fluid.peek(segs)]=newValue}};fluid.model.accessSimple=function(root,EL,newValue,environment,initSegs,returnSegs){return fluid.model.accessImpl(root,EL,newValue,environment,initSegs,returnSegs,fluid.model.traverseSimple)};fluid.model.traverseSimple=function(root,segs,initPos,environment,uncess){var origEnv=environment;var limit=segs.length-uncess;for(var i=0;i<limit;++i){if(!root){return undefined}var segment=segs[i];if(environment&&environment[segment]){root=environment[segment]}else{root=fluid.model.resolvePathSegment(root,segment,uncess===1,origEnv)}environment=null}return root};fluid.model.setSimple=function(root,EL,newValue,environment,initSegs){fluid.model.accessSimple(root,EL,newValue,environment,initSegs,false)};fluid.model.getSimple=function(root,EL,environment,initSegs){if(EL===null||EL===undefined||EL.length===0){return root}return fluid.model.accessSimple(root,EL,fluid.NO_VALUE,environment,initSegs,false)};fluid.getImmediate=function(root,segs,i){var limit=i===undefined?segs.length:i+1;for(var j=0;j<limit;++j){root=root?root[segs[j]]:undefined}return root};fluid.decodeAccessorArg=function(arg3){return!arg3||arg3===fluid.model.defaultGetConfig||arg3===fluid.model.defaultSetConfig?null:arg3.type==="environment"?arg3.value:undefined};fluid.set=function(root,EL,newValue,config,initSegs){var env=fluid.decodeAccessorArg(config);if(env===undefined){fluid.model.setWithStrategy(root,EL,newValue,config,initSegs)}else{fluid.model.setSimple(root,EL,newValue,env,initSegs)}};fluid.get=function(root,EL,config,initSegs){var env=fluid.decodeAccessorArg(config);return env===undefined?fluid.model.getWithStrategy(root,EL,config,initSegs):fluid.model.accessImpl(root,EL,fluid.NO_VALUE,env,null,false,fluid.model.traverseSimple)};fluid.getGlobalValue=function(path,env){if(path){env=env||fluid.environment;return fluid.get(fluid.global,path,{type:"environment",value:env})}};fluid.bind=function(obj,fnName,args){return obj[fnName].apply(obj,fluid.makeArray(args))};fluid.proxyComponentArgs=fluid.identity;fluid.invokeGlobalFunction=function(functionPath,args,environment){var func=fluid.getGlobalValue(functionPath,environment);if(!func){fluid.fail("Error invoking global function: "+functionPath+" could not be located")}else{var argsArray=fluid.isArrayable(args)?args:fluid.makeArray(args);fluid.proxyComponentArgs(argsArray);return func.apply(null,argsArray)}};fluid.registerGlobalFunction=function(functionPath,func,env){env=env||fluid.environment;fluid.set(fluid.global,functionPath,func,{type:"environment",value:env})};fluid.setGlobalValue=fluid.registerGlobalFunction;fluid.registerNamespace=function(path,env){env=env||fluid.environment;var existing=fluid.getGlobalValue(path,env);if(!existing){existing={};fluid.setGlobalValue(path,existing,env)}return existing};fluid.dumpEl=fluid.identity;fluid.renderTimestamp=fluid.identity;fluid.generateUniquePrefix=function(){return Math.floor(Math.random()*1e12).toString(36)+"-"};var fluid_prefix=fluid.generateUniquePrefix();fluid.fluidInstance=fluid_prefix;var fluid_guid=1;fluid.allocateGuid=function(){return fluid_prefix+fluid_guid++};fluid.registerNamespace("fluid.event");fluid.extremePriority=4e9;fluid.priorityTypes={first:-1,last:1,before:0,after:0};fluid.extremalPriorities={none:0,transaction:10,testing:20,authoring:30};fluid.parsePriorityConstraint=function(constraint,fixedOnly,site){var segs=constraint.split(":");var type=segs[0];var lookup=fluid.priorityTypes[type];if(lookup===undefined){fluid.fail("Invalid constraint type in priority field "+constraint+": the only supported values are "+fluid.keys(fluid.priorityTypes).join(", ")+" or numeric")}if(fixedOnly&&lookup===0){fluid.fail("Constraint type in priority field "+constraint+" is not supported in a "+site+" record - you must use either a numeric value or first, last")}return{type:segs[0],target:segs[1]}};fluid.parsePriority=function(priority,count,fixedOnly,site){priority=priority||0;var togo={count:count||0,fixed:null,constraint:null,site:site};if(typeof priority==="number"){togo.fixed=-priority}else{togo.constraint=fluid.parsePriorityConstraint(priority,fixedOnly,site)}var multiplier=togo.constraint?fluid.priorityTypes[togo.constraint.type]:0;if(multiplier!==0){var target=togo.constraint.target||"none";var extremal=fluid.extremalPriorities[target];if(extremal===undefined){fluid.fail("Unrecognised extremal priority target "+target+": the currently supported values are "+fluid.keys(fluid.extremalPriorities).join(", ")+": register your value in fluid.extremalPriorities")}togo.fixed=multiplier*(fluid.extremePriority+extremal)}if(togo.fixed!==null){togo.fixed+=togo.count/1024}return togo};fluid.renderPriority=function(parsed){return parsed.constraint?parsed.constraint.target?parsed.constraint.type+":"+parsed.constraint.target:parsed.constraint.type:Math.floor(parsed.fixed)};fluid.compareByPriority=function(recA,recB){if(recA.priority.fixed!==null&&recB.priority.fixed!==null){return recA.priority.fixed-recB.priority.fixed}else{return(recA.priority.fixed===null)-(recB.priority.fixed===null)}};fluid.honourConstraint=function(array,firstConstraint,c){var constraint=array[c].priority.constraint;var matchIndex=fluid.find(array,(function(element,index){return element.namespace===constraint.target?index:undefined}),-1);if(matchIndex===-1){return true}else if(matchIndex>=firstConstraint){return false}else{var offset=constraint.type==="after"?1:0;var target=matchIndex+offset;var temp=array[c];for(var shift=c;shift>=target;--shift){array[shift]=array[shift-1]}array[target]=temp;return true}};fluid.sortByPriority=function(array){array.sort(fluid.compareByPriority);var firstConstraint=fluid.find(array,(function(element,index){return element.priority.constraint&&fluid.priorityTypes[element.priority.constraint.type]===0?index:undefined}),array.length);while(true){if(firstConstraint===array.length){return array}var oldFirstConstraint=firstConstraint;for(var c=firstConstraint;c<array.length;++c){var applied=fluid.honourConstraint(array,firstConstraint,c);if(applied){++firstConstraint}}if(firstConstraint===oldFirstConstraint){var holders=array.slice(firstConstraint);fluid.fail("Could not find targets for any constraints in "+holders[0].priority.site+" ",holders,": none of the targets ("+fluid.getMembers(holders,"priority.constraint.target").join(", ")+") matched any namespaces of the elements in (",array.slice(0,firstConstraint),") - this is caused by either an invalid or circular reference")}}};fluid.parsePriorityRecords=function(records,name){var array=fluid.hashToArray(records,"namespace",(function(newElement,oldElement){$.extend(newElement,oldElement);newElement.priority=fluid.parsePriority(oldElement.priority,0,false,name)}));fluid.sortByPriority(array);return array};fluid.event.identifyListener=function(listener,soft){if(typeof listener!=="string"&&!listener.$$fluid_guid&&!soft){listener.$$fluid_guid=fluid.allocateGuid()}return listener.$$fluid_guid};fluid.event.impersonateListener=function(origListener,newListener){fluid.event.identifyListener(origListener);newListener.$$fluid_guid=origListener.$$fluid_guid};fluid.event.sortListeners=function(listeners){var togo=[];fluid.each(listeners,(function(oneNamespace){var headHard;for(var i=0;i<oneNamespace.length;++i){var thisListener=oneNamespace[i];if(!thisListener.softNamespace&&!headHard){headHard=thisListener}}if(headHard){togo.push(headHard)}else{togo=togo.concat(oneNamespace)}}));return fluid.sortByPriority(togo)};fluid.event.resolveListener=function(listener){var listenerName=listener.globalName||(typeof listener==="string"?listener:null);if(listenerName){var listenerFunc=fluid.getGlobalValue(listenerName);if(!listenerFunc){fluid.fail("Unable to look up name "+listenerName+" as a global function")}else{listener=listenerFunc}}return listener};fluid.nameComponent=function(that){return that?fluid.dumpComponentAndPath(that):"[unknown component]"};fluid.event.nameEvent=function(that,eventName){return eventName+" of "+fluid.nameComponent(that)};fluid.event.firer=function(){};fluid.makeEventFirer=function(options){options=options||{};var name=options.name||"<anonymous>";var that;var lazyInit=function(){that.listeners={};that.byId={};that.sortedListeners=[];that.onDestroy=null;that.addListener=function(listener,namespace,priority,softNamespace,listenerId){var record;if(that.destroyed){fluid.fail("Cannot add listener to destroyed event firer "+that.name)}if(!listener){return}if(fluid.isPlainObject(listener,true)&&!fluid.isApplicable(listener)){record=listener;listener=record.listener;namespace=record.namespace;priority=record.priority;softNamespace=record.softNamespace;listenerId=record.listenerId}if(typeof listener==="string"){listener={globalName:listener}}var id=listenerId||fluid.event.identifyListener(listener);namespace=namespace||id;record=$.extend(record||{},{namespace:namespace,listener:listener,softNamespace:softNamespace,listenerId:listenerId,priority:fluid.parsePriority(priority,that.sortedListeners.length,false,"listeners")});that.byId[id]=record;var thisListeners=that.listeners[namespace]=fluid.makeArray(that.listeners[namespace]);thisListeners[softNamespace?"push":"unshift"](record);that.sortedListeners=fluid.event.sortListeners(that.listeners)};that.addListener.apply(null,arguments)};that=Object.create(fluid.event.firer.prototype);fluid.extend(that,{eventId:fluid.allocateGuid(),name:name,ownerId:options.ownerId,typeName:"fluid.event.firer",destroy:function(){that.destroyed=true;fluid.each(that.onDestroy,(function(func){func()}))},addListener:function(){lazyInit.apply(null,arguments)},removeListener:function(listener){if(!that.listeners){return}var namespace,id,record;if(typeof listener==="string"){namespace=listener;record=that.listeners[namespace];if(!record){id=namespace;namespace=null}}else if(typeof listener==="function"){id=fluid.event.identifyListener(listener,true);if(!id){fluid.fail("Cannot remove unregistered listener function ",listener," from event "+that.name)}}var rec=that.byId[id];var softNamespace=rec&&rec.softNamespace;namespace=namespace||rec&&rec.namespace||id;delete that.byId[id];record=that.listeners[namespace];if(record){if(softNamespace){fluid.remove_if(record,(function(thisLis){return thisLis.listener.$$fluid_guid===id||thisLis.listenerId===id}))}else{record.shift()}if(record.length===0){delete that.listeners[namespace]}}that.sortedListeners=fluid.event.sortListeners(that.listeners)},fire:function(){var listeners=that.sortedListeners;if(options.promise){that.promisePayload=arguments[0]}if(!listeners||that.destroyed){return}for(var i=0;i<listeners.length;++i){var lisrec=listeners[i];if(typeof lisrec.listener!=="function"){lisrec.listener=fluid.event.resolveListener(lisrec.listener)}var listener=lisrec.listener;var ret=listener.apply(null,arguments);var value;if(options.preventable&&ret===false||that.destroyed){value=false}if(value!==undefined){return value}}}});if(options.promise){that.then=function(func){if("promisePayload"in that){func(that.promisePayload)}else{that.addListener(func)}}}return that};fluid.event.addPrimitiveListener=function(holder,name,func){var existing=holder[name];if(!existing){existing=holder[name]=[]}existing.push(func)};fluid.fireEvent=function(component,eventName,args){var firer=component.events&&component.events[eventName];if(firer){firer.fire.apply(null,fluid.makeArray(args))}};fluid.event.addListenerToFirer=function(firer,value,namespace,wrapper){wrapper=wrapper||fluid.identity;if(fluid.isArrayable(value)){for(var i=0;i<value.length;++i){fluid.event.addListenerToFirer(firer,value[i],namespace,wrapper)}}else if(typeof value==="function"||typeof value==="string"){wrapper(firer).addListener(value,namespace)}else if(value&&typeof value==="object"){wrapper(firer).addListener(value.listener,namespace||value.namespace,value.priority,value.softNamespace,value.listenerId)}};fluid.event.resolveListenerRecord=function(records){return{records:records}};fluid.expandImmediate=function(material){fluid.fail("fluid.expandImmediate could not be loaded - please include FluidIoC.js in order to operate IoC-driven event with descriptor "+material)};fluid.mergeListeners=function(that,events,listeners){fluid.each(listeners,(function(value,key){var firer,namespace;if(fluid.isIoCReference(key)){firer=fluid.expandImmediate(key,that);if(!firer){fluid.fail("Error in listener record: key "+key+' could not be looked up to an event firer - did you miss out "events." when referring to an event firer?')}}else{var keydot=key.indexOf(".");if(keydot!==-1){namespace=key.substring(keydot+1);key=key.substring(0,keydot)}if(!events[key]){fluid.fail("Listener registered for event "+key+" which is not defined for this component")}firer=events[key]}var record=fluid.event.resolveListenerRecord(value,that,key,namespace,true);fluid.event.addListenerToFirer(firer,record.records,namespace,record.adderWrapper)}))};fluid.eventFromRecord=function(eventSpec,eventKey,that){var isIoCEvent=eventSpec&&(typeof eventSpec!=="string"||fluid.isIoCReference(eventSpec));var event;if(isIoCEvent){if(!fluid.event.resolveEvent){fluid.fail("fluid.event.resolveEvent could not be loaded - please include FluidIoC.js in order to operate IoC-driven event with descriptor ",eventSpec)}else{event=fluid.event.resolveEvent(that,eventKey,eventSpec)}}else{event=fluid.makeEventFirer({name:fluid.event.nameEvent(that,eventKey),preventable:eventSpec==="preventable",promise:eventSpec==="promise",ownerId:that.id})}return event};fluid.mergeListenerPolicy=function(target,source,key){if(typeof key!=="string"){fluid.fail("Error in listeners declaration - the keys in this structure must resolve to event names - got "+key+" from ",source)}var hasNamespace=!fluid.isIoCReference(key)&&key.indexOf(".")!==-1;return hasNamespace?source||target:fluid.arrayConcatPolicy(target,source)};fluid.makeMergeListenersPolicy=function(merger,modelRelay){return function(target,source){target=target||{};if(modelRelay&&(fluid.isArrayable(source)||"target"in source&&(typeof source.target==="string"||source.target.segs))){target[""]=merger(target[""],source,"")}else{fluid.each(source,(function(listeners,key){target[key]=merger(target[key],listeners,key)}))}return target}};fluid.validateListenersImplemented=function(that){var errors=[];fluid.each(that.events,(function(event,name){fluid.each(event.sortedListeners,(function(lisrec){if(lisrec.listener===fluid.notImplemented||lisrec.listener.globalName==="fluid.notImplemented"){errors.push({name:name,namespace:lisrec.namespace,componentSource:fluid.model.getSimple(that.options.listeners,[name+"."+lisrec.namespace,0,"componentSource"])})}}))}));return errors};fluid.arrayConcatPolicy=function(target,source){return fluid.makeArray(target).concat(fluid.makeArray(source))};fluid.loggingEvent=fluid.makeEventFirer({name:"logging event"});fluid.addTimestampArg=function(args){var arg0=fluid.renderTimestamp(new Date)+": ";args.unshift(arg0)};fluid.loggingEvent.addListener(fluid.doBrowserLog,"log");fluid.loggingEvent.addListener(fluid.identity,"filterArgs","before:log");fluid.loggingEvent.addListener(fluid.addTimestampArg,"addTimestampArg","after:filterArgs");fluid.upgradeError=function(originError,whileMsg){var error=originError instanceof Error?originError:fluid.isPrimitive(originError)?{message:originError}:fluid.extend({},originError);error.message=error.message+whileMsg;return error};fluid.failureEvent=fluid.makeEventFirer({name:"failure event"});fluid.failureEvent.addListener(fluid.builtinFail,"fail");fluid.failureEvent.addListener(fluid.logFailure,"log","before:fail");fluid.componentConstructor=function(){};Object.defineProperty(fluid.componentConstructor,"name",{value:"fluid.componentConstructor"});fluid.typeTag=function(type,id){var that=Object.create(fluid.componentConstructor.prototype);that.typeName=type;that.id=id||fluid.allocateGuid();return that};var gradeTick=1;var gradeTickStore={};fluid.defaultsStore={};fluid.flattenGradeName=function(gradeName){return typeof gradeName==="string"?gradeName:JSON.stringify(gradeName)};fluid.resolveGradesImpl=function(gs,gradeNames){gradeNames=fluid.makeArray(gradeNames);for(var i=gradeNames.length-1;i>=0;--i){var gradeName=gradeNames[i];var flatGradeName=fluid.flattenGradeName(gradeName);if(gradeName&&!gs.gradeHash[flatGradeName]){var isDynamic=fluid.isReferenceOrExpander(gradeName);var options=(isDynamic?null:fluid.rawDefaults(gradeName))||{};var thisTick=gradeTickStore[gradeName]||gradeTick-1;gs.lastTick=Math.max(gs.lastTick,thisTick);gs.gradeHash[flatGradeName]=true;gs.gradeChain.push(gradeName);var oGradeNames=fluid.makeArray(options.gradeNames);for(var j=oGradeNames.length-1;j>=0;--j){fluid.resolveGradesImpl(gs,oGradeNames[j])}}}return gs};fluid.resolveGradeStructure=function(defaultName,gradeNames){var gradeStruct={lastTick:0,gradeChain:[],gradeHash:{}};fluid.resolveGradesImpl(gradeStruct,[defaultName].concat(fluid.makeArray(gradeNames)));gradeStruct.gradeChain.reverse();return gradeStruct};fluid.hasGrade=function(options,gradeName){return!options||!options.gradeNames?false:options.gradeNames.includes(gradeName)};fluid.resolveGrade=function(defaults,defaultName,gradeNames){var gradeStruct=fluid.resolveGradeStructure(defaultName,gradeNames);var mergeArgs=fluid.transform(gradeStruct.gradeChain,fluid.rawDefaults,fluid.copy);fluid.remove_if(mergeArgs,(function(options){return!options}));var mergePolicy={};for(var i=0;i<mergeArgs.length;++i){if(mergeArgs[i]&&mergeArgs[i].mergePolicy){mergePolicy=$.extend(true,mergePolicy,mergeArgs[i].mergePolicy)}}mergeArgs=[mergePolicy,{}].concat(mergeArgs);var mergedDefaults=fluid.merge.apply(null,mergeArgs);mergedDefaults.gradeNames=gradeStruct.gradeChain;fluid.freezeRecursive(mergedDefaults);return{defaults:mergedDefaults,lastTick:gradeStruct.lastTick}};fluid.mergedDefaultsCache={};fluid.gradeNamesToKey=function(defaultName,gradeNames){return defaultName+"|"+gradeNames.join("|")};fluid.getMergedDefaults=function(defaultName,gradeNames){gradeNames=fluid.makeArray(gradeNames);var key=fluid.gradeNamesToKey(defaultName,gradeNames);var mergedDefaults=fluid.mergedDefaultsCache[key];if(mergedDefaults){var lastTick=0;var searchGrades=mergedDefaults.defaults.gradeNames;for(var i=0;i<searchGrades.length;++i){lastTick=Math.max(lastTick,gradeTickStore[searchGrades[i]]||0)}if(lastTick>mergedDefaults.lastTick){if(fluid.passLogLevel(fluid.logLevel.TRACE)){fluid.log(fluid.logLevel.TRACE,"Clearing cache for component "+defaultName+" with gradeNames ",searchGrades)}mergedDefaults=null}}if(!mergedDefaults){var defaults=fluid.rawDefaults(defaultName);if(!defaults){return defaults}mergedDefaults=fluid.mergedDefaultsCache[key]=fluid.resolveGrade(defaults,defaultName,gradeNames)}return mergedDefaults.defaults};fluid.NO_ARGUMENTS=fluid.makeMarker("NO_ARGUMENTS");fluid.upgradePrimitiveFunc=function(rec,key){if(rec&&fluid.isPrimitive(rec)){var togo={};togo[key||(typeof rec==="string"&&rec.charAt(0)!=="{"?"funcName":"func")]=rec;togo.args=fluid.NO_ARGUMENTS;return togo}else{return rec}};fluid.annotateListeners=function(componentName,options){options.listeners=fluid.transform(options.listeners,(function(record){var togo=fluid.makeArray(record);return fluid.transform(togo,(function(onerec){onerec=fluid.upgradePrimitiveFunc(onerec,"listener");onerec.componentSource=componentName;return onerec}))}));options.invokers=fluid.transform(options.invokers,(function(record){record=fluid.upgradePrimitiveFunc(record);if(record){record.componentSource=componentName}return record}))};fluid.workflowCache={};fluid.workflowCacheSorted=[];fluid.resortWorkflows=function(workflowType,baseIndex){var thisCache=fluid.workflowCache[workflowType];var parsed=fluid.parsePriorityRecords(thisCache,workflowType+" workflows");parsed.forEach((function(oneParsed,index){thisCache[oneParsed.namespace].index=index+baseIndex}));return parsed};fluid.indexOneWorkflows=function(gradeName,workflowType,workflows,baseIndex){fluid.each(workflows,(function(oneWorkflow,workflowKey){fluid.model.setSimple(fluid.workflowCache,[workflowType,workflowKey],{workflowType:workflowType,workflowName:workflowKey,priority:oneWorkflow.priority,gradeName:gradeName,workflowOptions:oneWorkflow})}));return fluid.resortWorkflows(workflowType,baseIndex)};fluid.clearGradeWorkflows=function(gradeName,workflowType){var cacheForType=fluid.workflowCache[workflowType];fluid.each(cacheForType,(function(oneWorkflow,workflowKey){if(oneWorkflow.gradeName===gradeName){delete cacheForType[workflowKey]}}))};fluid.indexGradeWorkflows=function(gradeName,options){fluid.clearGradeWorkflows(gradeName,"global");fluid.clearGradeWorkflows(gradeName,"local");var sortedGlobal=fluid.indexOneWorkflows(gradeName,"global",fluid.getImmediate(options,["workflows","global"]),0);var globalWorkflowCount=sortedGlobal.length;var sortedLocal=fluid.indexOneWorkflows(gradeName,"local",fluid.getImmediate(options,["workflows","local"]),globalWorkflowCount);fluid.workflowCacheSorted=sortedGlobal.concat(sortedLocal)};fluid.rawDefaults=function(componentName){var entry=fluid.defaultsStore[componentName];return entry&&entry.options};fluid.registerRawDefaults=function(componentName,options){fluid.pushActivity("registerRawDefaults","registering defaults for grade %componentName with options %options",{componentName:componentName,options:options});var optionsCopy=fluid.expandCompact?fluid.expandCompact(options):fluid.copy(options);fluid.annotateListeners(componentName,optionsCopy);fluid.indexGradeWorkflows(componentName,optionsCopy);delete optionsCopy.workflows;var callerInfo=fluid.getCallerInfo&&fluid.getCallerInfo(6);fluid.freezeRecursive(optionsCopy);fluid.defaultsStore[componentName]={options:optionsCopy,callerInfo:callerInfo};gradeTickStore[componentName]=gradeTick++;fluid.popActivity()};fluid.doIndexDefaults=function(defaultName,defaults,index,indexSpec){var requiredGrades=fluid.makeArray(indexSpec.gradeNames);for(var i=0;i<requiredGrades.length;++i){if(!fluid.hasGrade(defaults,requiredGrades[i])){return}}var indexFunc=typeof indexSpec.indexFunc==="function"?indexSpec.indexFunc:fluid.getGlobalValue(indexSpec.indexFunc);var keys=indexFunc(defaults)||[];for(var j=0;j<keys.length;++j){fluid.pushArray(index,keys[j],defaultName)}};fluid.indexDefaults=function(indexName,indexSpec){var index={};for(var defaultName in fluid.defaultsStore){var defaults=fluid.getMergedDefaults(defaultName);fluid.doIndexDefaults(defaultName,defaults,index,indexSpec)}return index};fluid.defaults=function(componentName,options){if(options===undefined){return fluid.getMergedDefaults(componentName)}else{if(options&&options.options){fluid.fail("Probable error in options structure for "+componentName+' with option named "options" - perhaps you meant to write these options at top level in fluid.defaults? - ',options)}fluid.registerRawDefaults(componentName,options);var gradedDefaults=fluid.getMergedDefaults(componentName);if(!fluid.hasGrade(gradedDefaults,"fluid.function")){fluid.makeComponentCreator(componentName)}}};fluid.validateCreatorGrade=function(message,componentName){var defaults=fluid.getMergedDefaults(componentName);if(!defaults||!defaults.gradeNames||defaults.gradeNames.length===0){fluid.fail(message+" type "+componentName+" which does not have any gradeNames defined")}else if(!defaults.argumentMap){var blankGrades=[];for(var i=0;i<defaults.gradeNames.length;++i){var gradeName=defaults.gradeNames[i];var rawDefaults=fluid.rawDefaults(gradeName);if(!rawDefaults){blankGrades.push(gradeName)}}if(blankGrades.length===0){fluid.fail(message+" type "+componentName+" which is not derived from fluid.component")}else{fluid.fail("The grade hierarchy of component with type "+componentName+" is incomplete - it inherits from the following grade(s): "+blankGrades.join(", ")+" for which the grade definitions are corrupt or missing. Please check the files which might include these "+"grades and ensure they are readable and have been loaded by this instance of Infusion")}}};fluid.makeComponentCreator=function(componentName){var creator=function(){fluid.validateCreatorGrade("Cannot make component creator for",componentName);return fluid.initFreeComponent(componentName,arguments)};var existing=fluid.getGlobalValue(componentName);if(existing){$.extend(creator,existing)}fluid.setGlobalValue(componentName,creator)};fluid.emptyPolicy=fluid.freezeRecursive({});fluid.derefMergePolicy=function(policy){return(policy?policy["*"]:fluid.emptyPolicy)||fluid.emptyPolicy};fluid.compileMergePolicy=function(mergePolicy){var builtins={},defaultValues={};var togo={builtins:builtins,defaultValues:defaultValues};if(!mergePolicy){return togo}fluid.each(mergePolicy,(function(value,key){var parsed={},builtin=true;if(typeof value==="function"){parsed.func=value}else if(typeof value==="object"){parsed=value}else if(!fluid.isDefaultValueMergePolicy(value)){var split=value.split(/\s*,\s*/);for(var i=0;i<split.length;++i){parsed[split[i]]=true}}else{fluid.set(defaultValues,key,"{that}.options."+value);togo.hasDefaults=true;builtin=false}if(builtin){fluid.set(builtins,fluid.composePath(key,"*"),parsed)}}));return togo};fluid.isDefaultValueMergePolicy=function(policy){return typeof policy==="string"&&(policy.indexOf(",")===-1&&!/replace|nomerge|noexpand/.test(policy))};fluid.mergeOneImpl=function(thisTarget,thisSource,j,sources,newPolicy,newPolicyHolder,i,segs){var togo=thisTarget;var primitiveTarget=fluid.isPrimitive(thisTarget);if(thisSource!==undefined){if(!newPolicy.func&&thisSource!==null&&fluid.isPlainObject(thisSource)&&!newPolicy.nomerge){if(primitiveTarget){togo=thisTarget=fluid.freshContainer(thisSource)}}else{sources[j]=undefined;if(newPolicy.func){togo=newPolicy.func.call(null,thisTarget,thisSource,newPolicyHolder,segs,i)}else{togo=thisSource}}}return togo};fluid.regenerateCursor=function(source,segs,limit,sourceStrategy){for(var i=0;i<limit;++i){source=sourceStrategy(source,segs[i],i,fluid.makeArray(segs))}return source};fluid.regenerateSources=function(sources,segs,limit,sourceStrategies){var togo=[];for(var i=0;i<sources.length;++i){var thisSource=fluid.regenerateCursor(sources[i],segs,limit,sourceStrategies[i]);togo.push(thisSource)}return togo};fluid.fetchMergeChildren=function(target,i,segs,sources,mergePolicy,options){var thisPolicy=fluid.derefMergePolicy(mergePolicy);for(var j=sources.length-1;j>=0;--j){var source=sources[j];if(source!==undefined){fluid.each(source,(function(newSource,name){var childPolicy=fluid.concreteTrundler(mergePolicy,name);if(!(name in target)||options.evaluateFully&&childPolicy===undefined&&!fluid.isPrimitive(target[name])){segs[i]=name;options.strategy(target,name,i+1,segs,sources,mergePolicy)}}));if(thisPolicy.replace){break}}}return target};fluid.inEvaluationMarker=Object.freeze({__CURRENTLY_IN_EVALUATION__:true});fluid.strategyRecursionBailout=50;fluid.makeMergeStrategy=function(options){var strategy=function(target,name,i,segs,sources,policy){if(i>fluid.strategyRecursionBailout){fluid.fail("Overflow/circularity in options merging, current path is ",segs," at depth ",i,' - please protect components from merging using the "nomerge" merge policy')}if(fluid.isPrimitive(target)){return undefined}if(fluid.isTracing){fluid.tracing.pathCount.push(fluid.path(segs.slice(0,i)))}var oldTarget;if(name in target||options.fullyEvaluated){oldTarget=target[name];if(!options.evaluateFully){return oldTarget}}if(sources===undefined){segs=fluid.makeArray(segs);sources=fluid.regenerateSources(options.sources,segs,i-1,options.sourceStrategies);policy=fluid.regenerateCursor(options.mergePolicy,segs,i-1,fluid.concreteTrundler)}var newPolicyHolder=fluid.concreteTrundler(policy,name);var newPolicy=fluid.derefMergePolicy(newPolicyHolder);var start,limit,mul;if(newPolicy.replace){start=1-sources.length;limit=0;mul=-1}else{start=0;limit=sources.length-1;mul=+1}var newSources=[];var thisTarget;for(var j=start;j<=limit;++j){var k=mul*j;var thisSource=options.sourceStrategies[k](sources[k],name,i,segs);if(thisSource!==undefined){if(!fluid.isPrimitive(thisSource)){newSources[k]=thisSource}if(oldTarget===undefined){if(mul===-1){thisTarget=target[name]=thisSource;break}else{thisTarget=fluid.mergeOneImpl(thisTarget,thisSource,j,newSources,newPolicy,newPolicyHolder,i,segs,options);target[name]=thisTarget}}}}if(oldTarget!==undefined){thisTarget=oldTarget}if(newSources.length>0){if(fluid.isPlainObject(thisTarget)){fluid.fetchMergeChildren(thisTarget,i,segs,newSources,newPolicyHolder,options)}}return thisTarget};options.strategy=strategy;return strategy};fluid.driveStrategy=function(root,pathSegs,strategy){pathSegs=fluid.makeArray(pathSegs);for(var i=0;i<pathSegs.length;++i){if(!root){return undefined}root=strategy(root,pathSegs[i],i+1,pathSegs)}return root};fluid.concreteTrundler=function(source,seg){return!source?undefined:source[seg]};fluid.merge=function(policy,...sources){var compiled=fluid.compileMergePolicy(policy).builtins;var options=fluid.makeMergeOptions(compiled,sources,{});options.initter();return options.target};fluid.makeMergeOptions=function(policy,sources,userOptions){var options={mergePolicy:policy,sources:sources};options=$.extend(options,userOptions);options.target=options.target||fluid.freshContainer(options.sources[0]);options.sourceStrategies=options.sourceStrategies||fluid.generate(options.sources.length,fluid.concreteTrundler);options.initter=function(){options.evaluateFully=true;fluid.fetchMergeChildren(options.target,0,[],options.sources,options.mergePolicy,options);options.fullyEvaluated=true};fluid.makeMergeStrategy(options);return options};fluid.transformOptions=function(options,transRec){fluid.expect("Options transformation record",transRec,["transformer","config"]);var transFunc=fluid.getGlobalValue(transRec.transformer);return transFunc.call(null,options,transRec.config)};fluid.findMergeBlocks=function(mergeBlocks,recordType){return fluid.remove_if(fluid.makeArray(mergeBlocks),(function(block){return block.recordType!==recordType}))};fluid.transformOptionsBlocks=function(mergeBlocks,transformOptions,recordTypes){fluid.each(recordTypes,(function(recordType){var blocks=fluid.findMergeBlocks(mergeBlocks,recordType);fluid.each(blocks,(function(block){var source=block.source?"source":"target";block[block.simple||source==="target"?"target":"source"]=fluid.transformOptions(block[source],transformOptions)}))}))};fluid.dedupeDistributionNamespaces=function(mergeBlocks){var byNamespace={};fluid.remove_if(mergeBlocks,(function(mergeBlock){var ns=mergeBlock.namespace;if(ns){if(byNamespace[ns]&&byNamespace[ns]!==mergeBlock.contextThat.id){return true}else{byNamespace[ns]=mergeBlock.contextThat.id}}}))};fluid.mergeRecordTypes={defaults:1e3,defaultValueMerge:900,lensedComponents:800,subcomponentRecord:700,user:600,distribution:100};fluid.model.applyChangeRequest=function(model,request){var segs=request.segs;if(segs.length===0){if(request.type==="ADD"){$.extend(true,model,request.value)}else{fluid.clear(model)}}else if(request.type==="ADD"){fluid.model.setSimple(model,request.segs,request.value)}else{for(var i=0;i<segs.length-1;++i){model=model[segs[i]];if(!model){return}}var last=fluid.peek(segs);delete model[last]}};fluid.destroyValue=function(target,segs){if(target){fluid.model.applyChangeRequest(target,{type:"DELETE",segs:segs})}};fluid.mergeComponentOptions=function(that,potentia,lightMerge){fluid.validateCreatorGrade("Cannot construct component of",lightMerge.type);var sharedMergePolicy={};var mergeBlocks=fluid.expandComponentOptions(sharedMergePolicy,potentia,lightMerge,that);var options={};var sourceStrategies=[],sources=[];var baseMergeOptions={target:options,sourceStrategies:sourceStrategies};var updateBlocks=function(){fluid.each(mergeBlocks,(function(block){if(fluid.isPrimitive(block.priority)){block.priority=fluid.parsePriority(block.priority,0,false,block.recordType)}}));fluid.sortByPriority(mergeBlocks);fluid.dedupeDistributionNamespaces(mergeBlocks);sourceStrategies.length=0;sources.length=0;fluid.each(mergeBlocks,(function(block){sourceStrategies.push(block.strategy);sources.push(block.target)}))};updateBlocks();var mergeOptions=fluid.makeMergeOptions(sharedMergePolicy,sources,baseMergeOptions);mergeOptions.mergeBlocks=mergeBlocks;mergeOptions.updateBlocks=updateBlocks;mergeOptions.destroyValue=function(segs){for(var i=0;i<mergeBlocks.length;++i){if(!mergeBlocks[i].immutableTarget){fluid.destroyValue(mergeBlocks[i].target,segs)}}fluid.destroyValue(baseMergeOptions.target,segs)};var compiledPolicy;var mergePolicy;function computeMergePolicy(){mergePolicy=fluid.driveStrategy(options,"mergePolicy",mergeOptions.strategy);mergePolicy=$.extend({},fluid.rootMergePolicy,mergePolicy);compiledPolicy=fluid.compileMergePolicy(mergePolicy);$.extend(true,sharedMergePolicy,compiledPolicy.builtins)}computeMergePolicy();mergeOptions.computeMergePolicy=computeMergePolicy;if(compiledPolicy.hasDefaults){mergeBlocks.push(fluid.generateExpandBlock({options:compiledPolicy.defaultValues,recordType:"defaultValueMerge",priority:fluid.mergeRecordTypes.defaultValueMerge},that,{}));updateBlocks()}that.options=options;fluid.driveStrategy(options,"gradeNames",mergeOptions.strategy);fluid.deliverOptionsStrategy(that,options,mergeOptions);fluid.computeComponentAccessor(that,potentia.localRecord);var transformOptions=fluid.driveStrategy(options,"transformOptions",mergeOptions.strategy);if(transformOptions){fluid.transformOptionsBlocks(mergeBlocks,transformOptions,["user","subcomponentRecord"]);updateBlocks()}if(!baseMergeOptions.target.mergePolicy){computeMergePolicy()}return mergeOptions};fluid.defaults("fluid.function",{});fluid.invokeGradedFunction=function(name,spec){var defaults=fluid.defaults(name);if(!defaults||!defaults.argumentMap||!fluid.hasGrade(defaults,"fluid.function")){fluid.fail("Cannot look up name "+name+" to a function with registered argumentMap - got defaults ",defaults)}var args=[];fluid.each(defaults.argumentMap,(function(value,key){args[value]=spec[key]}));return fluid.invokeGlobalFunction(name,args)};fluid.noNamespaceDistributionPrefix="no-namespace-distribution-";fluid.mergeOneDistribution=function(target,source,key){var namespace=source.namespace||key||fluid.noNamespaceDistributionPrefix+fluid.allocateGuid();source.namespace=namespace;target[namespace]=$.extend(true,{},target[namespace],source)};fluid.distributeOptionsPolicy=function(target