;
l.StepAction={StepOut:0,
StepNext:1,
StepIn:2};
l.ScriptType={Native:0,
Extension:1,
Normal:2,
Wasm:3};
l.ScriptCompilationType={Host:0,
Eval:1,
JSON:2};
l.ScriptBreakPointType={ScriptId:0,
ScriptName:1,
ScriptRegExp:2};
l.BreakPositionAlignment={
Statement:0,
BreakPosition:1
};
function ScriptTypeFlag(n){
return(1<<n);
}
var o=0;
var p=1;
var q=[];
var r=[];
var s={
breakPointsActive:{
value:true,
getValue:function(){return this.value;},
setValue:function(t){
this.value=!!t;
%SetBreakPointsActive(this.value);
}
},
breakOnCaughtException:{
getValue:function(){return l.isBreakOnException();},
setValue:function(t){
if(t){
l.setBreakOnException();
}else{
l.clearBreakOnException();
}
}
},
breakOnUncaughtException:{
getValue:function(){return l.isBreakOnUncaughtException();},
setValue:function(t){
if(t){
l.setBreakOnUncaughtException();
}else{
l.clearBreakOnUncaughtException();
}
}
},
};
function MakeBreakPoint(u,v){
var w=new BreakPoint(u,v);
q.push(w);
return w;
}
function BreakPoint(u,v){
this.source_position_=u;
if(v){
this.script_break_point_=v;
}else{
this.number_=p++;
}
this.active_=true;
this.condition_=null;
}
BreakPoint.prototype.number=function(){
return this.number_;
};
BreakPoint.prototype.func=function(){
return this.func_;
};
BreakPoint.prototype.source_position=function(){
return this.source_position_;
};
BreakPoint.prototype.active=function(){
if(this.script_break_point()){
return this.script_break_point().active();
}
return this.active_;
};
BreakPoint.prototype.condition=function(){
if(this.script_break_point()&&this.script_break_point().condition()){
return this.script_break_point().condition();
}
return this.condition_;
};
BreakPoint.prototype.script_break_point=function(){
return this.script_break_point_;
};
BreakPoint.prototype.enable=function(){
this.active_=true;
};
BreakPoint.prototype.disable=function(){
this.active_=false;
};
BreakPoint.prototype.setCondition=function(x){
this.condition_=x;
};
BreakPoint.prototype.isTriggered=function(y){
if(!this.active())return false;
if(this.condition()){
try{
var z=y.frame(0).evaluate(this.condition());
if(!(z instanceof j)||!z.value_){
return false;
}
}catch(e){
return false;
}
}
return true;
};
function IsBreakPointTriggered(A,w){
return w.isTriggered(MakeExecutionState(A));
}
function ScriptBreakPoint(n,script_id_or_name,opt_line,opt_column,
opt_groupId,opt_position_alignment){
this.type_=n;
if(n==l.ScriptBreakPointType.ScriptId){
this.script_id_=script_id_or_name;
}else if(n==l.ScriptBreakPointType.ScriptName){
this.script_name_=script_id_or_name;
}else if(n==l.ScriptBreakPointType.ScriptRegExp){
this.script_regexp_object_=new e(script_id_or_name);
}else{
throw %make_error(2,"Unexpected breakpoint type "+n);
}
this.line_=opt_line||0;
this.column_=opt_column;
this.groupId_=opt_groupId;
this.position_alignment_=(opt_position_alignment===(void 0))
?l.BreakPositionAlignment.Statement:opt_position_alignment;
this.active_=true;
this.condition_=null;
this.break_points_=[];
}
ScriptBreakPoint.prototype.number=function(){
return this.number_;
};
ScriptBreakPoint.prototype.groupId=function(){
return this.groupId_;
};
ScriptBreakPoint.prototype.type=function(){
return this.type_;
};
ScriptBreakPoint.prototype.script_id=function(){
return this.script_id_;
};
ScriptBreakPoint.prototype.script_name=function(){
return this.script_name_;
};
ScriptBreakPoint.prototype.script_regexp_object=function(){
return this.script_regexp_object_;
};
ScriptBreakPoint.prototype.line=function(){
return this.line_;
};
ScriptBreakPoint.prototype.column=function(){
return this.column_;
};
ScriptBreakPoint.prototype.actual_locations=function(){
var B=[];
for(var C=0;C<this.break_points_.length;C++){
B.push(this.break_points_[C].actual_location);
}
return B;
};
ScriptBreakPoint.prototype.update_positions=function(D,E){
this.line_=D;
this.column_=E;
};
ScriptBreakPoint.prototype.active=function(){
return this.active_;
};
ScriptBreakPoint.prototype.condition=function(){
return this.condition_;
};
ScriptBreakPoint.prototype.enable=function(){
this.active_=true;
};
ScriptBreakPoint.prototype.disable=function(){
this.active_=false;
};
ScriptBreakPoint.prototype.setCondition=function(x){
this.condition_=x;
};
ScriptBreakPoint.prototype.matchesScript=function(F){
if(this.type_==l.ScriptBreakPointType.ScriptId){
return this.script_id_==F.id;
}else{
if(!(F.line_offset<=this.line_&&
this.line_<F.line_offset+%ScriptLineCount(F))){
return false;
}
if(this.type_==l.ScriptBreakPointType.ScriptName){
return this.script_name_==F.nameOrSourceURL();
}else if(this.type_==l.ScriptBreakPointType.ScriptRegExp){
return this.script_regexp_object_.test(F.nameOrSourceURL());
}else{
throw %make_error(2,"Unexpected breakpoint type "+this.type_);
}
}
};
ScriptBreakPoint.prototype.set=function(F){
var E=this.column();
var D=this.line();
if((E===(void 0))){
var G=%ScriptSourceLine(F,D||F.line_offset);
if(!F.sourceColumnStart_){
F.sourceColumnStart_=new d(%ScriptLineCount(F));
}
if((F.sourceColumnStart_[D]===(void 0))){
F.sourceColumnStart_[D]=
G.match(m)[0].length;
}
E=F.sourceColumnStart_[D];
}
var H=l.findScriptSourcePosition(F,this.line(),E);
if((H===null))return;
var w=MakeBreakPoint(H,this);
var I=%SetScriptBreakPoint(F,H,
this.position_alignment_,
w);
if((I===(void 0))){
I=H;
}
var J=F.locationFromPosition(I,true);
w.actual_location={line:J.line,
column:J.column,
script_id:F.id};
this.break_points_.push(w);
return w;
};
ScriptBreakPoint.prototype.clear=function(){
var K=[];
for(var C=0;C<q.length;C++){
if(q[C].script_break_point()&&
q[C].script_break_point()===this){
%ClearBreakPoint(q[C]);
}else{
K.push(q[C]);
}
}
q=K;
this.break_points_=[];
};
l.setListener=function(L,M){
if(!(%IsFunction(L))&&!(L===(void 0))&&!(L===null)){
throw %make_type_error(36);
}
%SetDebugEventListener(L,M);
};
l.findScript=function(N){
if((%IsFunction(N))){
return %FunctionGetScript(N);
}else if(%IsRegExp(N)){
var O=this.scripts();
var P=null;
var Q=0;
for(var C in O){
var F=O[C];
if(N.test(F.name)){
P=F;
Q++;
}
}
if(Q==1){
return P;
}else{
return(void 0);
}
}else{
return %GetScript(N);
}
};
l.scriptSource=function(N){
return this.findScript(N).source;
};
l.source=function(R){
if(!(%IsFunction(R)))throw %make_type_error(36);
return %FunctionGetSourceCode(R);
};
l.sourcePosition=function(R){
if(!(%IsFunction(R)))throw %make_type_error(36);
return %FunctionGetScriptSourcePosition(R);
};
l.findFunctionSourceLocation=function(S,T,U){
var F=%FunctionGetScript(S);
var V=%FunctionGetScriptSourcePosition(S);
return %ScriptLocationFromLine(F,T,U,V);
};
l.findScriptSourcePosition=function(F,T,U){
var W=%ScriptLocationFromLine(F,T,U,0);
return W?W.position:null;
};
l.findBreakPoint=function(X,Y){
var w;
for(var C=0;C<q.length;C++){
if(q[C].number()==X){
w=q[C];
if(Y){
q.splice(C,1);
}
break;
}
}
if(w){
return w;
}else{
return this.findScriptBreakPoint(X,Y);
}
};
l.findBreakPointActualLocations=function(X){
for(var C=0;C<r.length;C++){
if(r[C].number()==X){
return r[C].actual_locations();
}
}
for(var C=0;C<q.length;C++){
if(q[C].number()==X){
return[q[C].actual_location];
}
}
return[];
};
l.setBreakPoint=function(S,T,U,Z){
if(!(%IsFunction(S)))throw %make_type_error(36);
if(%FunctionIsAPIFunction(S)){
throw %make_error(2,'Cannot set break point in native code.');
}
var u=
this.findFunctionSourceLocation(S,T,U).position;
var F=%FunctionGetScript(S);
if(F.type==l.ScriptType.Native){
throw %make_error(2,'Cannot set break point in native code.');
}
if(F&&F.id){
var W=F.locationFromPosition(u,false);
return this.setScriptBreakPointById(F.id,
W.line,W.column,
Z);
}else{
var w=MakeBreakPoint(u);
var I=
%SetFunctionBreakPoint(S,u,w);
var J=F.locationFromPosition(I,true);
w.actual_location={line:J.line,
column:J.column,
script_id:F.id};
w.setCondition(Z);
return w.number();
}
};
l.setBreakPointByScriptIdAndPosition=function(script_id,H,
x,enabled,
opt_position_alignment)
{
var w=MakeBreakPoint(H);
w.setCondition(x);
if(!enabled){
w.disable();
}
var F=scriptById(script_id);
if(F){
var aa=(opt_position_alignment===(void 0))
?l.BreakPositionAlignment.Statement:opt_position_alignment;
w.actual_position=%SetScriptBreakPoint(F,H,
aa,w);
}
return w;
};
l.enableBreakPoint=function(X){
var w=this.findBreakPoint(X,false);
if(w){
w.enable();
}
};
l.disableBreakPoint=function(X){
var w=this.findBreakPoint(X,false);
if(w){
w.disable();
}
};
l.changeBreakPointCondition=function(X,x){
var w=this.findBreakPoint(X,false);
w.setCondition(x);
};
l.clearBreakPoint=function(X){
var w=this.findBreakPoint(X,true);
if(w){
return %ClearBreakPoint(w);
}else{
w=this.findScriptBreakPoint(X,true);
if(!w)throw %make_error(2,'Invalid breakpoint');
}
};
l.clearAllBreakPoints=function(){
for(var C=0;C<q.length;C++){
var w=q[C];
%ClearBreakPoint(w);
}
q=[];
};
l.disableAllBreakPoints=function(){
for(var C=1;C<p;C++){
l.disableBreakPoint(C);
}
%ChangeBreakOnException(l.ExceptionBreak.Caught,false);
%ChangeBreakOnException(l.ExceptionBreak.Uncaught,false);
};
l.findScriptBreakPoint=function(X,Y){
var ab;
for(var C=0;C<r.length;C++){
if(r[C].number()==X){
ab=r[C];
if(Y){
ab.clear();
r.splice(C,1);
}
break;
}
}
return ab;
};
l.setScriptBreakPoint=function(n,script_id_or_name,
T,U,Z,
opt_groupId,opt_position_alignment){
var ab=
new ScriptBreakPoint(n,script_id_or_name,T,U,
opt_groupId,opt_position_alignment);
ab.number_=p++;
ab.setCondition(Z);
r.push(ab);
var O=this.scripts();
for(var C=0;C<O.length;C++){
if(ab.matchesScript(O[C])){
ab.set(O[C]);
}
}
return ab.number();
};
l.setScriptBreakPointById=function(script_id,
T,U,
Z,opt_groupId,
opt_position_alignment){
return this.setScriptBreakPoint(l.ScriptBreakPointType.ScriptId,
script_id,T,U,
Z,opt_groupId,
opt_position_alignment);
};
l.setScriptBreakPointByName=function(script_name,
T,U,
Z,opt_groupId){
return this.setScriptBreakPoint(l.ScriptBreakPointType.ScriptName,
script_name,T,U,
Z,opt_groupId);
};
l.setScriptBreakPointByRegExp=function(script_regexp,
T,U,
Z,opt_groupId){
return this.setScriptBreakPoint(l.ScriptBreakPointType.ScriptRegExp,
script_regexp,T,U,
Z,opt_groupId);
};
l.enableScriptBreakPoint=function(X){
var ab=this.findScriptBreakPoint(X,false);
ab.enable();
};
l.disableScriptBreakPoint=function(X){
var ab=this.findScriptBreakPoint(X,false);
ab.disable();
};
l.changeScriptBreakPointCondition=function(
X,x){
var ab=this.findScriptBreakPoint(X,false);
ab.setCondition(x);
};
l.scriptBreakPoints=function(){
return r;
};
l.clearStepping=function(){
%ClearStepping();
};
l.setBreakOnException=function(){
return %ChangeBreakOnException(l.ExceptionBreak.Caught,true);
};
l.clearBreakOnException=function(){
return %ChangeBreakOnException(l.ExceptionBreak.Caught,false);
};
l.isBreakOnException=function(){
return!!%IsBreakOnException(l.ExceptionBreak.Caught);
};
l.setBreakOnUncaughtException=function(){
return %ChangeBreakOnException(l.ExceptionBreak.Uncaught,true);
};
l.clearBreakOnUncaughtException=function(){
return %ChangeBreakOnException(l.ExceptionBreak.Uncaught,false);
};
l.isBreakOnUncaughtException=function(){
return!!%IsBreakOnException(l.ExceptionBreak.Uncaught);
};
l.showBreakPoints=function(R,ac,ad){
if(!(%IsFunction(R)))throw %make_error(36);
var ae=ac?this.scriptSource(R):this.source(R);
var af=ac?0:this.sourcePosition(R);
var aa=(ad===(void 0))
?l.BreakPositionAlignment.Statement:ad;
var B=%GetBreakLocations(R,aa);
if(!B)return ae;
B.sort(function(ag,ah){return ag-ah;});
var ai="";
var aj=0;
var ak;
for(var C=0;C<B.length;C++){
ak=B[C]-af;
ai+=ae.slice(aj,ak);
ai+="[B"+C+"]";
aj=ak;
}
ak=ae.length;
ai+=ae.substring(aj,ak);
return ai;
};
l.scripts=function(){
return %DebugGetLoadedScripts();
};
function scriptById(al){
var O=l.scripts();
for(var F of O){
if(F.id==al)return F;
}
return(void 0);
};
l.debuggerFlags=function(){
return s;
};
l.MakeMirror=g;
function MakeExecutionState(A){
return new ExecutionState(A);
}
function ExecutionState(A){
this.break_id=A;
this.selected_frame=0;
}
ExecutionState.prototype.prepareStep=function(am){
if(am===l.StepAction.StepIn||
am===l.StepAction.StepOut||
am===l.StepAction.StepNext){
return %PrepareStep(this.break_id,am);
}
throw %make_type_error(36);
};
ExecutionState.prototype.evaluateGlobal=function(ae){
return g(%DebugEvaluateGlobal(this.break_id,ae));
};
ExecutionState.prototype.frameCount=function(){
return %GetFrameCount(this.break_id);
};
ExecutionState.prototype.frame=function(an){
if(an==null)an=this.selected_frame;
if(an<0||an>=this.frameCount()){
throw %make_type_error(35);
}
return new c(this.break_id,an);
};
ExecutionState.prototype.setSelectedFrame=function(ao){
var C=(%_ToNumber(ao));
if(C<0||C>=this.frameCount()){
throw %make_type_error(35);
}
this.selected_frame=C;
};
ExecutionState.prototype.selectedFrame=function(){
return this.selected_frame;
};
function MakeBreakEvent(A,ap){
return new BreakEvent(A,ap);
}
function BreakEvent(A,ap){
this.frame_=new c(A,0);
this.break_points_hit_=ap;
}
BreakEvent.prototype.eventType=function(){
return l.DebugEvent.Break;
};
BreakEvent.prototype.func=function(){
return this.frame_.func();
};
BreakEvent.prototype.sourceLine=function(){
return this.frame_.sourceLine();
};
BreakEvent.prototype.sourceColumn=function(){
return this.frame_.sourceColumn();
};
BreakEvent.prototype.sourceLineText=function(){
return this.frame_.sourceLineText();
};
BreakEvent.prototype.breakPointsHit=function(){
return this.break_points_hit_;
};
function MakeExceptionEvent(A,aq,ar,as){
return new ExceptionEvent(A,aq,ar,as);
}
function ExceptionEvent(A,aq,ar,as){
this.exec_state_=new ExecutionState(A);
this.exception_=aq;
this.uncaught_=ar;
this.promise_=as;
}
ExceptionEvent.prototype.eventType=function(){
return l.DebugEvent.Exception;
};
ExceptionEvent.prototype.exception=function(){
return this.exception_;
};
ExceptionEvent.prototype.uncaught=function(){
return this.uncaught_;
};
ExceptionEvent.prototype.promise=function(){
return this.promise_;
};
ExceptionEvent.prototype.func=function(){
return this.exec_state_.frame(0).func();
};
ExceptionEvent.prototype.sourceLine=function(){
return this.exec_state_.frame(0).sourceLine();
};
ExceptionEvent.prototype.sourceColumn=function(){
return this.exec_state_.frame(0).sourceColumn();
};
ExceptionEvent.prototype.sourceLineText=function(){
return this.exec_state_.frame(0).sourceLineText();
};
function MakeCompileEvent(F,n){
return new CompileEvent(F,n);
}
function CompileEvent(F,n){
this.script_=g(F);
this.type_=n;
}
CompileEvent.prototype.eventType=function(){
return this.type_;
};
CompileEvent.prototype.script=function(){
return this.script_;
};
function MakeScriptObject_(F,at){
var au={id:F.id(),
name:F.name(),
lineOffset:F.lineOffset(),
columnOffset:F.columnOffset(),
lineCount:F.lineCount(),
};
if(!(F.data()===(void 0))){
au.data=F.data();
}
if(at){
au.source=F.source();
}
return au;
}
function MakeAsyncTaskEvent(n,av){
return new AsyncTaskEvent(n,av);
}
function AsyncTaskEvent(n,av){
this.type_=n;
this.id_=av;
}
AsyncTaskEvent.prototype.type=function(){
return this.type_;
}
AsyncTaskEvent.prototype.id=function(){
return this.id_;
}
b.InstallConstants(a,[
"Debug",l,
"BreakEvent",BreakEvent,
"CompileEvent",CompileEvent,
"BreakPoint",BreakPoint,
]);
b.InstallFunctions(b,2,[
"MakeExecutionState",MakeExecutionState,
"MakeExceptionEvent",MakeExceptionEvent,
"MakeBreakEvent",MakeBreakEvent,
"MakeCompileEvent",MakeCompileEvent,
"MakeAsyncTaskEvent",MakeAsyncTaskEvent,
"IsBreakPointTriggered",IsBreakPointTriggered,
]);
})

 liveedit}
