(function(){var e=function(e){var t=this,n=function(){var t=function(e){return e.replace(/^\/\//,"").replace(/[\/\.]/g,"_")},n=e.makeArray,r=1,i=e.View=function(t,r,i,s){typeof i=="function"&&(s=i,i=undefined);var l=a(r);if(l.length){var c=e.Deferred();return l.push(o(t,!0)),e.when.apply(e,l).then(function(e){var t=n(arguments),o=t.pop()[0],a;if(u(r))r=f(e);else for(var l in r)u(r[l])&&(r[l]=f(t.shift()));a=o(r,i),c.resolve(a),s&&s(a)}),c.promise()}var h,p=typeof s=="function",c=o(t,p);return p?(h=c,c.done(function(e){s(e(r,i))})):c.done(function(e){h=e(r,i)}),h},s=function(e,t){if(!e.match(/[^\s]/))throw"$.View ERROR: There is no template or an empty template at "+t},o=function(t,n){return e.ajax({url:t,dataType:"view",async:n})},u=function(t){return t&&e.isFunction(t.always)},a=function(e){var t=[];if(u(e))return[e];for(var n in e)u(e[n])&&t.push(e[n]);return t},f=function(t){return e.isArray(t)&&t.length===3&&t[1]==="success"?t[0]:t};e.ajaxTransport("view",function(n,r){var o=r.url,u=o.match(/\.[\w\d]+$/),a,f,l,c,h=function(e){var t=a.renderer(l,e);return i.cache&&(i.cached[l]=t),{view:t}};if(f=document.getElementById(o))u="."+f.type.match(/\/(x\-)?(.+)/)[2];u||(u=i.ext,o+=i.ext),l=t(o);if(o.match(/^\/\//)){var p=o.substr(2);o=typeof steal=="undefined"?o="/"+p:steal.root.mapJoin(p)+""}a=i.types[u];var d=e.template()[r.url];return{send:function(t,n){if(d)return a=i.types["."+d.type],n(200,"success",h(d.content));if(i.cached[l])return n(200,"success",{view:i.cached[l]});f?n(200,"success",h(f.innerHTML)):c=e.ajax({async:r.async,url:o,dataType:"text",error:function(){s("",o),n(404)},success:function(e){s(e,o),n(200,"success",h(e))}})},abort:function(){c&&c.abort()}}}),e.extend(i,{hookups:{},hookup:function(e){var t=++r;return i.hookups[t]=e,t},cached:{},cache:!0,register:function(e){this.types["."+e.suffix]=e,window.steal&&steal.type(e.suffix+" view js",function(e,n,r){var s=i.types["."+e.type],o=t(e.rootSrc+"");e.text=s.script(o,e.text),n()})},types:{},ext:".ejs",registerScript:function(e,t,n){return"$.View.preload('"+t+"',"+i.types["."+e].script(t,n)+");"},preload:function(e,t){i.cached[e]=function(e,n){return t.call(e,e,n)}}}),window.steal&&steal.type("view js",function(e,n,r){var s=i.types["."+e.type],o=t(e.rootSrc+"");e.text="steal('"+(s.plugin||"jquery/view/"+e.type)+"').then(function($){"+"$.View.preload('"+o+"',"+e.text+");\n})",n()});var l,c,h,p,d,v,m,g,y={val:!0,text:!0};l=function(t){var r=e.fn[t];e.fn[t]=function(){var e=n(arguments),s,o,a=this,f;if(u(e[0]))return e[0].done(function(e){c.call(a,[e],r)}),this;if(h(e)){if(s=v(e))return o=e[s],e[s]=function(e){c.call(a,[e],r),o.call(a,e)},i.apply(i,e),this;f=i.apply(i,e);if(!!u(f))return f.done(function(e){c.call(a,[e],r)}),this;e=[f]}return y[t]?r.apply(this,e):c.call(this,e,r)}},c=function(t,n){var r,s,o;for(var u in i.hookups)break;return u&&t[0]&&p(t[0])&&(o=i.hookups,i.hookups={},t[0]=e(t[0])),r=n.apply(this,t),o&&m(t[0],o),r},h=function(e){var t=typeof e[1];return typeof e[0]=="string"&&(t=="object"||t=="function")&&!d(e[1])},d=function(e){return e.nodeType||e.jquery},p=function(t){return d(t)?!0:typeof t=="string"?(t=e.trim(t),t.substr(0,1)==="<"&&t.substr(t.length-1,1)===">"&&t.length>=3):!1},v=function(e){return typeof e[3]=="function"?3:typeof e[2]=="function"&&2},m=function(t,n){var r,s,o=0,u,a;t=t.filter(function(){return this.nodeType!=3}),r=t.add("[data-view-id]",t),s=r.length;for(;o<s;o++)r[o].getAttribute&&(u=r[o].getAttribute("data-view-id"))&&(a=n[u])&&(a(r[o],u),delete n[u],r[o].removeAttribute("data-view-id"));e.extend(i.hookups,n)},e.fn.hookup=function(){var e=i.hookups;return i.hookups={},m(this,e),this},e.each(["prepend","append","after","before","text","html","replaceWith","val"],function(e,t){l(t)})};n(),t.resolveWith(n)};dispatch("mvc/view").containing(e).to("Foundry/2.1 Modules")})();