create-prisma-php-app 4.0.0-beta.5 → 4.0.0-rc
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/bootstrap.php +35 -45
- package/dist/index.js +1 -1
- package/dist/public/js/main.js +1 -2
- package/dist/public/js/pp-reactive-v1.js +1 -42
- package/dist/settings/bs-config.ts +16 -3
- package/dist/src/app/layout.php +2 -3
- package/dist/ts/main.ts +0 -1
- package/dist/vite.config.ts +13 -6
- package/package.json +1 -1
- package/dist/public/js/pp-utilities.js +0 -1
- /package/dist/{src/app → public}/favicon.ico +0 -0
|
@@ -1,42 +1 @@
|
|
|
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 Z(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 re(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 U(s,e){return new _(s,{beforeExpr:!0,binop:e})}var X={beforeExpr:!0},$={startsExpr:!0},Xe={};function w(s,e){return e===void 0&&(e={}),e.keyword=s,Xe[s]=new _(s,e)}var l={num:new _("num",$),regexp:new _("regexp",$),string:new _("string",$),name:new _("name",$),privateId:new _("privateId",$),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 _(",",X),semi:new _(";",X),colon:new _(":",X),dot:new _("."),question:new _("?",X),questionDot:new _("?."),arrow:new _("=>",X),template:new _("template"),invalidTemplate:new _("invalidTemplate"),ellipsis:new _("...",X),backQuote:new _("`",$),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:U("||",1),logicalAND:U("&&",2),bitwiseOR:U("|",3),bitwiseXOR:U("^",4),bitwiseAND:U("&",5),equality:U("==/!=/===/!==",6),relational:U("</>/<=/>=",7),bitShift:U("<</>>/>>>",8),plusMin:new _("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:U("%",10),star:U("*",10),slash:U("/",10),starstar:new _("**",{beforeExpr:!0}),coalesce:U("??",1),_break:w("break"),_case:w("case",X),_catch:w("catch"),_continue:w("continue"),_debugger:w("debugger"),_default:w("default",X),_do:w("do",{isLoop:!0,beforeExpr:!0}),_else:w("else",X),_finally:w("finally"),_for:w("for",{isLoop:!0}),_function:w("function",$),_if:w("if"),_return:w("return",X),_switch:w("switch"),_throw:w("throw",X),_try:w("try"),_var:w("var"),_const:w("const"),_while:w("while",{isLoop:!0}),_with:w("with"),_new:w("new",{beforeExpr:!0,startsExpr:!0}),_this:w("this",$),_super:w("super",$),_class:w("class",$),_extends:w("extends",X),_export:w("export"),_import:w("import",$),_null:w("null",$),_true:w("true",$),_false:w("false",$),_in:w("in",{beforeExpr:!0,binop:7}),_instanceof:w("instanceof",{beforeExpr:!0,binop:7}),_typeof:w("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:w("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:w("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},j=/\r\n?|\n|\u2028|\u2029/,Gt=new RegExp(j.source,"g");function me(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(me(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]/,L=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,lt=Object.prototype,Qt=lt.hasOwnProperty,Zt=lt.toString,ge=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 ie(s){return tt[s]||(tt[s]=new RegExp("^(?:"+s.replace(/ /g,"|")+")$"))}function te(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])/,ye=function(e,t){this.line=e,this.column=t};ye.prototype.offset=function(e){return new ye(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 ye(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&&ge(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 ve=1,xe=2,qe=4,ht=8,ze=16,ft=32,Ie=64,dt=128,ue=256,Te=512,Me=ve|xe|ue;function Ke(s,e){return xe|(s?qe:0)|(e?ht:0)}var Pe=0,Ge=1,ne=2,mt=3,gt=4,xt=5,O=function(e,t,n){this.options=e=Jt(e),this.sourceFile=e.sourceFile,this.keywords=ie(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=ie(i);var r=(i?i+" ":"")+Fe.strict;this.reservedWordsStrict=ie(r),this.reservedWordsStrictBind=ie(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(j).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=l.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(ve),this.regexpState=null,this.privateNameStack=[]},Y={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}};O.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};Y.inFunction.get=function(){return(this.currentVarScope().flags&xe)>0};Y.inGenerator.get=function(){return(this.currentVarScope().flags&ht)>0};Y.inAsync.get=function(){return(this.currentVarScope().flags&qe)>0};Y.canAwait.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(ue|Te))return!1;if(t&xe)return(t&qe)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Y.allowSuper.get=function(){var s=this.currentThisScope(),e=s.flags;return(e&Ie)>0||this.options.allowSuperOutsideMethod};Y.allowDirectSuper.get=function(){return(this.currentThisScope().flags&dt)>0};Y.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Y.allowNewDotTarget.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(ue|Te)||t&xe&&!(t&ze))return!0}return!1};Y.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ue)>0};O.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};O.parse=function(e,t){return new this(t,e).parse()};O.parseExpressionAt=function(e,t,n){var i=new this(n,e,t);return i.nextToken(),i.parseExpression()};O.tokenizer=function(e,t){return new this(t,e)};Object.defineProperties(O.prototype,Y);var V=O.prototype,ts=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;V.strictDirective=function(s){if(this.options.ecmaVersion<5)return!1;for(;;){L.lastIndex=s,s+=L.exec(this.input)[0].length;var e=ts.exec(this.input.slice(s));if(!e)return!1;if((e[1]||e[2])==="use strict"){L.lastIndex=s+e[0].length;var t=L.exec(this.input),n=t.index+t[0].length,i=this.input.charAt(n);return i===";"||i==="}"||j.test(t[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i==="!"&&this.input.charAt(n+1)==="=")}s+=e[0].length,L.lastIndex=s,s+=L.exec(this.input)[0].length,this.input[s]===";"&&s++}};V.eat=function(s){return this.type===s?(this.next(),!0):!1};V.isContextual=function(s){return this.type===l.name&&this.value===s&&!this.containsEsc};V.eatContextual=function(s){return this.isContextual(s)?(this.next(),!0):!1};V.expectContextual=function(s){this.eatContextual(s)||this.unexpected()};V.canInsertSemicolon=function(){return this.type===l.eof||this.type===l.braceR||j.test(this.input.slice(this.lastTokEnd,this.start))};V.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};V.semicolon=function(){!this.eat(l.semi)&&!this.insertSemicolon()&&this.unexpected()};V.afterTrailingComma=function(s,e){if(this.type===s)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};V.expect=function(s){this.eat(s)||this.unexpected()};V.unexpected=function(s){this.raise(s??this.start,"Unexpected token")};var Re=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};V.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")}};V.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")};V.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")};V.isSimpleAssignTarget=function(s){return s.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(s.expression):s.type==="Identifier"||s.type==="MemberExpression"};var C=O.prototype;C.parseTopLevel=function(s){var e=Object.create(null);for(s.body||(s.body=[]);this.type!==l.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"};C.isLet=function(s){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;L.lastIndex=this.pos;var e=L.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(Z(n,!0)){for(var i=t+1;re(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};C.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;L.lastIndex=this.pos;var s=L.exec(this.input),e=this.pos+s[0].length,t;return!j.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(re(t=this.input.charCodeAt(e+8))||t>55295&&t<56320))};C.isUsingKeyword=function(s,e){if(this.options.ecmaVersion<17||!this.isContextual(s?"await":"using"))return!1;L.lastIndex=this.pos;var t=L.exec(this.input),n=this.pos+t[0].length;if(j.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||re(r=this.input.charCodeAt(i))||r>55295&&r<56320)return!1;L.lastIndex=i;var a=L.exec(this.input);if(a&&j.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||!re(c=this.input.charCodeAt(o))&&!(c>55295&&c<56320)))return!1}var u=this.input.charCodeAt(n);return Z(u,!0)||u===92};C.isAwaitUsing=function(s){return this.isUsingKeyword(!0,s)};C.isUsing=function(s){return this.isUsingKeyword(!1,s)};C.parseStatement=function(s,e,t){var n=this.type,i=this.startNode(),r;switch(this.isLet(s)&&(n=l._var,r="let"),n){case l._break:case l._continue:return this.parseBreakContinueStatement(i,n.keyword);case l._debugger:return this.parseDebuggerStatement(i);case l._do:return this.parseDoStatement(i);case l._for:return this.parseForStatement(i);case l._function:return s&&(this.strict||s!=="if"&&s!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!s);case l._class:return s&&this.unexpected(),this.parseClass(i,!0);case l._if:return this.parseIfStatement(i);case l._return:return this.parseReturnStatement(i);case l._switch:return this.parseSwitchStatement(i);case l._throw:return this.parseThrowStatement(i);case l._try:return this.parseTryStatement(i);case l._const:case l._var:return r=r||this.value,s&&r!=="var"&&this.unexpected(),this.parseVarStatement(i,r);case l._while:return this.parseWhileStatement(i);case l._with:return this.parseWithStatement(i);case l.braceL:return this.parseBlock(!0,i);case l.semi:return this.parseEmptyStatement(i);case l._export:case l._import:if(this.options.ecmaVersion>10&&n===l._import){L.lastIndex=this.pos;var a=L.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===l._import?this.parseImport(i):this.parseExport(i,t);default:if(this.isAsyncFunction())return s&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!s);var u=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(u)return e&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),u==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(i,!1,u),this.semicolon(),this.finishNode(i,"VariableDeclaration");var p=this.value,h=this.parseExpression();return n===l.name&&h.type==="Identifier"&&this.eat(l.colon)?this.parseLabeledStatement(i,p,h,s):this.parseExpressionStatement(i,h)}};C.parseBreakContinueStatement=function(s,e){var t=e==="break";this.next(),this.eat(l.semi)||this.insertSemicolon()?s.label=null:this.type!==l.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")};C.parseDebuggerStatement=function(s){return this.next(),this.semicolon(),this.finishNode(s,"DebuggerStatement")};C.parseDoStatement=function(s){return this.next(),this.labels.push(Qe),s.body=this.parseStatement("do"),this.labels.pop(),this.expect(l._while),s.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(l.semi):this.semicolon(),this.finishNode(s,"DoWhileStatement")};C.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(l.parenL),this.type===l.semi)return e>-1&&this.unexpected(e),this.parseFor(s,null);var t=this.isLet();if(this.type===l._var||this.type===l._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 u=this.containsEsc,p=new Re,h=this.start,f=e>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===l._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===l._in&&this.unexpected(e),s.await=!0):a&&this.options.ecmaVersion>=8&&(f.start===h&&!u&&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))};C.parseForAfterInit=function(s,e,t){return(this.type===l._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===l._in?t>-1&&this.unexpected(t):s.await=t>-1),this.parseForIn(s,e)):(t>-1&&this.unexpected(t),this.parseFor(s,e))};C.parseFunctionStatement=function(s,e,t){return this.next(),this.parseFunction(s,Ce|(t?0:We),!1,e)};C.parseIfStatement=function(s){return this.next(),s.test=this.parseParenExpression(),s.consequent=this.parseStatement("if"),s.alternate=this.eat(l._else)?this.parseStatement("if"):null,this.finishNode(s,"IfStatement")};C.parseReturnStatement=function(s){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(l.semi)||this.insertSemicolon()?s.argument=null:(s.argument=this.parseExpression(),this.semicolon()),this.finishNode(s,"ReturnStatement")};C.parseSwitchStatement=function(s){this.next(),s.discriminant=this.parseParenExpression(),s.cases=[],this.expect(l.braceL),this.labels.push(ss),this.enterScope(0);for(var e,t=!1;this.type!==l.braceR;)if(this.type===l._case||this.type===l._default){var n=this.type===l._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(l.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")};C.parseThrowStatement=function(s){return this.next(),j.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=[];C.parseCatchClauseParam=function(){var s=this.parseBindingAtom(),e=s.type==="Identifier";return this.enterScope(e?ft:0),this.checkLValPattern(s,e?gt:ne),this.expect(l.parenR),s};C.parseTryStatement=function(s){if(this.next(),s.block=this.parseBlock(),s.handler=null,this.type===l._catch){var e=this.startNode();this.next(),this.eat(l.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(l._finally)?this.parseBlock():null,!s.handler&&!s.finalizer&&this.raise(s.start,"Missing catch or finally clause"),this.finishNode(s,"TryStatement")};C.parseVarStatement=function(s,e,t){return this.next(),this.parseVar(s,!1,e,t),this.semicolon(),this.finishNode(s,"VariableDeclaration")};C.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")};C.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")};C.parseEmptyStatement=function(s){return this.next(),this.finishNode(s,"EmptyStatement")};C.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===l._switch?"switch":null,c=this.labels.length-1;c>=0;c--){var u=this.labels[c];if(u.statementStart===s.start)u.statementStart=this.start,u.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")};C.parseExpressionStatement=function(s,e){return s.expression=e,this.semicolon(),this.finishNode(s,"ExpressionStatement")};C.parseBlock=function(s,e,t){for(s===void 0&&(s=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(l.braceL),s&&this.enterScope(0);this.type!==l.braceR;){var n=this.parseStatement(null);e.body.push(n)}return t&&(this.strict=!1),this.next(),s&&this.exitScope(),this.finishNode(e,"BlockStatement")};C.parseFor=function(s,e){return s.init=e,this.expect(l.semi),s.test=this.type===l.semi?null:this.parseExpression(),this.expect(l.semi),s.update=this.type===l.parenR?null:this.parseExpression(),this.expect(l.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,"ForStatement")};C.parseForIn=function(s,e){var t=this.type===l._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(l.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,t?"ForInStatement":"ForOfStatement")};C.parseVar=function(s,e,t,n){for(s.declarations=[],s.kind=t;;){var i=this.startNode();if(this.parseVarId(i,t),this.eat(l.eq)?i.init=this.parseMaybeAssign(e):!n&&t==="const"&&!(this.type===l._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!n&&(t==="using"||t==="await using")&&this.options.ecmaVersion>=17&&this.type!==l._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+t+" declaration"):!n&&i.id.type!=="Identifier"&&!(e&&(this.type===l._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(l.comma))break}return s};C.parseVarId=function(s,e){s.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(s.id,e==="var"?Ge:ne,!1)};var Ce=1,We=2,Et=4;C.parseFunction=function(s,e,t,n,i){this.initFunction(s),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!n)&&(this.type===l.star&&e&We&&this.unexpected(),s.generator=this.eat(l.star)),this.options.ecmaVersion>=8&&(s.async=!!n),e&Ce&&(s.id=e&Et&&this.type!==l.name?null:this.parseIdent(),s.id&&!(e&We)&&this.checkLValSimple(s.id,this.strict||s.generator||s.async?this.treatFunctionsAsVar?Ge:ne: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&Ce||(s.id=this.type===l.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&Ce?"FunctionDeclaration":"FunctionExpression")};C.parseFunctionParams=function(s){this.expect(l.parenL),s.params=this.parseBindingList(l.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};C.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(l.braceL);this.type!==l.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")};C.parseClassElement=function(s){if(this.eat(l.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(l.braceL))return this.parseClassStaticBlock(t),t;this.isClassElementNameStart()||this.type===l.star?o=!0:n="static"}if(t.static=o,!n&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===l.star)&&!this.canInsertSemicolon()?r=!0:n="async"),!n&&(e>=9||!r)&&this.eat(l.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===l.parenL||a!=="method"||i||r){var u=!t.static&&we(t,"constructor"),p=u&&s;u&&a!=="method"&&this.raise(t.key.start,"Constructor can't have get/set modifier"),t.kind=u?"constructor":a,this.parseClassMethod(t,i,r,p)}else this.parseClassField(t);return t};C.isClassElementNameStart=function(){return this.type===l.name||this.type===l.privateId||this.type===l.num||this.type===l.string||this.type===l.bracketL||this.type.keyword};C.parseClassElementName=function(s){this.type===l.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)};C.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")};C.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(l.eq)?(this.enterScope(Te|Ie),s.value=this.parseMaybeAssign(),this.exitScope()):s.value=null,this.semicolon(),this.finishNode(s,"PropertyDefinition")};C.parseClassStaticBlock=function(s){s.body=[];var e=this.labels;for(this.labels=[],this.enterScope(ue|Ie);this.type!==l.braceR;){var t=this.parseStatement(null);s.body.push(t)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(s,"StaticBlock")};C.parseClassId=function(s,e){this.type===l.name?(s.id=this.parseIdent(),e&&this.checkLValSimple(s.id,ne,!1)):(e===!0&&this.unexpected(),s.id=null)};C.parseClassSuper=function(s){s.superClass=this.eat(l._extends)?this.parseExprSubscripts(null,!1):null};C.enterClassBody=function(){var s={declared:Object.create(null),used:[]};return this.privateNameStack.push(s),s.declared};C.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];ge(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)}C.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!==l.string&&this.unexpected(),s.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ExportAllDeclaration")};C.parseExport=function(s,e){if(this.next(),this.eat(l.star))return this.parseExportAllDeclaration(s,e);if(this.eat(l._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!==l.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")};C.parseExportDeclaration=function(s){return this.parseStatement(null)};C.parseExportDefaultDeclaration=function(){var s;if(this.type===l._function||(s=this.isAsyncFunction())){var e=this.startNode();return this.next(),s&&this.next(),this.parseFunction(e,Ce|Et,!1,s)}else if(this.type===l._class){var t=this.startNode();return this.parseClass(t,"nullableID")}else{var n=this.parseMaybeAssign();return this.semicolon(),n}};C.checkExport=function(s,e,t){s&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),ge(s,e)&&this.raiseRecoverable(t,"Duplicate export '"+e+"'"),s[e]=!0)};C.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)};C.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)}};C.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};C.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")};C.parseExportSpecifiers=function(s){var e=[],t=!0;for(this.expect(l.braceL);!this.eat(l.braceR);){if(t)t=!1;else if(this.expect(l.comma),this.afterTrailingComma(l.braceR))break;e.push(this.parseExportSpecifier(s))}return e};C.parseImport=function(s){return this.next(),this.type===l.string?(s.specifiers=ns,s.source=this.parseExprAtom()):(s.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),s.source=this.type===l.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ImportDeclaration")};C.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,ne),this.finishNode(s,"ImportSpecifier")};C.parseImportDefaultSpecifier=function(){var s=this.startNode();return s.local=this.parseIdent(),this.checkLValSimple(s.local,ne),this.finishNode(s,"ImportDefaultSpecifier")};C.parseImportNamespaceSpecifier=function(){var s=this.startNode();return this.next(),this.expectContextual("as"),s.local=this.parseIdent(),this.checkLValSimple(s.local,ne),this.finishNode(s,"ImportNamespaceSpecifier")};C.parseImportSpecifiers=function(){var s=[],e=!0;if(this.type===l.name&&(s.push(this.parseImportDefaultSpecifier()),!this.eat(l.comma)))return s;if(this.type===l.star)return s.push(this.parseImportNamespaceSpecifier()),s;for(this.expect(l.braceL);!this.eat(l.braceR);){if(e)e=!1;else if(this.expect(l.comma),this.afterTrailingComma(l.braceR))break;s.push(this.parseImportSpecifier())}return s};C.parseWithClause=function(){var s=[];if(!this.eat(l._with))return s;this.expect(l.braceL);for(var e={},t=!0;!this.eat(l.braceR);){if(t)t=!1;else if(this.expect(l.comma),this.afterTrailingComma(l.braceR))break;var n=this.parseImportAttribute(),i=n.key.type==="Identifier"?n.key.name:n.key.value;ge(e,i)&&this.raiseRecoverable(n.key.start,"Duplicate attribute key '"+i+"'"),e[i]=!0,s.push(n)}return s};C.parseImportAttribute=function(){var s=this.startNode();return s.key=this.type===l.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(l.colon),this.type!==l.string&&this.unexpected(),s.value=this.parseExprAtom(),this.finishNode(s,"ImportAttribute")};C.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===l.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)};C.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)};C.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=O.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!==l.name&&this.unexpected(),s.argument=this.parseBindingAtom(),this.finishNode(s,"RestElement")};K.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case l.bracketL:var s=this.startNode();return this.next(),s.elements=this.parseBindingList(l.bracketR,!0,!0),this.finishNode(s,"ArrayPattern");case l.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(l.comma),e&&this.type===l.comma)i.push(null);else{if(t&&this.afterTrailingComma(s))break;if(this.type===l.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),i.push(a),this.type===l.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(l.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===ne&&s.name==="let"&&this.raiseRecoverable(s.start,"let is disallowed as a lexically bound name"),t&&(ge(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},M={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)},Ee=O.prototype;Ee.initialContext=function(){return[M.b_stat]};Ee.curContext=function(){return this.context[this.context.length-1]};Ee.braceIsBlock=function(s){var e=this.curContext();return e===M.f_expr||e===M.f_stat?!0:s===l.colon&&(e===M.b_stat||e===M.b_expr)?!e.isExpr:s===l._return||s===l.name&&this.exprAllowed?j.test(this.input.slice(this.lastTokEnd,this.start)):s===l._else||s===l.semi||s===l.eof||s===l.parenR||s===l.arrow?!0:s===l.braceL?e===M.b_stat:s===l._var||s===l._const||s===l.name?!1:!this.exprAllowed};Ee.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};Ee.updateContext=function(s){var e,t=this.type;t.keyword&&s===l.dot?this.exprAllowed=!1:(e=t.updateContext)?e.call(this,s):this.exprAllowed=t.beforeExpr};Ee.overrideContext=function(s){this.curContext()!==s&&(this.context[this.context.length-1]=s)};l.parenR.updateContext=l.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var s=this.context.pop();s===M.b_stat&&this.curContext().token==="function"&&(s=this.context.pop()),this.exprAllowed=!s.isExpr};l.braceL.updateContext=function(s){this.context.push(this.braceIsBlock(s)?M.b_stat:M.b_expr),this.exprAllowed=!0};l.dollarBraceL.updateContext=function(){this.context.push(M.b_tmpl),this.exprAllowed=!0};l.parenL.updateContext=function(s){var e=s===l._if||s===l._for||s===l._with||s===l._while;this.context.push(e?M.p_stat:M.p_expr),this.exprAllowed=!0};l.incDec.updateContext=function(){};l._function.updateContext=l._class.updateContext=function(s){s.beforeExpr&&s!==l._else&&!(s===l.semi&&this.curContext()!==M.p_stat)&&!(s===l._return&&j.test(this.input.slice(this.lastTokEnd,this.start)))&&!((s===l.colon||s===l.braceL)&&this.curContext()===M.b_stat)?this.context.push(M.f_expr):this.context.push(M.f_stat),this.exprAllowed=!1};l.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};l.backQuote.updateContext=function(){this.curContext()===M.q_tmpl?this.context.pop():this.context.push(M.q_tmpl),this.exprAllowed=!1};l.star.updateContext=function(s){if(s===l._function){var e=this.context.length-1;this.context[e]===M.f_expr?this.context[e]=M.f_expr_gen:this.context[e]=M.f_gen}this.exprAllowed=!0};l.name.updateContext=function(s){var e=!1;this.options.ecmaVersion>=6&&s!==l.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var S=O.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===l.comma){var r=this.startNodeAt(t,n);for(r.expressions=[i];this.eat(l.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===l.parenL||this.type===l.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=s==="await");var u=this.parseMaybeConditional(s,e);if(t&&(u=t.call(this,u,o,c)),this.type.isAssign){var p=this.startNodeAt(o,c);return p.operator=this.value,this.type===l.eq&&(u=this.toAssignable(u,!1,e)),n||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=u.start&&(e.shorthandAssign=-1),this.type===l.eq?this.checkLValPattern(u):this.checkLValSimple(u),p.left=u,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),u};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(l.question)){var r=this.startNodeAt(t,n);return r.test=i,r.consequent=this.parseMaybeAssign(),this.expect(l.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!==l._in)&&r>n){var a=this.type===l.logicalOR||this.type===l.logicalAND,o=this.type===l.coalesce;o&&(r=l.logicalAND.binop);var c=this.value;this.next();var u=this.start,p=this.startLoc,h=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),u,p,r,i),f=this.buildBinary(e,t,s,h,c,a||o);return(a&&this.type===l.coalesce||o&&(this.type===l.logicalOR||this.type===l.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===l.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"&&je(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===l.privateId)(n||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==l._in&&this.unexpected();else{if(a=this.parseExprSubscripts(s,n),this.checkExpressionErrors(s))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=this.startNodeAt(i,r);u.operator=this.value,u.prefix=!1,u.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(u,"UpdateExpression")}}if(!t&&this.eat(l.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 je(s){return s.type==="MemberExpression"&&s.property.type==="PrivateIdentifier"||s.type==="ChainExpression"&&je(s.expression)||s.type==="ParenthesizedExpression"&&je(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(l.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(l.questionDot);n&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var u=this.eat(l.bracketL);if(u||c&&this.type!==l.parenL&&this.type!==l.backQuote||this.eat(l.dot)){var p=this.startNodeAt(e,t);p.object=s,u?(p.property=this.parseExpression(),this.expect(l.bracketR)):this.type===l.privateId&&s.type!=="Super"?p.property=this.parsePrivateIdent():p.property=this.parseIdent(this.options.allowReserved!=="never"),p.computed=!!u,o&&(p.optional=c),s=this.finishNode(p,"MemberExpression")}else if(!n&&this.eat(l.parenL)){var h=new Re,f=this.yieldPos,g=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var E=this.parseExprList(l.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=g,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(e,t,E,a);this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=g||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var y=this.startNodeAt(e,t);y.callee=s,y.arguments=E,o&&(y.optional=c),s=this.finishNode(y,"CallExpression")}else if(this.type===l.backQuote){(c||r)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var v=this.startNodeAt(e,t);v.tag=s,v.quasi=this.parseTemplate({isTagged:!0}),s=this.finishNode(v,"TaggedTemplateExpression")}return s};S.parseExprAtom=function(s,e,t){this.type===l.slash&&this.readRegexp();var n,i=this.potentialArrowAt===this.start;switch(this.type){case l._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),n=this.startNode(),this.next(),this.type===l.parenL&&!this.allowDirectSuper&&this.raise(n.start,"super() call outside constructor of a subclass"),this.type!==l.dot&&this.type!==l.bracketL&&this.type!==l.parenL&&this.unexpected(),this.finishNode(n,"Super");case l._this:return n=this.startNode(),this.next(),this.finishNode(n,"ThisExpression");case l.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(l._function))return this.overrideContext(M.f_expr),this.parseFunction(this.startNodeAt(r,a),0,!1,!0,e);if(i&&!this.canInsertSemicolon()){if(this.eat(l.arrow))return this.parseArrowExpression(this.startNodeAt(r,a),[c],!1,e);if(this.options.ecmaVersion>=8&&c.name==="async"&&this.type===l.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(l.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,a),[c],!0,e)}return c;case l.regexp:var u=this.value;return n=this.parseLiteral(u.value),n.regex={pattern:u.pattern,flags:u.flags},n;case l.num:case l.string:return this.parseLiteral(this.value);case l._null:case l._true:case l._false:return n=this.startNode(),n.value=this.type===l._null?null:this.type===l._true,n.raw=this.type.keyword,this.next(),this.finishNode(n,"Literal");case l.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 l.bracketL:return n=this.startNode(),this.next(),n.elements=this.parseExprList(l.bracketR,!0,!0,s),this.finishNode(n,"ArrayExpression");case l.braceL:return this.overrideContext(M.b_expr),this.parseObj(!1,s);case l._function:return n=this.startNode(),this.next(),this.parseFunction(n,0);case l._class:return this.parseClass(this.startNode(),!1);case l._new:return this.parseNew();case l.backQuote:return this.parseTemplate();case l._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===l.parenL&&!s)return this.parseDynamicImport(e);if(this.type===l.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(l.parenR)?s.options=null:(this.expect(l.comma),this.afterTrailingComma(l.parenR)?s.options=null:(s.options=this.parseMaybeAssign(),this.eat(l.parenR)||(this.expect(l.comma),this.afterTrailingComma(l.parenR)||this.unexpected())));else if(!this.eat(l.parenR)){var e=this.start;this.eat(l.comma)&&this.eat(l.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(l.parenL);var s=this.parseExpression();return this.expect(l.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=[],u=!0,p=!1,h=new Re,f=this.yieldPos,g=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==l.parenR;)if(u?u=!1:this.expect(l.comma),r&&this.afterTrailingComma(l.parenR,!0)){p=!0;break}else if(this.type===l.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===l.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else c.push(this.parseMaybeAssign(!1,h,this.parseParenItem));var E=this.lastTokEnd,y=this.lastTokEndLoc;if(this.expect(l.parenR),s&&this.shouldParseArrow(c)&&this.eat(l.arrow))return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=g,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=g||this.awaitPos,c.length>1?(i=this.startNodeAt(a,o),i.expressions=c,this.finishNodeAt(i,"SequenceExpression",E,y)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var v=this.startNodeAt(t,n);return v.expression=i,this.finishNode(v,"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===l.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(l.parenL)?s.arguments=this.parseExprList(l.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===l.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),t.value={raw:this.value.replace(/\r\n?/g,`
|
|
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===l.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===l.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(l.dollarBraceL),t.expressions.push(this.parseExpression()),this.expect(l.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===l.name||this.type===l.num||this.type===l.string||this.type===l.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===l.star)&&!j.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(l.braceR);){if(n)n=!1;else if(this.expect(l.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(l.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(l.ellipsis))return s?(t.argument=this.parseIdent(!1),this.type===l.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===l.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(l.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(l.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===l.colon&&this.unexpected(),this.eat(l.colon)?(s.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),s.kind="init"):this.options.ecmaVersion>=6&&this.type===l.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!==l.comma&&this.type!==l.braceR&&this.type!==l.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===l.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(l.bracketL))return s.computed=!0,s.key=this.parseMaybeAssign(),this.expect(l.bracketR),s.key;s.computed=!1}return s.key=this.type===l.num||this.type===l.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(l.parenL),n.params=this.parseBindingList(l.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!==l.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(l.comma),e&&this.afterTrailingComma(s))break;var a=void 0;t&&this.type===l.comma?a=null:this.type===l.ellipsis?(a=this.parseSpread(n),n&&this.type===l.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===l.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=l.name):this.unexpected(),s};S.parsePrivateIdent=function(){var s=this.startNode();return this.type===l.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===l.semi||this.canInsertSemicolon()||this.type!==l.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(l.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=O.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 ye(this.curLine,this.pos-this.lineStart)};var ae=O.prototype,as=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};ae.enterScope=function(s){this.scopeStack.push(new as(s))};ae.exitScope=function(){this.scopeStack.pop()};ae.treatFunctionsAsVarInScope=function(s){return s.flags&xe||!this.inModule&&s.flags&ve};ae.declareName=function(s,e,t){var n=!1;if(e===ne){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&ve&&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&ve&&delete this.undefinedExports[s],c.flags&Me)break}n&&this.raiseRecoverable(t,"Identifier '"+s+"' has already been declared")};ae.checkLocalExport=function(s){this.scopeStack[0].lexical.indexOf(s.name)===-1&&this.scopeStack[0].var.indexOf(s.name)===-1&&(this.undefinedExports[s.name]=s)};ae.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};ae.currentVarScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(Me|Te|ue))return e}};ae.currentThisScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(Me|Te|ue)&&!(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=O.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",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:ie(us[s]+" "+nt),binaryOfStrings:ie(ps[s]),nonBinary:{General_Category:ie(nt),Script:ie(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 b=O.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 J=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};J.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)};J.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};J.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};J.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};J.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};J.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};J.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};J.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1};J.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};b.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}b.validateRegExpPattern=function(s){this.regexp_pattern(s),!s.switchN&&this.options.ecmaVersion>=9&&gs(s.groupNames)&&(s.switchN=!0,this.regexp_pattern(s))};b.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")}};b.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")};b.regexp_alternative=function(s){for(;s.pos<s.source.length&&this.regexp_eatTerm(s););};b.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};b.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};b.regexp_eatQuantifier=function(s,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(s,e)?(s.eat(63),!0):!1};b.regexp_eatQuantifierPrefix=function(s,e){return s.eat(42)||s.eat(43)||s.eat(63)||this.regexp_eatBracedQuantifier(s,e)};b.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};b.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)};b.regexp_eatReverseSolidusAtomEscape=function(s){var e=s.pos;if(s.eat(92)){if(this.regexp_eatAtomEscape(s))return!0;s.pos=e}return!1};b.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};b.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};b.regexp_eatModifiers=function(s){for(var e="",t=0;(t=s.current())!==-1&&xs(t);)e+=te(t),s.advance();return e};function xs(s){return s===105||s===109||s===115}b.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)};b.regexp_eatInvalidBracedQuantifier=function(s){return this.regexp_eatBracedQuantifier(s,!0)&&s.raise("Nothing to repeat"),!1};b.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}b.regexp_eatPatternCharacters=function(s){for(var e=s.pos,t=0;(t=s.current())!==-1&&!Mt(t);)s.advance();return s.pos!==e};b.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};b.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}};b.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};b.regexp_eatRegExpIdentifierName=function(s){if(s.lastStringValue="",this.regexp_eatRegExpIdentifierStart(s)){for(s.lastStringValue+=te(s.lastIntValue);this.regexp_eatRegExpIdentifierPart(s);)s.lastStringValue+=te(s.lastIntValue);return!0}return!1};b.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 Z(s,!0)||s===36||s===95}b.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 re(s,!0)||s===36||s===95||s===8204||s===8205}b.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)};b.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};b.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};b.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)};b.regexp_eatCControlLetter=function(s){var e=s.pos;if(s.eat(99)){if(this.regexp_eatControlLetter(s))return!0;s.pos=e}return!1};b.regexp_eatZero=function(s){return s.current()===48&&!Le(s.lookahead())?(s.lastIntValue=0,s.advance(),!0):!1};b.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};b.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}b.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}b.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};b.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,se=1,q=2;b.regexp_eatCharacterClassEscape=function(s){var e=s.current();if(ys(e))return s.lastIntValue=-1,s.advance(),se;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 Ot};function ys(s){return s===100||s===68||s===115||s===83||s===119||s===87}b.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),se}}if(s.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(s)){var i=s.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(s,i)}return Ot};b.regexp_validateUnicodePropertyNameAndValue=function(s,e,t){ge(s.unicodeProperties.nonBinary,e)||s.raise("Invalid property name"),s.unicodeProperties.nonBinary[e].test(t)||s.raise("Invalid property value")};b.regexp_validateUnicodePropertyNameOrValue=function(s,e){if(s.unicodeProperties.binary.test(e))return se;if(s.switchV&&s.unicodeProperties.binaryOfStrings.test(e))return q;s.raise("Invalid property name")};b.regexp_eatUnicodePropertyName=function(s){var e=0;for(s.lastStringValue="";Lt(e=s.current());)s.lastStringValue+=te(e),s.advance();return s.lastStringValue!==""};function Lt(s){return Rt(s)||s===95}b.regexp_eatUnicodePropertyValue=function(s){var e=0;for(s.lastStringValue="";vs(e=s.current());)s.lastStringValue+=te(e),s.advance();return s.lastStringValue!==""};function vs(s){return Lt(s)||Le(s)}b.regexp_eatLoneUnicodePropertyNameOrValue=function(s){return this.regexp_eatUnicodePropertyValue(s)};b.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};b.regexp_classContents=function(s){return s.current()===93?se:s.switchV?this.regexp_classSetExpression(s):(this.regexp_nonEmptyClassRanges(s),se)};b.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")}}};b.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};b.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)};b.regexp_classSetExpression=function(s){var e=se,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=se);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)}};b.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};b.regexp_eatClassSetOperand=function(s){return this.regexp_eatClassSetCharacter(s)?se:this.regexp_eatClassStringDisjunction(s)||this.regexp_eatNestedClass(s)};b.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};b.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};b.regexp_classStringDisjunctionContents=function(s){for(var e=this.regexp_classString(s);s.eat(124);)this.regexp_classString(s)===q&&(e=q);return e};b.regexp_classString=function(s){for(var e=0;this.regexp_eatClassSetCharacter(s);)e++;return e===1?se:q};b.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}b.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}b.regexp_eatClassControlLetter=function(s){var e=s.current();return Le(e)||e===95?(s.lastIntValue=e%32,s.advance(),!0):!1};b.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};b.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}b.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}b.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};b.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}b.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=O.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===l.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(l.eof);if(s.override)return s.override(this);this.readToken(this.fullCharCodeAtPos())};P.readToken=function(s){return Z(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&&!me(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(l.ellipsis)):(++this.pos,this.finishToken(l.dot))};P.readToken_slash=function(){var s=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):s===61?this.finishOp(l.assign,2):this.finishOp(l.slash,1)};P.readToken_mult_modulo_exp=function(s){var e=this.input.charCodeAt(this.pos+1),t=1,n=s===42?l.star:l.modulo;return this.options.ecmaVersion>=7&&s===42&&e===42&&(++t,n=l.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(l.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(l.assign,3)}return this.finishOp(s===124?l.logicalOR:l.logicalAND,2)}return e===61?this.finishOp(l.assign,2):this.finishOp(s===124?l.bitwiseOR:l.bitwiseAND,1)};P.readToken_caret=function(){var s=this.input.charCodeAt(this.pos+1);return s===61?this.finishOp(l.assign,2):this.finishOp(l.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||j.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(l.incDec,2):e===61?this.finishOp(l.assign,2):this.finishOp(l.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(l.assign,t+1):this.finishOp(l.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(l.relational,t))};P.readToken_eq_excl=function(s){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(l.equality,this.input.charCodeAt(this.pos+2)===61?3:2):s===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(l.arrow)):this.finishOp(s===61?l.eq:l.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(l.questionDot,2)}if(e===63){if(s>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(l.assign,3)}return this.finishOp(l.coalesce,2)}}return this.finishOp(l.question,1)};P.readToken_numberSign=function(){var s=this.options.ecmaVersion,e=35;if(s>=13&&(++this.pos,e=this.fullCharCodeAtPos(),Z(e,!0)||e===92))return this.finishToken(l.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+te(e)+"'")};P.getTokenFromCode=function(s){switch(s){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(l.parenL);case 41:return++this.pos,this.finishToken(l.parenR);case 59:return++this.pos,this.finishToken(l.semi);case 44:return++this.pos,this.finishToken(l.comma);case 91:return++this.pos,this.finishToken(l.bracketL);case 93:return++this.pos,this.finishToken(l.bracketR);case 123:return++this.pos,this.finishToken(l.braceL);case 125:return++this.pos,this.finishToken(l.braceR);case 58:return++this.pos,this.finishToken(l.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(l.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(l.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+te(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(j.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 J(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(l.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,u=e??1/0;c<u;++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):Z(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(l.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,Z(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(l.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")),Z(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=Ps(this.input.slice(e,this.pos),t);return this.finishToken(l.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)):(me(n)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(t,this.pos++),this.finishToken(l.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===l.template||this.type===l.invalidTemplate)?t===36?(this.pos+=2,this.finishToken(l.dollarBraceL)):(++this.pos,this.finishToken(l.backQuote)):(s+=this.input.slice(e,this.pos),this.finishToken(l.template,s));if(t===92)s+=this.input.slice(e,this.pos),s+=this.readEscapedChar(!0),e=this.pos;else if(me(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}};P.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(l.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
7
|
-
`&&++this.pos;case`
|
|
8
|
-
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};P.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 te(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 me(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(re(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?Z:re)(a,n)||this.invalidStringToken(r,"Invalid Unicode escape"),s+=te(a),t=this.pos}else break;e=!1}return s+this.input.slice(t,this.pos)};P.readWord=function(){var s=this.readWord1(),e=l.name;return this.keywords.test(s)&&(e=Xe[s]),this.finishToken(e,s)};var ws="8.15.0";O.acorn={Parser:O,version:ws,defaultOptions:$e,Position:ye,SourceLocation:ke,getLineInfo:pt,Node:Oe,TokenType:_,tokTypes:l,keywordTypes:Xe,TokContext:G,tokContexts:M,isIdentifierChar:re,isIdentifierStart:Z,Token:Ze,isNewLine:me,lineBreak:j,lineBreakG:Gt,nonASCIIwhitespace:ut};function F(s,e){return O.parse(s,e)}function H(s,e,t,n,i){t||(t=x),(function r(a,o,c){var u=c||a.type;t[u](a,o,r),e[u]&&e[u](a,o)})(s,n,i)}function _s(s,e,t,n,i){var r=[];t||(t=x),(function a(o,c,u){var p=u||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 le(s,e,t){}var x={};x.Program=x.BlockStatement=x.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")}};x.Statement=Ye;x.EmptyStatement=le;x.ExpressionStatement=x.ParenthesizedExpression=x.ChainExpression=function(s,e,t){return t(s.expression,e,"Expression")};x.IfStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Statement"),s.alternate&&t(s.alternate,e,"Statement")};x.LabeledStatement=function(s,e,t){return t(s.body,e,"Statement")};x.BreakStatement=x.ContinueStatement=le;x.WithStatement=function(s,e,t){t(s.object,e,"Expression"),t(s.body,e,"Statement")};x.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)}};x.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")}};x.ReturnStatement=x.YieldExpression=x.AwaitExpression=function(s,e,t){s.argument&&t(s.argument,e,"Expression")};x.ThrowStatement=x.SpreadElement=function(s,e,t){return t(s.argument,e,"Expression")};x.TryStatement=function(s,e,t){t(s.block,e,"Statement"),s.handler&&t(s.handler,e),s.finalizer&&t(s.finalizer,e,"Statement")};x.CatchClause=function(s,e,t){s.param&&t(s.param,e,"Pattern"),t(s.body,e,"Statement")};x.WhileStatement=x.DoWhileStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.body,e,"Statement")};x.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")};x.ForInStatement=x.ForOfStatement=function(s,e,t){t(s.left,e,"ForInit"),t(s.right,e,"Expression"),t(s.body,e,"Statement")};x.ForInit=function(s,e,t){s.type==="VariableDeclaration"?t(s,e):t(s,e,"Expression")};x.DebuggerStatement=le;x.FunctionDeclaration=function(s,e,t){return t(s,e,"Function")};x.VariableDeclaration=function(s,e,t){for(var n=0,i=s.declarations;n<i.length;n+=1){var r=i[n];t(r,e)}};x.VariableDeclarator=function(s,e,t){t(s.id,e,"Pattern"),s.init&&t(s.init,e,"Expression")};x.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")};x.Pattern=function(s,e,t){s.type==="Identifier"?t(s,e,"VariablePattern"):s.type==="MemberExpression"?t(s,e,"MemberPattern"):t(s,e)};x.VariablePattern=le;x.MemberPattern=Ye;x.RestElement=function(s,e,t){return t(s.argument,e,"Pattern")};x.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")}};x.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")}};x.Expression=Ye;x.ThisExpression=x.Super=x.MetaProperty=le;x.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")}};x.ObjectExpression=function(s,e,t){for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];t(r,e)}};x.FunctionExpression=x.ArrowFunctionExpression=x.FunctionDeclaration;x.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")}};x.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")}};x.TemplateElement=le;x.UnaryExpression=x.UpdateExpression=function(s,e,t){t(s.argument,e,"Expression")};x.BinaryExpression=x.LogicalExpression=function(s,e,t){t(s.left,e,"Expression"),t(s.right,e,"Expression")};x.AssignmentExpression=x.AssignmentPattern=function(s,e,t){t(s.left,e,"Pattern"),t(s.right,e,"Expression")};x.ConditionalExpression=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Expression"),t(s.alternate,e,"Expression")};x.NewExpression=x.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")}};x.MemberExpression=function(s,e,t){t(s.object,e,"Expression"),s.computed&&t(s.property,e,"Expression")};x.ExportNamedDeclaration=x.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")};x.ExportAllDeclaration=function(s,e,t){s.exported&&t(s.exported,e),t(s.source,e,"Expression")};x.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")};x.ImportExpression=function(s,e,t){t(s.source,e,"Expression")};x.ImportSpecifier=x.ImportDefaultSpecifier=x.ImportNamespaceSpecifier=x.Identifier=x.PrivateIdentifier=x.Literal=le;x.TaggedTemplateExpression=function(s,e,t){t(s.tag,e,"Expression"),t(s.quasi,e,"Expression")};x.ClassDeclaration=x.ClassExpression=function(s,e,t){return t(s,e,"Class")};x.Class=function(s,e,t){s.id&&t(s.id,e,"Pattern"),s.superClass&&t(s.superClass,e,"Expression"),t(s.body,e)};x.ClassBody=function(s,e,t){for(var n=0,i=s.body;n<i.length;n+=1){var r=i[n];t(r,e)}};x.MethodDefinition=x.PropertyDefinition=x.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:/^\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}$/},Se=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 Wt(s){return s.charAt(0).toUpperCase()+s.slice(1)}function ce(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)){if(s.some(t=>t!==null&&(typeof t=="object"||Array.isArray(t))))try{return JSON.stringify(s)}catch{return"[Array]"}return s.map(t=>ce(t)).filter(t=>t!=="").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(u=>{const p=u,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(g=>{this.stateManager?.removeSubscription(g)}),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=[];try{const r=F(e,{ecmaVersion:2022,sourceType:"script"}),a=this.validateAST(r,e);n.push(...a.errors),i.push(...a.warnings);const o=this.validateSyntax(e);n.push(...o.errors),i.push(...o.warnings)}catch(r){n.push(`Invalid JavaScript syntax: ${r instanceof Error?r.message:String(r)}`)}return{valid:n.length===0,errors:n,warnings:i}}static validateAST(e,t){const n=[],i=[];return H(e,{ConditionalExpression:r=>{const a=t.slice(r.consequent.start,r.consequent.end),o=this.validateBranch(a,"truthy");n.push(...o.errors),i.push(...o.warnings);const c=t.slice(r.alternate.start,r.alternate.end),u=this.validateBranch(c,"falsy");n.push(...u.errors),i.push(...u.warnings)}}),{errors:n,warnings:i}}static validateBranch(e,t){const n=[],i=[];try{return F(e,{ecmaVersion:2022,sourceType:"script"}),{errors:n,warnings:i}}catch{const a=this.countQuotes(e);if(a.single%2!==0&&(n.push(`Unmatched single quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,"'"))){const o=this.suggestQuoteFix(e,"'");o&&n.push(` Did you mean: ${o}`)}if(a.double%2!==0&&(n.push(`Unmatched double quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,'"'))){const o=this.suggestQuoteFix(e,'"');o&&n.push(` Did you mean: ${o}`)}a.single%2===0&&a.double%2===0&&this.looksLikeUnquotedLiteral(e)&&i.push(`Value "${e}" in ternary ${t} branch may need quotes. Did you mean '${e}' or "${e}"?`)}return{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();if(!t||this.isAlreadyQuoted(t))return!1;try{return F(t,{ecmaVersion:2022,sourceType:"script"}),!1}catch{}return Se.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 he{static instance;walkerPool=[];traversalCache=new WeakMap;lastCacheTime=new WeakMap;CACHE_TTL=250;trackedElements=new Set;static getInstance(){return he.instance||(he.instance=new he),he.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 W{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 W.instance||(W.instance=new W),W.instance}queryComponentElements(e){const t=W.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=W.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=W.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=W.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=W.CACHE_KEYS.COMPONENT_ELEMENTS(e);this.componentElementsCache.delete(t);const n=W.CACHE_KEYS.SCRIPTS(e,"global");this.scriptElementsCache.delete(n);const i=W.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 Q{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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return H(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 Q.instance||(Q.instance=new Q),Q.instance}extractFunctionNames(e){const t=[];try{const n=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});H(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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return H(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(", "),u=`[${a.join(", ")}]`,p=c?`pp.effect(${o}, ${u}, ${c})`:`pp.effect(${o}, ${u})`;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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return H(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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(t);let n=this.transformShorthandProperties(e);const i=F(n,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),r=[];return H(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&&o.length>0&&r.push(...o)}}),_s(i,{Identifier:(a,o)=>{r.some(u=>a.start>=u.start&&a.end<=u.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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return H(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))return[];if(this.isPPCall(e))return[];if(!Q.isFunctionNeedingValueTransform(n)&&e.arguments.length>0){const r=[];for(const a of e.arguments)a.type==="Identifier"&&this.stateVariables.has(a.name)&&(this.alreadyHasValue(a,t)||r.push({start:a.start,end:a.end,replacement:`${a.name}.value`}));return r}return[]}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){H(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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return H(t,{CallExpression:r=>{const a=n.slice(r.callee.start,r.callee.end);if(Q.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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return H(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),u=`pp.state("${t}", ${c})`;return{start:e.start,end:e.end,replacement:u}}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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});H(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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});H(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+=ce(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=W.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 fe{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 u=this.domBindingManager.loopManager;if(u){const p=u.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 jt{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 u={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,u),this.setupLoopReactivity(u,i.iterableExpr),this.renderLoop(u,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),u=He(c);if(!Array.isArray(u)){console.warn(`Loop expression "${t}" did not return an array:`,u,`Available context keys: [${Object.keys(i).join(", ")}]`,"Parent loop context:",r),this.clearRenderedItems(e);return}this.updateRenderedItems(e,u)}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 u=this.generateItemKey(e,o,c),p=a.get(u);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,u);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 u=this.expressionEvaluator.evaluateExpression(c,o,e.component);return String(u)}else{const u=N.parse(a);let p="";for(const h of u)if(h.type==="static")p+=h.content;else if(h.expression){const f=this.expressionEvaluator.evaluateExpression(h.expression,o,e.component);p+=ce(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[u,p]of Object.entries(i))a.includes(u)&&!u.startsWith("set")&&!u.endsWith("Getter")||(o[u]=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 u={},p=t&&typeof t=="object"?Object.keys(t):[];for(const[g,m]of Object.entries(c)){if(typeof m=="function"&&!m.__pphp_key){u[g]=m;continue}if(g.startsWith("set")||g.endsWith("Getter")){u[g]=m;continue}if(["getContext","withContext","__getProp"].includes(g)){u[g]=m;continue}p.includes(g)||(u[g]=m)}const h=this.findAllParentLoopContexts(e.template),f={...u,...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 u=this.componentManager.buildComponentContext(c),p=o.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(p&&p!==c){const f=this.componentManager.buildComponentContext(p);return{...t,...u,...f}}return{...t,...u}},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 u;for(;u=o.nextNode();){const f=u;if(f.hasAttribute("pp-ref")){const g=f.getAttribute("pp-ref");c.push({element:f,expression:g})}}c.forEach(({element:f,expression:g})=>{this.processRefInLoopContext(f,g,t,n)});const p=this.bindLoopItemElement(e,t,n,i);this.setupEventBindingsForLoopItem(e,n);for(let f=0;f<e.childNodes.length;f++){const g=e.childNodes[f];if(g.nodeType===Node.TEXT_NODE){const m=g;if(m.textContent&&d.MUSTACHE_PATTERN.test(m.textContent)&&!T.isTextNodeInsideScript(m)){const E=this.getComponentForTextNode(m);this.processTextNodeWithLoopContext(m,p,E,i)}}else if(g.nodeType===Node.ELEMENT_NODE){const m=g;if(m.tagName.toLowerCase()==="script")continue;const y=m.getAttribute(d.ATTR_PREFIXES.COMPONENT)||n,v=this.bindLoopItemElement(m,p,y,i);this.setupEventBindingsForLoopItem(m,y),this.processChildrenRecursively(m,v,y,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 u=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);return u&&u!==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),u=this.bindLoopItemElement(o,t,c,i);this.setupEventBindingsForLoopItem(o,c),this.processChildrenRecursively(o,u,c,i)}}processChildElementsWithContext(e,t,n,i){const r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:u=>{if(u===e)return NodeFilter.FILTER_SKIP;if(u.nodeType===Node.TEXT_NODE){const p=u;if(T.isTextNodeInsideScript(p))return NodeFilter.FILTER_REJECT;if(p.textContent&&d.MUSTACHE_PATTERN.test(p.textContent))return NodeFilter.FILTER_ACCEPT}else if(u.nodeType===Node.ELEMENT_NODE){const p=u;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(u=>{const p=this.getComponentForTextNode(u);this.processTextNodeWithLoopContext(u,t,p,i)}),o.forEach(u=>{const p=T.getElementComponent(u),h=this.bindLoopItemElement(u,t,p,i);this.setupEventBindingsForLoopItem(u,p),this.processChildElementsWithContext(u,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 u={...n};const p=this.findParentLoopContextForNestedTemplate(e);if(p&&(u={...u,...p}),c&&this.componentManager){const f=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(f){const g=T.getParentComponentForElement(c);this.componentManager.hasStoredProps(c)||this.componentManager.setupProps(c,g);const m=this.evaluateComponentPropsWithContext(c,u);u={...this.componentManager.buildComponentContext(f),...m,...u}}}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,u),this.renderNestedLoop(h,r.iterableExpr,u)}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 u=n;if(o.parentElement){const h=this.getParentLoopContextForElement(o);h&&(u={...u,...h})}if(c&&this.componentManager){const h=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(h){const f=this.extractParentLoopContextFromBinding(e,n),g=this.evaluateComponentPropsWithContext(c,f),m=this.componentManager.buildComponentContext(h);u={...f,...m,...g}}}this.renderNestedLoop(e,t,u)},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 u=this.expressionEvaluator.evaluateExpression(t,c,e.component),p=He(u);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,u)=>{const p=this.generateNestedItemKey(e,c,u,n),h=o.get(p);if(h&&!a.has(h.element))a.add(h.element),this.updateNestedItemContext(e,h,c,u,n),r.push(h);else{const f=this.createNestedLoopItem(e,c,u,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 u=c.firstElementChild;if(!u)return console.warn("Template content must contain exactly one root element"),null;c.removeChild(u),this.loopItemElements.add(u),this.loopItemContexts.set(u,a),u.getAttribute("key")&&u.removeAttribute("key");const h={key:i,element:u,context:a,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.processElementWithContext(u,a,e.component,h),this.cleanupRawMustacheAttributes(u),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[u,p]of t.textNodeTemplates)document.contains(u)&&this.updateTextNodeWithContext(u,p,c,this.getTextNodeComponent(u));if(t.attributeTemplates)for(const[u,p]of t.attributeTemplates)document.contains(u)&&p.forEach((h,f)=>{try{const g=T.getElementComponent(u),m=this.buildElementSpecificContext(u,c),E=this.templateRenderer.render(h,m,g);this.domBindingManager?.updateElementProperty(u,f,E)}catch(g){console.error(`Nested binding update error for "${h}":`,g)}})}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 u=this.componentManager.buildComponentContext(c);u={...u,...t};const h=!!e.getAttribute(d.ATTR_PREFIXES.COMPONENT),f=new Map,g=new Map;r.forEach((v,A)=>{h&&A!=="class"&&A!=="style"?f.set(A,v):g.set(A,v)});const m={},E=this.sortPropsByDependency(f);for(const[v,A]of E)try{const D=this.templateRenderer.render(A,u,c);m[v]=D,u[v]=D}catch(D){console.error(`❌ Failed to evaluate prop "${v}":`,D),m[v]=void 0,u[v]=void 0}h&&Object.keys(m).length>0&&(window[n]||(window[n]={}),Object.assign(window[n],m));const y=u;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((v,A)=>{this.createLoopItemBinding(e,A,v,y,c,i)}),y}sortPropsByDependency(e){const t=Array.from(e.keys()),n=Array.from(e.entries()),i=[],r=[];for(const[a,o]of n)t.some(u=>u!==a&&o.includes(u))?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(fe.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(E=>E.type==="expression"))return;i&&(i.textNodeTemplates||(i.textNodeTemplates=new Map),i.textNodeTemplates.set(e,r));const c=this.findActualComponentForTextNode(e);let u=t;c!==n&&i&&this.componentManager&&(u={...this.componentManager.buildComponentContext(c),...i.context}),this.updateTextNodeWithContext(e,r,u,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 E={};if(this.componentManager&&(c!==n&&i?E={...this.componentManager.buildComponentContext(c),...i.context}:E=this.componentManager.buildComponentContext(c)),i){const y={};let v=null;for(const[A,D]of this.loopBindings)if(D.renderedItems.includes(i)){v=D;break}if(v){y[v.itemVar]=i.context[v.itemVar],v.indexVar&&(y[v.indexVar]=i.context[v.indexVar]);const A=this.findParentLoopContext(v.template);A&&Object.assign(y,A)}E={...E,...y}}this.updateTextNodeWithContext(e,r,E,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,u]of Object.entries(n))typeof u=="function"&&"__pphp_key"in u?a[c]=u.value:a[c]=u;let o="";for(const c of r)if(c.type==="static")o+=c.content;else if(c.expression)try{const u=this.expressionEvaluator.evaluateExpression(c.expression,a,i);o+=ce(u)}catch(u){console.warn(`Loop text evaluation error for "${c.expression}":`,u,"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 u;c?c==="app"?u="app":u=c:u=this.findLoopParentComponent(e,r);const p=this.templateRenderer.dependencies(n,u,this.stateManager);let h=null;const f=[];if(a?.parentTemplate&&(h=this.findParentComponentWithPropsFromTemplate(a.parentTemplate),h&&this.componentManager)){const I=h.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(I){const k=this.componentManager.getComponentPropDependencies(h,I);f.push(...k);const R=this.componentManager.elementProps.get(h);if(R){const be=Array.from(R.keys());for(const B of be)if(n.includes(B)){const ee=R.get(B);if(ee){const pe=this.templateRenderer.dependencies(ee.expression,ee.component,this.stateManager);f.push(...pe)}}}}}const g=new Set([...p,...f,"*"]);let m=!1,E=0;const y=5,v=()=>{if(m)return;if(!document.contains(e)){if(E++,E<y){const k=10*Math.pow(2,E-1);setTimeout(()=>{m||v()},k)}else m=!0,this.stateManager.removeSubscription(o);return}E=0;try{const k=this.componentManager.buildComponentContext(u);let R;if(a){R={...k};let B=null;for(const[ee,pe]of this.loopBindings)if(pe.renderedItems.includes(a)){B=pe;break}B&&(R[B.itemVar]=a.context[B.itemVar],B.indexVar&&(R[B.indexVar]=a.context[B.indexVar]));for(const[ee,pe]of Object.entries(a.context))ee in R||(R[ee]=pe);if(h&&this.componentManager){const ee=this.componentManager.evaluateProps(h);Object.assign(R,ee)}}else R=i;const be=this.templateRenderer.render(n,R,u);this.domBindingManager?.updateElementProperty(e,t,be)}catch(k){console.error(`❌ Loop item binding evaluation error for "${n}":`,k),console.error("Available context keys:",Object.keys(i))}},A={id:o,selector:"",dependencies:g,callback:()=>{m||v()},element:e,component:u};if(this.stateManager.addSubscription(A),a){a.subscriptionIds.push(o);const I=this.cleanupLoopItem.bind(this);this.cleanupLoopItem=k=>{k===a&&(m=!0),I(k)}}(()=>{document.contains(e)?v():Promise.resolve().then(()=>{if(!m&&document.contains(e))v();else if(!m&&E<y){E++;const I=10*Math.pow(2,E-1);setTimeout(()=>{m||v()},I)}else!m&&E>=y&&(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,u]of t.textNodeTemplates)document.contains(c)&&this.updateTextNodeWithContext(c,u,o,this.getTextNodeComponent(c));if(t.attributeTemplates)for(const[c,u]of t.attributeTemplates)document.contains(c)&&u.forEach((p,h)=>{try{const f=T.getElementComponent(c),g=this.buildElementSpecificContext(c,o),m=this.templateRenderer.render(p,g,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 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 u=this.parseObjectProperties(c);r.push(u)}}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],u=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&u!=="\\"&&(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],u=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&u!=="\\"&&(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],u=i>0?e[i-1]:"";!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&u!=="\\"&&(r=!1,a=""),!r&&c==="`"&&u!=="\\"&&(o=!o),!r&&!o&&(c==="{"?n++:c==="}"&&n--),i++}if(n===0){const c=e.slice(t+1,i-1);if(c.trim()){const u=this.checkForMismatchedQuotes(c);u.hasIssue&&(console.error(`
|
|
11
|
-
❌ Malformed expression detected during parsing:`),console.error(` Expression: ${c}`),console.error(` Issue: ${u.message}`),console.error(` Full content: ${e}`),console.error(` 💡 Hint: Check your quotes - strings must be properly quoted
|
|
12
|
-
`))}return{endIndex:i-1,expression:c}}return console.warn(`
|
|
13
|
-
⚠️ Failed to extract mustache expression - unclosed braces`),console.warn(` Content: ${e}`),console.warn(` Starting at position: ${t}
|
|
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
|
-
❌ 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 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=this.findSlotContext(e),i=e.parentElement,r=n||(i?T.getContextComponent(i):t),a=e.textContent||"",o=N.parse(a);if(!o.some(h=>h.type==="expression"))return;const u=this.resolveComponentRootForElement(e,r),p={originalContent:a,expressions:o,subscriptionIds:[],component:r,componentElement:u};o.filter(h=>h.type==="expression").forEach(h=>{if(!h.expression)return;const f=`text_${Date.now()}_${Math.random()}`,g=this.expressionEvaluator.extractDependencies(h.expression,r,this.stateManager);if(u&&this.componentManager){const E=this.componentManager.getComponentPropDependencies(u,r);g.push(...E)}const m={id:f,selector:"",dependencies:new Set(g),callback:()=>{this.updateTextNode(e)},element:e.parentElement??void 0,component:r};this.stateManager.addSubscription(m),p.subscriptionIds.push(f)}),this.textNodeBindings.set(e,p),this.bindingCount++,this.updateTextNode(e)}findSlotContext(e){let t=e.previousSibling,n=0;for(;t;){if(t.nodeType===Node.COMMENT_NODE){const a=t.textContent||"";if(a==="/pp-slot-context")n++;else if(a.startsWith("pp-slot-context:")){if(n===0)return a.substring(16);n--}}t=t.previousSibling}let i=e.parentElement;for(;i&&i!==document.body;){for(t=i.previousSibling;t;){if(t.nodeType===Node.COMMENT_NODE){const a=t.textContent||"";if(a==="/pp-slot-context")n++;else if(a.startsWith("pp-slot-context:")){if(n===0)return a.substring(16);n--}}t=t.previousSibling}i=i.parentElement}return null}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 a=e.parentElement?.hasAttribute(d.ATTR_PREFIXES.CONTEXT);let o;if(a&&i)o=this.componentManager.buildRestrictedComponentContextWithProps(n,i);else if(o=this.componentManager.buildRestrictedComponentContext(n,!1),i&&this.componentManager.hasStoredProps(i)){const p=this.componentManager.evaluateProps(i);Object.assign(o,p)}const c={};for(const[p,h]of Object.entries(o))typeof h=="function"&&"__pphp_key"in h?c[p]=h.value:c[p]=h;let u="";for(const p of t.expressions)if(p.type==="static")u+=p.content;else if(p.expression)try{const h=this.expressionEvaluator.evaluateExpression(p.expression,c,n);u+=ce(h)}catch(h){console.error(`❌ Text binding evaluation error for "${p.expression}":`,h),console.error(`Component: ${n}`),console.error(`Available variables: [${Object.keys(c).join(", ")}]`),u+=""}e.textContent!==u&&(e.textContent=u)}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}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{subscriptionManager=new Ms;stateStore={};updateQueue=new Set;isUpdating=!1;eventBus=new Ls;contextCache=new Map;previousValues=new Map;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)}}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),i=this.subscriptionManager.getAllSubscriptions();for(const[r,a]of i)for(const o of a.dependencies)if(this.isPathDependency(o)&&o.startsWith(e+".")){const c=o.substring(e.length+1),u=this.getPathValue(n,c),p=this.getPathValue(t,c);this.deepEqual(u,p)||this.updateQueue.add(o)}}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 de{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=de.CACHE_KEYS.COMMON(t);this.commonExpressionsCache.set(i,n)})}extractDependencies(e,t,n){const i=this.normalizeExpression(e),r=de.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=de.CACHE_KEYS.COMMON(i);let a=this.commonExpressionsCache.get(r);if(a){a.hitCount++;try{return a.fn()}catch(u){console.error(`Common expression evaluation failed: "${i}"`,u);return}}const o=de.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 u=this.buildArguments(a.contextMap,c);return a.fn(...u)}catch(u){console.error(`Expression evaluation failed: "${i}"`,u),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,u)=>{r.set(c,u),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))Se.has(n)||!this.isValidJavaScriptIdentifier(n)||(t[n]=i);return t}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!Se.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(Se.has(c))continue;const u=c.indexOf("."),p=u===-1?c:c.substring(0,u),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(u!==-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 jt(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 u=i[c];if(!(u.name===d.ATTR_PREFIXES.COMPONENT||u.name===d.ATTR_PREFIXES.CONTEXT||u.name===d.ATTR_PREFIXES.SPREAD||u.name===d.ATTR_PREFIXES.LOOP)&&!fe.isEventAttribute(u.name)&&u.value&&Rs.containsMustacheExpression(u.value)){if(a&&this.mightReferenceSelfProps(u.value,e))continue;const p=this.attributeToPropName(u.name),h={name:p,expression:u.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=F(a,{ecmaVersion:2022,sourceType:"script"}),c=new Set,u=new Set;H(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?u.add(p.name):c.add(p.name))}});for(const p of i){if(p==="dataState")continue;const h=c.has(p),f=u.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]=(...u)=>c.apply(this,u):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}buildRestrictedComponentContextWithProps(e,t){const n=this.buildRestrictedComponentContext(e,!1);if(this.elementProps.has(t)){const i=this.evaluateProps(t);Object.assign(n,i)}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;const o=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let c;o?o==="app"?c=this.buildComponentContext("app"):c=this.buildComponentContext(o):c=this.buildComponentContext(a.component);const u=this.loopManager?.getLoopContextForElement(e);u&&(c={...c,...u});const p=new Map,h=new Map,f=Array.from(r.keys());r.forEach((m,E)=>{f.some(v=>v!==E&&m.expression.includes(v))?h.set(E,m):p.set(E,m)}),p.forEach((m,E)=>{try{const y=this.templateRenderer?.render(m.expression,c,o||m.component);i[E]=y}catch(y){console.error(`❌ Failed to evaluate prop "${E}":`,y),i[E]=void 0}});const g={...c,...i};return h.forEach((m,E)=>{try{const y=this.templateRenderer?.render(m.expression,g,o||m.component);i[E]=y}catch(y){console.error(`❌ Failed to evaluate prop "${E}":`,y),i[E]=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(E=>{delete o[E];const y=`set${Wt(E)}`,v=`${E}Getter`;delete o[y],delete o[v]}),r){const E=this.evaluateProps(r);Object.assign(o,E)}o.getContext=()=>this.buildComponentContextWithProps(t),o.withContext=E=>{const y=this.buildComponentContextWithProps(t);return E.call(y,y)},o.__getProp=E=>{if(r)return this.evaluateProps(r)[E]};const c=Q.getInstance(),u=new Set;if(r){const E=this.evaluateProps(r);for(const[y,v]of Object.entries(E))typeof v=="function"&&"__pphp_key"in v&&(u.add(y),/^set[A-Z]/.test(y)&&u.add(y))}let p=c.transformStateDeclarations(e,u);p=this.modifyScriptForReactiveProps(p,t,r||void 0);const h=`
|
|
17
|
-
${p}
|
|
18
|
-
|
|
19
|
-
${i.map(E=>`
|
|
20
|
-
if (typeof ${E} === 'function') {
|
|
21
|
-
this['${E}'] = ${E};
|
|
22
|
-
}
|
|
23
|
-
`).join(`
|
|
24
|
-
`)}
|
|
25
|
-
`,f=Object.keys(o),g=f.map(E=>o[E]);if(this.checkIfInLoopItem()){const E=this.extractLoopItemContext();this.domBindingManager.stateManager.currentLoopContext=E}try{new Function(...f,h).call(window[t],...g),window[t].getContext=o.getContext,window[t].withContext=o.withContext,window[t].__getProp=o.__getProp;for(const y of i){const v=window[t][y];typeof v=="function"&&this.storeFunctionForComponent(t,y,v)}this.invalidateComponent(t)}catch(E){console.error("Script execution failed:",E),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=Q.getInstance().extractStateDeclarations(e).map(u=>u.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 u=e.slice(t+n.length);if(/^\s*[=:]/.test(u))return!1;const p=e.slice(Math.max(0,t-20),t);return!/[a-zA-Z0-9_$]\s*\.\s*$/.test(p)}extractFunctionNames(e){return Q.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 oe;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 Os(n,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new jt(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(g=>c.add(g));const u={id:i,selector:"",dependencies:c,callback:o,element:e,component:n};this.stateManager.addSubscription(u),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=W.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(u=>{this.cleanupRefBinding(u)}),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&&fe.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=he.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 g=T.getContextComponent(f),m=T.getComponentForNode(h);if(g!==n&&m!==n)return!1}else if(T.getComponentForNode(h)!==n)return!1;return!0});return[...p.textNodes,...p.elements]}),c=[],u=[];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")}u.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})}),u.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 u=e.getAttribute("pp-ref");i&&this.createRefBinding(e,u,n),e.removeAttribute("pp-ref")}if(e.hasAttribute(d.ATTR_PREFIXES.SPREAD)){const u=e.getAttribute(d.ATTR_PREFIXES.SPREAD);i&&this.createSpreadDirectiveBinding(e,u,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((u,p)=>{this.pendingBindings.push({element:e,property:p,expression:u,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 u=c;this.refBindings.set(e,{element:e,callback:u,component:a}),u(e)}else if(c&&typeof c=="object"&&"current"in c){const u=c;this.refBindings.set(e,{element:e,refObject:u,component:a}),u.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 u=0;u<n.length;u++){const p=n[u];if(!(p.name===d.ATTR_PREFIXES.COMPONENT||p.name===d.ATTR_PREFIXES.CONTEXT||p.name==="key"||fe.isEventAttribute(p.name))&&!(i&&i.bindings.has(p.name))&&p.value){const h=d.MUSTACHE_PATTERN.test(p.value),f=N.decodeEntities(p.value),g=d.MUSTACHE_PATTERN.test(f);if(h||g){if(this.looksLikeSerializedObject(f))continue;const m=N.extractExpressions(f),E=T.getContextComponent(e);if(m.length===0&&(h||g)){console.error(`
|
|
27
|
-
❌ Malformed mustache expression in attribute "${p.name}":`),console.error(` Value: ${f}`),console.error(" Element:",e),console.error(` Component: ${E}`),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 y of m){const v=Is.validate(y,E);v.valid||(console.error(`
|
|
29
|
-
❌ Invalid expression in attribute "${p.name}":`),console.error(` Expression: ${y}`),console.error(` Original HTML: ${p.value}`),console.error(` Decoded: ${f}`),console.error(" Element:",e),console.error(` Component: ${E}`),v.errors.forEach(A=>{console.error(` ⚠️ ${A}`)}),console.error(" 💡 Hint: Check your quotes and syntax in conditional expressions"),console.error(` 💡 Example: class="{isActive ? 'text-blue-500' : 'text-gray-500'}"
|
|
30
|
-
`)),v.warnings.length>0&&(console.warn(`
|
|
31
|
-
⚠️ Expression warnings in attribute "${p.name}":`),console.warn(` Expression: ${y}`),console.warn(" Element:",e),v.warnings.forEach(A=>{console.warn(` • ${A}`)}))}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()}`,r=this.findSlotContextForElement(e),a=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),c=e.getAttribute(d.ATTR_PREFIXES.COMPONENT)!==null;let u,p=!1;r?(u=r,p=!1):c?(a?u=a==="app"?"app":a:u=T.getParentComponentForElement(e),p=!0):(u=T.getContextComponent(e),p=!1),e.removeAttribute(t);let h=null,f=e.parentElement;for(;f&&f!==document.body;){if(f.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){h=f;break}f=f.parentElement}const g=this.templateRenderer.dependencies(n,u,this.stateManager),m=new Set(g),E=this.findComponentElementForMustacheBinding(e,u);if(E&&this.componentManager){const A=this.componentManager.elementProps.get(E);if(A)for(const D of g){const I=D.split("."),k=I[I.length-1];if(A.has(k)){const R=A.get(k);this.templateRenderer.dependencies(R.expression,R.component,this.stateManager).forEach(B=>m.add(B))}}}if(h&&h!==E&&this.componentManager&&this.componentManager.hasStoredProps(h)){const A=this.componentManager.elementProps.get(h);if(A)for(const D of g){const I=D.split("."),k=I[I.length-1];if(A.has(k)){const R=A.get(k);this.templateRenderer.dependencies(R.expression,R.component,this.stateManager).forEach(B=>m.add(B))}}}const y=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(i);return}try{let A;if(p){let I=null,k=e.parentElement;for(;k&&k!==document.body;){if(k.getAttribute(d.ATTR_PREFIXES.COMPONENT)===u){I=k;break}k=k.parentElement}if(A=this.componentManager.buildComponentContextWithProps(u,I||void 0),e!==I&&this.componentManager.hasStoredProps(e)){const R=this.componentManager.evaluatePropsWithContext(e,u,e);A={...A,...R}}}else{const I=this.findComponentElementForMustacheBinding(e,u);if(a&&I){if(A=this.componentManager.buildRestrictedComponentContextWithProps(u,I),e!==I&&this.componentManager.hasStoredProps(e)){const k=this.componentManager.evaluatePropsWithContext(e,u,e);A={...A,...k}}}else{if(A=this.componentManager.buildRestrictedComponentContext(u,!1),I&&this.componentManager.hasStoredProps(I)){const k=this.componentManager.evaluateProps(I);Object.assign(A,k)}if(e!==I&&this.componentManager.hasStoredProps(e)){const k=this.componentManager.evaluatePropsWithContext(e,u,e);Object.assign(A,k)}}}if(h&&this.componentManager&&this.componentManager.hasStoredProps(h)){const I=this.componentManager.evaluateProps(h);A={...A,...I}}const D=this.templateRenderer.render(n,A,u);this.scheduleElementUpdate(e,t,D)}catch(A){console.error(`Mustache binding evaluation error for "${n}":`,A),console.error(`Context component: ${u}`),console.error(`Use parent context: ${p}`)}},v={id:i,selector:"",dependencies:m,callback:y,element:e,component:u};this.stateManager.addSubscription(v),y()}findSlotContextForElement(e){let t=e.previousSibling,n=0;for(;t;){if(t.nodeType===Node.COMMENT_NODE){const a=t.textContent||"";if(a==="/pp-slot-context")n++;else if(a.startsWith("pp-slot-context:")){if(n===0)return a.substring(16);n--}}t=t.previousSibling}let i=e.parentElement;for(;i&&i!==document.body;){for(t=i.previousSibling;t;){if(t.nodeType===Node.COMMENT_NODE){const a=t.textContent||"";if(a==="/pp-slot-context")n++;else if(a.startsWith("pp-slot-context:")){if(n===0)return a.substring(16);n--}}t=t.previousSibling}i=i.parentElement}return null}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(fe.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 u=this.cachedValueToString(i);e instanceof HTMLOptionElement?e.value!==u&&(e.value=u,e.setAttribute("value",u)):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.value!==u&&(e.value=u);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){const t=e.startsWith("{")&&e.endsWith("}"),n=e.startsWith("[")&&e.endsWith("]");if(!t&&!n)return!1;try{const i=JSON.parse(e);return typeof i=="object"&&i!==null&&(Array.isArray(i)||Object.keys(i).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=ce(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 u=c;u.textContent&&d.MUSTACHE_PATTERN.test(u.textContent)&&a.add(u)}}),o.removedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)n.add(c);else if(c.nodeType===Node.TEXT_NODE){const u=c;u.textContent&&d.MUSTACHE_PATTERN.test(u.textContent)&&(document.contains(u)||this.textNodeManager.cleanupTextNode(u))}})),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:u,fn:p}of t)e.removeEventListener(u,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(u=>{this.loopManager.cleanupTemplate(u)});const a=e.__directEventListeners;a&&(a.forEach(({eventType:u,listener:p})=>{e.removeEventListener(u,p)}),delete e.__directEventListeners);const o=e.__spreadEventHandlers;o&&(o.forEach(u=>{window.__spreadHandlers&&window.__spreadHandlers.delete(u)}),delete e.__spreadEventHandlers);const c=e.__spreadSubscriptions;c&&(c.forEach(u=>{this.stateManager.removeSubscription(u)}),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||fe.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 oe{static eventCache=null;delegatedEvents=new Map;elementHandlers=new WeakMap;handlerCache=new z(200);componentManager;expressionEvaluator;loopManager;setupEvents=new Set;static getAllAvailableEvents(){if(oe.eventCache)return oe.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)),oe.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 oe.getAllAvailableEvents().has(e.toLowerCase())}getAllSupportedEvents(){return Array.from(oe.getAllAvailableEvents()).sort()}getDelegatedEvents(){return Array.from(this.delegatedEvents.keys()).sort()}setDependencies(e,t,n,i){this.componentManager=e,this.expressionEvaluator=t,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),u={code:n,component:o};c.set(r,u);const p=this.delegatedEvents.get(r);p?p.elements.add(e):(console.warn(`⚠️ No delegated listener for ${r}, attaching directly`),this.attachDirectListener(e,r,u))}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
|
-
try {
|
|
33
|
-
with(context) {
|
|
34
|
-
${i}
|
|
35
|
-
}
|
|
36
|
-
} catch(error) {
|
|
37
|
-
console.error('Event handler execution error:', error);
|
|
38
|
-
console.error('Handler code:', ${JSON.stringify(e)});
|
|
39
|
-
console.error('Component:', '${t}');
|
|
40
|
-
console.error('Available context keys:', Object.keys(context));
|
|
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=null;if(r&&r===e.component)a=t;else{let f=t.parentElement;for(;f&&f!==document.body;){if(f.getAttribute(d.ATTR_PREFIXES.COMPONENT)===e.component){a=f;break}f=f.parentElement}if(!a){const g=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e.component}"]`);for(const m of g)if(this.componentManager.hasStoredProps(m)){a=m;break}!a&&g.length>0&&(a=g[0])}}let o=null,c=t.parentElement;for(;c&&c!==document.body;){if(c.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){o=c;break}c=c.parentElement}let u;if(i&&a)u=this.componentManager.buildRestrictedComponentContextWithProps(e.component,a);else if(u=this.componentManager.buildRestrictedComponentContext(e.component,!1),a&&this.componentManager.hasStoredProps(a)){const f=this.componentManager.evaluateProps(a);Object.assign(u,f)}if(o&&o!==a&&this.componentManager.hasStoredProps(o)){const f=this.componentManager.evaluateProps(o);u={...u,...f}}const p={...u};for(const[f,g]of Object.entries(u))typeof g=="function"&&"__pphp_key"in g&&(p[f]=g.value);const h=this.loopManager?.getLoopContextForElement(t);if(h){const f={};for(const[g,m]of Object.entries(h))typeof m=="function"&&"__pphp_key"in m?f[g]=m.value:f[g]=m;u={...p,...f}}else u=p;e.compiledFn||(e.compiledFn=this.compileHandler(e.code,e.component)),e.compiledFn&&e.compiledFn(n,t,u)}catch(i){console.error("💥 Event handler execution failed:",i),console.error("Handler code:",e.code),console.error("Handler component:",e.component)}}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 de;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]),u=new Proxy(c,{get(h,f,g){if(f==="__pphp_key"||f==="__pphp_fullKey"||f==="__pphp_component"||f==="value"||f==="valueOf"||f==="toString")return Reflect.get(h,f,g);const m=h();if(m!=null){if(f in Object(m)){const E=m[f];return typeof E=="function"?E.bind(m):E}return Reflect.get(h,f,g)}},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 g=h();return g!=null&&f in Object(g)?!0:Reflect.has(h,f)},apply(h,f,g){return Reflect.apply(h,f,g)}});Object.defineProperty(u,"__pphp_key",{value:i,enumerable:!1,writable:!1}),Object.defineProperty(u,"__pphp_fullKey",{value:a,enumerable:!1,writable:!1}),Object.defineProperty(u,"__pphp_component",{value:n,enumerable:!1,writable:!1}),Object.defineProperty(u,"value",{get:()=>this.stateManager.getState()[a],enumerable:!0,configurable:!0}),c.valueOf=()=>this.stateManager.getState()[a],c.toString=()=>ce(this.stateManager.getState()[a]);const p=h=>{const f=this.stateManager.getState()[a],g=typeof h=="function"?h(f):h;this.stateManager.setState(a,g)};return this.createComponentScopedGlobals(n,i,u,p),[u,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(" ")&&!Se.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 u=()=>{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:u,component:i};this.stateManager.addSubscription(h);break;case"once":break;case"deps":const f=this.resolveDependencies(c.deps,i);if(f.length){const g={id:n,selector:"",dependencies:new Set(f),callback:u,component:i};this.stateManager.addSubscription(g)}break}return c.immediate!==!1&&u(),()=>{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("."),u=this.componentManager.getPropDependencies(o,t);if(u.length>0)n.push(...u);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${Wt(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};
|
|
1
|
+
var us=Object.defineProperty,ps=(e,t,n)=>t in e?us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t,n)=>ps(e,"symbol"!=typeof t?t+"":t,n),hs=[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],Tt=[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],fs="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",wt="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Ye={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"},Je="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",ds={5:Je,"5module":Je+" export import",6:Je+" const class extends export import super"},ms=/^in(stanceof)?$/,gs=new RegExp("["+wt+"]"),xs=new RegExp("["+wt+fs+"]");function et(e,t){for(var n=65536,s=0;s<t.length;s+=2){if((n+=t[s])>e)return!1;if((n+=t[s+1])>=e)return!0}return!1}function te(e,t){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&gs.test(String.fromCharCode(e)):!1!==t&&et(e,Tt)))}function ue(e,t){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&xs.test(String.fromCharCode(e)):!1!==t&&(et(e,Tt)||et(e,hs)))))}var k=function(e,t){void 0===t&&(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 q(e,t){return new k(e,{beforeExpr:!0,binop:t})}var X={beforeExpr:!0},H={startsExpr:!0},ct={};function N(e,t){return void 0===t&&(t={}),t.keyword=e,ct[e]=new k(e,t)}var h={num:new k("num",H),regexp:new k("regexp",H),string:new k("string",H),name:new k("name",H),privateId:new k("privateId",H),eof:new k("eof"),bracketL:new k("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new k("]"),braceL:new k("{",{beforeExpr:!0,startsExpr:!0}),braceR:new k("}"),parenL:new k("(",{beforeExpr:!0,startsExpr:!0}),parenR:new k(")"),comma:new k(",",X),semi:new k(";",X),colon:new k(":",X),dot:new k("."),question:new k("?",X),questionDot:new k("?."),arrow:new k("=>",X),template:new k("template"),invalidTemplate:new k("invalidTemplate"),ellipsis:new k("...",X),backQuote:new k("`",H),dollarBraceL:new k("${",{beforeExpr:!0,startsExpr:!0}),eq:new k("=",{beforeExpr:!0,isAssign:!0}),assign:new k("_=",{beforeExpr:!0,isAssign:!0}),incDec:new k("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new k("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:q("||",1),logicalAND:q("&&",2),bitwiseOR:q("|",3),bitwiseXOR:q("^",4),bitwiseAND:q("&",5),equality:q("==/!=/===/!==",6),relational:q("</>/<=/>=",7),bitShift:q("<</>>/>>>",8),plusMin:new k("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:q("%",10),star:q("*",10),slash:q("/",10),starstar:new k("**",{beforeExpr:!0}),coalesce:q("??",1),_break:N("break"),_case:N("case",X),_catch:N("catch"),_continue:N("continue"),_debugger:N("debugger"),_default:N("default",X),_do:N("do",{isLoop:!0,beforeExpr:!0}),_else:N("else",X),_finally:N("finally"),_for:N("for",{isLoop:!0}),_function:N("function",H),_if:N("if"),_return:N("return",X),_switch:N("switch"),_throw:N("throw",X),_try:N("try"),_var:N("var"),_const:N("const"),_while:N("while",{isLoop:!0}),_with:N("with"),_new:N("new",{beforeExpr:!0,startsExpr:!0}),_this:N("this",H),_super:N("super",H),_class:N("class",H),_extends:N("extends",X),_export:N("export"),_import:N("import",H),_null:N("null",H),_true:N("true",H),_false:N("false",H),_in:N("in",{beforeExpr:!0,binop:7}),_instanceof:N("instanceof",{beforeExpr:!0,binop:7}),_typeof:N("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:N("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:N("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},W=/\r\n?|\n|\u2028|\u2029/,Es=new RegExp(W.source,"g");function Te(e){return 10===e||13===e||8232===e||8233===e}function Pt(e,t,n){void 0===n&&(n=e.length);for(var s=t;s<n;s++){var i=e.charCodeAt(s);if(Te(i))return s<n-1&&13===i&&10===e.charCodeAt(s+1)?s+2:s+1}return-1}var At=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,D=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,_t=Object.prototype,bs=_t.hasOwnProperty,Cs=_t.toString,we=Object.hasOwn||function(e,t){return bs.call(e,t)},xt=Array.isArray||function(e){return"[object Array]"===Cs.call(e)},Et=Object.create(null);function le(e){return Et[e]||(Et[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function re(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}var ys=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Ne=function(e,t){this.line=e,this.column=t};Ne.prototype.offset=function(e){return new Ne(this.line,this.column+e)};var qe=function(e,t,n){this.start=t,this.end=n,null!==e.sourceFile&&(this.source=e.sourceFile)};function Nt(e,t){for(var n=1,s=0;;){var i=Pt(e,s,t);if(i<0)return new Ne(n,t-s);++n,s=i}}var tt={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},bt=!1;function vs(e){var t={};for(var n in tt)t[n]=e&&we(e,n)?e[n]:tt[n];if("latest"===t.ecmaVersion?t.ecmaVersion=1e8:null==t.ecmaVersion?(!bt&&"object"==typeof console&&console.warn&&(bt=!0,console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.")),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),null==t.allowReserved&&(t.allowReserved=t.ecmaVersion<5),(!e||null==e.allowHashBang)&&(t.allowHashBang=t.ecmaVersion>=14),xt(t.onToken)){var s=t.onToken;t.onToken=function(e){return s.push(e)}}return xt(t.onComment)&&(t.onComment=Ss(t,t.onComment)),t}function Ss(e,t){return function(n,s,i,r,a,o){var c={type:n?"Block":"Line",value:s,start:i,end:r};e.locations&&(c.loc=new qe(this,a,o)),e.ranges&&(c.range=[i,r]),t.push(c)}}var ke=1,Pe=2,lt=4,kt=8,ut=16,Mt=32,Xe=64,It=128,be=256,Me=512,ze=ke|Pe|be;function pt(e,t){return Pe|(e?lt:0)|(t?kt:0)}var Ve=0,ht=1,oe=2,Rt=3,Ot=4,Lt=5,L=function(e,t,n){this.options=e=vs(e),this.sourceFile=e.sourceFile,this.keywords=le(ds[e.ecmaVersion>=6?6:"module"===e.sourceType?"5module":5]);var s="";!0!==e.allowReserved&&(s=Ye[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(s+=" await")),this.reservedWords=le(s);var i=(s?s+" ":"")+Ye.strict;this.reservedWordsStrict=le(i),this.reservedWordsStrictBind=le(i+" "+Ye.strictBind),this.input=String(t),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(W).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=h.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="module"===e.sourceType,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),0===this.pos&&e.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(ke),this.regexpState=null,this.privateNameStack=[]},se={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}};L.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)},se.inFunction.get=function(){return(this.currentVarScope().flags&Pe)>0},se.inGenerator.get=function(){return(this.currentVarScope().flags&kt)>0},se.inAsync.get=function(){return(this.currentVarScope().flags<)>0},se.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(be|Me))return!1;if(t&Pe)return(t<)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},se.allowSuper.get=function(){return(this.currentThisScope().flags&Xe)>0||this.options.allowSuperOutsideMethod},se.allowDirectSuper.get=function(){return(this.currentThisScope().flags&It)>0},se.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},se.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(be|Me)||t&Pe&&!(t&ut))return!0}return!1},se.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&be)>0},L.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,s=0;s<e.length;s++)n=e[s](n);return n},L.parse=function(e,t){return new this(t,e).parse()},L.parseExpressionAt=function(e,t,n){var s=new this(n,e,t);return s.nextToken(),s.parseExpression()},L.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(L.prototype,se);var $=L.prototype,Ts=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;$.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){D.lastIndex=e,e+=D.exec(this.input)[0].length;var t=Ts.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){D.lastIndex=e+t[0].length;var n=D.exec(this.input),s=n.index+n[0].length,i=this.input.charAt(s);return";"===i||"}"===i||W.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||"!"===i&&"="===this.input.charAt(s+1))}e+=t[0].length,D.lastIndex=e,e+=D.exec(this.input)[0].length,";"===this.input[e]&&e++}},$.eat=function(e){return this.type===e&&(this.next(),!0)},$.isContextual=function(e){return this.type===h.name&&this.value===e&&!this.containsEsc},$.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},$.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},$.canInsertSemicolon=function(){return this.type===h.eof||this.type===h.braceR||W.test(this.input.slice(this.lastTokEnd,this.start))},$.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},$.semicolon=function(){!this.eat(h.semi)&&!this.insertSemicolon()&&this.unexpected()},$.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},$.expect=function(e){this.eat(e)||this.unexpected()},$.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var Ke=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};$.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}},$.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,s=e.doubleProto;if(!t)return n>=0||s>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),s>=0&&this.raiseRecoverable(s,"Redefinition of __proto__ property")},$.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")},$.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var S=L.prototype;S.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==h.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var s=0,i=Object.keys(this.undefinedExports);s<i.length;s+=1){var r=i[s];this.raiseRecoverable(this.undefinedExports[r].start,"Export '"+r+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var ft={kind:"loop"},ws={kind:"switch"};S.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;D.lastIndex=this.pos;var t=D.exec(this.input),n=this.pos+t[0].length,s=this.input.charCodeAt(n);if(91===s||92===s)return!0;if(e)return!1;if(123===s||s>55295&&s<56320)return!0;if(te(s,!0)){for(var i=n+1;ue(s=this.input.charCodeAt(i),!0);)++i;if(92===s||s>55295&&s<56320)return!0;var r=this.input.slice(n,i);if(!ms.test(r))return!0}return!1},S.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;D.lastIndex=this.pos;var e,t=D.exec(this.input),n=this.pos+t[0].length;return!(W.test(this.input.slice(this.pos,n))||"function"!==this.input.slice(n,n+8)||n+8!==this.input.length&&(ue(e=this.input.charCodeAt(n+8))||e>55295&&e<56320))},S.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;D.lastIndex=this.pos;var n=D.exec(this.input),s=this.pos+n[0].length;if(W.test(this.input.slice(this.pos,s)))return!1;if(e){var i,r=s+5;if("using"!==this.input.slice(s,r)||r===this.input.length||ue(i=this.input.charCodeAt(r))||i>55295&&i<56320)return!1;D.lastIndex=r;var a=D.exec(this.input);if(a&&W.test(this.input.slice(r,r+a[0].length)))return!1}if(t){var o,c=s+2;if(!("of"!==this.input.slice(s,c)||c!==this.input.length&&(ue(o=this.input.charCodeAt(c))||o>55295&&o<56320)))return!1}var l=this.input.charCodeAt(s);return te(l,!0)||92===l},S.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},S.isUsing=function(e){return this.isUsingKeyword(!1,e)},S.parseStatement=function(e,t,n){var s,i=this.type,r=this.startNode();switch(this.isLet(e)&&(i=h._var,s="let"),i){case h._break:case h._continue:return this.parseBreakContinueStatement(r,i.keyword);case h._debugger:return this.parseDebuggerStatement(r);case h._do:return this.parseDoStatement(r);case h._for:return this.parseForStatement(r);case h._function:return e&&(this.strict||"if"!==e&&"label"!==e)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(r,!1,!e);case h._class:return e&&this.unexpected(),this.parseClass(r,!0);case h._if:return this.parseIfStatement(r);case h._return:return this.parseReturnStatement(r);case h._switch:return this.parseSwitchStatement(r);case h._throw:return this.parseThrowStatement(r);case h._try:return this.parseTryStatement(r);case h._const:case h._var:return s=s||this.value,e&&"var"!==s&&this.unexpected(),this.parseVarStatement(r,s);case h._while:return this.parseWhileStatement(r);case h._with:return this.parseWithStatement(r);case h.braceL:return this.parseBlock(!0,r);case h.semi:return this.parseEmptyStatement(r);case h._export:case h._import:if(this.options.ecmaVersion>10&&i===h._import){D.lastIndex=this.pos;var a=D.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(40===c||46===c)return this.parseExpressionStatement(r,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||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'")),i===h._import?this.parseImport(r):this.parseExport(r,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(r,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return t&&"script"===this.options.sourceType&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),"await using"===l&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(r,!1,l),this.semicolon(),this.finishNode(r,"VariableDeclaration");var p=this.value,u=this.parseExpression();return i===h.name&&"Identifier"===u.type&&this.eat(h.colon)?this.parseLabeledStatement(r,p,u,e):this.parseExpressionStatement(r,u)}},S.parseBreakContinueStatement=function(e,t){var n="break"===t;this.next(),this.eat(h.semi)||this.insertSemicolon()?e.label=null:this.type!==h.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var s=0;s<this.labels.length;++s){var i=this.labels[s];if((null==e.label||i.name===e.label.name)&&(null!=i.kind&&(n||"loop"===i.kind)||e.label&&n))break}return s===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")},S.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},S.parseDoStatement=function(e){return this.next(),this.labels.push(ft),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(h._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(h.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},S.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(ft),this.enterScope(0),this.expect(h.parenL),this.type===h.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===h._var||this.type===h._const||n){var s=this.startNode(),i=n?"let":this.value;return this.next(),this.parseVar(s,!0,i),this.finishNode(s,"VariableDeclaration"),this.parseForAfterInit(e,s,t)}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(),"await using"===o&&this.next(),this.parseVar(c,!0,o),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,p=new Ke,u=this.start,d=t>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===h._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===h._in&&this.unexpected(t),e.await=!0):a&&this.options.ecmaVersion>=8&&(d.start!==u||l||"Identifier"!==d.type||"async"!==d.name?this.options.ecmaVersion>=9&&(e.await=!1):this.unexpected()),r&&a&&this.raise(d.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(d,!1,p),this.checkLValPattern(d),this.parseForIn(e,d)):(this.checkExpressionErrors(p,!0),t>-1&&this.unexpected(t),this.parseFor(e,d))},S.parseForAfterInit=function(e,t,n){return(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===t.declarations.length?(this.options.ecmaVersion>=9&&(this.type===h._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},S.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,_e|(n?0:st),!1,t)},S.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(h._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},S.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(h.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},S.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(h.braceL),this.labels.push(ws),this.enterScope(0);for(var t,n=!1;this.type!==h.braceR;)if(this.type===h._case||this.type===h._default){var s=this.type===h._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),s?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(h.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},S.parseThrowStatement=function(e){return this.next(),W.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Ps=[];S.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?Mt:0),this.checkLValPattern(e,t?Ot:oe),this.expect(h.parenR),e},S.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===h._catch){var t=this.startNode();this.next(),this.eat(h.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(h._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},S.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")},S.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(ft),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},S.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")},S.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},S.parseLabeledStatement=function(e,t,n,s){for(var i=0,r=this.labels;i<r.length;i+=1){r[i].name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var a=this.type.isLoop?"loop":this.type===h._switch?"switch":null,o=this.labels.length-1;o>=0;o--){var c=this.labels[o];if(c.statementStart!==e.start)break;c.statementStart=this.start,c.kind=a}return this.labels.push({name:t,kind:a,statementStart:this.start}),e.body=this.parseStatement(s?-1===s.indexOf("label")?s+"label":s:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")},S.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},S.parseBlock=function(e,t,n){for(void 0===e&&(e=!0),void 0===t&&(t=this.startNode()),t.body=[],this.expect(h.braceL),e&&this.enterScope(0);this.type!==h.braceR;){var s=this.parseStatement(null);t.body.push(s)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},S.parseFor=function(e,t){return e.init=t,this.expect(h.semi),e.test=this.type===h.semi?null:this.parseExpression(),this.expect(h.semi),e.update=this.type===h.parenR?null:this.parseExpression(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},S.parseForIn=function(e,t){var n=this.type===h._in;return this.next(),"VariableDeclaration"===t.type&&null!=t.declarations[0].init&&(!n||this.options.ecmaVersion<8||this.strict||"var"!==t.kind||"Identifier"!==t.declarations[0].id.type)&&this.raise(t.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")},S.parseVar=function(e,t,n,s){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(h.eq)?i.init=this.parseMaybeAssign(t):s||"const"!==n||this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of")?s||"using"!==n&&"await using"!==n||!(this.options.ecmaVersion>=17)||this.type===h._in||this.isContextual("of")?s||"Identifier"===i.id.type||t&&(this.type===h._in||this.isContextual("of"))?i.init=null:this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):this.unexpected(),e.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(h.comma))break}return e},S.parseVarId=function(e,t){e.id="using"===t||"await using"===t?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,"var"===t?ht:oe,!1)};var _e=1,st=2,Ft=4;function As(e,t){var n=t.key.name,s=e[n],i="true";return"MethodDefinition"===t.type&&("get"===t.kind||"set"===t.kind)&&(i=(t.static?"s":"i")+t.kind),"iget"===s&&"iset"===i||"iset"===s&&"iget"===i||"sget"===s&&"sset"===i||"sset"===s&&"sget"===i?(e[n]="true",!1):!!s||(e[n]=i,!1)}function De(e,t){var n=e.computed,s=e.key;return!n&&("Identifier"===s.type&&s.name===t||"Literal"===s.type&&s.value===t)}S.parseFunction=function(e,t,n,s,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!s)&&(this.type===h.star&&t&st&&this.unexpected(),e.generator=this.eat(h.star)),this.options.ecmaVersion>=8&&(e.async=!!s),t&_e&&(e.id=t&Ft&&this.type!==h.name?null:this.parseIdent(),e.id&&!(t&st)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?ht:oe:Rt));var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(pt(e.async,e.generator)),t&_e||(e.id=this.type===h.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,t&_e?"FunctionDeclaration":"FunctionExpression")},S.parseFunctionParams=function(e){this.expect(h.parenL),e.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},S.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var s=this.enterClassBody(),i=this.startNode(),r=!1;for(i.body=[],this.expect(h.braceL);this.type!==h.braceR;){var a=this.parseClassElement(null!==e.superClass);a&&(i.body.push(a),"MethodDefinition"===a.type&&"constructor"===a.kind?(r&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),r=!0):a.key&&"PrivateIdentifier"===a.key.type&&As(s,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},S.parseClassElement=function(e){if(this.eat(h.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),s="",i=!1,r=!1,a="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(h.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===h.star?o=!0:s="static"}if(n.static=o,!s&&t>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==h.star||this.canInsertSemicolon()?s="async":r=!0),!s&&(t>=9||!r)&&this.eat(h.star)&&(i=!0),!s&&!r&&!i){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:s=c)}if(s?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=s,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),t<13||this.type===h.parenL||"method"!==a||i||r){var l=!n.static&&De(n,"constructor"),p=l&&e;l&&"method"!==a&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=l?"constructor":a,this.parseClassMethod(n,i,r,p)}else this.parseClassField(n);return n},S.isClassElementNameStart=function(){return this.type===h.name||this.type===h.privateId||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword},S.parseClassElementName=function(e){this.type===h.privateId?("constructor"===this.value&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},S.parseClassMethod=function(e,t,n,s){var i=e.key;"constructor"===e.kind?(t&&this.raise(i.start,"Constructor can't be a generator"),n&&this.raise(i.start,"Constructor can't be an async method")):e.static&&De(e,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var r=e.value=this.parseMethod(t,n,s);return"get"===e.kind&&0!==r.params.length&&this.raiseRecoverable(r.start,"getter should have no params"),"set"===e.kind&&1!==r.params.length&&this.raiseRecoverable(r.start,"setter should have exactly one param"),"set"===e.kind&&"RestElement"===r.params[0].type&&this.raiseRecoverable(r.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},S.parseClassField=function(e){return De(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&De(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(h.eq)?(this.enterScope(Me|Xe),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},S.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(be|Xe);this.type!==h.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},S.parseClassId=function(e,t){this.type===h.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,oe,!1)):(!0===t&&this.unexpected(),e.id=null)},S.parseClassSuper=function(e){e.superClass=this.eat(h._extends)?this.parseExprSubscripts(null,!1):null},S.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},S.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var s=this.privateNameStack.length,i=0===s?null:this.privateNameStack[s-1],r=0;r<n.length;++r){var a=n[r];we(t,a.name)||(i?i.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}},S.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},S.parseExport=function(e,t){if(this.next(),this.eat(h.star))return this.parseExportAllDeclaration(e,t);if(this.eat(h._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),"VariableDeclaration"===e.declaration.type?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,s=e.specifiers;n<s.length;n+=1){var i=s[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),"Literal"===i.local.type&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")},S.parseExportDeclaration=function(e){return this.parseStatement(null)},S.parseExportDefaultDeclaration=function(){var e;if(this.type===h._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,_e|Ft,!1,e)}if(this.type===h._class){var n=this.startNode();return this.parseClass(n,"nullableID")}var s=this.parseMaybeAssign();return this.semicolon(),s},S.checkExport=function(e,t,n){e&&("string"!=typeof t&&(t="Identifier"===t.type?t.name:t.value),we(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)},S.checkPatternExport=function(e,t){var n=t.type;if("Identifier"===n)this.checkExport(e,t,t.start);else if("ObjectPattern"===n)for(var s=0,i=t.properties;s<i.length;s+=1){var r=i[s];this.checkPatternExport(e,r)}else if("ArrayPattern"===n)for(var a=0,o=t.elements;a<o.length;a+=1){var c=o[a];c&&this.checkPatternExport(e,c)}else"Property"===n?this.checkPatternExport(e,t.value):"AssignmentPattern"===n?this.checkPatternExport(e,t.left):"RestElement"===n&&this.checkPatternExport(e,t.argument)},S.checkVariableExport=function(e,t){if(e)for(var n=0,s=t;n<s.length;n+=1){var i=s[n];this.checkPatternExport(e,i.id)}},S.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},S.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")},S.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(h.braceL);!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;t.push(this.parseExportSpecifier(e))}return t},S.parseImport=function(e){return this.next(),this.type===h.string?(e.specifiers=Ps,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===h.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},S.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,oe),this.finishNode(e,"ImportSpecifier")},S.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,oe),this.finishNode(e,"ImportDefaultSpecifier")},S.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,oe),this.finishNode(e,"ImportNamespaceSpecifier")},S.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===h.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(h.comma)))return e;if(this.type===h.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(h.braceL);!this.eat(h.braceR);){if(t)t=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;e.push(this.parseImportSpecifier())}return e},S.parseWithClause=function(){var e=[];if(!this.eat(h._with))return e;this.expect(h.braceL);for(var t={},n=!0;!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;var s=this.parseImportAttribute(),i="Identifier"===s.key.type?s.key.name:s.key.value;we(t,i)&&this.raiseRecoverable(s.key.start,"Duplicate attribute key '"+i+"'"),t[i]=!0,e.push(s)}return e},S.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===h.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved),this.expect(h.colon),this.type!==h.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},S.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===h.string){var e=this.parseLiteral(this.value);return ys.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},S.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},S.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"string"==typeof e.expression.value&&('"'===this.input[e.start]||"'"===this.input[e.start])};var G=L.prototype;G.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&"await"===e.name&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var s=0,i=e.properties;s<i.length;s+=1){var r=i[s];this.toAssignable(r,t),"RestElement"===r.type&&("ArrayPattern"===r.argument.type||"ObjectPattern"===r.argument.type)&&this.raise(r.argument.start,"Unexpected token")}break;case"Property":"init"!==e.kind&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),"AssignmentPattern"===e.argument.type&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":"="!==e.operator&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e},G.toAssignableList=function(e,t){for(var n=e.length,s=0;s<n;s++){var i=e[s];i&&this.toAssignable(i,t)}if(n){var r=e[n-1];6===this.options.ecmaVersion&&t&&r&&"RestElement"===r.type&&"Identifier"!==r.argument.type&&this.unexpected(r.argument.start)}return e},G.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},G.parseRestBinding=function(){var e=this.startNode();return this.next(),6===this.options.ecmaVersion&&this.type!==h.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},G.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case h.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(h.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case h.braceL:return this.parseObj(!0)}return this.parseIdent()},G.parseBindingList=function(e,t,n,s){for(var i=[],r=!0;!this.eat(e);)if(r?r=!1:this.expect(h.comma),t&&this.type===h.comma)i.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===h.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),i.push(a),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}i.push(this.parseAssignableListItem(s))}return i},G.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},G.parseBindingListItem=function(e){return e},G.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(h.eq))return n;var s=this.startNodeAt(e,t);return s.left=n,s.right=this.parseMaybeAssign(),this.finishNode(s,"AssignmentPattern")},G.checkLValSimple=function(e,t,n){void 0===t&&(t=Ve);var s=t!==Ve;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(s?"Binding ":"Assigning to ")+e.name+" in strict mode"),s&&(t===oe&&"let"===e.name&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(we(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==Lt&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":s&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return s&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(s?"Binding":"Assigning to")+" rvalue")}},G.checkLValPattern=function(e,t,n){switch(void 0===t&&(t=Ve),e.type){case"ObjectPattern":for(var s=0,i=e.properties;s<i.length;s+=1){var r=i[s];this.checkLValInnerPattern(r,t,n)}break;case"ArrayPattern":for(var a=0,o=e.elements;a<o.length;a+=1){var c=o[a];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},G.checkLValInnerPattern=function(e,t,n){switch(void 0===t&&(t=Ve),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var J=function(e,t,n,s,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=s,this.generator=!!i},R={b_stat:new J("{",!1),b_expr:new J("{",!0),b_tmpl:new J("${",!1),p_stat:new J("(",!1),p_expr:new J("(",!0),q_tmpl:new J("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new J("function",!1),f_expr:new J("function",!0),f_expr_gen:new J("function",!0,!1,null,!0),f_gen:new J("function",!1,!1,null,!0)},Ae=L.prototype;Ae.initialContext=function(){return[R.b_stat]},Ae.curContext=function(){return this.context[this.context.length-1]},Ae.braceIsBlock=function(e){var t=this.curContext();return t===R.f_expr||t===R.f_stat||(e!==h.colon||t!==R.b_stat&&t!==R.b_expr?e===h._return||e===h.name&&this.exprAllowed?W.test(this.input.slice(this.lastTokEnd,this.start)):e===h._else||e===h.semi||e===h.eof||e===h.parenR||e===h.arrow||(e===h.braceL?t===R.b_stat:e!==h._var&&e!==h._const&&e!==h.name&&!this.exprAllowed):!t.isExpr)},Ae.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if("function"===t.token)return t.generator}return!1},Ae.updateContext=function(e){var t,n=this.type;n.keyword&&e===h.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Ae.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},h.parenR.updateContext=h.braceR.updateContext=function(){if(1!==this.context.length){var e=this.context.pop();e===R.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},h.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?R.b_stat:R.b_expr),this.exprAllowed=!0},h.dollarBraceL.updateContext=function(){this.context.push(R.b_tmpl),this.exprAllowed=!0},h.parenL.updateContext=function(e){var t=e===h._if||e===h._for||e===h._with||e===h._while;this.context.push(t?R.p_stat:R.p_expr),this.exprAllowed=!0},h.incDec.updateContext=function(){},h._function.updateContext=h._class.updateContext=function(e){!e.beforeExpr||e===h._else||e===h.semi&&this.curContext()!==R.p_stat||e===h._return&&W.test(this.input.slice(this.lastTokEnd,this.start))||(e===h.colon||e===h.braceL)&&this.curContext()===R.b_stat?this.context.push(R.f_stat):this.context.push(R.f_expr),this.exprAllowed=!1},h.colon.updateContext=function(){"function"===this.curContext().token&&this.context.pop(),this.exprAllowed=!0},h.backQuote.updateContext=function(){this.curContext()===R.q_tmpl?this.context.pop():this.context.push(R.q_tmpl),this.exprAllowed=!1},h.star.updateContext=function(e){if(e===h._function){var t=this.context.length-1;this.context[t]===R.f_expr?this.context[t]=R.f_expr_gen:this.context[t]=R.f_gen}this.exprAllowed=!0},h.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==h.dot&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var A=L.prototype;function Vt(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&Vt(e.expression)}function nt(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&nt(e.expression)||"ParenthesizedExpression"===e.type&&nt(e.expression)}A.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&"SpreadElement"===e.type||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var s,i=e.key;switch(i.type){case"Identifier":s=i.name;break;case"Literal":s=String(i.value);break;default:return}var r=e.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===s&&"init"===r&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=i.start):this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),t.proto=!0));var a=t[s="$"+s];if(a)("init"===r?this.strict&&a.init||a.get||a.set:a.init||a[r])&&this.raiseRecoverable(i.start,"Redefinition of property");else a=t[s]={init:!1,get:!1,set:!1};a[r]=!0}},A.parseExpression=function(e,t){var n=this.start,s=this.startLoc,i=this.parseMaybeAssign(e,t);if(this.type===h.comma){var r=this.startNodeAt(n,s);for(r.expressions=[i];this.eat(h.comma);)r.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(r,"SequenceExpression")}return i},A.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var s=!1,i=-1,r=-1,a=-1;t?(i=t.parenthesizedAssign,r=t.trailingComma,a=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Ke,s=!0);var o=this.start,c=this.startLoc;(this.type===h.parenL||this.type===h.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait="await"===e);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,o,c)),this.type.isAssign){var p=this.startNodeAt(o,c);return p.operator=this.value,this.type===h.eq&&(l=this.toAssignable(l,!1,t)),s||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===h.eq?this.checkLValPattern(l):this.checkLValSimple(l),p.left=l,this.next(),p.right=this.parseMaybeAssign(e),a>-1&&(t.doubleProto=a),this.finishNode(p,"AssignmentExpression")}return s&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),r>-1&&(t.trailingComma=r),l},A.parseMaybeConditional=function(e,t){var n=this.start,s=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(h.question)){var r=this.startNodeAt(n,s);return r.test=i,r.consequent=this.parseMaybeAssign(),this.expect(h.colon),r.alternate=this.parseMaybeAssign(e),this.finishNode(r,"ConditionalExpression")}return i},A.parseExprOps=function(e,t){var n=this.start,s=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,n,s,-1,e)},A.parseExprOp=function(e,t,n,s,i){var r=this.type.binop;if(null!=r&&(!i||this.type!==h._in)&&r>s){var a=this.type===h.logicalOR||this.type===h.logicalAND,o=this.type===h.coalesce;o&&(r=h.logicalAND.binop);var c=this.value;this.next();var l=this.start,p=this.startLoc,u=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,p,r,i),d=this.buildBinary(t,n,e,u,c,a||o);return(a&&this.type===h.coalesce||o&&(this.type===h.logicalOR||this.type===h.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(d,t,n,s,i)}return e},A.buildBinary=function(e,t,n,s,i,r){"PrivateIdentifier"===s.type&&this.raise(s.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(e,t);return a.left=n,a.operator=i,a.right=s,this.finishNode(a,r?"LogicalExpression":"BinaryExpression")},A.parseMaybeUnary=function(e,t,n,s){var i,r=this.start,a=this.startLoc;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(s),t=!0;else if(this.type.prefix){var o=this.startNode(),c=this.type===h.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,c,s),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(o.argument):this.strict&&"delete"===o.operator&&Vt(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):"delete"===o.operator&&nt(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(o,c?"UpdateExpression":"UnaryExpression")}else if(t||this.type!==h.privateId){if(i=this.parseExprSubscripts(e,s),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(r,a);l.operator=this.value,l.prefix=!1,l.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(l,"UpdateExpression")}}else(s||0===this.privateNameStack.length)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==h._in&&this.unexpected();return n||!this.eat(h.starstar)?i:t?void this.unexpected(this.lastTokStart):this.buildBinary(r,a,i,this.parseMaybeUnary(null,!1,!1,s),"**",!1)},A.parseExprSubscripts=function(e,t){var n=this.start,s=this.startLoc,i=this.parseExprAtom(e,t);if("ArrowFunctionExpression"===i.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd))return i;var r=this.parseSubscripts(i,n,s,!1,t);return e&&"MemberExpression"===r.type&&(e.parenthesizedAssign>=r.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=r.start&&(e.parenthesizedBind=-1),e.trailingComma>=r.start&&(e.trailingComma=-1)),r},A.parseSubscripts=function(e,t,n,s,i){for(var r=this.options.ecmaVersion>=8&&"Identifier"===e.type&&"async"===e.name&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,a=!1;;){var o=this.parseSubscript(e,t,n,s,r,a,i);if(o.optional&&(a=!0),o===e||"ArrowFunctionExpression"===o.type){if(a){var c=this.startNodeAt(t,n);c.expression=o,o=this.finishNode(c,"ChainExpression")}return o}e=o}},A.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(h.arrow)},A.parseSubscriptAsyncArrow=function(e,t,n,s){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,s)},A.parseSubscript=function(e,t,n,s,i,r,a){var o=this.options.ecmaVersion>=11,c=o&&this.eat(h.questionDot);s&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(h.bracketL);if(l||c&&this.type!==h.parenL&&this.type!==h.backQuote||this.eat(h.dot)){var p=this.startNodeAt(t,n);p.object=e,l?(p.property=this.parseExpression(),this.expect(h.bracketR)):this.type===h.privateId&&"Super"!==e.type?p.property=this.parsePrivateIdent():p.property=this.parseIdent("never"!==this.options.allowReserved),p.computed=!!l,o&&(p.optional=c),e=this.finishNode(p,"MemberExpression")}else if(!s&&this.eat(h.parenL)){var u=new Ke,d=this.yieldPos,m=this.awaitPos,f=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var g=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1,u);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(u,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=d,this.awaitPos=m,this.awaitIdentPos=f,this.parseSubscriptAsyncArrow(t,n,g,a);this.checkExpressionErrors(u,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=f||this.awaitIdentPos;var E=this.startNodeAt(t,n);E.callee=e,E.arguments=g,o&&(E.optional=c),e=this.finishNode(E,"CallExpression")}else if(this.type===h.backQuote){(c||r)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var y=this.startNodeAt(t,n);y.tag=e,y.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(y,"TaggedTemplateExpression")}return e},A.parseExprAtom=function(e,t,n){this.type===h.slash&&this.readRegexp();var s,i=this.potentialArrowAt===this.start;switch(this.type){case h._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),s=this.startNode(),this.next(),this.type===h.parenL&&!this.allowDirectSuper&&this.raise(s.start,"super() call outside constructor of a subclass"),this.type!==h.dot&&this.type!==h.bracketL&&this.type!==h.parenL&&this.unexpected(),this.finishNode(s,"Super");case h._this:return s=this.startNode(),this.next(),this.finishNode(s,"ThisExpression");case h.name:var r=this.start,a=this.startLoc,o=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&"async"===c.name&&!this.canInsertSemicolon()&&this.eat(h._function))return this.overrideContext(R.f_expr),this.parseFunction(this.startNodeAt(r,a),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(h.arrow))return this.parseArrowExpression(this.startNodeAt(r,a),[c],!1,t);if(this.options.ecmaVersion>=8&&"async"===c.name&&this.type===h.name&&!o&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(h.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,a),[c],!0,t)}return c;case h.regexp:var l=this.value;return(s=this.parseLiteral(l.value)).regex={pattern:l.pattern,flags:l.flags},s;case h.num:case h.string:return this.parseLiteral(this.value);case h._null:case h._true:case h._false:return(s=this.startNode()).value=this.type===h._null?null:this.type===h._true,s.raw=this.type.keyword,this.next(),this.finishNode(s,"Literal");case h.parenL:var p=this.start,u=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(u)&&(e.parenthesizedAssign=p),e.parenthesizedBind<0&&(e.parenthesizedBind=p)),u;case h.bracketL:return s=this.startNode(),this.next(),s.elements=this.parseExprList(h.bracketR,!0,!0,e),this.finishNode(s,"ArrayExpression");case h.braceL:return this.overrideContext(R.b_expr),this.parseObj(!1,e);case h._function:return s=this.startNode(),this.next(),this.parseFunction(s,0);case h._class:return this.parseClass(this.startNode(),!1);case h._new:return this.parseNew();case h.backQuote:return this.parseTemplate();case h._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},A.parseExprAtomDefault=function(){this.unexpected()},A.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===h.parenL&&!e)return this.parseDynamicImport(t);if(this.type===h.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}this.unexpected()},A.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(h.parenR)?e.options=null:(this.expect(h.comma),this.afterTrailingComma(h.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(h.parenR)||(this.expect(h.comma),this.afterTrailingComma(h.parenR)||this.unexpected())));else if(!this.eat(h.parenR)){var t=this.start;this.eat(h.comma)&&this.eat(h.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},A.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),"meta"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),"module"!==this.options.sourceType&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")},A.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),110===t.raw.charCodeAt(t.raw.length-1)&&(t.bigint=null!=t.value?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")},A.parseParenExpression=function(){this.expect(h.parenL);var e=this.parseExpression();return this.expect(h.parenR),e},A.shouldParseArrow=function(e){return!this.canInsertSemicolon()},A.parseParenAndDistinguishExpression=function(e,t){var n,s=this.start,i=this.startLoc,r=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,c=this.startLoc,l=[],p=!0,u=!1,d=new Ke,m=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==h.parenR;){if(p?p=!1:this.expect(h.comma),r&&this.afterTrailingComma(h.parenR,!0)){u=!0;break}if(this.type===h.ellipsis){a=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(!1,d,this.parseParenItem))}var g=this.lastTokEnd,E=this.lastTokEndLoc;if(this.expect(h.parenR),e&&this.shouldParseArrow(l)&&this.eat(h.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=m,this.awaitPos=f,this.parseParenArrowList(s,i,l,t);(!l.length||u)&&this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(d,!0),this.yieldPos=m||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?((n=this.startNodeAt(o,c)).expressions=l,this.finishNodeAt(n,"SequenceExpression",g,E)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var y=this.startNodeAt(s,i);return y.expression=n,this.finishNode(y,"ParenthesizedExpression")}return n},A.parseParenItem=function(e){return e},A.parseParenArrowList=function(e,t,n,s){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,s)};var _s=[];A.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===h.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),"target"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var s=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),s,i,!0,!1),this.eat(h.parenL)?e.arguments=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1):e.arguments=_s,this.finishNode(e,"NewExpression")},A.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===h.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,"\n"),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===h.backQuote,this.finishNode(n,"TemplateElement")},A.parseTemplate=function(e){void 0===e&&(e={});var t=e.isTagged;void 0===t&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var s=this.parseTemplateElement({isTagged:t});for(n.quasis=[s];!s.tail;)this.type===h.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(h.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(h.braceR),n.quasis.push(s=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")},A.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===h.name||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===h.star)&&!W.test(this.input.slice(this.lastTokEnd,this.start))},A.parseObj=function(e,t){var n=this.startNode(),s=!0,i={};for(n.properties=[],this.next();!this.eat(h.braceR);){if(s)s=!1;else if(this.expect(h.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(h.braceR))break;var r=this.parseProperty(e,t);e||this.checkPropClash(r,i,t),n.properties.push(r)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")},A.parseProperty=function(e,t){var n,s,i,r,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(h.ellipsis))return e?(a.argument=this.parseIdent(!1),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(a.argument=this.parseMaybeAssign(!1,t),this.type===h.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(e||t)&&(i=this.start,r=this.startLoc),e||(n=this.eat(h.star)));var o=this.containsEsc;return this.parsePropertyName(a),!e&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(s=!0,n=this.options.ecmaVersion>=9&&this.eat(h.star),this.parsePropertyName(a)):s=!1,this.parsePropertyValue(a,e,n,s,i,r,t,o),this.finishNode(a,"Property")},A.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n="get"===e.kind?0:1;if(e.value.params.length!==n){var s=e.value.start;"get"===e.kind?this.raiseRecoverable(s,"getter should have no params"):this.raiseRecoverable(s,"setter should have exactly one param")}else"set"===e.kind&&"RestElement"===e.value.params[0].type&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")},A.parsePropertyValue=function(e,t,n,s,i,r,a,o){(n||s)&&this.type===h.colon&&this.unexpected(),this.eat(h.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),e.kind="init"):this.options.ecmaVersion>=6&&this.type===h.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,s),e.kind="init"):t||o||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type===h.comma||this.type===h.braceR||this.type===h.eq?this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?((n||s)&&this.unexpected(),this.checkUnreserved(e.key),"await"===e.key.name&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,r,this.copyNode(e.key)):this.type===h.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,r,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected():((n||s)&&this.unexpected(),this.parseGetterSetter(e))},A.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(h.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(h.bracketR),e.key;e.computed=!1}return e.key=this.type===h.num||this.type===h.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},A.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},A.parseMethod=function(e,t,n){var s=this.startNode(),i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(s),this.options.ecmaVersion>=6&&(s.generator=e),this.options.ecmaVersion>=8&&(s.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(pt(t,s.generator)|Xe|(n?It:0)),this.expect(h.parenL),s.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(s,!1,!0,!1),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(s,"FunctionExpression")},A.parseArrowExpression=function(e,t,n,s){var i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(pt(n,!1)|ut),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,s),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(e,"ArrowFunctionExpression")},A.parseFunctionBody=function(e,t,n,s){var i=t&&this.type!==h.braceL,r=this.strict,a=!1;if(i)e.body=this.parseMaybeAssign(s),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!r||o)&&((a=this.strictDirective(this.end))&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(e,!r&&!a&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Lt),e.body=this.parseBlock(!1,void 0,a&&!r),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},A.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){if("Identifier"!==n[t].type)return!1}return!0},A.checkParams=function(e,t){for(var n=Object.create(null),s=0,i=e.params;s<i.length;s+=1){var r=i[s];this.checkLValInnerPattern(r,ht,t?null:n)}},A.parseExprList=function(e,t,n,s){for(var i=[],r=!0;!this.eat(e);){if(r)r=!1;else if(this.expect(h.comma),t&&this.afterTrailingComma(e))break;var a=void 0;n&&this.type===h.comma?a=null:this.type===h.ellipsis?(a=this.parseSpread(s),s&&this.type===h.comma&&s.trailingComma<0&&(s.trailingComma=this.start)):a=this.parseMaybeAssign(!1,s),i.push(a)}return i},A.checkUnreserved=function(e){var t=e.start,n=e.end,s=e.name;(this.inGenerator&&"yield"===s&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&"await"===s&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&ze)&&"arguments"===s&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&("arguments"===s||"await"===s)&&this.raise(t,"Cannot use "+s+" in class static initialization block"),this.keywords.test(s)&&this.raise(t,"Unexpected keyword '"+s+"'"),this.options.ecmaVersion<6&&-1!==this.input.slice(t,n).indexOf("\\"))||(this.strict?this.reservedWordsStrict:this.reservedWords).test(s)&&(!this.inAsync&&"await"===s&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+s+"' is reserved"))},A.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),"await"===t.name&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},A.parseIdentNode=function(){var e=this.startNode();return this.type===h.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,("class"===e.name||"function"===e.name)&&(this.lastTokEnd!==this.lastTokStart+1||46!==this.input.charCodeAt(this.lastTokStart))&&this.context.pop(),this.type=h.name):this.unexpected(),e},A.parsePrivateIdent=function(){var e=this.startNode();return this.type===h.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(0===this.privateNameStack.length?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},A.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===h.semi||this.canInsertSemicolon()||this.type!==h.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(h.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},A.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Be=L.prototype;Be.raise=function(e,t){var n=Nt(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var s=new SyntaxError(t);throw s.pos=e,s.loc=n,s.raisedAt=this.pos,s},Be.raiseRecoverable=Be.raise,Be.curPosition=function(){if(this.options.locations)return new Ne(this.curLine,this.pos-this.lineStart)};var pe=L.prototype,Ns=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};pe.enterScope=function(e){this.scopeStack.push(new Ns(e))},pe.exitScope=function(){this.scopeStack.pop()},pe.treatFunctionsAsVarInScope=function(e){return e.flags&Pe||!this.inModule&&e.flags&ke},pe.declareName=function(e,t,n){var s=!1;if(t===oe){var i=this.currentScope();s=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&ke&&delete this.undefinedExports[e]}else if(t===Ot){this.currentScope().lexical.push(e)}else if(t===Rt){var r=this.currentScope();s=this.treatFunctionsAsVar?r.lexical.indexOf(e)>-1:r.lexical.indexOf(e)>-1||r.var.indexOf(e)>-1,r.functions.push(e)}else for(var a=this.scopeStack.length-1;a>=0;--a){var o=this.scopeStack[a];if(o.lexical.indexOf(e)>-1&&!(o.flags&Mt&&o.lexical[0]===e)||!this.treatFunctionsAsVarInScope(o)&&o.functions.indexOf(e)>-1){s=!0;break}if(o.var.push(e),this.inModule&&o.flags&ke&&delete this.undefinedExports[e],o.flags&ze)break}s&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")},pe.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},pe.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},pe.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(ze|Me|be))return t}},pe.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(ze|Me|be)&&!(t.flags&ut))return t}};var Ge=function(e,t,n){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new qe(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ie=L.prototype;function Dt(e,t,n,s){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=s),this.options.ranges&&(e.range[1]=n),e}Ie.startNode=function(){return new Ge(this,this.start,this.startLoc)},Ie.startNodeAt=function(e,t){return new Ge(this,e,t)},Ie.finishNode=function(e,t){return Dt.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Ie.finishNodeAt=function(e,t,n,s){return Dt.call(this,e,t,n,s)},Ie.copyNode=function(e){var t=new Ge(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var ks="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",Bt="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",$t=Bt+" Extended_Pictographic",jt=$t,Ht=$t+" EBase EComp EMod EPres ExtPict",Wt=Ht,Ms=Ht,Is={9:Bt,10:$t,11:$t,12:Ht,13:Ht,14:Ms},Rs="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Os={9:"",10:"",11:"",12:"",13:"",14:Rs},Ct="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",Ut="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",qt=Ut+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Xt=qt+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",zt=Xt+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Kt=zt+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Ls=Kt+" "+ks,Fs={9:Ut,10:qt,11:Xt,12:zt,13:Kt,14:Ls},Gt={};function Vs(e){var t=Gt[e]={binary:le(Is[e]+" "+Ct),binaryOfStrings:le(Os[e]),nonBinary:{General_Category:le(Ct),Script:le(Fs[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var Ze=0,yt=[9,10,11,12,13,14];Ze<yt.length;Ze+=1){var Ds=yt[Ze];Vs(Ds)}var v=L.prototype,$e=function(e,t){this.parent=e,this.base=t||this};$e.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},$e.prototype.sibling=function(){return new $e(this.parent,this.base)};var ne=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=Gt[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};function Bs(e){for(var t in e)return!0;return!1}function $s(e){return 105===e||109===e||115===e}function Qt(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function js(e){return te(e,!0)||36===e||95===e}function Hs(e){return ue(e,!0)||36===e||95===e||8204===e||8205===e}function Yt(e){return e>=65&&e<=90||e>=97&&e<=122}function Ws(e){return e>=0&&e<=1114111}ne.prototype.reset=function(e,t,n){var s=-1!==n.indexOf("v"),i=-1!==n.indexOf("u");this.start=0|e,this.source=t+"",this.flags=n,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},ne.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},ne.prototype.at=function(e,t){void 0===t&&(t=!1);var n=this.source,s=n.length;if(e>=s)return-1;var i=n.charCodeAt(e);if(!t&&!this.switchU||i<=55295||i>=57344||e+1>=s)return i;var r=n.charCodeAt(e+1);return r>=56320&&r<=57343?(i<<10)+r-56613888:i},ne.prototype.nextIndex=function(e,t){void 0===t&&(t=!1);var n=this.source,s=n.length;if(e>=s)return s;var i,r=n.charCodeAt(e);return!t&&!this.switchU||r<=55295||r>=57344||e+1>=s||(i=n.charCodeAt(e+1))<56320||i>57343?e+1:e+2},ne.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},ne.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},ne.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},ne.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},ne.prototype.eatChars=function(e,t){void 0===t&&(t=!1);for(var n=this.pos,s=0,i=e;s<i.length;s+=1){var r=i[s],a=this.at(n,t);if(-1===a||a!==r)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},v.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,s=!1,i=!1,r=0;r<n.length;r++){var a=n.charAt(r);-1===t.indexOf(a)&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(a,r+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),"u"===a&&(s=!0),"v"===a&&(i=!0)}this.options.ecmaVersion>=15&&s&&i&&this.raise(e.start,"Invalid regular expression flag")},v.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Bs(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},v.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var s=n[t];e.groupNames[s]||e.raise("Invalid named capture referenced")}},v.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new $e(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")},v.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},v.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):!!(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))&&(this.regexp_eatQuantifier(e),!0)},v.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},v.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},v.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},v.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var s=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return-1!==i&&i<s&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1},v.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},v.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},v.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),s=e.eat(45);if(n||s){for(var i=0;i<n.length;i++){var r=n.charAt(i);n.indexOf(r,i+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(s){var a=this.regexp_eatModifiers(e);!n&&!a&&58===e.current()&&e.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var c=a.charAt(o);(a.indexOf(c,o+1)>-1||n.indexOf(c)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1},v.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):63===e.current()&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1},v.regexp_eatModifiers=function(e){for(var t="",n=0;-1!==(n=e.current())&&$s(n);)t+=re(n),e.advance();return t},v.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},v.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},v.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!Qt(t)&&(e.lastIntValue=t,e.advance(),!0)},v.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;-1!==(n=e.current())&&!Qt(n);)e.advance();return e.pos!==t},v.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return!(-1===t||36===t||t>=40&&t<=43||46===t||63===t||91===t||94===t||124===t)&&(e.advance(),!0)},v.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var s=0,i=n;s<i.length;s+=1){i[s].separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},v.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1},v.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=re(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=re(e.lastIntValue);return!0}return!1},v.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,s=e.current(n);return e.advance(n),92===s&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(s=e.lastIntValue),js(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)},v.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,s=e.current(n);return e.advance(n),92===s&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(s=e.lastIntValue),Hs(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)},v.regexp_eatAtomEscape=function(e){return!!(this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e))||(e.switchU&&(99===e.current()&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)},v.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},v.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1},v.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},v.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},v.regexp_eatZero=function(e){return 48===e.current()&&!Qe(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},v.regexp_eatControlEscape=function(e){var t=e.current();return 116===t?(e.lastIntValue=9,e.advance(),!0):110===t?(e.lastIntValue=10,e.advance(),!0):118===t?(e.lastIntValue=11,e.advance(),!0):102===t?(e.lastIntValue=12,e.advance(),!0):114===t&&(e.lastIntValue=13,e.advance(),!0)},v.regexp_eatControlLetter=function(e){var t=e.current();return!!Yt(t)&&(e.lastIntValue=t%32,e.advance(),!0)},v.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){void 0===t&&(t=!1);var n=e.pos,s=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(s&&i>=55296&&i<=56319){var r=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var a=e.lastIntValue;if(a>=56320&&a<=57343)return e.lastIntValue=1024*(i-55296)+(a-56320)+65536,!0}e.pos=r,e.lastIntValue=i}return!0}if(s&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Ws(e.lastIntValue))return!0;s&&e.raise("Invalid unicode escape"),e.pos=n}return!1},v.regexp_eatIdentityEscape=function(e){if(e.switchU)return!!this.regexp_eatSyntaxCharacter(e)||!!e.eat(47)&&(e.lastIntValue=47,!0);var t=e.current();return!(99===t||e.switchN&&107===t)&&(e.lastIntValue=t,e.advance(),!0)},v.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do{e.lastIntValue=10*e.lastIntValue+(t-48),e.advance()}while((t=e.current())>=48&&t<=57);return!0}return!1};var Jt=0,ae=1,z=2;function Us(e){return 100===e||68===e||115===e||83===e||119===e||87===e}function Zt(e){return Yt(e)||95===e}function qs(e){return Zt(e)||Qe(e)}function Xs(e){return 33===e||e>=35&&e<=38||e>=42&&e<=44||46===e||e>=58&&e<=64||94===e||96===e||126===e}function zs(e){return 40===e||41===e||45===e||47===e||e>=91&&e<=93||e>=123&&e<=125}function Ks(e){return 33===e||35===e||37===e||38===e||44===e||45===e||e>=58&&e<=62||64===e||96===e||126===e}function Qe(e){return e>=48&&e<=57}function es(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function ts(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function ss(e){return e>=48&&e<=55}v.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Us(t))return e.lastIntValue=-1,e.advance(),ae;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=80===t)||112===t)){var s;if(e.lastIntValue=-1,e.advance(),e.eat(123)&&(s=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&s===z&&e.raise("Invalid property name"),s;e.raise("Invalid property name")}return Jt},v.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,s),ae}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Jt},v.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){we(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")},v.regexp_validateUnicodePropertyNameOrValue=function(e,t){return e.unicodeProperties.binary.test(t)?ae:e.switchV&&e.unicodeProperties.binaryOfStrings.test(t)?z:void e.raise("Invalid property name")},v.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Zt(t=e.current());)e.lastStringValue+=re(t),e.advance();return""!==e.lastStringValue},v.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";qs(t=e.current());)e.lastStringValue+=re(t),e.advance();return""!==e.lastStringValue},v.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},v.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===z&&e.raise("Negated character class may contain strings"),!0}return!1},v.regexp_classContents=function(e){return 93===e.current()?ae:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),ae)},v.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(-1===t||-1===n)&&e.raise("Invalid character class"),-1!==t&&-1!==n&&t>n&&e.raise("Range out of order in character class")}}},v.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(99===n||ss(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var s=e.current();return 93!==s&&(e.lastIntValue=s,e.advance(),!0)},v.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},v.regexp_classSetExpression=function(e){var t,n=ae;if(!this.regexp_eatClassSetRange(e))if(t=this.regexp_eatClassSetOperand(e)){t===z&&(n=z);for(var s=e.pos;e.eatChars([38,38]);)38!==e.current()&&(t=this.regexp_eatClassSetOperand(e))?t!==z&&(n=ae):e.raise("Invalid character in character class");if(s!==e.pos)return n;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(s!==e.pos)return n}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(!(t=this.regexp_eatClassSetOperand(e)))return n;t===z&&(n=z)}},v.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var s=e.lastIntValue;return-1!==n&&-1!==s&&n>s&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1},v.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?ae:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},v.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),s=this.regexp_classContents(e);if(e.eat(93))return n&&s===z&&e.raise("Negated character class may contain strings"),s;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},v.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=t}return null},v.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===z&&(t=z);return t},v.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?ae:z},v.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return!(!this.regexp_eatCharacterEscape(e)&&!this.regexp_eatClassSetReservedPunctuator(e))||(e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1));var n=e.current();return!(n<0||n===e.lookahead()&&Xs(n)||zs(n))&&(e.advance(),e.lastIntValue=n,!0)},v.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return!!Ks(t)&&(e.lastIntValue=t,e.advance(),!0)},v.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!Qe(t)&&95!==t)&&(e.lastIntValue=t%32,e.advance(),!0)},v.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1},v.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Qe(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t},v.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;es(n=e.current());)e.lastIntValue=16*e.lastIntValue+ts(n),e.advance();return e.pos!==t},v.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*n+e.lastIntValue:e.lastIntValue=8*t+n}else e.lastIntValue=t;return!0}return!1},v.regexp_eatOctalDigit=function(e){var t=e.current();return ss(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},v.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var s=0;s<t;++s){var i=e.current();if(!es(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+ts(i),e.advance()}return!0};var dt=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new qe(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},_=L.prototype;function Gs(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function ns(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}_.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new dt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},_.getToken=function(){return this.next(),new dt(this)},typeof Symbol<"u"&&(_[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===h.eof,value:t}}}}),_.nextToken=function(){var e=this.curContext();return(!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(h.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},_.readToken=function(e){return te(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},_.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888},_.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(-1===n&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var s=void 0,i=t;(s=Pt(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=s;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},_.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),s=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Te(s);)s=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},_.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:10===this.input.charCodeAt(this.pos+1)&&++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(!(e>8&&e<14||e>=5760&&At.test(String.fromCharCode(e))))break e;++this.pos}}},_.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},_.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===e&&46===t?(this.pos+=3,this.finishToken(h.ellipsis)):(++this.pos,this.finishToken(h.dot))},_.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(h.assign,2):this.finishOp(h.slash,1)},_.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,s=42===e?h.star:h.modulo;return this.options.ecmaVersion>=7&&42===e&&42===t&&(++n,s=h.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(h.assign,n+1):this.finishOp(s,n)},_.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(h.assign,3);return this.finishOp(124===e?h.logicalOR:h.logicalAND,2)}return 61===t?this.finishOp(h.assign,2):this.finishOp(124===e?h.bitwiseOR:h.bitwiseAND,1)},_.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(h.assign,2):this.finishOp(h.bitwiseXOR,1)},_.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?45!==t||this.inModule||62!==this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!W.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(h.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(h.assign,2):this.finishOp(h.plusMin,1)},_.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(h.assign,n+1):this.finishOp(h.bitShift,n)):33!==t||60!==e||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===t&&(n=2),this.finishOp(h.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},_.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(h.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(h.arrow)):this.finishOp(61===e?h.eq:h.prefix,1)},_.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(46===t){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(h.questionDot,2)}if(63===t){if(e>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(h.assign,3);return this.finishOp(h.coalesce,2)}}return this.finishOp(h.question,1)},_.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,te(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(h.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+re(e)+"'")},_.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(h.parenL);case 41:return++this.pos,this.finishToken(h.parenR);case 59:return++this.pos,this.finishToken(h.semi);case 44:return++this.pos,this.finishToken(h.comma);case 91:return++this.pos,this.finishToken(h.bracketL);case 93:return++this.pos,this.finishToken(h.bracketR);case 123:return++this.pos,this.finishToken(h.braceL);case 125:return++this.pos,this.finishToken(h.braceR);case 58:return++this.pos,this.finishToken(h.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(h.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(120===t||88===t)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===t||79===t)return this.readRadixNumber(8);if(98===t||66===t)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(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(h.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+re(e)+"'")},_.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},_.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var s=this.input.charAt(this.pos);if(W.test(s)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if("["===s)t=!0;else if("]"===s&&t)t=!1;else if("/"===s&&!t)break;e="\\"===s}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var r=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(r);var o=this.regexpState||(this.regexpState=new ne(this));o.reset(n,i,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(i,a)}catch{}return this.finishToken(h.regexp,{pattern:i,flags:a,value:c})},_.readInt=function(e,t,n){for(var s=this.options.ecmaVersion>=12&&void 0===t,i=n&&48===this.input.charCodeAt(this.pos),r=this.pos,a=0,o=0,c=0,l=t??1/0;c<l;++c,++this.pos){var h=this.input.charCodeAt(this.pos),p=void 0;if(s&&95===h)i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),95===o&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),0===c&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=h;else{if((p=h>=97?h-97+10:h>=65?h-65+10:h>=48&&h<=57?h-48:1/0)>=e)break;o=h,a=a*e+p}}return s&&95===o&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===r||null!=t&&this.pos-r!==t?null:a},_.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return null==n&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&110===this.input.charCodeAt(this.pos)?(n=ns(this.input.slice(t,this.pos)),++this.pos):te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,n)},_.readNumber=function(e){var t=this.pos;!e&&null===this.readInt(10,void 0,!0)&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&48===this.input.charCodeAt(t);n&&this.strict&&this.raise(t,"Invalid number");var s=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&110===s){var i=ns(this.input.slice(t,this.pos));return++this.pos,te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),46===s&&!n&&(++this.pos,this.readInt(10),s=this.input.charCodeAt(this.pos)),(69===s||101===s)&&!n&&((43===(s=this.input.charCodeAt(++this.pos))||45===s)&&++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number")),te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=Gs(this.input.slice(t,this.pos),n);return this.finishToken(h.num,r)},_.readCodePoint=function(){var e;if(123===this.input.charCodeAt(this.pos)){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},_.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var s=this.input.charCodeAt(this.pos);if(s===e)break;92===s?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):8232===s||8233===s?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Te(s)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(h.string,t)};var is={};_.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==is)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},_.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw is;this.raise(e,t)},_.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(96===n||36===n&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==h.template&&this.type!==h.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(h.template,e)):36===n?(this.pos+=2,this.finishToken(h.dollarBraceL)):(++this.pos,this.finishToken(h.backQuote));if(92===n)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Te(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},_.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(h.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":"\n"===this.input[this.pos+1]&&++this.pos;case"\n":case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,"Unterminated template")},_.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return re(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:10===this.input.charCodeAt(this.pos)&&++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"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(s,8);return i>255&&(s=s.slice(0,-1),i=parseInt(s,8)),this.pos+=s.length-1,t=this.input.charCodeAt(this.pos),("0"!==s||56===t||57===t)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-s.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return Te(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},_.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return null===n&&this.invalidStringToken(t,"Bad character escape sequence"),n},_.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,s=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(ue(i,s))this.pos+=i<=65535?1:2;else{if(92!==i)break;this.containsEsc=!0,e+=this.input.slice(n,this.pos);var r=this.pos;117!==this.input.charCodeAt(++this.pos)&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(t?te:ue)(a,s)||this.invalidStringToken(r,"Invalid Unicode escape"),e+=re(a),n=this.pos}t=!1}return e+this.input.slice(n,this.pos)},_.readWord=function(){var e=this.readWord1(),t=h.name;return this.keywords.test(e)&&(t=ct[e]),this.finishToken(t,e)};var Qs="8.15.0";function F(e,t){return L.parse(e,t)}function U(e,t,n,s,i){n||(n=y),function e(s,i,r){var a=r||s.type;n[a](s,i,e),t[a]&&t[a](s,i)}(e,s,i)}function vt(e,t,n,s,i){var r=[];n||(n=y),function e(s,i,a){var o=a||s.type,c=s!==r[r.length-1];c&&r.push(s),n[o](s,i,e),t[o]&&t[o](s,i||r,r),c&&r.pop()}(e,s,i)}function mt(e,t,n){n(e,t)}function Ce(e,t,n){}L.acorn={Parser:L,version:Qs,defaultOptions:tt,Position:Ne,SourceLocation:qe,getLineInfo:Nt,Node:Ge,TokenType:k,tokTypes:h,keywordTypes:ct,TokContext:J,tokContexts:R,isIdentifierChar:ue,isIdentifierStart:te,Token:dt,isNewLine:Te,lineBreak:W,lineBreakG:Es,nonASCIIwhitespace:At};var y={};y.Program=y.BlockStatement=y.StaticBlock=function(e,t,n){for(var s=0,i=e.body;s<i.length;s+=1){n(i[s],t,"Statement")}},y.Statement=mt,y.EmptyStatement=Ce,y.ExpressionStatement=y.ParenthesizedExpression=y.ChainExpression=function(e,t,n){return n(e.expression,t,"Expression")},y.IfStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Statement"),e.alternate&&n(e.alternate,t,"Statement")},y.LabeledStatement=function(e,t,n){return n(e.body,t,"Statement")},y.BreakStatement=y.ContinueStatement=Ce,y.WithStatement=function(e,t,n){n(e.object,t,"Expression"),n(e.body,t,"Statement")},y.SwitchStatement=function(e,t,n){n(e.discriminant,t,"Expression");for(var s=0,i=e.cases;s<i.length;s+=1){n(i[s],t)}},y.SwitchCase=function(e,t,n){e.test&&n(e.test,t,"Expression");for(var s=0,i=e.consequent;s<i.length;s+=1){n(i[s],t,"Statement")}},y.ReturnStatement=y.YieldExpression=y.AwaitExpression=function(e,t,n){e.argument&&n(e.argument,t,"Expression")},y.ThrowStatement=y.SpreadElement=function(e,t,n){return n(e.argument,t,"Expression")},y.TryStatement=function(e,t,n){n(e.block,t,"Statement"),e.handler&&n(e.handler,t),e.finalizer&&n(e.finalizer,t,"Statement")},y.CatchClause=function(e,t,n){e.param&&n(e.param,t,"Pattern"),n(e.body,t,"Statement")},y.WhileStatement=y.DoWhileStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.body,t,"Statement")},y.ForStatement=function(e,t,n){e.init&&n(e.init,t,"ForInit"),e.test&&n(e.test,t,"Expression"),e.update&&n(e.update,t,"Expression"),n(e.body,t,"Statement")},y.ForInStatement=y.ForOfStatement=function(e,t,n){n(e.left,t,"ForInit"),n(e.right,t,"Expression"),n(e.body,t,"Statement")},y.ForInit=function(e,t,n){"VariableDeclaration"===e.type?n(e,t):n(e,t,"Expression")},y.DebuggerStatement=Ce,y.FunctionDeclaration=function(e,t,n){return n(e,t,"Function")},y.VariableDeclaration=function(e,t,n){for(var s=0,i=e.declarations;s<i.length;s+=1){n(i[s],t)}},y.VariableDeclarator=function(e,t,n){n(e.id,t,"Pattern"),e.init&&n(e.init,t,"Expression")},y.Function=function(e,t,n){e.id&&n(e.id,t,"Pattern");for(var s=0,i=e.params;s<i.length;s+=1){n(i[s],t,"Pattern")}n(e.body,t,e.expression?"Expression":"Statement")},y.Pattern=function(e,t,n){"Identifier"===e.type?n(e,t,"VariablePattern"):"MemberExpression"===e.type?n(e,t,"MemberPattern"):n(e,t)},y.VariablePattern=Ce,y.MemberPattern=mt,y.RestElement=function(e,t,n){return n(e.argument,t,"Pattern")},y.ArrayPattern=function(e,t,n){for(var s=0,i=e.elements;s<i.length;s+=1){var r=i[s];r&&n(r,t,"Pattern")}},y.ObjectPattern=function(e,t,n){for(var s=0,i=e.properties;s<i.length;s+=1){var r=i[s];"Property"===r.type?(r.computed&&n(r.key,t,"Expression"),n(r.value,t,"Pattern")):"RestElement"===r.type&&n(r.argument,t,"Pattern")}},y.Expression=mt,y.ThisExpression=y.Super=y.MetaProperty=Ce,y.ArrayExpression=function(e,t,n){for(var s=0,i=e.elements;s<i.length;s+=1){var r=i[s];r&&n(r,t,"Expression")}},y.ObjectExpression=function(e,t,n){for(var s=0,i=e.properties;s<i.length;s+=1){n(i[s],t)}},y.FunctionExpression=y.ArrowFunctionExpression=y.FunctionDeclaration,y.SequenceExpression=function(e,t,n){for(var s=0,i=e.expressions;s<i.length;s+=1){n(i[s],t,"Expression")}},y.TemplateLiteral=function(e,t,n){for(var s=0,i=e.quasis;s<i.length;s+=1){n(i[s],t)}for(var r=0,a=e.expressions;r<a.length;r+=1){n(a[r],t,"Expression")}},y.TemplateElement=Ce,y.UnaryExpression=y.UpdateExpression=function(e,t,n){n(e.argument,t,"Expression")},y.BinaryExpression=y.LogicalExpression=function(e,t,n){n(e.left,t,"Expression"),n(e.right,t,"Expression")},y.AssignmentExpression=y.AssignmentPattern=function(e,t,n){n(e.left,t,"Pattern"),n(e.right,t,"Expression")},y.ConditionalExpression=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Expression"),n(e.alternate,t,"Expression")},y.NewExpression=y.CallExpression=function(e,t,n){if(n(e.callee,t,"Expression"),e.arguments)for(var s=0,i=e.arguments;s<i.length;s+=1){n(i[s],t,"Expression")}},y.MemberExpression=function(e,t,n){n(e.object,t,"Expression"),e.computed&&n(e.property,t,"Expression")},y.ExportNamedDeclaration=y.ExportDefaultDeclaration=function(e,t,n){e.declaration&&n(e.declaration,t,"ExportNamedDeclaration"===e.type||e.declaration.id?"Statement":"Expression"),e.source&&n(e.source,t,"Expression")},y.ExportAllDeclaration=function(e,t,n){e.exported&&n(e.exported,t),n(e.source,t,"Expression")},y.ImportDeclaration=function(e,t,n){for(var s=0,i=e.specifiers;s<i.length;s+=1){n(i[s],t)}n(e.source,t,"Expression")},y.ImportExpression=function(e,t,n){n(e.source,t,"Expression")},y.ImportSpecifier=y.ImportDefaultSpecifier=y.ImportNamespaceSpecifier=y.Identifier=y.PrivateIdentifier=y.Literal=Ce,y.TaggedTemplateExpression=function(e,t,n){n(e.tag,t,"Expression"),n(e.quasi,t,"Expression")},y.ClassDeclaration=y.ClassExpression=function(e,t,n){return n(e,t,"Class")},y.Class=function(e,t,n){e.id&&n(e.id,t,"Pattern"),e.superClass&&n(e.superClass,t,"Expression"),n(e.body,t)},y.ClassBody=function(e,t,n){for(var s=0,i=e.body;s<i.length;s+=1){n(i[s],t)}},y.MethodDefinition=y.PropertyDefinition=y.Property=function(e,t,n){e.computed&&n(e.key,t,"Expression"),e.value&&n(e.value,t,"Expression")};class Ys{constructor(){d(this,"portals",new Map),d(this,"portalCounter",0),d(this,"componentManager"),d(this,"domBindingManager"),d(this,"cleanupObserver"),d(this,"stateManager"),d(this,"pphpInstance"),this.cleanupObserver=new MutationObserver(e=>{this.handleMutations(e)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}setDependencies(e,t,n,s){this.componentManager=e,this.domBindingManager=t,this.stateManager=n,this.pphpInstance=s}createPortal(e,t,n){var s;const i="string"==typeof t?document.querySelector(t):t;if(!i)throw new Error(`Portal container not found: ${t}`);const r=(null==(s=this.componentManager)?void 0:s.getCurrentComponent())||"app",a=(null==n?void 0: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){var s,i;if(this.componentManager&&this.domBindingManager)try{await this.renderPortal(e,t),await new Promise(e=>requestAnimationFrame(e)),this.domBindingManager.processPendingBindings(),await new Promise(e=>{var t;null==(t=this.stateManager)||t.onDOMUpdateComplete(()=>{e(void 0)})}),null==(s=this.pphpInstance)||s.markPortalHydrated(n),null!=t&&t.onMount&&t.onMount(e.container)}catch(e){console.error("Portal hydration error:",e),null==(i=this.pphpInstance)||i.markPortalHydrated(n)}else console.warn("PortalManager dependencies not set")}renderPortal(e,t){return new Promise((t,n)=>{if(!this.componentManager||!this.domBindingManager)return console.warn("PortalManager dependencies not set"),void n(new Error("Dependencies not set"));try{let n;if(e.renderedContent&&e.renderedContent.parentElement&&e.renderedContent.parentElement.removeChild(e.renderedContent),"string"==typeof e.content){const t=document.createElement("template");if(t.innerHTML=e.content.trim(),n=t.content.firstElementChild,!n)throw new Error("Invalid HTML string for portal content")}else if(e.content instanceof DocumentFragment){const t=document.createElement("div");if(t.appendChild(e.content.cloneNode(!0)),n=t.firstElementChild,!n)throw new Error("DocumentFragment must contain at least one element")}else n=e.content;n.setAttribute("data-portal-id",e.id),n.setAttribute("data-portal-component",e.component),e.container.appendChild(n),e.renderedContent=n;const s=[...this.componentManager.componentStack];try{this.componentManager.executePhpScripts(n),this.domBindingManager.processElement(n,!0);const s=n.querySelectorAll("template[pp-for]"),i=this.domBindingManager.loopManager;i&&(s.forEach(t=>{var n,s;const r=t;if(null!=(n=i.loopBindings)&&n.has(r)){const t=i.loopBindings.get(r);t&&(null==(s=t.subscriptionIds)||s.forEach(e=>{var t;null==(t=this.stateManager)||t.removeSubscription(e)}),i.loopBindings.delete(r)),i.processTemplate(r,e.component)}else i.queueTemplate(r,e.component)}),i.processPendingTemplates()),this.domBindingManager.processPendingBindings(),t()}finally{this.componentManager.componentStack=s}}catch(t){console.error("Portal rendering error:",t),this.portals.delete(e.id),n(t)}})}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(e){return console.error("Portal cleanup error:",e),!1}}cleanupPortalElement(e){var t;if(this.stateManager){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let s=e;do{s.nodeType===Node.ELEMENT_NODE&&(null==(t=this.stateManager.subscriptionManager)||t.cleanupElement(s))}while(s=n.nextNode())}}updatePortal(e,t,n){const s=this.portals.get(e);return!!s&&(s.content=t,this.renderPortal(s,n),!0)}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)"childList"===t.type&&t.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(const[e,n]of this.portals)(n.container===t||t.contains(n.container))&&this.removePortal(e)}})}destroy(){for(const e of Array.from(this.portals.keys()))this.removePortal(e);this.cleanupObserver.disconnect(),this.portals.clear()}}const Z=class e{constructor(){d(this,"stateVariables",new Set)}extractIterableName(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script"}).body;if(!t||0===t.length)return"items";const n=t[0];if("ExpressionStatement"!==n.type)return"items";const s=n.expression;if("Identifier"===s.type)return s.name;if("MemberExpression"===s.type)return this.extractMemberExpressionPath(s);if("CallExpression"===s.type){if("Identifier"===s.callee.type)return s.callee.name;if("MemberExpression"===s.callee.type)return this.extractMemberExpressionPath(s.callee)}return"CallExpression"===s.type&&"MemberExpression"===s.callee.type?this.extractRootIdentifier(s.callee.object):"items"}catch(t){return console.warn(`⚠️ Failed to parse iterable expression: "${e}"`,t),"items"}}extractMemberExpressionPath(e){const t=[];let n=e;for(;n;){if("Identifier"===n.type){t.unshift(n.name);break}if("MemberExpression"!==n.type)break;"Identifier"!==n.property.type||n.computed?n.computed&&"Literal"===n.property.type&&t.unshift(`[${n.property.value}]`):t.unshift(n.property.name),n=n.object}return t.join(".")||"items"}extractRootIdentifier(e){let t=e;for(;t;){if("Identifier"===t.type)return t.name;if("MemberExpression"!==t.type)break;t=t.object}return"items"}transformRefDeclarations(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{VariableDeclarator:t=>{if(this.isRefDeclaration(t)){const n=t.id.name,i=this.findStatementEnd(e,t.end);s.push({start:i,end:i,replacement:`; this.${n} = ${n}`})}}}),s.sort((e,t)=>t.start-e.start).forEach(e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)}),n}catch(t){return console.error("Ref transformation error:",t),e}}isRefDeclaration(e){var t,n,s,i,r;return"Identifier"===(null==(t=e.id)?void 0:t.type)&&"CallExpression"===(null==(n=e.init)?void 0:n.type)&&"MemberExpression"===(null==(s=e.init.callee)?void 0:s.type)&&"Identifier"===(null==(i=e.init.callee.object)?void 0:i.type)&&"pp"===e.init.callee.object.name&&"Identifier"===(null==(r=e.init.callee.property)?void 0:r.type)&&"ref"===e.init.callee.property.name}findStatementEnd(e,t){let n=t;for(;n<e.length&&";"!==e[n]&&"\n"!==e[n];)n++;return n}static getInstance(){return e.instance||(e.instance=new e),e.instance}extractFunctionNames(e){const t=[];try{U(F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),{FunctionDeclaration:e=>{var n;"Identifier"===(null==(n=e.id)?void 0:n.type)&&t.push(e.id.name)},VariableDeclarator:e=>{var n,s,i;"Identifier"===(null==(n=e.id)?void 0:n.type)&&("ArrowFunctionExpression"===(null==(s=e.init)?void 0:s.type)||"FunctionExpression"===(null==(i=e.init)?void 0:i.type))&&t.push(e.id.name)},AssignmentExpression:e=>{var n,s,i;"Identifier"===(null==(n=e.left)?void 0:n.type)&&("ArrowFunctionExpression"===(null==(s=e.right)?void 0:s.type)||"FunctionExpression"===(null==(i=e.right)?void 0:i.type))&&t.push(e.left.name)}})}catch(e){console.error("AST function extraction error:",e)}return Array.from(new Set(t))}transformEffectDeclarations(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{CallExpression:t=>{const n=this.transformEffectCall(t,e);n&&s.push(n)}}),s.sort((e,t)=>t.start-e.start).forEach(e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.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 s=n[1];if("ArrayExpression"!==s.type||!s.elements.some(e=>!!e&&("Identifier"===e.type||"MemberExpression"===e.type)))return null;const i=s.elements.map(e=>e?"Identifier"===e.type?`"${e.name}"`:"MemberExpression"===e.type?`"${this.extractMemberExpression(e,t)}"`:t.slice(e.start,e.end):"null"),r=t.slice(n[0].start,n[0].end),a=n.slice(2).map(e=>t.slice(e.start,e.end)).join(", "),o=`[${i.join(", ")}]`,c=a?`pp.effect(${r}, ${o}, ${a})`:`pp.effect(${r}, ${o})`;return{start:e.start,end:e.end,replacement:c}}extractMemberExpression(e,t){if("MemberExpression"!==e.type)return"Identifier"===e.type?e.name:t.slice(e.start,e.end);const n=this.extractMemberExpression(e.object,t);if(e.computed){return`${n}[${t.slice(e.property.start,e.property.end)}]`}return`${n}.${e.property.name||t.slice(e.property.start,e.property.end)}`}isPPEffectCall(e){var t,n,s;return"MemberExpression"===(null==(t=e.callee)?void 0:t.type)&&"Identifier"===(null==(n=e.callee.object)?void 0:n.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(s=e.callee.property)?void 0:s.type)&&"effect"===e.callee.property.name}transformStateDeclarations(e,t){this.stateVariables.clear(),t&&t.forEach(e=>this.stateVariables.add(e));let n=this.transformStateDeclarationsOnly(e);return n=this.transformEffectDeclarations(n),n=this.transformRefDeclarations(n),n=this.transformUnsupportedStateUsages(n),n}transformStateDeclarationsOnlyOriginal(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{VariableDeclarator:t=>{const n=this.transformStateDeclarator(t,e);n&&s.push(n)}}),s.sort((e,t)=>t.start-e.start).forEach(e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(t);let n=this.transformShorthandProperties(e);const s=F(n,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),i=[],r=new Set,a=new Map;vt(s,{VariableDeclarator:(e,t)=>{var n;if(this.isStateDeclaration(e))return;let s=null;for(let e=t.length-1;e>=0;e--){const n=t[e];if("FunctionExpression"===n.type||"ArrowFunctionExpression"===n.type||"FunctionDeclaration"===n.type||"BlockStatement"===n.type){s=n;break}}s&&"Identifier"===(null==(n=e.id)?void 0:n.type)&&(a.has(s)||a.set(s,new Set),a.get(s).add(e.id.name),r.add(e.id.name))}});const o=(e,t)=>{for(let n=t.length-1;n>=0;n--){const s=t[n],i=a.get(s);if(i&&i.has(e))return!0}return!1},c=(e,t)=>!(e&&"Identifier"===e.type&&this.stateVariables.has(e.name)&&!r.has(e.name)&&!this.alreadyHasValue(e,t));return U(s,{Property:e=>{var t;!e.shorthand&&"Identifier"===(null==(t=e.value)?void 0:t.type)&&this.stateVariables.has(e.value.name)&&!r.has(e.value.name)&&!this.alreadyHasValue(e.value,n)&&i.push({start:e.value.start,end:e.value.end,replacement:`${e.value.name}.value`})},MemberExpression:e=>{var t;"Identifier"===(null==(t=e.object)?void 0:t.type)&&this.stateVariables.has(e.object.name)&&!r.has(e.object.name)&&!this.alreadyHasValue(e.object,n)&&i.push({start:e.object.start,end:e.object.end,replacement:`${e.object.name}.value`})},SpreadElement:e=>{if(!c(e.argument,n)){const t=this.transformSpreadElement(e,n);t&&i.push(t)}},UnaryExpression:e=>{if(!c(e.argument,n)){const t=this.transformUnaryExpression(e,n);t&&i.push(t)}},BinaryExpression:e=>{const t=c(e.left,n),s=c(e.right,n);if(!t||!s){const t=this.transformBinaryExpression(e,n);t&&i.push(t)}},LogicalExpression:e=>{const t=c(e.left,n),s=c(e.right,n);if(!t||!s){const t=this.transformLogicalExpression(e,n);t&&i.push(t)}},ConditionalExpression:e=>{const t=this.transformConditionalExpression(e,n);t&&i.push(t)},IfStatement:e=>{if(!c(e.test,n)){const t=this.transformIfStatement(e,n);t&&i.push(t)}},WhileStatement:e=>{if(!c(e.test,n)){const t=this.transformWhileStatement(e,n);t&&i.push(t)}},ForStatement:e=>{const t=this.transformForStatement(e,n);t&&i.push(t)},ReturnStatement:e=>{const t=this.transformReturnStatement(e,n);t&&i.push(t)},VariableDeclarator:e=>{const t=this.transformVariableDeclarator(e,n);t&&i.push(t)},AssignmentExpression:e=>{const t=this.transformAssignmentExpression(e,n);t&&i.push(t)},CallExpression:e=>{const t=this.transformGeneralCallExpression(e,n);t&&t.length>0&&i.push(...t)}}),vt(s,{Identifier:(e,t)=>{!this.stateVariables.has(e.name)||i.some(t=>e.start>=t.start&&e.end<=t.end)||o(e.name,t)||this.alreadyHasValue(e,n)||this.isPartOfStateDeclaration(e,t)||this.isPropertyName(e,t)||this.isMethodCallObject(e,t)||this.isPartOfPPCall(e,t)||this.isPartOfDestructuring(e,t)||i.push({start:e.start,end:e.end,replacement:`${e.name}.value`})}}),i.sort((e,t)=>t.start-e.start).forEach(e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)}),n=this.transformMultipleCallArguments(n,r),n}catch(t){return console.error("State usage transformation error:",t),e}}transformShorthandProperties(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{Property:e=>{var t;if(e.shorthand&&"Identifier"===(null==(t=e.key)?void 0:t.type)&&this.stateVariables.has(e.key.name)){const t=e.key.name,n=`${t}: ${t}.value`;s.push({start:e.start,end:e.end,replacement:n})}}}),s.sort((e,t)=>t.start-e.start).forEach(e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)}),n}catch(t){return console.error("Shorthand property transformation error:",t),e}}transformLogicalExpression(e,t){var n,s;return"Identifier"===(null==(n=e.left)?void 0:n.type)&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t)?{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`}:"Identifier"===(null==(s=e.right)?void 0:s.type)&&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){var n,s,i;return"Identifier"===(null==(n=e.test)?void 0:n.type)&&this.stateVariables.has(e.test.name)&&!this.alreadyHasValue(e.test,t)?{start:e.test.start,end:e.test.end,replacement:`${e.test.name}.value`}:"Identifier"===(null==(s=e.consequent)?void 0:s.type)&&this.stateVariables.has(e.consequent.name)&&!this.alreadyHasValue(e.consequent,t)?{start:e.consequent.start,end:e.consequent.end,replacement:`${e.consequent.name}.value`}:"Identifier"===(null==(i=e.alternate)?void 0:i.type)&&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){var n,s,i;return this.isStateDeclaration(e)||"ArrayPattern"===(null==(n=e.id)?void 0:n.type)||"ObjectPattern"===(null==(s=e.id)?void 0:s.type)?null:"Identifier"===(null==(i=e.init)?void 0:i.type)&&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){var n,s,i;return"ArrayPattern"===(null==(n=e.left)?void 0:n.type)||"ObjectPattern"===(null==(s=e.left)?void 0:s.type)?null:"Identifier"===(null==(i=e.right)?void 0:i.type)&&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(t,n){var s,i;const r=n.slice(t.callee.start,t.callee.end);if("MemberExpression"===(null==(s=t.callee)?void 0:s.type)&&"Identifier"===(null==(i=t.callee.object)?void 0:i.type)&&this.stateVariables.has(t.callee.object.name))return[];if(this.isPPCall(t))return[];if(!e.isFunctionNeedingValueTransform(r)&&t.arguments.length>0){const e=[];for(const s of t.arguments)"Identifier"===s.type&&this.stateVariables.has(s.name)&&(this.alreadyHasValue(s,n)||e.push({start:s.start,end:s.end,replacement:`${s.name}.value`}));return e}return[]}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"Identifier"===(null==e?void 0:e.type)&&this.stateVariables.has(e.name)&&!this.alreadyHasValue(e,t)?{start:e.start,end:e.end,replacement:`${e.name}.value`}:null}isPPCall(e){var t,n,s;return"MemberExpression"===(null==(t=e.callee)?void 0:t.type)&&"Identifier"===(null==(n=e.callee.object)?void 0:n.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(s=e.callee.property)?void 0:s.type)&&("state"===e.callee.property.name||"effect"===e.callee.property.name)}isPartOfStateDeclaration(e,t){var n,s;if(!t||!Array.isArray(t))return!1;for(const e of t)if("VariableDeclarator"===e.type&&"ArrayPattern"===(null==(n=e.id)?void 0:n.type)&&"CallExpression"===(null==(s=e.init)?void 0:s.type)&&this.isPPStateCall(e.init))return!0;return!1}isPropertyName(e,t){if(!t||0===t.length)return!1;const n=t[t.length-1];return!!("Property"===(null==n?void 0:n.type)&&n.key===e||"Property"===(null==n?void 0:n.type)&&n.shorthand&&n.value===e||"MemberExpression"===(null==n?void 0:n.type)&&n.property===e&&!n.computed)}isMethodCallObject(e,t){if(!t||0===t.length)return!1;const n=t[t.length-1];if("MemberExpression"===(null==n?void 0:n.type)&&n.object===e&&t.length>=2){const e=t[t.length-2];if("CallExpression"===(null==e?void 0:e.type)&&e.callee===n)return!0}return!1}isPartOfPPCall(e,t){var n,s,i;if(!t||!Array.isArray(t))return!1;for(const e of t)if("CallExpression"===e.type&&"MemberExpression"===(null==(n=e.callee)?void 0:n.type)&&"Identifier"===(null==(s=e.callee.object)?void 0:s.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(i=e.callee.property)?void 0:i.type)&&("state"===e.callee.property.name||"effect"===e.callee.property.name))return!0;return!1}isPartOfDestructuring(e,t){if(!t||!Array.isArray(t))return!1;for(let n=0;n<t.length;n++){const s=t[n];if("ArrayPattern"===s.type||"ObjectPattern"===s.type){if(n+1<t.length){const i=t[n+1];if("VariableDeclarator"===(null==i?void 0:i.type)&&i.id===s&&i.init===e)return!1}return!0}}return!1}collectStateVariables(e){U(e,{VariableDeclarator:e=>{if(this.isStateDeclaration(e)){const t=e.id.elements[0];"Identifier"===(null==t?void 0:t.type)&&this.stateVariables.add(t.name)}}})}isStateDeclaration(e){var t,n;return"ArrayPattern"===(null==(t=e.id)?void 0:t.type)&&"CallExpression"===(null==(n=e.init)?void 0:n.type)&&this.isPPStateCall(e.init)}transformSpreadElement(e,t){var n;return"Identifier"===(null==(n=e.argument)?void 0:n.type)&&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){var n;return"Identifier"===(null==(n=e.argument)?void 0:n.type)&&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){var n,s;if(["===","!==","==","!=",">","<",">=","<=","+","-","*","/","%","**","&","|","^","<<",">>",">>>","in","instanceof"].includes(e.operator)){if("Identifier"===(null==(n=e.left)?void 0:n.type)&&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("Identifier"===(null==(s=e.right)?void 0:s.type)&&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(t,n){try{const s=F(t,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=t;const r=[];return U(s,{CallExpression:t=>{const s=i.slice(t.callee.start,t.callee.end);if(e.isFunctionNeedingValueTransform(s)&&t.arguments.length>0)for(const e of t.arguments)if("Identifier"===e.type&&this.stateVariables.has(e.name)){if(n&&n.has(e.name))continue;this.alreadyHasValue(e,i)||r.push({start:e.start,end:e.end,replacement:`${e.name}.value`})}}}),r.sort((e,t)=>t.start-e.start).forEach(e=>{i=i.slice(0,e.start)+e.replacement+i.slice(e.end)}),i}catch(e){return console.error("Multiple call arguments transformation error:",e),t}}transformDestructuringAssignments(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{VariableDeclarator:t=>{var n,i,r;this.isStateDeclaration(t)||("ArrayPattern"===(null==(n=t.id)?void 0:n.type)||"ObjectPattern"===(null==(i=t.id)?void 0:i.type))&&"Identifier"===(null==(r=t.init)?void 0:r.type)&&this.stateVariables.has(t.init.name)&&(this.alreadyHasValue(t.init,e)||s.push({start:t.init.start,end:t.init.end,replacement:`${t.init.name}.value`}))},AssignmentExpression:t=>{var n,i,r;("ArrayPattern"===(null==(n=t.left)?void 0:n.type)||"ObjectPattern"===(null==(i=t.left)?void 0:i.type))&&"Identifier"===(null==(r=t.right)?void 0:r.type)&&this.stateVariables.has(t.right.name)&&(this.alreadyHasValue(t.right,e)||s.push({start:t.right.start,end:t.right.end,replacement:`${t.right.name}.value`}))}}),s.sort((e,t)=>t.start-e.start).forEach(e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.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){var n,s;if("ArrayPattern"!==(null==(n=e.id)?void 0:n.type)||"CallExpression"!==(null==(s=e.init)?void 0:s.type))return null;const i=e.init;if(!this.isPPStateCall(i))return null;const r=e.id.elements[0];if(!r||"Identifier"!==r.type)return null;const a=r.name,o=`set${this.capitalize(a)}`,c=e.id.elements[1];return"Identifier"===(null==c?void 0:c.type)&&c.name!==o&&console.warn(`Setter name mismatch: expected ${o}, got ${c.name}`),this.createTransformation(i,a,t)}isPPStateCall(e){var t,n,s;return"MemberExpression"===(null==(t=e.callee)?void 0:t.type)&&"Identifier"===(null==(n=e.callee.object)?void 0:n.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(s=e.callee.property)?void 0:s.type)&&"state"===e.callee.property.name}createTransformation(e,t,n){const s=e.arguments;if(0===s.length){const n=`pp.state("${t}")`;return{start:e.start,end:e.end,replacement:n}}const i=s[0];if("Literal"===i.type&&"string"==typeof i.value&&i.value===t)return null;if(1===s.length){const s=`pp.state("${t}", ${n.slice(i.start,i.end)})`;return{start:e.start,end:e.end,replacement:s}}const r=`pp.state("${t}", ${n.slice(e.arguments[0].start,e.arguments[e.arguments.length-1].end)})`;return{start:e.start,end:e.end,replacement:r}}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")}extractStateDeclarations(e){const t=[];try{U(F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0}),{VariableDeclarator:n=>{const s=this.extractStateFromDeclarator(n,e);s&&t.push(s)}})}catch(e){console.error("State extraction error:",e)}return t}extractStateFromDeclarator(e,t){var n,s,i,r;if("ArrayPattern"!==(null==(n=e.id)?void 0:n.type)||"CallExpression"!==(null==(s=e.init)?void 0:s.type)||!this.isPPStateCall(e.init))return null;const a=e.id.elements[0],o=e.id.elements[1];if("Identifier"!==(null==a?void 0:a.type)||"Identifier"!==(null==o?void 0:o.type))return null;const c=e.init.arguments;let l,h=a.name;return c.length>=1&&("Literal"===c[0].type&&"string"==typeof c[0].value?this.looksLikeVariableName(c[0].value)?(h=c[0].value,c.length>=2&&(l=this.extractLiteralValue(c[1]))):(h=a.name,l=this.extractLiteralValue(c[0])):l=this.extractLiteralValue(c[0])),{variableName:a.name,setterName:o.name,stateKey:h,initialValue:l,line:(null==(i=e.loc)?void 0:i.start.line)||0,column:(null==(r=e.loc)?void 0:r.start.column)||0}}extractFunctionDeclarations(e){const t=[];try{U(F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0}),{FunctionDeclaration:e=>{var n,s;"Identifier"===(null==(n=e.id)?void 0:n.type)&&t.push({name:e.id.name,type:"function",params:e.params.map(e=>"Identifier"===e.type?e.name:""),line:(null==(s=e.loc)?void 0:s.start.line)||0})},VariableDeclarator:e=>{var n,s,i,r;if("Identifier"===(null==(n=e.id)?void 0:n.type)&&("ArrowFunctionExpression"===(null==(s=e.init)?void 0:s.type)||"FunctionExpression"===(null==(i=e.init)?void 0:i.type))){const n=e.init;t.push({name:e.id.name,type:"ArrowFunctionExpression"===n.type?"arrow":"function",params:n.params.map(e=>"Identifier"===e.type?e.name:""),line:(null==(r=e.loc)?void 0:r.start.line)||0})}}})}catch(e){console.error("Function extraction error:",e)}return t}extractLiteralValue(e){if("Literal"===e.type)return e.value;"Identifier"===e.type&&e.name}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}};d(Z,"instance"),d(Z,"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"]));let ye=Z;class Js{constructor(e,t){d(this,"componentManager"),d(this,"textNodeBindings",new Map),d(this,"expressionEvaluator"),d(this,"stateManager"),d(this,"cleanupObserver"),d(this,"bindingCount",0),this.expressionEvaluator=e,this.stateManager=t,this.cleanupObserver=new MutationObserver(e=>{this.cleanupDetachedNodes(e)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}cleanupDetachedNodes(e){const t=[];for(const n of e)"childList"===n.type&&n.removedNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE)t.push(e);else if(e.nodeType===Node.ELEMENT_NODE){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let s;for(;s=n.nextNode();)t.push(s)}});Promise.resolve().then(()=>{t.forEach(e=>{document.contains(e)||this.cleanupTextNode(e)})})}processTextNode(e,t){if(this.shouldSkipTextNode(e))return;const n=M.findScope(e);let s;if(n)s="app"===n?"app":n;else{const n=e.parentElement;s=n?w.getContextComponent(n):t}const i=e.textContent||"",r=O.parse(i);if(!this.hasValidExpressions(r))return;const a=this.resolveComponentRootForElement(e,s),o=this.createTextNodeBinding(i,r,s,a);this.setupExpressionSubscriptions(e,r,s,a,o),this.textNodeBindings.set(e,o),this.bindingCount++,this.updateTextNode(e)}shouldSkipTextNode(e){return this.textNodeBindings.has(e)||w.isTextNodeInsideScript(e)||this.isInsideLoopItem(e)||w.shouldIgnoreMustache(e)}hasValidExpressions(e){return e.some(e=>"expression"===e.type)}createTextNodeBinding(e,t,n,s){return{originalContent:e,expressions:t,subscriptionIds:[],component:n,componentElement:s}}setupExpressionSubscriptions(e,t,n,s,i){t.filter(e=>"expression"===e.type).forEach(t=>{if(!t.expression)return;const r=`text_${Date.now()}_${Math.random()}`,a=this.expressionEvaluator.extractDependencies(t.expression,n,this.stateManager);if(s&&this.componentManager){const e=this.componentManager.getComponentPropDependencies(s,n);a.push(...e)}const o={id:r,selector:"",dependencies:new Set(a),callback:()=>{this.updateTextNode(e)},element:e.parentElement??void 0,component:n};this.stateManager.addSubscription(o),i.subscriptionIds.push(r)})}updateTextNode(e){const t=this.textNodeBindings.get(e);if(!t||!e.parentElement)return;const n=this.resolveBindingComponentElement(e,t),s=this.buildEvaluationContext(e,t,n),i=this.evaluateExpressionsToText(t.expressions,s,t.component);this.applyTextUpdate(e,i)}resolveBindingComponentElement(e,t){let{componentElement:n}=t;return(!n||!document.contains(n))&&(n=this.resolveComponentRootForElement(e,t.component),t.componentElement=n),n}buildEvaluationContext(e,t,n){let s=this.componentManager.buildComponentContext(t.component);const i=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t.component}"]`);let r=!1;for(const e of i)if(this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluateProps(e);s={...s,...t},r=!0;break}if(!r){let t=e.parentElement;for(;t&&t!==document.body;){if(t.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);s={...s,...e};break}t=t.parentElement}}return os(s)}evaluateExpressionsToText(e,t,n){let s="";for(const i of e)if("static"===i.type)s+=i.content;else if(i.expression)try{s+=Ee(this.expressionEvaluator.evaluateExpression(i.expression,t,n))}catch(e){console.error(`❌ Text binding evaluation error for "${i.expression}":`,e),console.error(`Component: ${n}`),console.error(`Available variables: [${Object.keys(t).join(", ")}]`),s+=""}return s}applyTextUpdate(e,t){e.textContent!==t&&(e.textContent=t)}isInsideLoopItem(e){var t,n,s;let i=e.parentElement;for(;i&&i!==document.body;){const e=i.previousSibling;if(e&&e.nodeType===Node.COMMENT_NODE&&null!=(t=e.textContent)&&t.startsWith("pp-for:"))return!0;let r=(null==(n=i.parentElement)?void 0:n.firstChild)||null;for(;r;){if(r.nodeType===Node.COMMENT_NODE&&null!=(s=r.textContent)&&s.startsWith("pp-for:")&&r!==i)return!0;r=r.nextSibling}i=i.parentElement}return!1}resolveComponentRootForElement(e,t){const n=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);if(this.componentManager)for(const e of n)if(this.componentManager.hasStoredProps(e))return e;return n[0]||void 0}cleanupTextNode(e){const t=this.textNodeBindings.get(e);t&&(t.subscriptionIds.forEach(e=>{this.stateManager.removeSubscription(e)}),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()}}const ce=class e{constructor(){d(this,"delegatedEvents",new Map),d(this,"elementHandlers",new WeakMap),d(this,"handlerCache",new K(200)),d(this,"componentManager"),d(this,"expressionEvaluator"),d(this,"loopManager"),d(this,"setupEvents",new Set)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static getAllAvailableEvents(){if(e.eventCache)return e.eventCache;const t=new Set,n=["click","input","change","submit","focus","blur","keydown","keyup","mousedown","mouseup","mouseover","mouseout"];try{Object.getOwnPropertyNames(HTMLElement.prototype).filter(e=>e.startsWith("on")&&e.length>2).map(e=>e.substring(2).toLowerCase()).forEach(e=>t.add(e))}catch(e){console.warn("Could not get HTMLElement events:",e),n.forEach(e=>t.add(e))}try{Object.getOwnPropertyNames(Document.prototype).filter(e=>e.startsWith("on")&&e.length>2).map(e=>e.substring(2).toLowerCase()).forEach(e=>t.add(e))}catch(e){console.warn("Could not get Document events:",e)}try{Object.getOwnPropertyNames(Window.prototype).filter(e=>e.startsWith("on")&&e.length>2).map(e=>e.substring(2).toLowerCase()).forEach(e=>t.add(e))}catch(e){console.warn("Could not get Window events:",e)}try{Object.getOwnPropertyNames(Element.prototype).filter(e=>e.startsWith("on")&&e.length>2).map(e=>e.substring(2).toLowerCase()).forEach(e=>t.add(e))}catch(e){console.warn("Could not get Element events:",e)}return new Set(["beforeunload","unload","pagehide","pageshow","popstate","hashchange","storage","message","messageerror","offline","online","languagechange","rejectionhandled","unhandledrejection","afterprint","beforeprint","devicemotion","deviceorientation","deviceorientationabsolute"]).forEach(e=>t.delete(e)),e.eventCache=t,t}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),("focusin"===e||"focusout"===e)&&(t.capture=!1),t}isEventSupported(t){return e.getAllAvailableEvents().has(t.toLowerCase())}getAllSupportedEvents(){return Array.from(e.getAllAvailableEvents()).sort()}getDelegatedEvents(){return Array.from(this.delegatedEvents.keys()).sort()}setDependencies(e,t,n,s){this.componentManager=e,this.expressionEvaluator=t,this.loopManager=s}createDelegatedListener(e){return t=>{const n=t.target;if(!n)return;const s=this.findHandler(n,e);s&&this.executeHandler(s.handler,s.element,t)}}registerEventHandler(e,t,n,s){const i=t.toLowerCase();if(this.ensureEventSetup(i),!this.isEventSupported(i))return;const r=s;this.elementHandlers.has(e)||this.elementHandlers.set(e,new Map);const a={code:n,component:r};this.elementHandlers.get(e).set(i,a);const o=this.delegatedEvents.get(i);o?o.elements.add(e):(console.warn(`⚠️ No delegated listener for ${i}, attaching directly`),this.attachDirectListener(e,i,a))}ensureEventSetup(e){if(!this.setupEvents.has(e)){if(!this.isEventSupported(e))return void console.warn(`⚠️ Attempting to setup unsupported event: ${e}`);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 e=this.elementHandlers.get(n);if(null!=e&&e.has(t))return{handler:e.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 s=e;e.includes("this")&&(s=s.replace(/\bthis\b/g,"thisElement")),e.includes("event")&&(s=s.replace(/\bevent\b/g,"eventObject"));const i=new Function("eventObject","thisElement","context",`\n try {\n with(context) {\n ${s}\n }\n } catch(error) {\n console.error('Event handler execution error:', error);\n console.error('Handler code:', ${JSON.stringify(e)});\n console.error('Component:', '${t}');\n console.error('Available context keys:', Object.keys(context));\n }\n `);return this.handlerCache.set(n,i),i}executeHandler(e,t,n){var s;if(this.componentManager&&this.expressionEvaluator)try{const{effectiveComponent:i,useStrictScope:r,scopedComponent:a,actualElementComponent:o}=this.resolveEffectiveComponent(t,e),c=this.locateComponentElement(t,i,o),l=this.findNearestComponentWithProps(t);let h=r?this.buildContextStrict(a,i,c,t):this.buildContextNonStrict(i,c,l);h=os(h),h=this.mergeLoopContext(t,h),this.ensureCompiled(e),null==(s=e.compiledFn)||s.call(e,n,t,h)}catch(t){console.error("💥 Event handler execution failed:",t),console.error("Handler code:",e.code),console.error("Handler component:",e.component)}else console.warn("EventDelegationManager dependencies not set")}resolveEffectiveComponent(e,t){const n=M.findScope(e),s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);return n?{effectiveComponent:"app"===n?"app":n,useStrictScope:!0,scopedComponent:n,actualElementComponent:s}:t.component?{effectiveComponent:t.component,useStrictScope:!1,scopedComponent:null,actualElementComponent:s}:s?{effectiveComponent:s,useStrictScope:!1,scopedComponent:null,actualElementComponent:s}:{effectiveComponent:"app",useStrictScope:!1,scopedComponent:null,actualElementComponent:null}}locateComponentElement(e,t,n){if(n&&n===t)return e;let s=e.parentElement;for(;s&&s!==document.body;){if(s.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return s;s=s.parentElement}for(s=e.parentElement;s&&s!==document.body;){if(s.getAttribute(g.ATTR_PREFIXES.COMPONENT))return s;s=s.parentElement}const i=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const e of i)if(this.componentManager.hasStoredProps(e))return e;return i.length>0?i[0]:null}findNearestComponentWithProps(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(t))return t;t=t.parentElement}return null}buildContextStrict(e,t,n,s){if(t&&t!==e){let s=this.componentManager.buildComponentContext(t);if(n&&this.componentManager.hasStoredProps(n)){const e=this.componentManager.evaluateProps(n);s={...s,...e}}if(e&&e!==t)if("app"===e){const e=this.componentManager.buildComponentContext("app");for(const[t,n]of Object.entries(e))t in s||(s[t]=n)}else{const t=this.componentManager.buildComponentContext(e);for(const[e,n]of Object.entries(t))e in s||(s[e]=n)}return s}if("app"===e){let e=this.componentManager.buildComponentContext("app");if(n&&n!==document.body&&this.componentManager.hasStoredProps(n)){const t=this.componentManager.evaluateProps(n);e={...e,...t}}return e}let i=this.componentManager.buildComponentContext(t);if(n&&this.componentManager.hasStoredProps(n)){const e=this.componentManager.evaluateProps(n);i={...i,...e}}return i}buildContextNonStrict(e,t,n){let s=this.componentManager.buildRestrictedComponentContext(e,!1);if(n){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===e)return this.componentManager.buildComponentContextWithProps(e,n);if("app"===M.findScope(n)){let e={};e.getContext=()=>this.componentManager.buildComponentContext("app"),e.withContext=e=>{const t=this.componentManager.buildComponentContext("app");return e.call(t,t)},e.__getProp=e=>this.componentManager.evaluateProps(n)[e];const t=this.componentManager.evaluateProps(n);e={...e,...t};const s=n.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(s){const t=this.componentManager.getComponentFunctions(s);if(t)for(const[n,s]of t)e[n]=s}return e}const t=this.componentManager.buildRestrictedComponentContext(e,!1),s=this.componentManager.evaluateProps(n);return Object.assign(t,s),t}if(t&&t.getAttribute(g.ATTR_PREFIXES.COMPONENT)===e)return this.componentManager.buildComponentContextWithProps(e,t);const i=t||n;if(i&&this.componentManager.hasStoredProps(i)){const e=this.componentManager.evaluateProps(i);Object.assign(s,e)}if("app"!==e){const e=this.componentManager.buildComponentContext("app");for(const[t,n]of Object.entries(e))t in s||(s[t]=n)}return s}mergeLoopContext(e,t){var n;const s=null==(n=this.loopManager)?void 0:n.getLoopContextForElement(e);if(!s)return t;const i={};for(const[e,t]of Object.entries(s))i[e]="function"==typeof t&&"__pphp_key"in t?t.value:t;return{...t,...i}}ensureCompiled(e){e.compiledFn||(e.compiledFn=this.compileHandler(e.code,e.component))}attachDirectListener(e,t,n){const s=t=>{this.executeHandler(n,e,t)};e.addEventListener(t,s),e[`__${t}_listener`]=s}removeEventHandler(e,t){var n,s;const i=this.elementHandlers.get(e);i&&(i.delete(t),0===i.size&&this.elementHandlers.delete(e));const r=this.delegatedEvents.get(t);r&&(null==(s=(n=r.elements).delete)||s.call(n,e));const a=e[`__${t}_listener`];a&&(e.removeEventListener(t,a),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()}};d(ce,"eventCache",null);let ie=ce;class Zs{constructor(e,t,n){d(this,"loopManager"),d(this,"stateManager"),d(this,"textNodeManager"),d(this,"componentManager"),d(this,"expressionEvaluator"),d(this,"observer"),d(this,"listeners",new WeakMap),d(this,"pendingBindings",[]),d(this,"pendingTextNodes",[]),d(this,"applyingUpdates",!1),d(this,"elementCache",new WeakMap),d(this,"batchedUpdates",new Set),d(this,"processingRAF",null),d(this,"updateQueue",new Map),d(this,"eventDelegation",new ie),d(this,"processedElements",new WeakSet),d(this,"templateRenderer"),d(this,"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"}),d(this,"lastValueCache",new WeakMap),d(this,"stringValueCache",new K(500)),d(this,"refBindings",new WeakMap),d(this,"observerPaused",!1),d(this,"isRelevantMutation",e=>{if(this.observerPaused||this.applyingUpdates&&"attributes"===e.type)return!1;if("childList"===e.type||"characterData"===e.type)return!0;if("attributes"===e.type){const t=e.attributeName;return t===g.ATTR_PREFIXES.COMPONENT||null!==t&&ie.isEventAttribute(t)}return!1}),this.stateManager=e,this.componentManager=t,this.expressionEvaluator=n,this.textNodeManager=new Js(n,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new en(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 ve(n)}pauseObserver(){this.observerPaused=!0,this.observer&&this.observer.disconnect()}resumeObserver(){this.observerPaused=!1,this.observer&&this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,characterDataOldValue:!1,attributeFilter:[g.ATTR_PREFIXES.COMPONENT]})}refreshComponentElement(e,t){this.elementCache.delete(e),this.processedElements.delete(e);const n=[...this.componentManager.componentStack];this.componentManager.componentStack=["app"],"app"!==t&&this.componentManager.componentStack.push(t);try{const n=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(e,n,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:e=>{const n=e;return!n.textContent||!g.MUSTACHE_PATTERN.test(n.textContent)||w.isTextNodeInsideScript(n)||this.isTextNodeInsideLoopItem(n)||w.getComponentForNode(n)!==t?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let s;const i=[];for(;s=n.nextNode();)i.push(s);i.forEach(e=>{this.textNodeManager.cleanupTextNode(e),this.textNodeManager.cleanupTextNode(e),this.textNodeManager.processTextNode(e,t)})}walkComponentChildren(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n;return w.getElementComponent(s)!==t?NodeFilter.FILTER_REJECT:s===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});let s;const i=[];for(;s=n.nextNode();){const e=s;i.push(e)}i.forEach(n=>{this.elementCache.delete(n),this.processedElements.delete(n);const s=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(n,s,t,!0)})}createSpreadDirectiveBinding(e,t,n){const s=`spread_${Date.now()}_${Math.random()}`,i=O.parseSpreadDirective(t);if(0===i.spreads.length&&0===i.objects.length)return void console.warn(`Invalid pp-spread directive: ${t}`);const r=new Set,a=()=>{if(document.contains(e))try{const t=this.componentManager.buildComponentContextWithProps(n,e);this.clearSpreadAttributes(e,r);for(const s of i.spreads){const i=this.expressionEvaluator.evaluateExpression(s,t,n);i&&"object"==typeof i&&this.applySpreadObject(e,i,r)}for(const s of i.objects)this.applyObjectProperties(e,s,t,n,r)}catch(e){console.error(`Spread directive evaluation error for "${t}":`,e)}else this.stateManager.removeSubscription(s)},o=new Set;for(const e of i.spreads)this.templateRenderer.dependencies(e,n,this.stateManager).forEach(e=>o.add(e));for(const e of i.objects)for(const t of e)this.templateRenderer.dependencies(t.value,n,this.stateManager).forEach(e=>o.add(e));const c={id:s,selector:"",dependencies:o,callback:a,element:e,component:n};this.stateManager.addSubscription(c),this.storeSpreadSubscription(e,s),a()}applyObjectProperties(e,t,n,s,i){for(const r of t)try{const t=this.expressionEvaluator.evaluateExpression(r.value,n,s);if(this.isEventProperty(r.key)){this.handleSpreadEventProperty(e,r.key,t);continue}const a=this.normalizeAttributeName(r.key);this.updateElementProperty(e,a,t),i.add(a)}catch(e){console.error(`Error evaluating object property "${r.key}: ${r.value}":`,e)}}applySpreadObject(e,t,n){for(const[s,i]of Object.entries(t))if(null!=i){if(this.isEventProperty(s)){this.handleSpreadEventProperty(e,s,i);continue}const t=this.normalizeAttributeName(s);(!e.hasAttribute(t)||n.has(t))&&(this.updateElementProperty(e,t,i),n.add(t))}}isEventProperty(e){return e.startsWith("on")&&e.length>2}handleSpreadEventProperty(e,t,n){const s=t.substring(2).toLowerCase();if("function"==typeof n){const t=t=>{var s;try{const i=w.getContextComponent(e),r=(null==(s=this.componentManager)?void 0:s.buildComponentContextWithProps(i,e))||{};n.call(r,t)}catch(e){console.error("Spread event handler error:",e)}};return e.addEventListener(s,t),void this.storeDirectEventListener(e,s,t)}if("string"==typeof n){const t=w.getContextComponent(e);this.eventDelegation.registerEventHandler(e,s,n,t)}}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(0===t.length)return;const n=He.getInstance(),s=new Set;for(const e of t)if("childList"===e.type&&(e.removedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){const e=t;this.cleanupRefBinding(e),e.querySelectorAll(`[${g.ATTR_PREFIXES.REF}]`).forEach(e=>{this.cleanupRefBinding(e)}),n.invalidateElement(e),M.invalidateTree(e);const s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);s&&n.invalidateByComponent(s)}else if(t.nodeType===Node.COMMENT_NODE){const t=e.target;t&&s.add(t)}}),e.addedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);e&&n.invalidateByComponent(e)}else if(t.nodeType===Node.COMMENT_NODE){const t=e.target;t&&s.add(t)}})),"attributes"===e.type&&e.target){const t=e.target;n.invalidateElement(t);const s=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);s&&n.invalidateByComponent(s)}s.forEach(e=>{M.invalidateTree(e)}),this.processMutationsBatch(t)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,characterDataOldValue:!1,attributeFilter:[g.ATTR_PREFIXES.COMPONENT]})}processElement(e,t=!0){if(e===document.body){const n=Array.from(document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}]`)).sort((e,t)=>w.getElementDepth(e)-w.getElementDepth(t));this.processElementsBatch([e],t),n.forEach(e=>{this.processElementsBatch([e],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(e=>{this.componentManager.executePhpScripts(e)}),this.processPendingBindings())}processSingleElement(e,t){const n=w.getElementComponent(e),s=M.findScope(e);let i;i=s?"app"===s?"app":s:w.getParentComponentForElement(e);const r=this.componentManager.componentStack.length;"app"!==n&&this.componentManager.pushComponent(n),this.componentManager.setupProps(e,i),t&&this.componentManager.executePhpScripts(e),this.processLoopTemplates(e,n);const a=t?this.componentManager.buildComponentContextWithProps(n,e):{};for(this.processElementInContext(e,a,n,t),this.walkDOM(e,a,n,t);this.componentManager.componentStack.length>r;)this.componentManager.popComponent()}processLoopTemplates(e,t){this.getDirectComponentTemplates(e,t).forEach(e=>{this.loopManager.queueTemplate(e,t)})}getDirectComponentTemplates(e,t){const n=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>{const n=t;return n!==e&&n.hasAttribute(g.ATTR_PREFIXES.COMPONENT)?NodeFilter.FILTER_REJECT:"TEMPLATE"===n.tagName&&n.hasAttribute("pp-for")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let i;for(;i=s.nextNode();)n.push(i);return n}walkDOM(e,t,n,s){const i=it.getInstance(),r=`walkDOM_${n}_${s}`,a=i.getCachedTraversal(e,r,()=>{const t=i.traverseElementsAndText(e,t=>{if(t===e||"script"===t.tagName.toLowerCase()||this.loopManager.isLoopItem(t)||w.shouldIgnoreMustache(t))return!1;let s=t.parentElement;for(;s&&s!==e;){if(this.loopManager.isLoopItem(s))return!1;s=s.parentElement}return!(w.getElementComponent(t)!==n||this.processedElements.has(t))},e=>{if(!e.textContent||!g.MUSTACHE_PATTERN.test(e.textContent)||w.isTextNodeInsideScript(e)||this.isTextNodeInsideLoopItem(e))return!1;const t=e.parentElement;if(t){const s=w.getContextComponent(t),i=w.getComponentForNode(e);if(s!==n&&i!==n)return!1}else if(w.getComponentForNode(e)!==n)return!1;return!0});return[...t.textNodes,...t.elements]}),o=[],c=[];a.forEach(e=>{if(e.nodeType===Node.TEXT_NODE)o.push(e);else if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.hasAttribute(`${g.ATTR_PREFIXES.REF}`)&&s){const e=t.getAttribute(`${g.ATTR_PREFIXES.REF}`);this.createRefBinding(t,e,n),t.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}c.push(t),this.processedElements.add(t)}}),o.forEach(e=>{const t=e.parentElement,i=t?w.getContextComponent(t):n;s?this.textNodeManager.processTextNode(e,i):this.pendingTextNodes.push({textNode:e,component:i})}),c.forEach(e=>{this.processElementInContext(e,t,n,s)})}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,s){if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const t=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);s&&this.createRefBinding(e,t,n),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}if(e.hasAttribute(`${g.ATTR_PREFIXES.SPREAD}`)){const t=e.getAttribute(`${g.ATTR_PREFIXES.SPREAD}`);s&&this.createSpreadDirectiveBinding(e,t,n),e.removeAttribute(g.ATTR_PREFIXES.SPREAD)}if(this.loopManager.isLoopItem(e)||this.isElementInLoopItem(e))return;const i=this.extractDomMustacheBindings(e),r=this.elementCache.get(e),a=this.getElementHash(e);if(r&&r.hash===a&&this.isCacheValid(r)&&s)return void this.applyBindingsFromCache(e,r,t);const o={bindings:i,component:n,listeners:[],lastProcessed:Date.now(),hash:a};s?this.applyBindings(e,i,t,n):i.forEach((t,s)=>{this.pendingBindings.push({element:e,property:s,expression:t,component:n})}),this.setupEventBindings(e,n),this.elementCache.set(e,o)}createRefBinding(e,t,n){try{const n=O.decodeEntities(t),s=O.isSingleExpression(n)||n,i=w.getContextComponent(e),r=this.componentManager.buildComponentContextWithProps(i,e);try{const t=this.expressionEvaluator.evaluateExpression(s,r,i);if("function"==typeof t){const n=t;this.refBindings.set(e,{element:e,callback:n,component:i}),n(e)}else if(t&&"object"==typeof t&&"current"in t){const n=t;this.refBindings.set(e,{element:e,refObject:n,component:i}),n.current=e}else console.warn(`⚠️ ${g.ATTR_PREFIXES.REF} expression did not return a ref object or callback: ${s}`,t)}catch(e){console.error(`❌ Failed to evaluate ref "${s}":`,e)}}catch(e){console.error(`❌ Failed to create ref binding for "${t}":`,e)}}isElementInLoopItem(e){let t=e;for(;t;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}extractDomMustacheBindings(e){var t;const n=new Map,s=e.attributes,i=this.elementCache.get(e),r=M.findScope(e),a=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),o=a&&(null==(t=this.componentManager)?void 0:t.hasStoredProps(e)),c=r&&a&&r!==a;for(let t=0;t<s.length;t++){const r=s[t];if(r.name!==g.ATTR_PREFIXES.COMPONENT&&"key"!==r.name&&!ie.isEventAttribute(r.name)&&(!i||!i.bindings.has(r.name))&&r.value){const t=g.MUSTACHE_PATTERN.test(r.value),s=O.decodeEntities(r.value),i=g.MUSTACHE_PATTERN.test(s);if(t||i){if(this.looksLikeSerializedObject(s))continue;const a=O.extractExpressions(s),l=w.getContextComponent(e);if(0===a.length&&(t||i)){console.error(`\n❌ Malformed mustache expression in attribute "${r.name}":`),console.error(` Value: ${s}`),console.error(" Element:",e),console.error(` Component: ${l}`),console.error(" 💡 The expression has mustache syntax {} but couldn't be parsed"),console.error(" 💡 Common causes: unmatched quotes, unclosed braces, invalid syntax\n"),o||c&&w.shouldBeDirectBinding(e,r.name)?n.set(r.name,s):c||n.set(r.name,s);continue}for(const t of a){const n=an.validate(t,l);n.valid||(console.error(`\n❌ Invalid expression in attribute "${r.name}":`),console.error(` Expression: ${t}`),console.error(` Original HTML: ${r.value}`),console.error(` Decoded: ${s}`),console.error(" Element:",e),console.error(` Component: ${l}`),n.errors.forEach(e=>{console.error(` ⚠️ ${e}`)}),console.error(" 💡 Hint: Check your quotes and syntax in conditional expressions"),console.error(" 💡 Example: class=\"{isActive ? 'text-blue-500' : 'text-gray-500'}\"\n")),n.warnings.length>0&&(console.warn(`\n⚠️ Expression warnings in attribute "${r.name}":`),console.warn(` Expression: ${t}`),console.warn(" Element:",e),n.warnings.forEach(e=>{console.warn(` • ${e}`)}))}o||c&&w.shouldBeDirectBinding(e,r.name)?n.set(r.name,s):c||n.set(r.name,s)}}}return n}applyBindings(e,t,n,s){t.forEach((t,n)=>{this.createMustacheBinding(e,n,t)}),this.setupEventBindings(e,s)}applyBindingsFromCache(e,t,n){t.bindings.forEach((n,s)=>{try{const i=this.componentManager.buildComponentContextWithProps(t.component,e),r=this.templateRenderer.render(n,i,t.component);this.updateElementProperty(e,s,r)}catch(e){console.error(`Cached binding evaluation error for "${n}":`,e)}})}createMustacheBinding(e,t,n){const s=`mustache_${Date.now()}_${Math.random()}`,i=M.findScope(e),r=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);let a,o=!1,c=!1;r?i?(a="app"===i?"app":i,c=!0):(a=r,o=!1):i?(a="app"===i?"app":i,c=!0,o=!1):(a=w.getContextComponent(e),o=!1,c=!1),e.removeAttribute(t);let l=null,h=e.parentElement;for(;h&&h!==document.body;){if(h.hasAttribute(g.ATTR_PREFIXES.COMPONENT)){l=h;break}h=h.parentElement}const p=this.templateRenderer.dependencies(n,a,this.stateManager),u=new Set(p),d=this.findComponentElementForMustacheBinding(e,a);if(d&&this.componentManager){const e=this.componentManager.elementProps.get(d);if(e)for(const t of p){const n=t.split("."),s=n[n.length-1];if(e.has(s)){const t=e.get(s);this.templateRenderer.dependencies(t.expression,t.component,this.stateManager).forEach(e=>u.add(e))}}}if(l&&l!==d&&this.componentManager&&this.componentManager.hasStoredProps(l)){const e=this.componentManager.elementProps.get(l);if(e)for(const t of p){const n=t.split("."),s=n[n.length-1];if(e.has(s)){const t=e.get(s);this.templateRenderer.dependencies(t.expression,t.component,this.stateManager).forEach(e=>u.add(e))}}}const m=()=>{if(document.contains(e))try{let s;if(c){if(s=this.componentManager.buildComponentContextWithProps(a,d||void 0),e!==d&&this.componentManager.elementProps.get(e)){const t=this.componentManager.evaluateProps(e);s={...s,...t}}}else if(o){let t=null,n=e.parentElement;for(;n&&n!==document.body;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===a){t=n;break}n=n.parentElement}if(s=this.componentManager.buildComponentContextWithProps(a,t||void 0),e!==t&&this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluatePropsWithContext(e,a,e);s={...s,...t}}}else{const t=this.findComponentElementForMustacheBinding(e,a);if(t){if(s=this.componentManager.buildRestrictedComponentContextWithProps(a,t),e!==t&&this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluatePropsWithContext(e,a,e);s={...s,...t}}}else{if(s=this.componentManager.buildRestrictedComponentContext(a,!1),t&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);Object.assign(s,e)}if(e!==t&&this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluatePropsWithContext(e,a,e);Object.assign(s,t)}}}if(l&&this.componentManager&&this.componentManager.hasStoredProps(l)){const e=this.componentManager.evaluateProps(l);s={...s,...e}}const i=this.templateRenderer.render(n,s,a);this.scheduleElementUpdate(e,t,i)}catch(e){console.error(`Mustache binding evaluation error for "${n}":`,e),console.error(`Context component: ${a}`),console.error(`Use strict scope: ${c}`)}else this.stateManager.removeSubscription(s)},f={id:s,selector:"",dependencies:u,callback:m,element:e,component:a};this.stateManager.addSubscription(f),m()}findComponentElementForMustacheBinding(e,t){if(e.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const s=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const e of s)if(this.componentManager&&this.componentManager.hasStoredProps(e))return e;return s[0]||null}setupEventBindings(e,t){if(w.shouldIgnoreMustache(e))return;const n=M.findScope(e),s=n?"app"===n?"app":n:t;for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t];if(ie.isEventAttribute(n.name)){const t=n.name.substring(2);this.eventDelegation.registerEventHandler(e,t,n.value,s),e.removeAttribute(n.name)}}}scheduleElementUpdate(e,t,n){this.isCriticalProperty(t)?this.updateElementProperty(e,t,n):(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 t=e[`__pending_${n}`];this.updateElementProperty(e,n,t),delete e[`__pending_${n}`]}}}finally{this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF=null,this.applyingUpdates=!1}}updateElementProperty(e,t,n){const s=je(n),i=this.lastValueCache.get(e);if(i&&this.isSameValue(i.get(t),s))return;const r=this.applyingUpdates;this.applyingUpdates=!0;try{switch(t){case"textContent":const n=this.cachedValueToString(s);e.textContent!==n&&(e.textContent=n);break;case"innerHTML":const i=this.cachedValueToString(s);e.innerHTML!==i&&(e.innerHTML=i);break;case"value":const r=this.cachedValueToString(s);e instanceof HTMLOptionElement?e.value!==r&&(e.value=r,e.setAttribute("value",r)):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.value!==r&&(e.value=r);break;case"selectedIndex":if(e instanceof HTMLSelectElement){const t=Number(s);e.selectedIndex!==t&&(e.selectedIndex=t)}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,s);break;case"indeterminate":if(e instanceof HTMLInputElement&&"checkbox"===e.type){const t=!!s;e.indeterminate!==t&&(e.indeterminate=t)}break;case"class":case"className":const a=this.cachedValueToString(s);e instanceof SVGElement?e.getAttribute("class")!==a&&e.setAttribute("class",a):e.className!==a&&(e.className=a);break;case"htmlFor":case"for":if(e instanceof HTMLLabelElement){const t=this.cachedValueToString(s);e.htmlFor!==t&&(e.htmlFor=t)}break;case"style":if(e instanceof HTMLElement)if("object"==typeof s&&s&&!Array.isArray(s))this.updateStyleObject(e,s);else{const t=this.cachedValueToString(s);e.style.cssText!==t&&(e.style.cssText=t)}break;case"tabIndex":if(e instanceof HTMLElement){const t=null==s?-1:Number(s);e.tabIndex!==t&&(e.tabIndex=t)}break;case"contentEditable":if(e instanceof HTMLElement){const t=!0===s?"true":!1===s?"false":String(s);e.contentEditable!==t&&(e.contentEditable=t)}break;case"draggable":if(e instanceof HTMLElement){const t=!0===s,n=t?"true":"false";e.draggable!==t&&(e.draggable=t,e.setAttribute("draggable",n))}break;case"spellcheck":if(e instanceof HTMLElement){const t=!!s,n=t?"true":"false";e.spellcheck!==t&&(e.spellcheck=t,e.setAttribute("spellcheck",n))}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,s);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,s);break;default:t.startsWith("aria-")?this.setAriaAttribute(e,t,s):t.startsWith("data-")?this.setDataAttribute(e,t,s):this.setGenericAttribute(e,t,s)}this.updateValueCache(e,t,s)}catch(n){console.error(`Failed to update property "${t}" on element:`,e,n)}finally{this.applyingUpdates=r}}looksLikeSerializedObject(e){const t=e.startsWith("{")&&e.endsWith("}"),n=e.startsWith("[")&&e.endsWith("]");if(!t&&!n)return!1;try{const t=JSON.parse(e);return"object"==typeof t&&null!==t&&(Array.isArray(t)||Object.keys(t).length>0)}catch{return!1}}cachedValueToString(e){if("string"==typeof e)return e;if("number"==typeof e)return String(e);if(null==e)return"";if("boolean"==typeof e)return e?"true":"false";if(this.stringValueCache.has(e))return this.stringValueCache.get(e);const t=Ee(e);return this.stringValueCache.set(e,t),t}isSameValue(e,t){if(e===t)return!0;if("object"==typeof e&&"object"==typeof t){if(null===e||null===t)return e===t;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>e===t[n]);if(this.isStyleObject(e)&&this.isStyleObject(t)){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every(n=>e[n]===t[n])}}return!1}isStyleObject(e){return e&&"object"==typeof e&&!Array.isArray(e)}setBooleanProperty(e,t,n){const s=!!n;this.setBooleanProp(e,t,n)||(s&&!e.hasAttribute(t)?e.setAttribute(t,""):!s&&e.hasAttribute(t)&&e.removeAttribute(t))}updateStyleObject(e,t){var n;const s=null==(n=this.lastValueCache.get(e))?void 0:n.get("style"),i=s&&"object"==typeof s?s:{};for(const[n,s]of Object.entries(t))i[n]!==s&&(e.style[n]=s)}setStringAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n?e.removeAttribute(t):e.setAttribute(t,s))}setNumericAttribute(e,t,n){const s=String(n);e.getAttribute(t)!==s&&(null==n?e.removeAttribute(t):e.setAttribute(t,s))}setAriaAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,s))}setDataAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n?e.removeAttribute(t):e.setAttribute(t,s))}setGenericAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,s))}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 s=this.BOOL_REFLECTED[t];if(!s)return!1;const i=!!n;return e instanceof HTMLElement&&s in e?(e[s]!==i&&(e[s]=i),!0):(i?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[e,n]of t){const t=[...this.componentManager.componentStack];this.componentManager.componentStack="app"!==e?["app",e]:["app"];for(const t of n)try{if(!document.contains(t.element))continue;this.createMustacheBinding(t.element,t.property,t.expression)}catch(t){console.error(`❌ Failed to create binding for ${e}:`,t)}this.componentManager.componentStack=t}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 e=[...this.componentManager.componentStack];this.componentManager.componentStack="app"!==t?["app",t]:["app"];for(const{textNode:e,component:t}of n)if(document.contains(e))try{this.textNodeManager.processTextNode(e,t)}catch(e){console.error(`❌ Failed to process text node for ${t}:`,e)}this.componentManager.componentStack=e}}processMutationsBatch(e){const t=new Set,n=new Set,s=new Set,i=new Set,r=new Set;for(const s of e)if("childList"===s.type&&(s.addedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE)t.add(e);else if(e.nodeType===Node.TEXT_NODE){const t=e;t.textContent&&g.MUSTACHE_PATTERN.test(t.textContent)&&r.add(t)}}),s.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE)n.add(e);else if(e.nodeType===Node.TEXT_NODE){const t=e;t.textContent&&g.MUSTACHE_PATTERN.test(t.textContent)&&(document.contains(t)||this.textNodeManager.cleanupTextNode(t))}})),"attributes"===s.type&&s.target&&i.add(s.target),"characterData"===s.type&&s.target){const e=s.target;e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent)&&r.add(e)}for(const e of n)(t.has(e)||document.contains(e))&&(s.add(e),n.delete(e),t.has(e)&&t.delete(e));n.size>0&&this.cleanupElementsBatch(Array.from(n)),t.size>0&&this.processElementsBatch(Array.from(t)),r.size>0&&this.processTextNodesBatch(Array.from(r)),i.size>0&&this.rebindChangedElements(Array.from(i))}processTextNodesBatch(e){const t=new Map;for(const n of e){const e=w.getComponentForNode(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}for(const[e,n]of t)n.forEach(t=>{this.textNodeManager.processTextNode(t,e)})}rebindChangedElements(e){e.forEach(e=>{this.processElementBindings(e,!0)})}processElementBindings(e,t=!0){const n=this.extractDomMustacheBindings(e),s=w.getElementComponent(e);n.forEach((n,i)=>{t?this.createMustacheBinding(e,i,n):this.pendingBindings.push({element:e,property:i,expression:n,component:s})}),t&&this.setupEventBindings(e,s)}cleanupElementsBatch(e){e.forEach(e=>this.cleanupElement(e))}cleanupElement(e){var t;this.cleanupRefBinding(e),null==(t=this.stateManager.subscriptionManager)||t.cleanupElement(e);const n=this.listeners.get(e)||[];for(const{type:t,fn:s}of n)e.removeEventListener(t,s);this.listeners.delete(e),this.elementCache.delete(e),this.processedElements.delete(e),this.componentManager.cleanupProps(e);const s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let i;for(;i=s.nextNode();)this.textNodeManager.cleanupTextNode(i);"TEMPLATE"===e.tagName&&e.hasAttribute("pp-for")&&this.loopManager.cleanupTemplate(e),e.querySelectorAll("template[pp-for]").forEach(e=>{this.loopManager.cleanupTemplate(e)});const r=e.__directEventListeners;r&&(r.forEach(({eventType:t,listener:n})=>{e.removeEventListener(t,n)}),delete e.__directEventListeners);const a=e.__spreadEventHandlers;a&&(a.forEach(e=>{window.__spreadHandlers&&window.__spreadHandlers.delete(e)}),delete e.__spreadEventHandlers);const o=e.__spreadSubscriptions;o&&(o.forEach(e=>{this.stateManager.removeSubscription(e)}),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(e){console.error("Failed to cleanup ref:",e)}this.refBindings.delete(e)}}getElementHash(e){const t=[];for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n];(s.name===g.ATTR_PREFIXES.COMPONENT||ie.isEventAttribute(s.name)||s.value&&g.MUSTACHE_PATTERN.test(s.value))&&t.push(`${s.name}=${s.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(`[${g.ATTR_PREFIXES.REF}]`).forEach(e=>{this.cleanupRefBinding(e)}),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()}}const fe=class e{constructor(){d(this,"walkerPool",[]),d(this,"traversalCache",new WeakMap),d(this,"lastCacheTime",new WeakMap),d(this,"CACHE_TTL",250),d(this,"trackedElements",new Set)}static getInstance(){return e.instance||(e.instance=new e),e.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 s=Date.now(),i=this.traversalCache.get(e),r=this.lastCacheTime.get(e);if(i&&r&&s-r<this.CACHE_TTL){const e=i.get(t);if(e)return e}const a=n();return this.traversalCache.has(e)||(this.traversalCache.set(e,new Map),this.trackedElements.add(e)),this.traversalCache.get(e).set(t,a),this.lastCacheTime.set(e,s),a}traverseElementsAndText(e,t,n){const s=this.acquireWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),i=[],r=[];let a;for(;a=s.nextNode();)if(a.nodeType===Node.ELEMENT_NODE){const e=a;(!t||t(e))&&i.push(e)}else if(a.nodeType===Node.TEXT_NODE){const e=a;(!n||n(e))&&r.push(e)}return this.releaseWalker(s),{elements:i,textNodes:r}}cleanupCache(){const e=[];for(const t of this.trackedElements)document.contains(t)||e.push(t);e.forEach(e=>{this.traversalCache.delete(e),this.lastCacheTime.delete(e),this.trackedElements.delete(e)})}};d(fe,"instance");let it=fe;const de=class e{static getDOMCache(){return this.domCache||(this.domCache=He.getInstance()),this.domCache}static shouldIgnoreMustache(e){const t=e instanceof Text?e.parentElement:e;if(!t)return!1;if(t.hasAttribute(g.ATTR_PREFIXES.IGNORE))return!0;let n=t.parentElement;for(;n&&n!==document.body;){if(n.hasAttribute(g.ATTR_PREFIXES.IGNORE))return!0;n=n.parentElement}return!1}static isFrameworkAttribute(t){return e.FRAMEWORK_ATTRIBUTES.has(t)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static shouldBeDirectBinding(t,n){const s=M.findScope(t),i=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);return!(!s||!i||s===i)&&e.isDOMProperty(t,n)}static isDOMProperty(t,n){const s=t.tagName.toLowerCase(),i=document.createElement(s);return e.attributeToPropertyName(n)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,(e,t)=>t.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 e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}static isTextNodeInsideScript(e){let t=e.parentElement;for(;t&&t!==document.body;){const e=t.tagName.toLowerCase();if("script"===e||"style"===e)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)}};d(de,"FRAMEWORK_ATTRIBUTES",new Set(["pp-component","pp-for","pp-spread","pp-ref","key"])),d(de,"domCache");let w=de;class en{constructor(e,t){d(this,"eventDelegation"),d(this,"loopBindings",new Map),d(this,"stateManager"),d(this,"expressionEvaluator"),d(this,"componentManager"),d(this,"domBindingManager"),d(this,"cleanupObserver"),d(this,"loopCounter",0),d(this,"pendingTemplates",[]),d(this,"loopItemElements",new WeakSet),d(this,"loopItemContexts",new WeakMap),d(this,"templateRenderer"),d(this,"templateMoveObserver"),d(this,"processingPromises",new Set),d(this,"allLoopsProcessedResolve"),d(this,"isHydrating",!1),d(this,"deferredUpdates",new Map),d(this,"processingTemplates",new WeakSet),d(this,"astProcessor",ye.getInstance()),this.stateManager=e,this.expressionEvaluator=t,this.cleanupObserver=new MutationObserver(e=>{this.cleanupDetachedTemplates(e)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateMoveObserver=new MutationObserver(e=>{this.handleTemplateMoves(e)}),this.templateMoveObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateRenderer=new ve(t)}setHydrating(e){if(this.isHydrating=e,!e&&this.deferredUpdates.size>0){for(const[e,t]of this.deferredUpdates){const n=this.loopBindings.get(e);n&&this.renderLoop(n,t)}this.deferredUpdates.clear()}}async waitForAllLoopsProcessed(){if(0===this.processingPromises.size)return console.log("[LoopManager] No loops to wait for"),Promise.resolve();console.log(`[LoopManager] Waiting for ${this.processingPromises.size} loops to process`),await Promise.all(Array.from(this.processingPromises)),console.log("[LoopManager] All loops processed"),this.allLoopsProcessedResolve&&this.allLoopsProcessedResolve()}handleTemplateMoves(e){const t=new Set;for(const n of e)"childList"===n.type&&n.addedNodes.forEach(e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const n=e;if(n.querySelectorAll("template[pp-for]").forEach(e=>{const n=e;this.loopBindings.has(n)&&t.add(n)}),"TEMPLATE"===n.tagName&&n.hasAttribute("pp-for")){const e=n;this.loopBindings.has(e)&&t.add(e)}});t.size>0&&setTimeout(()=>{t.forEach(e=>{document.contains(e)&&this.updateMovedTemplate(e)})},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 s=[...t.renderedItems];t.placeholder.parentElement&&t.placeholder.parentElement!==n&&t.placeholder.parentElement.removeChild(t.placeholder);const i=document.createComment(`pp-for: ${t.expression}`);n.insertBefore(i,e),t.parentElement=n,t.placeholder=i,s.length>0&&(s.forEach(t=>{t.element.parentElement!==n&&n.insertBefore(t.element,e)}),this.updateDOMOrder(t,s)),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)){const e=t.getLoopItemContext(n);if(e)return e}n=n.parentElement}const s=t.getAllLoops();for(const[t,n]of s)for(const t of n.renderedItems)if(t.element.contains(e))return t.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)||this.processingTemplates.has(e))return;if(this.processingTemplates.add(e),!e.parentElement)return console.warn("⚠️ Template has no parent, queueing for later:",n),this.queueTemplate(e,t),void this.processingTemplates.delete(e);const s=this.parseLoopExpression(n);if(!s)return void console.error(`Invalid pp-for syntax: "${n}"`);const i=e.parentElement,r=document.createComment(`pp-for: ${n}`);i.insertBefore(r,e);const a=new Promise(a=>{requestAnimationFrame(()=>{try{const o=M.findScope(e);let c=t;if(o)if(o.includes(":children")){const e=o.replace(/:children$/,"");c="app"===e?"app":e}else c="app"===o?"app":o;const l={template:e,expression:n,itemVar:s.itemVar,indexVar:s.indexVar,component:c,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:i,placeholder:r,iterableExpr:s.iterableExpr};this.loopBindings.set(e,l),this.setupLoopReactivity(l,s.iterableExpr),this.renderLoop(l,s.iterableExpr),this.processingTemplates.delete(e),a()}catch(e){console.error("Loop processing error:",e),a()}})});this.processingPromises.add(a),a.finally(()=>{this.processingPromises.delete(a),0===this.processingPromises.size&&this.allLoopsProcessedResolve&&this.allLoopsProcessedResolve()})}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}`,s=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager),i=this.findComponentElementForLoop(e);if(i&&this.componentManager){const t=this.componentManager.getComponentPropDependencies(i,e.component);s.push(...t)}const r={id:n,selector:"",dependencies:new Set(s),callback:()=>{this.renderLoop(e,e.iterableExpr)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(r),e.subscriptionIds.push(n)}renderLoop(e,t){if(this.isHydrating&&e.renderedItems.length>0)this.deferredUpdates.set(e.template,t);else if(this.componentManager&&this.domBindingManager)try{const n=e.template,s=M.findScope(n);let i,r;if((null==s?void 0:s.includes(":children"))||!1){const e=s.replace(/:children$/,"");if(r=this.findComponentElementForScope(e),i=this.componentManager.buildComponentContext(e),r&&this.componentManager.hasStoredProps(r)){const e=this.componentManager.evaluateProps(r);i={...i,...e}}}else{r=this.findComponentElementForLoop(e);const t=this.findParentLoopContext(e.template);if(null!==s){const n=this.componentManager.buildComponentContext(e.component);if(r){const e=this.componentManager.evaluateProps(r);i={...n,...e}}else i=n;t&&(i={...i,...t})}else{if(i=this.componentManager.buildRestrictedComponentContext(e.component,!1),r&&this.componentManager.hasStoredProps(r)){const e=this.componentManager.evaluateProps(r);Object.assign(i,e)}t&&(i={...i,...t})}}const a=je(this.expressionEvaluator.evaluateExpression(t,i,e.component));if(!Array.isArray(a))return console.warn(`Loop expression "${t}" did not return an array:`,a,`Available context keys: [${Object.keys(i).join(", ")}]`,"Parent loop context:"),void this.clearRenderedItems(e);e.evaluatedIterable=a,e.iterableName=this.astProcessor.extractIterableName(t),this.updateRenderedItems(e,a)}catch(n){console.error(`❌ Error evaluating loop expression "${t}":`,n),this.clearRenderedItems(e)}}refreshLoopItemContent(e){if(e.textNodeTemplates)for(const[t,n]of e.textNodeTemplates)document.contains(t)&&this.updateTextNodeWithContext(t,n,e.context,this.getTextNodeComponent(t));if(e.attributeTemplates)for(const[t,n]of e.attributeTemplates)document.contains(t)&&n.forEach((n,s)=>{var i;try{const r=w.getElementComponent(t),a=this.templateRenderer.render(n,e.context,r);null==(i=this.domBindingManager)||i.updateElementProperty(t,s,a)}catch(e){console.error(`Error refreshing attribute "${s}":`,e)}})}findComponentElementForScope(e){const t=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const e of t)if(this.componentManager.hasStoredProps(e))return e;return t[0]||void 0}findParentLoopContext(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const e=this.loopItemContexts.get(n);e&&t.unshift(e)}for(const[s,i]of this.loopBindings)if(i.template!==e)for(const s of i.renderedItems)if(s.element===n||s.element.contains(e)){t.unshift(s.context);break}n=n.parentElement}return t.length>0?t.reduce((e,t)=>({...e,...t}),{}):null}findComponentElementForLoop(e){var t;let n=e.parentElement;for(;n;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===e.component)return n;n=n.parentElement}if("app"===e.component)for(n=e.parentElement;n&&n!==document.body;){if(n.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&null!=(t=this.componentManager)&&t.hasStoredProps(n))return n;n=n.parentElement}return document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${e.component}"]`)[0]||void 0}updateRenderedItems(e,t){const n=e.renderedItems,s=[],i=new Set,r=new Map,a=[];n.forEach(e=>{r.set(e.key,e),a.push(e)}),t.forEach((t,n)=>{const o=this.generateItemKey(e,t,n),c=r.get(o);if(c&&!i.has(c.element))i.add(c.element),this.updateItemContext(e,c,t,n),this.refreshLoopItemContent(c),s.push(c);else{const r=a.find(e=>!i.has(e.element));if(r)i.add(r.element),this.cleanupNestedLoops(r.element),r.key=o,this.updateItemContext(e,r,t,n),this.refreshLoopItemContent(r),r.element.querySelectorAll("template[pp-for]").forEach(t=>{const n=t;this.cleanupTemplate(n),this.processNestedTemplate(n,e.component,r.context)}),s.push(r);else{const i=this.createLoopItem(e,t,n,o);i&&(s.push(i),this.processNestedLoopsInItem(i,e.component))}}}),n.forEach(e=>{i.has(e.element)||(this.cleanupNestedLoops(e.element),this.cleanupLoopItem(e))}),this.updateDOMOrder(e,s),e.renderedItems=s}cleanupNestedLoops(e){e.querySelectorAll("template[pp-for]").forEach(e=>{const t=e,n=this.loopBindings.get(t);n&&(this.clearRenderedItems(n),n.subscriptionIds.forEach(e=>{this.stateManager.removeSubscription(e)}),this.loopBindings.delete(t))})}processNestedLoopsInItem(e,t){e.element.querySelectorAll("template[pp-for]").forEach(n=>{const s=n;this.loopBindings.has(s)||this.processNestedTemplate(s,t,e.context)})}generateItemKey(e,t,n){const s=e.template.content.firstElementChild;if(s&&s.hasAttribute("key")){const i=s.getAttribute("key");try{const s=this.createItemContextWithParentContext(e,t,n),r=O.isSingleExpression(i);if(r){const t=this.expressionEvaluator.evaluateExpression(r,s,e.component);return String(t)}{const t=O.parse(i);let n="";for(const i of t)if("static"===i.type)n+=i.content;else if(i.expression){n+=Ee(this.expressionEvaluator.evaluateExpression(i.expression,s,e.component))}return n}}catch(s){console.warn(`Error evaluating key expression "${i}":`,s,"Available context keys:",Object.keys(this.createItemContextWithParentContext(e,t,n)))}}return t&&"object"==typeof t&&"id"in t?String(t.id):`${e.expression}_${n}`}createItemContextWithParentContext(e,t,n){if(!this.componentManager)return{};const s=e.template,i=M.findScope(s);let r;if((null==i?void 0:i.includes(":children"))||!1){const e=i.replace(/:children$/,"");r=this.componentManager.buildComponentContext(e);const t=this.findComponentElementForScope(e);if(t&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);r={...r,...e}}}else{const t=null!==i,n=this.findComponentElementForLoop(e),s=n&&this.componentManager.hasStoredProps(n);if(t&&"app"===i&&s&&n){r={},r.getContext=()=>this.componentManager.buildComponentContext("app"),r.withContext=e=>{const t=this.componentManager.buildComponentContext("app");return e.call(t,t)},r.__getProp=e=>{if(n)return this.componentManager.evaluateProps(n)[e]};const e=this.componentManager.evaluateProps(n);r={...r,...e}}else r=this.componentManager.buildComponentContext(e.component)}const a=this.getAllParentLoopContexts(e.template),o=t&&"object"==typeof t?Object.keys(t):[],c={};for(const[e,t]of Object.entries(r))o.includes(e)&&!e.startsWith("set")&&!e.endsWith("Getter")||(c[e]=t);const l={...c,...a,[e.itemVar]:t};return e.indexVar&&(l[e.indexVar]=n),e.evaluatedIterable&&e.iterableName&&(l[e.iterableName]=e.evaluatedIterable),l}getAllParentLoopContexts(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const e=this.loopItemContexts.get(n);e&&t.unshift(e)}for(const[s,i]of this.loopBindings)for(const s of i.renderedItems)if(s.element.contains(e)||s.element===n){t.unshift(s.context);break}n=n.parentElement}const s={};for(const e of t)for(const[t,n]of Object.entries(e))if(!(t in s)){if("function"==typeof n&&!("__pphp_key"in n)){["getContext","withContext","__getProp"].includes(t)&&(s[t]=n);continue}s[t]=n}return s}createItemContext(e,t,n){if(!this.componentManager)return{};const s=e.template,i=M.findScope(s),r=null!==i,a=this.findComponentElementForLoop(e),o=a&&this.componentManager.hasStoredProps(a);let c,l=!1,h=s.parentElement;for(;h&&h!==document.body;){if(this.loopItemElements.has(h)){const e=this.loopItemContexts.get(h);if(e&&!Object.keys(e).some(t=>{const n=e[t];return"function"==typeof n&&!("__pphp_key"in n)&&!["getContext","withContext","__getProp"].includes(t)})){l=!0;break}}h=h.parentElement}if(r&&"app"===i&&o&&a||l&&o&&a){c={},c.getContext=()=>this.componentManager.buildComponentContext("app"),c.withContext=e=>{const t=this.componentManager.buildComponentContext("app");return e.call(t,t)},c.__getProp=e=>{if(a)return this.componentManager.evaluateProps(a)[e]};const e=this.componentManager.evaluateProps(a);c={...c,...e}}else c=r||o?this.componentManager.buildComponentContext(e.component):this.componentManager.buildRestrictedComponentContext(e.component,!1);const p={},u=t&&"object"==typeof t?Object.keys(t):[];for(const[e,t]of Object.entries(c))"function"!=typeof t||t.__pphp_key?e.startsWith("set")||e.endsWith("Getter")||["getContext","withContext","__getProp"].includes(e)?p[e]=t:u.includes(e)||(p[e]=t):p[e]=t;const d=this.findAllParentLoopContexts(e.template),m={...p,...d,[e.itemVar]:t};return e.indexVar&&(m[e.indexVar]=n),e.evaluatedIterable&&e.iterableName&&(m[e.iterableName]=e.evaluatedIterable),m}findAllParentLoopContexts(e){const t={};let n=e.parentElement,s=0;for(;n&&n!==document.body&&s<10;){if(s++,this.loopItemElements.has(n)){const e=this.loopItemContexts.get(n);if(e)for(const[n,s]of Object.entries(e))if(!(n in t)){const e="function"==typeof s,i=e&&"__pphp_key"in s,r=["getContext","withContext","__getProp"].includes(n);if(e&&!i){r&&(t[n]=s);continue}t[n]=s}}for(const[s,i]of this.loopBindings)if(s!==e)for(const e of i.renderedItems)if(e.element===n){for(const[n,s]of Object.entries(e.context))if(!(n in t)){const e="function"==typeof s,i=e&&"__pphp_key"in s,r=["getContext","withContext","__getProp"].includes(n);if(e&&!i){r&&(t[n]=s);continue}t[n]=s}break}n=n.parentElement}return t}createLoopItem(e,t,n,s){if(!this.domBindingManager)return null;try{const i=this.createItemContextWithParentContext(e,t,n);this.preCloneSanitizeTemplate(e.template);const r=document.importNode(e.template.content,!0),a=document.createElement("div");a.appendChild(r);const o=a.firstElementChild;if(!o)return console.error("❌ [LoopItem] No element found in template"),null;a.removeChild(o),this.loopItemElements.add(o),this.loopItemContexts.set(o,i),o.getAttribute("key")&&o.removeAttribute("key");const c={key:s,element:o,context:i,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map,parentTemplate:e.template};return this.executeComponentScriptsInLoopItem(o),this.processRefsInLoopItem(o,i,e.component,c),this.processElementWithContext(o,i,e.component,c),this.cleanupRawMustacheAttributes(o),c}catch(e){return console.error("❌ [LoopItem] Error creating loop item:",e),console.error(" Stack:",e.stack),null}}preCloneSanitizeTemplate(e){const t=e.content.querySelectorAll("input");for(const e of Array.from(t)){const t=(e.getAttribute("type")||"text").toLowerCase();if(!["number","date","time","datetime-local","month","week","email","url","tel","range"].includes(t))continue;const n=["value","min","max","step","pattern"];for(const t of n){const n=e.getAttribute(t);if(n&&g.MUSTACHE_PATTERN.test(n)){const s=`data-pp-${t}`;e.setAttribute(s,n),e.removeAttribute(t)}}"number"===t&&!e.hasAttribute("value")&&e.setAttribute("value","0")}}processRefsInLoopItem(e,t,n,s){if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const i=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);s&&(s.refTemplates||(s.refTemplates=new Map),s.refTemplates.set(e,i)),this.processRefAttribute(e,i,t,n),ve.containsMustacheExpression(i)||e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r;const a=[];for(;r=i.nextNode();)a.push(r);a.forEach(e=>{const i=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);s&&(s.refTemplates||(s.refTemplates=new Map),s.refTemplates.set(e,i)),this.processRefAttribute(e,i,t,n),ve.containsMustacheExpression(i)||e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)})}processRefAttribute(e,t,n,s){try{const i=O.decodeEntities(t),r=O.isSingleExpression(i)||i,a=this.expressionEvaluator.evaluateExpression(r,n,s);"function"==typeof a?a(e):a&&"object"==typeof a&&"current"in a?a.current=e:console.warn("⚠️ Invalid ref result:",a),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}catch(e){console.error("❌ Failed to process ref:",e)}}executeComponentScriptsInLoopItem(e){if(!this.componentManager)return;const t=[e],n=e.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}]`);t.push(...Array.from(n)),t.forEach(e=>{if(e.hasAttribute(g.ATTR_PREFIXES.COMPONENT)){const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t){const n=this.getLoopItemContextForElement(e),s=`${t}_${this.generateInstanceId(n)}`;e.setAttribute(g.ATTR_PREFIXES.COMPONENT,s),e.__originalComponentName=t,e.__uniqueComponentName=s,this.componentManager.pushComponent(s),window[s]||(window[s]={}),window[t]&&Object.assign(window[s],window[t]),this.getComponentScripts(e).forEach(e=>{this.componentManager.executeScript(e)}),this.componentManager.popComponent()}}})}getLoopItemContextForElement(e){let t=e;for(;t;){if(this.loopItemElements.has(t)){const e=this.loopItemContexts.get(t);if(e)return e}t=t.parentElement}for(const[t,n]of this.loopBindings)for(const t of n.renderedItems)if(t.element===e||t.element.contains(e))return t.context;return console.warn("⚠️ No loop item context found, using empty context"),{}}generateInstanceId(e){const t={};for(const[n,s]of Object.entries(e))"function"==typeof s||n.startsWith("set")||n.endsWith("Getter")||"getContext"===n||"withContext"===n||"__getProp"===n||s&&"function"==typeof s&&"__pphp_key"in s||"boolean"==typeof s||"number"==typeof s||"string"==typeof s||s&&"object"==typeof s&&!Array.isArray(s)&&"id"in s&&(t[n]=s);return 0===Object.keys(t).length?`${Date.now()}_${Math.random().toString(36).substring(2,7)}`:Object.keys(t).sort().map(e=>{const n=t[e];return n&&"object"==typeof n&&"id"in n?`${e}_${n.id}`:`${e}_${JSON.stringify(n)}`}).join("_").replace(/[^a-zA-Z0-9_]/g,"").substring(0,20)||`fallback_${Date.now()}`}getComponentScripts(e){const t=[];return e.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`).forEach(n=>{const s=n;let i=s.parentElement,r=!1;for(;i&&i!==e.parentElement;){if(i===e){r=!0;break}if(i.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&i!==e)break;i=i.parentElement}r&&t.push(s)}),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&&g.MUSTACHE_PATTERN.test(n.value)&&(w.isBooleanAttribute(n.name),e.removeAttribute(n.name))}processElementWithContext(e,t,n,s){if(!this.domBindingManager||!this.componentManager)return;const i=(e,n)=>{const s=this.componentManager.buildComponentContext(n),i=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(i&&i!==n){const e=this.componentManager.buildComponentContext(i);return{...t,...s,...e}}return{...t,...s}},r=this.componentManager.buildComponentContextWithProps.bind(this.componentManager);this.componentManager.buildComponentContextWithProps=(t,n)=>n&&(n===e||e.contains(n))?i(n,t):r(t,n);try{if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const s=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);this.processRefInLoopContext(e,s,t,n),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>t===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}),r=[];let a;for(;a=i.nextNode();){const e=a;if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const t=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);r.push({element:e,expression:t})}}r.forEach(({element:e,expression:s})=>{this.processRefInLoopContext(e,s,t,n)});const o=this.bindLoopItemElement(e,t,n,s);this.setupEventBindingsForLoopItem(e,n);for(let t=0;t<e.childNodes.length;t++){const i=e.childNodes[t];if(i.nodeType===Node.TEXT_NODE){const e=i;if(e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent)&&!w.isTextNodeInsideScript(e)){const t=this.getComponentForTextNode(e);this.processTextNodeWithLoopContext(e,o,t,s)}}else if(i.nodeType===Node.ELEMENT_NODE){const e=i;if("script"===e.tagName.toLowerCase())continue;const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT)||n,r=this.bindLoopItemElement(e,o,t,s);this.setupEventBindingsForLoopItem(e,t),this.processChildrenRecursively(e,r,t,s)}}e.querySelectorAll("template[pp-for]").forEach(t=>{(t.parentElement===e||e.contains(t))&&this.processNestedTemplate(t,n,o)})}finally{this.componentManager.buildComponentContextWithProps=r}}processChildrenRecursively(e,t,n,s){const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:t=>{if(t===e)return NodeFilter.FILTER_SKIP;if(t.nodeType===Node.TEXT_NODE){const e=t;if(w.isTextNodeInsideScript(e))return NodeFilter.FILTER_REJECT;if(e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent))return NodeFilter.FILTER_ACCEPT}else if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("script"===e.tagName.toLowerCase())return NodeFilter.FILTER_REJECT;const i=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);return i&&i!==n&&!s?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let r;for(;r=i.nextNode();)if(r.nodeType===Node.TEXT_NODE){const e=r,n=this.getComponentForTextNode(e);this.processTextNodeWithLoopContext(e,t,n,s)}else if(r.nodeType===Node.ELEMENT_NODE){const e=r,n=w.getElementComponent(e),i=this.bindLoopItemElement(e,t,n,s);this.setupEventBindingsForLoopItem(e,n),this.processChildrenRecursively(e,i,n,s)}}processChildElementsWithContext(e,t,n,s){const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:t=>{if(t===e)return NodeFilter.FILTER_SKIP;if(t.nodeType===Node.TEXT_NODE){const e=t;if(w.isTextNodeInsideScript(e))return NodeFilter.FILTER_REJECT;if(e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent))return NodeFilter.FILTER_ACCEPT}else if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("script"===e.tagName.toLowerCase())return NodeFilter.FILTER_REJECT;const s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);return s&&s!==n?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let r;const a=[],o=[];for(;r=i.nextNode();)r.nodeType===Node.ELEMENT_NODE?a.push(r):r.nodeType===Node.TEXT_NODE&&o.push(r);o.forEach(e=>{const n=this.getComponentForTextNode(e);this.processTextNodeWithLoopContext(e,t,n,s)}),a.forEach(e=>{const n=w.getElementComponent(e),i=this.bindLoopItemElement(e,t,n,s);this.setupEventBindingsForLoopItem(e,n),this.processChildElementsWithContext(e,i,n,s)})}processRefInLoopContext(e,t,n,s){try{const i=O.decodeEntities(t),r=O.isSingleExpression(i)||i,a=this.expressionEvaluator.evaluateExpression(r,n,s);"function"==typeof a?a(e):a&&"object"==typeof a&&"current"in a?a.current=e:console.warn("⚠️ Invalid ref result:",a),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}catch(e){console.error("❌ processRefInLoopContext error:",e)}}getComponentForTextNode(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}processNestedTemplate(e,t,n){const s=e.getAttribute("pp-for");if(!s||this.loopBindings.has(e))return;const i=this.parseLoopExpression(s);if(!i)return void console.error(`Invalid pp-for syntax: "${s}"`);const r=e.parentElement,a=document.createComment(`pp-for: ${s}`);r.insertBefore(a,e);const o=this.findComponentElementForTemplate(e);let c={...n};const l=this.findParentLoopContextForNestedTemplate(e);if(l&&(c={...c,...l}),o&&this.componentManager){const e=o.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e){const t=w.getParentComponentForElement(o);this.componentManager.hasStoredProps(o)||this.componentManager.setupProps(o,t);const n=this.evaluateComponentPropsWithContext(o,c);c={...this.componentManager.buildComponentContext(e),...n,...c}}}const h={template:e,expression:s,itemVar:i.itemVar,indexVar:i.indexVar,iterableExpr:i.iterableExpr,component:t,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:r,placeholder:a};this.loopBindings.set(e,h),this.setupNestedLoopReactivity(h,i.iterableExpr,c),this.renderNestedLoop(h,i.iterableExpr,c)}findParentLoopContextForNestedTemplate(e){let t=e.parentElement;const n={};let s=0;for(;t&&t!==document.body&&s<10;){if(s++,this.loopItemElements.has(t)){const e=this.loopItemContexts.get(t);if(e)for(const[t,s]of Object.entries(e))t in n||(n[t]=s)}for(const[s,i]of this.loopBindings)for(const s of i.renderedItems)(s.element.contains(e)||s.element===t)&&(i.itemVar in n||(n[i.itemVar]=s.context[i.itemVar]),i.indexVar&&!(i.indexVar in n)&&(n[i.indexVar]=s.context[i.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 s=this.componentManager.extractProps(e,"app");for(const[e,i]of s)try{const s=this.templateRenderer.render(i.expression,t,i.component);n[e]=s}catch(t){console.error(`Failed to evaluate prop "${e}":`,t),n[e]=void 0}return n}findComponentElementForTemplate(e){let t=e.parentElement;for(;t;){if(t.hasAttribute(g.ATTR_PREFIXES.COMPONENT))return t;t=t.parentElement}return null}setupNestedLoopReactivity(e,t,n){const s=`nested_loop_${Date.now()}_${++this.loopCounter}`;let i=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager);const r={id:s,selector:"",dependencies:new Set(i),callback:()=>{const s=e.template,i=this.findComponentElementForTemplate(s);let r=n;if(s.parentElement){const e=this.getParentLoopContextForElement(s);e&&(r={...r,...e})}if(i&&this.componentManager){const t=i.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t){const s=this.extractParentLoopContextFromBinding(e,n),a=this.evaluateComponentPropsWithContext(i,s),o=this.componentManager.buildComponentContext(t);r={...s,...o,...a}}}this.renderNestedLoop(e,t,r)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(r),e.subscriptionIds.push(s)}getParentLoopContextForElement(e){let t=e.parentElement;for(;t;){if(this.loopItemElements.has(t)){const e=this.loopItemContexts.get(t);if(e)return e}t=t.parentElement}return null}extractParentLoopContextFromBinding(e,t){const n=new Set;for(const[t,s]of this.loopBindings)if(s!==e)for(const t of s.renderedItems)if(t.element.contains(e.template)){n.add(s.itemVar),s.indexVar&&n.add(s.indexVar);break}const s={};for(const[e,i]of Object.entries(t))(n.has(e)||e.startsWith("users")||e.startsWith("set")||e.includes("Getter")||"function"==typeof i)&&(s[e]=i);return s}renderNestedLoop(e,t,n){if(this.componentManager&&this.domBindingManager)try{const s=e.template,i=null!==M.findScope(s),r=this.findComponentElementForLoop(e),a=r&&this.componentManager.hasStoredProps(r);let o;if(i||a)o=n;else{const t=this.componentManager.buildRestrictedComponentContext(e.component,!1),s=this.extractLoopVariablesOnly(n);o={...t,...s}}const c=je(this.expressionEvaluator.evaluateExpression(t,o,e.component));if(!Array.isArray(c))return console.warn(`Nested loop expression "${t}" did not return an array:`,c,`Available context keys: [${Object.keys(o).join(", ")}]`),void this.clearRenderedItems(e);this.updateNestedRenderedItems(e,c,o)}catch(s){console.error(`Error evaluating nested loop expression "${t}":`,s,`Available context keys: [${Object.keys(n).join(", ")}]`),this.clearRenderedItems(e)}}extractLoopVariablesOnly(e){const t={};for(const[n,s]of Object.entries(e))"function"==typeof s&&!("__pphp_key"in s)||n.startsWith("set")&&"function"==typeof s||n.endsWith("Getter")||["getContext","withContext","__getProp"].includes(n)||(t[n]=s);return t}updateNestedRenderedItems(e,t,n){const s=e.renderedItems,i=[],r=new Set,a=new Map;s.forEach(e=>{a.set(e.key,e)}),t.forEach((t,s)=>{const o=this.generateNestedItemKey(e,t,s,n),c=a.get(o);if(c&&!r.has(c.element))r.add(c.element),this.updateNestedItemContext(e,c,t,s,n),i.push(c);else{const r=this.createNestedLoopItem(e,t,s,o,n);r&&i.push(r)}}),s.forEach(e=>{r.has(e.element)||this.cleanupLoopItem(e)}),this.updateDOMOrder(e,i),e.renderedItems=i}generateNestedItemKey(e,t,n,s){return t&&"object"==typeof t&&"id"in t?String(t.id):`${e.expression}_${n}_${JSON.stringify(s[e.itemVar]||{})}`}createNestedLoopItem(e,t,n,s,i){if(!this.domBindingManager)return null;try{const r={...i,[e.itemVar]:t};e.indexVar&&(r[e.indexVar]=n);const 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 l={key:s,element:c,context:r,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.processElementWithContext(c,r,e.component,l),this.cleanupRawMustacheAttributes(c),l}catch(e){return console.error("Error creating nested loop item:",e),null}}updateNestedItemContext(e,t,n,s,i){const r={...i};r[e.itemVar]=n,e.indexVar&&(r[e.indexVar]=s);const a=this.gatherAllComponentContextsInLoopItem(t.element),o={...r,...a};if(t.context=o,this.loopItemContexts.set(t.element,o),t.textNodeTemplates)for(const[e,n]of t.textNodeTemplates)document.contains(e)&&this.updateTextNodeWithContext(e,n,o,this.getTextNodeComponent(e));if(t.attributeTemplates)for(const[e,n]of t.attributeTemplates)document.contains(e)&&n.forEach((t,n)=>{var s;try{const i=w.getElementComponent(e),r=this.buildElementSpecificContext(e,o),a=this.templateRenderer.render(t,r,i);null==(s=this.domBindingManager)||s.updateElementProperty(e,n,a)}catch(e){console.error(`Nested binding update error for "${t}":`,e)}})}bindLoopItemElement(e,t,n,s){const i=this.extractMustacheBindings(e),r=this.findOriginalComponentName(n),a=M.findScope(e);let o=r;o=a?"app"===a?"app":a:this.findLoopParentComponent(e,r);let c=this.componentManager.buildComponentContext(o);c={...c,...t};const l=!!e.getAttribute(g.ATTR_PREFIXES.COMPONENT),h=new Map,p=new Map;i.forEach((e,t)=>{if(l&&"class"!==t&&"style"!==t){const n=w.attributeToPropertyName(t);h.set(n,e)}else p.set(t,e)});const u={},d=this.sortPropsByDependency(h);for(const[e,t]of d)try{const n=this.templateRenderer.render(t,c,o);u[e]=n,c[e]=n}catch(t){console.error(`❌ Failed to evaluate prop "${e}":`,t),u[e]=void 0,c[e]=void 0}l&&Object.keys(u).length>0&&(window[n]||(window[n]={}),Object.assign(window[n],u));const m=c;if(s&&Object.keys(u).length>0&&Object.assign(s.context,u),s&&i.size>0){s.attributeTemplates||(s.attributeTemplates=new Map);const t=new Map;i.forEach((e,n)=>{if(l&&"class"!==n&&"style"!==n){const s=w.attributeToPropertyName(n);t.set(s,e)}else t.set(n,e)}),s.attributeTemplates.set(e,t)}return i.forEach((t,n)=>{const i=l&&"class"!==n&&"style"!==n?w.attributeToPropertyName(n):n;this.createLoopItemBinding(e,i,t,m,o,s)}),m}sortPropsByDependency(e){const t=Array.from(e.keys()),n=Array.from(e.entries()),s=[],i=[];for(const[e,r]of n)t.some(t=>t!==e&&r.includes(t))?i.push([e,r]):s.push([e,r]);return[...s,...i]}setupEventBindingsForLoopItem(e,t){if(!this.eventDelegation)return void console.warn("No event delegation manager available");const n=Array.from(e.attributes);for(const s of n)if(ie.isEventAttribute(s.name)){const n=s.name.substring(2);this.eventDelegation.registerEventHandler(e,n,s.value,t),e.removeAttribute(s.name)}}processTextNodeWithLoopContext(e,t,n,s){if(w.isTextNodeInsideScript(e))return;const i=e.textContent||"";if(!O.parse(i).some(e=>"expression"===e.type))return;s&&(s.textNodeTemplates||(s.textNodeTemplates=new Map),s.textNodeTemplates.set(e,i));const r=this.findActualComponentForTextNode(e);let a=t;r!==n&&s&&this.componentManager&&(a={...this.componentManager.buildComponentContext(r),...s.context}),this.updateTextNodeWithContext(e,i,a,r);const o=`loop_text_${Date.now()}_${Math.random()}`,c=this.templateRenderer.dependencies(i,r,this.stateManager),l=new Set(c),h={id:o,selector:"",dependencies:l,callback:()=>{if(!document.contains(e))return void this.stateManager.removeSubscription(o);let t={};if(this.componentManager&&(t=r!==n&&s?{...this.componentManager.buildComponentContext(r),...s.context}:this.componentManager.buildComponentContext(r)),s){const e={};let n=null;for(const[e,t]of this.loopBindings)if(t.renderedItems.includes(s)){n=t;break}if(n){e[n.itemVar]=s.context[n.itemVar],n.indexVar&&(e[n.indexVar]=s.context[n.indexVar]);const t=this.findParentLoopContext(n.template);t&&Object.assign(e,t)}t={...t,...e}}this.updateTextNodeWithContext(e,i,t,r)},component:r};this.stateManager.addSubscription(h),s&&s.subscriptionIds.push(o)}findActualComponentForTextNode(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e){return t.__uniqueComponentName||e}t=t.parentElement}return"app"}updateTextNodeWithContext(e,t,n,s){const i=O.parse(t),r={};for(const[e,t]of Object.entries(n))r[e]="function"==typeof t&&"__pphp_key"in t?t.value:t;let a="";for(const e of i)if("static"===e.type)a+=e.content;else if(e.expression)try{a+=Ee(this.expressionEvaluator.evaluateExpression(e.expression,r,s))}catch(t){console.warn(`Loop text evaluation error for "${e.expression}":`,t,"Available context keys:",Object.keys(r)),a+=""}e.textContent!==a&&(e.textContent=a)}extractMustacheBindings(e){const t=new Map,n=e.attributes;for(let e=0;e<n.length;e++){const s=n[e];if(s.name!==g.ATTR_PREFIXES.COMPONENT&&"key"!==s.name&&!s.name.startsWith("on")&&s.value){const e=g.MUSTACHE_PATTERN.test(s.value),n=O.decodeEntities(s.value),i=g.MUSTACHE_PATTERN.test(n);(e||i)&&t.set(s.name,n)}}return t}createLoopItemBinding(e,t,n,s,i,r){const a=`loop_item_${Date.now()}_${Math.random()}`,o=M.findScope(e);let c;c=o?"app"===o?"app":o:this.findLoopParentComponent(e,i);const l=this.templateRenderer.dependencies(n,c,this.stateManager);let h=null;const p=[];if(null!=r&&r.parentTemplate&&(h=this.findParentComponentWithPropsFromTemplate(r.parentTemplate),h&&this.componentManager)){const e=h.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e){const t=this.componentManager.getComponentPropDependencies(h,e);p.push(...t);const s=this.componentManager.elementProps.get(h);if(s){const e=Array.from(s.keys());for(const t of e)if(n.includes(t)){const e=s.get(t);if(e){const t=this.templateRenderer.dependencies(e.expression,e.component,this.stateManager);p.push(...t)}}}}}const u=new Set([...l,...p,"*"]);let d=!1,m=0;const f=()=>{var i;if(!d)if(document.contains(e)){m=0;try{const a=this.componentManager.buildComponentContext(c);let o;if(r){o={...a};let e=null;for(const[t,n]of this.loopBindings)if(n.renderedItems.includes(r)){e=n;break}e&&(o[e.itemVar]=r.context[e.itemVar],e.indexVar&&(o[e.indexVar]=r.context[e.indexVar]));for(const[e,t]of Object.entries(r.context))e in o||(o[e]=t);if(h&&this.componentManager){const e=this.componentManager.evaluateProps(h);Object.assign(o,e)}}else o=s;const l=this.templateRenderer.render(n,o,c);null==(i=this.domBindingManager)||i.updateElementProperty(e,t,l)}catch(e){console.error(`❌ Loop item binding evaluation error for "${n}":`,e),console.error("Available context keys:",Object.keys(s))}}else if(m++,m<5){const e=10*Math.pow(2,m-1);setTimeout(()=>{d||f()},e)}else d=!0,this.stateManager.removeSubscription(a)},E={id:a,selector:"",dependencies:u,callback:()=>{d||f()},element:e,component:c};if(this.stateManager.addSubscription(E),r){r.subscriptionIds.push(a);const e=this.cleanupLoopItem.bind(this);this.cleanupLoopItem=t=>{t===r&&(d=!0),e(t)}}(()=>{document.contains(e)?f():Promise.resolve().then(()=>{if(!d&&document.contains(e))f();else if(!d&&m<5){m++;const e=10*Math.pow(2,m-1);setTimeout(()=>{d||f()},e)}else!d&&m>=5&&(d=!0,this.stateManager.removeSubscription(a))})})()}findParentComponentWithPropsFromTemplate(e){var t;let n=e.parentElement;for(;n&&n!==document.body;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)&&null!=(t=this.componentManager)&&t.hasStoredProps(n))return n;n=n.parentElement}return null}findLoopParentComponent(e,t){for(const[t,n]of this.loopBindings)for(const t of n.renderedItems)if(t.element===e||t.element.contains(e))return n.component;return this.findOriginalComponentName(t)}findOriginalComponentName(e){return e.includes("_")&&/\d{13}/.test(e)?e.split("_")[0]:e}updateItemContext(e,t,n,s){const i=this.createItemContext(e,n,s),r=this.gatherAllComponentContextsInLoopItem(t.element),a={...this.componentManager.buildComponentContext(e.component),...r,...i};if(t.context=a,this.loopItemContexts.set(t.element,a),this.refreshNestedLoops(t.element,a),t.refTemplates)for(const[n,s]of t.refTemplates)if(document.contains(n))try{this.processRefAttribute(n,s,a,e.component)}catch(e){console.error(`Ref template update error for "${s}":`,e)}if(t.textNodeTemplates)for(const[e,n]of t.textNodeTemplates)document.contains(e)&&this.updateTextNodeWithContext(e,n,a,this.getTextNodeComponent(e));if(t.attributeTemplates)for(const[e,n]of t.attributeTemplates)document.contains(e)&&n.forEach((t,n)=>{var s;try{const i=w.getElementComponent(e),r=this.buildElementSpecificContext(e,a),o=this.templateRenderer.render(t,r,i);null==(s=this.domBindingManager)||s.updateElementProperty(e,n,o)}catch(e){console.error(`Attribute binding update error for "${t}":`,e)}})}refreshNestedLoops(e,t){e.querySelectorAll("template[pp-for]").forEach(e=>{const n=e,s=this.loopBindings.get(n);if(s)try{this.renderNestedLoop(s,s.iterableExpr,t)}catch(e){console.error(`Error refreshing nested loop "${s.expression}":`,e)}})}gatherAllComponentContextsInLoopItem(e){if(!this.componentManager)return{};const t={};if(e.hasAttribute(g.ATTR_PREFIXES.COMPONENT)){const n=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),s=this.componentManager.buildComponentContext(n);Object.assign(t,s)}return e.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}]`).forEach(e=>{var n;const s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),i=null==(n=this.componentManager)?void 0:n.buildComponentContext(s);Object.assign(t,i)}),t}buildElementSpecificContext(e,t){if(!this.componentManager)return t;const n=w.getElementComponent(e),s=this.componentManager.buildComponentContext(n);return{...t,...s}}getTextNodeComponent(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}updateDOMOrder(e,t){let n=e.placeholder;t.forEach(t=>{(t.element.parentElement!==e.parentElement||t.element!==n.nextSibling)&&e.parentElement.insertBefore(t.element,n.nextSibling),n=t.element})}clearRenderedItems(e){e.renderedItems.forEach(e=>{this.cleanupNestedLoops(e.element),this.cleanupLoopItem(e)}),e.renderedItems=[]}cleanupLoopItem(e){if(e.element instanceof HTMLElement){const t=e.element;if(t.style.transition||"none"!==getComputedStyle(t).transition)return t.style.opacity="0",void requestAnimationFrame(()=>{this.performCleanup(e)})}this.performCleanup(e)}performCleanup(e){this.loopItemElements.delete(e.element),this.loopItemContexts.delete(e.element),e.element.parentElement&&e.element.parentElement.removeChild(e.element),e.subscriptionIds.forEach(e=>{this.stateManager.removeSubscription(e)})}isLoopItem(e){return this.loopItemElements.has(e)}getLoopItemContext(e){return this.loopItemContexts.get(e)}cleanupDetachedTemplates(e){for(const t of e)"childList"===t.type&&t.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(document.contains(t))return;if("TEMPLATE"===t.tagName&&t.hasAttribute("pp-for")){const e=t;document.contains(e)||this.cleanupTemplate(e)}t.querySelectorAll("template[pp-for]").forEach(e=>{const t=e;document.contains(t)||this.cleanupTemplate(t)})}})}cleanupTemplate(e){const t=this.loopBindings.get(e);t&&(t.renderedItems.forEach(e=>{this.cleanupNestedLoops(e.element)}),this.clearRenderedItems(t),t.subscriptionIds.forEach(e=>{this.stateManager.removeSubscription(e)}),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 ve{constructor(e){this.evaluator=e}static containsMustacheExpression(e){if(g.MUSTACHE_PATTERN.test(e))return!0;const t=O.decodeEntities(e);return g.MUSTACHE_PATTERN.test(t)}render(e,t,n){const s=O.isSingleExpression(e);if(s)return this.evaluator.evaluateExpression(s,t,n);let i="";for(const s of O.parse(e))if("static"===s.type)i+=s.content;else if(s.expression)try{i+=Ee(this.evaluator.evaluateExpression(s.expression,t,n))}catch{}return i}dependencies(e,t,n){const s=O.extractExpressions(e),i=new Set;for(const e of s)for(const s of this.evaluator.extractDependencies(e,t,n))i.add(s);return[...i]}}class tn{constructor(e){d(this,"componentStack",["app"]),d(this,"elementProps",new WeakMap),d(this,"contextCache",new K(100)),d(this,"contextIndex",new Map),d(this,"contextInvalidated",new Set),d(this,"stateManager"),d(this,"processedScripts",new WeakSet),d(this,"componentFunctions",new Map),d(this,"expressionEvaluator"),d(this,"domBindingManager"),d(this,"templateRenderer"),d(this,"updateTimeouts"),d(this,"updateBatcher",new St),d(this,"propDependencyCache",new Map),this.stateManager=e,this.updateBatcher=new St,this.stateManager.onStateChange(e=>this.invalidateContextCache(e))}getPropDependencies(e,t){var n;const s=this.findElementWithProps(t);if(!s)return[];const i=this.elementProps.get(s);if(!i||!i.has(e))return[];const r=i.get(e),a=(null==(n=this.templateRenderer)?void 0:n.dependencies(r.expression,r.component,this.stateManager))||[],o=new Set(a);for(const e of a){const t=e.split("."),n=t[t.length-1];this.getPropDependencies(n,r.component).forEach(e=>o.add(e))}return Array.from(o)}buildRestrictedComponentContext(e,t=!1){const n={};window[e]&&Object.assign(n,window[e]);const s=this.componentFunctions.get(e);if(s)for(const[e,t]of s)n[e]=t;const i=this.stateManager.getState(),r=Object.keys(i).filter(t=>t.startsWith(e+"."));for(const t of r){const s=t.substring(e.length+1);s in n||(n[s]=i[t])}if(t&&"app"!==e){const e=this.componentFunctions.get("app");if(e)for(const[t,s]of e)t in n||(n[t]=s);if(window.app)for(const[e,t]of Object.entries(window.app))"function"==typeof t&&!("__pphp_key"in t)&&(e in n||(n[e]=t))}return n}getComponentPropDependencies(e,t){if(this.propDependencyCache.has(e))return this.propDependencyCache.get(e);const n=new Set,s=this.elementProps.get(e);s&&this.templateRenderer&&s.forEach(t=>{var s;const i=null==(s=this.templateRenderer)?void 0:s.dependencies(t.expression,t.component,this.stateManager);null==i||i.forEach(e=>n.add(e));const r=this.findElementWithProps(t.component);r&&r!==e&&this.getComponentPropDependencies(r,t.component).forEach(e=>n.add(e))});const i=Array.from(n);return this.propDependencyCache.set(e,i),i}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 ve(e)}extractProps(e,t){const n=new Map,s=e.attributes,i=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),r=M.findScope(e);let a=t;r&&(a="app"===r?"app":r);for(let t=0;t<s.length;t++){const r=s[t];if(r.name!==g.ATTR_PREFIXES.COMPONENT&&r.name!==g.ATTR_PREFIXES.SPREAD&&r.name!==g.ATTR_PREFIXES.LOOP&&!ie.isEventAttribute(r.name)&&r.value&&ve.containsMustacheExpression(r.value)){if(i&&this.mightReferenceSelfProps(r.value,e))continue;const t=w.attributeToPropertyName(r.name),s={name:t,expression:r.value,component:a,subscriptionIds:[]};n.set(t,s)}}return n}mightReferenceSelfProps(e,t){const n=this.elementProps.get(t);if(!n)return!1;const s=Array.from(n.keys()),i=O.extractExpressions(e);if(0===i.length)return!1;for(const e of i)try{const t=F(e,{ecmaVersion:2022,sourceType:"script"}),n=new Set,i=new Set;U(t,{Identifier:(e,t)=>{const s=null==t?void 0:t[t.length-1];"MemberExpression"===(null==s?void 0:s.type)&&s.property===e&&!s.computed||("FunctionExpression"===(null==s?void 0:s.type)||"ArrowFunctionExpression"===(null==s?void 0:s.type))&&(s.params||[]).includes(e)||("MemberExpression"===(null==s?void 0:s.type)&&s.object===e?i.add(e.name):n.add(e.name))}});for(const e of s){if("dataState"===e)continue;const t=n.has(e),s=i.has(e)&&!n.has(e);if(t&&!s)return!0}}catch(t){console.error(`❌ Failed to parse mustache expression "${e}":`,t);continue}return!1}setupProps(e,t){const n=this.extractProps(e,t);0!==n.size&&(this.elementProps.set(e,n),this.expressionEvaluator&&n.forEach((t,n)=>{this.setupPropBinding(e,t)}))}setupPropBinding(e,t){var n;if(!this.expressionEvaluator)return;const s=`prop_${Date.now()}_${Math.random()}`,i=(null==(n=this.templateRenderer)?void 0:n.dependencies(t.expression,t.component,this.stateManager))||[],r={id:s,selector:"",dependencies:new Set(i),callback:()=>{const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);t&&(this.updateBatcher.scheduleUpdate(t,e),this.refreshComponentBindings(e,t))},element:e,component:t.component};this.stateManager.addSubscription(r),t.subscriptionIds.push(s)}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 s=n.values().next().value;if(!s)return t;let i=this.buildComponentContext(s.component);const r=this.getLoopContextForElement(e);r&&(i={...i,...r});const a=this.findElementWithProps(s.component);if(a&&a!==e){const e=this.evaluateProps(a);i={...i,...e}}return n.forEach((e,n)=>{var s;try{const r=null==(s=this.templateRenderer)?void 0:s.render(e.expression,i,e.component);t[n]="function"==typeof r?"__pphp_key"in r?r:(...e)=>r.apply(this,e):r}catch(s){console.error(`❌ Failed to evaluate prop "${n}":`,s),console.error(` Expression: ${e.expression}`),console.error(` Component: ${e.component}`),console.error(" Context keys:",Object.keys(i)),t[n]=void 0}}),t}cleanupProps(e){const t=this.elementProps.get(e);t&&(t.forEach(e=>{e.subscriptionIds.forEach(e=>{this.stateManager.removeSubscription(e)})}),this.elementProps.delete(e))}buildComponentContextWithProps(e,t){const n=this.buildComponentContext(e);let s=this.findElementWithProps(e);if(t&&this.elementProps.has(t)&&(s=t),s)try{const i=this.evaluatePropsWithContext(s,e,t);Object.keys(i).length>0&&Object.keys(i).forEach(e=>{n[e]=i[e]})}catch(t){console.error(`❌ Error evaluating props for ${e}:`,t)}return n}buildRestrictedComponentContextWithProps(e,t){const n=this.buildRestrictedComponentContext(e,!1);if(this.elementProps.has(t)){const e=this.evaluateProps(t);Object.assign(n,e)}return n}evaluatePropsWithContext(e,t,n){const s={},i=this.elementProps.get(e);if(!i||!this.expressionEvaluator)return s;const r=i.values().next().value;if(!r)return s;const a=r.component;let o=this.buildComponentContext(a);const c=this.getLoopContextForElement(e);c&&(o={...o,...c});const l=this.findElementWithProps(a);if(l&&l!==e){const e=this.evaluateProps(l);o={...o,...e}}if("app"!==a){const e=this.buildComponentContext("app");for(const[t,n]of Object.entries(e))t in o||(o[t]=n)}const h=new Map,p=new Map,u=Array.from(i.keys());i.forEach((e,t)=>{u.some(n=>n!==t&&e.expression.includes(n))?p.set(t,e):h.set(t,e)}),h.forEach((e,t)=>{var n;try{const i=null==(n=this.templateRenderer)?void 0:n.render(e.expression,o,e.component);s[t]=i}catch(n){console.error(`❌ Failed to evaluate prop "${t}":`,n),console.error(` Expression: ${e.expression}`),console.error(` Component: ${e.component}`),console.error(" Available keys:",Object.keys(o)),s[t]=void 0}});const d={...o,...s};return p.forEach((e,t)=>{var n;try{const i=null==(n=this.templateRenderer)?void 0:n.render(e.expression,d,e.component);s[t]=i}catch(e){console.error(`❌ Failed to evaluate prop "${t}":`,e),s[t]=void 0}}),s}findElementWithProps(e){const t=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const e of t){const t=this.elementProps.get(e);if(t&&t.size>0)return e}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 n=e.split("_");n.pop();const s=n.join("_");window[s]&&Object.assign(t,window[s])}"app"!==e&&window[e]&&Object.assign(t,window[e]),"app"===e&&window.app&&Object.assign(t,window.app);const n=this.componentFunctions.get(e);if(n)for(const[e,s]of n)t[e]=s;const s=this.stateManager.getState();for(const n of Object.keys(s))if(n.startsWith(e+".")){const i=n.substring(e.length+1);i in t||(t[i]=s[n])}return t}invalidateContextCache(e){if(e.startsWith("app.")){this.contextCache.clear();for(const e of this.contextInvalidated.keys())this.contextInvalidated.add(e);return}const t=e.indexOf(".");if(-1!==t){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(g.ATTR_PREFIXES.COMPONENT),s=e===document.body;if(n||s){if(n){this.pushComponent(n);const t=this.getParentComponent(e);this.setupProps(e,t)}this.getRelevantScripts(e,s).forEach(e=>{const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);t&&t!==n?(this.pushComponent(t),this.executeScript(e),this.popComponent()):this.executeScript(e)})}for(Array.from(e.children).forEach(e=>this.executePhpScripts(e));this.componentStack.length>t;)this.popComponent()}getParentComponent(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}getRelevantScripts(e,t){return Array.from(e.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`)).filter(n=>{if(this.processedScripts.has(n))return!1;if(t)return!!n.hasAttribute(g.ATTR_PREFIXES.COMPONENT)||!n.closest(`[${g.ATTR_PREFIXES.COMPONENT}]`);let s=n.parentElement;for(;s&&s!==e;){if(s.hasAttribute(g.ATTR_PREFIXES.COMPONENT))return!1;s=s.parentElement}return s===e||e.contains(n)})}executeScript(e){if(this.processedScripts.has(e))return;this.processedScripts.add(e);const t=this.getCurrentComponent(),n=e.textContent||"",s=O.decodeEntities(n);try{const n=this.findComponentElementForScript(e,t);if(n&&!this.hasStoredProps(n)){const e=this.getParentComponent(n);this.setupProps(n,e)}const i=M.findScope(n||e),r=!(!n||!this.hasStoredProps(n));let a;if(a=this.shouldUseRestrictedContext(t,i,n,r)?this.buildIsolatedComponentContext(t,i,n,r):this.buildComponentContextWithProps(t,n),n&&this.domBindingManager){const e=this.getLoopContextForElement(n);e&&(a={...a,...e})}if(r&&n){const e=this.evaluateProps(n);a={...a,...e}}window[t]||(window[t]={}),this.executeScriptFunctions(s,t,a)}catch(e){console.error(`Script execution failed in component ${t}:`,e),console.error("Script content:",s)}}getLoopContextForElement(e){var t;if(null==(t=this.domBindingManager)||!t.loopManager)return null;const n=this.domBindingManager.loopManager;if(n.isLoopItem&&n.isLoopItem(e)){const t=n.getLoopItemContext(e);if(t)return this.extractLoopContextValues(t)}let s=e.parentElement;for(;s&&s!==document.body;){if(n.isLoopItem&&n.isLoopItem(s)){const e=n.getLoopItemContext(s);if(e)return this.extractLoopContextValues(e)}s=s.parentElement}const i=n.getAllLoops();for(const[t,n]of i)for(const t of n.renderedItems)if(t.element===e||t.element.contains(e))return this.extractLoopContextValues(t.context);return null}extractLoopContextValues(e){const t={};for(const[n,s]of Object.entries(e))["getContext","withContext","__getProp"].includes(n)||("function"==typeof s&&"__pphp_key"in s?t[n]=s.value:"function"==typeof s?!n.startsWith("set")&&!n.endsWith("Getter")&&(t[n]=s):t[n]=s);return t}shouldUseRestrictedContext(e,t,n,s){return!(!t&&!s)&&(!(t!==e||!s)||(t&&t!==e?this.findDirectParentComponent(n)===t:!!s))}findDirectParentComponent(e){if(!e)return null;let t=e.parentElement;for(;t&&t!==document.body;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return null}buildIsolatedComponentContext(e,t,n,s){const i={},r=this.buildRestrictedComponentContext(e,!1);if(Object.assign(i,r),n&&this.domBindingManager){const e=this.getLoopContextForElement(n);e&&Object.assign(i,e)}if(s&&n){const e=this.evaluateProps(n);Object.assign(i,e)}return i.getContext=()=>{let t={...this.buildRestrictedComponentContext(e,!1)};if(n&&this.domBindingManager){const e=this.getLoopContextForElement(n);e&&(t={...t,...e})}if(s&&n){const e=this.evaluateProps(n);return{...t,...e}}return t},i.withContext=e=>{const t=i.getContext();return e.call(t,t)},i.__getProp=e=>{if(n)return this.evaluateProps(n)[e]},i}findComponentElementForScript(e,t){if(e.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const s=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const e of s)if(this.elementProps.has(e))return e;return s[0]||void 0}executeScriptFunctions(e,t,n){const s=this.extractFunctionNames(e),i=this.findElementWithProps(t),r=this.extractVariableDeclarations(e);let a={...n};r.forEach(e=>{delete a[e];const t=`set${rs(e)}`,n=`${e}Getter`;delete a[t],delete a[n]});const o=i&&this.hasStoredProps(i);if(o){a=this.buildRestrictedComponentContext(t,!1);const e=this.evaluateProps(i);a={...a,...e}}else if(i){const e=this.evaluateProps(i);Object.assign(a,e)}a.getContext=()=>{if(o){return{...this.buildRestrictedComponentContext(t,!1),...i?this.evaluateProps(i):{}}}return this.buildComponentContextWithProps(t)},a.withContext=e=>{const t=a.getContext();return e.call(t,t)},a.__getProp=e=>{if(i)return this.evaluateProps(i)[e]};const c=ye.getInstance(),l=new Set;if(i){const e=this.evaluateProps(i);for(const[t,n]of Object.entries(e))"function"==typeof n&&"__pphp_key"in n&&(l.add(t),/^set[A-Z]/.test(t)&&l.add(t))}let h=c.transformStateDeclarations(e,l);h=this.modifyScriptForReactiveProps(h,t,i||void 0);const p=`\n ${h}\n\n ${s.map(e=>`\n if (typeof ${e} === 'function') {\n this['${e}'] = ${e};\n }\n `).join("\n")}\n `,u={};for(const[e,t]of Object.entries(a))this.isValidJavaScriptIdentifier(e)&&(u[e]=t);const d=Object.keys(u),m=d.map(e=>u[e]);try{new Function(...d,p).call(window[t],...m),window[t].getContext=a.getContext,window[t].withContext=a.withContext,window[t].__getProp=a.__getProp;for(const e of s){const n=window[t][e];"function"==typeof n&&this.storeFunctionForComponent(t,e,n)}this.invalidateComponent(t)}catch(n){console.error("Script execution failed:",n),console.error("Component:",t),console.error("Original script:",e),console.error("Available context keys:",Object.keys(u)),console.error("Should isolate:",o)}}isValidJavaScriptIdentifier(e){return!Se.has(e)&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}extractVariableDeclarations(e){const t=ye.getInstance().extractStateDeclarations(e).map(e=>e.variableName),n=[],s=/(?:const|let|var)\s*\[\s*([^,\]]+)(?:\s*,\s*([^,\]]+))?\s*\]/g;let i;for(;null!==(i=s.exec(e));)i[1]&&!t.includes(i[1].trim())&&n.push(i[1].trim()),i[2]&&!t.includes(i[2].trim())&&n.push(i[2].trim());const r=/(?:const|let|var)\s+([a-zA-Z_$][\w$]*)/g;for(;null!==(i=r.exec(e));)t.includes(i[1])||n.push(i[1]);return[...t,...n]}modifyScriptForReactiveProps(e,t,n){if(!n||!this.elementProps.has(n))return e;const s=this.elementProps.get(n),i=Array.from(s.keys());let r=e;return i.forEach(e=>{r=this.replacePropOutsideStrings(r,e)}),r}replacePropOutsideStrings(e,t){let n="",s=0;const i=e.length;for(;s<i;){const r=e[s];if("'"===r){const t=this.findStringEnd(e,s,"'");n+=e.slice(s,t+1),s=t+1;continue}if('"'===r){const t=this.findStringEnd(e,s,'"');n+=e.slice(s,t+1),s=t+1;continue}if("`"===r){const t=this.findTemplateEnd(e,s);n+=e.slice(s,t+1),s=t+1;continue}if("/"===r&&s+1<i){if("/"===e[s+1]){const t=e.indexOf("\n",s),r=-1===t?i:t;n+=e.slice(s,r),s=r;continue}if("*"===e[s+1]){const t=e.indexOf("*/",s+2),r=-1===t?i:t+2;n+=e.slice(s,r),s=r;continue}}this.matchesPropName(e,s,t)?(n+=`__getProp('${t}')`,s+=t.length):(n+=r,s++)}return n}findStringEnd(e,t,n){let s=t+1;for(;s<e.length;){if(e[s]===n&&"\\"!==e[s-1])return s;"\\"===e[s]&&s++,s++}return e.length-1}findTemplateEnd(e,t){let n=t+1,s=0;for(;n<e.length;){const t=e[n];if("`"===t&&0===s)return n;"$"===t&&n+1<e.length&&"{"===e[n+1]?(s++,n++):"}"===t&&s>0?s--:"\\"===t&&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 s=t>0?e[t-1]:"",i=t+n.length<e.length?e[t+n.length]:"",r=0===t||!/[a-zA-Z0-9_$]/.test(s),a=t+n.length===e.length||!/[a-zA-Z0-9_$]/.test(i);if(!r||!a||"."===s||"."===i)return!1;const o=e.slice(t+n.length);if(/^\s*[=:]/.test(o))return!1;const c=e.slice(Math.max(0,t-20),t);return!/[a-zA-Z0-9_$]\s*\.\s*$/.test(c)}extractFunctionNames(e){return ye.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(),this.processedScripts=new WeakSet}}class St{constructor(){d(this,"pendingUpdates",new Map),d(this,"batchTimeout",null),d(this,"componentManager"),d(this,"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),null===this.batchTimeout&&(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[e,n]of t)this.processComponentUpdate(e,n)}sortUpdatesByDependency(e){const t=new WeakMap,n=e=>{let n=t.get(e);return null==n&&(n=w.getElementDepth(e),t.set(e,n)),n};return Array.from(e.entries()).sort(([,e],[,t])=>Math.min(...Array.from(e,n))-Math.min(...Array.from(t,n)))}processComponentUpdate(e,t){if(!this.componentManager||!this.domBindingManager)return;this.componentManager.invalidateComponent(e);const n=[],s=[],i=[];for(const r of t){if(!document.contains(r))continue;const t=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null);let a;for(;a=t.nextNode();)n.push(a);const o=this.domBindingManager.loopManager;if(o){const t=o.getAllLoops();for(const[n,i]of t)i.component===e&&r.contains(n)&&s.push([n,i])}i.push(r)}this.updateTextNodesBatch(n,e),this.updateLoopsBatch(s),this.updateElementsBatch(i,e)}updateTextNodesBatch(e,t){var n;const s=null==(n=this.domBindingManager)?void 0:n.textNodeManager;s&&e.forEach(e=>{document.contains(e)&&w.getComponentForNode(e)===t&&s.updateTextNode(e)})}updateLoopsBatch(e){var t;const n=null==(t=this.domBindingManager)?void 0:t.loopManager;if(!n)return;const s=new Map;e.forEach(([e,t])=>{const n=w.getElementDepth(e);s.has(n)||s.set(n,[]),s.get(n).push([e,t])});const i=Array.from(s.keys()).sort((e,t)=>e-t);for(const e of i)s.get(e).forEach(([e,t])=>{document.contains(e)&&n.renderLoop(t,t.iterableExpr)})}updateElementsBatch(e,t){e.forEach(e=>{var t;document.contains(e)&&(null==(t=this.domBindingManager)||t.processElementBindings(e,!0))})}}const g={ATTR_PREFIXES:{COMPONENT:"pp-component",LOOP:"pp-for",SPREAD:"pp-spread",REF:"pp-ref",IGNORE:"pp-ignore"},SCRIPT_TYPE:"text/pp",MAX_CACHE_SIZE:2e3,DEBOUNCE_MS:16,MUSTACHE_PATTERN:/\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/},Se=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 sn(e,t){let n;return(...s)=>{clearTimeout(n),n=window.setTimeout(()=>e(...s),t)}}function rs(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ee(e){if(null==e||"boolean"==typeof e||"function"==typeof e||Array.isArray(e)&&0===e.length||"object"==typeof e&&0===Object.keys(e).length)return"";if("number"==typeof e)return String(e);if("string"==typeof e)return e;if(Array.isArray(e)){if(e.some(e=>null!==e&&("object"==typeof e||Array.isArray(e))))try{return JSON.stringify(e)}catch{return"[Array]"}return e.map(e=>Ee(e)).filter(e=>""!==e).join("")}if("object"==typeof e)try{return JSON.stringify(e)}catch{return"[object Object]"}return String(e)}function Re(e){return"function"==typeof e&&"__pphp_key"in e}function je(e){return Re(e)?e.value:e}function as(e,t={}){if(!Re(e))return e;const n=e.value;return t.forComparison||t.forLogical||t.forceExtract||null==n||"boolean"==typeof n||"string"==typeof n||"number"==typeof n?n:e}function os(e,t=!1){const n={};for(const[s,i]of Object.entries(e))Re(i)?n[s]=t?as(i):i.value:n[s]=i;return n}function nn(e){return e.includes("?")||e.includes("&&")||e.includes("||")||e.includes("===")||e.includes("!==")||e.includes("==")||e.includes("!=")||e.includes(">=")||e.includes("<=")||e.includes(">")||e.includes("<")||/^!/.test(e.trim())}var cs=(e=>(e.NOT_STARTED="not_started",e.SCRIPTS_EXECUTING="scripts_executing",e.LOOPS_PROCESSING="loops_processing",e.EFFECTS_RUNNING="effects_running",e.PORTALS_RENDERING="portals_rendering",e.COMPLETE="complete",e))(cs||{});class rn{constructor(){d(this,"phase","not_started"),d(this,"phasePromises",new Map),d(this,"phaseResolvers",new Map),d(this,"hooks",{}),Object.values(cs).forEach(e=>{const t=new Promise(t=>{this.phaseResolvers.set(e,t)});this.phasePromises.set(e,t)})}getCurrentPhase(){return this.phase}async waitForPhase(e){await this.phasePromises.get(e)}markPhaseComplete(e){this.phase=e;const t=this.phaseResolvers.get(e);t&&t(),this.emitPhaseEvent(e)}emitPhaseEvent(e){document.dispatchEvent(new CustomEvent(`pp:phase:${e}`,{detail:{phase:e,timestamp:performance.now()}}))}registerHooks(e){this.hooks={...this.hooks,...e}}async executeHook(e){const t=this.hooks[e];if(t)try{await Promise.resolve(t())}catch(t){console.error(`[Lifecycle] Hook ${e} failed:`,t)}}}class M{static findScope(e){const t=e instanceof Text?e.parentElement:e;if(!t)return null;if(this.scopeCache.has(t))return this.scopeCache.get(t);const n=this.findScopeUncached(t);return this.scopeCache.set(t,n),this.trackElement(t),n}static findScopeUncached(e){const t=this.findScopeInSiblings(e);if(null!==t)return t;let n=e.parentElement;for(;n&&n!==document.body;){if(n instanceof Element&&n.hasAttribute(g.ATTR_PREFIXES.COMPONENT))return null;const e=this.findScopeInSiblings(n);if(null!==e)return e;n=n.parentElement}return null}static findScopeInSiblings(e){let t=e.previousSibling,n=0;for(;t;){if(t.nodeType===Node.COMMENT_NODE){const e=t,s=this.parseCommentNode(e,n);if(null!==s)if("end"===s.type)n++;else if("start"===s.type){if(0===n)return s.name;n--}}t=t.previousSibling}return null}static parseCommentNode(e,t){if(this.commentCache.has(e)){const t=this.commentCache.get(e);if(""===t)return null;if("/pp-scope"===t)return{type:"end",name:""};if(t.startsWith("pp-scope:"))return{type:"start",name:t.substring(9)}}const n=(e.textContent||"").trim();if("/pp-scope"===n)return this.commentCache.set(e,n),{type:"end",name:""};if(n.startsWith("pp-scope:")){const t=n.substring(9).trim();return this.isValidScopeName(t)?(this.commentCache.set(e,n),{type:"start",name:t}):(console.warn(`⚠️ Invalid scope name in comment: "${t}". Scope names must be valid identifiers or "app".`),this.commentCache.set(e,""),null)}return this.commentCache.set(e,""),null}static isValidScopeName(e){return"app"===e||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}static removeScopeComments(){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT,{acceptNode:e=>{const t=(e.textContent||"").trim();return"/pp-scope"===t||t.startsWith("pp-scope:")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),t=[];let n;for(;n=e.nextNode();)t.push(n);if(0===t.length)return;console.debug(`Found ${t.length} scope comments to remove`);let s=0;for(const e of t)try{e.parentNode&&(e.parentNode.removeChild(e),s++)}catch(e){console.error("Failed to remove scope comment:",e)}console.debug(`✅ Successfully removed ${s} scope comments from DOM`)}static preCacheAllScopes(){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,null),t=[];let n;for(;n=e.nextNode();)t.push(n);for(const e of t)this.findScope(e);console.debug(`Pre-cached scopes for ${t.length} elements`)}static trackElement(e){this.trackedElements.add(e),this.trackedElements.size>=this.MAX_TRACKED_ELEMENTS&&this.scheduleCleanup(),Date.now()-this.lastCleanup>this.CLEANUP_INTERVAL&&this.scheduleCleanup()}static scheduleCleanup(){this.cleanupScheduled||(this.cleanupScheduled=!0,requestIdleCallback(()=>{this.performCleanup(),this.cleanupScheduled=!1},{timeout:1e3}))}static performCleanup(){const e=[];let t=0;for(const n of this.trackedElements){if(t++,t%100==0&&!this.cleanupScheduled)break;document.contains(n)||e.push(n)}e.forEach(e=>{this.scopeCache.delete(e),this.trackedElements.delete(e)}),this.lastCleanup=Date.now(),e.length>0&&console.debug(`ScopeResolver cleanup: removed ${e.length} detached elements, ${this.trackedElements.size} elements remaining`)}static clearCache(){this.scopeCache=new WeakMap,this.commentCache=new WeakMap,this.trackedElements.clear(),this.cleanupScheduled=!1,this.lastCleanup=0}static invalidateElement(e){this.scopeCache.delete(e),this.trackedElements.delete(e)}static invalidateTree(e){this.invalidateElement(e);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n;for(;n=t.nextNode();)this.invalidateElement(n)}static getCacheStats(){return{trackedElements:this.trackedElements.size,lastCleanup:this.lastCleanup,cleanupScheduled:this.cleanupScheduled}}static forceCleanup(){this.cleanupScheduled=!0,this.performCleanup(),this.cleanupScheduled=!1}}d(M,"scopeCache",new WeakMap),d(M,"commentCache",new WeakMap),d(M,"trackedElements",new Set),d(M,"cleanupScheduled",!1),d(M,"CLEANUP_INTERVAL",5e3),d(M,"MAX_TRACKED_ELEMENTS",1e3),d(M,"lastCleanup",0);class an{static validate(e,t){const n=[],s=[];try{const t=F(e,{ecmaVersion:2022,sourceType:"script"}),i=this.validateAST(t,e);n.push(...i.errors),s.push(...i.warnings);const r=this.validateSyntax(e);n.push(...r.errors),s.push(...r.warnings)}catch(e){n.push(`Invalid JavaScript syntax: ${e instanceof Error?e.message:String(e)}`)}return{valid:0===n.length,errors:n,warnings:s}}static validateAST(e,t){const n=[],s=[];return U(e,{ConditionalExpression:e=>{const i=t.slice(e.consequent.start,e.consequent.end),r=this.validateBranch(i,"truthy");n.push(...r.errors),s.push(...r.warnings);const a=t.slice(e.alternate.start,e.alternate.end),o=this.validateBranch(a,"falsy");n.push(...o.errors),s.push(...o.warnings)}}),{errors:n,warnings:s}}static validateBranch(e,t){const n=[],s=[];try{return F(e,{ecmaVersion:2022,sourceType:"script"}),{errors:n,warnings:s}}catch{const i=this.countQuotes(e);if(i.single%2!=0&&(n.push(`Unmatched single quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,"'"))){const t=this.suggestQuoteFix(e,"'");t&&n.push(` Did you mean: ${t}`)}if(i.double%2!=0&&(n.push(`Unmatched double quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,'"'))){const t=this.suggestQuoteFix(e,'"');t&&n.push(` Did you mean: ${t}`)}i.single%2==0&&i.double%2==0&&this.looksLikeUnquotedLiteral(e)&&s.push(`Value "${e}" in ternary ${t} branch may need quotes. Did you mean '${e}' or "${e}"?`)}return{errors:n,warnings:s}}static hasTrailingOrLeadingQuote(e,t){const n=e.startsWith(t),s=e.endsWith(t);return n&&!s||!n&&s}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();if(!t||this.isAlreadyQuoted(t))return!1;try{return F(t,{ecmaVersion:2022,sourceType:"script"}),!1}catch{}return!(Se.has(t)||"true"===t||"false"===t||"null"===t||"undefined"===t||!isNaN(Number(t))&&""!==t||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)||t.includes(".")||/\[.*\]/.test(t)||/\(.*\)/.test(t))&&!!(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,s=!1;for(let i=0;i<e.length;i++)s?s=!1:"\\"!==e[i]?("'"===e[i]&&t++,'"'===e[i]&&n++):s=!0;return{single:t,double:n}}static validateSyntax(e){const t=[],n=this.checkBrackets(e);n.valid||t.push(n.error);const s=this.checkParentheses(e);return s.valid||t.push(s.error),{errors:t,warnings:[]}}static checkBrackets(e){let t=0,n=!1,s="";for(let i=0;i<e.length;i++){const r=e[i],a=i>0?e[i-1]:"";if(n||"'"!==r&&'"'!==r?n&&r===s&&"\\"!==a&&(n=!1,s=""):(n=!0,s=r),!n&&("{"===r&&t++,"}"===r&&t--,t<0))return{valid:!1,error:"Unexpected closing bracket '}'"}}return 0!==t?{valid:!1,error:"Mismatched brackets - missing '}'"}:{valid:!0,error:""}}static checkParentheses(e){let t=0,n=!1,s="";for(let i=0;i<e.length;i++){const r=e[i],a=i>0?e[i-1]:"";if(n||"'"!==r&&'"'!==r?n&&r===s&&"\\"!==a&&(n=!1,s=""):(n=!0,s=r),!n&&("("===r&&t++,")"===r&&t--,t<0))return{valid:!1,error:"Unexpected closing parenthesis ')'"}}return 0!==t?{valid:!1,error:"Mismatched parentheses - missing ')'"}:{valid:!0,error:""}}}const B=class e{constructor(){d(this,"componentElementsCache",new K(100)),d(this,"scriptElementsCache",new K(50)),d(this,"templateElementsCache",new K(50)),d(this,"selectorCache",new K(200)),d(this,"elementComponentCache",new WeakMap),d(this,"parentComponentCache",new WeakMap),d(this,"contextComponentCache",new WeakMap),d(this,"elementDepthCache",new WeakMap),d(this,"elementChildrenCache",new WeakMap),d(this,"cacheHits",0),d(this,"cacheMisses",0)}static getInstance(){return e.instance||(e.instance=new e),e.instance}queryComponentElements(t){const n=e.CACHE_KEYS.COMPONENT_ELEMENTS(t);if(this.componentElementsCache.has(n))return this.cacheHits++,this.componentElementsCache.get(n);this.cacheMisses++;const s=Array.from(document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`));return s.forEach(e=>{this.elementComponentCache.set(e,t)}),this.componentElementsCache.set(n,s),s}querySelectorAll(t){const n=e.CACHE_KEYS.SELECTOR(t);if(this.selectorCache.has(n))return this.cacheHits++,this.selectorCache.get(n);this.cacheMisses++;const s=Array.from(document.querySelectorAll(t));return this.selectorCache.set(n,s),s}getElementComponent(e){if(this.elementComponentCache.has(e))return this.cacheHits++,this.elementComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;let n=e.parentElement;for(;n;){const t=n.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;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=M.findScope(e);let n;return n=t?"app"===t?"app":t: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++,"app"===e)return this.parentComponentCache.set(t,"app"),"app";let n=t;for(;n&&n.getAttribute(g.ATTR_PREFIXES.COMPONENT)!==e;)n=n.parentElement;if(!n)return this.parentComponentCache.set(t,"app"),"app";let s=n.parentElement;for(;s;){const e=s.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return this.parentComponentCache.set(t,e),e;s=s.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(t,n){const s=e.CACHE_KEYS.SCRIPTS(t,(null==n?void 0:n.tagName)||"global");if(this.scriptElementsCache.has(s))return this.cacheHits++,this.scriptElementsCache.get(s);this.cacheMisses++;let i=[];if(n){const e=n.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`);for(const t of e)t instanceof HTMLScriptElement&&i.push(t)}else{const e=document.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`);for(const n of e)if(n instanceof HTMLScriptElement){const e=n.getAttribute(g.ATTR_PREFIXES.COMPONENT);(e===t||!e&&!n.closest(`[${g.ATTR_PREFIXES.COMPONENT}]`))&&i.push(n)}}return this.scriptElementsCache.set(s,i),i}getComponentTemplates(t,n){const s=e.CACHE_KEYS.TEMPLATES(t,(null==n?void 0:n.tagName)||"global");if(this.templateElementsCache.has(s))return this.cacheHits++,this.templateElementsCache.get(s);this.cacheMisses++;let i=[];if(n){const e=n.querySelectorAll("template[pp-for]");for(const n of e)n instanceof HTMLTemplateElement&&this.getElementComponent(n)===t&&i.push(n)}else{const e=document.querySelectorAll("template[pp-for]");for(const n of e)n instanceof HTMLTemplateElement&&this.getElementComponent(n)===t&&i.push(n)}return this.templateElementsCache.set(s,i),i}querySelector(e){const t=this.querySelectorAll(e);return t.length>0?t[0]:null}findElementForComponent(e,t){if("app"===t)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(t){const n=e.CACHE_KEYS.COMPONENT_ELEMENTS(t);this.componentElementsCache.delete(n);const s=e.CACHE_KEYS.SCRIPTS(t,"global");this.scriptElementsCache.delete(s);const i=e.CACHE_KEYS.TEMPLATES(t,"global");this.templateElementsCache.delete(i),this.selectorCache.clear(),this.queryComponentElements(t).forEach(e=>M.invalidateElement(e))}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),M.invalidateElement(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,M.clearCache()}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}};d(B,"instance"),d(B,"CACHE_KEYS",{COMPONENT_ELEMENTS:e=>`comp:${e}`,SCRIPTS:(e,t)=>`scripts:${e}:${t}`,TEMPLATES:(e,t)=>`templates:${e}:${t}`,SELECTOR:e=>`sel:${e}`});let He=B;class on{constructor(){d(this,"subscriptions",new Map),d(this,"elementSubscriptions",new WeakMap),d(this,"keyIndex",new Map),d(this,"cleanupQueue",new Set),d(this,"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),0===n.size&&this.elementSubscriptions.delete(t.element))}for(const n of t.dependencies){const t=this.keyIndex.get(n);t&&(t.delete(e),0===t.size&&this.keyIndex.delete(n))}}}cleanupElement(e){const t=this.elementSubscriptions.get(e);t&&(t.forEach(e=>this.cleanupQueue.add(e)),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(e=>this.removeSubscription(e))}getStats(){return{totalSubscriptions:this.subscriptions.size,elementSubscriptions:this.elementSubscriptions instanceof WeakMap?-1:0,keyIndexes:this.keyIndex.size}}}class K{constructor(e){d(this,"cache",new Map),d(this,"maxSize"),d(this,"hits",0),d(this,"misses",0),this.maxSize=e}keys(){return Array.from(this.cache.keys())}deleteByPrefix(e){let t=0;const n=[];return this.cache.forEach((t,s)=>{"string"==typeof s&&s.startsWith(e)&&n.push(s)}),n.forEach(e=>{this.cache.delete(e)&&t++}),t}getKeysByPrefix(e){const t=[];return this.cache.forEach((n,s)=>{"string"==typeof s&&s.startsWith(e)&&t.push(s)}),t}get(e){const t=this.cache.get(e);if(void 0!==t)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 e=this.cache.keys().next().value;void 0!==e&&this.cache.delete(e)}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}}const ee=class e{static parseSpreadDirective(e){const t=e.replace(/^\s*\{\s*|\s*\}\s*$/g,""),n=this.parseSpreadParts(t),s=[],i=[];for(const e of n){const t=e.trim();if(t.startsWith("..."))s.push(t.substring(3).trim());else if(t.startsWith("{")&&t.endsWith("}")){const e=t.slice(1,-1).trim();if(e){const t=this.parseObjectProperties(e);i.push(t)}}else console.warn(`Invalid spread directive part: "${t}". Expected ...spread or {object}`)}return{spreads:s,objects:i}}static parseSpreadParts(e){const t=[];let n="",s=0,i=!1,r="",a=0;for(;a<e.length;){const o=e[a],c=a>0?e[a-1]:"";if(i||'"'!==o&&"'"!==o?i&&o===r&&"\\"!==c&&(i=!1,r=""):(i=!0,r=o),!i)if("{"===o)s++;else if("}"===o)s--;else if(","===o&&0===s){t.push(n.trim()),n="",a++;continue}n+=o,a++}return n.trim()&&t.push(n.trim()),t}static parseObjectProperties(e){const t=[],n=this.parseObjectParts(e);for(const e of n){const n=e.trim(),s=this.findPropertySeparator(n);if(-1!==s){const e=n.substring(0,s).trim().replace(/['"]/g,""),i=n.substring(s+1).trim();t.push({key:e,value:i})}else console.warn(`Invalid object property: "${n}". Expected key: value format.`)}return t}static parseObjectParts(e){const t=[];let n="",s=0,i=!1,r="";for(let a=0;a<e.length;a++){const o=e[a],c=a>0?e[a-1]:"";if(i||'"'!==o&&"'"!==o?i&&o===r&&"\\"!==c&&(i=!1,r=""):(i=!0,r=o),!i)if("{"===o||"["===o||"("===o)s++;else if("}"===o||"]"===o||")"===o)s--;else if(","===o&&0===s){t.push(n.trim()),n="";continue}n+=o}return n.trim()&&t.push(n.trim()),t}static findPropertySeparator(e){let t=0,n=!1,s="";for(let i=0;i<e.length;i++){const r=e[i],a=i>0?e[i-1]:"";if(n||'"'!==r&&"'"!==r?n&&r===s&&"\\"!==a&&(n=!1,s=""):(n=!0,s=r),!n)if("{"===r||"["===r||"("===r)t++;else if("}"===r||"]"===r||")"===r)t--;else if(":"===r&&0===t)return i}return-1}static parse(t){if(e.EXPRESSION_CACHE.has(t))return e.EXPRESSION_CACHE.get(t);const n=e.parseContentWithNesting(t);return e.EXPRESSION_CACHE.set(t,n),n}static parseContentWithNesting(e){const t=[],n=e.length;let s=0,i=0;for(;s<n;)if("{"===e[s]){s>i&&t.push({type:"static",content:e.substring(i,s),expression:null});const n=this.extractNestedExpression(e,s);-1!==n.endIndex&&n.expression&&this.isValidExpression(n.expression)?(t.push({type:"expression",content:e.substring(s,n.endIndex+1),expression:n.expression.trim()}),s=n.endIndex+1,i=s):s++}else s++;return i<n&&t.push({type:"static",content:e.substring(i),expression:null}),t}static isValidExpression(e){const t=e.trim();if(!t)return!1;try{const e=F(t,{ecmaVersion:2022,sourceType:"script"});if("Program"!==e.type)return!1;const n=e.body;if(!n||0===n.length)return!1;const s=n[0];if("ExpressionStatement"!==s.type)return!1;const i=s.expression;return!("ObjectExpression"===i.type||"SequenceExpression"===i.type)}catch{try{const e=F(`(${t})`,{ecmaVersion:2022,sourceType:"script"}).body;if(e&&e.length>0&&"ExpressionStatement"===e[0].type)return!0}catch{return!1}return!1}}static extractNestedExpression(e,t){let n=1,s=t+1,i=!1,r="",a=!1;for(;s<e.length&&n>0;){const t=e[s],o=s>0?e[s-1]:"";i||'"'!==t&&"'"!==t?i&&t===r&&"\\"!==o&&(i=!1,r=""):(i=!0,r=t),!i&&"`"===t&&"\\"!==o&&(a=!a),!i&&!a&&("{"===t?n++:"}"===t&&n--),s++}if(0===n){const n=e.slice(t+1,s-1);if(n.trim()){const t=this.checkForMismatchedQuotes(n);t.hasIssue&&(console.error("\n❌ Malformed expression detected during parsing:"),console.error(` Expression: ${n}`),console.error(` Issue: ${t.message}`),console.error(` Full content: ${e}`),console.error(" 💡 Hint: Check your quotes - strings must be properly quoted\n"))}return{endIndex:s-1,expression:n}}return console.warn("\n⚠️ Failed to extract mustache expression - unclosed braces"),console.warn(` Content: ${e}`),console.warn(` Starting at position: ${t}\n`),{endIndex:-1,expression:""}}static checkForMismatchedQuotes(e){let t=0,n=0,s=!1;for(let i=0;i<e.length;i++)s?s=!1:"\\"!==e[i]?("'"===e[i]&&t++,'"'===e[i]&&n++):s=!0;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(t){const n=e.parseContentWithNesting(t);return 1===n.length&&"expression"===n[0].type?n[0].expression:null}static extractExpressions(t){const n=e.parseContentWithNesting(t),s=n.filter(e=>"expression"===e.type).map(e=>e.expression).filter(e=>e);return n.some(e=>"expression"===e.type)&&0===s.length&&(console.error("\n❌ Failed to extract expressions from content:"),console.error(` Content: ${t}`),console.error(` Parsed ${n.length} parts, but extracted 0 expressions`),console.error(" This usually means malformed mustache syntax\n")),s}};d(ee,"EXPRESSION_CACHE",new K(1e3)),d(ee,"decodeEntities",e=>{const t=document.createElement("textarea");t.innerHTML=e;let n=t.value;for(;n.includes("&");){t.innerHTML=n;const e=t.value;if(e===n)break;n=e}return n});let O=ee;class cn{constructor(){d(this,"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){var n;null==(n=this.listeners.get(e))||n.delete(t)}emit(e,...t){const n=this.listeners.get(e);n&&n.forEach(n=>{try{n(...t)}catch(t){console.error(`Event listener error for ${e}:`,t)}})}}class Fe{constructor(){d(this,"subscriptionManager",new on),d(this,"stateStore",{}),d(this,"updateQueue",new Set),d(this,"isUpdating",!1),d(this,"eventBus",new cn),d(this,"contextCache",new Map),d(this,"previousValues",new Map),d(this,"originalStateStore",{}),d(this,"domUpdateCallbacks",[]),d(this,"domUpdateScheduled",!1),d(this,"suspendNotifications",!1),d(this,"scheduleFlush",sn(()=>{this.flushUpdates()},g.DEBOUNCE_MS)),this.setupGlobalStateProxy(),setInterval(()=>{this.subscriptionManager.cleanupStaleSubscriptions()},3e4)}suspendSubscriptions(){this.suspendNotifications=!0}resumeSubscriptions(){this.suspendNotifications=!1}static findExistingStateKey(e,t,n){return[`${t}.${e}`,`app.${e}`,e].find(e=>e in n)||null}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,s]of t)s.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(t=>t.startsWith(`${e}.`)).forEach(e=>{delete this.stateStore[e],delete this.originalStateStore[e],this.previousValues.delete(e)})}onDOMUpdateComplete(e){this.domUpdateCallbacks.push(e),this.domUpdateScheduled||(this.domUpdateScheduled=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=[...this.domUpdateCallbacks];this.domUpdateCallbacks=[],this.domUpdateScheduled=!1,e.forEach(e=>{try{e()}catch(e){console.error("DOM update callback error:",e)}})})}))}setInitialState(e,t){if(this.previousValues.set(e,void 0),this.originalStateStore[e]=t,this.previousValues.size>100){const e=this.previousValues.keys().next().value;"string"==typeof e&&this.previousValues.delete(e)}}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,s)=>{const i=e[t],r=Reflect.set(e,t,n,s);return i!==n&&this.notifySubscribers(t),r},get:(e,t)=>Reflect.get(e,t)})}notifySubscribers(e){if(this.updateQueue.add(e),e.includes(".")){const t=e.split(".")[0];this.updateQueue.add(t)}this.suspendNotifications||(this.eventBus.emit("stateChanged",e),this.notifyPathBasedSubscribers(e),this.isUpdating||this.scheduleFlush())}notifyPathBasedSubscribers(e){var t;const n=this.stateStore[e],s=null==(t=this.previousValues)?void 0:t.get(e),i=this.subscriptionManager.getAllSubscriptions();for(const[t,r]of i)for(const t of r.dependencies)if(this.isPathDependency(t)&&t.startsWith(e+".")){const i=t.substring(e.length+1),r=this.getPathValue(s,i),a=this.getPathValue(n,i);this.deepEqual(r,a)||this.updateQueue.add(t)}}isPathDependency(e){return e.includes(".")&&e.split(".").length>1}getPathValue(e,t){if(!e||"object"!=typeof e)return;const n=t.split(".");let s=e;for(const e of n){if(null==s)return;if(Array.isArray(s))return"length"===e?s.length:s.map(t=>null==t?void 0:t[e]).filter(e=>void 0!==e);s=s[e]}return s}deepEqual(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>this.deepEqual(e,t[n]));if("object"==typeof e&&"object"==typeof t){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every(n=>this.deepEqual(e[n],t[n]))}return!1}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 e of t){const t=this.subscriptionManager.getSubscription(e);if(!t)continue;if(t.element&&!document.contains(t.element)){this.subscriptionManager.removeSubscription(e);continue}const n=t.element??document.body;try{const e=Array.from(this.updateQueue)[0];t.callback(n,{key:e})}catch(e){console.error("Wildcard subscription callback failed:",e)}}for(const t of this.updateQueue){if(e.has(t))continue;e.add(t);const n=this.subscriptionManager.getSubscriptionsForKey(t);if(n)for(const e of n){const n=this.subscriptionManager.getSubscription(e);if(!n)continue;const s=n.element??document.body;try{n.callback(s,{key:t})}catch(e){console.error("Subscription callback failed:",e)}}}}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 e=this.previousValues.keys().next().value;"string"==typeof e&&this.previousValues.delete(e)}}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,s]of t)for(const t of s.dependencies)e.has(t)||e.set(t,new Set),e.get(t).add(n);return e}destroy(){this.clearState(),this.clearSubscriptions(),this.contextCache.clear(),this.previousValues.clear(),this.domUpdateCallbacks=[]}}const me=class e{constructor(){d(this,"expressionCache",new K(g.MAX_CACHE_SIZE)),d(this,"dependencyCache",new K(g.MAX_CACHE_SIZE)),d(this,"commonExpressionsCache",new K(100)),d(this,"dependencyParser",new ln),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},s=e.CACHE_KEYS.COMMON(t);this.commonExpressionsCache.set(s,n)})}extractDependencies(t,n,s){const i=this.normalizeExpression(t),r=e.CACHE_KEYS.DEPENDENCY(n,i);let a=this.dependencyCache.get(r);return a||(a=this.dependencyParser.extract(i,n,s),this.dependencyCache.set(r,a),a)}evaluateExpression(t,n,s){const i=this.normalizeExpression(t),r=e.CACHE_KEYS.COMMON(i);let a=this.commonExpressionsCache.get(r);if(a){a.hitCount++;try{return a.fn()}catch(e){return void console.error(`Common expression evaluation failed: "${i}"`,e)}}const o=e.CACHE_KEYS.EXPRESSION(s,i);a=this.expressionCache.get(o);const c=this.transformContextForEvaluation(n,i);(!a||this.isStale(a))&&(a=this.compileExpression(i,c,s),this.expressionCache.set(o,a)),a.hitCount++;try{const e=this.buildArguments(a.contextMap,c);return a.fn(...e)}catch(e){return console.error(`Expression evaluation failed: "${i}"`,e),void console.error("Available context:",Object.keys(c))}}transformContextForEvaluation(e,t){const n=!!t&&nn(t),s={};for(const[t,i]of Object.entries(e))Re(i)?s[t]=as(i,{forComparison:n}):s[t]=i;return s}compileExpression(e,t,n){const s=this.prepareSafeContext(t),i=new Map,r=[];Object.keys(s).forEach((e,t)=>{i.set(e,t),r.push(e)});const a=this.dependencyParser.extract(e,n);return{fn:new Function(...r,`return (${e})`),contextMap:i,dependencies:a,timestamp:Date.now(),hitCount:0}}buildArguments(e,t){const n=new Array(e.size);for(const[s,i]of e)n[i]=t[s];return n}isStale(e){return Date.now()-e.timestamp>3e5}prepareSafeContext(e){const t={};for(const[n,s]of Object.entries(e))Se.has(n)||!this.isValidJavaScriptIdentifier(n)||(t[n]=s);return t}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!Se.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(t=>{const n=this.expressionCache.get(t);n&&this.isStale(n)&&(this.expressionCache.delete(t),e++)}),e}};d(me,"CACHE_KEYS",{EXPRESSION:(e,t)=>`expr:${e}:${t}`,DEPENDENCY:(e,t)=>`deps:${e}:${t}`,COMMON:e=>`common:${e}`});let rt=me;class ln{constructor(){d(this,"parseCache",new K(500))}extract(e,t,n){const s=this.normalizeExpression(e),i=`${t}:${s}`;if(this.parseCache.has(i))return this.parseCache.get(i);const r=this.parseExpression(s,t,n);return this.parseCache.set(i,r),r}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}parseExpression(e,t,n){const s=this.extractIdentifiers(e),i=[],r=(null==n?void 0:n.getState())||{};for(const e of s){if(Se.has(e))continue;const n=e.indexOf("."),s=-1===n?e:e.substring(0,n),a=Fe.findExistingStateKey(s,t,r);if(a)i.push(a);else{const e="app"===t?[`app.${s}`]:[`${t}.${s}`,`app.${s}`];i.push(...e)}if(-1!==n){const e="app"===t?[`app.${s}`]:[`${t}.${s}`,`app.${s}`];i.push(...e)}}return Array.from(new Set(i))}extractIdentifiers(e){const t=[];let n=0;for(;n<e.length;){const s=e[n];if("'"!==s)if('"'!==s)if("`"!==s){if(this.isIdentifierStart(s)){const s=this.extractIdentifier(e,n);t.push(s.value),n=s.endIndex;continue}n++}else n=this.skipTemplateLiteral(e,n,t);else n=this.skipString(e,n,'"');else n=this.skipString(e,n,"'")}return t}skipString(e,t,n){let s=t+1;for(;s<e.length&&e[s]!==n;)"\\"===e[s]&&s++,s++;return s+1}skipTemplateLiteral(e,t,n){let s=t+1;for(;s<e.length&&"`"!==e[s];){if("$"===e[s]&&s+1<e.length&&"{"===e[s+1]){s+=2;let t=1;for(;s<e.length&&t>0;){const i=e[s];if('"'!==i&&"'"!==i){if("{"===i?t++:"}"===i&&t--,t>0&&this.isIdentifierStart(i)){const t=this.extractIdentifier(e,s);n.push(t.value),s=t.endIndex-1}s++}else s=this.skipString(e,s,i)}continue}"\\"===e[s]&&s++,s++}return s+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 ls{constructor(){d(this,"hydrationStarted",!1),d(this,"hydrationDone",!1),d(this,"initialized",!1),d(this,"stateManager",new Fe),d(this,"expressionEvaluator",new rt),d(this,"componentManager",new tn(this.stateManager)),d(this,"domBindingManager",new Zs(this.stateManager,this.componentManager,this.expressionEvaluator)),d(this,"hydrationCallbacks",new Set),d(this,"portalManager",new Ys),d(this,"hydrationResolve"),d(this,"hydrationPromise"),d(this,"portalHydrationPromises",new Set),d(this,"portalHydrationResolvers",new Map),d(this,"lifecycleManager",new rn),d(this,"pendingEffects",[]),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>this.initialize()):setTimeout(()=>this.initialize(),0),this.hydrationPromise=new Promise(e=>this.hydrationResolve=e)}async initialize(){if(this.initialized)return;this.initialized=!0,this.markHydrationStart();const e=this.domBindingManager.loopManager;return this.componentManager.setExpressionEvaluator(this.expressionEvaluator),this.portalManager.setDependencies(this.componentManager,this.domBindingManager,this.stateManager,this),M.preCacheAllScopes(),this.lifecycleManager.markPhaseComplete("not_started"),await this.lifecycleManager.executeHook("beforeScripts"),this.componentManager.executePhpScripts(document.body),await this.lifecycleManager.executeHook("afterScripts"),this.lifecycleManager.markPhaseComplete("scripts_executing"),e&&e.setHydrating(!1),await this.lifecycleManager.executeHook("beforeLoops"),await this.processAllLoops(),await this.lifecycleManager.executeHook("afterLoops"),this.lifecycleManager.markPhaseComplete("loops_processing"),await this.lifecycleManager.executeHook("beforeEffects"),await this.runPendingEffects(),await this.lifecycleManager.executeHook("afterEffects"),this.lifecycleManager.markPhaseComplete("effects_running"),await this.lifecycleManager.executeHook("beforePortals"),await Promise.all(Array.from(this.portalHydrationPromises)),await this.lifecycleManager.executeHook("afterPortals"),this.lifecycleManager.markPhaseComplete("portals_rendering"),Promise.resolve().then(()=>{requestAnimationFrame(()=>{this.lifecycleManager.markPhaseComplete("complete"),this.hydrationStarted=!1,this.hydrationDone=!0,this.markHydrated(),this.scheduleCommentCleanup(),this.reconnectObservers()})})}async processAllLoops(){this.domBindingManager.processElement(document.body,!0),this.domBindingManager.processPendingBindings();const e=this.domBindingManager.loopManager;e&&await e.waitForAllLoopsProcessed()}async runPendingEffects(){const e=[...this.pendingEffects];this.pendingEffects=[],this.stateManager.suspendSubscriptions();try{this.stateManager.batch(()=>{for(const t of e)try{t()}catch(e){console.error("[PPHP] Effect execution error:",e)}}),await new Promise(e=>setTimeout(e,0))}finally{this.stateManager.resumeSubscriptions(),this.stateManager.flushUpdates()}const t=this.domBindingManager.loopManager;t&&await this.triggerLoopUpdatesFromEffects(t)}async triggerLoopUpdatesFromEffects(e){const t=e.getAllLoops();for(const[n,s]of t)try{e.renderLoop(s,s.iterableExpr)}catch(e){console.error(`[PPHP] Error updating loop "${s.expression}":`,e)}await new Promise(e=>setTimeout(e,0))}onPhase(e,t){document.addEventListener(`pp:phase:${e}`,t)}waitForPhase(e){return this.lifecycleManager.waitForPhase(e)}registerLifecycleHooks(e){this.lifecycleManager.registerHooks(e)}disconnectObservers(){this.domBindingManager&&this.domBindingManager.pauseObserver()}reconnectObservers(){this.domBindingManager&&this.domBindingManager.resumeObserver()}scheduleCommentCleanup(){const e=()=>{try{M.removeScopeComments(),console.debug("✅ Scope comments cleaned up")}catch(e){console.error("Failed to remove scope comments:",e)}};"requestIdleCallback"in window?requestIdleCallback(e,{timeout:5e3}):setTimeout(e,100)}createPortal(e,t,n){const s=this.portalManager.createPortal(e,t,n),i=new Promise(e=>{this.portalHydrationResolvers.set(s,e)});return this.portalHydrationPromises.add(i),i.finally(()=>{this.portalHydrationPromises.delete(i),this.portalHydrationResolvers.delete(s)}),s}removePortal(e){return this.markPortalHydrated(e),this.portalManager.removePortal(e)}hasPortal(e){return this.portalManager.hasPortal(e)}getPortal(e){return this.portalManager.getPortal(e)}markPortalHydrated(e){const t=this.portalHydrationResolvers.get(e);t&&t()}updatePortal(e,t,n){return this.portalManager.updatePortal(e,t,n)}cleanup(){this.disconnectObservers(),this.portalHydrationPromises.clear(),this.portalHydrationResolvers.clear(),this.portalManager.destroy(),this.domBindingManager.destroy(),this.componentManager.destroy(),this.stateManager.clearState(),this.stateManager.clearSubscriptions(),this.expressionEvaluator.clearAllCaches(),this.hydrationCallbacks.clear(),this.deleteAllComponentObjects(),M.clearCache(),this.hydrationStarted=!1,this.hydrationDone=!1,this.initialized=!1}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)}markHydrationStart(){this.hydrationStarted=!0,this.hydrationDone=!1,document.dispatchEvent(new CustomEvent("pp:hydrationStart"))}get isHydrated(){return this.hydrationDone}get isHydrating(){return this.hydrationStarted&&!this.hydrationDone}markHydrated(){this.hydrationResolve();for(const e of this.hydrationCallbacks)try{e()}catch(e){console.error("❌ [PPHP] Hydration callback error:",e)}this.hydrationCallbacks.clear(),document.dispatchEvent(new CustomEvent("pp:hydrated",{detail:{at:performance.now()}}))}state(e,t){const n=this.componentManager.getCurrentComponent();let s,i;"string"==typeof e&&2===arguments.length?(s=e,i=t):"string"==typeof e&&1===arguments.length?this.looksLikeVariableName(e)?(s=e,i=void 0):(console.warn("pp.state() called with string that doesn't look like variable name:",e),s="unknownState",i=e):(console.warn("pp.state() called without explicit key - this should be handled by AST transformation"),s="unknownState",i=e),Re(i)&&(i=je(i));let r=`${n}.${s}`;this.stateManager.hasState(r)||this.stateManager.setInitialState(r,i);const a=()=>this.stateManager.getState()[r],o=new Proxy(a,{get(e,t,n){if("__pphp_key"===t||"__pphp_fullKey"===t||"__pphp_component"===t||"value"===t||"valueOf"===t||"toString"===t)return Reflect.get(e,t,n);const s=e();if(null!=s){if(t in Object(s)){const e=s[t];return"function"==typeof e?e.bind(s):e}return Reflect.get(e,t,n)}},has(e,t){if("__pphp_key"===t||"__pphp_fullKey"===t||"__pphp_component"===t||"value"===t||"valueOf"===t||"toString"===t)return Reflect.has(e,t);const n=e();return null!=n&&t in Object(n)||Reflect.has(e,t)},apply:(e,t,n)=>Reflect.apply(e,t,n)});Object.defineProperty(o,"__pphp_key",{value:s,enumerable:!1,writable:!1}),Object.defineProperty(o,"__pphp_fullKey",{value:r,enumerable:!1,writable:!1}),Object.defineProperty(o,"__pphp_component",{value:n,enumerable:!1,writable:!1}),Object.defineProperty(o,"value",{get:()=>this.stateManager.getState()[r],enumerable:!0,configurable:!0}),a.valueOf=()=>this.stateManager.getState()[r],a.toString=()=>Ee(this.stateManager.getState()[r]);const c=e=>{const t=this.stateManager.getState()[r],n="function"==typeof e?e(t):e;this.stateManager.setState(r,n)};return this.createComponentScopedGlobals(n,s,o,c),[o,c]}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")&&!Se.has(e)}effect(e,t){const n=`effect_${Date.now()}_${Math.random()}`,s=this.componentManager.getCurrentComponent();let i,r,a,o=!1,c=!1,l=!1;if(1===arguments.length)r="always",a={immediate:!0};else if(Array.isArray(t)){const e=this.extractDependencyNames(t,s);0===e.length?(r="once",a={deps:[],immediate:!0}):(r="deps",a={deps:e,immediate:!0})}else{const e={immediate:!0,...t||{}};if(e.deps)if(0===e.deps.length)r="once",a={deps:[],immediate:e.immediate};else{const t=this.extractDependencyNames(e.deps,s);r="deps",a={deps:t,immediate:e.immediate}}else r="always",a={immediate:e.immediate}}const h=()=>{if(!o&&!c){if(c=!0,l=!0,i&&"function"==typeof i)try{i()}catch(e){console.error(`[Effect ${n}] Cleanup error:`,e)}try{i=e()}catch(e){console.error(`[Effect ${n}] ❌ Error:`,e)}finally{c=!1}}},p=()=>{if(!(o||c||this.isHydrating&&l)){if("once"===r&&this.isHydrating)return void this.pendingEffects.push(h);if("once"===r)return void h();if(this.isHydrating&&("always"===r||"deps"===r))return void this.pendingEffects.push(h);this.stateManager.onDOMUpdateComplete(h)}};switch(r){case"always":this.stateManager.addSubscription({id:n,selector:"",dependencies:new Set(["*"]),callback:p,component:s});break;case"once":break;case"deps":const e=this.resolveDependencies(a.deps,s);e.length&&this.stateManager.addSubscription({id:n,selector:"",dependencies:new Set(e),callback:p,component:s})}return!1!==a.immediate&&(this.isHydrating?this.pendingEffects.push(h):p()),()=>{if(o=!0,i&&"function"==typeof i)try{i()}catch(e){console.error(`[Effect ${n}] Cleanup error:`,e)}this.stateManager.removeSubscription(n)}}extractDependencyNames(e,t){const n=[];for(const t of e)"string"==typeof t?n.push(t):"function"==typeof t&&t.__pphp_key?n.push(t.__pphp_key):console.warn("Invalid dependency in effect:",t);return n.filter(Boolean)}resolveDependencies(e,t){const n=[],s=this.stateManager.getState();for(const i of e)if(i.includes(".")){const e=i.split("."),r=e[0],a=e.slice(1).join("."),o=this.componentManager.getPropDependencies(r,t);if(o.length>0)n.push(...o);else{const e=Fe.findExistingStateKey(r,t,s);e?n.push(`${e}.${a}`):n.push(`${t}.${i}`)}}else{const e=this.componentManager.getPropDependencies(i,t);if(e.length>0)n.push(...e);else{const e=Fe.findExistingStateKey(i,t,s);e?n.push(e):n.push(`${t}.${i}`)}}return Array.from(new Set(n))}createComponentScopedGlobals(e,t,n,s){window[e]||(window[e]={});const i=`set${rs(t)}`;window[e][t]=n,window[e][i]=s,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"]);for(const n of e){if(t.has(n))continue;const e=window[n];(/^s[a-z0-9]+$/i.test(n)||"app"===n)&&e&&"object"==typeof e&&delete window[n]}}static resetInstance(){this.instance&&(this.instance.destroy(),this.instance=null)}destroy(){this.cleanup(),this.initialized=!1,this.hydrationDone=!1}}d(ls,"instance",null);const Ue=class e extends ls{constructor(){super(),d(this,"cryptoKey",null),d(this,"activeAbortController",null),d(this,"navigationEnabled",!1),d(this,"boundHandleLinkClick",null),d(this,"boundHandlePopState",null),d(this,"isNavigating",!1),this.hydrated().then(()=>{this.restoreBodyAccessibility(),this.enableSPANavigation()}).catch(e=>{console.error("PPHPUtilities hydration error:",e),this.restoreBodyAccessibility()})}restoreBodyAccessibility(){document.body.style.opacity="1",document.body.style.pointerEvents="auto",document.body.style.userSelect="auto",document.body.style.transition="",document.body.removeAttribute("inert"),document.body.setAttribute("aria-busy","false")}static resetInstance(){this.instance&&(this.instance.navigationEnabled&&this.instance.disableSPANavigation(),this.instance.activeAbortController&&(this.instance.activeAbortController.abort(),this.instance.activeAbortController=null),this.instance.destroy(),this.instance=null)}static getInstance(){return this.instance||(this.instance=new e),this.instance}enableSPANavigation(){this.navigationEnabled||"true"!==document.body.getAttribute("pp-spa")||(this.navigationEnabled=!0,this.boundHandleLinkClick=this.handleLinkClick.bind(this),this.boundHandlePopState=this.handlePopState.bind(this),document.addEventListener("click",this.boundHandleLinkClick),window.addEventListener("popstate",this.boundHandlePopState))}disableSPANavigation(){this.navigationEnabled=!1,this.boundHandleLinkClick&&(document.removeEventListener("click",this.boundHandleLinkClick),this.boundHandleLinkClick=null),this.boundHandlePopState&&(window.removeEventListener("popstate",this.boundHandlePopState),this.boundHandlePopState=null)}handleLinkClick(e){if(!this.navigationEnabled)return;const t=e.target.closest("a");if(t&&t.href)try{const n=new URL(t.href),s=n.origin!==window.location.origin,i=n.pathname===window.location.pathname&&n.search===window.location.search,r="false"===t.getAttribute("pp-spa");if(s||"_blank"===t.target||t.hasAttribute("download")||r||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;if(e.preventDefault(),i){const e=n.hash;if(e){const t=document.querySelector(e);t&&t.scrollIntoView({behavior:"smooth"})}else window.scrollTo({top:0,behavior:"smooth"});return}this.navigateTo(n.pathname+n.search+n.hash)}catch(e){console.error("Link click navigation error:",e)}}async handlePopState(){const e=window.location.pathname+window.location.search+window.location.hash;await this.navigateTo(e,!1)}async navigateTo(e,t=!0){this.isNavigating=!0;const n=this.saveScrollPositions();try{this.dispatchNavigationEvent("start",e),await this.showLoadingTransition();const s=await this.fetchPageContent(e);if("redirect"in s)return void await this.navigateTo(s.redirect,t);const i=s;this.updateBrowserHistory(e,t);const r=document.getElementById("loading-file-1B87E"),a="startViewTransition"in document;this.cleanup(),!r&&a?await this.updatePageContentWithViewTransition(i):this.updatePageContent(i),this.restoreScrollPositions(n),await this.initialize(),await this.hydrated(),await this.handleNavigationCompletion(e),this.dispatchNavigationEvent("complete",e)}catch(t){this.handleNavigationError(e,t)}finally{this.isNavigating=!1}}restoreScrollPositions(e){requestAnimationFrame(()=>{const t=e.window;t&&window.scrollTo(t.scrollLeft,t.scrollTop),document.querySelectorAll("*").forEach(t=>{const n=this.getElementKey(t);e[n]&&(t.scrollTop=e[n].scrollTop,t.scrollLeft=e[n].scrollLeft)})})}saveScrollPositions(){const e={window:{scrollTop:window.scrollY||document.documentElement.scrollTop,scrollLeft:window.scrollX||document.documentElement.scrollLeft}};return document.querySelectorAll("*").forEach(t=>{(t.scrollTop||t.scrollLeft)&&(e[this.getElementKey(t)]={scrollTop:t.scrollTop,scrollLeft:t.scrollLeft})}),e}getElementKey(e){return e.id||e.className||e.tagName}async updatePageContentWithViewTransition(e){if(this.isNavigating)return void this.updatePageContent(e);const t=document.startViewTransition(()=>{this.updatePageContent(e)});try{await t.finished}catch(e){console.warn("View transition failed, continuing anyway:",e)}}dispatchNavigationEvent(e,t,n){const s=`pp:navigation:${e}`,i=n?{url:t,error:n}:{url:t};document.dispatchEvent(new CustomEvent(s,{detail:i}))}async showLoadingTransition(){const e=document.getElementById("loading-file-1B87E");if(e){const t=this.findLoadingElement(e,window.location.pathname);if(t)return void await this.updateContentWithTransition(t)}const t=document.querySelector("[pp-loading-content='true']")||document.body;t&&!("startViewTransition"in document)&&await this.fadeOut(t,250)}async fetchPageContent(e){const t=await fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest","X-PP-Navigation":"true",Accept:"text/html"}});if(!t.ok)throw new Error(`Navigation failed: ${t.status} ${t.statusText}`);const n=await t.text(),s=n.match(/redirect_7F834=([^\s]+)/);return s?{redirect:s[1]}:(new DOMParser).parseFromString(n,"text/html")}updateBrowserHistory(e,t){t&&history.pushState(null,"",e)}updatePageContent(e){e.title&&(document.title=e.title),this.reconcileHead(e);const t=e.body;document.body.innerHTML=t.innerHTML}async handleNavigationCompletion(e){const t=document.querySelector("[pp-loading-content='true']")||document.body;this.fadeIn(t,150),setTimeout(()=>{this.restoreBodyAccessibility()},50)}handleNavigationError(e,t){console.error("Navigation error:",t),this.restoreBodyAccessibility(),this.dispatchNavigationEvent("error",e,t),window.location.href=e}findLoadingElement(e,t){let n=t;for(;;){const t=e.querySelector(`div[pp-loading-url='${n}']`);if(t)return t;if("/"===n)break;const s=n.lastIndexOf("/");n=s<=0?"/":n.substring(0,s)}return e.querySelector("div[pp-loading-url='/' ]")}async updateContentWithTransition(e){const t=document.querySelector("[pp-loading-content='true']")||document.body;if(!t)return;const{fadeIn:n,fadeOut:s}=this.parseTransition(e);await this.fadeOut(t,s),t.innerHTML=e.innerHTML,this.fadeIn(t,n)}parseTransition(e){let t=250,n=250;const s=e.querySelector("[pp-loading-transition]"),i=null==s?void 0:s.getAttribute("pp-loading-transition");if(i){let e=JSON.parse(i);e&&"object"==typeof e?(t=this.parseTime(e.fadeIn??t),n=this.parseTime(e.fadeOut??n)):console.warn("pp-loading-transition is not valid JSON → default values (250 ms) will be used. String:",i)}return{fadeIn:t,fadeOut:n}}fadeOut(e,t){return new Promise(n=>{e.style.transition=`opacity ${t}ms ease-out`,setTimeout(()=>{e.style.transition="",n()},t)})}fadeIn(e,t){e.style.transition=`opacity ${t}ms ease-in`,setTimeout(()=>{e.style.transition=""},t)}parseTime(e){if("number"==typeof e)return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const e=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":default:return e;case"s":return 1e3*e;case"m":return 60*e*1e3}}return 0}reconcileHead(e){const t="pp-dynamic-script",n="pp-dynamic-link";document.head.querySelectorAll("[pp-dynamic-meta]").forEach(e=>e.remove()),document.head.querySelectorAll(`[${n}]`).forEach(e=>e.remove()),document.head.querySelectorAll(`[${t}]`).forEach(e=>e.remove()),Array.from(e.head.children).forEach(e=>{var s;switch(e.tagName){case"SCRIPT":if(e.hasAttribute(t)){const t=document.createElement("script");Array.from(e.attributes).forEach(e=>t.setAttribute(e.name,e.value)),t.textContent=e.textContent,document.head.appendChild(t)}break;case"META":{const t=e;if(t.getAttribute("charset")||"viewport"===t.name)break;const n=t.name?`meta[name="${t.name}"]`:`meta[property="${t.getAttribute("property")}"]`,i=t.cloneNode(!0),r=document.head.querySelector(n);r?document.head.replaceChild(i,r):document.head.insertBefore(i,(null==(s=document.head.querySelector("title"))?void 0:s.nextSibling)||null);break}case"TITLE":{const t=e.cloneNode(!0),n=document.head.querySelector("title");n?document.head.replaceChild(t,n):document.head.appendChild(t);break}case"LINK":{const t=e;if("icon"===t.rel){const e=t.cloneNode(!0),n=document.head.querySelector('link[rel="icon"]');n?document.head.replaceChild(e,n):document.head.appendChild(e)}else t.hasAttribute(n)&&document.head.appendChild(t.cloneNode(!0));break}}})}async redirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:this.navigationEnabled?await this.navigateTo(t.pathname+t.search+t.hash):window.location.href=e}catch(e){console.error("Redirect error:",e)}}async initCryptoKey(){var e;const t=null==(e=document.cookie.split("; ").find(e=>e.startsWith("pp_function_call_jwt=")))?void 0:e.split("=",2)[1];if(!t)throw new Error("Missing function-call token");const[,n]=t.split("."),s=atob(n.replace(/-/g,"+").replace(/_/g,"/")),{k:i,exp:r}=JSON.parse(s);if(Date.now()/1e3>r)throw new Error("Function-call token expired");const a=Uint8Array.from(atob(i),e=>e.charCodeAt(0));this.cryptoKey=await crypto.subtle.importKey("raw",a,{name:"AES-CBC"},!1,["encrypt","decrypt"])}async encryptCallbackName(e){await this.initCryptoKey();const t=crypto.getRandomValues(new Uint8Array(16)),n=(new TextEncoder).encode(e),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:t},this.cryptoKey,n);return`${btoa(String.fromCharCode(...t))}:${btoa(String.fromCharCode(...new Uint8Array(s)))}`}createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}async fetchFunction(e,t={},n=!1){let s=null;try{n&&this.activeAbortController&&(this.activeAbortController.abort(),this.activeAbortController=null),s=new AbortController,n&&(this.activeAbortController=s);const i={callback:await this.encryptCallbackName(e),...t},r=window.location.href;let a;if(Object.keys(i).some(e=>{const t=i[e];return t instanceof File||t instanceof FileList&&t.length>0})){const e=new FormData;Object.keys(i).forEach(t=>{const n=i[t];n instanceof File?e.append(t,n):n instanceof FileList?Array.from(n).forEach(n=>e.append(t,n)):e.append(t,n)}),a={method:"POST",headers:{HTTP_PP_WIRE_REQUEST:"true"},body:e,signal:s.signal}}else a={signal:s.signal,...this.createFetchOptions(i)};const o=await fetch(r,a);if(!o.ok)throw new Error(`Fetch failed with status: ${o.status} ${o.statusText}`);const c=await o.text();s&&this.activeAbortController===s&&(this.activeAbortController=null);try{return JSON.parse(c)}catch{return c}}catch(e){if(s&&this.activeAbortController===s&&(this.activeAbortController=null),e instanceof Error&&"AbortError"===e.name)return console.log("Request was cancelled"),{cancelled:!0};throw console.error("Error in fetchFunction:",e),new Error("Failed to fetch data.")}}};d(Ue,"instance",null);let We=Ue;const ge=class e{constructor(e={}){d(this,"state"),d(this,"listeners"),d(this,"pp"),d(this,"STORAGE_KEY"),d(this,"lastSyncedState",null),this.state=e,this.listeners=[],this.pp=We.getInstance(),this.STORAGE_KEY=this.getCookie("pp_local_store_key")||"pp_local_store_59e13",this.lastSyncedState=localStorage.getItem(this.STORAGE_KEY),this.loadState()}static getInstance(t={}){return e.instance||(e.instance=new e(t)),e.instance}getCookie(e){var t;return(null==(t=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:t.split("=")[1])||null}setState(e,t=!1){const n={...this.state,...e};if(JSON.stringify(n)!==JSON.stringify(this.state)&&(this.state=n,this.listeners.forEach(e=>e(this.state)),this.saveState(),t)){const e=localStorage.getItem(this.STORAGE_KEY);e&&e!==this.lastSyncedState&&(this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:e}),this.lastSyncedState=e)}}saveState(){localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.state))}loadState(){const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.state=JSON.parse(e),this.listeners.forEach(e=>e(this.state)))}resetState(e,t=!1){if(e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem(this.STORAGE_KEY)),this.listeners.forEach(e=>e(this.state)),t){const t=e?localStorage.getItem(this.STORAGE_KEY):null;this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:t}),this.lastSyncedState=t}}};d(ge,"instance",null);let at=ge;const xe=class e{constructor(){d(this,"listeners",[])}static getInstance(){return e.instance||(e.instance=new e),e.instance}get params(){return new URLSearchParams(window.location.search)}get(e){return this.params.get(e)}set(e,t){const n=this.params;n.set(e,t),this.updateURL(n)}delete(e){const t=this.params;t.delete(e),this.updateURL(t)}replace(e){const t=new URLSearchParams;for(const n in e){const s=e[n];null!==s&&t.set(n,s)}this.updateURL(t,!0)}updateURL(e,t=!1){const n=`${window.location.pathname}?${e.toString()}`;t?history.replaceState(null,"",n):history.pushState(null,"",n),this.notifyListeners(e)}listen(e){this.listeners.push(e)}notifyListeners(e){for(const t of this.listeners)t(e)}enablePopStateListener(){window.addEventListener("popstate",()=>{this.notifyListeners(this.params)})}};d(xe,"instance",null);let ot=xe;function gt(e,t,n=window,s=!0){let i=null;if(Object.defineProperty(n,e,{get(){if(null!==i)return i;if(t&&"object"==typeof t&&!Array.isArray(t)&&"getInstance"in t&&"function"==typeof t.getInstance)return i=t.getInstance(),i;if("function"!=typeof t)return i=t,i;try{return i=t.getInstance(),i}catch{return i=t,i}},set(t){null===t?i=null:console.warn(`Cannot override global ${e}`)},configurable:!0,enumerable:!0}),s)try{n[e]}catch(t){console.error(`Failed to initialize ${e}:`,t)}}gt("pp",We),gt("store",at),gt("searchParams",ot);export{at as PPHPLocalStore,We as PPHPUtilities,ot as SearchParamsManager};
|