(function(a,b){
"use strict";
var c=a.Debug.findScriptSourcePosition;
var d=a.Array;
var e=a.Math.floor;
var f=a.Math.max;
var g=a.SyntaxError;
var h;
function ApplyPatchMultiChunk(script,diff_array,new_source,preview_only,
change_log){
var i=script.source;
var j=GatherCompileInfo(i,script);
var k=BuildCodeInfoTree(j);
var l=new PosTranslator(diff_array);
MarkChangedFunctions(k,l.GetChunks());
FindLiveSharedInfos(k,script);
var m;
try{
m=GatherCompileInfo(new_source,script);
}catch(e){
var n=
new Failure("Failed to compile new version of script: "+e);
if(e instanceof g){
var o={
type:"liveedit_compile_error",
syntaxErrorMessage:e.message
};
CopyErrorPositionToDetails(e,o);
n.details=o;
}
throw n;
}
var p=m.reduce(
(max,info)=>f(max,info.function_literal_id),0);
var q=BuildCodeInfoTree(m);
FindCorrespondingFunctions(k,q);
var r=new d();
var s=new d();
var t=new d();
var u=new d();
function HarvestTodo(v){
function CollectDamaged(w){
s.push(w);
for(var x=0;x<w.children.length;x++){
CollectDamaged(w.children[x]);
}
}
function CollectNew(y){
for(var x=0;x<y.length;x++){
t.push(y[x]);
CollectNew(y[x].children);
}
}
if(v.status==h.DAMAGED){
CollectDamaged(v);
return;
}
if(v.status==h.UNCHANGED){
u.push(v);
}else if(v.status==h.SOURCE_CHANGED){
u.push(v);
}else if(v.status==h.CHANGED){
r.push(v);
CollectNew(v.unmatched_new_nodes);
}
for(var x=0;x<v.children.length;x++){
HarvestTodo(v.children[x]);
}
}
var z={
change_tree:DescribeChangeTree(k),
textual_diff:{
old_len:i.length,
new_len:new_source.length,
chunks:diff_array
},
updated:false
};
if(preview_only){
return z;
}
HarvestTodo(k);
var A=new d();
var B=new d();
for(var x=0;x<r.length;x++){
var C=r[x].live_shared_function_infos;
var D=
r[x].corresponding_node.info.shared_function_info;
if(C){
for(var E=0;E<C.length;E++){
A.push(C[E]);
B.push(D);
}
}
}
var F=
CheckStackActivations(A,
B,
change_log);
z.stack_modified=F!=0;
var G;
if(s.length==0){
%LiveEditReplaceScript(script,new_source,null);
G=(void 0);
}else{
var H=CreateNameForOldScript(script);
G=%LiveEditReplaceScript(script,new_source,H);
var I=new d();
change_log.push({linked_to_old_script:I});
for(var x=0;x<s.length;x++){
LinkToOldScript(s[x],G,
I);
}
z.created_script_name=H;
}
for(var x=0;x<r.length;x++){
PatchFunctionCode(r[x],change_log);
}
var J=new d();
change_log.push({position_patched:J});
for(var x=0;x<u.length;x++){
PatchPositions(u[x],diff_array,
J);
if(u[x].live_shared_function_infos){
var K=
u[x]
.corresponding_node.info.function_literal_id;
u[x].live_shared_function_infos.forEach(function(
info){
%LiveEditFunctionSourceUpdated(
info.raw_array,K);
});
}
}
%LiveEditFixupScript(script,p);
for(var x=0;x<t.length;x++){
%LiveEditFunctionSetScript(
t[x].info.shared_function_info,script);
}
z.updated=true;
return z;
}
function GatherCompileInfo(L,M){
var N=%LiveEditGatherCompileInfo(M,L);
var O=new d();
var P=new d();
for(var x=0;x<N.length;x++){
var Q=new FunctionCompileInfo(N[x]);
%LiveEditFunctionSetScript(Q.shared_function_info,(void 0));
O.push(Q);
P.push(x);
}
for(var x=0;x<O.length;x++){
var R=x;
for(var E=x+1;E<O.length;E++){
if(O[R].start_position>O[E].start_position){
R=E;
}
}
if(R!=x){
var S=O[R];
var T=P[R];
O[R]=O[x];
P[R]=P[x];
O[x]=S;
P[x]=T;
}
}
var U=0;
function ResetIndexes(V,W){
var X=-1;
while(U<O.length&&
O[U].outer_index==W){
var Y=U;
O[Y].outer_index=V;
if(X!=-1){
O[X].next_sibling_index=Y;
}
X=Y;
U++;
ResetIndexes(Y,P[Y]);
}
if(X!=-1){
O[X].next_sibling_index=-1;
}
}
ResetIndexes(-1,-1);
Assert(U==O.length);
return O;
}
function PatchFunctionCode(v,Z){
var D=v.corresponding_node.info;
if(v.live_shared_function_infos){
v.live_shared_function_infos.forEach(function(aa){
%LiveEditReplaceFunctionCode(D.raw_array,
aa.raw_array);
for(var x=0;x<v.children.length;x++){
if(v.children[x].corresponding_node){
var ab=
v.children[x].corresponding_node.info.
shared_function_info;
if(v.children[x].live_shared_function_infos){
v.children[x].live_shared_function_infos.
forEach(function(ac){
%LiveEditReplaceRefToNestedFunction(
aa.info,
ab,
ac.info);
});
}
}
}
});
Z.push({function_patched:D.function_name});
}else{
Z.push({function_patched:D.function_name,
function_info_not_found:true});
}
}
function LinkToOldScript(ad,G,ae){
if(ad.live_shared_function_infos){
ad.live_shared_function_infos.
forEach(function(Q){
%LiveEditFunctionSetScript(Q.info,G);
});
ae.push({name:ad.info.function_name});
}else{
ae.push(
{name:ad.info.function_name,not_found:true});
}
}
function Assert(af,ag){
if(!af){
if(ag){
throw"Assert "+ag;
}else{
throw"Assert";
}
}
}
function DiffChunk(ah,ai,aj,ak){
this.pos1=ah;
this.pos2=ai;
this.len1=aj;
this.len2=ak;
}
function PosTranslator(al){
var am=new d();
var an=0;
for(var x=0;x<al.length;x+=3){
var ao=al[x];
var ap=ao+an;
var aq=al[x+1];
var ar=al[x+2];
am.push(new DiffChunk(ao,ap,aq-ao,
ar-ap));
an=ar-aq;
}
this.chunks=am;
}
PosTranslator.prototype.GetChunks=function(){
return this.chunks;
};
PosTranslator.prototype.Translate=function(as,at){
var au=this.chunks;
if(au.length==0||as<au[0].pos1){
return as;
}
var av=0;
var aw=au.length-1;
while(av<aw){
var ax=e((av+aw)/2);
if(as<au[ax+1].pos1){
aw=ax;
}else{
av=ax+1;
}
}
var ay=au[av];
if(as>=ay.pos1+ay.len1){
return as+ay.pos2+ay.len2-ay.pos1-ay.len1;
}
if(!at){
at=PosTranslator.DefaultInsideChunkHandler;
}
return at(as,ay);
};
PosTranslator.DefaultInsideChunkHandler=function(as,az){
Assert(false,"Cannot translate position in changed area");
};
PosTranslator.ShiftWithTopInsideChunkHandler=
function(as,az){
return as-az.pos1+az.pos2;
};
var h={
UNCHANGED:"unchanged",
SOURCE_CHANGED:"source changed",
CHANGED:"changed",
DAMAGED:"damaged"
};
function CodeInfoTreeNode(aA,aB,aC){
this.info=aA;
this.children=aB;
this.array_index=aC;
this.parent=(void 0);
this.status=h.UNCHANGED;
this.status_explanation=(void 0);
this.new_start_pos=(void 0);
this.new_end_pos=(void 0);
this.corresponding_node=(void 0);
this.unmatched_new_nodes=(void 0);
this.textual_corresponding_node=(void 0);
this.textually_unmatched_new_nodes=(void 0);
this.live_shared_function_infos=(void 0);
}
function BuildCodeInfoTree(aD){
var aE=0;
function BuildNode(){
var aF=aE;
aE++;
var aG=new d();
while(aE<aD.length&&
aD[aE].outer_index==aF){
aG.push(BuildNode());
}
var w=new CodeInfoTreeNode(aD[aF],aG,
aF);
for(var x=0;x<aG.length;x++){
aG[x].parent=w;
}
return w;
}
var aH=BuildNode();
Assert(aE==aD.length);
return aH;
}
function MarkChangedFunctions(aI,am){
var aJ=new function(){
var aK=0;
var aL=0;
this.current=function(){return am[aK];};
this.next=function(){
var ay=am[aK];
aL=ay.pos2+ay.len2-(ay.pos1+ay.len1);
aK++;
};
this.done=function(){return aK>=am.length;};
this.TranslatePos=function(as){return as+aL;};
};
function ProcessInternals(aM){
aM.new_start_pos=aJ.TranslatePos(
aM.info.start_position);
var aN=0;
var aO=false;
var aP=false;
while(!aJ.done()&&
aJ.current().pos1<aM.info.end_position){
if(aN<aM.children.length){
var aQ=aM.children[aN];
if(aQ.info.end_position<=aJ.current().pos1){
ProcessUnchangedChild(aQ);
aN++;
continue;
}else if(aQ.info.start_position>=
aJ.current().pos1+aJ.current().len1){
aO=true;
aJ.next();
continue;
}else if(aQ.info.start_position<=aJ.current().pos1&&
aQ.info.end_position>=aJ.current().pos1+
aJ.current().len1){
ProcessInternals(aQ);
aP=aP||
(aQ.status!=h.UNCHANGED);
aO=aO||
(aQ.status==h.DAMAGED);
aN++;
continue;
}else{
aO=true;
aQ.status=h.DAMAGED;
aQ.status_explanation=
"Text diff overlaps with function boundary";
aN++;
continue;
}
}else{
if(aJ.current().pos1+aJ.current().len1<=
aM.info.end_position){
aM.status=h.CHANGED;
aJ.next();
continue;
}else{
aM.status=h.DAMAGED;
aM.status_explanation=
"Text diff overlaps with function boundary";
return;
}
}
Assert("Unreachable",false);
}
while(aN<aM.children.length){
var aQ=aM.children[aN];
ProcessUnchangedChild(aQ);
aN++;
}
if(aO){
aM.status=h.CHANGED;
}else if(aP){
aM.status=h.SOURCE_CHANGED;
}
aM.new_end_pos=
aJ.TranslatePos(aM.info.end_position);
}
function ProcessUnchangedChild(w){
w.new_start_pos=aJ.TranslatePos(w.info.start_position);
w.new_end_pos=aJ.TranslatePos(w.info.end_position);
}
ProcessInternals(aI);
}
function FindCorrespondingFunctions(aR,aS){
function ProcessNode(v,aT){
var aU=
IsFunctionContextLocalsChanged(v.info,aT.info);
if(aU){
v.status=h.CHANGED;
}
var aV=v.children;
var aW=aT.children;
var aX=[];
var aY=[];
var aZ=0;
var ba=0;
while(aZ<aV.length){
if(aV[aZ].status==h.DAMAGED){
aZ++;
}else if(ba<aW.length){
if(aW[ba].info.start_position<
aV[aZ].new_start_pos){
aX.push(aW[ba]);
aY.push(aW[ba]);
ba++;
}else if(aW[ba].info.start_position==
aV[aZ].new_start_pos){
if(aW[ba].info.end_position==
aV[aZ].new_end_pos){
aV[aZ].corresponding_node=
aW[ba];
aV[aZ].textual_corresponding_node=
aW[ba];
if(aU){
aV[aZ].status=h.DAMAGED;
aV[aZ].status_explanation=
"Enclosing function is now incompatible. "+
aU;
aV[aZ].corresponding_node=(void 0);
}else if(aV[aZ].status!=
h.UNCHANGED){
ProcessNode(aV[aZ],
aW[ba]);
if(aV[aZ].status==h.DAMAGED){
aX.push(
aV[aZ].corresponding_node);
aV[aZ].corresponding_node=(void 0);
v.status=h.CHANGED;
}
}else{
ProcessNode(aV[aZ],aW[ba]);
}
}else{
aV[aZ].status=h.DAMAGED;
aV[aZ].status_explanation=
"No corresponding function in new script found";
v.status=h.CHANGED;
aX.push(aW[ba]);
aY.push(aW[ba]);
}
ba++;
aZ++;
}else{
aV[aZ].status=h.DAMAGED;
aV[aZ].status_explanation=
"No corresponding function in new script found";
v.status=h.CHANGED;
aZ++;
}
}else{
aV[aZ].status=h.DAMAGED;
aV[aZ].status_explanation=
"No corresponding function in new script found";
v.status=h.CHANGED;
aZ++;
}
}
while(ba<aW.length){
aX.push(aW[ba]);
aY.push(aW[ba]);
ba++;
}
if(v.status==h.CHANGED){
if(v.info.param_num!=aT.info.param_num){
v.status=h.DAMAGED;
v.status_explanation="Changed parameter number: "+
v.info.param_num+" and "+aT.info.param_num;
}
}
v.unmatched_new_nodes=aX;
v.textually_unmatched_new_nodes=
aY;
}
ProcessNode(aR,aS);
aR.corresponding_node=aS;
aR.textual_corresponding_node=aS;
Assert(aR.status!=h.DAMAGED,
"Script became damaged");
}
function FindLiveSharedInfos(aR,M){
var bb=%LiveEditFindSharedFunctionInfosForScript(M);
var bc=new d();
for(var x=0;x<bb.length;x++){
bc.push(new SharedInfoWrapper(bb[x]));
}
function FindFunctionInfos(O){
var bd=[];
for(var x=0;x<bc.length;x++){
var be=bc[x];
if(be.start_position==O.start_position&&
be.end_position==O.end_position){
bd.push(be);
}
}
if(bd.length>0){
return bd;
}
}
function TraverseTree(w){
w.live_shared_function_infos=FindFunctionInfos(w.info);
for(var x=0;x<w.children.length;x++){
TraverseTree(w.children[x]);
}
}
TraverseTree(aR);
}
function FunctionCompileInfo(bf){
this.function_name=bf[0];
this.start_position=bf[1];
this.end_position=bf[2];
this.param_num=bf[3];
this.scope_info=bf[4];
this.outer_index=bf[5];
this.shared_function_info=bf[6];
this.function_literal_id=bf[7];
this.next_sibling_index=null;
this.raw_array=bf;
}
function SharedInfoWrapper(bf){
this.function_name=bf[0];
this.start_position=bf[1];
this.end_position=bf[2];
this.info=bf[3];
this.raw_array=bf;
}
function PatchPositions(ad,al,ae){
if(ad.live_shared_function_infos){
ad.live_shared_function_infos.forEach(function(Q){
%LiveEditPatchFunctionPositions(Q.raw_array,
al);
});
ae.push({name:ad.info.function_name});
}else{
ae.push(
{name:ad.info.function_name,info_not_found:true});
}
}
function CreateNameForOldScript(M){
return M.name+" (old)";
}
function IsFunctionContextLocalsChanged(bg,bh){
var bi=bg.scope_info;
var bj=bh.scope_info;
var bk;
var bl;
if(bi){
bk=bi.toString();
}else{
bk="";
}
if(bj){
bl=bj.toString();
}else{
bl="";
}
if(bk!=bl){
return"Variable map changed: ["+bk+
"] => ["+bl+"]";
}
return;
}
var bm;
function CheckStackActivations(old_shared_wrapper_list,
new_shared_list,
Z){
var bn=new d();
for(var x=0;x<old_shared_wrapper_list.length;x++){
bn[x]=old_shared_wrapper_list[x].info;
}
var bo=%LiveEditCheckAndDropActivations(
bn,new_shared_list,true);
if(bo[old_shared_wrapper_list.length]){
throw new Failure(bo[old_shared_wrapper_list.length]);
}
var bp=new d();
var bq=new d();
for(var x=0;x<bn.length;x++){
var br=old_shared_wrapper_list[x];
if(bo[x]==bm.REPLACED_ON_ACTIVE_STACK){
bq.push({name:br.function_name});
}else if(bo[x]!=bm.AVAILABLE_FOR_PATCH){
var bs={
name:br.function_name,
start_pos:br.start_position,
end_pos:br.end_position,
replace_problem:
bm.SymbolName(bo[x])
};
bp.push(bs);
}
}
if(bq.length>0){
Z.push({dropped_from_stack:bq});
}
if(bp.length>0){
Z.push({functions_on_stack:bp});
throw new Failure("Blocked by functions on stack");
}
return bq.length;
}
var bm={
AVAILABLE_FOR_PATCH:1,
BLOCKED_ON_ACTIVE_STACK:2,
BLOCKED_ON_OTHER_STACK:3,
BLOCKED_UNDER_NATIVE_CODE:4,
REPLACED_ON_ACTIVE_STACK:5,
BLOCKED_UNDER_GENERATOR:6,
BLOCKED_ACTIVE_GENERATOR:7,
BLOCKED_NO_NEW_TARGET_ON_RESTART:8
};
bm.SymbolName=function(bt){
var bu=bm;
for(var bv in bu){
if(bu[bv]==bt){
return bv;
}
}
};
function Failure(ag){
this.message=ag;
}
Failure.prototype.toString=function(){
return"LiveEdit Failure: "+this.message;
};
function CopyErrorPositionToDetails(bw,o){
function createPositionStruct(M,bx){
if(bx==-1)return;
var by=M.locationFromPosition(bx,true);
if(by==null)return;
return{
line:by.line+1,
column:by.column+1,
position:bx
};
}
if(!("scriptObject"in bw)||!("startPosition"in bw)){
return;
}
var M=bw.scriptObject;
var bz={
start:createPositionStruct(M,bw.startPosition),
end:createPositionStruct(M,bw.endPosition)
};
o.position=bz;
}
function SetScriptSource(M,bA,bB,Z){
var i=M.source;
var bC=CompareStrings(i,bA);
return ApplyPatchMultiChunk(M,bC,bA,bB,
Z);
}
function CompareStrings(bD,bE){
return %LiveEditCompareStrings(bD,bE);
}
function ApplySingleChunkPatch(M,change_pos,change_len,new_str,
Z){
var i=M.source;
var bA=i.substring(0,change_pos)+
new_str+i.substring(change_pos+change_len);
return ApplyPatchMultiChunk(M,
[change_pos,change_pos+change_len,change_pos+new_str.length],
bA,false,Z);
}
function DescribeChangeTree(aR){
function ProcessOldNode(w){
var bF=[];
for(var x=0;x<w.children.length;x++){
var aQ=w.children[x];
if(aQ.status!=h.UNCHANGED){
bF.push(ProcessOldNode(aQ));
}
}
var bG=[];
if(w.textually_unmatched_new_nodes){
for(var x=0;x<w.textually_unmatched_new_nodes.length;x++){
var aQ=w.textually_unmatched_new_nodes[x];
bG.push(ProcessNewNode(aQ));
}
}
var bH={
name:w.info.function_name,
positions:DescribePositions(w),
status:w.status,
children:bF,
new_children:bG
};
if(w.status_explanation){
bH.status_explanation=w.status_explanation;
}
if(w.textual_corresponding_node){
bH.new_positions=DescribePositions(w.textual_corresponding_node);
}
return bH;
}
function ProcessNewNode(w){
var bF=[];
if(false){
for(var x=0;x<w.children.length;x++){
bF.push(ProcessNewNode(w.children[x]));
}
}
var bH={
name:w.info.function_name,
positions:DescribePositions(w),
children:bF,
};
return bH;
}
function DescribePositions(w){
return{
start_position:w.info.start_position,
end_position:w.info.end_position
};
}
return ProcessOldNode(aR);
}
var bI={};
bI.SetScriptSource=SetScriptSource;
bI.ApplyPatchMultiChunk=ApplyPatchMultiChunk;
bI.Failure=Failure;
bI.TestApi={
PosTranslator:PosTranslator,
CompareStrings:CompareStrings,
ApplySingleChunkPatch:ApplySingleChunkPatch
};
a.Debug.LiveEdit=bI;
})

