!function(window,undefined){function debounce(f){var timer;return debounced;function debounced(){if(timer)return;timer=setTimeout(function(args){f.apply(this,args);timer=null}.bind(this,arguments),0)}}var dashed2camel=function(dashedStr){return dashedStr.replace(/-(.){1}/g,function(_,c){return c.toUpperCase()})};var getAttrs=function(el){var data={};for(var i=0,_len=el.attributes.length;i<_len;i++){var attr=el.attributes[i];var match=attr.name.match(/^data-(.+)/);if(match){var prop=dashed2camel(match[1]);data[prop]=attr.value}}return data};var prefix="sprig";var componentAttr="data-"+prefix+"-component";var readyStateAttr="data-"+prefix+"-ready-state";var selectors={component:"["+componentAttr+"]",scheduled:"["+componentAttr+"]["+readyStateAttr+"=scheduled]",deferred:"["+componentAttr+"]["+readyStateAttr+"=deferred]",loading:"["+componentAttr+"]["+readyStateAttr+"=loading]",loaded:"["+componentAttr+"]["+readyStateAttr+"=loaded]"};selectors.forComponentDef=function(name){return"["+componentAttr+"="+name+"]"};function Component(el,parent){if(Sprig&&Sprig.hasOwnProperty("$")){this.$el=Sprig.$(el)}this.el=el;this.params=getAttrs(this.el);this.scan=debounce(this.scan);this.load=debounce(this.load);this.data={};this.children=[];this.parent=parent;if(parent)this.parent.children.push(this);this.registry={}}Component.prototype.define=function(name,opts){var myName=this.getName();var path=myName?myName+"."+name:name;this._loadDeferreds();return this.registry[path]=new ComponentDef(path,opts)};Component.prototype._loadDeferreds=function(){var deferredElements=this.query(selectors.deferred);if(deferredElements.length>0){this.load(deferredElements)}};Component.prototype.getName=function(){return this.el.getAttribute("data-sprig-component")};Component.prototype.query=function(selector){return this.el.querySelectorAll(selector)};Component.prototype.scan=function(){var allComponents=this.query(selectors.component);var unprocessedElements=[];for(var i=0;i