create-prisma-php-app 4.1.0-alpha.22 → 4.1.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/js/pp-reactive-v1.js +20 -20
- package/package.json +1 -1
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var Ht=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],at=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],Ut="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",ot="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Fe={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Ve="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",Xt={5:Ve,"5module":Ve+" export import",6:Ve+" const class extends export import super"},qt=/^in(stanceof)?$/,zt=new RegExp("["+ot+"]"),Kt=new RegExp("["+ot+Ut+"]");function Be(s,e){for(var t=65536,n=0;n<e.length;n+=2){if(t+=e[n],t>s)return!1;if(t+=e[n+1],t>=s)return!0}return!1}function Y(s,e){return s<65?s===36:s<91?!0:s<97?s===95:s<123?!0:s<=65535?s>=170&&zt.test(String.fromCharCode(s)):e===!1?!1:Be(s,at)}function ae(s,e){return s<48?s===36:s<58?!0:s<65?!1:s<91?!0:s<97?s===95:s<123?!0:s<=65535?s>=170&&Kt.test(String.fromCharCode(s)):e===!1?!1:Be(s,at)||Be(s,Ht)}var _=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function
|
|
2
|
-
Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),e.allowReserved==null&&(e.allowReserved=e.ecmaVersion<5),(!s||s.allowHashBang==null)&&(e.allowHashBang=e.ecmaVersion>=14),et(e.onToken)){var n=e.onToken;e.onToken=function(i){return n.push(i)}}return et(e.onComment)&&(e.onComment=es(e,e.onComment)),e}function es(s,e){return function(t,n,i,r,a,o){var c={type:t?"Block":"Line",value:n,start:i,end:r};s.locations&&(c.loc=new ke(this,a,o)),s.ranges&&(c.range=[i,r]),e.push(c)}}var Se=1,
|
|
3
|
-
`,n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split($).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=u.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(Se),this.regexpState=null,this.privateNameStack=[]},J={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};M.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};J.inFunction.get=function(){return(this.currentVarScope().flags&Ce)>0};J.inGenerator.get=function(){return(this.currentVarScope().flags&ht)>0};J.inAsync.get=function(){return(this.currentVarScope().flags&qe)>0};J.canAwait.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(le|Te))return!1;if(t&Ce)return(t&qe)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};J.allowSuper.get=function(){var s=this.currentThisScope(),e=s.flags;return(e&Ie)>0||this.options.allowSuperOutsideMethod};J.allowDirectSuper.get=function(){return(this.currentThisScope().flags&dt)>0};J.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};J.allowNewDotTarget.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(le|Te)||t&Ce&&!(t&ze))return!0}return!1};J.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&le)>0};M.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,i=0;i<e.length;i++)n=e[i](n);return n};M.parse=function(e,t){return new this(t,e).parse()};M.parseExpressionAt=function(e,t,n){var i=new this(n,e,t);return i.nextToken(),i.parseExpression()};M.tokenizer=function(e,t){return new this(t,e)};Object.defineProperties(M.prototype,J);var F=M.prototype,ts=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;F.strictDirective=function(s){if(this.options.ecmaVersion<5)return!1;for(;;){O.lastIndex=s,s+=O.exec(this.input)[0].length;var e=ts.exec(this.input.slice(s));if(!e)return!1;if((e[1]||e[2])==="use strict"){O.lastIndex=s+e[0].length;var t=O.exec(this.input),n=t.index+t[0].length,i=this.input.charAt(n);return i===";"||i==="}"||$.test(t[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i==="!"&&this.input.charAt(n+1)==="=")}s+=e[0].length,O.lastIndex=s,s+=O.exec(this.input)[0].length,this.input[s]===";"&&s++}};F.eat=function(s){return this.type===s?(this.next(),!0):!1};F.isContextual=function(s){return this.type===u.name&&this.value===s&&!this.containsEsc};F.eatContextual=function(s){return this.isContextual(s)?(this.next(),!0):!1};F.expectContextual=function(s){this.eatContextual(s)||this.unexpected()};F.canInsertSemicolon=function(){return this.type===u.eof||this.type===u.braceR||$.test(this.input.slice(this.lastTokEnd,this.start))};F.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};F.semicolon=function(){!this.eat(u.semi)&&!this.insertSemicolon()&&this.unexpected()};F.afterTrailingComma=function(s,e){if(this.type===s)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};F.expect=function(s){this.eat(s)||this.unexpected()};F.unexpected=function(s){this.raise(s??this.start,"Unexpected token")};var Oe=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};F.checkPatternErrors=function(s,e){if(s){s.trailingComma>-1&&this.raiseRecoverable(s.trailingComma,"Comma is not permitted after the rest element");var t=e?s.parenthesizedAssign:s.parenthesizedBind;t>-1&&this.raiseRecoverable(t,e?"Assigning to rvalue":"Parenthesized pattern")}};F.checkExpressionErrors=function(s,e){if(!s)return!1;var t=s.shorthandAssign,n=s.doubleProto;if(!e)return t>=0||n>=0;t>=0&&this.raise(t,"Shorthand property assignments are valid only in destructuring patterns"),n>=0&&this.raiseRecoverable(n,"Redefinition of __proto__ property")};F.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};F.isSimpleAssignTarget=function(s){return s.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(s.expression):s.type==="Identifier"||s.type==="MemberExpression"};var v=M.prototype;v.parseTopLevel=function(s){var e=Object.create(null);for(s.body||(s.body=[]);this.type!==u.eof;){var t=this.parseStatement(null,!0,e);s.body.push(t)}if(this.inModule)for(var n=0,i=Object.keys(this.undefinedExports);n<i.length;n+=1){var r=i[n];this.raiseRecoverable(this.undefinedExports[r].start,"Export '"+r+"' is not defined")}return this.adaptDirectivePrologue(s.body),this.next(),s.sourceType=this.options.sourceType,this.finishNode(s,"Program")};var Qe={kind:"loop"},ss={kind:"switch"};v.isLet=function(s){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;O.lastIndex=this.pos;var e=O.exec(this.input),t=this.pos+e[0].length,n=this.input.charCodeAt(t);if(n===91||n===92)return!0;if(s)return!1;if(n===123||n>55295&&n<56320)return!0;if(Y(n,!0)){for(var i=t+1;ae(n=this.input.charCodeAt(i),!0);)++i;if(n===92||n>55295&&n<56320)return!0;var r=this.input.slice(t,i);if(!qt.test(r))return!0}return!1};v.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;O.lastIndex=this.pos;var s=O.exec(this.input),e=this.pos+s[0].length,t;return!$.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(ae(t=this.input.charCodeAt(e+8))||t>55295&&t<56320))};v.isUsingKeyword=function(s,e){if(this.options.ecmaVersion<17||!this.isContextual(s?"await":"using"))return!1;O.lastIndex=this.pos;var t=O.exec(this.input),n=this.pos+t[0].length;if($.test(this.input.slice(this.pos,n)))return!1;if(s){var i=n+5,r;if(this.input.slice(n,i)!=="using"||i===this.input.length||ae(r=this.input.charCodeAt(i))||r>55295&&r<56320)return!1;O.lastIndex=i;var a=O.exec(this.input);if(a&&$.test(this.input.slice(i,i+a[0].length)))return!1}if(e){var o=n+2,c;if(this.input.slice(n,o)==="of"&&(o===this.input.length||!ae(c=this.input.charCodeAt(o))&&!(c>55295&&c<56320)))return!1}var l=this.input.charCodeAt(n);return Y(l,!0)||l===92};v.isAwaitUsing=function(s){return this.isUsingKeyword(!0,s)};v.isUsing=function(s){return this.isUsingKeyword(!1,s)};v.parseStatement=function(s,e,t){var n=this.type,i=this.startNode(),r;switch(this.isLet(s)&&(n=u._var,r="let"),n){case u._break:case u._continue:return this.parseBreakContinueStatement(i,n.keyword);case u._debugger:return this.parseDebuggerStatement(i);case u._do:return this.parseDoStatement(i);case u._for:return this.parseForStatement(i);case u._function:return s&&(this.strict||s!=="if"&&s!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!s);case u._class:return s&&this.unexpected(),this.parseClass(i,!0);case u._if:return this.parseIfStatement(i);case u._return:return this.parseReturnStatement(i);case u._switch:return this.parseSwitchStatement(i);case u._throw:return this.parseThrowStatement(i);case u._try:return this.parseTryStatement(i);case u._const:case u._var:return r=r||this.value,s&&r!=="var"&&this.unexpected(),this.parseVarStatement(i,r);case u._while:return this.parseWhileStatement(i);case u._with:return this.parseWithStatement(i);case u.braceL:return this.parseBlock(!0,i);case u.semi:return this.parseEmptyStatement(i);case u._export:case u._import:if(this.options.ecmaVersion>10&&n===u._import){O.lastIndex=this.pos;var a=O.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),n===u._import?this.parseImport(i):this.parseExport(i,t);default:if(this.isAsyncFunction())return s&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!s);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return e&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),l==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,"VariableDeclaration");var p=this.value,h=this.parseExpression();return n===u.name&&h.type==="Identifier"&&this.eat(u.colon)?this.parseLabeledStatement(i,p,h,s):this.parseExpressionStatement(i,h)}};v.parseBreakContinueStatement=function(s,e){var t=e==="break";this.next(),this.eat(u.semi)||this.insertSemicolon()?s.label=null:this.type!==u.name?this.unexpected():(s.label=this.parseIdent(),this.semicolon());for(var n=0;n<this.labels.length;++n){var i=this.labels[n];if((s.label==null||i.name===s.label.name)&&(i.kind!=null&&(t||i.kind==="loop")||s.label&&t))break}return n===this.labels.length&&this.raise(s.start,"Unsyntactic "+e),this.finishNode(s,t?"BreakStatement":"ContinueStatement")};v.parseDebuggerStatement=function(s){return this.next(),this.semicolon(),this.finishNode(s,"DebuggerStatement")};v.parseDoStatement=function(s){return this.next(),this.labels.push(Qe),s.body=this.parseStatement("do"),this.labels.pop(),this.expect(u._while),s.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(u.semi):this.semicolon(),this.finishNode(s,"DoWhileStatement")};v.parseForStatement=function(s){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Qe),this.enterScope(0),this.expect(u.parenL),this.type===u.semi)return e>-1&&this.unexpected(e),this.parseFor(s,null);var t=this.isLet();if(this.type===u._var||this.type===u._const||t){var n=this.startNode(),i=t?"let":this.value;return this.next(),this.parseVar(n,!0,i),this.finishNode(n,"VariableDeclaration"),this.parseForAfterInit(s,n,e)}var r=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var c=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(c,!0,o),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(s,c,e)}var l=this.containsEsc,p=new Oe,h=this.start,f=e>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===u._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===u._in&&this.unexpected(e),s.await=!0):a&&this.options.ecmaVersion>=8&&(f.start===h&&!l&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(s.await=!1)),r&&a&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,p),this.checkLValPattern(f),this.parseForIn(s,f)):(this.checkExpressionErrors(p,!0),e>-1&&this.unexpected(e),this.parseFor(s,f))};v.parseForAfterInit=function(s,e,t){return(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===u._in?t>-1&&this.unexpected(t):s.await=t>-1),this.parseForIn(s,e)):(t>-1&&this.unexpected(t),this.parseFor(s,e))};v.parseFunctionStatement=function(s,e,t){return this.next(),this.parseFunction(s,ye|(t?0:je),!1,e)};v.parseIfStatement=function(s){return this.next(),s.test=this.parseParenExpression(),s.consequent=this.parseStatement("if"),s.alternate=this.eat(u._else)?this.parseStatement("if"):null,this.finishNode(s,"IfStatement")};v.parseReturnStatement=function(s){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(u.semi)||this.insertSemicolon()?s.argument=null:(s.argument=this.parseExpression(),this.semicolon()),this.finishNode(s,"ReturnStatement")};v.parseSwitchStatement=function(s){this.next(),s.discriminant=this.parseParenExpression(),s.cases=[],this.expect(u.braceL),this.labels.push(ss),this.enterScope(0);for(var e,t=!1;this.type!==u.braceR;)if(this.type===u._case||this.type===u._default){var n=this.type===u._case;e&&this.finishNode(e,"SwitchCase"),s.cases.push(e=this.startNode()),e.consequent=[],this.next(),n?e.test=this.parseExpression():(t&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),t=!0,e.test=null),this.expect(u.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(s,"SwitchStatement")};v.parseThrowStatement=function(s){return this.next(),$.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),s.argument=this.parseExpression(),this.semicolon(),this.finishNode(s,"ThrowStatement")};var ns=[];v.parseCatchClauseParam=function(){var s=this.parseBindingAtom(),e=s.type==="Identifier";return this.enterScope(e?ft:0),this.checkLValPattern(s,e?gt:ie),this.expect(u.parenR),s};v.parseTryStatement=function(s){if(this.next(),s.block=this.parseBlock(),s.handler=null,this.type===u._catch){var e=this.startNode();this.next(),this.eat(u.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),s.handler=this.finishNode(e,"CatchClause")}return s.finalizer=this.eat(u._finally)?this.parseBlock():null,!s.handler&&!s.finalizer&&this.raise(s.start,"Missing catch or finally clause"),this.finishNode(s,"TryStatement")};v.parseVarStatement=function(s,e,t){return this.next(),this.parseVar(s,!1,e,t),this.semicolon(),this.finishNode(s,"VariableDeclaration")};v.parseWhileStatement=function(s){return this.next(),s.test=this.parseParenExpression(),this.labels.push(Qe),s.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(s,"WhileStatement")};v.parseWithStatement=function(s){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),s.object=this.parseParenExpression(),s.body=this.parseStatement("with"),this.finishNode(s,"WithStatement")};v.parseEmptyStatement=function(s){return this.next(),this.finishNode(s,"EmptyStatement")};v.parseLabeledStatement=function(s,e,t,n){for(var i=0,r=this.labels;i<r.length;i+=1){var a=r[i];a.name===e&&this.raise(t.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===u._switch?"switch":null,c=this.labels.length-1;c>=0;c--){var l=this.labels[c];if(l.statementStart===s.start)l.statementStart=this.start,l.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),s.body=this.parseStatement(n?n.indexOf("label")===-1?n+"label":n:"label"),this.labels.pop(),s.label=t,this.finishNode(s,"LabeledStatement")};v.parseExpressionStatement=function(s,e){return s.expression=e,this.semicolon(),this.finishNode(s,"ExpressionStatement")};v.parseBlock=function(s,e,t){for(s===void 0&&(s=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(u.braceL),s&&this.enterScope(0);this.type!==u.braceR;){var n=this.parseStatement(null);e.body.push(n)}return t&&(this.strict=!1),this.next(),s&&this.exitScope(),this.finishNode(e,"BlockStatement")};v.parseFor=function(s,e){return s.init=e,this.expect(u.semi),s.test=this.type===u.semi?null:this.parseExpression(),this.expect(u.semi),s.update=this.type===u.parenR?null:this.parseExpression(),this.expect(u.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,"ForStatement")};v.parseForIn=function(s,e){var t=this.type===u._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!t||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(t?"for-in":"for-of")+" loop variable declaration may not have an initializer"),s.left=e,s.right=t?this.parseExpression():this.parseMaybeAssign(),this.expect(u.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,t?"ForInStatement":"ForOfStatement")};v.parseVar=function(s,e,t,n){for(s.declarations=[],s.kind=t;;){var i=this.startNode();if(this.parseVarId(i,t),this.eat(u.eq)?i.init=this.parseMaybeAssign(e):!n&&t==="const"&&!(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!n&&(t==="using"||t==="await using")&&this.options.ecmaVersion>=17&&this.type!==u._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+t+" declaration"):!n&&i.id.type!=="Identifier"&&!(e&&(this.type===u._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):i.init=null,s.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(u.comma))break}return s};v.parseVarId=function(s,e){s.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(s.id,e==="var"?Ge:ie,!1)};var ye=1,je=2,Et=4;v.parseFunction=function(s,e,t,n,i){this.initFunction(s),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!n)&&(this.type===u.star&&e&je&&this.unexpected(),s.generator=this.eat(u.star)),this.options.ecmaVersion>=8&&(s.async=!!n),e&ye&&(s.id=e&Et&&this.type!==u.name?null:this.parseIdent(),s.id&&!(e&je)&&this.checkLValSimple(s.id,this.strict||s.generator||s.async?this.treatFunctionsAsVar?Ge:ie:mt));var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ke(s.async,s.generator)),e&ye||(s.id=this.type===u.name?this.parseIdent():null),this.parseFunctionParams(s),this.parseFunctionBody(s,t,!1,i),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(s,e&ye?"FunctionDeclaration":"FunctionExpression")};v.parseFunctionParams=function(s){this.expect(u.parenL),s.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};v.parseClass=function(s,e){this.next();var t=this.strict;this.strict=!0,this.parseClassId(s,e),this.parseClassSuper(s);var n=this.enterClassBody(),i=this.startNode(),r=!1;for(i.body=[],this.expect(u.braceL);this.type!==u.braceR;){var a=this.parseClassElement(s.superClass!==null);a&&(i.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(r&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),r=!0):a.key&&a.key.type==="PrivateIdentifier"&&is(n,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=t,this.next(),s.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(s,e?"ClassDeclaration":"ClassExpression")};v.parseClassElement=function(s){if(this.eat(u.semi))return null;var e=this.options.ecmaVersion,t=this.startNode(),n="",i=!1,r=!1,a="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(u.braceL))return this.parseClassStaticBlock(t),t;this.isClassElementNameStart()||this.type===u.star?o=!0:n="static"}if(t.static=o,!n&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===u.star)&&!this.canInsertSemicolon()?r=!0:n="async"),!n&&(e>=9||!r)&&this.eat(u.star)&&(i=!0),!n&&!r&&!i){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:n=c)}if(n?(t.computed=!1,t.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),t.key.name=n,this.finishNode(t.key,"Identifier")):this.parseClassElementName(t),e<13||this.type===u.parenL||a!=="method"||i||r){var l=!t.static&&we(t,"constructor"),p=l&&s;l&&a!=="method"&&this.raise(t.key.start,"Constructor can't have get/set modifier"),t.kind=l?"constructor":a,this.parseClassMethod(t,i,r,p)}else this.parseClassField(t);return t};v.isClassElementNameStart=function(){return this.type===u.name||this.type===u.privateId||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword};v.parseClassElementName=function(s){this.type===u.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),s.computed=!1,s.key=this.parsePrivateIdent()):this.parsePropertyName(s)};v.parseClassMethod=function(s,e,t,n){var i=s.key;s.kind==="constructor"?(e&&this.raise(i.start,"Constructor can't be a generator"),t&&this.raise(i.start,"Constructor can't be an async method")):s.static&&we(s,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var r=s.value=this.parseMethod(e,t,n);return s.kind==="get"&&r.params.length!==0&&this.raiseRecoverable(r.start,"getter should have no params"),s.kind==="set"&&r.params.length!==1&&this.raiseRecoverable(r.start,"setter should have exactly one param"),s.kind==="set"&&r.params[0].type==="RestElement"&&this.raiseRecoverable(r.params[0].start,"Setter cannot use rest params"),this.finishNode(s,"MethodDefinition")};v.parseClassField=function(s){return we(s,"constructor")?this.raise(s.key.start,"Classes can't have a field named 'constructor'"):s.static&&we(s,"prototype")&&this.raise(s.key.start,"Classes can't have a static field named 'prototype'"),this.eat(u.eq)?(this.enterScope(Te|Ie),s.value=this.parseMaybeAssign(),this.exitScope()):s.value=null,this.semicolon(),this.finishNode(s,"PropertyDefinition")};v.parseClassStaticBlock=function(s){s.body=[];var e=this.labels;for(this.labels=[],this.enterScope(le|Ie);this.type!==u.braceR;){var t=this.parseStatement(null);s.body.push(t)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(s,"StaticBlock")};v.parseClassId=function(s,e){this.type===u.name?(s.id=this.parseIdent(),e&&this.checkLValSimple(s.id,ie,!1)):(e===!0&&this.unexpected(),s.id=null)};v.parseClassSuper=function(s){s.superClass=this.eat(u._extends)?this.parseExprSubscripts(null,!1):null};v.enterClassBody=function(){var s={declared:Object.create(null),used:[]};return this.privateNameStack.push(s),s.declared};v.exitClassBody=function(){var s=this.privateNameStack.pop(),e=s.declared,t=s.used;if(this.options.checkPrivateFields)for(var n=this.privateNameStack.length,i=n===0?null:this.privateNameStack[n-1],r=0;r<t.length;++r){var a=t[r];Ee(e,a.name)||(i?i.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function is(s,e){var t=e.key.name,n=s[t],i="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(i=(e.static?"s":"i")+e.kind),n==="iget"&&i==="iset"||n==="iset"&&i==="iget"||n==="sget"&&i==="sset"||n==="sset"&&i==="sget"?(s[t]="true",!1):n?!0:(s[t]=i,!1)}function we(s,e){var t=s.computed,n=s.key;return!t&&(n.type==="Identifier"&&n.name===e||n.type==="Literal"&&n.value===e)}v.parseExportAllDeclaration=function(s,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(s.exported=this.parseModuleExportName(),this.checkExport(e,s.exported,this.lastTokStart)):s.exported=null),this.expectContextual("from"),this.type!==u.string&&this.unexpected(),s.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ExportAllDeclaration")};v.parseExport=function(s,e){if(this.next(),this.eat(u.star))return this.parseExportAllDeclaration(s,e);if(this.eat(u._default))return this.checkExport(e,"default",this.lastTokStart),s.declaration=this.parseExportDefaultDeclaration(),this.finishNode(s,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())s.declaration=this.parseExportDeclaration(s),s.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,s.declaration.declarations):this.checkExport(e,s.declaration.id,s.declaration.id.start),s.specifiers=[],s.source=null,this.options.ecmaVersion>=16&&(s.attributes=[]);else{if(s.declaration=null,s.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==u.string&&this.unexpected(),s.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause());else{for(var t=0,n=s.specifiers;t<n.length;t+=1){var i=n[t];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type==="Literal"&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}s.source=null,this.options.ecmaVersion>=16&&(s.attributes=[])}this.semicolon()}return this.finishNode(s,"ExportNamedDeclaration")};v.parseExportDeclaration=function(s){return this.parseStatement(null)};v.parseExportDefaultDeclaration=function(){var s;if(this.type===u._function||(s=this.isAsyncFunction())){var e=this.startNode();return this.next(),s&&this.next(),this.parseFunction(e,ye|Et,!1,s)}else if(this.type===u._class){var t=this.startNode();return this.parseClass(t,"nullableID")}else{var n=this.parseMaybeAssign();return this.semicolon(),n}};v.checkExport=function(s,e,t){s&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),Ee(s,e)&&this.raiseRecoverable(t,"Duplicate export '"+e+"'"),s[e]=!0)};v.checkPatternExport=function(s,e){var t=e.type;if(t==="Identifier")this.checkExport(s,e,e.start);else if(t==="ObjectPattern")for(var n=0,i=e.properties;n<i.length;n+=1){var r=i[n];this.checkPatternExport(s,r)}else if(t==="ArrayPattern")for(var a=0,o=e.elements;a<o.length;a+=1){var c=o[a];c&&this.checkPatternExport(s,c)}else t==="Property"?this.checkPatternExport(s,e.value):t==="AssignmentPattern"?this.checkPatternExport(s,e.left):t==="RestElement"&&this.checkPatternExport(s,e.argument)};v.checkVariableExport=function(s,e){if(s)for(var t=0,n=e;t<n.length;t+=1){var i=n[t];this.checkPatternExport(s,i.id)}};v.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};v.parseExportSpecifier=function(s){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(s,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};v.parseExportSpecifiers=function(s){var e=[],t=!0;for(this.expect(u.braceL);!this.eat(u.braceR);){if(t)t=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;e.push(this.parseExportSpecifier(s))}return e};v.parseImport=function(s){return this.next(),this.type===u.string?(s.specifiers=ns,s.source=this.parseExprAtom()):(s.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),s.source=this.type===u.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ImportDeclaration")};v.parseImportSpecifier=function(){var s=this.startNode();return s.imported=this.parseModuleExportName(),this.eatContextual("as")?s.local=this.parseIdent():(this.checkUnreserved(s.imported),s.local=s.imported),this.checkLValSimple(s.local,ie),this.finishNode(s,"ImportSpecifier")};v.parseImportDefaultSpecifier=function(){var s=this.startNode();return s.local=this.parseIdent(),this.checkLValSimple(s.local,ie),this.finishNode(s,"ImportDefaultSpecifier")};v.parseImportNamespaceSpecifier=function(){var s=this.startNode();return this.next(),this.expectContextual("as"),s.local=this.parseIdent(),this.checkLValSimple(s.local,ie),this.finishNode(s,"ImportNamespaceSpecifier")};v.parseImportSpecifiers=function(){var s=[],e=!0;if(this.type===u.name&&(s.push(this.parseImportDefaultSpecifier()),!this.eat(u.comma)))return s;if(this.type===u.star)return s.push(this.parseImportNamespaceSpecifier()),s;for(this.expect(u.braceL);!this.eat(u.braceR);){if(e)e=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;s.push(this.parseImportSpecifier())}return s};v.parseWithClause=function(){var s=[];if(!this.eat(u._with))return s;this.expect(u.braceL);for(var e={},t=!0;!this.eat(u.braceR);){if(t)t=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;var n=this.parseImportAttribute(),i=n.key.type==="Identifier"?n.key.name:n.key.value;Ee(e,i)&&this.raiseRecoverable(n.key.start,"Duplicate attribute key '"+i+"'"),e[i]=!0,s.push(n)}return s};v.parseImportAttribute=function(){var s=this.startNode();return s.key=this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(u.colon),this.type!==u.string&&this.unexpected(),s.value=this.parseExprAtom(),this.finishNode(s,"ImportAttribute")};v.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===u.string){var s=this.parseLiteral(this.value);return Yt.test(s.value)&&this.raise(s.start,"An export name cannot include a lone surrogate."),s}return this.parseIdent(!0)};v.adaptDirectivePrologue=function(s){for(var e=0;e<s.length&&this.isDirectiveCandidate(s[e]);++e)s[e].directive=s[e].expression.raw.slice(1,-1)};v.isDirectiveCandidate=function(s){return this.options.ecmaVersion>=5&&s.type==="ExpressionStatement"&&s.expression.type==="Literal"&&typeof s.expression.value=="string"&&(this.input[s.start]==='"'||this.input[s.start]==="'")};var K=M.prototype;K.toAssignable=function(s,e,t){if(this.options.ecmaVersion>=6&&s)switch(s.type){case"Identifier":this.inAsync&&s.name==="await"&&this.raise(s.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":s.type="ObjectPattern",t&&this.checkPatternErrors(t,!0);for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];this.toAssignable(r,e),r.type==="RestElement"&&(r.argument.type==="ArrayPattern"||r.argument.type==="ObjectPattern")&&this.raise(r.argument.start,"Unexpected token")}break;case"Property":s.kind!=="init"&&this.raise(s.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(s.value,e);break;case"ArrayExpression":s.type="ArrayPattern",t&&this.checkPatternErrors(t,!0),this.toAssignableList(s.elements,e);break;case"SpreadElement":s.type="RestElement",this.toAssignable(s.argument,e),s.argument.type==="AssignmentPattern"&&this.raise(s.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":s.operator!=="="&&this.raise(s.left.end,"Only '=' operator can be used for specifying default value."),s.type="AssignmentPattern",delete s.operator,this.toAssignable(s.left,e);break;case"ParenthesizedExpression":this.toAssignable(s.expression,e,t);break;case"ChainExpression":this.raiseRecoverable(s.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(s.start,"Assigning to rvalue")}else t&&this.checkPatternErrors(t,!0);return s};K.toAssignableList=function(s,e){for(var t=s.length,n=0;n<t;n++){var i=s[n];i&&this.toAssignable(i,e)}if(t){var r=s[t-1];this.options.ecmaVersion===6&&e&&r&&r.type==="RestElement"&&r.argument.type!=="Identifier"&&this.unexpected(r.argument.start)}return s};K.parseSpread=function(s){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,s),this.finishNode(e,"SpreadElement")};K.parseRestBinding=function(){var s=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==u.name&&this.unexpected(),s.argument=this.parseBindingAtom(),this.finishNode(s,"RestElement")};K.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case u.bracketL:var s=this.startNode();return this.next(),s.elements=this.parseBindingList(u.bracketR,!0,!0),this.finishNode(s,"ArrayPattern");case u.braceL:return this.parseObj(!0)}return this.parseIdent()};K.parseBindingList=function(s,e,t,n){for(var i=[],r=!0;!this.eat(s);)if(r?r=!1:this.expect(u.comma),e&&this.type===u.comma)i.push(null);else{if(t&&this.afterTrailingComma(s))break;if(this.type===u.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),i.push(a),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(s);break}else i.push(this.parseAssignableListItem(n))}return i};K.parseAssignableListItem=function(s){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};K.parseBindingListItem=function(s){return s};K.parseMaybeDefault=function(s,e,t){if(t=t||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(u.eq))return t;var n=this.startNodeAt(s,e);return n.left=t,n.right=this.parseMaybeAssign(),this.finishNode(n,"AssignmentPattern")};K.checkLValSimple=function(s,e,t){e===void 0&&(e=Pe);var n=e!==Pe;switch(s.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(s.name)&&this.raiseRecoverable(s.start,(n?"Binding ":"Assigning to ")+s.name+" in strict mode"),n&&(e===ie&&s.name==="let"&&this.raiseRecoverable(s.start,"let is disallowed as a lexically bound name"),t&&(Ee(t,s.name)&&this.raiseRecoverable(s.start,"Argument name clash"),t[s.name]=!0),e!==xt&&this.declareName(s.name,e,s.start));break;case"ChainExpression":this.raiseRecoverable(s.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":n&&this.raiseRecoverable(s.start,"Binding member expression");break;case"ParenthesizedExpression":return n&&this.raiseRecoverable(s.start,"Binding parenthesized expression"),this.checkLValSimple(s.expression,e,t);default:this.raise(s.start,(n?"Binding":"Assigning to")+" rvalue")}};K.checkLValPattern=function(s,e,t){switch(e===void 0&&(e=Pe),s.type){case"ObjectPattern":for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];this.checkLValInnerPattern(r,e,t)}break;case"ArrayPattern":for(var a=0,o=s.elements;a<o.length;a+=1){var c=o[a];c&&this.checkLValInnerPattern(c,e,t)}break;default:this.checkLValSimple(s,e,t)}};K.checkLValInnerPattern=function(s,e,t){switch(e===void 0&&(e=Pe),s.type){case"Property":this.checkLValInnerPattern(s.value,e,t);break;case"AssignmentPattern":this.checkLValPattern(s.left,e,t);break;case"RestElement":this.checkLValPattern(s.argument,e,t);break;default:this.checkLValPattern(s,e,t)}};var G=function(e,t,n,i,r){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=i,this.generator=!!r},k={b_stat:new G("{",!1),b_expr:new G("{",!0),b_tmpl:new G("${",!1),p_stat:new G("(",!1),p_expr:new G("(",!0),q_tmpl:new G("`",!0,!0,function(s){return s.tryReadTemplateToken()}),f_stat:new G("function",!1),f_expr:new G("function",!0),f_expr_gen:new G("function",!0,!1,null,!0),f_gen:new G("function",!1,!1,null,!0)},be=M.prototype;be.initialContext=function(){return[k.b_stat]};be.curContext=function(){return this.context[this.context.length-1]};be.braceIsBlock=function(s){var e=this.curContext();return e===k.f_expr||e===k.f_stat?!0:s===u.colon&&(e===k.b_stat||e===k.b_expr)?!e.isExpr:s===u._return||s===u.name&&this.exprAllowed?$.test(this.input.slice(this.lastTokEnd,this.start)):s===u._else||s===u.semi||s===u.eof||s===u.parenR||s===u.arrow?!0:s===u.braceL?e===k.b_stat:s===u._var||s===u._const||s===u.name?!1:!this.exprAllowed};be.inGeneratorContext=function(){for(var s=this.context.length-1;s>=1;s--){var e=this.context[s];if(e.token==="function")return e.generator}return!1};be.updateContext=function(s){var e,t=this.type;t.keyword&&s===u.dot?this.exprAllowed=!1:(e=t.updateContext)?e.call(this,s):this.exprAllowed=t.beforeExpr};be.overrideContext=function(s){this.curContext()!==s&&(this.context[this.context.length-1]=s)};u.parenR.updateContext=u.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var s=this.context.pop();s===k.b_stat&&this.curContext().token==="function"&&(s=this.context.pop()),this.exprAllowed=!s.isExpr};u.braceL.updateContext=function(s){this.context.push(this.braceIsBlock(s)?k.b_stat:k.b_expr),this.exprAllowed=!0};u.dollarBraceL.updateContext=function(){this.context.push(k.b_tmpl),this.exprAllowed=!0};u.parenL.updateContext=function(s){var e=s===u._if||s===u._for||s===u._with||s===u._while;this.context.push(e?k.p_stat:k.p_expr),this.exprAllowed=!0};u.incDec.updateContext=function(){};u._function.updateContext=u._class.updateContext=function(s){s.beforeExpr&&s!==u._else&&!(s===u.semi&&this.curContext()!==k.p_stat)&&!(s===u._return&&$.test(this.input.slice(this.lastTokEnd,this.start)))&&!((s===u.colon||s===u.braceL)&&this.curContext()===k.b_stat)?this.context.push(k.f_expr):this.context.push(k.f_stat),this.exprAllowed=!1};u.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};u.backQuote.updateContext=function(){this.curContext()===k.q_tmpl?this.context.pop():this.context.push(k.q_tmpl),this.exprAllowed=!1};u.star.updateContext=function(s){if(s===u._function){var e=this.context.length-1;this.context[e]===k.f_expr?this.context[e]=k.f_expr_gen:this.context[e]=k.f_gen}this.exprAllowed=!0};u.name.updateContext=function(s){var e=!1;this.options.ecmaVersion>=6&&s!==u.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var T=M.prototype;T.checkPropClash=function(s,e,t){if(!(this.options.ecmaVersion>=9&&s.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(s.computed||s.method||s.shorthand))){var n=s.key,i;switch(n.type){case"Identifier":i=n.name;break;case"Literal":i=String(n.value);break;default:return}var r=s.kind;if(this.options.ecmaVersion>=6){i==="__proto__"&&r==="init"&&(e.proto&&(t?t.doubleProto<0&&(t.doubleProto=n.start):this.raiseRecoverable(n.start,"Redefinition of __proto__ property")),e.proto=!0);return}i="$"+i;var a=e[i];if(a){var o;r==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[r],o&&this.raiseRecoverable(n.start,"Redefinition of property")}else a=e[i]={init:!1,get:!1,set:!1};a[r]=!0}};T.parseExpression=function(s,e){var t=this.start,n=this.startLoc,i=this.parseMaybeAssign(s,e);if(this.type===u.comma){var r=this.startNodeAt(t,n);for(r.expressions=[i];this.eat(u.comma);)r.expressions.push(this.parseMaybeAssign(s,e));return this.finishNode(r,"SequenceExpression")}return i};T.parseMaybeAssign=function(s,e,t){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(s);this.exprAllowed=!1}var n=!1,i=-1,r=-1,a=-1;e?(i=e.parenthesizedAssign,r=e.trailingComma,a=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Oe,n=!0);var o=this.start,c=this.startLoc;(this.type===u.parenL||this.type===u.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=s==="await");var l=this.parseMaybeConditional(s,e);if(t&&(l=t.call(this,l,o,c)),this.type.isAssign){var p=this.startNodeAt(o,c);return p.operator=this.value,this.type===u.eq&&(l=this.toAssignable(l,!1,e)),n||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=l.start&&(e.shorthandAssign=-1),this.type===u.eq?this.checkLValPattern(l):this.checkLValSimple(l),p.left=l,this.next(),p.right=this.parseMaybeAssign(s),a>-1&&(e.doubleProto=a),this.finishNode(p,"AssignmentExpression")}else n&&this.checkExpressionErrors(e,!0);return i>-1&&(e.parenthesizedAssign=i),r>-1&&(e.trailingComma=r),l};T.parseMaybeConditional=function(s,e){var t=this.start,n=this.startLoc,i=this.parseExprOps(s,e);if(this.checkExpressionErrors(e))return i;if(this.eat(u.question)){var r=this.startNodeAt(t,n);return r.test=i,r.consequent=this.parseMaybeAssign(),this.expect(u.colon),r.alternate=this.parseMaybeAssign(s),this.finishNode(r,"ConditionalExpression")}return i};T.parseExprOps=function(s,e){var t=this.start,n=this.startLoc,i=this.parseMaybeUnary(e,!1,!1,s);return this.checkExpressionErrors(e)||i.start===t&&i.type==="ArrowFunctionExpression"?i:this.parseExprOp(i,t,n,-1,s)};T.parseExprOp=function(s,e,t,n,i){var r=this.type.binop;if(r!=null&&(!i||this.type!==u._in)&&r>n){var a=this.type===u.logicalOR||this.type===u.logicalAND,o=this.type===u.coalesce;o&&(r=u.logicalAND.binop);var c=this.value;this.next();var l=this.start,p=this.startLoc,h=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,p,r,i),f=this.buildBinary(e,t,s,h,c,a||o);return(a&&this.type===u.coalesce||o&&(this.type===u.logicalOR||this.type===u.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,e,t,n,i)}return s};T.buildBinary=function(s,e,t,n,i,r){n.type==="PrivateIdentifier"&&this.raise(n.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(s,e);return a.left=t,a.operator=i,a.right=n,this.finishNode(a,r?"LogicalExpression":"BinaryExpression")};T.parseMaybeUnary=function(s,e,t,n){var i=this.start,r=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(n),e=!0;else if(this.type.prefix){var o=this.startNode(),c=this.type===u.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,c,n),this.checkExpressionErrors(s,!0),c?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&Ct(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&We(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,a=this.finishNode(o,c?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===u.privateId)(n||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==u._in&&this.unexpected();else{if(a=this.parseExprSubscripts(s,n),this.checkExpressionErrors(s))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,r);l.operator=this.value,l.prefix=!1,l.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(l,"UpdateExpression")}}if(!t&&this.eat(u.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(i,r,a,this.parseMaybeUnary(null,!1,!1,n),"**",!1);else return a};function Ct(s){return s.type==="Identifier"||s.type==="ParenthesizedExpression"&&Ct(s.expression)}function We(s){return s.type==="MemberExpression"&&s.property.type==="PrivateIdentifier"||s.type==="ChainExpression"&&We(s.expression)||s.type==="ParenthesizedExpression"&&We(s.expression)}T.parseExprSubscripts=function(s,e){var t=this.start,n=this.startLoc,i=this.parseExprAtom(s,e);if(i.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return i;var r=this.parseSubscripts(i,t,n,!1,e);return s&&r.type==="MemberExpression"&&(s.parenthesizedAssign>=r.start&&(s.parenthesizedAssign=-1),s.parenthesizedBind>=r.start&&(s.parenthesizedBind=-1),s.trailingComma>=r.start&&(s.trailingComma=-1)),r};T.parseSubscripts=function(s,e,t,n,i){for(var r=this.options.ecmaVersion>=8&&s.type==="Identifier"&&s.name==="async"&&this.lastTokEnd===s.end&&!this.canInsertSemicolon()&&s.end-s.start===5&&this.potentialArrowAt===s.start,a=!1;;){var o=this.parseSubscript(s,e,t,n,r,a,i);if(o.optional&&(a=!0),o===s||o.type==="ArrowFunctionExpression"){if(a){var c=this.startNodeAt(e,t);c.expression=o,o=this.finishNode(c,"ChainExpression")}return o}s=o}};T.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(u.arrow)};T.parseSubscriptAsyncArrow=function(s,e,t,n){return this.parseArrowExpression(this.startNodeAt(s,e),t,!0,n)};T.parseSubscript=function(s,e,t,n,i,r,a){var o=this.options.ecmaVersion>=11,c=o&&this.eat(u.questionDot);n&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(u.bracketL);if(l||c&&this.type!==u.parenL&&this.type!==u.backQuote||this.eat(u.dot)){var p=this.startNodeAt(e,t);p.object=s,l?(p.property=this.parseExpression(),this.expect(u.bracketR)):this.type===u.privateId&&s.type!=="Super"?p.property=this.parsePrivateIdent():p.property=this.parseIdent(this.options.allowReserved!=="never"),p.computed=!!l,o&&(p.optional=c),s=this.finishNode(p,"MemberExpression")}else if(!n&&this.eat(u.parenL)){var h=new Oe,f=this.yieldPos,x=this.awaitPos,b=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var g=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1,h);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=x,this.awaitIdentPos=b,this.parseSubscriptAsyncArrow(e,t,g,a);this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=x||this.awaitPos,this.awaitIdentPos=b||this.awaitIdentPos;var m=this.startNodeAt(e,t);m.callee=s,m.arguments=g,o&&(m.optional=c),s=this.finishNode(m,"CallExpression")}else if(this.type===u.backQuote){(c||r)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var E=this.startNodeAt(e,t);E.tag=s,E.quasi=this.parseTemplate({isTagged:!0}),s=this.finishNode(E,"TaggedTemplateExpression")}return s};T.parseExprAtom=function(s,e,t){this.type===u.slash&&this.readRegexp();var n,i=this.potentialArrowAt===this.start;switch(this.type){case u._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),n=this.startNode(),this.next(),this.type===u.parenL&&!this.allowDirectSuper&&this.raise(n.start,"super() call outside constructor of a subclass"),this.type!==u.dot&&this.type!==u.bracketL&&this.type!==u.parenL&&this.unexpected(),this.finishNode(n,"Super");case u._this:return n=this.startNode(),this.next(),this.finishNode(n,"ThisExpression");case u.name:var r=this.start,a=this.startLoc,o=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&c.name==="async"&&!this.canInsertSemicolon()&&this.eat(u._function))return this.overrideContext(k.f_expr),this.parseFunction(this.startNodeAt(r,a),0,!1,!0,e);if(i&&!this.canInsertSemicolon()){if(this.eat(u.arrow))return this.parseArrowExpression(this.startNodeAt(r,a),[c],!1,e);if(this.options.ecmaVersion>=8&&c.name==="async"&&this.type===u.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(u.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,a),[c],!0,e)}return c;case u.regexp:var l=this.value;return n=this.parseLiteral(l.value),n.regex={pattern:l.pattern,flags:l.flags},n;case u.num:case u.string:return this.parseLiteral(this.value);case u._null:case u._true:case u._false:return n=this.startNode(),n.value=this.type===u._null?null:this.type===u._true,n.raw=this.type.keyword,this.next(),this.finishNode(n,"Literal");case u.parenL:var p=this.start,h=this.parseParenAndDistinguishExpression(i,e);return s&&(s.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(s.parenthesizedAssign=p),s.parenthesizedBind<0&&(s.parenthesizedBind=p)),h;case u.bracketL:return n=this.startNode(),this.next(),n.elements=this.parseExprList(u.bracketR,!0,!0,s),this.finishNode(n,"ArrayExpression");case u.braceL:return this.overrideContext(k.b_expr),this.parseObj(!1,s);case u._function:return n=this.startNode(),this.next(),this.parseFunction(n,0);case u._class:return this.parseClass(this.startNode(),!1);case u._new:return this.parseNew();case u.backQuote:return this.parseTemplate();case u._import:return this.options.ecmaVersion>=11?this.parseExprImport(t):this.unexpected();default:return this.parseExprAtomDefault()}};T.parseExprAtomDefault=function(){this.unexpected()};T.parseExprImport=function(s){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===u.parenL&&!s)return this.parseDynamicImport(e);if(this.type===u.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);return t.name="import",e.meta=this.finishNode(t,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};T.parseDynamicImport=function(s){if(this.next(),s.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(u.parenR)?s.options=null:(this.expect(u.comma),this.afterTrailingComma(u.parenR)?s.options=null:(s.options=this.parseMaybeAssign(),this.eat(u.parenR)||(this.expect(u.comma),this.afterTrailingComma(u.parenR)||this.unexpected())));else if(!this.eat(u.parenR)){var e=this.start;this.eat(u.comma)&&this.eat(u.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(s,"ImportExpression")};T.parseImportMeta=function(s){this.next();var e=this.containsEsc;return s.property=this.parseIdent(!0),s.property.name!=="meta"&&this.raiseRecoverable(s.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(s.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(s.start,"Cannot use 'import.meta' outside a module"),this.finishNode(s,"MetaProperty")};T.parseLiteral=function(s){var e=this.startNode();return e.value=s,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};T.parseParenExpression=function(){this.expect(u.parenL);var s=this.parseExpression();return this.expect(u.parenR),s};T.shouldParseArrow=function(s){return!this.canInsertSemicolon()};T.parseParenAndDistinguishExpression=function(s,e){var t=this.start,n=this.startLoc,i,r=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,c=[],l=!0,p=!1,h=new Oe,f=this.yieldPos,x=this.awaitPos,b;for(this.yieldPos=0,this.awaitPos=0;this.type!==u.parenR;)if(l?l=!1:this.expect(u.comma),r&&this.afterTrailingComma(u.parenR,!0)){p=!0;break}else if(this.type===u.ellipsis){b=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else c.push(this.parseMaybeAssign(!1,h,this.parseParenItem));var g=this.lastTokEnd,m=this.lastTokEndLoc;if(this.expect(u.parenR),s&&this.shouldParseArrow(c)&&this.eat(u.arrow))return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=x,this.parseParenArrowList(t,n,c,e);(!c.length||p)&&this.unexpected(this.lastTokStart),b&&this.unexpected(b),this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=x||this.awaitPos,c.length>1?(i=this.startNodeAt(a,o),i.expressions=c,this.finishNodeAt(i,"SequenceExpression",g,m)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var E=this.startNodeAt(t,n);return E.expression=i,this.finishNode(E,"ParenthesizedExpression")}else return i};T.parseParenItem=function(s){return s};T.parseParenArrowList=function(s,e,t,n){return this.parseArrowExpression(this.startNodeAt(s,e),t,!1,n)};var rs=[];T.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var s=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===u.dot){var e=this.startNodeAt(s.start,s.loc&&s.loc.start);e.name="new",s.meta=this.finishNode(e,"Identifier"),this.next();var t=this.containsEsc;return s.property=this.parseIdent(!0),s.property.name!=="target"&&this.raiseRecoverable(s.property.start,"The only valid meta property for new is 'new.target'"),t&&this.raiseRecoverable(s.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(s.start,"'new.target' can only be used in functions and class static block"),this.finishNode(s,"MetaProperty")}var n=this.start,i=this.startLoc;return s.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),n,i,!0,!1),this.eat(u.parenL)?s.arguments=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1):s.arguments=rs,this.finishNode(s,"NewExpression")};T.parseTemplateElement=function(s){var e=s.isTagged,t=this.startNode();return this.type===u.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),t.value={raw:this.value.replace(/\r\n?/g,`
|
|
1
|
+
var Ht=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],at=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],Ut="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",ot="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Fe={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Ve="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",Xt={5:Ve,"5module":Ve+" export import",6:Ve+" const class extends export import super"},qt=/^in(stanceof)?$/,zt=new RegExp("["+ot+"]"),Kt=new RegExp("["+ot+Ut+"]");function Be(s,e){for(var t=65536,n=0;n<e.length;n+=2){if(t+=e[n],t>s)return!1;if(t+=e[n+1],t>=s)return!0}return!1}function Y(s,e){return s<65?s===36:s<91?!0:s<97?s===95:s<123?!0:s<=65535?s>=170&&zt.test(String.fromCharCode(s)):e===!1?!1:Be(s,at)}function ae(s,e){return s<48?s===36:s<58?!0:s<65?!1:s<91?!0:s<97?s===95:s<123?!0:s<=65535?s>=170&&Kt.test(String.fromCharCode(s)):e===!1?!1:Be(s,at)||Be(s,Ht)}var _=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function H(s,e){return new _(s,{beforeExpr:!0,binop:e})}var U={beforeExpr:!0},F={startsExpr:!0},Xe={};function P(s,e){return e===void 0&&(e={}),e.keyword=s,Xe[s]=new _(s,e)}var u={num:new _("num",F),regexp:new _("regexp",F),string:new _("string",F),name:new _("name",F),privateId:new _("privateId",F),eof:new _("eof"),bracketL:new _("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new _("]"),braceL:new _("{",{beforeExpr:!0,startsExpr:!0}),braceR:new _("}"),parenL:new _("(",{beforeExpr:!0,startsExpr:!0}),parenR:new _(")"),comma:new _(",",U),semi:new _(";",U),colon:new _(":",U),dot:new _("."),question:new _("?",U),questionDot:new _("?."),arrow:new _("=>",U),template:new _("template"),invalidTemplate:new _("invalidTemplate"),ellipsis:new _("...",U),backQuote:new _("`",F),dollarBraceL:new _("${",{beforeExpr:!0,startsExpr:!0}),eq:new _("=",{beforeExpr:!0,isAssign:!0}),assign:new _("_=",{beforeExpr:!0,isAssign:!0}),incDec:new _("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new _("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:H("||",1),logicalAND:H("&&",2),bitwiseOR:H("|",3),bitwiseXOR:H("^",4),bitwiseAND:H("&",5),equality:H("==/!=/===/!==",6),relational:H("</>/<=/>=",7),bitShift:H("<</>>/>>>",8),plusMin:new _("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:H("%",10),star:H("*",10),slash:H("/",10),starstar:new _("**",{beforeExpr:!0}),coalesce:H("??",1),_break:P("break"),_case:P("case",U),_catch:P("catch"),_continue:P("continue"),_debugger:P("debugger"),_default:P("default",U),_do:P("do",{isLoop:!0,beforeExpr:!0}),_else:P("else",U),_finally:P("finally"),_for:P("for",{isLoop:!0}),_function:P("function",F),_if:P("if"),_return:P("return",U),_switch:P("switch"),_throw:P("throw",U),_try:P("try"),_var:P("var"),_const:P("const"),_while:P("while",{isLoop:!0}),_with:P("with"),_new:P("new",{beforeExpr:!0,startsExpr:!0}),_this:P("this",F),_super:P("super",F),_class:P("class",F),_extends:P("extends",U),_export:P("export"),_import:P("import",F),_null:P("null",F),_true:P("true",F),_false:P("false",F),_in:P("in",{beforeExpr:!0,binop:7}),_instanceof:P("instanceof",{beforeExpr:!0,binop:7}),_typeof:P("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:P("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:P("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},D=/\r\n?|\n|\u2028|\u2029/,Gt=new RegExp(D.source,"g");function xe(s){return s===10||s===13||s===8232||s===8233}function ct(s,e,t){t===void 0&&(t=s.length);for(var n=e;n<t;n++){var i=s.charCodeAt(n);if(xe(i))return n<t-1&&i===13&&s.charCodeAt(n+1)===10?n+2:n+1}return-1}var ut=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,R=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,lt=Object.prototype,Qt=lt.hasOwnProperty,Zt=lt.toString,Ee=Object.hasOwn||(function(s,e){return Qt.call(s,e)}),et=Array.isArray||(function(s){return Zt.call(s)==="[object Array]"}),tt=Object.create(null);function re(s){return tt[s]||(tt[s]=new RegExp("^(?:"+s.replace(/ /g,"|")+")$"))}function se(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}var Yt=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,ve=function(e,t){this.line=e,this.column=t};ve.prototype.offset=function(e){return new ve(this.line,this.column+e)};var ke=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function pt(s,e){for(var t=1,n=0;;){var i=ct(s,n,e);if(i<0)return new ve(t,e-n);++t,n=i}}var $e={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},st=!1;function Jt(s){var e={};for(var t in $e)e[t]=s&&Ee(s,t)?s[t]:$e[t];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!st&&typeof console=="object"&&console.warn&&(st=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
+
Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),e.allowReserved==null&&(e.allowReserved=e.ecmaVersion<5),(!s||s.allowHashBang==null)&&(e.allowHashBang=e.ecmaVersion>=14),et(e.onToken)){var n=e.onToken;e.onToken=function(i){return n.push(i)}}return et(e.onComment)&&(e.onComment=es(e,e.onComment)),e}function es(s,e){return function(t,n,i,r,a,o){var c={type:t?"Block":"Line",value:n,start:i,end:r};s.locations&&(c.loc=new ke(this,a,o)),s.ranges&&(c.range=[i,r]),e.push(c)}}var Se=1,be=2,qe=4,ht=8,ze=16,ft=32,Ie=64,dt=128,le=256,Te=512,Me=Se|be|le;function Ke(s,e){return be|(s?qe:0)|(e?ht:0)}var we=0,Ge=1,ie=2,mt=3,gt=4,xt=5,M=function(e,t,n){this.options=e=Jt(e),this.sourceFile=e.sourceFile,this.keywords=re(Xt[e.ecmaVersion>=6?6:e.sourceType==="module"?"5module":5]);var i="";e.allowReserved!==!0&&(i=Fe[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType==="module"&&(i+=" await")),this.reservedWords=re(i);var r=(i?i+" ":"")+Fe.strict;this.reservedWordsStrict=re(r),this.reservedWordsStrictBind=re(r+" "+Fe.strictBind),this.input=String(t),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf(`
|
|
3
|
+
`,n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(D).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=u.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(Se),this.regexpState=null,this.privateNameStack=[]},J={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};M.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};J.inFunction.get=function(){return(this.currentVarScope().flags&be)>0};J.inGenerator.get=function(){return(this.currentVarScope().flags&ht)>0};J.inAsync.get=function(){return(this.currentVarScope().flags&qe)>0};J.canAwait.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(le|Te))return!1;if(t&be)return(t&qe)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};J.allowSuper.get=function(){var s=this.currentThisScope(),e=s.flags;return(e&Ie)>0||this.options.allowSuperOutsideMethod};J.allowDirectSuper.get=function(){return(this.currentThisScope().flags&dt)>0};J.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};J.allowNewDotTarget.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(le|Te)||t&be&&!(t&ze))return!0}return!1};J.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&le)>0};M.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,i=0;i<e.length;i++)n=e[i](n);return n};M.parse=function(e,t){return new this(t,e).parse()};M.parseExpressionAt=function(e,t,n){var i=new this(n,e,t);return i.nextToken(),i.parseExpression()};M.tokenizer=function(e,t){return new this(t,e)};Object.defineProperties(M.prototype,J);var L=M.prototype,ts=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;L.strictDirective=function(s){if(this.options.ecmaVersion<5)return!1;for(;;){R.lastIndex=s,s+=R.exec(this.input)[0].length;var e=ts.exec(this.input.slice(s));if(!e)return!1;if((e[1]||e[2])==="use strict"){R.lastIndex=s+e[0].length;var t=R.exec(this.input),n=t.index+t[0].length,i=this.input.charAt(n);return i===";"||i==="}"||D.test(t[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i==="!"&&this.input.charAt(n+1)==="=")}s+=e[0].length,R.lastIndex=s,s+=R.exec(this.input)[0].length,this.input[s]===";"&&s++}};L.eat=function(s){return this.type===s?(this.next(),!0):!1};L.isContextual=function(s){return this.type===u.name&&this.value===s&&!this.containsEsc};L.eatContextual=function(s){return this.isContextual(s)?(this.next(),!0):!1};L.expectContextual=function(s){this.eatContextual(s)||this.unexpected()};L.canInsertSemicolon=function(){return this.type===u.eof||this.type===u.braceR||D.test(this.input.slice(this.lastTokEnd,this.start))};L.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};L.semicolon=function(){!this.eat(u.semi)&&!this.insertSemicolon()&&this.unexpected()};L.afterTrailingComma=function(s,e){if(this.type===s)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};L.expect=function(s){this.eat(s)||this.unexpected()};L.unexpected=function(s){this.raise(s??this.start,"Unexpected token")};var Re=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};L.checkPatternErrors=function(s,e){if(s){s.trailingComma>-1&&this.raiseRecoverable(s.trailingComma,"Comma is not permitted after the rest element");var t=e?s.parenthesizedAssign:s.parenthesizedBind;t>-1&&this.raiseRecoverable(t,e?"Assigning to rvalue":"Parenthesized pattern")}};L.checkExpressionErrors=function(s,e){if(!s)return!1;var t=s.shorthandAssign,n=s.doubleProto;if(!e)return t>=0||n>=0;t>=0&&this.raise(t,"Shorthand property assignments are valid only in destructuring patterns"),n>=0&&this.raiseRecoverable(n,"Redefinition of __proto__ property")};L.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};L.isSimpleAssignTarget=function(s){return s.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(s.expression):s.type==="Identifier"||s.type==="MemberExpression"};var v=M.prototype;v.parseTopLevel=function(s){var e=Object.create(null);for(s.body||(s.body=[]);this.type!==u.eof;){var t=this.parseStatement(null,!0,e);s.body.push(t)}if(this.inModule)for(var n=0,i=Object.keys(this.undefinedExports);n<i.length;n+=1){var r=i[n];this.raiseRecoverable(this.undefinedExports[r].start,"Export '"+r+"' is not defined")}return this.adaptDirectivePrologue(s.body),this.next(),s.sourceType=this.options.sourceType,this.finishNode(s,"Program")};var Qe={kind:"loop"},ss={kind:"switch"};v.isLet=function(s){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;R.lastIndex=this.pos;var e=R.exec(this.input),t=this.pos+e[0].length,n=this.input.charCodeAt(t);if(n===91||n===92)return!0;if(s)return!1;if(n===123||n>55295&&n<56320)return!0;if(Y(n,!0)){for(var i=t+1;ae(n=this.input.charCodeAt(i),!0);)++i;if(n===92||n>55295&&n<56320)return!0;var r=this.input.slice(t,i);if(!qt.test(r))return!0}return!1};v.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;R.lastIndex=this.pos;var s=R.exec(this.input),e=this.pos+s[0].length,t;return!D.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(ae(t=this.input.charCodeAt(e+8))||t>55295&&t<56320))};v.isUsingKeyword=function(s,e){if(this.options.ecmaVersion<17||!this.isContextual(s?"await":"using"))return!1;R.lastIndex=this.pos;var t=R.exec(this.input),n=this.pos+t[0].length;if(D.test(this.input.slice(this.pos,n)))return!1;if(s){var i=n+5,r;if(this.input.slice(n,i)!=="using"||i===this.input.length||ae(r=this.input.charCodeAt(i))||r>55295&&r<56320)return!1;R.lastIndex=i;var a=R.exec(this.input);if(a&&D.test(this.input.slice(i,i+a[0].length)))return!1}if(e){var o=n+2,c;if(this.input.slice(n,o)==="of"&&(o===this.input.length||!ae(c=this.input.charCodeAt(o))&&!(c>55295&&c<56320)))return!1}var l=this.input.charCodeAt(n);return Y(l,!0)||l===92};v.isAwaitUsing=function(s){return this.isUsingKeyword(!0,s)};v.isUsing=function(s){return this.isUsingKeyword(!1,s)};v.parseStatement=function(s,e,t){var n=this.type,i=this.startNode(),r;switch(this.isLet(s)&&(n=u._var,r="let"),n){case u._break:case u._continue:return this.parseBreakContinueStatement(i,n.keyword);case u._debugger:return this.parseDebuggerStatement(i);case u._do:return this.parseDoStatement(i);case u._for:return this.parseForStatement(i);case u._function:return s&&(this.strict||s!=="if"&&s!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!s);case u._class:return s&&this.unexpected(),this.parseClass(i,!0);case u._if:return this.parseIfStatement(i);case u._return:return this.parseReturnStatement(i);case u._switch:return this.parseSwitchStatement(i);case u._throw:return this.parseThrowStatement(i);case u._try:return this.parseTryStatement(i);case u._const:case u._var:return r=r||this.value,s&&r!=="var"&&this.unexpected(),this.parseVarStatement(i,r);case u._while:return this.parseWhileStatement(i);case u._with:return this.parseWithStatement(i);case u.braceL:return this.parseBlock(!0,i);case u.semi:return this.parseEmptyStatement(i);case u._export:case u._import:if(this.options.ecmaVersion>10&&n===u._import){R.lastIndex=this.pos;var a=R.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),n===u._import?this.parseImport(i):this.parseExport(i,t);default:if(this.isAsyncFunction())return s&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!s);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return e&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),l==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,"VariableDeclaration");var p=this.value,h=this.parseExpression();return n===u.name&&h.type==="Identifier"&&this.eat(u.colon)?this.parseLabeledStatement(i,p,h,s):this.parseExpressionStatement(i,h)}};v.parseBreakContinueStatement=function(s,e){var t=e==="break";this.next(),this.eat(u.semi)||this.insertSemicolon()?s.label=null:this.type!==u.name?this.unexpected():(s.label=this.parseIdent(),this.semicolon());for(var n=0;n<this.labels.length;++n){var i=this.labels[n];if((s.label==null||i.name===s.label.name)&&(i.kind!=null&&(t||i.kind==="loop")||s.label&&t))break}return n===this.labels.length&&this.raise(s.start,"Unsyntactic "+e),this.finishNode(s,t?"BreakStatement":"ContinueStatement")};v.parseDebuggerStatement=function(s){return this.next(),this.semicolon(),this.finishNode(s,"DebuggerStatement")};v.parseDoStatement=function(s){return this.next(),this.labels.push(Qe),s.body=this.parseStatement("do"),this.labels.pop(),this.expect(u._while),s.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(u.semi):this.semicolon(),this.finishNode(s,"DoWhileStatement")};v.parseForStatement=function(s){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Qe),this.enterScope(0),this.expect(u.parenL),this.type===u.semi)return e>-1&&this.unexpected(e),this.parseFor(s,null);var t=this.isLet();if(this.type===u._var||this.type===u._const||t){var n=this.startNode(),i=t?"let":this.value;return this.next(),this.parseVar(n,!0,i),this.finishNode(n,"VariableDeclaration"),this.parseForAfterInit(s,n,e)}var r=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var c=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(c,!0,o),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(s,c,e)}var l=this.containsEsc,p=new Re,h=this.start,f=e>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===u._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===u._in&&this.unexpected(e),s.await=!0):a&&this.options.ecmaVersion>=8&&(f.start===h&&!l&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(s.await=!1)),r&&a&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,p),this.checkLValPattern(f),this.parseForIn(s,f)):(this.checkExpressionErrors(p,!0),e>-1&&this.unexpected(e),this.parseFor(s,f))};v.parseForAfterInit=function(s,e,t){return(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===u._in?t>-1&&this.unexpected(t):s.await=t>-1),this.parseForIn(s,e)):(t>-1&&this.unexpected(t),this.parseFor(s,e))};v.parseFunctionStatement=function(s,e,t){return this.next(),this.parseFunction(s,ye|(t?0:je),!1,e)};v.parseIfStatement=function(s){return this.next(),s.test=this.parseParenExpression(),s.consequent=this.parseStatement("if"),s.alternate=this.eat(u._else)?this.parseStatement("if"):null,this.finishNode(s,"IfStatement")};v.parseReturnStatement=function(s){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(u.semi)||this.insertSemicolon()?s.argument=null:(s.argument=this.parseExpression(),this.semicolon()),this.finishNode(s,"ReturnStatement")};v.parseSwitchStatement=function(s){this.next(),s.discriminant=this.parseParenExpression(),s.cases=[],this.expect(u.braceL),this.labels.push(ss),this.enterScope(0);for(var e,t=!1;this.type!==u.braceR;)if(this.type===u._case||this.type===u._default){var n=this.type===u._case;e&&this.finishNode(e,"SwitchCase"),s.cases.push(e=this.startNode()),e.consequent=[],this.next(),n?e.test=this.parseExpression():(t&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),t=!0,e.test=null),this.expect(u.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(s,"SwitchStatement")};v.parseThrowStatement=function(s){return this.next(),D.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),s.argument=this.parseExpression(),this.semicolon(),this.finishNode(s,"ThrowStatement")};var ns=[];v.parseCatchClauseParam=function(){var s=this.parseBindingAtom(),e=s.type==="Identifier";return this.enterScope(e?ft:0),this.checkLValPattern(s,e?gt:ie),this.expect(u.parenR),s};v.parseTryStatement=function(s){if(this.next(),s.block=this.parseBlock(),s.handler=null,this.type===u._catch){var e=this.startNode();this.next(),this.eat(u.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),s.handler=this.finishNode(e,"CatchClause")}return s.finalizer=this.eat(u._finally)?this.parseBlock():null,!s.handler&&!s.finalizer&&this.raise(s.start,"Missing catch or finally clause"),this.finishNode(s,"TryStatement")};v.parseVarStatement=function(s,e,t){return this.next(),this.parseVar(s,!1,e,t),this.semicolon(),this.finishNode(s,"VariableDeclaration")};v.parseWhileStatement=function(s){return this.next(),s.test=this.parseParenExpression(),this.labels.push(Qe),s.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(s,"WhileStatement")};v.parseWithStatement=function(s){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),s.object=this.parseParenExpression(),s.body=this.parseStatement("with"),this.finishNode(s,"WithStatement")};v.parseEmptyStatement=function(s){return this.next(),this.finishNode(s,"EmptyStatement")};v.parseLabeledStatement=function(s,e,t,n){for(var i=0,r=this.labels;i<r.length;i+=1){var a=r[i];a.name===e&&this.raise(t.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===u._switch?"switch":null,c=this.labels.length-1;c>=0;c--){var l=this.labels[c];if(l.statementStart===s.start)l.statementStart=this.start,l.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),s.body=this.parseStatement(n?n.indexOf("label")===-1?n+"label":n:"label"),this.labels.pop(),s.label=t,this.finishNode(s,"LabeledStatement")};v.parseExpressionStatement=function(s,e){return s.expression=e,this.semicolon(),this.finishNode(s,"ExpressionStatement")};v.parseBlock=function(s,e,t){for(s===void 0&&(s=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(u.braceL),s&&this.enterScope(0);this.type!==u.braceR;){var n=this.parseStatement(null);e.body.push(n)}return t&&(this.strict=!1),this.next(),s&&this.exitScope(),this.finishNode(e,"BlockStatement")};v.parseFor=function(s,e){return s.init=e,this.expect(u.semi),s.test=this.type===u.semi?null:this.parseExpression(),this.expect(u.semi),s.update=this.type===u.parenR?null:this.parseExpression(),this.expect(u.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,"ForStatement")};v.parseForIn=function(s,e){var t=this.type===u._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!t||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(t?"for-in":"for-of")+" loop variable declaration may not have an initializer"),s.left=e,s.right=t?this.parseExpression():this.parseMaybeAssign(),this.expect(u.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,t?"ForInStatement":"ForOfStatement")};v.parseVar=function(s,e,t,n){for(s.declarations=[],s.kind=t;;){var i=this.startNode();if(this.parseVarId(i,t),this.eat(u.eq)?i.init=this.parseMaybeAssign(e):!n&&t==="const"&&!(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!n&&(t==="using"||t==="await using")&&this.options.ecmaVersion>=17&&this.type!==u._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+t+" declaration"):!n&&i.id.type!=="Identifier"&&!(e&&(this.type===u._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):i.init=null,s.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(u.comma))break}return s};v.parseVarId=function(s,e){s.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(s.id,e==="var"?Ge:ie,!1)};var ye=1,je=2,Et=4;v.parseFunction=function(s,e,t,n,i){this.initFunction(s),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!n)&&(this.type===u.star&&e&je&&this.unexpected(),s.generator=this.eat(u.star)),this.options.ecmaVersion>=8&&(s.async=!!n),e&ye&&(s.id=e&Et&&this.type!==u.name?null:this.parseIdent(),s.id&&!(e&je)&&this.checkLValSimple(s.id,this.strict||s.generator||s.async?this.treatFunctionsAsVar?Ge:ie:mt));var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ke(s.async,s.generator)),e&ye||(s.id=this.type===u.name?this.parseIdent():null),this.parseFunctionParams(s),this.parseFunctionBody(s,t,!1,i),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(s,e&ye?"FunctionDeclaration":"FunctionExpression")};v.parseFunctionParams=function(s){this.expect(u.parenL),s.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};v.parseClass=function(s,e){this.next();var t=this.strict;this.strict=!0,this.parseClassId(s,e),this.parseClassSuper(s);var n=this.enterClassBody(),i=this.startNode(),r=!1;for(i.body=[],this.expect(u.braceL);this.type!==u.braceR;){var a=this.parseClassElement(s.superClass!==null);a&&(i.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(r&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),r=!0):a.key&&a.key.type==="PrivateIdentifier"&&is(n,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=t,this.next(),s.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(s,e?"ClassDeclaration":"ClassExpression")};v.parseClassElement=function(s){if(this.eat(u.semi))return null;var e=this.options.ecmaVersion,t=this.startNode(),n="",i=!1,r=!1,a="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(u.braceL))return this.parseClassStaticBlock(t),t;this.isClassElementNameStart()||this.type===u.star?o=!0:n="static"}if(t.static=o,!n&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===u.star)&&!this.canInsertSemicolon()?r=!0:n="async"),!n&&(e>=9||!r)&&this.eat(u.star)&&(i=!0),!n&&!r&&!i){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:n=c)}if(n?(t.computed=!1,t.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),t.key.name=n,this.finishNode(t.key,"Identifier")):this.parseClassElementName(t),e<13||this.type===u.parenL||a!=="method"||i||r){var l=!t.static&&Pe(t,"constructor"),p=l&&s;l&&a!=="method"&&this.raise(t.key.start,"Constructor can't have get/set modifier"),t.kind=l?"constructor":a,this.parseClassMethod(t,i,r,p)}else this.parseClassField(t);return t};v.isClassElementNameStart=function(){return this.type===u.name||this.type===u.privateId||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword};v.parseClassElementName=function(s){this.type===u.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),s.computed=!1,s.key=this.parsePrivateIdent()):this.parsePropertyName(s)};v.parseClassMethod=function(s,e,t,n){var i=s.key;s.kind==="constructor"?(e&&this.raise(i.start,"Constructor can't be a generator"),t&&this.raise(i.start,"Constructor can't be an async method")):s.static&&Pe(s,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var r=s.value=this.parseMethod(e,t,n);return s.kind==="get"&&r.params.length!==0&&this.raiseRecoverable(r.start,"getter should have no params"),s.kind==="set"&&r.params.length!==1&&this.raiseRecoverable(r.start,"setter should have exactly one param"),s.kind==="set"&&r.params[0].type==="RestElement"&&this.raiseRecoverable(r.params[0].start,"Setter cannot use rest params"),this.finishNode(s,"MethodDefinition")};v.parseClassField=function(s){return Pe(s,"constructor")?this.raise(s.key.start,"Classes can't have a field named 'constructor'"):s.static&&Pe(s,"prototype")&&this.raise(s.key.start,"Classes can't have a static field named 'prototype'"),this.eat(u.eq)?(this.enterScope(Te|Ie),s.value=this.parseMaybeAssign(),this.exitScope()):s.value=null,this.semicolon(),this.finishNode(s,"PropertyDefinition")};v.parseClassStaticBlock=function(s){s.body=[];var e=this.labels;for(this.labels=[],this.enterScope(le|Ie);this.type!==u.braceR;){var t=this.parseStatement(null);s.body.push(t)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(s,"StaticBlock")};v.parseClassId=function(s,e){this.type===u.name?(s.id=this.parseIdent(),e&&this.checkLValSimple(s.id,ie,!1)):(e===!0&&this.unexpected(),s.id=null)};v.parseClassSuper=function(s){s.superClass=this.eat(u._extends)?this.parseExprSubscripts(null,!1):null};v.enterClassBody=function(){var s={declared:Object.create(null),used:[]};return this.privateNameStack.push(s),s.declared};v.exitClassBody=function(){var s=this.privateNameStack.pop(),e=s.declared,t=s.used;if(this.options.checkPrivateFields)for(var n=this.privateNameStack.length,i=n===0?null:this.privateNameStack[n-1],r=0;r<t.length;++r){var a=t[r];Ee(e,a.name)||(i?i.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function is(s,e){var t=e.key.name,n=s[t],i="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(i=(e.static?"s":"i")+e.kind),n==="iget"&&i==="iset"||n==="iset"&&i==="iget"||n==="sget"&&i==="sset"||n==="sset"&&i==="sget"?(s[t]="true",!1):n?!0:(s[t]=i,!1)}function Pe(s,e){var t=s.computed,n=s.key;return!t&&(n.type==="Identifier"&&n.name===e||n.type==="Literal"&&n.value===e)}v.parseExportAllDeclaration=function(s,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(s.exported=this.parseModuleExportName(),this.checkExport(e,s.exported,this.lastTokStart)):s.exported=null),this.expectContextual("from"),this.type!==u.string&&this.unexpected(),s.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ExportAllDeclaration")};v.parseExport=function(s,e){if(this.next(),this.eat(u.star))return this.parseExportAllDeclaration(s,e);if(this.eat(u._default))return this.checkExport(e,"default",this.lastTokStart),s.declaration=this.parseExportDefaultDeclaration(),this.finishNode(s,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())s.declaration=this.parseExportDeclaration(s),s.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,s.declaration.declarations):this.checkExport(e,s.declaration.id,s.declaration.id.start),s.specifiers=[],s.source=null,this.options.ecmaVersion>=16&&(s.attributes=[]);else{if(s.declaration=null,s.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==u.string&&this.unexpected(),s.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause());else{for(var t=0,n=s.specifiers;t<n.length;t+=1){var i=n[t];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type==="Literal"&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}s.source=null,this.options.ecmaVersion>=16&&(s.attributes=[])}this.semicolon()}return this.finishNode(s,"ExportNamedDeclaration")};v.parseExportDeclaration=function(s){return this.parseStatement(null)};v.parseExportDefaultDeclaration=function(){var s;if(this.type===u._function||(s=this.isAsyncFunction())){var e=this.startNode();return this.next(),s&&this.next(),this.parseFunction(e,ye|Et,!1,s)}else if(this.type===u._class){var t=this.startNode();return this.parseClass(t,"nullableID")}else{var n=this.parseMaybeAssign();return this.semicolon(),n}};v.checkExport=function(s,e,t){s&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),Ee(s,e)&&this.raiseRecoverable(t,"Duplicate export '"+e+"'"),s[e]=!0)};v.checkPatternExport=function(s,e){var t=e.type;if(t==="Identifier")this.checkExport(s,e,e.start);else if(t==="ObjectPattern")for(var n=0,i=e.properties;n<i.length;n+=1){var r=i[n];this.checkPatternExport(s,r)}else if(t==="ArrayPattern")for(var a=0,o=e.elements;a<o.length;a+=1){var c=o[a];c&&this.checkPatternExport(s,c)}else t==="Property"?this.checkPatternExport(s,e.value):t==="AssignmentPattern"?this.checkPatternExport(s,e.left):t==="RestElement"&&this.checkPatternExport(s,e.argument)};v.checkVariableExport=function(s,e){if(s)for(var t=0,n=e;t<n.length;t+=1){var i=n[t];this.checkPatternExport(s,i.id)}};v.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};v.parseExportSpecifier=function(s){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(s,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};v.parseExportSpecifiers=function(s){var e=[],t=!0;for(this.expect(u.braceL);!this.eat(u.braceR);){if(t)t=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;e.push(this.parseExportSpecifier(s))}return e};v.parseImport=function(s){return this.next(),this.type===u.string?(s.specifiers=ns,s.source=this.parseExprAtom()):(s.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),s.source=this.type===u.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ImportDeclaration")};v.parseImportSpecifier=function(){var s=this.startNode();return s.imported=this.parseModuleExportName(),this.eatContextual("as")?s.local=this.parseIdent():(this.checkUnreserved(s.imported),s.local=s.imported),this.checkLValSimple(s.local,ie),this.finishNode(s,"ImportSpecifier")};v.parseImportDefaultSpecifier=function(){var s=this.startNode();return s.local=this.parseIdent(),this.checkLValSimple(s.local,ie),this.finishNode(s,"ImportDefaultSpecifier")};v.parseImportNamespaceSpecifier=function(){var s=this.startNode();return this.next(),this.expectContextual("as"),s.local=this.parseIdent(),this.checkLValSimple(s.local,ie),this.finishNode(s,"ImportNamespaceSpecifier")};v.parseImportSpecifiers=function(){var s=[],e=!0;if(this.type===u.name&&(s.push(this.parseImportDefaultSpecifier()),!this.eat(u.comma)))return s;if(this.type===u.star)return s.push(this.parseImportNamespaceSpecifier()),s;for(this.expect(u.braceL);!this.eat(u.braceR);){if(e)e=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;s.push(this.parseImportSpecifier())}return s};v.parseWithClause=function(){var s=[];if(!this.eat(u._with))return s;this.expect(u.braceL);for(var e={},t=!0;!this.eat(u.braceR);){if(t)t=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;var n=this.parseImportAttribute(),i=n.key.type==="Identifier"?n.key.name:n.key.value;Ee(e,i)&&this.raiseRecoverable(n.key.start,"Duplicate attribute key '"+i+"'"),e[i]=!0,s.push(n)}return s};v.parseImportAttribute=function(){var s=this.startNode();return s.key=this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(u.colon),this.type!==u.string&&this.unexpected(),s.value=this.parseExprAtom(),this.finishNode(s,"ImportAttribute")};v.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===u.string){var s=this.parseLiteral(this.value);return Yt.test(s.value)&&this.raise(s.start,"An export name cannot include a lone surrogate."),s}return this.parseIdent(!0)};v.adaptDirectivePrologue=function(s){for(var e=0;e<s.length&&this.isDirectiveCandidate(s[e]);++e)s[e].directive=s[e].expression.raw.slice(1,-1)};v.isDirectiveCandidate=function(s){return this.options.ecmaVersion>=5&&s.type==="ExpressionStatement"&&s.expression.type==="Literal"&&typeof s.expression.value=="string"&&(this.input[s.start]==='"'||this.input[s.start]==="'")};var z=M.prototype;z.toAssignable=function(s,e,t){if(this.options.ecmaVersion>=6&&s)switch(s.type){case"Identifier":this.inAsync&&s.name==="await"&&this.raise(s.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":s.type="ObjectPattern",t&&this.checkPatternErrors(t,!0);for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];this.toAssignable(r,e),r.type==="RestElement"&&(r.argument.type==="ArrayPattern"||r.argument.type==="ObjectPattern")&&this.raise(r.argument.start,"Unexpected token")}break;case"Property":s.kind!=="init"&&this.raise(s.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(s.value,e);break;case"ArrayExpression":s.type="ArrayPattern",t&&this.checkPatternErrors(t,!0),this.toAssignableList(s.elements,e);break;case"SpreadElement":s.type="RestElement",this.toAssignable(s.argument,e),s.argument.type==="AssignmentPattern"&&this.raise(s.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":s.operator!=="="&&this.raise(s.left.end,"Only '=' operator can be used for specifying default value."),s.type="AssignmentPattern",delete s.operator,this.toAssignable(s.left,e);break;case"ParenthesizedExpression":this.toAssignable(s.expression,e,t);break;case"ChainExpression":this.raiseRecoverable(s.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(s.start,"Assigning to rvalue")}else t&&this.checkPatternErrors(t,!0);return s};z.toAssignableList=function(s,e){for(var t=s.length,n=0;n<t;n++){var i=s[n];i&&this.toAssignable(i,e)}if(t){var r=s[t-1];this.options.ecmaVersion===6&&e&&r&&r.type==="RestElement"&&r.argument.type!=="Identifier"&&this.unexpected(r.argument.start)}return s};z.parseSpread=function(s){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,s),this.finishNode(e,"SpreadElement")};z.parseRestBinding=function(){var s=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==u.name&&this.unexpected(),s.argument=this.parseBindingAtom(),this.finishNode(s,"RestElement")};z.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case u.bracketL:var s=this.startNode();return this.next(),s.elements=this.parseBindingList(u.bracketR,!0,!0),this.finishNode(s,"ArrayPattern");case u.braceL:return this.parseObj(!0)}return this.parseIdent()};z.parseBindingList=function(s,e,t,n){for(var i=[],r=!0;!this.eat(s);)if(r?r=!1:this.expect(u.comma),e&&this.type===u.comma)i.push(null);else{if(t&&this.afterTrailingComma(s))break;if(this.type===u.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),i.push(a),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(s);break}else i.push(this.parseAssignableListItem(n))}return i};z.parseAssignableListItem=function(s){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};z.parseBindingListItem=function(s){return s};z.parseMaybeDefault=function(s,e,t){if(t=t||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(u.eq))return t;var n=this.startNodeAt(s,e);return n.left=t,n.right=this.parseMaybeAssign(),this.finishNode(n,"AssignmentPattern")};z.checkLValSimple=function(s,e,t){e===void 0&&(e=we);var n=e!==we;switch(s.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(s.name)&&this.raiseRecoverable(s.start,(n?"Binding ":"Assigning to ")+s.name+" in strict mode"),n&&(e===ie&&s.name==="let"&&this.raiseRecoverable(s.start,"let is disallowed as a lexically bound name"),t&&(Ee(t,s.name)&&this.raiseRecoverable(s.start,"Argument name clash"),t[s.name]=!0),e!==xt&&this.declareName(s.name,e,s.start));break;case"ChainExpression":this.raiseRecoverable(s.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":n&&this.raiseRecoverable(s.start,"Binding member expression");break;case"ParenthesizedExpression":return n&&this.raiseRecoverable(s.start,"Binding parenthesized expression"),this.checkLValSimple(s.expression,e,t);default:this.raise(s.start,(n?"Binding":"Assigning to")+" rvalue")}};z.checkLValPattern=function(s,e,t){switch(e===void 0&&(e=we),s.type){case"ObjectPattern":for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];this.checkLValInnerPattern(r,e,t)}break;case"ArrayPattern":for(var a=0,o=s.elements;a<o.length;a+=1){var c=o[a];c&&this.checkLValInnerPattern(c,e,t)}break;default:this.checkLValSimple(s,e,t)}};z.checkLValInnerPattern=function(s,e,t){switch(e===void 0&&(e=we),s.type){case"Property":this.checkLValInnerPattern(s.value,e,t);break;case"AssignmentPattern":this.checkLValPattern(s.left,e,t);break;case"RestElement":this.checkLValPattern(s.argument,e,t);break;default:this.checkLValPattern(s,e,t)}};var G=function(e,t,n,i,r){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=i,this.generator=!!r},k={b_stat:new G("{",!1),b_expr:new G("{",!0),b_tmpl:new G("${",!1),p_stat:new G("(",!1),p_expr:new G("(",!0),q_tmpl:new G("`",!0,!0,function(s){return s.tryReadTemplateToken()}),f_stat:new G("function",!1),f_expr:new G("function",!0),f_expr_gen:new G("function",!0,!1,null,!0),f_gen:new G("function",!1,!1,null,!0)},Ce=M.prototype;Ce.initialContext=function(){return[k.b_stat]};Ce.curContext=function(){return this.context[this.context.length-1]};Ce.braceIsBlock=function(s){var e=this.curContext();return e===k.f_expr||e===k.f_stat?!0:s===u.colon&&(e===k.b_stat||e===k.b_expr)?!e.isExpr:s===u._return||s===u.name&&this.exprAllowed?D.test(this.input.slice(this.lastTokEnd,this.start)):s===u._else||s===u.semi||s===u.eof||s===u.parenR||s===u.arrow?!0:s===u.braceL?e===k.b_stat:s===u._var||s===u._const||s===u.name?!1:!this.exprAllowed};Ce.inGeneratorContext=function(){for(var s=this.context.length-1;s>=1;s--){var e=this.context[s];if(e.token==="function")return e.generator}return!1};Ce.updateContext=function(s){var e,t=this.type;t.keyword&&s===u.dot?this.exprAllowed=!1:(e=t.updateContext)?e.call(this,s):this.exprAllowed=t.beforeExpr};Ce.overrideContext=function(s){this.curContext()!==s&&(this.context[this.context.length-1]=s)};u.parenR.updateContext=u.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var s=this.context.pop();s===k.b_stat&&this.curContext().token==="function"&&(s=this.context.pop()),this.exprAllowed=!s.isExpr};u.braceL.updateContext=function(s){this.context.push(this.braceIsBlock(s)?k.b_stat:k.b_expr),this.exprAllowed=!0};u.dollarBraceL.updateContext=function(){this.context.push(k.b_tmpl),this.exprAllowed=!0};u.parenL.updateContext=function(s){var e=s===u._if||s===u._for||s===u._with||s===u._while;this.context.push(e?k.p_stat:k.p_expr),this.exprAllowed=!0};u.incDec.updateContext=function(){};u._function.updateContext=u._class.updateContext=function(s){s.beforeExpr&&s!==u._else&&!(s===u.semi&&this.curContext()!==k.p_stat)&&!(s===u._return&&D.test(this.input.slice(this.lastTokEnd,this.start)))&&!((s===u.colon||s===u.braceL)&&this.curContext()===k.b_stat)?this.context.push(k.f_expr):this.context.push(k.f_stat),this.exprAllowed=!1};u.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};u.backQuote.updateContext=function(){this.curContext()===k.q_tmpl?this.context.pop():this.context.push(k.q_tmpl),this.exprAllowed=!1};u.star.updateContext=function(s){if(s===u._function){var e=this.context.length-1;this.context[e]===k.f_expr?this.context[e]=k.f_expr_gen:this.context[e]=k.f_gen}this.exprAllowed=!0};u.name.updateContext=function(s){var e=!1;this.options.ecmaVersion>=6&&s!==u.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var S=M.prototype;S.checkPropClash=function(s,e,t){if(!(this.options.ecmaVersion>=9&&s.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(s.computed||s.method||s.shorthand))){var n=s.key,i;switch(n.type){case"Identifier":i=n.name;break;case"Literal":i=String(n.value);break;default:return}var r=s.kind;if(this.options.ecmaVersion>=6){i==="__proto__"&&r==="init"&&(e.proto&&(t?t.doubleProto<0&&(t.doubleProto=n.start):this.raiseRecoverable(n.start,"Redefinition of __proto__ property")),e.proto=!0);return}i="$"+i;var a=e[i];if(a){var o;r==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[r],o&&this.raiseRecoverable(n.start,"Redefinition of property")}else a=e[i]={init:!1,get:!1,set:!1};a[r]=!0}};S.parseExpression=function(s,e){var t=this.start,n=this.startLoc,i=this.parseMaybeAssign(s,e);if(this.type===u.comma){var r=this.startNodeAt(t,n);for(r.expressions=[i];this.eat(u.comma);)r.expressions.push(this.parseMaybeAssign(s,e));return this.finishNode(r,"SequenceExpression")}return i};S.parseMaybeAssign=function(s,e,t){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(s);this.exprAllowed=!1}var n=!1,i=-1,r=-1,a=-1;e?(i=e.parenthesizedAssign,r=e.trailingComma,a=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Re,n=!0);var o=this.start,c=this.startLoc;(this.type===u.parenL||this.type===u.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=s==="await");var l=this.parseMaybeConditional(s,e);if(t&&(l=t.call(this,l,o,c)),this.type.isAssign){var p=this.startNodeAt(o,c);return p.operator=this.value,this.type===u.eq&&(l=this.toAssignable(l,!1,e)),n||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=l.start&&(e.shorthandAssign=-1),this.type===u.eq?this.checkLValPattern(l):this.checkLValSimple(l),p.left=l,this.next(),p.right=this.parseMaybeAssign(s),a>-1&&(e.doubleProto=a),this.finishNode(p,"AssignmentExpression")}else n&&this.checkExpressionErrors(e,!0);return i>-1&&(e.parenthesizedAssign=i),r>-1&&(e.trailingComma=r),l};S.parseMaybeConditional=function(s,e){var t=this.start,n=this.startLoc,i=this.parseExprOps(s,e);if(this.checkExpressionErrors(e))return i;if(this.eat(u.question)){var r=this.startNodeAt(t,n);return r.test=i,r.consequent=this.parseMaybeAssign(),this.expect(u.colon),r.alternate=this.parseMaybeAssign(s),this.finishNode(r,"ConditionalExpression")}return i};S.parseExprOps=function(s,e){var t=this.start,n=this.startLoc,i=this.parseMaybeUnary(e,!1,!1,s);return this.checkExpressionErrors(e)||i.start===t&&i.type==="ArrowFunctionExpression"?i:this.parseExprOp(i,t,n,-1,s)};S.parseExprOp=function(s,e,t,n,i){var r=this.type.binop;if(r!=null&&(!i||this.type!==u._in)&&r>n){var a=this.type===u.logicalOR||this.type===u.logicalAND,o=this.type===u.coalesce;o&&(r=u.logicalAND.binop);var c=this.value;this.next();var l=this.start,p=this.startLoc,h=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,p,r,i),f=this.buildBinary(e,t,s,h,c,a||o);return(a&&this.type===u.coalesce||o&&(this.type===u.logicalOR||this.type===u.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,e,t,n,i)}return s};S.buildBinary=function(s,e,t,n,i,r){n.type==="PrivateIdentifier"&&this.raise(n.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(s,e);return a.left=t,a.operator=i,a.right=n,this.finishNode(a,r?"LogicalExpression":"BinaryExpression")};S.parseMaybeUnary=function(s,e,t,n){var i=this.start,r=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(n),e=!0;else if(this.type.prefix){var o=this.startNode(),c=this.type===u.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,c,n),this.checkExpressionErrors(s,!0),c?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&bt(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&We(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,a=this.finishNode(o,c?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===u.privateId)(n||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==u._in&&this.unexpected();else{if(a=this.parseExprSubscripts(s,n),this.checkExpressionErrors(s))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,r);l.operator=this.value,l.prefix=!1,l.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(l,"UpdateExpression")}}if(!t&&this.eat(u.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(i,r,a,this.parseMaybeUnary(null,!1,!1,n),"**",!1);else return a};function bt(s){return s.type==="Identifier"||s.type==="ParenthesizedExpression"&&bt(s.expression)}function We(s){return s.type==="MemberExpression"&&s.property.type==="PrivateIdentifier"||s.type==="ChainExpression"&&We(s.expression)||s.type==="ParenthesizedExpression"&&We(s.expression)}S.parseExprSubscripts=function(s,e){var t=this.start,n=this.startLoc,i=this.parseExprAtom(s,e);if(i.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return i;var r=this.parseSubscripts(i,t,n,!1,e);return s&&r.type==="MemberExpression"&&(s.parenthesizedAssign>=r.start&&(s.parenthesizedAssign=-1),s.parenthesizedBind>=r.start&&(s.parenthesizedBind=-1),s.trailingComma>=r.start&&(s.trailingComma=-1)),r};S.parseSubscripts=function(s,e,t,n,i){for(var r=this.options.ecmaVersion>=8&&s.type==="Identifier"&&s.name==="async"&&this.lastTokEnd===s.end&&!this.canInsertSemicolon()&&s.end-s.start===5&&this.potentialArrowAt===s.start,a=!1;;){var o=this.parseSubscript(s,e,t,n,r,a,i);if(o.optional&&(a=!0),o===s||o.type==="ArrowFunctionExpression"){if(a){var c=this.startNodeAt(e,t);c.expression=o,o=this.finishNode(c,"ChainExpression")}return o}s=o}};S.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(u.arrow)};S.parseSubscriptAsyncArrow=function(s,e,t,n){return this.parseArrowExpression(this.startNodeAt(s,e),t,!0,n)};S.parseSubscript=function(s,e,t,n,i,r,a){var o=this.options.ecmaVersion>=11,c=o&&this.eat(u.questionDot);n&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(u.bracketL);if(l||c&&this.type!==u.parenL&&this.type!==u.backQuote||this.eat(u.dot)){var p=this.startNodeAt(e,t);p.object=s,l?(p.property=this.parseExpression(),this.expect(u.bracketR)):this.type===u.privateId&&s.type!=="Super"?p.property=this.parsePrivateIdent():p.property=this.parseIdent(this.options.allowReserved!=="never"),p.computed=!!l,o&&(p.optional=c),s=this.finishNode(p,"MemberExpression")}else if(!n&&this.eat(u.parenL)){var h=new Re,f=this.yieldPos,E=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var x=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1,h);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=E,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(e,t,x,a);this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=E||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(e,t);g.callee=s,g.arguments=x,o&&(g.optional=c),s=this.finishNode(g,"CallExpression")}else if(this.type===u.backQuote){(c||r)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var C=this.startNodeAt(e,t);C.tag=s,C.quasi=this.parseTemplate({isTagged:!0}),s=this.finishNode(C,"TaggedTemplateExpression")}return s};S.parseExprAtom=function(s,e,t){this.type===u.slash&&this.readRegexp();var n,i=this.potentialArrowAt===this.start;switch(this.type){case u._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),n=this.startNode(),this.next(),this.type===u.parenL&&!this.allowDirectSuper&&this.raise(n.start,"super() call outside constructor of a subclass"),this.type!==u.dot&&this.type!==u.bracketL&&this.type!==u.parenL&&this.unexpected(),this.finishNode(n,"Super");case u._this:return n=this.startNode(),this.next(),this.finishNode(n,"ThisExpression");case u.name:var r=this.start,a=this.startLoc,o=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&c.name==="async"&&!this.canInsertSemicolon()&&this.eat(u._function))return this.overrideContext(k.f_expr),this.parseFunction(this.startNodeAt(r,a),0,!1,!0,e);if(i&&!this.canInsertSemicolon()){if(this.eat(u.arrow))return this.parseArrowExpression(this.startNodeAt(r,a),[c],!1,e);if(this.options.ecmaVersion>=8&&c.name==="async"&&this.type===u.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(u.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,a),[c],!0,e)}return c;case u.regexp:var l=this.value;return n=this.parseLiteral(l.value),n.regex={pattern:l.pattern,flags:l.flags},n;case u.num:case u.string:return this.parseLiteral(this.value);case u._null:case u._true:case u._false:return n=this.startNode(),n.value=this.type===u._null?null:this.type===u._true,n.raw=this.type.keyword,this.next(),this.finishNode(n,"Literal");case u.parenL:var p=this.start,h=this.parseParenAndDistinguishExpression(i,e);return s&&(s.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(s.parenthesizedAssign=p),s.parenthesizedBind<0&&(s.parenthesizedBind=p)),h;case u.bracketL:return n=this.startNode(),this.next(),n.elements=this.parseExprList(u.bracketR,!0,!0,s),this.finishNode(n,"ArrayExpression");case u.braceL:return this.overrideContext(k.b_expr),this.parseObj(!1,s);case u._function:return n=this.startNode(),this.next(),this.parseFunction(n,0);case u._class:return this.parseClass(this.startNode(),!1);case u._new:return this.parseNew();case u.backQuote:return this.parseTemplate();case u._import:return this.options.ecmaVersion>=11?this.parseExprImport(t):this.unexpected();default:return this.parseExprAtomDefault()}};S.parseExprAtomDefault=function(){this.unexpected()};S.parseExprImport=function(s){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===u.parenL&&!s)return this.parseDynamicImport(e);if(this.type===u.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);return t.name="import",e.meta=this.finishNode(t,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};S.parseDynamicImport=function(s){if(this.next(),s.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(u.parenR)?s.options=null:(this.expect(u.comma),this.afterTrailingComma(u.parenR)?s.options=null:(s.options=this.parseMaybeAssign(),this.eat(u.parenR)||(this.expect(u.comma),this.afterTrailingComma(u.parenR)||this.unexpected())));else if(!this.eat(u.parenR)){var e=this.start;this.eat(u.comma)&&this.eat(u.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(s,"ImportExpression")};S.parseImportMeta=function(s){this.next();var e=this.containsEsc;return s.property=this.parseIdent(!0),s.property.name!=="meta"&&this.raiseRecoverable(s.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(s.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(s.start,"Cannot use 'import.meta' outside a module"),this.finishNode(s,"MetaProperty")};S.parseLiteral=function(s){var e=this.startNode();return e.value=s,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};S.parseParenExpression=function(){this.expect(u.parenL);var s=this.parseExpression();return this.expect(u.parenR),s};S.shouldParseArrow=function(s){return!this.canInsertSemicolon()};S.parseParenAndDistinguishExpression=function(s,e){var t=this.start,n=this.startLoc,i,r=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,c=[],l=!0,p=!1,h=new Re,f=this.yieldPos,E=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==u.parenR;)if(l?l=!1:this.expect(u.comma),r&&this.afterTrailingComma(u.parenR,!0)){p=!0;break}else if(this.type===u.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else c.push(this.parseMaybeAssign(!1,h,this.parseParenItem));var x=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(u.parenR),s&&this.shouldParseArrow(c)&&this.eat(u.arrow))return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=E,this.parseParenArrowList(t,n,c,e);(!c.length||p)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=E||this.awaitPos,c.length>1?(i=this.startNodeAt(a,o),i.expressions=c,this.finishNodeAt(i,"SequenceExpression",x,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var C=this.startNodeAt(t,n);return C.expression=i,this.finishNode(C,"ParenthesizedExpression")}else return i};S.parseParenItem=function(s){return s};S.parseParenArrowList=function(s,e,t,n){return this.parseArrowExpression(this.startNodeAt(s,e),t,!1,n)};var rs=[];S.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var s=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===u.dot){var e=this.startNodeAt(s.start,s.loc&&s.loc.start);e.name="new",s.meta=this.finishNode(e,"Identifier"),this.next();var t=this.containsEsc;return s.property=this.parseIdent(!0),s.property.name!=="target"&&this.raiseRecoverable(s.property.start,"The only valid meta property for new is 'new.target'"),t&&this.raiseRecoverable(s.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(s.start,"'new.target' can only be used in functions and class static block"),this.finishNode(s,"MetaProperty")}var n=this.start,i=this.startLoc;return s.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),n,i,!0,!1),this.eat(u.parenL)?s.arguments=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1):s.arguments=rs,this.finishNode(s,"NewExpression")};S.parseTemplateElement=function(s){var e=s.isTagged,t=this.startNode();return this.type===u.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),t.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
4
|
`),cooked:null}):t.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
5
|
-
`),cooked:this.value},this.next(),t.tail=this.type===u.backQuote,this.finishNode(t,"TemplateElement")};T.parseTemplate=function(s){s===void 0&&(s={});var e=s.isTagged;e===void 0&&(e=!1);var t=this.startNode();this.next(),t.expressions=[];var n=this.parseTemplateElement({isTagged:e});for(t.quasis=[n];!n.tail;)this.type===u.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(u.dollarBraceL),t.expressions.push(this.parseExpression()),this.expect(u.braceR),t.quasis.push(n=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(t,"TemplateLiteral")};T.isAsyncProp=function(s){return!s.computed&&s.key.type==="Identifier"&&s.key.name==="async"&&(this.type===u.name||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===u.star)&&!$.test(this.input.slice(this.lastTokEnd,this.start))};T.parseObj=function(s,e){var t=this.startNode(),n=!0,i={};for(t.properties=[],this.next();!this.eat(u.braceR);){if(n)n=!1;else if(this.expect(u.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(u.braceR))break;var r=this.parseProperty(s,e);s||this.checkPropClash(r,i,e),t.properties.push(r)}return this.finishNode(t,s?"ObjectPattern":"ObjectExpression")};T.parseProperty=function(s,e){var t=this.startNode(),n,i,r,a;if(this.options.ecmaVersion>=9&&this.eat(u.ellipsis))return s?(t.argument=this.parseIdent(!1),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(t,"RestElement")):(t.argument=this.parseMaybeAssign(!1,e),this.type===u.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(t,"SpreadElement"));this.options.ecmaVersion>=6&&(t.method=!1,t.shorthand=!1,(s||e)&&(r=this.start,a=this.startLoc),s||(n=this.eat(u.star)));var o=this.containsEsc;return this.parsePropertyName(t),!s&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(t)?(i=!0,n=this.options.ecmaVersion>=9&&this.eat(u.star),this.parsePropertyName(t)):i=!1,this.parsePropertyValue(t,s,n,i,r,a,e,o),this.finishNode(t,"Property")};T.parseGetterSetter=function(s){var e=s.key.name;this.parsePropertyName(s),s.value=this.parseMethod(!1),s.kind=e;var t=s.kind==="get"?0:1;if(s.value.params.length!==t){var n=s.value.start;s.kind==="get"?this.raiseRecoverable(n,"getter should have no params"):this.raiseRecoverable(n,"setter should have exactly one param")}else s.kind==="set"&&s.value.params[0].type==="RestElement"&&this.raiseRecoverable(s.value.params[0].start,"Setter cannot use rest params")};T.parsePropertyValue=function(s,e,t,n,i,r,a,o){(t||n)&&this.type===u.colon&&this.unexpected(),this.eat(u.colon)?(s.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),s.kind="init"):this.options.ecmaVersion>=6&&this.type===u.parenL?(e&&this.unexpected(),s.method=!0,s.value=this.parseMethod(t,n),s.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!s.computed&&s.key.type==="Identifier"&&(s.key.name==="get"||s.key.name==="set")&&this.type!==u.comma&&this.type!==u.braceR&&this.type!==u.eq?((t||n)&&this.unexpected(),this.parseGetterSetter(s)):this.options.ecmaVersion>=6&&!s.computed&&s.key.type==="Identifier"?((t||n)&&this.unexpected(),this.checkUnreserved(s.key),s.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=i),e?s.value=this.parseMaybeDefault(i,r,this.copyNode(s.key)):this.type===u.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),s.value=this.parseMaybeDefault(i,r,this.copyNode(s.key))):s.value=this.copyNode(s.key),s.kind="init",s.shorthand=!0):this.unexpected()};T.parsePropertyName=function(s){if(this.options.ecmaVersion>=6){if(this.eat(u.bracketL))return s.computed=!0,s.key=this.parseMaybeAssign(),this.expect(u.bracketR),s.key;s.computed=!1}return s.key=this.type===u.num||this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};T.initFunction=function(s){s.id=null,this.options.ecmaVersion>=6&&(s.generator=s.expression=!1),this.options.ecmaVersion>=8&&(s.async=!1)};T.parseMethod=function(s,e,t){var n=this.startNode(),i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=s),this.options.ecmaVersion>=8&&(n.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ke(e,n.generator)|Ie|(t?dt:0)),this.expect(u.parenL),n.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1,!0,!1),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(n,"FunctionExpression")};T.parseArrowExpression=function(s,e,t,n){var i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(Ke(t,!1)|ze),this.initFunction(s),this.options.ecmaVersion>=8&&(s.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,s.params=this.toAssignableList(e,!0),this.parseFunctionBody(s,!0,!1,n),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(s,"ArrowFunctionExpression")};T.parseFunctionBody=function(s,e,t,n){var i=e&&this.type!==u.braceL,r=this.strict,a=!1;if(i)s.body=this.parseMaybeAssign(n),s.expression=!0,this.checkParams(s,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(s.params);(!r||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(s.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(s,!r&&!a&&!e&&!t&&this.isSimpleParamList(s.params)),this.strict&&s.id&&this.checkLValSimple(s.id,xt),s.body=this.parseBlock(!1,void 0,a&&!r),s.expression=!1,this.adaptDirectivePrologue(s.body.body),this.labels=c}this.exitScope()};T.isSimpleParamList=function(s){for(var e=0,t=s;e<t.length;e+=1){var n=t[e];if(n.type!=="Identifier")return!1}return!0};T.checkParams=function(s,e){for(var t=Object.create(null),n=0,i=s.params;n<i.length;n+=1){var r=i[n];this.checkLValInnerPattern(r,Ge,e?null:t)}};T.parseExprList=function(s,e,t,n){for(var i=[],r=!0;!this.eat(s);){if(r)r=!1;else if(this.expect(u.comma),e&&this.afterTrailingComma(s))break;var a=void 0;t&&this.type===u.comma?a=null:this.type===u.ellipsis?(a=this.parseSpread(n),n&&this.type===u.comma&&n.trailingComma<0&&(n.trailingComma=this.start)):a=this.parseMaybeAssign(!1,n),i.push(a)}return i};T.checkUnreserved=function(s){var e=s.start,t=s.end,n=s.name;if(this.inGenerator&&n==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&n==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&Me)&&n==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(n==="arguments"||n==="await")&&this.raise(e,"Cannot use "+n+" in class static initialization block"),this.keywords.test(n)&&this.raise(e,"Unexpected keyword '"+n+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,t).indexOf("\\")!==-1)){var i=this.strict?this.reservedWordsStrict:this.reservedWords;i.test(n)&&(!this.inAsync&&n==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+n+"' is reserved"))}};T.parseIdent=function(s){var e=this.parseIdentNode();return this.next(!!s),this.finishNode(e,"Identifier"),s||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};T.parseIdentNode=function(){var s=this.startNode();return this.type===u.name?s.name=this.value:this.type.keyword?(s.name=this.type.keyword,(s.name==="class"||s.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=u.name):this.unexpected(),s};T.parsePrivateIdent=function(){var s=this.startNode();return this.type===u.privateId?s.name=this.value:this.unexpected(),this.next(),this.finishNode(s,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(s)),s};T.parseYield=function(s){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===u.semi||this.canInsertSemicolon()||this.type!==u.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(u.star),e.argument=this.parseMaybeAssign(s)),this.finishNode(e,"YieldExpression")};T.parseAwait=function(s){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,s),this.finishNode(e,"AwaitExpression")};var _e=M.prototype;_e.raise=function(s,e){var t=pt(this.input,s);e+=" ("+t.line+":"+t.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var n=new SyntaxError(e);throw n.pos=s,n.loc=t,n.raisedAt=this.pos,n};_e.raiseRecoverable=_e.raise;_e.curPosition=function(){if(this.options.locations)return new ve(this.curLine,this.pos-this.lineStart)};var oe=M.prototype,as=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};oe.enterScope=function(s){this.scopeStack.push(new as(s))};oe.exitScope=function(){this.scopeStack.pop()};oe.treatFunctionsAsVarInScope=function(s){return s.flags&Ce||!this.inModule&&s.flags&Se};oe.declareName=function(s,e,t){var n=!1;if(e===ie){var i=this.currentScope();n=i.lexical.indexOf(s)>-1||i.functions.indexOf(s)>-1||i.var.indexOf(s)>-1,i.lexical.push(s),this.inModule&&i.flags&Se&&delete this.undefinedExports[s]}else if(e===gt){var r=this.currentScope();r.lexical.push(s)}else if(e===mt){var a=this.currentScope();this.treatFunctionsAsVar?n=a.lexical.indexOf(s)>-1:n=a.lexical.indexOf(s)>-1||a.var.indexOf(s)>-1,a.functions.push(s)}else for(var o=this.scopeStack.length-1;o>=0;--o){var c=this.scopeStack[o];if(c.lexical.indexOf(s)>-1&&!(c.flags&ft&&c.lexical[0]===s)||!this.treatFunctionsAsVarInScope(c)&&c.functions.indexOf(s)>-1){n=!0;break}if(c.var.push(s),this.inModule&&c.flags&Se&&delete this.undefinedExports[s],c.flags&Me)break}n&&this.raiseRecoverable(t,"Identifier '"+s+"' has already been declared")};oe.checkLocalExport=function(s){this.scopeStack[0].lexical.indexOf(s.name)===-1&&this.scopeStack[0].var.indexOf(s.name)===-1&&(this.undefinedExports[s.name]=s)};oe.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};oe.currentVarScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(Me|Te|le))return e}};oe.currentThisScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(Me|Te|le)&&!(e.flags&ze))return e}};var Re=function(e,t,n){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new ke(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ae=M.prototype;Ae.startNode=function(){return new Re(this,this.start,this.startLoc)};Ae.startNodeAt=function(s,e){return new Re(this,s,e)};function bt(s,e,t,n){return s.type=e,s.end=t,this.options.locations&&(s.loc.end=n),this.options.ranges&&(s.range[1]=t),s}Ae.finishNode=function(s,e){return bt.call(this,s,e,this.lastTokEnd,this.lastTokEndLoc)};Ae.finishNodeAt=function(s,e,t,n){return bt.call(this,s,e,t,n)};Ae.copyNode=function(s){var e=new Re(this,s.start,this.startLoc);for(var t in s)e[t]=s[t];return e};var os="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",yt="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",vt=yt+" Extended_Pictographic",St=vt,Tt=St+" EBase EComp EMod EPres ExtPict",At=Tt,cs=At,us={9:yt,10:vt,11:St,12:Tt,13:At,14:cs},ls="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",ps={9:"",10:"",11:"",12:"",13:"",14:ls},nt="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",Pt="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",wt=Pt+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",_t=wt+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Nt=_t+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",kt=Nt+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",hs=kt+" "+os,fs={9:Pt,10:wt,11:_t,12:Nt,13:kt,14:hs},It={};function ds(s){var e=It[s]={binary:re(us[s]+" "+nt),binaryOfStrings:re(ps[s]),nonBinary:{General_Category:re(nt),Script:re(fs[s])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var De=0,it=[9,10,11,12,13,14];De<it.length;De+=1){var ms=it[De];ds(ms)}var y=M.prototype,Ne=function(e,t){this.parent=e,this.base=t||this};Ne.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1};Ne.prototype.sibling=function(){return new Ne(this.parent,this.base)};var ee=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=It[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};ee.prototype.reset=function(e,t,n){var i=n.indexOf("v")!==-1,r=n.indexOf("u")!==-1;this.start=e|0,this.source=t+"",this.flags=n,i&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=r&&this.parser.options.ecmaVersion>=9)};ee.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};ee.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,i=n.length;if(e>=i)return-1;var r=n.charCodeAt(e);if(!(t||this.switchU)||r<=55295||r>=57344||e+1>=i)return r;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(r<<10)+a-56613888:r};ee.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,i=n.length;if(e>=i)return i;var r=n.charCodeAt(e),a;return!(t||this.switchU)||r<=55295||r>=57344||e+1>=i||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2};ee.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};ee.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};ee.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};ee.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1};ee.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,i=0,r=e;i<r.length;i+=1){var a=r[i],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0};y.validateRegExpFlags=function(s){for(var e=s.validFlags,t=s.flags,n=!1,i=!1,r=0;r<t.length;r++){var a=t.charAt(r);e.indexOf(a)===-1&&this.raise(s.start,"Invalid regular expression flag"),t.indexOf(a,r+1)>-1&&this.raise(s.start,"Duplicate regular expression flag"),a==="u"&&(n=!0),a==="v"&&(i=!0)}this.options.ecmaVersion>=15&&n&&i&&this.raise(s.start,"Invalid regular expression flag")};function gs(s){for(var e in s)return!0;return!1}y.validateRegExpPattern=function(s){this.regexp_pattern(s),!s.switchN&&this.options.ecmaVersion>=9&&gs(s.groupNames)&&(s.switchN=!0,this.regexp_pattern(s))};y.regexp_pattern=function(s){s.pos=0,s.lastIntValue=0,s.lastStringValue="",s.lastAssertionIsQuantifiable=!1,s.numCapturingParens=0,s.maxBackReference=0,s.groupNames=Object.create(null),s.backReferenceNames.length=0,s.branchID=null,this.regexp_disjunction(s),s.pos!==s.source.length&&(s.eat(41)&&s.raise("Unmatched ')'"),(s.eat(93)||s.eat(125))&&s.raise("Lone quantifier brackets")),s.maxBackReference>s.numCapturingParens&&s.raise("Invalid escape");for(var e=0,t=s.backReferenceNames;e<t.length;e+=1){var n=t[e];s.groupNames[n]||s.raise("Invalid named capture referenced")}};y.regexp_disjunction=function(s){var e=this.options.ecmaVersion>=16;for(e&&(s.branchID=new Ne(s.branchID,null)),this.regexp_alternative(s);s.eat(124);)e&&(s.branchID=s.branchID.sibling()),this.regexp_alternative(s);e&&(s.branchID=s.branchID.parent),this.regexp_eatQuantifier(s,!0)&&s.raise("Nothing to repeat"),s.eat(123)&&s.raise("Lone quantifier brackets")};y.regexp_alternative=function(s){for(;s.pos<s.source.length&&this.regexp_eatTerm(s););};y.regexp_eatTerm=function(s){return this.regexp_eatAssertion(s)?(s.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(s)&&s.switchU&&s.raise("Invalid quantifier"),!0):(s.switchU?this.regexp_eatAtom(s):this.regexp_eatExtendedAtom(s))?(this.regexp_eatQuantifier(s),!0):!1};y.regexp_eatAssertion=function(s){var e=s.pos;if(s.lastAssertionIsQuantifiable=!1,s.eat(94)||s.eat(36))return!0;if(s.eat(92)){if(s.eat(66)||s.eat(98))return!0;s.pos=e}if(s.eat(40)&&s.eat(63)){var t=!1;if(this.options.ecmaVersion>=9&&(t=s.eat(60)),s.eat(61)||s.eat(33))return this.regexp_disjunction(s),s.eat(41)||s.raise("Unterminated group"),s.lastAssertionIsQuantifiable=!t,!0}return s.pos=e,!1};y.regexp_eatQuantifier=function(s,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(s,e)?(s.eat(63),!0):!1};y.regexp_eatQuantifierPrefix=function(s,e){return s.eat(42)||s.eat(43)||s.eat(63)||this.regexp_eatBracedQuantifier(s,e)};y.regexp_eatBracedQuantifier=function(s,e){var t=s.pos;if(s.eat(123)){var n=0,i=-1;if(this.regexp_eatDecimalDigits(s)&&(n=s.lastIntValue,s.eat(44)&&this.regexp_eatDecimalDigits(s)&&(i=s.lastIntValue),s.eat(125)))return i!==-1&&i<n&&!e&&s.raise("numbers out of order in {} quantifier"),!0;s.switchU&&!e&&s.raise("Incomplete quantifier"),s.pos=t}return!1};y.regexp_eatAtom=function(s){return this.regexp_eatPatternCharacters(s)||s.eat(46)||this.regexp_eatReverseSolidusAtomEscape(s)||this.regexp_eatCharacterClass(s)||this.regexp_eatUncapturingGroup(s)||this.regexp_eatCapturingGroup(s)};y.regexp_eatReverseSolidusAtomEscape=function(s){var e=s.pos;if(s.eat(92)){if(this.regexp_eatAtomEscape(s))return!0;s.pos=e}return!1};y.regexp_eatUncapturingGroup=function(s){var e=s.pos;if(s.eat(40)){if(s.eat(63)){if(this.options.ecmaVersion>=16){var t=this.regexp_eatModifiers(s),n=s.eat(45);if(t||n){for(var i=0;i<t.length;i++){var r=t.charAt(i);t.indexOf(r,i+1)>-1&&s.raise("Duplicate regular expression modifiers")}if(n){var a=this.regexp_eatModifiers(s);!t&&!a&&s.current()===58&&s.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var c=a.charAt(o);(a.indexOf(c,o+1)>-1||t.indexOf(c)>-1)&&s.raise("Duplicate regular expression modifiers")}}}}if(s.eat(58)){if(this.regexp_disjunction(s),s.eat(41))return!0;s.raise("Unterminated group")}}s.pos=e}return!1};y.regexp_eatCapturingGroup=function(s){if(s.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(s):s.current()===63&&s.raise("Invalid group"),this.regexp_disjunction(s),s.eat(41))return s.numCapturingParens+=1,!0;s.raise("Unterminated group")}return!1};y.regexp_eatModifiers=function(s){for(var e="",t=0;(t=s.current())!==-1&&xs(t);)e+=se(t),s.advance();return e};function xs(s){return s===105||s===109||s===115}y.regexp_eatExtendedAtom=function(s){return s.eat(46)||this.regexp_eatReverseSolidusAtomEscape(s)||this.regexp_eatCharacterClass(s)||this.regexp_eatUncapturingGroup(s)||this.regexp_eatCapturingGroup(s)||this.regexp_eatInvalidBracedQuantifier(s)||this.regexp_eatExtendedPatternCharacter(s)};y.regexp_eatInvalidBracedQuantifier=function(s){return this.regexp_eatBracedQuantifier(s,!0)&&s.raise("Nothing to repeat"),!1};y.regexp_eatSyntaxCharacter=function(s){var e=s.current();return Mt(e)?(s.lastIntValue=e,s.advance(),!0):!1};function Mt(s){return s===36||s>=40&&s<=43||s===46||s===63||s>=91&&s<=94||s>=123&&s<=125}y.regexp_eatPatternCharacters=function(s){for(var e=s.pos,t=0;(t=s.current())!==-1&&!Mt(t);)s.advance();return s.pos!==e};y.regexp_eatExtendedPatternCharacter=function(s){var e=s.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(s.advance(),!0):!1};y.regexp_groupSpecifier=function(s){if(s.eat(63)){this.regexp_eatGroupName(s)||s.raise("Invalid group");var e=this.options.ecmaVersion>=16,t=s.groupNames[s.lastStringValue];if(t)if(e)for(var n=0,i=t;n<i.length;n+=1){var r=i[n];r.separatedFrom(s.branchID)||s.raise("Duplicate capture group name")}else s.raise("Duplicate capture group name");e?(t||(s.groupNames[s.lastStringValue]=[])).push(s.branchID):s.groupNames[s.lastStringValue]=!0}};y.regexp_eatGroupName=function(s){if(s.lastStringValue="",s.eat(60)){if(this.regexp_eatRegExpIdentifierName(s)&&s.eat(62))return!0;s.raise("Invalid capture group name")}return!1};y.regexp_eatRegExpIdentifierName=function(s){if(s.lastStringValue="",this.regexp_eatRegExpIdentifierStart(s)){for(s.lastStringValue+=se(s.lastIntValue);this.regexp_eatRegExpIdentifierPart(s);)s.lastStringValue+=se(s.lastIntValue);return!0}return!1};y.regexp_eatRegExpIdentifierStart=function(s){var e=s.pos,t=this.options.ecmaVersion>=11,n=s.current(t);return s.advance(t),n===92&&this.regexp_eatRegExpUnicodeEscapeSequence(s,t)&&(n=s.lastIntValue),Es(n)?(s.lastIntValue=n,!0):(s.pos=e,!1)};function Es(s){return Y(s,!0)||s===36||s===95}y.regexp_eatRegExpIdentifierPart=function(s){var e=s.pos,t=this.options.ecmaVersion>=11,n=s.current(t);return s.advance(t),n===92&&this.regexp_eatRegExpUnicodeEscapeSequence(s,t)&&(n=s.lastIntValue),Cs(n)?(s.lastIntValue=n,!0):(s.pos=e,!1)};function Cs(s){return ae(s,!0)||s===36||s===95||s===8204||s===8205}y.regexp_eatAtomEscape=function(s){return this.regexp_eatBackReference(s)||this.regexp_eatCharacterClassEscape(s)||this.regexp_eatCharacterEscape(s)||s.switchN&&this.regexp_eatKGroupName(s)?!0:(s.switchU&&(s.current()===99&&s.raise("Invalid unicode escape"),s.raise("Invalid escape")),!1)};y.regexp_eatBackReference=function(s){var e=s.pos;if(this.regexp_eatDecimalEscape(s)){var t=s.lastIntValue;if(s.switchU)return t>s.maxBackReference&&(s.maxBackReference=t),!0;if(t<=s.numCapturingParens)return!0;s.pos=e}return!1};y.regexp_eatKGroupName=function(s){if(s.eat(107)){if(this.regexp_eatGroupName(s))return s.backReferenceNames.push(s.lastStringValue),!0;s.raise("Invalid named reference")}return!1};y.regexp_eatCharacterEscape=function(s){return this.regexp_eatControlEscape(s)||this.regexp_eatCControlLetter(s)||this.regexp_eatZero(s)||this.regexp_eatHexEscapeSequence(s)||this.regexp_eatRegExpUnicodeEscapeSequence(s,!1)||!s.switchU&&this.regexp_eatLegacyOctalEscapeSequence(s)||this.regexp_eatIdentityEscape(s)};y.regexp_eatCControlLetter=function(s){var e=s.pos;if(s.eat(99)){if(this.regexp_eatControlLetter(s))return!0;s.pos=e}return!1};y.regexp_eatZero=function(s){return s.current()===48&&!Le(s.lookahead())?(s.lastIntValue=0,s.advance(),!0):!1};y.regexp_eatControlEscape=function(s){var e=s.current();return e===116?(s.lastIntValue=9,s.advance(),!0):e===110?(s.lastIntValue=10,s.advance(),!0):e===118?(s.lastIntValue=11,s.advance(),!0):e===102?(s.lastIntValue=12,s.advance(),!0):e===114?(s.lastIntValue=13,s.advance(),!0):!1};y.regexp_eatControlLetter=function(s){var e=s.current();return Ot(e)?(s.lastIntValue=e%32,s.advance(),!0):!1};function Ot(s){return s>=65&&s<=90||s>=97&&s<=122}y.regexp_eatRegExpUnicodeEscapeSequence=function(s,e){e===void 0&&(e=!1);var t=s.pos,n=e||s.switchU;if(s.eat(117)){if(this.regexp_eatFixedHexDigits(s,4)){var i=s.lastIntValue;if(n&&i>=55296&&i<=56319){var r=s.pos;if(s.eat(92)&&s.eat(117)&&this.regexp_eatFixedHexDigits(s,4)){var a=s.lastIntValue;if(a>=56320&&a<=57343)return s.lastIntValue=(i-55296)*1024+(a-56320)+65536,!0}s.pos=r,s.lastIntValue=i}return!0}if(n&&s.eat(123)&&this.regexp_eatHexDigits(s)&&s.eat(125)&&bs(s.lastIntValue))return!0;n&&s.raise("Invalid unicode escape"),s.pos=t}return!1};function bs(s){return s>=0&&s<=1114111}y.regexp_eatIdentityEscape=function(s){if(s.switchU)return this.regexp_eatSyntaxCharacter(s)?!0:s.eat(47)?(s.lastIntValue=47,!0):!1;var e=s.current();return e!==99&&(!s.switchN||e!==107)?(s.lastIntValue=e,s.advance(),!0):!1};y.regexp_eatDecimalEscape=function(s){s.lastIntValue=0;var e=s.current();if(e>=49&&e<=57){do s.lastIntValue=10*s.lastIntValue+(e-48),s.advance();while((e=s.current())>=48&&e<=57);return!0}return!1};var Rt=0,ne=1,q=2;y.regexp_eatCharacterClassEscape=function(s){var e=s.current();if(ys(e))return s.lastIntValue=-1,s.advance(),ne;var t=!1;if(s.switchU&&this.options.ecmaVersion>=9&&((t=e===80)||e===112)){s.lastIntValue=-1,s.advance();var n;if(s.eat(123)&&(n=this.regexp_eatUnicodePropertyValueExpression(s))&&s.eat(125))return t&&n===q&&s.raise("Invalid property name"),n;s.raise("Invalid property name")}return Rt};function ys(s){return s===100||s===68||s===115||s===83||s===119||s===87}y.regexp_eatUnicodePropertyValueExpression=function(s){var e=s.pos;if(this.regexp_eatUnicodePropertyName(s)&&s.eat(61)){var t=s.lastStringValue;if(this.regexp_eatUnicodePropertyValue(s)){var n=s.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(s,t,n),ne}}if(s.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(s)){var i=s.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(s,i)}return Rt};y.regexp_validateUnicodePropertyNameAndValue=function(s,e,t){Ee(s.unicodeProperties.nonBinary,e)||s.raise("Invalid property name"),s.unicodeProperties.nonBinary[e].test(t)||s.raise("Invalid property value")};y.regexp_validateUnicodePropertyNameOrValue=function(s,e){if(s.unicodeProperties.binary.test(e))return ne;if(s.switchV&&s.unicodeProperties.binaryOfStrings.test(e))return q;s.raise("Invalid property name")};y.regexp_eatUnicodePropertyName=function(s){var e=0;for(s.lastStringValue="";Lt(e=s.current());)s.lastStringValue+=se(e),s.advance();return s.lastStringValue!==""};function Lt(s){return Ot(s)||s===95}y.regexp_eatUnicodePropertyValue=function(s){var e=0;for(s.lastStringValue="";vs(e=s.current());)s.lastStringValue+=se(e),s.advance();return s.lastStringValue!==""};function vs(s){return Lt(s)||Le(s)}y.regexp_eatLoneUnicodePropertyNameOrValue=function(s){return this.regexp_eatUnicodePropertyValue(s)};y.regexp_eatCharacterClass=function(s){if(s.eat(91)){var e=s.eat(94),t=this.regexp_classContents(s);return s.eat(93)||s.raise("Unterminated character class"),e&&t===q&&s.raise("Negated character class may contain strings"),!0}return!1};y.regexp_classContents=function(s){return s.current()===93?ne:s.switchV?this.regexp_classSetExpression(s):(this.regexp_nonEmptyClassRanges(s),ne)};y.regexp_nonEmptyClassRanges=function(s){for(;this.regexp_eatClassAtom(s);){var e=s.lastIntValue;if(s.eat(45)&&this.regexp_eatClassAtom(s)){var t=s.lastIntValue;s.switchU&&(e===-1||t===-1)&&s.raise("Invalid character class"),e!==-1&&t!==-1&&e>t&&s.raise("Range out of order in character class")}}};y.regexp_eatClassAtom=function(s){var e=s.pos;if(s.eat(92)){if(this.regexp_eatClassEscape(s))return!0;if(s.switchU){var t=s.current();(t===99||Dt(t))&&s.raise("Invalid class escape"),s.raise("Invalid escape")}s.pos=e}var n=s.current();return n!==93?(s.lastIntValue=n,s.advance(),!0):!1};y.regexp_eatClassEscape=function(s){var e=s.pos;if(s.eat(98))return s.lastIntValue=8,!0;if(s.switchU&&s.eat(45))return s.lastIntValue=45,!0;if(!s.switchU&&s.eat(99)){if(this.regexp_eatClassControlLetter(s))return!0;s.pos=e}return this.regexp_eatCharacterClassEscape(s)||this.regexp_eatCharacterEscape(s)};y.regexp_classSetExpression=function(s){var e=ne,t;if(!this.regexp_eatClassSetRange(s))if(t=this.regexp_eatClassSetOperand(s)){t===q&&(e=q);for(var n=s.pos;s.eatChars([38,38]);){if(s.current()!==38&&(t=this.regexp_eatClassSetOperand(s))){t!==q&&(e=ne);continue}s.raise("Invalid character in character class")}if(n!==s.pos)return e;for(;s.eatChars([45,45]);)this.regexp_eatClassSetOperand(s)||s.raise("Invalid character in character class");if(n!==s.pos)return e}else s.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(s)){if(t=this.regexp_eatClassSetOperand(s),!t)return e;t===q&&(e=q)}};y.regexp_eatClassSetRange=function(s){var e=s.pos;if(this.regexp_eatClassSetCharacter(s)){var t=s.lastIntValue;if(s.eat(45)&&this.regexp_eatClassSetCharacter(s)){var n=s.lastIntValue;return t!==-1&&n!==-1&&t>n&&s.raise("Range out of order in character class"),!0}s.pos=e}return!1};y.regexp_eatClassSetOperand=function(s){return this.regexp_eatClassSetCharacter(s)?ne:this.regexp_eatClassStringDisjunction(s)||this.regexp_eatNestedClass(s)};y.regexp_eatNestedClass=function(s){var e=s.pos;if(s.eat(91)){var t=s.eat(94),n=this.regexp_classContents(s);if(s.eat(93))return t&&n===q&&s.raise("Negated character class may contain strings"),n;s.pos=e}if(s.eat(92)){var i=this.regexp_eatCharacterClassEscape(s);if(i)return i;s.pos=e}return null};y.regexp_eatClassStringDisjunction=function(s){var e=s.pos;if(s.eatChars([92,113])){if(s.eat(123)){var t=this.regexp_classStringDisjunctionContents(s);if(s.eat(125))return t}else s.raise("Invalid escape");s.pos=e}return null};y.regexp_classStringDisjunctionContents=function(s){for(var e=this.regexp_classString(s);s.eat(124);)this.regexp_classString(s)===q&&(e=q);return e};y.regexp_classString=function(s){for(var e=0;this.regexp_eatClassSetCharacter(s);)e++;return e===1?ne:q};y.regexp_eatClassSetCharacter=function(s){var e=s.pos;if(s.eat(92))return this.regexp_eatCharacterEscape(s)||this.regexp_eatClassSetReservedPunctuator(s)?!0:s.eat(98)?(s.lastIntValue=8,!0):(s.pos=e,!1);var t=s.current();return t<0||t===s.lookahead()&&Ss(t)||Ts(t)?!1:(s.advance(),s.lastIntValue=t,!0)};function Ss(s){return s===33||s>=35&&s<=38||s>=42&&s<=44||s===46||s>=58&&s<=64||s===94||s===96||s===126}function Ts(s){return s===40||s===41||s===45||s===47||s>=91&&s<=93||s>=123&&s<=125}y.regexp_eatClassSetReservedPunctuator=function(s){var e=s.current();return As(e)?(s.lastIntValue=e,s.advance(),!0):!1};function As(s){return s===33||s===35||s===37||s===38||s===44||s===45||s>=58&&s<=62||s===64||s===96||s===126}y.regexp_eatClassControlLetter=function(s){var e=s.current();return Le(e)||e===95?(s.lastIntValue=e%32,s.advance(),!0):!1};y.regexp_eatHexEscapeSequence=function(s){var e=s.pos;if(s.eat(120)){if(this.regexp_eatFixedHexDigits(s,2))return!0;s.switchU&&s.raise("Invalid escape"),s.pos=e}return!1};y.regexp_eatDecimalDigits=function(s){var e=s.pos,t=0;for(s.lastIntValue=0;Le(t=s.current());)s.lastIntValue=10*s.lastIntValue+(t-48),s.advance();return s.pos!==e};function Le(s){return s>=48&&s<=57}y.regexp_eatHexDigits=function(s){var e=s.pos,t=0;for(s.lastIntValue=0;Ft(t=s.current());)s.lastIntValue=16*s.lastIntValue+Vt(t),s.advance();return s.pos!==e};function Ft(s){return s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102}function Vt(s){return s>=65&&s<=70?10+(s-65):s>=97&&s<=102?10+(s-97):s-48}y.regexp_eatLegacyOctalEscapeSequence=function(s){if(this.regexp_eatOctalDigit(s)){var e=s.lastIntValue;if(this.regexp_eatOctalDigit(s)){var t=s.lastIntValue;e<=3&&this.regexp_eatOctalDigit(s)?s.lastIntValue=e*64+t*8+s.lastIntValue:s.lastIntValue=e*8+t}else s.lastIntValue=e;return!0}return!1};y.regexp_eatOctalDigit=function(s){var e=s.current();return Dt(e)?(s.lastIntValue=e-48,s.advance(),!0):(s.lastIntValue=0,!1)};function Dt(s){return s>=48&&s<=55}y.regexp_eatFixedHexDigits=function(s,e){var t=s.pos;s.lastIntValue=0;for(var n=0;n<e;++n){var i=s.current();if(!Ft(i))return s.pos=t,!1;s.lastIntValue=16*s.lastIntValue+Vt(i),s.advance()}return!0};var Ze=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new ke(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},P=M.prototype;P.next=function(s){!s&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Ze(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};P.getToken=function(){return this.next(),new Ze(this)};typeof Symbol<"u"&&(P[Symbol.iterator]=function(){var s=this;return{next:function(){var e=s.getToken();return{done:e.type===u.eof,value:e}}}});P.nextToken=function(){var s=this.curContext();if((!s||!s.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(u.eof);if(s.override)return s.override(this);this.readToken(this.fullCharCodeAtPos())};P.readToken=function(s){return Y(s,this.options.ecmaVersion>=6)||s===92?this.readWord():this.getTokenFromCode(s)};P.fullCharCodeAtPos=function(){var s=this.input.charCodeAt(this.pos);if(s<=55295||s>=56320)return s;var e=this.input.charCodeAt(this.pos+1);return e<=56319||e>=57344?s:(s<<10)+e-56613888};P.skipBlockComment=function(){var s=this.options.onComment&&this.curPosition(),e=this.pos,t=this.input.indexOf("*/",this.pos+=2);if(t===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=t+2,this.options.locations)for(var n=void 0,i=e;(n=ct(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=n;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,t),e,this.pos,s,this.curPosition())};P.skipLineComment=function(s){for(var e=this.pos,t=this.options.onComment&&this.curPosition(),n=this.input.charCodeAt(this.pos+=s);this.pos<this.input.length&&!xe(n);)n=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+s,this.pos),e,this.pos,t,this.curPosition())};P.skipSpace=function(){e:for(;this.pos<this.input.length;){var s=this.input.charCodeAt(this.pos);switch(s){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(s>8&&s<14||s>=5760&&ut.test(String.fromCharCode(s)))++this.pos;else break e}}};P.finishToken=function(s,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var t=this.type;this.type=s,this.value=e,this.updateContext(t)};P.readToken_dot=function(){var s=this.input.charCodeAt(this.pos+1);if(s>=48&&s<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&s===46&&e===46?(this.pos+=3,this.finishToken(u.ellipsis)):(++this.pos,this.finishToken(u.dot))};P.readToken_slash=function(){var s=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):s===61?this.finishOp(u.assign,2):this.finishOp(u.slash,1)};P.readToken_mult_modulo_exp=function(s){var e=this.input.charCodeAt(this.pos+1),t=1,n=s===42?u.star:u.modulo;return this.options.ecmaVersion>=7&&s===42&&e===42&&(++t,n=u.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(u.assign,t+1):this.finishOp(n,t)};P.readToken_pipe_amp=function(s){var e=this.input.charCodeAt(this.pos+1);if(e===s){if(this.options.ecmaVersion>=12){var t=this.input.charCodeAt(this.pos+2);if(t===61)return this.finishOp(u.assign,3)}return this.finishOp(s===124?u.logicalOR:u.logicalAND,2)}return e===61?this.finishOp(u.assign,2):this.finishOp(s===124?u.bitwiseOR:u.bitwiseAND,1)};P.readToken_caret=function(){var s=this.input.charCodeAt(this.pos+1);return s===61?this.finishOp(u.assign,2):this.finishOp(u.bitwiseXOR,1)};P.readToken_plus_min=function(s){var e=this.input.charCodeAt(this.pos+1);return e===s?e===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||$.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(u.incDec,2):e===61?this.finishOp(u.assign,2):this.finishOp(u.plusMin,1)};P.readToken_lt_gt=function(s){var e=this.input.charCodeAt(this.pos+1),t=1;return e===s?(t=s===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+t)===61?this.finishOp(u.assign,t+1):this.finishOp(u.bitShift,t)):e===33&&s===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(t=2),this.finishOp(u.relational,t))};P.readToken_eq_excl=function(s){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(u.equality,this.input.charCodeAt(this.pos+2)===61?3:2):s===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(u.arrow)):this.finishOp(s===61?u.eq:u.prefix,1)};P.readToken_question=function(){var s=this.options.ecmaVersion;if(s>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var t=this.input.charCodeAt(this.pos+2);if(t<48||t>57)return this.finishOp(u.questionDot,2)}if(e===63){if(s>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(u.assign,3)}return this.finishOp(u.coalesce,2)}}return this.finishOp(u.question,1)};P.readToken_numberSign=function(){var s=this.options.ecmaVersion,e=35;if(s>=13&&(++this.pos,e=this.fullCharCodeAtPos(),Y(e,!0)||e===92))return this.finishToken(u.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+se(e)+"'")};P.getTokenFromCode=function(s){switch(s){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(u.parenL);case 41:return++this.pos,this.finishToken(u.parenR);case 59:return++this.pos,this.finishToken(u.semi);case 44:return++this.pos,this.finishToken(u.comma);case 91:return++this.pos,this.finishToken(u.bracketL);case 93:return++this.pos,this.finishToken(u.bracketR);case 123:return++this.pos,this.finishToken(u.braceL);case 125:return++this.pos,this.finishToken(u.braceR);case 58:return++this.pos,this.finishToken(u.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(u.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(s);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(s);case 124:case 38:return this.readToken_pipe_amp(s);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(s);case 60:case 62:return this.readToken_lt_gt(s);case 61:case 33:return this.readToken_eq_excl(s);case 63:return this.readToken_question();case 126:return this.finishOp(u.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+se(s)+"'")};P.finishOp=function(s,e){var t=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(s,t)};P.readRegexp=function(){for(var s,e,t=this.pos;;){this.pos>=this.input.length&&this.raise(t,"Unterminated regular expression");var n=this.input.charAt(this.pos);if($.test(n)&&this.raise(t,"Unterminated regular expression"),s)s=!1;else{if(n==="[")e=!0;else if(n==="]"&&e)e=!1;else if(n==="/"&&!e)break;s=n==="\\"}++this.pos}var i=this.input.slice(t,this.pos);++this.pos;var r=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(r);var o=this.regexpState||(this.regexpState=new ee(this));o.reset(t,i,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(i,a)}catch{}return this.finishToken(u.regexp,{pattern:i,flags:a,value:c})};P.readInt=function(s,e,t){for(var n=this.options.ecmaVersion>=12&&e===void 0,i=t&&this.input.charCodeAt(this.pos)===48,r=this.pos,a=0,o=0,c=0,l=e??1/0;c<l;++c,++this.pos){var p=this.input.charCodeAt(this.pos),h=void 0;if(n&&p===95){i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),c===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=p;continue}if(p>=97?h=p-97+10:p>=65?h=p-65+10:p>=48&&p<=57?h=p-48:h=1/0,h>=s)break;o=p,a=a*s+h}return n&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===r||e!=null&&this.pos-r!==e?null:a};function Ps(s,e){return e?parseInt(s,8):parseFloat(s.replace(/_/g,""))}function Bt(s){return typeof BigInt!="function"?null:BigInt(s.replace(/_/g,""))}P.readRadixNumber=function(s){var e=this.pos;this.pos+=2;var t=this.readInt(s);return t==null&&this.raise(this.start+2,"Expected number in radix "+s),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(t=Bt(this.input.slice(e,this.pos)),++this.pos):Y(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,t)};P.readNumber=function(s){var e=this.pos;!s&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var t=this.pos-e>=2&&this.input.charCodeAt(e)===48;t&&this.strict&&this.raise(e,"Invalid number");var n=this.input.charCodeAt(this.pos);if(!t&&!s&&this.options.ecmaVersion>=11&&n===110){var i=Bt(this.input.slice(e,this.pos));return++this.pos,Y(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,i)}t&&/[89]/.test(this.input.slice(e,this.pos))&&(t=!1),n===46&&!t&&(++this.pos,this.readInt(10),n=this.input.charCodeAt(this.pos)),(n===69||n===101)&&!t&&(n=this.input.charCodeAt(++this.pos),(n===43||n===45)&&++this.pos,this.readInt(10)===null&&this.raise(e,"Invalid number")),Y(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=Ps(this.input.slice(e,this.pos),t);return this.finishToken(u.num,r)};P.readCodePoint=function(){var s=this.input.charCodeAt(this.pos),e;if(s===123){this.options.ecmaVersion<6&&this.unexpected();var t=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(t,"Code point out of bounds")}else e=this.readHexChar(4);return e};P.readString=function(s){for(var e="",t=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var n=this.input.charCodeAt(this.pos);if(n===s)break;n===92?(e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!1),t=this.pos):n===8232||n===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(xe(n)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(t,this.pos++),this.finishToken(u.string,e)};var $t={};P.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(s){if(s===$t)this.readInvalidTemplateToken();else throw s}this.inTemplateElement=!1};P.invalidStringToken=function(s,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw $t;this.raise(s,e)};P.readTmplToken=function(){for(var s="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var t=this.input.charCodeAt(this.pos);if(t===96||t===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===u.template||this.type===u.invalidTemplate)?t===36?(this.pos+=2,this.finishToken(u.dollarBraceL)):(++this.pos,this.finishToken(u.backQuote)):(s+=this.input.slice(e,this.pos),this.finishToken(u.template,s));if(t===92)s+=this.input.slice(e,this.pos),s+=this.readEscapedChar(!0),e=this.pos;else if(xe(t)){switch(s+=this.input.slice(e,this.pos),++this.pos,t){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:s+=`
|
|
6
|
-
`;break;default:s+=String.fromCharCode(t);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};
|
|
5
|
+
`),cooked:this.value},this.next(),t.tail=this.type===u.backQuote,this.finishNode(t,"TemplateElement")};S.parseTemplate=function(s){s===void 0&&(s={});var e=s.isTagged;e===void 0&&(e=!1);var t=this.startNode();this.next(),t.expressions=[];var n=this.parseTemplateElement({isTagged:e});for(t.quasis=[n];!n.tail;)this.type===u.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(u.dollarBraceL),t.expressions.push(this.parseExpression()),this.expect(u.braceR),t.quasis.push(n=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(t,"TemplateLiteral")};S.isAsyncProp=function(s){return!s.computed&&s.key.type==="Identifier"&&s.key.name==="async"&&(this.type===u.name||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===u.star)&&!D.test(this.input.slice(this.lastTokEnd,this.start))};S.parseObj=function(s,e){var t=this.startNode(),n=!0,i={};for(t.properties=[],this.next();!this.eat(u.braceR);){if(n)n=!1;else if(this.expect(u.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(u.braceR))break;var r=this.parseProperty(s,e);s||this.checkPropClash(r,i,e),t.properties.push(r)}return this.finishNode(t,s?"ObjectPattern":"ObjectExpression")};S.parseProperty=function(s,e){var t=this.startNode(),n,i,r,a;if(this.options.ecmaVersion>=9&&this.eat(u.ellipsis))return s?(t.argument=this.parseIdent(!1),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(t,"RestElement")):(t.argument=this.parseMaybeAssign(!1,e),this.type===u.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(t,"SpreadElement"));this.options.ecmaVersion>=6&&(t.method=!1,t.shorthand=!1,(s||e)&&(r=this.start,a=this.startLoc),s||(n=this.eat(u.star)));var o=this.containsEsc;return this.parsePropertyName(t),!s&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(t)?(i=!0,n=this.options.ecmaVersion>=9&&this.eat(u.star),this.parsePropertyName(t)):i=!1,this.parsePropertyValue(t,s,n,i,r,a,e,o),this.finishNode(t,"Property")};S.parseGetterSetter=function(s){var e=s.key.name;this.parsePropertyName(s),s.value=this.parseMethod(!1),s.kind=e;var t=s.kind==="get"?0:1;if(s.value.params.length!==t){var n=s.value.start;s.kind==="get"?this.raiseRecoverable(n,"getter should have no params"):this.raiseRecoverable(n,"setter should have exactly one param")}else s.kind==="set"&&s.value.params[0].type==="RestElement"&&this.raiseRecoverable(s.value.params[0].start,"Setter cannot use rest params")};S.parsePropertyValue=function(s,e,t,n,i,r,a,o){(t||n)&&this.type===u.colon&&this.unexpected(),this.eat(u.colon)?(s.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),s.kind="init"):this.options.ecmaVersion>=6&&this.type===u.parenL?(e&&this.unexpected(),s.method=!0,s.value=this.parseMethod(t,n),s.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!s.computed&&s.key.type==="Identifier"&&(s.key.name==="get"||s.key.name==="set")&&this.type!==u.comma&&this.type!==u.braceR&&this.type!==u.eq?((t||n)&&this.unexpected(),this.parseGetterSetter(s)):this.options.ecmaVersion>=6&&!s.computed&&s.key.type==="Identifier"?((t||n)&&this.unexpected(),this.checkUnreserved(s.key),s.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=i),e?s.value=this.parseMaybeDefault(i,r,this.copyNode(s.key)):this.type===u.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),s.value=this.parseMaybeDefault(i,r,this.copyNode(s.key))):s.value=this.copyNode(s.key),s.kind="init",s.shorthand=!0):this.unexpected()};S.parsePropertyName=function(s){if(this.options.ecmaVersion>=6){if(this.eat(u.bracketL))return s.computed=!0,s.key=this.parseMaybeAssign(),this.expect(u.bracketR),s.key;s.computed=!1}return s.key=this.type===u.num||this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};S.initFunction=function(s){s.id=null,this.options.ecmaVersion>=6&&(s.generator=s.expression=!1),this.options.ecmaVersion>=8&&(s.async=!1)};S.parseMethod=function(s,e,t){var n=this.startNode(),i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=s),this.options.ecmaVersion>=8&&(n.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ke(e,n.generator)|Ie|(t?dt:0)),this.expect(u.parenL),n.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1,!0,!1),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(n,"FunctionExpression")};S.parseArrowExpression=function(s,e,t,n){var i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(Ke(t,!1)|ze),this.initFunction(s),this.options.ecmaVersion>=8&&(s.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,s.params=this.toAssignableList(e,!0),this.parseFunctionBody(s,!0,!1,n),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(s,"ArrowFunctionExpression")};S.parseFunctionBody=function(s,e,t,n){var i=e&&this.type!==u.braceL,r=this.strict,a=!1;if(i)s.body=this.parseMaybeAssign(n),s.expression=!0,this.checkParams(s,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(s.params);(!r||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(s.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(s,!r&&!a&&!e&&!t&&this.isSimpleParamList(s.params)),this.strict&&s.id&&this.checkLValSimple(s.id,xt),s.body=this.parseBlock(!1,void 0,a&&!r),s.expression=!1,this.adaptDirectivePrologue(s.body.body),this.labels=c}this.exitScope()};S.isSimpleParamList=function(s){for(var e=0,t=s;e<t.length;e+=1){var n=t[e];if(n.type!=="Identifier")return!1}return!0};S.checkParams=function(s,e){for(var t=Object.create(null),n=0,i=s.params;n<i.length;n+=1){var r=i[n];this.checkLValInnerPattern(r,Ge,e?null:t)}};S.parseExprList=function(s,e,t,n){for(var i=[],r=!0;!this.eat(s);){if(r)r=!1;else if(this.expect(u.comma),e&&this.afterTrailingComma(s))break;var a=void 0;t&&this.type===u.comma?a=null:this.type===u.ellipsis?(a=this.parseSpread(n),n&&this.type===u.comma&&n.trailingComma<0&&(n.trailingComma=this.start)):a=this.parseMaybeAssign(!1,n),i.push(a)}return i};S.checkUnreserved=function(s){var e=s.start,t=s.end,n=s.name;if(this.inGenerator&&n==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&n==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&Me)&&n==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(n==="arguments"||n==="await")&&this.raise(e,"Cannot use "+n+" in class static initialization block"),this.keywords.test(n)&&this.raise(e,"Unexpected keyword '"+n+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,t).indexOf("\\")!==-1)){var i=this.strict?this.reservedWordsStrict:this.reservedWords;i.test(n)&&(!this.inAsync&&n==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+n+"' is reserved"))}};S.parseIdent=function(s){var e=this.parseIdentNode();return this.next(!!s),this.finishNode(e,"Identifier"),s||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};S.parseIdentNode=function(){var s=this.startNode();return this.type===u.name?s.name=this.value:this.type.keyword?(s.name=this.type.keyword,(s.name==="class"||s.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=u.name):this.unexpected(),s};S.parsePrivateIdent=function(){var s=this.startNode();return this.type===u.privateId?s.name=this.value:this.unexpected(),this.next(),this.finishNode(s,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(s)),s};S.parseYield=function(s){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===u.semi||this.canInsertSemicolon()||this.type!==u.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(u.star),e.argument=this.parseMaybeAssign(s)),this.finishNode(e,"YieldExpression")};S.parseAwait=function(s){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,s),this.finishNode(e,"AwaitExpression")};var _e=M.prototype;_e.raise=function(s,e){var t=pt(this.input,s);e+=" ("+t.line+":"+t.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var n=new SyntaxError(e);throw n.pos=s,n.loc=t,n.raisedAt=this.pos,n};_e.raiseRecoverable=_e.raise;_e.curPosition=function(){if(this.options.locations)return new ve(this.curLine,this.pos-this.lineStart)};var oe=M.prototype,as=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};oe.enterScope=function(s){this.scopeStack.push(new as(s))};oe.exitScope=function(){this.scopeStack.pop()};oe.treatFunctionsAsVarInScope=function(s){return s.flags&be||!this.inModule&&s.flags&Se};oe.declareName=function(s,e,t){var n=!1;if(e===ie){var i=this.currentScope();n=i.lexical.indexOf(s)>-1||i.functions.indexOf(s)>-1||i.var.indexOf(s)>-1,i.lexical.push(s),this.inModule&&i.flags&Se&&delete this.undefinedExports[s]}else if(e===gt){var r=this.currentScope();r.lexical.push(s)}else if(e===mt){var a=this.currentScope();this.treatFunctionsAsVar?n=a.lexical.indexOf(s)>-1:n=a.lexical.indexOf(s)>-1||a.var.indexOf(s)>-1,a.functions.push(s)}else for(var o=this.scopeStack.length-1;o>=0;--o){var c=this.scopeStack[o];if(c.lexical.indexOf(s)>-1&&!(c.flags&ft&&c.lexical[0]===s)||!this.treatFunctionsAsVarInScope(c)&&c.functions.indexOf(s)>-1){n=!0;break}if(c.var.push(s),this.inModule&&c.flags&Se&&delete this.undefinedExports[s],c.flags&Me)break}n&&this.raiseRecoverable(t,"Identifier '"+s+"' has already been declared")};oe.checkLocalExport=function(s){this.scopeStack[0].lexical.indexOf(s.name)===-1&&this.scopeStack[0].var.indexOf(s.name)===-1&&(this.undefinedExports[s.name]=s)};oe.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};oe.currentVarScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(Me|Te|le))return e}};oe.currentThisScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(Me|Te|le)&&!(e.flags&ze))return e}};var Oe=function(e,t,n){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new ke(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ae=M.prototype;Ae.startNode=function(){return new Oe(this,this.start,this.startLoc)};Ae.startNodeAt=function(s,e){return new Oe(this,s,e)};function Ct(s,e,t,n){return s.type=e,s.end=t,this.options.locations&&(s.loc.end=n),this.options.ranges&&(s.range[1]=t),s}Ae.finishNode=function(s,e){return Ct.call(this,s,e,this.lastTokEnd,this.lastTokEndLoc)};Ae.finishNodeAt=function(s,e,t,n){return Ct.call(this,s,e,t,n)};Ae.copyNode=function(s){var e=new Oe(this,s.start,this.startLoc);for(var t in s)e[t]=s[t];return e};var os="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",yt="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",vt=yt+" Extended_Pictographic",St=vt,Tt=St+" EBase EComp EMod EPres ExtPict",At=Tt,cs=At,us={9:yt,10:vt,11:St,12:Tt,13:At,14:cs},ls="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",ps={9:"",10:"",11:"",12:"",13:"",14:ls},nt="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",wt="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Pt=wt+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",_t=Pt+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Nt=_t+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",kt=Nt+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",hs=kt+" "+os,fs={9:wt,10:Pt,11:_t,12:Nt,13:kt,14:hs},It={};function ds(s){var e=It[s]={binary:re(us[s]+" "+nt),binaryOfStrings:re(ps[s]),nonBinary:{General_Category:re(nt),Script:re(fs[s])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var De=0,it=[9,10,11,12,13,14];De<it.length;De+=1){var ms=it[De];ds(ms)}var y=M.prototype,Ne=function(e,t){this.parent=e,this.base=t||this};Ne.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1};Ne.prototype.sibling=function(){return new Ne(this.parent,this.base)};var ee=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=It[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};ee.prototype.reset=function(e,t,n){var i=n.indexOf("v")!==-1,r=n.indexOf("u")!==-1;this.start=e|0,this.source=t+"",this.flags=n,i&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=r&&this.parser.options.ecmaVersion>=9)};ee.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};ee.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,i=n.length;if(e>=i)return-1;var r=n.charCodeAt(e);if(!(t||this.switchU)||r<=55295||r>=57344||e+1>=i)return r;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(r<<10)+a-56613888:r};ee.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,i=n.length;if(e>=i)return i;var r=n.charCodeAt(e),a;return!(t||this.switchU)||r<=55295||r>=57344||e+1>=i||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2};ee.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};ee.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};ee.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};ee.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1};ee.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,i=0,r=e;i<r.length;i+=1){var a=r[i],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0};y.validateRegExpFlags=function(s){for(var e=s.validFlags,t=s.flags,n=!1,i=!1,r=0;r<t.length;r++){var a=t.charAt(r);e.indexOf(a)===-1&&this.raise(s.start,"Invalid regular expression flag"),t.indexOf(a,r+1)>-1&&this.raise(s.start,"Duplicate regular expression flag"),a==="u"&&(n=!0),a==="v"&&(i=!0)}this.options.ecmaVersion>=15&&n&&i&&this.raise(s.start,"Invalid regular expression flag")};function gs(s){for(var e in s)return!0;return!1}y.validateRegExpPattern=function(s){this.regexp_pattern(s),!s.switchN&&this.options.ecmaVersion>=9&&gs(s.groupNames)&&(s.switchN=!0,this.regexp_pattern(s))};y.regexp_pattern=function(s){s.pos=0,s.lastIntValue=0,s.lastStringValue="",s.lastAssertionIsQuantifiable=!1,s.numCapturingParens=0,s.maxBackReference=0,s.groupNames=Object.create(null),s.backReferenceNames.length=0,s.branchID=null,this.regexp_disjunction(s),s.pos!==s.source.length&&(s.eat(41)&&s.raise("Unmatched ')'"),(s.eat(93)||s.eat(125))&&s.raise("Lone quantifier brackets")),s.maxBackReference>s.numCapturingParens&&s.raise("Invalid escape");for(var e=0,t=s.backReferenceNames;e<t.length;e+=1){var n=t[e];s.groupNames[n]||s.raise("Invalid named capture referenced")}};y.regexp_disjunction=function(s){var e=this.options.ecmaVersion>=16;for(e&&(s.branchID=new Ne(s.branchID,null)),this.regexp_alternative(s);s.eat(124);)e&&(s.branchID=s.branchID.sibling()),this.regexp_alternative(s);e&&(s.branchID=s.branchID.parent),this.regexp_eatQuantifier(s,!0)&&s.raise("Nothing to repeat"),s.eat(123)&&s.raise("Lone quantifier brackets")};y.regexp_alternative=function(s){for(;s.pos<s.source.length&&this.regexp_eatTerm(s););};y.regexp_eatTerm=function(s){return this.regexp_eatAssertion(s)?(s.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(s)&&s.switchU&&s.raise("Invalid quantifier"),!0):(s.switchU?this.regexp_eatAtom(s):this.regexp_eatExtendedAtom(s))?(this.regexp_eatQuantifier(s),!0):!1};y.regexp_eatAssertion=function(s){var e=s.pos;if(s.lastAssertionIsQuantifiable=!1,s.eat(94)||s.eat(36))return!0;if(s.eat(92)){if(s.eat(66)||s.eat(98))return!0;s.pos=e}if(s.eat(40)&&s.eat(63)){var t=!1;if(this.options.ecmaVersion>=9&&(t=s.eat(60)),s.eat(61)||s.eat(33))return this.regexp_disjunction(s),s.eat(41)||s.raise("Unterminated group"),s.lastAssertionIsQuantifiable=!t,!0}return s.pos=e,!1};y.regexp_eatQuantifier=function(s,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(s,e)?(s.eat(63),!0):!1};y.regexp_eatQuantifierPrefix=function(s,e){return s.eat(42)||s.eat(43)||s.eat(63)||this.regexp_eatBracedQuantifier(s,e)};y.regexp_eatBracedQuantifier=function(s,e){var t=s.pos;if(s.eat(123)){var n=0,i=-1;if(this.regexp_eatDecimalDigits(s)&&(n=s.lastIntValue,s.eat(44)&&this.regexp_eatDecimalDigits(s)&&(i=s.lastIntValue),s.eat(125)))return i!==-1&&i<n&&!e&&s.raise("numbers out of order in {} quantifier"),!0;s.switchU&&!e&&s.raise("Incomplete quantifier"),s.pos=t}return!1};y.regexp_eatAtom=function(s){return this.regexp_eatPatternCharacters(s)||s.eat(46)||this.regexp_eatReverseSolidusAtomEscape(s)||this.regexp_eatCharacterClass(s)||this.regexp_eatUncapturingGroup(s)||this.regexp_eatCapturingGroup(s)};y.regexp_eatReverseSolidusAtomEscape=function(s){var e=s.pos;if(s.eat(92)){if(this.regexp_eatAtomEscape(s))return!0;s.pos=e}return!1};y.regexp_eatUncapturingGroup=function(s){var e=s.pos;if(s.eat(40)){if(s.eat(63)){if(this.options.ecmaVersion>=16){var t=this.regexp_eatModifiers(s),n=s.eat(45);if(t||n){for(var i=0;i<t.length;i++){var r=t.charAt(i);t.indexOf(r,i+1)>-1&&s.raise("Duplicate regular expression modifiers")}if(n){var a=this.regexp_eatModifiers(s);!t&&!a&&s.current()===58&&s.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var c=a.charAt(o);(a.indexOf(c,o+1)>-1||t.indexOf(c)>-1)&&s.raise("Duplicate regular expression modifiers")}}}}if(s.eat(58)){if(this.regexp_disjunction(s),s.eat(41))return!0;s.raise("Unterminated group")}}s.pos=e}return!1};y.regexp_eatCapturingGroup=function(s){if(s.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(s):s.current()===63&&s.raise("Invalid group"),this.regexp_disjunction(s),s.eat(41))return s.numCapturingParens+=1,!0;s.raise("Unterminated group")}return!1};y.regexp_eatModifiers=function(s){for(var e="",t=0;(t=s.current())!==-1&&xs(t);)e+=se(t),s.advance();return e};function xs(s){return s===105||s===109||s===115}y.regexp_eatExtendedAtom=function(s){return s.eat(46)||this.regexp_eatReverseSolidusAtomEscape(s)||this.regexp_eatCharacterClass(s)||this.regexp_eatUncapturingGroup(s)||this.regexp_eatCapturingGroup(s)||this.regexp_eatInvalidBracedQuantifier(s)||this.regexp_eatExtendedPatternCharacter(s)};y.regexp_eatInvalidBracedQuantifier=function(s){return this.regexp_eatBracedQuantifier(s,!0)&&s.raise("Nothing to repeat"),!1};y.regexp_eatSyntaxCharacter=function(s){var e=s.current();return Mt(e)?(s.lastIntValue=e,s.advance(),!0):!1};function Mt(s){return s===36||s>=40&&s<=43||s===46||s===63||s>=91&&s<=94||s>=123&&s<=125}y.regexp_eatPatternCharacters=function(s){for(var e=s.pos,t=0;(t=s.current())!==-1&&!Mt(t);)s.advance();return s.pos!==e};y.regexp_eatExtendedPatternCharacter=function(s){var e=s.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(s.advance(),!0):!1};y.regexp_groupSpecifier=function(s){if(s.eat(63)){this.regexp_eatGroupName(s)||s.raise("Invalid group");var e=this.options.ecmaVersion>=16,t=s.groupNames[s.lastStringValue];if(t)if(e)for(var n=0,i=t;n<i.length;n+=1){var r=i[n];r.separatedFrom(s.branchID)||s.raise("Duplicate capture group name")}else s.raise("Duplicate capture group name");e?(t||(s.groupNames[s.lastStringValue]=[])).push(s.branchID):s.groupNames[s.lastStringValue]=!0}};y.regexp_eatGroupName=function(s){if(s.lastStringValue="",s.eat(60)){if(this.regexp_eatRegExpIdentifierName(s)&&s.eat(62))return!0;s.raise("Invalid capture group name")}return!1};y.regexp_eatRegExpIdentifierName=function(s){if(s.lastStringValue="",this.regexp_eatRegExpIdentifierStart(s)){for(s.lastStringValue+=se(s.lastIntValue);this.regexp_eatRegExpIdentifierPart(s);)s.lastStringValue+=se(s.lastIntValue);return!0}return!1};y.regexp_eatRegExpIdentifierStart=function(s){var e=s.pos,t=this.options.ecmaVersion>=11,n=s.current(t);return s.advance(t),n===92&&this.regexp_eatRegExpUnicodeEscapeSequence(s,t)&&(n=s.lastIntValue),Es(n)?(s.lastIntValue=n,!0):(s.pos=e,!1)};function Es(s){return Y(s,!0)||s===36||s===95}y.regexp_eatRegExpIdentifierPart=function(s){var e=s.pos,t=this.options.ecmaVersion>=11,n=s.current(t);return s.advance(t),n===92&&this.regexp_eatRegExpUnicodeEscapeSequence(s,t)&&(n=s.lastIntValue),bs(n)?(s.lastIntValue=n,!0):(s.pos=e,!1)};function bs(s){return ae(s,!0)||s===36||s===95||s===8204||s===8205}y.regexp_eatAtomEscape=function(s){return this.regexp_eatBackReference(s)||this.regexp_eatCharacterClassEscape(s)||this.regexp_eatCharacterEscape(s)||s.switchN&&this.regexp_eatKGroupName(s)?!0:(s.switchU&&(s.current()===99&&s.raise("Invalid unicode escape"),s.raise("Invalid escape")),!1)};y.regexp_eatBackReference=function(s){var e=s.pos;if(this.regexp_eatDecimalEscape(s)){var t=s.lastIntValue;if(s.switchU)return t>s.maxBackReference&&(s.maxBackReference=t),!0;if(t<=s.numCapturingParens)return!0;s.pos=e}return!1};y.regexp_eatKGroupName=function(s){if(s.eat(107)){if(this.regexp_eatGroupName(s))return s.backReferenceNames.push(s.lastStringValue),!0;s.raise("Invalid named reference")}return!1};y.regexp_eatCharacterEscape=function(s){return this.regexp_eatControlEscape(s)||this.regexp_eatCControlLetter(s)||this.regexp_eatZero(s)||this.regexp_eatHexEscapeSequence(s)||this.regexp_eatRegExpUnicodeEscapeSequence(s,!1)||!s.switchU&&this.regexp_eatLegacyOctalEscapeSequence(s)||this.regexp_eatIdentityEscape(s)};y.regexp_eatCControlLetter=function(s){var e=s.pos;if(s.eat(99)){if(this.regexp_eatControlLetter(s))return!0;s.pos=e}return!1};y.regexp_eatZero=function(s){return s.current()===48&&!Le(s.lookahead())?(s.lastIntValue=0,s.advance(),!0):!1};y.regexp_eatControlEscape=function(s){var e=s.current();return e===116?(s.lastIntValue=9,s.advance(),!0):e===110?(s.lastIntValue=10,s.advance(),!0):e===118?(s.lastIntValue=11,s.advance(),!0):e===102?(s.lastIntValue=12,s.advance(),!0):e===114?(s.lastIntValue=13,s.advance(),!0):!1};y.regexp_eatControlLetter=function(s){var e=s.current();return Rt(e)?(s.lastIntValue=e%32,s.advance(),!0):!1};function Rt(s){return s>=65&&s<=90||s>=97&&s<=122}y.regexp_eatRegExpUnicodeEscapeSequence=function(s,e){e===void 0&&(e=!1);var t=s.pos,n=e||s.switchU;if(s.eat(117)){if(this.regexp_eatFixedHexDigits(s,4)){var i=s.lastIntValue;if(n&&i>=55296&&i<=56319){var r=s.pos;if(s.eat(92)&&s.eat(117)&&this.regexp_eatFixedHexDigits(s,4)){var a=s.lastIntValue;if(a>=56320&&a<=57343)return s.lastIntValue=(i-55296)*1024+(a-56320)+65536,!0}s.pos=r,s.lastIntValue=i}return!0}if(n&&s.eat(123)&&this.regexp_eatHexDigits(s)&&s.eat(125)&&Cs(s.lastIntValue))return!0;n&&s.raise("Invalid unicode escape"),s.pos=t}return!1};function Cs(s){return s>=0&&s<=1114111}y.regexp_eatIdentityEscape=function(s){if(s.switchU)return this.regexp_eatSyntaxCharacter(s)?!0:s.eat(47)?(s.lastIntValue=47,!0):!1;var e=s.current();return e!==99&&(!s.switchN||e!==107)?(s.lastIntValue=e,s.advance(),!0):!1};y.regexp_eatDecimalEscape=function(s){s.lastIntValue=0;var e=s.current();if(e>=49&&e<=57){do s.lastIntValue=10*s.lastIntValue+(e-48),s.advance();while((e=s.current())>=48&&e<=57);return!0}return!1};var Ot=0,ne=1,X=2;y.regexp_eatCharacterClassEscape=function(s){var e=s.current();if(ys(e))return s.lastIntValue=-1,s.advance(),ne;var t=!1;if(s.switchU&&this.options.ecmaVersion>=9&&((t=e===80)||e===112)){s.lastIntValue=-1,s.advance();var n;if(s.eat(123)&&(n=this.regexp_eatUnicodePropertyValueExpression(s))&&s.eat(125))return t&&n===X&&s.raise("Invalid property name"),n;s.raise("Invalid property name")}return Ot};function ys(s){return s===100||s===68||s===115||s===83||s===119||s===87}y.regexp_eatUnicodePropertyValueExpression=function(s){var e=s.pos;if(this.regexp_eatUnicodePropertyName(s)&&s.eat(61)){var t=s.lastStringValue;if(this.regexp_eatUnicodePropertyValue(s)){var n=s.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(s,t,n),ne}}if(s.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(s)){var i=s.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(s,i)}return Ot};y.regexp_validateUnicodePropertyNameAndValue=function(s,e,t){Ee(s.unicodeProperties.nonBinary,e)||s.raise("Invalid property name"),s.unicodeProperties.nonBinary[e].test(t)||s.raise("Invalid property value")};y.regexp_validateUnicodePropertyNameOrValue=function(s,e){if(s.unicodeProperties.binary.test(e))return ne;if(s.switchV&&s.unicodeProperties.binaryOfStrings.test(e))return X;s.raise("Invalid property name")};y.regexp_eatUnicodePropertyName=function(s){var e=0;for(s.lastStringValue="";Lt(e=s.current());)s.lastStringValue+=se(e),s.advance();return s.lastStringValue!==""};function Lt(s){return Rt(s)||s===95}y.regexp_eatUnicodePropertyValue=function(s){var e=0;for(s.lastStringValue="";vs(e=s.current());)s.lastStringValue+=se(e),s.advance();return s.lastStringValue!==""};function vs(s){return Lt(s)||Le(s)}y.regexp_eatLoneUnicodePropertyNameOrValue=function(s){return this.regexp_eatUnicodePropertyValue(s)};y.regexp_eatCharacterClass=function(s){if(s.eat(91)){var e=s.eat(94),t=this.regexp_classContents(s);return s.eat(93)||s.raise("Unterminated character class"),e&&t===X&&s.raise("Negated character class may contain strings"),!0}return!1};y.regexp_classContents=function(s){return s.current()===93?ne:s.switchV?this.regexp_classSetExpression(s):(this.regexp_nonEmptyClassRanges(s),ne)};y.regexp_nonEmptyClassRanges=function(s){for(;this.regexp_eatClassAtom(s);){var e=s.lastIntValue;if(s.eat(45)&&this.regexp_eatClassAtom(s)){var t=s.lastIntValue;s.switchU&&(e===-1||t===-1)&&s.raise("Invalid character class"),e!==-1&&t!==-1&&e>t&&s.raise("Range out of order in character class")}}};y.regexp_eatClassAtom=function(s){var e=s.pos;if(s.eat(92)){if(this.regexp_eatClassEscape(s))return!0;if(s.switchU){var t=s.current();(t===99||Dt(t))&&s.raise("Invalid class escape"),s.raise("Invalid escape")}s.pos=e}var n=s.current();return n!==93?(s.lastIntValue=n,s.advance(),!0):!1};y.regexp_eatClassEscape=function(s){var e=s.pos;if(s.eat(98))return s.lastIntValue=8,!0;if(s.switchU&&s.eat(45))return s.lastIntValue=45,!0;if(!s.switchU&&s.eat(99)){if(this.regexp_eatClassControlLetter(s))return!0;s.pos=e}return this.regexp_eatCharacterClassEscape(s)||this.regexp_eatCharacterEscape(s)};y.regexp_classSetExpression=function(s){var e=ne,t;if(!this.regexp_eatClassSetRange(s))if(t=this.regexp_eatClassSetOperand(s)){t===X&&(e=X);for(var n=s.pos;s.eatChars([38,38]);){if(s.current()!==38&&(t=this.regexp_eatClassSetOperand(s))){t!==X&&(e=ne);continue}s.raise("Invalid character in character class")}if(n!==s.pos)return e;for(;s.eatChars([45,45]);)this.regexp_eatClassSetOperand(s)||s.raise("Invalid character in character class");if(n!==s.pos)return e}else s.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(s)){if(t=this.regexp_eatClassSetOperand(s),!t)return e;t===X&&(e=X)}};y.regexp_eatClassSetRange=function(s){var e=s.pos;if(this.regexp_eatClassSetCharacter(s)){var t=s.lastIntValue;if(s.eat(45)&&this.regexp_eatClassSetCharacter(s)){var n=s.lastIntValue;return t!==-1&&n!==-1&&t>n&&s.raise("Range out of order in character class"),!0}s.pos=e}return!1};y.regexp_eatClassSetOperand=function(s){return this.regexp_eatClassSetCharacter(s)?ne:this.regexp_eatClassStringDisjunction(s)||this.regexp_eatNestedClass(s)};y.regexp_eatNestedClass=function(s){var e=s.pos;if(s.eat(91)){var t=s.eat(94),n=this.regexp_classContents(s);if(s.eat(93))return t&&n===X&&s.raise("Negated character class may contain strings"),n;s.pos=e}if(s.eat(92)){var i=this.regexp_eatCharacterClassEscape(s);if(i)return i;s.pos=e}return null};y.regexp_eatClassStringDisjunction=function(s){var e=s.pos;if(s.eatChars([92,113])){if(s.eat(123)){var t=this.regexp_classStringDisjunctionContents(s);if(s.eat(125))return t}else s.raise("Invalid escape");s.pos=e}return null};y.regexp_classStringDisjunctionContents=function(s){for(var e=this.regexp_classString(s);s.eat(124);)this.regexp_classString(s)===X&&(e=X);return e};y.regexp_classString=function(s){for(var e=0;this.regexp_eatClassSetCharacter(s);)e++;return e===1?ne:X};y.regexp_eatClassSetCharacter=function(s){var e=s.pos;if(s.eat(92))return this.regexp_eatCharacterEscape(s)||this.regexp_eatClassSetReservedPunctuator(s)?!0:s.eat(98)?(s.lastIntValue=8,!0):(s.pos=e,!1);var t=s.current();return t<0||t===s.lookahead()&&Ss(t)||Ts(t)?!1:(s.advance(),s.lastIntValue=t,!0)};function Ss(s){return s===33||s>=35&&s<=38||s>=42&&s<=44||s===46||s>=58&&s<=64||s===94||s===96||s===126}function Ts(s){return s===40||s===41||s===45||s===47||s>=91&&s<=93||s>=123&&s<=125}y.regexp_eatClassSetReservedPunctuator=function(s){var e=s.current();return As(e)?(s.lastIntValue=e,s.advance(),!0):!1};function As(s){return s===33||s===35||s===37||s===38||s===44||s===45||s>=58&&s<=62||s===64||s===96||s===126}y.regexp_eatClassControlLetter=function(s){var e=s.current();return Le(e)||e===95?(s.lastIntValue=e%32,s.advance(),!0):!1};y.regexp_eatHexEscapeSequence=function(s){var e=s.pos;if(s.eat(120)){if(this.regexp_eatFixedHexDigits(s,2))return!0;s.switchU&&s.raise("Invalid escape"),s.pos=e}return!1};y.regexp_eatDecimalDigits=function(s){var e=s.pos,t=0;for(s.lastIntValue=0;Le(t=s.current());)s.lastIntValue=10*s.lastIntValue+(t-48),s.advance();return s.pos!==e};function Le(s){return s>=48&&s<=57}y.regexp_eatHexDigits=function(s){var e=s.pos,t=0;for(s.lastIntValue=0;Ft(t=s.current());)s.lastIntValue=16*s.lastIntValue+Vt(t),s.advance();return s.pos!==e};function Ft(s){return s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102}function Vt(s){return s>=65&&s<=70?10+(s-65):s>=97&&s<=102?10+(s-97):s-48}y.regexp_eatLegacyOctalEscapeSequence=function(s){if(this.regexp_eatOctalDigit(s)){var e=s.lastIntValue;if(this.regexp_eatOctalDigit(s)){var t=s.lastIntValue;e<=3&&this.regexp_eatOctalDigit(s)?s.lastIntValue=e*64+t*8+s.lastIntValue:s.lastIntValue=e*8+t}else s.lastIntValue=e;return!0}return!1};y.regexp_eatOctalDigit=function(s){var e=s.current();return Dt(e)?(s.lastIntValue=e-48,s.advance(),!0):(s.lastIntValue=0,!1)};function Dt(s){return s>=48&&s<=55}y.regexp_eatFixedHexDigits=function(s,e){var t=s.pos;s.lastIntValue=0;for(var n=0;n<e;++n){var i=s.current();if(!Ft(i))return s.pos=t,!1;s.lastIntValue=16*s.lastIntValue+Vt(i),s.advance()}return!0};var Ze=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new ke(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},A=M.prototype;A.next=function(s){!s&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Ze(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};A.getToken=function(){return this.next(),new Ze(this)};typeof Symbol<"u"&&(A[Symbol.iterator]=function(){var s=this;return{next:function(){var e=s.getToken();return{done:e.type===u.eof,value:e}}}});A.nextToken=function(){var s=this.curContext();if((!s||!s.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(u.eof);if(s.override)return s.override(this);this.readToken(this.fullCharCodeAtPos())};A.readToken=function(s){return Y(s,this.options.ecmaVersion>=6)||s===92?this.readWord():this.getTokenFromCode(s)};A.fullCharCodeAtPos=function(){var s=this.input.charCodeAt(this.pos);if(s<=55295||s>=56320)return s;var e=this.input.charCodeAt(this.pos+1);return e<=56319||e>=57344?s:(s<<10)+e-56613888};A.skipBlockComment=function(){var s=this.options.onComment&&this.curPosition(),e=this.pos,t=this.input.indexOf("*/",this.pos+=2);if(t===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=t+2,this.options.locations)for(var n=void 0,i=e;(n=ct(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=n;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,t),e,this.pos,s,this.curPosition())};A.skipLineComment=function(s){for(var e=this.pos,t=this.options.onComment&&this.curPosition(),n=this.input.charCodeAt(this.pos+=s);this.pos<this.input.length&&!xe(n);)n=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+s,this.pos),e,this.pos,t,this.curPosition())};A.skipSpace=function(){e:for(;this.pos<this.input.length;){var s=this.input.charCodeAt(this.pos);switch(s){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(s>8&&s<14||s>=5760&&ut.test(String.fromCharCode(s)))++this.pos;else break e}}};A.finishToken=function(s,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var t=this.type;this.type=s,this.value=e,this.updateContext(t)};A.readToken_dot=function(){var s=this.input.charCodeAt(this.pos+1);if(s>=48&&s<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&s===46&&e===46?(this.pos+=3,this.finishToken(u.ellipsis)):(++this.pos,this.finishToken(u.dot))};A.readToken_slash=function(){var s=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):s===61?this.finishOp(u.assign,2):this.finishOp(u.slash,1)};A.readToken_mult_modulo_exp=function(s){var e=this.input.charCodeAt(this.pos+1),t=1,n=s===42?u.star:u.modulo;return this.options.ecmaVersion>=7&&s===42&&e===42&&(++t,n=u.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(u.assign,t+1):this.finishOp(n,t)};A.readToken_pipe_amp=function(s){var e=this.input.charCodeAt(this.pos+1);if(e===s){if(this.options.ecmaVersion>=12){var t=this.input.charCodeAt(this.pos+2);if(t===61)return this.finishOp(u.assign,3)}return this.finishOp(s===124?u.logicalOR:u.logicalAND,2)}return e===61?this.finishOp(u.assign,2):this.finishOp(s===124?u.bitwiseOR:u.bitwiseAND,1)};A.readToken_caret=function(){var s=this.input.charCodeAt(this.pos+1);return s===61?this.finishOp(u.assign,2):this.finishOp(u.bitwiseXOR,1)};A.readToken_plus_min=function(s){var e=this.input.charCodeAt(this.pos+1);return e===s?e===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||D.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(u.incDec,2):e===61?this.finishOp(u.assign,2):this.finishOp(u.plusMin,1)};A.readToken_lt_gt=function(s){var e=this.input.charCodeAt(this.pos+1),t=1;return e===s?(t=s===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+t)===61?this.finishOp(u.assign,t+1):this.finishOp(u.bitShift,t)):e===33&&s===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(t=2),this.finishOp(u.relational,t))};A.readToken_eq_excl=function(s){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(u.equality,this.input.charCodeAt(this.pos+2)===61?3:2):s===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(u.arrow)):this.finishOp(s===61?u.eq:u.prefix,1)};A.readToken_question=function(){var s=this.options.ecmaVersion;if(s>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var t=this.input.charCodeAt(this.pos+2);if(t<48||t>57)return this.finishOp(u.questionDot,2)}if(e===63){if(s>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(u.assign,3)}return this.finishOp(u.coalesce,2)}}return this.finishOp(u.question,1)};A.readToken_numberSign=function(){var s=this.options.ecmaVersion,e=35;if(s>=13&&(++this.pos,e=this.fullCharCodeAtPos(),Y(e,!0)||e===92))return this.finishToken(u.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+se(e)+"'")};A.getTokenFromCode=function(s){switch(s){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(u.parenL);case 41:return++this.pos,this.finishToken(u.parenR);case 59:return++this.pos,this.finishToken(u.semi);case 44:return++this.pos,this.finishToken(u.comma);case 91:return++this.pos,this.finishToken(u.bracketL);case 93:return++this.pos,this.finishToken(u.bracketR);case 123:return++this.pos,this.finishToken(u.braceL);case 125:return++this.pos,this.finishToken(u.braceR);case 58:return++this.pos,this.finishToken(u.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(u.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(s);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(s);case 124:case 38:return this.readToken_pipe_amp(s);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(s);case 60:case 62:return this.readToken_lt_gt(s);case 61:case 33:return this.readToken_eq_excl(s);case 63:return this.readToken_question();case 126:return this.finishOp(u.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+se(s)+"'")};A.finishOp=function(s,e){var t=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(s,t)};A.readRegexp=function(){for(var s,e,t=this.pos;;){this.pos>=this.input.length&&this.raise(t,"Unterminated regular expression");var n=this.input.charAt(this.pos);if(D.test(n)&&this.raise(t,"Unterminated regular expression"),s)s=!1;else{if(n==="[")e=!0;else if(n==="]"&&e)e=!1;else if(n==="/"&&!e)break;s=n==="\\"}++this.pos}var i=this.input.slice(t,this.pos);++this.pos;var r=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(r);var o=this.regexpState||(this.regexpState=new ee(this));o.reset(t,i,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(i,a)}catch{}return this.finishToken(u.regexp,{pattern:i,flags:a,value:c})};A.readInt=function(s,e,t){for(var n=this.options.ecmaVersion>=12&&e===void 0,i=t&&this.input.charCodeAt(this.pos)===48,r=this.pos,a=0,o=0,c=0,l=e??1/0;c<l;++c,++this.pos){var p=this.input.charCodeAt(this.pos),h=void 0;if(n&&p===95){i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),c===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=p;continue}if(p>=97?h=p-97+10:p>=65?h=p-65+10:p>=48&&p<=57?h=p-48:h=1/0,h>=s)break;o=p,a=a*s+h}return n&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===r||e!=null&&this.pos-r!==e?null:a};function ws(s,e){return e?parseInt(s,8):parseFloat(s.replace(/_/g,""))}function Bt(s){return typeof BigInt!="function"?null:BigInt(s.replace(/_/g,""))}A.readRadixNumber=function(s){var e=this.pos;this.pos+=2;var t=this.readInt(s);return t==null&&this.raise(this.start+2,"Expected number in radix "+s),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(t=Bt(this.input.slice(e,this.pos)),++this.pos):Y(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,t)};A.readNumber=function(s){var e=this.pos;!s&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var t=this.pos-e>=2&&this.input.charCodeAt(e)===48;t&&this.strict&&this.raise(e,"Invalid number");var n=this.input.charCodeAt(this.pos);if(!t&&!s&&this.options.ecmaVersion>=11&&n===110){var i=Bt(this.input.slice(e,this.pos));return++this.pos,Y(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,i)}t&&/[89]/.test(this.input.slice(e,this.pos))&&(t=!1),n===46&&!t&&(++this.pos,this.readInt(10),n=this.input.charCodeAt(this.pos)),(n===69||n===101)&&!t&&(n=this.input.charCodeAt(++this.pos),(n===43||n===45)&&++this.pos,this.readInt(10)===null&&this.raise(e,"Invalid number")),Y(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=ws(this.input.slice(e,this.pos),t);return this.finishToken(u.num,r)};A.readCodePoint=function(){var s=this.input.charCodeAt(this.pos),e;if(s===123){this.options.ecmaVersion<6&&this.unexpected();var t=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(t,"Code point out of bounds")}else e=this.readHexChar(4);return e};A.readString=function(s){for(var e="",t=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var n=this.input.charCodeAt(this.pos);if(n===s)break;n===92?(e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!1),t=this.pos):n===8232||n===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(xe(n)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(t,this.pos++),this.finishToken(u.string,e)};var $t={};A.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(s){if(s===$t)this.readInvalidTemplateToken();else throw s}this.inTemplateElement=!1};A.invalidStringToken=function(s,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw $t;this.raise(s,e)};A.readTmplToken=function(){for(var s="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var t=this.input.charCodeAt(this.pos);if(t===96||t===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===u.template||this.type===u.invalidTemplate)?t===36?(this.pos+=2,this.finishToken(u.dollarBraceL)):(++this.pos,this.finishToken(u.backQuote)):(s+=this.input.slice(e,this.pos),this.finishToken(u.template,s));if(t===92)s+=this.input.slice(e,this.pos),s+=this.readEscapedChar(!0),e=this.pos;else if(xe(t)){switch(s+=this.input.slice(e,this.pos),++this.pos,t){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:s+=`
|
|
6
|
+
`;break;default:s+=String.fromCharCode(t);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};A.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(u.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
7
7
|
`&&++this.pos;case`
|
|
8
|
-
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};
|
|
9
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return se(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),s){var t=this.pos-1;this.invalidStringToken(t,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(n,8);return i>255&&(n=n.slice(0,-1),i=parseInt(n,8)),this.pos+=n.length-1,e=this.input.charCodeAt(this.pos),(n!=="0"||e===56||e===57)&&(this.strict||s)&&this.invalidStringToken(this.pos-1-n.length,s?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return xe(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};P.readHexChar=function(s){var e=this.pos,t=this.readInt(16,s);return t===null&&this.invalidStringToken(e,"Bad character escape sequence"),t};P.readWord1=function(){this.containsEsc=!1;for(var s="",e=!0,t=this.pos,n=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(ae(i,n))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,s+=this.input.slice(t,this.pos);var r=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(e?Y:ae)(a,n)||this.invalidStringToken(r,"Invalid Unicode escape"),s+=se(a),t=this.pos}else break;e=!1}return s+this.input.slice(t,this.pos)};P.readWord=function(){var s=this.readWord1(),e=u.name;return this.keywords.test(s)&&(e=Xe[s]),this.finishToken(e,s)};var ws="8.15.0";M.acorn={Parser:M,version:ws,defaultOptions:$e,Position:ve,SourceLocation:ke,getLineInfo:pt,Node:Re,TokenType:_,tokTypes:u,keywordTypes:Xe,TokContext:G,tokContexts:k,isIdentifierChar:ae,isIdentifierStart:Y,Token:Ze,isNewLine:xe,lineBreak:$,lineBreakG:Gt,nonASCIIwhitespace:ut};function j(s,e){return M.parse(s,e)}function W(s,e,t,n,i){t||(t=C),(function r(a,o,c){var l=c||a.type;t[l](a,o,r),e[l]&&e[l](a,o)})(s,n,i)}function _s(s,e,t,n,i){var r=[];t||(t=C),(function a(o,c,l){var p=l||o.type,h=o!==r[r.length-1];h&&r.push(o),t[p](o,c,a),e[p]&&e[p](o,c||r,r),h&&r.pop()})(s,n,i)}function Ye(s,e,t){t(s,e)}function pe(s,e,t){}var C={};C.Program=C.BlockStatement=C.StaticBlock=function(s,e,t){for(var n=0,i=s.body;n<i.length;n+=1){var r=i[n];t(r,e,"Statement")}};C.Statement=Ye;C.EmptyStatement=pe;C.ExpressionStatement=C.ParenthesizedExpression=C.ChainExpression=function(s,e,t){return t(s.expression,e,"Expression")};C.IfStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Statement"),s.alternate&&t(s.alternate,e,"Statement")};C.LabeledStatement=function(s,e,t){return t(s.body,e,"Statement")};C.BreakStatement=C.ContinueStatement=pe;C.WithStatement=function(s,e,t){t(s.object,e,"Expression"),t(s.body,e,"Statement")};C.SwitchStatement=function(s,e,t){t(s.discriminant,e,"Expression");for(var n=0,i=s.cases;n<i.length;n+=1){var r=i[n];t(r,e)}};C.SwitchCase=function(s,e,t){s.test&&t(s.test,e,"Expression");for(var n=0,i=s.consequent;n<i.length;n+=1){var r=i[n];t(r,e,"Statement")}};C.ReturnStatement=C.YieldExpression=C.AwaitExpression=function(s,e,t){s.argument&&t(s.argument,e,"Expression")};C.ThrowStatement=C.SpreadElement=function(s,e,t){return t(s.argument,e,"Expression")};C.TryStatement=function(s,e,t){t(s.block,e,"Statement"),s.handler&&t(s.handler,e),s.finalizer&&t(s.finalizer,e,"Statement")};C.CatchClause=function(s,e,t){s.param&&t(s.param,e,"Pattern"),t(s.body,e,"Statement")};C.WhileStatement=C.DoWhileStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.body,e,"Statement")};C.ForStatement=function(s,e,t){s.init&&t(s.init,e,"ForInit"),s.test&&t(s.test,e,"Expression"),s.update&&t(s.update,e,"Expression"),t(s.body,e,"Statement")};C.ForInStatement=C.ForOfStatement=function(s,e,t){t(s.left,e,"ForInit"),t(s.right,e,"Expression"),t(s.body,e,"Statement")};C.ForInit=function(s,e,t){s.type==="VariableDeclaration"?t(s,e):t(s,e,"Expression")};C.DebuggerStatement=pe;C.FunctionDeclaration=function(s,e,t){return t(s,e,"Function")};C.VariableDeclaration=function(s,e,t){for(var n=0,i=s.declarations;n<i.length;n+=1){var r=i[n];t(r,e)}};C.VariableDeclarator=function(s,e,t){t(s.id,e,"Pattern"),s.init&&t(s.init,e,"Expression")};C.Function=function(s,e,t){s.id&&t(s.id,e,"Pattern");for(var n=0,i=s.params;n<i.length;n+=1){var r=i[n];t(r,e,"Pattern")}t(s.body,e,s.expression?"Expression":"Statement")};C.Pattern=function(s,e,t){s.type==="Identifier"?t(s,e,"VariablePattern"):s.type==="MemberExpression"?t(s,e,"MemberPattern"):t(s,e)};C.VariablePattern=pe;C.MemberPattern=Ye;C.RestElement=function(s,e,t){return t(s.argument,e,"Pattern")};C.ArrayPattern=function(s,e,t){for(var n=0,i=s.elements;n<i.length;n+=1){var r=i[n];r&&t(r,e,"Pattern")}};C.ObjectPattern=function(s,e,t){for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];r.type==="Property"?(r.computed&&t(r.key,e,"Expression"),t(r.value,e,"Pattern")):r.type==="RestElement"&&t(r.argument,e,"Pattern")}};C.Expression=Ye;C.ThisExpression=C.Super=C.MetaProperty=pe;C.ArrayExpression=function(s,e,t){for(var n=0,i=s.elements;n<i.length;n+=1){var r=i[n];r&&t(r,e,"Expression")}};C.ObjectExpression=function(s,e,t){for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];t(r,e)}};C.FunctionExpression=C.ArrowFunctionExpression=C.FunctionDeclaration;C.SequenceExpression=function(s,e,t){for(var n=0,i=s.expressions;n<i.length;n+=1){var r=i[n];t(r,e,"Expression")}};C.TemplateLiteral=function(s,e,t){for(var n=0,i=s.quasis;n<i.length;n+=1){var r=i[n];t(r,e)}for(var a=0,o=s.expressions;a<o.length;a+=1){var c=o[a];t(c,e,"Expression")}};C.TemplateElement=pe;C.UnaryExpression=C.UpdateExpression=function(s,e,t){t(s.argument,e,"Expression")};C.BinaryExpression=C.LogicalExpression=function(s,e,t){t(s.left,e,"Expression"),t(s.right,e,"Expression")};C.AssignmentExpression=C.AssignmentPattern=function(s,e,t){t(s.left,e,"Pattern"),t(s.right,e,"Expression")};C.ConditionalExpression=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Expression"),t(s.alternate,e,"Expression")};C.NewExpression=C.CallExpression=function(s,e,t){if(t(s.callee,e,"Expression"),s.arguments)for(var n=0,i=s.arguments;n<i.length;n+=1){var r=i[n];t(r,e,"Expression")}};C.MemberExpression=function(s,e,t){t(s.object,e,"Expression"),s.computed&&t(s.property,e,"Expression")};C.ExportNamedDeclaration=C.ExportDefaultDeclaration=function(s,e,t){s.declaration&&t(s.declaration,e,s.type==="ExportNamedDeclaration"||s.declaration.id?"Statement":"Expression"),s.source&&t(s.source,e,"Expression")};C.ExportAllDeclaration=function(s,e,t){s.exported&&t(s.exported,e),t(s.source,e,"Expression")};C.ImportDeclaration=function(s,e,t){for(var n=0,i=s.specifiers;n<i.length;n+=1){var r=i[n];t(r,e)}t(s.source,e,"Expression")};C.ImportExpression=function(s,e,t){t(s.source,e,"Expression")};C.ImportSpecifier=C.ImportDefaultSpecifier=C.ImportNamespaceSpecifier=C.Identifier=C.PrivateIdentifier=C.Literal=pe;C.TaggedTemplateExpression=function(s,e,t){t(s.tag,e,"Expression"),t(s.quasi,e,"Expression")};C.ClassDeclaration=C.ClassExpression=function(s,e,t){return t(s,e,"Class")};C.Class=function(s,e,t){s.id&&t(s.id,e,"Pattern"),s.superClass&&t(s.superClass,e,"Expression"),t(s.body,e)};C.ClassBody=function(s,e,t){for(var n=0,i=s.body;n<i.length;n+=1){var r=i[n];t(r,e)}};C.MethodDefinition=C.PropertyDefinition=C.Property=function(s,e,t){s.computed&&t(s.key,e,"Expression"),s.value&&t(s.value,e,"Expression")};const d={ATTR_PREFIXES:{COMPONENT:"pp-component",CONTEXT:"pp-context",LOOP:"pp-for",SPREAD:"pp-spread",REF:"pp-ref"},SCRIPT_TYPE:"text/pp",MAX_CACHE_SIZE:2e3,DEBOUNCE_MS:16,POOL_SIZE:10,MUSTACHE_PATTERN:/\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/,MUSTACHE_SINGLE_PATTERN:/^\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}$/},ge=new Set(["true","false","null","undefined","this","window","document","console","Math","Date","JSON","Object","Array","return","let","const","var","if","else","for","while","switch","case","break","continue","function","new","in","of","typeof","instanceof","void","delete","try","catch","finally","class","extends","super","thisElement","eventObject","arguments"]);function Ns(s,e){let t;return(...n)=>{clearTimeout(t),t=window.setTimeout(()=>s(...n),e)}}function jt(s){return s.charAt(0).toUpperCase()+s.slice(1)}function ue(s){if(s==null||typeof s=="boolean"||typeof s=="function"||Array.isArray(s)&&s.length===0||typeof s=="object"&&Object.keys(s).length===0)return"";if(typeof s=="number")return String(s);if(typeof s=="string")return s;if(Array.isArray(s))return s.map(e=>ue(e)).filter(e=>e!=="").join("");if(typeof s=="object")try{return JSON.stringify(s)}catch{return"[object Object]"}return String(s)}function He(s){return typeof s=="function"&&"__pphp_key"in s?s.value:s}class ks{portals=new Map;portalCounter=0;componentManager;domBindingManager;cleanupObserver;stateManager;pphpInstance;constructor(){this.cleanupObserver=new MutationObserver(e=>{this.handleMutations(e)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}setDependencies(e,t,n,i){this.componentManager=e,this.domBindingManager=t,this.stateManager=n,this.pphpInstance=i}createPortal(e,t,n){const i=typeof t=="string"?document.querySelector(t):t;if(!i)throw new Error(`Portal container not found: ${t}`);const r=this.componentManager?.getCurrentComponent()||"app",a=n?.key||`portal_${++this.portalCounter}_${Date.now()}`;this.portals.has(a)&&this.removePortal(a);const o={id:a,content:e,container:i,component:r};return this.portals.set(a,o),this.renderPortalWithHydration(o,n,a),a}async renderPortalWithHydration(e,t,n){if(!this.componentManager||!this.domBindingManager){console.warn("PortalManager dependencies not set");return}try{await this.renderPortal(e,t),await new Promise(i=>requestAnimationFrame(i)),this.domBindingManager.processPendingBindings(),await new Promise(i=>{this.stateManager?.onDOMUpdateComplete(()=>{i(void 0)})}),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n),t?.onMount&&t.onMount(e.container)}catch(i){console.error("Portal hydration error:",i),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n)}}renderPortal(e,t){return new Promise((n,i)=>{if(!this.componentManager||!this.domBindingManager){console.warn("PortalManager dependencies not set"),i(new Error("Dependencies not set"));return}try{e.renderedContent&&e.renderedContent.parentElement&&e.renderedContent.parentElement.removeChild(e.renderedContent);let r;if(typeof e.content=="string"){const o=document.createElement("template");if(o.innerHTML=e.content.trim(),r=o.content.firstElementChild,!r)throw new Error("Invalid HTML string for portal content")}else if(e.content instanceof DocumentFragment){const o=document.createElement("div");if(o.appendChild(e.content.cloneNode(!0)),r=o.firstElementChild,!r)throw new Error("DocumentFragment must contain at least one element")}else r=e.content;r.setAttribute("data-portal-id",e.id),r.setAttribute("data-portal-component",e.component),r.hasAttribute("pp-context")||r.setAttribute("pp-context",e.component),e.container.appendChild(r),e.renderedContent=r;const a=[...this.componentManager.componentStack];e.component!=="app"?this.componentManager.componentStack=["app",e.component]:this.componentManager.componentStack=["app"];try{this.componentManager.executePhpScripts(r),this.domBindingManager.processElement(r,!0);const o=r.querySelectorAll("template[pp-for]"),c=this.domBindingManager.loopManager;c&&(o.forEach(l=>{const p=l,h=p.getAttribute("pp-context");if(c.loopBindings?.has(p))if(typeof c.updateTemplateParent=="function")c.updateTemplateParent(p);else{const f=c.loopBindings.get(p);f&&(f.subscriptionIds?.forEach(x=>{this.stateManager?.removeSubscription(x)}),c.loopBindings.delete(p)),c.processTemplate(p,h||e.component)}else c.queueTemplate(p,h||e.component)}),c.processPendingTemplates()),this.domBindingManager.processPendingBindings(),n()}finally{this.componentManager.componentStack=a}}catch(r){console.error("Portal rendering error:",r),this.portals.delete(e.id),i(r)}})}removePortal(e){const t=this.portals.get(e);if(!t)return!1;try{return t.cleanup&&t.cleanup(),t.renderedContent&&this.cleanupPortalElement(t.renderedContent),t.renderedContent&&t.renderedContent.parentElement&&t.renderedContent.parentElement.removeChild(t.renderedContent),this.portals.delete(e),!0}catch(n){return console.error("Portal cleanup error:",n),!1}}cleanupPortalElement(e){if(this.stateManager){const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n=e;do n.nodeType===Node.ELEMENT_NODE&&this.stateManager.subscriptionManager?.cleanupElement(n);while(n=t.nextNode())}}updatePortal(e,t,n){const i=this.portals.get(e);return i?(i.content=t,this.renderPortal(i,n),!0):!1}getPortal(e){return this.portals.get(e)}hasPortal(e){return this.portals.has(e)}getAllPortals(){return Array.from(this.portals.values())}handleMutations(e){for(const t of e)t.type==="childList"&&t.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const i=n;for(const[r,a]of this.portals)(a.container===i||i.contains(a.container))&&this.removePortal(r)}})}destroy(){for(const e of Array.from(this.portals.keys()))this.removePortal(e);this.cleanupObserver.disconnect(),this.portals.clear()}}class Is{static validate(e,t){const n=[],i=[],r=this.validateTernaryOperator(e);n.push(...r.errors),i.push(...r.warnings);const a=this.validateSyntax(e);return n.push(...a.errors),i.push(...a.warnings),{valid:n.length===0,errors:n,warnings:i}}static validateTernaryOperator(e){const t=[],n=[];if(!e.includes("?")||!e.includes(":"))return{errors:t,warnings:n};const i=e.match(/([^?]+)\?([^:]+):(.+)/);if(!i)return{errors:t,warnings:n};const[,,r,a]=i,o=r.trim(),c=this.validateBranch(o,"truthy");t.push(...c.errors),n.push(...c.warnings);const l=a.trim(),p=this.validateBranch(l,"falsy");return t.push(...p.errors),n.push(...p.warnings),{errors:t,warnings:n}}static validateBranch(e,t){const n=[],i=[],r=this.countQuotes(e);if(r.single%2!==0&&(n.push(`Unmatched single quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,"'"))){const a=this.suggestQuoteFix(e,"'");a&&n.push(` Did you mean: ${a}`)}if(r.double%2!==0&&(n.push(`Unmatched double quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,'"'))){const a=this.suggestQuoteFix(e,'"');a&&n.push(` Did you mean: ${a}`)}return r.single===0&&r.double===0&&this.looksLikeUnquotedLiteral(e)&&i.push(`Value "${e}" in ternary ${t} branch may need quotes. Did you mean '${e}' or "${e}"?`),{errors:n,warnings:i}}static hasTrailingOrLeadingQuote(e,t){const n=e.startsWith(t),i=e.endsWith(t);return n&&!i||!n&&i}static suggestQuoteFix(e,t){return e.endsWith(t)&&!e.startsWith(t)?`${t}${e}`:e.startsWith(t)&&!e.endsWith(t)?`${e}${t}`:null}static looksLikeUnquotedLiteral(e){const t=e.trim();return!t||this.isAlreadyQuoted(t)||ge.has(t)||t==="true"||t==="false"||t==="null"||t==="undefined"||!isNaN(Number(t))&&t!==""||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)||t.includes(".")||/\[.*\]/.test(t)||/\(.*\)/.test(t)?!1:!!(t.includes("-")||/\s/.test(t)||/[^a-zA-Z0-9_$.]/.test(t))}static isAlreadyQuoted(e){return e.startsWith("'")&&e.endsWith("'")&&e.length>=2||e.startsWith('"')&&e.endsWith('"')&&e.length>=2}static countQuotes(e){let t=0,n=0,i=!1;for(let r=0;r<e.length;r++){if(i){i=!1;continue}if(e[r]==="\\"){i=!0;continue}e[r]==="'"&&t++,e[r]==='"'&&n++}return{single:t,double:n}}static validateSyntax(e){const t=[],n=[],i=this.checkBrackets(e);i.valid||t.push(i.error);const r=this.checkParentheses(e);return r.valid||t.push(r.error),{errors:t,warnings:n}}static checkBrackets(e){let t=0,n=!1,i="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!n&&(a==="'"||a==='"')?(n=!0,i=a):n&&a===i&&o!=="\\"&&(n=!1,i=""),!n&&(a==="{"&&t++,a==="}"&&t--,t<0))return{valid:!1,error:"Unexpected closing bracket '}'"}}return t!==0?{valid:!1,error:"Mismatched brackets - missing '}'"}:{valid:!0,error:""}}static checkParentheses(e){let t=0,n=!1,i="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!n&&(a==="'"||a==='"')?(n=!0,i=a):n&&a===i&&o!=="\\"&&(n=!1,i=""),!n&&(a==="("&&t++,a===")"&&t--,t<0))return{valid:!1,error:"Unexpected closing parenthesis ')'"}}return t!==0?{valid:!1,error:"Mismatched parentheses - missing ')'"}:{valid:!0,error:""}}}class fe{static instance;walkerPool=[];traversalCache=new WeakMap;lastCacheTime=new WeakMap;CACHE_TTL=250;trackedElements=new Set;static getInstance(){return fe.instance||(fe.instance=new fe),fe.instance}acquireWalker(e,t,n){return document.createTreeWalker(e,t,n)}releaseWalker(e){this.walkerPool.length<3&&this.walkerPool.push(e)}getCachedTraversal(e,t,n){const i=Date.now(),r=this.traversalCache.get(e),a=this.lastCacheTime.get(e);if(r&&a&&i-a<this.CACHE_TTL){const c=r.get(t);if(c)return c}const o=n();return this.traversalCache.has(e)||(this.traversalCache.set(e,new Map),this.trackedElements.add(e)),this.traversalCache.get(e).set(t,o),this.lastCacheTime.set(e,i),o}traverseElementsAndText(e,t,n){const i=this.acquireWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),r=[],a=[];let o;for(;o=i.nextNode();)if(o.nodeType===Node.ELEMENT_NODE){const c=o;(!t||t(c))&&r.push(c)}else if(o.nodeType===Node.TEXT_NODE){const c=o;(!n||n(c))&&a.push(c)}return this.releaseWalker(i),{elements:r,textNodes:a}}cleanupCache(){const e=[];for(const t of this.trackedElements)document.contains(t)||e.push(t);e.forEach(t=>{this.traversalCache.delete(t),this.lastCacheTime.delete(t),this.trackedElements.delete(t)})}}class B{static instance;componentElementsCache=new z(100);scriptElementsCache=new z(50);templateElementsCache=new z(50);selectorCache=new z(200);elementComponentCache=new WeakMap;parentComponentCache=new WeakMap;contextComponentCache=new WeakMap;elementDepthCache=new WeakMap;elementChildrenCache=new WeakMap;cacheHits=0;cacheMisses=0;static CACHE_KEYS={COMPONENT_ELEMENTS:e=>`comp:${e}`,SCRIPTS:(e,t)=>`scripts:${e}:${t}`,TEMPLATES:(e,t)=>`templates:${e}:${t}`,SELECTOR:e=>`sel:${e}`};static getInstance(){return B.instance||(B.instance=new B),B.instance}queryComponentElements(e){const t=B.CACHE_KEYS.COMPONENT_ELEMENTS(e);if(this.componentElementsCache.has(t))return this.cacheHits++,this.componentElementsCache.get(t);this.cacheMisses++;const n=Array.from(document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e}"]`));return n.forEach(i=>{this.elementComponentCache.set(i,e)}),this.componentElementsCache.set(t,n),n}querySelectorAll(e){const t=B.CACHE_KEYS.SELECTOR(e);if(this.selectorCache.has(t))return this.cacheHits++,this.selectorCache.get(t);this.cacheMisses++;const n=Array.from(document.querySelectorAll(e));return this.selectorCache.set(t,n),n}getElementComponent(e){if(this.elementComponentCache.has(e))return this.cacheHits++,this.elementComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;let n=e.parentElement;for(;n;){const i=n.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return this.elementComponentCache.set(e,i),i;n=n.parentElement}return this.elementComponentCache.set(e,"app"),"app"}getContextComponent(e){if(this.contextComponentCache.has(e))return this.cacheHits++,this.contextComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let n;if(t)if(t==="parent"){const i=this.getElementComponent(e);n=this.getParentOfComponent(i,e)}else t==="app"?n="app":n=t;else n=this.getElementComponent(e);return this.contextComponentCache.set(e,n),n}getParentOfComponent(e,t){if(this.parentComponentCache.has(t))return this.cacheHits++,this.parentComponentCache.get(t);if(this.cacheMisses++,e==="app")return this.parentComponentCache.set(t,"app"),"app";let n=t;for(;n&&n.getAttribute(d.ATTR_PREFIXES.COMPONENT)!==e;)n=n.parentElement;if(!n)return this.parentComponentCache.set(t,"app"),"app";let i=n.parentElement;for(;i;){const r=i.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r)return this.parentComponentCache.set(t,r),r;i=i.parentElement}return this.parentComponentCache.set(t,"app"),"app"}getElementDepthCached(e){if(this.elementDepthCache.has(e))return this.cacheHits++,this.elementDepthCache.get(e);this.cacheMisses++;let t=0,n=e.parentElement;for(;n&&n!==document.body;)t++,n=n.parentElement;return this.elementDepthCache.set(e,t),t}getFirstComponentElement(e){const t=this.queryComponentElements(e);return t.length>0?t[0]:null}getComponentScripts(e,t){const n=B.CACHE_KEYS.SCRIPTS(e,t?.tagName||"global");if(this.scriptElementsCache.has(n))return this.cacheHits++,this.scriptElementsCache.get(n);this.cacheMisses++;let i=[];if(t){const r=t.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`);for(const a of r)a instanceof HTMLScriptElement&&i.push(a)}else{const r=document.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`);for(const a of r)if(a instanceof HTMLScriptElement){const o=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);(o===e||!o&&!a.closest(`[${d.ATTR_PREFIXES.COMPONENT}]`))&&i.push(a)}}return this.scriptElementsCache.set(n,i),i}getComponentTemplates(e,t){const n=B.CACHE_KEYS.TEMPLATES(e,t?.tagName||"global");if(this.templateElementsCache.has(n))return this.cacheHits++,this.templateElementsCache.get(n);this.cacheMisses++;let i=[];if(t){const r=t.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&i.push(a)}else{const r=document.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&i.push(a)}return this.templateElementsCache.set(n,i),i}querySelector(e){const t=this.querySelectorAll(e);return t.length>0?t[0]:null}findElementForComponent(e,t){if(t==="app")return document.body;const n=this.queryComponentElements(t);return n.length>0?n[0]:null}invalidateCache(e){switch(e){case"components":this.componentElementsCache.clear();break;case"selectors":this.selectorCache.clear();break;case"scripts":this.scriptElementsCache.clear();break;case"templates":this.templateElementsCache.clear();break;default:this.clearAllCaches()}}invalidateByComponent(e){const t=B.CACHE_KEYS.COMPONENT_ELEMENTS(e);this.componentElementsCache.delete(t);const n=B.CACHE_KEYS.SCRIPTS(e,"global");this.scriptElementsCache.delete(n);const i=B.CACHE_KEYS.TEMPLATES(e,"global");this.templateElementsCache.delete(i),this.selectorCache.clear()}invalidateByPrefix(e){this.invalidateByComponent(e)}invalidateElement(e){this.elementComponentCache.delete(e),this.contextComponentCache.delete(e),this.parentComponentCache.delete(e),this.elementDepthCache.delete(e),this.elementChildrenCache.delete(e)}clearAllCaches(){this.componentElementsCache.clear(),this.scriptElementsCache.clear(),this.templateElementsCache.clear(),this.selectorCache.clear(),this.elementComponentCache=new WeakMap,this.parentComponentCache=new WeakMap,this.contextComponentCache=new WeakMap,this.elementDepthCache=new WeakMap,this.elementChildrenCache=new WeakMap}getCacheStats(){const e=this.cacheHits+this.cacheMisses;return{componentElements:this.componentElementsCache.getStats(),scriptElements:this.scriptElementsCache.getStats(),templateElements:this.templateElementsCache.getStats(),selectors:this.selectorCache.getStats(),global:{size:0,maxSize:-1,hitRate:e>0?this.cacheHits/e*100:0,hits:this.cacheHits,misses:this.cacheMisses}}}resetStats(){this.cacheHits=0,this.cacheMisses=0}}class Ms{subscriptions=new Map;elementSubscriptions=new WeakMap;keyIndex=new Map;cleanupQueue=new Set;cleanupScheduled=!1;addSubscription(e){this.subscriptions.set(e.id,e),e.element&&(this.elementSubscriptions.has(e.element)||this.elementSubscriptions.set(e.element,new Set),this.elementSubscriptions.get(e.element).add(e.id));for(const t of e.dependencies)this.keyIndex.has(t)||this.keyIndex.set(t,new Set),this.keyIndex.get(t).add(e.id)}removeSubscription(e){const t=this.subscriptions.get(e);if(t){if(this.subscriptions.delete(e),t.element){const n=this.elementSubscriptions.get(t.element);n&&(n.delete(e),n.size===0&&this.elementSubscriptions.delete(t.element))}for(const n of t.dependencies){const i=this.keyIndex.get(n);i&&(i.delete(e),i.size===0&&this.keyIndex.delete(n))}}}cleanupElement(e){const t=this.elementSubscriptions.get(e);t&&(t.forEach(n=>this.cleanupQueue.add(n)),this.scheduleCleanup())}scheduleCleanup(){this.cleanupScheduled||(this.cleanupScheduled=!0,queueMicrotask(()=>{this.processCleanupQueue(),this.cleanupScheduled=!1}))}processCleanupQueue(){for(const e of this.cleanupQueue)this.removeSubscription(e);this.cleanupQueue.clear()}getSubscription(e){return this.subscriptions.get(e)}getSubscriptionsForKey(e){return this.keyIndex.get(e)}getAllSubscriptions(){return new Map(this.subscriptions)}cleanupStaleSubscriptions(){const e=[];for(const[t,n]of this.subscriptions)n.element&&!document.contains(n.element)&&e.push(t);e.forEach(t=>this.removeSubscription(t))}getStats(){return{totalSubscriptions:this.subscriptions.size,elementSubscriptions:this.elementSubscriptions instanceof WeakMap?-1:0,keyIndexes:this.keyIndex.size}}}class Z{static instance;stateVariables=new Set;static FUNCTIONS_NEEDING_VALUE_TRANSFORM=new Set(["console.log","console.warn","console.error","console.info","console.debug","console.dir","console.table","console.trace","console.assert","JSON.stringify","JSON.parse","Object.keys","Object.values","Object.entries","Array.from","Array.isArray","Math.max","Math.min","Math.abs","Math.floor","Math.ceil","Math.round","alert","confirm","prompt","parseInt","parseFloat","Number","String","Boolean"]);transformRefDeclarations(e){try{const t=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return W(t,{VariableDeclarator:r=>{if(this.isRefDeclaration(r)){const a=r.id.name,o=this.findStatementEnd(e,r.end);i.push({start:o,end:o,replacement:`; this.${a} = ${a}`})}}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Ref transformation error:",t),e}}isRefDeclaration(e){return e.id?.type==="Identifier"&&e.init?.type==="CallExpression"&&e.init.callee?.type==="MemberExpression"&&e.init.callee.object?.type==="Identifier"&&e.init.callee.object.name==="pp"&&e.init.callee.property?.type==="Identifier"&&e.init.callee.property.name==="ref"}findStatementEnd(e,t){let n=t;for(;n<e.length&&e[n]!==";"&&e[n]!==`
|
|
10
|
-
`;)n++;return n}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}extractFunctionNames(e){const t=[];try{const n=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});W(n,{FunctionDeclaration:i=>{i.id?.type==="Identifier"&&t.push(i.id.name)},VariableDeclarator:i=>{i.id?.type==="Identifier"&&(i.init?.type==="ArrowFunctionExpression"||i.init?.type==="FunctionExpression")&&t.push(i.id.name)},AssignmentExpression:i=>{i.left?.type==="Identifier"&&(i.right?.type==="ArrowFunctionExpression"||i.right?.type==="FunctionExpression")&&t.push(i.left.name)}})}catch(n){console.error("AST function extraction error:",n)}return Array.from(new Set(t))}transformEffectDeclarations(e){try{const t=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return W(t,{CallExpression:r=>{const a=this.transformEffectCall(r,e);a&&i.push(a)}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Effect transformation error:",t),e}}transformEffectCall(e,t){if(!this.isPPEffectCall(e))return null;const n=e.arguments;if(n.length<2)return null;const i=n[1];if(i.type!=="ArrayExpression"||!i.elements.some(h=>h?h.type==="Identifier"||h.type==="MemberExpression":!1))return null;const a=i.elements.map(h=>h?h.type==="Identifier"?`"${h.name}"`:h.type==="MemberExpression"?`"${this.extractMemberExpression(h,t)}"`:t.slice(h.start,h.end):"null"),o=t.slice(n[0].start,n[0].end),c=n.slice(2).map(h=>t.slice(h.start,h.end)).join(", "),l=`[${a.join(", ")}]`,p=c?`pp.effect(${o}, ${l}, ${c})`:`pp.effect(${o}, ${l})`;return{start:e.start,end:e.end,replacement:p}}extractMemberExpression(e,t){if(e.type!=="MemberExpression")return e.type==="Identifier"?e.name:t.slice(e.start,e.end);const n=this.extractMemberExpression(e.object,t);if(e.computed){const i=t.slice(e.property.start,e.property.end);return`${n}[${i}]`}else{const i=e.property.name||t.slice(e.property.start,e.property.end);return`${n}.${i}`}}isPPEffectCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="effect"}transformStateDeclarations(e,t){this.stateVariables.clear(),t&&t.forEach(i=>this.stateVariables.add(i));let n=this.transformStateDeclarationsOnly(e);return n=this.transformEffectDeclarations(n),n=this.transformRefDeclarations(n),n=this.transformUnsupportedStateUsages(n),n}transformStateDeclarationsOnlyOriginal(e){try{const t=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return W(t,{VariableDeclarator:r=>{const a=this.transformStateDeclarator(r,e);a&&i.push(a)}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("AST transformation error:",t),e}}transformStateDeclarationsOnly(e){let t=this.transformStateDeclarationsOnlyOriginal(e);return t=this.transformDestructuringAssignments(t),t}transformUnsupportedStateUsages(e){try{const t=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(t);let n=this.transformShorthandProperties(e);const i=j(n,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),r=[];return W(i,{SpreadElement:a=>{const o=this.transformSpreadElement(a,n);o&&r.push(o)},UnaryExpression:a=>{const o=this.transformUnaryExpression(a,n);o&&r.push(o)},BinaryExpression:a=>{const o=this.transformBinaryExpression(a,n);o&&r.push(o)},LogicalExpression:a=>{const o=this.transformLogicalExpression(a,n);o&&r.push(o)},ConditionalExpression:a=>{const o=this.transformConditionalExpression(a,n);o&&r.push(o)},IfStatement:a=>{const o=this.transformIfStatement(a,n);o&&r.push(o)},WhileStatement:a=>{const o=this.transformWhileStatement(a,n);o&&r.push(o)},ForStatement:a=>{const o=this.transformForStatement(a,n);o&&r.push(o)},ReturnStatement:a=>{const o=this.transformReturnStatement(a,n);o&&r.push(o)},VariableDeclarator:a=>{const o=this.transformVariableDeclarator(a,n);o&&r.push(o)},AssignmentExpression:a=>{const o=this.transformAssignmentExpression(a,n);o&&r.push(o)},CallExpression:a=>{const o=this.transformGeneralCallExpression(a,n);o&&r.push(o)}}),_s(i,{Identifier:(a,o)=>{r.some(l=>a.start>=l.start&&a.end<=l.end)||this.stateVariables.has(a.name)&&(this.alreadyHasValue(a,n)||this.isPartOfStateDeclaration(a,o)||this.isPropertyName(a,o)||this.isMethodCallObject(a,o)||this.isPartOfPPCall(a,o)||this.isPartOfDestructuring(a,o)||r.push({start:a.start,end:a.end,replacement:`${a.name}.value`}))}}),r.sort((a,o)=>o.start-a.start).forEach(a=>{n=n.slice(0,a.start)+a.replacement+n.slice(a.end)}),n=this.transformMultipleCallArguments(n),n}catch(t){return console.error("State usage transformation error:",t),e}}transformShorthandProperties(e){try{const t=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return W(t,{Property:r=>{if(r.shorthand&&r.key?.type==="Identifier"&&this.stateVariables.has(r.key.name)){const a=r.key.name,o=`${a}: ${a}.value`;i.push({start:r.start,end:r.end,replacement:o})}}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Shorthand property transformation error:",t),e}}transformLogicalExpression(e,t){return e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t)?{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`}:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformConditionalExpression(e,t){return e.test?.type==="Identifier"&&this.stateVariables.has(e.test.name)&&!this.alreadyHasValue(e.test,t)?{start:e.test.start,end:e.test.end,replacement:`${e.test.name}.value`}:e.consequent?.type==="Identifier"&&this.stateVariables.has(e.consequent.name)&&!this.alreadyHasValue(e.consequent,t)?{start:e.consequent.start,end:e.consequent.end,replacement:`${e.consequent.name}.value`}:e.alternate?.type==="Identifier"&&this.stateVariables.has(e.alternate.name)&&!this.alreadyHasValue(e.alternate,t)?{start:e.alternate.start,end:e.alternate.end,replacement:`${e.alternate.name}.value`}:null}transformIfStatement(e,t){return this.transformExpressionNode(e.test,t)}transformWhileStatement(e,t){return this.transformExpressionNode(e.test,t)}transformForStatement(e,t){return e.test?this.transformExpressionNode(e.test,t):null}transformReturnStatement(e,t){return e.argument?this.transformExpressionNode(e.argument,t):null}transformVariableDeclarator(e,t){return this.isStateDeclaration(e)||e.id?.type==="ArrayPattern"||e.id?.type==="ObjectPattern"?null:e.init?.type==="Identifier"&&this.stateVariables.has(e.init.name)&&!this.alreadyHasValue(e.init,t)?{start:e.init.start,end:e.init.end,replacement:`${e.init.name}.value`}:null}transformAssignmentExpression(e,t){return e.left?.type==="ArrayPattern"||e.left?.type==="ObjectPattern"?null:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformGeneralCallExpression(e,t){const n=t.slice(e.callee.start,e.callee.end);if(e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&this.stateVariables.has(e.callee.object.name)||this.isPPCall(e))return null;if(!Z.isFunctionNeedingValueTransform(n)&&e.arguments.length>0){for(const r of e.arguments)if(r.type==="Identifier"&&this.stateVariables.has(r.name)&&!this.alreadyHasValue(r,t))return{start:r.start,end:r.end,replacement:`${r.name}.value`}}return null}static isFunctionNeedingValueTransform(e){if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(e))return!0;const t=e.lastIndexOf(".");if(t>-1){const n=e.slice(t+1);if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(n))return!0}return!1}transformExpressionNode(e,t){return e?.type==="Identifier"&&this.stateVariables.has(e.name)&&!this.alreadyHasValue(e,t)?{start:e.start,end:e.end,replacement:`${e.name}.value`}:null}isPPCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&(e.callee.property.name==="state"||e.callee.property.name==="effect")}isPartOfStateDeclaration(e,t){if(!t||!Array.isArray(t))return!1;for(const n of t)if(n.type==="VariableDeclarator"&&n.id?.type==="ArrayPattern"&&n.init?.type==="CallExpression"&&this.isPPStateCall(n.init))return!0;return!1}isPropertyName(e,t){if(!t||t.length===0)return!1;const n=t[t.length-1];return!!(n?.type==="Property"&&n.key===e||n?.type==="Property"&&n.shorthand&&n.value===e||n?.type==="MemberExpression"&&n.property===e&&!n.computed)}isMethodCallObject(e,t){if(!t||t.length===0)return!1;const n=t[t.length-1];if(n?.type==="MemberExpression"&&n.object===e&&t.length>=2){const i=t[t.length-2];if(i?.type==="CallExpression"&&i.callee===n)return!0}return!1}isPartOfPPCall(e,t){if(!t||!Array.isArray(t))return!1;for(const n of t)if(n.type==="CallExpression"&&n.callee?.type==="MemberExpression"&&n.callee.object?.type==="Identifier"&&n.callee.object.name==="pp"&&n.callee.property?.type==="Identifier"&&(n.callee.property.name==="state"||n.callee.property.name==="effect"))return!0;return!1}isPartOfDestructuring(e,t){if(!t||!Array.isArray(t))return!1;for(let n=0;n<t.length;n++){const i=t[n];if(i.type==="ArrayPattern"||i.type==="ObjectPattern"){if(n+1<t.length){const r=t[n+1];if(r?.type==="VariableDeclarator"&&r.id===i&&r.init===e)return!1}return!0}}return!1}collectStateVariables(e){W(e,{VariableDeclarator:t=>{if(this.isStateDeclaration(t)){const n=t.id.elements[0];n?.type==="Identifier"&&this.stateVariables.add(n.name)}}})}isStateDeclaration(e){return e.id?.type==="ArrayPattern"&&e.init?.type==="CallExpression"&&this.isPPStateCall(e.init)}transformSpreadElement(e,t){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)?this.alreadyHasValue(e.argument,t)?null:{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformUnaryExpression(e,t){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)&&["typeof","!","+","-","~","void","delete"].includes(e.operator)&&!this.alreadyHasValue(e.argument,t)?{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformBinaryExpression(e,t){if(["===","!==","==","!=",">","<",">=","<=","+","-","*","/","%","**","&","|","^","<<",">>",">>>","in","instanceof"].includes(e.operator)){if(e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t))return{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`};if(e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t))return{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}}return null}transformMultipleCallArguments(e){try{const t=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return W(t,{CallExpression:r=>{const a=n.slice(r.callee.start,r.callee.end);if(Z.isFunctionNeedingValueTransform(a)&&r.arguments.length>0)for(const c of r.arguments)c.type==="Identifier"&&this.stateVariables.has(c.name)&&(this.alreadyHasValue(c,n)||i.push({start:c.start,end:c.end,replacement:`${c.name}.value`}))}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Multiple call arguments transformation error:",t),e}}transformDestructuringAssignments(e){try{const t=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return W(t,{VariableDeclarator:r=>{this.isStateDeclaration(r)||(r.id?.type==="ArrayPattern"||r.id?.type==="ObjectPattern")&&r.init?.type==="Identifier"&&this.stateVariables.has(r.init.name)&&(this.alreadyHasValue(r.init,e)||i.push({start:r.init.start,end:r.init.end,replacement:`${r.init.name}.value`}))},AssignmentExpression:r=>{(r.left?.type==="ArrayPattern"||r.left?.type==="ObjectPattern")&&r.right?.type==="Identifier"&&this.stateVariables.has(r.right.name)&&(this.alreadyHasValue(r.right,e)||i.push({start:r.right.start,end:r.right.end,replacement:`${r.right.name}.value`}))}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Destructuring transformation error:",t),e}}alreadyHasValue(e,t){const n=e.end;return t.slice(n,n+6).startsWith(".value")}transformStateDeclarator(e,t){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression")return null;const n=e.init;if(!this.isPPStateCall(n))return null;const i=e.id.elements[0];if(!i||i.type!=="Identifier")return null;const r=i.name,a=`set${this.capitalize(r)}`,o=e.id.elements[1];return o?.type==="Identifier"&&o.name!==a&&console.warn(`Setter name mismatch: expected ${a}, got ${o.name}`),this.createTransformation(n,r,t)}isPPStateCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="state"}createTransformation(e,t,n){const i=e.arguments;if(i.length===0){const c=`pp.state("${t}")`;return{start:e.start,end:e.end,replacement:c}}const r=i[0];if(r.type==="Literal"&&typeof r.value=="string"&&r.value===t)return null;if(i.length===1){const c=n.slice(r.start,r.end),l=`pp.state("${t}", ${c})`;return{start:e.start,end:e.end,replacement:l}}const a=n.slice(e.arguments[0].start,e.arguments[e.arguments.length-1].end),o=`pp.state("${t}", ${a})`;return{start:e.start,end:e.end,replacement:o}}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")}extractStateDeclarations(e){const t=[];try{const n=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});W(n,{VariableDeclarator:i=>{const r=this.extractStateFromDeclarator(i,e);r&&t.push(r)}})}catch(n){console.error("State extraction error:",n)}return t}extractStateFromDeclarator(e,t){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression"||!this.isPPStateCall(e.init))return null;const n=e.id.elements[0],i=e.id.elements[1];if(n?.type!=="Identifier"||i?.type!=="Identifier")return null;const r=e.init.arguments;let a=n.name,o;return r.length>=1&&(r[0].type==="Literal"&&typeof r[0].value=="string"?this.looksLikeVariableName(r[0].value)?(a=r[0].value,r.length>=2&&(o=this.extractLiteralValue(r[1]))):(a=n.name,o=this.extractLiteralValue(r[0])):o=this.extractLiteralValue(r[0])),{variableName:n.name,setterName:i.name,stateKey:a,initialValue:o,line:e.loc?.start.line||0,column:e.loc?.start.column||0}}extractFunctionDeclarations(e){const t=[];try{const n=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});W(n,{FunctionDeclaration:i=>{i.id?.type==="Identifier"&&t.push({name:i.id.name,type:"function",params:i.params.map(r=>r.type==="Identifier"?r.name:""),line:i.loc?.start.line||0})},VariableDeclarator:i=>{if(i.id?.type==="Identifier"&&(i.init?.type==="ArrowFunctionExpression"||i.init?.type==="FunctionExpression")){const r=i.init;t.push({name:i.id.name,type:r.type==="ArrowFunctionExpression"?"arrow":"function",params:r.params.map(a=>a.type==="Identifier"?a.name:""),line:i.loc?.start.line||0})}}})}catch(n){console.error("Function extraction error:",n)}return t}extractLiteralValue(e){if(e.type==="Literal")return e.value;e.type==="Identifier"&&e.name}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}}class Je{constructor(e){this.evaluator=e}render(e,t,n){const i=N.isSingleExpression(e);if(i)return this.evaluator.evaluateExpression(i,t,n);let r="";for(const a of N.parse(e))if(a.type==="static")r+=a.content;else if(a.expression)try{const o=this.evaluator.evaluateExpression(a.expression,t,n);r+=ue(o)}catch{}return r}dependencies(e,t,n){const i=N.extractExpressions(e),r=new Set;for(const a of i)for(const o of this.evaluator.extractDependencies(a,t,n))r.add(o);return[...r]}}class Os{static containsMustacheExpression(e){if(d.MUSTACHE_PATTERN.test(e))return!0;const n=N.decodeEntities(e);return d.MUSTACHE_PATTERN.test(n)}}class S{static FRAMEWORK_ATTRIBUTES=new Set(["pp-component","pp-context","pp-for","pp-spread","pp-ref","key"]);static domCache;static getDOMCache(){return this.domCache||(this.domCache=B.getInstance()),this.domCache}static isFrameworkAttribute(e){return S.FRAMEWORK_ATTRIBUTES.has(e)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static shouldBeDirectBinding(e,t){const n=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),i=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);return!n||!i||n===i?!1:S.isDOMProperty(e,t)}static isDOMProperty(e,t){const n=e.tagName.toLowerCase(),i=document.createElement(n);return S.attributeToPropertyName(t)in i}static attributeToPropertyName(e){const t={class:"className",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",tabindex:"tabIndex",contenteditable:"contentEditable",formnovalidate:"formNoValidate",novalidate:"noValidate",allowfullscreen:"allowFullscreen",itemscope:"itemScope"};return t[e]?t[e]:e.replace(/-([a-z])/g,(n,i)=>i.toUpperCase())}static isBooleanAttribute(e){return["checked","disabled","hidden","readonly","required","multiple","selected","autofocus","autoplay","controls","defer","loop","muted","open","reversed","async","default","formnovalidate","novalidate","allowfullscreen","capture","itemscope"].includes(e)}static getContextComponent(e){return this.getDOMCache().getContextComponent(e)}static getParentOfComponent(e,t){return this.getDOMCache().getParentOfComponent(e,t)}static findElementForComponent(e,t){return this.getDOMCache().findElementForComponent(e,t)}static getElementDepth(e){return this.getDOMCache().getElementDepthCached(e)}static getParentComponentForElement(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}static isTextNodeInsideScript(e){let t=e.parentElement;for(;t&&t!==document.body;){const n=t.tagName.toLowerCase();if(n==="script"||n==="style")return!0;t=t.parentElement}return!1}static getComponentForNode(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return t?this.getDOMCache().getElementComponent(t):"app"}static getElementComponent(e){return this.getDOMCache().getElementComponent(e)}}class de{static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}}class Ue{static findExistingStateKey(e,t,n){return[`${t}.${e}`,`app.${e}`,e].find(r=>r in n)||null}}class rt{pendingUpdates=new Map;batchTimeout=null;componentManager;domBindingManager;setManagers(e,t){this.componentManager=e,this.domBindingManager=t}scheduleUpdate(e,t){this.pendingUpdates.has(e)||this.pendingUpdates.set(e,new Set),this.pendingUpdates.get(e).add(t),this.batchTimeout===null&&(this.batchTimeout=requestAnimationFrame(()=>{this.processBatchedUpdates(),this.batchTimeout=null}))}processBatchedUpdates(){const e=new Map(this.pendingUpdates);this.pendingUpdates.clear(),this.batchTimeout=null;const t=this.sortUpdatesByDependency(e);for(const[n,i]of t)this.processComponentUpdate(n,i)}sortUpdatesByDependency(e){const t=new WeakMap,n=i=>{let r=t.get(i);return r==null&&(r=S.getElementDepth(i),t.set(i,r)),r};return Array.from(e.entries()).sort(([,i],[,r])=>{const a=Math.min(...Array.from(i,n)),o=Math.min(...Array.from(r,n));return a-o})}processComponentUpdate(e,t){if(!this.componentManager||!this.domBindingManager)return;this.componentManager.invalidateComponent(e);const n=[],i=[],r=[];for(const a of t){if(!document.contains(a))continue;const o=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null);let c;for(;c=o.nextNode();)n.push(c);const l=this.domBindingManager.loopManager;if(l){const p=l.getAllLoops();for(const[h,f]of p)f.component===e&&a.contains(h)&&i.push([h,f])}r.push(a)}this.updateTextNodesBatch(n,e),this.updateLoopsBatch(i),this.updateElementsBatch(r,e)}updateTextNodesBatch(e,t){const n=this.domBindingManager.textNodeManager;n&&e.forEach(i=>{document.contains(i)&&S.getComponentForNode(i)===t&&n.updateTextNode(i)})}updateLoopsBatch(e){const t=this.domBindingManager.loopManager;if(!t)return;const n=new Map;e.forEach(([r,a])=>{const o=S.getElementDepth(r);n.has(o)||n.set(o,[]),n.get(o).push([r,a])});const i=Array.from(n.keys()).sort((r,a)=>r-a);for(const r of i)n.get(r).forEach(([o,c])=>{document.contains(o)&&t.renderLoop(c,c.iterableExpr)})}updateElementsBatch(e,t){e.forEach(n=>{document.contains(n)&&this.domBindingManager.processElementBindings(n,!0)})}}class Wt{loopBindings=new Map;stateManager;expressionEvaluator;componentManager;domBindingManager;cleanupObserver;loopCounter=0;pendingTemplates=[];loopItemElements=new WeakSet;loopItemContexts=new WeakMap;templateRenderer;templateMoveObserver;constructor(e,t){this.stateManager=e,this.expressionEvaluator=t,this.cleanupObserver=new MutationObserver(n=>{this.cleanupDetachedTemplates(n)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateMoveObserver=new MutationObserver(n=>{this.handleTemplateMoves(n)}),this.templateMoveObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateRenderer=new Je(t)}handleTemplateMoves(e){const t=new Set;for(const n of e)n.type==="childList"&&n.addedNodes.forEach(i=>{if(i.nodeType!==Node.ELEMENT_NODE)return;const r=i;if(r.querySelectorAll("template[pp-for]").forEach(o=>{const c=o;this.loopBindings.has(c)&&t.add(c)}),r.tagName==="TEMPLATE"&&r.hasAttribute("pp-for")){const o=r;this.loopBindings.has(o)&&t.add(o)}});t.size>0&&setTimeout(()=>{t.forEach(n=>{document.contains(n)&&this.updateMovedTemplate(n)})},0)}updateMovedTemplate(e){const t=this.loopBindings.get(e);if(!t)return;const n=e.parentElement;if(!n||n===t.parentElement&&t.placeholder.parentElement===n&&t.placeholder.nextSibling===e)return;const i=[...t.renderedItems];t.placeholder.parentElement&&t.placeholder.parentElement!==n&&t.placeholder.parentElement.removeChild(t.placeholder);const r=document.createComment(`pp-for: ${t.expression}`);n.insertBefore(r,e),t.parentElement=n,t.placeholder=r,i.length>0&&(i.forEach(a=>{a.element.parentElement!==n&&n.insertBefore(a.element,e)}),this.updateDOMOrder(t,i)),setTimeout(()=>{document.contains(e)&&this.renderLoop(t,t.iterableExpr)},0)}getLoopContextForElement(e){if(!this.domBindingManager)return null;const t=this.domBindingManager.loopManager;if(!t)return null;let n=e.parentElement;for(;n;){if(t.isLoopItem&&t.isLoopItem(n))return t.getLoopItemContext(n);n=n.parentElement}const i=t.getAllLoops();for(const[r,a]of i)for(const o of a.renderedItems)if(o.element.contains(e))return o.context;return null}setDependencies(e,t){this.componentManager=e,this.domBindingManager=t}queueTemplate(e,t){this.loopBindings.has(e)||this.pendingTemplates.push({template:e,component:t})}processPendingTemplates(){const e=[...this.pendingTemplates];this.pendingTemplates=[];for(const{template:t,component:n}of e)document.contains(t)&&this.processTemplate(t,n)}processTemplate(e,t){const n=e.getAttribute("pp-for");if(!n||this.loopBindings.has(e))return;if(!e.parentElement){console.warn("⚠️ Template has no parent, queueing for later:",n),this.queueTemplate(e,t);return}const i=this.parseLoopExpression(n);if(!i){console.error(`Invalid pp-for syntax: "${n}"`);return}const r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let a=t;r&&(r==="app"?a="app":r==="parent"?a=S.getParentOfComponent(t,e):a=r);const o=e.parentElement,c=document.createComment(`pp-for: ${n}`);o.insertBefore(c,e);const l={template:e,expression:n,itemVar:i.itemVar,indexVar:i.indexVar,component:a,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:o,placeholder:c,iterableExpr:i.iterableExpr};this.loopBindings.set(e,l),this.setupLoopReactivity(l,i.iterableExpr),this.renderLoop(l,i.iterableExpr)}parseLoopExpression(e){const t=e.match(/^\s*([a-zA-Z_$][\w$]*)\s+in\s+(.+)$/);if(t)return{itemVar:t[1],iterableExpr:t[2].trim()};const n=e.match(/^\s*\(\s*([a-zA-Z_$][\w$]*)\s*,\s*([a-zA-Z_$][\w$]*)\s*\)\s+in\s+(.+)$/);return n?{itemVar:n[1],indexVar:n[2],iterableExpr:n[3].trim()}:null}setupLoopReactivity(e,t){const n=`loop_${Date.now()}_${++this.loopCounter}`,i=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager),r=this.findComponentElementForLoop(e);if(r&&this.componentManager){const o=this.componentManager.getComponentPropDependencies(r,e.component);i.push(...o)}const a={id:n,selector:"",dependencies:new Set(i),callback:()=>{this.renderLoop(e,e.iterableExpr)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(n)}renderLoop(e,t){if(!(!this.componentManager||!this.domBindingManager))try{const n=this.findComponentElementForLoop(e);let i;const r=this.findParentLoopContext(e.template);if(e.template.hasAttribute(d.ATTR_PREFIXES.CONTEXT)){const p=this.componentManager.buildComponentContext(e.component);if(n){const h=this.componentManager.evaluateProps(n);i={...p,...h}}else i=p;r&&(i={...i,...r})}else{if(i=this.componentManager.buildRestrictedComponentContext(e.component,!1),n&&this.componentManager.hasStoredProps(n)){const p=this.componentManager.evaluateProps(n);Object.assign(i,p)}r&&(i={...i,...r})}const c=this.expressionEvaluator.evaluateExpression(t,i,e.component),l=He(c);if(!Array.isArray(l)){console.warn(`Loop expression "${t}" did not return an array:`,l,`Available context keys: [${Object.keys(i).join(", ")}]`,"Parent loop context:",r),this.clearRenderedItems(e);return}this.updateRenderedItems(e,l)}catch(n){console.error(`Error evaluating loop expression "${t}":`,n),this.clearRenderedItems(e)}}findParentLoopContext(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const i=this.loopItemContexts.get(n);i&&t.unshift(i)}for(const[i,r]of this.loopBindings)if(r.template!==e){for(const a of r.renderedItems)if(a.element===n||a.element.contains(e)){t.unshift(a.context);break}}n=n.parentElement}return t.length>0?t.reduce((i,r)=>({...i,...r}),{}):null}findComponentElementForLoop(e){let t=e.parentElement;for(;t;){if(t.getAttribute(d.ATTR_PREFIXES.COMPONENT)===e.component)return t;t=t.parentElement}return document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e.component}"]`)[0]||void 0}updateRenderedItems(e,t){const n=e.renderedItems,i=[],r=new Set,a=new Map;n.forEach(o=>{a.set(o.key,o)}),t.forEach((o,c)=>{const l=this.generateItemKey(e,o,c),p=a.get(l);if(p&&!r.has(p.element))r.add(p.element),this.updateItemContext(e,p,o,c),i.push(p);else{const h=this.createLoopItem(e,o,c,l);h&&(i.push(h),this.processNestedLoopsInItem(h,e.component))}}),n.forEach(o=>{r.has(o.element)||this.cleanupLoopItem(o)}),this.updateDOMOrder(e,i),e.renderedItems=i}processNestedLoopsInItem(e,t){e.element.querySelectorAll("template[pp-for]").forEach(i=>{const r=i;this.loopBindings.has(r)||this.processNestedTemplate(r,t,e.context)})}generateItemKey(e,t,n){const r=e.template.content.firstElementChild;if(r&&r.hasAttribute("key")){const a=r.getAttribute("key");try{const o=this.createItemContextWithParentContext(e,t,n),c=N.isSingleExpression(a);if(c){const l=this.expressionEvaluator.evaluateExpression(c,o,e.component);return String(l)}else{const l=N.parse(a);let p="";for(const h of l)if(h.type==="static")p+=h.content;else if(h.expression){const f=this.expressionEvaluator.evaluateExpression(h.expression,o,e.component);p+=ue(f)}return p}}catch(o){console.warn(`Error evaluating key expression "${a}":`,o,"Available context keys:",Object.keys(this.createItemContextWithParentContext(e,t,n)))}}return t&&typeof t=="object"&&"id"in t?String(t.id):`${e.expression}_${n}`}createItemContextWithParentContext(e,t,n){if(!this.componentManager)return{};const i=this.componentManager.buildComponentContext(e.component),r=this.getAllParentLoopContexts(e.template),a=t&&typeof t=="object"?Object.keys(t):[],o={};for(const[l,p]of Object.entries(i))a.includes(l)&&!l.startsWith("set")&&!l.endsWith("Getter")||(o[l]=p);const c={...o,...r,[e.itemVar]:t};return e.indexVar&&(c[e.indexVar]=n),c}getAllParentLoopContexts(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const i=this.loopItemContexts.get(n);i&&t.unshift(i)}for(const[i,r]of this.loopBindings)if(i!==e){for(const a of r.renderedItems)if(a.element===n||a.element.contains(e)){t.unshift(a.context);break}}n=n.parentElement}return t.reduce((i,r)=>({...i,...r}),{})}createItemContext(e,t,n){if(!this.componentManager)return{};const r=e.template.hasAttribute(d.ATTR_PREFIXES.CONTEXT),a=this.findComponentElementForLoop(e),o=a&&this.componentManager.hasStoredProps(a);let c;r||o?c=this.componentManager.buildComponentContext(e.component):c=this.componentManager.buildRestrictedComponentContext(e.component,!1);const l={},p=t&&typeof t=="object"?Object.keys(t):[];for(const[x,b]of Object.entries(c)){if(typeof b=="function"&&!b.__pphp_key){l[x]=b;continue}if(x.startsWith("set")||x.endsWith("Getter")){l[x]=b;continue}if(["getContext","withContext","__getProp"].includes(x)){l[x]=b;continue}p.includes(x)||(l[x]=b)}const h=this.findAllParentLoopContexts(e.template),f={...l,...h,[e.itemVar]:t};return e.indexVar&&(f[e.indexVar]=n),f}findAllParentLoopContexts(e){const t={};let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const i=this.loopItemContexts.get(n);if(i)for(const[r,a]of Object.entries(i))r in t||(t[r]=a)}for(const[i,r]of this.loopBindings)if(i!==e){for(const a of r.renderedItems)if(a.element===n){for(const[o,c]of Object.entries(a.context))o in t||(t[o]=c);break}}n=n.parentElement}return t}createLoopItem(e,t,n,i){if(!this.domBindingManager)return null;try{const r=this.createItemContextWithParentContext(e,t,n),a=document.importNode(e.template.content,!0),o=document.createElement("div");o.appendChild(a);const c=o.firstElementChild;if(!c)return console.warn("Template content must contain exactly one root element"),null;o.removeChild(c),this.loopItemElements.add(c),this.loopItemContexts.set(c,r),c.getAttribute("key")&&c.removeAttribute("key");const p={key:i,element:c,context:r,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map,parentTemplate:e.template};return this.executeComponentScriptsInLoopItem(c),this.processRefsInLoopItem(c,r,e.component),this.processElementWithContext(c,r,e.component,p),this.cleanupRawMustacheAttributes(c),p}catch(r){return console.error("Error creating loop item:",r),null}}processRefsInLoopItem(e,t,n){if(e.hasAttribute("pp-ref")){const o=e.getAttribute("pp-ref");this.processRefAttribute(e,o,t,n)}const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>o.hasAttribute("pp-ref")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r;const a=[];for(;r=i.nextNode();)a.push(r);a.forEach(o=>{const c=o.getAttribute("pp-ref");this.processRefAttribute(o,c,t,n)})}processRefAttribute(e,t,n,i){try{const r=N.decodeEntities(t),a=N.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,n,i);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ Failed to process ref:",r)}}executeComponentScriptsInLoopItem(e){if(!this.componentManager)return;const t=[e],n=e.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`);t.push(...Array.from(n)),t.forEach(i=>{if(i.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){const r=i.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r){const a=this.getLoopItemContextForElement(i),o=this.generateInstanceId(a),c=`${r}_${o}`;i.setAttribute(d.ATTR_PREFIXES.COMPONENT,c),i.__originalComponentName=r,i.__uniqueComponentName=c,this.componentManager.pushComponent(c),window[c]||(window[c]={}),window[r]&&Object.assign(window[c],window[r]),this.getComponentScripts(i).forEach(p=>{this.componentManager.executeScript(p)}),this.componentManager.popComponent()}}})}getLoopItemContextForElement(e){let t=e;for(;t;){if(this.loopItemElements.has(t)){const n=this.loopItemContexts.get(t);if(n)return n}t=t.parentElement}for(const[n,i]of this.loopBindings)for(const r of i.renderedItems)if(r.element===e||r.element.contains(e))return r.context;return console.warn("⚠️ No loop item context found, using empty context"),{}}generateInstanceId(e){const t={};for(const[a,o]of Object.entries(e))typeof o=="function"||a.startsWith("set")||a.endsWith("Getter")||a==="getContext"||a==="withContext"||a==="__getProp"||o&&typeof o=="function"&&"__pphp_key"in o||typeof o=="boolean"||typeof o=="number"||typeof o=="string"||o&&typeof o=="object"&&!Array.isArray(o)&&"id"in o&&(t[a]=o);return Object.keys(t).length===0?`${Date.now()}_${Math.random().toString(36).substring(2,7)}`:Object.keys(t).sort().map(a=>{const o=t[a];return o&&typeof o=="object"&&"id"in o?`${a}_${o.id}`:`${a}_${JSON.stringify(o)}`}).join("_").replace(/[^a-zA-Z0-9_]/g,"").substring(0,20)||`fallback_${Date.now()}`}getComponentScripts(e){const t=[];return e.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`).forEach(i=>{const r=i;let a=r.parentElement,o=!1;for(;a&&a!==e.parentElement;){if(a===e){o=!0;break}if(a.hasAttribute(d.ATTR_PREFIXES.COMPONENT)&&a!==e)break;a=a.parentElement}o&&t.push(r)}),t}cleanupRawMustacheAttributes(e){this.cleanupElementMustacheAttributes(e);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n;for(;n=t.nextNode();)this.cleanupElementMustacheAttributes(n)}cleanupElementMustacheAttributes(e){const t=Array.from(e.attributes);for(const n of t)n.value&&d.MUSTACHE_PATTERN.test(n.value)&&(S.isBooleanAttribute(n.name),e.removeAttribute(n.name))}processElementWithContext(e,t,n,i){if(!this.domBindingManager||!this.componentManager)return;const r=(o,c)=>{const l=this.componentManager.buildComponentContext(c),p=o.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(p&&p!==c){const f=this.componentManager.buildComponentContext(p);return{...t,...l,...f}}return{...t,...l}},a=this.componentManager.buildComponentContextWithProps.bind(this.componentManager);this.componentManager.buildComponentContextWithProps=(o,c)=>c&&(c===e||e.contains(c))?r(c,o):a(o,c);try{if(e.hasAttribute("pp-ref")){const f=e.getAttribute("pp-ref");this.processRefInLoopContext(e,f,t,n),e.removeAttribute("pp-ref")}const o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:f=>f===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}),c=[];let l;for(;l=o.nextNode();){const f=l;if(f.hasAttribute("pp-ref")){const x=f.getAttribute("pp-ref");c.push({element:f,expression:x})}}c.forEach(({element:f,expression:x})=>{this.processRefInLoopContext(f,x,t,n)});const p=this.bindLoopItemElement(e,t,n,i);this.setupEventBindingsForLoopItem(e,n);for(let f=0;f<e.childNodes.length;f++){const x=e.childNodes[f];if(x.nodeType===Node.TEXT_NODE){const b=x;if(b.textContent&&d.MUSTACHE_PATTERN.test(b.textContent)&&!S.isTextNodeInsideScript(b)){const g=this.getComponentForTextNode(b);this.processTextNodeWithLoopContext(b,p,g,i)}}else if(x.nodeType===Node.ELEMENT_NODE){const b=x;if(b.tagName.toLowerCase()==="script")continue;const m=b.getAttribute(d.ATTR_PREFIXES.COMPONENT)||n,E=this.bindLoopItemElement(b,p,m,i);this.setupEventBindingsForLoopItem(b,m),this.processChildrenRecursively(b,E,m,i)}}e.querySelectorAll("template[pp-for]").forEach(f=>{(f.parentElement===e||e.contains(f))&&this.processNestedTemplate(f,n,p)})}finally{this.componentManager.buildComponentContextWithProps=a}}processChildrenRecursively(e,t,n,i){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{if(o===e)return NodeFilter.FILTER_SKIP;if(o.nodeType===Node.TEXT_NODE){const c=o;if(S.isTextNodeInsideScript(c))return NodeFilter.FILTER_REJECT;if(c.textContent&&d.MUSTACHE_PATTERN.test(c.textContent))return NodeFilter.FILTER_ACCEPT}else if(o.nodeType===Node.ELEMENT_NODE){const c=o;if(c.tagName.toLowerCase()==="script")return NodeFilter.FILTER_REJECT;const l=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);return l&&l!==n&&!i?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let a;for(;a=r.nextNode();)if(a.nodeType===Node.TEXT_NODE){const o=a,c=this.getComponentForTextNode(o);this.processTextNodeWithLoopContext(o,t,c,i)}else if(a.nodeType===Node.ELEMENT_NODE){const o=a,c=S.getElementComponent(o),l=this.bindLoopItemElement(o,t,c,i);this.setupEventBindingsForLoopItem(o,c),this.processChildrenRecursively(o,l,c,i)}}processChildElementsWithContext(e,t,n,i){const r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:l=>{if(l===e)return NodeFilter.FILTER_SKIP;if(l.nodeType===Node.TEXT_NODE){const p=l;if(S.isTextNodeInsideScript(p))return NodeFilter.FILTER_REJECT;if(p.textContent&&d.MUSTACHE_PATTERN.test(p.textContent))return NodeFilter.FILTER_ACCEPT}else if(l.nodeType===Node.ELEMENT_NODE){const p=l;if(p.tagName.toLowerCase()==="script")return NodeFilter.FILTER_REJECT;const h=p.getAttribute(d.ATTR_PREFIXES.COMPONENT);return h&&h!==n?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let a;const o=[],c=[];for(;a=r.nextNode();)a.nodeType===Node.ELEMENT_NODE?o.push(a):a.nodeType===Node.TEXT_NODE&&c.push(a);c.forEach(l=>{const p=this.getComponentForTextNode(l);this.processTextNodeWithLoopContext(l,t,p,i)}),o.forEach(l=>{const p=S.getElementComponent(l),h=this.bindLoopItemElement(l,t,p,i);this.setupEventBindingsForLoopItem(l,p),this.processChildElementsWithContext(l,h,p,i)})}processRefInLoopContext(e,t,n,i){try{const r=N.decodeEntities(t),a=N.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,n,i);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ processRefInLoopContext error:",r)}}getComponentForTextNode(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}processNestedTemplate(e,t,n){const i=e.getAttribute("pp-for");if(!i||this.loopBindings.has(e))return;const r=this.parseLoopExpression(i);if(!r){console.error(`Invalid pp-for syntax: "${i}"`);return}const a=e.parentElement,o=document.createComment(`pp-for: ${i}`);a.insertBefore(o,e);const c=this.findComponentElementForTemplate(e);let l={...n};const p=this.findParentLoopContextForNestedTemplate(e);if(p&&(l={...l,...p}),c&&this.componentManager){const f=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(f){const x=S.getParentComponentForElement(c);this.componentManager.hasStoredProps(c)||this.componentManager.setupProps(c,x);const b=this.evaluateComponentPropsWithContext(c,l);l={...this.componentManager.buildComponentContext(f),...b,...l}}}const h={template:e,expression:i,itemVar:r.itemVar,indexVar:r.indexVar,iterableExpr:r.iterableExpr,component:t,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:a,placeholder:o};this.loopBindings.set(e,h),this.setupNestedLoopReactivity(h,r.iterableExpr,l),this.renderNestedLoop(h,r.iterableExpr,l)}findParentLoopContextForNestedTemplate(e){let t=e.parentElement;const n={};let i=0;for(;t&&t!==document.body&&i<10;){if(i++,this.loopItemElements.has(t)){const r=this.loopItemContexts.get(t);if(r)for(const[a,o]of Object.entries(r))a in n||(n[a]=o)}for(const[r,a]of this.loopBindings)for(const o of a.renderedItems)(o.element.contains(e)||o.element===t)&&(a.itemVar in n||(n[a.itemVar]=o.context[a.itemVar]),a.indexVar&&!(a.indexVar in n)&&(n[a.indexVar]=o.context[a.indexVar]));t=t.parentElement}return Object.keys(n).length>0?n:null}evaluateComponentPropsWithContext(e,t){const n={};if(!this.componentManager||!this.expressionEvaluator)return n;const i=this.componentManager.extractProps(e,"app");for(const[r,a]of i)try{const o=this.templateRenderer.render(a.expression,t,a.component);n[r]=o}catch(o){console.error(`Failed to evaluate prop "${r}":`,o),n[r]=void 0}return n}findComponentElementForTemplate(e){let t=e.parentElement;for(;t;){if(t.hasAttribute(d.ATTR_PREFIXES.COMPONENT))return t;t=t.parentElement}return null}setupNestedLoopReactivity(e,t,n){const i=`nested_loop_${Date.now()}_${++this.loopCounter}`;let r=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager);const a={id:i,selector:"",dependencies:new Set(r),callback:()=>{const o=e.template,c=this.findComponentElementForTemplate(o);let l=n;if(o.parentElement){const h=this.getParentLoopContextForElement(o);h&&(l={...l,...h})}if(c&&this.componentManager){const h=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(h){const f=this.extractParentLoopContextFromBinding(e,n),x=this.evaluateComponentPropsWithContext(c,f),b=this.componentManager.buildComponentContext(h);l={...f,...b,...x}}}this.renderNestedLoop(e,t,l)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(i)}getParentLoopContextForElement(e){let t=e.parentElement;for(;t;){if(this.loopItemElements.has(t)){const n=this.loopItemContexts.get(t);if(n)return n}t=t.parentElement}return null}extractParentLoopContextFromBinding(e,t){const n=new Set;for(const[r,a]of this.loopBindings)if(a!==e){for(const o of a.renderedItems)if(o.element.contains(e.template)){n.add(a.itemVar),a.indexVar&&n.add(a.indexVar);break}}const i={};for(const[r,a]of Object.entries(t))(n.has(r)||r.startsWith("users")||r.startsWith("set")||r.includes("Getter")||typeof a=="function")&&(i[r]=a);return i}renderNestedLoop(e,t,n){if(!(!this.componentManager||!this.domBindingManager))try{const r=e.template.hasAttribute(d.ATTR_PREFIXES.CONTEXT),a=this.findComponentElementForLoop(e),o=a&&this.componentManager.hasStoredProps(a);let c;if(r||o)c=n;else{const h=this.componentManager.buildRestrictedComponentContext(e.component,!1),f=this.extractLoopVariablesOnly(n);c={...h,...f}}const l=this.expressionEvaluator.evaluateExpression(t,c,e.component),p=He(l);if(!Array.isArray(p)){console.warn(`Nested loop expression "${t}" did not return an array:`,p,`Available context keys: [${Object.keys(c).join(", ")}]`),this.clearRenderedItems(e);return}this.updateNestedRenderedItems(e,p,c)}catch(i){console.error(`Error evaluating nested loop expression "${t}":`,i,`Available context keys: [${Object.keys(n).join(", ")}]`),this.clearRenderedItems(e)}}extractLoopVariablesOnly(e){const t={};for(const[n,i]of Object.entries(e))typeof i=="function"&&!("__pphp_key"in i)||n.startsWith("set")&&typeof i=="function"||n.endsWith("Getter")||["getContext","withContext","__getProp"].includes(n)||(t[n]=i);return t}updateNestedRenderedItems(e,t,n){const i=e.renderedItems,r=[],a=new Set,o=new Map;i.forEach(c=>{o.set(c.key,c)}),t.forEach((c,l)=>{const p=this.generateNestedItemKey(e,c,l,n),h=o.get(p);if(h&&!a.has(h.element))a.add(h.element),this.updateNestedItemContext(e,h,c,l,n),r.push(h);else{const f=this.createNestedLoopItem(e,c,l,p,n);f&&r.push(f)}}),i.forEach(c=>{a.has(c.element)||this.cleanupLoopItem(c)}),this.updateDOMOrder(e,r),e.renderedItems=r}generateNestedItemKey(e,t,n,i){return t&&typeof t=="object"&&"id"in t?String(t.id):`${e.expression}_${n}_${JSON.stringify(i[e.itemVar]||{})}`}createNestedLoopItem(e,t,n,i,r){if(!this.domBindingManager)return null;try{const a={...r,[e.itemVar]:t};e.indexVar&&(a[e.indexVar]=n);const o=document.importNode(e.template.content,!0),c=document.createElement("div");c.appendChild(o);const l=c.firstElementChild;if(!l)return console.warn("Template content must contain exactly one root element"),null;c.removeChild(l),this.loopItemElements.add(l),this.loopItemContexts.set(l,a),l.getAttribute("key")&&l.removeAttribute("key");const h={key:i,element:l,context:a,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.processElementWithContext(l,a,e.component,h),this.cleanupRawMustacheAttributes(l),h}catch(a){return console.error("Error creating nested loop item:",a),null}}updateNestedItemContext(e,t,n,i,r){const a={...r};a[e.itemVar]=n,e.indexVar&&(a[e.indexVar]=i);const o=this.gatherAllComponentContextsInLoopItem(t.element),c={...a,...o};if(t.context=c,this.loopItemContexts.set(t.element,c),t.textNodeTemplates)for(const[l,p]of t.textNodeTemplates)document.contains(l)&&this.updateTextNodeWithContext(l,p,c,this.getTextNodeComponent(l));if(t.attributeTemplates)for(const[l,p]of t.attributeTemplates)document.contains(l)&&p.forEach((h,f)=>{try{const x=S.getElementComponent(l),b=this.buildElementSpecificContext(l,c),g=this.templateRenderer.render(h,b,x);this.domBindingManager?.updateElementProperty(l,f,g)}catch(x){console.error(`Nested binding update error for "${h}":`,x)}})}bindLoopItemElement(e,t,n,i){const r=this.extractMustacheBindings(e),a=this.findOriginalComponentName(n),o=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let c=a;o?o==="app"?c="app":o==="parent"?c=this.findLoopParentComponent(e,a):c=o:c=this.findLoopParentComponent(e,a);let l=this.componentManager.buildComponentContext(c);l={...l,...t};const h=!!e.getAttribute(d.ATTR_PREFIXES.COMPONENT),f=new Map,x=new Map;r.forEach((E,A)=>{h&&A!=="class"&&A!=="style"?f.set(A,E):x.set(A,E)});const b={},g=this.sortPropsByDependency(f);for(const[E,A]of g)try{const I=this.templateRenderer.render(A,l,c);b[E]=I,l[E]=I}catch(I){console.error(`❌ Failed to evaluate prop "${E}":`,I),b[E]=void 0,l[E]=void 0}h&&Object.keys(b).length>0&&(window[n]||(window[n]={}),Object.assign(window[n],b));const m=l;return i&&Object.keys(b).length>0&&Object.assign(i.context,b),i&&r.size>0&&(i.attributeTemplates||(i.attributeTemplates=new Map),i.attributeTemplates.set(e,new Map(r))),r.forEach((E,A)=>{this.createLoopItemBinding(e,A,E,m,c,i)}),m}sortPropsByDependency(e){const t=Array.from(e.keys()),n=Array.from(e.entries()),i=[],r=[];for(const[a,o]of n)t.some(l=>l!==a&&o.includes(l))?r.push([a,o]):i.push([a,o]);return[...i,...r]}setupEventBindingsForLoopItem(e,t){const n=this.domBindingManager.eventDelegation;if(!n){console.warn("No event delegation manager available");return}const i=Array.from(e.attributes);for(const r of i)if(de.isEventAttribute(r.name)){const a=r.name.substring(2);n.registerEventHandler(e,a,r.value,t),e.removeAttribute(r.name)}}processTextNodeWithLoopContext(e,t,n,i){if(S.isTextNodeInsideScript(e))return;const r=e.textContent||"";if(!N.parse(r).some(g=>g.type==="expression"))return;i&&(i.textNodeTemplates||(i.textNodeTemplates=new Map),i.textNodeTemplates.set(e,r));const c=this.findActualComponentForTextNode(e);let l=t;c!==n&&i&&this.componentManager&&(l={...this.componentManager.buildComponentContext(c),...i.context}),this.updateTextNodeWithContext(e,r,l,c);const p=`loop_text_${Date.now()}_${Math.random()}`,h=this.templateRenderer.dependencies(r,c,this.stateManager),f=new Set(h),b={id:p,selector:"",dependencies:f,callback:()=>{if(!document.contains(e)){this.stateManager.removeSubscription(p);return}let g={};if(this.componentManager&&(c!==n&&i?g={...this.componentManager.buildComponentContext(c),...i.context}:g=this.componentManager.buildComponentContext(c)),i){const m={};let E=null;for(const[A,I]of this.loopBindings)if(I.renderedItems.includes(i)){E=I;break}if(E){m[E.itemVar]=i.context[E.itemVar],E.indexVar&&(m[E.indexVar]=i.context[E.indexVar]);const A=this.findParentLoopContext(E.template);A&&Object.assign(m,A)}g={...g,...m}}this.updateTextNodeWithContext(e,r,g,c)},component:c};this.stateManager.addSubscription(b),i&&i.subscriptionIds.push(p)}findActualComponentForTextNode(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n){const i=t.__uniqueComponentName;return i||n}t=t.parentElement}return"app"}updateTextNodeWithContext(e,t,n,i){const r=N.parse(t),a={};for(const[c,l]of Object.entries(n))typeof l=="function"&&"__pphp_key"in l?a[c]=l.value:a[c]=l;let o="";for(const c of r)if(c.type==="static")o+=c.content;else if(c.expression)try{const l=this.expressionEvaluator.evaluateExpression(c.expression,a,i);o+=ue(l)}catch(l){console.warn(`Loop text evaluation error for "${c.expression}":`,l,"Available context keys:",Object.keys(a)),o+=""}e.textContent!==o&&(e.textContent=o)}extractMustacheBindings(e){const t=new Map,n=e.attributes;for(let i=0;i<n.length;i++){const r=n[i];if(!(r.name===d.ATTR_PREFIXES.COMPONENT||r.name==="key"||r.name.startsWith("on"))&&r.value){const a=d.MUSTACHE_PATTERN.test(r.value),o=N.decodeEntities(r.value),c=d.MUSTACHE_PATTERN.test(o);(a||c)&&t.set(r.name,o)}}return t}createLoopItemBinding(e,t,n,i,r,a){const o=`loop_item_${Date.now()}_${Math.random()}`,c=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let l;if(c)if(c==="app")l="app";else if(c==="parent"){const R=e.getAttribute(d.ATTR_PREFIXES.COMPONENT)||r,V=this.findOriginalComponentName(R);l=this.findParentComponentForLoop(e,V)}else l=c;else l=this.findLoopParentComponent(e,r);const p=this.templateRenderer.dependencies(n,l,this.stateManager);let h=null;const f=[];if(a?.parentTemplate&&(h=this.findParentComponentWithPropsFromTemplate(a.parentTemplate),h&&this.componentManager)){const R=h.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(R){const V=this.componentManager.getComponentPropDependencies(h,R);f.push(...V);const L=this.componentManager.elementProps.get(h);if(L){const Q=Array.from(L.keys());for(const H of Q)if(n.includes(H)){const te=L.get(H);if(te){const he=this.templateRenderer.dependencies(te.expression,te.component,this.stateManager);f.push(...he)}}}}}const x=new Set([...p,...f,"*"]);let b=!1,g=0;const m=5,E=()=>{if(b)return;if(!document.contains(e)){if(g++,g<m){const V=10*Math.pow(2,g-1);setTimeout(()=>{b||E()},V)}else b=!0,this.stateManager.removeSubscription(o);return}g=0;try{const V=this.componentManager.buildComponentContext(l);let L;if(a){L={...V};let H=null;for(const[te,he]of this.loopBindings)if(he.renderedItems.includes(a)){H=he;break}H&&(L[H.itemVar]=a.context[H.itemVar],H.indexVar&&(L[H.indexVar]=a.context[H.indexVar]));for(const[te,he]of Object.entries(a.context))te in L||(L[te]=he);if(h&&this.componentManager){const te=this.componentManager.evaluateProps(h);Object.assign(L,te)}}else L=i;const Q=this.templateRenderer.render(n,L,l);this.domBindingManager?.updateElementProperty(e,t,Q)}catch(V){console.error(`❌ Loop item binding evaluation error for "${n}":`,V),console.error("Available context keys:",Object.keys(i))}},A={id:o,selector:"",dependencies:x,callback:()=>{b||E()},element:e,component:l};if(this.stateManager.addSubscription(A),a){a.subscriptionIds.push(o);const R=this.cleanupLoopItem.bind(this);this.cleanupLoopItem=V=>{V===a&&(b=!0),R(V)}}(()=>{document.contains(e)?E():Promise.resolve().then(()=>{if(!b&&document.contains(e))E();else if(!b&&g<m){g++;const R=10*Math.pow(2,g-1);setTimeout(()=>{b||E()},R)}else!b&&g>=m&&(b=!0,this.stateManager.removeSubscription(o))})})()}findParentComponentWithPropsFromTemplate(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.getAttribute(d.ATTR_PREFIXES.COMPONENT)&&this.componentManager?.hasStoredProps(t))return t;t=t.parentElement}return null}findLoopParentComponent(e,t){for(const[n,i]of this.loopBindings)for(const r of i.renderedItems)if(r.element===e||r.element.contains(e))return i.component;return this.findOriginalComponentName(t)}findParentComponentForLoop(e,t){for(const[n,i]of this.loopBindings)for(const r of i.renderedItems)if(r.element===e||r.element.contains(e))return this.findParentComponent(i.component,n);return S.getParentComponentForElement(e)}findParentComponent(e,t){if(e==="app")return"app";let n=t.parentElement;for(;n;){if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===e){let r=n.parentElement;for(;r;){const a=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(a)return a;r=r.parentElement}return"app"}n=n.parentElement}return"app"}findOriginalComponentName(e){return e.includes("_")&&/\d{13}/.test(e)?e.split("_")[0]:e}updateItemContext(e,t,n,i){const r=this.createItemContext(e,n,i),a=this.gatherAllComponentContextsInLoopItem(t.element),o={...r,...a};if(t.context=o,this.loopItemContexts.set(t.element,o),t.textNodeTemplates)for(const[c,l]of t.textNodeTemplates)document.contains(c)&&this.updateTextNodeWithContext(c,l,o,this.getTextNodeComponent(c));if(t.attributeTemplates)for(const[c,l]of t.attributeTemplates)document.contains(c)&&l.forEach((p,h)=>{try{const f=S.getElementComponent(c),x=this.buildElementSpecificContext(c,o),b=this.templateRenderer.render(p,x,f);this.domBindingManager?.updateElementProperty(c,h,b)}catch(f){console.error(`Attribute binding update error for "${p}":`,f)}})}gatherAllComponentContextsInLoopItem(e){if(!this.componentManager)return{};const t={};if(e.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){const i=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),r=this.componentManager.buildComponentContext(i);Object.assign(t,r)}return e.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`).forEach(i=>{const r=i.getAttribute(d.ATTR_PREFIXES.COMPONENT),a=this.componentManager?.buildComponentContext(r);Object.assign(t,a)}),t}buildElementSpecificContext(e,t){if(!this.componentManager)return t;const n=S.getElementComponent(e),i=this.componentManager.buildComponentContext(n);return{...t,...i}}getTextNodeComponent(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}updateDOMOrder(e,t){let n=e.placeholder;t.forEach(i=>{(i.element.parentElement!==e.parentElement||i.element!==n.nextSibling)&&e.parentElement.insertBefore(i.element,n.nextSibling),n=i.element})}clearRenderedItems(e){e.renderedItems.forEach(t=>{this.cleanupLoopItem(t)}),e.renderedItems=[]}cleanupLoopItem(e){this.loopItemElements.delete(e.element),this.loopItemContexts.delete(e.element),e.element.parentElement&&e.element.parentElement.removeChild(e.element),e.subscriptionIds.forEach(t=>{this.stateManager.removeSubscription(t)})}isLoopItem(e){return this.loopItemElements.has(e)}getLoopItemContext(e){return this.loopItemContexts.get(e)}cleanupDetachedTemplates(e){for(const t of e)t.type==="childList"&&t.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const i=n;if(document.contains(i))return;if(i.tagName==="TEMPLATE"&&i.hasAttribute("pp-for")){const a=i;document.contains(a)||this.cleanupTemplate(a)}i.querySelectorAll("template[pp-for]").forEach(a=>{const o=a;document.contains(o)||this.cleanupTemplate(o)})}})}cleanupTemplate(e){const t=this.loopBindings.get(e);t&&(this.clearRenderedItems(t),t.subscriptionIds.forEach(n=>{this.stateManager.removeSubscription(n)}),t.placeholder.parentElement&&t.placeholder.parentElement.removeChild(t.placeholder),this.loopBindings.delete(e))}getAllLoops(){return new Map(this.loopBindings)}destroy(){this.cleanupObserver.disconnect(),this.templateMoveObserver.disconnect(),Array.from(this.loopBindings.keys()).forEach(e=>{this.cleanupTemplate(e)}),this.loopItemContexts=new WeakMap}}class z{cache=new Map;maxSize;hits=0;misses=0;constructor(e){this.maxSize=e}keys(){return Array.from(this.cache.keys())}deleteByPrefix(e){let t=0;const n=[];return this.cache.forEach((i,r)=>{typeof r=="string"&&r.startsWith(e)&&n.push(r)}),n.forEach(i=>{this.cache.delete(i)&&t++}),t}getKeysByPrefix(e){const t=[];return this.cache.forEach((n,i)=>{typeof i=="string"&&i.startsWith(e)&&t.push(i)}),t}get(e){const t=this.cache.get(e);if(t!==void 0)return this.hits++,this.cache.delete(e),this.cache.set(e,t),t;this.misses++}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){const n=this.cache.keys().next().value;n!==void 0&&this.cache.delete(n)}this.cache.set(e,t)}size(){return this.cache.size}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.hits=0,this.misses=0}getStats(){const e=this.hits+this.misses;return{size:this.cache.size,maxSize:this.maxSize,hitRate:e>0?this.hits/e*100:0,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}}class N{static EXPRESSION_CACHE=new z(1e3);static parseSpreadDirective(e){const t=e.replace(/^\s*\{\s*|\s*\}\s*$/g,""),n=this.parseSpreadParts(t),i=[],r=[];for(const a of n){const o=a.trim();if(o.startsWith("..."))i.push(o.substring(3).trim());else if(o.startsWith("{")&&o.endsWith("}")){const c=o.slice(1,-1).trim();if(c){const l=this.parseObjectProperties(c);r.push(l)}}else console.warn(`Invalid spread directive part: "${o}". Expected ...spread or {object}`)}return{spreads:i,objects:r}}static parseSpreadParts(e){const t=[];let n="",i=0,r=!1,a="",o=0;for(;o<e.length;){const c=e[o],l=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r){if(c==="{")i++;else if(c==="}")i--;else if(c===","&&i===0){t.push(n.trim()),n="",o++;continue}}n+=c,o++}return n.trim()&&t.push(n.trim()),t}static parseObjectProperties(e){const t=[],n=this.parseObjectParts(e);for(const i of n){const r=i.trim(),a=this.findPropertySeparator(r);if(a!==-1){const o=r.substring(0,a).trim().replace(/['"]/g,""),c=r.substring(a+1).trim();t.push({key:o,value:c})}else console.warn(`Invalid object property: "${r}". Expected key: value format.`)}return t}static parseObjectParts(e){const t=[];let n="",i=0,r=!1,a="";for(let o=0;o<e.length;o++){const c=e[o],l=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r){if(c==="{"||c==="["||c==="(")i++;else if(c==="}"||c==="]"||c===")")i--;else if(c===","&&i===0){t.push(n.trim()),n="";continue}}n+=c}return n.trim()&&t.push(n.trim()),t}static findPropertySeparator(e){let t=0,n=!1,i="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!n&&(a==='"'||a==="'")?(n=!0,i=a):n&&a===i&&o!=="\\"&&(n=!1,i=""),!n){if(a==="{"||a==="["||a==="(")t++;else if(a==="}"||a==="]"||a===")")t--;else if(a===":"&&t===0)return r}}return-1}static decodeEntities=e=>{const t=document.createElement("textarea");t.innerHTML=e;let n=t.value;for(;n.includes("&");){t.innerHTML=n;const i=t.value;if(i===n)break;n=i}return n};static parse(e){const t=N.decodeEntities(e);if(N.EXPRESSION_CACHE.has(t))return N.EXPRESSION_CACHE.get(t);const n=N.parseContentWithNesting(t);return N.EXPRESSION_CACHE.set(t,n),n}static parseContentWithNesting(e){const t=[],n=e.length;let i=0,r=0;for(;i<n;)if(e[i]==="{"){i>r&&t.push({type:"static",content:e.substring(r,i),expression:null});const o=this.extractNestedExpression(e,i);o.endIndex!==-1?(t.push({type:"expression",content:e.substring(i,o.endIndex+1),expression:o.expression.trim()}),i=o.endIndex+1,r=i):i++}else i++;return r<n&&t.push({type:"static",content:e.substring(r),expression:null}),t}static extractNestedExpression(e,t){let n=1,i=t+1,r=!1,a="",o=!1;for(;i<e.length&&n>0;){const c=e[i],l=i>0?e[i-1]:"";!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r&&c==="`"&&l!=="\\"&&(o=!o),!r&&!o&&(c==="{"?n++:c==="}"&&n--),i++}if(n===0){const c=e.slice(t+1,i-1);if(c.trim()){const l=this.checkForMismatchedQuotes(c);l.hasIssue&&(console.error(`
|
|
8
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};A.readEscapedChar=function(s){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return`
|
|
9
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return se(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),s){var t=this.pos-1;this.invalidStringToken(t,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(n,8);return i>255&&(n=n.slice(0,-1),i=parseInt(n,8)),this.pos+=n.length-1,e=this.input.charCodeAt(this.pos),(n!=="0"||e===56||e===57)&&(this.strict||s)&&this.invalidStringToken(this.pos-1-n.length,s?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return xe(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};A.readHexChar=function(s){var e=this.pos,t=this.readInt(16,s);return t===null&&this.invalidStringToken(e,"Bad character escape sequence"),t};A.readWord1=function(){this.containsEsc=!1;for(var s="",e=!0,t=this.pos,n=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(ae(i,n))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,s+=this.input.slice(t,this.pos);var r=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(e?Y:ae)(a,n)||this.invalidStringToken(r,"Invalid Unicode escape"),s+=se(a),t=this.pos}else break;e=!1}return s+this.input.slice(t,this.pos)};A.readWord=function(){var s=this.readWord1(),e=u.name;return this.keywords.test(s)&&(e=Xe[s]),this.finishToken(e,s)};var Ps="8.15.0";M.acorn={Parser:M,version:Ps,defaultOptions:$e,Position:ve,SourceLocation:ke,getLineInfo:pt,Node:Oe,TokenType:_,tokTypes:u,keywordTypes:Xe,TokContext:G,tokContexts:k,isIdentifierChar:ae,isIdentifierStart:Y,Token:Ze,isNewLine:xe,lineBreak:D,lineBreakG:Gt,nonASCIIwhitespace:ut};function B(s,e){return M.parse(s,e)}function $(s,e,t,n,i){t||(t=b),(function r(a,o,c){var l=c||a.type;t[l](a,o,r),e[l]&&e[l](a,o)})(s,n,i)}function _s(s,e,t,n,i){var r=[];t||(t=b),(function a(o,c,l){var p=l||o.type,h=o!==r[r.length-1];h&&r.push(o),t[p](o,c,a),e[p]&&e[p](o,c||r,r),h&&r.pop()})(s,n,i)}function Ye(s,e,t){t(s,e)}function pe(s,e,t){}var b={};b.Program=b.BlockStatement=b.StaticBlock=function(s,e,t){for(var n=0,i=s.body;n<i.length;n+=1){var r=i[n];t(r,e,"Statement")}};b.Statement=Ye;b.EmptyStatement=pe;b.ExpressionStatement=b.ParenthesizedExpression=b.ChainExpression=function(s,e,t){return t(s.expression,e,"Expression")};b.IfStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Statement"),s.alternate&&t(s.alternate,e,"Statement")};b.LabeledStatement=function(s,e,t){return t(s.body,e,"Statement")};b.BreakStatement=b.ContinueStatement=pe;b.WithStatement=function(s,e,t){t(s.object,e,"Expression"),t(s.body,e,"Statement")};b.SwitchStatement=function(s,e,t){t(s.discriminant,e,"Expression");for(var n=0,i=s.cases;n<i.length;n+=1){var r=i[n];t(r,e)}};b.SwitchCase=function(s,e,t){s.test&&t(s.test,e,"Expression");for(var n=0,i=s.consequent;n<i.length;n+=1){var r=i[n];t(r,e,"Statement")}};b.ReturnStatement=b.YieldExpression=b.AwaitExpression=function(s,e,t){s.argument&&t(s.argument,e,"Expression")};b.ThrowStatement=b.SpreadElement=function(s,e,t){return t(s.argument,e,"Expression")};b.TryStatement=function(s,e,t){t(s.block,e,"Statement"),s.handler&&t(s.handler,e),s.finalizer&&t(s.finalizer,e,"Statement")};b.CatchClause=function(s,e,t){s.param&&t(s.param,e,"Pattern"),t(s.body,e,"Statement")};b.WhileStatement=b.DoWhileStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.body,e,"Statement")};b.ForStatement=function(s,e,t){s.init&&t(s.init,e,"ForInit"),s.test&&t(s.test,e,"Expression"),s.update&&t(s.update,e,"Expression"),t(s.body,e,"Statement")};b.ForInStatement=b.ForOfStatement=function(s,e,t){t(s.left,e,"ForInit"),t(s.right,e,"Expression"),t(s.body,e,"Statement")};b.ForInit=function(s,e,t){s.type==="VariableDeclaration"?t(s,e):t(s,e,"Expression")};b.DebuggerStatement=pe;b.FunctionDeclaration=function(s,e,t){return t(s,e,"Function")};b.VariableDeclaration=function(s,e,t){for(var n=0,i=s.declarations;n<i.length;n+=1){var r=i[n];t(r,e)}};b.VariableDeclarator=function(s,e,t){t(s.id,e,"Pattern"),s.init&&t(s.init,e,"Expression")};b.Function=function(s,e,t){s.id&&t(s.id,e,"Pattern");for(var n=0,i=s.params;n<i.length;n+=1){var r=i[n];t(r,e,"Pattern")}t(s.body,e,s.expression?"Expression":"Statement")};b.Pattern=function(s,e,t){s.type==="Identifier"?t(s,e,"VariablePattern"):s.type==="MemberExpression"?t(s,e,"MemberPattern"):t(s,e)};b.VariablePattern=pe;b.MemberPattern=Ye;b.RestElement=function(s,e,t){return t(s.argument,e,"Pattern")};b.ArrayPattern=function(s,e,t){for(var n=0,i=s.elements;n<i.length;n+=1){var r=i[n];r&&t(r,e,"Pattern")}};b.ObjectPattern=function(s,e,t){for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];r.type==="Property"?(r.computed&&t(r.key,e,"Expression"),t(r.value,e,"Pattern")):r.type==="RestElement"&&t(r.argument,e,"Pattern")}};b.Expression=Ye;b.ThisExpression=b.Super=b.MetaProperty=pe;b.ArrayExpression=function(s,e,t){for(var n=0,i=s.elements;n<i.length;n+=1){var r=i[n];r&&t(r,e,"Expression")}};b.ObjectExpression=function(s,e,t){for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];t(r,e)}};b.FunctionExpression=b.ArrowFunctionExpression=b.FunctionDeclaration;b.SequenceExpression=function(s,e,t){for(var n=0,i=s.expressions;n<i.length;n+=1){var r=i[n];t(r,e,"Expression")}};b.TemplateLiteral=function(s,e,t){for(var n=0,i=s.quasis;n<i.length;n+=1){var r=i[n];t(r,e)}for(var a=0,o=s.expressions;a<o.length;a+=1){var c=o[a];t(c,e,"Expression")}};b.TemplateElement=pe;b.UnaryExpression=b.UpdateExpression=function(s,e,t){t(s.argument,e,"Expression")};b.BinaryExpression=b.LogicalExpression=function(s,e,t){t(s.left,e,"Expression"),t(s.right,e,"Expression")};b.AssignmentExpression=b.AssignmentPattern=function(s,e,t){t(s.left,e,"Pattern"),t(s.right,e,"Expression")};b.ConditionalExpression=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Expression"),t(s.alternate,e,"Expression")};b.NewExpression=b.CallExpression=function(s,e,t){if(t(s.callee,e,"Expression"),s.arguments)for(var n=0,i=s.arguments;n<i.length;n+=1){var r=i[n];t(r,e,"Expression")}};b.MemberExpression=function(s,e,t){t(s.object,e,"Expression"),s.computed&&t(s.property,e,"Expression")};b.ExportNamedDeclaration=b.ExportDefaultDeclaration=function(s,e,t){s.declaration&&t(s.declaration,e,s.type==="ExportNamedDeclaration"||s.declaration.id?"Statement":"Expression"),s.source&&t(s.source,e,"Expression")};b.ExportAllDeclaration=function(s,e,t){s.exported&&t(s.exported,e),t(s.source,e,"Expression")};b.ImportDeclaration=function(s,e,t){for(var n=0,i=s.specifiers;n<i.length;n+=1){var r=i[n];t(r,e)}t(s.source,e,"Expression")};b.ImportExpression=function(s,e,t){t(s.source,e,"Expression")};b.ImportSpecifier=b.ImportDefaultSpecifier=b.ImportNamespaceSpecifier=b.Identifier=b.PrivateIdentifier=b.Literal=pe;b.TaggedTemplateExpression=function(s,e,t){t(s.tag,e,"Expression"),t(s.quasi,e,"Expression")};b.ClassDeclaration=b.ClassExpression=function(s,e,t){return t(s,e,"Class")};b.Class=function(s,e,t){s.id&&t(s.id,e,"Pattern"),s.superClass&&t(s.superClass,e,"Expression"),t(s.body,e)};b.ClassBody=function(s,e,t){for(var n=0,i=s.body;n<i.length;n+=1){var r=i[n];t(r,e)}};b.MethodDefinition=b.PropertyDefinition=b.Property=function(s,e,t){s.computed&&t(s.key,e,"Expression"),s.value&&t(s.value,e,"Expression")};const d={ATTR_PREFIXES:{COMPONENT:"pp-component",CONTEXT:"pp-context",LOOP:"pp-for",SPREAD:"pp-spread",REF:"pp-ref"},SCRIPT_TYPE:"text/pp",MAX_CACHE_SIZE:2e3,DEBOUNCE_MS:16,POOL_SIZE:10,MUSTACHE_PATTERN:/\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/,MUSTACHE_SINGLE_PATTERN:/^\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}$/},ge=new Set(["true","false","null","undefined","this","window","document","console","Math","Date","JSON","Object","Array","return","let","const","var","if","else","for","while","switch","case","break","continue","function","new","in","of","typeof","instanceof","void","delete","try","catch","finally","class","extends","super","thisElement","eventObject","arguments"]);function Ns(s,e){let t;return(...n)=>{clearTimeout(t),t=window.setTimeout(()=>s(...n),e)}}function jt(s){return s.charAt(0).toUpperCase()+s.slice(1)}function ue(s){if(s==null||typeof s=="boolean"||typeof s=="function"||Array.isArray(s)&&s.length===0||typeof s=="object"&&Object.keys(s).length===0)return"";if(typeof s=="number")return String(s);if(typeof s=="string")return s;if(Array.isArray(s))return s.map(e=>ue(e)).filter(e=>e!=="").join("");if(typeof s=="object")try{return JSON.stringify(s)}catch{return"[object Object]"}return String(s)}function He(s){return typeof s=="function"&&"__pphp_key"in s?s.value:s}class ks{portals=new Map;portalCounter=0;componentManager;domBindingManager;cleanupObserver;stateManager;pphpInstance;constructor(){this.cleanupObserver=new MutationObserver(e=>{this.handleMutations(e)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}setDependencies(e,t,n,i){this.componentManager=e,this.domBindingManager=t,this.stateManager=n,this.pphpInstance=i}createPortal(e,t,n){const i=typeof t=="string"?document.querySelector(t):t;if(!i)throw new Error(`Portal container not found: ${t}`);const r=this.componentManager?.getCurrentComponent()||"app",a=n?.key||`portal_${++this.portalCounter}_${Date.now()}`;this.portals.has(a)&&this.removePortal(a);const o={id:a,content:e,container:i,component:r};return this.portals.set(a,o),this.renderPortalWithHydration(o,n,a),a}async renderPortalWithHydration(e,t,n){if(!this.componentManager||!this.domBindingManager){console.warn("PortalManager dependencies not set");return}try{await this.renderPortal(e,t),await new Promise(i=>requestAnimationFrame(i)),this.domBindingManager.processPendingBindings(),await new Promise(i=>{this.stateManager?.onDOMUpdateComplete(()=>{i(void 0)})}),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n),t?.onMount&&t.onMount(e.container)}catch(i){console.error("Portal hydration error:",i),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n)}}renderPortal(e,t){return new Promise((n,i)=>{if(!this.componentManager||!this.domBindingManager){console.warn("PortalManager dependencies not set"),i(new Error("Dependencies not set"));return}try{e.renderedContent&&e.renderedContent.parentElement&&e.renderedContent.parentElement.removeChild(e.renderedContent);let r;if(typeof e.content=="string"){const o=document.createElement("template");if(o.innerHTML=e.content.trim(),r=o.content.firstElementChild,!r)throw new Error("Invalid HTML string for portal content")}else if(e.content instanceof DocumentFragment){const o=document.createElement("div");if(o.appendChild(e.content.cloneNode(!0)),r=o.firstElementChild,!r)throw new Error("DocumentFragment must contain at least one element")}else r=e.content;r.setAttribute("data-portal-id",e.id),r.setAttribute("data-portal-component",e.component),r.hasAttribute("pp-context")||r.setAttribute("pp-context",e.component),e.container.appendChild(r),e.renderedContent=r;const a=[...this.componentManager.componentStack];e.component!=="app"?this.componentManager.componentStack=["app",e.component]:this.componentManager.componentStack=["app"];try{this.componentManager.executePhpScripts(r),this.domBindingManager.processElement(r,!0);const o=r.querySelectorAll("template[pp-for]"),c=this.domBindingManager.loopManager;c&&(o.forEach(l=>{const p=l,h=p.getAttribute("pp-context");if(c.loopBindings?.has(p))if(typeof c.updateTemplateParent=="function")c.updateTemplateParent(p);else{const f=c.loopBindings.get(p);f&&(f.subscriptionIds?.forEach(E=>{this.stateManager?.removeSubscription(E)}),c.loopBindings.delete(p)),c.processTemplate(p,h||e.component)}else c.queueTemplate(p,h||e.component)}),c.processPendingTemplates()),this.domBindingManager.processPendingBindings(),n()}finally{this.componentManager.componentStack=a}}catch(r){console.error("Portal rendering error:",r),this.portals.delete(e.id),i(r)}})}removePortal(e){const t=this.portals.get(e);if(!t)return!1;try{return t.cleanup&&t.cleanup(),t.renderedContent&&this.cleanupPortalElement(t.renderedContent),t.renderedContent&&t.renderedContent.parentElement&&t.renderedContent.parentElement.removeChild(t.renderedContent),this.portals.delete(e),!0}catch(n){return console.error("Portal cleanup error:",n),!1}}cleanupPortalElement(e){if(this.stateManager){const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n=e;do n.nodeType===Node.ELEMENT_NODE&&this.stateManager.subscriptionManager?.cleanupElement(n);while(n=t.nextNode())}}updatePortal(e,t,n){const i=this.portals.get(e);return i?(i.content=t,this.renderPortal(i,n),!0):!1}getPortal(e){return this.portals.get(e)}hasPortal(e){return this.portals.has(e)}getAllPortals(){return Array.from(this.portals.values())}handleMutations(e){for(const t of e)t.type==="childList"&&t.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const i=n;for(const[r,a]of this.portals)(a.container===i||i.contains(a.container))&&this.removePortal(r)}})}destroy(){for(const e of Array.from(this.portals.keys()))this.removePortal(e);this.cleanupObserver.disconnect(),this.portals.clear()}}class Is{static validate(e,t){const n=[],i=[],r=this.validateTernaryOperator(e);n.push(...r.errors),i.push(...r.warnings);const a=this.validateSyntax(e);return n.push(...a.errors),i.push(...a.warnings),{valid:n.length===0,errors:n,warnings:i}}static validateTernaryOperator(e){const t=[],n=[];if(!e.includes("?")||!e.includes(":"))return{errors:t,warnings:n};const i=e.match(/([^?]+)\?([^:]+):(.+)/);if(!i)return{errors:t,warnings:n};const[,,r,a]=i,o=r.trim(),c=this.validateBranch(o,"truthy");t.push(...c.errors),n.push(...c.warnings);const l=a.trim(),p=this.validateBranch(l,"falsy");return t.push(...p.errors),n.push(...p.warnings),{errors:t,warnings:n}}static validateBranch(e,t){const n=[],i=[],r=this.countQuotes(e);if(r.single%2!==0&&(n.push(`Unmatched single quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,"'"))){const a=this.suggestQuoteFix(e,"'");a&&n.push(` Did you mean: ${a}`)}if(r.double%2!==0&&(n.push(`Unmatched double quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,'"'))){const a=this.suggestQuoteFix(e,'"');a&&n.push(` Did you mean: ${a}`)}return r.single===0&&r.double===0&&this.looksLikeUnquotedLiteral(e)&&i.push(`Value "${e}" in ternary ${t} branch may need quotes. Did you mean '${e}' or "${e}"?`),{errors:n,warnings:i}}static hasTrailingOrLeadingQuote(e,t){const n=e.startsWith(t),i=e.endsWith(t);return n&&!i||!n&&i}static suggestQuoteFix(e,t){return e.endsWith(t)&&!e.startsWith(t)?`${t}${e}`:e.startsWith(t)&&!e.endsWith(t)?`${e}${t}`:null}static looksLikeUnquotedLiteral(e){const t=e.trim();return!t||this.isAlreadyQuoted(t)||ge.has(t)||t==="true"||t==="false"||t==="null"||t==="undefined"||!isNaN(Number(t))&&t!==""||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)||t.includes(".")||/\[.*\]/.test(t)||/\(.*\)/.test(t)?!1:!!(t.includes("-")||/\s/.test(t)||/[^a-zA-Z0-9_$.]/.test(t))}static isAlreadyQuoted(e){return e.startsWith("'")&&e.endsWith("'")&&e.length>=2||e.startsWith('"')&&e.endsWith('"')&&e.length>=2}static countQuotes(e){let t=0,n=0,i=!1;for(let r=0;r<e.length;r++){if(i){i=!1;continue}if(e[r]==="\\"){i=!0;continue}e[r]==="'"&&t++,e[r]==='"'&&n++}return{single:t,double:n}}static validateSyntax(e){const t=[],n=[],i=this.checkBrackets(e);i.valid||t.push(i.error);const r=this.checkParentheses(e);return r.valid||t.push(r.error),{errors:t,warnings:n}}static checkBrackets(e){let t=0,n=!1,i="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!n&&(a==="'"||a==='"')?(n=!0,i=a):n&&a===i&&o!=="\\"&&(n=!1,i=""),!n&&(a==="{"&&t++,a==="}"&&t--,t<0))return{valid:!1,error:"Unexpected closing bracket '}'"}}return t!==0?{valid:!1,error:"Mismatched brackets - missing '}'"}:{valid:!0,error:""}}static checkParentheses(e){let t=0,n=!1,i="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!n&&(a==="'"||a==='"')?(n=!0,i=a):n&&a===i&&o!=="\\"&&(n=!1,i=""),!n&&(a==="("&&t++,a===")"&&t--,t<0))return{valid:!1,error:"Unexpected closing parenthesis ')'"}}return t!==0?{valid:!1,error:"Mismatched parentheses - missing ')'"}:{valid:!0,error:""}}}class fe{static instance;walkerPool=[];traversalCache=new WeakMap;lastCacheTime=new WeakMap;CACHE_TTL=250;trackedElements=new Set;static getInstance(){return fe.instance||(fe.instance=new fe),fe.instance}acquireWalker(e,t,n){return document.createTreeWalker(e,t,n)}releaseWalker(e){this.walkerPool.length<3&&this.walkerPool.push(e)}getCachedTraversal(e,t,n){const i=Date.now(),r=this.traversalCache.get(e),a=this.lastCacheTime.get(e);if(r&&a&&i-a<this.CACHE_TTL){const c=r.get(t);if(c)return c}const o=n();return this.traversalCache.has(e)||(this.traversalCache.set(e,new Map),this.trackedElements.add(e)),this.traversalCache.get(e).set(t,o),this.lastCacheTime.set(e,i),o}traverseElementsAndText(e,t,n){const i=this.acquireWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),r=[],a=[];let o;for(;o=i.nextNode();)if(o.nodeType===Node.ELEMENT_NODE){const c=o;(!t||t(c))&&r.push(c)}else if(o.nodeType===Node.TEXT_NODE){const c=o;(!n||n(c))&&a.push(c)}return this.releaseWalker(i),{elements:r,textNodes:a}}cleanupCache(){const e=[];for(const t of this.trackedElements)document.contains(t)||e.push(t);e.forEach(t=>{this.traversalCache.delete(t),this.lastCacheTime.delete(t),this.trackedElements.delete(t)})}}class V{static instance;componentElementsCache=new q(100);scriptElementsCache=new q(50);templateElementsCache=new q(50);selectorCache=new q(200);elementComponentCache=new WeakMap;parentComponentCache=new WeakMap;contextComponentCache=new WeakMap;elementDepthCache=new WeakMap;elementChildrenCache=new WeakMap;cacheHits=0;cacheMisses=0;static CACHE_KEYS={COMPONENT_ELEMENTS:e=>`comp:${e}`,SCRIPTS:(e,t)=>`scripts:${e}:${t}`,TEMPLATES:(e,t)=>`templates:${e}:${t}`,SELECTOR:e=>`sel:${e}`};static getInstance(){return V.instance||(V.instance=new V),V.instance}queryComponentElements(e){const t=V.CACHE_KEYS.COMPONENT_ELEMENTS(e);if(this.componentElementsCache.has(t))return this.cacheHits++,this.componentElementsCache.get(t);this.cacheMisses++;const n=Array.from(document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e}"]`));return n.forEach(i=>{this.elementComponentCache.set(i,e)}),this.componentElementsCache.set(t,n),n}querySelectorAll(e){const t=V.CACHE_KEYS.SELECTOR(e);if(this.selectorCache.has(t))return this.cacheHits++,this.selectorCache.get(t);this.cacheMisses++;const n=Array.from(document.querySelectorAll(e));return this.selectorCache.set(t,n),n}getElementComponent(e){if(this.elementComponentCache.has(e))return this.cacheHits++,this.elementComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;let n=e.parentElement;for(;n;){const i=n.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return this.elementComponentCache.set(e,i),i;n=n.parentElement}return this.elementComponentCache.set(e,"app"),"app"}getContextComponent(e){if(this.contextComponentCache.has(e))return this.cacheHits++,this.contextComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let n;return t?t==="app"?n="app":n=t:n=this.getElementComponent(e),this.contextComponentCache.set(e,n),n}getParentOfComponent(e,t){if(this.parentComponentCache.has(t))return this.cacheHits++,this.parentComponentCache.get(t);if(this.cacheMisses++,e==="app")return this.parentComponentCache.set(t,"app"),"app";let n=t;for(;n&&n.getAttribute(d.ATTR_PREFIXES.COMPONENT)!==e;)n=n.parentElement;if(!n)return this.parentComponentCache.set(t,"app"),"app";let i=n.parentElement;for(;i;){const r=i.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r)return this.parentComponentCache.set(t,r),r;i=i.parentElement}return this.parentComponentCache.set(t,"app"),"app"}getElementDepthCached(e){if(this.elementDepthCache.has(e))return this.cacheHits++,this.elementDepthCache.get(e);this.cacheMisses++;let t=0,n=e.parentElement;for(;n&&n!==document.body;)t++,n=n.parentElement;return this.elementDepthCache.set(e,t),t}getFirstComponentElement(e){const t=this.queryComponentElements(e);return t.length>0?t[0]:null}getComponentScripts(e,t){const n=V.CACHE_KEYS.SCRIPTS(e,t?.tagName||"global");if(this.scriptElementsCache.has(n))return this.cacheHits++,this.scriptElementsCache.get(n);this.cacheMisses++;let i=[];if(t){const r=t.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`);for(const a of r)a instanceof HTMLScriptElement&&i.push(a)}else{const r=document.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`);for(const a of r)if(a instanceof HTMLScriptElement){const o=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);(o===e||!o&&!a.closest(`[${d.ATTR_PREFIXES.COMPONENT}]`))&&i.push(a)}}return this.scriptElementsCache.set(n,i),i}getComponentTemplates(e,t){const n=V.CACHE_KEYS.TEMPLATES(e,t?.tagName||"global");if(this.templateElementsCache.has(n))return this.cacheHits++,this.templateElementsCache.get(n);this.cacheMisses++;let i=[];if(t){const r=t.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&i.push(a)}else{const r=document.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&i.push(a)}return this.templateElementsCache.set(n,i),i}querySelector(e){const t=this.querySelectorAll(e);return t.length>0?t[0]:null}findElementForComponent(e,t){if(t==="app")return document.body;const n=this.queryComponentElements(t);return n.length>0?n[0]:null}invalidateCache(e){switch(e){case"components":this.componentElementsCache.clear();break;case"selectors":this.selectorCache.clear();break;case"scripts":this.scriptElementsCache.clear();break;case"templates":this.templateElementsCache.clear();break;default:this.clearAllCaches()}}invalidateByComponent(e){const t=V.CACHE_KEYS.COMPONENT_ELEMENTS(e);this.componentElementsCache.delete(t);const n=V.CACHE_KEYS.SCRIPTS(e,"global");this.scriptElementsCache.delete(n);const i=V.CACHE_KEYS.TEMPLATES(e,"global");this.templateElementsCache.delete(i),this.selectorCache.clear()}invalidateByPrefix(e){this.invalidateByComponent(e)}invalidateElement(e){this.elementComponentCache.delete(e),this.contextComponentCache.delete(e),this.parentComponentCache.delete(e),this.elementDepthCache.delete(e),this.elementChildrenCache.delete(e)}clearAllCaches(){this.componentElementsCache.clear(),this.scriptElementsCache.clear(),this.templateElementsCache.clear(),this.selectorCache.clear(),this.elementComponentCache=new WeakMap,this.parentComponentCache=new WeakMap,this.contextComponentCache=new WeakMap,this.elementDepthCache=new WeakMap,this.elementChildrenCache=new WeakMap}getCacheStats(){const e=this.cacheHits+this.cacheMisses;return{componentElements:this.componentElementsCache.getStats(),scriptElements:this.scriptElementsCache.getStats(),templateElements:this.templateElementsCache.getStats(),selectors:this.selectorCache.getStats(),global:{size:0,maxSize:-1,hitRate:e>0?this.cacheHits/e*100:0,hits:this.cacheHits,misses:this.cacheMisses}}}resetStats(){this.cacheHits=0,this.cacheMisses=0}}class Ms{subscriptions=new Map;elementSubscriptions=new WeakMap;keyIndex=new Map;cleanupQueue=new Set;cleanupScheduled=!1;addSubscription(e){this.subscriptions.set(e.id,e),e.element&&(this.elementSubscriptions.has(e.element)||this.elementSubscriptions.set(e.element,new Set),this.elementSubscriptions.get(e.element).add(e.id));for(const t of e.dependencies)this.keyIndex.has(t)||this.keyIndex.set(t,new Set),this.keyIndex.get(t).add(e.id)}removeSubscription(e){const t=this.subscriptions.get(e);if(t){if(this.subscriptions.delete(e),t.element){const n=this.elementSubscriptions.get(t.element);n&&(n.delete(e),n.size===0&&this.elementSubscriptions.delete(t.element))}for(const n of t.dependencies){const i=this.keyIndex.get(n);i&&(i.delete(e),i.size===0&&this.keyIndex.delete(n))}}}cleanupElement(e){const t=this.elementSubscriptions.get(e);t&&(t.forEach(n=>this.cleanupQueue.add(n)),this.scheduleCleanup())}scheduleCleanup(){this.cleanupScheduled||(this.cleanupScheduled=!0,queueMicrotask(()=>{this.processCleanupQueue(),this.cleanupScheduled=!1}))}processCleanupQueue(){for(const e of this.cleanupQueue)this.removeSubscription(e);this.cleanupQueue.clear()}getSubscription(e){return this.subscriptions.get(e)}getSubscriptionsForKey(e){return this.keyIndex.get(e)}getAllSubscriptions(){return new Map(this.subscriptions)}cleanupStaleSubscriptions(){const e=[];for(const[t,n]of this.subscriptions)n.element&&!document.contains(n.element)&&e.push(t);e.forEach(t=>this.removeSubscription(t))}getStats(){return{totalSubscriptions:this.subscriptions.size,elementSubscriptions:this.elementSubscriptions instanceof WeakMap?-1:0,keyIndexes:this.keyIndex.size}}}class Z{static instance;stateVariables=new Set;static FUNCTIONS_NEEDING_VALUE_TRANSFORM=new Set(["console.log","console.warn","console.error","console.info","console.debug","console.dir","console.table","console.trace","console.assert","JSON.stringify","JSON.parse","Object.keys","Object.values","Object.entries","Array.from","Array.isArray","Math.max","Math.min","Math.abs","Math.floor","Math.ceil","Math.round","alert","confirm","prompt","parseInt","parseFloat","Number","String","Boolean"]);transformRefDeclarations(e){try{const t=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return $(t,{VariableDeclarator:r=>{if(this.isRefDeclaration(r)){const a=r.id.name,o=this.findStatementEnd(e,r.end);i.push({start:o,end:o,replacement:`; this.${a} = ${a}`})}}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Ref transformation error:",t),e}}isRefDeclaration(e){return e.id?.type==="Identifier"&&e.init?.type==="CallExpression"&&e.init.callee?.type==="MemberExpression"&&e.init.callee.object?.type==="Identifier"&&e.init.callee.object.name==="pp"&&e.init.callee.property?.type==="Identifier"&&e.init.callee.property.name==="ref"}findStatementEnd(e,t){let n=t;for(;n<e.length&&e[n]!==";"&&e[n]!==`
|
|
10
|
+
`;)n++;return n}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}extractFunctionNames(e){const t=[];try{const n=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});$(n,{FunctionDeclaration:i=>{i.id?.type==="Identifier"&&t.push(i.id.name)},VariableDeclarator:i=>{i.id?.type==="Identifier"&&(i.init?.type==="ArrowFunctionExpression"||i.init?.type==="FunctionExpression")&&t.push(i.id.name)},AssignmentExpression:i=>{i.left?.type==="Identifier"&&(i.right?.type==="ArrowFunctionExpression"||i.right?.type==="FunctionExpression")&&t.push(i.left.name)}})}catch(n){console.error("AST function extraction error:",n)}return Array.from(new Set(t))}transformEffectDeclarations(e){try{const t=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return $(t,{CallExpression:r=>{const a=this.transformEffectCall(r,e);a&&i.push(a)}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Effect transformation error:",t),e}}transformEffectCall(e,t){if(!this.isPPEffectCall(e))return null;const n=e.arguments;if(n.length<2)return null;const i=n[1];if(i.type!=="ArrayExpression"||!i.elements.some(h=>h?h.type==="Identifier"||h.type==="MemberExpression":!1))return null;const a=i.elements.map(h=>h?h.type==="Identifier"?`"${h.name}"`:h.type==="MemberExpression"?`"${this.extractMemberExpression(h,t)}"`:t.slice(h.start,h.end):"null"),o=t.slice(n[0].start,n[0].end),c=n.slice(2).map(h=>t.slice(h.start,h.end)).join(", "),l=`[${a.join(", ")}]`,p=c?`pp.effect(${o}, ${l}, ${c})`:`pp.effect(${o}, ${l})`;return{start:e.start,end:e.end,replacement:p}}extractMemberExpression(e,t){if(e.type!=="MemberExpression")return e.type==="Identifier"?e.name:t.slice(e.start,e.end);const n=this.extractMemberExpression(e.object,t);if(e.computed){const i=t.slice(e.property.start,e.property.end);return`${n}[${i}]`}else{const i=e.property.name||t.slice(e.property.start,e.property.end);return`${n}.${i}`}}isPPEffectCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="effect"}transformStateDeclarations(e,t){this.stateVariables.clear(),t&&t.forEach(i=>this.stateVariables.add(i));let n=this.transformStateDeclarationsOnly(e);return n=this.transformEffectDeclarations(n),n=this.transformRefDeclarations(n),n=this.transformUnsupportedStateUsages(n),n}transformStateDeclarationsOnlyOriginal(e){try{const t=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return $(t,{VariableDeclarator:r=>{const a=this.transformStateDeclarator(r,e);a&&i.push(a)}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("AST transformation error:",t),e}}transformStateDeclarationsOnly(e){let t=this.transformStateDeclarationsOnlyOriginal(e);return t=this.transformDestructuringAssignments(t),t}transformUnsupportedStateUsages(e){try{const t=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(t);let n=this.transformShorthandProperties(e);const i=B(n,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),r=[];return $(i,{SpreadElement:a=>{const o=this.transformSpreadElement(a,n);o&&r.push(o)},UnaryExpression:a=>{const o=this.transformUnaryExpression(a,n);o&&r.push(o)},BinaryExpression:a=>{const o=this.transformBinaryExpression(a,n);o&&r.push(o)},LogicalExpression:a=>{const o=this.transformLogicalExpression(a,n);o&&r.push(o)},ConditionalExpression:a=>{const o=this.transformConditionalExpression(a,n);o&&r.push(o)},IfStatement:a=>{const o=this.transformIfStatement(a,n);o&&r.push(o)},WhileStatement:a=>{const o=this.transformWhileStatement(a,n);o&&r.push(o)},ForStatement:a=>{const o=this.transformForStatement(a,n);o&&r.push(o)},ReturnStatement:a=>{const o=this.transformReturnStatement(a,n);o&&r.push(o)},VariableDeclarator:a=>{const o=this.transformVariableDeclarator(a,n);o&&r.push(o)},AssignmentExpression:a=>{const o=this.transformAssignmentExpression(a,n);o&&r.push(o)},CallExpression:a=>{const o=this.transformGeneralCallExpression(a,n);o&&r.push(o)}}),_s(i,{Identifier:(a,o)=>{r.some(l=>a.start>=l.start&&a.end<=l.end)||this.stateVariables.has(a.name)&&(this.alreadyHasValue(a,n)||this.isPartOfStateDeclaration(a,o)||this.isPropertyName(a,o)||this.isMethodCallObject(a,o)||this.isPartOfPPCall(a,o)||this.isPartOfDestructuring(a,o)||r.push({start:a.start,end:a.end,replacement:`${a.name}.value`}))}}),r.sort((a,o)=>o.start-a.start).forEach(a=>{n=n.slice(0,a.start)+a.replacement+n.slice(a.end)}),n=this.transformMultipleCallArguments(n),n}catch(t){return console.error("State usage transformation error:",t),e}}transformShorthandProperties(e){try{const t=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return $(t,{Property:r=>{if(r.shorthand&&r.key?.type==="Identifier"&&this.stateVariables.has(r.key.name)){const a=r.key.name,o=`${a}: ${a}.value`;i.push({start:r.start,end:r.end,replacement:o})}}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Shorthand property transformation error:",t),e}}transformLogicalExpression(e,t){return e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t)?{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`}:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformConditionalExpression(e,t){return e.test?.type==="Identifier"&&this.stateVariables.has(e.test.name)&&!this.alreadyHasValue(e.test,t)?{start:e.test.start,end:e.test.end,replacement:`${e.test.name}.value`}:e.consequent?.type==="Identifier"&&this.stateVariables.has(e.consequent.name)&&!this.alreadyHasValue(e.consequent,t)?{start:e.consequent.start,end:e.consequent.end,replacement:`${e.consequent.name}.value`}:e.alternate?.type==="Identifier"&&this.stateVariables.has(e.alternate.name)&&!this.alreadyHasValue(e.alternate,t)?{start:e.alternate.start,end:e.alternate.end,replacement:`${e.alternate.name}.value`}:null}transformIfStatement(e,t){return this.transformExpressionNode(e.test,t)}transformWhileStatement(e,t){return this.transformExpressionNode(e.test,t)}transformForStatement(e,t){return e.test?this.transformExpressionNode(e.test,t):null}transformReturnStatement(e,t){return e.argument?this.transformExpressionNode(e.argument,t):null}transformVariableDeclarator(e,t){return this.isStateDeclaration(e)||e.id?.type==="ArrayPattern"||e.id?.type==="ObjectPattern"?null:e.init?.type==="Identifier"&&this.stateVariables.has(e.init.name)&&!this.alreadyHasValue(e.init,t)?{start:e.init.start,end:e.init.end,replacement:`${e.init.name}.value`}:null}transformAssignmentExpression(e,t){return e.left?.type==="ArrayPattern"||e.left?.type==="ObjectPattern"?null:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformGeneralCallExpression(e,t){const n=t.slice(e.callee.start,e.callee.end);if(e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&this.stateVariables.has(e.callee.object.name)||this.isPPCall(e))return null;if(!Z.isFunctionNeedingValueTransform(n)&&e.arguments.length>0){for(const r of e.arguments)if(r.type==="Identifier"&&this.stateVariables.has(r.name)&&!this.alreadyHasValue(r,t))return{start:r.start,end:r.end,replacement:`${r.name}.value`}}return null}static isFunctionNeedingValueTransform(e){if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(e))return!0;const t=e.lastIndexOf(".");if(t>-1){const n=e.slice(t+1);if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(n))return!0}return!1}transformExpressionNode(e,t){return e?.type==="Identifier"&&this.stateVariables.has(e.name)&&!this.alreadyHasValue(e,t)?{start:e.start,end:e.end,replacement:`${e.name}.value`}:null}isPPCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&(e.callee.property.name==="state"||e.callee.property.name==="effect")}isPartOfStateDeclaration(e,t){if(!t||!Array.isArray(t))return!1;for(const n of t)if(n.type==="VariableDeclarator"&&n.id?.type==="ArrayPattern"&&n.init?.type==="CallExpression"&&this.isPPStateCall(n.init))return!0;return!1}isPropertyName(e,t){if(!t||t.length===0)return!1;const n=t[t.length-1];return!!(n?.type==="Property"&&n.key===e||n?.type==="Property"&&n.shorthand&&n.value===e||n?.type==="MemberExpression"&&n.property===e&&!n.computed)}isMethodCallObject(e,t){if(!t||t.length===0)return!1;const n=t[t.length-1];if(n?.type==="MemberExpression"&&n.object===e&&t.length>=2){const i=t[t.length-2];if(i?.type==="CallExpression"&&i.callee===n)return!0}return!1}isPartOfPPCall(e,t){if(!t||!Array.isArray(t))return!1;for(const n of t)if(n.type==="CallExpression"&&n.callee?.type==="MemberExpression"&&n.callee.object?.type==="Identifier"&&n.callee.object.name==="pp"&&n.callee.property?.type==="Identifier"&&(n.callee.property.name==="state"||n.callee.property.name==="effect"))return!0;return!1}isPartOfDestructuring(e,t){if(!t||!Array.isArray(t))return!1;for(let n=0;n<t.length;n++){const i=t[n];if(i.type==="ArrayPattern"||i.type==="ObjectPattern"){if(n+1<t.length){const r=t[n+1];if(r?.type==="VariableDeclarator"&&r.id===i&&r.init===e)return!1}return!0}}return!1}collectStateVariables(e){$(e,{VariableDeclarator:t=>{if(this.isStateDeclaration(t)){const n=t.id.elements[0];n?.type==="Identifier"&&this.stateVariables.add(n.name)}}})}isStateDeclaration(e){return e.id?.type==="ArrayPattern"&&e.init?.type==="CallExpression"&&this.isPPStateCall(e.init)}transformSpreadElement(e,t){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)?this.alreadyHasValue(e.argument,t)?null:{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformUnaryExpression(e,t){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)&&["typeof","!","+","-","~","void","delete"].includes(e.operator)&&!this.alreadyHasValue(e.argument,t)?{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformBinaryExpression(e,t){if(["===","!==","==","!=",">","<",">=","<=","+","-","*","/","%","**","&","|","^","<<",">>",">>>","in","instanceof"].includes(e.operator)){if(e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t))return{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`};if(e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t))return{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}}return null}transformMultipleCallArguments(e){try{const t=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return $(t,{CallExpression:r=>{const a=n.slice(r.callee.start,r.callee.end);if(Z.isFunctionNeedingValueTransform(a)&&r.arguments.length>0)for(const c of r.arguments)c.type==="Identifier"&&this.stateVariables.has(c.name)&&(this.alreadyHasValue(c,n)||i.push({start:c.start,end:c.end,replacement:`${c.name}.value`}))}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Multiple call arguments transformation error:",t),e}}transformDestructuringAssignments(e){try{const t=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return $(t,{VariableDeclarator:r=>{this.isStateDeclaration(r)||(r.id?.type==="ArrayPattern"||r.id?.type==="ObjectPattern")&&r.init?.type==="Identifier"&&this.stateVariables.has(r.init.name)&&(this.alreadyHasValue(r.init,e)||i.push({start:r.init.start,end:r.init.end,replacement:`${r.init.name}.value`}))},AssignmentExpression:r=>{(r.left?.type==="ArrayPattern"||r.left?.type==="ObjectPattern")&&r.right?.type==="Identifier"&&this.stateVariables.has(r.right.name)&&(this.alreadyHasValue(r.right,e)||i.push({start:r.right.start,end:r.right.end,replacement:`${r.right.name}.value`}))}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Destructuring transformation error:",t),e}}alreadyHasValue(e,t){const n=e.end;return t.slice(n,n+6).startsWith(".value")}transformStateDeclarator(e,t){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression")return null;const n=e.init;if(!this.isPPStateCall(n))return null;const i=e.id.elements[0];if(!i||i.type!=="Identifier")return null;const r=i.name,a=`set${this.capitalize(r)}`,o=e.id.elements[1];return o?.type==="Identifier"&&o.name!==a&&console.warn(`Setter name mismatch: expected ${a}, got ${o.name}`),this.createTransformation(n,r,t)}isPPStateCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="state"}createTransformation(e,t,n){const i=e.arguments;if(i.length===0){const c=`pp.state("${t}")`;return{start:e.start,end:e.end,replacement:c}}const r=i[0];if(r.type==="Literal"&&typeof r.value=="string"&&r.value===t)return null;if(i.length===1){const c=n.slice(r.start,r.end),l=`pp.state("${t}", ${c})`;return{start:e.start,end:e.end,replacement:l}}const a=n.slice(e.arguments[0].start,e.arguments[e.arguments.length-1].end),o=`pp.state("${t}", ${a})`;return{start:e.start,end:e.end,replacement:o}}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")}extractStateDeclarations(e){const t=[];try{const n=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});$(n,{VariableDeclarator:i=>{const r=this.extractStateFromDeclarator(i,e);r&&t.push(r)}})}catch(n){console.error("State extraction error:",n)}return t}extractStateFromDeclarator(e,t){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression"||!this.isPPStateCall(e.init))return null;const n=e.id.elements[0],i=e.id.elements[1];if(n?.type!=="Identifier"||i?.type!=="Identifier")return null;const r=e.init.arguments;let a=n.name,o;return r.length>=1&&(r[0].type==="Literal"&&typeof r[0].value=="string"?this.looksLikeVariableName(r[0].value)?(a=r[0].value,r.length>=2&&(o=this.extractLiteralValue(r[1]))):(a=n.name,o=this.extractLiteralValue(r[0])):o=this.extractLiteralValue(r[0])),{variableName:n.name,setterName:i.name,stateKey:a,initialValue:o,line:e.loc?.start.line||0,column:e.loc?.start.column||0}}extractFunctionDeclarations(e){const t=[];try{const n=B(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});$(n,{FunctionDeclaration:i=>{i.id?.type==="Identifier"&&t.push({name:i.id.name,type:"function",params:i.params.map(r=>r.type==="Identifier"?r.name:""),line:i.loc?.start.line||0})},VariableDeclarator:i=>{if(i.id?.type==="Identifier"&&(i.init?.type==="ArrowFunctionExpression"||i.init?.type==="FunctionExpression")){const r=i.init;t.push({name:i.id.name,type:r.type==="ArrowFunctionExpression"?"arrow":"function",params:r.params.map(a=>a.type==="Identifier"?a.name:""),line:i.loc?.start.line||0})}}})}catch(n){console.error("Function extraction error:",n)}return t}extractLiteralValue(e){if(e.type==="Literal")return e.value;e.type==="Identifier"&&e.name}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}}class Je{constructor(e){this.evaluator=e}render(e,t,n){const i=N.isSingleExpression(e);if(i)return this.evaluator.evaluateExpression(i,t,n);let r="";for(const a of N.parse(e))if(a.type==="static")r+=a.content;else if(a.expression)try{const o=this.evaluator.evaluateExpression(a.expression,t,n);r+=ue(o)}catch{}return r}dependencies(e,t,n){const i=N.extractExpressions(e),r=new Set;for(const a of i)for(const o of this.evaluator.extractDependencies(a,t,n))r.add(o);return[...r]}}class Rs{static containsMustacheExpression(e){if(d.MUSTACHE_PATTERN.test(e))return!0;const n=N.decodeEntities(e);return d.MUSTACHE_PATTERN.test(n)}}class T{static FRAMEWORK_ATTRIBUTES=new Set(["pp-component","pp-context","pp-for","pp-spread","pp-ref","key"]);static domCache;static getDOMCache(){return this.domCache||(this.domCache=V.getInstance()),this.domCache}static isFrameworkAttribute(e){return T.FRAMEWORK_ATTRIBUTES.has(e)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static shouldBeDirectBinding(e,t){const n=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),i=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);return!n||!i||n===i?!1:T.isDOMProperty(e,t)}static isDOMProperty(e,t){const n=e.tagName.toLowerCase(),i=document.createElement(n);return T.attributeToPropertyName(t)in i}static attributeToPropertyName(e){const t={class:"className",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",tabindex:"tabIndex",contenteditable:"contentEditable",formnovalidate:"formNoValidate",novalidate:"noValidate",allowfullscreen:"allowFullscreen",itemscope:"itemScope"};return t[e]?t[e]:e.replace(/-([a-z])/g,(n,i)=>i.toUpperCase())}static isBooleanAttribute(e){return["checked","disabled","hidden","readonly","required","multiple","selected","autofocus","autoplay","controls","defer","loop","muted","open","reversed","async","default","formnovalidate","novalidate","allowfullscreen","capture","itemscope"].includes(e)}static getContextComponent(e){return this.getDOMCache().getContextComponent(e)}static getParentOfComponent(e,t){return this.getDOMCache().getParentOfComponent(e,t)}static findElementForComponent(e,t){return this.getDOMCache().findElementForComponent(e,t)}static getElementDepth(e){return this.getDOMCache().getElementDepthCached(e)}static getParentComponentForElement(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}static isTextNodeInsideScript(e){let t=e.parentElement;for(;t&&t!==document.body;){const n=t.tagName.toLowerCase();if(n==="script"||n==="style")return!0;t=t.parentElement}return!1}static getComponentForNode(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return t?this.getDOMCache().getElementComponent(t):"app"}static getElementComponent(e){return this.getDOMCache().getElementComponent(e)}}class de{static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}}class Ue{static findExistingStateKey(e,t,n){return[`${t}.${e}`,`app.${e}`,e].find(r=>r in n)||null}}class rt{pendingUpdates=new Map;batchTimeout=null;componentManager;domBindingManager;setManagers(e,t){this.componentManager=e,this.domBindingManager=t}scheduleUpdate(e,t){this.pendingUpdates.has(e)||this.pendingUpdates.set(e,new Set),this.pendingUpdates.get(e).add(t),this.batchTimeout===null&&(this.batchTimeout=requestAnimationFrame(()=>{this.processBatchedUpdates(),this.batchTimeout=null}))}processBatchedUpdates(){const e=new Map(this.pendingUpdates);this.pendingUpdates.clear(),this.batchTimeout=null;const t=this.sortUpdatesByDependency(e);for(const[n,i]of t)this.processComponentUpdate(n,i)}sortUpdatesByDependency(e){const t=new WeakMap,n=i=>{let r=t.get(i);return r==null&&(r=T.getElementDepth(i),t.set(i,r)),r};return Array.from(e.entries()).sort(([,i],[,r])=>{const a=Math.min(...Array.from(i,n)),o=Math.min(...Array.from(r,n));return a-o})}processComponentUpdate(e,t){if(!this.componentManager||!this.domBindingManager)return;this.componentManager.invalidateComponent(e);const n=[],i=[],r=[];for(const a of t){if(!document.contains(a))continue;const o=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null);let c;for(;c=o.nextNode();)n.push(c);const l=this.domBindingManager.loopManager;if(l){const p=l.getAllLoops();for(const[h,f]of p)f.component===e&&a.contains(h)&&i.push([h,f])}r.push(a)}this.updateTextNodesBatch(n,e),this.updateLoopsBatch(i),this.updateElementsBatch(r,e)}updateTextNodesBatch(e,t){const n=this.domBindingManager.textNodeManager;n&&e.forEach(i=>{document.contains(i)&&T.getComponentForNode(i)===t&&n.updateTextNode(i)})}updateLoopsBatch(e){const t=this.domBindingManager.loopManager;if(!t)return;const n=new Map;e.forEach(([r,a])=>{const o=T.getElementDepth(r);n.has(o)||n.set(o,[]),n.get(o).push([r,a])});const i=Array.from(n.keys()).sort((r,a)=>r-a);for(const r of i)n.get(r).forEach(([o,c])=>{document.contains(o)&&t.renderLoop(c,c.iterableExpr)})}updateElementsBatch(e,t){e.forEach(n=>{document.contains(n)&&this.domBindingManager.processElementBindings(n,!0)})}}class Wt{loopBindings=new Map;stateManager;expressionEvaluator;componentManager;domBindingManager;cleanupObserver;loopCounter=0;pendingTemplates=[];loopItemElements=new WeakSet;loopItemContexts=new WeakMap;templateRenderer;templateMoveObserver;constructor(e,t){this.stateManager=e,this.expressionEvaluator=t,this.cleanupObserver=new MutationObserver(n=>{this.cleanupDetachedTemplates(n)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateMoveObserver=new MutationObserver(n=>{this.handleTemplateMoves(n)}),this.templateMoveObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateRenderer=new Je(t)}handleTemplateMoves(e){const t=new Set;for(const n of e)n.type==="childList"&&n.addedNodes.forEach(i=>{if(i.nodeType!==Node.ELEMENT_NODE)return;const r=i;if(r.querySelectorAll("template[pp-for]").forEach(o=>{const c=o;this.loopBindings.has(c)&&t.add(c)}),r.tagName==="TEMPLATE"&&r.hasAttribute("pp-for")){const o=r;this.loopBindings.has(o)&&t.add(o)}});t.size>0&&setTimeout(()=>{t.forEach(n=>{document.contains(n)&&this.updateMovedTemplate(n)})},0)}updateMovedTemplate(e){const t=this.loopBindings.get(e);if(!t)return;const n=e.parentElement;if(!n||n===t.parentElement&&t.placeholder.parentElement===n&&t.placeholder.nextSibling===e)return;const i=[...t.renderedItems];t.placeholder.parentElement&&t.placeholder.parentElement!==n&&t.placeholder.parentElement.removeChild(t.placeholder);const r=document.createComment(`pp-for: ${t.expression}`);n.insertBefore(r,e),t.parentElement=n,t.placeholder=r,i.length>0&&(i.forEach(a=>{a.element.parentElement!==n&&n.insertBefore(a.element,e)}),this.updateDOMOrder(t,i)),setTimeout(()=>{document.contains(e)&&this.renderLoop(t,t.iterableExpr)},0)}getLoopContextForElement(e){if(!this.domBindingManager)return null;const t=this.domBindingManager.loopManager;if(!t)return null;let n=e.parentElement;for(;n;){if(t.isLoopItem&&t.isLoopItem(n))return t.getLoopItemContext(n);n=n.parentElement}const i=t.getAllLoops();for(const[r,a]of i)for(const o of a.renderedItems)if(o.element.contains(e))return o.context;return null}setDependencies(e,t){this.componentManager=e,this.domBindingManager=t}queueTemplate(e,t){this.loopBindings.has(e)||this.pendingTemplates.push({template:e,component:t})}processPendingTemplates(){const e=[...this.pendingTemplates];this.pendingTemplates=[];for(const{template:t,component:n}of e)document.contains(t)&&this.processTemplate(t,n)}processTemplate(e,t){const n=e.getAttribute("pp-for");if(!n||this.loopBindings.has(e))return;if(!e.parentElement){console.warn("⚠️ Template has no parent, queueing for later:",n),this.queueTemplate(e,t);return}const i=this.parseLoopExpression(n);if(!i){console.error(`Invalid pp-for syntax: "${n}"`);return}const r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let a=t;r&&(r==="app"?a="app":a=r);const o=e.parentElement,c=document.createComment(`pp-for: ${n}`);o.insertBefore(c,e);const l={template:e,expression:n,itemVar:i.itemVar,indexVar:i.indexVar,component:a,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:o,placeholder:c,iterableExpr:i.iterableExpr};this.loopBindings.set(e,l),this.setupLoopReactivity(l,i.iterableExpr),this.renderLoop(l,i.iterableExpr)}parseLoopExpression(e){const t=e.match(/^\s*([a-zA-Z_$][\w$]*)\s+in\s+(.+)$/);if(t)return{itemVar:t[1],iterableExpr:t[2].trim()};const n=e.match(/^\s*\(\s*([a-zA-Z_$][\w$]*)\s*,\s*([a-zA-Z_$][\w$]*)\s*\)\s+in\s+(.+)$/);return n?{itemVar:n[1],indexVar:n[2],iterableExpr:n[3].trim()}:null}setupLoopReactivity(e,t){const n=`loop_${Date.now()}_${++this.loopCounter}`,i=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager),r=this.findComponentElementForLoop(e);if(r&&this.componentManager){const o=this.componentManager.getComponentPropDependencies(r,e.component);i.push(...o)}const a={id:n,selector:"",dependencies:new Set(i),callback:()=>{this.renderLoop(e,e.iterableExpr)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(n)}renderLoop(e,t){if(!(!this.componentManager||!this.domBindingManager))try{const n=this.findComponentElementForLoop(e);let i;const r=this.findParentLoopContext(e.template);if(e.template.hasAttribute(d.ATTR_PREFIXES.CONTEXT)){const p=this.componentManager.buildComponentContext(e.component);if(n){const h=this.componentManager.evaluateProps(n);i={...p,...h}}else i=p;r&&(i={...i,...r})}else{if(i=this.componentManager.buildRestrictedComponentContext(e.component,!1),n&&this.componentManager.hasStoredProps(n)){const p=this.componentManager.evaluateProps(n);Object.assign(i,p)}r&&(i={...i,...r})}const c=this.expressionEvaluator.evaluateExpression(t,i,e.component),l=He(c);if(!Array.isArray(l)){console.warn(`Loop expression "${t}" did not return an array:`,l,`Available context keys: [${Object.keys(i).join(", ")}]`,"Parent loop context:",r),this.clearRenderedItems(e);return}this.updateRenderedItems(e,l)}catch(n){console.error(`Error evaluating loop expression "${t}":`,n),this.clearRenderedItems(e)}}findParentLoopContext(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const i=this.loopItemContexts.get(n);i&&t.unshift(i)}for(const[i,r]of this.loopBindings)if(r.template!==e){for(const a of r.renderedItems)if(a.element===n||a.element.contains(e)){t.unshift(a.context);break}}n=n.parentElement}return t.length>0?t.reduce((i,r)=>({...i,...r}),{}):null}findComponentElementForLoop(e){let t=e.parentElement;for(;t;){if(t.getAttribute(d.ATTR_PREFIXES.COMPONENT)===e.component)return t;t=t.parentElement}return document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e.component}"]`)[0]||void 0}updateRenderedItems(e,t){const n=e.renderedItems,i=[],r=new Set,a=new Map;n.forEach(o=>{a.set(o.key,o)}),t.forEach((o,c)=>{const l=this.generateItemKey(e,o,c),p=a.get(l);if(p&&!r.has(p.element))r.add(p.element),this.updateItemContext(e,p,o,c),i.push(p);else{const h=this.createLoopItem(e,o,c,l);h&&(i.push(h),this.processNestedLoopsInItem(h,e.component))}}),n.forEach(o=>{r.has(o.element)||this.cleanupLoopItem(o)}),this.updateDOMOrder(e,i),e.renderedItems=i}processNestedLoopsInItem(e,t){e.element.querySelectorAll("template[pp-for]").forEach(i=>{const r=i;this.loopBindings.has(r)||this.processNestedTemplate(r,t,e.context)})}generateItemKey(e,t,n){const r=e.template.content.firstElementChild;if(r&&r.hasAttribute("key")){const a=r.getAttribute("key");try{const o=this.createItemContextWithParentContext(e,t,n),c=N.isSingleExpression(a);if(c){const l=this.expressionEvaluator.evaluateExpression(c,o,e.component);return String(l)}else{const l=N.parse(a);let p="";for(const h of l)if(h.type==="static")p+=h.content;else if(h.expression){const f=this.expressionEvaluator.evaluateExpression(h.expression,o,e.component);p+=ue(f)}return p}}catch(o){console.warn(`Error evaluating key expression "${a}":`,o,"Available context keys:",Object.keys(this.createItemContextWithParentContext(e,t,n)))}}return t&&typeof t=="object"&&"id"in t?String(t.id):`${e.expression}_${n}`}createItemContextWithParentContext(e,t,n){if(!this.componentManager)return{};const i=this.componentManager.buildComponentContext(e.component),r=this.getAllParentLoopContexts(e.template),a=t&&typeof t=="object"?Object.keys(t):[],o={};for(const[l,p]of Object.entries(i))a.includes(l)&&!l.startsWith("set")&&!l.endsWith("Getter")||(o[l]=p);const c={...o,...r,[e.itemVar]:t};return e.indexVar&&(c[e.indexVar]=n),c}getAllParentLoopContexts(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const i=this.loopItemContexts.get(n);i&&t.unshift(i)}for(const[i,r]of this.loopBindings)if(i!==e){for(const a of r.renderedItems)if(a.element===n||a.element.contains(e)){t.unshift(a.context);break}}n=n.parentElement}return t.reduce((i,r)=>({...i,...r}),{})}createItemContext(e,t,n){if(!this.componentManager)return{};const r=e.template.hasAttribute(d.ATTR_PREFIXES.CONTEXT),a=this.findComponentElementForLoop(e),o=a&&this.componentManager.hasStoredProps(a);let c;r||o?c=this.componentManager.buildComponentContext(e.component):c=this.componentManager.buildRestrictedComponentContext(e.component,!1);const l={},p=t&&typeof t=="object"?Object.keys(t):[];for(const[E,m]of Object.entries(c)){if(typeof m=="function"&&!m.__pphp_key){l[E]=m;continue}if(E.startsWith("set")||E.endsWith("Getter")){l[E]=m;continue}if(["getContext","withContext","__getProp"].includes(E)){l[E]=m;continue}p.includes(E)||(l[E]=m)}const h=this.findAllParentLoopContexts(e.template),f={...l,...h,[e.itemVar]:t};return e.indexVar&&(f[e.indexVar]=n),f}findAllParentLoopContexts(e){const t={};let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const i=this.loopItemContexts.get(n);if(i)for(const[r,a]of Object.entries(i))r in t||(t[r]=a)}for(const[i,r]of this.loopBindings)if(i!==e){for(const a of r.renderedItems)if(a.element===n){for(const[o,c]of Object.entries(a.context))o in t||(t[o]=c);break}}n=n.parentElement}return t}createLoopItem(e,t,n,i){if(!this.domBindingManager)return null;try{const r=this.createItemContextWithParentContext(e,t,n),a=document.importNode(e.template.content,!0),o=document.createElement("div");o.appendChild(a);const c=o.firstElementChild;if(!c)return console.warn("Template content must contain exactly one root element"),null;o.removeChild(c),this.loopItemElements.add(c),this.loopItemContexts.set(c,r),c.getAttribute("key")&&c.removeAttribute("key");const p={key:i,element:c,context:r,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map,parentTemplate:e.template};return this.executeComponentScriptsInLoopItem(c),this.processRefsInLoopItem(c,r,e.component),this.processElementWithContext(c,r,e.component,p),this.cleanupRawMustacheAttributes(c),p}catch(r){return console.error("Error creating loop item:",r),null}}processRefsInLoopItem(e,t,n){if(e.hasAttribute("pp-ref")){const o=e.getAttribute("pp-ref");this.processRefAttribute(e,o,t,n)}const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>o.hasAttribute("pp-ref")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r;const a=[];for(;r=i.nextNode();)a.push(r);a.forEach(o=>{const c=o.getAttribute("pp-ref");this.processRefAttribute(o,c,t,n)})}processRefAttribute(e,t,n,i){try{const r=N.decodeEntities(t),a=N.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,n,i);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ Failed to process ref:",r)}}executeComponentScriptsInLoopItem(e){if(!this.componentManager)return;const t=[e],n=e.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`);t.push(...Array.from(n)),t.forEach(i=>{if(i.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){const r=i.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r){const a=this.getLoopItemContextForElement(i),o=this.generateInstanceId(a),c=`${r}_${o}`;i.setAttribute(d.ATTR_PREFIXES.COMPONENT,c),i.__originalComponentName=r,i.__uniqueComponentName=c,this.componentManager.pushComponent(c),window[c]||(window[c]={}),window[r]&&Object.assign(window[c],window[r]),this.getComponentScripts(i).forEach(p=>{this.componentManager.executeScript(p)}),this.componentManager.popComponent()}}})}getLoopItemContextForElement(e){let t=e;for(;t;){if(this.loopItemElements.has(t)){const n=this.loopItemContexts.get(t);if(n)return n}t=t.parentElement}for(const[n,i]of this.loopBindings)for(const r of i.renderedItems)if(r.element===e||r.element.contains(e))return r.context;return console.warn("⚠️ No loop item context found, using empty context"),{}}generateInstanceId(e){const t={};for(const[a,o]of Object.entries(e))typeof o=="function"||a.startsWith("set")||a.endsWith("Getter")||a==="getContext"||a==="withContext"||a==="__getProp"||o&&typeof o=="function"&&"__pphp_key"in o||typeof o=="boolean"||typeof o=="number"||typeof o=="string"||o&&typeof o=="object"&&!Array.isArray(o)&&"id"in o&&(t[a]=o);return Object.keys(t).length===0?`${Date.now()}_${Math.random().toString(36).substring(2,7)}`:Object.keys(t).sort().map(a=>{const o=t[a];return o&&typeof o=="object"&&"id"in o?`${a}_${o.id}`:`${a}_${JSON.stringify(o)}`}).join("_").replace(/[^a-zA-Z0-9_]/g,"").substring(0,20)||`fallback_${Date.now()}`}getComponentScripts(e){const t=[];return e.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`).forEach(i=>{const r=i;let a=r.parentElement,o=!1;for(;a&&a!==e.parentElement;){if(a===e){o=!0;break}if(a.hasAttribute(d.ATTR_PREFIXES.COMPONENT)&&a!==e)break;a=a.parentElement}o&&t.push(r)}),t}cleanupRawMustacheAttributes(e){this.cleanupElementMustacheAttributes(e);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n;for(;n=t.nextNode();)this.cleanupElementMustacheAttributes(n)}cleanupElementMustacheAttributes(e){const t=Array.from(e.attributes);for(const n of t)n.value&&d.MUSTACHE_PATTERN.test(n.value)&&(T.isBooleanAttribute(n.name),e.removeAttribute(n.name))}processElementWithContext(e,t,n,i){if(!this.domBindingManager||!this.componentManager)return;const r=(o,c)=>{const l=this.componentManager.buildComponentContext(c),p=o.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(p&&p!==c){const f=this.componentManager.buildComponentContext(p);return{...t,...l,...f}}return{...t,...l}},a=this.componentManager.buildComponentContextWithProps.bind(this.componentManager);this.componentManager.buildComponentContextWithProps=(o,c)=>c&&(c===e||e.contains(c))?r(c,o):a(o,c);try{if(e.hasAttribute("pp-ref")){const f=e.getAttribute("pp-ref");this.processRefInLoopContext(e,f,t,n),e.removeAttribute("pp-ref")}const o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:f=>f===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}),c=[];let l;for(;l=o.nextNode();){const f=l;if(f.hasAttribute("pp-ref")){const E=f.getAttribute("pp-ref");c.push({element:f,expression:E})}}c.forEach(({element:f,expression:E})=>{this.processRefInLoopContext(f,E,t,n)});const p=this.bindLoopItemElement(e,t,n,i);this.setupEventBindingsForLoopItem(e,n);for(let f=0;f<e.childNodes.length;f++){const E=e.childNodes[f];if(E.nodeType===Node.TEXT_NODE){const m=E;if(m.textContent&&d.MUSTACHE_PATTERN.test(m.textContent)&&!T.isTextNodeInsideScript(m)){const x=this.getComponentForTextNode(m);this.processTextNodeWithLoopContext(m,p,x,i)}}else if(E.nodeType===Node.ELEMENT_NODE){const m=E;if(m.tagName.toLowerCase()==="script")continue;const g=m.getAttribute(d.ATTR_PREFIXES.COMPONENT)||n,C=this.bindLoopItemElement(m,p,g,i);this.setupEventBindingsForLoopItem(m,g),this.processChildrenRecursively(m,C,g,i)}}e.querySelectorAll("template[pp-for]").forEach(f=>{(f.parentElement===e||e.contains(f))&&this.processNestedTemplate(f,n,p)})}finally{this.componentManager.buildComponentContextWithProps=a}}processChildrenRecursively(e,t,n,i){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{if(o===e)return NodeFilter.FILTER_SKIP;if(o.nodeType===Node.TEXT_NODE){const c=o;if(T.isTextNodeInsideScript(c))return NodeFilter.FILTER_REJECT;if(c.textContent&&d.MUSTACHE_PATTERN.test(c.textContent))return NodeFilter.FILTER_ACCEPT}else if(o.nodeType===Node.ELEMENT_NODE){const c=o;if(c.tagName.toLowerCase()==="script")return NodeFilter.FILTER_REJECT;const l=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);return l&&l!==n&&!i?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let a;for(;a=r.nextNode();)if(a.nodeType===Node.TEXT_NODE){const o=a,c=this.getComponentForTextNode(o);this.processTextNodeWithLoopContext(o,t,c,i)}else if(a.nodeType===Node.ELEMENT_NODE){const o=a,c=T.getElementComponent(o),l=this.bindLoopItemElement(o,t,c,i);this.setupEventBindingsForLoopItem(o,c),this.processChildrenRecursively(o,l,c,i)}}processChildElementsWithContext(e,t,n,i){const r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:l=>{if(l===e)return NodeFilter.FILTER_SKIP;if(l.nodeType===Node.TEXT_NODE){const p=l;if(T.isTextNodeInsideScript(p))return NodeFilter.FILTER_REJECT;if(p.textContent&&d.MUSTACHE_PATTERN.test(p.textContent))return NodeFilter.FILTER_ACCEPT}else if(l.nodeType===Node.ELEMENT_NODE){const p=l;if(p.tagName.toLowerCase()==="script")return NodeFilter.FILTER_REJECT;const h=p.getAttribute(d.ATTR_PREFIXES.COMPONENT);return h&&h!==n?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let a;const o=[],c=[];for(;a=r.nextNode();)a.nodeType===Node.ELEMENT_NODE?o.push(a):a.nodeType===Node.TEXT_NODE&&c.push(a);c.forEach(l=>{const p=this.getComponentForTextNode(l);this.processTextNodeWithLoopContext(l,t,p,i)}),o.forEach(l=>{const p=T.getElementComponent(l),h=this.bindLoopItemElement(l,t,p,i);this.setupEventBindingsForLoopItem(l,p),this.processChildElementsWithContext(l,h,p,i)})}processRefInLoopContext(e,t,n,i){try{const r=N.decodeEntities(t),a=N.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,n,i);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ processRefInLoopContext error:",r)}}getComponentForTextNode(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}processNestedTemplate(e,t,n){const i=e.getAttribute("pp-for");if(!i||this.loopBindings.has(e))return;const r=this.parseLoopExpression(i);if(!r){console.error(`Invalid pp-for syntax: "${i}"`);return}const a=e.parentElement,o=document.createComment(`pp-for: ${i}`);a.insertBefore(o,e);const c=this.findComponentElementForTemplate(e);let l={...n};const p=this.findParentLoopContextForNestedTemplate(e);if(p&&(l={...l,...p}),c&&this.componentManager){const f=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(f){const E=T.getParentComponentForElement(c);this.componentManager.hasStoredProps(c)||this.componentManager.setupProps(c,E);const m=this.evaluateComponentPropsWithContext(c,l);l={...this.componentManager.buildComponentContext(f),...m,...l}}}const h={template:e,expression:i,itemVar:r.itemVar,indexVar:r.indexVar,iterableExpr:r.iterableExpr,component:t,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:a,placeholder:o};this.loopBindings.set(e,h),this.setupNestedLoopReactivity(h,r.iterableExpr,l),this.renderNestedLoop(h,r.iterableExpr,l)}findParentLoopContextForNestedTemplate(e){let t=e.parentElement;const n={};let i=0;for(;t&&t!==document.body&&i<10;){if(i++,this.loopItemElements.has(t)){const r=this.loopItemContexts.get(t);if(r)for(const[a,o]of Object.entries(r))a in n||(n[a]=o)}for(const[r,a]of this.loopBindings)for(const o of a.renderedItems)(o.element.contains(e)||o.element===t)&&(a.itemVar in n||(n[a.itemVar]=o.context[a.itemVar]),a.indexVar&&!(a.indexVar in n)&&(n[a.indexVar]=o.context[a.indexVar]));t=t.parentElement}return Object.keys(n).length>0?n:null}evaluateComponentPropsWithContext(e,t){const n={};if(!this.componentManager||!this.expressionEvaluator)return n;const i=this.componentManager.extractProps(e,"app");for(const[r,a]of i)try{const o=this.templateRenderer.render(a.expression,t,a.component);n[r]=o}catch(o){console.error(`Failed to evaluate prop "${r}":`,o),n[r]=void 0}return n}findComponentElementForTemplate(e){let t=e.parentElement;for(;t;){if(t.hasAttribute(d.ATTR_PREFIXES.COMPONENT))return t;t=t.parentElement}return null}setupNestedLoopReactivity(e,t,n){const i=`nested_loop_${Date.now()}_${++this.loopCounter}`;let r=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager);const a={id:i,selector:"",dependencies:new Set(r),callback:()=>{const o=e.template,c=this.findComponentElementForTemplate(o);let l=n;if(o.parentElement){const h=this.getParentLoopContextForElement(o);h&&(l={...l,...h})}if(c&&this.componentManager){const h=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(h){const f=this.extractParentLoopContextFromBinding(e,n),E=this.evaluateComponentPropsWithContext(c,f),m=this.componentManager.buildComponentContext(h);l={...f,...m,...E}}}this.renderNestedLoop(e,t,l)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(i)}getParentLoopContextForElement(e){let t=e.parentElement;for(;t;){if(this.loopItemElements.has(t)){const n=this.loopItemContexts.get(t);if(n)return n}t=t.parentElement}return null}extractParentLoopContextFromBinding(e,t){const n=new Set;for(const[r,a]of this.loopBindings)if(a!==e){for(const o of a.renderedItems)if(o.element.contains(e.template)){n.add(a.itemVar),a.indexVar&&n.add(a.indexVar);break}}const i={};for(const[r,a]of Object.entries(t))(n.has(r)||r.startsWith("users")||r.startsWith("set")||r.includes("Getter")||typeof a=="function")&&(i[r]=a);return i}renderNestedLoop(e,t,n){if(!(!this.componentManager||!this.domBindingManager))try{const r=e.template.hasAttribute(d.ATTR_PREFIXES.CONTEXT),a=this.findComponentElementForLoop(e),o=a&&this.componentManager.hasStoredProps(a);let c;if(r||o)c=n;else{const h=this.componentManager.buildRestrictedComponentContext(e.component,!1),f=this.extractLoopVariablesOnly(n);c={...h,...f}}const l=this.expressionEvaluator.evaluateExpression(t,c,e.component),p=He(l);if(!Array.isArray(p)){console.warn(`Nested loop expression "${t}" did not return an array:`,p,`Available context keys: [${Object.keys(c).join(", ")}]`),this.clearRenderedItems(e);return}this.updateNestedRenderedItems(e,p,c)}catch(i){console.error(`Error evaluating nested loop expression "${t}":`,i,`Available context keys: [${Object.keys(n).join(", ")}]`),this.clearRenderedItems(e)}}extractLoopVariablesOnly(e){const t={};for(const[n,i]of Object.entries(e))typeof i=="function"&&!("__pphp_key"in i)||n.startsWith("set")&&typeof i=="function"||n.endsWith("Getter")||["getContext","withContext","__getProp"].includes(n)||(t[n]=i);return t}updateNestedRenderedItems(e,t,n){const i=e.renderedItems,r=[],a=new Set,o=new Map;i.forEach(c=>{o.set(c.key,c)}),t.forEach((c,l)=>{const p=this.generateNestedItemKey(e,c,l,n),h=o.get(p);if(h&&!a.has(h.element))a.add(h.element),this.updateNestedItemContext(e,h,c,l,n),r.push(h);else{const f=this.createNestedLoopItem(e,c,l,p,n);f&&r.push(f)}}),i.forEach(c=>{a.has(c.element)||this.cleanupLoopItem(c)}),this.updateDOMOrder(e,r),e.renderedItems=r}generateNestedItemKey(e,t,n,i){return t&&typeof t=="object"&&"id"in t?String(t.id):`${e.expression}_${n}_${JSON.stringify(i[e.itemVar]||{})}`}createNestedLoopItem(e,t,n,i,r){if(!this.domBindingManager)return null;try{const a={...r,[e.itemVar]:t};e.indexVar&&(a[e.indexVar]=n);const o=document.importNode(e.template.content,!0),c=document.createElement("div");c.appendChild(o);const l=c.firstElementChild;if(!l)return console.warn("Template content must contain exactly one root element"),null;c.removeChild(l),this.loopItemElements.add(l),this.loopItemContexts.set(l,a),l.getAttribute("key")&&l.removeAttribute("key");const h={key:i,element:l,context:a,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.processElementWithContext(l,a,e.component,h),this.cleanupRawMustacheAttributes(l),h}catch(a){return console.error("Error creating nested loop item:",a),null}}updateNestedItemContext(e,t,n,i,r){const a={...r};a[e.itemVar]=n,e.indexVar&&(a[e.indexVar]=i);const o=this.gatherAllComponentContextsInLoopItem(t.element),c={...a,...o};if(t.context=c,this.loopItemContexts.set(t.element,c),t.textNodeTemplates)for(const[l,p]of t.textNodeTemplates)document.contains(l)&&this.updateTextNodeWithContext(l,p,c,this.getTextNodeComponent(l));if(t.attributeTemplates)for(const[l,p]of t.attributeTemplates)document.contains(l)&&p.forEach((h,f)=>{try{const E=T.getElementComponent(l),m=this.buildElementSpecificContext(l,c),x=this.templateRenderer.render(h,m,E);this.domBindingManager?.updateElementProperty(l,f,x)}catch(E){console.error(`Nested binding update error for "${h}":`,E)}})}bindLoopItemElement(e,t,n,i){const r=this.extractMustacheBindings(e),a=this.findOriginalComponentName(n),o=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let c=a;o?o==="app"?c="app":c=o:c=this.findLoopParentComponent(e,a);let l=this.componentManager.buildComponentContext(c);l={...l,...t};const h=!!e.getAttribute(d.ATTR_PREFIXES.COMPONENT),f=new Map,E=new Map;r.forEach((C,w)=>{h&&w!=="class"&&w!=="style"?f.set(w,C):E.set(w,C)});const m={},x=this.sortPropsByDependency(f);for(const[C,w]of x)try{const I=this.templateRenderer.render(w,l,c);m[C]=I,l[C]=I}catch(I){console.error(`❌ Failed to evaluate prop "${C}":`,I),m[C]=void 0,l[C]=void 0}h&&Object.keys(m).length>0&&(window[n]||(window[n]={}),Object.assign(window[n],m));const g=l;return i&&Object.keys(m).length>0&&Object.assign(i.context,m),i&&r.size>0&&(i.attributeTemplates||(i.attributeTemplates=new Map),i.attributeTemplates.set(e,new Map(r))),r.forEach((C,w)=>{this.createLoopItemBinding(e,w,C,g,c,i)}),g}sortPropsByDependency(e){const t=Array.from(e.keys()),n=Array.from(e.entries()),i=[],r=[];for(const[a,o]of n)t.some(l=>l!==a&&o.includes(l))?r.push([a,o]):i.push([a,o]);return[...i,...r]}setupEventBindingsForLoopItem(e,t){const n=this.domBindingManager.eventDelegation;if(!n){console.warn("No event delegation manager available");return}const i=Array.from(e.attributes);for(const r of i)if(de.isEventAttribute(r.name)){const a=r.name.substring(2);n.registerEventHandler(e,a,r.value,t),e.removeAttribute(r.name)}}processTextNodeWithLoopContext(e,t,n,i){if(T.isTextNodeInsideScript(e))return;const r=e.textContent||"";if(!N.parse(r).some(x=>x.type==="expression"))return;i&&(i.textNodeTemplates||(i.textNodeTemplates=new Map),i.textNodeTemplates.set(e,r));const c=this.findActualComponentForTextNode(e);let l=t;c!==n&&i&&this.componentManager&&(l={...this.componentManager.buildComponentContext(c),...i.context}),this.updateTextNodeWithContext(e,r,l,c);const p=`loop_text_${Date.now()}_${Math.random()}`,h=this.templateRenderer.dependencies(r,c,this.stateManager),f=new Set(h),m={id:p,selector:"",dependencies:f,callback:()=>{if(!document.contains(e)){this.stateManager.removeSubscription(p);return}let x={};if(this.componentManager&&(c!==n&&i?x={...this.componentManager.buildComponentContext(c),...i.context}:x=this.componentManager.buildComponentContext(c)),i){const g={};let C=null;for(const[w,I]of this.loopBindings)if(I.renderedItems.includes(i)){C=I;break}if(C){g[C.itemVar]=i.context[C.itemVar],C.indexVar&&(g[C.indexVar]=i.context[C.indexVar]);const w=this.findParentLoopContext(C.template);w&&Object.assign(g,w)}x={...x,...g}}this.updateTextNodeWithContext(e,r,x,c)},component:c};this.stateManager.addSubscription(m),i&&i.subscriptionIds.push(p)}findActualComponentForTextNode(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n){const i=t.__uniqueComponentName;return i||n}t=t.parentElement}return"app"}updateTextNodeWithContext(e,t,n,i){const r=N.parse(t),a={};for(const[c,l]of Object.entries(n))typeof l=="function"&&"__pphp_key"in l?a[c]=l.value:a[c]=l;let o="";for(const c of r)if(c.type==="static")o+=c.content;else if(c.expression)try{const l=this.expressionEvaluator.evaluateExpression(c.expression,a,i);o+=ue(l)}catch(l){console.warn(`Loop text evaluation error for "${c.expression}":`,l,"Available context keys:",Object.keys(a)),o+=""}e.textContent!==o&&(e.textContent=o)}extractMustacheBindings(e){const t=new Map,n=e.attributes;for(let i=0;i<n.length;i++){const r=n[i];if(!(r.name===d.ATTR_PREFIXES.COMPONENT||r.name==="key"||r.name.startsWith("on"))&&r.value){const a=d.MUSTACHE_PATTERN.test(r.value),o=N.decodeEntities(r.value),c=d.MUSTACHE_PATTERN.test(o);(a||c)&&t.set(r.name,o)}}return t}createLoopItemBinding(e,t,n,i,r,a){const o=`loop_item_${Date.now()}_${Math.random()}`,c=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let l;c?c==="app"?l="app":l=c:l=this.findLoopParentComponent(e,r);const p=this.templateRenderer.dependencies(n,l,this.stateManager);let h=null;const f=[];if(a?.parentTemplate&&(h=this.findParentComponentWithPropsFromTemplate(a.parentTemplate),h&&this.componentManager)){const K=h.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(K){const j=this.componentManager.getComponentPropDependencies(h,K);f.push(...j);const O=this.componentManager.elementProps.get(h);if(O){const Q=Array.from(O.keys());for(const W of Q)if(n.includes(W)){const te=O.get(W);if(te){const he=this.templateRenderer.dependencies(te.expression,te.component,this.stateManager);f.push(...he)}}}}}const E=new Set([...p,...f,"*"]);let m=!1,x=0;const g=5,C=()=>{if(m)return;if(!document.contains(e)){if(x++,x<g){const j=10*Math.pow(2,x-1);setTimeout(()=>{m||C()},j)}else m=!0,this.stateManager.removeSubscription(o);return}x=0;try{const j=this.componentManager.buildComponentContext(l);let O;if(a){O={...j};let W=null;for(const[te,he]of this.loopBindings)if(he.renderedItems.includes(a)){W=he;break}W&&(O[W.itemVar]=a.context[W.itemVar],W.indexVar&&(O[W.indexVar]=a.context[W.indexVar]));for(const[te,he]of Object.entries(a.context))te in O||(O[te]=he);if(h&&this.componentManager){const te=this.componentManager.evaluateProps(h);Object.assign(O,te)}}else O=i;const Q=this.templateRenderer.render(n,O,l);this.domBindingManager?.updateElementProperty(e,t,Q)}catch(j){console.error(`❌ Loop item binding evaluation error for "${n}":`,j),console.error("Available context keys:",Object.keys(i))}},w={id:o,selector:"",dependencies:E,callback:()=>{m||C()},element:e,component:l};if(this.stateManager.addSubscription(w),a){a.subscriptionIds.push(o);const K=this.cleanupLoopItem.bind(this);this.cleanupLoopItem=j=>{j===a&&(m=!0),K(j)}}(()=>{document.contains(e)?C():Promise.resolve().then(()=>{if(!m&&document.contains(e))C();else if(!m&&x<g){x++;const K=10*Math.pow(2,x-1);setTimeout(()=>{m||C()},K)}else!m&&x>=g&&(m=!0,this.stateManager.removeSubscription(o))})})()}findParentComponentWithPropsFromTemplate(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.getAttribute(d.ATTR_PREFIXES.COMPONENT)&&this.componentManager?.hasStoredProps(t))return t;t=t.parentElement}return null}findLoopParentComponent(e,t){for(const[n,i]of this.loopBindings)for(const r of i.renderedItems)if(r.element===e||r.element.contains(e))return i.component;return this.findOriginalComponentName(t)}findOriginalComponentName(e){return e.includes("_")&&/\d{13}/.test(e)?e.split("_")[0]:e}updateItemContext(e,t,n,i){const r=this.createItemContext(e,n,i),a=this.gatherAllComponentContextsInLoopItem(t.element),o={...r,...a};if(t.context=o,this.loopItemContexts.set(t.element,o),t.textNodeTemplates)for(const[c,l]of t.textNodeTemplates)document.contains(c)&&this.updateTextNodeWithContext(c,l,o,this.getTextNodeComponent(c));if(t.attributeTemplates)for(const[c,l]of t.attributeTemplates)document.contains(c)&&l.forEach((p,h)=>{try{const f=T.getElementComponent(c),E=this.buildElementSpecificContext(c,o),m=this.templateRenderer.render(p,E,f);this.domBindingManager?.updateElementProperty(c,h,m)}catch(f){console.error(`Attribute binding update error for "${p}":`,f)}})}gatherAllComponentContextsInLoopItem(e){if(!this.componentManager)return{};const t={};if(e.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){const i=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),r=this.componentManager.buildComponentContext(i);Object.assign(t,r)}return e.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`).forEach(i=>{const r=i.getAttribute(d.ATTR_PREFIXES.COMPONENT),a=this.componentManager?.buildComponentContext(r);Object.assign(t,a)}),t}buildElementSpecificContext(e,t){if(!this.componentManager)return t;const n=T.getElementComponent(e),i=this.componentManager.buildComponentContext(n);return{...t,...i}}getTextNodeComponent(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}updateDOMOrder(e,t){let n=e.placeholder;t.forEach(i=>{(i.element.parentElement!==e.parentElement||i.element!==n.nextSibling)&&e.parentElement.insertBefore(i.element,n.nextSibling),n=i.element})}clearRenderedItems(e){e.renderedItems.forEach(t=>{this.cleanupLoopItem(t)}),e.renderedItems=[]}cleanupLoopItem(e){this.loopItemElements.delete(e.element),this.loopItemContexts.delete(e.element),e.element.parentElement&&e.element.parentElement.removeChild(e.element),e.subscriptionIds.forEach(t=>{this.stateManager.removeSubscription(t)})}isLoopItem(e){return this.loopItemElements.has(e)}getLoopItemContext(e){return this.loopItemContexts.get(e)}cleanupDetachedTemplates(e){for(const t of e)t.type==="childList"&&t.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const i=n;if(document.contains(i))return;if(i.tagName==="TEMPLATE"&&i.hasAttribute("pp-for")){const a=i;document.contains(a)||this.cleanupTemplate(a)}i.querySelectorAll("template[pp-for]").forEach(a=>{const o=a;document.contains(o)||this.cleanupTemplate(o)})}})}cleanupTemplate(e){const t=this.loopBindings.get(e);t&&(this.clearRenderedItems(t),t.subscriptionIds.forEach(n=>{this.stateManager.removeSubscription(n)}),t.placeholder.parentElement&&t.placeholder.parentElement.removeChild(t.placeholder),this.loopBindings.delete(e))}getAllLoops(){return new Map(this.loopBindings)}destroy(){this.cleanupObserver.disconnect(),this.templateMoveObserver.disconnect(),Array.from(this.loopBindings.keys()).forEach(e=>{this.cleanupTemplate(e)}),this.loopItemContexts=new WeakMap}}class q{cache=new Map;maxSize;hits=0;misses=0;constructor(e){this.maxSize=e}keys(){return Array.from(this.cache.keys())}deleteByPrefix(e){let t=0;const n=[];return this.cache.forEach((i,r)=>{typeof r=="string"&&r.startsWith(e)&&n.push(r)}),n.forEach(i=>{this.cache.delete(i)&&t++}),t}getKeysByPrefix(e){const t=[];return this.cache.forEach((n,i)=>{typeof i=="string"&&i.startsWith(e)&&t.push(i)}),t}get(e){const t=this.cache.get(e);if(t!==void 0)return this.hits++,this.cache.delete(e),this.cache.set(e,t),t;this.misses++}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){const n=this.cache.keys().next().value;n!==void 0&&this.cache.delete(n)}this.cache.set(e,t)}size(){return this.cache.size}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.hits=0,this.misses=0}getStats(){const e=this.hits+this.misses;return{size:this.cache.size,maxSize:this.maxSize,hitRate:e>0?this.hits/e*100:0,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}}class N{static EXPRESSION_CACHE=new q(1e3);static parseSpreadDirective(e){const t=e.replace(/^\s*\{\s*|\s*\}\s*$/g,""),n=this.parseSpreadParts(t),i=[],r=[];for(const a of n){const o=a.trim();if(o.startsWith("..."))i.push(o.substring(3).trim());else if(o.startsWith("{")&&o.endsWith("}")){const c=o.slice(1,-1).trim();if(c){const l=this.parseObjectProperties(c);r.push(l)}}else console.warn(`Invalid spread directive part: "${o}". Expected ...spread or {object}`)}return{spreads:i,objects:r}}static parseSpreadParts(e){const t=[];let n="",i=0,r=!1,a="",o=0;for(;o<e.length;){const c=e[o],l=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r){if(c==="{")i++;else if(c==="}")i--;else if(c===","&&i===0){t.push(n.trim()),n="",o++;continue}}n+=c,o++}return n.trim()&&t.push(n.trim()),t}static parseObjectProperties(e){const t=[],n=this.parseObjectParts(e);for(const i of n){const r=i.trim(),a=this.findPropertySeparator(r);if(a!==-1){const o=r.substring(0,a).trim().replace(/['"]/g,""),c=r.substring(a+1).trim();t.push({key:o,value:c})}else console.warn(`Invalid object property: "${r}". Expected key: value format.`)}return t}static parseObjectParts(e){const t=[];let n="",i=0,r=!1,a="";for(let o=0;o<e.length;o++){const c=e[o],l=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r){if(c==="{"||c==="["||c==="(")i++;else if(c==="}"||c==="]"||c===")")i--;else if(c===","&&i===0){t.push(n.trim()),n="";continue}}n+=c}return n.trim()&&t.push(n.trim()),t}static findPropertySeparator(e){let t=0,n=!1,i="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!n&&(a==='"'||a==="'")?(n=!0,i=a):n&&a===i&&o!=="\\"&&(n=!1,i=""),!n){if(a==="{"||a==="["||a==="(")t++;else if(a==="}"||a==="]"||a===")")t--;else if(a===":"&&t===0)return r}}return-1}static decodeEntities=e=>{const t=document.createElement("textarea");t.innerHTML=e;let n=t.value;for(;n.includes("&");){t.innerHTML=n;const i=t.value;if(i===n)break;n=i}return n};static parse(e){const t=N.decodeEntities(e);if(N.EXPRESSION_CACHE.has(t))return N.EXPRESSION_CACHE.get(t);const n=N.parseContentWithNesting(t);return N.EXPRESSION_CACHE.set(t,n),n}static parseContentWithNesting(e){const t=[],n=e.length;let i=0,r=0;for(;i<n;)if(e[i]==="{"){i>r&&t.push({type:"static",content:e.substring(r,i),expression:null});const o=this.extractNestedExpression(e,i);o.endIndex!==-1?(t.push({type:"expression",content:e.substring(i,o.endIndex+1),expression:o.expression.trim()}),i=o.endIndex+1,r=i):i++}else i++;return r<n&&t.push({type:"static",content:e.substring(r),expression:null}),t}static extractNestedExpression(e,t){let n=1,i=t+1,r=!1,a="",o=!1;for(;i<e.length&&n>0;){const c=e[i],l=i>0?e[i-1]:"";!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r&&c==="`"&&l!=="\\"&&(o=!o),!r&&!o&&(c==="{"?n++:c==="}"&&n--),i++}if(n===0){const c=e.slice(t+1,i-1);if(c.trim()){const l=this.checkForMismatchedQuotes(c);l.hasIssue&&(console.error(`
|
|
11
11
|
❌ Malformed expression detected during parsing:`),console.error(` Expression: ${c}`),console.error(` Issue: ${l.message}`),console.error(` Full content: ${e}`),console.error(` 💡 Hint: Check your quotes - strings must be properly quoted
|
|
12
12
|
`))}return{endIndex:i-1,expression:c}}return console.warn(`
|
|
13
13
|
⚠️ Failed to extract mustache expression - unclosed braces`),console.warn(` Content: ${e}`),console.warn(` Starting at position: ${t}
|
|
14
14
|
`),{endIndex:-1,expression:""}}static checkForMismatchedQuotes(e){let t=0,n=0,i=!1;for(let r=0;r<e.length;r++){if(i){i=!1;continue}if(e[r]==="\\"){i=!0;continue}e[r]==="'"&&t++,e[r]==='"'&&n++}return t%2!==0?{hasIssue:!0,message:`Unmatched single quotes (found ${t})`}:n%2!==0?{hasIssue:!0,message:`Unmatched double quotes (found ${n})`}:{hasIssue:!1,message:""}}static isSingleExpression(e){const t=N.decodeEntities(e),n=N.parseContentWithNesting(t);return n.length===1&&n[0].type==="expression"?n[0].expression:null}static extractExpressions(e){const t=N.decodeEntities(e),n=N.parseContentWithNesting(t),i=n.filter(r=>r.type==="expression").map(r=>r.expression).filter(r=>r);return n.some(r=>r.type==="expression")&&i.length===0&&(console.error(`
|
|
15
15
|
❌ Failed to extract expressions from content:`),console.error(` Content: ${e}`),console.error(` Parsed ${n.length} parts, but extracted 0 expressions`),console.error(` This usually means malformed mustache syntax
|
|
16
|
-
`)),i}}class Rs{textNodeBindings=new Map;expressionEvaluator;stateManager;componentManager;cleanupObserver;bindingCount=0;constructor(e,t){this.expressionEvaluator=e,this.stateManager=t,this.cleanupObserver=new MutationObserver(n=>{this.cleanupDetachedNodes(n)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}cleanupDetachedNodes(e){const t=[];for(const n of e)n.type==="childList"&&n.removedNodes.forEach(i=>{if(i.nodeType===Node.TEXT_NODE)t.push(i);else if(i.nodeType===Node.ELEMENT_NODE){const r=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,null);let a;for(;a=r.nextNode();)t.push(a)}});Promise.resolve().then(()=>{t.forEach(n=>{document.contains(n)||this.cleanupTextNode(n)})})}processTextNode(e,t){if(this.textNodeBindings.has(e)||S.isTextNodeInsideScript(e)||this.isInsideLoopItem(e))return;const n=e.parentElement,i=n?S.getContextComponent(n):t,r=e.textContent||"",a=N.parse(r);if(!a.some(p=>p.type==="expression"))return;const c=this.resolveComponentRootForElement(e,i),l={originalContent:r,expressions:a,subscriptionIds:[],component:i,componentElement:c};a.filter(p=>p.type==="expression").forEach(p=>{if(!p.expression)return;const h=`text_${Date.now()}_${Math.random()}`,f=this.expressionEvaluator.extractDependencies(p.expression,i,this.stateManager);if(c&&this.componentManager){const b=this.componentManager.getComponentPropDependencies(c,i);f.push(...b)}const x={id:h,selector:"",dependencies:new Set(f),callback:()=>{this.updateTextNode(e)},element:e.parentElement??void 0,component:i};this.stateManager.addSubscription(x),l.subscriptionIds.push(h)}),this.textNodeBindings.set(e,l),this.bindingCount++,this.updateTextNode(e)}isInsideLoopItem(e){let t=e.parentElement;for(;t&&t!==document.body;){const n=t.previousSibling;if(n&&n.nodeType===Node.COMMENT_NODE&&n.textContent?.startsWith("pp-for:"))return!0;let i=t.parentElement?.firstChild||null;for(;i;){if(i.nodeType===Node.COMMENT_NODE&&i.textContent?.startsWith("pp-for:")&&i!==t)return!0;i=i.nextSibling}t=t.parentElement}return!1}updateTextNode(e){const t=this.textNodeBindings.get(e);if(!t||!e.parentElement)return;const n=t.component;let i=t.componentElement;(!i||!document.contains(i))&&(i=this.resolveComponentRootForElement(e,n),t.componentElement=i);const r=this.hasInheritedContext(e,n);let a;if(r)i?a=this.getFreshComponentContext(n,i):a=this.getContextForComponent(n,i);else if(this.componentManager){if(a=this.componentManager.buildRestrictedComponentContext(n,!1),i&&this.componentManager.hasStoredProps(i)){const f=this.componentManager.evaluateProps(i);Object.assign(a,f)}const l=t.expressions.filter(f=>f.type==="expression").map(f=>f.expression).filter(f=>f),h=this.extractVariableNames(l).filter(f=>!(f in a));if(h.length>0){const f=this.findVariablesInParentComponents(e,n,h);Object.keys(f).length>0?Object.assign(a,f):console.warn("⚠️ [TextNode Update] Could not find missing variables in parent components")}}else a={};const o={};for(const[l,p]of Object.entries(a))typeof p=="function"&&"__pphp_key"in p?o[l]=p.value:o[l]=p;let c="";for(const l of t.expressions)if(l.type==="static")c+=l.content;else if(l.expression)try{const p=this.expressionEvaluator.evaluateExpression(l.expression,o,n);c+=ue(p)}catch(p){const h=typeof p=="object"&&p!==null&&"message"in p?p.message:String(p);console.error(`❌ Text binding evaluation error for "${l.expression}": ${h}`),console.error("Available context:",Object.keys(o)),console.error(" Component:",n),console.error(" Text node parent:",e.parentElement?.tagName),c+=""}e.textContent!==c&&(e.textContent=c)}extractVariableNames(e){const t=new Set;for(const n of e)try{const i=j(n,{ecmaVersion:2022,sourceType:"script"});W(i,{Identifier:(r,a)=>{const o=a?.[a.length-1];o?.type==="MemberExpression"&&o.property===r&&!o.computed||ge.has(r.name)||t.add(r.name)}})}catch{console.warn("Failed to parse expression for variable extraction:",n)}return Array.from(t)}findVariablesInParentComponents(e,t,n){const i={};if(!this.componentManager)return i;let r=e.parentElement;const a=new Set([t]);for(;r&&r!==document.body;){const o=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(o&&!a.has(o)){a.add(o);const c=this.componentManager.buildComponentContextWithProps(o,r);for(const l of n)l in c&&!(l in i)&&(i[l]=c[l]);if(Object.keys(i).length===n.length)break}r=r.parentElement}if(Object.keys(i).length<n.length){const o=this.componentManager.buildComponentContext("app");for(const c of n)c in o&&!(c in i)&&(i[c]=o[c])}return i}hasInheritedContext(e,t){const n=e.parentElement;if(n?.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;let i=n;for(;i&&i!==document.body;){if(i.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t){if(i.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;break}i=i.parentElement}for(i=n;i&&i!==document.body;){const r=i.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r&&r!==t&&i.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;i=i.parentElement}return!1}getFreshComponentContext(e,t){return this.componentManager?(this.componentManager.contextInvalidated.add(e),this.componentManager.contextCache.delete(e),this.componentManager.buildComponentContextWithProps(e,t)):{}}resolveComponentRootForElement(e,t){const n=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${t}"]`);if(this.componentManager){for(const i of n)if(this.componentManager.hasStoredProps(i))return i}return n[0]||void 0}getContextForComponent(e,t){return this.componentManager?this.componentManager.buildComponentContextWithProps(e,t):{}}cleanupTextNode(e){const t=this.textNodeBindings.get(e);t&&(t.subscriptionIds.forEach(n=>{this.stateManager.removeSubscription(n)}),this.textNodeBindings.delete(e),this.bindingCount=Math.max(0,this.bindingCount-1))}getBindingCount(){return this.textNodeBindings.size}getAllBindings(){return new Map(this.textNodeBindings)}clearAllBindings(){for(const[e]of this.textNodeBindings)this.cleanupTextNode(e)}destroy(){this.cleanupObserver.disconnect(),this.clearAllBindings()}}class Ls{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...t){const n=this.listeners.get(e);n&&n.forEach(i=>{try{i(...t)}catch(r){console.error(`Event listener error for ${e}:`,r)}})}}class Fs{stateStore={};subscriptions=new Map;updateQueue=new Set;isUpdating=!1;eventBus=new Ls;contextCache=new Map;previousValues=new Map;_subscriptionManager=new Ms;originalStateStore={};domUpdateCallbacks=[];domUpdateScheduled=!1;constructor(){this.setupGlobalStateProxy(),setInterval(()=>{this.subscriptionManager.cleanupStaleSubscriptions()},3e4)}clearSubscriptions(){const e=this._subscriptionManager.getAllSubscriptions();for(const[t]of e)this._subscriptionManager.removeSubscription(t);this.updateQueue.clear()}clearComponentSubscriptions(e){const t=this._subscriptionManager.getAllSubscriptions();for(const[n,i]of t)i.component===e&&this._subscriptionManager.removeSubscription(n)}clearState(){Object.keys(this.stateStore).forEach(e=>{delete this.stateStore[e],delete this.originalStateStore[e]}),this.previousValues.clear(),this.updateQueue.clear(),this.contextCache.clear()}clearComponentState(e){Object.keys(this.stateStore).filter(n=>n.startsWith(`${e}.`)).forEach(n=>{delete this.stateStore[n],delete this.originalStateStore[n],this.previousValues.delete(n)})}onDOMUpdateComplete(e){this.domUpdateCallbacks.push(e),this.domUpdateScheduled||(this.domUpdateScheduled=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=[...this.domUpdateCallbacks];this.domUpdateCallbacks=[],this.domUpdateScheduled=!1,t.forEach(n=>{try{n()}catch(i){console.error("DOM update callback error:",i)}})})}))}setInitialState(e,t){if(this.previousValues.set(e,void 0),this.originalStateStore[e]=t,this.previousValues.size>100){const n=this.previousValues.keys().next().value;typeof n=="string"&&this.previousValues.delete(n)}}get subscriptionManager(){return this._subscriptionManager}batchStateUpdates(e){const t=this.isUpdating;this.isUpdating=!0;try{return e()}finally{this.isUpdating=t,!this.isUpdating&&this.updateQueue.size>0&&this.scheduleFlush()}}invalidateContextCache(){this.contextCache.clear()}setupGlobalStateProxy(){this.originalStateStore=this.stateStore,this.stateStore=new Proxy(this.stateStore,{set:(e,t,n,i)=>{const r=e[t],a=Reflect.set(e,t,n,i);return r!==n&&this.notifySubscribers(t),a},get:(e,t)=>Reflect.get(e,t)})}notifySubscribers(e){if(this.eventBus.emit("stateChanged",e),this.updateQueue.add(e),e.includes(".")){const t=e.split(".")[0];this.updateQueue.add(t)}this.notifyPathBasedSubscribers(e),this.isUpdating||this.scheduleFlush()}notifyPathBasedSubscribers(e){const t=this.stateStore[e],n=this.previousValues?.get(e);for(const[i,r]of this.subscriptions)for(const a of r.dependencies)if(this.isPathDependency(a)&&a.startsWith(e+".")){const o=a.substring(e.length+1),c=this.getPathValue(n,o),l=this.getPathValue(t,o);this.deepEqual(c,l)||this.updateQueue.add(a)}}isPathDependency(e){return e.includes(".")&&e.split(".").length>1}getPathValue(e,t){if(!e||typeof e!="object")return;const n=t.split(".");let i=e;for(const r of n){if(i==null)return;if(Array.isArray(i))return r==="length"?i.length:i.map(a=>a?.[r]).filter(a=>a!==void 0);i=i[r]}return i}deepEqual(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((n,i)=>this.deepEqual(n,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),i=Object.keys(t);return n.length!==i.length?!1:n.every(r=>this.deepEqual(e[r],t[r]))}return!1}scheduleFlush=Ns(()=>{this.flushUpdates()},d.DEBOUNCE_MS);flushUpdates(){if(!this.isUpdating){this.isUpdating=!0;try{const e=new Set,t=this.subscriptionManager.getSubscriptionsForKey("*");if(t&&t.size>0&&this.updateQueue.size>0)for(const n of t){const i=this.subscriptionManager.getSubscription(n);if(!i)continue;if(i.element&&!document.contains(i.element)){this.subscriptionManager.removeSubscription(n);continue}const r=i.element??document.body;try{const a=Array.from(this.updateQueue)[0];i.callback(r,{key:a})}catch(a){console.error("Wildcard subscription callback failed:",a)}}for(const n of this.updateQueue){if(e.has(n))continue;e.add(n);const i=this.subscriptionManager.getSubscriptionsForKey(n);if(i)for(const r of i){const a=this.subscriptionManager.getSubscription(r);if(!a)continue;if(a.element&&!document.contains(a.element)){this.subscriptionManager.removeSubscription(r);continue}const o=a.element??document.body;try{a.callback(o,{key:n})}catch(c){console.error("Subscription callback failed:",c)}}}}finally{this.updateQueue.clear(),this.isUpdating=!1}}}getState(){return this.stateStore}setState(e,t){if(this.previousValues.set(e,this.stateStore[e]),this.stateStore[e]=t,this.previousValues.size>100){const n=this.previousValues.keys().next().value;typeof n=="string"&&this.previousValues.delete(n)}}hasState(e){return e in this.originalStateStore}addSubscription(e){this._subscriptionManager.addSubscription(e)}removeSubscription(e){this._subscriptionManager.removeSubscription(e)}onStateChange(e){return this.eventBus.on("stateChanged",e)}batch(e){const t=this.isUpdating;this.isUpdating=!0;try{return e()}finally{this.isUpdating=t,!this.isUpdating&&this.updateQueue.size&&this.flushUpdates()}}getSubscriptions(){return this.subscriptionManager.getAllSubscriptions()}getKeyIndex(){const e=new Map,t=this.subscriptionManager.getAllSubscriptions();for(const[n,i]of t)for(const r of i.dependencies)e.has(r)||e.set(r,new Set),e.get(r).add(n);return e}destroy(){this.clearState(),this.clearSubscriptions(),this.contextCache.clear(),this.previousValues.clear(),this.domUpdateCallbacks=[]}}class me{expressionCache=new z(d.MAX_CACHE_SIZE);dependencyCache=new z(d.MAX_CACHE_SIZE);commonExpressionsCache=new z(100);dependencyParser=new Vs;static CACHE_KEYS={EXPRESSION:(e,t)=>`expr:${e}:${t}`,DEPENDENCY:(e,t)=>`deps:${e}:${t}`,COMMON:e=>`common:${e}`};constructor(){this.precompileCommonExpressions()}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}precompileCommonExpressions(){["true","false","null","undefined"].forEach(t=>{const n={fn:new Function("return "+t),contextMap:new Map,dependencies:[t],timestamp:Date.now(),hitCount:0},i=me.CACHE_KEYS.COMMON(t);this.commonExpressionsCache.set(i,n)})}extractDependencies(e,t,n){const i=this.normalizeExpression(e),r=me.CACHE_KEYS.DEPENDENCY(t,i);let a=this.dependencyCache.get(r);return a||(a=this.dependencyParser.extract(i,t,n),this.dependencyCache.set(r,a),a)}evaluateExpression(e,t,n){const i=this.normalizeExpression(e),r=me.CACHE_KEYS.COMMON(i);let a=this.commonExpressionsCache.get(r);if(a){a.hitCount++;try{return a.fn()}catch(l){console.error(`Common expression evaluation failed: "${i}"`,l);return}}const o=me.CACHE_KEYS.EXPRESSION(n,i);a=this.expressionCache.get(o);const c=this.transformContextForEvaluation(t,i);(!a||this.isStale(a))&&(a=this.compileExpression(i,c,n),this.expressionCache.set(o,a)),a.hitCount++;try{const l=this.buildArguments(a.contextMap,c);return a.fn(...l)}catch(l){console.error(`Expression evaluation failed: "${i}"`,l),console.error("Available context:",Object.keys(c));return}}transformContextForEvaluation(e,t){const n={},i=t&&(t.includes("?")||t.includes("&&")||t.includes("||")||t.includes("===")||t.includes("!==")||t.includes("==")||t.includes("!=")||t.includes(">=")||t.includes("<=")||t.includes(">")||t.includes("<")||/^!/.test(t.trim()));for(const[r,a]of Object.entries(e))if(typeof a=="function"&&"__pphp_key"in a){const o=a.value;i||o===null||o===void 0||typeof o=="boolean"||typeof o=="string"||typeof o=="number"?n[r]=o:n[r]=a}else n[r]=a;return n}compileExpression(e,t,n){const i=this.prepareSafeContext(t),r=new Map,a=[];Object.keys(i).forEach((c,l)=>{r.set(c,l),a.push(c)});const o=this.dependencyParser.extract(e,n);return{fn:new Function(...a,`return (${e})`),contextMap:r,dependencies:o,timestamp:Date.now(),hitCount:0}}buildArguments(e,t){const n=new Array(e.size);for(const[i,r]of e)n[r]=t[i];return n}isStale(e){return Date.now()-e.timestamp>3e5}prepareSafeContext(e){const t={};for(const[n,i]of Object.entries(e))ge.has(n)||!this.isValidJavaScriptIdentifier(n)||(t[n]=i);return t}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!ge.has(e)}invalidateCache(e){switch(e){case"expressions":this.expressionCache.clear();break;case"dependencies":this.dependencyCache.clear();break;case"common":this.commonExpressionsCache.clear(),this.precompileCommonExpressions();break;case"parser":this.dependencyParser.clearCache();break;default:this.clearAllCaches()}}invalidateByComponent(e){this.expressionCache.deleteByPrefix(`expr:${e}:`),this.dependencyCache.deleteByPrefix(`deps:${e}:`)}clearAllCaches(){this.expressionCache.clear(),this.dependencyCache.clear(),this.commonExpressionsCache.clear(),this.dependencyParser.clearCache(),this.precompileCommonExpressions()}getCacheStats(){return{expressions:this.expressionCache.getStats(),dependencies:this.dependencyCache.getStats(),commonExpressions:this.commonExpressionsCache.getStats(),dependencyParser:this.getDependencyParserStats()}}getDependencyParserStats(){return this.dependencyParser.getCacheSize?{size:this.dependencyParser.getCacheSize(),maxSize:500,hitRate:0,hits:0,misses:0}:{size:0,maxSize:0,hitRate:0,hits:0,misses:0}}cleanupStaleExpressions(){let e=0;return this.expressionCache.keys().forEach(n=>{const i=this.expressionCache.get(n);i&&this.isStale(i)&&(this.expressionCache.delete(n),e++)}),e}}class Vs{parseCache=new z(500);extract(e,t,n){const i=this.normalizeExpression(e),r=`${t}:${i}`;if(this.parseCache.has(r))return this.parseCache.get(r);const a=this.parseExpression(i,t,n);return this.parseCache.set(r,a),a}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}parseExpression(e,t,n){const i=this.extractIdentifiers(e),r=[],a=n?.getState()||{};for(const c of i){if(ge.has(c))continue;const l=c.indexOf("."),p=l===-1?c:c.substring(0,l),h=Ue.findExistingStateKey(p,t,a);if(h)r.push(h);else{const f=t==="app"?[`app.${p}`]:[`${t}.${p}`,`app.${p}`];r.push(...f)}if(l!==-1){const f=t==="app"?[`app.${p}`]:[`${t}.${p}`,`app.${p}`];r.push(...f)}}return Array.from(new Set(r))}extractIdentifiers(e){const t=[];let n=0;for(;n<e.length;){const i=e[n];if(i==="'"){n=this.skipString(e,n,"'");continue}if(i==='"'){n=this.skipString(e,n,'"');continue}if(i==="`"){n=this.skipTemplateLiteral(e,n,t);continue}if(this.isIdentifierStart(i)){const r=this.extractIdentifier(e,n);t.push(r.value),n=r.endIndex;continue}n++}return t}skipString(e,t,n){let i=t+1;for(;i<e.length&&e[i]!==n;)e[i]==="\\"&&i++,i++;return i+1}skipTemplateLiteral(e,t,n){let i=t+1;for(;i<e.length&&e[i]!=="`";){if(e[i]==="$"&&i+1<e.length&&e[i+1]==="{"){i+=2;let r=1;for(;i<e.length&&r>0;){const a=e[i];if(a==='"'||a==="'"){i=this.skipString(e,i,a);continue}if(a==="{"?r++:a==="}"&&r--,r>0&&this.isIdentifierStart(a)){const o=this.extractIdentifier(e,i);n.push(o.value),i=o.endIndex-1}i++}continue}e[i]==="\\"&&i++,i++}return i+1}extractIdentifier(e,t){let n=t;for(;n<e.length&&(this.isIdentifierPart(e[n])||e[n]===".");)n++;return{value:e.substring(t,n),endIndex:n}}isIdentifierStart(e){return/[a-zA-Z_$]/.test(e)}isIdentifierPart(e){return/[a-zA-Z0-9_$]/.test(e)}clearCache(){this.parseCache.clear()}getCacheSize(){return this.parseCache.cache.size}}class Ds{componentStack=["app"];elementProps=new WeakMap;contextCache=new z(100);contextIndex=new Map;contextInvalidated=new Set;stateManager;processedScripts=new WeakSet;componentFunctions=new Map;expressionEvaluator;domBindingManager;loopManager;templateRenderer;updateTimeouts;updateBatcher=new rt;propDependencyCache=new Map;constructor(e){this.stateManager=e,this.updateBatcher=new rt,this.stateManager.onStateChange(t=>this.invalidateContextCache(t))}getPropDependencies(e,t){const n=this.findElementWithProps(t);if(!n)return[];const i=this.elementProps.get(n);if(!i||!i.has(e))return[];const r=i.get(e);return this.templateRenderer?.dependencies(r.expression,r.component,this.stateManager)||[]}buildRestrictedComponentContext(e,t=!1){const n={};window[e]&&Object.assign(n,window[e]);const i=this.componentFunctions.get(e);if(i)for(const[a,o]of i)n[a]=o;const r=this.stateManager.getState();for(const a of Object.keys(r))if(a.startsWith(e+".")){const o=a.substring(e.length+1);o in n||(n[o]=r[a])}if(t){if(window.app)for(const[o,c]of Object.entries(window.app))o in n||(n[o]=c);const a=this.componentFunctions.get("app");if(a)for(const[o,c]of a)o in n||(n[o]=c);for(const o of Object.keys(r))if(o.startsWith("app.")){const c=o.substring(4);c in n||(n[c]=r[o])}}return n}getComponentPropDependencies(e,t){if(this.propDependencyCache.has(e))return this.propDependencyCache.get(e);const n=[],i=this.elementProps.get(e);i&&this.templateRenderer&&i.forEach(a=>{const o=this.templateRenderer?.dependencies(a.expression,a.component,this.stateManager);n.push(...o??[])});const r=Array.from(new Set(n));return this.propDependencyCache.set(e,r),r}setDOMBindingManager(e){this.domBindingManager=e,this.updateBatcher.setManagers(this,e)}hasStoredProps(e){return this.elementProps.has(e)&&this.elementProps.get(e).size>0}setExpressionEvaluator(e){this.expressionEvaluator=e,this.templateRenderer=new Je(e),this.loopManager=new Wt(this.stateManager,e)}extractProps(e,t){const n=new Map,i=e.attributes,r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);let o=t;r&&(r==="app"?o="app":r==="parent"?o=S.getParentOfComponent(a||"app",e):o=r);for(let c=0;c<i.length;c++){const l=i[c];if(!(l.name===d.ATTR_PREFIXES.COMPONENT||l.name===d.ATTR_PREFIXES.CONTEXT||l.name===d.ATTR_PREFIXES.SPREAD||l.name===d.ATTR_PREFIXES.LOOP)&&!de.isEventAttribute(l.name)&&l.value&&Os.containsMustacheExpression(l.value)){if(a&&this.mightReferenceSelfProps(l.value,e))continue;const p=this.attributeToPropName(l.name),h={name:p,expression:l.value,component:o,subscriptionIds:[]};n.set(p,h)}}return n}mightReferenceSelfProps(e,t){const n=this.elementProps.get(t);if(!n)return!1;const i=Array.from(n.keys()),r=N.extractExpressions(e);if(r.length===0)return!1;for(const a of r)try{const o=j(a,{ecmaVersion:2022,sourceType:"script"}),c=new Set,l=new Set;W(o,{Identifier:(p,h)=>{const f=h?.[h.length-1];f?.type==="MemberExpression"&&f.property===p&&!f.computed||(f?.type==="FunctionExpression"||f?.type==="ArrowFunctionExpression")&&(f.params||[]).includes(p)||(f?.type==="MemberExpression"&&f.object===p?l.add(p.name):c.add(p.name))}});for(const p of i){if(p==="dataState")continue;const h=c.has(p),f=l.has(p)&&!c.has(p);if(h&&!f)return!0}}catch(o){console.error(`❌ Failed to parse mustache expression "${a}":`,o);continue}return!1}attributeToPropName(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}setupProps(e,t){const n=this.extractProps(e,t);n.size!==0&&(this.elementProps.set(e,n),this.expressionEvaluator&&n.forEach((i,r)=>{this.setupPropBinding(e,i)}))}setupPropBinding(e,t){if(!this.expressionEvaluator)return;const n=`prop_${Date.now()}_${Math.random()}`,i=this.templateRenderer?.dependencies(t.expression,t.component,this.stateManager)||[],r={id:n,selector:"",dependencies:new Set(i),callback:()=>{const a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);a&&(this.updateBatcher.scheduleUpdate(a,e),this.refreshComponentBindings(e,a))},element:e,component:t.component};this.stateManager.addSubscription(r),t.subscriptionIds.push(n)}refreshComponentBindings(e,t){this.contextInvalidated.add(t),this.contextCache.delete(t),this.domBindingManager&&this.domBindingManager.refreshComponentElement(e,t)}evaluateProps(e){const t={},n=this.elementProps.get(e);if(!n||!this.expressionEvaluator)return t;const i=n.values().next().value;if(!i)return t;const r=this.buildComponentContext(i.component);return n.forEach((a,o)=>{try{const c=this.templateRenderer?.render(a.expression,r,a.component);typeof c=="function"?"__pphp_key"in c?t[o]=c:t[o]=(...l)=>c.apply(this,l):t[o]=c}catch(c){console.error(`❌ Failed to evaluate prop "${o}":`,c),t[o]=void 0}}),t}cleanupProps(e){const t=this.elementProps.get(e);t&&(t.forEach(n=>{n.subscriptionIds.forEach(i=>{this.stateManager.removeSubscription(i)})}),this.elementProps.delete(e))}buildComponentContextWithProps(e,t){const n=this.buildComponentContext(e);let i=this.findElementWithProps(e);if(t&&this.elementProps.has(t)&&(i=t),i)try{const r=this.evaluatePropsWithContext(i,e,t);Object.keys(r).length>0&&Object.keys(r).forEach(a=>{n[a]=r[a]})}catch(r){console.error(`❌ Error evaluating props for ${e}:`,r)}return n}evaluatePropsWithContext(e,t,n){const i={},r=this.elementProps.get(e);if(!r||!this.expressionEvaluator)return i;const a=r.values().next().value;if(!a)return i;let o;const c=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),l=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(c)if(c==="app")o=this.buildComponentContext("app");else if(c==="parent"){const g=S.getParentOfComponent(l||"app",e);o=this.buildComponentContext(g)}else o=this.buildComponentContext(c);else o=this.buildComponentContext(a.component);const p=this.loopManager?.getLoopContextForElement(e);p&&(o={...o,...p});const h=new Map,f=new Map,x=Array.from(r.keys());r.forEach((g,m)=>{x.some(A=>A!==m&&g.expression.includes(A))?f.set(m,g):h.set(m,g)}),h.forEach((g,m)=>{try{const E=this.templateRenderer?.render(g.expression,o,c||g.component);i[m]=E}catch(E){console.error(`❌ Failed to evaluate simple prop "${m}":`,E),i[m]=void 0}});const b={...o,...i};return f.forEach((g,m)=>{try{const E=this.templateRenderer?.render(g.expression,b,c||g.component);i[m]=E}catch(E){console.error(`❌ Failed to evaluate complex prop "${m}":`,E),i[m]=void 0}}),i}findElementWithProps(e){const t=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const n of t){const i=this.elementProps.get(n);if(i&&i.size>0)return n}return null}pushComponent(e){this.componentStack.push(e)}popComponent(){return this.componentStack.pop()}getCurrentComponent(){return this.componentStack[this.componentStack.length-1]}buildComponentContext(e){if(!this.contextInvalidated.has(e)&&this.contextCache.has(e))return this.contextCache.get(e);const t=this.computeComponentContext(e);return this.contextCache.set(e,t),this.contextInvalidated.delete(e),t}computeComponentContext(e){const t={};if(e.includes("_loop_")||e.match(/_[a-zA-Z0-9]{8}$/)){const r=e.split("_");r.pop();const a=r.join("_");window[a]&&Object.assign(t,window[a])}e!=="app"&&window[e]&&Object.assign(t,window[e]),e==="app"&&window.app&&Object.assign(t,window.app);const n=this.componentFunctions.get(e);if(n)for(const[r,a]of n)t[r]=a;if(e!=="app"){const r=this.componentFunctions.get("app");if(r)for(const[a,o]of r)a in t||(t[a]=o);if(window.app)for(const[a,o]of Object.entries(window.app))a in t||(t[a]=o)}const i=this.stateManager.getState();for(const r of Object.keys(i))if(r.startsWith(e+".")){const a=r.substring(e.length+1);a in t||(t[a]=i[r])}if(e!=="app"){for(const r of Object.keys(i))if(r.startsWith("app.")){const a=r.substring(4);a in t||(t[a]=i[r])}}return t}invalidateContextCache(e){if(e.startsWith("app.")){this.contextCache.clear();for(const n of this.contextInvalidated.keys())this.contextInvalidated.add(n);return}const t=e.indexOf(".");if(t!==-1){const n=e.slice(0,t);this.invalidateComponent(n)}}invalidateComponent(e){this.contextInvalidated.add(e),this.contextIndex.delete(e)}executePhpScripts(e){const t=this.componentStack.length,n=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),i=e===document.body;if(n||i){if(n){this.pushComponent(n);const a=this.getParentComponent(e);this.setupProps(e,a)}this.getRelevantScripts(e,i).forEach(a=>{const o=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);o&&o!==n?(this.pushComponent(o),this.executeScript(a),this.popComponent()):this.executeScript(a)})}for(Array.from(e.children).forEach(r=>this.executePhpScripts(r));this.componentStack.length>t;)this.popComponent()}getParentComponent(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}getRelevantScripts(e,t){return Array.from(e.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`)).filter(n=>{if(this.processedScripts.has(n))return!1;if(t)return n.hasAttribute(d.ATTR_PREFIXES.COMPONENT)?!0:!n.closest(`[${d.ATTR_PREFIXES.COMPONENT}]`);let i=n.parentElement;for(;i&&i!==e;){if(i.hasAttribute(d.ATTR_PREFIXES.COMPONENT))return!1;i=i.parentElement}return i===e||e.contains(n)})}executeScript(e){if(this.processedScripts.has(e))return;this.processedScripts.add(e);const t=this.getCurrentComponent(),n=e.textContent||"",i=N.decodeEntities(n);try{const r=this.findComponentElementForScript(e,t);if(r===e){const c=this.getParentComponent(e);this.setupProps(e,c)}const a=this.hasExplicitContext(r||e,t);let o;if(a)o=this.buildComponentContextWithProps(t,r);else if(o=this.buildRestrictedComponentContext(t,!1),r&&this.hasStoredProps(r)){const c=this.evaluateProps(r);Object.assign(o,c)}window[t]||(window[t]={}),this.executeScriptFunctions(i,t,o)}catch(r){console.error(`Script execution failed in component ${t}:`,r),console.error("Script content:",i)}}hasExplicitContext(e,t){if(e.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;let n=e;for(;n&&n!==document.body;){if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t){if(n.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;break}n=n.parentElement}for(n=e.parentElement;n&&n!==document.body;){if(n.hasAttribute(d.ATTR_PREFIXES.CONTEXT)){const i=n.getAttribute(d.ATTR_PREFIXES.CONTEXT);if(i==="app"||i==="parent")return!0}n=n.parentElement}return!1}findComponentElementForScript(e,t){if(e.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const i=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const r of i)if(this.elementProps.has(r))return r;return i[0]||void 0}executeScriptFunctions(e,t,n){const i=this.extractFunctionNames(e),r=this.findElementWithProps(t),a=this.extractVariableDeclarations(e);let o={...n};if(a.forEach(g=>{delete o[g];const m=`set${jt(g)}`,E=`${g}Getter`;delete o[m],delete o[E]}),r){const g=this.evaluateProps(r);Object.assign(o,g)}o.getContext=()=>this.buildComponentContextWithProps(t),o.withContext=g=>{const m=this.buildComponentContextWithProps(t);return g.call(m,m)},o.__getProp=g=>{if(r)return this.evaluateProps(r)[g]};const c=Z.getInstance(),l=new Set;if(r){const g=this.evaluateProps(r);for(const[m,E]of Object.entries(g))typeof E=="function"&&"__pphp_key"in E&&(l.add(m),/^set[A-Z]/.test(m)&&l.add(m))}let p=c.transformStateDeclarations(e,l);p=this.modifyScriptForReactiveProps(p,t,r||void 0);const h=`
|
|
16
|
+
`)),i}}class Os{textNodeBindings=new Map;expressionEvaluator;stateManager;componentManager;cleanupObserver;bindingCount=0;constructor(e,t){this.expressionEvaluator=e,this.stateManager=t,this.cleanupObserver=new MutationObserver(n=>{this.cleanupDetachedNodes(n)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}cleanupDetachedNodes(e){const t=[];for(const n of e)n.type==="childList"&&n.removedNodes.forEach(i=>{if(i.nodeType===Node.TEXT_NODE)t.push(i);else if(i.nodeType===Node.ELEMENT_NODE){const r=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,null);let a;for(;a=r.nextNode();)t.push(a)}});Promise.resolve().then(()=>{t.forEach(n=>{document.contains(n)||this.cleanupTextNode(n)})})}processTextNode(e,t){if(this.textNodeBindings.has(e)||T.isTextNodeInsideScript(e)||this.isInsideLoopItem(e))return;const n=e.parentElement,i=n?T.getContextComponent(n):t,r=e.textContent||"",a=N.parse(r);if(!a.some(p=>p.type==="expression"))return;const c=this.resolveComponentRootForElement(e,i),l={originalContent:r,expressions:a,subscriptionIds:[],component:i,componentElement:c};a.filter(p=>p.type==="expression").forEach(p=>{if(!p.expression)return;const h=`text_${Date.now()}_${Math.random()}`,f=this.expressionEvaluator.extractDependencies(p.expression,i,this.stateManager);if(c&&this.componentManager){const m=this.componentManager.getComponentPropDependencies(c,i);f.push(...m)}const E={id:h,selector:"",dependencies:new Set(f),callback:()=>{this.updateTextNode(e)},element:e.parentElement??void 0,component:i};this.stateManager.addSubscription(E),l.subscriptionIds.push(h)}),this.textNodeBindings.set(e,l),this.bindingCount++,this.updateTextNode(e)}isInsideLoopItem(e){let t=e.parentElement;for(;t&&t!==document.body;){const n=t.previousSibling;if(n&&n.nodeType===Node.COMMENT_NODE&&n.textContent?.startsWith("pp-for:"))return!0;let i=t.parentElement?.firstChild||null;for(;i;){if(i.nodeType===Node.COMMENT_NODE&&i.textContent?.startsWith("pp-for:")&&i!==t)return!0;i=i.nextSibling}t=t.parentElement}return!1}updateTextNode(e){const t=this.textNodeBindings.get(e);if(!t||!e.parentElement)return;const n=t.component;let i=t.componentElement;(!i||!document.contains(i))&&(i=this.resolveComponentRootForElement(e,n),t.componentElement=i);const r=this.hasInheritedContext(e,n);let a;if(r)i?a=this.getFreshComponentContext(n,i):a=this.getContextForComponent(n,i);else if(this.componentManager){if(a=this.componentManager.buildRestrictedComponentContext(n,!1),i&&this.componentManager.hasStoredProps(i)){const f=this.componentManager.evaluateProps(i);Object.assign(a,f)}const l=t.expressions.filter(f=>f.type==="expression").map(f=>f.expression).filter(f=>f),h=this.extractVariableNames(l).filter(f=>!(f in a));if(h.length>0){const f=this.findVariablesInParentComponents(e,n,h);Object.keys(f).length>0?Object.assign(a,f):console.warn("⚠️ [TextNode Update] Could not find missing variables in parent components")}}else a={};const o={};for(const[l,p]of Object.entries(a))typeof p=="function"&&"__pphp_key"in p?o[l]=p.value:o[l]=p;let c="";for(const l of t.expressions)if(l.type==="static")c+=l.content;else if(l.expression)try{const p=this.expressionEvaluator.evaluateExpression(l.expression,o,n);c+=ue(p)}catch(p){const h=typeof p=="object"&&p!==null&&"message"in p?p.message:String(p);console.error(`❌ Text binding evaluation error for "${l.expression}": ${h}`),console.error("Available context:",Object.keys(o)),console.error(" Component:",n),console.error(" Text node parent:",e.parentElement?.tagName),c+=""}e.textContent!==c&&(e.textContent=c)}extractVariableNames(e){const t=new Set;for(const n of e)try{const i=B(n,{ecmaVersion:2022,sourceType:"script"});$(i,{Identifier:(r,a)=>{const o=a?.[a.length-1];o?.type==="MemberExpression"&&o.property===r&&!o.computed||ge.has(r.name)||t.add(r.name)}})}catch{console.warn("Failed to parse expression for variable extraction:",n)}return Array.from(t)}findVariablesInParentComponents(e,t,n){const i={};if(!this.componentManager)return i;let r=e.parentElement;const a=new Set([t]);for(;r&&r!==document.body;){const o=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(o&&!a.has(o)){a.add(o);const c=this.componentManager.buildComponentContextWithProps(o,r);for(const l of n)l in c&&!(l in i)&&(i[l]=c[l]);if(Object.keys(i).length===n.length)break}r=r.parentElement}if(Object.keys(i).length<n.length){const o=this.componentManager.buildComponentContext("app");for(const c of n)c in o&&!(c in i)&&(i[c]=o[c])}return i}hasInheritedContext(e,t){const n=e.parentElement;if(n?.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;let i=n;for(;i&&i!==document.body;){if(i.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t){if(i.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;break}i=i.parentElement}for(i=n;i&&i!==document.body;){const r=i.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r&&r!==t&&i.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;i=i.parentElement}return!1}getFreshComponentContext(e,t){return this.componentManager?(this.componentManager.contextInvalidated.add(e),this.componentManager.contextCache.delete(e),this.componentManager.buildComponentContextWithProps(e,t)):{}}resolveComponentRootForElement(e,t){const n=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${t}"]`);if(this.componentManager){for(const i of n)if(this.componentManager.hasStoredProps(i))return i}return n[0]||void 0}getContextForComponent(e,t){return this.componentManager?this.componentManager.buildComponentContextWithProps(e,t):{}}cleanupTextNode(e){const t=this.textNodeBindings.get(e);t&&(t.subscriptionIds.forEach(n=>{this.stateManager.removeSubscription(n)}),this.textNodeBindings.delete(e),this.bindingCount=Math.max(0,this.bindingCount-1))}getBindingCount(){return this.textNodeBindings.size}getAllBindings(){return new Map(this.textNodeBindings)}clearAllBindings(){for(const[e]of this.textNodeBindings)this.cleanupTextNode(e)}destroy(){this.cleanupObserver.disconnect(),this.clearAllBindings()}}class Ls{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...t){const n=this.listeners.get(e);n&&n.forEach(i=>{try{i(...t)}catch(r){console.error(`Event listener error for ${e}:`,r)}})}}class Fs{stateStore={};subscriptions=new Map;updateQueue=new Set;isUpdating=!1;eventBus=new Ls;contextCache=new Map;previousValues=new Map;_subscriptionManager=new Ms;originalStateStore={};domUpdateCallbacks=[];domUpdateScheduled=!1;constructor(){this.setupGlobalStateProxy(),setInterval(()=>{this.subscriptionManager.cleanupStaleSubscriptions()},3e4)}clearSubscriptions(){const e=this._subscriptionManager.getAllSubscriptions();for(const[t]of e)this._subscriptionManager.removeSubscription(t);this.updateQueue.clear()}clearComponentSubscriptions(e){const t=this._subscriptionManager.getAllSubscriptions();for(const[n,i]of t)i.component===e&&this._subscriptionManager.removeSubscription(n)}clearState(){Object.keys(this.stateStore).forEach(e=>{delete this.stateStore[e],delete this.originalStateStore[e]}),this.previousValues.clear(),this.updateQueue.clear(),this.contextCache.clear()}clearComponentState(e){Object.keys(this.stateStore).filter(n=>n.startsWith(`${e}.`)).forEach(n=>{delete this.stateStore[n],delete this.originalStateStore[n],this.previousValues.delete(n)})}onDOMUpdateComplete(e){this.domUpdateCallbacks.push(e),this.domUpdateScheduled||(this.domUpdateScheduled=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=[...this.domUpdateCallbacks];this.domUpdateCallbacks=[],this.domUpdateScheduled=!1,t.forEach(n=>{try{n()}catch(i){console.error("DOM update callback error:",i)}})})}))}setInitialState(e,t){if(this.previousValues.set(e,void 0),this.originalStateStore[e]=t,this.previousValues.size>100){const n=this.previousValues.keys().next().value;typeof n=="string"&&this.previousValues.delete(n)}}get subscriptionManager(){return this._subscriptionManager}batchStateUpdates(e){const t=this.isUpdating;this.isUpdating=!0;try{return e()}finally{this.isUpdating=t,!this.isUpdating&&this.updateQueue.size>0&&this.scheduleFlush()}}invalidateContextCache(){this.contextCache.clear()}setupGlobalStateProxy(){this.originalStateStore=this.stateStore,this.stateStore=new Proxy(this.stateStore,{set:(e,t,n,i)=>{const r=e[t],a=Reflect.set(e,t,n,i);return r!==n&&this.notifySubscribers(t),a},get:(e,t)=>Reflect.get(e,t)})}notifySubscribers(e){if(this.eventBus.emit("stateChanged",e),this.updateQueue.add(e),e.includes(".")){const t=e.split(".")[0];this.updateQueue.add(t)}this.notifyPathBasedSubscribers(e),this.isUpdating||this.scheduleFlush()}notifyPathBasedSubscribers(e){const t=this.stateStore[e],n=this.previousValues?.get(e);for(const[i,r]of this.subscriptions)for(const a of r.dependencies)if(this.isPathDependency(a)&&a.startsWith(e+".")){const o=a.substring(e.length+1),c=this.getPathValue(n,o),l=this.getPathValue(t,o);this.deepEqual(c,l)||this.updateQueue.add(a)}}isPathDependency(e){return e.includes(".")&&e.split(".").length>1}getPathValue(e,t){if(!e||typeof e!="object")return;const n=t.split(".");let i=e;for(const r of n){if(i==null)return;if(Array.isArray(i))return r==="length"?i.length:i.map(a=>a?.[r]).filter(a=>a!==void 0);i=i[r]}return i}deepEqual(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((n,i)=>this.deepEqual(n,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),i=Object.keys(t);return n.length!==i.length?!1:n.every(r=>this.deepEqual(e[r],t[r]))}return!1}scheduleFlush=Ns(()=>{this.flushUpdates()},d.DEBOUNCE_MS);flushUpdates(){if(!this.isUpdating){this.isUpdating=!0;try{const e=new Set,t=this.subscriptionManager.getSubscriptionsForKey("*");if(t&&t.size>0&&this.updateQueue.size>0)for(const n of t){const i=this.subscriptionManager.getSubscription(n);if(!i)continue;if(i.element&&!document.contains(i.element)){this.subscriptionManager.removeSubscription(n);continue}const r=i.element??document.body;try{const a=Array.from(this.updateQueue)[0];i.callback(r,{key:a})}catch(a){console.error("Wildcard subscription callback failed:",a)}}for(const n of this.updateQueue){if(e.has(n))continue;e.add(n);const i=this.subscriptionManager.getSubscriptionsForKey(n);if(i)for(const r of i){const a=this.subscriptionManager.getSubscription(r);if(!a)continue;if(a.element&&!document.contains(a.element)){this.subscriptionManager.removeSubscription(r);continue}const o=a.element??document.body;try{a.callback(o,{key:n})}catch(c){console.error("Subscription callback failed:",c)}}}}finally{this.updateQueue.clear(),this.isUpdating=!1}}}getState(){return this.stateStore}setState(e,t){if(this.previousValues.set(e,this.stateStore[e]),this.stateStore[e]=t,this.previousValues.size>100){const n=this.previousValues.keys().next().value;typeof n=="string"&&this.previousValues.delete(n)}}hasState(e){return e in this.originalStateStore}addSubscription(e){this._subscriptionManager.addSubscription(e)}removeSubscription(e){this._subscriptionManager.removeSubscription(e)}onStateChange(e){return this.eventBus.on("stateChanged",e)}batch(e){const t=this.isUpdating;this.isUpdating=!0;try{return e()}finally{this.isUpdating=t,!this.isUpdating&&this.updateQueue.size&&this.flushUpdates()}}getSubscriptions(){return this.subscriptionManager.getAllSubscriptions()}getKeyIndex(){const e=new Map,t=this.subscriptionManager.getAllSubscriptions();for(const[n,i]of t)for(const r of i.dependencies)e.has(r)||e.set(r,new Set),e.get(r).add(n);return e}destroy(){this.clearState(),this.clearSubscriptions(),this.contextCache.clear(),this.previousValues.clear(),this.domUpdateCallbacks=[]}}class me{expressionCache=new q(d.MAX_CACHE_SIZE);dependencyCache=new q(d.MAX_CACHE_SIZE);commonExpressionsCache=new q(100);dependencyParser=new Vs;static CACHE_KEYS={EXPRESSION:(e,t)=>`expr:${e}:${t}`,DEPENDENCY:(e,t)=>`deps:${e}:${t}`,COMMON:e=>`common:${e}`};constructor(){this.precompileCommonExpressions()}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}precompileCommonExpressions(){["true","false","null","undefined"].forEach(t=>{const n={fn:new Function("return "+t),contextMap:new Map,dependencies:[t],timestamp:Date.now(),hitCount:0},i=me.CACHE_KEYS.COMMON(t);this.commonExpressionsCache.set(i,n)})}extractDependencies(e,t,n){const i=this.normalizeExpression(e),r=me.CACHE_KEYS.DEPENDENCY(t,i);let a=this.dependencyCache.get(r);return a||(a=this.dependencyParser.extract(i,t,n),this.dependencyCache.set(r,a),a)}evaluateExpression(e,t,n){const i=this.normalizeExpression(e),r=me.CACHE_KEYS.COMMON(i);let a=this.commonExpressionsCache.get(r);if(a){a.hitCount++;try{return a.fn()}catch(l){console.error(`Common expression evaluation failed: "${i}"`,l);return}}const o=me.CACHE_KEYS.EXPRESSION(n,i);a=this.expressionCache.get(o);const c=this.transformContextForEvaluation(t,i);(!a||this.isStale(a))&&(a=this.compileExpression(i,c,n),this.expressionCache.set(o,a)),a.hitCount++;try{const l=this.buildArguments(a.contextMap,c);return a.fn(...l)}catch(l){console.error(`Expression evaluation failed: "${i}"`,l),console.error("Available context:",Object.keys(c));return}}transformContextForEvaluation(e,t){const n={},i=t&&(t.includes("?")||t.includes("&&")||t.includes("||")||t.includes("===")||t.includes("!==")||t.includes("==")||t.includes("!=")||t.includes(">=")||t.includes("<=")||t.includes(">")||t.includes("<")||/^!/.test(t.trim()));for(const[r,a]of Object.entries(e))if(typeof a=="function"&&"__pphp_key"in a){const o=a.value;i||o===null||o===void 0||typeof o=="boolean"||typeof o=="string"||typeof o=="number"?n[r]=o:n[r]=a}else n[r]=a;return n}compileExpression(e,t,n){const i=this.prepareSafeContext(t),r=new Map,a=[];Object.keys(i).forEach((c,l)=>{r.set(c,l),a.push(c)});const o=this.dependencyParser.extract(e,n);return{fn:new Function(...a,`return (${e})`),contextMap:r,dependencies:o,timestamp:Date.now(),hitCount:0}}buildArguments(e,t){const n=new Array(e.size);for(const[i,r]of e)n[r]=t[i];return n}isStale(e){return Date.now()-e.timestamp>3e5}prepareSafeContext(e){const t={};for(const[n,i]of Object.entries(e))ge.has(n)||!this.isValidJavaScriptIdentifier(n)||(t[n]=i);return t}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!ge.has(e)}invalidateCache(e){switch(e){case"expressions":this.expressionCache.clear();break;case"dependencies":this.dependencyCache.clear();break;case"common":this.commonExpressionsCache.clear(),this.precompileCommonExpressions();break;case"parser":this.dependencyParser.clearCache();break;default:this.clearAllCaches()}}invalidateByComponent(e){this.expressionCache.deleteByPrefix(`expr:${e}:`),this.dependencyCache.deleteByPrefix(`deps:${e}:`)}clearAllCaches(){this.expressionCache.clear(),this.dependencyCache.clear(),this.commonExpressionsCache.clear(),this.dependencyParser.clearCache(),this.precompileCommonExpressions()}getCacheStats(){return{expressions:this.expressionCache.getStats(),dependencies:this.dependencyCache.getStats(),commonExpressions:this.commonExpressionsCache.getStats(),dependencyParser:this.getDependencyParserStats()}}getDependencyParserStats(){return this.dependencyParser.getCacheSize?{size:this.dependencyParser.getCacheSize(),maxSize:500,hitRate:0,hits:0,misses:0}:{size:0,maxSize:0,hitRate:0,hits:0,misses:0}}cleanupStaleExpressions(){let e=0;return this.expressionCache.keys().forEach(n=>{const i=this.expressionCache.get(n);i&&this.isStale(i)&&(this.expressionCache.delete(n),e++)}),e}}class Vs{parseCache=new q(500);extract(e,t,n){const i=this.normalizeExpression(e),r=`${t}:${i}`;if(this.parseCache.has(r))return this.parseCache.get(r);const a=this.parseExpression(i,t,n);return this.parseCache.set(r,a),a}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}parseExpression(e,t,n){const i=this.extractIdentifiers(e),r=[],a=n?.getState()||{};for(const c of i){if(ge.has(c))continue;const l=c.indexOf("."),p=l===-1?c:c.substring(0,l),h=Ue.findExistingStateKey(p,t,a);if(h)r.push(h);else{const f=t==="app"?[`app.${p}`]:[`${t}.${p}`,`app.${p}`];r.push(...f)}if(l!==-1){const f=t==="app"?[`app.${p}`]:[`${t}.${p}`,`app.${p}`];r.push(...f)}}return Array.from(new Set(r))}extractIdentifiers(e){const t=[];let n=0;for(;n<e.length;){const i=e[n];if(i==="'"){n=this.skipString(e,n,"'");continue}if(i==='"'){n=this.skipString(e,n,'"');continue}if(i==="`"){n=this.skipTemplateLiteral(e,n,t);continue}if(this.isIdentifierStart(i)){const r=this.extractIdentifier(e,n);t.push(r.value),n=r.endIndex;continue}n++}return t}skipString(e,t,n){let i=t+1;for(;i<e.length&&e[i]!==n;)e[i]==="\\"&&i++,i++;return i+1}skipTemplateLiteral(e,t,n){let i=t+1;for(;i<e.length&&e[i]!=="`";){if(e[i]==="$"&&i+1<e.length&&e[i+1]==="{"){i+=2;let r=1;for(;i<e.length&&r>0;){const a=e[i];if(a==='"'||a==="'"){i=this.skipString(e,i,a);continue}if(a==="{"?r++:a==="}"&&r--,r>0&&this.isIdentifierStart(a)){const o=this.extractIdentifier(e,i);n.push(o.value),i=o.endIndex-1}i++}continue}e[i]==="\\"&&i++,i++}return i+1}extractIdentifier(e,t){let n=t;for(;n<e.length&&(this.isIdentifierPart(e[n])||e[n]===".");)n++;return{value:e.substring(t,n),endIndex:n}}isIdentifierStart(e){return/[a-zA-Z_$]/.test(e)}isIdentifierPart(e){return/[a-zA-Z0-9_$]/.test(e)}clearCache(){this.parseCache.clear()}getCacheSize(){return this.parseCache.cache.size}}class Ds{componentStack=["app"];elementProps=new WeakMap;contextCache=new q(100);contextIndex=new Map;contextInvalidated=new Set;stateManager;processedScripts=new WeakSet;componentFunctions=new Map;expressionEvaluator;domBindingManager;loopManager;templateRenderer;updateTimeouts;updateBatcher=new rt;propDependencyCache=new Map;constructor(e){this.stateManager=e,this.updateBatcher=new rt,this.stateManager.onStateChange(t=>this.invalidateContextCache(t))}getPropDependencies(e,t){const n=this.findElementWithProps(t);if(!n)return[];const i=this.elementProps.get(n);if(!i||!i.has(e))return[];const r=i.get(e);return this.templateRenderer?.dependencies(r.expression,r.component,this.stateManager)||[]}buildRestrictedComponentContext(e,t=!1){const n={};window[e]&&Object.assign(n,window[e]);const i=this.componentFunctions.get(e);if(i)for(const[a,o]of i)n[a]=o;const r=this.stateManager.getState();for(const a of Object.keys(r))if(a.startsWith(e+".")){const o=a.substring(e.length+1);o in n||(n[o]=r[a])}if(t){if(window.app)for(const[o,c]of Object.entries(window.app))o in n||(n[o]=c);const a=this.componentFunctions.get("app");if(a)for(const[o,c]of a)o in n||(n[o]=c);for(const o of Object.keys(r))if(o.startsWith("app.")){const c=o.substring(4);c in n||(n[c]=r[o])}}return n}getComponentPropDependencies(e,t){if(this.propDependencyCache.has(e))return this.propDependencyCache.get(e);const n=[],i=this.elementProps.get(e);i&&this.templateRenderer&&i.forEach(a=>{const o=this.templateRenderer?.dependencies(a.expression,a.component,this.stateManager);n.push(...o??[])});const r=Array.from(new Set(n));return this.propDependencyCache.set(e,r),r}setDOMBindingManager(e){this.domBindingManager=e,this.updateBatcher.setManagers(this,e)}hasStoredProps(e){return this.elementProps.has(e)&&this.elementProps.get(e).size>0}setExpressionEvaluator(e){this.expressionEvaluator=e,this.templateRenderer=new Je(e),this.loopManager=new Wt(this.stateManager,e)}extractProps(e,t){const n=new Map,i=e.attributes,r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);let o=t;r&&(r==="app"?o="app":o=r);for(let c=0;c<i.length;c++){const l=i[c];if(!(l.name===d.ATTR_PREFIXES.COMPONENT||l.name===d.ATTR_PREFIXES.CONTEXT||l.name===d.ATTR_PREFIXES.SPREAD||l.name===d.ATTR_PREFIXES.LOOP)&&!de.isEventAttribute(l.name)&&l.value&&Rs.containsMustacheExpression(l.value)){if(a&&this.mightReferenceSelfProps(l.value,e))continue;const p=this.attributeToPropName(l.name),h={name:p,expression:l.value,component:o,subscriptionIds:[]};n.set(p,h)}}return n}mightReferenceSelfProps(e,t){const n=this.elementProps.get(t);if(!n)return!1;const i=Array.from(n.keys()),r=N.extractExpressions(e);if(r.length===0)return!1;for(const a of r)try{const o=B(a,{ecmaVersion:2022,sourceType:"script"}),c=new Set,l=new Set;$(o,{Identifier:(p,h)=>{const f=h?.[h.length-1];f?.type==="MemberExpression"&&f.property===p&&!f.computed||(f?.type==="FunctionExpression"||f?.type==="ArrowFunctionExpression")&&(f.params||[]).includes(p)||(f?.type==="MemberExpression"&&f.object===p?l.add(p.name):c.add(p.name))}});for(const p of i){if(p==="dataState")continue;const h=c.has(p),f=l.has(p)&&!c.has(p);if(h&&!f)return!0}}catch(o){console.error(`❌ Failed to parse mustache expression "${a}":`,o);continue}return!1}attributeToPropName(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}setupProps(e,t){const n=this.extractProps(e,t);n.size!==0&&(this.elementProps.set(e,n),this.expressionEvaluator&&n.forEach((i,r)=>{this.setupPropBinding(e,i)}))}setupPropBinding(e,t){if(!this.expressionEvaluator)return;const n=`prop_${Date.now()}_${Math.random()}`,i=this.templateRenderer?.dependencies(t.expression,t.component,this.stateManager)||[],r={id:n,selector:"",dependencies:new Set(i),callback:()=>{const a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);a&&(this.updateBatcher.scheduleUpdate(a,e),this.refreshComponentBindings(e,a))},element:e,component:t.component};this.stateManager.addSubscription(r),t.subscriptionIds.push(n)}refreshComponentBindings(e,t){this.contextInvalidated.add(t),this.contextCache.delete(t),this.domBindingManager&&this.domBindingManager.refreshComponentElement(e,t)}evaluateProps(e){const t={},n=this.elementProps.get(e);if(!n||!this.expressionEvaluator)return t;const i=n.values().next().value;if(!i)return t;const r=this.buildComponentContext(i.component);return n.forEach((a,o)=>{try{const c=this.templateRenderer?.render(a.expression,r,a.component);typeof c=="function"?"__pphp_key"in c?t[o]=c:t[o]=(...l)=>c.apply(this,l):t[o]=c}catch(c){console.error(`❌ Failed to evaluate prop "${o}":`,c),t[o]=void 0}}),t}cleanupProps(e){const t=this.elementProps.get(e);t&&(t.forEach(n=>{n.subscriptionIds.forEach(i=>{this.stateManager.removeSubscription(i)})}),this.elementProps.delete(e))}buildComponentContextWithProps(e,t){const n=this.buildComponentContext(e);let i=this.findElementWithProps(e);if(t&&this.elementProps.has(t)&&(i=t),i)try{const r=this.evaluatePropsWithContext(i,e,t);Object.keys(r).length>0&&Object.keys(r).forEach(a=>{n[a]=r[a]})}catch(r){console.error(`❌ Error evaluating props for ${e}:`,r)}return n}evaluatePropsWithContext(e,t,n){const i={},r=this.elementProps.get(e);if(!r||!this.expressionEvaluator)return i;const a=r.values().next().value;if(!a)return i;let o;const c=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);c?c==="app"?o=this.buildComponentContext("app"):o=this.buildComponentContext(c):o=this.buildComponentContext(a.component);const l=this.loopManager?.getLoopContextForElement(e);l&&(o={...o,...l});const p=new Map,h=new Map,f=Array.from(r.keys());r.forEach((m,x)=>{f.some(C=>C!==x&&m.expression.includes(C))?h.set(x,m):p.set(x,m)}),p.forEach((m,x)=>{try{const g=this.templateRenderer?.render(m.expression,o,c||m.component);i[x]=g}catch(g){console.error(`❌ Failed to evaluate simple prop "${x}":`,g),i[x]=void 0}});const E={...o,...i};return h.forEach((m,x)=>{try{const g=this.templateRenderer?.render(m.expression,E,c||m.component);i[x]=g}catch(g){console.error(`❌ Failed to evaluate complex prop "${x}":`,g),i[x]=void 0}}),i}findElementWithProps(e){const t=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const n of t){const i=this.elementProps.get(n);if(i&&i.size>0)return n}return null}pushComponent(e){this.componentStack.push(e)}popComponent(){return this.componentStack.pop()}getCurrentComponent(){return this.componentStack[this.componentStack.length-1]}buildComponentContext(e){if(!this.contextInvalidated.has(e)&&this.contextCache.has(e))return this.contextCache.get(e);const t=this.computeComponentContext(e);return this.contextCache.set(e,t),this.contextInvalidated.delete(e),t}computeComponentContext(e){const t={};if(e.includes("_loop_")||e.match(/_[a-zA-Z0-9]{8}$/)){const r=e.split("_");r.pop();const a=r.join("_");window[a]&&Object.assign(t,window[a])}e!=="app"&&window[e]&&Object.assign(t,window[e]),e==="app"&&window.app&&Object.assign(t,window.app);const n=this.componentFunctions.get(e);if(n)for(const[r,a]of n)t[r]=a;if(e!=="app"){const r=this.componentFunctions.get("app");if(r)for(const[a,o]of r)a in t||(t[a]=o);if(window.app)for(const[a,o]of Object.entries(window.app))a in t||(t[a]=o)}const i=this.stateManager.getState();for(const r of Object.keys(i))if(r.startsWith(e+".")){const a=r.substring(e.length+1);a in t||(t[a]=i[r])}if(e!=="app"){for(const r of Object.keys(i))if(r.startsWith("app.")){const a=r.substring(4);a in t||(t[a]=i[r])}}return t}invalidateContextCache(e){if(e.startsWith("app.")){this.contextCache.clear();for(const n of this.contextInvalidated.keys())this.contextInvalidated.add(n);return}const t=e.indexOf(".");if(t!==-1){const n=e.slice(0,t);this.invalidateComponent(n)}}invalidateComponent(e){this.contextInvalidated.add(e),this.contextIndex.delete(e)}executePhpScripts(e){const t=this.componentStack.length,n=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),i=e===document.body;if(n||i){if(n){this.pushComponent(n);const a=this.getParentComponent(e);this.setupProps(e,a)}this.getRelevantScripts(e,i).forEach(a=>{const o=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);o&&o!==n?(this.pushComponent(o),this.executeScript(a),this.popComponent()):this.executeScript(a)})}for(Array.from(e.children).forEach(r=>this.executePhpScripts(r));this.componentStack.length>t;)this.popComponent()}getParentComponent(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}getRelevantScripts(e,t){return Array.from(e.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`)).filter(n=>{if(this.processedScripts.has(n))return!1;if(t)return n.hasAttribute(d.ATTR_PREFIXES.COMPONENT)?!0:!n.closest(`[${d.ATTR_PREFIXES.COMPONENT}]`);let i=n.parentElement;for(;i&&i!==e;){if(i.hasAttribute(d.ATTR_PREFIXES.COMPONENT))return!1;i=i.parentElement}return i===e||e.contains(n)})}executeScript(e){if(this.processedScripts.has(e))return;this.processedScripts.add(e);const t=this.getCurrentComponent(),n=e.textContent||"",i=N.decodeEntities(n);try{const r=this.findComponentElementForScript(e,t);if(r===e){const c=this.getParentComponent(e);this.setupProps(e,c)}const a=this.hasExplicitContext(r||e,t);let o;if(a)o=this.buildComponentContextWithProps(t,r);else if(o=this.buildRestrictedComponentContext(t,!1),r&&this.hasStoredProps(r)){const c=this.evaluateProps(r);Object.assign(o,c)}window[t]||(window[t]={}),this.executeScriptFunctions(i,t,o)}catch(r){console.error(`Script execution failed in component ${t}:`,r),console.error("Script content:",i)}}hasExplicitContext(e,t){if(e.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;let n=e;for(;n&&n!==document.body;){if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t){if(n.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;break}n=n.parentElement}for(n=e.parentElement;n&&n!==document.body;){if(n.hasAttribute(d.ATTR_PREFIXES.CONTEXT)&&n.getAttribute(d.ATTR_PREFIXES.CONTEXT)==="app")return!0;n=n.parentElement}return!1}findComponentElementForScript(e,t){if(e.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const i=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const r of i)if(this.elementProps.has(r))return r;return i[0]||void 0}executeScriptFunctions(e,t,n){const i=this.extractFunctionNames(e),r=this.findElementWithProps(t),a=this.extractVariableDeclarations(e);let o={...n};if(a.forEach(x=>{delete o[x];const g=`set${jt(x)}`,C=`${x}Getter`;delete o[g],delete o[C]}),r){const x=this.evaluateProps(r);Object.assign(o,x)}o.getContext=()=>this.buildComponentContextWithProps(t),o.withContext=x=>{const g=this.buildComponentContextWithProps(t);return x.call(g,g)},o.__getProp=x=>{if(r)return this.evaluateProps(r)[x]};const c=Z.getInstance(),l=new Set;if(r){const x=this.evaluateProps(r);for(const[g,C]of Object.entries(x))typeof C=="function"&&"__pphp_key"in C&&(l.add(g),/^set[A-Z]/.test(g)&&l.add(g))}let p=c.transformStateDeclarations(e,l);p=this.modifyScriptForReactiveProps(p,t,r||void 0);const h=`
|
|
17
17
|
${p}
|
|
18
18
|
|
|
19
|
-
${i.map(
|
|
20
|
-
if (typeof ${
|
|
21
|
-
this['${
|
|
19
|
+
${i.map(x=>`
|
|
20
|
+
if (typeof ${x} === 'function') {
|
|
21
|
+
this['${x}'] = ${x};
|
|
22
22
|
}
|
|
23
23
|
`).join(`
|
|
24
24
|
`)}
|
|
25
|
-
`,f=Object.keys(o),
|
|
26
|
-
`,i),c=o===-1?r:o;n+=e.slice(i,c),i=c;continue}else if(e[i+1]==="*"){const o=e.indexOf("*/",i+2),c=o===-1?r:o+2;n+=e.slice(i,c),i=c;continue}}this.matchesPropName(e,i,t)?(n+=`__getProp('${t}')`,i+=t.length):(n+=a,i++)}return n}findStringEnd(e,t,n){let i=t+1;for(;i<e.length;){if(e[i]===n&&e[i-1]!=="\\")return i;e[i]==="\\"&&i++,i++}return e.length-1}findTemplateEnd(e,t){let n=t+1,i=0;for(;n<e.length;){const r=e[n];if(r==="`"&&i===0)return n;r==="$"&&n+1<e.length&&e[n+1]==="{"?(i++,n++):r==="}"&&i>0?i--:r==="\\"&&n++,n++}return e.length-1}matchesPropName(e,t,n){if(t+n.length>e.length||e.substr(t,n.length)!==n)return!1;const r=t>0?e[t-1]:"",a=t+n.length<e.length?e[t+n.length]:"",o=t===0||!/[a-zA-Z0-9_$]/.test(r),c=t+n.length===e.length||!/[a-zA-Z0-9_$]/.test(a);if(!o||!c||r==="."||a===".")return!1;const l=e.slice(t+n.length);if(/^\s*[=:]/.test(l))return!1;const p=e.slice(Math.max(0,t-20),t);return!/[a-zA-Z0-9_$]\s*\.\s*$/.test(p)}extractFunctionNames(e){return Z.getInstance().extractFunctionNames(e)}storeFunctionForComponent(e,t,n){this.componentFunctions.has(e)||this.componentFunctions.set(e,new Map),this.componentFunctions.get(e).set(t,n),window[e]||(window[e]={}),window[e][t]=n}getComponentFunctions(e){return this.componentFunctions.get(e)}destroy(){if(this.updateTimeouts){for(const e of this.updateTimeouts.values())clearTimeout(e);this.updateTimeouts.clear()}this.componentFunctions.clear(),this.elementProps=new WeakMap,this.contextCache.clear(),this.propDependencyCache.clear()}}class Bs{stateManager;componentManager;expressionEvaluator;textNodeManager;observer;listeners=new WeakMap;pendingBindings=[];pendingTextNodes=[];applyingUpdates=!1;elementCache=new WeakMap;batchedUpdates=new Set;processingRAF=null;updateQueue=new Map;eventDelegation=new ce;processedElements=new WeakSet;loopManager;templateRenderer;BOOL_REFLECTED={checked:"checked",disabled:"disabled",hidden:"hidden",readonly:"readOnly",required:"required",multiple:"multiple",selected:"selected",autofocus:"autofocus",autoplay:"autoplay",controls:"controls",defer:"defer",loop:"loop",muted:"muted",open:"open",reversed:"reversed",async:"async",default:"default",formnovalidate:"formNoValidate",novalidate:"noValidate",allowfullscreen:"allowFullscreen",capture:"capture",itemscope:"itemScope"};lastValueCache=new WeakMap;stringValueCache=new z(500);refBindings=new WeakMap;constructor(e,t,n){this.stateManager=e,this.componentManager=t,this.expressionEvaluator=n,this.textNodeManager=new Rs(n,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new Wt(e,n),this.loopManager.setDependencies(t,this),this.loopManager.eventDelegation=this.eventDelegation,this.eventDelegation.setDependencies(this.componentManager,this.expressionEvaluator,this.stateManager,this.loopManager),this.templateRenderer=new Je(n)}refreshComponentElement(e,t){this.elementCache.delete(e),this.processedElements.delete(e);const n=[...this.componentManager.componentStack];this.componentManager.componentStack=["app"],t!=="app"&&this.componentManager.componentStack.push(t);try{const i=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(e,i,t,!0),this.walkComponentChildren(e,t),this.refreshComponentTextNodes(e,t)}finally{this.componentManager.componentStack=n}}refreshComponentTextNodes(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:a=>{const o=a;return!o.textContent||!d.MUSTACHE_PATTERN.test(o.textContent)||S.isTextNodeInsideScript(o)||this.isTextNodeInsideLoopItem(o)||S.getComponentForNode(o)!==t?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let i;const r=[];for(;i=n.nextNode();)r.push(i);r.forEach(a=>{this.textNodeManager.cleanupTextNode(a),this.textNodeManager.cleanupTextNode(a),this.textNodeManager.processTextNode(a,t)})}walkComponentChildren(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return S.getElementComponent(o)!==t?NodeFilter.FILTER_REJECT:o===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});let i;const r=[];for(;i=n.nextNode();){const a=i;r.push(a)}r.forEach(a=>{this.elementCache.delete(a),this.processedElements.delete(a);const o=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(a,o,t,!0)})}createSpreadDirectiveBinding(e,t,n){const i=`spread_${Date.now()}_${Math.random()}`,r=N.parseSpreadDirective(t);if(r.spreads.length===0&&r.objects.length===0){console.warn(`Invalid pp-spread directive: ${t}`);return}const a=new Set,o=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(i);return}try{const p=this.componentManager.buildComponentContextWithProps(n,e);this.clearSpreadAttributes(e,a);for(const h of r.spreads){const f=this.expressionEvaluator.evaluateExpression(h,p,n);f&&typeof f=="object"&&this.applySpreadObject(e,f,a)}for(const h of r.objects)this.applyObjectProperties(e,h,p,n,a)}catch(p){console.error(`Spread directive evaluation error for "${t}":`,p)}},c=new Set;for(const p of r.spreads)this.templateRenderer.dependencies(p,n,this.stateManager).forEach(f=>c.add(f));for(const p of r.objects)for(const h of p)this.templateRenderer.dependencies(h.value,n,this.stateManager).forEach(x=>c.add(x));const l={id:i,selector:"",dependencies:c,callback:o,element:e,component:n};this.stateManager.addSubscription(l),this.storeSpreadSubscription(e,i),o()}applyObjectProperties(e,t,n,i,r){for(const a of t)try{const o=this.expressionEvaluator.evaluateExpression(a.value,n,i);if(this.isEventProperty(a.key)){this.handleSpreadEventProperty(e,a.key,o);continue}const c=this.normalizeAttributeName(a.key);this.updateElementProperty(e,c,o),r.add(c)}catch(o){console.error(`Error evaluating object property "${a.key}: ${a.value}":`,o)}}applySpreadObject(e,t,n){for(const[i,r]of Object.entries(t))if(r!=null){if(this.isEventProperty(i)){this.handleSpreadEventProperty(e,i,r);continue}const a=this.normalizeAttributeName(i);(!e.hasAttribute(a)||n.has(a))&&(this.updateElementProperty(e,a,r),n.add(a))}}isEventProperty(e){return e.startsWith("on")&&e.length>2}handleSpreadEventProperty(e,t,n){const i=t.substring(2).toLowerCase();if(typeof n=="function"){const r=a=>{try{const o=S.getContextComponent(e),c=this.componentManager?.buildComponentContextWithProps(o,e)||{};n.call(c,a)}catch(o){console.error("Spread event handler error:",o)}};e.addEventListener(i,r),this.storeDirectEventListener(e,i,r);return}if(typeof n=="string"){const r=S.getContextComponent(e);this.eventDelegation.registerEventHandler(e,i,n,r)}}storeDirectEventListener(e,t,n){e.__directEventListeners||(e.__directEventListeners=[]),e.__directEventListeners.push({eventType:t,listener:n})}clearSpreadAttributes(e,t){for(const n of t)e.hasAttribute(n)&&e.removeAttribute(n);t.clear()}normalizeAttributeName(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}storeSpreadSubscription(e,t){e.__spreadSubscriptions||(e.__spreadSubscriptions=[]),e.__spreadSubscriptions.push(t)}setupMutationObserver(){this.observer=new MutationObserver(e=>{const t=e.filter(this.isRelevantMutation);if(t.length===0)return;const n=B.getInstance();for(const i of t)if(i.type==="childList"&&(i.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const a=r;this.cleanupRefBinding(a),a.querySelectorAll("[pp-ref]").forEach(l=>{this.cleanupRefBinding(l)}),n.invalidateElement(a);const c=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);c&&n.invalidateByComponent(c)}}),i.addedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const o=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);o&&n.invalidateByComponent(o)}})),i.type==="attributes"&&i.target){const r=i.target;n.invalidateElement(r);const a=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);a&&n.invalidateByComponent(a)}this.processMutationsBatch(t)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,attributeFilter:[d.ATTR_PREFIXES.COMPONENT]})}isRelevantMutation=e=>{if(this.applyingUpdates&&e.type==="attributes")return!1;if(e.type==="childList"||e.type==="characterData")return!0;if(e.type==="attributes"){const t=e.attributeName;return t===d.ATTR_PREFIXES.COMPONENT||t!==null&&de.isEventAttribute(t)}return!1};processElement(e,t=!0){if(e===document.body){const i=Array.from(document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`)).sort((r,a)=>{const o=S.getElementDepth(r),c=S.getElementDepth(a);return o-c});this.processElementsBatch([e],t),i.forEach(r=>{this.processElementsBatch([r],t)}),t&&this.loopManager.processPendingTemplates()}else this.processElementsBatch([e],t)}processElementsBatch(e,t=!0){for(const n of e)this.processSingleElement(n,t);t&&(e.forEach(n=>{this.componentManager.executePhpScripts(n)}),this.processPendingBindings())}processSingleElement(e,t){const n=S.getElementComponent(e),i=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let r;i?i==="app"?r="app":i==="parent"?r=S.getParentOfComponent(n,e):r=i:r=S.getParentComponentForElement(e);const a=this.componentManager.componentStack.length;n!=="app"&&this.componentManager.pushComponent(n),this.componentManager.setupProps(e,r),t&&this.componentManager.executePhpScripts(e),this.processLoopTemplates(e,n);const o=t?this.componentManager.buildComponentContextWithProps(n,e):{};for(this.processElementInContext(e,o,n,t),this.walkDOM(e,o,n,t);this.componentManager.componentStack.length>a;)this.componentManager.popComponent()}processLoopTemplates(e,t){this.getDirectComponentTemplates(e,t).forEach(i=>{this.loopManager.queueTemplate(i,t)})}getDirectComponentTemplates(e,t){const n=[],i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return o!==e&&o.hasAttribute(d.ATTR_PREFIXES.COMPONENT)?NodeFilter.FILTER_REJECT:o.tagName==="TEMPLATE"&&o.hasAttribute("pp-for")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let r;for(;r=i.nextNode();)n.push(r);return n}walkDOM(e,t,n,i){const r=fe.getInstance(),a=`walkDOM_${n}_${i}`,o=r.getCachedTraversal(e,a,()=>{const p=r.traverseElementsAndText(e,h=>{if(h===e||h.tagName.toLowerCase()==="script"||this.loopManager.isLoopItem(h))return!1;let f=h.parentElement;for(;f&&f!==e;){if(this.loopManager.isLoopItem(f))return!1;f=f.parentElement}return!(S.getElementComponent(h)!==n||this.processedElements.has(h))},h=>{if(!h.textContent||!d.MUSTACHE_PATTERN.test(h.textContent)||S.isTextNodeInsideScript(h)||this.isTextNodeInsideLoopItem(h))return!1;const f=h.parentElement;if(f){const x=S.getContextComponent(f),b=S.getComponentForNode(h);if(x!==n&&b!==n)return!1}else if(S.getComponentForNode(h)!==n)return!1;return!0});return[...p.textNodes,...p.elements]}),c=[],l=[];o.forEach(p=>{if(p.nodeType===Node.TEXT_NODE)c.push(p);else if(p.nodeType===Node.ELEMENT_NODE){const h=p;if(h.hasAttribute("pp-ref")&&i){const f=h.getAttribute("pp-ref");this.createRefBinding(h,f,n),h.removeAttribute("pp-ref")}l.push(h),this.processedElements.add(h)}}),c.forEach(p=>{const h=p.parentElement,f=h?S.getContextComponent(h):n;i?this.textNodeManager.processTextNode(p,f):this.pendingTextNodes.push({textNode:p,component:f})}),l.forEach(p=>{this.processElementInContext(p,t,n,i)})}isTextNodeInsideLoopItem(e){let t=e.parentElement;for(;t&&t!==document.body;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}processElementInContext(e,t,n,i){if(e.hasAttribute("pp-ref")){const l=e.getAttribute("pp-ref");i&&this.createRefBinding(e,l,n),e.removeAttribute("pp-ref")}if(e.hasAttribute(d.ATTR_PREFIXES.SPREAD)){const l=e.getAttribute(d.ATTR_PREFIXES.SPREAD);i&&this.createSpreadDirectiveBinding(e,l,n),e.removeAttribute(d.ATTR_PREFIXES.SPREAD)}if(this.loopManager.isLoopItem(e)||this.isElementInLoopItem(e))return;const r=this.extractDomMustacheBindings(e),a=this.elementCache.get(e),o=this.getElementHash(e);if(a&&a.hash===o&&this.isCacheValid(a)&&i){this.applyBindingsFromCache(e,a,t);return}const c={bindings:r,component:n,listeners:[],lastProcessed:Date.now(),hash:o};i?this.applyBindings(e,r,t,n):r.forEach((l,p)=>{this.pendingBindings.push({element:e,property:p,expression:l,component:n})}),this.setupEventBindings(e,n),this.elementCache.set(e,c)}createRefBinding(e,t,n){try{const i=N.decodeEntities(t),r=N.isSingleExpression(i)||i,a=S.getContextComponent(e),o=this.componentManager.buildComponentContextWithProps(a,e);try{const c=this.expressionEvaluator.evaluateExpression(r,o,a);if(typeof c=="function"){const l=c;this.refBindings.set(e,{element:e,callback:l,component:a}),l(e)}else if(c&&typeof c=="object"&&"current"in c){const l=c;this.refBindings.set(e,{element:e,refObject:l,component:a}),l.current=e}else console.warn(`⚠️ pp-ref expression did not return a ref object or callback: ${r}`,c)}catch(c){console.error(`❌ Failed to evaluate ref "${r}":`,c)}}catch(i){console.error(`❌ Failed to create ref binding for "${t}":`,i)}}isElementInLoopItem(e){let t=e;for(;t;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}extractDomMustacheBindings(e){const t=new Map,n=e.attributes,i=this.elementCache.get(e),r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),o=a&&this.componentManager?.hasStoredProps(e),c=r&&a&&r!==a;for(let l=0;l<n.length;l++){const p=n[l];if(!(p.name===d.ATTR_PREFIXES.COMPONENT||p.name===d.ATTR_PREFIXES.CONTEXT||p.name==="key"||de.isEventAttribute(p.name))&&!(i&&i.bindings.has(p.name))&&p.value){const h=d.MUSTACHE_PATTERN.test(p.value),f=N.decodeEntities(p.value),x=d.MUSTACHE_PATTERN.test(f);if(h||x){if(this.looksLikeSerializedObject(f))continue;const b=N.extractExpressions(f),g=S.getContextComponent(e);if(b.length===0&&(h||x)){console.error(`
|
|
27
|
-
❌ Malformed mustache expression in attribute "${p.name}":`),console.error(` Value: ${f}`),console.error(" Element:",e),console.error(` Component: ${
|
|
28
|
-
`),o||c&&
|
|
29
|
-
❌ Invalid expression in attribute "${p.name}":`),console.error(` Expression: ${
|
|
30
|
-
`)),
|
|
31
|
-
⚠️ Expression warnings in attribute "${p.name}":`),console.warn(` Expression: ${m}`),console.warn(" Element:",e),E.warnings.forEach(A=>{console.warn(` • ${A}`)}))}o||c&&S.shouldBeDirectBinding(e,p.name)?t.set(p.name,f):c||t.set(p.name,f)}}}return t}applyBindings(e,t,n,i){t.forEach((r,a)=>{this.createMustacheBinding(e,a,r)}),this.setupEventBindings(e,i)}applyBindingsFromCache(e,t,n){t.bindings.forEach((i,r)=>{try{const a=this.componentManager.buildComponentContextWithProps(t.component,e),o=this.templateRenderer.render(i,a,t.component);this.updateElementProperty(e,r,o)}catch(a){console.error(`Cached binding evaluation error for "${i}":`,a)}})}createMustacheBinding(e,t,n){const i=`mustache_${Date.now()}_${Math.random()}`;let r;const a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),o=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);if(a&&this.componentManager?.hasStoredProps(e)){const x=this.componentManager.elementProps.get(e);(x?Array.from(x.keys()):[]).some(m=>n.includes(m))?r=a:r=S.getContextComponent(e)}else r=S.getContextComponent(e);e.removeAttribute(t);const c=new Set;this.templateRenderer.dependencies(n,r,this.stateManager).forEach(x=>c.add(x));const p=this.findComponentElementForMustacheBinding(e,r);p&&this.componentManager&&this.componentManager.getComponentPropDependencies(p,r).forEach(b=>c.add(b));const h=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(i);return}try{const x=o!==null||this.hasInheritedContextForElement(e,r);let b;if(x){const m=r===a?e:p||void 0;b=this.componentManager.buildComponentContextWithProps(r,m)}else if(b=this.componentManager.buildRestrictedComponentContext(r,!1),p&&this.componentManager){const m=this.componentManager.evaluateProps(p);Object.assign(b,m)}const g=this.templateRenderer.render(n,b,r);this.scheduleElementUpdate(e,t,g)}catch(x){console.error(`Mustache binding evaluation error for "${n}":`,x)}},f={id:i,selector:"",dependencies:c,callback:h,element:e,component:r};this.stateManager.addSubscription(f),h()}hasInheritedContextForElement(e,t){let n=e;for(;n&&n!==document.body;){if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t){if(n.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;break}n=n.parentElement}for(n=e.parentElement;n&&n!==document.body;){const i=n.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i&&i!==t&&n.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;n=n.parentElement}return!1}findComponentElementForMustacheBinding(e,t){if(e.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return e;let i=e.parentElement;for(;i;){if(i.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return i;i=i.parentElement}const r=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const a of r)if(this.componentManager&&this.componentManager.hasStoredProps(a))return a;return r[0]||null}setupEventBindings(e,t){for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n];if(de.isEventAttribute(i.name)){const r=i.name.substring(2),a=S.getContextComponent(e);this.eventDelegation.registerEventHandler(e,r,i.value,a),e.removeAttribute(i.name)}}}scheduleElementUpdate(e,t,n){if(this.isCriticalProperty(t)){this.updateElementProperty(e,t,n);return}this.updateQueue.has(e)||(this.updateQueue.set(e,new Set),this.batchedUpdates.add(e)),this.updateQueue.get(e).add(t),this.processingRAF||(this.processingRAF=requestAnimationFrame(()=>{this.processBatchedElementUpdates()})),e[`__pending_${t}`]=n}isCriticalProperty(e){return["textContent","innerHTML","value","checked","selected","disabled","class","className","style","hidden","display"].includes(e)}processBatchedElementUpdates(){this.applyingUpdates=!0;try{for(const e of this.batchedUpdates){const t=this.updateQueue.get(e);if(t)for(const n of t){const i=e[`__pending_${n}`];this.updateElementProperty(e,n,i),delete e[`__pending_${n}`]}}}finally{this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF=null,this.applyingUpdates=!1}}updateElementProperty(e,t,n){const i=He(n),r=this.lastValueCache.get(e);if(r&&this.isSameValue(r.get(t),i))return;const a=this.applyingUpdates;this.applyingUpdates=!0;try{switch(t){case"textContent":const o=this.cachedValueToString(i);e.textContent!==o&&(e.textContent=o);break;case"innerHTML":const c=this.cachedValueToString(i);e.innerHTML!==c&&(e.innerHTML=c);break;case"value":const l=this.cachedValueToString(i);e instanceof HTMLOptionElement?e.value!==l&&(e.value=l,e.setAttribute("value",l)):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.value!==l&&(e.value=l);break;case"selectedIndex":if(e instanceof HTMLSelectElement){const h=Number(i);e.selectedIndex!==h&&(e.selectedIndex=h)}break;case"checked":case"disabled":case"hidden":case"readonly":case"required":case"multiple":case"selected":case"autofocus":case"autoplay":case"controls":case"defer":case"loop":case"muted":case"open":case"reversed":case"async":case"default":case"formnovalidate":case"novalidate":case"allowfullscreen":case"capture":case"itemscope":this.setBooleanProperty(e,t,i);break;case"indeterminate":if(e instanceof HTMLInputElement&&e.type==="checkbox"){const h=!!i;e.indeterminate!==h&&(e.indeterminate=h)}break;case"class":case"className":const p=this.cachedValueToString(i);e instanceof SVGElement?e.getAttribute("class")!==p&&e.setAttribute("class",p):e.className!==p&&(e.className=p);break;case"htmlFor":case"for":if(e instanceof HTMLLabelElement){const h=this.cachedValueToString(i);e.htmlFor!==h&&(e.htmlFor=h)}break;case"style":if(e instanceof HTMLElement)if(typeof i=="object"&&i&&!Array.isArray(i))this.updateStyleObject(e,i);else{const h=this.cachedValueToString(i);e.style.cssText!==h&&(e.style.cssText=h)}break;case"tabIndex":if(e instanceof HTMLElement){const h=i==null?-1:Number(i);e.tabIndex!==h&&(e.tabIndex=h)}break;case"contentEditable":if(e instanceof HTMLElement){const h=i===!0?"true":i===!1?"false":String(i);e.contentEditable!==h&&(e.contentEditable=h)}break;case"draggable":if(e instanceof HTMLElement){const h=i===!0,f=h?"true":"false";e.draggable!==h&&(e.draggable=h,e.setAttribute("draggable",f))}break;case"spellcheck":if(e instanceof HTMLElement){const h=!!i,f=h?"true":"false";e.spellcheck!==h&&(e.spellcheck=h,e.setAttribute("spellcheck",f))}break;case"src":case"href":case"action":case"alt":case"title":case"placeholder":case"id":case"name":case"type":case"method":case"target":case"rel":case"pattern":case"accept":case"autocomplete":case"enctype":case"wrap":case"download":case"ping":case"referrerpolicy":case"crossorigin":case"integrity":case"loading":case"decoding":case"srcset":case"sizes":case"dir":case"lang":case"translate":case"role":this.setStringAttribute(e,t,i);break;case"min":case"max":case"step":case"maxLength":case"minLength":case"size":case"rows":case"cols":case"rowSpan":case"colSpan":this.setNumericAttribute(e,t,i);break;default:t.startsWith("aria-")?this.setAriaAttribute(e,t,i):t.startsWith("data-")?this.setDataAttribute(e,t,i):this.setGenericAttribute(e,t,i);break}this.updateValueCache(e,t,i)}catch(o){console.error(`Failed to update property "${t}" on element:`,e,o)}finally{this.applyingUpdates=a}}looksLikeSerializedObject(e){if(!e.startsWith("{")||!e.endsWith("}"))return!1;try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}catch{return!1}}cachedValueToString(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(e==null)return"";if(typeof e=="boolean")return e?"true":"false";if(this.stringValueCache.has(e))return this.stringValueCache.get(e);const t=ue(e);return this.stringValueCache.set(e,t),t}isSameValue(e,t){if(e===t)return!0;if(typeof e=="object"&&typeof t=="object"){if(e===null||t===null)return e===t;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,i)=>n===t[i]);if(this.isStyleObject(e)&&this.isStyleObject(t)){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every(r=>e[r]===t[r])}}return!1}isStyleObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}setBooleanProperty(e,t,n){const i=!!n;this.setBooleanProp(e,t,n)||(i&&!e.hasAttribute(t)?e.setAttribute(t,""):!i&&e.hasAttribute(t)&&e.removeAttribute(t))}updateStyleObject(e,t){const n=this.lastValueCache.get(e)?.get("style"),i=n&&typeof n=="object"?n:{};for(const[r,a]of Object.entries(t))i[r]!==a&&(e.style[r]=a)}setStringAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null?e.removeAttribute(t):e.setAttribute(t,i))}setNumericAttribute(e,t,n){const i=String(n);e.getAttribute(t)!==i&&(n==null?e.removeAttribute(t):e.setAttribute(t,i))}setAriaAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null||n===!1?e.removeAttribute(t):e.setAttribute(t,i))}setDataAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null?e.removeAttribute(t):e.setAttribute(t,i))}setGenericAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null||n===!1?e.removeAttribute(t):e.setAttribute(t,i))}updateValueCache(e,t,n){this.lastValueCache.has(e)||this.lastValueCache.set(e,new Map),this.lastValueCache.get(e).set(t,n)}setBooleanProp(e,t,n){const i=this.BOOL_REFLECTED[t];if(!i)return!1;const r=!!n;return e instanceof HTMLElement&&i in e?(e[i]!==r&&(e[i]=r),!0):(r?e.hasAttribute(t)||e.setAttribute(t,""):e.hasAttribute(t)&&e.removeAttribute(t),!0)}processPendingBindings(){const e=[...this.pendingBindings];this.pendingBindings=[];const t=new Map;for(const n of e)t.has(n.component)||t.set(n.component,[]),t.get(n.component).push(n);for(const[n,i]of t){const r=[...this.componentManager.componentStack];n!=="app"?this.componentManager.componentStack=["app",n]:this.componentManager.componentStack=["app"];for(const a of i)try{if(!document.contains(a.element))continue;this.createMustacheBinding(a.element,a.property,a.expression)}catch(o){console.error(`❌ Failed to create binding for ${n}:`,o)}this.componentManager.componentStack=r}this.processTextNodesPending()}processTextNodesPending(){const e=new Map;for(const t of this.pendingTextNodes)e.has(t.component)||e.set(t.component,[]),e.get(t.component).push(t);this.pendingTextNodes=[];for(const[t,n]of e){const i=[...this.componentManager.componentStack];t!=="app"?this.componentManager.componentStack=["app",t]:this.componentManager.componentStack=["app"];for(const{textNode:r,component:a}of n)if(document.contains(r))try{this.textNodeManager.processTextNode(r,a)}catch(o){console.error(`❌ Failed to process text node for ${a}:`,o)}this.componentManager.componentStack=i}}processMutationsBatch(e){const t=new Set,n=new Set,i=new Set,r=new Set,a=new Set;for(const o of e)if(o.type==="childList"&&(o.addedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)t.add(c);else if(c.nodeType===Node.TEXT_NODE){const l=c;l.textContent&&d.MUSTACHE_PATTERN.test(l.textContent)&&a.add(l)}}),o.removedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)n.add(c);else if(c.nodeType===Node.TEXT_NODE){const l=c;l.textContent&&d.MUSTACHE_PATTERN.test(l.textContent)&&(document.contains(l)||this.textNodeManager.cleanupTextNode(l))}})),o.type==="attributes"&&o.target&&r.add(o.target),o.type==="characterData"&&o.target){const c=o.target;c.textContent&&d.MUSTACHE_PATTERN.test(c.textContent)&&a.add(c)}for(const o of n)(t.has(o)||document.contains(o))&&(i.add(o),n.delete(o),t.has(o)&&t.delete(o));n.size>0&&this.cleanupElementsBatch(Array.from(n)),t.size>0&&this.processElementsBatch(Array.from(t)),a.size>0&&this.processTextNodesBatch(Array.from(a)),r.size>0&&this.rebindChangedElements(Array.from(r))}processTextNodesBatch(e){const t=new Map;for(const n of e){const i=S.getComponentForNode(n);t.has(i)||t.set(i,[]),t.get(i).push(n)}for(const[n,i]of t)i.forEach(r=>{this.textNodeManager.processTextNode(r,n)})}rebindChangedElements(e){e.forEach(t=>{this.processElementBindings(t,!0)})}processElementBindings(e,t=!0){const n=this.extractDomMustacheBindings(e),i=S.getElementComponent(e);n.forEach((r,a)=>{t?this.createMustacheBinding(e,a,r):this.pendingBindings.push({element:e,property:a,expression:r,component:i})}),t&&this.setupEventBindings(e,i)}cleanupElementsBatch(e){e.forEach(t=>this.cleanupElement(t))}cleanupElement(e){this.cleanupRefBinding(e),this.stateManager.subscriptionManager?.cleanupElement(e);const t=this.listeners.get(e)||[];for(const{type:l,fn:p}of t)e.removeEventListener(l,p);this.listeners.delete(e),this.elementCache.delete(e),this.processedElements.delete(e),this.componentManager.cleanupProps(e);const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let i;for(;i=n.nextNode();)this.textNodeManager.cleanupTextNode(i);e.tagName==="TEMPLATE"&&e.hasAttribute("pp-for")&&this.loopManager.cleanupTemplate(e),e.querySelectorAll("template[pp-for]").forEach(l=>{this.loopManager.cleanupTemplate(l)});const a=e.__directEventListeners;a&&(a.forEach(({eventType:l,listener:p})=>{e.removeEventListener(l,p)}),delete e.__directEventListeners);const o=e.__spreadEventHandlers;o&&(o.forEach(l=>{window.__spreadHandlers&&window.__spreadHandlers.delete(l)}),delete e.__spreadEventHandlers);const c=e.__spreadSubscriptions;c&&(c.forEach(l=>{this.stateManager.removeSubscription(l)}),delete e.__spreadSubscriptions),this.lastValueCache.delete(e),this.stringValueCache.size()>1500&&this.stringValueCache.clear()}cleanupRefBinding(e){const t=this.refBindings.get(e);if(t){try{t.callback?t.callback(null):t.refObject&&(t.refObject.current=null)}catch(n){console.error("Failed to cleanup ref:",n)}this.refBindings.delete(e)}}getElementHash(e){const t=[];for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n];(i.name===d.ATTR_PREFIXES.COMPONENT||de.isEventAttribute(i.name)||i.value&&d.MUSTACHE_PATTERN.test(i.value))&&t.push(`${i.name}=${i.value}`)}return t.sort().join("|")}isCacheValid(e){return Date.now()-e.lastProcessed<3e4}refreshAllBindings(){this.elementCache=new WeakMap,this.processedElements=new WeakSet,this.processElement(document.body,!0)}destroy(){this.observer&&this.observer.disconnect(),document.querySelectorAll("[pp-ref]").forEach(t=>{this.cleanupRefBinding(t)}),this.eventDelegation.cleanup(),this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF&&cancelAnimationFrame(this.processingRAF),this.elementCache=new WeakMap,this.listeners=new WeakMap,this.processedElements=new WeakSet,this.loopManager.destroy()}}class ce{static eventCache=null;delegatedEvents=new Map;elementHandlers=new WeakMap;handlerCache=new z(200);componentManager;expressionEvaluator;loopManager;setupEvents=new Set;stateManager;static getAllAvailableEvents(){if(ce.eventCache)return ce.eventCache;const e=new Set,t=["click","input","change","submit","focus","blur","keydown","keyup","mousedown","mouseup","mouseover","mouseout"];try{Object.getOwnPropertyNames(HTMLElement.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get HTMLElement events:",i),t.forEach(r=>e.add(r))}try{Object.getOwnPropertyNames(Document.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get Document events:",i)}try{Object.getOwnPropertyNames(Window.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get Window events:",i)}try{Object.getOwnPropertyNames(Element.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get Element events:",i)}return new Set(["beforeunload","unload","pagehide","pageshow","popstate","hashchange","storage","message","messageerror","offline","online","languagechange","rejectionhandled","unhandledrejection","afterprint","beforeprint","devicemotion","deviceorientation","deviceorientationabsolute"]).forEach(i=>e.delete(i)),ce.eventCache=e,e}setupEventDelegation(){const e=["click","input","change","submit","focus","blur"];for(const t of e)this.ensureEventSetup(t)}getEventOptions(e){const t={capture:!0,passive:!1};return["wheel","touchstart","touchmove","touchend","scroll","mousewheel"].includes(e)&&(t.passive=!0),(e==="focusin"||e==="focusout")&&(t.capture=!1),t}isEventSupported(e){return ce.getAllAvailableEvents().has(e.toLowerCase())}getAllSupportedEvents(){return Array.from(ce.getAllAvailableEvents()).sort()}getDelegatedEvents(){return Array.from(this.delegatedEvents.keys()).sort()}setDependencies(e,t,n,i){this.componentManager=e,this.expressionEvaluator=t,this.stateManager=n,this.loopManager=i}createDelegatedListener(e){return t=>{const n=t.target;if(!n)return;const i=this.findHandler(n,e);i&&this.executeHandler(i.handler,i.element,t)}}registerEventHandler(e,t,n,i){const r=t.toLowerCase();if(this.ensureEventSetup(r),!this.isEventSupported(r)){console.warn(`⚠️ Event type "${t}" is not supported`);return}const a=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let o=i;if(a)if(a==="app")o="app";else if(a==="parent"){const h=S.getElementComponent(e);o=S.getParentOfComponent(h,e)}else o=a;this.elementHandlers.has(e)||this.elementHandlers.set(e,new Map);const c=this.elementHandlers.get(e),l={code:n,component:o};c.set(r,l);const p=this.delegatedEvents.get(r);p?p.elements.add(e):(console.warn(`⚠️ No delegated listener for ${r}, attaching directly`),this.attachDirectListener(e,r,l))}ensureEventSetup(e){if(!this.setupEvents.has(e)){if(!this.isEventSupported(e)){console.warn(`⚠️ Attempting to setup unsupported event: ${e}`);return}try{const t=this.createDelegatedListener(e),n=this.getEventOptions(e);document.addEventListener(e,t,n),this.setupEvents.add(e),this.delegatedEvents.set(e,{listener:t,elements:new WeakSet})}catch(t){console.error(`Failed to setup event delegation for ${e}:`,t),this.setupEvents.delete(e)}}}findHandler(e,t){let n=e;for(;n;){const i=this.elementHandlers.get(n);if(i?.has(t))return{handler:i.get(t),element:n};n=n.parentElement}return null}compileHandler(e,t){const n=`${t}:${e}`;if(this.handlerCache.has(n))return this.handlerCache.get(n);let i=e;e.includes("this")&&(i=i.replace(/\bthis\b/g,"thisElement")),e.includes("event")&&(i=i.replace(/\bevent\b/g,"eventObject"));const r=new Function("eventObject","thisElement","context",`
|
|
25
|
+
`,f=Object.keys(o),E=f.map(x=>o[x]);if(this.checkIfInLoopItem()){const x=this.extractLoopItemContext();this.domBindingManager.stateManager.currentLoopContext=x}try{new Function(...f,h).call(window[t],...E),window[t].getContext=o.getContext,window[t].withContext=o.withContext,window[t].__getProp=o.__getProp;for(const g of i){const C=window[t][g];typeof C=="function"&&this.storeFunctionForComponent(t,g,C)}this.invalidateComponent(t)}catch(x){console.error("Script execution failed:",x),console.error("Component:",t),console.error("Original script:",e),console.error("Processed script:",p),console.error("Execution context keys:",Object.keys(o))}finally{this.domBindingManager.stateManager.currentLoopContext=null}}checkIfInLoopItem(){return!1}extractLoopItemContext(){return{}}extractVariableDeclarations(e){const i=Z.getInstance().extractStateDeclarations(e).map(l=>l.variableName),r=[],a=/(?:const|let|var)\s*\[\s*([^,\]]+)(?:\s*,\s*([^,\]]+))?\s*\]/g;let o;for(;(o=a.exec(e))!==null;)o[1]&&!i.includes(o[1].trim())&&r.push(o[1].trim()),o[2]&&!i.includes(o[2].trim())&&r.push(o[2].trim());const c=/(?:const|let|var)\s+([a-zA-Z_$][\w$]*)/g;for(;(o=c.exec(e))!==null;)i.includes(o[1])||r.push(o[1]);return[...i,...r]}modifyScriptForReactiveProps(e,t,n){if(!n||!this.elementProps.has(n))return e;const i=this.elementProps.get(n),r=Array.from(i.keys());let a=e;return r.forEach(o=>{a=this.replacePropOutsideStrings(a,o)}),a}replacePropOutsideStrings(e,t){let n="",i=0;const r=e.length;for(;i<r;){const a=e[i];if(a==="'"){const o=this.findStringEnd(e,i,"'");n+=e.slice(i,o+1),i=o+1;continue}if(a==='"'){const o=this.findStringEnd(e,i,'"');n+=e.slice(i,o+1),i=o+1;continue}if(a==="`"){const o=this.findTemplateEnd(e,i);n+=e.slice(i,o+1),i=o+1;continue}if(a==="/"&&i+1<r){if(e[i+1]==="/"){const o=e.indexOf(`
|
|
26
|
+
`,i),c=o===-1?r:o;n+=e.slice(i,c),i=c;continue}else if(e[i+1]==="*"){const o=e.indexOf("*/",i+2),c=o===-1?r:o+2;n+=e.slice(i,c),i=c;continue}}this.matchesPropName(e,i,t)?(n+=`__getProp('${t}')`,i+=t.length):(n+=a,i++)}return n}findStringEnd(e,t,n){let i=t+1;for(;i<e.length;){if(e[i]===n&&e[i-1]!=="\\")return i;e[i]==="\\"&&i++,i++}return e.length-1}findTemplateEnd(e,t){let n=t+1,i=0;for(;n<e.length;){const r=e[n];if(r==="`"&&i===0)return n;r==="$"&&n+1<e.length&&e[n+1]==="{"?(i++,n++):r==="}"&&i>0?i--:r==="\\"&&n++,n++}return e.length-1}matchesPropName(e,t,n){if(t+n.length>e.length||e.substr(t,n.length)!==n)return!1;const r=t>0?e[t-1]:"",a=t+n.length<e.length?e[t+n.length]:"",o=t===0||!/[a-zA-Z0-9_$]/.test(r),c=t+n.length===e.length||!/[a-zA-Z0-9_$]/.test(a);if(!o||!c||r==="."||a===".")return!1;const l=e.slice(t+n.length);if(/^\s*[=:]/.test(l))return!1;const p=e.slice(Math.max(0,t-20),t);return!/[a-zA-Z0-9_$]\s*\.\s*$/.test(p)}extractFunctionNames(e){return Z.getInstance().extractFunctionNames(e)}storeFunctionForComponent(e,t,n){this.componentFunctions.has(e)||this.componentFunctions.set(e,new Map),this.componentFunctions.get(e).set(t,n),window[e]||(window[e]={}),window[e][t]=n}getComponentFunctions(e){return this.componentFunctions.get(e)}destroy(){if(this.updateTimeouts){for(const e of this.updateTimeouts.values())clearTimeout(e);this.updateTimeouts.clear()}this.componentFunctions.clear(),this.elementProps=new WeakMap,this.contextCache.clear(),this.propDependencyCache.clear()}}class Bs{stateManager;componentManager;expressionEvaluator;textNodeManager;observer;listeners=new WeakMap;pendingBindings=[];pendingTextNodes=[];applyingUpdates=!1;elementCache=new WeakMap;batchedUpdates=new Set;processingRAF=null;updateQueue=new Map;eventDelegation=new ce;processedElements=new WeakSet;loopManager;templateRenderer;BOOL_REFLECTED={checked:"checked",disabled:"disabled",hidden:"hidden",readonly:"readOnly",required:"required",multiple:"multiple",selected:"selected",autofocus:"autofocus",autoplay:"autoplay",controls:"controls",defer:"defer",loop:"loop",muted:"muted",open:"open",reversed:"reversed",async:"async",default:"default",formnovalidate:"formNoValidate",novalidate:"noValidate",allowfullscreen:"allowFullscreen",capture:"capture",itemscope:"itemScope"};lastValueCache=new WeakMap;stringValueCache=new q(500);refBindings=new WeakMap;constructor(e,t,n){this.stateManager=e,this.componentManager=t,this.expressionEvaluator=n,this.textNodeManager=new Os(n,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new Wt(e,n),this.loopManager.setDependencies(t,this),this.loopManager.eventDelegation=this.eventDelegation,this.eventDelegation.setDependencies(this.componentManager,this.expressionEvaluator,this.stateManager,this.loopManager),this.templateRenderer=new Je(n)}refreshComponentElement(e,t){this.elementCache.delete(e),this.processedElements.delete(e);const n=[...this.componentManager.componentStack];this.componentManager.componentStack=["app"],t!=="app"&&this.componentManager.componentStack.push(t);try{const i=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(e,i,t,!0),this.walkComponentChildren(e,t),this.refreshComponentTextNodes(e,t)}finally{this.componentManager.componentStack=n}}refreshComponentTextNodes(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:a=>{const o=a;return!o.textContent||!d.MUSTACHE_PATTERN.test(o.textContent)||T.isTextNodeInsideScript(o)||this.isTextNodeInsideLoopItem(o)||T.getComponentForNode(o)!==t?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let i;const r=[];for(;i=n.nextNode();)r.push(i);r.forEach(a=>{this.textNodeManager.cleanupTextNode(a),this.textNodeManager.cleanupTextNode(a),this.textNodeManager.processTextNode(a,t)})}walkComponentChildren(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return T.getElementComponent(o)!==t?NodeFilter.FILTER_REJECT:o===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});let i;const r=[];for(;i=n.nextNode();){const a=i;r.push(a)}r.forEach(a=>{this.elementCache.delete(a),this.processedElements.delete(a);const o=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(a,o,t,!0)})}createSpreadDirectiveBinding(e,t,n){const i=`spread_${Date.now()}_${Math.random()}`,r=N.parseSpreadDirective(t);if(r.spreads.length===0&&r.objects.length===0){console.warn(`Invalid pp-spread directive: ${t}`);return}const a=new Set,o=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(i);return}try{const p=this.componentManager.buildComponentContextWithProps(n,e);this.clearSpreadAttributes(e,a);for(const h of r.spreads){const f=this.expressionEvaluator.evaluateExpression(h,p,n);f&&typeof f=="object"&&this.applySpreadObject(e,f,a)}for(const h of r.objects)this.applyObjectProperties(e,h,p,n,a)}catch(p){console.error(`Spread directive evaluation error for "${t}":`,p)}},c=new Set;for(const p of r.spreads)this.templateRenderer.dependencies(p,n,this.stateManager).forEach(f=>c.add(f));for(const p of r.objects)for(const h of p)this.templateRenderer.dependencies(h.value,n,this.stateManager).forEach(E=>c.add(E));const l={id:i,selector:"",dependencies:c,callback:o,element:e,component:n};this.stateManager.addSubscription(l),this.storeSpreadSubscription(e,i),o()}applyObjectProperties(e,t,n,i,r){for(const a of t)try{const o=this.expressionEvaluator.evaluateExpression(a.value,n,i);if(this.isEventProperty(a.key)){this.handleSpreadEventProperty(e,a.key,o);continue}const c=this.normalizeAttributeName(a.key);this.updateElementProperty(e,c,o),r.add(c)}catch(o){console.error(`Error evaluating object property "${a.key}: ${a.value}":`,o)}}applySpreadObject(e,t,n){for(const[i,r]of Object.entries(t))if(r!=null){if(this.isEventProperty(i)){this.handleSpreadEventProperty(e,i,r);continue}const a=this.normalizeAttributeName(i);(!e.hasAttribute(a)||n.has(a))&&(this.updateElementProperty(e,a,r),n.add(a))}}isEventProperty(e){return e.startsWith("on")&&e.length>2}handleSpreadEventProperty(e,t,n){const i=t.substring(2).toLowerCase();if(typeof n=="function"){const r=a=>{try{const o=T.getContextComponent(e),c=this.componentManager?.buildComponentContextWithProps(o,e)||{};n.call(c,a)}catch(o){console.error("Spread event handler error:",o)}};e.addEventListener(i,r),this.storeDirectEventListener(e,i,r);return}if(typeof n=="string"){const r=T.getContextComponent(e);this.eventDelegation.registerEventHandler(e,i,n,r)}}storeDirectEventListener(e,t,n){e.__directEventListeners||(e.__directEventListeners=[]),e.__directEventListeners.push({eventType:t,listener:n})}clearSpreadAttributes(e,t){for(const n of t)e.hasAttribute(n)&&e.removeAttribute(n);t.clear()}normalizeAttributeName(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}storeSpreadSubscription(e,t){e.__spreadSubscriptions||(e.__spreadSubscriptions=[]),e.__spreadSubscriptions.push(t)}setupMutationObserver(){this.observer=new MutationObserver(e=>{const t=e.filter(this.isRelevantMutation);if(t.length===0)return;const n=V.getInstance();for(const i of t)if(i.type==="childList"&&(i.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const a=r;this.cleanupRefBinding(a),a.querySelectorAll("[pp-ref]").forEach(l=>{this.cleanupRefBinding(l)}),n.invalidateElement(a);const c=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);c&&n.invalidateByComponent(c)}}),i.addedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const o=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);o&&n.invalidateByComponent(o)}})),i.type==="attributes"&&i.target){const r=i.target;n.invalidateElement(r);const a=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);a&&n.invalidateByComponent(a)}this.processMutationsBatch(t)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,attributeFilter:[d.ATTR_PREFIXES.COMPONENT]})}isRelevantMutation=e=>{if(this.applyingUpdates&&e.type==="attributes")return!1;if(e.type==="childList"||e.type==="characterData")return!0;if(e.type==="attributes"){const t=e.attributeName;return t===d.ATTR_PREFIXES.COMPONENT||t!==null&&de.isEventAttribute(t)}return!1};processElement(e,t=!0){if(e===document.body){const i=Array.from(document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`)).sort((r,a)=>{const o=T.getElementDepth(r),c=T.getElementDepth(a);return o-c});this.processElementsBatch([e],t),i.forEach(r=>{this.processElementsBatch([r],t)}),t&&this.loopManager.processPendingTemplates()}else this.processElementsBatch([e],t)}processElementsBatch(e,t=!0){for(const n of e)this.processSingleElement(n,t);t&&(e.forEach(n=>{this.componentManager.executePhpScripts(n)}),this.processPendingBindings())}processSingleElement(e,t){const n=T.getElementComponent(e),i=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let r;i?i==="app"?r="app":r=i:r=T.getParentComponentForElement(e);const a=this.componentManager.componentStack.length;n!=="app"&&this.componentManager.pushComponent(n),this.componentManager.setupProps(e,r),t&&this.componentManager.executePhpScripts(e),this.processLoopTemplates(e,n);const o=t?this.componentManager.buildComponentContextWithProps(n,e):{};for(this.processElementInContext(e,o,n,t),this.walkDOM(e,o,n,t);this.componentManager.componentStack.length>a;)this.componentManager.popComponent()}processLoopTemplates(e,t){this.getDirectComponentTemplates(e,t).forEach(i=>{this.loopManager.queueTemplate(i,t)})}getDirectComponentTemplates(e,t){const n=[],i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return o!==e&&o.hasAttribute(d.ATTR_PREFIXES.COMPONENT)?NodeFilter.FILTER_REJECT:o.tagName==="TEMPLATE"&&o.hasAttribute("pp-for")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let r;for(;r=i.nextNode();)n.push(r);return n}walkDOM(e,t,n,i){const r=fe.getInstance(),a=`walkDOM_${n}_${i}`,o=r.getCachedTraversal(e,a,()=>{const p=r.traverseElementsAndText(e,h=>{if(h===e||h.tagName.toLowerCase()==="script"||this.loopManager.isLoopItem(h))return!1;let f=h.parentElement;for(;f&&f!==e;){if(this.loopManager.isLoopItem(f))return!1;f=f.parentElement}return!(T.getElementComponent(h)!==n||this.processedElements.has(h))},h=>{if(!h.textContent||!d.MUSTACHE_PATTERN.test(h.textContent)||T.isTextNodeInsideScript(h)||this.isTextNodeInsideLoopItem(h))return!1;const f=h.parentElement;if(f){const E=T.getContextComponent(f),m=T.getComponentForNode(h);if(E!==n&&m!==n)return!1}else if(T.getComponentForNode(h)!==n)return!1;return!0});return[...p.textNodes,...p.elements]}),c=[],l=[];o.forEach(p=>{if(p.nodeType===Node.TEXT_NODE)c.push(p);else if(p.nodeType===Node.ELEMENT_NODE){const h=p;if(h.hasAttribute("pp-ref")&&i){const f=h.getAttribute("pp-ref");this.createRefBinding(h,f,n),h.removeAttribute("pp-ref")}l.push(h),this.processedElements.add(h)}}),c.forEach(p=>{const h=p.parentElement,f=h?T.getContextComponent(h):n;i?this.textNodeManager.processTextNode(p,f):this.pendingTextNodes.push({textNode:p,component:f})}),l.forEach(p=>{this.processElementInContext(p,t,n,i)})}isTextNodeInsideLoopItem(e){let t=e.parentElement;for(;t&&t!==document.body;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}processElementInContext(e,t,n,i){if(e.hasAttribute("pp-ref")){const l=e.getAttribute("pp-ref");i&&this.createRefBinding(e,l,n),e.removeAttribute("pp-ref")}if(e.hasAttribute(d.ATTR_PREFIXES.SPREAD)){const l=e.getAttribute(d.ATTR_PREFIXES.SPREAD);i&&this.createSpreadDirectiveBinding(e,l,n),e.removeAttribute(d.ATTR_PREFIXES.SPREAD)}if(this.loopManager.isLoopItem(e)||this.isElementInLoopItem(e))return;const r=this.extractDomMustacheBindings(e),a=this.elementCache.get(e),o=this.getElementHash(e);if(a&&a.hash===o&&this.isCacheValid(a)&&i){this.applyBindingsFromCache(e,a,t);return}const c={bindings:r,component:n,listeners:[],lastProcessed:Date.now(),hash:o};i?this.applyBindings(e,r,t,n):r.forEach((l,p)=>{this.pendingBindings.push({element:e,property:p,expression:l,component:n})}),this.setupEventBindings(e,n),this.elementCache.set(e,c)}createRefBinding(e,t,n){try{const i=N.decodeEntities(t),r=N.isSingleExpression(i)||i,a=T.getContextComponent(e),o=this.componentManager.buildComponentContextWithProps(a,e);try{const c=this.expressionEvaluator.evaluateExpression(r,o,a);if(typeof c=="function"){const l=c;this.refBindings.set(e,{element:e,callback:l,component:a}),l(e)}else if(c&&typeof c=="object"&&"current"in c){const l=c;this.refBindings.set(e,{element:e,refObject:l,component:a}),l.current=e}else console.warn(`⚠️ pp-ref expression did not return a ref object or callback: ${r}`,c)}catch(c){console.error(`❌ Failed to evaluate ref "${r}":`,c)}}catch(i){console.error(`❌ Failed to create ref binding for "${t}":`,i)}}isElementInLoopItem(e){let t=e;for(;t;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}extractDomMustacheBindings(e){const t=new Map,n=e.attributes,i=this.elementCache.get(e),r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),o=a&&this.componentManager?.hasStoredProps(e),c=r&&a&&r!==a;for(let l=0;l<n.length;l++){const p=n[l];if(!(p.name===d.ATTR_PREFIXES.COMPONENT||p.name===d.ATTR_PREFIXES.CONTEXT||p.name==="key"||de.isEventAttribute(p.name))&&!(i&&i.bindings.has(p.name))&&p.value){const h=d.MUSTACHE_PATTERN.test(p.value),f=N.decodeEntities(p.value),E=d.MUSTACHE_PATTERN.test(f);if(h||E){if(this.looksLikeSerializedObject(f))continue;const m=N.extractExpressions(f),x=T.getContextComponent(e);if(m.length===0&&(h||E)){console.error(`
|
|
27
|
+
❌ Malformed mustache expression in attribute "${p.name}":`),console.error(` Value: ${f}`),console.error(" Element:",e),console.error(` Component: ${x}`),console.error(" 💡 The expression has mustache syntax {} but couldn't be parsed"),console.error(` 💡 Common causes: unmatched quotes, unclosed braces, invalid syntax
|
|
28
|
+
`),o||c&&T.shouldBeDirectBinding(e,p.name)?t.set(p.name,f):c||t.set(p.name,f);continue}for(const g of m){const C=Is.validate(g,x);C.valid||(console.error(`
|
|
29
|
+
❌ Invalid expression in attribute "${p.name}":`),console.error(` Expression: ${g}`),console.error(` Original HTML: ${p.value}`),console.error(` Decoded: ${f}`),console.error(" Element:",e),console.error(` Component: ${x}`),C.errors.forEach(w=>{console.error(` ⚠️ ${w}`)}),console.error(" 💡 Hint: Check your quotes and syntax in conditional expressions"),console.error(` 💡 Example: class="{isActive ? 'text-blue-500' : 'text-gray-500'}"
|
|
30
|
+
`)),C.warnings.length>0&&(console.warn(`
|
|
31
|
+
⚠️ Expression warnings in attribute "${p.name}":`),console.warn(` Expression: ${g}`),console.warn(" Element:",e),C.warnings.forEach(w=>{console.warn(` • ${w}`)}))}o||c&&T.shouldBeDirectBinding(e,p.name)?t.set(p.name,f):c||t.set(p.name,f)}}}return t}applyBindings(e,t,n,i){t.forEach((r,a)=>{this.createMustacheBinding(e,a,r)}),this.setupEventBindings(e,i)}applyBindingsFromCache(e,t,n){t.bindings.forEach((i,r)=>{try{const a=this.componentManager.buildComponentContextWithProps(t.component,e),o=this.templateRenderer.render(i,a,t.component);this.updateElementProperty(e,r,o)}catch(a){console.error(`Cached binding evaluation error for "${i}":`,a)}})}createMustacheBinding(e,t,n){const i=`mustache_${Date.now()}_${Math.random()}`;let r;const a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),o=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);if(a&&this.componentManager?.hasStoredProps(e)){const E=this.componentManager.elementProps.get(e);(E?Array.from(E.keys()):[]).some(g=>n.includes(g))?r=a:r=T.getContextComponent(e)}else r=T.getContextComponent(e);e.removeAttribute(t);const c=new Set;this.templateRenderer.dependencies(n,r,this.stateManager).forEach(E=>c.add(E));const p=this.findComponentElementForMustacheBinding(e,r);p&&this.componentManager&&this.componentManager.getComponentPropDependencies(p,r).forEach(m=>c.add(m));const h=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(i);return}try{const E=o!==null||this.hasInheritedContextForElement(e,r);let m;if(E){const g=r===a?e:p||void 0;m=this.componentManager.buildComponentContextWithProps(r,g)}else if(m=this.componentManager.buildRestrictedComponentContext(r,!1),p&&this.componentManager){const g=this.componentManager.evaluateProps(p);Object.assign(m,g)}const x=this.templateRenderer.render(n,m,r);this.scheduleElementUpdate(e,t,x)}catch(E){console.error(`Mustache binding evaluation error for "${n}":`,E)}},f={id:i,selector:"",dependencies:c,callback:h,element:e,component:r};this.stateManager.addSubscription(f),h()}hasInheritedContextForElement(e,t){let n=e;for(;n&&n!==document.body;){if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t){if(n.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;break}n=n.parentElement}for(n=e.parentElement;n&&n!==document.body;){const i=n.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i&&i!==t&&n.hasAttribute(d.ATTR_PREFIXES.CONTEXT))return!0;n=n.parentElement}return!1}findComponentElementForMustacheBinding(e,t){if(e.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return e;let i=e.parentElement;for(;i;){if(i.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return i;i=i.parentElement}const r=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const a of r)if(this.componentManager&&this.componentManager.hasStoredProps(a))return a;return r[0]||null}setupEventBindings(e,t){for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n];if(de.isEventAttribute(i.name)){const r=i.name.substring(2),a=T.getContextComponent(e);this.eventDelegation.registerEventHandler(e,r,i.value,a),e.removeAttribute(i.name)}}}scheduleElementUpdate(e,t,n){if(this.isCriticalProperty(t)){this.updateElementProperty(e,t,n);return}this.updateQueue.has(e)||(this.updateQueue.set(e,new Set),this.batchedUpdates.add(e)),this.updateQueue.get(e).add(t),this.processingRAF||(this.processingRAF=requestAnimationFrame(()=>{this.processBatchedElementUpdates()})),e[`__pending_${t}`]=n}isCriticalProperty(e){return["textContent","innerHTML","value","checked","selected","disabled","class","className","style","hidden","display"].includes(e)}processBatchedElementUpdates(){this.applyingUpdates=!0;try{for(const e of this.batchedUpdates){const t=this.updateQueue.get(e);if(t)for(const n of t){const i=e[`__pending_${n}`];this.updateElementProperty(e,n,i),delete e[`__pending_${n}`]}}}finally{this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF=null,this.applyingUpdates=!1}}updateElementProperty(e,t,n){const i=He(n),r=this.lastValueCache.get(e);if(r&&this.isSameValue(r.get(t),i))return;const a=this.applyingUpdates;this.applyingUpdates=!0;try{switch(t){case"textContent":const o=this.cachedValueToString(i);e.textContent!==o&&(e.textContent=o);break;case"innerHTML":const c=this.cachedValueToString(i);e.innerHTML!==c&&(e.innerHTML=c);break;case"value":const l=this.cachedValueToString(i);e instanceof HTMLOptionElement?e.value!==l&&(e.value=l,e.setAttribute("value",l)):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.value!==l&&(e.value=l);break;case"selectedIndex":if(e instanceof HTMLSelectElement){const h=Number(i);e.selectedIndex!==h&&(e.selectedIndex=h)}break;case"checked":case"disabled":case"hidden":case"readonly":case"required":case"multiple":case"selected":case"autofocus":case"autoplay":case"controls":case"defer":case"loop":case"muted":case"open":case"reversed":case"async":case"default":case"formnovalidate":case"novalidate":case"allowfullscreen":case"capture":case"itemscope":this.setBooleanProperty(e,t,i);break;case"indeterminate":if(e instanceof HTMLInputElement&&e.type==="checkbox"){const h=!!i;e.indeterminate!==h&&(e.indeterminate=h)}break;case"class":case"className":const p=this.cachedValueToString(i);e instanceof SVGElement?e.getAttribute("class")!==p&&e.setAttribute("class",p):e.className!==p&&(e.className=p);break;case"htmlFor":case"for":if(e instanceof HTMLLabelElement){const h=this.cachedValueToString(i);e.htmlFor!==h&&(e.htmlFor=h)}break;case"style":if(e instanceof HTMLElement)if(typeof i=="object"&&i&&!Array.isArray(i))this.updateStyleObject(e,i);else{const h=this.cachedValueToString(i);e.style.cssText!==h&&(e.style.cssText=h)}break;case"tabIndex":if(e instanceof HTMLElement){const h=i==null?-1:Number(i);e.tabIndex!==h&&(e.tabIndex=h)}break;case"contentEditable":if(e instanceof HTMLElement){const h=i===!0?"true":i===!1?"false":String(i);e.contentEditable!==h&&(e.contentEditable=h)}break;case"draggable":if(e instanceof HTMLElement){const h=i===!0,f=h?"true":"false";e.draggable!==h&&(e.draggable=h,e.setAttribute("draggable",f))}break;case"spellcheck":if(e instanceof HTMLElement){const h=!!i,f=h?"true":"false";e.spellcheck!==h&&(e.spellcheck=h,e.setAttribute("spellcheck",f))}break;case"src":case"href":case"action":case"alt":case"title":case"placeholder":case"id":case"name":case"type":case"method":case"target":case"rel":case"pattern":case"accept":case"autocomplete":case"enctype":case"wrap":case"download":case"ping":case"referrerpolicy":case"crossorigin":case"integrity":case"loading":case"decoding":case"srcset":case"sizes":case"dir":case"lang":case"translate":case"role":this.setStringAttribute(e,t,i);break;case"min":case"max":case"step":case"maxLength":case"minLength":case"size":case"rows":case"cols":case"rowSpan":case"colSpan":this.setNumericAttribute(e,t,i);break;default:t.startsWith("aria-")?this.setAriaAttribute(e,t,i):t.startsWith("data-")?this.setDataAttribute(e,t,i):this.setGenericAttribute(e,t,i);break}this.updateValueCache(e,t,i)}catch(o){console.error(`Failed to update property "${t}" on element:`,e,o)}finally{this.applyingUpdates=a}}looksLikeSerializedObject(e){if(!e.startsWith("{")||!e.endsWith("}"))return!1;try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}catch{return!1}}cachedValueToString(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(e==null)return"";if(typeof e=="boolean")return e?"true":"false";if(this.stringValueCache.has(e))return this.stringValueCache.get(e);const t=ue(e);return this.stringValueCache.set(e,t),t}isSameValue(e,t){if(e===t)return!0;if(typeof e=="object"&&typeof t=="object"){if(e===null||t===null)return e===t;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,i)=>n===t[i]);if(this.isStyleObject(e)&&this.isStyleObject(t)){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every(r=>e[r]===t[r])}}return!1}isStyleObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}setBooleanProperty(e,t,n){const i=!!n;this.setBooleanProp(e,t,n)||(i&&!e.hasAttribute(t)?e.setAttribute(t,""):!i&&e.hasAttribute(t)&&e.removeAttribute(t))}updateStyleObject(e,t){const n=this.lastValueCache.get(e)?.get("style"),i=n&&typeof n=="object"?n:{};for(const[r,a]of Object.entries(t))i[r]!==a&&(e.style[r]=a)}setStringAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null?e.removeAttribute(t):e.setAttribute(t,i))}setNumericAttribute(e,t,n){const i=String(n);e.getAttribute(t)!==i&&(n==null?e.removeAttribute(t):e.setAttribute(t,i))}setAriaAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null||n===!1?e.removeAttribute(t):e.setAttribute(t,i))}setDataAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null?e.removeAttribute(t):e.setAttribute(t,i))}setGenericAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null||n===!1?e.removeAttribute(t):e.setAttribute(t,i))}updateValueCache(e,t,n){this.lastValueCache.has(e)||this.lastValueCache.set(e,new Map),this.lastValueCache.get(e).set(t,n)}setBooleanProp(e,t,n){const i=this.BOOL_REFLECTED[t];if(!i)return!1;const r=!!n;return e instanceof HTMLElement&&i in e?(e[i]!==r&&(e[i]=r),!0):(r?e.hasAttribute(t)||e.setAttribute(t,""):e.hasAttribute(t)&&e.removeAttribute(t),!0)}processPendingBindings(){const e=[...this.pendingBindings];this.pendingBindings=[];const t=new Map;for(const n of e)t.has(n.component)||t.set(n.component,[]),t.get(n.component).push(n);for(const[n,i]of t){const r=[...this.componentManager.componentStack];n!=="app"?this.componentManager.componentStack=["app",n]:this.componentManager.componentStack=["app"];for(const a of i)try{if(!document.contains(a.element))continue;this.createMustacheBinding(a.element,a.property,a.expression)}catch(o){console.error(`❌ Failed to create binding for ${n}:`,o)}this.componentManager.componentStack=r}this.processTextNodesPending()}processTextNodesPending(){const e=new Map;for(const t of this.pendingTextNodes)e.has(t.component)||e.set(t.component,[]),e.get(t.component).push(t);this.pendingTextNodes=[];for(const[t,n]of e){const i=[...this.componentManager.componentStack];t!=="app"?this.componentManager.componentStack=["app",t]:this.componentManager.componentStack=["app"];for(const{textNode:r,component:a}of n)if(document.contains(r))try{this.textNodeManager.processTextNode(r,a)}catch(o){console.error(`❌ Failed to process text node for ${a}:`,o)}this.componentManager.componentStack=i}}processMutationsBatch(e){const t=new Set,n=new Set,i=new Set,r=new Set,a=new Set;for(const o of e)if(o.type==="childList"&&(o.addedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)t.add(c);else if(c.nodeType===Node.TEXT_NODE){const l=c;l.textContent&&d.MUSTACHE_PATTERN.test(l.textContent)&&a.add(l)}}),o.removedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)n.add(c);else if(c.nodeType===Node.TEXT_NODE){const l=c;l.textContent&&d.MUSTACHE_PATTERN.test(l.textContent)&&(document.contains(l)||this.textNodeManager.cleanupTextNode(l))}})),o.type==="attributes"&&o.target&&r.add(o.target),o.type==="characterData"&&o.target){const c=o.target;c.textContent&&d.MUSTACHE_PATTERN.test(c.textContent)&&a.add(c)}for(const o of n)(t.has(o)||document.contains(o))&&(i.add(o),n.delete(o),t.has(o)&&t.delete(o));n.size>0&&this.cleanupElementsBatch(Array.from(n)),t.size>0&&this.processElementsBatch(Array.from(t)),a.size>0&&this.processTextNodesBatch(Array.from(a)),r.size>0&&this.rebindChangedElements(Array.from(r))}processTextNodesBatch(e){const t=new Map;for(const n of e){const i=T.getComponentForNode(n);t.has(i)||t.set(i,[]),t.get(i).push(n)}for(const[n,i]of t)i.forEach(r=>{this.textNodeManager.processTextNode(r,n)})}rebindChangedElements(e){e.forEach(t=>{this.processElementBindings(t,!0)})}processElementBindings(e,t=!0){const n=this.extractDomMustacheBindings(e),i=T.getElementComponent(e);n.forEach((r,a)=>{t?this.createMustacheBinding(e,a,r):this.pendingBindings.push({element:e,property:a,expression:r,component:i})}),t&&this.setupEventBindings(e,i)}cleanupElementsBatch(e){e.forEach(t=>this.cleanupElement(t))}cleanupElement(e){this.cleanupRefBinding(e),this.stateManager.subscriptionManager?.cleanupElement(e);const t=this.listeners.get(e)||[];for(const{type:l,fn:p}of t)e.removeEventListener(l,p);this.listeners.delete(e),this.elementCache.delete(e),this.processedElements.delete(e),this.componentManager.cleanupProps(e);const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let i;for(;i=n.nextNode();)this.textNodeManager.cleanupTextNode(i);e.tagName==="TEMPLATE"&&e.hasAttribute("pp-for")&&this.loopManager.cleanupTemplate(e),e.querySelectorAll("template[pp-for]").forEach(l=>{this.loopManager.cleanupTemplate(l)});const a=e.__directEventListeners;a&&(a.forEach(({eventType:l,listener:p})=>{e.removeEventListener(l,p)}),delete e.__directEventListeners);const o=e.__spreadEventHandlers;o&&(o.forEach(l=>{window.__spreadHandlers&&window.__spreadHandlers.delete(l)}),delete e.__spreadEventHandlers);const c=e.__spreadSubscriptions;c&&(c.forEach(l=>{this.stateManager.removeSubscription(l)}),delete e.__spreadSubscriptions),this.lastValueCache.delete(e),this.stringValueCache.size()>1500&&this.stringValueCache.clear()}cleanupRefBinding(e){const t=this.refBindings.get(e);if(t){try{t.callback?t.callback(null):t.refObject&&(t.refObject.current=null)}catch(n){console.error("Failed to cleanup ref:",n)}this.refBindings.delete(e)}}getElementHash(e){const t=[];for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n];(i.name===d.ATTR_PREFIXES.COMPONENT||de.isEventAttribute(i.name)||i.value&&d.MUSTACHE_PATTERN.test(i.value))&&t.push(`${i.name}=${i.value}`)}return t.sort().join("|")}isCacheValid(e){return Date.now()-e.lastProcessed<3e4}refreshAllBindings(){this.elementCache=new WeakMap,this.processedElements=new WeakSet,this.processElement(document.body,!0)}destroy(){this.observer&&this.observer.disconnect(),document.querySelectorAll("[pp-ref]").forEach(t=>{this.cleanupRefBinding(t)}),this.eventDelegation.cleanup(),this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF&&cancelAnimationFrame(this.processingRAF),this.elementCache=new WeakMap,this.listeners=new WeakMap,this.processedElements=new WeakSet,this.loopManager.destroy()}}class ce{static eventCache=null;delegatedEvents=new Map;elementHandlers=new WeakMap;handlerCache=new q(200);componentManager;expressionEvaluator;loopManager;setupEvents=new Set;stateManager;static getAllAvailableEvents(){if(ce.eventCache)return ce.eventCache;const e=new Set,t=["click","input","change","submit","focus","blur","keydown","keyup","mousedown","mouseup","mouseover","mouseout"];try{Object.getOwnPropertyNames(HTMLElement.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get HTMLElement events:",i),t.forEach(r=>e.add(r))}try{Object.getOwnPropertyNames(Document.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get Document events:",i)}try{Object.getOwnPropertyNames(Window.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get Window events:",i)}try{Object.getOwnPropertyNames(Element.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get Element events:",i)}return new Set(["beforeunload","unload","pagehide","pageshow","popstate","hashchange","storage","message","messageerror","offline","online","languagechange","rejectionhandled","unhandledrejection","afterprint","beforeprint","devicemotion","deviceorientation","deviceorientationabsolute"]).forEach(i=>e.delete(i)),ce.eventCache=e,e}setupEventDelegation(){const e=["click","input","change","submit","focus","blur"];for(const t of e)this.ensureEventSetup(t)}getEventOptions(e){const t={capture:!0,passive:!1};return["wheel","touchstart","touchmove","touchend","scroll","mousewheel"].includes(e)&&(t.passive=!0),(e==="focusin"||e==="focusout")&&(t.capture=!1),t}isEventSupported(e){return ce.getAllAvailableEvents().has(e.toLowerCase())}getAllSupportedEvents(){return Array.from(ce.getAllAvailableEvents()).sort()}getDelegatedEvents(){return Array.from(this.delegatedEvents.keys()).sort()}setDependencies(e,t,n,i){this.componentManager=e,this.expressionEvaluator=t,this.stateManager=n,this.loopManager=i}createDelegatedListener(e){return t=>{const n=t.target;if(!n)return;const i=this.findHandler(n,e);i&&this.executeHandler(i.handler,i.element,t)}}registerEventHandler(e,t,n,i){const r=t.toLowerCase();if(this.ensureEventSetup(r),!this.isEventSupported(r)){console.warn(`⚠️ Event type "${t}" is not supported`);return}const a=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let o=i;a&&(a==="app"?o="app":o=a),this.elementHandlers.has(e)||this.elementHandlers.set(e,new Map);const c=this.elementHandlers.get(e),l={code:n,component:o};c.set(r,l);const p=this.delegatedEvents.get(r);p?p.elements.add(e):(console.warn(`⚠️ No delegated listener for ${r}, attaching directly`),this.attachDirectListener(e,r,l))}ensureEventSetup(e){if(!this.setupEvents.has(e)){if(!this.isEventSupported(e)){console.warn(`⚠️ Attempting to setup unsupported event: ${e}`);return}try{const t=this.createDelegatedListener(e),n=this.getEventOptions(e);document.addEventListener(e,t,n),this.setupEvents.add(e),this.delegatedEvents.set(e,{listener:t,elements:new WeakSet})}catch(t){console.error(`Failed to setup event delegation for ${e}:`,t),this.setupEvents.delete(e)}}}findHandler(e,t){let n=e;for(;n;){const i=this.elementHandlers.get(n);if(i?.has(t))return{handler:i.get(t),element:n};n=n.parentElement}return null}compileHandler(e,t){const n=`${t}:${e}`;if(this.handlerCache.has(n))return this.handlerCache.get(n);let i=e;e.includes("this")&&(i=i.replace(/\bthis\b/g,"thisElement")),e.includes("event")&&(i=i.replace(/\bevent\b/g,"eventObject"));const r=new Function("eventObject","thisElement","context",`
|
|
32
32
|
try {
|
|
33
33
|
with(context) {
|
|
34
34
|
${i}
|
|
@@ -39,4 +39,4 @@ Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=1
|
|
|
39
39
|
console.error('Component:', '${t}');
|
|
40
40
|
console.error('Available context keys:', Object.keys(context));
|
|
41
41
|
}
|
|
42
|
-
`);return this.handlerCache.set(n,r),r}executeHandler(e,t,n){if(!this.componentManager||!this.expressionEvaluator){console.warn("EventDelegationManager dependencies not set");return}try{const i=t.getAttribute(d.ATTR_PREFIXES.CONTEXT),r=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);let a=e.component,o=e.component;if(i)if(i==="app")a="app",r||(o="app");else if(i==="parent"){const m=S.getElementComponent(t);a=S.getParentOfComponent(m,t),r||(o=a)}else a=i,r||(o=i);else{let m=t,E=null;for(;m&&m!==document.body;){const A=m.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(A){const I=m.__originalComponentName;if(A===e.component||I===e.component){E=m;break}}m=m.parentElement}if(E){const A=E.getAttribute(d.ATTR_PREFIXES.COMPONENT);A&&(o=A);const I=E.getAttribute(d.ATTR_PREFIXES.CONTEXT);if(I)if(I==="app")a="app";else if(I==="parent"){const R=S.getElementComponent(E);a=S.getParentOfComponent(R,E)}else a=I}for(m=t;m&&m!==document.body;){const A=m.__uniqueComponentName,I=m.__originalComponentName;if(A){a=A,(!E||!E.__originalComponentName)&&(o=I||e.component);break}m=m.parentElement}}r&&(o=r);const c=i==="app"||i==="parent"||a==="app",l=a==="app",p=S.findElementForComponent(t,a);let h;if(c||l)h=this.componentManager.buildComponentContextWithProps(a,p||void 0);else if(h=this.componentManager.buildRestrictedComponentContext(a,!1),p){const m=this.componentManager.evaluateProps(p);Object.assign(h,m)}let f=t.parentElement,x=0;for(;f&&f!==document.body&&x<10;){if(x++,f.getAttribute(d.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(f)){const E=this.componentManager.evaluateProps(f);Object.assign(h,E);break}f=f.parentElement}if(o&&o!==a&&!o.includes("_loop_")){const m=this.getComponentOwnState(o);Object.assign(h,m)}if(a!==o&&window[a]){const m=window[a];for(const[E,A]of Object.entries(m))typeof A!="function"&&!(E in h)&&(h[E]=A)}const b={...h};for(const[m,E]of Object.entries(h))typeof E=="function"&&"__pphp_key"in E&&(b[m]=E.value);const g=this.loopManager?.getLoopContextForElement(t);if(g){const m={};for(const[E,A]of Object.entries(g)){if(typeof A=="function")continue;const I=`set${E.charAt(0).toUpperCase()}${E.slice(1)}`,R=`${E}Getter`,V=I in g&&typeof g[I]=="function",L=R in g&&typeof g[R]=="function";if(V||L)if(L){const Q=g[R],H=typeof Q.value<"u"?Q.value:Q();m[E]=H}else{const Q=b[E];Q!==void 0?m[E]=Q:m[E]=A}else m[E]=A}h={...b,...m}}else h=b;e.compiledFn||(e.compiledFn=this.compileHandler(e.code,o)),e.compiledFn&&e.compiledFn(n,t,h)}catch(i){console.error("💥 Event handler execution failed:",i),console.error("Handler code:",e.code),console.error("Handler component:",e.component)}}getComponentOwnState(e){const t={};window[e]&&Object.assign(t,window[e]);const n=this.stateManager?.getState();if(n){const i=Object.keys(n).filter(r=>r.startsWith(e+"."));for(const r of i){const a=r.substring(e.length+1);a in t||(t[a]=n[r])}}return t}attachDirectListener(e,t,n){const i=r=>{this.executeHandler(n,e,r)};e.addEventListener(t,i),e[`__${t}_listener`]=i}removeEventHandler(e,t){const n=this.elementHandlers.get(e);n&&(n.delete(t),n.size===0&&this.elementHandlers.delete(e));const i=this.delegatedEvents.get(t);i&&i.elements.delete?.(e);const r=e[`__${t}_listener`];r&&(e.removeEventListener(t,r),delete e[`__${t}_listener`])}cleanup(){for(const[e,t]of this.delegatedEvents)document.removeEventListener(e,t.listener,!0);this.delegatedEvents.clear(),this.handlerCache.clear(),this.setupEvents.clear()}}class $s{static instance=null;stateManager=new Fs;expressionEvaluator=new me;componentManager=new Ds(this.stateManager);domBindingManager=new Bs(this.stateManager,this.componentManager,this.expressionEvaluator);hydrationCallbacks=new Set;portalManager=new ks;initialized=!1;hydrationDone=!1;hydrationResolve;hydrationPromise;portalHydrationPromises=new Set;portalHydrationResolvers=new Map;constructor(){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.initialize()):setTimeout(()=>this.initialize(),0),this.hydrationPromise=new Promise(e=>this.hydrationResolve=e)}initialize(){this.initialized||(this.initialized=!0,this.markHydrationStart(),this.componentManager.setExpressionEvaluator(this.expressionEvaluator),this.portalManager.setDependencies(this.componentManager,this.domBindingManager,this.stateManager,this),this.componentManager.executePhpScripts(document.body),this.domBindingManager.processElement(document.body,!0),this.domBindingManager.processPendingBindings(),Promise.resolve().then(()=>{requestAnimationFrame(()=>{this.markHydrated()})}))}createPortal(e,t,n){const i=this.portalManager.createPortal(e,t,n),r=new Promise(a=>{this.portalHydrationResolvers.set(i,a)});return this.portalHydrationPromises.add(r),r.finally(()=>{this.portalHydrationPromises.delete(r),this.portalHydrationResolvers.delete(i)}),i}removePortal(e){return this.markPortalHydrated(e),this.portalManager.removePortal(e)}markPortalHydrated(e){const t=this.portalHydrationResolvers.get(e);t&&t()}updatePortal(e,t,n){return this.portalManager.updatePortal(e,t,n)}cleanup(){this.portalManager.destroy(),this.domBindingManager.destroy(),this.componentManager.destroy(),this.stateManager.clearState(),this.stateManager.clearSubscriptions(),this.expressionEvaluator.clearAllCaches(),this.hydrationCallbacks.clear(),this.deleteAllComponentObjects()}ref(e=null){return{current:e}}async hydrated(){await Promise.all([this.hydrationPromise,...Array.from(this.portalHydrationPromises)])}onHydrated(e){this.hydrationDone?queueMicrotask(e):this.hydrationCallbacks.add(e)}get isHydrated(){return this.hydrationDone}markHydrationStart(){document.dispatchEvent(new CustomEvent("pp:hydrationstart"))}markHydrated(){if(!this.hydrationDone){this.hydrationDone=!0,this.hydrationResolve();for(const e of this.hydrationCallbacks)try{e()}catch{}this.hydrationCallbacks.clear(),document.dispatchEvent(new CustomEvent("pp:hydrated",{detail:{at:performance.now()}}))}}state(e,t){const n=this.componentManager.getCurrentComponent();let i,r;typeof e=="string"&&arguments.length===2?(i=e,r=t):typeof e=="string"&&arguments.length===1?this.looksLikeVariableName(e)?(i=e,r=void 0):(console.warn("pp.state() called with string that doesn't look like variable name:",e),i="unknownState",r=e):(console.warn("pp.state() called without explicit key - this should be handled by AST transformation"),i="unknownState",r=e),r&&typeof r=="function"&&"__pphp_key"in r&&(r=r.value);let a;const o=this.getLoopExecutionContext();if(o){const h=this.generateLoopInstanceId(o);a=`${n}.${h}.${i}`}else a=`${n}.${i}`;this.stateManager.hasState(a)||this.stateManager.setInitialState(a,r);const c=(()=>this.stateManager.getState()[a]),l=new Proxy(c,{get(h,f,x){if(f==="__pphp_key"||f==="__pphp_fullKey"||f==="__pphp_component"||f==="value"||f==="valueOf"||f==="toString")return Reflect.get(h,f,x);const b=h();if(b!=null){if(f in Object(b)){const g=b[f];return typeof g=="function"?g.bind(b):g}return Reflect.get(h,f,x)}},has(h,f){if(f==="__pphp_key"||f==="__pphp_fullKey"||f==="__pphp_component"||f==="value"||f==="valueOf"||f==="toString")return Reflect.has(h,f);const x=h();return x!=null&&f in Object(x)?!0:Reflect.has(h,f)},apply(h,f,x){return Reflect.apply(h,f,x)}});Object.defineProperty(l,"__pphp_key",{value:i,enumerable:!1,writable:!1}),Object.defineProperty(l,"__pphp_fullKey",{value:a,enumerable:!1,writable:!1}),Object.defineProperty(l,"__pphp_component",{value:n,enumerable:!1,writable:!1}),Object.defineProperty(l,"value",{get:()=>this.stateManager.getState()[a],enumerable:!0,configurable:!0}),c.valueOf=()=>this.stateManager.getState()[a],c.toString=()=>ue(this.stateManager.getState()[a]);const p=h=>{const f=this.stateManager.getState()[a],x=typeof h=="function"?h(f):h;this.stateManager.setState(a,x)};return this.createComponentScopedGlobals(n,i,l,p),[l,p]}currentLoopContext=null;getLoopExecutionContext(){return this.currentLoopContext}generateLoopInstanceId(e){const n=Object.keys(e).sort().map(r=>{const a=e[r];return a&&typeof a=="object"&&"id"in a?`${r}:${a.id}`:`${r}:${JSON.stringify(a)}`});return`loop_${btoa(n.join("|")).replace(/[^a-zA-Z0-9]/g,"").substring(0,8)}`}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")&&!ge.has(e)}effect(e,t){const n=`effect_${Date.now()}_${Math.random()}`,i=this.componentManager.getCurrentComponent();let r,a=!1,o,c;if(arguments.length===1)o="always",c={immediate:!0,detectDeps:!0};else if(Array.isArray(t)){const p=this.extractDependencyNames(t,i);p.length===0?(o="once",c={deps:p,immediate:!0}):(o="deps",c={deps:p,immediate:!0})}else{const p={immediate:!0,...t||{}};if(!p.deps||p.deps.length===0)o="always",c={immediate:p.immediate,detectDeps:!0};else{const h=this.extractDependencyNames(p.deps,i);o="deps",c={deps:h,immediate:p.immediate,detectDeps:p.detectDeps}}}const l=()=>{a||this.stateManager.onDOMUpdateComplete(()=>{if(!a){if(r&&typeof r=="function")try{r()}catch(p){console.error("Effect cleanup error:",p)}try{r=e()}catch(p){console.error("Effect callback error:",p)}}})};switch(o){case"always":const p=["*"],h={id:n,selector:"",dependencies:new Set(p),callback:l,component:i};this.stateManager.addSubscription(h);break;case"once":break;case"deps":const f=this.resolveDependencies(c.deps,i);if(f.length){const x={id:n,selector:"",dependencies:new Set(f),callback:l,component:i};this.stateManager.addSubscription(x)}break}return c.immediate!==!1&&l(),()=>{if(a=!0,r&&typeof r=="function")try{r()}catch(p){console.error("Effect cleanup error:",p)}this.stateManager.removeSubscription(n)}}extractDependencyNames(e,t){const n=[];for(const i of e)typeof i=="string"?n.push(i):typeof i=="function"&&i.__pphp_key?n.push(i.__pphp_key):console.warn("Invalid dependency in effect:",i);return n.filter(Boolean)}resolveDependencies(e,t){const n=[],i=this.stateManager.getState();for(const r of e)if(r.includes(".")){const a=r.split("."),o=a[0],c=a.slice(1).join("."),l=this.componentManager.getPropDependencies(o,t);if(l.length>0)n.push(...l);else{const p=Ue.findExistingStateKey(o,t,i);p?n.push(`${p}.${c}`):n.push(`${t}.${r}`)}}else{const a=this.componentManager.getPropDependencies(r,t);if(a.length>0)n.push(...a);else{const o=Ue.findExistingStateKey(r,t,i);o?n.push(o):n.push(`${t}.${r}`)}}return Array.from(new Set(n))}createComponentScopedGlobals(e,t,n,i){window[e]||(window[e]={});const r=`set${jt(t)}`;window[e][t]=n,window[e][r]=i,window[e][`${t}Getter`]=n}deleteAllComponentObjects(){const e=Object.keys(window),t=new Set(["window","self","document","location","customElements","history","navigation","locationbar","menubar","personalbar","scrollbars","statusbar","toolbar","frames","top","parent","navigator","external","screen","visualViewport","crypto","performance","localStorage","sessionStorage","indexedDB","fetch","XMLHttpRequest","WebSocket","Worker","SharedWorker","MessageChannel","MessagePort","Notification","Push","BroadcastChannel","Cache","CacheStorage","requestAnimationFrame","cancelAnimationFrame","requestIdleCallback","cancelIdleCallback","setInterval","clearInterval","setTimeout","clearTimeout","queueMicrotask","atob","btoa","alert","confirm","prompt","open","close","focus","blur","print","stop","getComputedStyle","getSelection","matchMedia","scroll","scrollBy","scrollTo","resizeBy","resizeTo","moveBy","moveTo","pp","store","searchParams"]);for(const n of e){if(t.has(n))continue;const i=window[n];(/^s[a-z0-9]+$/i.test(n)||n==="app")&&i&&typeof i=="object"&&delete window[n]}}static resetInstance(){this.instance&&(this.instance.destroy(),this.instance=null)}destroy(){this.cleanup(),this.initialized=!1,this.hydrationDone=!1}}export{$s as P};
|
|
42
|
+
`);return this.handlerCache.set(n,r),r}executeHandler(e,t,n){if(!this.componentManager||!this.expressionEvaluator){console.warn("EventDelegationManager dependencies not set");return}try{const i=t.getAttribute(d.ATTR_PREFIXES.CONTEXT),r=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);let a=e.component,o=e.component;if(i)i==="app"?(a="app",r||(o="app")):(a=i,r||(o=i));else{let g=t,C=null;for(;g&&g!==document.body;){const w=g.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(w){const I=g.__originalComponentName;if(w===e.component||I===e.component){C=g;break}}g=g.parentElement}if(C){const w=C.getAttribute(d.ATTR_PREFIXES.COMPONENT);w&&(o=w);const I=C.getAttribute(d.ATTR_PREFIXES.CONTEXT);I&&(I==="app"?a="app":a=I)}for(g=t;g&&g!==document.body;){const w=g.__uniqueComponentName,I=g.__originalComponentName;if(w){a=w,(!C||!C.__originalComponentName)&&(o=I||e.component);break}g=g.parentElement}}r&&(o=r);const c=i==="app"||a==="app",l=a==="app",p=T.findElementForComponent(t,a);let h;if(c||l)h=this.componentManager.buildComponentContextWithProps(a,p||void 0);else if(h=this.componentManager.buildRestrictedComponentContext(a,!1),p){const g=this.componentManager.evaluateProps(p);Object.assign(h,g)}let f=t.parentElement,E=0;for(;f&&f!==document.body&&E<10;){if(E++,f.getAttribute(d.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(f)){const C=this.componentManager.evaluateProps(f);Object.assign(h,C);break}f=f.parentElement}if(o&&o!==a&&!o.includes("_loop_")){const g=this.getComponentOwnState(o);Object.assign(h,g)}if(a!==o&&window[a]){const g=window[a];for(const[C,w]of Object.entries(g))typeof w!="function"&&!(C in h)&&(h[C]=w)}const m={...h};for(const[g,C]of Object.entries(h))typeof C=="function"&&"__pphp_key"in C&&(m[g]=C.value);const x=this.loopManager?.getLoopContextForElement(t);if(x){const g={};for(const[C,w]of Object.entries(x)){if(typeof w=="function")continue;const I=`set${C.charAt(0).toUpperCase()}${C.slice(1)}`,K=`${C}Getter`,j=I in x&&typeof x[I]=="function",O=K in x&&typeof x[K]=="function";if(j||O)if(O){const Q=x[K],W=typeof Q.value<"u"?Q.value:Q();g[C]=W}else{const Q=m[C];Q!==void 0?g[C]=Q:g[C]=w}else g[C]=w}h={...m,...g}}else h=m;e.compiledFn||(e.compiledFn=this.compileHandler(e.code,o)),e.compiledFn&&e.compiledFn(n,t,h)}catch(i){console.error("💥 Event handler execution failed:",i),console.error("Handler code:",e.code),console.error("Handler component:",e.component)}}getComponentOwnState(e){const t={};window[e]&&Object.assign(t,window[e]);const n=this.stateManager?.getState();if(n){const i=Object.keys(n).filter(r=>r.startsWith(e+"."));for(const r of i){const a=r.substring(e.length+1);a in t||(t[a]=n[r])}}return t}attachDirectListener(e,t,n){const i=r=>{this.executeHandler(n,e,r)};e.addEventListener(t,i),e[`__${t}_listener`]=i}removeEventHandler(e,t){const n=this.elementHandlers.get(e);n&&(n.delete(t),n.size===0&&this.elementHandlers.delete(e));const i=this.delegatedEvents.get(t);i&&i.elements.delete?.(e);const r=e[`__${t}_listener`];r&&(e.removeEventListener(t,r),delete e[`__${t}_listener`])}cleanup(){for(const[e,t]of this.delegatedEvents)document.removeEventListener(e,t.listener,!0);this.delegatedEvents.clear(),this.handlerCache.clear(),this.setupEvents.clear()}}class $s{static instance=null;stateManager=new Fs;expressionEvaluator=new me;componentManager=new Ds(this.stateManager);domBindingManager=new Bs(this.stateManager,this.componentManager,this.expressionEvaluator);hydrationCallbacks=new Set;portalManager=new ks;initialized=!1;hydrationDone=!1;hydrationResolve;hydrationPromise;portalHydrationPromises=new Set;portalHydrationResolvers=new Map;constructor(){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.initialize()):setTimeout(()=>this.initialize(),0),this.hydrationPromise=new Promise(e=>this.hydrationResolve=e)}initialize(){this.initialized||(this.initialized=!0,this.markHydrationStart(),this.componentManager.setExpressionEvaluator(this.expressionEvaluator),this.portalManager.setDependencies(this.componentManager,this.domBindingManager,this.stateManager,this),this.componentManager.executePhpScripts(document.body),this.domBindingManager.processElement(document.body,!0),this.domBindingManager.processPendingBindings(),Promise.resolve().then(()=>{requestAnimationFrame(()=>{this.markHydrated()})}))}createPortal(e,t,n){const i=this.portalManager.createPortal(e,t,n),r=new Promise(a=>{this.portalHydrationResolvers.set(i,a)});return this.portalHydrationPromises.add(r),r.finally(()=>{this.portalHydrationPromises.delete(r),this.portalHydrationResolvers.delete(i)}),i}removePortal(e){return this.markPortalHydrated(e),this.portalManager.removePortal(e)}markPortalHydrated(e){const t=this.portalHydrationResolvers.get(e);t&&t()}updatePortal(e,t,n){return this.portalManager.updatePortal(e,t,n)}cleanup(){this.portalManager.destroy(),this.domBindingManager.destroy(),this.componentManager.destroy(),this.stateManager.clearState(),this.stateManager.clearSubscriptions(),this.expressionEvaluator.clearAllCaches(),this.hydrationCallbacks.clear(),this.deleteAllComponentObjects()}ref(e=null){return{current:e}}async hydrated(){await Promise.all([this.hydrationPromise,...Array.from(this.portalHydrationPromises)])}onHydrated(e){this.hydrationDone?queueMicrotask(e):this.hydrationCallbacks.add(e)}get isHydrated(){return this.hydrationDone}markHydrationStart(){document.dispatchEvent(new CustomEvent("pp:hydrationstart"))}markHydrated(){if(!this.hydrationDone){this.hydrationDone=!0,this.hydrationResolve();for(const e of this.hydrationCallbacks)try{e()}catch{}this.hydrationCallbacks.clear(),document.dispatchEvent(new CustomEvent("pp:hydrated",{detail:{at:performance.now()}}))}}state(e,t){const n=this.componentManager.getCurrentComponent();let i,r;typeof e=="string"&&arguments.length===2?(i=e,r=t):typeof e=="string"&&arguments.length===1?this.looksLikeVariableName(e)?(i=e,r=void 0):(console.warn("pp.state() called with string that doesn't look like variable name:",e),i="unknownState",r=e):(console.warn("pp.state() called without explicit key - this should be handled by AST transformation"),i="unknownState",r=e),r&&typeof r=="function"&&"__pphp_key"in r&&(r=r.value);let a;const o=this.getLoopExecutionContext();if(o){const h=this.generateLoopInstanceId(o);a=`${n}.${h}.${i}`}else a=`${n}.${i}`;this.stateManager.hasState(a)||this.stateManager.setInitialState(a,r);const c=(()=>this.stateManager.getState()[a]),l=new Proxy(c,{get(h,f,E){if(f==="__pphp_key"||f==="__pphp_fullKey"||f==="__pphp_component"||f==="value"||f==="valueOf"||f==="toString")return Reflect.get(h,f,E);const m=h();if(m!=null){if(f in Object(m)){const x=m[f];return typeof x=="function"?x.bind(m):x}return Reflect.get(h,f,E)}},has(h,f){if(f==="__pphp_key"||f==="__pphp_fullKey"||f==="__pphp_component"||f==="value"||f==="valueOf"||f==="toString")return Reflect.has(h,f);const E=h();return E!=null&&f in Object(E)?!0:Reflect.has(h,f)},apply(h,f,E){return Reflect.apply(h,f,E)}});Object.defineProperty(l,"__pphp_key",{value:i,enumerable:!1,writable:!1}),Object.defineProperty(l,"__pphp_fullKey",{value:a,enumerable:!1,writable:!1}),Object.defineProperty(l,"__pphp_component",{value:n,enumerable:!1,writable:!1}),Object.defineProperty(l,"value",{get:()=>this.stateManager.getState()[a],enumerable:!0,configurable:!0}),c.valueOf=()=>this.stateManager.getState()[a],c.toString=()=>ue(this.stateManager.getState()[a]);const p=h=>{const f=this.stateManager.getState()[a],E=typeof h=="function"?h(f):h;this.stateManager.setState(a,E)};return this.createComponentScopedGlobals(n,i,l,p),[l,p]}currentLoopContext=null;getLoopExecutionContext(){return this.currentLoopContext}generateLoopInstanceId(e){const n=Object.keys(e).sort().map(r=>{const a=e[r];return a&&typeof a=="object"&&"id"in a?`${r}:${a.id}`:`${r}:${JSON.stringify(a)}`});return`loop_${btoa(n.join("|")).replace(/[^a-zA-Z0-9]/g,"").substring(0,8)}`}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")&&!ge.has(e)}effect(e,t){const n=`effect_${Date.now()}_${Math.random()}`,i=this.componentManager.getCurrentComponent();let r,a=!1,o,c;if(arguments.length===1)o="always",c={immediate:!0,detectDeps:!0};else if(Array.isArray(t)){const p=this.extractDependencyNames(t,i);p.length===0?(o="once",c={deps:p,immediate:!0}):(o="deps",c={deps:p,immediate:!0})}else{const p={immediate:!0,...t||{}};if(!p.deps||p.deps.length===0)o="always",c={immediate:p.immediate,detectDeps:!0};else{const h=this.extractDependencyNames(p.deps,i);o="deps",c={deps:h,immediate:p.immediate,detectDeps:p.detectDeps}}}const l=()=>{a||this.stateManager.onDOMUpdateComplete(()=>{if(!a){if(r&&typeof r=="function")try{r()}catch(p){console.error("Effect cleanup error:",p)}try{r=e()}catch(p){console.error("Effect callback error:",p)}}})};switch(o){case"always":const p=["*"],h={id:n,selector:"",dependencies:new Set(p),callback:l,component:i};this.stateManager.addSubscription(h);break;case"once":break;case"deps":const f=this.resolveDependencies(c.deps,i);if(f.length){const E={id:n,selector:"",dependencies:new Set(f),callback:l,component:i};this.stateManager.addSubscription(E)}break}return c.immediate!==!1&&l(),()=>{if(a=!0,r&&typeof r=="function")try{r()}catch(p){console.error("Effect cleanup error:",p)}this.stateManager.removeSubscription(n)}}extractDependencyNames(e,t){const n=[];for(const i of e)typeof i=="string"?n.push(i):typeof i=="function"&&i.__pphp_key?n.push(i.__pphp_key):console.warn("Invalid dependency in effect:",i);return n.filter(Boolean)}resolveDependencies(e,t){const n=[],i=this.stateManager.getState();for(const r of e)if(r.includes(".")){const a=r.split("."),o=a[0],c=a.slice(1).join("."),l=this.componentManager.getPropDependencies(o,t);if(l.length>0)n.push(...l);else{const p=Ue.findExistingStateKey(o,t,i);p?n.push(`${p}.${c}`):n.push(`${t}.${r}`)}}else{const a=this.componentManager.getPropDependencies(r,t);if(a.length>0)n.push(...a);else{const o=Ue.findExistingStateKey(r,t,i);o?n.push(o):n.push(`${t}.${r}`)}}return Array.from(new Set(n))}createComponentScopedGlobals(e,t,n,i){window[e]||(window[e]={});const r=`set${jt(t)}`;window[e][t]=n,window[e][r]=i,window[e][`${t}Getter`]=n}deleteAllComponentObjects(){const e=Object.keys(window),t=new Set(["window","self","document","location","customElements","history","navigation","locationbar","menubar","personalbar","scrollbars","statusbar","toolbar","frames","top","parent","navigator","external","screen","visualViewport","crypto","performance","localStorage","sessionStorage","indexedDB","fetch","XMLHttpRequest","WebSocket","Worker","SharedWorker","MessageChannel","MessagePort","Notification","Push","BroadcastChannel","Cache","CacheStorage","requestAnimationFrame","cancelAnimationFrame","requestIdleCallback","cancelIdleCallback","setInterval","clearInterval","setTimeout","clearTimeout","queueMicrotask","atob","btoa","alert","confirm","prompt","open","close","focus","blur","print","stop","getComputedStyle","getSelection","matchMedia","scroll","scrollBy","scrollTo","resizeBy","resizeTo","moveBy","moveTo","pp","store","searchParams"]);for(const n of e){if(t.has(n))continue;const i=window[n];(/^s[a-z0-9]+$/i.test(n)||n==="app")&&i&&typeof i=="object"&&delete window[n]}}static resetInstance(){this.instance&&(this.instance.destroy(),this.instance=null)}destroy(){this.cleanup(),this.initialized=!1,this.hydrationDone=!1}}export{$s as P};
|