@ prologue3
(function(a,b,c){
"use strict";
%CheckIsBootstrapping();
var d=(void 0);
var e=%ExportFromRuntime({});
function Export(f){
f(e);
}
function Import(f){
f.next=d;
d=f;
}
function ImportNow(g){
return e[g];
}
function SetFunctionName(f,g,h){
if((typeof(g)==='symbol')){
g="["+%SymbolDescription(g)+"]";
}
if((h===(void 0))){
%FunctionSetName(f,g);
}else{
%FunctionSetName(f,h+" "+g);
}
}
function InstallConstants(i,j){
%CheckIsBootstrapping();
%OptimizeObjectForAddingMultipleProperties(i,j.length>>1);
var k=2|4|1;
for(var l=0;l<j.length;l+=2){
var g=j[l];
var m=j[l+1];
%AddNamedProperty(i,g,m,k);
}
%ToFastProperties(i);
}
function InstallFunctions(i,k,n){
%CheckIsBootstrapping();
%OptimizeObjectForAddingMultipleProperties(i,n.length>>1);
for(var l=0;l<n.length;l+=2){
var o=n[l];
var f=n[l+1];
SetFunctionName(f,o);
%FunctionRemovePrototype(f);
%AddNamedProperty(i,o,f,k);
%SetNativeFlag(f);
}
%ToFastProperties(i);
}
function InstallGetter(i,g,p,k,h){
%CheckIsBootstrapping();
if((k===(void 0)))k=2;
SetFunctionName(p,g,(h===(void 0))?"get":h);
%FunctionRemovePrototype(p);
%DefineGetterPropertyUnchecked(i,g,p,k);
%SetNativeFlag(p);
}
function OverrideFunction(i,g,f,q){
%CheckIsBootstrapping();
%object_define_property(i,g,{value:f,
writeable:true,
configurable:true,
enumerable:false});
SetFunctionName(f,g);
if(!q)%FunctionRemovePrototype(f);
%SetNativeFlag(f);
}
function SetUpLockedPrototype(
constructor,fields,methods){
%CheckIsBootstrapping();
var r=constructor.prototype;
var s=(methods.length>>1)+(fields?fields.length:0);
if(s>=4){
%OptimizeObjectForAddingMultipleProperties(r,s);
}
if(fields){
for(var l=0;l<fields.length;l++){
%AddNamedProperty(r,fields[l],
(void 0),2|4);
}
}
for(var l=0;l<methods.length;l+=2){
var o=methods[l];
var f=methods[l+1];
%AddNamedProperty(r,o,f,2|4|1);
%SetNativeFlag(f);
}
%InternalSetPrototype(r,null);
%ToFastProperties(r);
}
function PostNatives(b){
%CheckIsBootstrapping();
for(;!(d===(void 0));d=d.next){
d(e);
}
e=(void 0);
b.Export=(void 0);
b.Import=(void 0);
b.ImportNow=(void 0);
b.PostNatives=(void 0);
}
%OptimizeObjectForAddingMultipleProperties(b,14);
b.Import=Import;
b.ImportNow=ImportNow;
b.Export=Export;
b.SetFunctionName=SetFunctionName;
b.InstallConstants=InstallConstants;
b.InstallFunctions=InstallFunctions;
b.InstallGetter=InstallGetter;
b.OverrideFunction=OverrideFunction;
b.SetUpLockedPrototype=SetUpLockedPrototype;
b.PostNatives=PostNatives;
%ToFastProperties(b);
%OptimizeObjectForAddingMultipleProperties(c,11);
c.logStackTrace=function logStackTrace(){
%DebugTrace();
};
c.log=function log(){
let message='';
for(const arg of arguments){
message+=arg;
}
%GlobalPrint(message);
};
c.createPrivateSymbol=function createPrivateSymbol(g){
return %CreatePrivateSymbol(g);
};
c.simpleBind=function simpleBind(t,u){
return function(...args){
return %reflect_apply(t,u,args);
};
};
c.uncurryThis=function uncurryThis(t){
return function(u,...args){
return %reflect_apply(t,u,args);
};
};
c.rejectPromise=function rejectPromise(v,w){
%promise_internal_reject(v,w,true);
}
c.markPromiseAsHandled=function markPromiseAsHandled(v){
%PromiseMarkAsHandled(v);
};
c.promiseState=function promiseState(v){
return %PromiseStatus(v);
};
c.kPROMISE_PENDING=0;
c.kPROMISE_FULFILLED=1;
c.kPROMISE_REJECTED=2;
%ToFastProperties(c);
})

