;/*FB_PKG_DELIM*/ __d("TestRealtimeClientSyncAppQuery_facebookRelayOperation",[],(function(a,b,c,d,e,f){e.exports="5369793749699725"}),null); __d("TestRealtimeClientSyncAppQuery.graphql",["TestRealtimeClientSyncAppQuery_facebookRelayOperation"],(function(a,b,c,d,e,f){"use strict";a=function(){var a=[{defaultValue:null,kind:"LocalArgument",name:"entity_id"}],c=[{alias:null,args:[{kind:"Variable",name:"entity_id",variableName:"entity_id"}],kind:"ScalarField",name:"xfb_test_realtime_client_sync_app_get_entity",storageKey:null}];return{fragment:{argumentDefinitions:a,kind:"Fragment",metadata:null,name:"TestRealtimeClientSyncAppQuery",selections:c,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:a,kind:"Operation",name:"TestRealtimeClientSyncAppQuery",selections:c},params:{id:b("TestRealtimeClientSyncAppQuery_facebookRelayOperation"),metadata:{},name:"TestRealtimeClientSyncAppQuery",operationKind:"query",text:null}}}();e.exports=a}),null); __d("PayloadAwareInflightAmends",["InflightAmends","err"],(function(a,b,c,d,e,f,g){"use strict";var h="inflight_amends_queue_max_limit_exceeded";a=function(a){babelHelpers.inheritsLoose(b,a);function b(b,c,d,e){b=a.call(this,b,d,e)||this;b.$PayloadAwareInflightAmends2=c;b.$PayloadAwareInflightAmends1=new Map();return b}var d=b.prototype;d.add=function(b,d){if(this.getSize()===this.$PayloadAwareInflightAmends2)throw c("err")(h);if(d==null)throw c("err")("payload is null.");this.$PayloadAwareInflightAmends1.set(b,d);return a.prototype.add.call(this,b)};d.getPayload=function(a){return this.$PayloadAwareInflightAmends1.get(a)};d.resolve=function(b,c){this.$PayloadAwareInflightAmends3(b),a.prototype.resolve.call(this,b,c)};d.reject=function(b,c){this.$PayloadAwareInflightAmends3(b),a.prototype.reject.call(this,b,c)};d.rejectAll=function(b){this.$PayloadAwareInflightAmends1.clear(),a.prototype.rejectAll.call(this,b)};d.getAllPayloadsAndPromises=function(){var a=[];for(var b=this.$PayloadAwareInflightAmends1.entries(),c=Array.isArray(b),d=0,b=c?b:b[typeof Symbol==="function"?Symbol.iterator:"@@iterator"]();;){var e;if(c){if(d>=b.length)break;e=b[d++]}else{d=b.next();if(d.done)break;e=d.value}e=e;var f=e[0];e=e[1];f=this.getPromise(f);a.push({promise:f,payload:e})}return a};d.getAllPayloads=function(){return Array.from(this.$PayloadAwareInflightAmends1.values())};d.getAllAmendIds=function(){return Array.from(this.$PayloadAwareInflightAmends1.keys())};d.$PayloadAwareInflightAmends3=function(a){this.$PayloadAwareInflightAmends1.get(a)!=null&&this.$PayloadAwareInflightAmends1["delete"](a)};return b}(c("InflightAmends"));g["default"]=a}),98); __d("RealtimeClientSyncUtils",["err"],(function(a,b,c,d,e,f,g){function a(a,b){if(a0};e.getInflightUpdateOperations=function(){return this.$2.getAllPayloadsAndPromises()};return a}();g.GuaranteedUpdateHandler=a}),98); __d("MQTTRequestStreamClient",["BladeRunnerClient","MQTTRequestStreamUtils","Promise","RequestStreamTransport"],(function(a,b,c,d,e,f,g){"use strict";var h;a=function(){function a(){}var e=a.prototype;e.createStream=function(a,e,f,g,i){!(typeof e==="string")&&e!=null?i=new TextDecoder().decode(e):i=e;e=new(c("BladeRunnerClient"))(null,d("RequestStreamTransport").RequestStreamTransport.WEB_RS_MQTT).createStream(a,i,d("MQTTRequestStreamUtils").convertToBRHandler(g),f||{requestId:"UNKNOWN"});return(h||(h=b("Promise"))).resolve(e)};return a}();g["default"]=a}),98); __d("MQTTRequestStreamDeferredClient",["Promise","nullthrows","requireDeferred"],(function(a,b,c,d,e,f,g){"use strict";var h;a=function(){function a(){this.$1=null}var d=a.prototype;d.createStream=function(a,b,d,e,f){this.$2();return c("nullthrows")(this.$1).then(function(c){return c.createStream(a,b,d,e,f)})};d.$2=function(){this.$1==null&&(this.$1=new(h||(h=b("Promise")))(function(a){c("requireDeferred")("MQTTRequestStreamClient").__setRef("MQTTRequestStreamDeferredClient").onReady(function(b){a(new b())})}))};return a}();d=new a();g["default"]=d}),98); __d("PulsarTestTypes",["$InternalEnum"],(function(a,b,c,d,e,f){"use strict";a=b("$InternalEnum")({INIT_REQUEST_ERROR:"Request error",INIT_REQUEST_TIMEOUT:"Request timeout",PAYLOAD_PUBLISH_TIMEOUT:"Publish timeout",PAYLOAD_INTEGRITY_CHECK:"Payload integrity check failure",PAYLOAD_OUT_OF_ORDER:"Payload is delivered out of order",STREAM_TERMINATE:"Stream terminate",AMEND_REQUEST_TIMEOUT:"Amend timeout",AMEND_ACK_TIMEOUT:"Amend ack timeout",TEST_TIME_OUT:"Test timeout"});c=b("$InternalEnum").Mirrored(["INITIALIZED","REQUESTING","STARTED","SUCCESS","FAILURE","ABORTED"]);f.PulsarTestFailureReason=a;f.PulsarTestState=c}),66); __d("PulsarTestUtils",[],(function(a,b,c,d,e,f){"use strict";function a(a,b){try{a=JSON.parse(a);a=a.payload||"";return a.length===b}catch(a){return!1}}function b(a){return a<2?"":new Array(Math.floor(a/2)+1).join("a")}f.payloadIntegrityCheck=a;f.genStringOfSize=b}),66); __d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes",["$InternalEnum"],(function(a,b,c,d,e,f){"use strict";c=(a=b("$InternalEnum"))({UNKNOWN:0,INTERNAL_ERROR:1,WWW_HANDLER_ROUTING_ERROR:2,NOT_AUTHORIZED:1e3,FAILED_TO_GET_AUTHORIZATION:1001,NOT_AUTHORIZED_TO_READ_ENTITY:1002,NOT_AUTHORIZED_TO_UPDATE_ENTITY:1003,DELIVERY_METHOD_NOT_SUPPORTED:2e3,FAILED_TO_PUBLISH_ENTITY_UPDATE:2001,FAILED_TO_PUBLISH_PRESENCE_UPDATE:2002,PAYLOAD_SIZE_EXCEEDS_MAX_LIMIT:2003,FAILED_TO_PUBLISH_E2EE_UPDATE:2004,FAILED_TO_TRANSFORM_ENTITY_UPDATE:3e3,FAILED_TO_TRANSFORM_PRESENCE:3001,FAILED_TO_TRANSFORM_ALL_PRESENCES:3002,FAILED_TO_TRANSFORM_E2EE_UPDATE:3003,FAILED_TO_SEND_ALL_PRESENCES:4e3,FAILED_TO_SUBSCRIBE_FOR_ENTITY_UPDATES:5e3,ENTITY_UPDATES_SUBSCRIPTION_FAILURE:5001,FAILED_TO_SUBSCRIBE_FOR_AUTHORIZATION_UPDATES:5002,AUTHORIZATION_UPDATES_SUBSCRIPTION_FAILURE:5003,FAILED_TO_SUBSCRIBE_FOR_PRESENCE_UPDATES:5004,PRESENCE_UPDATES_SUBSCRIPTION_FAILURE:5005,FAILED_TO_SUBSCRIBE_FOR_BEST_EFFORT_UPDATES:5006,BEST_EFFORT_UPDATES_SUBSCRIPTION_FAILURE:5007,CLIENT_MISSING_ENTITY_PAYLOAD_DETECTED:6e3,CLIENT_DROPPED_INFLIGHT_UPDATES_ON_CLOSE:6001,CLIENT_FAILED_TO_PUBLISH_AFTER_RETRIES:6002,CLIENT_FAILED_TO_SEND_HEARTBEAT:6003,CLIENT_INPUT_ERROR:6004,APP_FAILED_TO_SAVE_SNAPSHOT:7e3,APP_FAILED_TO_MUTATE_ENTITY:7001,APP_FAILED_TO_HANDLE_ENTITY_UPDATE:7003,APP_FAILED_TO_HANDLE_PRESENCE_UPDATE:7004,APP_FAILED_TO_HANDLE_CONNECTION_STATE_CHANGE:7005,APP_FAILED_TO_HANDLE_ERROR:7006,APP_FAILED_TO_LOG_DEBUG_LOGS:7007,APP_FAILED_TO_HANDLE_ON_BECAME_LEADER_CALLBACK:7008,APP_FAILED_TO_HANDLE_ON_LOST_LEADERSHIP_CALLBACK:7009,APP_FAILED_TO_SERIALIZE_ENTITY_UPDATE:7100,APP_FAILED_TO_DESERIALIZE_ENTITY_UPDATE:7101,APP_FAILED_TO_SERIALIZE_PRESENCE:7102,APP_FAILED_TO_DESERIALIZE_PRESENCE:7103,APP_FAILED_TO_SERIALIZE_ENTITY:7104,APP_FAILED_TO_DESERIALIZE_ENTITY:7105,APP_FAILED_TO_TRANSFORM_PRESENCE:7201,APP_FAILED_TO_TRANSFORM_ENTITY_UPDATE:7202,APP_FAILED_TO_HANDLE_ON_STREAM_CLOSED_CALLBACK:7203,APP_FAILED_TO_HANDLE_INITIAL_REQUEST:7204,APP_FAILED_TO_TRANSFORM_E2EE_UPDATE:7205,SERVER_FAILED_TO_SEND_UPDATE_TO_HEARTBEAT_STORE:8e3,LEADER_SERVER_FAILED_TO_BROADCAST_HEARTBEAT:8001,FOLLOWER_SERVER_FAILED_TO_WATCH_HEARTBEAT_FROM_LEADER_SERVER:8002,SERVER_FAILED_TO_RUN_LEADER_ELECTION:8003,SERVER_MISSED_HEARTBEAT_FROM_CLIENT:8004,SERVER_FAILED_TO_HANDLE_LEADER_SERVER_HEARTBEAT_UPDATE:8005,LEADER_ELECTION_CONFIG_VALIDATION_ERROR:8006,SERVER_FAILED_TO_WATCH_HEARTBEAT_FROM_CLIENT:8007,FAILED_TO_HANDLE_ON_STREAM_CLOSED_CALLBACK:9e3,FAILED_TO_HANDLE_INITIAL_REQUEST:9001,FAILED_TO_TAKE_ENTITY_SNAPSHOT_FROM_SERVER:9002});d=a({UNKNOWN:0,CLIENT_JOINED:1,CLIENT_LEFT:2,CLIENT_GENERATED:3,SERVER_UPDATE:4});f=a({LEADER_ELECTED:0,ENTITY_PRESENCE:1});b=a({LEADER_RESIGNED:0});var g=a({UNKNOWN:0,INTERN:1,PROD:2}),h=a({UNKNOWN:0,ENTITY_UPDATE:1,PRESENCE_UPDATE:2,AUTHORIZATION_UPDATE:3,HEARTBEAT_UPDATE:4,E2EE_UPDATE:5}),i=a({UNKNOWN:0,GUARANTEED:1,BEST_EFFORT:2,INITIAL_CONNECTION:3}),j=a({StreamCloseCallbackResponse:"streamCloseCallbackResponse",Error:"error"}),k=a({InitialConnectionResponse:"initialConnectionResponse",Error:"error"}),l=a({EntityUpdateTransformResponse:"entityUpdateTransformResponse",Error:"error"}),m=a({E2eeUpdateTransformResponse:"e2eeUpdateTransformResponse",Error:"error"}),n=a({PresenceTransformResponse:"presenceTransformResponse",Error:"error"}),o=a({AllPresencesTransformResponse:"allPresencesTransformResponse",Error:"error"});a=a({SnapshotResponse:"snapshotResponse",Error:"error"});e.exports={AllPresencesTransformResponseOrError$Types:o,DeliveryMethod:i,E2EEUpdateTransformResponseOrError$Types:m,EntityUpdateTransformResponseOrError$Types:l,ErrorCode:c,HeartBeatStartCause:f,HeartBeatStopCause:b,InitialConnectionResponseOrError$Types:k,PresenceTransformResponseOrError$Types:n,PresenceUpdateCause:d,SkywalkerPayloadType:h,SnapshotResponseOrError$Types:a,StreamCloseCallbackResponseOrError$Types:j,WwwTier:g}}),null); __d("RealtimeClientSyncTypes",["BladerunnerRealtimeClientSyncRealtimeClientSyncTypes"],(function(a,b,c,d,e,f,g){"use strict";a="default-realtime-client-sync-previous-cursor-value-returned-for-newly-created-entities";g.ErrorCode=(b=d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes")).ErrorCode;g.DeliveryMethod=b.DeliveryMethod;g.WwwTier=b.WwwTier;g.HeartBeatStartCause=b.HeartBeatStartCause;g.HeartBeatStopCause=b.HeartBeatStopCause;g.PresenceUpdateCause=b.PresenceUpdateCause;g.DEFAULT_PREVIOUS_CURSOR_VALUE=a}),98); __d("ErrorSafeEventHandler",["BladerunnerRealtimeClientSyncRealtimeClientSyncTypes","FBLogger","regeneratorRuntime"],(function(a,b,c,d,e,f,g){"use strict";a=function(){function a(a,b){var c=this;this.onRequestStreamDebugLog=function(a){c.$3({handler:function(){return c.$1.onRequestStreamDebugLog==null?void 0:c.$1.onRequestStreamDebugLog(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_LOG_DEBUG_LOGS})};this.onBecameLeader=function(){c.$3({handler:function(){return c.$1.onBecameLeader==null?void 0:c.$1.onBecameLeader()},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_HANDLE_ON_BECAME_LEADER_CALLBACK})};this.onLostLeadership=function(){c.$3({handler:function(){return c.$1.onLostLeadership==null?void 0:c.$1.onLostLeadership()},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_HANDLE_ON_LOST_LEADERSHIP_CALLBACK})};this.$1=a;this.$2=b}var e=a.prototype;e.onEntityUpdatePayloadReceived=function(a){var b=this;this.$3({handler:function(){b.$1.onEntityUpdatePayloadReceived(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_HANDLE_ENTITY_UPDATE})};e.onPresenceUpdatePayloadReceived=function(a){var b=this;this.$3({handler:function(){b.$1.onPresenceUpdatePayloadReceived(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_HANDLE_PRESENCE_UPDATE})};e.genOnSave=function(a,c){var e=this;return b("regeneratorRuntime").async(function(f){while(1)switch(f.prev=f.next){case 0:f.next=2;return b("regeneratorRuntime").awrap(this.$4({handler:function(){var d;return b("regeneratorRuntime").async(function(f){while(1)switch(f.prev=f.next){case 0:f.next=2;return b("regeneratorRuntime").awrap(e.$1.genOnSave(a,c));case 2:d=f.sent;return f.abrupt("return",d);case 4:case"end":return f.stop()}},null,this)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_SAVE_SNAPSHOT}));case 2:case"end":return f.stop()}},null,this)};e.onError=function(a,b){try{this.$1.onError(a,b)}catch(a){this.$2("app.error."+String(d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_HANDLE_ERROR));c("FBLogger")(this.constructor.name).catching(a).warn(a.message);throw a}};e.onConnectionStatusChange=function(a){var b=this;this.$3({handler:function(){b.$1.onConnectionStatusChange(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_HANDLE_CONNECTION_STATE_CHANGE})};e.$4=function(a){var c,d,e;return b("regeneratorRuntime").async(function(f){while(1)switch(f.prev=f.next){case 0:c=a.handler,d=a.errorCode;f.prev=1;f.next=4;return b("regeneratorRuntime").awrap(c());case 4:e=f.sent;return f.abrupt("return",e);case 8:f.prev=8,f.t0=f["catch"](1),this.$5({errorCode:d,message:f.t0.message});case 11:case"end":return f.stop()}},null,this,[[1,8]])};e.$3=function(a){var b=a.handler;a=a.errorCode;try{b=b();return b}catch(b){this.$5({errorCode:a,message:b.message})}};e.$5=function(a){var b;this.$2("app.error."+String(a.errorCode));b=(b=a.message)!=null?b:"Unexpected error from product handler. Error code= "+String(a.errorCode)+", Error Message: "+String(a.message);this.$1.onError({errorCode:a.errorCode,message:b});c("FBLogger")(this.constructor.name).warn(b)};return a}();g["default"]=a}),98); __d("SerializerErrorWrapper",["BladerunnerRealtimeClientSyncRealtimeClientSyncTypes"],(function(a,b,c,d,e,f,g){"use strict";a=function(){function a(a,b){this.$1=a,this.$2=b}var b=a.prototype;b.serializeEntity=function(a){var b=this;return this.$3({handler:function(){return b.$1.serializeEntity(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_SERIALIZE_ENTITY})};b.deserializeEntity=function(a){var b=this;return this.$3({handler:function(){return b.$1.deserializeEntity(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_DESERIALIZE_ENTITY})};b.serializeEntityUpdate=function(a){var b=this;return this.$3({handler:function(){return b.$1.serializeEntityUpdate(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_SERIALIZE_ENTITY_UPDATE})};b.deserializeEntityUpdate=function(a){var b=this;return this.$3({handler:function(){return b.$1.deserializeEntityUpdate(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_DESERIALIZE_ENTITY_UPDATE})};b.serializePresence=function(a){var b=this;return this.$3({handler:function(){return b.$1.serializePresence(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_SERIALIZE_PRESENCE})};b.deserializePresence=function(a){var b=this;return this.$3({handler:function(){return b.$1.deserializePresence(a)},errorCode:d("BladerunnerRealtimeClientSyncRealtimeClientSyncTypes").ErrorCode.APP_FAILED_TO_DESERIALIZE_PRESENCE})};b.$3=function(a){var b=a.handler;a=a.errorCode;try{return b()}catch(b){this.$2({errorCode:a,message:b.message});throw b}};return a}();g["default"]=a}),98); __d("RealtimeClientSync",["BladeRunnerStreamStatus","ErrorSafeEventHandler","FBLogger","GuaranteedUpdateHandler","MQTTRequestStreamUtils","ODS","Promise","RealtimeClientSyncTypes","RealtimeClientSyncUtils","RequestStreamCommonRequestStreamCommonTypes","SerializerErrorWrapper","TransportSelectingClientSingleton","clearTimeout","err","justknobx","nullthrows","regeneratorRuntime","setTimeout","uuidv4"],(function(a,b,c,d,e,f,g){"use strict";var h,i;a=function(){function a(a,b,e){var f=this;this.$7=c("uuidv4")();this.$10=!1;this.$11=!1;this.$24=function(a){a=JSON.parse(a);switch(a.dataType){case"entity_update":f.$16(a.dataType+".received",{deliveryMethod:a.deliveryMethod});if(a.deliveryMethod===d("RealtimeClientSyncTypes").DeliveryMethod.GUARANTEED){a.update.cursor!=null&&a.update.previousCursor!=null?f.$27(babelHelpers["extends"]({},a,{update:babelHelpers["extends"]({},a.update,{cursor:a.update.cursor,previousCursor:a.update.previousCursor})})):f.$28({errorCode:d("RealtimeClientSyncTypes").ErrorCode.INTERNAL_ERROR,message:"entity update payload misses cursor(s). id = '"+a.amendmentId+"', update = '"+JSON.stringify(a.update)+"'"});break}f.$29(babelHelpers["extends"]({},a,{update:{update:a.update.update}}));break;case"presence_update":f.$16(a.dataType+"."+d("RealtimeClientSyncTypes").PresenceUpdateCause.getName(a.causedBy).toLowerCase()+".received");f.$7===a.senderClientId&&a.amendmentId!=null&&f.$14.responseReceived(a.amendmentId,a.dataType);if(f.$30(a.senderClientId))return;var b={senderClientId:a.senderClientId,causedBy:a.causedBy};a.presence!=null&&(b.presence=f.$2.deserializePresence(a.presence));f.$1.onPresenceUpdatePayloadReceived(b);break;case"heartbeat_start":f.$16(a.dataType+".received");f.$31(a.intervalSec*1e3);a.causedBy===d("RealtimeClientSyncTypes").HeartBeatStartCause.LEADER_ELECTED&&(f.$1.onBecameLeader==null?void 0:f.$1.onBecameLeader());break;case"heartbeat_stop":f.$16(a.dataType+".received");c("clearTimeout")(f.$12);a.causedBy===d("RealtimeClientSyncTypes").HeartBeatStopCause.LEADER_RESIGNED&&(f.$1.onLostLeadership==null?void 0:f.$1.onLostLeadership());break;case"snapshot":f.$16(a.dataType+".received");f.$32();break;case"error":f.$16(a.dataType+"."+d("RealtimeClientSyncTypes").ErrorCode.getName(a.error.errorCode).toLowerCase()+".received");f.$28(a.error);break}};this.$17=function(a){f.$16("app.error."+String(a.errorCode));var b="Unexpected error from serializer handler, Error code: "+String(a.errorCode)+", Error Message: "+String(a.message);c("FBLogger")(f.constructor.name).warn(b);f.$26(a)};this.$16=function(a,b){b=b===void 0?{}:b;b=b.deliveryMethod;var c="realtime.clientsync";c=[c,a];b!=null&&c.push(d("RealtimeClientSyncTypes").DeliveryMethod.getName(b).toLowerCase());c.push(f.$3.usecase);(i||(i=d("ODS"))).bumpEntityKey(4566,"RealtimeClientSync",c.join("."))};this.$1=new(c("ErrorSafeEventHandler"))(a,this.$16);this.$2=new(c("SerializerErrorWrapper"))(b,this.$17);this.$3=e;this.$13=this.$18();this.$14=this.$18();this.$8=d("RealtimeClientSyncTypes").DEFAULT_PREVIOUS_CURSOR_VALUE;this.$9=d("RealtimeClientSyncTypes").DEFAULT_PREVIOUS_CURSOR_VALUE;this.$15=this.$19()}var e=a.prototype;e.$18=function(){return new(d("GuaranteedUpdateHandler").GuaranteedUpdateHandler)({retryPolicy:this.$3.retryPolicy,amendAckTimeoutInMs:this.$3.amendAckTimeoutInMs,maxInflightAmendsQueueSize:this.$3.maxInflightAmendsQueueSize,bumpCounter:this.$16})};e.genStart=function(a){var c,d;return b("regeneratorRuntime").async(function(e){while(1)switch(e.prev=e.next){case 0:this.$20();this.$16("request.attempt");c=Date.now();this.$21(a.entity);e.next=6;return b("regeneratorRuntime").awrap(this.$22(a.entityID,a.lastCursor));case 6:d=e.sent;this.$16("request."+d.kind);this.$23("request.latency",Date.now()-c);return e.abrupt("return",d);case 10:case"end":return e.stop()}},null,this)};e.$20=function(){if(this.$10)throw c("err")("genStart has already been called once. To call again, create a new instance of RealtimeClientSync.");this.$10=!0};e.$21=function(a){this.$4=this.$2.deserializeEntity(this.$2.serializeEntity(a))};e.$22=function(a,e){var f=this;return new(h||(h=b("Promise")))(function(g,h){var i,j,k,l;return b("regeneratorRuntime").async(function(m){while(1)switch(m.prev=m.next){case 0:f.$5=a;f.$8=(h=e)!=null?h:d("RealtimeClientSyncTypes").DEFAULT_PREVIOUS_CURSOR_VALUE;f.$9=f.$8;j={method:"RealtimeClientSync:"+f.$3.usecase};f.$3.sandbox!=null&&(j["javascript-sandbox"]=f.$3.sandbox);f.$3.wwwSandbox!=null&&(j.www_sandbox=f.$3.wwwSandbox);k={useCase:f.$3.usecase,clientId:f.$7,entityId:a,wwwTier:(i=f.$3.wwwTier)!=null?i:d("RealtimeClientSyncTypes").WwwTier.PROD,cursor:e};l={onData:f.$24,onFlowStatus:function(a){switch(a){case d("RequestStreamCommonRequestStreamCommonTypes").FlowStatus.Started:g({kind:"success"});break;default:break}f.$25(a)},onTermination:function(a){a.message===d("MQTTRequestStreamUtils").TERMINATION_REASON_REJECTED?(g({kind:"failure",error:{errorCode:d("RealtimeClientSyncTypes").ErrorCode.INTERNAL_ERROR,message:a.message}}),f.$1.onConnectionStatusChange(d("BladeRunnerStreamStatus").StreamStatus.REJECTED)):a.message===d("MQTTRequestStreamUtils").TERMINATION_REASON_CLOSED&&f.$1.onConnectionStatusChange(d("BladeRunnerStreamStatus").StreamStatus.CLOSED),f.$1.onRequestStreamDebugLog&&f.$1.onRequestStreamDebugLog("onTermination - "+a.message),f.$16("close.from.server.received")},onLog:function(a){f.$1.onRequestStreamDebugLog&&f.$1.onRequestStreamDebugLog("onLog - "+a)}};f.$26();m.next=11;return b("regeneratorRuntime").awrap(c("TransportSelectingClientSingleton").requestStream(j,JSON.stringify(k),l,f.$3.instrumentationData));case 11:f.$6=m.sent,f.$13.setStream(f.$6),f.$14.setStream(f.$6);case 14:case"end":return m.stop()}},null,this)})};e.$25=function(a){switch(a){case d("RequestStreamCommonRequestStreamCommonTypes").FlowStatus.Accepted:this.$1.onConnectionStatusChange(d("BladeRunnerStreamStatus").StreamStatus.ACCEPTED);break;case d("RequestStreamCommonRequestStreamCommonTypes").FlowStatus.Started:this.$1.onConnectionStatusChange(d("BladeRunnerStreamStatus").StreamStatus.STARTED);break;case d("RequestStreamCommonRequestStreamCommonTypes").FlowStatus.Stopped:this.$1.onConnectionStatusChange(d("BladeRunnerStreamStatus").StreamStatus.STOPPED);break}};e.$31=function(a){var b=this;this.$33({amendmentType:"client_heartbeat"});this.$12=c("setTimeout")(function(){b.$31(a)},a)};e.genSendEntityUpdate=function(a,e){var f=this,g,i;return b("regeneratorRuntime").async(function(j){while(1)switch(j.prev=j.next){case 0:if(!((e==null?void 0:e.deliveryMethod)===d("RealtimeClientSyncTypes").DeliveryMethod.BEST_EFFORT)){j.next=3;break}g=this.$33({id:c("uuidv4")(),amendmentType:"entity_update",update:this.$2.serializeEntityUpdate(a),deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.BEST_EFFORT});return j.abrupt("return",(h||(h=b("Promise"))).resolve(g));case 3:j.next=5;return b("regeneratorRuntime").awrap(this.$34(a,"entity_update",this.$13,function(a){return f.$2.serializeEntityUpdate(a)}));case 5:i=j.sent;return j.abrupt("return",i);case 7:case"end":return j.stop()}},null,this)};e.$34=function(a,e,f,g){var h,i,j;return b("regeneratorRuntime").async(function(k){while(1)switch(k.prev=k.next){case 0:k.prev=0;if(!this.$11){k.next=3;break}throw c("err")("stream terminating");case 3:h=c("uuidv4")();i=JSON.stringify({id:h,amendmentType:e,update:g(a),deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.GUARANTEED});if(!(i.length>this.$15)){k.next=7;break}return k.abrupt("return",this.$35({amendmentType:e,failureType:"payload_size_exceeds_max_limit",errorCode:d("RealtimeClientSyncTypes").ErrorCode.PAYLOAD_SIZE_EXCEEDS_MAX_LIMIT,message:"Your payload size = "+i.length+" is exceeding max supported size = "+this.$15,deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.GUARANTEED}));case 7:k.next=9;return b("regeneratorRuntime").awrap(f.genSendUpdate(h,e,a,i));case 9:j=k.sent;if(!(j!=null)){k.next=13;break}this.$26({message:j.message,errorCode:d("RealtimeClientSyncTypes").ErrorCode.CLIENT_FAILED_TO_PUBLISH_AFTER_RETRIES});return k.abrupt("return",this.$35({amendmentType:e,failureType:j.failureCause,message:j.message,deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.GUARANTEED}));case 13:k.next=18;break;case 15:k.prev=15;k.t0=k["catch"](0);return k.abrupt("return",this.$35({amendmentType:e,failureType:"error_thrown",message:k.t0.message,deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.GUARANTEED}));case 18:case"end":return k.stop()}},null,this,[[0,15]])};e.$33=function(a){var b=a.amendmentType;this.$16(b+".attempt",{deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.BEST_EFFORT});if(this.$6==null)return this.$35({amendmentType:b,failureType:"null_stream",message:"null stream, call open or create entity before sending updates.",deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.BEST_EFFORT});a=JSON.stringify(babelHelpers["extends"]({},a,{deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.BEST_EFFORT}));if(a.length>this.$15)return this.$35({amendmentType:b,failureType:"payload_size_exceeds_max_limit",errorCode:d("RealtimeClientSyncTypes").ErrorCode.PAYLOAD_SIZE_EXCEEDS_MAX_LIMIT,message:"Your payload size = "+a.length+" is exceeding max supported size = "+this.$15,deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.BEST_EFFORT});try{var c;(c=this.$6)==null?void 0:c.amendWithoutAck(a);this.$16(b+".success",{deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.BEST_EFFORT})}catch(a){return this.$35({amendmentType:b,failureType:"error_thrown",message:a.message,deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.BEST_EFFORT})}};e.$35=function(a){var b=a.amendmentType,e=a.failureType,f=a.errorCode,g=a.message;a=a.deliveryMethod;this.$16(b+".failure."+e,{deliveryMethod:a});e=b+" failed with type "+e+": "+((a=g)!=null?a:"");c("FBLogger")(this.constructor.name).warn(e);g=b==="entity_update"?d("RealtimeClientSyncTypes").ErrorCode.FAILED_TO_PUBLISH_ENTITY_UPDATE:d("RealtimeClientSyncTypes").ErrorCode.FAILED_TO_PUBLISH_PRESENCE_UPDATE;return{errorCode:(a=f)!=null?a:g,message:e}};e.sendPresence=function(a){return this.$33({id:c("uuidv4")(),amendmentType:"presence_update",update:this.$2.serializePresence(a)})};e.genSendPresence=function(a,e){var f=this,g,h;return b("regeneratorRuntime").async(function(i){while(1)switch(i.prev=i.next){case 0:if(!((e==null?void 0:e.deliveryMethod)===d("RealtimeClientSyncTypes").DeliveryMethod.GUARANTEED)){i.next=5;break}i.next=3;return b("regeneratorRuntime").awrap(this.$34(a,"presence_update",this.$14,function(a){return f.$2.serializePresence(a)}));case 3:g=i.sent;return i.abrupt("return",g);case 5:h=this.$33({id:c("uuidv4")(),amendmentType:"presence_update",update:this.$2.serializePresence(a),deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.BEST_EFFORT});return i.abrupt("return",h);case 7:case"end":return i.stop()}},null,this)};e.getPendingGuaranteedEntityUpdatesForTesting=function(){return this.$13.getInflightUpdateIds()};e.getPendingGuaranteedPresenceUpdatesForTesting=function(){return this.$14.getInflightUpdateIds()};e.getEntityCopyForTesting=function(){return this.$4};e.getInflightEntityUpdates=function(){return this.$13.getInflightUpdateOperations()};e.getClientID=function(){return this.$7};e.$28=function(a,b){this.$1.onError==null?void 0:this.$1.onError(a,b),this.$16("error."+this.$36(a.errorCode)+".sent")};e.$36=function(a){return a==null?"error-code-missing":d("RealtimeClientSyncTypes").ErrorCode.getName(a).toLowerCase()};e.$26=function(a){var b;this.$13.anyInflightUpdate()&&(b=this.$13.getInflightUpdatePayloads(),this.$13.rejectInflightUpdates(c("err")("stream terminating")));a!=null&&this.$6!=null&&this.$28(a,b);this.$37()};e.genClose=function(a){var e=this,f,g;return b("regeneratorRuntime").async(function(i){while(1)switch(i.prev=i.next){case 0:this.$16("close.from.user.attempt");f=!0;this.$11=!0;a!=null&&(g=c("setTimeout")(function(){f=!e.$13.anyInflightUpdate(),f||e.$26({errorCode:d("RealtimeClientSyncTypes").ErrorCode.CLIENT_DROPPED_INFLIGHT_UPDATES_ON_CLOSE,message:"Force closing the stream while there are inflight updates."})},a));i.next=6;return b("regeneratorRuntime").awrap((h||(h=b("Promise"))).allSettled(this.$13.getInflightUpdatePromises()));case 6:c("clearTimeout")(g);i.next=9;return b("regeneratorRuntime").awrap(this.$32());case 9:this.$4=null;this.$37();this.$16("close.from.user."+(f?"success":"failure"));return i.abrupt("return",f);case 13:case"end":return i.stop()}},null,this)};e.$37=function(){var a;(a=this.$6)==null?void 0:a.cancel();this.$6=null;this.$11=!1;this.$13.setStream(null);this.$14.rejectInflightUpdates(c("err")("stream terminated"));this.$14.setStream(null);c("clearTimeout")(this.$12)};e.$32=function(){return b("regeneratorRuntime").async(function(a){while(1)switch(a.prev=a.next){case 0:this.$16("snapshot.attempt");if(!(this.$9!==this.$8)){a.next=5;break}a.next=4;return b("regeneratorRuntime").awrap(this.$1.genOnSave(c("nullthrows")(this.$4),this.$8));case 4:this.$9=this.$8;case 5:this.$16("snapshot.success");case 6:case"end":return a.stop()}},null,this)};e.$38=function(a){return this.$8===a.cursor||this.$8===a.previousCursor};e.$39=function(a){this.$26();a="Entity update in-order delivery failed (entity id = '"+String(this.$5)+"', last cursor processed = '"+String(this.$8)+"', previous cursor received = '"+String(a)+"')";this.$28({errorCode:d("RealtimeClientSyncTypes").ErrorCode.CLIENT_MISSING_ENTITY_PAYLOAD_DETECTED,message:a})};e.$23=function(a,b){b=d("RealtimeClientSyncUtils").getMatchingBucket(b,[100,500,1e3,2e3,5e3]);this.$16(a+"."+b)};e.$27=function(a){if(!this.$38(a.update)){this.$39(a.update.previousCursor);return}this.$7===a.senderClientId&&this.$13.responseReceived(a.amendmentId,a.dataType);this.$8=a.update.cursor;var b=this.$2.deserializeEntityUpdate(a.update.update);b.mutate(c("nullthrows")(this.$4));this.$40({update:b,senderClientId:a.senderClientId,cursor:a.update.cursor,deliveryMethod:a.deliveryMethod,metadata:a.responseMetadata})};e.$29=function(a){var b=this.$2.deserializeEntityUpdate(a.update.update);b.mutate(c("nullthrows")(this.$4));this.$40({update:b,senderClientId:a.senderClientId,deliveryMethod:a.deliveryMethod,metadata:a.responseMetadata})};e.$40=function(a){if(this.$30(a.senderClientId))return;this.$1.onEntityUpdatePayloadReceived(a)};e.$30=function(a){return a===this.$7&&this.$3.dropSameClientUpdates===!0};e.$19=function(){var a=1024*1024,b=16;try{b=c("justknobx")._("350")}catch(a){c("FBLogger")(this.constructor.name).catching(a).warn("Failed to evaluate knob realtime/clientsync:max_payload_size_in_mb : "+a)}return b*a};return a}();g["default"]=a}),98); __d("TestRealtimeClientSyncApp",["BladeRunnerStreamStatus","RealtimeClientSync","RelayHooks","TestRealtimeClientSyncAppQuery.graphql","regeneratorRuntime"],(function(a,b,c,d,e,f,g){"use strict";var h,i=h!==void 0?h:h=b("TestRealtimeClientSyncAppQuery.graphql"),j=function(a){this.entity=a},k=function(){function a(a){this.append_suffix=a}var b=a.prototype;b.setTransformedEntityUpdate=function(a){this.transformed_append_suffix=a};b.mutate=function(a){a.entity+=(a=this.transformed_append_suffix)!=null?a:this.append_suffix};return a}(),l=function(){function a(a){this.online_state=a}var b=a.prototype;b.setTransformedOnlineState=function(a){this.transformed_online_state=a};return a}();a=function(){function a(){}var b=a.prototype;b.serializeEntity=function(a){return JSON.stringify(a)};b.deserializeEntity=function(a){return new j(JSON.parse(a).entity)};b.serializeEntityUpdate=function(a){return JSON.stringify(a)};b.deserializeEntityUpdate=function(a){a=JSON.parse(a);var b=new k(a.append_suffix);b.setTransformedEntityUpdate(a.transformed_append_suffix);return b};b.serializePresence=function(a){return JSON.stringify(a)};b.deserializePresence=function(a){a=JSON.parse(a);var b=new l(a.online_state);b.setTransformedOnlineState(a.transformed_online_state);return b};return a}();e=function(){function a(a,b,c,d){var e=this;this.onRequestStreamDebugLog=function(a){e.log("onDebugLog: "+a)};this.onBecameLeader=function(){e.log("onBecameLeader called")};this.onLostLeadership=function(){e.log("onLostLeadership called")};this.log=a;this.onEntityUpdateAction=b;this.onPresenceUpdateAction=c;this.onSave=d}var c=a.prototype;c.onEntityUpdatePayloadReceived=function(a){this.log("onEntityUpdatePayloadReceived: "+JSON.stringify(a,null,2)),this.onEntityUpdateAction()};c.onPresenceUpdatePayloadReceived=function(a){this.log("onPresenceUpdatePayloadReceived: "+JSON.stringify(a,null,2)),this.onPresenceUpdateAction()};c.genOnSave=function(a,c){return b("regeneratorRuntime").async(function(b){while(1)switch(b.prev=b.next){case 0:this.log("Save Snapshot lastCursor="+c),this.onSave==null?void 0:this.onSave(a);case 2:case"end":return b.stop()}},null,this)};c.onConnectionStatusChange=function(a){var b;b=(b=Object.keys(d("BladeRunnerStreamStatus").StreamStatus).find(function(b){return d("BladeRunnerStreamStatus").StreamStatus[b]===a}))!=null?b:"UNKNOWN";this.log("onConnectionStatusChange: "+b)};c.onError=function(a){this.log("onError: "+JSON.stringify(a))};return a}();f=function(a){a={entity_id:a};a=d("RelayHooks").useLazyLoadQuery(i,a);return a.xfb_test_realtime_client_sync_app_get_entity};var m=new e(function(){},function(){},function(){}),n=new a();new(c("RealtimeClientSync"))(m,n,{usecase:"test_realtime_client_sync_app"});g.TestRealtimeClientSyncAppEntity=j;g.TestRealtimeClientSyncAppEntityUpdate=k;g.TestRealtimeClientSyncAppPresence=l;g.TestRealtimeClientSyncAppSerializer=a;g.TestRealtimeClientSyncAppEventHandler=e;g.GetEntity=f}),98); __d("ClientSyncPulsarTest",["BladeRunnerLogger","BladeRunnerStreamStatus","Deferred","ODS","PulsarTestTypes","PulsarTestUtils","RealtimeClientSyncTypes","RetryLib","TestRealtimeClientSyncApp","clearTimeout","nullthrows","regeneratorRuntime","setTimeout","uuidv4"],(function(a,b,c,d,e,f,g){var h,i=function(a){c("BladeRunnerLogger").info(a)};a=function(){function a(a,b){this.$9="",this.$1=a,this.$7=b,this.$2=d("PulsarTestTypes").PulsarTestState.INITIALIZED,this.$3=this.$8(a),this.$5=new(c("Deferred"))()}var e=a.prototype;e.start=function(a){var c=this,e,f,g;return b("regeneratorRuntime").async(function(h){while(1)switch(h.prev=h.next){case 0:if(!(this.$2!==d("PulsarTestTypes").PulsarTestState.INITIALIZED)){h.next=2;break}return h.abrupt("return",this.$5.getPromise());case 2:e={onEntityUpdatePayloadReceived:function(a){a=a.update.append_suffix;if(c.$9===a)return;c.$9=a;var b=++c.$3.numPayloadReceived;if(!a.startsWith(b+"_")){c.$3.lastSeenError="Out of order delivery.\n Expected prefix "+b+"_\n Recieved "+a;c.$3.failureReason=d("PulsarTestTypes").PulsarTestFailureReason.PAYLOAD_OUT_OF_ORDER;c.$10(d("PulsarTestTypes").PulsarTestState.FAILURE);return}c.$3.numPayloadReceived===c.$1.numAmends&&(c.$3.numAmendAcked===c.$1.numAmends-1&&c.$3.numAmendAcked++,c.$10(d("PulsarTestTypes").PulsarTestState.SUCCESS))},onPresenceUpdatePayloadReceived:function(a){},genOnSave:function(a,c){return b("regeneratorRuntime").async(function(a){while(1)switch(a.prev=a.next){case 0:case"end":return a.stop()}},null,this)},onConnectionStatusChange:function(a){switch(a){case d("BladeRunnerStreamStatus").StreamStatus.CREATED:break;case d("BladeRunnerStreamStatus").StreamStatus.ACCEPTED:c.$3.numFlowStatusAccepted++;break;case d("BladeRunnerStreamStatus").StreamStatus.STARTED:c.$2=d("PulsarTestTypes").PulsarTestState.STARTED;c.$3.numFlowStatusStarted++;c.$3.numRequestsLanded++;c.$3.initialRequestLatencyMs=Date.now()-c.$3.initialRequestSentTimestampMs;break;case d("BladeRunnerStreamStatus").StreamStatus.REJECTED:case d("BladeRunnerStreamStatus").StreamStatus.STOPPED:case d("BladeRunnerStreamStatus").StreamStatus.CLOSED:c.$3.numFlowStatusStopped++;c.$3.lastSeenError="Stream interrupted with flow status: "+a;c.$10(d("PulsarTestTypes").PulsarTestState.ABORTED);break}},onError:function(a){var b;a.errorCode===d("RealtimeClientSyncTypes").ErrorCode.CLIENT_FAILED_TO_PUBLISH_AFTER_RETRIES?c.$3.failureReason=d("PulsarTestTypes").PulsarTestFailureReason.AMEND_ACK_TIMEOUT:c.$3.failureReason=d("PulsarTestTypes").PulsarTestFailureReason.STREAM_TERMINATE;c.$3.lastSeenError="ErrorMessage: "+((b=a.message)!=null?b:"")+", ErrorCode: "+a.errorCode;c.$10(d("PulsarTestTypes").PulsarTestState.FAILURE)}};f=new(d("TestRealtimeClientSyncApp").TestRealtimeClientSyncAppSerializer)();g={usecase:"web_pulsar_test",instrumentationData:{requestId:a,forceLogContext:"pulsar"},retryPolicy:{backoffFunction:d("RetryLib").Backoffs.exponential(100,2),maxTries:this.$1.amendRetryCount,retryCondition:d("RetryLib").RetryConditions.always()},amendAckTimeoutInMs:this.$1.amendTimeoutMS};this.$6=this.$7(e,f,g);i("RealtimeClientSync Set Up");h.prev=7;h.next=10;return b("regeneratorRuntime").awrap(this.$11());case 10:h.next=15;break;case 12:h.prev=12,h.t0=h["catch"](7),this.$12(h.t0);case 15:return h.abrupt("return",this.$5.getPromise());case 16:case"end":return h.stop()}},null,this,[[7,12]])};e.$11=function(){var a=this,e,f,g;return b("regeneratorRuntime").async(function(h){while(1)switch(h.prev=h.next){case 0:e=c("nullthrows")(this.$6);this.$2=d("PulsarTestTypes").PulsarTestState.REQUESTING;this.$3.numRequests++;this.$3.initialRequestSentTimestampMs=Date.now();f=c("uuidv4")();h.next=7;return b("regeneratorRuntime").awrap(e.genStart({entity:new(d("TestRealtimeClientSyncApp").TestRealtimeClientSyncAppEntity)(""),entityID:f}));case 7:g=h.sent;if(!(g.kind==="success")){h.next=12;break}i("Stream Started with entityID "+f);h.next=15;break;case 12:i("Stream failed to start");this.$5.isSettled()||(this.$3.lastSeenError="clientSync.genStart() failed",this.$3.failureReason=d("PulsarTestTypes").PulsarTestFailureReason.INIT_REQUEST_ERROR,this.$10(d("PulsarTestTypes").PulsarTestState.FAILURE));return h.abrupt("return");case 15:c("setTimeout")(function(){return b("regeneratorRuntime").async(function(c){while(1)switch(c.prev=c.next){case 0:c.next=2;return b("regeneratorRuntime").awrap(a.$13(1));case 2:case"end":return c.stop()}},null,this)},0),c("setTimeout")(function(){a.$14(1)},0),this.$15();case 18:case"end":return h.stop()}},null,this)};e.getState=function(){return this.$2};e.$14=function(a){var b,e=this,f=d("PulsarTestUtils").genStringOfSize(this.$1.amendPayloadSizeBytes);b=(b=this.$6)==null?void 0:b.sendPresence(new(d("TestRealtimeClientSyncApp").TestRealtimeClientSyncAppPresence)(f));if(b==null)i("Presence Update Published Successfully: "+f);else{i("Presence Update failed to publish: "+String(b.errorCode)+" "+((f=b.message)!=null?f:""))}var g=a+1;g<=this.$1.numAmends&&!this.$16()&&c("setTimeout")(function(){e.$14(g)},this.$1.amendIntervalMs)};e.$13=function(a){var e,f=this,g,h,j,k,l,m,n,o,p;return b("regeneratorRuntime").async(function(q){while(1)switch(q.prev=q.next){case 0:g=Math.ceil(this.$1.amendPayloadSizeBytes+(.5+Math.random()));h=d("PulsarTestUtils").genStringOfSize(g);j=a+"_"+h;this.$3.numAmendSent++;k=Date.now();q.next=7;return b("regeneratorRuntime").awrap((e=this.$6)==null?void 0:e.genSendEntityUpdate(new(d("TestRealtimeClientSyncApp").TestRealtimeClientSyncAppEntityUpdate)(j),{deliveryMethod:d("RealtimeClientSyncTypes").DeliveryMethod.GUARANTEED}));case 7:l=q.sent,m=Date.now(),n=!0,l==null?(i("Entity Update Published Successfully: "+j),this.$3.numAmendAcked=this.$1.numPayloadsExpected?(this.$9={succeeded:!0},this.$19()):this.$21()};e.$15=function(a){if(this.$18())return;this.$5.failureReason=a;this.$9={succeeded:!1,failureReason:a};this.$19()};e.$18=function(){return this.$4===d("PulsarTestTypes").PulsarTestState.SUCCESS||this.$4===d("PulsarTestTypes").PulsarTestState.ABORTED||this.$4===d("PulsarTestTypes").PulsarTestState.FAILURE};e.$23=function(){this.$5.testEndTimestampMs=Date.now(),this.$6.resolve(this.$5),this.$24()};e.$16=function(a){this.$6.reject(a),this.$24()};e.$24=function(){var a;this.$7!==null&&(window.clearTimeout(this.$7),this.$7=null);(a=this.$3)==null?void 0:a.cancel()};e.$10=function(){var a={number_of_payloads:this.$1.numPayloadsExpected,number_of_amends:this.$1.numAmends,payload_size_in_bytes:this.$1.payloadSize,time_interval_in_seconds:this.$1.payloadIntervalMs/1e3,test_name:this.$1.testName,time_span_mode:"fixed",publish_mode:"direct",close_on_finish:this.$1.numAmends===0};return JSON.stringify({input:a})};e.$19=function(){if(this.$8!=null&&this.$9!=null)if(this.$8.succeeded&&this.$9.succeeded)this.$4=d("PulsarTestTypes").PulsarTestState.SUCCESS,this.$23();else{var a;this.$4=d("PulsarTestTypes").PulsarTestState.FAILURE;this.$5.failureReason=(a=(a=this.$9.failureReason)!=null?a:this.$8.failureReason)!=null?a:null;this.$23()}};return a}();g["default"]=a}),98); __d("TestStateMachine",["$InternalEnum","BladeRunnerLogger","PulsarLogger"],(function(a,b,c,d,e,f,g){var h=b("$InternalEnum").Mirrored(["INITIAL","START","REQUEST_LANDED","SUCCESS","FAILURE","ABORT"]),i="Request timeout",j="Publish timeout",k="Payload integrity check failure",l="Stream terminate";a=function(){function a(a,b,c){this.$1=b,this.$2=c,this.$3=a,this.$4=h.INITIAL,this.$5=0,this.$6=0,this.$7=0,this.$8=0,this.$9=Date.now(),this.$13=0,this.$14=0,this.$15=0,this.$16=0,this.$10=0,this.$11=0,this.$12=0,this.$20=null}var b=a.prototype;b.setStreamRef=function(a){this.$20=a};b.hasTestEnd=function(){return this.$4===h.SUCCESS||this.$4===h.ABORT||this.$4===h.FAILURE};b.updatePublishTimeoutIntervalMs=function(){this.$5==0&&(this.$16=this.$3.payloadIntervalMs),this.$16=this.$3.timeoutIntervalMs+this.$3.payloadIntervalMs};b.getFailureReason=function(){return this.$17!=null?this.$18!=null?this.$17+" lastSeenError: "+this.$18:this.$17:""};b.logTestResultAndCancel=function(){this.$12=Date.now(),c("BladeRunnerLogger").info("Pulsar test concluded. Number of expected payloads = "+this.$3.numPayloadsExpected+" , Number of received payload = "+this.$5+" , Test Result = "+this.$4+", Failure reason: "+(this.$17!=null?this.$17:"")),d("PulsarLogger").pulsarLogger.log(this.$3,{testId:this.$1,requestId:this.$2,testResult:this.hasTestEnd()?this.$4:"Unknown",numFlowStatusAccepted:this.$13,numFlowStatusStarted:this.$14,numFlowStatusStopped:this.$15,numPayloadsReceived:this.$5,publishTimeoutIntervalMs:this.$16,subscribeIssued:this.$6>0,subscribeRetryCount:this.$8,subscribeLatencyMs:this.$11,subscribeSuccess:this.$7>0,testDurationMs:this.$12-this.$9,testEndTimeMs:this.$12,numAmendAcked:0,numAmendSent:0,numAmendExpected:0,failureReason:this.$4===h.SUCCESS?"":this.getFailureReason()}),this.$20&&(this.$20.cancel(),this.$20=null)};b.onStart=function(){var a=this;c("BladeRunnerLogger").info("Pulsar starts testId:"+this.$1+"requestId: "+this.$2);if(this.$4!==h.INITIAL){c("BladeRunnerLogger").warn("Drop Pulsar request");return}this.$4=h.START;this.$6++;this.$11==0&&(this.$10=Date.now());this.$19=window.setTimeout(function(){a.onTimeOut()},this.$3.timeoutIntervalMs)};b.onRequestLanded=function(){var a=this;c("BladeRunnerLogger").info("Pulsar request Landed");if(this.$4!==h.START){c("BladeRunnerLogger").warn("drop the request ack");return}window.clearTimeout(this.$19);this.updatePublishTimeoutIntervalMs();this.$4=h.REQUEST_LANDED;this.$7++;this.$11==0&&(this.$11=Date.now()-this.$10);this.$19=window.setTimeout(function(){a.onTimeOut()},this.$16)};b.onPayloadReceived=function(a){var b=this;c("BladeRunnerLogger").info("Pulsar payload received");if(this.$4!==h.REQUEST_LANDED){c("BladeRunnerLogger").warn("drop the received payload");return}window.clearTimeout(this.$19);this.$5++;this.updatePublishTimeoutIntervalMs();if(!this.payloadIntegrityCheck(a)){this.$17=k;this.$4=h.FAILURE;this.logTestResultAndCancel();return}this.$3.numPayloadsExpected<=this.$5?(this.$4=h.SUCCESS,this.logTestResultAndCancel()):this.$19=window.setTimeout(function(){b.onTimeOut()},this.$16)};b.onTerminate=function(a){c("BladeRunnerLogger").info("Pulsar on terminate");if(this.hasTestEnd()){c("BladeRunnerLogger").info("stream gets terminated after test ends "+a);return}window.clearTimeout(this.$19);this.$4=h.FAILURE;this.$17=l;this.$18=a;this.$8--;this.logTestResultAndCancel()};b.onRetry=function(){c("BladeRunnerLogger").info("Pulsar on retry"),this.$18="Mid hop retry",this.$8++};b.onFlowStatusAccepted=function(){this.$13++};b.onFlowStatusStarted=function(){c("BladeRunnerLogger").info("Pulsar on flow status started"),this.$14++};b.onFlowStatusStopped=function(){this.$15++};b.onTimeOut=function(){c("BladeRunnerLogger").info("Pulsar timeout");if(this.hasTestEnd()){c("BladeRunnerLogger").warn("Timer not stopped after test ends");return}this.$4===h.REQUEST_LANDED?this.$17=j:this.$17=i;this.$4=h.FAILURE;this.logTestResultAndCancel()};b.payloadIntegrityCheck=function(a){a=JSON.parse(a);a=a.payload||"";return a.length==this.$3.payloadSize+(this.$7-1)};return a}();g["default"]=a}),98); __d("PulsarClient",["$InternalEnum","BladeRunnerDeferredClient","BladeRunnerLogger","BladeRunnerStreamHandler","BladeRunnerStreamStatus","ClientSyncPulsarTest","DGWRequestStreamDeferredClient","MQTTRequestStreamDeferredClient","Promise","PulsarLogger","PulsarTest","PulsarTestTypes","Random","RealtimeClientSync","RequestStreamHandler","RequestStreamTransport","TestStateMachine","WebStorage","qex","regeneratorRuntime","uuidv4"],(function(a,b,c,d,e,f,g){var h,i,j=["facebook.com","workplace.com","meta.com"],k="web_pulsar_qe",l=b("$InternalEnum").Mirrored(["REQUEST_STREAM","CLIENT_SYNC"]);a=function(){function a(){var a;this.$1=l.REQUEST_STREAM;this.$2="";this.$3=[];this.$26=!1;a=(a=c("qex")._("593"))!=null?a:"";this.$1=a===l.CLIENT_SYNC?l.CLIENT_SYNC:l.REQUEST_STREAM;this.$2=(a=c("qex")._("467"))!=null?a:k;a=(a=c("qex")._("470"))!=null?a:d("RequestStreamTransport").RequestStreamTransport.WEB_BR_MQTT;this.$3=[];for(var a=a.split(","),b=Array.isArray(a),e=0,a=b?a:a[typeof Symbol==="function"?Symbol.iterator:"@@iterator"]();;){var f;if(b){if(e>=a.length)break;f=a[e++]}else{e=a.next();if(e.done)break;f=e.value}f=f;switch(f){case d("RequestStreamTransport").RequestStreamTransport.WEB_BR_MQTT:this.$3.push(d("RequestStreamTransport").RequestStreamTransport.WEB_BR_MQTT);break;case d("RequestStreamTransport").RequestStreamTransport.WEB_RS_MQTT:this.$3.push(d("RequestStreamTransport").RequestStreamTransport.WEB_RS_MQTT);break;case d("RequestStreamTransport").RequestStreamTransport.WEB_RS_STARGATE:this.$3.push(d("RequestStreamTransport").RequestStreamTransport.WEB_RS_STARGATE);break;default:c("BladeRunnerLogger").info("Pulsar test unknown transport");break}}this.$4=(f=c("qex")._("482"))!=null?f:0;this.$4!==0&&this.$4<10&&(this.$4=10);this.$5=(e=c("qex")._("486"))!=null?e:2;this.$6=(b=c("qex")._("505"))!=null?b:100;this.$7=(a=c("qex")._("539"))!=null?a:1e5;this.$8=(f=c("qex")._("551"))!=null?f:1e4;this.$9=(e=c("qex")._("583"))!=null?e:1;this.$10=(b=c("qex")._("584"))!=null?b:0;this.$11=(a=c("qex")._("629"))!=null?a:0;this.$14=(f=c("qex")._("630"))!=null?f:"";this.$17=(e=c("qex")._("631"))!=null?e:!1;this.$12=(b=c("qex")._("163"))!=null?b:0;this.$13=(a=c("qex")._("164"))!=null?a:100;this.$15=(f=c("qex")._("1695"))!=null?f:5;this.$16=(e=c("qex")._("1697"))!=null?e:3e3}var e=a.prototype;e.startPulsarTest=function(){try{if(this.$18()){(i||(i=c("WebStorage"))).setItemGuarded(i.getSessionStorage(),"pulsarTestConcurrency",this.$9.toString());return this.$19()}c("BladeRunnerLogger").info("Test did not run");return(h||(h=b("Promise"))).resolve([])}catch(a){c("BladeRunnerLogger").info("Pulsar test failed with exception msg: "+a.message);return(h||(h=b("Promise"))).resolve([])}};e.$18=function(){var a=window.location.hostname.split(".").slice(-2).join(".");if(!c("Random").coinflip(this.$4)||!j.includes(a))return!1;a=(i||(i=c("WebStorage"))).getSessionStorageForRead();return a&&a.getItem("pulsarTestConcurrency")?!1:!0};e.$19=function(){var a=[],e=c("uuidv4")(),f={testName:this.$2,transport:"WEB_RS_STARGATE",numPayloadsExpected:this.$5,payloadIntervalMs:this.$7,payloadSize:this.$6,timeoutIntervalMs:this.$8,amendProcessingDelayMs:this.$12,amendPayloadSizeBytes:this.$13,amendIntervalMs:this.$10,numAmends:this.$11,amendRetryCount:this.$15,amendTimeoutMS:this.$16,rsOptions:{}};for(var g=0;g=j.length)break;n=j[m++]}else{m=j.next();if(m.done)break;n=m.value}n=n;f.transport=n;n===d("RequestStreamTransport").RequestStreamTransport.WEB_BR_MQTT?a.push(this.$21(e,i,babelHelpers["extends"]({},f,{instrumentationData:{requestId:i,requestLogContext:this.$14}}))):a.push(this.$22(n,e,i,babelHelpers["extends"]({},f,{instrumentationData:{requestId:i,requestLogContext:this.$14}})))}}return(h||(h=b("Promise"))).allSettled(a).then(function(a){return a.map(function(a){return a.status==="fulfilled"})})};e.$21=function(a,e,f){var g,h,i;return b("regeneratorRuntime").async(function(b){while(1)switch(b.prev=b.next){case 0:c("BladeRunnerLogger").info("Running MQTT pulsar test");g=c("BladeRunnerDeferredClient");h=new(c("TestStateMachine"))(f,a,e);i=new(c("BladeRunnerStreamHandler"))(function(a){h.onPayloadReceived(a)},null,function(a){switch(a){case d("BladeRunnerStreamStatus").StreamStatus.ACCEPTED:h.onFlowStatusAccepted();break;case d("BladeRunnerStreamStatus").StreamStatus.STARTED:h.onFlowStatusStarted();h.onRequestLanded();break;case d("BladeRunnerStreamStatus").StreamStatus.STOPPED:h.onFlowStatusStopped();h.onRetry();break;case d("BladeRunnerStreamStatus").StreamStatus.REJECTED:h.onTerminate("StreamUpdate: REJECTED");break;case d("BladeRunnerStreamStatus").StreamStatus.CLOSED:h.onTerminate("StreamUpdate: CLOSED");break;default:c("BladeRunnerLogger").info("Pulsar Received statusUpdate unknown?")}},function(a){c("BladeRunnerLogger").info(" Pulsar Received log: "+a)},function(a){c("BladeRunnerLogger").info("Pulsar Received batch: "+JSON.stringify(a))});h.onStart();g.requestStream({method:"Pulsar",test_id:a},this.$23(f),i,{requestId:e,forceLogContext:"pulsar"});return b.abrupt("return",!0);case 7:case"end":return b.stop()}},null,this)};e.$22=function(a,e,f,g){var h,i,j,k,l,m;return b("regeneratorRuntime").async(function(n){while(1)switch(n.prev=n.next){case 0:c("BladeRunnerLogger").info("Running SG pulsar test");h=a===d("RequestStreamTransport").RequestStreamTransport.WEB_RS_MQTT?c("MQTTRequestStreamDeferredClient"):c("DGWRequestStreamDeferredClient");i=null;if(!this.$17){n.next=7;break}n.next=6;return b("regeneratorRuntime").awrap(this.$24(h));case 6:i=n.sent;case 7:j=new(c("PulsarTest"))(g,h);n.prev=8;n.next=11;return b("regeneratorRuntime").awrap(j.start(e));case 11:k=n.sent;l=j.getState();this.$25(e,f,g,l,k);c("BladeRunnerLogger").info("Pulsar test finished.");n.next=21;break;case 17:n.prev=17;n.t0=n["catch"](8);c("BladeRunnerLogger").info("Pulsar test failed with exception msg: "+n.t0.message);return n.abrupt("return",!1);case 21:n.prev=21;(m=i)==null?void 0:m.cancel();return n.finish(21);case 24:return n.abrupt("return",!0);case 25:case"end":return n.stop()}},null,this,[[8,17,21,24]])};e.$24=function(a){var d;return b("regeneratorRuntime").async(function(e){while(1)switch(e.prev=e.next){case 0:e.next=2;return b("regeneratorRuntime").awrap(a.createStream({method:"Pulsar",test_id:"pulsar-prime-"+c("uuidv4")()},JSON.stringify({number_of_payloads:2,payload_size_in_bytes:1,time_interval_in_seconds:1e4,test_name:"pulsar-prime",time_span_mode:"fixed",publish_mode:"direct"}),null,new(c("RequestStreamHandler"))({onFlowStatus:function(){}})));case 2:d=e.sent;e.next=5;return b("regeneratorRuntime").awrap(d.start());case 5:return e.abrupt("return",d);case 6:case"end":return e.stop()}},null,this)};e.$20=function(a,d,e){var f,g,h,i,j,k;return b("regeneratorRuntime").async(function(l){while(1)switch(l.prev=l.next){case 0:if(!this.$26){l.next=4;break}return l.abrupt("return",!0);case 4:this.$26=!0;case 5:c("BladeRunnerLogger").info("Running ClientSync pulsar test");f=null;if(!this.$17){l.next=11;break}l.next=10;return b("regeneratorRuntime").awrap(this.$24(c("DGWRequestStreamDeferredClient")));case 10:f=l.sent;case 11:g=function(a,b,d){return new(c("RealtimeClientSync"))(a,b,d)};l.prev=12;h=new(c("ClientSyncPulsarTest"))(e,g);l.next=16;return b("regeneratorRuntime").awrap(h.start(d));case 16:i=l.sent;j=h.getState();this.$25(a,d,e,j,i);c("BladeRunnerLogger").info("Pulsar test finished.");l.next=26;break;case 22:l.prev=22;l.t0=l["catch"](12);c("BladeRunnerLogger").info("Pulsar test failed with exception msg: "+l.t0.message);return l.abrupt("return",!1);case 26:l.prev=26;(k=f)==null?void 0:k.cancel();this.$26=!1;return l.finish(26);case 30:return l.abrupt("return",!0);case 31:case"end":return l.stop()}},null,this,[[12,22,26,30]])};e.$25=function(a,b,c,e,f){d("PulsarLogger").pulsarLogger.log(c,{testId:a,requestId:b,testResult:e,numFlowStatusAccepted:f.numFlowStatusAccepted,numFlowStatusStarted:f.numFlowStatusStarted,numFlowStatusStopped:f.numFlowStatusStopped,numPayloadsReceived:f.numPayloadReceived,publishTimeoutIntervalMs:f.publishTimeoutIntervalMs,subscribeIssued:f.numRequests>0,subscribeRetryCount:f.numRetries,subscribeLatencyMs:f.initialRequestLatencyMs,subscribeSuccess:f.numRequestsLanded>0,testDurationMs:f.testEndTimestampMs-f.testStartTimestampMs,testEndTimeMs:f.testEndTimestampMs,numAmendSent:f.numAmendSent,numAmendAcked:f.numAmendAcked,numAmendExpected:c.numAmends,failureReason:e===d("PulsarTestTypes").PulsarTestState.SUCCESS?"":this.$27(f)})};e.$23=function(a){a={number_of_payloads:a.numPayloadsExpected,number_of_amends:a.numAmends,payload_size_in_bytes:a.payloadSize,time_interval_in_seconds:a.payloadIntervalMs/1e3,test_name:a.testName,time_span_mode:"fixed",publish_mode:"direct",close_on_finish:a.numAmends===0};return JSON.stringify({input:a})};e.$27=function(a){return a.failureReason!=null?a.lastSeenError!=null?a.failureReason+" lastSeenError: "+a.lastSeenError:a.failureReason:""};return a}();g["default"]=a}),98); __d("PulsarClientSingleton",["PulsarClient"],(function(a,b,c,d,e,f,g){"use strict";a=new(c("PulsarClient"))();g["default"]=a}),98);