diff --git a/README.md b/README.md index 2a1bd7ce2..54cd80503 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ You can choose the latest stable release : ```html ``` @@ -72,7 +72,7 @@ with the [available stdlib](https://github.com/brython-dev/brython/tree/master/w ```html ``` diff --git a/npm/package.json b/npm/package.json index 2bb77c2f0..a375f12a5 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "brython", - "version": "3.12.1", + "version": "3.12.3", "description": "Python 3 in the browser", "main": "brython.js", "scripts": { diff --git a/releases/index.html b/releases/index.html index 2bf81b500..e640077d9 100644 --- a/releases/index.html +++ b/releases/index.html @@ -7,7 +7,7 @@ -
+ - + - + @@ -40,8 +40,8 @@ - + @@ -49,8 +49,16 @@ - - + + + + + + + + + + diff --git a/www/demo.html b/www/demo.html index bad269c02..714456a14 100644 --- a/www/demo.html +++ b/www/demo.html @@ -1277,6 +1277,8 @@ + + @@ -1307,6 +1309,15 @@ + + + + + + + + + diff --git a/www/doc/doc_brython.css b/www/doc/doc_brython.css index 9fe1150b6..5259870f7 100644 --- a/www/doc/doc_brython.css +++ b/www/doc/doc_brython.css @@ -146,7 +146,7 @@ select.language { border-color:#888; border-radius: 10px; width:auto; - font-family: "Consolas"; + font-family: "Consolas", monospace; } .xml{ @@ -176,7 +176,7 @@ li { } pre{ - font-family: Consolas; + font-family: Consolas, monospace; } pre.marked { color:var(--header-color); @@ -200,7 +200,7 @@ span.python-builtin{ code { color:var(--special-text-color); - font-family: Consolas; + font-family: Consolas, monospace; } em { diff --git a/www/doc/en/install.md b/www/doc/en/install.md index eee163e9e..fe7b7f672 100644 --- a/www/doc/en/install.md +++ b/www/doc/en/install.md @@ -11,14 +11,14 @@ Brython scripts from a CDN: ``` The minor version can be specified with `brython@3.12` and the micro version -with `brython@3.12.1`. +with `brython@3.12.3`. Brython is also available with cdnjs: ```xml - - ``` diff --git a/www/doc/fr/install.md b/www/doc/fr/install.md index 8ca8fa00e..18a7d8d1f 100644 --- a/www/doc/fr/install.md +++ b/www/doc/fr/install.md @@ -11,14 +11,14 @@ d'inclure les scripts Brython dans la page HTML depuis un CDN. ``` On peut aussi préciser la version mineure avec `brython@3.12` et la version -micro avec `brython@3.12.1`. +micro avec `brython@3.12.3`. Brython est également disponible sur cdnjs: ```xml - - ``` diff --git a/www/gallery/ajax.html b/www/gallery/ajax.html index efb7913d5..2fad94164 100644 --- a/www/gallery/ajax.html +++ b/www/gallery/ajax.html @@ -14,6 +14,8 @@ + + @@ -35,8 +37,8 @@ - + @@ -45,6 +47,16 @@ + + + + + + + + + + diff --git a/www/gallery/indexedDB_cache.html b/www/gallery/indexedDB_cache.html index 59ae256c0..bc91e05e9 100644 --- a/www/gallery/indexedDB_cache.html +++ b/www/gallery/indexedDB_cache.html @@ -17,6 +17,8 @@ + + @@ -47,6 +49,15 @@ + + + + + + + + + diff --git a/www/gallery/inject_scripts.html b/www/gallery/inject_scripts.html index 992ffc200..2ec4cd6ea 100644 --- a/www/gallery/inject_scripts.html +++ b/www/gallery/inject_scripts.html @@ -16,6 +16,8 @@ + + @@ -29,7 +31,6 @@ - @@ -38,6 +39,7 @@ + @@ -47,11 +49,15 @@ + + - - - + + + + + diff --git a/www/gallery/music/drum_score.py b/www/gallery/music/drum_score.py index 002840013..633f8a2dd 100644 --- a/www/gallery/music/drum_score.py +++ b/www/gallery/music/drum_score.py @@ -11,7 +11,7 @@ def __init__(self, message): class NoteStyle: checked = '#666' - unchecked = '#ddd' + unchecked = {0: '#bbb', 1: '#ddd'} class NoteCell(html.TD): @@ -22,10 +22,13 @@ def __init__(self, text=""): class Note(NoteCell): - def __init__(self, bar, instrument): + def __init__(self, bar, instrument, pos): super().__init__() self.instrument = instrument self.bar = bar + nb = bar.score.notes_per_bar + div = nb / 4 + self.unchecked_color = NoteStyle.unchecked[(pos // div) % 2] self.bind('click', self.click) self.uncheck() @@ -45,14 +48,9 @@ def check(self): self.style.backgroundColor = NoteStyle.checked def uncheck(self): - self.style.backgroundColor = NoteStyle.unchecked + self.style.backgroundColor = self.unchecked_color -def checked(elt): - return elt.style.backgroundColor != NoteStyle.unchecked - -seq = [] - class Tab(html.TD): def __init__(self, score, num): @@ -68,41 +66,36 @@ def __init__(self, score, num): self.add_close_button() def add_close_button(self): - if self.num > 1: - self.row <= self.close_button + self.row <= self.close_button def remove_close_button(self): - if self.num > 1: - self.close_button.remove() + self.close_button.remove() def select(self): - index = self.num - 1 - bar = self.score.bars[index] if self.score.selected_tab is not None: self.score.selected_tab.unselect() + index = self.score.tabs.index(self) self.score.bar_cell <= self.score.bars[index] self.score.selected_tab = self self.className = 'selected_tab' + self.add_close_button() def unselect(self): - bar = self.score.bars[self.num - 1] self.score.bar_cell.clear() self.className = 'unselected_tab' def close(self, ev): ev.stopPropagation() - self.score.tabs[-2].add_close_button() - self.score.tabs[-2].select() - del self.score.tabs[-1] - del self.score.bars[-1] - self.remove() + self.score.remove_tab(self) + class Score(html.TABLE): - def __init__(self, instruments): + def __init__(self, instruments, notes_per_bar=12): super().__init__(cellpadding=0, cellspacing=0, Class='score') self.instruments = instruments + self.notes_per_bar = notes_per_bar self.plus_tab = html.TD('+', Class='plus unselected_tab') self.tabs = [] @@ -135,46 +128,76 @@ def new_tab(self, ev=None, notes=None): tab.select() self.selected_tab = tab + def get_tab(self, tab_num): + for tab in self.tabs: + if tab.num == tab_num: + return tab + def show_pattern(self, pattern_num): - selected = self.tabs[pattern_num] - if selected is self.selected_tab: - return - selected.select() + for tab in self.tabs: + if tab.num == pattern_num: + selected = tab + if selected is self.selected_tab: + return + selected.select() + + def play_pattern(self, ev): + pass def flash(self, cell): cell.style.backgroundColor = 'black' timer.set_timeout(lambda: cell.check(), 100) def select_tab(self, ev): - self.show_pattern(int(ev.target.text) - 1) - - def get_seq(self, bpm): + tab = ev.target.parentNode.closest('TD') + while not hasattr(tab, 'num'): + tab = tab.parentNode.closest('TD') + self.show_pattern(tab.num) + + def remove_tab(self, tab): + ix = self.tabs.index(tab) + if len(self.tabs) > 1: + next_tab = self.tabs[ix + 1] if ix < len(self.tabs) - 1 \ + else self.tabs[ix - 1] + self.tabs.remove(tab) + del self.bars[ix] + tab.remove() + if self.tabs: + self.show_pattern(next_tab.num) + + def get_seq(self, pattern_num=None): seq = [] patterns = [] - for pattern in self.patterns.value.split(): - repeat = pattern.split('x') - if len(repeat) == 2: - patterns += [int(repeat[0]) - 1] * int(repeat[1]) - elif len(repeat) > 2: - raise PatternError(f'invalid pattern: {pattern}') - else: - patterns.append(int(pattern) - 1) - #patterns = [int(x.strip()) - 1 for x in self.patterns.value.split()] + if pattern_num is None: + for pattern in self.patterns.value.split(): + repeat = pattern.split('x') + if len(repeat) == 2: + patterns += [int(repeat[0])] * int(repeat[1]) + elif len(repeat) > 2: + raise PatternError(f'invalid pattern: {pattern}') + else: + patterns.append(int(pattern)) + else: + patterns = [pattern_num + 1] nb_bars = len(patterns) # there are bpm quarter notes per minute # each quarter note lasts 60/bpm second + quarter_len = 60 / self.bpm # a bar has 4 quarter notes, so a bar lasts 240/bpm seconds + bar_len = 4 * quarter_len + # number of notes between 2 quarter notes # dt is the interval between 16th notes (1/4 of a quarter) - dt = 15 / bpm + dt = bar_len / self.notes_per_bar t0 = 0 for pattern in patterns: - bar = self.bars[pattern] + tab = self.get_tab(pattern) + bar = self.bars[self.tabs.index(tab)] notes = bar.notes for line_num, instrument in enumerate(notes): for pos in notes[instrument]: cell = bar.lines[line_num].children[pos + 1] seq.append((line_num, t0 + pos * dt, pattern, cell)) - t0 += 240 / bpm + t0 += bar_len seq.sort(key=lambda x: x[1]) return seq, nb_bars @@ -186,16 +209,22 @@ def __init__(self, score, notes=None): self.score = score if notes is None: notes = {} - top = html.TR(html.TD(' ')) - top <= [NoteCell(x) for x in '1 2 3 4 '] + play_button = html.BUTTON('⏵') + play_button.bind('click', self.score.play_pattern) + top = html.TR(html.TD(play_button)) + nb = score.notes_per_bar + if nb == 16: + top <= [NoteCell(x) for x in '1 2 3 4 '] + elif nb == 13: + top <= [NoteCell(x) for x in '1 2 3 4 '] self <= top self.lines = [] self.notes = {} for instrument in score.instruments: self.notes[instrument] = notes.get(instrument.__name__, []) line = html.TR(html.TD(instrument.__name__)) - for pos in range(16): - note = Note(self, instrument) + for pos in range(nb): + note = Note(self, instrument, pos) line <= note if pos in self.notes[instrument]: note.check() diff --git a/www/gallery/music/synth_drums.html b/www/gallery/music/synth_drums.html index 5b4f0cc57..c2165c6ad 100644 --- a/www/gallery/music/synth_drums.html +++ b/www/gallery/music/synth_drums.html @@ -10,23 +10,30 @@ -
- Kick frequency
-
-
-
-
-
+
+
`};code.__getattribute__=function(self,attr){return self[attr]};$B.set_func_names(code,"builtins");_b_.compile=function(){var $=$B.args("compile",7,{source:null,filename:null,mode:null,flags:null,dont_inherit:null,optimize:null,_feature_version:null},["source","filename","mode","flags","dont_inherit","optimize","_feature_version"],arguments,{flags:0,dont_inherit:false,optimize:-1,_feature_version:0},null,null);var module_name="$exec_"+$B.UUID();$.__class__=code;$.co_flags=$.flags;$.co_name="";var filename=$.co_filename=$.filename;var interactive=$.mode=="single"&&$.flags&512;$B.file_cache[filename]=$.source;$B.url2name[filename]=module_name;if($B.$isinstance($.source,_b_.bytes)){var encoding="utf-8",lfpos=$.source.source.indexOf(10),first_line,second_line;if(lfpos==-1){first_line=$.source}else{first_line=_b_.bytes.$factory($.source.source.slice(0,lfpos))}first_line=_b_.bytes.decode(first_line,"latin-1");var encoding_re=/^[\t\f]*#.*?coding[:=][\t]*([-_.a-zA-Z0-9]+)/;var mo=first_line.match(encoding_re);if(mo){encoding=mo[1]}else if(lfpos>-1){var rest=$.source.source.slice(lfpos+1);lfpos=rest.indexOf(10);if(lfpos>-1){second_line=_b_.bytes.$factory(rest.slice(0,lfpos))}else{second_line=_b_.bytes.$factory(rest)}second_line=_b_.bytes.decode(second_line,"latin-1");mo=second_line.match(encoding_re);if(mo){encoding=mo[1]}}$.source=_b_.bytes.decode($.source,encoding)}if(!$B.$isinstance(filename,[_b_.bytes,_b_.str])){$B.warn(_b_.DeprecationWarning,`path should be string, bytes, or os.PathLike, `+`not ${$B.class_name(filename)}`)}if(interactive&&!$.source.endsWith("\n")){var lines=$.source.split("\n");if($B.last(lines).startsWith(" ")){throw _b_.SyntaxError.$factory("unexpected EOF while parsing")}}if($.source.__class__&&$.source.__class__.__module__=="ast"){$B.imported._ast._validate($.source);$._ast=$.source;delete $.source;return $}var _ast,parser;if($B.parser_to_ast){try{var parser_mode=$.mode=="eval"?"eval":"file";parser=new $B.Parser($.source,filename,parser_mode);_ast=parser.parse()}catch(err){if($.mode=="single"){try{parser.tokens.next}catch(err2){var tokens=parser.tokens,tester=tokens[tokens.length-2];if(tester.type=="NEWLINE"&&$.flags&16384||tester.type=="DEDENT"&&$.flags&512){err.__class__=_b_.SyntaxError;err.args[0]="incomplete input"}}}throw err}if($.mode=="single"&&_ast.body.length==1&&_ast.body[0]instanceof $B.ast.Expr){parser=new $B.Parser($.source,filename,"eval");_ast=parser.parse();$.single_expression=true}if($.flags==$B.PyCF_ONLY_AST){delete $B.url2name[filename];let res=$B.ast_js_to_py(_ast);res.$js_ast=_ast;return res}}else{var root=$B.parser.create_root_node({src:$.source,filename:filename},module_name,module_name);root.mode=$.mode;root.parent_block=$B.builtins_scope;try{$B.parser.dispatch_tokens(root,$.source);_ast=root.ast()}catch(err){if($.mode=="single"&&root.token_reader.read()===undefined){let tokens=root.token_reader.tokens,tester=tokens[tokens.length-2];if(tester.type=="NEWLINE"&&$.flags&16384||tester.type=="DEDENT"&&$.flags&512){err.__class__=_b_.SyntaxError;err.args[0]="incomplete input"}}throw err}if($.mode=="single"&&_ast.body.length==1&&_ast.body[0]instanceof $B.ast.Expr){root=$B.parser.create_root_node({src:$.source,filename:filename},module_name,module_name);root.mode="eval";$.single_expression=true;root.parent_block=$B.builtins_scope;$B.parser.dispatch_tokens(root,$.source);_ast=root.ast()}delete $B.url2name[filename];if($.flags==$B.PyCF_ONLY_AST){$B.create_python_ast_classes();let res=$B.ast_js_to_py(_ast);res.$js_ast=_ast;return res}}delete $B.url2name[filename];$._ast=$B.ast_js_to_py(_ast);$._ast.$js_ast=_ast;return $};_b_.debug=$B.debug>0;_b_.delattr=function(obj,attr){check_nb_args_no_kw("delattr",2,arguments);if(typeof attr!="string"){throw _b_.TypeError.$factory("attribute name must be string, not '"+$B.class_name(attr)+"'")}return $B.$getattr(obj,"__delattr__")(attr)};$B.$delete=function(name,is_global){function del(obj){if(obj.__class__===$B.generator){obj.js_gen.return()}}var found=false,frame=$B.frame_obj.frame;if(!is_global){if(frame[1][name]!==undefined){found=true;del(frame[1][name]);delete frame[1][name]}}else{if(frame[2]!=frame[0]&&frame[3][name]!==undefined){found=true;del(frame[3][name]);delete frame[3][name]}}if(!found){throw $B.name_error(name)}};_b_.dir=function(obj){if(obj===undefined){var locals=_b_.locals();return _b_.sorted(locals)}check_nb_args_no_kw("dir",1,arguments);var klass=obj.__class__||$B.get_class(obj);if(obj.$is_class){var dir_func=$B.$getattr(obj.__class__,"__dir__");return $B.$call(dir_func)(obj)}try{let res=$B.$call($B.$getattr(klass,"__dir__"))(obj);res=_b_.list.$factory(res);return res}catch(err){if($B.get_option("debug")>2){console.log("error in dir, obj",obj,"klass",klass,$B.$getattr(klass,"__dir__"),err.message)}throw err}};_b_.divmod=function(x,y){check_nb_args_no_kw("divmod",2,arguments);try{return $B.rich_op("__divmod__",x,y)}catch(err){if($B.is_exc(err,[_b_.TypeError])){return _b_.tuple.$factory([$B.rich_op("__floordiv__",x,y),$B.rich_op("__mod__",x,y)])}throw err}};var enumerate=_b_.enumerate=$B.make_class("enumerate",(function(){var $ns=$B.args("enumerate",2,{iterable:null,start:null},["iterable","start"],arguments,{start:0},null,null),_iter=iter($ns["iterable"]),start=$ns["start"];return{__class__:enumerate,__name__:"enumerate iterator",counter:start-1,iter:_iter,start:start}}));enumerate.__iter__=function(self){self.counter=self.start-1;return self};enumerate.__next__=function(self){self.counter++;return $B.fast_tuple([self.counter,next(self.iter)])};$B.set_func_names(enumerate,"builtins");var $$eval=_b_.eval=function(){var $=$B.args("eval",4,{src:null,globals:null,locals:null,mode:null},["src","globals","locals","mode"],arguments,{globals:_b_.None,locals:_b_.None,mode:"eval"},null,null,4),src=$.src,_globals=$.globals,_locals=$.locals,mode=$.mode;if($.src.mode&&$.src.mode=="single"&&["",""].indexOf($.src.filename)>-1){_b_.print(">",$.src.source.trim())}var filename="";if(src.__class__===code){filename=src.filename}else if(!src.valueOf||typeof src.valueOf()!=="string"){throw _b_.TypeError.$factory(`${mode}() arg 1 must be a string,`+" bytes or code object")}else{src=src.valueOf()}var __name__="exec";if(_globals!==_b_.None&&_globals.__class__==_b_.dict&&_b_.dict.$contains_string(_globals,"__name__")){__name__=_b_.dict.$getitem_string(_globals,"__name__")}$B.url2name[filename]=__name__;var frame=$B.frame_obj.frame;$B.exec_scope=$B.exec_scope||{};if(typeof src=="string"&&src.endsWith("\\\n")){var exc=_b_.SyntaxError.$factory("unexpected EOF while parsing");var lines=src.split("\n"),line=lines[lines.length-2];exc.args=["unexpected EOF while parsing",[filename,lines.length-1,1,line]];exc.filename=filename;exc.text=line;throw exc}var local_name="locals_"+__name__,global_name="globals_"+__name__,exec_locals={},exec_globals={};if(_globals===_b_.None){if(frame[1]===frame[3]){global_name+="_globals";exec_locals=exec_globals=frame[3]}else{if(mode=="exec"){exec_locals=$B.clone(frame[1]);for(var attr in frame[3]){exec_locals[attr]=frame[3][attr]}exec_globals=exec_locals}else{exec_locals=frame[1];exec_globals=frame[3]}}}else{if(_globals.__class__!==_b_.dict){throw _b_.TypeError.$factory(`${mode}() globals must be `+"a dict, not "+$B.class_name(_globals))}exec_globals={};if(_globals.$jsobj){exec_globals=_globals.$jsobj}else{exec_globals=_globals.$jsobj={};for(var key of _b_.dict.$keys_string(_globals)){_globals.$jsobj[key]=_b_.dict.$getitem_string(_globals,key);if(key=="__name__"){__name__=_globals.$jsobj[key]}}_globals.$all_str=false}if(exec_globals.__builtins__===undefined){exec_globals.__builtins__=_b_.__builtins__}if(_locals===_b_.None){exec_locals=exec_globals}else{if(_locals===_globals){global_name+="_globals";exec_locals=exec_globals}else if(_locals.$jsobj){for(let key in _locals.$jsobj){exec_globals[key]=_locals.$jsobj[key]}}else{if(_locals.$jsobj){exec_locals=_locals.$jsobj}else{var klass=$B.get_class(_locals),getitem=$B.$call($B.$getattr(klass,"__getitem__")),setitem=$B.$call($B.$getattr(klass,"__setitem__"));exec_locals=new Proxy(_locals,{get(target,prop){if(prop=="$target"){return target}try{return getitem(target,prop)}catch(err){return undefined}},set(target,prop,value){return setitem(target,prop,value)}})}}}}var save_frame_obj=$B.frame_obj;var _ast;frame=[__name__,exec_locals,__name__,exec_globals];frame.is_exec_top=true;frame.__file__=filename;frame.$f_trace=$B.enter_frame(frame);var _frame_obj=$B.frame_obj;frame.$lineno=1;if(src.__class__===code){_ast=src._ast;if(_ast.$js_ast){_ast=_ast.$js_ast}else{_ast=$B.ast_py_to_js(_ast)}}try{if($B.parser_to_ast){if(!_ast){var _mode=mode=="eval"?"eval":"file";_ast=new $B.Parser(src,filename,_mode).parse()}}else{if(!_ast){var root=$B.parser.create_root_node(src,"",frame[0],frame[2],1);root.mode=mode;root.filename=filename;$B.parser.dispatch_tokens(root);_ast=root.ast()}}var future=$B.future_features(_ast,filename),symtable=$B._PySymtable_Build(_ast,filename,future),js_obj=$B.js_from_root({ast:_ast,symtable:symtable,filename:filename,namespaces:{local_name:local_name,exec_locals:exec_locals,global_name:global_name,exec_globals:exec_globals}}),js=js_obj.js}catch(err){if(err.args){if(err.args[1]){exec_locals.$lineno=err.args[1][1]}}else{console.log("JS Error",err.message)}$B.frame_obj=save_frame_obj;throw err}if(mode=="eval"){js=`var __file__ = '${filename}'\n`+`var locals = ${local_name}\nreturn ${js}`}else if(src.single_expression){js=`var result = ${js}\n`+`if(result !== _b_.None){\n`+`_b_.print(result)\n`+`}`}try{var exec_func=new Function("$B","_b_",local_name,global_name,"frame","_frame_obj",js)}catch(err){if($B.get_option("debug")>1){console.log("eval() error\n",$B.format_indent(js,0));console.log("-- python source\n",src)}throw err}try{var res=exec_func($B,_b_,exec_locals,exec_globals,frame,_frame_obj)}catch(err){if($B.get_option("debug")>2){console.log("Python code\n",src,"\nexec func",$B.format_indent(exec_func+"",0),"\n filename",filename,"\n name from filename",$B.url2name[filename],"\n local_name",local_name,"\n exec_locals",exec_locals,"\n global_name",global_name,"\n exec_globals",exec_globals,"\n frame",frame,"\n _ast",_ast,"\n js",js)}$B.frame_obj=save_frame_obj;throw err}if(_globals!==_b_.None&&!_globals.$jsobj){for(var _key in exec_globals){if(!_key.startsWith("$")){_b_.dict.$setitem(_globals,_key,exec_globals[_key])}}}$B.frame_obj=save_frame_obj;return res};$$eval.$is_func=true;var exec=_b_.exec=function(){var $=$B.args("exec",3,{src:null,globals:null,locals:null},["src","globals","locals"],arguments,{globals:_b_.None,locals:_b_.None},null,null,3),src=$.src,globals=$.globals,locals=$.locals;$$eval(src,globals,locals,"exec");return _b_.None};exec.$is_func=true;var exit=_b_.exit=function(){throw _b_.SystemExit};exit.__repr__=exit.__str__=function(){return"Use exit() or Ctrl-Z plus Return to exit"};var filter=_b_.filter=$B.make_class("filter",(function(func,iterable){check_nb_args_no_kw("filter",2,arguments);iterable=iter(iterable);if(func===_b_.None){func=$B.$bool}return{__class__:filter,func:func,iterable:iterable}}));filter.__iter__=function(self){return self};filter.__next__=function(self){while(true){var _item=next(self.iterable);if(self.func(_item)){return _item}}};$B.set_func_names(filter,"builtins");_b_.format=function(){var $=$B.args("format",2,{value:null,format_spec:null},["value","format_spec"],arguments,{format_spec:""},null,null),value=$.value;var klass=value.__class__||$B.get_class(value);try{var method=$B.$getattr(klass,"__format__")}catch(err){if(err.__class__===_b_.AttributeError){throw _b_.NotImplementedError("__format__ is not implemented "+"for object '"+_b_.str.$factory(value)+"'")}throw err}return $B.$call(method)(value,$.format_spec)};function attr_error(attr,obj){var cname=$B.get_class(obj);var msg="bad operand type for unary #: '"+cname+"'";switch(attr){case"__neg__":throw _b_.TypeError.$factory(msg.replace("#","-"));case"__pos__":throw _b_.TypeError.$factory(msg.replace("#","+"));case"__invert__":throw _b_.TypeError.$factory(msg.replace("#","~"));case"__call__":throw _b_.TypeError.$factory("'"+cname+"'"+" object is not callable");default:throw $B.attr_error(attr,obj)}}_b_.getattr=function(){var missing={};var $=$B.args("getattr",3,{obj:null,attr:null,_default:null},["obj","attr","_default"],arguments,{_default:missing},null,null);if(!$B.$isinstance($.attr,_b_.str)){throw _b_.TypeError.$factory("attribute name must be string, "+`not '${$B.class_name($.attr)}'`)}return $B.$getattr($.obj,_b_.str.$to_string($.attr),$._default===missing?undefined:$._default)};function in_mro(klass,attr){if(klass===undefined){return false}if(klass.hasOwnProperty(attr)){return klass[attr]}var mro=klass.__mro__;for(var i=0,len=mro.length;i-1}))}break;case"__mro__":if(obj.__mro__){return _b_.tuple.$factory([obj].concat(obj.__mro__))}else if(obj.__dict__&&_b_.dict.$contains_string(obj.__dict__,"__mro__")){return _b_.dict.$getitem_string(obj.__dict__,"__mro__")}throw $B.attr_error(attr,obj);case"__subclasses__":if(klass.$factory||klass.$is_class){var subclasses=obj.$subclasses||[];return function(){return subclasses}}break}if(typeof obj=="function"){var value=obj[attr];if(value!==undefined){if(attr=="__module__"){return value}}}if(!is_class&&klass.$native){if(obj.$method_cache&&obj.$method_cache[attr]){return obj.$method_cache[attr]}if($test){console.log("native class",klass,klass[attr])}if(attr=="__doc__"&&klass[attr]===undefined){_get_builtins_doc();klass[attr]=$B.builtins_doc[klass.__name__]}if(klass[attr]===undefined){var object_attr=_b_.object[attr];if($test){console.log("object attr",object_attr)}if(object_attr!==undefined){klass[attr]=object_attr}else{if($test){console.log("obj[attr]",obj[attr])}var attrs=obj.__dict__;if(attrs&&_b_.dict.$contains_string(attrs,attr)){return _b_.dict.$getitem_string(attrs,attr)}if(_default===undefined){throw $B.attr_error(attr,obj)}return _default}}if(klass.$descriptors&&klass.$descriptors[attr]!==undefined){return klass[attr](obj)}if(typeof klass[attr]=="function"){var func=klass[attr];if(attr=="__new__"){func.$type="staticmethod"}if(func.$type=="staticmethod"){return func}var self=klass[attr].__class__==$B.method?klass:obj,method=klass[attr].bind(null,self);method.__class__=$B.method;method.$infos={__func__:func,__name__:attr,__self__:self,__qualname__:klass.__qualname__+"."+attr};if(typeof obj=="object"){obj.__class__=klass;obj.$method_cache=obj.$method_cache||{};if(obj.$method_cache){obj.$method_cache[attr]=method}}return method}else if(klass[attr].__class__===_b_.classmethod){return _b_.classmethod.__get__(klass[attr],obj,klass)}else if(klass[attr]!==undefined){return klass[attr]}attr_error(rawname,klass)}var attr_func;if(is_class){if($test){console.log("obj is class",obj);console.log("is a type ?",_b_.isinstance(klass,_b_.type));console.log("is type",klass===_b_.type)}if(klass===_b_.type){attr_func=_b_.type.__getattribute__}else{attr_func=$B.$call($B.$getattr(klass,"__getattribute__"))}if($test){console.log("attr func",attr_func)}}else{attr_func=klass.__getattribute__;if(attr_func===undefined){for(var cls of klass.__mro__){attr_func=cls["__getattribute__"];if(attr_func!==undefined){break}}}}if(typeof attr_func!=="function"){console.log(attr+" is not a function "+attr_func,klass)}var odga=_b_.object.__getattribute__;if($test){console.log("attr_func is odga ?",attr_func,attr_func===odga,"\n","\nobj[attr]",obj[attr])}if(attr_func===odga){res=obj[attr];if(Array.isArray(obj)&&Array.prototype[attr]!==undefined){res=undefined}else if(res===null){return null}else if(res!==undefined){if($test){console.log(obj,attr,obj[attr],res.__set__||res.$is_class)}if(res.$is_property){return _b_.property.__get__(res)}if(res.__set__===undefined||res.$is_class){if($test){console.log("return",res,res+"",res.__set__,res.$is_class)}return res}}}var getattr;try{res=attr_func(obj,attr);if($test){console.log("result of attr_func",res)}}catch(err){if($test){console.log("attr_func raised error",err.args,err.name)}if(klass===$B.module){getattr=obj.__getattr__;if($test){console.log("use module getattr",getattr);console.log(getattr+"")}if(getattr){try{return getattr(attr)}catch(err){if($test){console.log("encore erreur",err)}if(_default!==undefined){return _default}throw err}}}getattr=in_mro(klass,"__getattr__");if($test){console.log("try getattr",getattr)}if(getattr){if($test){console.log("try with getattr",getattr)}try{return getattr(obj,attr)}catch(err){if(_default!==undefined){return _default}throw err}}if(_default!==undefined){return _default}throw err}if(res!==undefined){return res}if(_default!==undefined){return _default}attr_error(rawname,is_class?obj:klass)};_b_.globals=function(){check_nb_args_no_kw("globals",0,arguments);var res=$B.obj_dict($B.frame_obj.frame[3]);res.$jsobj.__BRYTHON__=$B.JSObj.$factory($B);res.$is_namespace=true;return res};_b_.hasattr=function(obj,attr){check_nb_args_no_kw("hasattr",2,arguments);try{$B.$getattr(obj,attr);return true}catch(err){return false}};_b_.hash=function(obj){check_nb_args_no_kw("hash",1,arguments);return $B.$hash(obj)};$B.$hash=function(obj){if(obj.__hashvalue__!==undefined){return obj.__hashvalue__}if(typeof obj==="boolean"){return obj?1:0}if(obj.$is_class||obj.__class__===_b_.type||obj.__class__===$B.function){return obj.__hashvalue__=$B.$py_next_hash--}if(typeof obj=="string"){return _b_.str.__hash__(obj)}else if(typeof obj=="number"){return obj}else if(typeof obj=="boolean"){return obj?1:0}else if(obj.__class__===_b_.float){return _b_.float.$hash_func(obj)}var klass=obj.__class__||$B.get_class(obj);if(klass===undefined){throw _b_.TypeError.$factory("unhashable type: '"+_b_.str.$factory($B.JSObj.$factory(obj))+"'")}var hash_method=_b_.type.__getattribute__(klass,"__hash__",_b_.None);if(hash_method===_b_.None){throw _b_.TypeError.$factory("unhashable type: '"+$B.class_name(obj)+"'")}if(hash_method.$infos.__func__===_b_.object.__hash__){if(_b_.type.__getattribute__(klass,"__eq__")!==_b_.object.__eq__){throw _b_.TypeError.$factory("unhashable type: '"+$B.class_name(obj)+"'","hash")}else{return obj.__hashvalue__=_b_.object.__hash__(obj)}}else{return $B.$call(hash_method)(obj)}};function _get_builtins_doc(){if($B.builtins_doc===undefined){var url=$B.brython_path;if(url.charAt(url.length-1)=="/"){url=url.substr(0,url.length-1)}url+="/builtins_docstrings.js";var f=_b_.open(url);eval(f.$content);for(var key in docs){if(_b_[key]){_b_[key].__doc__=docs[key]}}$B.builtins_doc=docs}}var help=_b_.help=function(obj){if(obj===undefined){obj="help"}if(typeof obj=="string"){var lib_url="https://docs.python.org/3/library";var parts=obj.split("."),head=[],url;while(parts.length>0){head.push(parts.shift());if($B.stdlib[head.join(".")]){url=head.join(".")}else{break}}if(url){var doc_url;if(["browser","javascript","interpreter"].indexOf(obj.split(".")[0])>-1){doc_url="/static_doc/"+($B.language=="fr"?"fr":"en")}else{doc_url=lib_url}window.open(`${doc_url}/${url}.html#`+obj);return}if(_b_[obj]){if(obj==obj.toLowerCase()){url=lib_url+`/functions.html#${obj}`}else if(["False","True","None","NotImplemented","Ellipsis","__debug__"].indexOf(obj)>-1){url=lib_url+`/constants.html#${obj}`}else if(_b_[obj].$is_class&&_b_[obj].__bases__.indexOf(_b_.Exception)>-1){url=lib_url+`/exceptions.html#${obj}`}if(url){window.open(url);return}}$B.$import("pydoc");return $B.$call($B.$getattr($B.imported.pydoc,"help"))(obj)}if(obj.__class__===$B.module){return help(obj.__name__)}try{_b_.print($B.$getattr(obj,"__doc__"))}catch(err){return""}};help.__repr__=help.__str__=function(){return"Type help() for interactive help, or help(object) "+"for help about object."};_b_.hex=function(obj){check_nb_args_no_kw("hex",1,arguments);return bin_hex_oct(16,obj)};_b_.id=function(obj){check_nb_args_no_kw("id",1,arguments);if(obj.$id!==undefined){return obj.$id}else if($B.$isinstance(obj,[_b_.str,_b_.int,_b_.float])&&!$B.$isinstance(obj,$B.long_int)){return $B.$getattr(_b_.str.$factory(obj),"__hash__")()}else{return obj.$id=$B.UUID()}};_b_.__import__=function(){var $=$B.args("__import__",5,{name:null,globals:null,locals:null,fromlist:null,level:null},["name","globals","locals","fromlist","level"],arguments,{globals:None,locals:None,fromlist:_b_.tuple.$factory(),level:0},null,null);return $B.$__import__($.name,$.globals,$.locals,$.fromlist)};_b_.input=function(msg){var res=prompt(msg||"")||"";if($B.imported["sys"]&&$B.imported["sys"].ps1){var ps1=$B.imported["sys"].ps1,ps2=$B.imported["sys"].ps2;if(msg==ps1||msg==ps2){console.log(msg,res)}}return res};_b_.isinstance=function(obj,cls){check_nb_args_no_kw("isinstance",2,arguments);return $B.$isinstance(obj,cls)};$B.$isinstance=function(obj,cls){if(obj===null){return cls===$B.imported.javascript.NullType}if(obj===undefined){return false}var kls;if(Array.isArray(cls)){for(kls of cls){if($B.$isinstance(obj,kls)){return true}}return false}if(cls.__class__===$B.UnionType){for(kls of cls.items){if($B.$isinstance(obj,kls)){return true}}return false}if(cls.__class__===$B.GenericAlias){throw _b_.TypeError.$factory("isinstance() arg 2 cannot be a parameterized generic")}if(!cls.__class__&&!cls.$is_class){if(!$B.$getattr(cls,"__instancecheck__",false)){throw _b_.TypeError.$factory("isinstance() arg 2 must be a type "+"or tuple of types")}}if(cls===_b_.int&&(obj===True||obj===False)){return True}if(cls===_b_.bool){switch(typeof obj){case"string":return false;case"number":return false;case"boolean":return true}}var klass=obj.__class__;if(klass==undefined){if(typeof obj=="string"){if(cls==_b_.str){return true}else if($B.builtin_classes.indexOf(cls)>-1){return false}}else if(typeof obj=="number"&&Number.isFinite(obj)){if(Number.isFinite(obj)&&cls==_b_.int){return true}}klass=$B.get_class(obj)}if(klass===undefined){return false}if(klass===cls){return true}var mro=klass.__mro__;for(var i=0;i-1){return true}var sch=$B.$getattr(classinfo.__class__||$B.get_class(classinfo),"__subclasscheck__",_b_.None);if(sch==_b_.None){return false}return sch(classinfo,klass)};var iterator_class=$B.make_class("iterator",(function(getitem,len){return{__class__:iterator_class,getitem:getitem,len:len,counter:-1}}));iterator_class.__next__=function(self){self.counter++;if(self.len!==null&&self.counter==self.len){throw _b_.StopIteration.$factory("")}try{return self.getitem(self.counter)}catch(err){throw _b_.StopIteration.$factory("")}};$B.set_func_names(iterator_class,"builtins");const callable_iterator=$B.make_class("callable_iterator",(function(func,sentinel){return{__class__:callable_iterator,func:func,sentinel:sentinel}}));callable_iterator.__iter__=function(self){return self};callable_iterator.__next__=function(self){var res=self.func();if($B.rich_comp("__eq__",res,self.sentinel)){throw _b_.StopIteration.$factory()}return res};$B.set_func_names(callable_iterator,"builtins");$B.$iter=function(obj,sentinel){if(sentinel===undefined){var klass=obj.__class__||$B.get_class(obj);try{var _iter=$B.$call($B.$getattr(klass,"__iter__"))}catch(err){if(err.__class__===_b_.AttributeError){try{var gi_method=$B.$call($B.$getattr(klass,"__getitem__")),gi=function(i){return gi_method(obj,i)},len;try{len=len(obj)}catch(err){throw _b_.TypeError.$factory("'"+$B.class_name(obj)+"' object is not iterable")}return iterator_class.$factory(gi,len)}catch(err){throw _b_.TypeError.$factory("'"+$B.class_name(obj)+"' object is not iterable")}}throw err}var res=$B.$call(_iter)(obj);try{$B.$getattr(res,"__next__")}catch(err){if($B.$isinstance(err,_b_.AttributeError)){throw _b_.TypeError.$factory("iter() returned non-iterator of type '"+$B.class_name(res)+"'")}}return res}else{return callable_iterator.$factory(obj,sentinel)}};var iter=_b_.iter=function(){var $=$B.args("iter",1,{obj:null},["obj"],arguments,{},"args","kw"),sentinel;if($.args.length>0){sentinel=$.args[0]}return $B.$iter($.obj,sentinel)};var len=_b_.len=function(obj){check_nb_args_no_kw("len",1,arguments);var klass=obj.__class__||$B.get_class(obj);try{var method=$B.$getattr(klass,"__len__")}catch(err){throw _b_.TypeError.$factory("object of type '"+$B.class_name(obj)+"' has no len()")}return $B.$call(method)(obj)};_b_.locals=function(){check_nb_args("locals",0,arguments);var locals_obj=$B.frame_obj.frame[1];var class_locals=locals_obj.$target;if(class_locals){return class_locals}var res=$B.obj_dict($B.clone(locals_obj),(function(key){return key.startsWith("$")}));res.$is_namespace=true;return res};var map=_b_.map=$B.make_class("map",(function(){var $=$B.args("map",2,{func:null,it1:null},["func","it1"],arguments,{},"args",null),func=$B.$call($.func);var iter_args=[$B.make_js_iterator($.it1)];for(var arg of $.args){iter_args.push($B.make_js_iterator(arg))}var obj={__class__:map,args:iter_args,func:func};obj[Symbol.iterator]=function(){this.iters=[];for(var arg of this.args){this.iters.push(arg[Symbol.iterator]())}return this};obj.next=function(){var args=[];for(var iter of this.iters){var arg=iter.next();if(arg.done){return{done:true,value:null}}args.push(arg.value)}return{done:false,value:this.func.apply(null,args)}};return obj}));map.__iter__=function(self){self[Symbol.iterator]();return self};map.__next__=function(self){var args=[];for(var iter of self.iters){var arg=iter.next();if(arg.done){throw _b_.StopIteration.$factory("")}args.push(arg.value)}return self.func.apply(null,args)};$B.set_func_names(map,"builtins");function $extreme(args,op){var $op_name="min";if(op==="__gt__"){$op_name="max"}var $=$B.args($op_name,0,{},[],args,{},"args","kw");var has_default=false,func=false;for(var attr in $.kw.$jsobj){switch(attr){case"key":func=$.kw.$jsobj[attr];func=func===_b_.None?func:$B.$call(func);break;case"default":var default_value=$.kw.$jsobj[attr];has_default=true;break;default:throw _b_.TypeError.$factory("'"+attr+"' is an invalid keyword argument for this function")}}if(!func||func===_b_.None){func=x=>x}if($.args.length==0){throw _b_.TypeError.$factory($op_name+" expected 1 arguments, got 0")}else if($.args.length==1){var $iter=$B.make_js_iterator($.args[0]),res=null,x_value,extr_value;for(var x of $iter){if(res===null){extr_value=func(x);res=x}else{x_value=func(x);if($B.rich_comp(op,x_value,extr_value)){res=x;extr_value=x_value}}}if(res===null){if(has_default){return default_value}else{throw _b_.ValueError.$factory($op_name+"() arg is an empty sequence")}}else{return res}}else{if(has_default){throw _b_.TypeError.$factory("Cannot specify a default for "+$op_name+"() with multiple positional arguments")}var _args;if($B.last(args).$kw){_args=[$.args].concat($B.last(args))}else{_args=[$.args]}return $extreme.call(null,_args,op)}}_b_.max=function(){return $extreme(arguments,"__gt__")};var memoryview=_b_.memoryview=$B.make_class("memoryview",(function(obj){check_nb_args_no_kw("memoryview",1,arguments);if(obj.__class__===memoryview){return obj}if($B.get_class(obj).$buffer_protocol){return{__class__:memoryview,obj:obj,format:"B",itemsize:1,ndim:1,shape:_b_.tuple.$factory([_b_.len(obj)]),strides:_b_.tuple.$factory([1]),suboffsets:_b_.tuple.$factory([]),c_contiguous:true,f_contiguous:true,contiguous:true}}else{throw _b_.TypeError.$factory("memoryview: a bytes-like object "+"is required, not '"+$B.class_name(obj)+"'")}}));memoryview.$match_sequence_pattern=true,memoryview.$buffer_protocol=true;memoryview.$not_basetype=true;memoryview.__eq__=function(self,other){if(other.__class__!==memoryview){return false}return $B.$getattr(self.obj,"__eq__")(other.obj)};memoryview.__getitem__=function(self,key){var res;if($B.$isinstance(key,_b_.int)){var start=key*self.itemsize;if(self.format=="I"){res=self.obj.source[start];var coef=256;for(var i=1;i<4;i++){res+=self.obj.source[start+i]*coef;coef*=256}return res}else if("B".indexOf(self.format)>-1){if(key>self.obj.source.length-1){throw _b_.KeyError.$factory(key)}return self.obj.source[key]}else{return self.obj.source[key]}}res=self.obj.__class__.__getitem__(self.obj,key);if(key.__class__===_b_.slice){return memoryview.$factory(res)}};memoryview.__len__=function(self){return len(self.obj)/self.itemsize};memoryview.__setitem__=function(self,key,value){try{$B.$setitem(self.obj,key,value)}catch(err){throw _b_.TypeError.$factory("cannot modify read-only memory")}};memoryview.cast=function(self,format){switch(format){case"B":return memoryview.$factory(self.obj);case"I":var res=memoryview.$factory(self.obj),objlen=len(self.obj);res.itemsize=4;res.format="I";if(objlen%4!=0){throw _b_.TypeError.$factory("memoryview: length is not "+"a multiple of itemsize")}return res}};memoryview.hex=function(self){var res="",bytes=_b_.bytes.$factory(self);bytes.source.forEach((function(item){res+=item.toString(16)}));return res};memoryview.tobytes=function(self){return{__class__:_b_.bytes,source:self.obj.source}};memoryview.tolist=function(self){if(self.itemsize==1){return _b_.list.$factory(_b_.bytes.$factory(self.obj))}else if(self.itemsize==4){if(self.format=="I"){var res=[];for(var i=0;i=65536&&code<=131071||code>=131072&&code<=196607||code>=196608&&code<=262143||code>=851968&&code<=917503||code>=917504&&code<=1048575){return code}}throw _b_.TypeError.$factory("ord() expected a character, but "+"string of length "+c.length+" found")}switch($B.get_class(c)){case _b_.str:if(c.length==1){return c.charCodeAt(0)}throw _b_.TypeError.$factory("ord() expected a character, but "+"string of length "+c.length+" found");case _b_.bytes:case _b_.bytearray:if(c.source.length==1){return c.source[0]}throw _b_.TypeError.$factory("ord() expected a character, but "+"string of length "+c.source.length+" found");default:throw _b_.TypeError.$factory("ord() expected a character, but "+$B.class_name(c)+" was found")}};var complex_modulo=()=>_b_.ValueError.$factory("complex modulo");var all_ints=()=>_b_.TypeError.$factory("pow() 3rd argument not "+"allowed unless all arguments are integers");_b_.pow=function(){var $=$B.args("pow",3,{x:null,y:null,mod:null},["x","y","mod"],arguments,{mod:None},null,null),x=$.x,y=$.y,z=$.mod;if(z===_b_.None){return $B.rich_op("__pow__",x,y)}else{if($B.$isinstance(x,_b_.int)){if($B.$isinstance(y,_b_.float)){throw all_ints()}else if($B.$isinstance(y,_b_.complex)){throw complex_modulo()}else if($B.$isinstance(y,_b_.int)){if($B.$isinstance(z,_b_.complex)){throw complex_modulo()}else if(!$B.$isinstance(z,_b_.int)){throw all_ints()}}return _b_.int.__pow__(x,y,z)}else if($B.$isinstance(x,_b_.float)){throw all_ints()}else if($B.$isinstance(x,_b_.complex)){throw complex_modulo()}}};var $print=_b_.print=function(){var $ns=$B.args("print",0,{},[],arguments,{},"args","kw");var kw=$ns["kw"],end=$B.is_none(kw.$jsobj.end)?"\n":kw.$jsobj.end,sep=$B.is_none(kw.$jsobj.sep)?" ":kw.$jsobj.sep,file=$B.is_none(kw.$jsobj.file)?$B.get_stdout():kw.$jsobj.file;var args=$ns["args"],writer=$B.$getattr(file,"write");for(var i=0,len=args.length;i-1){has_slot=true;break}}}if(!has_slot){throw $B.attr_error(attr,klass)}}}if($test){console.log("attr",attr,"use _setattr",_setattr)}if(!_setattr){if(obj.__dict__===undefined){obj[attr]=value}else{_b_.dict.$setitem(obj.__dict__,attr,value)}if($test){console.log("no setattr, obj",obj)}}else{if($test){console.log("apply _setattr",obj,attr)}_setattr(obj,attr,value)}return None};_b_.sorted=function(){var $=$B.args("sorted",1,{iterable:null},["iterable"],arguments,{},null,"kw");var _list=_b_.list.$factory($.iterable),args=[_list].concat(Array.from(arguments).slice(1));_b_.list.sort.apply(null,args);return _list};_b_.sum=function(){var $=$B.args("sum",2,{iterable:null,start:null},["iterable","start"],arguments,{start:0},null,null),iterable=$.iterable,start=$.start;if($B.$isinstance(start,[_b_.str,_b_.bytes])){throw _b_.TypeError.$factory("sum() can't sum bytes"+" [use b''.join(seq) instead]")}var res=start;iterable=iter(iterable);while(true){try{var _item=next(iterable);res=$B.rich_op("__add__",res,_item)}catch(err){if(err.__class__===_b_.StopIteration){break}else{throw err}}}return res};$B.missing_super2=function(obj){obj.$missing=true;return obj};var $$super=_b_.super=$B.make_class("super",(function(_type,object_or_type){var no_object_or_type=object_or_type===undefined;if(_type===undefined&&object_or_type===undefined){var frame=$B.frame_obj.frame,pyframe=$B.imported["_sys"]._getframe(),code=$B.frame.f_code.__get__(pyframe),co_varnames=code.co_varnames;if(co_varnames.length>0){_type=frame[1].__class__;if(_type===undefined){throw _b_.RuntimeError.$factory("super(): no arguments")}object_or_type=frame[1][code.co_varnames[0]]}else{throw _b_.RuntimeError.$factory("super(): no arguments")}}if(!no_object_or_type&&Array.isArray(object_or_type)){object_or_type=object_or_type[0]}var $arg2;if(object_or_type!==undefined){if(object_or_type===_type||object_or_type.$is_class&&_b_.issubclass(object_or_type,_type)){$arg2="type"}else if($B.$isinstance(object_or_type,_type)){$arg2="object"}else{throw _b_.TypeError.$factory("super(type, obj): obj must be an instance "+"or subtype of type")}}return{__class__:$$super,__thisclass__:_type,__self_class__:object_or_type,$arg2:$arg2}}));$$super.__get__=function(self,instance){return $$super.$factory(self.__thisclass__,instance)};$$super.__getattribute__=function(self,attr){if(self.__thisclass__.$is_js_class){if(attr=="__init__"){return function(){mro[0].$js_func.call(self.__self_class__,...arguments)}}}var object_or_type=self.__self_class__,mro=self.$arg2=="type"?object_or_type.__mro__:$B.get_class(object_or_type).__mro__;var search_start=mro.indexOf(self.__thisclass__)+1,search_classes=mro.slice(search_start);var $test=attr=="new";if($test){console.log("super.__ga__, self",self,"search classes",search_classes)}var f;for(var klass of search_classes){if(klass===undefined){console.log("klass undef in super",self);console.log("mro",mro)}if(klass[attr]!==undefined){f=klass[attr];break}}if(f===undefined){if($$super[attr]!==undefined){return function(x){return function(){var args=[x];for(var i=0,len=arguments.length;i";if(self.__self_class__!==undefined){res+=", <"+self.__self_class__.__class__.__name__+" object>"}else{res+=", NULL"}return res+">"};$B.set_func_names($$super,"builtins");_b_.vars=function(){var def={},$=$B.args("vars",1,{obj:null},["obj"],arguments,{obj:def},null,null);if($.obj===def){return _b_.locals()}else{try{return $B.$getattr($.obj,"__dict__")}catch(err){if(err.__class__===_b_.AttributeError){throw _b_.TypeError.$factory("vars() argument must have __dict__ attribute")}throw err}}};var $Reader=$B.make_class("Reader");$Reader.__bool__=function(){return true};$Reader.__enter__=function(self){return self};$Reader.__exit__=function(){return false};$Reader.__init__=function(_self,initial_value=""){_self.$content=initial_value;_self.$counter=0};$Reader.__iter__=function(self){return iter($Reader.readlines(self))};$Reader.__len__=function(self){return self.lines.length};$Reader.__new__=function(cls){return{__class__:cls}};$Reader.close=function(self){self.closed=true};$Reader.flush=function(){return None};$Reader.read=function(){var $=$B.args("read",2,{self:null,size:null},["self","size"],arguments,{size:-1},null,null),self=$.self,size=$B.$GetInt($.size);if(self.closed===true){throw _b_.ValueError.$factory("I/O operation on closed file")}if(size<0){size=self.$length-self.$counter}var res;if(self.$binary){res=_b_.bytes.$factory(self.$content.source.slice(self.$counter,self.$counter+size))}else{res=self.$content.substr(self.$counter,size)}self.$counter+=size;return res};$Reader.readable=function(){return true};function make_lines(self){if(self.$lines===undefined){if(!self.$binary){self.$lines=self.$content.split("\n");if($B.last(self.$lines)==""){self.$lines.pop()}self.$lines=self.$lines.map((x=>x+"\n"))}else{var lines=[],pos=0,source=self.$content.source;while(pos-1){rest=rest.slice(0,size)}self.$counter=self.$content.source.length;return _b_.bytes.$factory(rest)}else{var line_source=self.$content.source.slice(self.$counter,ix+1);if(size>-1){line_source=line_source.slice(0,size)}result={__class__:_b_.bytes,source:line_source};self.$counter=ix+1;return result}}else{if(self.$counter==self.$content.length){return""}ix=self.$content.indexOf("\n",self.$counter);if(ix==-1){rest=self.$content.substr(self.$counter);if(size>-1){rest=rest.substr(0,size)}self.$counter=self.$content.length;return rest}else{result=self.$content.substring(self.$counter,ix+1);if(size>-1){result=result.substr(0,size)}self.$counter=ix+1;self.$lc+=1;return result}}};$Reader.readlines=function(){var $=$B.args("readlines",2,{self:null,hint:null},["self","hint"],arguments,{hint:-1},null,null),self=$.self,hint=$B.$GetInt($.hint);var nb_read=0;if(self.closed===true){throw _b_.ValueError.$factory("I/O operation on closed file")}self.$lc=self.$lc===undefined?-1:self.$lc;make_lines(self);var lines;if(hint<0){lines=self.$lines.slice(self.$lc+1)}else{lines=[];while(self.$lc-1;if(mode.search("w")>-1){result={$binary:is_binary,$content:is_binary?_b_.bytes.$factory():"",$encoding:encoding,closed:False,mode:mode,name:file};result.__class__=is_binary?$BufferedReader:$TextIOWrapper;$B.file_cache[file]=result.$content;return result}else if(["r","rb"].indexOf(mode)==-1){throw _b_.ValueError.$factory("Invalid mode '"+mode+"'")}if($B.$isinstance(file,_b_.str)){if($B.file_cache.hasOwnProperty($.file)){var f=$B.file_cache[$.file];result.content=f;if(is_binary&&typeof f=="string"){result.content=_b_.str.encode(f,"utf-8")}else if(f.__class__===_b_.bytes&&!is_binary){result.content=_b_.bytes.decode(f,encoding)}}else if($B.files&&$B.files.hasOwnProperty($.file)){var $res=atob($B.files[$.file].content);var source=[];for(const char of $res){source.push(char.charCodeAt(0))}result.content=_b_.bytes.$factory(source);if(!is_binary){try{result.content=_b_.bytes.decode(result.content,encoding)}catch(error){result.error=error}}}else if($B.protocol!="file"){var req=new XMLHttpRequest;req.overrideMimeType("text/plain;charset=x-user-defined");req.onreadystatechange=function(){if(this.readyState!=4){return}var status=this.status;if(status==404){result.error=_b_.FileNotFoundError.$factory(file)}else if(status!=200){result.error=_b_.IOError.$factory("Could not open file "+file+" : status "+status)}else{var bytes=[];for(var i=0,len=this.response.length;i63232){cp-=63232}bytes.push(cp)}result.content=_b_.bytes.$factory(bytes);if(!is_binary){try{result.content=_b_.bytes.decode(result.content,encoding)}catch(error){result.error=error}}}};var cache=$B.get_option("cache"),fake_qs=cache?"":"?foo="+(new Date).getTime();req.open("GET",encodeURI(file+fake_qs),false);req.send()}else{throw _b_.FileNotFoundError.$factory("cannot use 'open()' with protocol 'file'")}if(result.error!==undefined){throw result.error}var res={$binary:is_binary,$content:result.content,$counter:0,$encoding:encoding,$length:is_binary?result.content.source.length:result.content.length,closed:False,mode:mode,name:file};res.__class__=is_binary?$BufferedReader:$TextIOWrapper;return res}else{throw _b_.TypeError.$factory("invalid argument for open(): "+_b_.str.$factory(file))}};var zip=_b_.zip=$B.make_class("zip",(function(){var res={__class__:zip,items:[]};if(arguments.length==0){return res}var $ns=$B.args("zip",0,{},[],arguments,{},"args","kw");var _args=$ns["args"],strict=$B.$bool($ns.kw.$jsobj.strict||false);var iters=[];for(var arg of _args){iters.push($B.make_js_iterator(arg))}return{__class__:zip,iters:iters,strict:strict}}));zip.__iter__=function(self){return self};zip.__next__=function(self){var res=[],len=self.iters.length;for(var i=0;i0){throw _b_.ValueError.$factory(`zip() argument ${i+1} is longer than argument ${i}`)}else{for(var j=1;j!x.startsWith("$")))};$B.function.__get__=function(self,obj){if(obj===_b_.None){return self}return $B.method.$factory(self,obj)};$B.function.__getattribute__=function(self,attr){if(self.$infos&&self.$infos[attr]!==undefined){if(attr=="__code__"){var res={__class__:code};for(var _attr in self.$infos.__code__){res[_attr]=self.$infos.__code__[_attr]}res.name=self.$infos.__name__;res.filename=self.$infos.__code__.co_filename;res.co_code=self+"";return res}else if(attr=="__annotations__"){return $B.obj_dict(self.$infos[attr])}else if(self.$infos.hasOwnProperty(attr)){return self.$infos[attr]}}else if(self.$infos&&self.$infos.__dict__&&_b_.dict.$contains_string(self.$infos.__dict__,attr)){return _b_.dict.$getitem_string(self.$infos.__dict__,attr)}else if(attr=="__closure__"){var free_vars=self.$infos.__code__.co_freevars;if(free_vars.length==0){return None}var cells=[];for(var i=0;i"}else{return""}};$B.function.__mro__=[_b_.object];$B.make_function_infos=function(f,__module__,__defaults__,__globals__,__kwdefaults__,__doc__,arg_names,vararg,kwarg,co_argcount,co_filename,co_firstlineno,co_flags,co_freevars,co_kwonlyargcount,co_name,co_nlocals,co_posonlyargcount,co_qualname,co_varnames){f.$is_func=true;f.$infos={__module__:__module__,__defaults__:__defaults__,__globals__:__globals__,__kwdefaults__:__kwdefaults__,__doc__:__doc__,arg_names:arg_names,vararg:vararg,kwarg:kwarg};f.$infos.__name__=co_name;f.$infos.__qualname__=co_qualname;f.$infos.__code__={co_argcount:co_argcount,co_filename:co_filename,co_firstlineno:co_firstlineno,co_flags:co_flags,co_freevars:co_freevars,co_kwonlyargcount:co_kwonlyargcount,co_name:co_name,co_nlocals:co_nlocals,co_posonlyargcount:co_posonlyargcount,co_qualname:co_qualname,co_varnames:co_varnames}};$B.make_function_defaults=function(f){if(f.$infos===undefined||f.$infos.__code__===undefined){throw _b_.AttributeError.$factory(`cannot set defauts to ${_b_.str.$factory(f)}`)}const varnames=f.$infos.__code__.co_varnames,value=f.$infos.__defaults__,offset=f.$infos.__code__.co_argcount-value.length,$kwdefaults=new Map;var nb_kw_defaults=f.$infos.__kwdefaults__===_b_.None?0:_b_.dict.__len__(f.$infos.__kwdefaults__);if(f.$infos.__kwdefaults__!==_b_.None){const kwdef=f.$infos.__kwdefaults__;for(let kw of $B.make_js_iterator(kwdef)){$kwdefaults.set(kw,$B.$getitem(kwdef,kw))}}f.$kwdefaults=$kwdefaults;f.$kwdefaults_values=[...$kwdefaults.values()];f.$hasParams=new Set;for(let i=f.$infos.__code__.co_posonlyargcount;i0){named_defaults=PARAMS_NAMED_DEFAULTS_COUNT>=PARAMS_NAMED_COUNT?DEFAULTS.ALL:DEFAULTS.SOME}const PARAMS_POSONLY_COUNT=$CODE.co_posonlyargcount;const PARAMS_POS_COUNT=$CODE.co_argcount-PARAMS_POSONLY_COUNT;let pos_defaults=DEFAULTS.NONE;if(PARAMS_POS_COUNT!==0&&value.length>0){pos_defaults=value.length>=PARAMS_POS_COUNT?DEFAULTS.ALL:DEFAULTS.SOME}let posonly_defaults=DEFAULTS.NONE;if(value.length>PARAMS_POS_COUNT){posonly_defaults=value.length>=$CODE.co_argcount?DEFAULTS.ALL:DEFAULTS.SOME}f.$args_parser=f.$infos.args_parser=$B.getArgs0(PARAMS_POSONLY_COUNT!==0,posonly_defaults,PARAMS_POS_COUNT!==0,pos_defaults,$INFOS.vararg!==null,PARAMS_NAMED_COUNT!==0,named_defaults,$INFOS.kwarg!==null);return _b_.None};$B.function.__setattr__=function(self,attr,value){if(attr=="__closure__"){throw _b_.AttributeError.$factory("readonly attribute")}else if(attr=="__defaults__"){if(value===_b_.None){value=[]}else if(!$B.$isinstance(value,_b_.tuple)){throw _b_.TypeError.$factory("__defaults__ must be set to a tuple object")}if(self.$infos){self.$infos.__defaults__=value;$B.make_function_defaults(self)}else{throw _b_.AttributeError.$factory("cannot set attribute "+attr+" of "+_b_.str.$factory(self))}}else if(attr=="__kwdefaults__"){if(value===_b_.None){value=$B.empty_dict}else if(!$B.$isinstance(value,_b_.dict)){throw _b_.TypeError.$factory("__kwdefaults__ must be set to a dict object")}if(self.$infos){self.$infos.__kwdefaults__=value;$B.make_function_defaults(self)}else{throw _b_.AttributeError.$factory("cannot set attribute "+attr+" of "+_b_.str.$factory(self))}}if(self.$infos[attr]!==undefined){self.$infos[attr]=value}else{self.$attrs=self.$attrs||{};self.$attrs[attr]=value}};$B.function.$factory=function(){};$B.set_func_names($B.function,"builtins");_b_.__BRYTHON__=__BRYTHON__;$B.builtin_funcs=["__build_class__","abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dir","divmod","eval","exec","exit","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","locals","max","min","next","oct","open","ord","pow","print","quit","repr","round","setattr","sorted","sum","vars"];var builtin_function=$B.builtin_function_or_method=$B.make_class("builtin_function_or_method",(function(f){f.__class__=builtin_function;return f}));builtin_function.__getattribute__=$B.function.__getattribute__;builtin_function.__reduce_ex__=builtin_function.__reduce__=function(self){return self.$infos.__name__};builtin_function.__repr__=builtin_function.__str__=function(self){return""};$B.set_func_names(builtin_function,"builtins");var method_wrapper=$B.make_class("method_wrapper");method_wrapper.__repr__=method_wrapper.__str__=function(self){return""};$B.set_func_names(method_wrapper,"builtins");$B.builtin_classes=["bool","bytearray","bytes","classmethod","complex","dict","enumerate","filter","float","frozenset","int","list","map","memoryview","object","property","range","reversed","set","slice","staticmethod","str","super","tuple","type","zip"];var other_builtins=["Ellipsis","False","None","True","__debug__","__import__","copyright","credits","license","NotImplemented"];var builtin_names=$B.builtin_funcs.concat($B.builtin_classes).concat(other_builtins);for(var name of builtin_names){try{if($B.builtin_funcs.indexOf(name)>-1){_b_[name].__class__=builtin_function;_b_[name].$infos={__module__:"builtins",__name__:name,__qualname__:name}}}catch(err){}}_b_.object.__init__.__class__=$B.wrapper_descriptor;_b_.object.__new__.__class__=builtin_function})(__BRYTHON__);(function($B){var _b_=$B.builtins;var DEFAULT_MIN_MERGE=32;var DEFAULT_MIN_GALLOPING=7;var DEFAULT_TMP_STORAGE_LENGTH=256;var POWERS_OF_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function log10(x){if(x<1e5){if(x<100){return x<10?0:1}if(x<1e4){return x<1e3?2:3}return 4}if(x<1e7){return x<1e6?5:6}if(x<1e9){return x<1e8?7:8}return 9}function alphabeticalCompare(a,b){if(a===b){return 0}if(~~a===a&&~~b===b){if(a===0||b===0){return a=0){return-1}if(a>=0){return 1}a=-a;b=-b}var al=log10(a),bl=log10(b);var t=0;if(albl){b*=POWERS_OF_TEN[al-bl-1];a/=10;t=1}if(a===b){return t}return a=DEFAULT_MIN_MERGE){r|=n&1;n>>=1}return n+r}function makeAscendingRun(array,lo,hi,compare){var runHi=lo+1;if(runHi===hi){return 1}if(compare(array[runHi++],array[lo])<0){while(runHi=0){runHi++}}return runHi-lo}function reverseRun(array,lo,hi){hi--;while(lo>>1;if(compare(pivot,array[mid])<0){right=mid}else{left=mid+1}}var n=start-left;switch(n){case 3:array[left+3]=array[left+2];case 2:array[left+2]=array[left+1];case 1:array[left+1]=array[left];break;default:while(n>0){array[left+n]=array[left+n-1];n--}}array[left]=pivot}}function gallopLeft(value,array,start,length,hint,compare){var lastOffset=0,maxOffset=0,offset=1;if(compare(value,array[start+hint])>0){maxOffset=length-hint;while(offset0){lastOffset=offset;offset=(offset<<1)+1;if(offset<=0){offset=maxOffset}}if(offset>maxOffset){offset=maxOffset}lastOffset+=hint;offset+=hint}else{maxOffset=hint+1;while(offsetmaxOffset){offset=maxOffset}var tmp=lastOffset;lastOffset=hint-offset;offset=hint-tmp}lastOffset++;while(lastOffset>>1);if(compare(value,array[start+m])>0){lastOffset=m+1}else{offset=m}}return offset}function gallopRight(value,array,start,length,hint,compare){var lastOffset=0,maxOffset=0,offset=1;if(compare(value,array[start+hint])<0){maxOffset=hint+1;while(offsetmaxOffset){offset=maxOffset}var tmp=lastOffset;lastOffset=hint-offset;offset=hint-tmp}else{maxOffset=length-hint;while(offset=0){lastOffset=offset;offset=(offset<<1)+1;if(offset<=0){offset=maxOffset}}if(offset>maxOffset){offset=maxOffset}lastOffset+=hint;offset+=hint}lastOffset++;while(lastOffset>>1);if(compare(value,array[start+m])<0){offset=m}else{lastOffset=m+1}}return offset}var TIM_SORT_ASSERTION="TimSortAssertion";var TimSortAssertion=function(message){this.name=TIM_SORT_ASSERTION;this.message=message};var TimSort=function(array,compare){var self={array:array,compare:compare,minGallop:DEFAULT_MIN_GALLOPING,length:array.length,tmpStorageLength:DEFAULT_TMP_STORAGE_LENGTH,stackLength:0,runStart:null,runLength:null,stackSize:0,pushRun:function(runStart,runLength){this.runStart[this.stackSize]=runStart;this.runLength[this.stackSize]=runLength;this.stackSize+=1},mergeRuns:function(){while(this.stackSize>1){var n=this.stackSize-2;if(n>=1&&this.runLength[n-1]<=this.runLength[n]+this.runLength[n+1]||n>=2&&this.runLength[n-2]<=this.runLength[n]+this.runLength[n-1]){if(this.runLength[n-1]this.runLength[n+1]){break}this.mergeAt(n)}},forceMergeRuns:function(){while(this.stackSize>1){var n=this.stackSize-2;if(n>0&&this.runLength[n-1]=DEFAULT_MIN_GALLOPING||count2>=DEFAULT_MIN_GALLOPING);if(exit){break}if(minGallop<0){minGallop=0}minGallop+=2}this.minGallop=minGallop;if(minGallop<1){this.minGallop=1}if(length1===1){for(var i=0;i=0;i--){array[customDest+i]=array[customCursor+i]}array[dest]=tmp[cursor2];return}var minGallop=this.minGallop;while(true){var count1=0,count2=0,exit=false;do{if(compare(tmp[cursor2],array[cursor1])<0){array[dest--]=array[cursor1--];count1++;count2=0;if(--length1===0){exit=true;break}}else{array[dest--]=tmp[cursor2--];count2++;count1=0;if(--length2===1){exit=true;break}}}while((count1|count2)=0;i--){array[customDest+i]=array[customCursor+i]}if(length1===0){exit=true;break}}array[dest--]=tmp[cursor2--];if(--length2===1){exit=true;break}count2=length2-gallopLeft(array[cursor1],tmp,0,length2,length2-1,compare);if(count2!==0){dest-=count2;cursor2-=count2;length2-=count2;customDest=dest+1;customCursor=cursor2+1;for(var i=0;i=DEFAULT_MIN_GALLOPING||count2>=DEFAULT_MIN_GALLOPING);if(exit){break}if(minGallop<0){minGallop=0}minGallop+=2}this.minGallop=minGallop;if(minGallop<1){this.minGallop=1}if(length2===1){dest-=length1;cursor1-=length1;customDest=dest+1;customCursor=cursor1+1;for(var i=length1-1;i>=0;i--){array[customDest+i]=array[customCursor+i]}array[dest]=tmp[cursor2]}else if(length2==0){throw new TimSortAssertion("mergeHigh preconditions were not respected")}else{customCursor=dest-(length2-1);for(var i=0;i>>1}self.tmp=new Array(self.tmpStorageLength);self.stackLength=self.length<120?5:self.length<1542?10:self.length<119151?19:40;self.runStart=new Array(self.stackLength);self.runLength=new Array(self.stackLength);return self};function tim_sort(array,compare,lo,hi){if(!Array.isArray(array)){throw _b_.TypeError.$factory("Can only sort arrays")}if(!compare){compare=alphabeticalCompare}else if(typeof compare!=="function"){hi=lo;lo=compare;compare=alphabeticalCompare}if(!lo){lo=0}if(!hi){hi=array.length}var remaining=hi-lo;if(remaining<2){return}var runLength=0;if(remainingminRun){force=minRun}binaryInsertionSort(array,lo,lo+force,lo+runLength,compare);runLength=force}ts.pushRun(lo,runLength);ts.mergeRuns();remaining-=runLength;lo+=runLength}while(remaining!==0);ts.forceMergeRuns()}function tim_sort_safe(array,compare){try{tim_sort(array,compare,0,array.length)}catch(e){if(e.name==TIM_SORT_ASSERTION){array.sort(compare)}else{throw e}}}$B.$TimSort=tim_sort_safe;$B.$AlphabeticalCompare=alphabeticalCompare})(__BRYTHON__);(function($B){var _b_=$B.builtins;$B.del_exc=function(frame){delete frame[1].$current_exception};$B.set_exc=function(exc,frame){if(frame===undefined){var msg="Internal error: no frame for exception "+_b_.repr(exc);console.error(["Traceback (most recent call last):",$B.print_stack(exc.$frame_obj),msg].join("\n"));if($B.get_option("debug",exc)>1){console.log(exc.args);console.log(exc.stack)}throw Error(msg)}else{frame[1].$current_exception=$B.exception(exc)}};$B.get_exc=function(){var frame=$B.frame_obj.frame;return frame[1].$current_exception};$B.set_exception_offsets=function(exc,position){exc.$positions=exc.$positions||{};exc.$positions[$B.frame_obj.count-1]=position;return exc};$B.$raise=function(arg,cause){var active_exc=$B.get_exc();if(arg===undefined){if(active_exc!==undefined){throw active_exc}throw _b_.RuntimeError.$factory("No active exception to reraise")}else{if($B.$isinstance(arg,_b_.BaseException)){if(arg.__class__===_b_.StopIteration&&$B.frame_obj.frame.$is_generator){arg=_b_.RuntimeError.$factory("generator raised StopIteration")}arg.__context__=active_exc===undefined?_b_.None:active_exc;arg.__cause__=cause||_b_.None;arg.__suppress_context__=cause!==undefined;throw arg}else if(arg.$is_class&&_b_.issubclass(arg,_b_.BaseException)){if(arg===_b_.StopIteration){if($B.frame_obj.frame[1].$is_generator){throw _b_.RuntimeError.$factory("generator raised StopIteration")}}var exc=$B.$call(arg)();exc.__context__=active_exc===undefined?_b_.None:active_exc;exc.__cause__=cause||_b_.None;exc.__suppress_context__=cause!==undefined;throw exc}else{throw _b_.TypeError.$factory("exceptions must derive from BaseException")}}};$B.print_stack=function(frame_obj){var stack=make_frames_stack(frame_obj||$B.frame_obj);var trace=[];for(var frame of stack){var lineno=frame.$lineno,filename=frame.__file__;if(lineno!==undefined){var local=frame[0]==frame[2]?"":frame[0];trace.push(` File "${filename}" line ${lineno}, in ${local}`);var src=$B.file_cache[filename];if(src){var lines=src.split("\n"),line=lines[lineno-1];trace.push(" "+line.trim())}}}return trace.join("\n")};$B.last_frame=function(){var frame=$B.frame_obj.frame;return`file ${frame.__file__} line ${frame.$lineno}`};var traceback=$B.traceback=$B.make_class("traceback",(function(exc){var frame_obj=exc.$frame_obj;if(frame_obj===null){return _b_.None}if($B.$isinstance(exc,_b_.SyntaxError)){frame_obj=frame_obj.prev}var $linenums=$B.make_linenums(frame_obj);return{__class__:traceback,$stack:make_frames_stack(frame_obj),$linenums:$linenums,pos:0}}));traceback.__getattribute__=function(_self,attr){switch(attr){case"tb_frame":return _self.$stack[_self.pos];case"tb_lineno":return _self.$linenums[_self.pos];case"tb_lasti":return-1;case"tb_next":if(_self.pos<_self.$stack.length-1){_self.pos++;return _self}else{return _b_.None}case"stack":return _self.$stack;default:return _b_.object.__getattribute__(_self,attr)}};$B.set_func_names(traceback,"builtins");var frame=$B.frame=$B.make_class("frame",(function(frame_list){frame_list.__class__=frame;return frame_list}));frame.__delattr__=function(_self,attr){if(attr=="f_trace"){_self.$f_trace=_b_.None}};frame.__dir__=function(_self){return _b_.object.__dir__(frame).concat(["clear","f_back","f_builtins","f_code","f_globals","f_lasti","f_lineno","f_locals","f_trace","f_trace_lines","f_trace_opcodes"])};frame.__getattr__=function(_self,attr){if(attr=="f_back"){var frame_obj=$B.frame_obj;while(frame_obj!==null){if(frame_obj.frame===_self){break}frame_obj=frame_obj.prev}if(frame_obj.prev!==null){return frame.$factory(frame_obj.prev.frame)}return _b_.None}else if(attr=="clear"){return function(){}}else if(attr=="f_trace"){var locals=_self[1];if(_self.$f_trace===undefined){return _b_.None}return _self.$f_trace}console.log("no attr",attr,"for frame",_self);throw $B.attr_error(attr,_self)};frame.__setattr__=function(_self,attr,value){if(attr=="f_trace"){_self.$f_trace=value}};frame.__str__=frame.__repr__=function(_self){return""};frame.f_builtins={__get__:function(_self){return $B.$getattr(_self[3].__builtins__,"__dict__")}};frame.f_code={__get__:function(_self){var res;if(_self[4]){res=_self[4].$infos.__code__}else if(_self.f_code){res=_self.f_code}else{res={co_name:_self[0]==_self[2]?"":_self[0],co_filename:_self.__file__,co_varnames:$B.fast_tuple([])};res.co_qualname=res.co_name}res.__class__=_b_.code;return res}};frame.f_globals={__get__:function(_self){if(_self.f_globals){return _self.f_globals}else if(_self.f_locals&&_self[1]==_self[3]){return _self.f_globals=_self.f_locals}else{return _self.f_globals=$B.obj_dict(_self[3])}}};frame.f_lineno={__get__:function(_self){return _self.$lineno}};frame.f_locals={__get__:function(_self){if(_self.f_locals){return _self.f_locals}else if(_self.f_globals&&_self[1]==_self[3]){return _self.f_locals=_self.f_globals}else{return _self.f_locals=$B.obj_dict(_self[1])}}};frame.f_trace={__get__:function(_self){return _self.$f_trace}};$B.set_func_names(frame,"builtins");$B._frame=frame;$B.deep_copy=function(stack){var res=[];for(const s of stack){var item=[s[0],{},s[2],{}];if(s[4]!==undefined){item.push(s[4])}for(const i of[1,3]){for(var key in s[i]){item[i][key]=s[i][key]}}res.push(item)}return res};$B.restore_frame_obj=function(frame_obj,locals){$B.frame_obj=frame_obj;$B.frame_obj.frame[1]=locals};$B.make_linenums=function(frame_obj){var res=[],frame_obj=frame_obj||$B.frame_obj;while(frame_obj!==null){res.push(frame_obj.frame.$lineno);frame_obj=frame_obj.prev}return res.reverse()};var make_frames_stack=$B.make_frames_stack=function(frame_obj){var stack=[];while(frame_obj!==null){stack[stack.length]=frame_obj.frame;frame_obj=frame_obj.prev}stack.reverse();return stack};$B.freeze=function(err){if(err.$frame_obj===undefined){err.$frame_obj=$B.frame_obj;err.$linenums=$B.make_linenums()}err.__traceback__=traceback.$factory(err)};$B.exception=function(js_exc,in_ctx_manager){if(!js_exc.__class__){if(js_exc.$py_exc){return js_exc.$py_exc}var exc=_b_.JavascriptError.$factory(js_exc.__name__||js_exc.name);exc.$js_exc=js_exc;if($B.is_recursion_error(js_exc)){return _b_.RecursionError.$factory("too much recursion")}exc.__cause__=_b_.None;exc.__context__=_b_.None;exc.__suppress_context__=false;var $message=js_exc.message||"<"+js_exc+">";exc.args=_b_.tuple.$factory([$message]);exc.$py_error=true;js_exc.$py_exc=exc;$B.freeze(exc)}else{var exc=js_exc;$B.freeze(exc)}return exc};$B.is_exc=function(exc,exc_list){if(exc.__class__===undefined){exc=$B.exception(exc)}var this_exc_class=exc.$is_class?exc:exc.__class__;for(var i=0;i1){res+=", "+_b_.repr($B.fast_tuple(self.args.slice(1)))}return res+")"};_b_.BaseException.__str__=function(self){if(self.args.length>0&&self.args[0]!==_b_.None){return _b_.str.$factory(self.args[0])}return""};_b_.BaseException.__new__=function(cls){var err=_b_.BaseException.$factory();err.__class__=cls;err.__dict__=$B.empty_dict();return err};_b_.BaseException.__getattr__=function(self,attr){if(attr=="__context__"){var frame=$B.frame_obj.frame,ctx=frame[1].$current_exception;return ctx||_b_.None}else{throw $B.attr_error(attr,self)}};_b_.BaseException.add_note=function(self,note){if(!$B.$isinstance(note,_b_.str)){throw _b_.TypeError.$factory("note must be a str, not "+`'${$B.class_name(note)}'`)}if(self.__notes__!==undefined){self.__notes__.push(note)}else{self.__notes__=[note]}};_b_.BaseException.with_traceback=function(_self,tb){_self.__traceback__=tb;return _self};$B.set_func_names(_b_.BaseException,"builtins");make_builtin_exception(["SystemExit","KeyboardInterrupt","GeneratorExit","Exception"],_b_.BaseException);make_builtin_exception("JavascriptError",_b_.Exception);make_builtin_exception(["ArithmeticError","AssertionError","BufferError","EOFError","LookupError","MemoryError","OSError","ReferenceError","RuntimeError","SystemError","TypeError","ValueError","Warning"],_b_.Exception);make_builtin_exception("StopIteration",_b_.Exception,"value");make_builtin_exception("StopAsyncIteration",_b_.Exception,"value");make_builtin_exception("ImportError",_b_.Exception,"name");make_builtin_exception("SyntaxError",_b_.Exception,"msg");make_builtin_exception(["FloatingPointError","OverflowError","ZeroDivisionError"],_b_.ArithmeticError);make_builtin_exception("ModuleNotFoundError",_b_.ImportError,"name");make_builtin_exception(["IndexError","KeyError"],_b_.LookupError);make_builtin_exception(["BlockingIOError","ChildProcessError","ConnectionError","FileExistsError","FileNotFoundError","InterruptedError","IsADirectoryError","NotADirectoryError","PermissionError","ProcessLookupError","TimeoutError"],_b_.OSError);make_builtin_exception(["BrokenPipeError","ConnectionAbortedError","ConnectionRefusedError","ConnectionResetError"],_b_.ConnectionError);make_builtin_exception(["NotImplementedError","RecursionError"],_b_.RuntimeError);make_builtin_exception("IndentationError",_b_.SyntaxError,"msg");make_builtin_exception("TabError",_b_.IndentationError);make_builtin_exception("UnicodeError",_b_.ValueError);make_builtin_exception(["UnicodeDecodeError","UnicodeEncodeError","UnicodeTranslateError"],_b_.UnicodeError);make_builtin_exception(["DeprecationWarning","PendingDeprecationWarning","RuntimeWarning","SyntaxWarning","UserWarning","FutureWarning","ImportWarning","UnicodeWarning","BytesWarning","ResourceWarning","EncodingWarning"],_b_.Warning);make_builtin_exception(["EnvironmentError","IOError","VMSError","WindowsError"],_b_.OSError);_b_.AttributeError=$B.make_class("AttributeError",(function(){var $=$B.args("AttributeError",3,{msg:null,name:null,obj:null},["msg","name","obj"],arguments,{msg:_b_.None,name:_b_.None,obj:_b_.None},"*",null);var err=Error();err.__class__=_b_.AttributeError;err.__traceback__=_b_.None;err.$py_error=true;err.$frame_obj=$B.frame_obj;err.$linenums=$B.make_linenums();err.args=$B.fast_tuple($.msg===_b_.None?[]:[$.msg]);err.name=$.name;err.obj=$.obj;if(err.obj===undefined){console.log("pas de obj",$)}err.__cause__=_b_.None;err.__context__=_b_.None;err.__suppress_context__=false;return err}));_b_.AttributeError.__bases__=[_b_.Exception];_b_.AttributeError.__mro__=_b_.type.mro(_b_.AttributeError);_b_.AttributeError.__str__=function(self){return self.args[0]};$B.set_func_names(_b_.AttributeError,"builtins");$B.attr_error=function(name,obj){if(obj.$is_class){var msg=`type object '${obj.__name__}'`}else{var msg=`'${$B.class_name(obj)}' object`}msg+=` has no attribute '${name}'`;return _b_.AttributeError.$factory({$kw:[{name:name,obj:obj,msg:msg}]})};_b_.NameError=$B.make_class("NameError",(function(){var $=$B.args("NameError",2,{message:null,name:null},["message","name"],arguments,{message:_b_.None,name:_b_.None},"*",null,1);var err=Error();err.__class__=_b_.NameError;err.__traceback__=_b_.None;err.$py_error=true;err.$frame_obj=$B.frame_obj;err.$linenums=$B.make_linenums();err.args=$B.fast_tuple($.message===_b_.None?[]:[$.message]);err.name=$.name;err.__cause__=_b_.None;err.__context__=_b_.None;err.__suppress_context__=false;return err}));_b_.NameError.__bases__=[_b_.Exception];_b_.NameError.__mro__=_b_.type.mro(_b_.NameError).slice(1);_b_.NameError.__str__=function(self){return self.args[0]};$B.set_func_names(_b_.NameError,"builtins");make_builtin_exception("UnboundLocalError",_b_.NameError);_b_.UnboundLocalError.__str__=function(self){return self.args[0]};$B.set_func_names(_b_.UnboundLocalError,"builtins");$B.name_error=function(name){var exc=_b_.NameError.$factory(`name '${name}' is not defined`);exc.name=name;exc.$frame_obj=$B.frame_obj;return exc};$B.recursion_error=function(frame){var exc=_b_.RecursionError.$factory("maximum recursion depth exceeded");$B.set_exc(exc,frame);return exc};var MAX_CANDIDATE_ITEMS=750,MAX_STRING_SIZE=40,MOVE_COST=2,CASE_COST=1,SIZE_MAX=65535;function LEAST_FIVE_BITS(n){return n&31}function levenshtein_distance(a,b,max_cost){if(a==b){return 0}if(a.lengthmax_cost){return max_cost+1}var buffer=[];for(var i=0;imax_cost){return max_cost+1}}return result}function substitution_cost(a,b){if(LEAST_FIVE_BITS(a)!=LEAST_FIVE_BITS(b)){return MOVE_COST}if(a==b){return 0}if(a.toLowerCase()==b.toLowerCase()){return CASE_COST}return MOVE_COST}function calculate_suggestions(dir,name){if(dir.length>=MAX_CANDIDATE_ITEMS){return null}var suggestion_distance=2**52,suggestion=null;for(var item of dir){var max_distance=(name.length+item.length+3)*MOVE_COST/6;max_distance=Math.min(max_distance,suggestion_distance-1);var current_distance=levenshtein_distance(name,item,max_distance);if(current_distance>max_distance){continue}if(!suggestion||current_distance!x.startsWith("$")));var suggestion=calculate_suggestions(locals,name);if(suggestion){return suggestion}if(frame[2]!=frame[0]){var globals=Object.keys(frame[3]).filter((x=>!x.startsWith("$")));var suggestion=calculate_suggestions(globals,name);if(suggestion){return suggestion}}if(frame[4]&&frame[4].$is_method){var instance_name=frame[4].$infos.__code__.co_varnames[0],instance=frame[1][instance_name];if(_b_.hasattr(instance,name)){return`self.${name}`}}return _b_.None};_b_.BaseExceptionGroup=$B.make_class("BaseExceptionGFroup",(function(){var missing={},$=$B.args("BaseExceptionGroup",2,{message:null,exceptions:null},["message","exceptions"],arguments,{exceptions:missing},null,null);var err=Error();err.args=$B.fast_tuple(Array.from(arguments));err.__class__=_b_.BaseExceptionGroup;err.__traceback__=_b_.None;err.$py_error=true;err.$frame_obj=$B.frame_obj;err.$linenums=$B.make_linenums();err.message=$.message;err.exceptions=$.exceptions===missing?[]:$.exceptions;if(err.exceptions!==_b_.None){var exc_list=_b_.list.$factory(err.exceptions);var all_exceptions=true;for(var exc of exc_list){if(!$B.$isinstance(exc,_b_.Exception)){all_exceptions=false;break}}if(all_exceptions){err.__class__=_b_.ExceptionGroup}}err.__cause__=_b_.None;err.__context__=_b_.None;err.__suppress_context__=false;return err}));_b_.BaseExceptionGroup.__bases__=[_b_.BaseException];_b_.BaseExceptionGroup.__mro__=_b_.type.mro(_b_.BaseExceptionGroup);_b_.BaseExceptionGroup.__str__=function(self){return`${self.message} (${self.exceptions.length} sub-exception`+`${self.exceptions.length>1?"s":""})`};_b_.BaseExceptionGroup.split=function(self,condition){var matching_excs=[],non_matching_excs=[];for(var exc of self.exceptions){if($B.$isinstance(exc,_b_.BaseExceptionGroup)){var subsplit=_b_.BaseExceptionGroup.split(exc,condition),matching=subsplit[0],non_matching=subsplit[1];if(matching===_b_.None){non_matching_excs.push(exc)}else if(matching.exceptions.length==exc.exceptions.length){matching_excs.push(exc)}else{if(matching.exceptions.length>0){matching_excs=matching_excs.concat(matching)}if(non_matching.exceptions.length>0){non_matching_excs=non_matching_excs.concat(non_matching)}}}else if(condition(exc)){matching_excs.push(exc)}else{non_matching_excs.push(exc)}}if(matching_excs.length==0){matching_excs=_b_.None}if(non_matching_excs.length==0){non_matching_excs=_b_.None}var res=[];for(var item of[matching_excs,non_matching_excs]){var eg=_b_.BaseExceptionGroup.$factory(self.message,item);eg.__cause__=self.__cause__;eg.__context__=self.__context__;eg.__traceback__=self.__traceback__;res.push(eg)}return $B.fast_tuple(res)};_b_.BaseExceptionGroup.subgroup=function(self,condition){return _b_.BaseExceptionGroup.split(self,condition)[0]};$B.set_func_names(_b_.BaseExceptionGroup,"builtins");_b_.ExceptionGroup=$B.make_class("ExceptionGFroup",(function(){var missing={},$=$B.args("ExceptionGroup",2,{message:null,exceptions:null},["message","exceptions"],arguments,{exceptions:missing},null,null);var err=Error();err.args=$B.fast_tuple(Array.from(arguments));err.__class__=_b_.ExceptionGroup;err.__traceback__=_b_.None;err.$py_error=true;err.$frame_obj=$B.frame_obj;err.$linenums=$B.make_linenums();err.message=$.message;err.exceptions=$.exceptions===missing?[]:$.exceptions;if(err.exceptions!==_b_.None){var exc_list=_b_.list.$factory(err.exceptions);for(var exc of exc_list){if(!$B.$isinstance(exc,_b_.Exception)){throw _b_.TypeError.$factory("Cannot nest BaseExceptions in an ExceptionGroup")}}}err.__cause__=_b_.None;err.__context__=_b_.None;err.__suppress_context__=false;return err}));_b_.ExceptionGroup.__bases__=[_b_.BaseExceptionGroup,_b_.Exception];_b_.ExceptionGroup.__mro__=_b_.type.mro(_b_.ExceptionGroup);$B.set_func_names(_b_.ExceptionGroup,"builtins");function trace_from_stack(err){function handle_repeats(src,count_repeats){if(count_repeats>0){var len=trace.length;for(var i=0;i<2;i++){if(src){trace.push(trace[len-2]);trace.push(trace[len-1])}else{trace.push(trace[len-1])}count_repeats--;if(count_repeats==0){break}}if(count_repeats>0){trace.push(`[Previous line repeated ${count_repeats} more`+` time${count_repeats>1?"s":""}]`)}}}var trace=[],save_filename,save_lineno,save_scope,count_repeats=0,stack=err.$frame_obj===undefined?[]:make_frames_stack(err.$frame_obj),linenos=err.$linenums;for(var frame_num=0,len=stack.length;frame_num":frame[0];if(filename==save_filename&&scope==save_scope&&lineno==save_lineno){count_repeats++;continue}handle_repeats(src,count_repeats);save_filename=filename;save_lineno=lineno;save_scope=scope;count_repeats=0;var src=$B.file_cache[filename];trace.push(` File "${filename}", line ${lineno}, in `+(frame[0]==frame[2]?"":frame[0]));if(src){var lines=src.split("\n"),line=lines[lineno-1];if(line){trace.push(" "+line.trim())}else{console.log("no line",line)}if(err.$positions!==undefined){var position=err.$positions[frame_num],trace_line="";if(position&&(position[1]!=position[0]||position[2]-position[1]!=line.trim().length||position[3])){var indent=line.length-line.trimLeft().length;var paddings=[position[0]-indent,position[1]-position[0],position[2]-position[1]];for(var padding in paddings){if(padding<0){console.log("wrong values, position",position,"indent",indent);paddings[paddings.indexOf(padding)]=0}}trace_line+=" "+" ".repeat(paddings[0])+"~".repeat(paddings[1])+"^".repeat(paddings[2]);if(position[3]!==undefined){trace_line+="~".repeat(position[3]-position[2])}trace.push(trace_line)}}}else{console.log("no src for filename",filename);console.log("in file_cache",Object.keys($B.file_cache).join("\n"))}}if(count_repeats>0){var len=trace.length;for(var i=0;i<2;i++){if(src){trace.push(trace[len-2]);trace.push(trace[len-1])}else{trace.push(trace[len-1])}}trace.push(`[Previous line repeated ${count_repeats-2} more times]`)}return trace.join("\n")+"\n"}$B.error_trace=function(err){var trace="",stack=err.$frame_obj===undefined?[]:make_frames_stack(err.$frame_obj);if($B.get_option("debug",err)>1){console.log("handle error",err.__class__,err.args);console.log("stack",stack);console.log(err.stack)}if(stack.length>0){trace="Traceback (most recent call last):\n"}if(err.__class__===_b_.SyntaxError||err.__class__===_b_.IndentationError){err.$frame_obj=err.$frame_obj===null?null:err.$frame_obj.prev;trace+=trace_from_stack(err);var filename=err.filename,line=err.text,indent=line.length-line.trimLeft().length;trace+=` File "${filename}", line ${err.args[1][1]}\n`+` ${line.trim()}\n`;if(err.__class__!==_b_.IndentationError&&err.text){if($B.get_option("debug",err)>1){console.log("error args",err.args[1]);console.log("err line",line);console.log("indent",indent)}var start=err.offset-indent-1,end_offset=err.end_offset-1+(err.end_offset==err.offset?1:0),marks=" "+" ".repeat(start),nb_marks=1;if(err.end_lineno){if(err.end_lineno>err.lineno){nb_marks=line.length-start-indent}else{nb_marks=end_offset-start-indent}if(nb_marks==0&&err.end_offset==line.substr(indent).length){nb_marks=1}}marks+="^".repeat(nb_marks)+"\n";trace+=marks}trace+=`${err.__class__.__name__}: ${err.args[0]}`}else if(err.__class__!==undefined){var name=$B.class_name(err);trace+=trace_from_stack(err);var args_str=_b_.str.$factory(err);trace+=name+(args_str?": "+args_str:"");var save_frame_obj=$B.frame_obj;$B.frame_obj=err.$frame_obj;if(err.__class__===_b_.NameError){var suggestion=$B.offer_suggestions_for_name_error(err);if(suggestion!==_b_.None){trace+=`. Did you mean '${suggestion}'?`}if($B.stdlib_module_names.indexOf(err.name)>-1){trace+=`. Did you forget to import '${err.name}'?`}}else if(err.__class__===_b_.AttributeError){var suggestion=$B.offer_suggestions_for_attribute_error(err);if(suggestion!==_b_.None){trace+=`. Did you mean: '${suggestion}'?`}}else if(err.__class__===_b_.ImportError){if(err.$suggestion!==_b_.None){trace+=`. Did you mean: '${err.$suggestion}'?`}}$B.frame_obj=save_frame_obj}else{trace=err+""}if(err.$js_exc){trace+="\n\nJavascript error\n"+err.$js_exc+"\n"+err.$js_exc.stack}return trace};$B.get_stderr=function(){if($B.imported.sys){return $B.imported.sys.stderr}return $B.imported._sys.stderr};$B.get_stdout=function(){if($B.imported.sys){return $B.imported.sys.stdout}return $B.imported._sys.stdout};$B.show_error=function(err){var trace=$B.error_trace($B.exception(err));try{var stderr=$B.get_stderr();$B.$getattr(stderr,"write")(trace);var flush=$B.$getattr(stderr,"flush",_b_.None);if(flush!==_b_.None){flush()}}catch(print_exc_err){console.debug(trace)}};$B.handle_error=function(err){if(err.$handled){return}err.$handled=true;$B.show_error(err);throw err}})(__BRYTHON__);(function($B){var _b_=$B.builtins,None=_b_.None,range={__class__:_b_.type,__mro__:[_b_.object],__qualname__:"range",$is_class:true,$native:true,$match_sequence_pattern:true,$not_basetype:true,$descriptors:{start:true,step:true,stop:true}};range.__contains__=function(self,other){if(range.__len__(self)==0){return false}try{other=$B.int_or_bool(other)}catch(err){try{range.index(self,other);return true}catch(err){return false}}var start=_b_.int.$to_bigint(self.start),stop=_b_.int.$to_bigint(self.stop),step=_b_.int.$to_bigint(self.step),other=_b_.int.$to_bigint(other);var sub=other-start,fl=sub/step,res=step*fl;if(res==sub){if(stop>start){return other>=start&&stop>other}else{return start>=other&&other>stop}}else{return false}};range.__delattr__=function(self,attr,value){throw _b_.AttributeError.$factory("readonly attribute")};range.__eq__=function(self,other){if($B.$isinstance(other,range)){var len=range.__len__(self);if(!$B.rich_comp("__eq__",len,range.__len__(other))){return false}if(len==0){return true}if(!$B.rich_comp("__eq__",self.start,other.start)){return false}if(len==1){return true}return $B.rich_comp("__eq__",self.step,other.step)}return false};function compute_item(r,i){var len=range.__len__(r);if(len==0){return r.start}else if(i>len){return r.stop}return $B.rich_op("__add__",r.start,$B.rich_op("__mul__",r.step,i))}range.__getitem__=function(self,rank){if($B.$isinstance(rank,_b_.slice)){var norm=_b_.slice.$conv_for_seq(rank,range.__len__(self)),substep=$B.rich_op("__mul__",self.step,norm.step),substart=compute_item(self,norm.start),substop=compute_item(self,norm.stop);return range.$factory(substart,substop,substep)}if(typeof rank!="number"){rank=$B.$GetInt(rank)}if($B.rich_comp("__gt__",0,rank)){rank=$B.rich_op("__add__",rank,range.__len__(self))}var res=$B.rich_op("__add__",self.start,$B.rich_op("__mul__",rank,self.step));if($B.rich_comp("__gt__",self.step,0)&&($B.rich_comp("__ge__",res,self.stop)||$B.rich_comp("__gt__",self.start,res))||$B.rich_comp("__gt__",0,self.step)&&($B.rich_comp("__ge__",self.stop,res)||$B.rich_comp("__gt__",res,self.start))){throw _b_.IndexError.$factory("range object index out of range")}return res};range.__hash__=function(self){var len=range.__len__(self);if(len==0){return _b_.hash(_b_.tuple.$factory([0,None,None]))}if(len==1){return _b_.hash(_b_.tuple.$factory([1,self.start,None]))}return _b_.hash(_b_.tuple.$factory([len,self.start,self.step]))};var RangeIterator=$B.make_class("range_iterator",(function(obj){return{__class__:RangeIterator,obj:obj}}));RangeIterator.__iter__=function(self){return self};RangeIterator.__next__=function(self){return _b_.next(self.obj)};$B.set_func_names(RangeIterator,"builtins");range.__iter__=function(self){var res={__class__:range,start:self.start,stop:self.stop,step:self.step};if(self.$safe){res.$counter=self.start-self.step}else{res.$counter=$B.rich_op("__sub__",self.start,self.step)}return RangeIterator.$factory(res)};range.__len__=function(self){var len,start=_b_.int.$to_bigint(self.start),stop=_b_.int.$to_bigint(self.stop),step=_b_.int.$to_bigint(self.step);if(self.step>0){if(self.start>=self.stop){return 0}len=1n+(stop-start-1n)/step}else{if(self.stop>=self.start){return 0}len=1n+(start-stop-1n)/-step}return _b_.int.$int_or_long(len)};range.__next__=function(self){if(self.$safe){self.$counter+=self.step;if(self.step>0&&self.$counter>=self.stop||self.step<0&&self.$counter<=self.stop){throw _b_.StopIteration.$factory("")}}else{self.$counter=$B.rich_op("__add__",self.$counter,self.step);if($B.rich_comp("__gt__",self.step,0)&&$B.rich_comp("__ge__",self.$counter,self.stop)||$B.rich_comp("__gt__",0,self.step)&&$B.rich_comp("__ge__",self.stop,self.$counter)){throw _b_.StopIteration.$factory("")}}return self.$counter};range.__reversed__=function(self){var n=$B.rich_op("__sub__",range.__len__(self),1);return range.$factory($B.rich_op("__add__",self.start,$B.rich_op("__mul__",n,self.step)),$B.rich_op("__sub__",self.start,self.step),$B.rich_op("__mul__",-1,self.step))};range.__repr__=function(self){$B.builtins_repr_check(range,arguments);var res="range("+_b_.str.$factory(self.start)+", "+_b_.str.$factory(self.stop);if(self.step!=1){res+=", "+_b_.str.$factory(self.step)}return res+")"};range.__setattr__=function(self,attr,value){throw _b_.AttributeError.$factory("readonly attribute")};range.start=function(self){return self.start};range.step=function(self){return self.step},range.stop=function(self){return self.stop};range.count=function(self,ob){if($B.$isinstance(ob,[_b_.int,_b_.float,_b_.bool])){return _b_.int.$factory(range.__contains__(self,ob))}else{var comp=function(other){return $B.rich_comp("__eq__",ob,other)},it=range.__iter__(self),_next=RangeIterator.__next__,nb=0;while(true){try{if(comp(_next(it))){nb++}}catch(err){if($B.$isinstance(err,_b_.StopIteration)){return nb}throw err}}}};range.index=function(self,other){var $=$B.args("index",2,{self:null,other:null},["self","other"],arguments,{},null,null),self=$.self,other=$.other;try{other=$B.int_or_bool(other)}catch(err){var comp=function(x){return $B.rich_comp("__eq__",other,x)},it=range.__iter__(self),_next=RangeIterator.__next__,nb=0;while(true){try{if(comp(_next(it))){return nb}nb++}catch(err){if($B.$isinstance(err,_b_.StopIteration)){throw _b_.ValueError.$factory(_b_.str.$factory(other)+" not in range")}throw err}}}var sub=$B.rich_op("__sub__",other,self.start),fl=$B.rich_op("__floordiv__",sub,self.step),res=$B.rich_op("__mul__",self.step,fl);if($B.rich_comp("__eq__",res,sub)){if($B.rich_comp("__gt__",self.stop,self.start)&&$B.rich_comp("__ge__",other,self.start)&&$B.rich_comp("__gt__",self.stop,other)||$B.rich_comp("__ge__",self.start,self.stop)&&$B.rich_comp("__ge__",self.start,other)&&$B.rich_comp("__gt__",other,self.stop)){return fl}else{throw _b_.ValueError.$factory(_b_.str.$factory(other)+" not in range")}}else{throw _b_.ValueError.$factory(_b_.str.$factory(other)+" not in range")}};range.$factory=function(){var $=$B.args("range",3,{start:null,stop:null,step:null},["start","stop","step"],arguments,{start:null,stop:null,step:null},null,null),start=$.start,stop=$.stop,step=$.step,safe;if(stop===null&&step===null){if(start==null){throw _b_.TypeError.$factory("range expected 1 arguments, got 0")}stop=$B.PyNumber_Index(start);safe=typeof stop==="number";return{__class__:range,start:0,stop:stop,step:1,$is_range:true,$safe:safe}}if(step===null){step=1}start=$B.PyNumber_Index(start);stop=$B.PyNumber_Index(stop);step=$B.PyNumber_Index(step);if(step==0){throw _b_.ValueError.$factory("range arg 3 must not be zero")}safe=typeof start=="number"&&typeof stop=="number"&&typeof step=="number";return{__class__:range,start:start,stop:stop,step:step,$is_range:true,$safe:safe}};$B.set_func_names(range,"builtins");var slice={__class__:_b_.type,__mro__:[_b_.object],__qualname__:"slice",$is_class:true,$native:true,$not_basetype:true,$descriptors:{start:true,step:true,stop:true}};slice.__eq__=function(self,other){var conv1=conv_slice(self),conv2=conv_slice(other);return conv1[0]==conv2[0]&&conv1[1]==conv2[1]&&conv1[2]==conv2[2]};slice.__repr__=function(self){$B.builtins_repr_check(slice,arguments);return"slice("+_b_.str.$factory(self.start)+", "+_b_.str.$factory(self.stop)+", "+_b_.str.$factory(self.step)+")"};slice.__setattr__=function(self,attr,value){throw _b_.AttributeError.$factory("readonly attribute")};function conv_slice(self){var attrs=["start","stop","step"],res=[];for(var i=0;i=0;i--){if(cars.indexOf(self.source[i])==-1){break}}return bytes.$factory(self.source.slice(0,i+1))}function invalid(other){return!$B.$isinstance(other,[bytes,bytearray])}var bytearray={__class__:_b_.type,__mro__:[_b_.object],__qualname__:"bytearray",$buffer_protocol:true,$is_class:true};var mutable_methods=["__delitem__","clear","copy","count","index","pop","remove","reverse"];for(var method of mutable_methods){bytearray[method]=function(m){return function(self){var args=[self.source],pos=1;for(var i=1,len=arguments.length;i255){throw _b_.ValueError.$factory("byte must be in range(0, 256)")}var pos=arg;if(arg<0){pos=self.source.length+pos}if(pos>=0&&pos=0;i--){if(!$B.$isinstance($temp[i],_b_.int)){throw _b_.TypeError.$factory("an integer is required")}else if($temp[i]>255){throw _b_.ValueError.$factory("byte must be in range(0, 256)")}self.source.splice(start,0,$temp[i])}}catch(err){throw _b_.TypeError.$factory("can only assign an iterable")}}else{throw _b_.TypeError.$factory("list indices must be integer, not "+$B.class_name(arg))}};bytearray.append=function(self,b){if(arguments.length!=2){throw _b_.TypeError.$factory("append takes exactly one argument ("+(arguments.length-1)+" given)")}if(!$B.$isinstance(b,_b_.int)){throw _b_.TypeError.$factory("an integer is required")}if(b>255){throw _b_.ValueError.$factory("byte must be in range(0, 256)")}self.source[self.source.length]=b};bytearray.extend=function(self,b){if(self.in_iteration){throw _b_.BufferError.$factory("Existing exports of data: object "+"cannot be re-sized")}if(b.__class__===bytearray||b.__class__===bytes){self.source=self.source.concat(b.source);return _b_.None}for(var item of $B.make_js_iterator(b)){bytearray.append(self,$B.PyNumber_Index(item))}return _b_.None};bytearray.insert=function(self,pos,b){if(arguments.length!=3){throw _b_.TypeError.$factory("insert takes exactly 2 arguments ("+(arguments.length-1)+" given)")}if(!$B.$isinstance(b,_b_.int)){throw _b_.TypeError.$factory("an integer is required")}if(b>255){throw _b_.ValueError.$factory("byte must be in range(0, 256)")}_b_.list.insert(self.source,pos,b)};bytearray.$factory=function(){var args=[bytearray];for(var i=0,len=arguments.length;i-1}if(self.source.length=0&&pos0){stop=Math.min(stop,self.source.length);if(stop<=start){return bytes.$factory([])}for(var i=start;i=start){return bytes.$factory([])}stop=Math.max(0,stop);for(var i=start;i>=stop;i+=step){res[pos++]=self.source[i]}}return bytes.$factory(res)}else if($B.$isinstance(arg,_b_.bool)){return self.source.__getitem__(_b_.int.$factory(arg))}};bytes.$getnewargs=function(self){return $B.fast_tuple([bytes_value(self)])};bytes.__getnewargs__=function(){return bytes.$getnewargs($B.single_arg("__getnewargs__","self",arguments))};bytes.__gt__=function(self,other){if(invalid(other)){return _b_.NotImplemented}return _b_.list.__gt__(self.source,other.source)};bytes.__hash__=function(self){if(self===undefined){return bytes.__hashvalue__||$B.$py_next_hash--}var hash=1;for(var i=0,len=self.source.length;i=0&&item<256){source.push(item)}else{throw _b_.ValueError.$factory("bytes must be in range (0, 256)")}}}return{__class__:$.cls,source:source}};bytes.$new=function(cls,source,encoding,errors){var self={__class__:cls},int_list=[],pos=0;if(source===undefined){}else if(typeof source=="number"||$B.$isinstance(source,_b_.int)){var i=source;while(i--){int_list[pos++]=0}}else{if(typeof source=="string"||$B.$isinstance(source,_b_.str)){if(encoding===undefined){throw _b_.TypeError.$factory("string argument without an encoding")}int_list=encode(source,encoding||"utf-8",errors||"strict")}else{if(encoding!==undefined){console.log("encoding",encoding);throw _b_.TypeError.$factory("encoding without a string argument")}if(Array.isArray(source)){int_list=source}else{try{int_list=_b_.list.$factory(source)}catch(err){var bytes_method=$B.$getattr(source,"__bytes__",_b_.None);if(bytes_method===_b_.None){throw _b_.TypeError.$factory("cannot convert "+`'${$B.class_name(source)}' object to bytes`)}var res=$B.$call(bytes_method)();if(!$B.$isinstance(res,_b_.bytes)){throw _b_.TypeError.$factory(`__bytes__ returned `+`non-bytes (type ${$B.class_name(res)})`)}return res}for(var i=0;i255){throw _b_.ValueError.$factory("bytes must be in range"+"(0, 256)")}}}}}self.source=int_list;self.encoding=encoding;self.errors=errors;return self};bytes.__repr__=bytes.__str__=function(self){var t=$B.special_string_repr,res="";for(var i=0,len=self.source.length;i=128){var hx=s.toString(16);hx=(hx.length==1?"0":"")+hx;res+="\\x"+hx}else if(s=="\\".charCodeAt(0)){res+="\\\\"}else{res+=String.fromCharCode(s)}}if(res.indexOf("'")>-1&&res.indexOf('"')==-1){return'b"'+res+'"'}else{return"b'"+res.replace(new RegExp("'","g"),"\\'")+"'"}};bytes.capitalize=function(self){var src=self.source,len=src.length,buffer=src.slice();if(buffer[0]>96&&buffer[0]<123){buffer[0]-=32}for(var i=1;i64&&buffer[i]<91){buffer[i]+=32}}return bytes.$factory(buffer)};bytes.center=function(){var $=$B.args("center",3,{self:null,width:null,fillbyte:null},["self","width","fillbyte"],arguments,{fillbyte:bytes.$factory([32])},null,null);var diff=$.width-$.self.source.length;if(diff<=0){return bytes.$factory($.self.source)}var ljust=bytes.ljust($.self,$.self.source.length+Math.floor(diff/2),$.fillbyte);return bytes.rjust(ljust,$.width,$.fillbyte)};bytes.count=function(){var $=$B.args("count",4,{self:null,sub:null,start:null,end:null},["self","sub","start","end"],arguments,{start:0,end:-1},null,null);var n=0,index=-1,len=0;if(typeof $.sub=="number"){if($.sub<0||$.sub>255)throw _b_.ValueError.$factory("byte must be in range(0, 256)");len=1}else if(!$.sub.__class__){throw _b_.TypeError.$factory("first argument must be a bytes-like "+"object, not '"+$B.class_name($.sub)+"'")}else if(!$.sub.__class__.$buffer_protocol){throw _b_.TypeError.$factory("first argument must be a bytes-like "+"object, not '"+$B.class_name($.sub)+"'")}else{len=$.sub.source.length}do{index=bytes.find($.self,$.sub,Math.max(index+len,$.start),$.end);if(index!=-1){n++}}while(index!=-1);return n};bytes.decode=function(self,encoding,errors){var $=$B.args("decode",3,{self:null,encoding:null,errors:null},["self","encoding","errors"],arguments,{encoding:"utf-8",errors:"strict"},null,null);switch($.errors){case"strict":case"ignore":case"replace":case"surrogateescape":case"surrogatepass":case"xmlcharrefreplace":case"backslashreplace":return decode($.self,$.encoding,$.errors);default:}};bytes.endswith=function(){var $=$B.args("endswith",4,{self:null,suffix:null,start:null,end:null},["self","suffix","start","end"],arguments,{start:-1,end:-1},null,null);if($B.$isinstance($.suffix,bytes)){var start=$.start==-1?$.self.source.length-$.suffix.source.length:Math.min($.self.source.length-$.suffix.source.length,$.start);var end=$.end==-1?$.self.source.length:$.end;var res=true;for(var i=$.suffix.source.length-1,len=$.suffix.source.length;i>=0&&res;--i){res=$.self.source[end-len+i]==$.suffix.source[i]}return res}else if($B.$isinstance($.suffix,_b_.tuple)){for(var i=0;i<$.suffix.length;++i){if($B.$isinstance($.suffix[i],bytes)){if(bytes.endswith($.self,$.suffix[i],$.start,$.end)){return true}}else{throw _b_.TypeError.$factory("endswith first arg must be "+"bytes or a tuple of bytes, not "+$B.class_name($.suffix))}}return false}else{throw _b_.TypeError.$factory("endswith first arg must be bytes "+"or a tuple of bytes, not "+$B.class_name($.suffix))}};bytes.expandtabs=function(){var $=$B.args("expandtabs",2,{self:null,tabsize:null},["self","tabsize"],arguments,{tabsize:8},null,null);var tab_spaces=[];for(let i=0;i<$.tabsize;++i){tab_spaces.push(32)}var buffer=$.self.source.slice();for(let i=0;i255){throw _b_.ValueError.$factory("byte must be in range(0, 256)")}return self.source.slice(0,end==-1?undefined:end).indexOf(sub,start)}else if(!sub.__class__){throw _b_.TypeError.$factory("first argument must be a bytes-like "+"object, not '"+$B.class_name(sub)+"'")}else if(!sub.__class__.$buffer_protocol){throw _b_.TypeError.$factory("first argument must be a bytes-like "+"object, not '"+$B.class_name(sub)+"'")}end=end==-1?self.source.length:Math.min(self.source.length,end);var len=sub.source.length;for(var i=start;i<=end-len;i++){var chunk=self.source.slice(i,i+len),found=true;for(var j=0;jstring.length){throw _b_.ValueError.$factory("non-hexadecimal number found "+"in fromhex() arg")}source.push(_b_.int.$factory(string.substr(i,2),16))}return $.cls.$factory(source)};bytes.hex=function(){var $=$B.args("hex",3,{self:null,sep:null,bytes_per_sep:null},["self","sep","bytes_per_sep"],arguments,{sep:"",bytes_per_sep:1},null,null),self=$.self,sep=$.sep,bytes_per_sep=$.bytes_per_sep,res="",digits="0123456789abcdef",bps=bytes_per_sep,jstart=bps,len=self.source.length;if(bytes_per_sep<0){bps=-bytes_per_sep;jstart=bps}else if(bytes_per_sep==0){sep=""}else{jstart=len%bps;if(jstart==0){jstart=bps}}for(var i=0,j=jstart;i>4];res+=digits[c&15]}return res};bytes.index=function(){var $=$B.args("index",4,{self:null,sub:null,start:null,end:null},["self","sub","start","end"],arguments,{start:0,end:-1},null,null);var index=bytes.find($.self,$.sub,$.start,$.end);console.log("index",index);if(index==-1){throw _b_.ValueError.$factory("subsection not found")}return index};bytes.isalnum=function(){var $=$B.args("isalnum",1,{self:null},["self"],arguments,{},null,null),self=$.self;var src=self.source,len=src.length,res=len>0;for(var i=0;i96&&src[i]<123||src[i]>64&&src[i]<91||src[i]>47&&src[i]<58}return res};bytes.isalpha=function(){var $=$B.args("isalpha",1,{self:null},["self"],arguments,{},null,null),self=$.self;var src=self.source,len=src.length,res=len>0;for(var i=0;i96&&src[i]<123||src[i]>64&&src[i]<91}return res};bytes.isdigit=function(){var $=$B.args("isdigit",1,{self:null},["self"],arguments,{},null,null),self=$.self;var src=self.source,len=src.length,res=len>0;for(let i=0;i47&&src[i]<58}return res};bytes.islower=function(){var $=$B.args("islower",1,{self:null},["self"],arguments,{},null,null),self=$.self;var src=self.source,len=src.length,res=false;for(let i=0;i96&&src[i]<123;if(src[i]>64&&src[i]<91){return false}}return res};bytes.isspace=function(){var $=$B.args("isspace",1,{self:null},["self"],arguments,{},null,null),self=$.self;var src=self.source,len=src.length;for(let i=0;i64&&src[i]<91;if(src[i]>96&&src[i]<123){return false}}return res};bytes.istitle=function(){var $=$B.args("istitle",1,{self:null},["self"],arguments,{},null,null),self=$.self;var src=self.source,len=src.length,current_char_is_letter=false,prev_char_was_letter=false,is_uppercase=false,is_lowercase=false;for(var i=0;i96&&src[i]<123;is_uppercase=src[i]>64&&src[i]<91;current_char_is_letter=is_lowercase||is_uppercase;if(current_char_is_letter&&(prev_char_was_letter&&is_uppercase)||!prev_char_was_letter&&is_lowercase){return false}prev_char_was_letter=current_char_is_letter}return true};bytes.join=function(){var $ns=$B.args("join",2,{self:null,iterable:null},["self","iterable"],arguments,{}),self=$ns["self"],iterable=$ns["iterable"];var next_func=$B.$getattr(_b_.iter(iterable),"__next__"),res=self.__class__.$factory(),empty=true;while(true){try{var item=next_func();if(empty){empty=false}else{res=bytes.__add__(res,self)}res=bytes.__add__(res,item)}catch(err){if($B.$isinstance(err,_b_.StopIteration)){break}throw err}}return res};var _lower=function(char_code){if(char_code>=65&&char_code<=90){return char_code+32}else{return char_code}};bytes.lower=function(self){var _res=[],pos=0;for(var i=0,len=self.source.length;i=0?$.count:src.length;if(!$.old.__class__){throw _b_.TypeError.$factory("first argument must be a bytes-like "+"object, not '"+$B.class_name($.old)+"'")}else if(!$.old.__class__.$buffer_protocol){throw _b_.TypeError.$factory("first argument must be a bytes-like "+"object, not '"+$B.class_name($.sep)+"'")}if(!$.new.__class__){throw _b_.TypeError.$factory("second argument must be a bytes-like "+"object, not '"+$B.class_name($.old)+"'")}else if(!$.new.__class__.$buffer_protocol){throw _b_.TypeError.$factory("second argument must be a bytes-like "+"object, not '"+$B.class_name($.sep)+"'")}for(var i=0;i255){throw _b_.ValueError.$factory("byte must be in range(0, 256)")}return $.self.source.slice(start,$.end==-1?undefined:$.end).lastIndexOf(sub)+start}else if(!sub.__class__){throw _b_.TypeError.$factory("first argument must be a bytes-like "+"object, not '"+$B.class_name($.sub)+"'")}else if(!sub.__class__.$buffer_protocol){throw _b_.TypeError.$factory("first argument must be a bytes-like "+"object, not '"+$B.class_name(sub)+"'")}end=end==-1?self.source.length:Math.min(self.source.length,end);var len=sub.source.length;for(var i=end-len;i>=start;--i){var chunk=self.source.slice(i,i+len),found=true;for(var j=0;jstart){res.push(bytes.$factory(src.slice(start,stop)))}return res};bytes.splitlines=function(self){var $=$B.args("splitlines",2,{self:null,keepends:null},["self","keepends"],arguments,{keepends:false},null,null);if(!$B.$isinstance($.keepends,[_b_.bool,_b_.int])){throw _b_.TypeError("integer argument expected, got "+$B.get_class($.keepends).__name)}var keepends=_b_.int.$factory($.keepends),res=[],source=$.self.source,start=0,pos=0;if(!source.length){return res}while(pos96&&buffer[i]<123){buffer[i]-=32}else if(buffer[i]>64&&buffer[i]<91){buffer[i]+=32}}return bytes.$factory(buffer)};bytes.title=function(self){var src=self.source,len=src.length,buffer=src.slice(),current_char_is_letter=false,prev_char_was_letter=false,is_uppercase=false,is_lowercase=false;for(var i=0;i96&&buffer[i]<123;is_uppercase=buffer[i]>64&&buffer[i]<91;current_char_is_letter=is_lowercase||is_uppercase;if(current_char_is_letter){if(prev_char_was_letter&&is_uppercase){buffer[i]+=32}else if(!prev_char_was_letter&&is_lowercase){buffer[i]-=32}}prev_char_was_letter=current_char_is_letter}return bytes.$factory(buffer)};bytes.translate=function(self,table,_delete){if(_delete===undefined){_delete=[]}else if($B.$isinstance(_delete,bytes)){_delete=_delete.source}else{throw _b_.TypeError.$factory("Type "+$B.get_class(_delete).__name+" doesn't support the buffer API")}var res=[],pos=0;if($B.$isinstance(table,bytes)&&table.source.length==256){for(var i=0,len=self.source.length;i-1){continue}res[pos++]=table.source[self.source[i]]}}return bytes.$factory(res)};var _upper=function(char_code){if(char_code>=97&&char_code<=122){return char_code-32}else{return char_code}};bytes.upper=function(self){var _res=[],pos=0;for(var i=0,len=self.source.length;i>5==6){if(b[pos+1]===undefined){err_info=[byte,pos,"end"]}else if((b[pos+1]&192)!=128){err_info=[byte,pos,"continuation"]}if(err_info!==null){if(errors=="ignore"){pos++}else{throw _b_.UnicodeDecodeError.$factory("'utf-8' codec can't decode byte 0x"+err_info[0].toString(16)+" in position "+err_info[1]+(err_info[2]=="end"?": unexpected end of data":": invalid continuation byte"))}}else{var cp=byte&31;cp<<=6;cp+=b[pos+1]&63;s+=String.fromCodePoint(cp);pos+=2}}else if(byte>>4==14){if(b[pos+1]===undefined){err_info=[byte,pos,"end",pos+1]}else if((b[pos+1]&192)!=128){err_info=[byte,pos,"continuation",pos+2]}else if(b[pos+2]===undefined){err_info=[byte,pos+"-"+(pos+1),"end",pos+2]}else if((b[pos+2]&192)!=128){err_info=[byte,pos,"continuation",pos+3]}if(err_info!==null){if(errors=="ignore"){pos=err_info[3]}else if(errors=="surrogateescape"){for(var i=pos;i>3==30){if(b[pos+1]===undefined){err_info=[byte,pos,"end",pos+1]}else if((b[pos+1]&192)!=128){err_info=[byte,pos,"continuation",pos+2]}else if(b[pos+2]===undefined){err_info=[byte,pos+"-"+(pos+1),"end",pos+2]}else if((b[pos+2]&192)!=128){err_info=[byte,pos,"continuation",pos+3]}else if(b[pos+3]===undefined){err_info=[byte,pos+"-"+(pos+1)+"-"+(pos+2),"end",pos+3]}else if((b[pos+2]&192)!=128){err_info=[byte,pos,"continuation",pos+3]}if(err_info!==null){if(errors=="ignore"){pos=err_info[3]}else if(errors=="surrogateescape"){for(var i=pos;i")}}return decoded}return s};var encode=$B.encode=function(){var $=$B.args("encode",3,{s:null,encoding:null,errors:null},["s","encoding","errors"],arguments,{encoding:"utf-8",errors:"strict"},null,null),s=$.s,encoding=$.encoding,errors=$.errors;var t=[],pos=0,enc=normalise(encoding);switch(enc){case"utf-8":case"utf_8":case"utf8":for(var i=0,len=s.length;i>6),128+(cp&63))}else if(cp<=65535){t.push(224+(cp>>12),128+((cp&4095)>>6),128+(cp&63))}else{console.log("4 bytes")}}break;case"latin":case"latin1":case"latin-1":case"latin_1":case"L1":case"iso8859_1":case"iso_8859_1":case"8859":case"cp819":case"windows1252":for(var i=0,len=s.length;i>2>other_size){return set_copy_and_difference(so,other)}var result=make_new_set();if(other_is_dict){for(var entry of set_iter_with_hash(so)){if(!_b_.dict.$lookup_by_key(other,entry.item,entry.hash).found){set_add(result,entry.item,entry.hash)}}return result}for(var entry of set_iter_with_hash(so)){if(!set_contains(other,entry.item,entry.hash)){set_add(result,entry.item,entry.hash)}}result.__class__=so.__class__;return result}function set_difference_update(so,other){if(so===other){return set.clear(so)}if($B.$isinstance(other,[set,frozenset])){for(var entry of set_iter_with_hash(other)){set_discard_entry(so,entry.item,entry.hash)}}else if($B.$isinstance(other,_b_.dict)){for(var entry of _b_.dict.$iter_items_with_hash(other)){set_discard_entry(so,entry.key,entry.hash)}}else{var iterator=$B.make_js_iterator(other);for(var key of iterator){set_discard_key(so,key)}}}const DISCARD_NOTFOUND=0,DISCARD_FOUND=1;function set_discard_entry(so,key,hash){var entry=set_lookkey(so,key,hash);if(!entry){return DISCARD_NOTFOUND}if(so.$store[entry.hash]!==undefined){set_remove(so,entry.hash,entry.index)}}function set_discard_key(so,key){return set_discard_entry(so,key)}function*set_iter(so){var ordered_keys=Object.keys(so.$store).sort();for(var hash of ordered_keys){if(so.$store[hash]!==undefined){for(var item of so.$store[hash]){yield item}}}}function*set_iter_with_hash(so){for(var hash in so.$store){if(so.$store[hash]!==undefined){for(var item of so.$store[hash]){yield{item:item,hash:hash}}}}}function set_remove(so,hash,index){so.$store[hash].splice(index,1);if(so.$store[hash].length==0){delete so.$store[hash]}so.$used--}function set_intersection(so,other){if(so===other){return set_copy(so)}var result=make_new_set_base_type(so),iterator;if($B.$isinstance(other,[set,frozenset])){if(other.$used>so.$used){var tmp=so;so=other;other=tmp}for(var entry of set_iter_with_hash(other)){if(set_contains(so,entry.item,entry.hash)){set_add(result,entry.item,entry.hash)}}}else if($B.$isinstance(other,_b_.dict)){for(var entry of _b_.dict.$iter_items_with_hash(other)){if(set_contains(so,entry.key,entry.hash)){set_add(result,entry.key,entry.hash)}}}else{var iterator=$B.make_js_iterator(other);for(var other_item of iterator){var test=set_contains(so,other_item);if(test){set_add(result,other_item)}}}return result}function set_intersection_multi(so,args){var result=set_copy(so);if(args.length==0){return result}for(var other of args){result=set_intersection(result,other)}return result}function set_lookkey(so,key,hash){if(hash===undefined){try{hash=$B.$hash(key)}catch(err){if($B.$isinstance(key,set)){hash=$B.$hash(frozenset.$factory(key))}else{throw err}}}var items=so.$store[hash];if(items===undefined){return false}for(var index=0,len=so.$store[hash].length;index0){set.clear(self)}set.update(self,iterable);return _b_.None};var set_iterator=$B.make_class("set_iterator",(function(so){return{__class__:set_iterator,so:so,it:set_iter(so),version:so.$version}}));set_iterator.__iter__=function(self){return self};set_iterator.__length_hint__=function(self){return self.so.$used};set_iterator.__next__=function(self){var res=self.it.next();if(res.done){throw _b_.StopIteration.$factory()}if(self.so.$version!=self.version){throw _b_.RuntimeError.$factory("Set changed size during iteration")}return res.value};set_iterator.__reduce_ex__=function(self,protocol){return $B.fast_tuple([_b_.iter,$B.fast_tuple([set_make_items(self.so)])])};$B.set_func_names(set_iterator,"builtins");set.__iter__=function(self){return set_iterator.$factory(self)};function check_version(s,version){if(s.$version!=version){throw _b_.RuntimeError.$factory("Set changed size during iteration")}}function set_make_items(so){var items=[];for(var hash in so.$store){items=items.concat(so.$store[hash])}return items}function make_hash_iter(obj,hash){let version=obj.$version,hashes=obj.$hashes[hash],len=hashes.length,i=0;const iterator={*[Symbol.iterator](){while(iset.__len__(other)){return false}for(var entry of set_iter_with_hash(self)){if(!set_lookkey(other,entry.item,entry.hash)){return false}}return true}else if($B.$isinstance(other,_b_.dict)){for(var entry of _b_.dict.$iter_items_with_hash(self)){if(!set_lookkey(other,entry.key,entry.hash)){return false}}return true}else{var member_func=$B.member_func(other);for(var entry of set_iter_with_hash(self)){if(!member_func(entry.item)){return false}}return true}};set.issuperset=function(){var $=$B.args("issuperset",2,{self:null,other:null},["self","other"],arguments,{},"args",null),self=$.self,other=$.other;if($B.$isinstance(other,[set,frozenset])){return set.issubset(other,self)}else{return set.issubset(set.$factory(other),self)}};set.__iand__=function(self,other){if(!$B.$isinstance(other,[set,frozenset])){return _b_.NotImplemented}set.intersection_update(self,other);return self};set.__isub__=function(self,other){if(!$B.$isinstance(other,[set,frozenset])){return _b_.NotImplemented}set_difference_update(self,other);return self};set.__ixor__=function(self,other){if(!$B.$isinstance(other,[set,frozenset])){return _b_.NotImplemented}set.symmetric_difference_update(self,other);return self};set.__ior__=function(self,other){if(!$B.$isinstance(other,[set,frozenset])){return _b_.NotImplemented}set.update(self,other);return self};set.$literal=function(items){var res=make_new_set(set);for(var item of items){if(item.constant){set_add(res,item.constant[0],item.constant[1])}else if(item.starred){for(var item of $B.make_js_iterator(item.starred)){set_add(res,item)}}else{set_add(res,item.item)}}return res};set.$factory=function(){var args=[set].concat(Array.from(arguments)),self=set.__new__.apply(null,args);set.__init__(self,...arguments);return self};$B.set_func_names(set,"builtins");set.__class_getitem__=_b_.classmethod.$factory(set.__class_getitem__);var frozenset=$B.make_class("frozenset");frozenset.$native=true;for(var attr in set){switch(attr){case"add":case"clear":case"discard":case"pop":case"remove":case"update":break;default:if(frozenset[attr]==undefined){if(typeof set[attr]=="function"){frozenset[attr]=function(x){return function(){return set[x].apply(null,arguments)}}(attr)}else{frozenset[attr]=set[attr]}}}}frozenset.__hash__=function(self){if(self===undefined){return frozenset.__hashvalue__||$B.$py_next_hash--}if(self.__hashvalue__!==undefined){return self.__hashvalue__}var _hash=1927868237;_hash*=self.$used;for(var entry of set_iter_with_hash(self)){var _h=entry.hash;_hash^=(_h^89869747^_h<<16)*3644798167}_hash=_hash*69069+907133923;if(_hash==-1){_hash=590923713}return self.__hashvalue__=_hash};frozenset.__init__=function(){return _b_.None};frozenset.__new__=function(cls,iterable){if(cls===undefined){throw _b_.TypeError.$factory("frozenset.__new__(): not enough arguments")}var self=make_new_set(cls);if(iterable===undefined){return self}$B.check_nb_args_no_kw("__new__",2,arguments);if(cls===frozenset&&iterable.__class__===frozenset){return iterable}set.update(self,iterable);return self};frozenset.__repr__=function(self){$B.builtins_repr_check(frozenset,arguments);return set_repr(self)};frozenset.copy=function(self){if(self.__class__===frozenset){return self}return set_copy(self)};var singleton_id=Math.floor(Math.random()*Math.pow(2,40));function empty_frozenset(){var res=frozenset.__new__(frozenset);res.$id=singleton_id;return res}frozenset.$factory=function(){var args=[frozenset].concat(Array.from(arguments)),self=frozenset.__new__.apply(null,args);frozenset.__init__(self,...arguments);return self};$B.set_func_names(frozenset,"builtins");_b_.set=set;_b_.frozenset=frozenset})(__BRYTHON__);(function($B){var _b_=$B.builtins,_window=globalThis;var Module=$B.module=$B.make_class("module",(function(name,doc,$package){return{$tp_class:Module,__builtins__:_b_.__builtins__,__name__:name,__doc__:doc||_b_.None,__package__:$package||_b_.None}}));Module.__dir__=function(self){if(self.__dir__){return $B.$call(self.__dir__)()}var res=[];for(var key in self){if(key.startsWith("$")||key=="__class__"){continue}res[res.length]=key}return res.sort()};Module.__new__=function(cls,name,doc,$package){return{__class__:cls,__builtins__:_b_.__builtins__,__name__:name,__doc__:doc||_b_.None,__package__:$package||_b_.None}};Module.__repr__=Module.__str__=function(self){var res=""};Module.__setattr__=function(self,attr,value){if(self.__name__=="__builtins__"){$B.builtins[attr]=value}else{self[attr]=value}};$B.set_func_names(Module,"builtins");$B.make_import_paths=function(filename){var elts=filename.split("/");elts.pop();var script_dir=elts.join("/"),path=[$B.brython_path+"Lib",$B.brython_path+"libs",script_dir,$B.brython_path+"Lib/site-packages"];var meta_path=[],path_hooks=[];if($B.use_VFS){meta_path.push($B.finders.VFS)}var static_stdlib_import=$B.get_option_from_filename("static_stdlib_import",filename);if(static_stdlib_import!==false&&$B.protocol!="file"){meta_path.push($B.finders.stdlib_static);if(path.length>3){path.shift();path.shift()}}var pythonpath=$B.get_option_from_filename("pythonpath",filename);if(pythonpath){var ix=path.indexOf($B.script_dir);if(ix===-1){console.log("bizarre",path,$B.script_dir)}else{path.splice(ix,1,...pythonpath)}}if($B.protocol!=="file"){meta_path.push($B.finders.path);path_hooks.push($B.url_hook)}$B.import_info[filename]={meta_path:meta_path,path_hooks:path_hooks,path:path}};function $download_module(mod,url,$package){var xhr=new XMLHttpRequest,fake_qs="?v="+(new Date).getTime(),res=null,mod_name=mod.__name__;var timer=_window.setTimeout((function(){xhr.abort()}),5e3);if($B.get_option("cache")){xhr.open("GET",url,false)}else{xhr.open("GET",url+fake_qs,false)}xhr.send();if($B.$CORS){if(xhr.status==200||xhr.status==0){res=xhr.responseText}else{res=_b_.ModuleNotFoundError.$factory("No module named '"+mod_name+"'")}}else{if(xhr.readyState==4){if(xhr.status==200){res=xhr.responseText;mod.$last_modified=xhr.getResponseHeader("Last-Modified")}else{console.info("Error "+xhr.status+" means that Python module "+mod_name+" was not found at url "+url);res=_b_.ModuleNotFoundError.$factory("No module named '"+mod_name+"'")}}}_window.clearTimeout(timer);if(res==null){throw _b_.ModuleNotFoundError.$factory("No module named '"+mod_name+"' (res is null)")}if(res.constructor===Error){throw res}return res}$B.$download_module=$download_module;function import_js(mod,path){try{var module_contents=$download_module(mod,path,undefined)}catch(err){return null}run_js(module_contents,path,mod);return true}$B.addToImported=function(name,modobj){$B.imported[name]=modobj;if(modobj===undefined){throw _b_.ImportError.$factory("imported not set by module")}modobj.__class__=Module;modobj.__name__=name;for(var attr in modobj){if(typeof modobj[attr]=="function"){modobj[attr].$infos={__module__:name,__name__:attr,__qualname__:attr};modobj[attr].$in_js_module=true}else if($B.$isinstance(modobj[attr],_b_.type)&&!modobj[attr].hasOwnProperty("__module__")){modobj[attr].__module__=name}}};function run_js(module_contents,path,_module){var module_id="$locals_"+_module.__name__.replace(/\./g,"_");try{new Function(module_contents)()}catch(err){throw $B.exception(err)}var modobj=$B.imported[_module.__name__];if(modobj===undefined){throw _b_.ImportError.$factory("imported not set by module")}modobj.__class__=Module;modobj.__name__=_module.__name__;for(var attr in modobj){if(typeof modobj[attr]=="function"){modobj[attr].$infos={__module__:_module.__name__,__name__:attr,__qualname__:attr};modobj[attr].$in_js_module=true}else if($B.$isinstance(modobj[attr],_b_.type)&&!modobj[attr].hasOwnProperty("__module__")){modobj[attr].__module__=_module.__name__}}return true}function show_ns(){var kk=Object.keys(_window);for(var i=0,len=kk.length;i1){console.log("error in imported module",module);console.log("stack",$B.make_frames_stack(err.$frame_obj))}throw err}}try{js=compiled?module_contents:root.to_js();if($B.get_option("debug")==10){console.log("code for module "+module.__name__);console.log($B.format_indent(js,0))}var src=js;js="var $module = (function(){\n"+js;var prefix="locals_";js+="return "+prefix;js+=module.__name__.replace(/\./g,"_")+"})(__BRYTHON__)\n"+"return $module";var module_id=prefix+module.__name__.replace(/\./g,"_");var mod=new Function(module_id,js)(module)}catch(err){err.$frame_obj=err.$frame_obj||$B.frame_obj;if($B.get_option("debug",err)>2){console.log(err+" for module "+module.__name__);console.log("module",module);console.log(root);if($B.get_option("debug",err)>1){console.log($B.format_indent(js,0))}for(var attr in err){console.log(attr,err[attr])}console.log("message: "+err.$message);console.log("filename: "+err.fileName);console.log("linenum: "+err.lineNumber);console.log(js.split("\n").slice(err.lineNumber-3,err.lineNumber+3).join("\n"));console.log(err.stack)}throw err}try{for(var attr in mod){module[attr]=mod[attr]}module.__initializing__=false;$B.imported[module.__name__]=module;return{content:src,name:mod_name,imports:Object.keys(root.imports).join(",")}}catch(err){console.log(""+err+" "+" for module "+module.__name__);for(var attr in err){console.log(attr+" "+err[attr])}if($B.get_option("debug")>0){console.log("line info "+__BRYTHON__.line_info)}throw err}}$B.run_py=run_py;$B.run_js=run_js;var ModuleSpec=$B.make_class("ModuleSpec",(function(fields){fields.__class__=ModuleSpec;return fields}));ModuleSpec.__str__=ModuleSpec.__repr__=function(self){var res=`ModuleSpec(name='${self.name}', `+`loader=${_b_.str.$factory(self.loader)}, `+`origin='${self.origin}'`;if(self.submodule_search_locations!==_b_.None){res+=`, submodule_search_locations=`+`${_b_.str.$factory(self.submodule_search_locations)}`}return res+")"};$B.set_func_names(ModuleSpec,"builtins");function parent_package(mod_name){var parts=mod_name.split(".");parts.pop();return parts.join(".")}var VFSFinder=$B.make_class("VFSFinder",(function(){return{__class__:VFSFinder}}));VFSFinder.find_spec=function(cls,fullname,path){var stored,is_package,timestamp;if(!$B.use_VFS){return _b_.None}stored=$B.VFS[fullname];if(stored===undefined){return _b_.None}is_package=stored[3]||false;timestamp=stored.timestamp;if(stored){var is_builtin=$B.builtin_module_names.indexOf(fullname)>-1;return ModuleSpec.$factory({name:fullname,loader:VFSLoader.$factory(),origin:is_builtin?"built-in":"brython_stdlib",submodule_search_locations:is_package?[]:_b_.None,loader_state:{stored:stored,timestamp:timestamp},cached:_b_.None,parent:is_package?fullname:parent_package(fullname),has_location:_b_.False})}};$B.set_func_names(VFSFinder,"");for(var method in VFSFinder){if(typeof VFSFinder[method]=="function"){VFSFinder[method]=_b_.classmethod.$factory(VFSFinder[method])}}const VFSLoader=$B.make_class("VFSLoader",(function(){return{__class__:VFSLoader}}));VFSLoader.create_module=function(self,spec){return _b_.None};VFSLoader.exec_module=function(self,modobj){var stored=modobj.__spec__.loader_state.stored,timestamp=modobj.__spec__.loader_state.timestamp;var ext=stored[0],module_contents=stored[1],imports=stored[2];modobj.$is_package=stored[3]||false;var path="VFS."+modobj.__name__;path+=modobj.$is_package?"/__init__.py":ext;modobj.__file__=path;$B.file_cache[modobj.__file__]=$B.VFS[modobj.__name__][1];$B.url2name[modobj.__file__]=modobj.__name__;if(ext==".js"){run_js(module_contents,modobj.__path__,modobj)}else if($B.precompiled.hasOwnProperty(modobj.__name__)){if($B.get_option("debug")>1){console.info("load",modobj.__name__,"from precompiled")}var parts=modobj.__name__.split(".");for(var i=0;i";mod.__package__=parent;mod.$is_package=true}else{var elts=parent.split(".");elts.pop();mod.__package__=elts.join(".")}mod.__file__=path;try{var parent_id=parent.replace(/\./g,"_"),prefix="locals_";mod_js+="return "+prefix+parent_id;var $module=new Function(prefix+parent_id,mod_js)(mod)}catch(err){if($B.get_option("debug")>1){console.log("error in module",mod);console.log(err);for(var k in err){console.log(k,err[k])}console.log(Object.keys($B.imported));console.log(modobj,"mod_js",mod_js)}throw err}for(var attr in $module){mod[attr]=$module[attr]}$module.__file__=path;if(i>0){$B.builtins.setattr($B.imported[parts.slice(0,i).join(".")],parts[i],$module)}}return $module}else{var mod_name=modobj.__name__;if($B.get_option("debug")>1){console.log("run Python code from VFS",mod_name)}var record=run_py(module_contents,modobj.__file__,modobj);record.imports=imports.join(",");record.is_package=modobj.$is_package;record.timestamp=$B.timestamp;record.source_ts=timestamp;$B.precompiled[mod_name]=record.is_package?[record.content]:record.content;var elts=mod_name.split(".");if(elts.length>1){elts.pop()}if($B.$options.indexedDB&&$B.indexedDB&&$B.idb_name){var idb_cx=indexedDB.open($B.idb_name);idb_cx.onsuccess=function(evt){var db=evt.target.result,tx=db.transaction("modules","readwrite"),store=tx.objectStore("modules"),cursor=store.openCursor(),request=store.put(record);request.onsuccess=function(){if($B.get_option("debug")>1){console.info(modobj.__name__,"stored in db")}};request.onerror=function(){console.info("could not store "+modobj.__name__)}}}}};$B.set_func_names(VFSLoader,"builtins");var finder_cpython={__class__:_b_.type,__mro__:[_b_.object],__qualname__:"CPythonFinder",$infos:{__module__:"builtins",__name__:"CPythonFinder"},create_module:function(cls,spec){return _b_.None},exec_module:function(cls,modobj){console.log("exec PYthon module",modobj);var loader_state=modobj.__spec__.loader_state;var content=loader_state.content;delete modobj.__spec__["loader_state"];modobj.$is_package=loader_state.is_package;modobj.__file__=loader_state.__file__;$B.file_cache[modobj.__file__]=content;$B.url2file[modobj.__file__]=modobj.__name__;var mod_name=modobj.__name__;if($B.get_option("debug")>1){console.log("run Python code from CPython",mod_name)}run_py(content,modobj.__path__,modobj)},find_module:function(cls,name,path){return{__class__:Loader,load_module:function(name,path){var spec=cls.find_spec(cls,name,path);var mod=Module.$factory(name);$B.imported[name]=mod;mod.__spec__=spec;cls.exec_module(cls,mod)}}},find_spec:function(cls,fullname,path){console.log("finder cpython",fullname);var xhr=new XMLHttpRequest,url="/cpython_import?module="+fullname,result;xhr.open("GET",url,false);xhr.onreadystatechange=function(){if(this.readyState==4&&this.status==200){var data=JSON.parse(this.responseText);result=ModuleSpec.$factory({name:fullname,loader:cls,origin:"CPython",submodule_search_locations:data.is_package?[]:_b_.None,loader_state:{content:data.content},cached:_b_.None,parent:data.is_package?fullname:parent_package(fullname),has_location:_b_.False})}};xhr.send();return result}};$B.set_func_names(finder_cpython,"");for(var method in finder_cpython){if(typeof finder_cpython[method]=="function"){finder_cpython[method]=_b_.classmethod.$factory(finder_cpython[method])}}finder_cpython.$factory=function(){return{__class__:finder_cpython}};var StdlibStaticFinder=$B.make_class("StdlibStaticFinder",(function(){return{__class__:StdlibStaticFinder}}));StdlibStaticFinder.find_spec=function(self,fullname,path){if($B.stdlib&&$B.get_option("static_stdlib_import")){var address=$B.stdlib[fullname];if(address===undefined){var elts=fullname.split(".");if(elts.length>1){elts.pop();var $package=$B.stdlib[elts.join(".")];if($package&&$package[1]){address=["py"]}}}if(address!==undefined){var ext=address[0],is_pkg=address[1]!==undefined,path=$B.brython_path+(ext=="py"?"Lib/":"libs/")+fullname.replace(/\./g,"/"),metadata={ext:ext,is_package:is_pkg,path:path+(is_pkg?"/__init__.py":ext=="py"?".py":".js"),address:address},_module=Module.$factory(fullname);metadata.code=$download_module(_module,metadata.path);var res=ModuleSpec.$factory({name:fullname,loader:PathLoader.$factory(),origin:metadata.path,submodule_search_locations:is_pkg?[path]:_b_.None,loader_state:metadata,cached:_b_.None,parent:is_pkg?fullname:parent_package(fullname),has_location:_b_.True});return res}}return _b_.None};$B.set_func_names(StdlibStaticFinder,"");for(var method in StdlibStaticFinder){if(typeof StdlibStaticFinder[method]=="function"){StdlibStaticFinder[method]=_b_.classmethod.$factory(StdlibStaticFinder[method])}}StdlibStaticFinder.$factory=function(){return{__class__:StdlibStaticFinder}};var PathFinder=$B.make_class("PathFinder",(function(){return{__class__:PathFinder}}));PathFinder.find_spec=function(cls,fullname,path){if($B.VFS&&$B.VFS[fullname]){return _b_.None}if($B.is_none(path)){path=get_info("path")}for(var i=0,li=path.length;i");for(var method in PathFinder){if(typeof PathFinder[method]=="function"){PathFinder[method]=_b_.classmethod.$factory(PathFinder[method])}}var PathEntryFinder=$B.make_class("PathEntryFinder",(function(path_entry,hint){return{__class__:PathEntryFinder,path_entry:path_entry,hint:hint}}));PathEntryFinder.find_spec=function(self,fullname){var loader_data={},notfound=true,hint=self.hint,base_path=self.path_entry+fullname.match(/[^.]+$/g)[0],modpaths=[],py_ext=$B.get_option("python_extension");var tryall=hint===undefined;if(tryall||hint=="py"){modpaths=modpaths.concat([[base_path+py_ext,"py",false],[base_path+"/__init__"+py_ext,"py",true]])}for(var j=0;notfound&&j-1){meta_path.splice(path_ix,1)}}for(var i=0,len=meta_path.length;i0;if(modobj==_b_.None){import_error(mod_name)}if(modobj===undefined){if($B.is_none(fromlist)){fromlist=[]}for(var i=0,modsep="",_mod_name="",len=parsed_name.length-1,__path__=_b_.None;i<=len;++i){var _parent_name=_mod_name;_mod_name+=modsep+parsed_name[i];modsep=".";var modobj=$B.imported[_mod_name];if($test){console.log("iter",i,_mod_name,"\nmodobj",modobj,"\n__path__",__path__,Array.isArray(__path__));alert()}if(modobj==_b_.None){import_error(_mod_name)}else if(modobj===undefined){try{import_engine(_mod_name,__path__,from_stdlib)}catch(err){delete $B.imported[_mod_name];throw err}if($B.is_none($B.imported[_mod_name])){import_error(_mod_name)}else{if(_parent_name){_b_.setattr($B.imported[_parent_name],parsed_name[i],$B.imported[_mod_name])}}}else if($B.imported[_parent_name]&&$B.imported[_parent_name][parsed_name[i]]===undefined){_b_.setattr($B.imported[_parent_name],parsed_name[i],$B.imported[_mod_name])}if(i0){return $B.imported[mod_name]}else{let package_name=mod_name;while(parsed_name.length>1){var module=parsed_name.pop();package_name=parsed_name.join(".");if($B.imported[package_name]===undefined){$B.$import(package_name,globals,locals,[]);$B.imported[package_name][module]=$B.imported[mod_name];mod_name=module}}return $B.imported[package_name]}};$B.$import=function(mod_name,fromlist,aliases,locals){var test=false;if(test){console.log("import",mod_name,fromlist,aliases);alert()}if(mod_name=="_frozen_importlib_external"){var alias=aliases[mod_name]||mod_name;var imp=$B.$import_from("importlib",["_bootstrap_external"],{_bootstrap_external:alias},0,locals);var _bootstrap=$B.imported.importlib._bootstrap,_bootstrap_external=$B.imported.importlib["_bootstrap_external"];_bootstrap_external._set_bootstrap_module(_bootstrap);_bootstrap._bootstap_external=_bootstrap_external;var _frozen_importlib=$B.imported._frozen_importlib;if(_frozen_importlib){_frozen_importlib._bootstrap_external=_bootstrap_external}return}var level=0,frame=$B.frame_obj.frame,current_module=frame[2],parts=current_module.split(".");while(mod_name.length>0&&mod_name.startsWith(".")){level++;mod_name=mod_name.substr(1);if(parts.length==0){throw _b_.ImportError.$factory("Parent module '' not loaded, "+"cannot perform relative import")}current_module=parts.join(".");parts.pop()}if(level>0){mod_name=current_module+(mod_name.length>0?"."+mod_name:"")}var parts=mod_name.split(".");if(mod_name[mod_name.length-1]=="."){parts.pop()}var norm_parts=[],prefix=true;for(var i=0,len=parts.length;i1){console.log($err3);console.log($B.frame_obj.frame)}throw _b_.ImportError.$factory("cannot import name '"+name+"'")}}}}return locals}};$B.$import_from=function(module,names,aliases,level,locals){var current_module_name=$B.frame_obj.frame[2],parts=current_module_name.split("."),relative=level>0;if(relative){var current_module=$B.imported[parts.join(".")];if(current_module===undefined){throw _b_.ImportError.$factory("attempted relative import with no known parent package")}if(!current_module.$is_package){if(parts.length==1){throw _b_.ImportError.$factory("attempted relative import with no known parent package")}else{parts.pop();current_module=$B.imported[parts.join(".")]}}while(level>0){var current_module=$B.imported[parts.join(".")];if(!current_module.$is_package){throw _b_.ImportError.$factory("attempted relative import with no known parent package")}level--;parts.pop()}if(module){var submodule=current_module.__name__+"."+module;$B.$import(submodule,[],{},{});current_module=$B.imported[submodule]}if(names.length>0&&names[0]=="*"){for(var key in current_module){if(key.startsWith("$")||key.startsWith("_")){continue}locals[key]=current_module[key]}}else{for(var name of names){var alias=aliases[name]||name;if(current_module[name]!==undefined){locals[alias]=current_module[name]}else{var sub_module=current_module.__name__+"."+name;$B.$import(sub_module,[],{},{});locals[alias]=$B.imported[sub_module]}}}}else{$B.$import(module,names,aliases,locals)}};$B.import_all=function(locals,module){for(var attr in module){if("_$".indexOf(attr.charAt(0))==-1){locals[attr]=module[attr]}}};$B.$meta_path=[VFSFinder,StdlibStaticFinder,PathFinder];$B.finders={VFS:VFSFinder,stdlib_static:StdlibStaticFinder,path:PathFinder,CPython:finder_cpython};function optimize_import_for_path(path,filetype){if(path.slice(-1)!="/"){path=path+"/"}var value=filetype=="none"?_b_.None:url_hook(path,filetype);$B.path_importer_cache[path]=value}var Loader={__class__:$B.$type,__mro__:[_b_.object],__name__:"Loader"};var _importlib_module={__class__:Module,__name__:"_importlib",Loader:Loader,VFSFinder:VFSFinder,StdlibStatic:StdlibStaticFinder,ImporterPath:PathFinder,UrlPathFinder:url_hook,optimize_import_for_path:optimize_import_for_path};_importlib_module.__repr__=_importlib_module.__str__=function(){return""};$B.imported["_importlib"]=_importlib_module})(__BRYTHON__);(function($B){var _b_=$B.builtins;var unicode_tables=$B.unicode_tables;$B.has_surrogate=function(s){for(var i=0;i=55296&&code<=56319){return true}}return false};var escape2cp={b:"\b",f:"\f",n:"\n",r:"\r",t:"\t",v:"\v"};$B.surrogates=function(s){var s1="",escaped=false;for(var char of s){if(escaped){var echar=escape2cp[char];if(echar!==undefined){s1+=echar}else{s1+="\\"+char}escaped=false}else if(char=="\\"){escaped=true}else{s1+=char}}var codepoints=[],surrogates=[],j=0;for(var i=0,len=s1.length;i=65536){surrogates.push(j);i++}j++}return surrogates};$B.String=function(s){var srg=$B.surrogates(s);return srg.length==0?s:$B.make_String(s,srg)};$B.make_String=function(s,surrogates){if(!Array.isArray(surrogates)){throw Error("not list")}var res=new String(s);res.__class__=str;res.surrogates=surrogates;return res};function pypos2jspos(s,pypos){if(s.surrogates===undefined){return pypos}var nb=0;while(s.surrogates[nb]=55296&&code<=56319){var v=65536;v+=(code&1023)<<10;v+=s.charCodeAt(i+1)&1023;cps.push(v);i++}else{cps.push(code)}}return s.codepoints=cps}str.__add__=function(_self,other){if(!$B.$isinstance(other,str)){try{return $B.$getattr(other,"__radd__")(_self)}catch(err){throw _b_.TypeError.$factory("Can't convert "+$B.class_name(other)+" to str implicitly")}}[_self,other]=to_string([_self,other]);var res=$B.String(_self+other);return res};str.__contains__=function(_self,item){if(!$B.$isinstance(item,str)){throw _b_.TypeError.$factory("'in ' requires "+"string as left operand, not "+$B.class_name(item))}[_self,item]=to_string([_self,item]);if(item.__class__===str||$B.$isinstance(item,str)){var nbcar=item.length}else{var nbcar=_b_.len(item)}if(nbcar==0){return true}var len=_self.length;if(len==0){return nbcar==0}for(var i=0,len=_self.length;i=0&&pos=65536){return $B.String(_self.substr(jspos,2))}else{return _self[jspos]}}throw _b_.IndexError.$factory("string index out of range")}if($B.$isinstance(arg,_b_.slice)){return _b_.str.$getitem_slice(_self,arg)}if($B.$isinstance(arg,_b_.bool)){return _self.__getitem__(_b_.int.$factory(arg))}throw _b_.TypeError.$factory("string indices must be integers")};str.$getitem_slice=function(_self,slice){var len=str.__len__(_self),s=_b_.slice.$conv_for_seq(slice,len),start=pypos2jspos(_self,s.start),stop=pypos2jspos(_self,s.stop),step=s.step;var res="",i=null;if(step>0){if(stop<=start){return""}for(var i=start;i=start){return""}for(var i=start;i>stop;i+=step){res+=_self[i]}}return $B.String(res)};var prefix=2,suffix=3,mask=2**32-1;str.$nb_str_hash_cache=0;function fnv(p){if(p.length==0){return 0}var x=prefix;x=(x^p[0]<<7)&mask;for(var i=0,len=p.length;imax_precision){throw _b_.OverflowError.$factory("precision too large")}var s;if(val.__class__===$B.long_int){s=$B.long_int.to_base(val,10)}else{s=val.toString()}if(precision-s.length>max_repeat){throw _b_.OverflowError.$factory("precision too large")}if(s[0]==="-"){return"-"+"0".repeat(Math.max(0,precision-s.length+1))+s.slice(1)}return"0".repeat(Math.max(0,precision-s.length))+s};var format_float_precision=function(val,upper,flags,modifier){var precision=flags.precision;if(isFinite(val)){return modifier(val,precision,flags,upper)}if(val===Infinity){val="inf"}else if(val===-Infinity){val="-inf"}else{val="nan"}if(upper){return val.toUpperCase()}return val};var format_sign=function(val,flags){if(flags.sign){if(val>=0||isNaN(val)||val===Number.POSITIVE_INFINITY){return"+"}}else if(flags.space){if(val>=0||isNaN(val)){return" "}}return""};var str_format=function(val,flags){flags.pad_char=" ";return format_padding(str.$factory(val),flags)};var num_format=function(val,flags){number_check(val,flags);if($B.$isinstance(val,_b_.float)){val=parseInt(val.value)}else if(!$B.$isinstance(val,_b_.int)){val=parseInt(val)}var s=format_int_precision(val,flags);if(flags.pad_char==="0"){if(val<0){s=s.substring(1);return"-"+format_padding(s,flags,true)}var sign=format_sign(val,flags);if(sign!==""){return sign+format_padding(s,flags,true)}}return format_padding(format_sign(val,flags)+s,flags)};var repr_format=function(val,flags){flags.pad_char=" ";return format_padding(_b_.repr(val),flags)};var ascii_format=function(val,flags,type){flags.pad_char=" ";var ascii;if(type=="bytes"){var repr=_b_.repr(val);ascii=_b_.str.encode(repr,"ascii","backslashreplace");ascii=_b_.bytes.decode(ascii,"ascii")}else{ascii=_b_.ascii(val)}return format_padding(ascii,flags)};var _float_helper=function(val,flags){number_check(val,flags);if(flags.precision===undefined){if(!flags.decimal_point){flags.precision=6}else{flags.precision=0}}else{flags.precision=parseInt(flags.precision,10);validate_precision(flags.precision)}return $B.$isinstance(val,_b_.int)?val:val.value};var trailing_zeros=/(.*?)(0+)([eE].*)/,leading_zeros=/\.(0*)/,trailing_dot=/\.$/;var validate_precision=function(precision){if(precision>20){precision=20}};function handle_special_values(value,upper){var special;if(isNaN(value)){special=upper?"NAN":"nan"}else if(value==Number.POSITIVE_INFINITY){special=upper?"INF":"inf"}else if(value==Number.NEGATIVE_INFINITY){special=upper?"-INF":"-inf"}return special}var floating_point_format=function(val,upper,flags){val=_float_helper(val,flags);var special=handle_special_values(val,upper);if(special){return format_padding(format_sign(val,flags)+special,flags)}var p=flags.precision;if(p==0){p=1}var exp_format=val.toExponential(p-1),e_index=exp_format.indexOf("e"),exp=parseInt(exp_format.substr(e_index+1)),res;function remove_zeros(v){if(flags.alternate){return v}if(v.indexOf(".")>-1){while(v.endsWith("0")){v=v.substr(0,v.length-1)}if(v.endsWith(".")){v=v.substr(0,v.length-1)}}return v}if(-4<=exp&&exp-1){return BigInt(v).toString()}const mul=Math.pow(10,d);var is_neg=v<0;if(is_neg){v=-v}var res_floor=(Math.floor(v*mul)/mul).toFixed(d),res_ceil=(Math.ceil(v*mul)/mul).toFixed(d),res;if(v-res_floor==res_ceil-v){var last=res_floor[res_floor.length-1];res=last.match(/[02468]/)?res_floor:res_ceil}else{res=v-res_floor1){mant+="."+parts[0].substr(1)+(parts[1]||"")}else if(parts[1]){mant+="."+parts[1]}}mant=parseFloat(mant);mant=roundDownToFixed(parseFloat(mant),precision);if(parseFloat(mant)==10){parts=mant.split(".");parts[0]="1";mant=parts.join(".");exp=parseInt(exp)+1}if(flags.alternate&&mant.indexOf(".")==-1){mant+="."}if(exp.toString().length==1){exp="0"+exp}return`${is_neg?"-":""}${mant}${upper?"E":"e"}${exp_sign}${exp}`};var floating_point_exponential_format=function(val,upper,flags){val=_float_helper(val,flags);return format_padding(format_sign(val,flags)+format_float_precision(val,upper,flags,_floating_exp_helper),flags)};$B.formatters={floating_point_format:floating_point_format,floating_point_decimal_format:floating_point_decimal_format,floating_point_exponential_format:floating_point_exponential_format};var signed_hex_format=function(val,upper,flags){var ret;if(!$B.$isinstance(val,_b_.int)){throw _b_.TypeError.$factory(`%X format: an integer is required, not ${$B.class_name(val)}`)}if(val.__class__===$B.long_int){ret=val.value.toString(16)}else{ret=parseInt(val);ret=ret.toString(16)}ret=format_int_precision(ret,flags);if(upper){ret=ret.toUpperCase()}if(flags.pad_char==="0"){if(val<0){ret=ret.substring(1);ret="-"+format_padding(ret,flags,true)}var sign=format_sign(val,flags);if(sign!==""){ret=sign+format_padding(ret,flags,true)}}if(flags.alternate){if(ret.charAt(0)==="-"){if(upper){ret="-0X"+ret.slice(1)}else{ret="-0x"+ret.slice(1)}}else{if(upper){ret="0X"+ret}else{ret="0x"+ret}}}return format_padding(format_sign(val,flags)+ret,flags)};var octal_format=function(val,flags){number_check(val,flags);var ret;if(val.__class__===$B.long_int){ret=$B.long_int.to_base(8)}else{ret=parseInt(val);ret=ret.toString(8)}ret=format_int_precision(ret,flags);if(flags.pad_char==="0"){if(val<0){ret=ret.substring(1);ret="-"+format_padding(ret,flags,true)}var sign=format_sign(val,flags);if(sign!==""){ret=sign+format_padding(ret,flags,true)}}if(flags.alternate){if(ret.charAt(0)==="-"){ret="-0o"+ret.slice(1)}else{ret="0o"+ret}}return format_padding(ret,flags)};function series_of_bytes(val,flags){if(val.__class__&&val.__class__.$buffer_protocol){var it=_b_.iter(val),ints=[];while(true){try{ints.push(_b_.next(it))}catch(err){if(err.__class__===_b_.StopIteration){var b=_b_.bytes.$factory(ints);return format_padding(_b_.bytes.decode(b,"ascii"),flags)}throw err}}}else{try{var bytes_obj=$B.$getattr(val,"__bytes__")();return format_padding(_b_.bytes.decode(bytes_obj),flags)}catch(err){if(err.__class__===_b_.AttributeError){throw _b_.TypeError.$factory("%b does not accept '"+$B.class_name(val)+"'")}throw err}}}var single_char_format=function(val,flags,type){if(type=="bytes"){if($B.$isinstance(val,_b_.int)){if(val.__class__===$B.long_int||val<0||val>255){throw _b_.OverflowError.$factory("%c arg not in range(256)")}}else if($B.$isinstance(val,[_b_.bytes,_b_.bytearray])){if(val.source.length>1){throw _b_.TypeError.$factory("%c requires an integer in range(256) or a single byte")}val=val.source[0]}}else{if($B.$isinstance(val,_b_.str)){if(_b_.str.__len__(val)==1){return val}throw _b_.TypeError.$factory("%c requires int or char")}else if(!$B.$isinstance(val,_b_.int)){throw _b_.TypeError.$factory("%c requires int or char")}if(val.__class__===$B.long_int&&(val.value<0||val.value>=1114112)||(val<0||val>=1114112)){throw _b_.OverflowError.$factory("%c arg not in range(0x110000)")}}return format_padding(_b_.chr(val),flags)};var num_flag=function(c,flags){if(c==="0"&&!flags.padding&&!flags.decimal_point&&!flags.left){flags.pad_char="0";return}if(!flags.decimal_point){flags.padding=(flags.padding||"")+c}else{flags.precision=(flags.precision||"")+c}};var decimal_point_flag=function(val,flags){if(flags.decimal_point){throw new UnsupportedChar}flags.decimal_point=true};var neg_flag=function(val,flags){flags.pad_char=" ";flags.left=true};var space_flag=function(val,flags){flags.space=true};var sign_flag=function(val,flags){flags.sign=true};var alternate_flag=function(val,flags){flags.alternate=true};var char_mapping={b:series_of_bytes,s:str_format,d:num_format,i:num_format,u:num_format,o:octal_format,r:repr_format,a:ascii_format,g:function(val,flags){return floating_point_format(val,false,flags)},G:function(val,flags){return floating_point_format(val,true,flags)},f:function(val,flags){return floating_point_decimal_format(val,false,flags)},F:function(val,flags){return floating_point_decimal_format(val,true,flags)},e:function(val,flags){return floating_point_exponential_format(val,false,flags)},E:function(val,flags){return floating_point_exponential_format(val,true,flags)},x:function(val,flags){return signed_hex_format(val,false,flags)},X:function(val,flags){return signed_hex_format(val,true,flags)},c:single_char_format,0:function(val,flags){return num_flag("0",flags)},1:function(val,flags){return num_flag("1",flags)},2:function(val,flags){return num_flag("2",flags)},3:function(val,flags){return num_flag("3",flags)},4:function(val,flags){return num_flag("4",flags)},5:function(val,flags){return num_flag("5",flags)},6:function(val,flags){return num_flag("6",flags)},7:function(val,flags){return num_flag("7",flags)},8:function(val,flags){return num_flag("8",flags)},9:function(val,flags){return num_flag("9",flags)},"-":neg_flag," ":space_flag,"+":sign_flag,".":decimal_point_flag,"#":alternate_flag};var UnsupportedChar=function(){this.name="UnsupportedChar"};const conversion_flags="#0- +",length_modifiers="hlL",conversion_types="diouxXeEfFgGcrsa";function parse_mod_format(s,type,pos){var flags={pad_char:" "},len=s.length,start_pos=pos,mo;pos++;while(pos-1){flags.conversion_flag=char;if(char=="#"){flags.alternate=true}else if(char=="-"){flags.left=true}else if(char=="+"){flags.sign="+"}else if(char=="0"){flags.pad_char="0"}else if(char==" "){flags.space=true}pos++}else if(char=="*"){flags.padding="*";pos++}else if(mo=/^\d+/.exec(s.substr(pos))){flags.padding=mo[0];pos+=mo[0].length}else if(char=="."){pos++;if(s[pos]=="*"){flags.precision="*";pos++}else if(mo=/^\d+/.exec(s.substr(pos))){flags.precision=mo[0];pos+=mo[0].length}else{flags.precision="0"}}else if(length_modifiers.indexOf(char)>-1){flags.length_modifier=char;pos++}else if(conversion_types.indexOf(char)>-1||char=="b"&&type=="bytes"){if(type=="bytes"){if(char=="s"){char="b"}else if(char=="r"){char="a"}}flags.conversion_type=char;flags.end=pos;flags.string=s.substring(start_pos,pos+1);if(flags.left&&flags.pad_char=="0"){flags.pad_char=" "}return flags}else{throw _b_.ValueError.$factory(`invalid character in format: ${char}`)}}throw _b_.ValueError.$factory("invalid format")}function is_mapping(obj){return _b_.hasattr(obj,"keys")&&_b_.hasattr(obj,"__getitem__")}$B.printf_format=function(s,type,args){var length=s.length,pos=0,argpos=null,getitem;if($B.$isinstance(args,_b_.tuple)){argpos=0}else{getitem=$B.$getattr(args,"__getitem__",_b_.None)}var ret="",nbph=0,pos=0,len=s.length;while(pos1){if(!$B.$isinstance(args,_b_.tuple)&&!is_mapping(args)){throw _b_.TypeError.$factory("not enough arguments for format string")}}var fmt=parse_mod_format(s,type,pos);pos=fmt.end+1;if(fmt.padding=="*"){if(args[argpos]===undefined){throw _b_.ValueError.$factory("no value for field width *")}fmt.padding=args[argpos];argpos++}if(fmt.precision=="*"){if(args[argpos]===undefined){throw _b_.ValueError.$factory("no value for precision *")}fmt.precision=args[argpos];argpos++}var func=char_mapping[fmt.conversion_type],value;if(fmt.mapping_key!==undefined){value=getitem(fmt.mapping_key)}else{if(argpos===null){value=args}else{value=args[argpos];if(value===undefined){throw _b_.TypeError.$factory("not enough arguments for format string")}argpos++}}ret+=func(value,fmt,type)}}if(argpos!==null){if(args.length>argpos){throw _b_.TypeError.$factory("not enough arguments for format string")}else if(args.length=127&&cp<160){cp=cp.toString(16);if(cp.length<2){cp="0"+cp}repl+="\\x"+cp}else if(cp>=768&&cp<=879){repl+=""+chars[i]+" "}else if(cp.toString(16)=="feff"){repl+="\\ufeff"}else{repl+=chars[i]}}var res=repl;if(res.search('"')==-1&&res.search("'")==-1){return"'"+res+"'"}else if(_self.search('"')==-1){return'"'+res+'"'}var qesc=new RegExp("'","g");res="'"+res.replace(qesc,"\\'")+"'";return res};str.__rmod__=function(){var $=$B.args("__rmod__",2,{self:null,other:null},["self","other"],arguments,{},null,null);if(!$B.$isinstance($.other,str)){return _b_.NotImplemented}return str.__mod__($.other,$.self)};str.__rmul__=function(_self,other){_self=to_string(_self);if($B.$isinstance(other,_b_.int)){other=_b_.int.numerator(other);var res="";while(other>0){res+=_self;other--}return res}return _b_.NotImplemented};str.__setattr__=function(_self,attr,value){if(typeof _self==="string"){if(str.hasOwnProperty(attr)){throw _b_.AttributeError.$factory("'str' object attribute '"+attr+"' is read-only")}else{throw _b_.AttributeError.$factory("'str' object has no attribute '"+attr+"'")}}_b_.dict.$setitem(_self.__dict__,attr,value);return _b_.None};str.__setitem__=function(self,attr,value){throw _b_.TypeError.$factory("'str' object does not support item assignment")};var combining=[];for(var cp=768;cp<=879;cp++){combining.push(String.fromCharCode(cp))}var combining_re=new RegExp("("+combining.join("|")+")","g");str.__str__=function(_self){_self=to_string(_self);var repl="",chars=to_chars(_self);if(chars.length==_self.length){return _self.replace(combining_re,"$1")}for(var i=0;i=768&&cp<=879){repl+=""+chars[i]}else{repl+=chars[i]}}return repl};var body=`var _b_ = __BRYTHON__.builtins\nif(typeof other !== typeof _self){\n return _b_.NotImplemented}else if(typeof _self == "string"){\n return _self > other}else{\n return _self.$brython_value > other.$brython_value}`;var comps={">":"gt",">=":"ge","<":"lt","<=":"le"};for(var op in comps){str[`__${comps[op]}__`]=Function("_self","other",body.replace(/>/gm,op))}str.capitalize=function(){var $=$B.args("capitalize",1,{self:self},["self"],arguments,{},null,null),_self=to_string($.self);if(_self.length==0){return""}return _self.charAt(0).toUpperCase()+_self.substr(1).toLowerCase()};str.casefold=function(){var $=$B.args("casefold",1,{self:self},["self"],arguments,{},null,null),res="",char,cf,_self=to_string($.self),chars=to_chars(_self);for(var i=0,len=chars.length;i=0){n++;pos+=sub.length}else{break}}return n};str.encode=function(){var $=$B.args("encode",3,{self:null,encoding:null,errors:null},["self","encoding","errors"],arguments,{encoding:"utf-8",errors:"strict"},null,null),_self=to_string($.self);if($.encoding=="rot13"||$.encoding=="rot_13"){var res="";for(var i=0,len=_self.length;i0){res+=" ";col++}break;case"\r":case"\n":res+=car;col=0;break;default:res+=car;col++;break}pos++}return res};str.find=function(){var $=$B.args("str.find",4,{self:null,sub:null,start:null,end:null},["self","sub","start","end"],arguments,{start:0,end:null},null,null),_self,sub;check_str($.sub);normalize_start_end($);[_self,sub]=to_string([$.self,$.sub]);var len=str.__len__(_self),sub_len=str.__len__(sub);if(sub_len==0&&$.start==len){return len}if(len+sub_len==0){return-1}var js_start=pypos2jspos(_self,$.start),js_end=pypos2jspos(_self,$.end),ix=_self.slice(js_start,js_end).indexOf(sub);if(ix==-1){return-1}return jspos2pypos(_self,js_start+ix)};$B.parse_format=function(fmt_string){var elts=fmt_string.split(":"),name,conv,spec,name_ext=[];if(elts.length==1){name=fmt_string}else{name=elts[0];spec=elts.splice(1).join(":")}var elts=name.split("!");if(elts.length>1){name=elts[0];conv=elts[1]}if(name!==undefined){function name_repl(match){name_ext.push(match);return""}var name_ext_re=/\.[_a-zA-Z][_a-zA-Z0-9]*|\[[_a-zA-Z][_a-zA-Z0-9]*\]|\[[0-9]+\]/g;name=name.replace(name_ext_re,name_repl)}return{name:name,name_ext:name_ext,conv:conv,spec:spec||"",string:fmt_string}};$B.split_format=function(s){var pos=0,_len=s.length,car,text="",parts=[],rank=0;while(pos<_len){car=s.charAt(pos);if(car=="{"&&s.charAt(pos+1)=="{"){text+="{";pos+=2}else if(car=="}"&&s.charAt(pos+1)=="}"){text+="}";pos+=2}else if(car=="{"){parts.push(text);var end=pos+1,nb=1;while(end<_len){if(s.charAt(end)=="{"){nb++;end++}else if(s.charAt(end)=="}"){nb--;end++;if(nb==0){var fmt_string=s.substring(pos+1,end-1);var fmt_obj=$B.parse_format(fmt_string);fmt_obj.raw_name=fmt_obj.name;fmt_obj.raw_spec=fmt_obj.spec;if(!fmt_obj.name){fmt_obj.name=rank+"";rank++}if(fmt_obj.spec!==undefined){function replace_nested(name,key){if(key==""){return"{"+rank+++"}"}return"{"+key+"}"}fmt_obj.spec=fmt_obj.spec.replace(/\{(.*?)\}/g,replace_nested)}parts.push(fmt_obj);text="";break}}else{end++}}if(nb>0){throw _b_.ValueError.$factory("wrong format "+s)}pos=end}else{text+=car;pos++}}if(text){parts.push(text)}return parts};str.format=function(_self){var last_arg=$B.last(arguments);if(last_arg.$nat=="mapping"){var mapping=last_arg.mapping,getitem=$B.$getattr(mapping,"__getitem__");var args=[];for(var i=0,len=arguments.length-1;i-1){var pos=parseInt(fmt.name),value=_b_.tuple.__getitem__($.$args,pos)}else{var value=getitem(fmt.name)}for(var j=0;j-1){key=parseInt(key)}value=$B.$getattr(value,"__getitem__")(key)}}if(fmt.conv=="a"){value=_b_.ascii(value)}else if(fmt.conv=="r"){value=_b_.repr(value)}else if(fmt.conv=="s"){value=_b_.str.$factory(value)}if(value.$is_class||value.$factory){res+=value.__class__.__format__(value,fmt.spec)}else{res+=$B.$getattr(value,"__format__")(fmt.spec)}}return res};str.format_map=function(){var $=$B.args("format_map",2,{self:null,mapping:null},["self","mapping"],arguments,{},null,null),_self=to_string($.self);return str.format(_self,{$nat:"mapping",mapping:$.mapping})};str.index=function(self){var res=str.find.apply(null,arguments);if(res===-1){throw _b_.ValueError.$factory("substring not found")}return res};str.isascii=function(){var $=$B.args("isascii",1,{self:null},["self"],arguments,{},null,null),_self=to_string($.self);for(var i=0,len=_self.length;i127){return false}}return true};str.isalnum=function(){var $=$B.args("isalnum",1,{self:null},["self"],arguments,{},null,null),cp,_self=to_string($.self);for(var char of _self){cp=_b_.ord(char);for(var cat of["Ll","Lu","Lm","Lt","Lo","Nd","digits","numeric"]){if(!$B.in_unicode_category(cat,cp)){return false}}}return true};str.isalpha=function(){var $=$B.args("isalpha",1,{self:null},["self"],arguments,{},null,null),cp,_self=to_string($.self);for(var char of _self){cp=_b_.ord(char);for(var cat of["Ll","Lu","Lm","Lt","Lo"]){if(!$B.in_unicode_category(cat,cp)){return false}}}return true};str.isdecimal=function(){var $=$B.args("isdecimal",1,{self:null},["self"],arguments,{},null,null),cp,_self=to_string($.self);for(var char of _self){cp=_b_.ord(char);if(!$B.in_unicode_category("Nd",cp)){return false}}return _self.length>0};str.isdigit=function(){var $=$B.args("isdigit",1,{self:null},["self"],arguments,{},null,null),cp,_self=to_string($.self);for(var char of _self){if(/\p{Nd}/u.test(char)){continue}cp=_b_.ord(char);if(!$B.in_unicode_category("No_digits",cp)){return false}}return _self.length>0};str.isidentifier=function(){var $=$B.args("isidentifier",1,{self:null},["self"],arguments,{},null,null),_self=to_string($.self);if(_self.length==0){return false}var chars=to_chars(_self);if(!$B.is_XID_Start(_b_.ord(chars[0]))){return false}else{for(var char of chars){var cp=_b_.ord(char);if(!$B.is_XID_Continue(cp)){return false}}}return true};str.islower=function(){var $=$B.args("islower",1,{self:null},["self"],arguments,{},null,null),has_cased=false,cp,_self=to_string($.self);for(var char of _self){cp=_b_.ord(char);if($B.in_unicode_category("Ll",cp)){has_cased=true;continue}else if($B.in_unicode_category("Lu",cp)||$B.in_unicode_category("Lt",cp)){return false}}return has_cased};const numeric_re=/\p{Nd}|\p{Nl}|\p{No}/u;str.isnumeric=function(){var $=$B.args("isnumeric",1,{self:null},["self"],arguments,{},null,null),_self=to_string($.self);for(var char of _self){if(!numeric_re.test(char)&&!$B.in_unicode_category("Lo_numeric",_b_.ord(char))){return false}}return _self.length>0};var unprintable_re=/\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}|\p{Zl}|\p{Zp}|\p{Zs}/u;str.isprintable=function(){var $=$B.args("isprintable",1,{self:null},["self"],arguments,{},null,null),_self=to_string($.self);for(var char of _self){if(char==" "){continue}if(unprintable_re.test(char)){return false}}return true};str.isspace=function(self){var $=$B.args("isspace",1,{self:null},["self"],arguments,{},null,null),cp,_self=to_string($.self);for(var char of _self){cp=_b_.ord(char);if(!$B.in_unicode_category("Zs",cp)&&$B.unicode_bidi_whitespace.indexOf(cp)==-1){return false}}return _self.length>0};str.istitle=function(self){var $=$B.args("istitle",1,{self:null},["self"],arguments,{},null,null),_self=to_string($.self);return _self.length>0&&str.title(_self)==_self};str.isupper=function(self){var $=$B.args("islower",1,{self:null},["self"],arguments,{},null,null),is_upper=false,cp,_self=to_string(self);for(var char of _self){cp=_b_.ord(char);if($B.in_unicode_category("Lu",cp)){is_upper=true;continue}else if($B.in_unicode_category("Ll",cp)||$B.in_unicode_category("Lt",cp)){return false}}return is_upper};str.join=function(){var $=$B.args("join",2,{self:null,iterable:null},["self","iterable"],arguments,{},null,null),_self=to_string($.self);var iterable=_b_.iter($.iterable),res=[],count=0;while(1){try{var obj2=_b_.next(iterable);if(!$B.$isinstance(obj2,str)){throw _b_.TypeError.$factory("sequence item "+count+": expected str instance, "+$B.class_name(obj2)+" found")}res.push(obj2)}catch(err){if($B.$isinstance(err,_b_.StopIteration)){break}else{throw err}}}return res.join(_self)};str.ljust=function(self){var $=$B.args("ljust",3,{self:null,width:null,fillchar:null},["self","width","fillchar"],arguments,{fillchar:" "},null,null),_self=to_string($.self),len=str.__len__(_self);if($.width<=len){return _self}return _self+$.fillchar.repeat($.width-len)};str.lower=function(self){var $=$B.args("lower",1,{self:null},["self"],arguments,{},null,null),_self=to_string($.self);return _self.toLowerCase()};str.lstrip=function(self,x){var $=$B.args("lstrip",2,{self:null,chars:null},["self","chars"],arguments,{chars:_b_.None},null,null),_self=$.self,chars=$.chars;if(chars===_b_.None){return self.trimStart()}[_self,chars]=to_string([_self,chars]);while(_self.length>0){var flag=false;for(var char of chars){if(_self.startsWith(char)){_self=_self.substr(char.length);flag=true;break}}if(!flag){return $.self.surrogates?$B.String(_self):_self}}return""};str.maketrans=function(){var $=$B.args("maketrans",3,{x:null,y:null,z:null},["x","y","z"],arguments,{y:null,z:null},null,null);var _t=$B.empty_dict();if($.y===null&&$.z===null){if(!$B.$isinstance($.x,_b_.dict)){throw _b_.TypeError.$factory("maketrans only argument must be a dict")}var items=_b_.list.$factory(_b_.dict.items($.x));for(var i=0,len=items.length;i