1 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("lodash"),require("vue")):(t="undefined"!=typeof globalThis?globalThis:t||self).Truss=e(t._,t.Vue)}(this,function(g,c){"use strict";var a;g=g&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g,c=c&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c;function u(){a.digestRequest>h||(a.digestRequest=h+1)}var e,h=0,l=!1,f={active:"undefined"!=typeof window&&window.angular};f.active?(e=window.angular.module("firetruss",[]),f.digest=u,f.watch=function(){throw new Error("Angular watch proxy not yet initialized")},f.defineModule=function(t){e.constant("Truss",t)},f.debounceDigest=function(t){var e;t?(e=g.debounce(u,t),f.digest=function(){a.digestRequest>h||(l?u:e)()}):f.digest=u},e.config(["$provide",function(t){t.decorator("$rootScope",["$delegate","$exceptionHandler",function(t,e){var r=t;f.watch=r.$watch.bind(r);var n,i,o=Object.getPrototypeOf(r),s=o.$digest;return o.$digest=u,o.$digest.original=s,(a=new c({data:{digestRequest:0}})).$watch(function(){return a.digestRequest},function(){a.digestRequest>h?c.nextTick(function(){a.digestRequest<=h||(l=!0,r.$digest.original.call(r),h=a.digestRequest=a.digestRequest+1)}):l=!1}),g.last(a._watchers).id=1/0,n=Object.getPrototypeOf(g.last(a._watchers)),i=n.get,n.get=function(){try{return i.call(this)}catch(t){if(this.vm._watcher!==this||!c.config.errorHandler)throw t;c.config.errorHandler(t,this.vm,"uncaught render error")}},r}])}])):g.forEach(["digest","watch","defineModule","debounceDigest"],function(t){f[t]=g.noop});function n(t,e){this.key=t,this.value=e,this.touch()}n.prototype.touch=function(){this.timestamp=Date.now()};function t(t,e){this._items=Object.create(null),this._size=0,this._maxSize=t,this._pruningSize=e||Math.ceil(.1*t)}t.prototype.has=function(t){return Boolean(this._items[t])},t.prototype.get=function(t){var e=this._items[t];if(e)return e.touch(),e.value},t.prototype.set=function(t,e){var r=this._items[t];r?r.value=e:(this._size>=this._maxSize&&this._prune(),this._items[t]=new n(t,e),this._size+=1)},t.prototype.delete=function(t){this._items[t]&&(delete this._items[t],--this._size)},t.prototype._prune=function(){for(var t=0,e=g(this._items).toArray().sortBy("timestamp").take(this._pruningSize).value();t<e.length;t+=1){var r=e[t];this.delete(r.key)}};var i=new t(1e3),r={};function p(t){return t?t.toString().replace(/[\x00-\x1f\\.$#[\]\x7f/]/g,function(t){return"\\"+g.padStart(t.charCodeAt(0).toString(16),2,"0")}):t}function d(t){return t?t.toString().replace(/\\[0-9a-f]{2}/gi,function(t){return String.fromCharCode(parseInt(t.slice(1),16))}):t}function _(t){if(!g.isObject(t)||!Object.isExtensible(t))return t;var e,r,n,i=t;for(var o in t){t.hasOwnProperty(o)&&(e=t[o],r=p(o),n=_(e),r===o&&n===e||(i===t&&(i=g.clone(t)),i[r]=n,i[o]===e&&delete i[o]))}return i}function y(){for(var t=[],e=0,r=arguments;e<r.length;e+=1){var n=r[e];g.isString(n)||(n=""+n),"/"===n.charAt(0)&&t.splice(0,t.length),t.push(n)}return"/"===t[0]&&(t[0]=""),t.join("/")}function v(t,e){var r=(e?"esc:":"")+t,n=i.get(r);return n||(n=t.split("/"),e||(n=g.map(n,d)),i.set(r,n)),n}function o(t){var e=this;this.variables=[];var r=g.endsWith(t,"/$*");r&&(t=t.slice(0,-3));var n=t.replace(/\/\$[^/]*/g,function(t){return 1<t.length&&e.variables.push(t.slice(1)),""});if(Object.freeze(this.variables),/[.$#[\]]|\\(?![0-9a-f][0-9a-f])/i.test(n))throw new Error("Path pattern has unescaped keys: "+t);this._regex=new RegExp("^"+n.replace(/\u0001/g,"/([^/]+)")+(r?"($|/)":"$"))}function b(t){var e=r[t];return e||(e=new o(t),1e3===g.size(r)&&delete r[g.keys(r)[0]],r[t]=e),e}o.prototype.match=function(t){this._regex.lastIndex=0;var e=this._regex.exec(t);if(e){for(var r={},n=0;n<this.variables.length;n++)r[this.variables[n]]=d(e[n+1]);return r}},o.prototype.test=function(t){return this._regex.test(t)},o.prototype.toString=function(){return this._regex.toString()};function s(t){var e=t.path,r=t.value,n=t.exists,i=t.writeSerial;this._path=e,this._value=r,this._exists=void 0===r?n||!1:null!==r,this._writeSerial=i}var m="2.2.0",w={path:{configurable:!0},exists:{configurable:!0},value:{configurable:!0},key:{configurable:!0},writeSerial:{configurable:!0}};w.path.get=function(){return this._path},w.exists.get=function(){return this._exists},w.value.get=function(){if(void 0===this._value)throw new Error("Value omitted from snapshot");return this._value},w.key.get=function(){return void 0===this._key&&(this._key=d(this._path.replace(/.*\//,""))),this._key},w.writeSerial.get=function(){return this._writeSerial},Object.defineProperties(s.prototype,w);function $(t){var e=this;this._idCounter=0,this._deferreds={},this._suspended=!1,this._servers={},this._callbacks={},this._log=g.noop,this._inboundMessages=[],this._outboundMessages=[],this._flushMessageQueue=this._flushMessageQueue.bind(this),this._port=t.port||t,this._shared=!!t.port,Object.seal(this),this._port.onmessage=this._receive.bind(this),window.addEventListener("unload",function(){e._send({msg:"destroy"})})}function k(e,t){if(!e||g.isError(e))return e;var r=new Error(e.message);for(var n in r.params=t,e)if("message"!==n&&e.hasOwnProperty(n))try{r[n]=e[n]}catch(t){r.extra=r.extra||{},r.extra[n]=e[n]}return r}$.prototype.init=function(t,e){var r=[];try{var n=window.localStorage||window.sessionStorage;if(!n)throw new Error("localStorage and sessionStorage not available");for(var i=0;i<n.length;i++){var o=n.key(i);r.push({key:o,value:n.getItem(o)})}}catch(t){}return this._send({msg:"init",storage:r,config:e}).then(function(t){var e=t.version.match(/^(\d+)\.(\d+)\.(\d+)(-.*)?$/);if(e){var r=m.match(/^(\d+)\.(\d+)\.(\d+)(-.*)?$/);if(!(e[1]===r[1]&&(e[2]>r[2]||e[2]===r[2]&&e[3]>=r[3])))return Promise.reject(new Error("Incompatible Firetruss worker version: "+t.version+" ("+m+" or better required)"))}return t})},$.prototype.suspend=function(t){void 0===t&&(t=!0),this._suspended!==t&&((this._suspended=t)||(this._receiveMessages(this._inboundMessages),this._inboundMessages=[],this._outboundMessages.length&&Promise.resolve().then(this._flushMessageQueue)))},$.prototype.enableLogging=function(t){t?(!0===t&&(t=console.log.bind(console)),this._log=t):this._log=g.noop},$.prototype._send=function(r){var t,e,n=this;return r.id=++this._idCounter,r.oneWay?t=Promise.resolve():(t=new Promise(function(t,e){n._deferreds[r.id]={resolve:t,reject:e}}),((e=this._deferreds[r.id]).promise=t).sent=new Promise(function(t){e.resolveSent=t}),e.params=r),this._outboundMessages.length||this._suspended||Promise.resolve().then(this._flushMessageQueue),this._log("send:",r),this._outboundMessages.push(r),t},$.prototype._flushMessageQueue=function(){try{this._port.postMessage(this._outboundMessages),this._outboundMessages=[]}catch(t){throw t.extra={messages:this._outboundMessages},t}},$.prototype._receive=function(t){this._suspended?this._inboundMessages=this._inboundMessages.concat(t.data):this._receiveMessages(t.data)},$.prototype._receiveMessages=function(t){for(var e=0,r=t;e<r.length;e+=1){var n=r[e];this._log("recv:",n);var i=this[n.msg];if(!g.isFunction(i))throw new Error("Unknown message: "+n.msg);i.call(this,n)}},$.prototype.bindExposedFunction=function(t){return function(){return this._send({msg:"call",name:t,args:Array.prototype.slice.call(arguments)})}.bind(this)},$.prototype.resolve=function(t){var e=this._deferreds[t.id];if(!e)throw new Error("Received resolution to inexistent Firebase call");delete this._deferreds[t.id],e.resolve(t.result)},$.prototype.reject=function(t){var e=this._deferreds[t.id];if(!e)throw new Error("Received rejection of inexistent Firebase call");delete this._deferreds[t.id],e.reject(k(t.error,e.params))},$.prototype.updateLocalStorage=function(t){var e=t.items;try{for(var r=window.localStorage||window.sessionStorage,n=0,i=e;n<i.length;n+=1){var o=i[n];null===o.value?r.removeItem(o.key):r.setItem(o.key,o.value)}}catch(t){}},$.prototype.trackServer=function(t){if(this._servers.hasOwnProperty(t))return Promise.resolve();var e=this._servers[t]={authListeners:[]},r=this._registerCallback(this._authCallback.bind(this,e));this._send({msg:"onAuth",url:t,callbackId:r})},$.prototype._authCallback=function(t,e){t.auth=e;for(var r=0,n=t.authListeners;r<n.length;r+=1){(0,n[r])(e)}},$.prototype.onAuth=function(t,e,r){var n=e.bind(r);n.callback=e,n.context=r,this._servers[t].authListeners.push(n),n(this.getAuth(t))},$.prototype.offAuth=function(t,e,r){for(var n=this._servers[t].authListeners,i=0;i<n.length;i++){var o=n[i];if(o.callback===e&&o.context===r){n.splice(i,1);break}}},$.prototype.getAuth=function(t){return this._servers[t].auth},$.prototype.authWithCustomToken=function(t,e){return this._send({msg:"authWithCustomToken",url:t,authToken:e})},$.prototype.authAnonymously=function(t){return this._send({msg:"authAnonymously",url:t})},$.prototype.unauth=function(t){return this._send({msg:"unauth",url:t})},$.prototype.set=function(t,e,r){return this._send({msg:"set",url:t,value:e,writeSerial:r})},$.prototype.update=function(t,e,r){return this._send({msg:"update",url:t,value:e,writeSerial:r})},$.prototype.once=function(t,e){return this._send({msg:"once",url:t,writeSerial:e}).then(function(t){return new s(t)})},$.prototype.on=function(t,e,r,n,i,o,s,a){var u={listenerKey:t,eventType:n,snapshotCallback:i,cancelCallback:o,context:s,params:{msg:"on",listenerKey:t,url:e,spec:r,eventType:n,options:a}},c=this._onCallback.bind(this,u);this._registerCallback(c,u),i.__callbackIds=i.__callbackIds||[],i.__callbackIds.push(u.id),this._send({msg:"on",listenerKey:t,url:e,spec:r,eventType:n,callbackId:u.id,options:a}).catch(function(t){c(t)})},$.prototype.off=function(e,t,r,n,i,o){var s,a=this,u=[];if(i){if(!(s=this._findAndRemoveCallbackId(i,function(t){return g.isMatch(t,{listenerKey:e,eventType:n,context:o})})))return Promise.resolve();u.push(s)}else for(var c=0,h=g.keys(this._callbacks);c<h.length;c+=1){var l=h[c],p=this._callbacks[l];p.listenerKey!==e||n&&p.eventType!==n||u.push(l)}for(var f=0,d=u;f<d.length;f+=1){var _=d[f];this._nullifyCallback(_)}return this._send({msg:"off",listenerKey:e,url:t,spec:r,eventType:n,callbackId:s}).then(function(){for(var t=0,e=u;t<e.length;t+=1){var r=e[t];a._deregisterCallback(r)}})},$.prototype._onCallback=function(t,e,r){var n;e?(this._deregisterCallback(t.id),n=k(e,t.params),t.cancelCallback?t.cancelCallback.call(t.context,n):console.error(n)):t.snapshotCallback.call(t.context,new s(r))},$.prototype.transaction=function(t,e,r,n){return this._send({msg:"transaction",url:t,oldValue:e,relativeUpdates:r,writeSerial:n}).then(function(t){return t.snapshots&&(t.snapshots=g.map(t.snapshots,function(t){return new s(t)})),t})},$.prototype.onDisconnect=function(t,e,r){return this._send({msg:"onDisconnect",url:t,method:e,value:r})},$.prototype.bounceConnection=function(){return this._send({msg:"bounceConnection"})},$.prototype.callback=function(t){var e=t.id,r=t.args,n=this._callbacks[e];if(!n)throw new Error("Unregistered callback: "+e);n.callback.apply(null,r)},$.prototype._registerCallback=function(t,e){return(e=e||{}).callback=t,e.id="cb"+ ++this._idCounter,(this._callbacks[e.id]=e).id},$.prototype._nullifyCallback=function(t){this._callbacks[t].callback=g.noop},$.prototype._deregisterCallback=function(t){delete this._callbacks[t]},$.prototype._findAndRemoveCallbackId=function(t,e){if(t.__callbackIds)for(var r=0;r<t.__callbackIds.length;){var n=t.__callbackIds[r],i=this._callbacks[n];if(i){if(e(i))return t.__callbackIds.splice(r,1),n;r+=1}else t.__callbackIds.splice(r,1)}};var P={};Object.freeze(P);var O=function(t,e,r){this._tree=t,this._path=e.replace(/^\/*/,"/").replace(/\/$/,"")||"/",r&&(this._annotations=r,Object.freeze(r))},E={$ref:{configurable:!0},key:{configurable:!0},path:{configurable:!0},_pathPrefix:{configurable:!0},parent:{configurable:!0},annotations:{configurable:!0}};E.$ref.get=function(){return this},E.key.get=function(){return this._key||(this._key=d(this._path.replace(/.*\//,""))),this._key},E.path.get=function(){return this._path},E._pathPrefix.get=function(){return"/"===this._path?"":this._path},E.parent.get=function(){return new C(this._tree,this._path.replace(/\/[^/]*$/,""),this._annotations)},E.annotations.get=function(){return this._annotations||P},O.prototype.child=function(){if(!arguments.length)return this;for(var t=[],e=0,r=arguments;e<r.length;e+=1){var n=r[e];if(g.isNil(n))return;t.push(p(n))}return new C(this._tree,this._pathPrefix+"/"+t.join("/"),this._annotations)},O.prototype.children=function(){var t=arguments;if(!arguments.length)return this;for(var e=[],r=0;r<arguments.length;r++){var n=t[r];if(g.isArray(n)){for(var i={},o=this._pathPrefix+(e.length?"/"+e.join("/"):""),s=g.slice(t,r+1),a=0,u=n;a<u.length;a+=1){var c=u[a],h=new C(this._tree,o+"/"+p(c),this._annotations),l=h.children.apply(h,s);l&&(i[c]=l)}return i}if(g.isNil(n))return;e.push(p(n))}return new C(this._tree,this._pathPrefix+"/"+e.join("/"),this._annotations)},O.prototype.peek=function(t){return this._tree.truss.peek(this,t)},O.prototype.match=function(t){return b(t).match(this.path)},O.prototype.test=function(t){return b(t).test(this.path)},O.prototype.isEqual=function(t){return t instanceof O&&(this._tree===t._tree&&this.toString()===t.toString()&&g.isEqual(this._annotations,t._annotations))},O.prototype.belongsTo=function(t){return this._tree.truss===t},Object.defineProperties(O.prototype,E);var j=function(o){function e(t,e,r,n){o.call(this,t,e,n),this._spec=this._copyAndValidateSpec(r);var i=g(this._spec).map(function(t,e){return e+"="+encodeURIComponent(JSON.stringify(t))}).sortBy().join("&");this._string=this._path+"?"+i,Object.freeze(this)}o&&(e.__proto__=o),(e.prototype=Object.create(o&&o.prototype)).constructor=e;var t={ready:{configurable:!0},constraints:{configurable:!0}};return t.ready.get=function(){return this._tree.isQueryReady(this)},t.constraints.get=function(){return this._spec},e.prototype.annotate=function(t){return new e(this._tree,this._path,this._spec,g.assign({},this._annotations,t))},e.prototype._copyAndValidateSpec=function(e){if(!e.by)throw new Error('Query needs "by" clause: '+JSON.stringify(e));if(1<("at"in e)+("from"in e)+("to"in e))throw new Error('Query must contain at most one of "at", "from", or "to" clauses: '+JSON.stringify(e));if(1<("first"in e)+("last"in e))throw new Error('Query must contain at most one of "first" or "last" clauses: '+JSON.stringify(e));if(!g.some(["at","from","to","first","last"],function(t){return t in e}))throw new Error('Query must contain at least one of "at", "from", "to", "first", or "last" clauses: '+JSON.stringify(e));if("$key"!==(e=g.clone(e)).by&&"$value"!==e.by){if(!(e.by instanceof C))throw new Error('Query "by" value must be a reference: '+e.by);var t=e.by.toString();if(!g.startsWith(t,this._path))throw new Error('Query "by" value must be a descendant of target reference: '+e.by);if(t=t.slice(this._path.length).replace(/^\/?/,""),!g.includes(t,"/"))throw new Error('Query "by" value must not be a direct child of target reference: '+e.by);e.by=t.replace(/.*?\//,"")}return Object.freeze(e),e},e.prototype.toString=function(){return this._string},Object.defineProperties(e.prototype,t),e}(O),C=function(n){function e(t,e,r){n.call(this,t,e,r),Object.freeze(this)}n&&(e.__proto__=n),(e.prototype=Object.create(n&&n.prototype)).constructor=e;var t={ready:{configurable:!0},value:{configurable:!0}};return t.ready.get=function(){return this._tree.isReferenceReady(this)},t.value.get=function(){return this._tree.getObject(this.path)},e.prototype.toString=function(){return this._path},e.prototype.annotate=function(t){return new e(this._tree,this._path,g.assign({},this._annotations,t))},e.prototype.query=function(t){return new j(this._tree,this._path,t,this._annotations)},e.prototype.set=function(t){var e;return this._checkForUndefinedPath(),this._tree.update(this,"set",((e={})[this.path]=t,e))},e.prototype.update=function(t){return this._checkForUndefinedPath(),this._tree.update(this,"update",t)},e.prototype.override=function(t){var e;return this._checkForUndefinedPath(),this._tree.update(this,"override",((e={})[this.path]=t,e))},e.prototype.commit=function(t){return this._checkForUndefinedPath(),this._tree.commit(this,t)},e.prototype._checkForUndefinedPath=function(){if("/undefined"===this.path)throw new Error("Invalid path for operation: "+this.path)},Object.defineProperties(e.prototype,t),e}(O),S=Object.freeze({".sv":"timestamp"});function R(t,e){return g.isEqualWith(t,e,x)}function x(t,e){return t===e||null==t||null==e||t.$truss||e.$truss?t===e:t.isEqual?t.isEqual(e):void 0}function T(t,e){for(var r=0,n=Object.getOwnPropertyNames(t.prototype);r<n.length;r+=1){var i=n[r];"constructor"!==i&&Object.defineProperty(e.prototype,i,Object.getOwnPropertyDescriptor(t.prototype,i))}}var A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function D(t){g.assign(this,{name:t,numRecomputes:0,numUpdates:0,runtime:0})}var z,M,I=(function(s){(function(){var t,e,r,n,i,o;"undefined"!=typeof performance&&null!==performance&&performance.now?s.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(s.exports=function(){return(t()-i)/1e6},e=process.hrtime,n=(t=function(){var t=e();return 1e9*t[0]+t[1]})(),o=1e9*process.uptime(),i=n-o):r=Date.now?(s.exports=function(){return Date.now()-r},Date.now()):(s.exports=function(){return(new Date).getTime()-r},(new Date).getTime())}).call(A)}(M={path:z,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&M.path)}},M.exports),M.exports),q={runtimePerRecompute:{configurable:!0}};D.prototype.add=function(t){this.runtime+=t.runtime,this.numUpdates+=t.numUpdates,this.numRecomputes+=t.numRecomputes},q.runtimePerRecompute.get=function(){return this.numRecomputes?this.runtime/this.numRecomputes:0},D.prototype.toLogParts=function(t){return[this.name+":"," "+(this.runtime/1e3).toFixed(2)+"s","("+(this.runtime/t.runtime*100).toFixed(1)+"%)"," "+this.numUpdates+" upd /",this.numRecomputes+" runs","("+(this.numUpdates/this.numRecomputes*100).toFixed(1)+"%)"," "+this.runtimePerRecompute.toFixed(2)+"ms / run"]},Object.defineProperties(D.prototype,q);function V(){this._items={}}var U={list:{configurable:!0}};V.prototype.for=function(t){return this._items[t]||(this._items[t]=new D(t)),this._items[t]},U.list.get=function(){return g(this._items).values().sortBy(function(t){return-t.runtime}).value()},V.prototype.log=function(t){void 0===t&&(t=10);var e,r,n,i,o=this.list;o.length&&(e=new D("=== Total"),g.forEach(o,function(t){e.add(t)}),o=g.take(o,t),r=new D("--- Above"),g.forEach(o,function(t){r.add(t)}),(n=g.map(o,function(t){return t.toLogParts(e)})).push(r.toLogParts(e)),n.push(e.toLogParts(e)),i=g.map(g.range(n[0].length),function(e){return g(n).map(function(t){return t[e].length}).max()}),g.forEach(n,function(t){console.log(g.map(t,function(t,e){return g.padStart(t,i[e])}).join(" "))}))},V.prototype.wrap=function(n,t,i){var o=this.for(t+"."+i);return function(){var t=I(),e=this._computedWatchers&&this._computedWatchers[i].value;try{var r=n.call(this);return R(e,r)||(o.numUpdates+=1),r}finally{o.runtime+=I()-t,o.numRecomputes+=1}}},Object.defineProperties(V.prototype,U);function F(t,e,r,n,i){var o=this;Object.freeze(e),this._scope=t,this._connections=e,this._tree=r,this._method=n,this._subConnectors={},this._disconnects={},this._angularUnwatches=void 0,this._data={},this._vue=new c({data:{descriptors:{},refs:i||{},values:g.mapValues(e,g.constant(void 0))}}),this.destroy=this.destroy,Object.seal(this),this._linkScopeProperties(),g.forEach(e,function(t,e){g.isFunction(t)?o._bindComputedConnection(e,t):o._connect(e,t)}),f.active&&t&&t.$on&&t.$id&&t.$on("$destroy",function(){o.destroy()})}var W=new V,K={ready:{configurable:!0},at:{configurable:!0},data:{configurable:!0}};function N(t){if(t)return t instanceof O?t.toString():g.mapValues(t,N)}function L(t){return function(){try{return Promise.resolve(t.apply(this,arguments))}catch(t){return Promise.reject(t)}}}function Q(t,e){return(t=H(t,function(){e=null})).cancel=function(){e&&(e(),e=null)},function n(i,o){var s=i.then,r=i.catch;i.then=function(t,e){var r=s.call(i,t,e);return r[o]=i[o],n(r,o),r};i.catch=function(t){var e=r.call(i,t);return e[o]=i[o],n(e,o),e};return i}(t,"cancel"),t}function H(t,e){return e?(e=L(e),t.then(function(t){return e().then(function(){return t})},function(t){return e().then(function(){return Promise.reject(t)})})):t}K.ready.get=function(){var n=this;return g.every(this._connections,function(t,e){var r=n._vue.descriptors[e];return!!r&&(r instanceof O?r.ready:n._subConnectors[e].ready)})},K.at.get=function(){return this._vue.refs},K.data.get=function(){return this._data},F.prototype.destroy=function(){var r=this;this._unlinkScopeProperties(),g.forEach(this._angularUnwatches,function(t){t()}),g.forEach(this._connections,function(t,e){r._disconnect(e)}),this._vue.$destroy()},F.prototype._linkScopeProperties=function(){var r=this,t=g.mapValues(this._connections,function(t,e){return{configurable:!0,enumerable:!1,get:function(){var t=r._vue.descriptors[e];return t instanceof C?t.value:r._vue.values[e]}}});if(Object.defineProperties(this._data,t),this._scope){for(var e in this._connections)if(e in this._scope)throw new Error("Property already defined on connection target: "+e);Object.defineProperties(this._scope,t),this._scope.__ob__&&this._scope.__ob__.dep.notify()}},F.prototype._unlinkScopeProperties=function(){var r=this;this._scope&&g.forEach(this._connections,function(t,e){delete r._scope[e]})},F.prototype._bindComputedConnection=function(t,e){var r=W.for("connection.at."+t),n=this._computeConnection.bind(this,e,r),i=this._updateComputedConnection.bind(this,t,e,r),o=f.active&&!e.angularWatchSuppressed;this._vue.$watch(n,i,{immediate:!o}),o&&(this._angularUnwatches||(this._angularUnwatches=[]),this._angularUnwatches.push(f.watch(n,i,!0)))},F.prototype._computeConnection=function(t,e){var r=I();try{return N(t.call(this._scope))}finally{e.runtime+=I()-r,e.numRecomputes+=1}},F.prototype._updateComputedConnection=function(t,e,r){var n=g.isFunction(e)?e(this._scope):e,i=!R(this._vue.descriptors[t],n);i&&(r&&i&&(r.numUpdates+=1),n?(n instanceof O||!g.has(this._subConnectors,t)?(this._disconnect(t),this._connect(t,n)):this._subConnectors[t]._updateConnections(n),c.set(this._vue.descriptors,t,n),f.digest()):this._disconnect(t))},F.prototype._updateConnections=function(r){var n=this;g.forEach(r,function(t,e){n._updateComputedConnection(e,t)}),g.forEach(this._connections,function(t,e){g.has(r,e)||n._updateComputedConnection(e)}),this._connections=r},F.prototype._connect=function(e,t){var r,n,i,o,s,a=this;c.set(this._vue.descriptors,e,t),f.digest(),t&&(c.set(this._vue.values,e,void 0),t instanceof C?(c.set(this._vue.refs,e,t),this._disconnects[e]=this._tree.connectReference(t,this._method)):t instanceof j?(c.set(this._vue.refs,e,t),r=this._updateQueryValue.bind(this,e),this._disconnects[e]=this._tree.connectQuery(t,r,this._method)):(n={},i={},c.set(this._vue.refs,e,i),o=this._subConnectors[e]=new F(n,t,this._tree,this._method,i),s=this._disconnects[e]=this._tree.truss.observe(function(){return o.ready},function(t){t&&(s(),delete a._disconnects[e],c.set(a._vue.values,e,n),f.digest())})))},F.prototype._disconnect=function(t){c.delete(this._vue.refs,t),this._updateRefValue(t,void 0),g.has(this._subConnectors,t)&&(this._subConnectors[t].destroy(),delete this._subConnectors[t]),this._disconnects[t]&&this._disconnects[t](),delete this._disconnects[t],c.delete(this._vue.descriptors,t),f.digest()},F.prototype._updateRefValue=function(t,e){this._vue.values[t]!==e&&(c.set(this._vue.values,t,e),f.digest())},F.prototype._updateQueryValue=function(t,e){this._vue.values[t]||(c.set(this._vue.values,t,{}),f.digest());var r=this._vue.values[t];for(var n in r)r.hasOwnProperty(n)&&(g.includes(e,n)||(c.delete(r,n),f.digest()));for(var i=this._tree.getObject(this._vue.descriptors[t].path),o=0,s=e;o<s.length;o+=1){var a=s[o];r.hasOwnProperty(a)||(c.set(r,a,i[a]),f.digest())}},Object.defineProperties(F.prototype,K);function B(t,e,r){this._operation=t,this._delay=e,this._callback=r,this._fired=!1}var J=["read","write","auth","set","update","commit","connect","peek","authenticate","unathenticate","certify","all"],G=[];B.prototype.initiate=function(){var t=this;this.cancel(),this._fired=!1;var e=Date.now()-this._operation._startTimestamp;this._timeoutId=setTimeout(function(){t._fired=!0,t._callback(t._operation)},this._delay-e)},B.prototype.cancel=function(){this._fired&&this._callback(this._operation),this._timeoutId&&clearTimeout(this._timeoutId)};function Y(t,e,r,n){this._type=t,this._method=e,this._target=r,this._operand=n,this._ready=!1,this._running=!1,this._ended=!1,this._tries=0,this._startTimestamp=Date.now(),this._slowHandles=[]}var X={type:{configurable:!0},method:{configurable:!0},target:{configurable:!0},targets:{configurable:!0},operand:{configurable:!0},ready:{configurable:!0},running:{configurable:!0},ended:{configurable:!0},tries:{configurable:!0},error:{configurable:!0}};X.type.get=function(){return this._type},X.method.get=function(){return this._method},X.target.get=function(){return this._target},X.targets.get=function(){var r=this;return"update"!==this._method?[this._target]:g.map(this._operand,function(t,e){return new C(r._target._tree,y(r._target.path,e),r._target._annotations)})},X.operand.get=function(){return this._operand},X.ready.get=function(){return this._ready},X.running.get=function(){return this._running},X.ended.get=function(){return this._ended},X.tries.get=function(){return this._tries},X.error.get=function(){return this._error},Y.prototype.onSlow=function(t,e){var r=new B(this,t,e);this._slowHandles.push(r),r.initiate()},Y.prototype._setRunning=function(t){this._running=t},Y.prototype._setEnded=function(t){this._ended=t},Y.prototype._markReady=function(t){this._ready=!0,t||(this._tries=0),g.forEach(this._slowHandles,function(t){return t.cancel()})},Y.prototype._clearReady=function(){this._ready=!1,this._startTimestamp=Date.now(),g.forEach(this._slowHandles,function(t){return t.initiate()})},Y.prototype._incrementTries=function(){this._tries++},Object.defineProperties(Y.prototype,X);function Z(t){this._bridge=t,this._callbacks={},Object.freeze(this)}Z.prototype.intercept=function(t,e){if(!g.includes(J,t))throw new Error("Unknown intercept operation type: "+t);var r=g.difference(g.keys(e),["onBefore","onAfter","onError","onFailure"]);if(r.length)throw new Error("Unknown intercept callback types: "+r.join(", "));var n={onBefore:this._addCallback("onBefore",t,e.onBefore),onAfter:this._addCallback("onAfter",t,e.onAfter),onError:this._addCallback("onError",t,e.onError),onFailure:this._addCallback("onFailure",t,e.onFailure)};return this._removeCallbacks.bind(this,t,n)},Z.prototype._addCallback=function(t,e,r){if(r){var n=this._getCallbacksKey(t,e),i=L(r);return(this._callbacks[n]||(this._callbacks[n]=[])).push(i),i}},Z.prototype._removeCallback=function(t,e,r){var n;r&&(n=this._getCallbacksKey(t,e),this._callbacks[n]&&g.pull(this._callbacks[n],r))},Z.prototype._removeCallbacks=function(r,t){var n=this;g.forEach(t,function(t,e){n._removeCallback(e,r,t)})},Z.prototype._getCallbacks=function(t,e,r){return[].concat(this._callbacks[this._getCallbacksKey(t,r)]||G,this._callbacks[this._getCallbacksKey(t,e)]||G,this._callbacks[this._getCallbacksKey(t,"all")]||G)},Z.prototype._getCallbacksKey=function(t,e){return t+"_"+e},Z.prototype.execute=function(t,e,r,n,i){var o=this;i=L(i);var s=this.createOperation(t,e,r,n);return this.begin(s).then(function(){var e=function(){return i().catch(function(t){return o._retryOrEnd(s,t).then(e)})};return e()}).then(function(t){return o.end(s).then(function(){return t})})},Z.prototype.createOperation=function(t,e,r,n){return new Y(t,e,r,n)},Z.prototype.begin=function(e){var r=this;return Promise.all(g.map(this._getCallbacks("onBefore",e.type,e.method),function(t){return t(e)})).then(function(){e.ended||e._setRunning(!0)},function(t){return r.end(e,t)})},Z.prototype.markReady=function(t){t._markReady()},Z.prototype.clearReady=function(t){t._clearReady()},Z.prototype.retry=function(r,e){return r._incrementTries(),r._error=e,Promise.all(g.map(this._getCallbacks("onError",r.type,r.method),function(t){return t(r,e)})).then(function(t){if(!r.ended){var e=g.some(t);return e&&delete r._error,e}})},Z.prototype._retryOrEnd=function(e,r){var n=this;return this.retry(e,r).then(function(t){if(!t)return n.end(e,r)},function(t){return n.end(e,t)})},Z.prototype.end=function(e,t){var r=this;return e.ended?Promise.resolve():(e._setRunning(!1),e._setEnded(!0),t?e._error=t:delete e._error,Promise.all(g.map(this._getCallbacks("onAfter",e.type,e.method),function(t){return t(e)})).then(function(){return r._afterEnd(e)},function(t){return e._error=t,r._afterEnd(e)}))},Z.prototype._afterEnd=function(e){if(e._markReady(!0),!e.error)return Promise.resolve();var t=this._getCallbacks("onFailure",e.type,e.method);return t&&setTimeout(function(){g.forEach(t,function(t){return t(e)})},0),Promise.reject(e.error)};function tt(){this._lastUniqueKeyTime=0,this._lastRandomValues=[]}var et="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",rt=window.crypto&&window.crypto.getRandomValues&&window.crypto.getRandomValues.bind(window.crypto);tt.prototype.generateUniqueKey=function(t){t=t||Date.now();for(var e=new Array(20),r=t,n=7;0<=n;n--)e[n]=et.charAt(63&r),r=Math.floor(r/64);if(t===this._lastUniqueKeyTime){for(var i=11;0<=i&&63===this._lastRandomValues[i];)this._lastRandomValues[i]=0,--i;if(-1===i)throw new Error("Internal assertion failure: ran out of unique IDs for this millisecond");this._lastRandomValues[i]+=1}else if(this._lastUniqueKeyTime=t,rt){var o=new Uint8Array(12);rt(o);for(var s=0;s<12;s++)this._lastRandomValues[s]=o[s]&(s?63:15)}else for(var a=0;a<12;a++)this._lastRandomValues[a]=Math.floor(Math.random()*(a?64:16));for(var u=0;u<12;u++)e[u+8]=et[this._lastRandomValues[u]];return e.join("")};function nt(t,e,r,n){this._rootUrl=t,this._tree=e,this._dispatcher=n,this._bridge=r,this._vue=new c({data:{$root:{connected:void 0,timeOffset:0,user:void 0,userid:void 0,nowAtInterval:function(t){var e,r=this,n="now"+t;return this.hasOwnProperty(n)||((e=function(){c.set(r,n,Date.now()+r.timeOffset),f.digest()})(),setInterval(e,t)),this[n]}}}}),this._auth={serial:0,initialAuthChangeReceived:!1},r.onAuth(t,this._handleAuthChange,this),this._connectInfoProperty("serverTimeOffset","timeOffset"),this._connectInfoProperty("connected","connected"),Object.freeze(this)}var it={root:{configurable:!0}};it.root.get=function(){return this._vue.$data.$root},nt.prototype.destroy=function(){this._bridge.offAuth(this._rootUrl,this._handleAuthChange,this),this._vue.$destroy()},nt.prototype.authenticate=function(t){var e=this;return this._auth.serial++,this._dispatcher.execute("auth","authenticate",new C(this._tree,"/"),t,function(){return t?e._bridge.authWithCustomToken(e._rootUrl,t):e._bridge.authAnonymously(e._rootUrl)})},nt.prototype.unauthenticate=function(){var e=this;return this._auth.serial++,this._handleAuthChange(null).then(function(t){if(t)return e._dispatcher.execute("auth","unauthenticate",new C(e._tree,"/"),void 0,function(){return e._bridge.unauth(e._rootUrl)})})},nt.prototype._handleAuthChange=function(t){var e=this,r=!this._auth.initialAuthChangeReceived&&this._auth.serial;if(void 0!==t&&(this._auth.initialAuthChangeReceived=!0),!r){var n=this._auth.serial;return this.root.user===t?Promise.resolve(!1):this._dispatcher.execute("auth","certify",new C(this._tree,"/"),t,function(){return e.root.user!==t&&n===e._auth.serial&&(t&&Object.freeze(t),e.root.user=t,e.root.userid=t&&t.uid,f.digest(),!0)})}},nt.prototype._isAuthChangeStale=function(t){return this.root.user===t},nt.prototype._connectInfoProperty=function(t,e){var r=this,n=this._rootUrl+"/.info/"+t;this._bridge.on(n,n,null,"value",function(t){r.root[e]=t.value,f.digest()})},Object.defineProperties(nt.prototype,it);function ot(){}var st,at,ut={$$$trussCheck:!0,__ob__:!0},ct={$meta:{configurable:!0},$store:{configurable:!0},$now:{configurable:!0},$$finalizers:{configurable:!0}};ct.$meta.get=function(){return this.$truss.meta},ct.$store.get=function(){return this.$truss.store},ct.$now.get=function(){return this.$truss.now},ot.prototype.$newKey=function(){return this.$truss.newKey()},ot.prototype.$intercept=function(t,e){var r=this;if(this.$destroyed)throw new Error("Object already destroyed");var n=this.$truss.intercept(t,e),i=function(){n(),g.pull(r.$$finalizers,i)};return this.$$finalizers.push(i),i},ot.prototype.$connect=function(t,e){var r=this;if(this.$destroyed)throw new Error("Object already destroyed");e||(e=t,t=void 0);var n=this.$truss.connect(t,function r(n,t){if(!t||t instanceof O)return t;return g.mapValues(t,function(t){if(t instanceof O)return t;if(g.isFunction(t)){var e=function(){return n.$$touchThis(),r(n,t.call(this))};return e.angularWatchSuppressed=!0,e}return r(n,t)})}(this,e)),i=n.destroy,o=function(){return g.pull(r.$$finalizers,o),i.call(n)};return this.$$finalizers.push(o),n.destroy=o,n},ot.prototype.$peek=function(t,e){var r=this;if(this.$destroyed)throw new Error("Object already destroyed");var n=H(this.$truss.peek(t,e),function(){g.pull(r.$$finalizers,n.cancel)});return this.$$finalizers.push(n.cancel),n},ot.prototype.$observe=function(t,e,r){var n=this;if(this.$destroyed)throw new Error("Object already destroyed");var i=this.$truss.observe(function(){return n.$$touchThis(),t.call(n)},e.bind(this),r),o=function(){i(),g.pull(n.$$finalizers,o)};return this.$$finalizers.push(o),o},ot.prototype.$when=function(t,e){var r=this;if(this.$destroyed)throw new Error("Object already destroyed");var n=this.$truss.when(function(){return r.$$touchThis(),t.call(r)},e);return H(n,function(){g.pull(r.$$finalizers,n.cancel)}),this.$$finalizers.push(n.cancel),n},ct.$$finalizers.get=function(){return Object.defineProperty(this,"$$finalizers",{value:[],writable:!1,enumerable:!1,configurable:!1}),this.$$finalizers},Object.defineProperties(ot.prototype,ct);function ht(){}var lt={$parent:{configurable:!0},$path:{configurable:!0},$truss:{configurable:!0},$ref:{configurable:!0},$refs:{configurable:!0},$key:{configurable:!0},$data:{configurable:!0},$hidden:{configurable:!0},$empty:{configurable:!0},$keys:{configurable:!0},$values:{configurable:!0},$ready:{configurable:!0},$overridden:{configurable:!0},$$initializers:{configurable:!0},$destroyed:{configurable:!0}};lt.$parent.get=function(){return st.$parent.value},lt.$path.get=function(){return st.$path.value},lt.$truss.get=function(){return Object.defineProperty(this,"$truss",{value:this.$parent.$truss}),this.$truss},lt.$ref.get=function(){return Object.defineProperty(this,"$ref",{value:new C(this.$truss._tree,this.$path)}),this.$ref},lt.$refs.get=function(){return this.$ref},lt.$key.get=function(){return Object.defineProperty(this,"$key",{value:d(this.$path.slice(this.$path.lastIndexOf("/")+1))}),this.$key},lt.$data.get=function(){return this},lt.$hidden.get=function(){return!1},lt.$empty.get=function(){return g.isEmpty(this.$data)},lt.$keys.get=function(){return g.keys(this.$data)},lt.$values.get=function(){return g.values(this.$data)},lt.$ready.get=function(){return this.$ref.ready},lt.$overridden.get=function(){return!1},ht.prototype.$nextTick=function(){var t=this;if(this.$destroyed)throw new Error("Object already destroyed");var e=this.$truss.nextTick();return H(e,function(){g.pull(t.$$finalizers,e.cancel)}),this.$$finalizers.push(e.cancel),e},ht.prototype.$freezeComputedProperty=function(){if(!g.isBoolean(at))throw new Error("Cannot freeze a computed property outside of its getter function");at=!0},ht.prototype.$set=function(t){return this.$ref.set(t)},ht.prototype.$update=function(t){return this.$ref.update(t)},ht.prototype.$override=function(t){return this.$ref.override(t)},ht.prototype.$commit=function(t,e){return this.$ref.commit(t,e)},ht.prototype.$$touchThis=function(){this.__ob__?this.__ob__.dep.depend():this.$parent?(this.$parent.hasOwnProperty("$data")?this.$parent.$data:this.$parent)[this.$key]:this.$store},lt.$$initializers.get=function(){return Object.defineProperty(this,"$$initializers",{value:[],writable:!1,enumerable:!1,configurable:!0}),this.$$initializers},lt.$destroyed.get=function(){return!1},Object.defineProperties(ht.prototype,lt),T(ot,ht),g.forEach(ht.prototype,function(t,e){Object.defineProperty(ht.prototype,e,{value:t,enumerable:!1,configurable:!1,writable:!1})});function pt(t){this.error=t}function ft(t){this.value=t}function dt(t){this._trie={Class:ht},this._debug=t,Object.freeze(this)}dt.prototype.init=function(t,e){var r=this;g.isPlainObject(t)&&(g.forEach(t,function(t,e){t.$trussMount||(t.$$trussMount=t.$$trussMount||[],t.$$trussMount.push(e))}),t=g.values(t),g.forEach(t,function(t){!t.$trussMount&&t.$$trussMount&&(t.$trussMount=t.$$trussMount,delete t.$$trussMount)})),t=g.uniq(t),g.forEach(t,function(t){return r._mountClass(t,e)}),this._decorateTrie(this._trie)},dt.prototype.destroy=function(){},dt.prototype._getMount=function(t,e,r){for(var n,i=0,o=v(t,!0);i<o.length;i+=1){var s=o[i],a=s?n.children&&(n.children[s]||!e&&n.children.$):this._trie;if(!a){if(!e)return;n.children=n.children||{},a=n.children[s]={Class:ht}}if(n=a,r&&r(n))break}return n},dt.prototype._findMount=function(t,e){if(t(e=e||this._trie))return e;for(var r=0,n=g.keys(e.children);r<n.length;r+=1){var i=n[r],o=this._findMount(t,e.children[i]);if(o)return o}},dt.prototype._decorateTrie=function(e){var r=this;g.forEach(e.children,function(t){r._decorateTrie(t),(t.local||t.localDescendants)&&(e.localDescendants=!0)})},dt.prototype._augmentClass=function(t){for(var e,r=t.prototype;r&&r.constructor!==Object;){for(var n=0,i=Object.getOwnPropertyNames(r);n<i.length;n+=1){var o=i[n],s=Object.getOwnPropertyDescriptor(r,o);if("$"===o.charAt(0)){if("$finalize"===o)continue;if(g.isEqual(s,Object.getOwnPropertyDescriptor(ht.prototype,o)))continue;throw new Error('Property names starting with "$" are reserved: '+t.name+"."+o)}!s.get||e&&e[o]||((e=e||{})[o]={name:o,fullName:r.constructor.name+"."+o,get:s.get,set:s.set})}r=Object.getPrototypeOf(r)}for(var a=0,u=Object.getOwnPropertyNames(ht.prototype);a<u.length;a+=1){var c=u[a];"constructor"===c||t.prototype.hasOwnProperty(c)||Object.defineProperty(t.prototype,c,Object.getOwnPropertyDescriptor(ht.prototype,c))}return e},dt.prototype._mountClass=function(a,u){var c=this,h=this._augmentClass(a),l=[],t=a.$trussMount;if(!t)throw new Error("Class "+a.name+" lacks a $trussMount static property");g.isArray(t)||(t=[t]),g.forEach(t,function(t){if(g.isString(t)&&(t={path:t}),!u&&"/"===t.path)throw new Error("Data root already accessed, too late to mount class");for(var e=b(t.path),r=0,n=e.variables;r<n.length;r+=1){var i=n[r];if("$"===i||"$"===i.charAt(1))throw new Error("Invalid variable name: "+i);if("$"===i.charAt(0)&&(g.has(ht.prototype,i)||ut[i]))throw new Error("Variable name conflicts with built-in property or method: "+i);l.push(i)}var o=t.path.match(/\/([^/]*)$/)[1];if("$"===o.charAt(0)){if(t.placeholder)throw new Error("Class "+a.name+" mounted at wildcard "+o+" cannot be a placeholder")}else g.has(t,"placeholder")||(t.placeholder={});var s=c._getMount(t.path.replace(/\$[^/]*/g,"$"),!0);if(s.matcher&&(s.escapedKey===o||"$"===s.escapedKey.charAt(0)&&"$"===o.charAt(0)))throw new Error("Multiple classes mounted at "+t.path+": "+s.Class.name+", "+a.name);g.assign(s,{Class:a,matcher:e,computedProperties:h,escapedKey:o},g.pick(t,"placeholder","local","keysUnsafe","hidden"))}),g.forEach(l,function(t){a.prototype[t]||Object.defineProperty(a.prototype,t,{get:function(){return st?st[t]&&st[t].value:void 0}})})},dt.prototype.createObject=function(t,e){var r=this,n=this._getMount(t)||{Class:ht};try{if(n.matcher){var i=n.matcher.match(t);for(var o in i)e[o]={value:i[o]}}st=e;var s=new n.Class;return st=null,f.active&&this._wrapProperties(s),n.keysUnsafe&&(e.$data={value:Object.create(null),configurable:!0,enumerable:!0}),n.hidden&&(e.$hidden={value:!0}),n.computedProperties&&g.forEach(n.computedProperties,function(t){e[t.name]=r._buildComputedPropertyDescriptor(s,t)}),s}catch(t){throw t.extra=g.assign({mount:n,properties:e,className:n.Class&&n.Class.name},t.extra),t}},dt.prototype._wrapProperties=function(i){g.forEach(i,function(t,e){var r,n="$_"+e;Object.defineProperties(i,((r={})[n]={value:t,writable:!0},r[e]={get:function(){return i[n]},set:function(t){i[n]=t,f.digest()},enumerable:!0,configurable:!0},r))})},dt.prototype._buildComputedPropertyDescriptor=function(s,a){var u,c,h=this,l=W.for(a.fullName),p=!1;return s.$$initializers.push(function(t){var e=!1,r=function(t,e){if(this.$destroyed)return;this.$$touchThis();var r=at;at=!1;var n,i=I();try{try{n=t.get.call(this)}catch(t){n=new pt(t)}finally{e.runtime+=I()-i,e.numRecomputes+=1}return at&&(n=new ft(n)),n}finally{at=r}}.bind(s,a,l);h._debug&&(r.toString=function(){return a.fullName});var n=function(){e=!0},n=t.$watch(r,function(t){if(s.$destroyed)n();else if(c&&(c.cancel&&c.cancel(),c=void 0),g.isObject(t)&&g.isFunction(t.then)){var e=t.then(function(t){e===c&&o(t)},function(t){if(e===c&&o(new pt(t))&&!t.trussExpectedException)throw t});c=e}else if(o(t)&&(f.digest(),t instanceof pt&&!t.error.trussExpectedException))throw t.error},{immediate:!0}),i=g.last(t._watchers);function o(t){return t instanceof ft&&(t=t.value,n(),g.pull(s.$$finalizers,n)),!R(u,t)&&(l.numUpdates+=1,p=!0,s[a.name]=t,p=!1,function e(t){if(g.isNil(t)||!g.isObject(t)||Object.isFrozen(t)||t.$truss)return t;t=Object.freeze(t);if(g.isArray(t))return g.map(t,function(t){return e(t)});return g.mapValues(t,function(t){return e(t)})}(t),1)}i.id=-i.id,e?n():s.$$finalizers.push(n)}),{enumerable:!0,configurable:!0,get:function(){if(!p&&u instanceof pt)throw u.error;return u},set:function(t){if(p)u=t;else{if(!a.set)throw new Error("You cannot set a computed property: "+a.name);a.set.call(this,t)}}}},dt.prototype.destroyObject=function(t){if(g.has(t,"$$finalizers"))for(var e=0,r=g.clone(t.$$finalizers);e<r.length;e+=1){(0,r[e])()}g.isFunction(t.$finalize)&&t.$finalize(),Object.defineProperty(t,"$destroyed",{value:!0,enumerable:!1,configurable:!1})},dt.prototype.isPlaceholder=function(t){var e=this._getMount(t);return e&&e.placeholder},dt.prototype.isLocal=function(t,e){var r=this._getMount(t,!1,function(t){return t.local});if(r&&r.local)return!0;if(this._hasLocalProperties(r,e))throw new Error("Write on a mix of local and remote tree paths.");return!1},dt.prototype._hasLocalProperties=function(t,e){if(!t)return!1;if(t.local)return!0;if(!t.localDescendants||!g.isObject(e))return!1;for(var r in e){if(this._hasLocalProperties(t.children[p(r)]||t.children.$,e[r]))return!0}return!1},dt.prototype.forEachPlaceholderChild=function(t,e){var r=this._getMount(t);g.forEach(r&&r.children,function(t){t.placeholder&&e(t)})},dt.prototype.checkVueObject=function(e,t,r){var n=!r;n&&(r=[]);try{for(var i=0,o=Object.getOwnPropertyNames(e);i<o.length;i+=1){var s=o[i];if(!(ut[s]||ht.prototype.hasOwnProperty(s)||/^\$_/.test(s))){var a=this._findMount(function(t){return t.Class===e.constructor});if(!(a&&a.matcher&&g.includes(a.matcher.variables,s))){var u=void 0;try{u=e[s]}catch(t){continue}if(!g.isArray(e)||!/\d+/.test(s)&&"length"!==s){var c=Object.getOwnPropertyDescriptor(e,s);if("value"in c||!c.get)throw new Error("Value at "+t+", contained in a Firetruss object, has a rogue property: "+s);if(e.$truss&&c.enumerable)try{throw e[s]=u,new Error("Firetruss object at "+t+" has an enumerable non-Firebase property: "+s)}catch(t){if("firebase_overwrite"!==t.trussCode)throw t}}g.isObject(u)&&!u.$$$trussCheck&&Object.isExtensible(u)&&!(g.isFunction(u)||u instanceof Promise)&&(u.$$$trussCheck=!0,r.push(u),this.checkVueObject(u,y(t,p(s)),r))}}}}finally{if(n)for(var h=0,l=r;h<l.length;h+=1){delete l[h].$$$trussCheck}}};function _t(t,e){this._coupler=t,this._query=e,this._listeners=[],this._keys=[],this._url=this._coupler._rootUrl+e.path,this._segments=v(e.path,!0),this._listening=!1,this.ready=!1}_t.prototype.attach=function(t,e){this._listen(),this._listeners.push({operation:t,keysCallback:e}),e&&e(this._keys)},_t.prototype.detach=function(t){var e=g.findIndex(this._listeners,{operation:t});return 0<=e&&this._listeners.splice(e,1),this._listeners.length},_t.prototype._listen=function(){this._listening||(this._coupler._bridge.on(this._query.toString(),this._url,this._query.constraints,"value",this._handleSnapshot,this._handleError,this,{sync:!0}),this._listening=!0)},_t.prototype.destroy=function(){this._coupler._bridge.off(this._query.toString(),this._url,this._query.constraints,"value",this._handleSnapshot,this),this._listening=!1,this.ready=!1,f.digest();for(var t=0,e=this._keys;t<e.length;t+=1){var r=e[t];this._coupler._decoupleSegments(this._segments.concat(r))}},_t.prototype._handleSnapshot=function(a){var u=this;this._coupler._queueSnapshotCallback(function(){if(u._listeners.length&&u._listening){var t=u._updateKeys(a);if(u._coupler._applySnapshot(a),!u.ready){u.ready=!0,f.digest();for(var e=0,r=u._listeners;e<r.length;e+=1){var n=r[e];u._coupler._dispatcher.markReady(n.operation)}}if(t)for(var i=0,o=u._listeners;i<o.length;i+=1){var s=o[i];s.keysCallback&&s.keysCallback(t)}}})},_t.prototype._updateKeys=function(t){var e,r;if(t.path===this._query.path)if((e=g.keys(t.value)).sort(),g.isEqual(this._keys,e))e=null;else{for(var n=0,i=g.difference(e,this._keys);n<i.length;n+=1){var o=i[n];this._coupler._coupleSegments(this._segments.concat(o))}for(var s=0,a=g.difference(this._keys,e);s<a.length;s+=1){var u=a[s];this._coupler._decoupleSegments(this._segments.concat(u))}this._keys=e}else t.path.replace(/\/[^/]+/,"")===this._query.path&&(r=g.includes(this._keys,t.key),t.value?r||(this._coupler._coupleSegments(this._segments.concat(t.key)),this._keys.push(t.key),this._keys.sort(),e=this._keys):r&&(this._coupler._decoupleSegments(this._segments.concat(t.key)),g.pull(this._keys,t.key),this._keys.sort(),e=this._keys));return e},_t.prototype._handleError=function(n){var i=this;this._listeners.length&&this._listening&&(this._listening=!1,this.ready=!1,f.digest(),Promise.all(g.map(this._listeners,function(e){return i._coupler._dispatcher.clearReady(e.operation),i._coupler._dispatcher.retry(e.operation,n).catch(function(t){return e.operation._disconnect(t),!1})})).then(function(t){if(g.some(t))i._listeners.length&&i._listen();else for(var e=0,r=i._listeners;e<r.length;e+=1){r[e].operation._disconnect(n)}}))};function yt(t,e,r){this._coupler=t,this.path=e,this.parent=r,this.url=this._coupler._rootUrl+e,this.operations=[],this.queryCount=0,this.listening=!1,this.ready=!1,this.children={}}var gt={active:{configurable:!0},count:{configurable:!0}};gt.active.get=function(){return this.count||this.queryCount},gt.count.get=function(){return this.operations.length},yt.prototype.listen=function(t){var e=this;if(!t&&this.count){if(this.listening)return;g.forEach(this.operations,function(t){e._coupler._dispatcher.clearReady(t)}),this._coupler._bridge.on(this.url,this.url,null,"value",this._handleSnapshot,this._handleError,this,{sync:!0}),this.listening=!0}else g.forEach(this.children,function(t){t.listen()})},yt.prototype.unlisten=function(t){!t&&this.listening?(this._coupler._bridge.off(this.url,this.url,null,"value",this._handleSnapshot,this),this.listening=!1,this._forAllDescendants(function(t){return!t.listening&&void(t.ready&&(t.ready=!1,f.digest()))})):g.forEach(this.children,function(t){t.unlisten()})},yt.prototype._handleSnapshot=function(t){var i=this;this._coupler._queueSnapshotCallback(function(){i.listening&&i._coupler.isTrunkCoupled(t.path)&&(i._coupler._applySnapshot(t),i.ready||t.path!==i.path||(i.ready=!0,f.digest(),i.unlisten(!0),i._forAllDescendants(function(t){for(var e=0,r=t.operations;e<r.length;e+=1){var n=r[e];i._coupler._dispatcher.markReady(n)}})))})},yt.prototype._handleError=function(n){var i=this;if(this.count&&this.listening)return this.listening=!1,this._forAllDescendants(function(t){if(t.listening)return!1;t.ready&&(t.ready=!1,f.digest());for(var e=0,r=t.operations;e<r.length;e+=1){var n=r[e];i._coupler._dispatcher.clearReady(n)}}),Promise.all(g.map(this.operations,function(e){return i._coupler._dispatcher.retry(e,n).catch(function(t){return e._disconnect(t),!1})})).then(function(t){if(g.some(t))i.count&&i.listen();else for(var e=0,r=i.operations;e<r.length;e+=1){r[e]._disconnect(n)}})},yt.prototype._forAllDescendants=function(e){!1!==e(this)&&g.forEach(this.children,function(t){return t._forAllDescendants(e)})},yt.prototype.collectCoupledDescendantPaths=function(e){return(e=e||{})[this.path]=this.active,this.active||g.forEach(this.children,function(t){t.collectCoupledDescendantPaths(e)}),e},Object.defineProperties(yt.prototype,gt);function vt(t,e,r,n,i){this._rootUrl=t,this._bridge=e,this._dispatcher=r,this._applySnapshot=n,this._pendingSnapshotCallbacks=[],this._throttled={processPendingSnapshots:this._processPendingSnapshots},this._prunePath=i,this._vue=new c({data:{root:void 0,queryHandlers:{}}}),this._vue._renderProxy=this._vue,this._nodeIndex=Object.create(null),Object.freeze(this),this._vue.$data.root=new yt(this,"/"),this._nodeIndex["/"]=this._root}var bt={_root:{configurable:!0},_queryHandlers:{configurable:!0}};bt._root.get=function(){return this._vue.$data.root},bt._queryHandlers.get=function(){return this._vue.$data.queryHandlers},vt.prototype.destroy=function(){g.forEach(this._queryHandlers,function(t){t.destroy()}),this._root.unlisten(),this._vue.$destroy()},vt.prototype.couple=function(t,e){return this._coupleSegments(v(t,!0),e)},vt.prototype._coupleSegments=function(t,e){for(var r,n=!e,i=!1,o=0,s=t;o<s.length;o+=1){var a=s[o],u=a?r.children&&r.children[a]:this._root;u||(u=new yt(this,("/"===r.path?"":r.path)+"/"+a,r),c.set(r.children,a,u),this._nodeIndex[u.path]=u),n=n||u.listening,i=i||u.ready,r=u}e?r.operations.push(e):r.queryCount++,n?e&&i&&this._dispatcher.markReady(e):r.listen()},vt.prototype.decouple=function(t,e){return this._decoupleSegments(v(t,!0),e)},vt.prototype._decoupleSegments=function(t,e){for(var r=[],n=0,i=t;n<i.length;n+=1){var o,s=i[n];if(!(o=s?o.children&&o.children[s]:this._root))break;r.push(o)}if(!o||!(e?o.count:o.queryCount))throw new Error("Path not coupled: "+(t.join("/")||"/"));if(e?g.pull(o.operations,e):o.queryCount--,e&&!o.count&&(o.listen(),o.listening&&o.unlisten()),!o.active){for(var a=r.length-1;0<a&&((o=r[a])!==this._root&&!o.active&&g.isEmpty(o.children));a--)c.delete(r[a-1].children,t[a]),o.ready=void 0,delete this._nodeIndex[o.path];var u=t.join("/")||"/";this._prunePath(u,this.findCoupledDescendantPaths(u))}},vt.prototype.subscribe=function(t,e,r){var n=this._queryHandlers[t.toString()];n||(n=new _t(this,t),c.set(this._queryHandlers,t.toString(),n)),n.attach(e,r)},vt.prototype.unsubscribe=function(t,e){var r=this._queryHandlers[t.toString()];r&&!r.detach(e)&&(r.destroy(),c.delete(this._queryHandlers,t.toString()))},vt.prototype.isTrunkCoupled=function(t){for(var e=0,r=v(t,!0);e<r.length;e+=1){var n,i=r[e];if(!(n=i?n.children&&n.children[i]:this._root))return!1;if(n.active)return!0}return!1},vt.prototype.findCoupledDescendantPaths=function(t){for(var e,r=0,n=v(t,!0);r<n.length;r+=1){var i,o=n[r];if((i=o?i.children&&i.children[o]:this._root)&&i.active)return(e={})[t]=i.active,e;if(!i)break}return i&&i.collectCoupledDescendantPaths()},vt.prototype.isSubtreeReady=function(t){var e,r;function n(t){return r=t.slice(1),""}for(;!(e=this._nodeIndex[t]);)t=t.replace(/\/[^/]*$/,n)||"/";for(r&&e.children;e;){if(e.ready)return!0;e=e.parent}return!1},vt.prototype.isQueryReady=function(t){var e=this._queryHandlers[t.toString()];return e&&e.ready},vt.prototype._queueSnapshotCallback=function(t){this._pendingSnapshotCallbacks.push(t),this._throttled.processPendingSnapshots.call(this)},vt.prototype._processPendingSnapshots=function(){for(var t=0,e=this._pendingSnapshotCallbacks;t<e.length;t+=1){(0,e[t])()}this._pendingSnapshotCallbacks.splice(0,1/0)},vt.prototype.throttleSnapshots=function(t){this._throttled.processPendingSnapshots=t?g.throttle(this._processPendingSnapshots,t):this._processPendingSnapshots},Object.defineProperties(vt.prototype,bt);function mt(t){this._ref=t,this._outcome=void 0,this._values=void 0}var wt={currentValue:{configurable:!0},outcome:{configurable:!0},values:{configurable:!0}};wt.currentValue.get=function(){return this._ref.value},wt.outcome.get=function(){return this._outcome},wt.values.get=function(){return this._values},mt.prototype._setOutcome=function(t){if(this._outcome)throw new Error("Transaction already resolved with "+this._outcome);this._outcome=t},mt.prototype.abort=function(){this._setOutcome("abort")},mt.prototype.cancel=function(){this._setOutcome("cancel")},mt.prototype.set=function(t){if(void 0===t)throw new Error("Invalid argument: undefined");this._setOutcome("set"),this._values={"":t}},mt.prototype.update=function(t){if(void 0===t)throw new Error("Invalid argument: undefined");if(g.isEmpty(t))return this.cancel();this._setOutcome("update"),this._values=t},Object.defineProperties(mt.prototype,wt);function $t(t,e,r,n){this._truss=t,this._rootUrl=e,this._bridge=r,this._dispatcher=n,this._firebasePropertyEditAllowed=!1,this._writeSerial=0,this._localWrites={},this._localWriteTimestamp=null,this._initialized=!1,this._modeler=new dt("dev"===t.constructor.VERSION),this._coupler=new vt(e,r,n,this._integrateSnapshot.bind(this),this._prune.bind(this)),this._vue=new c({data:{$root:void 0}}),Object.seal(this)}var kt,Pt,Ot={root:{configurable:!0},truss:{configurable:!0}};function Et(r,n){g.forEach(g.keys(n),function(t){if("/"===t.charAt(0)){if(!(t===r||"/"===r||g.startsWith(t,r+"/")&&t.length>r.length+1))throw new Error("Update item is not a descendant of target ref: "+t)}else{if(g.includes(t,"/"))throw new Error("Update item deep path must be absolute, taken from a reference: "+t);var e=y(r,p(t));if(n.hasOwnProperty(e))throw new Error("Update items overlap: "+t+" and "+e);n[e]=n[t],delete n[t]}});var o=g(n).keys().map(function(t){return y(t,"")}).sortBy("length").value();g.forEach(n,function(t,e){for(var r=0,n=o;r<n.length;r+=1){var i=n[r];if(i.length>e.length)break;if(e!==i&&g.startsWith(e,i))throw new Error("Update items overlap: "+i+" and "+e)}})}function jt(t,e){var r="/"===t?1:t.length+1;g.forEach(g.keys(e),function(t){e[t.slice(r)]=e[t],delete e[t]})}function Ct(t){if(!g.isObject(t))return t;var e={},r=t.$data;for(var n in r)r.hasOwnProperty(n)&&(e[p(n)]=Ct(r[n]));return e}Ot.root.get=function(){return this._vue.$data.$root||(this._vue.$data.$root=this._createObject("/"),this._fixObject(this._vue.$data.$root),this._completeCreateObject(this._vue.$data.$root),f.digest()),this._vue.$data.$root},Ot.truss.get=function(){return this._truss},$t.prototype.init=function(t){if(this._initialized)throw new Error("Data objects already created, too late to mount classes");this._initialized=!0,this._modeler.init(t,!this._vue.$data.$root);var e=[];this._plantPlaceholders(this.root,"/",void 0,e);for(var r=0,n=e;r<n.length;r+=1){var i=n[r];this._completeCreateObject(i)}},$t.prototype.destroy=function(){this._coupler.destroy(),this._modeler&&this._modeler.destroy(),this._vue.$destroy()},$t.prototype.connectReference=function(t,e){var r=this;this._checkHandle(t);var n=this._dispatcher.createOperation("read",e,t);return n._disconnect=this._disconnectReference.bind(this,t,n,void 0),this._dispatcher.begin(n).then(function(){n.running&&!n._disconnected&&(r._coupler.couple(t.path,n),n._coupled=!0)}).catch(g.noop),n._disconnect},$t.prototype._disconnectReference=function(t,e,r,n){e._disconnected||(e._disconnected=!0,r&&r(),e._coupled&&(this._coupler.decouple(t.path,e),e._coupled=!1),this._dispatcher.end(e,n).catch(g.noop))},$t.prototype.isReferenceReady=function(t){return this._checkHandle(t),this._coupler.isSubtreeReady(t.path)},$t.prototype.connectQuery=function(t,e,r){var n=this;this._checkHandle(t);var i=this._dispatcher.createOperation("read",r,t);return i._disconnect=this._disconnectQuery.bind(this,t,i),this._dispatcher.begin(i).then(function(){i.running&&!i._disconnected&&(n._coupler.subscribe(t,i,e),i._coupled=!0)}).catch(g.noop),i._disconnect},$t.prototype._disconnectQuery=function(t,e,r){e._disconnected||(e._disconnected=!0,e._coupled&&(this._coupler.unsubscribe(t,e),e._coupled=!1),this._dispatcher.end(e,r).catch(g.noop))},$t.prototype.isQueryReady=function(t){return this._coupler.isQueryReady(t)},$t.prototype._checkHandle=function(t){if(!t.belongsTo(this._truss))throw new Error("Reference belongs to another Truss instance")},$t.prototype.throttleRemoteDataUpdates=function(t){this._coupler.throttleSnapshots(t)},$t.prototype.update=function(e,t,r){var n=this;r=g.mapValues(r,_);var i=g.size(r);if(!i)return Promise.resolve();if("update"!==t&&"override"!==t||Et(e.path,r),this._applyLocalWrite(r,"override"===t))return Promise.resolve();var o,s,a=(o=r,g.forEach(o,function(t,e){var r="/"===e?[""]:v(e,!0);if(s){for(var n=0,i=Math.min(s.length,r.length);n<i&&s[n]===r[n];)n++;if(!(s=s.slice(0,n)).length)return!1}else s=r}),1===s.length?"/":s.join("/"));jt(a,r),a!==e.path&&(e=new C(e._tree,a,e._annotations));var u=this._rootUrl+a,c=this._writeSerial,h=1===i,l=h?r[""]:r;return this._dispatcher.execute("write",h?"set":"update",e,l,function(){return n._bridge[h?"set":"update"](u,l,c).catch(function(t){return t.immediateFailure?H(n._repair(e,r),function(){return Promise.reject(t)}):Promise.reject(t)})})},$t.prototype.commit=function(i,t){var o=this,e=0;t=L(t);var s=function(){if(25<=e++)return Promise.reject(new Error("Transaction needed too many retries, giving up"));var r,n=new mt(i);return c.nextTick().then(function(){return r=Ct(n.currentValue),t(n)}).then(function(){var t;if(!g.isEqual(r,Ct(n.currentValue)))return s();if("abort"===n.outcome)return n;var e=g.mapValues(n.values,_);switch(n.outcome){case"cancel":break;case"set":if(o._applyLocalWrite(((t={})[i.path]=e[""],t)))return Promise.resolve();break;case"update":if(Et(i.path,e),o._applyLocalWrite(e))return Promise.resolve();jt(i.path,e);break;default:throw new Error("Invalid transaction outcome: "+(n.outcome||"none"))}return o._bridge.transaction(o._rootUrl+i.path,r,e,o._writeSerial).then(function(t){return g.forEach(t.snapshots,function(t){return o._integrateSnapshot(t)}),t.committed?n:s()},function(t){return!t.immediateFailure||"set"!==n.outcome&&"update"!==n.outcome?Promise.reject(t):H(o._repair(i,e),function(){return Promise.reject(t)})})})};return this._truss.peek(i,function(){return o._dispatcher.execute("write","commit",i,void 0,s)})},$t.prototype._repair=function(t,e){var r=this,n=t.path,i=g(e).keys().flatMap(function(t){var e=n;return t&&(e=y(e,t)),g.keys(r._coupler.findCoupledDescendantPaths(e))}).value();return Promise.all(g.map(i,function(t){return r._bridge.once(r._rootUrl+t).then(function(t){r._integrateSnapshot(t)})}))},$t.prototype._applyLocalWrite=function(t,f){var d=this;this._writeSerial++,this._localWriteTimestamp=this._truss.now;var _=[],y=0;g.forEach(t,function(t,e){var r,n=d._modeler.isLocal(e,t);n&&y++;var i=n?((r={})[e]=!0,r):d._coupler.findCoupledDescendantPaths(e);if(!g.isEmpty(i)){var o=("/"===e?0:e.length)+1;for(var s in i){var a,u=s.slice(o),c=t;if(u&&null!=t)for(var h=0,l=v(u);h<l.length;h+=1){var p=l[h];if(void 0===(c=c.$data[p]))break}g.isNil(c)?d._prune(s):(a=g.last(v(s)),d._plantValue(s,a,c,d._scaffoldAncestors(s,!1,_),!1,f,n,_)),f||n||(d._localWrites[s]=d._writeSerial)}}});for(var e=0,r=_;e<r.length;e+=1){var n=r[e];this._completeCreateObject(n)}if(y&&y<g.size(t))throw new Error("Write on a mix of local and remote tree paths.");return f||!!y},$t.prototype._createObject=function(t,e){this._initialized||"/"===t||this.init();var r={$parent:{value:e,configurable:!0,enumerable:!0},$path:{value:t}};"/"===t&&(r.$truss={value:this._truss});var n=this._modeler.createObject(t,r);return Object.defineProperties(n,r),n},$t.prototype._fixObject=function(t){for(var e=0,r=Object.getOwnPropertyNames(t);e<r.length;e+=1){var n=r[e],i=Object.getOwnPropertyDescriptor(t,n);i.configurable&&i.enumerable&&(i.enumerable=!1,g.startsWith(n,"$")&&(i.configurable=!1),Object.defineProperty(t,n,i))}},$t.prototype._completeCreateObject=function(t){if(t.hasOwnProperty("$$initializers")){for(var e=0,r=t.$$initializers;e<r.length;e+=1){(0,r[e])(this._vue)}delete t.$$initializers}},$t.prototype._destroyObject=function(t){if(t&&t.$truss&&!t.$destroyed){this._modeler.destroyObject(t);for(var e=0,r=Object.getOwnPropertyNames(t.$data);e<r.length;e+=1){var n=r[e],i=t.$data[n];i&&i.$parent===t&&this._destroyObject(i)}}},$t.prototype._integrateSnapshot=function(r){var n=this;if(g.forEach(this._localWrites,function(t,e){r.writeSerial>=t&&delete n._localWrites[e]}),r.exists){var t=[],e=this._scaffoldAncestors(r.path,!0,t);e&&this._plantValue(r.path,r.key,r.value,e,!0,!1,!1,t);for(var i=0,o=t;i<o.length;i+=1){var s=o[i];this._completeCreateObject(s)}}else this._prune(r.path,null,!0)},$t.prototype._scaffoldAncestors=function(t,e,r){for(var n,i=g.dropRight(v(t,!0)),o="/",s=0;s<i.length;s++){var a=i[s],u=d(a),c=a?n.$data[u]:this.root;if(a&&(o+=("/"===o?"":"/")+a),c){if(e&&this._localWrites[o])return}else if(!(c=this._plantValue(o,u,{},n,e,!1,!1,r)))return;n=c}return n},$t.prototype._plantValue=function(n,t,i,e,o,r,s,a){var u=this;if(o&&g.isNil(i))throw new Error("Snapshot includes invalid value at "+n+": "+i);if(!o||!this._localWrites[n||"/"]){g.isEqual(i,S)&&(i=this._localWriteTimestamp);var c=e.$data[t];if(!g.isArray(i)&&!(s?g.isPlainObject(i):g.isObject(i)))return this._destroyObject(c),void(!s&&g.isNil(i)?this._deleteFirebaseProperty(e,t):this._setFirebaseProperty(e,t,i));var h=!1;return g.isObject(c)||(this._setFirebaseProperty(e,t,null),c=this._createObject(n,e),this._setFirebaseProperty(e,t,c,c.$hidden),this._fixObject(c),a.push(c),h=!0),r?Object.defineProperty(c,"$overridden",{get:g.constant(!0),configurable:!0}):c.$overridden&&delete c.$overridden,h&&this._plantPlaceholders(c,n,!0,a),g.forEach(i,function(t,e){u._plantValue(y(n,e),d(e),t,c,o,r,s,a)}),h?this._plantPlaceholders(c,n,!1,a):g.forEach(c.$data,function(t,e){var r=p(e);i.hasOwnProperty(r)||u._prune(y(n,r),null,o)}),c}},$t.prototype._plantPlaceholders=function(r,n,i,o){var s=this;this._modeler.forEachPlaceholderChild(n,function(t){var e;void 0!==i&&i!==!!t.hidden||(e=d(t.escapedKey),r.$data.hasOwnProperty(e)||s._plantValue(y(n,t.escapedKey),e,t.placeholder,r,!1,!1,!1,o))})},$t.prototype._prune=function(t,e,r){e=e||{};var n=this.getObject(t);void 0!==n&&(r&&this._avoidLocalWritePaths(t,e)||g.isEmpty(e)&&this._pruneAncestors(t,n)||!g.isObject(n)||this._pruneDescendants(n,e))},$t.prototype._avoidLocalWritePaths=function(t,e){for(var r in this._localWrites)if(this._localWrites.hasOwnProperty(r)){if(t===r||"/"===r||g.startsWith(t,r+"/"))return!0;if("/"===t||g.startsWith(r,t+"/"))for(var n=v(r,!0),i=n.length;0<i;i--){var o=n.slice(0,i).join("/"),s=i===n.length;if(e[o]||e[o]===s)break;if(e[o]=s,o===t)break}}},$t.prototype._pruneAncestors=function(t,e){for(var r,n=!1,i=e,o=t.replace(/\/[^/]+$/,function(t){return r=d(t.slice(1)),""});void 0!==i&&i!==this.root;){var s,a=i&&i.$parent||i===e&&this.getObject(o);this._modeler.isPlaceholder(i&&i.$path||t)||(s=n?null:[e],this._holdsConcreteData(i,s)||(n=!0,this._deleteFirebaseProperty(a,i&&i.$key||i===e&&r))),i=a}return n},$t.prototype._holdsConcreteData=function(t,e){var r=this;return!g.isNil(t)&&((!e||!g.includes(e,t))&&(!g.isObject(t)||!t.$truss||g.some(t.$data,function(t){return r._holdsConcreteData(t,e)})))},$t.prototype._pruneDescendants=function(o,s){var a=this;if(s[o.$path])return!0;o.$overridden&&delete o.$overridden;var u=!1;return g.forEach(o.$data,function(t,e){var r,n,i=!0;s[y(o.$path,p(e))]?r=!(i=!1):g.isNil(t)||!t.$truss||((n=a._modeler.isPlaceholder(t.$path))||g.has(s,t.$path))&&(r=a._pruneDescendants(t,s),i=!n&&!r),i&&a._deleteFirebaseProperty(o,e),u=u||r}),u},$t.prototype.getObject=function(t){for(var e=0,r=v(t);e<r.length;e+=1){var n,i=r[e];if(void 0===(n=i?n.$data[i]:this.root))return}return n},$t.prototype._getFirebasePropertyDescriptor=function(t,e,r){var n=Object.getOwnPropertyDescriptor(e,r);if(n){if(!n.enumerable){var i=e[r];if(!i||i.$parent!==t)throw new Error("Key conflict between Firebase and instance or computed properties at "+t.$path+": "+r)}if(!n.get||!n.set)throw new Error("Unbound property at "+t.$path+": "+r)}else if(r in e)throw new Error("Key conflict between Firebase and inherited property at "+t.$path+": "+r);return n},$t.prototype._setFirebaseProperty=function(t,e,r,n){var i=t.hasOwnProperty("$data")?t.$data:t,o=this._getFirebasePropertyDescriptor(t,i,e);if(o){if(n&&Object.defineProperty(i,e,{get:o.get,set:o.set,configurable:!0,enumerable:!1}),i[e]===r)return;this._firebasePropertyEditAllowed=!0,i[e]=r,this._firebasePropertyEditAllowed=!1}else c.set(i,e,r),o=Object.getOwnPropertyDescriptor(i,e),Object.defineProperty(i,e,{get:o.get,set:this._overwriteFirebaseProperty.bind(this,o,e),configurable:!0,enumerable:!n});f.digest()},$t.prototype._overwriteFirebaseProperty=function(t,e,r){if(!this._firebasePropertyEditAllowed){var n=new Error("Firebase data cannot be mutated directly: "+e);throw n.trussCode="firebase_overwrite",n}t.set.call(this,r)},$t.prototype._deleteFirebaseProperty=function(t,e){var r=t.hasOwnProperty("$data")?t.$data:t;this._getFirebasePropertyDescriptor(t,r,e),this._destroyObject(r[e]),c.delete(r,e),f.digest()},$t.prototype.checkVueObject=function(t,e){this._modeler.checkVueObject(t,e)},Object.defineProperties($t.prototype,Ot);function St(t){if(!kt)throw new Error("Truss worker not connected, please call Truss.connectWorker first");this._rootUrl=t.replace(/\/$/,""),this._keyGenerator=new tt,this._dispatcher=new Z(kt),this._vue=new c,kt.trackServer(this._rootUrl),this._tree=new $t(this,this._rootUrl,kt,this._dispatcher),this._metaTree=new nt(this._rootUrl,this._tree,kt,this._dispatcher),Object.freeze(this)}var Rt={},xt={meta:{configurable:!0},store:{configurable:!0},now:{configurable:!0},SERVER_TIMESTAMP:{configurable:!0},VERSION:{configurable:!0},FIREBASE_SDK_VERSION:{configurable:!0}},Tt={computedPropertyStats:{configurable:!0},worker:{configurable:!0}};return xt.meta.get=function(){return this._metaTree.root},xt.store.get=function(){return this._tree.root},St.prototype.mount=function(t){this._tree.init(t)},St.prototype.destroy=function(){this._vue.$destroy(),this._tree.destroy(),this._metaTree.destroy()},xt.now.get=function(){return Date.now()+this.meta.timeOffset},St.prototype.newKey=function(){return this._keyGenerator.generateUniqueKey(this.now)},St.prototype.authenticate=function(t){return this._metaTree.authenticate(t)},St.prototype.unauthenticate=function(){return this._metaTree.unauthenticate()},St.prototype.intercept=function(t,e){return this._dispatcher.intercept(t,e)},St.prototype.connect=function(t,e){return e||(e=t,t=void 0),e instanceof O&&(e={_:e}),new F(t,e,this._tree,"connect")},St.prototype.peek=function(a,u){var c,h,l=this;return u=L(u||g.identity),Q(Promise.resolve().then(function(){return new Promise(function(e,n){var r,i={},t=new F(i,{result:a},l._tree,"peek"),o=l.intercept("peek",{onFailure:function(r){!function t(e){if(e)return e instanceof O?r.target.isEqual(e):g.some(e,t)}(t.at)||(n(r.error),c())}}),s=l.observe(function(){return t.ready},function(t){t&&(s(),s=null,r=H(u(i.result),function(){f.digest(),r=null,c()}).then(function(t){e(t)},function(t){n(t)}))});c=function(){s&&(s(),s=null),o&&(o(),o=null),t&&(t.destroy(),t=null),r&&r.cancel&&r.cancel()},h=function(){n(new Error("Canceled")),c()}})}),h)},St.prototype.observe=function(t,n,i){var o,s=g.isObject(i&&i.precise),a=0;s&&(o=i.deep?g.cloneDeep(i.precise):g.clone(i.precise));var u=this._vue.$watch(t,function(t,e){if(i&&i.precise){var r=s?i.deep?g.defaultsDeep({},t,i.precise):g.defaults({},t,i.precise):i.deep?g.cloneDeep(t):g.clone(t);if(g.isEqual(r,o))return;o=r}a++,u?(n(t,e),f.digest()):Promise.resolve().then(function(){1<a||n(t,e)})},{immediate:!0,deep:i&&i.deep});return i&&i.scope&&i.scope.$on("$destroy",u),u},St.prototype.when=function(n,i){var o,s,a=this,t=Q(H(t=new Promise(function(e,t){var r=a.observe(n,function(t){t&&c.nextTick(function(){(t=n())&&(e(t),o())})});g.has(i,"timeout")&&(s=setTimeout(function(){s=null,t(new Error(i.timeoutMessage||"Timeout")),o()},i.timeout)),o=function(){r&&(r(),r=null),s&&(clearTimeout(s),s=null),t(new Error("Canceled"))}}),o),o);return i&&i.scope&&i.scope.$on("$destroy",function(){t.cancel()}),t},St.prototype.nextTick=function(){var r;return Q(new Promise(function(t,e){c.nextTick(t),r=function(){e(new Error("Canceled"))}}),r)},St.prototype.throttleRemoteDataUpdates=function(t){this._tree.throttleRemoteDataUpdates(t)},St.prototype.checkObjectsForRogueProperties=function(){this._tree.checkVueObject(this._tree.root,"/")},Tt.computedPropertyStats.get=function(){return W},St.connectWorker=function(t,e){if(kt)throw new Error("Worker already connected");if(g.isString(t)){var r=window.SharedWorker||window.Worker;if(!r)throw new Error("Browser does not implement Web Workers");t=new r(t)}return kt=new $(t),Pt&&kt.enableLogging(Pt),kt.init(t,e).then(function(t){var e=t.exposedFunctionNames,r=t.firebaseSdkVersion;Object.defineProperty(St,"FIREBASE_SDK_VERSION",{value:r});for(var n=0,i=e;n<i.length;n+=1){var o=i[n];St.worker[o]=kt.bindExposedFunction(o)}})},Tt.worker.get=function(){return Rt},St.preExpose=function(t){St.worker[t]=kt.bindExposedFunction(t)},St.bounceConnection=function(){return kt.bounceConnection()},St.suspend=function(){return kt.suspend()},St.debugPermissionDeniedErrors=function(t,e,r){return kt.debugPermissionDeniedErrors(t,e,r)},St.debounceAngularDigest=function(t){f.debounceDigest(t)},St.escapeKey=p,St.unescapeKey=d,St.enableLogging=function(t){Pt=t,kt&&kt.enableLogging(t)},xt.SERVER_TIMESTAMP.get=function(){return St.SERVER_TIMESTAMP},xt.VERSION.get=function(){return St.VERSION},xt.FIREBASE_SDK_VERSION.get=function(){return St.FIREBASE_SDK_VERSION},Object.defineProperties(St.prototype,xt),Object.defineProperties(St,Tt),Object.defineProperties(St,{SERVER_TIMESTAMP:{value:S},VERSION:{value:"4.1.2"},ComponentPlugin:{value:{install:function(t,e){if(c!==t)throw new Error("Multiple versions of Vue detected");if(!e.truss)throw new Error("Need to pass `truss` instance as an option to use the ComponentPlugin");var r={$truss:{value:e.truss},$destroyed:{get:function(){return this._isBeingDestroyed||this._isDestroyed}},$$touchThis:{value:function(){this.__ob__&&this.__ob__.dep.depend()}}},n=g(r).keys().union(g.keys(ot.prototype)).intersection(g.keys(c.prototype)).value();if(n.length)throw new Error("Truss extension properties conflict with Vue properties: "+n.join(", "));Object.defineProperties(c.prototype,r),T(ot,c),c.mixin({destroyed:function(){if(g.has(this,"$$finalizers"))for(var t=0,e=g.clone(this.$$finalizers);t<e.length;t+=1){(0,e[t])()}}})}}}}),f.defineModule(St),St});
|