react-native-onyx 1.0.75 → 1.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.min.js CHANGED
@@ -1,3 +1,2 @@
1
- /*! For license information please see web.min.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("fast-equals"),require("underscore"),require("idb-keyval"),require("lodash/transform"),require("react")):"function"==typeof define&&define.amd?define(["fast-equals","underscore","idb-keyval","lodash/transform","react"],e):"object"==typeof exports?exports["react-native-onyx/web"]=e(require("fast-equals"),require("underscore"),require("idb-keyval"),require("lodash/transform"),require("react")):t["react-native-onyx/web"]=e(t["fast-equals"],t.underscore,t["idb-keyval"],t["lodash/transform"],t.react)}(self,((t,e,n,r,o)=>(()=>{var i={378:(t,e,n)=>{"use strict";function r(t){return t}function o(){}function i(){}function s(){}n.r(e),n.d(e,{decorateWithMetrics:()=>r,getMetrics:()=>o,printMetrics:()=>i,resetMetrics:()=>s})},501:function(t,e,n){var r;t=n.nmd(t),function(o){var i=(t&&t.exports,"object"==typeof n.g&&n.g);i.global!==i&&i.window;var s=function(t){this.message=t};(s.prototype=new Error).name="InvalidCharacterError";var a=function(t){throw new s(t)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,l={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&a("The string to be encoded contains characters outside of the Latin1 range.");for(var e,n,r,o,i=t.length%3,s="",u=-1,l=t.length-i;++u<l;)e=t.charCodeAt(u)<<16,n=t.charCodeAt(++u)<<8,r=t.charCodeAt(++u),s+=c.charAt((o=e+n+r)>>18&63)+c.charAt(o>>12&63)+c.charAt(o>>6&63)+c.charAt(63&o);return 2==i?(e=t.charCodeAt(u)<<8,n=t.charCodeAt(++u),s+=c.charAt((o=e+n)>>10)+c.charAt(o>>4&63)+c.charAt(o<<2&63)+"="):1==i&&(o=t.charCodeAt(u),s+=c.charAt(o>>2)+c.charAt(o<<4&63)+"=="),s},decode:function(t){var e=(t=String(t).replace(u,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),(e%4==1||/[^+a-zA-Z0-9/]/.test(t))&&a("Invalid character: the string to be decoded is not correctly encoded.");for(var n,r,o=0,i="",s=-1;++s<e;)r=c.indexOf(t.charAt(s)),n=o%4?64*n+r:r,o++%4&&(i+=String.fromCharCode(255&n>>(-2*o&6)));return i},version:"0.1.0"};void 0===(r=function(){return l}.call(e,n,e,t))||(t.exports=r)}()},151:(t,e,n)=>{t.exports=n(782)},819:(t,e,n)=>{n(346);var r=n(521),o="undefined"!=typeof WeakMap?WeakMap:function(){var t=[],e=[];return{set:function(n,r){t.push(n),e.push(r)},get:function(n){for(var r=0;r<t.length;r++)if(t[r]===n)return e[r]}}};e.decycle=function t(e,n,i,s){"use strict";s=s||new o;var a=!Object.prototype.hasOwnProperty.call(n,"circular"),c=!1!==n.refs;return function e(o,u,l){var h,p,d,f="function"==typeof i?i(l||"",o):o;if(n.date&&f instanceof Date)return{$jsan:"d"+f.getTime()};if(n.regex&&f instanceof RegExp)return{$jsan:"r"+r.getRegexFlags(f)+","+f.source};if(n.function&&"function"==typeof f)return{$jsan:"f"+r.stringifyFunction(f,n.function)};if(n.nan&&"number"==typeof f&&isNaN(f))return{$jsan:"n"};if(n.infinity){if(Number.POSITIVE_INFINITY===f)return{$jsan:"i"};if(Number.NEGATIVE_INFINITY===f)return{$jsan:"y"}}if(n[void 0]&&void 0===f)return{$jsan:"u"};if(n.error&&f instanceof Error)return{$jsan:"e"+f.message};if(n.symbol&&"symbol"==typeof f){var y=Symbol.keyFor(f);return void 0!==y?{$jsan:"g"+y}:{$jsan:"s"+f.toString().slice(7,-1)}}if(n.map&&"function"==typeof Map&&f instanceof Map&&"function"==typeof Array.from)return{$jsan:"m"+JSON.stringify(t(Array.from(f),n,i,s))};if(n.set&&"function"==typeof Set&&f instanceof Set&&"function"==typeof Array.from)return{$jsan:"l"+JSON.stringify(t(Array.from(f),n,i,s))};if(f&&"function"==typeof f.toJSON)try{f=f.toJSON(l)}catch(t){var m=l||"$";return"toJSON failed for '"+(s.get(f)||m)+"'"}if(!("object"!=typeof f||null===f||f instanceof Boolean||f instanceof Date||f instanceof Number||f instanceof RegExp||f instanceof String||"symbol"==typeof f||f instanceof Error)){if("object"==typeof f){var g=s.get(f);if(g){if(a&&c)return{$jsan:g};if(0===u.split(".").slice(0,-1).join(".").indexOf(g))return a?{$jsan:g}:"function"==typeof n.circular?n.circular(f,u,g):n.circular;if(c)return{$jsan:g}}s.set(f,u)}if("[object Array]"===Object.prototype.toString.apply(f))for(d=[],h=0;h<f.length;h+=1)d[h]=e(f[h],u+"["+h+"]",h);else for(p in d={},f)if(Object.prototype.hasOwnProperty.call(f,p)){var v=/^\w+$/.test(p)?"."+p:"["+JSON.stringify(p)+"]";d[p]="$jsan"===p?[e(f[p],u+v)]:e(f[p],u+v,p)}return d}return f}(e,"$")},e.retrocycle=function(t){"use strict";return function e(n){var o,i,s;if(n&&"object"==typeof n)if("[object Array]"===Object.prototype.toString.apply(n))for(o=0;o<n.length;o+=1)(i=n[o])&&"object"==typeof i&&(i.$jsan?n[o]=r.restore(i.$jsan,t):e(i));else for(s in n){if("string"==typeof n[s]&&"$jsan"===s)return r.restore(n.$jsan,t);"$jsan"===s&&(n[s]=n[s][0]),"object"==typeof n[s]&&(i=n[s])&&"object"==typeof i&&(i.$jsan?n[s]=r.restore(i.$jsan,t):e(i))}return n}(t)}},782:(t,e,n)=>{var r=n(819);e.stringify=function(t,e,n,o){if(arguments.length<4)try{return 1===arguments.length?JSON.stringify(t):JSON.stringify.apply(JSON,arguments)}catch(t){}var i=o||!1;"boolean"==typeof i&&(i={date:i,function:i,regex:i,undefined:i,error:i,symbol:i,map:i,set:i,nan:i,infinity:i});var s=r.decycle(t,i,e);return 1===arguments.length?JSON.stringify(s):JSON.stringify(s,Array.isArray(e)?e:null,n)},e.parse=function(t,e){var n,o=/"\$jsan"/.test(t);return n=1===arguments.length?JSON.parse(t):JSON.parse(t,e),o&&(n=r.retrocycle(n)),n}},346:t=>{t.exports=function(t,e){if("$"!==e)for(var n=function(t){for(var e,n=/(?:\.(\w+))|(?:\[(\d+)\])|(?:\["((?:[^\\"]|\\.)*)"\])/g,r=[];e=n.exec(t);)r.push(e[1]||e[2]||e[3]);return r}(e),r=0;r<n.length;r++)void 0===t[e=n[r].toString().replace(/\\"/g,'"')]&&r!==n.length-1||(t=t[e]);return t}},521:(t,e,n)=>{var r=n(346),o=n(782);e.getRegexFlags=function(t){var e="";return t.ignoreCase&&(e+="i"),t.global&&(e+="g"),t.multiline&&(e+="m"),e},e.stringifyFunction=function(t,e){if("function"==typeof e)return e(t);var n=t.toString(),r=n.match(/^[^{]*{|^[^=]*=>/),o=r?r[0]:"<function> ",i="}"===n[n.length-1]?"}":"";return o.replace(/\r\n|\n/g," ").replace(/\s+/g," ")+" /* ... */ "+i},e.restore=function(t,e){var n=t[0],i=t.slice(1);switch(n){case"$":return r(e,t);case"r":var s=i.indexOf(","),a=i.slice(0,s),c=i.slice(s+1);return RegExp(c,a);case"d":return new Date(+i);case"f":var u=function(){throw new Error("can't run jsan parsed function")};return u.toString=function(){return i},u;case"u":return;case"e":var l=new Error(i);return l.stack="Stack is unavailable for jsan parsed errors",l;case"s":return Symbol(i);case"g":return Symbol.for(i);case"m":return new Map(o.parse(i));case"l":return new Set(o.parse(i));case"n":return NaN;case"i":return 1/0;case"y":return-1/0;default:return console.warn("unknown type",t),t}}},661:t=>{"use strict";var e,n;function r(){if(arguments.length)return r.from(arguments)}function o(){}e="An argument without append, prepend, or detach methods was given to `List",n=r.prototype,r.of=function(){return r.from.call(this,arguments)},r.from=function(t){var e,n,r,o=new this;if(t&&(e=t.length))for(n=-1;++n<e;)null!=(r=t[n])&&o.append(r);return o},n.head=null,n.tail=null,n.toArray=function(){for(var t=this.head,e=[];t;)e.push(t),t=t.next;return e},n.prepend=function(t){if(!t)return!1;if(!t.append||!t.prepend||!t.detach)throw new Error(e+"#prepend`.");var n;return(n=this.head)?n.prepend(t):(t.detach(),t.list=this,this.head=t,t)},n.append=function(t){if(!t)return!1;if(!t.append||!t.prepend||!t.detach)throw new Error(e+"#append`.");var n,r,o;return(o=(n=this).tail)?o.append(t):(r=n.head)?r.append(t):(t.detach(),t.list=n,n.head=t,t)},r.Item=o;var i=o.prototype;i.next=null,i.prev=null,i.list=null,i.detach=function(){var t=this,e=t.list,n=t.prev,r=t.next;return e?(e.tail===t&&(e.tail=n),e.head===t&&(e.head=r),e.tail===e.head&&(e.tail=null),n&&(n.next=r),r&&(r.prev=n),t.prev=t.next=t.list=null,t):t},i.prepend=function(t){if(!(t&&t.append&&t.prepend&&t.detach))throw new Error(e+"Item#prepend`.");var n=this,r=n.list,o=n.prev;return!!r&&(t.detach(),o&&(t.prev=o,o.next=t),t.next=n,t.list=r,n.prev=t,n===r.head&&(r.head=t),r.tail||(r.tail=n),t)},i.append=function(t){if(!(t&&t.append&&t.prepend&&t.detach))throw new Error(e+"Item#append`.");var n=this,r=n.list,o=n.next;return!!r&&(t.detach(),o&&(t.next=o,o.prev=t),t.prev=n,t.list=r,n.next=t,n!==r.tail&&r.tail||(r.tail=t),t)},t.exports=r},357:(t,e,n)=>{"use strict";t.exports=n(661)},703:(t,e,n)=>{"use strict";var r=n(414);function o(){}function i(){}i.resetWarningCache=o,t.exports=function(){function t(t,e,n,o,i,s){if(s!==r){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function e(){return t}t.isRequired=t;var n={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}},697:(t,e,n)=>{t.exports=n(703)()},414:t=>{"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},900:(t,e)=>{"use strict";e.__esModule=!0,e.defaultSocketOptions={secure:!0,hostname:"remotedev.io",port:443,autoReconnect:!0,autoReconnectOptions:{randomness:6e4}}},254:(t,e,n)=>{"use strict";e.__esModule=!0,e.send=void 0,e.extractState=h,e.generateId=p,e.start=f,e.connect=g,e.connectViaExtension=v;var r=n(151),o=a(n(984)),i=a(n(954)),s=n(900);function a(t){return t&&t.__esModule?t:{default:t}}var c=void 0,u=void 0,l={};function h(t){if(t&&t.state)return"string"==typeof t.state?(0,r.parse)(t.state):t.state}function p(){return Math.random().toString(36).substr(2)}function d(t){t.payload||(t.payload=t.action),Object.keys(l).forEach((function(e){t.instanceId&&e!==t.instanceId||("function"==typeof l[e]?l[e](t):l[e].forEach((function(e){e(t)})))}))}function f(t){t&&t.port&&!t.hostname&&(t.hostname="localhost"),function(t){var e;c||(e=t.port?{port:t.port,hostname:(0,i.default)(t.hostname||"localhost"),secure:!!t.secure}:s.defaultSocketOptions,c=o.default.create(e),u||c.emit("login","master",(function(t,e){t?console.log(t):((u=c.subscribe(e)).watch(d),c.on(e,d))})))}(t)}function y(t,e){if(t.action)return t;var n={timestamp:Date.now()};return t?e.getActionType?n.action=e.getActionType(t):"string"==typeof t?n.action={type:t}:t.type?n.action=t:n.action={type:"update"}:n.action={type:t},n}function m(t,e,n,o,i){f(n),setTimeout((function(){var s={payload:e?(0,r.stringify)(e):"",action:"ACTION"===o?(0,r.stringify)(y(t,n)):t,type:o||"ACTION",id:c.id,instanceId:i,name:n.name};c.emit(c.id?"log":"log-noid",s)}),0)}function g(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=p(t.instanceId);return f(t),{init:function(n,r){m(r||{},n,t,"INIT",e)},subscribe:function(t){if(t)return l[e]||(l[e]=[]),l[e].push(t),function(){var n=l[e].indexOf(t);l[e].splice(n,1)}},unsubscribe:function(){delete l[e]},send:function(n,r){n?m(n,r,t,"ACTION",e):m(void 0,r,t,"STATE",e)},error:function(t){c.emit({type:"ERROR",payload:t,id:c.id,instanceId:e})}}}function v(t){return t&&t.remote||"undefined"==typeof window||!window.__REDUX_DEVTOOLS_EXTENSION__?g(t):window.__REDUX_DEVTOOLS_EXTENSION__.connect(t)}e.send=m,e.default={connect:g,connectViaExtension:v,send:m,extractState:h,generateId:p}},53:(t,e,n)=>{"use strict";t.exports=n(254)},954:t=>{"use strict";t.exports=function(t){if("object"!=typeof __fbBatchedBridgeConfig||"localhost"!==t&&"127.0.0.1"!==t)return t;var e=function(t){var e="undefined"!=typeof window&&window.__fbBatchedBridgeConfig&&window.__fbBatchedBridgeConfig.remoteModuleConfig;if(!Array.isArray(e)||"localhost"!==t&&"127.0.0.1"!==t)return{hostname:t,passed:!1};var n=t,r=!1;return e.some((function(t){if(!t)return!1;var e=t[0],o=t[1];return("AndroidConstants"===e||"PlatformConstants"===e)&&o&&o.ServerHost?(n=o.ServerHost.split(":")[0],r=!0,!0):!("SourceCode"!==e||!o||!o.scriptURL||(n=o.scriptURL.replace(/https?:\/\//,"").split(":")[0],r=!0,0))})),{hostname:n,passed:r}}(t);return e.passed?e.hostname:function(t){var e,n,r,o=console.warn;if("undefined"==typeof window||!window.__DEV__||"function"!=typeof window.require||"metroRequire"===window.require.name)return t;console.warn=function(){if(!(arguments[0]&&"function"==typeof arguments[0].indexOf&&arguments[0].indexOf("Requiring module 'NativeModules' by name")>-1))return o.apply(console,arguments)};try{e=window.require("NativeModules")}catch(t){}return console.warn=o,e?(n=e.PlatformConstants||e.AndroidConstants,r=e.SourceCode,n&&n.ServerHost?n.ServerHost.split(":")[0]:r&&r.scriptURL?r.scriptURL.replace(/https?:\/\//,"").split(":")[0]:t):t}(t)}},10:(t,e,n)=>{var r=n(576),o=function(t,e,n){r.call(this),this.PENDING="pending",this.SUBSCRIBED="subscribed",this.UNSUBSCRIBED="unsubscribed",this.name=t,this.state=this.UNSUBSCRIBED,this.client=e,this.options=n||{},this.setOptions(this.options)};(o.prototype=Object.create(r.prototype)).setOptions=function(t){t||(t={}),this.waitForAuth=t.waitForAuth||!1,this.batch=t.batch||!1,void 0!==t.data&&(this.data=t.data)},o.prototype.getState=function(){return this.state},o.prototype.subscribe=function(t){this.client.subscribe(this.name,t)},o.prototype.unsubscribe=function(){this.client.unsubscribe(this.name)},o.prototype.isSubscribed=function(t){return this.client.isSubscribed(this.name,t)},o.prototype.publish=function(t,e){this.client.publish(this.name,t,e)},o.prototype.watch=function(t){this.client.watch(this.name,t)},o.prototype.unwatch=function(t){this.client.unwatch(this.name,t)},o.prototype.watchers=function(){return this.client.watchers(this.name)},o.prototype.destroy=function(){this.client.destroyChannel(this.name)},t.exports.X=o},576:t=>{function e(t){if(t)return function(t){for(var n in e.prototype)t[n]=e.prototype[n];return t}(t)}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},e.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var o=0;o<r.length;o++)if((n=r[o])===e||n.fn===e){r.splice(o,1);break}return this},e.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,e);return this},e.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},e.prototype.hasListeners=function(t){return!!this.listeners(t).length}},438:t=>{t.exports=function(t){var e=[],n=[];return function t(r,o){var i,s,a;if(!("object"!=typeof r||null===r||r instanceof Boolean||r instanceof Date||r instanceof Number||r instanceof RegExp||r instanceof String)){for(i=0;i<e.length;i+=1)if(e[i]===r)return{$ref:n[i]};if(e.push(r),n.push(o),"[object Array]"===Object.prototype.toString.apply(r))for(a=[],i=0;i<r.length;i+=1)a[i]=t(r[i],o+"["+i+"]");else for(s in a={},r)Object.prototype.hasOwnProperty.call(r,s)&&(a[s]=t(r[s],o+"["+JSON.stringify(s)+"]"));return a}return r}(t,"$")}},375:(t,e,n)=>{var r=n(438),o=function(){return!this}();function i(t,e){this.name="AuthTokenExpiredError",this.message=t,this.expiry=e,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function s(t){this.name="AuthTokenInvalidError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function a(t,e){this.name="AuthTokenNotBeforeError",this.message=t,this.date=e,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function c(t){this.name="AuthTokenError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function u(t,e){this.name="SilentMiddlewareBlockedError",this.message=t,this.type=e,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function l(t){this.name="InvalidActionError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function h(t){this.name="InvalidArgumentsError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function p(t){this.name="InvalidOptionsError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function d(t){this.name="InvalidMessageError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function f(t,e){this.name="SocketProtocolError",this.message=t,this.code=e,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function y(t){this.name="ServerProtocolError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function m(t){this.name="HTTPServerError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function g(t){this.name="ResourceLimitError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function v(t){this.name="TimeoutError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function b(t,e){this.name="BadConnectionError",this.message=t,this.type=e,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function E(t){this.name="BrokerError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function k(t,e){this.name="ProcessExitError",this.message=t,this.code=e,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function S(t){this.name="UnknownError",this.message=t,Error.captureStackTrace&&!o?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}i.prototype=Object.create(Error.prototype),s.prototype=Object.create(Error.prototype),a.prototype=Object.create(Error.prototype),c.prototype=Object.create(Error.prototype),u.prototype=Object.create(Error.prototype),l.prototype=Object.create(Error.prototype),h.prototype=Object.create(Error.prototype),p.prototype=Object.create(Error.prototype),d.prototype=Object.create(Error.prototype),f.prototype=Object.create(Error.prototype),y.prototype=Object.create(Error.prototype),m.prototype=Object.create(Error.prototype),g.prototype=Object.create(Error.prototype),v.prototype=Object.create(Error.prototype),b.prototype=Object.create(Error.prototype),E.prototype=Object.create(Error.prototype),k.prototype=Object.create(Error.prototype),S.prototype=Object.create(Error.prototype),t.exports={AuthTokenExpiredError:i,AuthTokenInvalidError:s,AuthTokenNotBeforeError:a,AuthTokenError:c,SilentMiddlewareBlockedError:u,InvalidActionError:l,InvalidArgumentsError:h,InvalidOptionsError:p,InvalidMessageError:d,SocketProtocolError:f,ServerProtocolError:y,HTTPServerError:m,ResourceLimitError:g,TimeoutError:v,BadConnectionError:b,BrokerError:E,ProcessExitError:k,UnknownError:S},t.exports.socketProtocolErrorStatuses={1001:"Socket was disconnected",1002:"A WebSocket protocol error was encountered",1003:"Server terminated socket because it received invalid data",1005:"Socket closed without status code",1006:"Socket hung up",1007:"Message format was incorrect",1008:"Encountered a policy violation",1009:"Message was too big to process",1010:"Client ended the connection because the server did not comply with extension requirements",1011:"Server encountered an unexpected fatal condition",4e3:"Server ping timed out",4001:"Client pong timed out",4002:"Server failed to sign auth token",4003:"Failed to complete handshake",4004:"Client failed to save auth token",4005:"Did not receive #handshake from client before timeout",4006:"Failed to bind socket to message broker",4007:"Client connection establishment timed out",4008:"Server rejected handshake from client"},t.exports.socketProtocolIgnoreStatuses={1e3:"Socket closed normally",1001:"Socket hung up"};var T={domain:1,domainEmitter:1,domainThrown:1};t.exports.dehydrateError=function(t,e){var n;if(t&&"object"==typeof t)for(var o in n={message:t.message},e&&(n.stack=t.stack),t)T[o]||(n[o]=t[o]);else n="function"==typeof t?"[function "+(t.name||"anonymous")+"]":t;return r(n)},t.exports.hydrateError=function(t){var e=null;if(null!=t)if("object"==typeof t)for(var n in e=new Error(t.message),t)t.hasOwnProperty(n)&&(e[n]=t[n]);else e=t;return e},t.exports.decycle=r},556:(t,e,n)=>{const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=/^[ \n\r\t]*[{\[]/;let i=function(t){let e=new Uint8Array(t),n=e.length,o="";for(let t=0;t<n;t+=3)o+=r[e[t]>>2],o+=r[(3&e[t])<<4|e[t+1]>>4],o+=r[(15&e[t+1])<<2|e[t+2]>>6],o+=r[63&e[t+2]];return n%3==2?o=o.substring(0,o.length-1)+"=":n%3==1&&(o=o.substring(0,o.length-2)+"=="),o},s=function(t,e){if(n.g.ArrayBuffer&&e instanceof n.g.ArrayBuffer)return{base64:!0,data:i(e)};if(n.g.Buffer){if(e instanceof n.g.Buffer)return{base64:!0,data:e.toString("base64")};if(e&&"Buffer"===e.type&&Array.isArray(e.data)){let t;return t=n.g.Buffer.from?n.g.Buffer.from(e.data):new n.g.Buffer(e.data),{base64:!0,data:t.toString("base64")}}}return e};t.exports.decode=function(t){if(null==t)return null;if("#1"===t||"#2"===t)return t;let e=t.toString();if(!o.test(e))return e;try{return JSON.parse(e)}catch(t){}return e},t.exports.encode=function(t){return"#1"===t||"#2"===t?t:JSON.stringify(t,s)}},984:(t,e,n)=>{var r=n(625),o=n(116);t.exports.factory=o,t.exports.SCClientSocket=r,t.exports.Emitter=n(214),t.exports.create=function(t){return o.create(t)},t.exports.connect=t.exports.create,t.exports.destroy=function(t){return o.destroy(t)},t.exports.clients=o.clients,t.exports.version="13.0.1"},147:(t,e,n)=>{var r=function(){this._internalStorage={},this.isLocalStorageEnabled=this._checkLocalStorageEnabled()};r.prototype._checkLocalStorageEnabled=function(){var t;try{n.g.localStorage,n.g.localStorage.setItem("__scLocalStorageTest",1),n.g.localStorage.removeItem("__scLocalStorageTest")}catch(e){t=e}return!t},r.prototype.saveToken=function(t,e,r,o){this.isLocalStorageEnabled&&n.g.localStorage?n.g.localStorage.setItem(t,e):this._internalStorage[t]=e,o&&o(null,e)},r.prototype.removeToken=function(t,e){var r;this.loadToken(t,(function(t,e){r=e})),this.isLocalStorageEnabled&&n.g.localStorage?n.g.localStorage.removeItem(t):delete this._internalStorage[t],e&&e(null,r)},r.prototype.loadToken=function(t,e){e(null,this.isLocalStorageEnabled&&n.g.localStorage?n.g.localStorage.getItem(t):this._internalStorage[t]||null)},t.exports.K=r},116:(t,e,n)=>{var r=n(625),o=n(375),i=n(270),s=o.InvalidArgumentsError,a={};function c(t,e){var r=null==t.secure?e:t.secure;return t.port||(n.g.location&&location.port?location.port:r?443:80)}t.exports={create:function(t){if((t=t||{}).host&&!t.host.match(/[^:]+:\d{2,5}/))throw new s('The host option should include both the hostname and the port number in the format "hostname:port"');if(t.host&&t.hostname)throw new s('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and hostname options together');if(t.host&&t.port)throw new s('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and port options together');var e=n.g.location&&"https:"==location.protocol,o={port:c(t,e),hostname:n.g.location&&location.hostname||"localhost",path:"/socketcluster/",secure:e,autoConnect:!0,autoReconnect:!0,autoSubscribeOnConnect:!0,connectTimeout:2e4,ackTimeout:1e4,timestampRequests:!1,timestampParam:"t",authEngine:null,authTokenName:"socketCluster.authToken",binaryType:"arraybuffer",multiplex:!0,pubSubBatchDuration:null,cloneData:!1};for(var u in t)t.hasOwnProperty(u)&&(o[u]=t[u]);if(o.clientMap=a,!1===o.multiplex){o.clientId=i.v4();var l=new r(o);return a[o.clientId]=l,l}return o.clientId=function(t){var e=t.secure?"https://":"http://",n="";if(t.query)if("string"==typeof t.query)n=t.query;else{var r=[],o=t.query;for(var i in o)o.hasOwnProperty(i)&&r.push(i+"="+o[i]);r.length&&(n="?"+r.join("&"))}return e+(t.host?t.host:t.hostname+":"+t.port)+t.path+n}(o),a[o.clientId]?o.autoConnect&&a[o.clientId].connect():a[o.clientId]=new r(o),a[o.clientId]},destroy:function(t){t.destroy()},clients:a}},701:(t,e,n)=>{var r=n(375),o=r.InvalidActionError,i=function(t,e){this.socket=t,this.id=e,this.sent=!1};i.prototype._respond=function(t){if(this.sent)throw new o("Response "+this.id+" has already been sent");this.sent=!0,this.socket.send(this.socket.encode(t))},i.prototype.end=function(t){if(this.id){var e={rid:this.id};void 0!==t&&(e.data=t),this._respond(e)}},i.prototype.error=function(t,e){if(this.id){var n=r.dehydrateError(t),o={rid:this.id,error:n};void 0!==e&&(o.data=e),this._respond(o)}},i.prototype.callback=function(t,e){t?this.error(t,e):this.end(e)},t.exports.H=i},625:(t,e,n)=>{var r=n(214),o=n(10).X,i=(n(701).H,n(147).K),s=n(556),a=n(763).U,c=n(347),u=n(357),l=n(501),h=n(634),p=n(375),d=p.InvalidArgumentsError,f=p.InvalidMessageError,y=p.InvalidActionError,m=p.SocketProtocolError,g=p.TimeoutError,v=p.BadConnectionError,b="undefined"!=typeof window,E=function(t){var e=this;r.call(this),this.id=null,this.state=this.CLOSED,this.authState=this.UNAUTHENTICATED,this.signedAuthToken=null,this.authToken=null,this.pendingReconnect=!1,this.pendingReconnectTimeout=null,this.preparingPendingSubscriptions=!1,this.clientId=t.clientId,this.connectTimeout=t.connectTimeout,this.ackTimeout=t.ackTimeout,this.channelPrefix=t.channelPrefix||null,this.disconnectOnUnload=null==t.disconnectOnUnload||t.disconnectOnUnload,this.authTokenName=t.authTokenName,this.pingTimeout=this.ackTimeout,this.pingTimeoutDisabled=!!t.pingTimeoutDisabled,this.active=!0,this._clientMap=t.clientMap||{};var o=Math.pow(2,31)-1,a=function(t){if(e[t]>o)throw new d("The "+t+" value provided exceeded the maximum amount allowed")};if(a("connectTimeout"),a("ackTimeout"),this._localEvents={connect:1,connectAbort:1,close:1,disconnect:1,message:1,error:1,raw:1,kickOut:1,subscribe:1,unsubscribe:1,subscribeStateChange:1,authStateChange:1,authenticate:1,deauthenticate:1,removeAuthToken:1,subscribeRequest:1},this.connectAttempts=0,this._emitBuffer=new u,this.channels={},this.options=t,this._cid=1,this.options.callIdGenerator=function(){return e._cid++},this.options.autoReconnect){null==this.options.autoReconnectOptions&&(this.options.autoReconnectOptions={});var l=this.options.autoReconnectOptions;null==l.initialDelay&&(l.initialDelay=1e4),null==l.randomness&&(l.randomness=1e4),null==l.multiplier&&(l.multiplier=1.5),null==l.maxDelay&&(l.maxDelay=6e4)}null==this.options.subscriptionRetryOptions&&(this.options.subscriptionRetryOptions={}),this.options.authEngine?this.auth=this.options.authEngine:this.auth=new i,this.options.codecEngine?this.codec=this.options.codecEngine:this.codec=s,this.options.path=this.options.path.replace(/\/$/,"")+"/",this.options.query=t.query||{},"string"==typeof this.options.query&&(this.options.query=c.parse(this.options.query)),this._channelEmitter=new r,this._unloadHandler=function(){e.disconnect()},b&&this.disconnectOnUnload&&n.g.addEventListener&&n.g.addEventListener("beforeunload",this._unloadHandler,!1),this._clientMap[this.clientId]=this,this.options.autoConnect&&this.connect()};E.prototype=Object.create(r.prototype),E.CONNECTING=E.prototype.CONNECTING=a.prototype.CONNECTING,E.OPEN=E.prototype.OPEN=a.prototype.OPEN,E.CLOSED=E.prototype.CLOSED=a.prototype.CLOSED,E.AUTHENTICATED=E.prototype.AUTHENTICATED="authenticated",E.UNAUTHENTICATED=E.prototype.UNAUTHENTICATED="unauthenticated",E.PENDING=E.prototype.PENDING="pending",E.ignoreStatuses=p.socketProtocolIgnoreStatuses,E.errorStatuses=p.socketProtocolErrorStatuses,E.prototype._privateEventHandlerMap={"#publish":function(t){var e=this._undecorateChannelName(t.channel);this.isSubscribed(e,!0)&&this._channelEmitter.emit(e,t.data)},"#kickOut":function(t){var e=this._undecorateChannelName(t.channel),n=this.channels[e];n&&(r.prototype.emit.call(this,"kickOut",t.message,e),n.emit("kickOut",t.message,e),this._triggerChannelUnsubscribe(n))},"#setAuthToken":function(t,e){var n=this;t?this.auth.saveToken(this.authTokenName,t.token,{},(function(r){r?(e.error(r),n._onSCError(r)):(n._changeToAuthenticatedState(t.token),e.end())})):e.error(new f("No token data provided by #setAuthToken event"))},"#removeAuthToken":function(t,e){var n=this;this.auth.removeToken(this.authTokenName,(function(t,o){t?(e.error(t),n._onSCError(t)):(r.prototype.emit.call(n,"removeAuthToken",o),n._changeToUnauthenticatedStateAndClearTokens(),e.end())}))},"#disconnect":function(t){this.transport.close(t.code,t.data)}},E.prototype.getState=function(){return this.state},E.prototype.getBytesReceived=function(){return this.transport.getBytesReceived()},E.prototype.deauthenticate=function(t){var e=this;this.auth.removeToken(this.authTokenName,(function(n,o){n?e._onSCError(n):(r.prototype.emit.call(e,"removeAuthToken",o),e.state!=e.CLOSED&&e.emit("#removeAuthToken"),e._changeToUnauthenticatedStateAndClearTokens()),t&&t(n)}))},E.prototype.connect=E.prototype.open=function(){var t=this;if(this.active)this.state==this.CLOSED&&(this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this.state=this.CONNECTING,r.prototype.emit.call(this,"connecting"),this.transport&&this.transport.off(),this.transport=new a(this.auth,this.codec,this.options),this.transport.on("open",(function(e){t.state=t.OPEN,t._onSCOpen(e)})),this.transport.on("error",(function(e){t._onSCError(e)})),this.transport.on("close",(function(e,n){t.state=t.CLOSED,t._onSCClose(e,n)})),this.transport.on("openAbort",(function(e,n){t.state=t.CLOSED,t._onSCClose(e,n,!0)})),this.transport.on("event",(function(e,n,r){t._onSCEvent(e,n,r)})));else{var e=new y("Cannot connect a destroyed client");this._onSCError(e)}},E.prototype.reconnect=function(t,e){this.disconnect(t,e),this.connect()},E.prototype.disconnect=function(t,e){if("number"!=typeof(t=t||1e3))throw new d("If specified, the code argument must be a number");this.state==this.OPEN||this.state==this.CONNECTING?this.transport.close(t,e):(this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef))},E.prototype.destroy=function(t,e){b&&n.g.removeEventListener&&n.g.removeEventListener("beforeunload",this._unloadHandler,!1),this.active=!1,this.disconnect(t,e),delete this._clientMap[this.clientId]},E.prototype._changeToUnauthenticatedStateAndClearTokens=function(){if(this.authState!=this.UNAUTHENTICATED){var t=this.authState,e=this.signedAuthToken;this.authState=this.UNAUTHENTICATED,this.signedAuthToken=null,this.authToken=null;var n={oldState:t,newState:this.authState};r.prototype.emit.call(this,"authStateChange",n),r.prototype.emit.call(this,"deauthenticate",e)}},E.prototype._changeToAuthenticatedState=function(t){if(this.signedAuthToken=t,this.authToken=this._extractAuthTokenData(t),this.authState!=this.AUTHENTICATED){var e=this.authState;this.authState=this.AUTHENTICATED;var n={oldState:e,newState:this.authState,signedAuthToken:t,authToken:this.authToken};this.preparingPendingSubscriptions||this.processPendingSubscriptions(),r.prototype.emit.call(this,"authStateChange",n)}r.prototype.emit.call(this,"authenticate",t)},E.prototype.decodeBase64=function(t){return"undefined"==typeof Buffer?n.g.atob?n.g.atob(t):l.decode(t):new Buffer(t,"base64").toString("utf8")},E.prototype.encodeBase64=function(t){return"undefined"==typeof Buffer?n.g.btoa?n.g.btoa(t):l.encode(t):new Buffer(t,"utf8").toString("base64")},E.prototype._extractAuthTokenData=function(t){var e=(t||"").split(".")[1];if(null!=e){var n=e;try{return n=this.decodeBase64(n),JSON.parse(n)}catch(t){return n}}return null},E.prototype.getAuthToken=function(){return this.authToken},E.prototype.getSignedAuthToken=function(){return this.signedAuthToken},E.prototype.authenticate=function(t,e){var n=this;this.emit("#authenticate",t,(function(r,o){o&&null!=o.isAuthenticated?o.authError&&(o.authError=p.hydrateError(o.authError)):o={isAuthenticated:n.authState,authError:null},r?("BadConnectionError"!=r.name&&"TimeoutError"!=r.name&&n._changeToUnauthenticatedStateAndClearTokens(),e&&e(r,o)):n.auth.saveToken(n.authTokenName,t,{},(function(r){r&&n._onSCError(r),o.isAuthenticated?n._changeToAuthenticatedState(t):n._changeToUnauthenticatedStateAndClearTokens(),e&&e(r,o)}))}))},E.prototype._tryReconnect=function(t){var e,n=this,r=this.connectAttempts++,o=this.options.autoReconnectOptions;if(null==t||r>0){var i=Math.round(o.initialDelay+(o.randomness||0)*Math.random());e=Math.round(i*Math.pow(o.multiplier,r))}else e=t;e>o.maxDelay&&(e=o.maxDelay),clearTimeout(this._reconnectTimeoutRef),this.pendingReconnect=!0,this.pendingReconnectTimeout=e,this._reconnectTimeoutRef=setTimeout((function(){n.connect()}),e)},E.prototype._onSCOpen=function(t){var e=this;this.preparingPendingSubscriptions=!0,t?(this.id=t.id,this.pingTimeout=t.pingTimeout,this.transport.pingTimeout=this.pingTimeout,t.isAuthenticated?this._changeToAuthenticatedState(t.authToken):this._changeToUnauthenticatedStateAndClearTokens()):this._changeToUnauthenticatedStateAndClearTokens(),this.connectAttempts=0,this.options.autoSubscribeOnConnect&&this.processPendingSubscriptions(),r.prototype.emit.call(this,"connect",t,(function(){e.processPendingSubscriptions()})),this.state==this.OPEN&&this._flushEmitBuffer()},E.prototype._onSCError=function(t){var e=this;setTimeout((function(){if(e.listeners("error").length<1)throw t;r.prototype.emit.call(e,"error",t)}),0)},E.prototype._suspendSubscriptions=function(){var t,e;for(var n in this.channels)this.channels.hasOwnProperty(n)&&(e=(t=this.channels[n]).state==t.SUBSCRIBED||t.state==t.PENDING?t.PENDING:t.UNSUBSCRIBED,this._triggerChannelUnsubscribe(t,e))},E.prototype._abortAllPendingEventsDueToBadConnection=function(t){for(var e,n=this._emitBuffer.head;n;){e=n.next;var r=n.data;clearTimeout(r.timeout),delete r.timeout,n.detach(),n=e;var o=r.callback;if(o){delete r.callback;var i="Event '"+r.event+"' was aborted due to a bad connection",s=new v(i,t);o.call(r,s,r)}r.cid&&this.transport.cancelPendingResponse(r.cid)}},E.prototype._onSCClose=function(t,e,n){var o=this;if(this.id=null,this.transport&&this.transport.off(),this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this._suspendSubscriptions(),this._abortAllPendingEventsDueToBadConnection(n?"connectAbort":"disconnect"),this.options.autoReconnect&&(4e3==t||4001==t||1005==t?this._tryReconnect(0):1e3!=t&&t<4500&&this._tryReconnect()),n?r.prototype.emit.call(o,"connectAbort",t,e):r.prototype.emit.call(o,"disconnect",t,e),r.prototype.emit.call(o,"close",t,e),!E.ignoreStatuses[t]){var i;i=e?"Socket connection closed with status code "+t+" and reason: "+e:"Socket connection closed with status code "+t;var s=new m(E.errorStatuses[t]||i,t);this._onSCError(s)}},E.prototype._onSCEvent=function(t,e,n){var o=this._privateEventHandlerMap[t];o?o.call(this,e,n):r.prototype.emit.call(this,t,e,(function(){n&&n.callback.apply(n,arguments)}))},E.prototype.decode=function(t){return this.transport.decode(t)},E.prototype.encode=function(t){return this.transport.encode(t)},E.prototype._flushEmitBuffer=function(){for(var t,e=this._emitBuffer.head;e;){t=e.next;var n=e.data;e.detach(),this.transport.emitObject(n),e=t}},E.prototype._handleEventAckTimeout=function(t,e){e&&e.detach(),delete t.timeout;var n=t.callback;if(n){delete t.callback;var r=new g("Event response for '"+t.event+"' timed out");n.call(t,r,t)}t.cid&&this.transport.cancelPendingResponse(t.cid)},E.prototype._emit=function(t,e,n){var r=this;this.state==this.CLOSED&&this.connect();var o={event:t,callback:n},i=new u.Item;this.options.cloneData?o.data=h(e):o.data=e,i.data=o,o.timeout=setTimeout((function(){r._handleEventAckTimeout(o,i)}),this.ackTimeout),this._emitBuffer.append(i),this.state==this.OPEN&&this._flushEmitBuffer()},E.prototype.send=function(t){this.transport.send(t)},E.prototype.emit=function(t,e,n){if(null==this._localEvents[t])this._emit(t,e,n);else if("error"==t)r.prototype.emit.call(this,t,e);else{var o=new y('The "'+t+'" event is reserved and cannot be emitted on a client socket');this._onSCError(o)}},E.prototype.publish=function(t,e,n){var r={channel:this._decorateChannelName(t),data:e};this.emit("#publish",r,n)},E.prototype._triggerChannelSubscribe=function(t,e){var n=t.name;if(t.state!=t.SUBSCRIBED){var o=t.state;t.state=t.SUBSCRIBED;var i={channel:n,oldState:o,newState:t.state,subscriptionOptions:e};t.emit("subscribeStateChange",i),t.emit("subscribe",n,e),r.prototype.emit.call(this,"subscribeStateChange",i),r.prototype.emit.call(this,"subscribe",n,e)}},E.prototype._triggerChannelSubscribeFail=function(t,e,n){var o=e.name,i=!e.waitForAuth||this.authState==this.AUTHENTICATED;e.state!=e.UNSUBSCRIBED&&i&&(e.state=e.UNSUBSCRIBED,e.emit("subscribeFail",t,o,n),r.prototype.emit.call(this,"subscribeFail",t,o,n))},E.prototype._cancelPendingSubscribeCallback=function(t){null!=t._pendingSubscriptionCid&&(this.transport.cancelPendingResponse(t._pendingSubscriptionCid),delete t._pendingSubscriptionCid)},E.prototype._decorateChannelName=function(t){return this.channelPrefix&&(t=this.channelPrefix+t),t},E.prototype._undecorateChannelName=function(t){return this.channelPrefix&&0==t.indexOf(this.channelPrefix)?t.replace(this.channelPrefix,""):t},E.prototype._trySubscribe=function(t){var e=this,n=!t.waitForAuth||this.authState==this.AUTHENTICATED;if(this.state==this.OPEN&&!this.preparingPendingSubscriptions&&null==t._pendingSubscriptionCid&&n){var o={noTimeout:!0},i={channel:this._decorateChannelName(t.name)};t.waitForAuth&&(o.waitForAuth=!0,i.waitForAuth=o.waitForAuth),t.data&&(i.data=t.data),t.batch&&(o.batch=!0,i.batch=!0),t._pendingSubscriptionCid=this.transport.emit("#subscribe",i,o,(function(n){delete t._pendingSubscriptionCid,n?e._triggerChannelSubscribeFail(n,t,i):e._triggerChannelSubscribe(t,i)})),r.prototype.emit.call(this,"subscribeRequest",t.name,i)}},E.prototype.subscribe=function(t,e){var n=this.channels[t];return n?e&&n.setOptions(e):(n=new o(t,this,e),this.channels[t]=n),n.state==n.UNSUBSCRIBED&&(n.state=n.PENDING,this._trySubscribe(n)),n},E.prototype._triggerChannelUnsubscribe=function(t,e){var n=t.name,o=t.state;if(t.state=e||t.UNSUBSCRIBED,this._cancelPendingSubscribeCallback(t),o==t.SUBSCRIBED){var i={channel:n,oldState:o,newState:t.state};t.emit("subscribeStateChange",i),t.emit("unsubscribe",n),r.prototype.emit.call(this,"subscribeStateChange",i),r.prototype.emit.call(this,"unsubscribe",n)}},E.prototype._tryUnsubscribe=function(t){if(this.state==this.OPEN){var e={noTimeout:!0};t.batch&&(e.batch=!0),this._cancelPendingSubscribeCallback(t);var n=this._decorateChannelName(t.name);this.transport.emit("#unsubscribe",n,e)}},E.prototype.unsubscribe=function(t){var e=this.channels[t];e&&e.state!=e.UNSUBSCRIBED&&(this._triggerChannelUnsubscribe(e),this._tryUnsubscribe(e))},E.prototype.channel=function(t,e){var n=this.channels[t];return n||(n=new o(t,this,e),this.channels[t]=n),n},E.prototype.destroyChannel=function(t){var e=this.channels[t];e&&(e.unwatch(),e.unsubscribe(),delete this.channels[t])},E.prototype.subscriptions=function(t){var e,n=[];for(var r in this.channels)this.channels.hasOwnProperty(r)&&(e=this.channels[r],(t?e&&(e.state==e.SUBSCRIBED||e.state==e.PENDING):e&&e.state==e.SUBSCRIBED)&&n.push(r));return n},E.prototype.isSubscribed=function(t,e){var n=this.channels[t];return e?!!n&&(n.state==n.SUBSCRIBED||n.state==n.PENDING):!!n&&n.state==n.SUBSCRIBED},E.prototype.processPendingSubscriptions=function(){var t=this;this.preparingPendingSubscriptions=!1;var e=[];for(var n in this.channels)if(this.channels.hasOwnProperty(n)){var r=this.channels[n];r.state==r.PENDING&&e.push(r)}e.sort((function(t,e){var n=t.priority||0,r=e.priority||0;return n>r?-1:n<r?1:0})),e.forEach((function(e){t._trySubscribe(e)}))},E.prototype.watch=function(t,e){if("function"!=typeof e)throw new d("No handler function was provided");this._channelEmitter.on(t,e)},E.prototype.unwatch=function(t,e){e?this._channelEmitter.removeListener(t,e):this._channelEmitter.removeAllListeners(t)},E.prototype.watchers=function(t){return this._channelEmitter.listeners(t)},t.exports=E},763:(t,e,n)=>{var r,o,i=n(214),s=n(701).H,a=n(347);n.g.WebSocket?(r=n.g.WebSocket,o=function(t,e){return new r(t)}):(r=n(560),o=function(t,e){return new r(t,null,e)});var c=n(375),u=c.TimeoutError,l=c.BadConnectionError,h=function(t,e,n){var r=this;this.state=this.CLOSED,this.auth=t,this.codec=e,this.options=n,this.connectTimeout=n.connectTimeout,this.pingTimeout=n.ackTimeout,this.pingTimeoutDisabled=!!n.pingTimeoutDisabled,this.callIdGenerator=n.callIdGenerator,this.authTokenName=n.authTokenName,this._pingTimeoutTicker=null,this._callbackMap={},this._batchSendList=[],this.state=this.CONNECTING;var i=this.uri(),s=o(i,this.options);s.binaryType=this.options.binaryType,this.socket=s,s.onopen=function(){r._onOpen()},s.onclose=function(t){var e;e=null==t.code?1005:t.code,r._onClose(e,t.reason)},s.onmessage=function(t,e){r._onMessage(t.data)},s.onerror=function(t){r.state===r.CONNECTING&&r._onClose(1006)},this._connectTimeoutRef=setTimeout((function(){r._onClose(4007),r.socket.close(4007)}),this.connectTimeout)};h.prototype=Object.create(i.prototype),h.CONNECTING=h.prototype.CONNECTING="connecting",h.OPEN=h.prototype.OPEN="open",h.CLOSED=h.prototype.CLOSED="closed",h.prototype.uri=function(){var t,e=this.options.query||{},n=this.options.secure?"wss":"ws";if(this.options.timestampRequests&&(e[this.options.timestampParam]=(new Date).getTime()),(e=a.encode(e)).length&&(e="?"+e),this.options.host)t=this.options.host;else{var r="";this.options.port&&("wss"==n&&443!=this.options.port||"ws"==n&&80!=this.options.port)&&(r=":"+this.options.port),t=this.options.hostname+r}return n+"://"+t+this.options.path+e},h.prototype._onOpen=function(){var t=this;clearTimeout(this._connectTimeoutRef),this._resetPingTimeout(),this._handshake((function(e,n){var r;e?(r=n&&n.code?n.code:4003,t._onError(e),t._onClose(r,e.toString()),t.socket.close(r)):(t.state=t.OPEN,i.prototype.emit.call(t,"open",n),t._resetPingTimeout())}))},h.prototype._handshake=function(t){var e=this;this.auth.loadToken(this.authTokenName,(function(n,r){n?t(n):e.emit("#handshake",{authToken:r},{force:!0},(function(e,n){n&&(n.authToken=r,n.authError&&(n.authError=c.hydrateError(n.authError))),t(e,n)}))}))},h.prototype._abortAllPendingEventsDueToBadConnection=function(t){for(var e in this._callbackMap)if(this._callbackMap.hasOwnProperty(e)){var n=this._callbackMap[e];delete this._callbackMap[e],clearTimeout(n.timeout),delete n.timeout;var r="Event '"+n.event+"' was aborted due to a bad connection",o=new l(r,t),i=n.callback;delete n.callback,i.call(n,o,n)}},h.prototype._onClose=function(t,e){delete this.socket.onopen,delete this.socket.onclose,delete this.socket.onmessage,delete this.socket.onerror,clearTimeout(this._connectTimeoutRef),clearTimeout(this._pingTimeoutTicker),clearTimeout(this._batchTimeout),this.state==this.OPEN?(this.state=this.CLOSED,i.prototype.emit.call(this,"close",t,e),this._abortAllPendingEventsDueToBadConnection("disconnect")):this.state==this.CONNECTING&&(this.state=this.CLOSED,i.prototype.emit.call(this,"openAbort",t,e),this._abortAllPendingEventsDueToBadConnection("connectAbort"))},h.prototype._handleEventObject=function(t,e){if(t&&null!=t.event){var n=new s(this,t.cid);i.prototype.emit.call(this,"event",t.event,t.data,n)}else if(t&&null!=t.rid){var r=this._callbackMap[t.rid];if(r&&(clearTimeout(r.timeout),delete r.timeout,delete this._callbackMap[t.rid],r.callback)){var o=c.hydrateError(t.error);r.callback(o,t.data)}}else i.prototype.emit.call(this,"event","raw",e)},h.prototype._onMessage=function(t){i.prototype.emit.call(this,"event","message",t);var e=this.decode(t);if("#1"==e)this._resetPingTimeout(),this.socket.readyState==this.socket.OPEN&&this.sendObject("#2");else if(Array.isArray(e))for(var n=e.length,r=0;r<n;r++)this._handleEventObject(e[r],t);else this._handleEventObject(e,t)},h.prototype._onError=function(t){i.prototype.emit.call(this,"error",t)},h.prototype._resetPingTimeout=function(){if(!this.pingTimeoutDisabled){var t=this;(new Date).getTime(),clearTimeout(this._pingTimeoutTicker),this._pingTimeoutTicker=setTimeout((function(){t._onClose(4e3),t.socket.close(4e3)}),this.pingTimeout)}},h.prototype.getBytesReceived=function(){return this.socket.bytesReceived},h.prototype.close=function(t,e){if(t=t||1e3,this.state==this.OPEN){var n={code:t,data:e};this.emit("#disconnect",n),this._onClose(t,e),this.socket.close(t)}else this.state==this.CONNECTING&&(this._onClose(t,e),this.socket.close(t))},h.prototype.emitObject=function(t,e){var n={event:t.event,data:t.data};return t.callback&&(n.cid=t.cid=this.callIdGenerator(),this._callbackMap[t.cid]=t),this.sendObject(n,e),t.cid||null},h.prototype._handleEventAckTimeout=function(t){t.cid&&delete this._callbackMap[t.cid],delete t.timeout;var e=t.callback;if(e){delete t.callback;var n=new u("Event response for '"+t.event+"' timed out");e.call(t,n,t)}},h.prototype.emit=function(t,e,n,r){var o,i,s=this;r?(i=n,o=r):n instanceof Function?(i={},o=n):i=n;var a={event:t,data:e,callback:o};o&&!i.noTimeout&&(a.timeout=setTimeout((function(){s._handleEventAckTimeout(a)}),this.options.ackTimeout));var c=null;return(this.state==this.OPEN||i.force)&&(c=this.emitObject(a,i)),c},h.prototype.cancelPendingResponse=function(t){delete this._callbackMap[t]},h.prototype.decode=function(t){return this.codec.decode(t)},h.prototype.encode=function(t){return this.codec.encode(t)},h.prototype.send=function(t){this.socket.readyState!=this.socket.OPEN?this._onClose(1005):this.socket.send(t)},h.prototype.serializeObject=function(t){var e,n;try{e=this.encode(t)}catch(t){n=t,this._onError(n)}return n?null:e},h.prototype.sendObjectBatch=function(t){var e=this;this._batchSendList.push(t),this._batchTimeout||(this._batchTimeout=setTimeout((function(){if(delete e._batchTimeout,e._batchSendList.length){var t=e.serializeObject(e._batchSendList);null!=t&&e.send(t),e._batchSendList=[]}}),this.options.pubSubBatchDuration||0))},h.prototype.sendObjectSingle=function(t){var e=this.serializeObject(t);null!=e&&this.send(e)},h.prototype.sendObject=function(t,e){e&&e.batch?this.sendObjectBatch(t):this.sendObjectSingle(t)},t.exports.U=h},560:t=>{var e,n=(e="undefined"!=typeof WorkerGlobalScope?self:"undefined"!=typeof window&&window||function(){return this}()).WebSocket||e.MozWebSocket;function r(t,e,r){return e?new n(t,e):new n(t)}n&&(r.prototype=n.prototype),t.exports=n?r:null},634:t=>{var e=function(){"use strict";function t(t,e){return null!=e&&t instanceof e}var e,n,r;try{e=Map}catch(t){e=function(){}}try{n=Set}catch(t){n=function(){}}try{r=Promise}catch(t){r=function(){}}function o(i,a,c,u,l){"object"==typeof a&&(c=a.depth,u=a.prototype,l=a.includeNonEnumerable,a=a.circular);var h=[],p=[],d="undefined"!=typeof Buffer;return void 0===a&&(a=!0),void 0===c&&(c=1/0),function i(c,f){if(null===c)return null;if(0===f)return c;var y,m;if("object"!=typeof c)return c;if(t(c,e))y=new e;else if(t(c,n))y=new n;else if(t(c,r))y=new r((function(t,e){c.then((function(e){t(i(e,f-1))}),(function(t){e(i(t,f-1))}))}));else if(o.__isArray(c))y=[];else if(o.__isRegExp(c))y=new RegExp(c.source,s(c)),c.lastIndex&&(y.lastIndex=c.lastIndex);else if(o.__isDate(c))y=new Date(c.getTime());else{if(d&&Buffer.isBuffer(c))return y=new Buffer(c.length),c.copy(y),y;t(c,Error)?y=Object.create(c):void 0===u?(m=Object.getPrototypeOf(c),y=Object.create(m)):(y=Object.create(u),m=u)}if(a){var g=h.indexOf(c);if(-1!=g)return p[g];h.push(c),p.push(y)}for(var v in t(c,e)&&c.forEach((function(t,e){var n=i(e,f-1),r=i(t,f-1);y.set(n,r)})),t(c,n)&&c.forEach((function(t){var e=i(t,f-1);y.add(e)})),c){var b;m&&(b=Object.getOwnPropertyDescriptor(m,v)),b&&null==b.set||(y[v]=i(c[v],f-1))}if(Object.getOwnPropertySymbols){var E=Object.getOwnPropertySymbols(c);for(v=0;v<E.length;v++){var k=E[v];(!(T=Object.getOwnPropertyDescriptor(c,k))||T.enumerable||l)&&(y[k]=i(c[k],f-1),T.enumerable||Object.defineProperty(y,k,{enumerable:!1}))}}if(l){var S=Object.getOwnPropertyNames(c);for(v=0;v<S.length;v++){var T,O=S[v];(T=Object.getOwnPropertyDescriptor(c,O))&&T.enumerable||(y[O]=i(c[O],f-1),Object.defineProperty(y,O,{enumerable:!1}))}}return y}(i,c)}function i(t){return Object.prototype.toString.call(t)}function s(t){var e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),e}return o.clonePrototype=function(t){if(null===t)return null;var e=function(){};return e.prototype=t,new e},o.__objToStr=i,o.__isDate=function(t){return"object"==typeof t&&"[object Date]"===i(t)},o.__isArray=function(t){return"object"==typeof t&&"[object Array]"===i(t)},o.__isRegExp=function(t){return"object"==typeof t&&"[object RegExp]"===i(t)},o.__getRegExpFlags=s,o}();t.exports&&(t.exports=e)},214:t=>{function e(t){if(t)return function(t){for(var n in e.prototype)t[n]=e.prototype[n];return t}(t)}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},e.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var o=0;o<r.length;o++)if((n=r[o])===e||n.fn===e){r.splice(o,1);break}return this},e.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,e);return this},e.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},e.prototype.hasListeners=function(t){return!!this.listeners(t).length}},699:t=>{"use strict";function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,n,r,o){n=n||"&",r=r||"=";var i={};if("string"!=typeof t||0===t.length)return i;var s=/\+/g;t=t.split(n);var a=1e3;o&&"number"==typeof o.maxKeys&&(a=o.maxKeys);var c=t.length;a>0&&c>a&&(c=a);for(var u=0;u<c;++u){var l,h,p,d,f=t[u].replace(s,"%20"),y=f.indexOf(r);y>=0?(l=f.substr(0,y),h=f.substr(y+1)):(l=f,h=""),p=decodeURIComponent(l),d=decodeURIComponent(h),e(i,p)?Array.isArray(i[p])?i[p].push(d):i[p]=[i[p],d]:i[p]=d}return i}},836:t=>{"use strict";var e=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,n,r,o){return n=n||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map((function(o){var i=encodeURIComponent(e(o))+r;return Array.isArray(t[o])?t[o].map((function(t){return i+encodeURIComponent(e(t))})).join(n):i+encodeURIComponent(e(t[o]))})).join(n):o?encodeURIComponent(e(o))+r+encodeURIComponent(e(t)):""}},347:(t,e,n)=>{"use strict";e.decode=e.parse=n(699),e.encode=e.stringify=n(836)},270:(t,e,n)=>{var r=n(593),o=n(130),i=o;i.v1=r,i.v4=o,t.exports=i},623:t=>{for(var e=[],n=0;n<256;++n)e[n]=(n+256).toString(16).substr(1);t.exports=function(t,n){var r=n||0,o=e;return o[t[r++]]+o[t[r++]]+o[t[r++]]+o[t[r++]]+"-"+o[t[r++]]+o[t[r++]]+"-"+o[t[r++]]+o[t[r++]]+"-"+o[t[r++]]+o[t[r++]]+"-"+o[t[r++]]+o[t[r++]]+o[t[r++]]+o[t[r++]]+o[t[r++]]+o[t[r++]]}},80:t=>{var e="undefined"!=typeof crypto&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&msCrypto.getRandomValues.bind(msCrypto);if(e){var n=new Uint8Array(16);t.exports=function(){return e(n),n}}else{var r=new Array(16);t.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),r[e]=t>>>((3&e)<<3)&255;return r}}},593:(t,e,n)=>{var r,o,i=n(80),s=n(623),a=0,c=0;t.exports=function(t,e,n){var u=e&&n||0,l=e||[],h=(t=t||{}).node||r,p=void 0!==t.clockseq?t.clockseq:o;if(null==h||null==p){var d=i();null==h&&(h=r=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==p&&(p=o=16383&(d[6]<<8|d[7]))}var f=void 0!==t.msecs?t.msecs:(new Date).getTime(),y=void 0!==t.nsecs?t.nsecs:c+1,m=f-a+(y-c)/1e4;if(m<0&&void 0===t.clockseq&&(p=p+1&16383),(m<0||f>a)&&void 0===t.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=f,c=y,o=p;var g=(1e4*(268435455&(f+=122192928e5))+y)%4294967296;l[u++]=g>>>24&255,l[u++]=g>>>16&255,l[u++]=g>>>8&255,l[u++]=255&g;var v=f/4294967296*1e4&268435455;l[u++]=v>>>8&255,l[u++]=255&v,l[u++]=v>>>24&15|16,l[u++]=v>>>16&255,l[u++]=p>>>8|128,l[u++]=255&p;for(var b=0;b<6;++b)l[u+b]=h[b];return e||s(l)}},130:(t,e,n)=>{var r=n(80),o=n(623);t.exports=function(t,e,n){var i=e&&n||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var s=(t=t||{}).random||(t.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e)for(var a=0;a<16;++a)e[i+a]=s[a];return e||o(s)}},746:e=>{"use strict";e.exports=t},802:t=>{"use strict";t.exports=n},407:t=>{"use strict";t.exports=r},156:t=>{"use strict";t.exports=o},952:t=>{"use strict";t.exports=e}},s={};function a(t){var e=s[t];if(void 0!==e)return e.exports;var n=s[t]={id:t,loaded:!1,exports:{}};return i[t].call(n.exports,n,n.exports,a),n.loaded=!0,n.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var c={};return(()=>{"use strict";a.r(c),a.d(c,{default:()=>_t,withOnyx:()=>wt});var t=a(746),e=a(952),n=a.n(e);let r=()=>{};function o(t){r({message:`[Onyx] ${t}`,level:"alert"})}function i(t){r({message:`[Onyx] ${t}`,level:"info"})}function s(t){return null!=t&&"object"==typeof t&&"[object RegExp]"!==Object.prototype.toString.call(t)&&"[object Date]"!==Object.prototype.toString.call(t)}const u=function t(e,n){return Array.isArray(n)?n:function(e,n){const r={};if(s(e)){const t=Object.keys(e);for(let n=0;n<t.length;++n){const o=t[n];r[o]=e[o]}}const o=Object.keys(n);for(let i=0;i<o.length;++i){const a=o[i];void 0!==n[a]&&(s(n[a])&&e[a]?r[a]=t(e[a],n[a]):r[a]=n[a])}return r}(e,n)},l=n().negate(n().isUndefined),h=new class{constructor(){this.storageKeys=new Set,this.recentKeys=new Set,this.storageMap={},this.pendingPromises={},n().bindAll(this,"getAllKeys","getValue","hasCacheForKey","addKey","set","drop","merge","hasPendingTask","getTaskPromise","captureTask","removeLeastRecentlyUsedKeys","setRecentKeysLimit")}getAllKeys(){return Array.from(this.storageKeys)}getValue(t){return this.addToAccessedKeys(t),this.storageMap[t]}hasCacheForKey(t){return l(this.storageMap[t])}addKey(t){this.storageKeys.add(t)}set(t,e){return this.addKey(t),this.addToAccessedKeys(t),this.storageMap[t]=e,e}drop(t){delete this.storageMap[t],this.storageKeys.delete(t),this.recentKeys.delete(t)}merge(t){if(!n().isObject(t)||n().isArray(t))throw new Error("data passed to cache.merge() must be an Object of onyx key/value pairs");this.storageMap=Object.assign({},u(this.storageMap,t));const e=this.getAllKeys(),r=n().keys(t);this.storageKeys=new Set([...e,...r]),n().each(r,(t=>this.addToAccessedKeys(t)))}hasPendingTask(t){return l(this.pendingPromises[t])}getTaskPromise(t){return this.pendingPromises[t]}captureTask(t,e){return this.pendingPromises[t]=e.finally((()=>{delete this.pendingPromises[t]})),this.pendingPromises[t]}addToAccessedKeys(t){this.recentKeys.delete(t),this.recentKeys.add(t)}removeLeastRecentlyUsedKeys(){if(this.recentKeys.size<=this.maxRecentKeysSize)return;const t=[...this.recentKeys].slice(-this.maxRecentKeysSize),e=n().keys(this.storageMap),r=n().difference(e,t);n().each(r,this.drop)}setRecentKeysLimit(t){this.maxRecentKeysSize=t}hasValueChanged(e,n){return!(0,t.deepEqual)(this.storageMap[e],n)}};function p(t,e){return n().isString(t)&&n().isString(e)&&t.startsWith(e)}function d(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];return n().isFunction(t)?t(...r):t}var f=a(407),y=a.n(f);let m=!1;function g(t){m=t}function v(t,e,r,o,i){if(!m)return;const s={};i&&(s.keyThatChanged=i),n().isObject(r)&&n().isObject(e)?s.difference=function t(e,r){return y()(e,((e,o,i)=>{n().isEqual(o,r[i])||(e[i]=n().isObject(o)&&n().isObject(r[i])?t(o,r[i]):o)}))}(e,r):(s.previousValue=e,s.newValue=r),console.debug(`[Onyx-Debug] ${t.displayName} setState() called. Subscribed to key '${t.key}' (${o})`,s)}var b=a(802);let E;const k=()=>(E||(E=(0,b.createStore)("OnyxDB","keyvaluepairs")),E),S={setItem:(t,e)=>(0,b.set)(t,e,k()),multiGet:t=>(0,b.getMany)(t,k()).then((e=>n().map(e,((e,n)=>[t[n],e])))),multiMerge:t=>k()("readwrite",(e=>Promise.all(n().map(t,(t=>{let[n]=t;return(0,b.promisifyRequest)(e.get(n))}))).then((r=>{const o=n().map(t,((t,o)=>{let[i,s]=t;const a=r[o],c=n().isObject(a)?u(a,s):s;return(0,b.promisifyRequest)(e.put(c,i))}));return Promise.all(o)})))),mergeItem:(t,e,n)=>S.multiMerge([[t,n]]),multiSet:t=>(0,b.setMany)(t,k()),clear:()=>(0,b.clear)(k()),setMemoryOnlyKeys:()=>{},getAllKeys:()=>(0,b.keys)(k()),getItem:t=>(0,b.get)(t,k()),removeItem:t=>(0,b.del)(t,k()),removeItems:t=>(0,b.delMany)(t,k()),getDatabaseSize(){if(!window.navigator||!window.navigator.storage)throw new Error("StorageManager browser API unavailable");return window.navigator.storage.estimate().then((t=>({bytesUsed:t.usage,bytesRemaining:t.quota-t.usage}))).catch((t=>{throw new Error(`Unable to estimate web storage quota. Original error: ${t}`)}))}},T=S,O="SYNC_ONYX";function w(t){a.g.localStorage.setItem(O,t),a.g.localStorage.removeItem(O,t)}const _={...T,keepInstancesSync(t){this.setItem=(t,e)=>T.setItem(t,e).then((()=>w(t))),this.removeItem=t=>T.removeItem(t).then((()=>w(t))),this.removeItems=t=>T.removeItems(t).then((()=>{return e=t,void n().each(e,(t=>{w(t)}));var e})),this.clear=()=>{let t;return T.getAllKeys().then((e=>{t=e})).then((()=>T.clear())).then((()=>{n().each(t,w)}))},a.g.addEventListener("storage",(e=>{if(e.key!==O||!e.newValue)return;const n=e.newValue;T.getItem(n).then((e=>t(n,e)))}))}},{connectViaExtension:C}=a(53),x=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.state=t,this.remotedev=C(),this.remotedev.init(this.state)}registerAction(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={...this.state,...n};this.remotedev.send({type:t,payload:e},r),this.state=r}clearState(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=n().map(t,(t=>[t,void 0]));this.registerAction("CLEAR",void 0,n().object(e))}},A={SET:"set",MERGE:"merge",MERGE_COLLECTION:"mergecollection",MULTI_SET:"multiset",CLEAR:"clear"},I={};let N=0;const P={};let j=new Map,R=[],D=[],M={registerAction:()=>{},clearState:()=>{}};const U={};let B={};const L=function(){const t={};return t.promise=new Promise((e=>{t.resolve=e})),t}(),$=(t,e,n)=>e(t,n),K=(t,e,r)=>n().reduce(t,((t,n,o)=>(t[o]=$(n,e,r),t)),{});function F(t){if(h.hasCacheForKey(t))return Promise.resolve(h.getValue(t));const e=`get:${t}`;if(h.hasPendingTask(e))return h.getTaskPromise(e);const n=_.getItem(t).then((e=>(h.set(t,e),e))).catch((e=>i(`Unable to get item from persistent storage. Key: ${t} Error: ${e}`)));return h.captureTask(e,n)}function q(){const t=h.getAllKeys();if(t.length>0)return Promise.resolve(t);const e="getAllKeys";if(h.hasPendingTask(e))return h.getTaskPromise(e);const r=_.getAllKeys().then((t=>(n().each(t,(t=>h.addKey(t))),t)));return h.captureTask(e,r)}function G(t){return j.has(t)}function V(t,e){return p(e,t)&&e.length>t.length}function W(t,e){return G(t)?p(e,t):t===e}function H(t){return n().some(D,(e=>W(e,t)))}function J(t){R=n().without(R,t)}function z(t){!G(t)&&H(t)&&(J(t),R.push(t))}function X(t,e){U[t]=n().without(U[t]||[],e),0===U[t].length&&delete U[t]}function Y(t){const e=n().filter(h.getAllKeys(),(e=>V(t,e)));return n().reduce(e,((t,e)=>{const n=h.getValue(e);return n?(t[e]=n,t):t}),{})}function Q(e,r){const o=n().keys(P);for(let i=0;i<o.length;i++){const s=P[o[i]];if(!s)continue;if(!p(s.key,e))continue;const a=s.key===e,c=V(e,s.key),u=Y(e);if(n().isFunction(s.callback)){if(a){if(s.waitForCollectionCallback){s.callback(u);continue}const t=n().keys(r);for(let e=0;e<t.length;e++){const n=t[e];s.callback(u[n],n)}continue}if(c){s.callback(u[s.key],s.key);continue}}else if(s.withOnyxInstance){if(a){if(s.selector){s.withOnyxInstance.setState((e=>{const n=e[s.statePropertyName],r=K(u,s.selector,s.withOnyxInstance.state);return(0,t.deepEqual)(n,r)?null:{[s.statePropertyName]:r}}));continue}s.withOnyxInstance.setState((t=>{const o=n().clone(t[s.statePropertyName]||{}),i=n().keys(r);for(let t=0;t<i.length;t++){const e=i[t];o[e]=u[e]}return v(s,t[s.statePropertyName],o,"keysChanged",e),{[s.statePropertyName]:o}}));continue}if(c){const o=r[s.key];if(n().isUndefined(o))continue;if(s.selector){s.withOnyxInstance.setState((n=>{const r=n[s.statePropertyName],o=$(u[s.key],s.selector,s.withOnyxInstance.state);return(0,t.deepEqual)(r,o)?null:(v(s,r,o,"keysChanged",e),{[s.statePropertyName]:o})}));continue}s.withOnyxInstance.setState((t=>{const n=u[s.key],r=t[s.statePropertyName];return n===r?null:(v(s,r,n,"keysChanged",e),{[s.statePropertyName]:n})}))}}}}function Z(e,r,o){n().isNull(r)?J(e):z(e);const i=n().keys(P);for(let s=0;s<i.length;s++){const a=P[i[s]];if(a&&W(a.key,e)&&(!n().isFunction(o)||o(a)))if(n().isFunction(a.callback)){if(G(a.key)&&a.waitForCollectionCallback){const t=Y(a.key);t[e]=r,a.callback(t);continue}a.callback(r,e)}else if(a.withOnyxInstance){if(G(a.key)){if(a.selector){a.withOnyxInstance.setState((n=>{const o=n[a.statePropertyName],i={[e]:$(r,a.selector,a.withOnyxInstance.state)},s={...o,...i};return(0,t.deepEqual)(o,s)?null:(v(a,o,i,"keyChanged",e),{[a.statePropertyName]:s})}));continue}a.withOnyxInstance.setState((t=>{const n=t[a.statePropertyName]||{},o={...n,[e]:r};return v(a,n,o,"keyChanged",e),{[a.statePropertyName]:o}}));continue}if(a.selector){a.withOnyxInstance.setState((e=>{const n=$(e[a.statePropertyName],a.selector,a.withOnyxInstance.state),o=$(r,a.selector,a.withOnyxInstance.state);return(0,t.deepEqual)(n,o)?null:{[a.statePropertyName]:o}}));continue}a.withOnyxInstance.setState((t=>{const n=t[a.statePropertyName];return n===r?null:(v(a,n,r,"keyChanged",e),{[a.statePropertyName]:r})}))}else console.error("Warning: Found a matching subscriber to a key that changed, but no callback or withOnyxInstance could be found.")}}function tt(t,e,r){if(P[t.connectionID]){if(t.withOnyxInstance){let n=e;return t.selector&&(n=G(t.key)?K(e,t.selector,t.withOnyxInstance.state):$(e,t.selector,t.withOnyxInstance.state)),v(t,null,n,"sendDataToConnection"),void t.withOnyxInstance.setWithOnyxState(t.statePropertyName,n)}n().isFunction(t.callback)&&t.callback(e,r)}}function et(t,e){Promise.all(n().map(t,(t=>F(t)))).then((e=>n().reduce(e,((e,n,r)=>(e[t[r]]=n,e)),{}))).then((t=>tt(e,t)))}function nt(t,e,n){Promise.resolve().then((()=>Z(t,e,n)))}function rt(t){return h.drop(t),nt(t,null),_.removeItem(t).then((e=>(M.registerAction(`REMOVE/${t.toUpperCase()}`,void 0,{[t]:void 0}),e)))}function ot(){return _.getDatabaseSize().then((t=>{let{bytesUsed:e,bytesRemaining:n}=t;i(`Storage Quota Check -- bytesUsed: ${e} bytesRemaining: ${n}`)})).catch((t=>{o(`Unable to get database size. Error: ${t}`)}))}function it(t,e){for(var r=arguments.length,s=new Array(r>2?r-2:0),a=2;a<r;a++)s[a-2]=arguments[a];if(i(`Failed to save to storage. Error: ${t}. onyxMethod: ${e.name}`),t&&p(t.message,"Failed to execute 'put' on 'IDBObjectStore'"))throw o("Attempted to set invalid data set in Onyx. Please ensure all data is serializable."),t;const c=n().find(R,(t=>!U[t]));return c?(i(`Out of storage. Evicting least recently accessed key (${c}) and retrying.`),ot(),rt(c).then((()=>e(...s)))):(o("Out of storage. But found no acceptable keys to remove."),ot())}function st(t,e,r,o){i(`${o}() called for key: ${t}${n().isObject(e)?` properties: ${n().keys(e).join(",")}`:""}`),r?h.set(t,e):h.addToAccessedKeys(t),nt(t,e,(t=>r||!1===t.initWithStoredValues))}function at(t){return Boolean(I[t])}function ct(t){return n().isArray(t)||!n().isObject(t)?t:n().omit(t,(t=>n().isNull(t)))}function ut(t,e){if(n().isNull(e))return rt(t);at(t)&&o(`Onyx.set() called after Onyx.merge() for key: ${t}. It is recommended to use set() or merge() not both.`);const r=ct(e),i=h.hasValueChanged(t,r);return st(t,e,"set"),st(t,r,i,"set"),i?_.setItem(t,r).then((e=>(M.registerAction(`SET/${t.toUpperCase()}`,r,{[t]:r}),e))).catch((e=>it(e,ut,t,r))):Promise.resolve()}function lt(t){return n().map(t,((t,e)=>[e,t]))}function ht(t){const e=lt(t);return n().each(t,((t,e)=>{h.set(e,t),nt(e,t),n().isNull(t)?M.registerAction(`REMOVE/${e.toUpperCase()}`,t,{[e]:void 0}):M.registerAction(`SET/${e.toUpperCase()}`,t,{[e]:t})})),_.multiSet(e).catch((e=>it(e,ht,t)))}function pt(t,e){const r=n().last(e);return n().isArray(t)||n().isArray(r)?r:n().isObject(t)||n().every(e,n().isObject)?n().reduce(e,((t,e)=>u(t,e)),t||{}):r}function dt(t,e){return I[t]?(I[t].push(e),Promise.resolve()):(I[t]=[e],F(t).then((e=>{try{let n=pt(void 0,I[t]);delete I[t];const r=ct(pt(e,[n]));e||(n=ct(n));const o=h.hasValueChanged(t,r);return st(t,r,o,"merge"),o?_.mergeItem(t,n,r).then((e=>(M.registerAction(`MERGE/${t.toUpperCase()}`,r,{[t]:r}),e))):Promise.resolve()}catch(e){o(`An error occurred while applying merge for key: ${t}, Error: ${e}`)}return Promise.resolve()})))}function ft(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return _.multiGet(n().keys(B)).then((e=>{const r=n().object(e),o=u(r,B);h.merge(o),n().each(o,((t,e)=>Z(e,t))),t&&(M=new x(o))}))}function yt(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return q().then((e=>{const r=[],o={},i={};n().each(e,(e=>{const s=n().contains(t,e),a=n().has(B,e);if(!s){const t=h.getValue(e),r=n().get(B,e,void 0);if(r!==t){h.set(e,r);const t=e.substring(0,e.indexOf("_")+1);t?(o[t]||(o[t]={}),o[t][e]=r):i[e]=r}}s||a||r.push(e)})),n().each(i,((t,e)=>{nt(e,t)})),n().each(o,((t,e)=>{!function(t,e){Promise.resolve().then((()=>Q(t,e)))}(e,t)}));const s=n().omit(B,t),a=n().pairs(s);return n().each(r,(t=>h.drop(t))),_.removeItems(r).then((()=>(M.clearState(r),_.multiSet(a))))}))}function mt(t,e){if(!n().isObject(e)||n().isArray(e)||n().isEmpty(e))return i("mergeCollection() called with invalid or empty value. Skipping this update."),Promise.resolve();let r=!1;return n().each(e,((e,n)=>{W(t,n)||(r=!0,o(`Provided collection doesn't have all its data belonging to the same parent. CollectionKey: ${t}, DataKey: ${n}`))})),r?Promise.resolve():q().then((r=>{const[o,i]=n().chain(e).keys().partition((t=>r.includes(t))).value(),s=n().pick(e,o),a=n().pick(e,i),c=lt(s),u=lt(a),l=[];return c.length>0&&l.push(_.multiMerge(c)),u.length>0&&l.push(_.multiSet(u)),Promise.all(n().map(o,F)).then((()=>{h.merge(e),Q(t,e),n().isNull(e)?M.registerAction(`REMOVE/${t.toUpperCase()}`,e,{[t]:void 0}):M.registerAction(`SET/${t.toUpperCase()}`,e,{[t]:e})})),Promise.all(l).catch((t=>it(t,mt,e)))}))}function gt(t){n().each(t,(t=>{let{onyxMethod:e,key:r,value:o}=t;if(!n().contains([A.CLEAR,A.SET,A.MERGE,A.MERGE_COLLECTION,A.MULTI_SET],e))throw new Error(`Invalid onyxMethod ${e} in Onyx update.`);if(e===A.MULTI_SET){if(!n().isObject(o)||n().isArray(o)||n().isFunction(o))throw new Error("Invalid value provided in Onyx multiSet. Onyx multiSet value must be of type object.")}else if(e!==A.CLEAR&&!n().isString(r))throw new Error(`Invalid ${typeof r} key provided in Onyx update. Onyx key must be of type string.`)}));const e=[];let r=Promise.resolve();return n().each(t,(t=>{let{onyxMethod:n,key:o,value:i}=t;switch(n){case A.SET:e.push((()=>ut(o,i)));break;case A.MERGE:e.push((()=>dt(o,i)));break;case A.MERGE_COLLECTION:e.push((()=>mt(o,i)));break;case A.MULTI_SET:e.push((()=>ht(i)));break;case A.CLEAR:r=yt()}})),r.then((()=>Promise.all(n().map(e,(t=>t())))))}const vt={connect:function(t){const e=N++;return P[e]=t,P[e].connectionID=e,!1===t.initWithStoredValues||L.promise.then((()=>function(t){if(H(t.key)&&(h.removeLeastRecentlyUsedKeys(),t.withOnyxInstance&&!G(t.key))){if(n().isUndefined(t.canEvict))throw new Error(`Cannot subscribe to safe eviction key '${t.key}' without providing a canEvict value.`);z(t.key)}}(t))).then(q).then((e=>{const r=n().filter(e,(e=>W(t.key,e)));if(0!==r.length)if(n().isFunction(t.callback)){if(G(t.key)){if(t.waitForCollectionCallback)return void et(r,t);for(let e=0;e<r.length;e++)F(r[e]).then((n=>tt(t,n,r[e])));return}F(t.key).then((e=>tt(t,e,t.key)))}else{if(t.withOnyxInstance)return G(t.key)?void et(r,t):void F(t.key).then((e=>tt(t,e,t.key)));console.error("Warning: Onyx.connect() was found without a callback or withOnyxInstance")}else tt(t,null)})),e},disconnect:function(t,e){P[t]&&(e&&X(e,t),delete P[t])},set:ut,multiSet:ht,merge:dt,mergeCollection:mt,update:gt,clear:yt,getAllKeys:q,init:function(){let{keys:t={},initialKeyStates:e={},safeEvictionKeys:r=[],maxCachedKeysCount:o=1e3,captureMetrics:i=!1,shouldSyncMultipleInstances:s=Boolean(a.g.localStorage),debugSetState:c=!1,enableDevTools:u=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i&&function(){const t=a(378);F=t.decorateWithMetrics(F,"Onyx:get"),ut=t.decorateWithMetrics(ut,"Onyx:set"),ht=t.decorateWithMetrics(ht,"Onyx:multiSet"),yt=t.decorateWithMetrics(yt,"Onyx:clear"),dt=t.decorateWithMetrics(dt,"Onyx:merge"),mt=t.decorateWithMetrics(mt,"Onyx:mergeCollection"),q=t.decorateWithMetrics(q,"Onyx:getAllKeys"),ft=t.decorateWithMetrics(ft,"Onyx:defaults"),gt=t.decorateWithMetrics(gt,"Onyx:update"),vt.set=ut,vt.multiSet=ht,vt.clear=yt,vt.merge=dt,vt.mergeCollection=mt,vt.update=gt,vt.getMetrics=t.getMetrics,vt.resetMetrics=t.resetMetrics,vt.printMetrics=t.printMetrics}(),c&&g(!0),o>0&&h.setRecentKeysLimit(o);const l=n().values(t.COLLECTION);j=n().reduce(l,((t,e)=>(t.set(e,!0),t)),new Map),B=e,D=r,Promise.all([q().then((t=>{n().each(D,(e=>{n().each(t,(t=>{W(e,t)&&z(t)}))}))})),ft(u)]).then(L.resolve),s&&n().isFunction(_.keepInstancesSync)&&_.keepInstancesSync(((t,e)=>{h.set(t,e),Z(t,e),n().isNull(e)?M.registerAction(`REMOVE/${t.toUpperCase()}`,e,{[t]:void 0}):M.registerAction(`SET/${t.toUpperCase()}`,e,{[t]:e})}))},registerLogger:function(t){r=t},addToEvictionBlockList:function(t,e){X(t,e),U[t]||(U[t]=[]),U[t].push(e)},removeFromEvictionBlockList:X,isSafeEvictionKey:H,METHOD:A,setMemoryOnlyKeys:function(t){_.setMemoryOnlyKeys(t),h.setRecentKeysLimit(1/0)},tryGetCachedValue:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=h.getValue(t);if(G(t)){const e=h.getAllKeys(),o=n().filter(e,(e=>e.startsWith(t))),i=n().reduce(o,((t,e)=>{const n=h.getValue(e);return n&&(t[e]=n),t}),{});if(n().isEmpty(i))return;r=i}if(e.selector){const n=e.withOnyxInstance?e.withOnyxInstance.state:void 0;return G(t)?K(r,e.selector,n):$(r,e.selector,n)}return r},hasPendingMergeForKey:at},bt=vt;var Et=a(697),kt=a.n(Et),St=a(156),Tt=a.n(St);function Ot(){return Ot=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Ot.apply(this,arguments)}function wt(t){const e=n().chain(t).omit((t=>!1===t.initWithStoredValues)).keys().value();return r=>{const o=(i=r).displayName||i.name||"Component";var i;class s extends Tt().Component{constructor(r){super(r),this.setWithOnyxState=this.setWithOnyxState.bind(this),this.activeConnectionIDs={};const o=n().reduce(t,((t,e,n)=>{const o=d(e.key,r),i=bt.tryGetCachedValue(o,e);return void 0===i||bt.hasPendingMergeForKey(o)||(t[n]=i),t}),{});o.loading=n().size(o)<e.length,this.tempState=o,this.state=o}componentDidMount(){n().each(t,((t,e)=>{this.connectMappingToOnyx(t,e)})),this.checkEvictableKeys()}componentDidUpdate(e){n().each(t,((t,n)=>{const r=d(t.key,e);r!==d(t.key,this.props)&&(bt.disconnect(this.activeConnectionIDs[r],r),delete this.activeConnectionIDs[r],this.connectMappingToOnyx(t,n))})),this.checkEvictableKeys()}componentWillUnmount(){n().each(t,(t=>{const e=d(t.key,this.props),n=this.activeConnectionIDs[e];bt.disconnect(n,e)}))}setWithOnyxState(t,r){const o=this.state[t];(this.state.loading||o!==r)&&(this.state.loading?(this.tempState[t]=r,n().some(e,(t=>n().isUndefined(this.tempState[t])))||(this.setState((t=>({...n().omit(this.tempState,n().keys(t)),loading:!1}))),delete this.tempState)):this.setState({[t]:r}))}checkEvictableKeys(){n().each(t,(t=>{if(n().isUndefined(t.canEvict))return;const e=d(t.canEvict,this.props),r=d(t.key,this.props);if(!bt.isSafeEvictionKey(r))throw new Error(`canEvict can't be used on key '${r}'. This key must explicitly be flagged as safe for removal by adding it to Onyx.init({safeEvictionKeys: []}).`);e?bt.removeFromEvictionBlockList(r,t.connectionID):bt.addToEvictionBlockList(r,t.connectionID)}))}connectMappingToOnyx(t,e){const n=d(t.key,this.props);this.activeConnectionIDs[n]=bt.connect({...t,key:n,statePropertyName:e,withOnyxInstance:this,displayName:o})}render(){if(this.state.loading)return null;let t=n().omit(this.state,"loading");t=n().omit(t,(t=>n().isNull(t)));const e=n().omit(this.props,(t=>n().isNull(t)));return Tt().createElement(r,Ot({},e,t,{ref:this.props.forwardedRef}))}}return s.propTypes={forwardedRef:kt().oneOfType([kt().func,kt().shape({current:kt().object})])},s.defaultProps={forwardedRef:void 0},s.displayName=`withOnyx(${o})`,Tt().forwardRef(((t,e)=>{const n=s;return Tt().createElement(n,Ot({},t,{forwardedRef:e}))}))}}const _t=bt})(),c})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("fast-equals"),require("underscore"),require("idb-keyval"),require("lodash/transform"),require("react")):"function"==typeof define&&define.amd?define(["fast-equals","underscore","idb-keyval","lodash/transform","react"],t):"object"==typeof exports?exports["react-native-onyx/web"]=t(require("fast-equals"),require("underscore"),require("idb-keyval"),require("lodash/transform"),require("react")):e["react-native-onyx/web"]=t(e["fast-equals"],e.underscore,e["idb-keyval"],e["lodash/transform"],e.react)}(self,((e,t,n,s,r)=>(()=>{var o={378:(e,t,n)=>{"use strict";function s(e){return e}function r(){}function o(){}function i(){}n.r(t),n.d(t,{decorateWithMetrics:()=>s,getMetrics:()=>r,printMetrics:()=>o,resetMetrics:()=>i})},703:(e,t,n)=>{"use strict";var s=n(414);function r(){}function o(){}o.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,o,i){if(i!==s){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:r};return n.PropTypes=n,n}},697:(e,t,n)=>{e.exports=n(703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},746:t=>{"use strict";t.exports=e},802:e=>{"use strict";e.exports=n},407:e=>{"use strict";e.exports=s},156:e=>{"use strict";e.exports=r},952:e=>{"use strict";e.exports=t}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return o[e](n,n.exports,a),n.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return(()=>{"use strict";a.r(c),a.d(c,{default:()=>xe,withOnyx:()=>we});var e=a(746),t=a(952),n=a.n(t);let s=()=>{};function r(e){s({message:`[Onyx] ${e}`,level:"alert"})}function o(e){s({message:`[Onyx] ${e}`,level:"info"})}function i(e){return null!=e&&"object"==typeof e&&"[object RegExp]"!==Object.prototype.toString.call(e)&&"[object Date]"!==Object.prototype.toString.call(e)}const l=function e(t,n){return Array.isArray(n)?n:function(t,n){const s={};if(i(t)){const e=Object.keys(t);for(let n=0;n<e.length;++n){const r=e[n];s[r]=t[r]}}const r=Object.keys(n);for(let o=0;o<r.length;++o){const a=r[o];void 0!==n[a]&&(i(n[a])&&t[a]?s[a]=e(t[a],n[a]):s[a]=n[a])}return s}(t,n)},u=n().negate(n().isUndefined),y=new class{constructor(){this.storageKeys=new Set,this.recentKeys=new Set,this.storageMap={},this.pendingPromises={},n().bindAll(this,"getAllKeys","getValue","hasCacheForKey","addKey","set","drop","merge","hasPendingTask","getTaskPromise","captureTask","removeLeastRecentlyUsedKeys","setRecentKeysLimit")}getAllKeys(){return Array.from(this.storageKeys)}getValue(e){return this.addToAccessedKeys(e),this.storageMap[e]}hasCacheForKey(e){return u(this.storageMap[e])}addKey(e){this.storageKeys.add(e)}set(e,t){return this.addKey(e),this.addToAccessedKeys(e),this.storageMap[e]=t,t}drop(e){delete this.storageMap[e],this.storageKeys.delete(e),this.recentKeys.delete(e)}merge(e){if(!n().isObject(e)||n().isArray(e))throw new Error("data passed to cache.merge() must be an Object of onyx key/value pairs");this.storageMap=Object.assign({},l(this.storageMap,e));const t=this.getAllKeys(),s=n().keys(e);this.storageKeys=new Set([...t,...s]),n().each(s,(e=>this.addToAccessedKeys(e)))}hasPendingTask(e){return u(this.pendingPromises[e])}getTaskPromise(e){return this.pendingPromises[e]}captureTask(e,t){return this.pendingPromises[e]=t.finally((()=>{delete this.pendingPromises[e]})),this.pendingPromises[e]}addToAccessedKeys(e){this.recentKeys.delete(e),this.recentKeys.add(e)}removeLeastRecentlyUsedKeys(){if(this.recentKeys.size<=this.maxRecentKeysSize)return;const e=[...this.recentKeys].slice(-this.maxRecentKeysSize),t=n().keys(this.storageMap),s=n().difference(t,e);n().each(s,this.drop)}setRecentKeysLimit(e){this.maxRecentKeysSize=e}hasValueChanged(t,n){return!(0,e.deepEqual)(this.storageMap[t],n)}};function h(e,t){return n().isString(e)&&n().isString(t)&&e.startsWith(t)}function d(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),r=1;r<t;r++)s[r-1]=arguments[r];return n().isFunction(e)?e(...s):e}var f=a(407),p=a.n(f);let m=!1;function g(e){m=e}function v(e,t,s,r,o){if(!m)return;const i={};o&&(i.keyThatChanged=o),n().isObject(s)&&n().isObject(t)?i.difference=function e(t,s){return p()(t,((t,r,o)=>{n().isEqual(r,s[o])||(t[o]=n().isObject(r)&&n().isObject(s[o])?e(r,s[o]):r)}))}(t,s):(i.previousValue=t,i.newValue=s),console.debug(`[Onyx-Debug] ${e.displayName} setState() called. Subscribed to key '${e.key}' (${r})`,i)}var k=a(802);let b;const O=()=>(b||(b=(0,k.createStore)("OnyxDB","keyvaluepairs")),b),w={setItem:(e,t)=>(0,k.set)(e,t,O()),multiGet:e=>(0,k.getMany)(e,O()).then((t=>n().map(t,((t,n)=>[e[n],t])))),multiMerge:e=>O()("readwrite",(t=>Promise.all(n().map(e,(e=>{let[n]=e;return(0,k.promisifyRequest)(t.get(n))}))).then((s=>{const r=n().map(e,((e,r)=>{let[o,i]=e;const a=s[r],c=n().isObject(a)?l(a,i):i;return(0,k.promisifyRequest)(t.put(c,o))}));return Promise.all(r)})))),mergeItem:(e,t,n)=>w.multiMerge([[e,n]]),multiSet:e=>(0,k.setMany)(e,O()),clear:()=>(0,k.clear)(O()),setMemoryOnlyKeys:()=>{},getAllKeys:()=>(0,k.keys)(O()),getItem:e=>(0,k.get)(e,O()),removeItem:e=>(0,k.del)(e,O()),removeItems:e=>(0,k.delMany)(e,O()),getDatabaseSize(){if(!window.navigator||!window.navigator.storage)throw new Error("StorageManager browser API unavailable");return window.navigator.storage.estimate().then((e=>({bytesUsed:e.usage,bytesRemaining:e.quota-e.usage}))).catch((e=>{throw new Error(`Unable to estimate web storage quota. Original error: ${e}`)}))}},x=w,S="SYNC_ONYX";function I(e){a.g.localStorage.setItem(S,e),a.g.localStorage.removeItem(S,e)}const E={...x,keepInstancesSync(e){this.setItem=(e,t)=>x.setItem(e,t).then((()=>I(e))),this.removeItem=e=>x.removeItem(e).then((()=>I(e))),this.removeItems=e=>x.removeItems(e).then((()=>{return t=e,void n().each(t,(e=>{I(e)}));var t})),this.clear=()=>{let e;return x.getAllKeys().then((t=>{e=t})).then((()=>x.clear())).then((()=>{n().each(e,I)}))},a.g.addEventListener("storage",(t=>{if(t.key!==S||!t.newValue)return;const n=t.newValue;x.getItem(n).then((t=>e(n,t)))}))}},P={SET:"set",MERGE:"merge",MERGE_COLLECTION:"mergecollection",MULTI_SET:"multiset",CLEAR:"clear"},M={};let K=0;const T={};let C=new Map,j=[],A=[];const R={};let N={};const L=function(){const e={};return e.promise=new Promise((t=>{e.resolve=t})),e}(),$=(e,t,n)=>t(e,n),q=(e,t,s)=>n().reduce(e,((e,n,r)=>(e[r]=$(n,t,s),e)),{});function W(e){if(y.hasCacheForKey(e))return Promise.resolve(y.getValue(e));const t=`get:${e}`;if(y.hasPendingTask(t))return y.getTaskPromise(t);const n=E.getItem(e).then((t=>(y.set(e,t),t))).catch((t=>o(`Unable to get item from persistent storage. Key: ${e} Error: ${t}`)));return y.captureTask(t,n)}function F(){const e=y.getAllKeys();if(e.length>0)return Promise.resolve(e);const t="getAllKeys";if(y.hasPendingTask(t))return y.getTaskPromise(t);const s=E.getAllKeys().then((e=>(n().each(e,(e=>y.addKey(e))),e)));return y.captureTask(t,s)}function D(e){return C.has(e)}function U(e,t){return h(t,e)&&t.length>e.length}function _(e,t){return D(e)?h(t,e):e===t}function V(e){return n().some(A,(t=>_(t,e)))}function B(e){j=n().without(j,e)}function G(e){!D(e)&&V(e)&&(B(e),j.push(e))}function z(e,t){R[e]=n().without(R[e]||[],t),0===R[e].length&&delete R[e]}function Y(e){const t=n().filter(y.getAllKeys(),(t=>U(e,t)));return n().reduce(t,((e,t)=>{const n=y.getValue(t);return n?(e[t]=n,e):e}),{})}function H(t,s){const r=n().keys(T);for(let o=0;o<r.length;o++){const i=T[r[o]];if(!i)continue;if(!h(i.key,t))continue;const a=i.key===t,c=U(t,i.key),l=Y(t);if(n().isFunction(i.callback)){if(a){if(i.waitForCollectionCallback){i.callback(l);continue}const e=n().keys(s);for(let t=0;t<e.length;t++){const n=e[t];i.callback(l[n],n)}continue}if(c){i.callback(l[i.key],i.key);continue}}else if(i.withOnyxInstance){if(a){if(i.selector){i.withOnyxInstance.setState((t=>{const n=t[i.statePropertyName],s=q(l,i.selector,i.withOnyxInstance.state);return(0,e.deepEqual)(n,s)?null:{[i.statePropertyName]:s}}));continue}i.withOnyxInstance.setState((e=>{const r=n().clone(e[i.statePropertyName]||{}),o=n().keys(s);for(let e=0;e<o.length;e++){const t=o[e];r[t]=l[t]}return v(i,e[i.statePropertyName],r,"keysChanged",t),{[i.statePropertyName]:r}}));continue}if(c){const r=s[i.key];if(n().isUndefined(r))continue;if(i.selector){i.withOnyxInstance.setState((n=>{const s=n[i.statePropertyName],r=$(l[i.key],i.selector,i.withOnyxInstance.state);return(0,e.deepEqual)(s,r)?null:(v(i,s,r,"keysChanged",t),{[i.statePropertyName]:r})}));continue}i.withOnyxInstance.setState((e=>{const n=l[i.key],s=e[i.statePropertyName];return n===s?null:(v(i,s,n,"keysChanged",t),{[i.statePropertyName]:n})}))}}}}function Q(t,s,r){n().isNull(s)?B(t):G(t);const o=n().keys(T);for(let i=0;i<o.length;i++){const a=T[o[i]];if(a&&_(a.key,t)&&(!n().isFunction(r)||r(a)))if(n().isFunction(a.callback)){if(D(a.key)&&a.waitForCollectionCallback){const e=Y(a.key);e[t]=s,a.callback(e);continue}a.callback(s,t)}else if(a.withOnyxInstance){if(D(a.key)){if(a.selector){a.withOnyxInstance.setState((n=>{const r=n[a.statePropertyName],o={[t]:$(s,a.selector,a.withOnyxInstance.state)},i={...r,...o};return(0,e.deepEqual)(r,i)?null:(v(a,r,o,"keyChanged",t),{[a.statePropertyName]:i})}));continue}a.withOnyxInstance.setState((e=>{const n=e[a.statePropertyName]||{},r={...n,[t]:s};return v(a,n,r,"keyChanged",t),{[a.statePropertyName]:r}}));continue}if(a.selector){a.withOnyxInstance.setState((t=>{const n=$(t[a.statePropertyName],a.selector,a.withOnyxInstance.state),r=$(s,a.selector,a.withOnyxInstance.state);return(0,e.deepEqual)(n,r)?null:{[a.statePropertyName]:r}}));continue}a.withOnyxInstance.setState((e=>{const n=e[a.statePropertyName];return n===s?null:(v(a,n,s,"keyChanged",t),{[a.statePropertyName]:s})}))}else console.error("Warning: Found a matching subscriber to a key that changed, but no callback or withOnyxInstance could be found.")}}function X(e,t,s){if(T[e.connectionID]){if(e.withOnyxInstance){let n=t;return e.selector&&(n=D(e.key)?q(t,e.selector,e.withOnyxInstance.state):$(t,e.selector,e.withOnyxInstance.state)),v(e,null,n,"sendDataToConnection"),void e.withOnyxInstance.setWithOnyxState(e.statePropertyName,n)}n().isFunction(e.callback)&&e.callback(t,s)}}function J(e,t){Promise.all(n().map(e,(e=>W(e)))).then((t=>n().reduce(t,((t,n,s)=>(t[e[s]]=n,t)),{}))).then((e=>X(t,e)))}function Z(e,t,n){Promise.resolve().then((()=>Q(e,t,n)))}function ee(e){return y.drop(e),Z(e,null),E.removeItem(e)}function te(){return E.getDatabaseSize().then((e=>{let{bytesUsed:t,bytesRemaining:n}=e;o(`Storage Quota Check -- bytesUsed: ${t} bytesRemaining: ${n}`)})).catch((e=>{r(`Unable to get database size. Error: ${e}`)}))}function ne(e,t){for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];if(o(`Failed to save to storage. Error: ${e}. onyxMethod: ${t.name}`),e&&h(e.message,"Failed to execute 'put' on 'IDBObjectStore'"))throw r("Attempted to set invalid data set in Onyx. Please ensure all data is serializable."),e;const c=n().find(j,(e=>!R[e]));return c?(o(`Out of storage. Evicting least recently accessed key (${c}) and retrying.`),te(),ee(c).then((()=>t(...i)))):(r("Out of storage. But found no acceptable keys to remove."),te())}function se(e,t,s,r){o(`${r}() called for key: ${e}${n().isObject(t)?` properties: ${n().keys(t).join(",")}`:""}`),s?y.set(e,t):y.addToAccessedKeys(e),Z(e,t,(e=>s||!1===e.initWithStoredValues))}function re(e){return Boolean(M[e])}function oe(e){return n().isArray(e)||!n().isObject(e)?e:n().omit(e,(e=>n().isNull(e)))}function ie(e,t){if(n().isNull(t))return ee(e);re(e)&&r(`Onyx.set() called after Onyx.merge() for key: ${e}. It is recommended to use set() or merge() not both.`);const s=oe(t),o=y.hasValueChanged(e,s);return se(e,s,o,"set"),o?E.setItem(e,s).catch((t=>ne(t,ie,e,s))):Promise.resolve()}function ae(e){return n().map(e,((e,t)=>[t,e]))}function ce(e){const t=ae(e);return n().each(e,((e,t)=>{y.set(t,e),Z(t,e)})),E.multiSet(t).catch((t=>ne(t,ce,e)))}function le(e,t){const s=n().last(t);return n().isArray(e)||n().isArray(s)?s:n().isObject(e)||n().every(t,n().isObject)?n().reduce(t,((e,t)=>l(e,t)),e||{}):s}function ue(e,t){return M[e]?(M[e].push(t),Promise.resolve()):(M[e]=[t],W(e).then((t=>{try{let n=le(void 0,M[e]);delete M[e];const s=oe(le(t,[n]));t||(n=oe(n));const r=y.hasValueChanged(e,s);return se(e,s,r,"merge"),r?E.mergeItem(e,n,s):Promise.resolve()}catch(t){r(`An error occurred while applying merge for key: ${e}, Error: ${t}`)}return Promise.resolve()})))}function ye(){return E.multiGet(n().keys(N)).then((e=>{const t=n().object(e),s=l(t,N);y.merge(s),n().each(s,((e,t)=>Q(t,e)))}))}function he(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return F().then((t=>{const s=[],r={},o={};n().each(t,(t=>{const i=n().contains(e,t),a=n().has(N,t);if(!i){const e=y.getValue(t),s=n().get(N,t,null);if(s!==e){y.set(t,s);const e=t.substring(0,t.indexOf("_")+1);e?(r[e]||(r[e]={}),r[e][t]=s):o[t]=s}}i||a||s.push(t)})),n().each(o,((e,t)=>{Z(t,e)})),n().each(r,((e,t)=>{!function(e,t){Promise.resolve().then((()=>H(e,t)))}(t,e)}));const i=n().pairs(n().omit(N,e));return n().each(s,(e=>y.drop(e))),E.removeItems(s).then((()=>E.multiSet(i)))}))}function de(e,t){if(!n().isObject(t)||n().isArray(t)||n().isEmpty(t))return o("mergeCollection() called with invalid or empty value. Skipping this update."),Promise.resolve();let s=!1;return n().each(t,((t,n)=>{_(e,n)||(s=!0,r(`Provided collection doesn't have all its data belonging to the same parent. CollectionKey: ${e}, DataKey: ${n}`))})),s?Promise.resolve():F().then((s=>{const[r,o]=n().chain(t).keys().partition((e=>s.includes(e))).value(),i=n().pick(t,r),a=n().pick(t,o),c=ae(i),l=ae(a),u=[];return c.length>0&&u.push(E.multiMerge(c)),l.length>0&&u.push(E.multiSet(l)),Promise.all(n().map(r,W)).then((()=>{y.merge(t),H(e,t)})),Promise.all(u).catch((e=>ne(e,de,t)))}))}function fe(e){n().each(e,(e=>{let{onyxMethod:t,key:s,value:r}=e;if(!n().contains([P.CLEAR,P.SET,P.MERGE,P.MERGE_COLLECTION,P.MULTI_SET],t))throw new Error(`Invalid onyxMethod ${t} in Onyx update.`);if(t===P.MULTI_SET){if(!n().isObject(r)||n().isArray(r)||n().isFunction(r))throw new Error("Invalid value provided in Onyx multiSet. Onyx multiSet value must be of type object.")}else if(t!==P.CLEAR&&!n().isString(s))throw new Error(`Invalid ${typeof s} key provided in Onyx update. Onyx key must be of type string.`)}));const t=[];let s=Promise.resolve();return n().each(e,(e=>{let{onyxMethod:n,key:r,value:o}=e;switch(n){case P.SET:t.push((()=>ie(r,o)));break;case P.MERGE:t.push((()=>ue(r,o)));break;case P.MERGE_COLLECTION:t.push((()=>de(r,o)));break;case P.MULTI_SET:t.push((()=>ce(o)));break;case P.CLEAR:s=he()}})),s.then((()=>Promise.all(n().map(t,(e=>e())))))}const pe={connect:function(e){const t=K++;return T[t]=e,T[t].connectionID=t,!1===e.initWithStoredValues||L.promise.then((()=>function(e){if(V(e.key)&&(y.removeLeastRecentlyUsedKeys(),e.withOnyxInstance&&!D(e.key))){if(n().isUndefined(e.canEvict))throw new Error(`Cannot subscribe to safe eviction key '${e.key}' without providing a canEvict value.`);G(e.key)}}(e))).then(F).then((t=>{const s=n().filter(t,(t=>_(e.key,t)));if(0!==s.length)if(n().isFunction(e.callback)){if(D(e.key)){if(e.waitForCollectionCallback)return void J(s,e);for(let t=0;t<s.length;t++)W(s[t]).then((n=>X(e,n,s[t])));return}W(e.key).then((t=>X(e,t,e.key)))}else{if(e.withOnyxInstance)return D(e.key)?void J(s,e):void W(e.key).then((t=>X(e,t,e.key)));console.error("Warning: Onyx.connect() was found without a callback or withOnyxInstance")}else X(e,null)})),t},disconnect:function(e,t){T[e]&&(t&&z(t,e),delete T[e])},set:ie,multiSet:ce,merge:ue,mergeCollection:de,update:fe,clear:he,getAllKeys:F,init:function(){let{keys:e={},initialKeyStates:t={},safeEvictionKeys:s=[],maxCachedKeysCount:r=1e3,captureMetrics:o=!1,shouldSyncMultipleInstances:i=Boolean(a.g.localStorage),debugSetState:c=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o&&function(){const e=a(378);W=e.decorateWithMetrics(W,"Onyx:get"),ie=e.decorateWithMetrics(ie,"Onyx:set"),ce=e.decorateWithMetrics(ce,"Onyx:multiSet"),he=e.decorateWithMetrics(he,"Onyx:clear"),ue=e.decorateWithMetrics(ue,"Onyx:merge"),de=e.decorateWithMetrics(de,"Onyx:mergeCollection"),F=e.decorateWithMetrics(F,"Onyx:getAllKeys"),ye=e.decorateWithMetrics(ye,"Onyx:defaults"),fe=e.decorateWithMetrics(fe,"Onyx:update"),pe.set=ie,pe.multiSet=ce,pe.clear=he,pe.merge=ue,pe.mergeCollection=de,pe.update=fe,pe.getMetrics=e.getMetrics,pe.resetMetrics=e.resetMetrics,pe.printMetrics=e.printMetrics}(),c&&g(!0),r>0&&y.setRecentKeysLimit(r);const l=n().values(e.COLLECTION);C=n().reduce(l,((e,t)=>(e.set(t,!0),e)),new Map),N=t,A=s,Promise.all([F().then((e=>{n().each(A,(t=>{n().each(e,(e=>{_(t,e)&&G(e)}))}))})),ye()]).then(L.resolve),i&&n().isFunction(E.keepInstancesSync)&&E.keepInstancesSync(((e,t)=>{y.set(e,t),Q(e,t)}))},registerLogger:function(e){s=e},addToEvictionBlockList:function(e,t){z(e,t),R[e]||(R[e]=[]),R[e].push(t)},removeFromEvictionBlockList:z,isSafeEvictionKey:V,METHOD:P,setMemoryOnlyKeys:function(e){E.setMemoryOnlyKeys(e),y.setRecentKeysLimit(1/0)},tryGetCachedValue:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=y.getValue(e);if(D(e)){const t=y.getAllKeys(),r=n().filter(t,(t=>t.startsWith(e))),o=n().reduce(r,((e,t)=>{const n=y.getValue(t);return n&&(e[t]=n),e}),{});if(n().isEmpty(o))return;s=o}if(t.selector){const n=t.withOnyxInstance?t.withOnyxInstance.state:void 0;return D(e)?q(s,t.selector,n):$(s,t.selector,n)}return s},hasPendingMergeForKey:re},me=pe;var ge=a(697),ve=a.n(ge),ke=a(156),be=a.n(ke);function Oe(){return Oe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Oe.apply(this,arguments)}function we(e){const t=n().chain(e).omit((e=>!1===e.initWithStoredValues)).keys().value();return s=>{const r=(o=s).displayName||o.name||"Component";var o;class i extends be().Component{constructor(s){super(s),this.setWithOnyxState=this.setWithOnyxState.bind(this),this.activeConnectionIDs={};const r=n().reduce(e,((e,t,n)=>{const r=d(t.key,s),o=me.tryGetCachedValue(r,t);return void 0===o||me.hasPendingMergeForKey(r)||(e[n]=o),e}),{});r.loading=n().size(r)<t.length,this.tempState=r,this.state=r}componentDidMount(){n().each(e,((e,t)=>{this.connectMappingToOnyx(e,t)})),this.checkEvictableKeys()}componentDidUpdate(t){n().each(e,((e,n)=>{const s=d(e.key,t);s!==d(e.key,this.props)&&(me.disconnect(this.activeConnectionIDs[s],s),delete this.activeConnectionIDs[s],this.connectMappingToOnyx(e,n))})),this.checkEvictableKeys()}componentWillUnmount(){n().each(e,(e=>{const t=d(e.key,this.props),n=this.activeConnectionIDs[t];me.disconnect(n,t)}))}setWithOnyxState(e,s){const r=this.state[e];(this.state.loading||r!==s)&&(this.state.loading?(this.tempState[e]=s,n().some(t,(e=>n().isUndefined(this.tempState[e])))||(this.setState((e=>({...n().omit(this.tempState,n().keys(e)),loading:!1}))),delete this.tempState)):this.setState({[e]:s}))}checkEvictableKeys(){n().each(e,(e=>{if(n().isUndefined(e.canEvict))return;const t=d(e.canEvict,this.props),s=d(e.key,this.props);if(!me.isSafeEvictionKey(s))throw new Error(`canEvict can't be used on key '${s}'. This key must explicitly be flagged as safe for removal by adding it to Onyx.init({safeEvictionKeys: []}).`);t?me.removeFromEvictionBlockList(s,e.connectionID):me.addToEvictionBlockList(s,e.connectionID)}))}connectMappingToOnyx(e,t){const n=d(e.key,this.props);this.activeConnectionIDs[n]=me.connect({...e,key:n,statePropertyName:t,withOnyxInstance:this,displayName:r})}render(){if(this.state.loading)return null;let e=n().omit(this.state,"loading");e=n().omit(e,(e=>n().isNull(e)));const t=n().omit(this.props,(e=>n().isNull(e)));return be().createElement(s,Oe({},t,e,{ref:this.props.forwardedRef}))}}return i.propTypes={forwardedRef:ve().oneOfType([ve().func,ve().shape({current:ve().object})])},i.defaultProps={forwardedRef:void 0},i.displayName=`withOnyx(${r})`,be().forwardRef(((e,t)=>{const n=i;return be().createElement(n,Oe({},e,{forwardedRef:t}))}))}}const xe=me})(),c})()));
3
2
  //# sourceMappingURL=web.min.js.map