(function(factory){if(typeof define==='function'&&define.amd){define(['knockout'],factory);}else if(typeof exports==='object'){factory(require('knockout'));}else{factory(window.ko);}})(function(ko){if(!ko.virtualElements) throw Error('Repeat requires at least Knockout 2.1');var ko_bindingFlags=ko.bindingFlags||{};var ko_unwrap=ko.utils.unwrapObservable;var koProtoName='__ko_proto__';if(ko.version>="3.0.0"){var provider=ko.bindingProvider.instance,previousPreprocessFn=provider.preprocessNode;provider.preprocessNode=function(node){var newNodes,nodeBinding;if(!previousPreprocessFn||!(newNodes=previousPreprocessFn.call(this,node))){if(node.nodeType===1&&(nodeBinding=node.getAttribute('data-bind'))){if(/^\s*repeat\s*:/.test(nodeBinding)){var leadingComment=node.ownerDocument.createComment('ko '+nodeBinding),trailingComment=node.ownerDocument.createComment('/ko');node.parentNode.insertBefore(leadingComment,node);node.parentNode.insertBefore(trailingComment,node.nextSibling);node.removeAttribute('data-bind');newNodes=[leadingComment,node,trailingComment];}}} return newNodes;};} ko.virtualElements.allowedBindings.repeat=true;ko.bindingHandlers.repeat={flags:ko_bindingFlags.contentBind|ko_bindingFlags.canUseVirtual,init:function(element,valueAccessor,allBindingsAccessor,xxx,bindingContext){var repeatParam=ko_unwrap(valueAccessor());if(repeatParam&&typeof repeatParam=='object'&&!('length'in repeatParam)){var repeatIndex=repeatParam.index,repeatData=repeatParam.item,repeatStep=repeatParam.step,repeatReversed=repeatParam.reverse,repeatBind=repeatParam.bind,repeatInit=repeatParam.init,repeatUpdate=repeatParam.update;} repeatIndex=repeatIndex||'$index';repeatData=repeatData||ko.bindingHandlers.repeat.itemName||'$item';repeatStep=repeatStep||1;repeatReversed=repeatReversed||false;var parent=element.parentNode,placeholder;if(element.nodeType==8){var childNodes=ko.utils.arrayFilter(ko.virtualElements.childNodes(element),function(node){return node.nodeType==1;});if(childNodes.length!==1){throw Error("Repeat binding requires a single element to repeat");} ko.virtualElements.emptyNode(element);placeholder=repeatReversed?element:element.nextSibling;element=childNodes[0];}else{var origBindString=element.getAttribute('data-bind');ko.cleanNode(element);element.removeAttribute('data-bind');placeholder=element.ownerDocument.createComment('ko_repeatplaceholder '+origBindString);parent.replaceChild(placeholder,element);} if(!repeatBind){repeatBind=element.getAttribute('data-repeat-bind');if(repeatBind){element.removeAttribute('data-repeat-bind');}} var cleanNode=element.cloneNode(true);if(typeof repeatBind=="string"){cleanNode.setAttribute('data-bind',repeatBind);repeatBind=null;} var lastRepeatCount=0,notificationObservable=ko.observable(),repeatArray,arrayObservable;if(repeatInit){repeatInit(parent);} var subscribable=ko.computed(function(){function makeArrayItemAccessor(index){var f=function(newValue){var item=repeatArray[index];if(!arguments.length){notificationObservable();return ko_unwrap(item);} if(ko.isObservable(item)){item(newValue);}else if(arrayObservable&&arrayObservable.splice){arrayObservable.splice(index,1,newValue);}else{repeatArray[index]=newValue;} return this;};f[koProtoName]=ko.observable;return f;} function makeBinding(item,index,context){return repeatArray?function(){return repeatBind.call(bindingContext.$data,item,index,context);}:function(){return repeatBind.call(bindingContext.$data,index,context);}} var paramObservable=valueAccessor(),repeatParam=ko_unwrap(paramObservable),repeatCount=0;if(repeatParam&&typeof repeatParam=='object'){if('length'in repeatParam){repeatArray=repeatParam;repeatCount=repeatArray.length;}else{if('foreach'in repeatParam){repeatArray=ko_unwrap(paramObservable=repeatParam.foreach);if(repeatArray&&typeof repeatArray=='object'&&'length'in repeatArray){repeatCount=repeatArray.length||0;}else{repeatCount=repeatArray||0;repeatArray=null;}} if('count'in repeatParam) repeatCount=ko_unwrap(repeatParam.count)||repeatCount;if('limit'in repeatParam) repeatCount=Math.min(repeatCount,ko_unwrap(repeatParam.limit))||repeatCount;} arrayObservable=repeatArray&&ko.isObservable(paramObservable)?paramObservable:null;}else{repeatCount=repeatParam||0;} for(;lastRepeatCount>repeatCount;lastRepeatCount-=repeatStep){ko.removeNode(repeatReversed?placeholder.nextSibling:placeholder.previousSibling);} notificationObservable.notifySubscribers();for(;lastRepeatCount