From 7495d40d4df7f9ea087e315f2615bbb46a38cd02 Mon Sep 17 00:00:00 2001 From: klarkxy <278370456@qq.com> Date: Thu, 3 Sep 2026 18:06:03 +0800 Subject: [PATCH] feat(courseware): add protected PPTX viewer --- courseware/README.md | 16 + courseware/示例课件.pptx | Bin 0 -> 31714 bytes tests/courseware_test.php | 145 +++ web/courseware-file.php | 53 + web/courseware.php | 22 + web/doc/2.2 数组的插入与删除.md | 451 -------- web/doc/3.1 原码反码补码.md | 482 --------- web/doc/3.2 二进制运算.md | 595 ----------- web/doc/3.3 高阶位运算.md | 1222 ---------------------- web/doc/4.0 流程图的画法与读法.md | 376 ------- web/doc/4.1 自定义函数和递归.md | 728 ------------- web/docs.php | 72 +- web/include/courseware.inc.php | 225 ++++ web/include/pptxviewjs/LICENSE | 21 + web/include/pptxviewjs/PptxViewJS.min.js | 1 + web/include/pptxviewjs/jszip.LICENSE | 651 ++++++++++++ web/include/pptxviewjs/jszip.min.js | 13 + web/lang/cn.php | 12 + web/lang/cnt.php | 12 + web/lang/en.php | 12 + web/lang/fa.php | 12 + web/lang/ko.php | 12 + web/lang/th.php | 12 + web/lang/ug.php | 12 + web/template/syzoj/courseware.php | 583 +++++++++++ web/template/syzoj/docs.php | 193 ---- web/template/syzoj/footer.php | 2 + web/template/syzoj/header.php | 5 + 28 files changed, 1823 insertions(+), 4117 deletions(-) create mode 100644 courseware/README.md create mode 100644 courseware/示例课件.pptx create mode 100644 tests/courseware_test.php create mode 100644 web/courseware-file.php create mode 100644 web/courseware.php delete mode 100644 web/doc/2.2 数组的插入与删除.md delete mode 100644 web/doc/3.1 原码反码补码.md delete mode 100644 web/doc/3.2 二进制运算.md delete mode 100644 web/doc/3.3 高阶位运算.md delete mode 100644 web/doc/4.0 流程图的画法与读法.md delete mode 100644 web/doc/4.1 自定义函数和递归.md create mode 100644 web/include/courseware.inc.php create mode 100644 web/include/pptxviewjs/LICENSE create mode 100644 web/include/pptxviewjs/PptxViewJS.min.js create mode 100644 web/include/pptxviewjs/jszip.LICENSE create mode 100644 web/include/pptxviewjs/jszip.min.js create mode 100644 web/template/syzoj/courseware.php delete mode 100644 web/template/syzoj/docs.php diff --git a/courseware/README.md b/courseware/README.md new file mode 100644 index 0000000..b1fd4e0 --- /dev/null +++ b/courseware/README.md @@ -0,0 +1,16 @@ +# 课件怎么放 + +学生打开导航里的「课件」,点进去就能直接翻 PPT。不需要导出图片,也不需要后台上传。 + +把 PowerPoint 文件放进**仓库根目录**的 `courseware/`,用 git 提交: + +``` +courseware/2.2 数组的插入与删除.pptx +courseware/3.1 原码反码补码.pptx +``` + +目录里每一个 `.pptx` 就是一课,文件名就是标题。网页不能直接访问这个目录;播放器通过 `courseware-file.php` 读取文件。 + +请用 **`.pptx`**(PowerPoint 2007 及以后)。旧的 `.ppt` 请在 PowerPoint 里「另存为 → pptx」再提交。 + +动画、特殊字体、SmartArt 在网页里可能和上课投影不完全一样,但可以翻页看内容。 diff --git a/courseware/示例课件.pptx b/courseware/示例课件.pptx new file mode 100644 index 0000000000000000000000000000000000000000..a66d01f2f79db8e4e58732d6610f3e26c97fadd7 GIT binary patch literal 31714 zcmdqIRa79&mZlAbySux)I~4Bj?(Xgmg}b}ETjB0dxVyVM6fo3xdj2`z`FlZ^;A>P*2c-$#z|Mn z-Okuio7TV`Sx-ubd9S(*f%B|@P`EXxmpZeQ9&QP6$d z7K|6OXN(~S3y!y0dOfhwE11KT2Ll~V}s+idh3>cN0z6! zoW~cKQx7P9f=K5jHsh3?c8beAVHB7fHq7XfH2BfT!9Ky|7}uF#Ud9n=h}XM)9MDhz zuC}T9^Pn}D?Gt|O2k%O8s$byX%|pz0w1z5slkF)1UcRMXD*t1jZV_KVxxc0S28Qh% z;49@j-v9uhzEZC1U~J_`NBd{2n(dVUVt@zTZkI)HSW#rNMnO2Sp(DH}Rlw7eDsC?m zHxVnY_x6;J)mTZ!_4qZFW6P*c9g03rcDPHyvQU|=0+~Q^q`0JHdv-J`SQO6h08g&3 zcu}V`{%CR&4mhAl*?E*7g05ihMAsKHguG@Lq=00IX|OC8jbBu}jsf}xh?D-}lbqveCHW79nfoijWYgbwii8fawrAYi7cbS*I7D9@qSY}y#$xVzJdvAYWkb2(W-;YN$7pA{ zHj6jI&$zWnx$6`{upczpKQO+xwEdEq0~Y6`!Mf5*d-OYLeO4@!qr}^xeFcbv)|*`! z(l6_CXeNauF)UrwBRS;tJF~hwFGvb%jbVXO=p4gb?jV;*1&P;)Hv*!ELb7ibwO}FW zCuJq#rvimhvkQtm%Ix%n$RET*6FCT+!#oB0ZN~E>phNLf4tQ*RG}O_na#jI9(r-pj~<{08N9Q8bE69H`vv8^)Co3~WB}^eAXl zMZ)ylYCARXDdpoJS1e|j(^-={Yc8FKy=-mpz5?fx>Ulf2mC$nf&ISk`&YaqX<~j*T zmXq0-wkp`c=kBeAGY`^T09}26>0NilZsoox37Rzc*Gsn?EENo_H3maM*j!C=PnHbdUQS~+i{de_WXcX< zn3_?QH*FmJ&g;PQ-lrC-WkIh`y(0qkDbeYU4<-xcwSYdK#>8^i95^=l9#r0o+LwyG zDrnifulYk?%7@IXeF25G^mQgbYF9hi8{X}QnPsJ@4fu%SzzXk&?R0v1b=S2TE)Hn5 zkvM`>nWhpF#V;WrB3-Z~@i@QV`kTJ$7!8uzc#y*c0=S)xAl*DS-dIGq--Lq>sq?-Uy=+MiSbj~ zs%NsDRkf;B91FCs*ace4dbZaS6gBAqi`cRD5%V;?0aw9Dp6r{4DdSBAJ_j;oIo@Ca z+w%^+;B*3`xJMCB>g)+Tlv$Vak%6vuip~+w%v(}`KPaW@UN6tH>Su2@>ueE$lhhv_=s^zMbCHQc10=rA~fn!OF zZlE52?Pp(Ud-CD5eE642{$(UnDF0Q(chCR;f3(le&WX;>!PxOj==7b;ZEgO{k&Bcy zn*w_HkgF#O>aBf)1qbkwT=t~q3W=mPh514_`d|nF7S{SK>XW$|XyRBUst3TI{U1j; z7`&Q8)OhLP2}G3I61^syom@oZjA<$PdJQcXbJ~nVt9~Q?lKxgM-+4UM-qjY(tKo%nuAZQi zlEy(kAKB*ARH-<5$CnFJe)L;7BLhR>F!EIg9&D5w5>Z0Q!gSv8Qr@)5>BF$w=Q2KM zW&}s`sR=t~f4_pex)a?ZhRT{(e3Ab2WwS2=m4IX=Y=#^HX~~&_p#&3SA?-V|0MivE zxVhX@mtlC4))I#14Gus0sAIkt`?n&j}zxAa4>oL@ZC%6xn?%l9ns4L zOJPbmx@0au9dHp25{}E}>#i3gW^ltT71fXy0&u$BlvlH*sY}EeIBkhX{BQ;2v%rza z1ySu|S&`0x!xw%MYUm|erb3NdMqf$}TQC>H9U|3z@J#tRrwVtZ1r_Vo3w%KlUzOcx zEG!6$z9_$Gh_o&QMxJfACiYCI7~CknTn@q1=Vzdtm!6WfWTYHei77JlXSciM2vUAi zN}gOhVDg)U<~ImAc7SkD{;nLM3st>u$S{7p2)XR3vZnXJ5^&@g0P37`1m1bGKpK$% z!us4evv$R^I>y~P3|VKoNeg^`N0j3TDjwArqC7zW0Py}}3jRZR|8*k%rNo`{oihFO z@L<8n`{u)nUQi`&<&Qk79CWh)oEB^E19VzxcAOrcj$^ ztiS-18q^bq#0Po~tL2&}@>?F}9+(ZpW>FQmpwt_|B2n)uR;bLx$J8qmMOCn@8TL@( zeBr;{K}HTNyVo|&Xre_DM{1J?r@XXN3q-~n5q@s~%W3hbH;%ihrB?X0=n40Ea?z}r z)L$^p2d&0wAH-h;>6R=8&#pNx_szHip_y{_Cu@4dT;)tGHC`eKI2FD^^8is*!wiko zUR3>2(4Ky>qHkJ9W?nWz96j|ge&SC!{+W))M|5ENh zb>1{9YZ*w74to8jwV$bOti zG2|Xfb4v6jVl6`{JB&)cu32IUE*njYHcVop8X_D=KR`-G=Dq4DXE6zEFcK}Y3`7zA*q-`wOEu*K6O>^<9faT3Mm#)` zHmr;3pJ-RVf2|31*OWX1|9x_sGLc3Vd<8uK=pRn$PtaY=ja~o0phqc6+pf_=cfu|E z!n@i2_Fo*2B=1DtDC&VEUeiuO*9@eF$d6}#e+V?@vR=jZnDZpY!xJ}i-f|7Wp^tS* z7OWfb&r6aqU$c8|@a|CmRzO~fIHbOB_dVe4;mMXt7mpb?2k4B;unZM@72P|_m{{{1 zm?l$n&DG@SI~gI3mKh_;fc#o9lX}{b@*;$_emR_OnQMDi^7Hn7mmrpCoS%r$1$EQv zT;*YR{vio!tdF=Z9=ELE6vPqkNk|Sgvp_`@n!;MhXm)>0Ikv~h+;42css5EzR`jl~q~g2T9!xPqlq1(6)o3QLimk))bS0aG z!3aYVXAQLE@xY?fS7Nzf)ULtyH-Dq4m3*?ScV6bq_0`8G8IPAHGmp0c(ZI8c_t>ln z_0o;MeZUfh5CjvVr2H9krfP|ffcqo%c4XM~t&?gTodSj%n3VnICY9XF@S-2Cy1zVH z{QI(f2x?^>p4u7lA=IFz&xEDibg4?h&usH42LF$?$*jiGmAhc zUNWBSrN8UhUbLx#Gj#Gd6E8L7Xwjm9KVhlJhy;GG-L$OIS|h*L1em+~IXO9bY0^1u z3J4DzbkvntSGDQT$uy(>&3Mv%V?(2Tv3ytZHN){aNv32@r)-;s+_L%bdc3J<(W4-s zCAV@V`>DHO^MY3S8a0t6IcJf4r=X)_! z!T1rA!}s~#QnSvl4chg5IGQt+-SPYw(e2}P?pGs;p19+k4j*ijAlOKSxJ?UWgs&@` zj|W5}S$QW02u8HWZ+rSPpo<3-6jm!#38RCI0#3UpMg)!$_G-|funfqJN`|t>nm|od z%v7o+vWgLk2)8wATpptZ%5J-UBP(rdQXVrQs7=YmP{H0Y6mSV1L57)eYJisjw(c!a z#ciY5A6WvLrA<~ItTZ8>7ssq+S~?vdux`B92O7nu`6@43kM;p;KQ|m07tpbcxbpj+ zDE(|KJ5NYZQk-V4VM>ChA%+sTs>Zh%a3nJ(Vu@Cx%Mts*4b7fX&()R{_A9J={x$@mD+8lxmeB_tkBm(rRBKaVDLz8q^8OsG8Fz5PW@1Ie|gH!Rgz3QhxPL z@*%6Z&-d#3y~<59tn)H$y+8~lyDd1joQ=y=Ut~p~8Zc8UiqU{WrG))F_jA0`a1)v~ zUT;kd@||MgMhBYW#(qQNhf+1C0y)aqFiVGAOJ{{bbwl0begH%T^TLg@9P&+u>h-CRJ6(QeNy06%u({EjM>s>>jo< zyuFf6Vd$AdzgV!V{E?P2Go7@FQmHi&++fv1;;25D&a`CKGS#+FoNH**<%KPWQG0UJNarG+D_=K7bg@TO zT%M+^1`X?_H3iCKDYD?}3`u$3)!Segc7FJ+UY6C>r+y8#dW}r+VzQ)EwJmgcb3I4F z;Mxz^BM@4DpdKN~CRTrOIgWMPAAHz7p{$bFNJvV8bFba#hnX95+9HO?ov(NJq!$~L zo&gZ%B~AQvAa{Cc+zSs8dsYfp?d}} z?k6jpZ-)rvWB3sd5OZVZT151_cBTFevqJ|c!Du~!0tZ*=0Uv4Du)k8uc zIXDY2{*Ef7Y#WrRSw`Hw@1;WzwbE>hLVQ%~uG_Wm9cS$Ry+){>nq0LBQ5-|Qb$fx3 zu0log1<|^w5anR3qm!j5;?5y;y;jM0>hR$xh8f7cEjrI|4Yq@wOt2s=It`er&wxFH zYr2iS1=DVBmQMAcs!*xr`812#cC3t<$V*L{WMmGV6W&f?8r=eL6zZL(9=g)dOwg`|kA|ke@~hpI>NIO~(~oOa@74}x-2|l8DezE!I?AI3YmwrZ zK_$|g7#BnfELjFTBm}zltCO-u*g+MLc5_rABVXqfRK7;nHw7y9QW8_JXo2--+Z=OS z*hLfM<2R$Fabdv64ZAg7g70y*Y-cXm=c|v8r=zurNgkrYfKEgq@uXwy-_*5L%R`#s znTk9J59F#u2|JfY(!{Px6u>gWcfOCrz}G%?gzN9?SqbJ&1g22{*KaYcoyuELr|O4Y z8xa^mBauvM{fr$vPza;8HBo{qYga3>ndd1mStxb7f{DWo$OLHki0?h2Qi zq{FcfBMmGISU@$VlZ)G_@P0vW#^Y1<%Dq52CM*w0ay9)O_X9b#@WN>Y(L{v|4?|F~U{<-ggStU|y42;2m1a5ktU~ zAZ=bOzI5o+$OBChaBxCwYBj|mR&_QPH`ZEC;=g2Fgk|?We^R#^C)JQ9ws9#v?dCe9 zuqV{*QE+pRgyRv|vQxwdE_e@Gm|;ze-+H=Z7z z0vv3Z*W<8Gi_hrI$n7NNW-TTaG%a3>hx`mL5J#adI>?v&~wL^s{^m+;t)hO zbvYSV`xlqcutFciyB|iel1q@i)KD96rtV>P(oiJ%s3W|8h3Q^ob{(~TZkcQPT$p>F zOObvo7&F&i*fD~OvSSM!&*DXT!R3(;2(YJH&AJrv#Lz{cnVwDMd^|jT4c>lM)(^Iq zPF2-Z3ynPrhYY`+nZv!9VMPPu0?B~9P(T95!>(XRvm6NVQr>nH7^QA);Tc!V0V2_p$2e0Mp%SPv3bfY@Ta&P( z>a7~EB+;R|(F}v@4LJBs8*&I0AXR&1A+T2NC^a~1=|Go!>b*)olQ8cL1_s9NC*^oH5%GNom*h*y(@kbLO)98@62poYY=6gH++s6L!OYmar=Nc0C_`kVjS0Tg(2ln zPkb2VirPS!#PDDo-xzxOogway^2cNr#98OW-z$P?Zb8Y2r(0z)zlBQP8Ct(#$-N`V zzi;(MeEy44VvOIszTqumWFs$$vS>YulQ5YLbxrkA4 z4Hzj)sG}s{D2_!lsArS#G^x)gH-p}mUg$>PN9O7my=MRJ=!R`B-+KKQTO}DLr`q$? zcd7d7Z4>@;Sf%vcZJnL|!+`wbhT$&<(xf_Rv&IhJb)^Wu8Ymm?Lp@rLP*l5Ls)jEe z+0^c;QfQTrJW67&x|z?fYx!jVN(`l-lF7c=)7yp?mT$uQ%WEr=rORiD71^pzDX75; zUh4(OPkj(UzryO;UcK!EfE)%RAdx8(#zhTgbK|!I4QY5j*UvpHnAH$Q7XP${MGYx# zS!K(0e&<0D6Kg?BTCCCqloTpB@#o-LWx>wrC!`wxAP!Go_h`NvONAYb8deySHlVoF z@6zmwmV`<%q`w4^5UC~_AAE4*Hz6`PG^ror&B9BdX*9vqJX;6Tkl5Ll3>0X{zd^II zJAU*iBtRu(^Q`=Wmr6Ed&)v4EAcv7Gm&{jRYyU+p(fLh1wy1k)!GQEv7yX@e! z*1VErHa1yJWG%6nF%7%+{LDK3~E}!+veezH(CIBV$7Q6 zke0Yk)xrCT=-TmG39xrnM9=Ny&a2@xn$fOy#WDjr2B?KN;Y2pGS;5p4As9&pArWtf z{i1!kLoN|=;#mEi4|nA$B#=ESkUcUc?KpQ(sD(q6Ywta*U_&e2WHv1@PrNIzNP_M@ z+Taa;Vi1(%2vKfCB`q-R&3*@9;W)rx1ovT@4TNODG?%02huJkCWfVy*GJr9@wAd=B z2?2wkBl*si=!o`l-_XXerJ|em@Qx%7jG!YVRmUN+K183Sn8gn+1!VYn+{`Ie)^O1s zsy)*cj7aJi1bd+6uusOxc-xT6BN ztsgqKQS)aFI|VI$39rPjMVi#7npU7JK8x!8l1`|zuyVe}zc6Rpt|&eqif?5WK75rt zrQ;@dEi=*P(sG6_tvRLFnWGHYa)euK;zWfR9`@|jg|=R6C<8DpXSd@kSrPfHCPZ(! zmA}zpyZ2t_ib>BLu!MO^OZ<{X<5ebU3!-dF&Z73U$(>hw90N{KJgko-<{^TTfCqib zIGjVEyCHFtN8YeaPnZwl%QK6}rA}CJI)C-iXfwwxx@6BJwaFgPXO}6EPfv*vu8=yk zn#@zIXXto0A)UcbS3+E~e`1@58xy!UP_hvtY29t=DtBwhY31qd)}vsrGj!d)0z05# z=Gzp9581I}zBKNu8hwGULh#YQMN0@DgOlU7vW{bZg+B?3cA@ciW4JJkJq zr_RrK=STZj-Lrn7mF7RI|9`^jKU3f@u0~DO{l(SkPTeoAmK&Lp7peVHfW)W=egX=* zw~7$Eg5V)x_swAmfz_rbr_bmjaj%T|&{=K=8~d+Nr< z4aDE00PubeL-w`%3-Yy5|F>n>e@4MSOU=pDjpz(^MUAiN%8XTv!(--(Ni%TL=qXb$6PZ#wWKt_q0HsV~y=YlP!vr zxg4_BFUNw8Q*9zP+nNmu2PSpw8eAlP^Q~TK%Zt8hi<{d{SAX}qNq^}mKMkOEtFs1I z%t8_%S79-AP;7CyUhEpur20WDm9`=qH=jomR%9U@1`?UJ95--VdB%28sWyX1zaBf_ zF^#Gxd={UoS?>)Wbd0*ziF8q}4au};(}J8!+Z5_kd~na^!8B*gHD{MCtqUj3y{4K! zqpG8aMHJH+8S zxD8$%xS{Gb^-PhCRvS}`oZH)6Q@-0-g@+Q;6LW;)B)s;xaKH30BfV+phO7jYJTDkN_mQQ zx=`>34pvdTr6&bZ%ndkAN*$;V^*%;7$Q;Bg;k^ReYoxeKmz^972OBB*;S`4zJ$e}T zFex)FL=EJ53h`jNcFx2wy}Cww@s#uB_t7t=wesuu?!$;|mVxaU-+~f-Q7p#T&ArDC z7*^IVE@s;JTPTqo^S3wN@bz)vXp!w_VD^yS;4a4-@JJCoY0o@598CWbvL1PK-DAlT ziuT9ROZ$)u9oY7(nys6i+C92jLOpSN0oKf9A-`>GF5fb0{7;EWnBs-nw|2g*kF3vY zW#yS!p&JsZhL=9!Jnz86xF~q&3nxI^bLwDqR@Z*>?B1IGC66!^d1t{}k4}_*pNh(* z@&gW^bGP17G2!t$OGMc8{me55c4d%k!6b<=nPk2eHF82w&Y2;-eZ%!4XMd|TDv17S zo~*EZcx&nQ{rtGdVVW;@^w1*lbf!|?`lcyQwwS`4CE^pJ!1bVK(?7`EeB_S2>Wi6>1s(e14P4hD`xGdgoS2?Q(>cyw5j^ zFbPrr#2JY!)>S9moCI@Mm1 ztL;}n_%$nTw<8N+LLwSuJvTZW+9yrQZ$1KFn7QLrKWuS(`I}Fc6^&h)wssjY!`1)|0`Or}=7N*)^g*9;x zC}aT1vLm%1R0=4a8AwX3l4{=m>Mr3yXLou%%!jQPxDQ(*v#q5YCfu3_PQSc8?~b2t z0D$q0!xWRr8Ys~%7Ci%Dtuw`dXmPf>eXWWFe`Ndq45!9-CUix#xdG^E@b-c}D55$( zs`ak?oA&85>~cnh>7iYTfO{&nY=g1)r-YUIRtMq*43?WLD@!Hp=(`x1Q}!qVwmQrU zrTzH0EF}Gh4y52G{}sCZw$)|+WzrI8c??%aW1u2qr&`-M`)Y(a=wn5h8v zG8=OwjO&dP4F}A!SlA1)(u}y(a_GihL+OvEeYJ5H)pK7+c- z3xB0hXH4~RkFHbyfMnB{q}woNh}a;^7Lm^;8TazITe#N~Xe1|T_TI2HI|dIt4$ZD5 zDB2HKea+vO-qP|2@EuaHGk6>Cx#H@>VHWMD{!uJ|JS475x{mRy#7cUHEu>p5QOU<| z*T+EbQrq;W|N+bw{&2)4X$?{@QIDrqQ*6JvrBBhYa!KeVKjiy#lk9+VKH7jYn3io% z6b`uT5R4A|5|-VL-Bh|4WR9IXw98_gzxel3eQTcx8rBb7C`yTi7dd)G1j)}EBE=^ zZ)EY`rBj|q$9KWZPPi&R61}@ya%`U$6|G<7>6#zyX~gq7pU+EHj4VXE+;OD8F@@*a z7Av}0n@~*Dhg}ReK>M7y0)WJ;sjy@#kFyNBTAF93!wx$Lj^BiorWCS&wxnzw84ab5 zJ?X1#bJQzHY!)BHugSK$lrKc)0vnELmkwCq>_Ho_OB%@F@< zYsvhF(idtQe<l^aZf}b9aOpraGd~=2xOm-pqJi|pC93NeM8Vt00@sb z^9@17o_kr3!Oity+?WZW@TUM)bG)855+x~lbFu;}(lEjc;*ywFE$E!Hw8W4l@gT?^ zRLS;nU4BG5d)HZrOcbTX!`TbNnYy|PM|Pc;vLPiGVl+fNN`ZkoOJ6O^a4icqlvI&U zr)B&)GkfzsQTy9{C+zM}#_xCOQ*Tnuz!q=ZzF4{Hd4!)l>gFgO@(&86)jmjSY460B5UK)aBBOg2QW#fR2ob zmWG#G8#q>7ohtz@6QHA&;<1WfKbJ0_hq6K?5TQHBY9c%HTlHT|0m(h5unv5VHj(o0 z)HgDU;!)p(q7C#QR zf(X$l1|WDN3h5LTj`0DF0?<-I@Zu9NfUTnABNr)%T0}9E6c6(39zUT?WQ9kuuBsiQ zL-obdm2tPk%tunZG3_b*qo?d6+xkxlN^+i%x?b;~;|zme$^ za77Qc$q}Q!4zy?YN|V8P@Gm{Fm+aV#{FWl|bs87XIfIi6U>4CA4wZKp6Tp1b4sOvq zn&s=sGv?XFvK~MoNiRVqU~FMpD%up$xqiiy z3J1Ek)-%lCHEpcimfCl+HI@XCn~-ao`kqu)w!s(keWCG27oYYP#0e z@4S&y3a53vAmW`k9SeH8qKorzgz0M&Fglv&fQwJ&VTRNpyVLoE{zB@n^1<-E_N3P- zM=d4pVLXmaJFK{P5)|%e$$Y9mBqyYeI_`uIJHjI)2^|$s z(ATR^W$BzCrt%{22QSJusiHplh^}0_Q0d_i9IDW z^0-SXUXQijKQ69xyM5n|pj%J5ZNayjIuPpd{84HQ&Lra_1^J>7xo-4K`d8eHWE<#f z8}z{S(}m`o+}@R0P`TMhITo|Rw;<>CuD2^_MYRtyAymd9G8eqt2h5j=4q+;sh6fzq za782LEA)|Hc!LbtPy2(G#*V6*D6bt4e3?ceKK;_$RmjAvwj9f{EhyWL9gU#myE0H` z7P|kZQ2mQ4|6Wi%DIAE|`hqGe_J0jkmcO8ywqdjTkJf1Axp2+wKv)91*(^e#aic;> z73d-0`hfpAyUQX2vJ3NU$KvJQL_#GtI3Ogowwig-LCDY1(J5ZM56AGW&KwkIsj^Ck z-U2E&YhA!Gq_{&bWNmNUM`0S6oEt(4&ox_WBa<0>&y zkOK?AxI}~`D4nRgdJD4yhDL?ia0lh?&Q@X;I&-5^G=@wV-GRNk8qm_HgG3QfW}D5V zETbNU9&rI8B2-~<5w^Uy7*b>ZIubJ9pxMY)u94`&H z%Bm&N$yg_oH0pb0BaBqx5Np5IkH&i*PDOn6b*a_%(P#TmYsRiMeQOpZHOmBx8q^5S zi|DzZOcN*t0M#89i<(JKgf9w!w7eqfJ69z?Baz8bDUF@%8*cXvGi%6SGN z5W2y#8w1p`T>vBi(vBd!@e=Y7r$vDhNG#e5j`Lz;b7X|0B{a7N!p0W{doc^ZUcSp4 z%FE8ba?r(()oK$Zwlj%clZ_GVkIlJ$5p zOFOwz!rGo_loN7Z-sIh9H|=8Cg4ejQ+6QLc@^~PyRyFA|{n%X>*jy51o9V!h)T`KY zoLEnE{R``+-<~$6q}{ggX;7&AX2$Ja#Vh-wFsGgC?$O2c*lQz=c6*ET>wrlL=24gS zp4a|Lv}>(upuo1aN0VfY%gMsWQfInvsp_4~)dFh~bQZDk+iR1`814INk#76FWr~k= zp0z-Mb&JppjQ-u!Oij_)@`o$(YRN~Jc~xIVUE||!#Zp9j3+v+q*ZPBWWSr@v%}f@? zlN`3IHQo8}vF6>Ii^QMvFmEqrgeQAK7{ewY8ZvqUEt6tHvv)_pY#b+0d9FJiDglm0 zB#I8INH9BpdF~)-Ay8^r3b$0`DNXy{qaTukv!UX3Ow7N!#*ge*Gzj=?z@%8$=gKn~@%DI?MYpa=e048OOiLB|= zIp$)xOyl|SO4 zb|!>8K1Wx9OsAAgSOeFS+sR#@j);n(Zzc!_W>clE(%E>ZL8o%$ox4HD1(AR!{=!~m zSyO&VCY7~6 zM+m&PYVd!;`6xKmS&fS%_Qe+%_%kz{-UF${)rZ|S6CaGxK;E~w@RjH)#3r9JPkwX1 z?h>1~GhsiP$uk zU-d#Cy;mq~eN*n9R4T~W&M%E7a6!c@aM42vN5a;eO+=G0>dTgl6w}cOD`P&Ih&|ss>HNlt_H)ovYc z{4Q926Mm-l;-a3(w`6v8U1820*9Y$H)fO}*$^v~-Egyu*#Skv?8SH?z3%YaBkDzXn0HHS&1~_Cb9)VaUXgMQ(<`t_eZT@=%IgQQa%~_!iA<^07eL zv%{EHa@=UoNQk^tkM}qq?;c4fFkQ&bTXMIU^erE=HHPYfQ&T3Ge4?^|N})QvZ1P-g zs!Y65c2PrRsf@HGw!_S=>eK1h&iwC}y|-?(=zW(XRxve46lBQ%4*2nVXj-2ki z_?$46_*VpM(f8?fqU3&c#)$Zp^ZA}a$JnVs&J8x$E{%DqZoyOiE6<>}80!=1@Nnxb zLQ^y_@8^S`FaNSD{r}#2{j0kEz2I_&mg9Qy^*5gB*SW9%YQKo>FSscG3tY~{{tsLp zfza)Zpbo6X$C9v+k8Lk}WV#D;sSg&ZW5KQ>m@y}zk20Cibvn-21wE&W;|Mc?OnZU- zONp%qSTnpnlsra(F(iRWq##E~!RQlQQ+%~bgZ1yzv5hR{htuex;&-x|EOy?CR{_Zm zr6}QXOq=F2)f`D57E98-tOt^r_#gvXr^Jb_V{5kJ>CW29^hhd_18au~G12RykWH4z znN$>Q%Zi!N;hU#?Hsg87N3L;*cA-SPQ#S=e1ijqzP!~eviNQmmkGz8%F(1T%*d@=m zESuylH-XQ}T${CP%?5Ja%ghR15kr}r z58~f5Z_FUtKKB3?%T^#2dZnJ-aOgklGo{B!5TMM zv#d9xwrhA)ArKj4=)-Rw!H9&c1pp$zC9aK6$NYM?J2h+OSz#&YvnpXOLT?b>N9Gda%9$fzF^^0@fGmCh|K zI{>Z!SbAKyi1ZaNq#1nNp-ZD!2cEbnW#4|cXvX34;7%R6NZc!X|Db;wGgPbb_hiHC z-7uf;$M2gf2$KchHq^X^r6E{U3+IHLH*VP@`M7-@+@T`0npsC%^D;UlsH3 z1&qnD@P(gW3)a5>Mi-F%4=^UxW*olG@_f0G=~_5ASNBINwyhjE*M&EpCm-7pwkJ|DScLUV5eeI=uvyX%&Xx-Z=Arff9@R7#@ z8a&jMn)EB8^(%nOAQIZ1rWE5d!Us^hKksa;0b!6}!f4F2JIX{(GEMw;;s;dv(uk!3 zrh>HsfK|iA4Np&H;PW*q-O0+`S&-V!q?wR%N0608^*J^oV2eMEqHNeZFQMiJ3Y=*r z9wzUwD-Fk+dPKZAPchUbW1HdTLQ76=UEo-?buPYofdHnaaz*7?>xLZJagM5D5&-Mv zjCWNPmf1e#fO}U$Mf)wc%|BEcUaOO}UyAZi?JguY+)^htC35w)TdRa@x7!73NW0EN zc<(i<;6rpmmzCEURf$@&udNC^w(hK$kN_H-Mun|5S~44x9b5B+TCgCgK=PnaHRlzk z7~_3YA>@3+Xr`1M+t~VAo|`-S70ckNBqxA#Q)vt$=->9%zd2JNNzku(kkKJ(6z2Ht z`xylTU)j@y0kqlVsziospE59$=&wLS{mvU+|5ZA>8fEfDw(K_*TeJysnbG*UNbv1W z8xZ7`S3rl37aw}?#Jp|?K0kQadCvnMco5#8kGjjxvD@sqE)8#<80R_9$cKFGO2Fxm zSI=5AG)sWSJTth(jX_KRYqM+QMF2Cw{*teTAr_|_xvd2Cp5~RjU}tzb9jinjw2l69OD2aFnOZWo>PV0ny9;OE}v=Vid~2f?#w(M zwBB)7#(d7{c^44Hm77tFpU9zUWAKu6+a$%U3!s@#>2olIe14aCdoaO*$00Sa>~aS7 zRla!0)I?I{#g|QOJCW?2?+`Qozt2h|!wa4}fG}2WU5tdm!l2#c=UXMSOn}_UfEq^#Ur4sXDrQaOm7qG&=rzbk63bPw$q7_Zf4y<1UVz zO58RO|2t9W7+E}VRFngFqhDa38w2fEb2Z0gV|Yz3F^2BfMw71a-gGn}@^XTtlQ9`m zBC#PGx(w3&>4PqJe?tA8xZ79}_|lSFG4@U}ib-iM!jWolKjHmE@Blb4## zHS|crmtQ&4{#SQr85L!_^>IQPDe3O+5(McGkQjz;P&%c%B?Y8YT2dOMLApagQZVR{ z?tDj{a~^QS^FC|6pWZWkU=6J6xBfG;?tNdgul?T}S(GK1`tV+6ei(Bgv>X3@XgB<0 zc&ccVlw;K|W6CgMSxRUgaJ!O5R`R5-_FjtE`Cqw)7F~M#Hpx5lkB!Ocbyn(eR~)Np z?yEHWP%NM{u)@o}e_b_l&Z=p6uC-bsL5H>V!eM4bTyafIc0a2?FVrfGUns`W?!+ho2jjC_5AbmO zE$JUEm$w!O%-ep$#1M?J006FgxY+c(Giu^D6i6HDOL^+tQ~(d;3!=mV9`aa}JyE9F}P^VymU{5lMkGKUp)- zDbSj{WEuql%!EE#IR>a7Of`T& z0zjDltcR}>w_qRvNAvMXD$Y#ey@W*>X5hMKV0KlVvZi#uv+Uyx(G}mf*j4+rzWstj zlzGi>o(@uig1;gt`1cjTtVx5)KHsyX)^(dCdclCoK4TEw zTdT-1654$^FJx-|_RS@XAh#RvKeW5U%NcOX&wY6X#BT^*pI9%=`r2RShbfuDq-GoZ~J(Z=F*Z+()g{RBe-=um>Oi-d+FoB1IS1{e!bje zB{tYR{jy?cJq25$*j^nHgW1yb6l6s_R zt(uf=h2nVr;x?h6V?%o1X$tm*AW`OfYT%$lBWfYWAt1Iks=oZZwp9^*N~LqXg#E&Z z(u%`Yrq9=VUD?4aCO$8sVXU%7M|mix^9nVIdoO3ygk9QVLL5jCMppj73v+6ocK_mD z3vO8MSx!-v?fU|`%}=_5SEm;fL(Oh0%FEj%kEikqHMl5BqYTYFNFt)UhlVGK-E7R- zq%dZ(OfjcNS-n{avH;jxm&1I}#Dq&x2~2^4A&wQTe)8`b3fSWtmh2qj_6nwsZ0>oH zDsGQhcsN^CsF!teRzdk=2nI!wn)ZruYuHt5Xdi19=_1?F3+lh9;FeXylN{)$1C)!8 zQfLQ_&ut!PokRa$BlmUa`tOR|4?DSz!$CR30Z>`!|LQ|x{VR$1w-0Hpg+^R3j%X@K zQO#C~@in#ZkIgq&lH7ohg{VpfYe0HQ)ftaR6pU$)+z6&k>0Ia&KwAXImxmOCpJv|c zn;=O8TPlR@(NWO0rO|p-r@qdY?~g)`z}opHetmu4F&)mj#H&6EIMB^B7aS&R*;bSK zyjeq})FMHp(=%Ab>*&g}UskB@n3`Nj9 zEW5STeQ1APVJ~m?%2s5i46ebaeQ%*kIhs6j7eoYTtIw>?($T1}i$r&PH${z?bWX-) zeT`>SFEHh2G`Jiw9m1yjkseo841FjTHdm<9eHUK%>GTq2#>`{S*I}3hjsMY@M3vL# zvW>wO0^LWlf;n9#Yw-hh3g$UF)3z^xPNkDw7Lv7_l&shV6*FG;(ODcs>Nx{2Q&XY> z2<3L6&b^iD2}ICG33)`Il#m7@mBDgduAy_ zwv0T2JyQORP!a`$$K?Z}mvcaaG2l_I8>(MwtL_8djbQgE;EK;T#BpDA1zG{P+BkYt z1aY5akN0jtQHM1rT(4%DgL?QsjGJ!ZoXf}z#}NfxM!2e}q!6A46T1zjk>EA%cEc$7 zK4{lN+PHUo91C(5Dd%RP>IUnCgt4zje~X@I9X%D_w^J1vQEeq8a8`t9v%`d7BOdWG zoWrlElfT$@_exGe$LW{===3k?Kiah(nVOUzeZH`~x6sM5n@wx<%|sEqr}}c7Y|=a9 zevEw;z^1t@zQ?pcOxPVytSyV2i(+}=`IxyPqJH6a8GR40QhwNU-|jLj19X8Z^`kWQ zWy9y6Im-27AnIl~(^7ZXAHlICMb^vik#p@_y{;5jikm;N_#UXQacY{HeMy-bcHzz+ zGB1^+mE+>_M8lF|IeBS83v@EF^$_GNvJ23IoTO=4hc``|U~B z-;rqP^2}wjO3f*&Cw1;e)26h?N0%`~d^j187}R7qZ|!8s#R6`XHGHX~H2wTowT4RS zq@XV{D>$ritF7efKO`dlp{wZnn*Q&KX)6m-A9+DBt%4E)g7#nDDjQo_+^p_6JX_40vD;RmbfP) z_td%sMw-5C0-+!u!21)AQ?9|lba|d!l<987ABAK#05KPbKvl?tUb6fLH0Y3v8&Azw z9Av5bmrx8h6S;{U%yXw})wu*5i)XU7#^0{FaYB5;_xf=(U7#Ym(t7mRSHXA;P~>UN zqe$RNl+ni^`^gjHSQpLJ({udAq)hb*LYT_)rAcS$y|--^(TBQYTR;=$99TvChYbJ3>Ebpz4_5 zVVS?PVNpN`Co(vAEgbDN!D@V-c@PDas0Ht1T$s*tPM}jHq^u*&Ku8CF*gqcWlNq{i zf+Pm1N2-llZ;RaPT_cv@0NoLfE>szFzoRtX@{CLuNg7u#Jtej)kSY5)48c0$Qb$Ne z*yG;MyOXa;E4ARm2#ftR$-Sqk`Xn`)yq(VvRVX6$Zi?rFEY0D3;?7)aBgF&~JMs(k||fKHVLFBOo?L00~5oM(2) zRNAhv$^+KjYRLumSZse1dZI`;qhd$DJ>+$!>TwrxJiDZ^!EszR(4Jm7Zct)}Np`(y zE9RkcZe-sSfPGO4M`g=VXZ%ZE_SpI<;ITQ#vfQ+=9w3bHaY-4D?r`&wIQ=+ho_b^s zbeNN#R5qIewD=dX{xvsoz@>`Jc1KRzk5&ItnEBGwb-T?0Wm362_+J&jHeHHXzYJKkdx-U@UIAV8DB~b^obb=r7W?b4Wbiv*-MuZ zhtTh3j)f+87g9!gTH~)nDb<5W%#~EMw7Mfz5vwVmxkqP2#bM~Dyqg_cr%|3jla{SB zBz3&Sr>nlunEb`-*L_tyX~9cZ(B&5Z+EQTMwl@CD)O_t`{uC!0LBNIEwdIc37oRfe z(jyZMpjNK4==B*fapJYH=TB9aA)c9>+sLN57Z|5_FR<~2&=agRm?}b{QtddFim4c2 zGgLWEbc}uMeI%u|4&sQbp{ugA<%c8o*4Vtz&oVi&_={mQJ@2E1i;K8mPY6ttG|Uu3 zTB6CLJxFP$?qD`U+8kPVa7ExI`vF^&i9+h)18MU&^EjCt_ z*Sxj_zD(ZTU9;!0sgt36~=gzJ@tY%qntoLr?8}c z71OI71(h_JRS)Ee>n4Y5O|Y3qT-0)uGE=5Av_MyDeq>Xui%|}bQi7r*R@3jx;%C?U zvaa8oi6j1W_i(Yu@Og+PdE#VEB&T-`Z62a8&;gGVTHkrct9I*t(bYZ3>X> z>`iD>aka>?Wef+d#OqiQXW6XPVvw!PAK~A{uJ;Nq?n*p137|^JAh}m`NT2ChIBHdS z!JFy1ETJY{JhT#3No7#->G%m5p6EpnnPT=v;syymTe@AF;(PrLz(R~!o_7;Yn^D^l z87>oP)8Iot~;1Z5;RP zudeQ2_UzA8OyL|o%?|3jYQTPr z#Sx7Y&VX581T|nwLkc32JgMi$b^4{yMHqA~H*q+8!Oq_DbN2b4p3!Ej8HoI}UM zA6-w=|D(tM8!o?Ri^LIi2fRb4(cAHelj8m23Cy>6t`+rs;4Pr)#T{{wf99+}FZ-@A zb#15lk=SQ7&yD-?$OF-rpag%GHj$ki)qp0I`4JI?6pl7K#v*+Bli26{j;h-BGt98G z!w+c{kcU^ThBK|Bdm1E!d#ia~Fqg7PLAvN`J3BwQc$9WO_>6^`3i=tnGMV$p?%`+b zbbc)L7D=h~nbDT`8kiVreu}3yNtHQDRXX;~lO>Nr4D}S*iyu+?ENiF|bpcj+nS!Su zU@b;REsDg66+R}Dl%wuR_KlEU0@cs+Qql3G9F!1`G)E}`ii4T&H4lghw2LjcM2?6? z>cqsXPm3uU$$oMH&`r*kJX%HQ>p!$m@+Qew{S|S+RVZVE-?EhYwl&`Ax%?9L;XSXm43UBysLqMkZ*t4w2=A~sUMX3PR-saqEIOaQlixsBef*vkIxG4xC$UHsk+G;k$3x~ zs&LZK$$l*)j}-~l^4scGtxSl0{kh0yBj%N&Q;Da?)oNOrK-1OwTD2gH;JNcb-%Nzp zmFLOUkVLk*srD1i_b#;-Fk2{ctf+%!HDB=tKCsDheWQ@@@nRB*xE~(z-O(R9nUF*r zcm81E7*fOpJLRNhwucSK-$WyjY#lEc6!HCde5RuWu0)_BO3)BPi6O!iC8WRnxg=|| zoIM+?6tK6dqrZ-D^mE>>Z<%=4*UNB@i`|FDAE%m|_c8;C)VB?n%fE`u8GVSOm^eLM zTQ6*a5zJTDExlKVhL)O&q+Y?<7KJ3Y?snmP?0znE412hz{&nxXh)pyZ)E2juF^KK3 zbsJAVzzwif`bBSC?@+COdpzM~GMlKTK6WN|`1v76>ju0eoW7sB-_$d|i3t`J)ot#_JR3>17n zDAkbqpdl;eoj}_|UYFjKynnn-dwzoCNfn|mGgWoGl6v~-22in5BS z>~tnHQnj^B)rBxkpNxH|>E6&hl|CNMo|J7I-(ZZd22$%rt{qI`$BCKJpB*YGZv(V{ zU3AXyGVMdzB*jlIcwP69ZgFF8S-2zmBM&^{4M-z)Q=hPA>rD)mLt?86r_ezs~t`8 z_%K%6+;X@XIg&gEri1 z`drTJCq|5l;xfbBG5MH=+tTKdkHYDTZT!X%a1yHS7u8t2R-w@vm!td0(7G1z2z2f# z=Lhe%?*1apovf_&DTOT03>EnnMQdRQ=5Y+p1gM40gUAF8fP=WdZ*#Y*$J@FZQZZ9@E`>3r zNxfk1fA=JmBn}DTNun?+Q~-Vos6dovT>pJv++jy;q>dMQrWnp~Rpl3%v>kJm?-(iH zL?~2%$PEK#eDP~lF_wU7m2x(w68d4IVbo{)E{lNhb%w;n3!Mg;g@pMMm1dOsabUzHELfS zqE>vXis=+-TmzNOc~)ItO5K*sr2x>&v0QxDi&y+qNt||;64r^Pc)ogkit@~f#+rSj zH^nlVpta^Rl~6T<)6VQ_Juph!m9IW;kgxT^LwRrZQ`+*99cn$;F zB>mO-!*X&fD2ycgi9^)gS&hDV_WSy=5(H%N>`F$!SGW*9CL(6zGdNV}KmV%NA8^Ko zgxbm|o!KrM1zO7!Du1Naj}BT6`g?;PTj=34ZhrU*9zyE2$fF=uf;WRpT_scK6>!h6 z>)@Voud&sCC`#SM7Q6CA!lhf!4>aILY{=Ns=oOhj^d`1gIdyV*dAU3=)9iJ! zH(&2W3PEytdeL^K3(7#v>vWdM9=Q!pU7|DQxret$$kdDY#dO*l1>VzlP`zXkc?HWv zlLpqt>z{?IKbh11KZh%gbd;hTQ2YLQR0s$h&<^+Sc`)`S4weR1`lc4lW;TY#KUB;W zlnik_2Tz(RLWTH>$!WQ3$Psy081)bn@i&-DgMyG~SqFIfZ1q%8>er{Vg#wJCm{q)X zM=s=pRK__+)znS6gcCJ@Sw?xZ^Zo$+>K#Q#g4rcLH)S%WtKCbNFCNXyjr?0jgHGdK zBUfD1ahOR+EiVW|0LaHf1#bPYZPT`Wy&`t`2!wEXPU^E(!4r@JawQgY^ux*%V{2p3 zU)k=zcp{PVY3apse0)3EJh1CjC$`mK;BC5$FuHq2mvrfd*qC=iJbfXhx= zzF|Ld1o2E@3=ua`vUu%=navXerTT}wP2#3;?isFh5Z@omV)a2jXWewHoy4fDw@?AX zcyoI5EgWLAUJ-hq^-L(mqUte!kT-jcR0!pKIp^rMhz}7Ap}V!6#Nc=7XskWeE5!I^ zc0t1m!2o57KR^Q_AHu7XIcbV07vkPQ=EwFWnAe!~B|HgfG0qzFPc!&`IEt#1qDD@r z%k)B0LNBmQ8R}P!K#VX+i@#H$7ec9NTx=ok4g%6Yt73;JK!1!V*|AlniVbJ5DpI0_ z_v&rc{csUGv@hS{Vzm43t;kIo=OY?~s~G|Tq^OOwj|zQxU*;dEP$d6w7g7uPl!8UB zmFEXfkWvFh#7HXwX>TJMfOOwRNCaJshfE~EuO3>~=9LeFDk~(PuZdEoq#CEiGd(D* zK^QjXB(Vd|z_nEa4e9t{tt2=iZHcWcnf%B#Q(|qxaHfcYA+t9~%j&2kVldVCFv-y# zc#*Deb~OTjY)3Db1Ut?SSKzMExI%5G)4fW;8MxBxIs;Pho|+C_bbUv4)LR@_Vn9Zs z5NT#*M27c6_qWl&#e{tcxghGBZ9j&Lj`9{&UJ33a;VEeg5(6c23xX=U!g!GWI0 z2iyoRfK!X?_C^v7rw>lk4lYiAoW40FDM{YV1Cq~l6YoM!$s9%wWl%I`N4P&hdHt~4 z4dBFe=;^-jtmd(t_#K>Hl;)GKwiBYzUTKn19Q`9e-_MnE( zC}Tp1@(%kNkXl$NHtEXxUjft`?E&kDg1E9k6KpQs>Z)3ccv1LRDMO`2(cGlMUZ7#V zbOO+@pR*i0h;Q2U);mbptd;|p2K-|;6SwEHD8So3N>QYly_`h z)z54-mqU~K36(66_)d&1nLwz#(<>1$5UK?=q{IK9XyrP|yudDmnGDCxE9B>SsKP;q za*1Nn6pBj5V;{*{7cYE~tFL!OY$c->H8aq1;+7F6%mUYH+G5U|xp;oY2L06^f^=Vh z(OCp0_K}f@MT(c;;nRCV=&e9<_!y|q(1h|rRjt{H>L&#~h40qJ4iKgYsx2ZCl}qcb zLl##~DpMZS+KE^gjEtG~R4iv3f97&(nMJ}`T$+8xnuHh{GC+kDt6VstG%+^4))634 z|LjfIy1A+4%<$!KTLgdIYFSs>WZjSa+%%WN+GX99xw5^t@w!t7Yv$HX2ZyOnb3dl) zx3VIRyllUI&5##7+nrRs=#oz%mr!XiwtXtZTlr4%s-p&9b>2)Xtg!eh=N$S9b&4f9{RJ zhmL_S2cLa)v%C|OllXi2zb0XUuLhrtbhCO1)YSUl!&7e0NdhN;54O1>m?Hc|`0KUb zIpzi&20p#z2KEv0M$X@3MZlMX∓4E&=L}`P)$2f0Ci!`({M{nftwCS3Ff<>22zr7Z`YNz#DWo zs8HcI^lhm>%M|{T(x3fw{{8TVWTv?T_q)=c&^v{Kch{R<6NUvg)?3AkYJgYz5e8;x6nZy%$BBf!%`op-Z83-WvR3*wfbKi|Q?Q_nYoJf8nTyB2ikUF*++*iC*x+!FNXI~90x=|&Kv f>8)-2uc;;l85qzm9Rh+L^wWV10Rd 3), 99) === 3, 'clamp high when count is known'); + +$outside = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'hustoj-cw-out-' . bin2hex(random_bytes(4)); +cw_assert(mkdir($outside), 'create outside dir'); +$secret = $outside . DIRECTORY_SEPARATOR . 'secret.pptx'; +cw_assert(copy($fixture, $secret), 'copy secret pptx outside root'); +cw_assert(!courseware_inside_root(realpath($secret), realpath($tmp)), 'outside realpath is rejected'); + +$escape = $tmp . DIRECTORY_SEPARATOR . 'escape.pptx'; +$link_ok = @symlink($secret, $escape); +if ($link_ok) { + cw_assert(courseware_build_deck('escape') === null, 'out-of-root symlink is rejected'); +} else { + fwrite(STDOUT, "SKIP symlink escape test (cannot create symlink)\n"); +} + +$rel_link = $tmp . DIRECTORY_SEPARATOR . 'relescape.pptx'; +$rel_ok = @symlink('..' . DIRECTORY_SEPARATOR . basename($outside) . DIRECTORY_SEPARATOR . 'secret.pptx', $rel_link); +if (!$rel_ok) { + $rel_ok = @symlink(realpath($secret), $rel_link); +} +if ($rel_ok) { + cw_assert(courseware_build_deck('relescape') === null, 'relative out-of-root symlink is rejected'); +} else { + fwrite(STDOUT, "SKIP relative symlink test (cannot create symlink)\n"); +} + +unset($GLOBALS['_courseware_root']); +$example = courseware_build_deck('示例课件'); +cw_assert($example !== null, 'example pptx is present in default root'); +cw_assert($example['filename'] === '示例课件.pptx', 'example uses actual filename'); +cw_assert($example['url'] === 'courseware-file.php?deck=' . rawurlencode('示例课件'), 'example url uses file endpoint'); +cw_assert(!array_key_exists('page_count', $example), 'example does not fake page count'); + +cw_rmdir_tree($tmp); +cw_rmdir_tree($outside); + +fwrite(STDOUT, "OK courseware_test.php\n"); diff --git a/web/courseware-file.php b/web/courseware-file.php new file mode 100644 index 0000000..0c8fc21 --- /dev/null +++ b/web/courseware-file.php @@ -0,0 +1,53 @@ + 这节课讲图的时候,我们主要说“第几个位置”;写代码的时候,再换成下标。 - ---- - -## 二、为什么数组的插入和删除要“搬家”? - -数组里的元素是**连续排在一起**的。 - -这就像一排已经坐好的同学: - -- 想在中间插入一个人,就得有人挪一挪,腾出空位。 -- 想删掉中间一个人,就会空出一个洞,后面的人要补上来。 - -所以数组的插入和删除,最关键的不是“放进去”或“拿出来”,而是: - -> **怎样移动其他元素,才能既不丢数据,也不弄乱顺序。** - -这就是本节最重要的地方。 - ---- - -## 三、数组插入:先腾位置,再放新元素 - -### 1. 例子:在第 3 个位置插入 20 - -原数组: - -```text -位置: 1 2 3 4 5 6 -内容: [12] [18] [23] [31] [40] [ ] -``` - -注意:这里第 6 个位置先留空,表示数组容量足够大,可以插入新元素。 - -现在要把 `20` 插入到**第 3 个位置**。 - -插入后应该变成: - -```text -位置: 1 2 3 4 5 6 -内容: [12] [18] [20] [23] [31] [40] -``` - -### 2. 插入时,元素是怎样移动的? - -要想让第 3 个位置空出来,原来第 3、4、5 个位置上的元素都要向后移动一格。 - -但一定要记住: - -> **插入时,要从后往前移。** - -移动过程如下: - -```text -原来: [12] [18] [23] [31] [40] [ ] -第1步: [12] [18] [23] [31] [40] [40] 把 40 往后移 -第2步: [12] [18] [23] [31] [31] [40] 把 31 往后移 -第3步: [12] [18] [23] [23] [31] [40] 把 23 往后移 -第4步: [12] [18] [20] [23] [31] [40] 把 20 放进第 3 个位置 -``` - -### 3. 为什么插入要从后往前移? - -因为如果你从前往后移,前面的数据会把后面的数据盖掉。 - -来看一个错误示范。还是在第 3 个位置插入 `20`: - -```text -原来: [12] [18] [23] [31] [40] [ ] - -错误地从前往后移: -第1步: [12] [18] [23] [23] [40] [ ] -第2步: [12] [18] [23] [23] [23] [ ] -第3步: [12] [18] [23] [23] [23] [23] -``` - -你会发现:原来的 `31` 和 `40` 都不见了! - -原因是: - -- 你先把 `23` 复制到了后面。 -- 后面的位置被改掉以后,再继续搬,就只能搬到已经改坏的数据。 - -所以插入时一定要: - -> **从最后一个元素开始,倒着往前挪。** - -### 4. 插入的步骤口诀 - -可以记成一句话: - -> **先留空,从后搬,最后放。** - -具体就是: - -1. 先保证数组后面有空位置。 -2. 从最后一个元素开始,依次向后移动一格。 -3. 移到目标位置后停下。 -4. 把新元素放进去。 -5. 数组长度 `n` 加 1。 - -### 5. 插入的课堂版 C++ 代码 - -下面的代码约定: - -- 数组现在有 `n` 个元素。 -- 要把 `x` 插入到第 `pos` 个位置。 -- `pos` 从 `1` 开始数。 -- 数组容量足够大。 - -```cpp -for (int i = n; i >= pos; i--) { - a[i] = a[i - 1]; -} -a[pos - 1] = x; -n++; -``` - -你可以这样理解这段循环: - -- `i = n` 时,把最后一个元素搬到新位置。 -- `i = n - 1` 时,把倒数第二个元素往后搬。 -- 一直搬到第 `pos` 个位置为止。 - ---- - -## 四、数组删除:先补空位,再缩短长度 - -### 1. 例子:删除第 3 个位置的元素 - -原数组: - -```text -位置: 1 2 3 4 5 -内容: [ 8] [11] [14] [17] [20] -``` - -现在要删除第 3 个位置上的 `14`。 - -删除后应该变成: - -```text -位置: 1 2 3 4 -内容: [ 8] [11] [17] [20] -``` - -### 2. 删除时,元素是怎样移动的? - -第 3 个位置删掉以后,会空出一个位置。后面的元素要依次往前补。 - -注意: - -> **删除时,要从前往后移。** - -移动过程如下: - -```text -原来: [ 8] [11] [14] [17] [20] -第1步: [ 8] [11] [17] [17] [20] 把 17 往前移 -第2步: [ 8] [11] [17] [20] [20] 把 20 往前移 -最后: [ 8] [11] [17] [20] 长度减 1 -``` - -最后那个多出来的 `20` 虽然还留在原来的地方,但因为数组长度已经减 1,所以它已经**不算数组的一部分了**。 - -### 3. 为什么删除要从前往后移? - -因为空位在前面,应该让后面的元素一个一个补上来。 - -如果你反过来,从后往前移,也会出问题。还是删除第 3 个位置: - -```text -原来: [ 8] [11] [14] [17] [20] - -错误地从后往前移: -第1步: [ 8] [11] [14] [20] [20] -第2步: [ 8] [11] [20] [20] [20] -``` - -原来的 `17` 被弄丢了。 - -所以删除时要记住: - -> **从缺口的后面开始,按顺序往前补。** - -### 4. 删除的步骤口诀 - -可以记成一句话: - -> **先删掉,从前搬,最后减。** - -具体就是: - -1. 找到要删除的位置。 -2. 让后面的元素依次向前移动一格。 -3. 数组长度 `n` 减 1。 - -### 5. 删除的课堂版 C++ 代码 - -下面的代码约定: - -- 数组现在有 `n` 个元素。 -- 删除第 `pos` 个位置上的元素。 -- `pos` 从 `1` 开始数。 - -```cpp -for (int i = pos; i < n; i++) { - a[i - 1] = a[i]; -} -n--; -``` - -你可以这样理解这段循环: - -- `i = pos` 时,把后一个元素补到空位上。 -- `i = pos + 1` 时,再把更后面的元素补上来。 -- 一直补到最后一个元素为止。 - ---- - -## 五、插入和删除放在一起比较 - -| 操作 | 会发生什么 | 正确移动方向 | 为什么 | -|:---:|:---|:---:|:---| -| 插入 | 中间要腾出一个空位 | 从后往前 | 先保护后面的数据,不让它们被覆盖 | -| 删除 | 中间会出现一个缺口 | 从前往后 | 让后面的数据按顺序补上来 | - -再记一遍: - -- **插入:从后往前移** -- **删除:从前往后移** - -这是本节最重要的结论。 - ---- - -## 六、两个最容易忽略的小细节 - -### 1. 插入前,数组要有空位 - -如果数组已经装满了,就不能直接插入。 - -比如数组最多只能放 5 个数,现在已经有 5 个数了,再插入第 6 个,就没有地方放了。 - -所以写程序时,常常会这样做: - -- 开一个更大的数组,比如最多放 `100` 个数。 -- 实际已经用了多少个,用变量 `n` 记录。 - -### 2. 删除后,不是把数“擦掉”,而是把长度减 1 - -数组删除一个元素后,最后那个位置里可能还保留着旧数值,但这已经不重要了。 - -因为程序只看前 `n` 个元素: - -- 删除前看前 `n` 个 -- 删除后只看前 `n - 1` 个 - -所以真正关键的是: - -> **长度变了,数组有效范围也变了。** - ---- - -## 七、特殊情况也要会判断 - -### 1. 在最后面插入 - -如果要在第 `n + 1` 个位置插入,也就是直接接到数组末尾: - -```text -[12] [18] [23] [31] [40] -> [12] [18] [23] [31] [40] [50] -``` - -这时不需要搬动任何元素,直接放进去即可。 - -### 2. 删除最后一个元素 - -如果删除的是最后一个元素: - -```text -[12] [18] [23] [31] [40] -> [12] [18] [23] [31] -``` - -这时也不需要搬动任何元素,只要把长度减 1 就行。 - ---- - -## 八、最容易犯的 5 个错误 - -### 错误 1:插入时移动方向写反 - -结果:后面的数据会被覆盖。 - -### 错误 2:删除时移动方向写反 - -结果:中间的数据会丢失。 - -### 错误 3:忘记更新 `n` - -插入后忘记 `n++`,新元素虽然放进去了,但程序可能不把它算进去。 - -删除后忘记 `n--`,旧数据虽然应该消失了,但程序还会把它输出出来。 - -### 错误 4:把“第几个位置”和“下标”搞混 - -记住: - -- 第 `1` 个位置,对应下标 `0` -- 第 `pos` 个位置,对应下标 `pos - 1` - -### 错误 5:插入时没有预留空间 - -结果:数组越界,程序可能出错。 - ---- - -## 九、一张总图记住本节内容 - -```text -数组插入:先腾空位 - -[12] [18] [23] [31] [40] [ ] - ← ← ← -[12] [18] [20] [23] [31] [40] - - -数组删除:先补缺口 - -[ 8] [11] [14] [17] [20] - → → -[ 8] [11] [17] [20] -``` - -记忆口诀: - -> **插入看后面,从后往前搬;删除看前面,从前往后搬。** - ---- - -## 十、课堂版完整示例 - -下面是一份把“插入”和“删除”都写进去的课堂版程序。为了简单起见,输入位置 `pos` 按“第几个位置”来理解,也就是从 `1` 开始数。 - -```cpp -#include -using namespace std; - -const int MAXN = 105; -int a[MAXN]; -int n; - -void insertValue(int pos, int x) { - for (int i = n; i >= pos; i--) { - a[i] = a[i - 1]; - } - a[pos - 1] = x; - n++; -} - -void deleteValue(int pos) { - for (int i = pos; i < n; i++) { - a[i - 1] = a[i]; - } - n--; -} - -int main() { - cin >> n; - for (int i = 0; i < n; i++) { - cin >> a[i]; - } - - int pos, x; - cin >> pos >> x; - insertValue(pos, x); - - for (int i = 0; i < n; i++) { - cout << a[i] << " "; - } - cout << "\n"; - - cin >> pos; - deleteValue(pos); - - for (int i = 0; i < n; i++) { - cout << a[i] << " "; - } - cout << "\n"; - - return 0; -} -``` - ---- - -## 十一、自己试一试 - -### 1. 观察移动过程 - -把 `9` 插入到下面数组的第 2 个位置,请你把每一步移动都画出来: - -```text -[3] [7] [12] [15] [ ] -``` - -### 2. 观察删除过程 - -删除下面数组的第 4 个位置,请你把每一步移动都画出来: - -```text -[5] [8] [11] [14] [20] -``` - -### 3. 想一想 - -- 为什么插入和删除都可能需要移动很多个元素? -- 如果总是在数组最前面插入,会不会很麻烦? - -如果你能清楚地回答这两个问题,就说明你已经真正理解数组的插入和删除了。 \ No newline at end of file diff --git a/web/doc/3.1 原码反码补码.md b/web/doc/3.1 原码反码补码.md deleted file mode 100644 index 210341c..0000000 --- a/web/doc/3.1 原码反码补码.md +++ /dev/null @@ -1,482 +0,0 @@ -# 3.1 原码、反码与补码 - ---- - -## 一、先搞清楚:计算机为什么只认识 0 和 1? - -你有没有想过,我们平时写下的数字 `5`、`-3`、`100`,计算机根本"看不懂"? - -计算机的本质是**电路**。电路里的导线,要么**通电**,要么**断电**,只有两种状态。科学家就用 `1` 表示通电,用 `0` 表示断电。这就是**二进制**的由来。 - -**类比:** 想象一排电灯开关,每个开关只能「开」或「关」。用这一排开关,我们可以用不同的开/关组合来代表不同的数字——这就是二进制的核心思想。 - -| 十进制 | 二进制 | -|:---:|:------:| -| 0 | `0000` | -| 1 | `0001` | -| 2 | `0010` | -| 3 | `0011` | -| 5 | `0101` | -| 7 | `0111` | - -> **为什么不用十进制?** -> 如果用十进制,每根导线需要精确区分 10 种不同的电压(0V、1V、2V……9V)。电路稍微受到干扰,电压抖动一点,数字就读错了。而二进制只需区分「高电压」和「低电压」两种情况,极难出错,制造成本也低得多。 - ---- - -## 二、正数好说,负数怎么办? - -表示 `5` 很简单,写成 `0101` 就行。但 `-5` 呢? - -计算机存数字时,会分配固定长度的空间,比如 **8位**(8个 0 或 1)。科学家想出了一个办法: - -> **把最左边(最高位)那一位专门用来表示正负,叫"符号位":** -> -> - `0` → 正数 -> - `1` → 负数 - -剩下的 7 位用来表示数值的大小。 - -这就是最朴素的方案——**原码**。 - ---- - -## 三、原码:最直观的方案 - -### 规则 - -- **正数:** 符号位写 `0`,后面写数值的二进制。 -- **负数:** 符号位写 `1`,后面写数值**绝对值**的二进制。 - -### 例子(8位) - -| 十进制 | 原码 | -|:----:|:-----------:| -| `+5` | `0000 0101` | -| `-5` | `1000 0101` | -| `+0` | `0000 0000` | -| `-0` | `1000 0000` | - -直观,容易理解!但…… - -### 原码的两个大麻烦 - -**麻烦一:零有两个写法** - -`+0` 写成 `0000 0000`,`-0` 写成 `1000 0000`,但它们其实是同一个数 `0`!这会让计算机很困惑——判断一个数是不是 `0` 时,要检查两种情况。 - -**麻烦二:加减法会算错** - -用原码做 `5 + (-5)`,把两个原码直接相加: - -``` - 0000 0101 (+5 的原码) -+ 1000 0101 (-5 的原码) ------------ - 1000 1010 ← 这是 -10 的原码,答案错了! -``` - -正确答案应该是 `0`,结果算出了 `-10`。这意味着计算机必须专门写一套特殊的判断逻辑来处理负数加法,硬件电路会变得很复杂。 - ---- - -## 四、反码:改进的尝试 - -### 规则 - -- **正数:** 反码与原码**完全相同**。 -- **负数:** 符号位保持 `1` 不变,其余 7 位**全部翻转**(`0` 变 `1`,`1` 变 `0`)。 - -### 例子(8位) - -| 十进制 | 原码 | 反码 | -|:----:|:-----------:|:-----------:| -| `+5` | `0000 0101` | `0000 0101` | -| `-5` | `1000 0101` | `1111 1010` | - -### 用反码再试试 `5 + (-5)` - -``` - 0000 0101 (+5 的反码) -+ 1111 1010 (-5 的反码) ------------ - 1111 1111 ← 这是反码,对应的真值是 -0 -``` - -结果是 `1111 1111`,这个反码代表 `-0`。虽然不是理想的 `0000 0000`,但至少方向对了——运算逻辑有所改进。 - -### 反码还剩下的问题 - -零**依然有两种写法**: - -- `0000 0000` = `+0` 的反码 -- `1111 1111` = `-0` 的反码 - -问题没有根本解决,只是往前走了一步。 - ---- - -## 五、补码:现代计算机真正使用的方案 - -### 规则 - -- **正数:** 补码与原码**完全相同**。 -- **负数:** 先求反码,再在最末位**加 1**。 - -### 一步步求 `-5` 的补码(8位) - -``` -第一步:写出 -5 的原码 - 1000 0101 - -第二步:符号位不变,其余位取反(得到反码) - 1111 1010 - -第三步:反码末位加 1(得到补码) - 1111 1010 - + 1 - ----------- - 1111 1011 ← 这就是 -5 的补码 -``` - -### 例子(8位) - -| 十进制 | 原码 | 反码 | 补码 | -|:----:|:-----------:|:-----------:|:-------------:| -| `+5` | `0000 0101` | `0000 0101` | `0000 0101` | -| `-5` | `1000 0101` | `1111 1010` | `1111 1011` | -| `+0` | `0000 0000` | `0000 0000` | `0000 0000` | -| `-0` | `1000 0000` | `1111 1111` | `0000 0000` ✓ | - -> **神奇的事情:** `-0` 的反码 `1111 1111` 加 `1`,得到 `1 0000 0000`,共 9 位!但我们只保留 8 位,最高位的 `1` 自动丢弃,结果就是 `0000 0000`。这样正负零合并为同一个编码了! - -### 用补码验证 `5 + (-5)` - -``` - 0000 0101 (+5 的补码) -+ 1111 1011 (-5 的补码) ------------ -1 0000 0000 ← 产生了进位,但只保留低 8 位 - -结果 = 0000 0000 = 0 ✓ 正确! -``` - -### 再验证 `7 + (-3)`(答案应为 4) - -``` - 0000 0111 (+7 的补码) -+ 1111 1101 (-3 的补码) ------------ -1 0000 0100 ← 低 8 位是 0000 0100 = +4 ✓ -``` - -补码让**减法可以用加法来做**,计算机只需要一个加法器就够了,硬件设计大大简化! - ---- - -## 六、三种编码方式总结 - -| | 原码 | 反码 | 补码 | -|:------------:|:-----------:|:-------------:|:---------------:| -| **正数规则** | 符号位 0 + 绝对值 | 同原码 | 同原码 | -| **负数规则** | 符号位 1 + 绝对值 | 原码各位取反(符号位除外) | 反码 + 1 | -| **零的表示** | 两种(正零/负零) | 两种(正零/负零) | 一种(唯一) | -| **能否直接做加减法** | ✗ 不能 | 部分改善 | ✓ 可以 | -| **8位表示范围** | -127 ~ +127 | -127 ~ +127 | **-128 ~ +127** | - -> **补码能多表示一个负数**,原因是消灭了 `-0`,空出来的编码 `1000 0000` 就用来表示 `-128`。 - ---- - -## 七、补码的"逆运算":已知补码求原来的数 - -如果拿到一个**负数的补码**,怎么还原成十进制? - -**方法:对补码再做一次"取反加一"即可。** - -**例:** 已知某数的 8 位补码为 `1111 1011`,求它是多少? - -``` -第一步:末位加 1(取反加一 = 再做一次补码运算) - 1111 1011 →(取反)→ 1000 0100 →(加1)→ 1000 0101 - -第二步:读结果:符号位为 1(负数),数值部分为 0000 0101 = 5 - -结论:1111 1011 这个补码表示的是 -5。 -``` - ---- - -## 八、用 C++ 实现原码、反码、补码的输出 - -学完了手算方法,我们来用 C++ 写一个程序,让计算机自动完成这些步骤。 - -### 核心思路 - -用一个长度为 8 的 `int` 数组来表示 8 位二进制,**下标 0 存最低位,下标 7 存符号位(最高位)**。 - -- **原码**:先把绝对值不断除以 2 取余数,填入数组;再把下标 7 设为符号位(正数为 0,负数为 1)。 -- **反码**:正数与原码相同;负数把除符号位以外的每一位取反(`0` 变 `1`,`1` 变 `0`,即 `1 - bit`)。 -- **补码**:正数与原码相同;负数在反码的基础上加 1,用"逐位进位"模拟加法。 - -### 代码 - -```cpp -#include -using namespace std; - -// 将非负整数 n(0~127)的二进制填入数组 bits[] -// bits[0] 是最低位,bits[7] 是最高位(符号位) -void fillBits(int n, int bits[8]) { - for (int i = 0; i < 8; i++) { - bits[i] = n % 2; - n = n / 2; - } -} - -// 打印 8 位数组,格式为 "XXXX XXXX"(高位在前) -void printBits(int bits[8]) { - for (int i = 7; i >= 0; i--) { - cout << bits[i]; - if (i == 4) cout << " "; - } - cout << endl; -} - -// 输出整数 n(范围 -127 ~ 127)的原码、反码、补码 -void showCodes(int n) { - int original[8]; // 原码 - int inverse[8]; // 反码 - int complement[8]; // 补码 - - if (n >= 0) { - fillBits(n, original); - // 正数:三种编码完全相同 - for (int i = 0; i < 8; i++) { - inverse[i] = original[i]; - complement[i] = original[i]; - } - } else { - // 原码:绝对值的二进制,符号位设为 1 - fillBits(-n, original); - original[7] = 1; - - // 反码:符号位不变,其余位取反 - inverse[7] = 1; - for (int i = 0; i < 7; i++) { - inverse[i] = 1 - original[i]; - } - - // 补码:反码加 1,模拟手动进位 - int carry = 1; - for (int i = 0; i < 8; i++) { - int sum = inverse[i] + carry; - complement[i] = sum % 2; - carry = sum / 2; - } - } - - cout << "原码: "; printBits(original); - cout << "反码: "; printBits(inverse); - cout << "补码: "; printBits(complement); -} - -int main() { - int n; - cin >> n; - - if (n < -127 || n > 127) { - cout << "请输入 -127 到 127 之间的整数!" << endl; - return 0; - } - - cout << "n = " << n << endl; - showCodes(n); - return 0; -} -``` - -### 运行示例 - -输入 `-5`,输出: - -``` -n = -5 -原码: 1000 0101 -反码: 1111 1010 -补码: 1111 1011 -``` - -输入 `5`,输出: - -``` -n = 5 -原码: 0000 0101 -反码: 0000 0101 -补码: 0000 0101 -``` - -### 关键代码讲解 - -**① `fillBits`:把整数转为二进制数组** - -``` -n = 5: - 5 % 2 = 1 → bits[0] = 1, n = 5/2 = 2 - 2 % 2 = 0 → bits[1] = 0, n = 2/2 = 1 - 1 % 2 = 1 → bits[2] = 1, n = 1/2 = 0 - 其余位全为 0 -``` - -这就是"短除法"的代码版本,与手算完全一致。 - -**② `inverse[i] = 1 - original[i]`:取反** - -- `original[i]` 是 0 时,`1 - 0 = 1`; -- `original[i]` 是 1 时,`1 - 1 = 0`。 - -不需要任何特殊符号,普通减法就能完成翻转。 - -**③ 反码加 1 的进位模拟** - -``` - 假设反码是 1111 1010,加 1: - carry = 1 - i=0: 0+1=1, bits=1, carry=0 - i=1: 1+0=1, bits=1, carry=0 - ...(carry 已为 0,后续不变) - 结果:1111 1011 ← 这正是 -5 的补码 -``` - -用 `sum % 2` 取本位,`sum / 2` 取进位,完全模拟了手算的竖式加法。 - -> **想一想:** 为什么范围限制在 `-127` 到 `127`,而不包括 `-128`? -> 因为 `-128` 没有合法的 8 位**原码**(8 位原码最多表示 `-127`),只有**补码**能表示它(`1000 0000`)。你可以尝试修改代码,增加对 `-128` 的特殊处理。 - ---- - -## 九、练习题 - -### 【第一组】进制转换热身 - -1. 将十进制 `13` 转换成二进制。 -2. 将十进制 `25` 转换成二进制。 -3. 将二进制 `0001 0110` 转换成十进制。 - ---- - -### 【第二组】求原码 - -用**8位**二进制写出下列各数的原码: - -4. `+9` -5. `-9` -6. `+20` -7. `-20` -8. `+0` 和 `-0` 的原码分别是什么?它们相同吗? - ---- - -### 【第三组】求反码 - -用**8位**二进制写出下列各数的反码(需要先写原码再推导): - -9. `+9` -10. `-9` -11. `-20` -12. `-1`(提示:`1` 的原码是 `0000 0001`) - ---- - -### 【第四组】求补码 - -用**8位**二进制写出下列各数的补码: - -13. `+9` -14. `-9` -15. `-20` -16. `-1` -17. `-128`(这道题有些特别,想想为什么原码方法不好用?) - ---- - -### 【第五组】补码反推原值 - -已知以下 8 位补码,请判断符号并求出对应的十进制数: - -18. `0000 1010` -19. `1111 1110` -20. `1111 0000` -21. `1000 0000`(提示:这是补码范围内的特殊值) - ---- - -### 【第六组】补码加法验证 - -用补码计算以下各题,并验证结果正确(用 8 位,溢出位丢弃): - -22. `6 + (-2)` -23. `(-6) + (-2)` -24. `10 + (-10)` -25. `(-1) + 1` - ---- - -### 【第七组】思考题 - -26. 为什么计算机不直接使用原码来做加减法?用 `3 + (-3)` 举例说明原码的问题。 -27. 8 位补码最多能表示多少个不同的整数?范围是多少? -28. 如果把 8 位扩展到 **16 位**,用补码表示整数,范围是多少?(规律:$n$ 位补码的范围是 $-2^{n-1}$ 到 $2^{n-1}-1$) - ---- - -## 参考答案 - -**第一组** - -1. `1101` -2. `1 1001`(即 `0001 1001`) -3. `16 + 4 + 2 = 22` - -**第二组** - -4. `0000 1001` -5. `1000 1001` -6. `0001 0100` -7. `1001 0100` -8. 分别是 `0000 0000` 和 `1000 0000`,**不相同**。 - -**第三组** - -9. `0000 1001`(正数不变) -10. `1111 0110` -11. `1110 1011` -12. `1111 1110` - -**第四组** - -13. `0000 1001` -14. `1111 0111` -15. `1110 1100` -16. `1111 1111` -17. `-128` 的 8 位补码为 `1000 0000`(这是规定值,因为补码多表示了这一个负数) - -**第五组** - -18. 符号位 `0`,正数,`= +10` -19. 取反加一:`0000 0001 + 1 = 0000 0010`,`= -2` -20. 取反加一:`0000 1111 + 1 = 0001 0000`,`= -16` -21. `-128`(特殊规定值) - -**第六组** - -22. `0000 0110 + 1111 1110 = 0000 0100 = +4` ✓ -23. `1111 1010 + 1111 1110 = 1111 1000 = -8` ✓ -24. `0000 1010 + 1111 0110 = 0000 0000 = 0` ✓ -25. `1111 1111 + 0000 0001 = 0000 0000 = 0` ✓ - -**第七组** - -26. `3 + (-3)` 用原码:`0000 0011 + 1000 0011 = 1000 0110 = -6`,答案错误。 -27. $2^8 = 256$ 个,范围 `-128` 到 `+127`。 -28. 范围是 `-32768` 到 `+32767`(即 $-2^{15}$ 到 $2^{15}-1$)。 diff --git a/web/doc/3.2 二进制运算.md b/web/doc/3.2 二进制运算.md deleted file mode 100644 index 12e64f1..0000000 --- a/web/doc/3.2 二进制运算.md +++ /dev/null @@ -1,595 +0,0 @@ -# 3.2 二进制运算 - ---- - -## 一、为什么还要学“二进制运算”? - -在上一节里,我们已经知道了计算机用二进制存数,也知道了补码能把减法变成加法。接下来要学的是: - -- 按位与(AND) -- 按位或(OR) -- 按位非(NOT) -- 按位异或(XOR) -- 左移(`<<`) -- 右移(`>>`) -- 二进制加法 -- 二进制减法 - -这些运算不是“冷知识”,而是程序里常见的底层工具:权限开关、状态压缩、快速比较、数据校验都会用到。 - ---- - -## 二、先记住 6 个位运算 - -设两个二进制位分别是 $a$ 和 $b$,每一位只可能是 0 或 1。 - -### 1. 按位与 AND(符号 `&`) - -规则:只有两位都为 1,结果才是 1。 - -| a | b | a & b | -|:---:|:---:|:-----:| -| 0 | 0 | 0 | -| 0 | 1 | 0 | -| 1 | 0 | 0 | -| 1 | 1 | 1 | - -可以理解为“都同意才通过”。 - -### 2. 按位或 OR(符号 `|`) - -规则:只要有一位是 1,结果就是 1。 - -| a | b | a \| b | -|:---:|:---:|:------:| -| 0 | 0 | 0 | -| 0 | 1 | 1 | -| 1 | 0 | 1 | -| 1 | 1 | 1 | - -可以理解为“有人同意就通过”。 - -### 3. 按位非 NOT(符号 `~`,一元运算) - -规则:0 变 1,1 变 0。 - -| a | ~a | -|:---:|:---:| -| 0 | 1 | -| 1 | 0 | - -### 4. 按位异或 XOR(符号 `^`) - -规则:两位不同为 1,相同为 0。 - -| a | b | a ^ b | -|:---:|:---:|:-----:| -| 0 | 0 | 0 | -| 0 | 1 | 1 | -| 1 | 0 | 1 | -| 1 | 1 | 0 | - -可以理解为“不同就亮灯”。 - -### 5. 左移(符号 `<<`) - -规则:`x << k` 表示所有位向左移动 $k$ 位,右侧补 0。 - -- 在不溢出的情况下,数值相当于乘 $2^k$。 -- 固定 32 位时,左边移出去的高位会被丢弃。 - -例:8 位下 `00101101 << 2 = 10110100`。 - -### 6. 右移(符号 `>>`) - -规则:`x >> k` 表示所有位向右移动 $k$ 位。 - -- 对无符号数,左侧补 0。 -- 对有符号数,很多语言会做“算术右移”(补符号位),所以课堂里先按无符号来理解更稳妥。 - -例:8 位下 `00101101 >> 3 = 00000101`。 - ---- - -## 三、C++ 里位运算的优先级(一定要加括号) - -下面按 cppreference 的顺序,只保留“和计算最相关”的部分(第 5-7、9-15 级): - -| 优先级(高 -> 低) | 运算符 | 含义 | | -|:-----------:|:----------------- |:----- |:---:| -| 5 | `*` `/` `%` | 乘、除、模 | | -| 6 | `+` `-` | 加、减 | | -| 7 | `<<` `>>` | 左移、右移 | | -| 9 | `<` `<=` `>` `>=` | 关系比较 | | -| 10 | `==` `!=` | 相等比较 | | -| 11 | `&` | 按位与 | | -| 12 | `^` | 按位异或 | | -| 13 | `\|` | 按位或 | | -| 14 | `&&` | 逻辑与 | | -| 15 | `\|\|` | 逻辑或 | | - -看 5 个典型例子: - -1) `a + b << 1` -- 实际等价于 `(a + b) << 1` -- 不是 `a + (b << 1)` -2) `x | y & z` -- 实际等价于 `x | (y & z)` -- 不是 `(x | y) & z` -3) `a ^ b & c` -- 实际等价于 `a ^ (b & c)` -- 不是 `(a ^ b) & c` -4) `x + y > z` -- 实际等价于 `(x + y) > z` -- 不是 `x + (y > z)` -5) `a & b == 0` -- 实际等价于 `a & (b == 0)`(因为 `==` 高于 `&`) -- 想判断“按位与结果是否为 0”,应写成 `(a & b) == 0` - -课堂建议:只要一个表达式里混用了两类以上运算符,就主动加括号,别赌记忆。 - ---- - -## 四、位串上的运算:逐位独立进行 - -例如: - -``` -a = 00101101 -b = 00010111 -``` - -逐位计算: - -``` -a & b = 00000101 -a | b = 00111111 -a ^ b = 00111010 -~a = 11010010 -``` - -注意:`~a` 的结果长度和机器位数有关。课堂里我们常固定成 8 位或 32 位来讨论。 - -### 竖式写法示范(像小学列竖式) - -把高位写在左边、低位写在右边,同一列对齐后逐列运算。 - -1) 按位与 `&` - -```text - 0 0 1 0 1 1 0 1 (a) -& 0 0 0 1 0 1 1 1 (b) ----------------------- - 0 0 0 0 0 1 0 1 (a & b) -``` - -2) 按位或 `|` - -```text - 0 0 1 0 1 1 0 1 (a) -| 0 0 0 1 0 1 1 1 (b) ----------------------- - 0 0 1 1 1 1 1 1 (a | b) -``` - -3) 按位异或 `^` - -```text - 0 0 1 0 1 1 0 1 (a) -^ 0 0 0 1 0 1 1 1 (b) ----------------------- - 0 0 1 1 1 0 1 0 (a ^ b) -``` - -4) 左移与右移也可按“横向挪位”理解 - -```text -a : 0 0 1 0 1 1 0 1 -a << 2 : 1 0 1 1 0 1 0 0 (左移两格,右侧补 0) -a >> 3 : 0 0 0 0 0 1 0 1 (右移三格,左侧补 0) -``` - ---- - -## 五、二进制加法与减法 - -### 1. 二进制加法 - -和十进制竖式一样,也是“本位求和 + 进位”。 - -单个位相加规则: - -- $0+0=0$,进位 0 -- $0+1=1$,进位 0 -- $1+0=1$,进位 0 -- $1+1=0$,进位 1 - -如果再加上原来的进位,就变成三数相加。 - -竖式例子(8 位):`00101101 + 00010111` - -```text -进位: 0 0 1 1 1 1 1 - 0 0 1 0 1 1 0 1 -+ 0 0 0 1 0 1 1 1 ----------------------- - 0 1 0 0 0 1 0 0 -``` - -可让学生从最右列开始,逐列写“本列结果位”和“向左进位”。 - -### 2. 二进制减法 - -可以按“借位法”逐位减,也可以用补码思想把减法变加法。 - -在本章练习里,统一按 **32 位无符号整数** 处理: - -- 超过 $2^{32}-1$ 的高位进位丢弃 -- 不足 0 时按 32 位环绕(相当于加上 $2^{32}$) - -竖式例子(8 位):`00101101 - 00010111` - -```text -借位: 0 0 1 1 1 1 0 - 0 0 1 0 1 1 0 1 -- 0 0 0 1 0 1 1 1 ----------------------- - 0 0 0 1 0 1 1 0 -``` - -从最右列开始,若不够减就向左借 1(借 1 相当于当前位加 2)。 - ---- - -## 六、C++:用数组模拟按位运算与加减 - -下面给一份课堂版代码: - -```cpp -#include -using namespace std; - -const int LEN = 32; - -// 把无符号整数转成二进制数组:bits[0] 是最低位 -void toBits(unsigned int x, int bits[]) { - for (int i = 0; i < LEN; i++) { - bits[i] = x % 2; - x /= 2; - } -} - -// 把二进制数组转回无符号整数 -unsigned int toUInt(const int bits[]) { - unsigned int x = 0; - for (int i = LEN - 1; i >= 0; i--) { - x = x * 2 + bits[i]; - } - return x; -} - -// 打印 32 位二进制串(高位在前) -void printBits(const int bits[]) { - for (int i = LEN - 1; i >= 0; i--) { - cout << bits[i]; - } - cout << '\n'; -} - -void bitAnd(const int a[], const int b[], int c[]) { - for (int i = 0; i < LEN; i++) c[i] = a[i] & b[i]; -} - -void bitOr(const int a[], const int b[], int c[]) { - for (int i = 0; i < LEN; i++) c[i] = a[i] | b[i]; -} - -void bitXor(const int a[], const int b[], int c[]) { - for (int i = 0; i < LEN; i++) c[i] = a[i] ^ b[i]; -} - -void bitNot(const int a[], int c[]) { - for (int i = 0; i < LEN; i++) c[i] = 1 - a[i]; -} - -// 32 位无符号加法:溢出进位自动丢弃 -void addBits(const int a[], const int b[], int c[]) { - int carry = 0; - for (int i = 0; i < LEN; i++) { - int sum = a[i] + b[i] + carry; - c[i] = sum % 2; - carry = sum / 2; - } -} - -// 32 位无符号减法:逐位借位 -void subBits(const int a[], const int b[], int c[]) { - int borrow = 0; - for (int i = 0; i < LEN; i++) { - int cur = a[i] - b[i] - borrow; - if (cur >= 0) { - c[i] = cur; - borrow = 0; - } else { - c[i] = cur + 2; - borrow = 1; - } - } -} - -int main() { - unsigned int A, B; - cin >> A >> B; - - int a[LEN], b[LEN], c[LEN]; - toBits(A, a); - toBits(B, b); - - cout << "A = "; printBits(a); - cout << "B = "; printBits(b); - - bitAnd(a, b, c); - cout << "A AND B= "; printBits(c); - - bitOr(a, b, c); - cout << "A OR B= "; printBits(c); - - bitXor(a, b, c); - cout << "A XOR B= "; printBits(c); - - bitNot(a, c); - cout << "NOT A = "; printBits(c); - - addBits(a, b, c); - cout << "A + B = " << toUInt(c) << '\n'; - - subBits(a, b, c); - cout << "A - B = " << toUInt(c) << '\n'; - - return 0; -} -``` - ---- - -## 七、练习题 - -### 【第一组】按位运算热身(进阶版,8 位) - -已知: - -- `a = 00101101` -- `b = 00010111` -1. 求 `a & b`。 -2. 求 `a | b`。 -3. 求 `a ^ b`。 -4. 求 `~a`。 -5. 求 `~b`。 -6. 求 `(a & b) ^ a`。 -7. 求 `(a | b) ^ b`。 -8. 求 `(a ^ b) & a`。 -9. 求 `(a ^ b) | b`。 -10. 求 `(~a) & b`。 -11. 求 `(~b) | a`。 -12. 求 `a & (~b)`。 -13. 求 `(a | b) & (a ^ b)`。 - -再设: - -- `c = 01011000` -- `d = 00110101` -14. 求 `c & d`。 -15. 求 `c | d`。 -16. 求 `c ^ d`。 -17. 求 `(c ^ d) ^ c`。 -18. 求 `(c & d) | (c ^ d)`。 -19. 求 `~(c ^ d)`。 -20. 求 `(~c) ^ d`。 - -再做移位: - -21. 求 `a << 1`(8 位)。 -22. 求 `a << 3`(8 位)。 -23. 求 `a >> 2`(8 位)。 -24. 求 `b >> 1`(8 位)。 -25. 求 `(a << 2) & 0b11111111`(8 位掩码保留)。 -26. 求 `(b << 1) ^ (a >> 2)`(8 位)。 - ---- - -### 【第二组】真值与规律(先判断,再写一句理由) - -27. 对任意位串 `x`,是否总有 `x ^ x == 0`? -28. 对任意位串 `x`,是否总有 `x & x == x`? -29. 对任意位串 `x`,是否总有 `x | x == x`? -30. 对任意位串 `x`,是否总有 `x ^ 0 == x`? -31. 对任意位串 `x`,是否总有 `x ^ FULL_MASK == ~x`?(其中 `FULL_MASK` 指整个位宽全 1) -32. 对任意位串 `x`,是否总有 `(~x) & x == 0`? -33. 对任意位串 `x`,是否总有 `(~x) | x == FULL_MASK`? -34. 对任意非负整数 `x`,是否总有 `(x << 1) == 2 * x`? -35. 对任意非负整数 `x`,是否总有 `(x >> 1) == x / 2`(整除)? -36. 若 `x` 是 2 的幂,是否总有 `x > 0 && (x & (x - 1)) == 0`? - ---- - -### 【第三组】加减法进阶(8 位,丢弃溢出位) - -37. 计算:`00000101 + 00000110` -38. 计算:`11111111 + 00000001` -39. 计算:`00001010 - 00000011` -40. 计算:`00000000 - 00000001` -41. 计算:`10000000 + 10000000` -42. 计算:`01111111 + 00000001` -43. 计算:`01010101 + 00110011` -44. 计算:`00100000 - 00011111` -45. 计算:`00010000 - 00100000` -46. 计算:`10101010 - 01010101` - ---- - -### 【第四组】逆向构造题(更像算法题) - -设 `a = 11001010`,求一个 8 位 `x`,使得: - -47. `a & x == 10001000`(若有多解,写出任意一个) -48. `a | x == 11101110`(若有多解,写出任意一个) -49. `a ^ x == 01100111`(写唯一解) - -再设 `u = 00110110`,`v = 00000110`: - -50. 构造一个 8 位 `y`,使得 `y & u == v`。 -51. 判断是否存在 8 位 `z`,使得 `z | u == v`,若存在给出一个,若不存在说明原因。 - ---- - -### 【第五组】常用位技巧(探究题,重点) - -这一组不要先背公式,先按题目把例子算出来,再归纳。 - -#### A. 探究“最低位 1”(lowbit) - -对下面每个 `x`,先写出二进制,再计算 `-x`(按补码),最后算出 `x & (-x)`: - -52. `x = 12` - -53. `x = 40` - -54. `x = 44` - -55. `x = 72` - -56. 观察 52-55 的结果,归纳一句话:`x & (-x)` 保留了 `x` 的哪一部分? - -#### B. 探究“去掉最低位 1” - -对下面每个 `x`,计算 `x - 1`,再算 `x & (x - 1)`: - -57. `x = 12` - -58. `x = 40` - -59. `x = 44` - -60. `x = 72` - -61. 观察 57-60 的结果,归纳一句话:`x & (x-1)` 对二进制位做了什么变化? - -#### C. 由例子得到“2 的幂”判定 - -分别计算 `x & (x - 1)`,并记录是否为 0: - -62. `x = 1` - -63. `x = 2` - -64. `x = 4` - -65. `x = 8` - -66. `x = 3` - -67. `x = 6` - -68. 根据 62-67,总结:当 `x > 0` 时,什么条件等价于“`x` 是 2 的幂”? - -#### D. 应用题(把结论用起来) - -69. 不用循环,判断 `64` 是否是 2 的幂,并写出关键表达式值。 -70. 不用循环,判断 `72` 是否是 2 的幂,并写出关键表达式值。 -71. 设 `x = 01011000`(8 位),先求 `x & (-x)`,再给出最低位 1 的位置(最低位记第 0 位)。 -72. 设 `x = 00101000`(8 位),先求 `x & (-x)`,再给出最低位 1 的位置(最低位记第 0 位)。 -73. 设 `x = 10000000`(8 位),先求 `x & (-x)`,再给出最低位 1 的位置(最低位记第 0 位)。 -74. 从 `x = 90` 开始,反复执行 `x = x & (x - 1)` 直到变成 0,需要几步?由此得到 `90` 的二进制中有几个 1? -75. 给定偶数 `n`,写出一个表达式快速判断它是否能被 4 整除,并说明对应的“二进制末尾特征”。 - -## 参考答案 - -**第一组** - -1. `00000101` -2. `00111111` -3. `00111010` -4. `11010010` -5. `11101000` -6. `00101000` -7. `00101000` -8. `00101000` -9. `00111111` -10. `00010010` -11. `11101101` -12. `00101000` -13. `00111010` -14. `00010000` -15. `01111101` -16. `01101101` -17. `00110101` -18. `01111101` -19. `10010010` -20. `10010010` -21. `01011010` -22. `01101000` -23. `00001011` -24. `00001011` -25. `10110100` -26. `00100101` - -**第二组** - -27. 是。 -28. 是。 -29. 是。 -30. 是。 -31. 是(全 1 掩码下逐位翻转)。 -32. 是。 -33. 是。 -34. 在不溢出的前提下是。 -35. 是(无符号或非负整数语境下)。 -36. 是。 - -**第三组** - -37. `00001011`(十进制 11) -38. `00000000`(十进制 0) -39. `00000111`(十进制 7) -40. `11111111`(十进制 255) -41. `00000000`(十进制 0) -42. `10000000`(十进制 128) -43. `10001000`(十进制 136) -44. `00000001`(十进制 1) -45. `11110000`(十进制 240) -46. `01010101`(十进制 85) - -**第四组(给一种可行解)** - -47. 可取 `x = 10001100`。 -48. 可取 `x = 01100100`。 -49. 唯一解 `x = 10101101`。 -50. 可取 `y = 11100110`(只要在 `u` 为 1 的位上与 `v` 对齐即可,`u` 为 0 的位任意)。 -51. 不存在,因为按位或不会把 `u` 中的 1 变成 0,而 `u = 00110110` 在第 5、4、2、1 位已有 1,但 `v = 00000110` 在第 5、4 位是 0。 - -**第五组** - -52. `12 = 1100`,`-12`(8 位)是 `11110100`,`12 & (-12) = 0100`(十进制 4) -53. `40 = 101000`,`40 & (-40) = 001000`(十进制 8) -54. `44 = 101100`,`44 & (-44) = 000100`(十进制 4) -55. `72 = 1001000`,`72 & (-72) = 0001000`(十进制 8) -56. 结论:`x & (-x)` 只保留最低位的 1,其余位清零(即 lowbit) -57. `12 & 11 = 1100 & 1011 = 1000`(十进制 8) -58. `40 & 39 = 101000 & 100111 = 100000`(十进制 32) -59. `44 & 43 = 101100 & 101011 = 101000`(十进制 40) -60. `72 & 71 = 1001000 & 1000111 = 1000000`(十进制 64) -61. 结论:`x & (x-1)` 会把最低位 1 消掉,且更低位保持为 0 -62. `1 & 0 = 0` -63. `2 & 1 = 0` -64. `4 & 3 = 0` -65. `8 & 7 = 0` -66. `3 & 2 = 2`(非 0) -67. `6 & 5 = 4`(非 0) -68. 结论:`x > 0 && (x & (x - 1)) == 0` 当且仅当 `x` 是 2 的幂 -69. `64 & 63 = 0`,所以是 2 的幂 -70. `72 & 71 = 64`,非 0,所以不是 2 的幂 -71. lowbit 是 `00001000`(8),最低位 1 在第 3 位 -72. lowbit 是 `00001000`(8),最低位 1 在第 3 位 -73. lowbit 是 `10000000`(128),最低位 1 在第 7 位 -74. `90 -> 88 -> 80 -> 64 -> 0`,共 4 步,所以有 4 个 1 -75. 可用 `(n & 3) == 0`,对应二进制末两位为 `00` diff --git a/web/doc/3.3 高阶位运算.md b/web/doc/3.3 高阶位运算.md deleted file mode 100644 index f10f3fc..0000000 --- a/web/doc/3.3 高阶位运算.md +++ /dev/null @@ -1,1222 +0,0 @@ -# 3.3 高阶位运算 - ---- - -## 一、这一节要学什么? - -在上一节里,我们已经会了最基础的按位与、按位或、按位异或、取反、左移、右移。接下来要进入真正“能拿来做题”的部分。 - -这一节的重点不是再背几个符号,而是学会把位运算当成一套工具箱来使用。你会看到: - -- 怎么只改某一位、不动别的位; -- 怎么一次性提取一段二进制位; -- 怎么快速找到“最低位的 1”; -- 怎么在 $O(1)$ 时间判断一个数是不是 2 的幂; -- 怎么用异或找“只出现一次”的数; -- 怎么把“选或不选”压成一个整数,枚举所有方案。 - -如果说 3.2 还是“认识工具”,那 3.3 更像是“学会用工具解题”。 - ---- - -## 二、先介绍 `unsigned` - -这一节我们主要讨论“非负整数”的位运算,所以在 C++ 里,优先推荐使用 `unsigned` 类型。 - -原因很简单: - -- 它本来就不表示负数; -- 做位运算时,不容易被“符号位”干扰; -- 像右移这样的操作,课堂里更容易讲清楚。 - -### 1. `unsigned int` 是什么 - -```cpp -unsigned int x; -``` - -它表示无符号整数,也就是只能存 $0$ 和正整数,不能存负数。 - -在大多数 OJ 和常见编译环境里: - -- `int` 通常是 32 位; -- `unsigned int` 也通常是 32 位。 - -区别在于: - -- `int` 要留一部分范围给负数; -- `unsigned int` 把全部 32 位都拿来表示非负数。 - -所以常见范围可以记成: - -- `int`:大约 $-2^{31}$ 到 $2^{31}-1$; -- `unsigned int`:$0$ 到 $2^{32}-1$。 - -如果课堂里讨论的是“32 位二进制串”,那么 `unsigned int` 非常合适。 - -### 2. `unsigned long long` 是什么 - -```cpp -unsigned long long x; -``` - -它也是无符号整数,只是位数更大。常见环境里,它通常是 64 位。 - -所以常见范围可以记成: - -- `unsigned long long`:$0$ 到 $2^{64}-1$。 - -它适合下面这些场景: - -- 位数可能超过 32 位; -- 要写 `1 << k`,而 `k` 可能比较大; -- 需要把更长的二进制状态装进一个整数。 - -例如: - -```cpp -unsigned long long x = 1ull << 40; -``` - -这里如果你写成 `1 << 40`,就很危险,因为 `1` 默认是 `int`,位宽不够。写成 `1ull` 才表示“这是一个 64 位无符号整数 1”。 - -### 3. 什么时候用哪一个? - -- 只讨论 32 位以内的普通位运算题:优先用 `unsigned int`。 -- 可能涉及更高位,或者要安全地写较大的移位:优先用 `unsigned long long`。 - -课堂里可以先把这条经验记住: - -> 32 位用 `unsigned int`,64 位用 `unsigned long long`。 - -### 4. 输入和输出怎么写 - -#### `unsigned int` - -```cpp -unsigned int x; -cin >> x; -cout << x << '\n'; -``` - -#### `unsigned long long` - -```cpp -unsigned long long x; -cin >> x; -cout << x << '\n'; -``` - -和普通整数一样直接输入输出就可以。 - -### 5. 为什么这一节更推荐 `unsigned` - -例如下面这个式子: - -```cpp -x >> 1 -``` - -如果 `x` 是无符号数,我们就可以直接把它理解成“所有二进制位整体右移一格,左边补 0”。 - -如果 `x` 是有符号数,右移时很多语言还会涉及“符号扩展”,课堂理解会麻烦得多。 - -所以这一节讨论位运算技巧时,默认主要站在 `unsigned` 的角度来讲。 - -### 6. 顺便提一句 `bitset` - -虽然这一节主线不用 `bitset`,但你以后看题解或写调试代码时,还是会经常见到它。 - -最常见的用法是: - -```cpp -#include -#include -using namespace std; - -int main() { - bitset<8> bs(13); // 把十进制 13 转成 8 位二进制 00001101 - cout << bs << '\n'; // 直接输出整串二进制 - cout << bs.count() << '\n'; // 统计二进制里有几个 1 - cout << bs[0] << '\n'; // 读取最低位 - return 0; -} -``` - -它比较适合做这些事: - -- 把一个整数的二进制形式直接打印出来; -- 快速观察某几位的变化; -- 写一些“看位”的小工具。 - -但是它也有很明显的缺陷,所以这节不把它当主角: - -- 长度必须在编译时写死,不像数组或 `vector` 那样灵活; -- 像 `x & (-x)`、`x & (x - 1)`、`x + 1`、`x - 1` 这类高阶技巧,本质上还是整数运算更直接; -- 若频繁在 `bitset` 和整数之间来回转换,代码会更绕; -- `bs[0]` 是最低位,但输出时最高位在左,初学者很容易看反。 - -所以可以把它理解成一句话: - -> `bitset` 适合“展示二进制”,不太适合替代这一节里的核心整数技巧。 - ---- - -## 三、先建立一个核心概念:掩码 mask - -高阶位运算里最常见的词就是“掩码”。 - -你可以把掩码理解成一张“筛子”: - -- 掩码某一位是 1,表示这一位要参与操作; -- 掩码某一位是 0,表示这一位尽量保持不动,或者被过滤掉。 - -例如,设 - -```text -x = 11010110 -mask = 00001111 -``` - -那么: - -```text -x & mask = 00000110 // 只保留末 4 位 -x | mask = 11011111 // 末 4 位全部变成 1 -x ^ mask = 11011001 // 末 4 位全部翻转 -x & ~mask = 11010000 // 末 4 位全部清零 -``` - -所以,许多位运算题本质上都在做两件事: - -1. 先构造出一个合适的掩码。 -2. 再用 `&`、`|`、`^`、`~` 去操作它。 - -这一节后面几乎所有公式,都可以看成是“掩码 + 位运算”的组合。 - ---- - -## 四、最常用的 4 个单点操作 - -下面默认: - -- 右起最低位编号为第 0 位; -- 第 $k$ 位指的是右起第 $k$ 位; -- 用 `unsigned int x` 表示一个 32 位状态。 - -设 `x` 是原数,那么: - -### 1. 把第 k 位变成 1 - -```cpp -x |= (1u << k); -``` - -原因:`1u << k` 只有第 $k$ 位是 1,和 `x` 按位或以后,第 $k$ 位一定变成 1,其余位不受影响。 - -### 2. 把第 k 位变成 0 - -```cpp -x &= ~(1u << k); -``` - -原因:`1u << k` 只有第 $k$ 位是 1,取反后只有第 $k$ 位是 0。再和 `x` 按位与,第 $k$ 位就会被清成 0,其余位保持不变。 - -### 3. 把第 k 位翻转 - -```cpp -x ^= (1u << k); -``` - -原因:异或 1 会翻转,异或 0 保持不变。 - -### 4. 读取第 k 位是 0 还是 1 - -```cpp -unsigned int bit = (x >> k) & 1u; -``` - -先把第 $k$ 位移到最低位,再和 1 相与,只保留这一位。 - -### 演示 - -设: - -```text -x = 00101101 -``` - -若 `k = 3`,那么第 3 位原本是 1。 - -```text -1u << 3 = 00001000 -x | (1u << 3) = 00101101 // 本来就是 1,不变 -x & ~(1u << 3) = 00100101 // 第 3 位清零 -x ^ (1u << 3) = 00100101 // 第 3 位翻转 -(x >> 3) & 1 = 1 -``` - -### 对应程序 1:单点位编辑器 - -下面程序支持 4 类操作:设置某位、清零某位、翻转某位、查询某位。 - -```cpp -#include -using namespace std; - -int main() { - ios::sync_with_stdio(false); - cin.tie(nullptr); - - unsigned int x; - int q; - cin >> x >> q; // 读入初始状态和操作次数 - - while (q--) { - string op; - int k; - cin >> op >> k; // 读入操作名和位编号 - - if (op == "SET") { - x |= (1u << k); // 把第 k 位设为 1 - } else if (op == "CLEAR") { - x &= ~(1u << k); // 把第 k 位清成 0 - } else if (op == "FLIP") { - x ^= (1u << k); // 把第 k 位翻转 - } else if (op == "TEST") { - cout << ((x >> k) & 1u) << '\n'; // 输出第 k 位当前是 0 还是 1 - } - } - - cout << x << '\n'; // 输出最终状态的十进制值 - return 0; -} -``` - ---- - -## 五、连续区间上的位操作 - -真正的题目里,很多时候不是只改 1 位,而是要改“连续一段”。这时就要学会构造“连续若干个 1”的掩码。 - -### 1. 保留末 k 位 - -```cpp -x & ((1u << k) - 1) -``` - -因为: - -```text -1u << k = 1000...000 (1 后面 k 个 0) -(1u << k)-1 = 0111...111 (低 k 位全是 1) -``` - -例如: - -```text -x = 11010110 -k = 4 -(1u << 4) - 1 = 00001111 -x & 00001111 = 00000110 -``` - -### 2. 把末 k 位全部清零 - -```cpp -x & ~((1u << k) - 1) -``` - -例如: - -```text -x = 11010110 -mask = 00001111 -~mask = 11110000 -x & ~mask = 11010000 -``` - -### 3. 取出第 l 到第 r 位这段二进制 - -假设 $0 \le l \le r$,并且位编号仍然从右往左、从 0 开始。 - -公式: - -```cpp -(x >> l) & ((1u << (r - l + 1)) - 1) -``` - -思路是两步: - -1. 先把第 $l$ 位移到最低位。 -2. 再保留低 $(r-l+1)$ 位。 - -例如: - -```text -x = 11010110 -取第 2 到第 5 位 - -x >> 2 = 00110101 -保留低 4 位 = 00000101 -``` - -所以第 2 到第 5 位组成的数是 `0101`,即十进制 5。 - -### 竖式感受 1:为什么“右移再与掩码”能取出一段位 - -还是以 `x = 11010110`,取第 2 到第 5 位为例: - -```text -x = 1 1 0 1 0 1 1 0 -x >> 2 = 0 0 1 1 0 1 0 1 -mask = 0 0 0 0 1 1 1 1 ------------------------- -结果 = 0 0 0 0 0 1 0 1 -``` - -从右往左看,原来第 2 到第 5 位的内容是 `0101`,右移后它被搬到了最低 4 位,再与上 `1111`,其他位就被全部滤掉了。 - -### 4. 用 y 替换 x 的第 l 到第 r 位 - -公式: - -```cpp -unsigned int updateBits(unsigned int x, unsigned int y, int l, int r) { - unsigned int mask = (1u << (r - l + 1)) - 1; - x &= ~(mask << l); // 先清空这一段 - x |= ((y & mask) << l); // 再把 y 的低若干位填进去 - return x; -} -``` - -例如: - -```text -x = 10000000000 -y = 10101 -l = 2, r = 6 -``` - -替换后得到: - -```text -10001010100 -``` - -这正是“更新二进制位”这类题的标准做法。 - -### 竖式感受 2:区间替换到底做了哪两步 - -设 `x = 11101101`,把第 1 到第 3 位替换成 `y = 010`。 - -```text -x = 1 1 1 0 1 1 0 1 -mask = 0 0 0 0 1 1 1 0 -clear x = 1 1 1 0 0 0 0 1 -y << 1 = 0 0 0 0 0 1 0 0 ------------------------- -结果 = 1 1 1 0 0 1 0 1 -``` - -你可以把“区间替换”理解成两个连续动作: - -1. 先把目标区间擦干净; -2. 再把新内容平移到对应位置后填进去。 - -### 对应程序 2:区间取位与区间替换 - -```cpp -#include -using namespace std; - -unsigned int extractBits(unsigned int x, int l, int r) { - unsigned int mask = (1u << (r - l + 1)) - 1; // 低 len 位全是 1 - return (x >> l) & mask; // 先右移,再保留低位 -} - -unsigned int updateBits(unsigned int x, unsigned int y, int l, int r) { - unsigned int mask = (1u << (r - l + 1)) - 1; // 先得到这一段的基础掩码 - x &= ~(mask << l); // 把 x 的 [l, r] 区间清零 - x |= ((y & mask) << l); // 把 y 的低若干位平移后填进去 - return x; // 返回替换后的结果 -} - -int main() { - ios::sync_with_stdio(false); - cin.tie(nullptr); - - unsigned int x, y; - int l, r; - cin >> x >> y >> l >> r; // 读入原数、新数和区间端点 - - cout << extractBits(x, l, r) << '\n'; // 输出取出的这一段 - cout << updateBits(x, y, l, r) << '\n'; // 输出区间替换后的结果 - return 0; -} -``` - -> 说明:上面程序默认 `r - l + 1 < 32`。如果可能用到更高位,建议把 `1u` 改成 `1ull`,并把类型换成 `unsigned long long`。 - ---- - -## 六、`x & (-x)`:只保留最低位的 1 - -这是位运算里最经典的高阶技巧之一,也常被叫做 `lowbit(x)`。 - -公式: - -```cpp -x & (-x) -``` - -它的作用是: - -> 只保留 `x` 二进制中最右边的那个 1,其余位全部清零。 - -### 例子 1 - -```text -x = 44 = 101100 -x & (-x) = 000100 = 4 -``` - -说明最低位的 1 在第 2 位,它的权值是 4。 - -### 例子 2 - -```text -x = 72 = 1001000 -x & (-x) = 0001000 = 8 -``` - -### 竖式感受:`x & (-x)` 为什么只剩一个 1 - -以 8 位下 `x = 44` 为例: - -```text -x = 0 0 1 0 1 1 0 0 -~x = 1 1 0 1 0 0 1 1 -~x + 1 = 1 1 0 1 0 1 0 0 (这就是 -x 的补码) ------------------------- -x & (-x) = 0 0 0 0 0 1 0 0 -``` - -最右边那个 1 被单独保留下来,其余位都在按位与时被消掉了。 - -### 为什么成立? - -设一个数的二进制长成这样: - -```text -x = ?????1000...000 -``` - -也就是: - -- 最低位的 1 左边是什么无所谓; -- 最低位的 1 右边全是 0。 - -那么它的相反数 `-x` 在补码里,会恰好保留这一位对应的权值,和 `x` 相与以后,就只剩下这一个 1。 - -你不必每次都重新推补码,记住结论即可: - -```cpp -unsigned int lowbit = x & -x; -``` - -在这里把 `x` 看成无符号整数,重点理解“二进制位模式”就够了。 - -### `lowbit` 有什么用? - -- 找最低位的 1; -- 判断某个数能被多少个 2 连续整除; -- 树状数组里跳步; -- 把一个状态拆成若干个单独的二进制位。 - ---- - -## 七、`x & (x - 1)`:消掉最低位的 1 - -公式: - -```cpp -x & (x - 1) -``` - -它的作用是: - -> 把 `x` 最低位的那个 1 清掉,其他更高位尽量保持不变。 - -### 为什么成立? - -设: - -```text -x = ?????1000...000 -x - 1 = ?????0111...111 -``` - -那么: - -```text -x & (x - 1) = ?????0000...000 -``` - -也就是说,最低位的 1 被清掉了。 - -### 例子 - -```text -x = 90 = 1011010 - -第一次:1011010 & 1011001 = 1011000 = 88 -第二次:1011000 & 1010111 = 1010000 = 80 -第三次:1010000 & 1001111 = 1000000 = 64 -第四次:1000000 & 0111111 = 0000000 = 0 -``` - -共做了 4 次才变成 0,所以 90 的二进制里有 4 个 1。 - -### 竖式感受:`x - 1` 会先改掉哪些位 - -以 8 位下 `x = 90 = 01011010` 为例: - -```text -x = 0 1 0 1 1 0 1 0 -x - 1 = 0 1 0 1 1 0 0 1 ------------------------- -x & (x - 1) = 0 1 0 1 1 0 0 0 -``` - -从右往左看,最低位那个 1 被清掉了,而它右边发生变化的部分在按位与后也全部消失,于是只剩“去掉最低位 1”后的结果。 - -### 用它统计 1 的个数 - -```cpp -int popcount(unsigned int x) { - int cnt = 0; - while (x) { - x &= (x - 1); // 每次清掉一个最低位的 1 - ++cnt; // 记录一共清掉了多少次 - } - return cnt; -} -``` - -循环几次,就有几个 1。 - -### 用它判断 2 的幂 - -如果一个正整数是 2 的幂,那么它的二进制里恰好只有一个 1。 - -所以: - -```cpp -x > 0 && (x & (x - 1)) == 0 -``` - -成立,当且仅当 `x` 是 2 的幂。 - -例如: - -- `8 = 1000`,`8 & 7 = 0`,所以是 2 的幂; -- `12 = 1100`,`12 & 11 = 8`,不是 0,所以不是 2 的幂。 - -### 对应程序 3:`lowbit`、统计 1 的个数、判断 2 的幂 - -```cpp -#include -using namespace std; - -unsigned int lowbit(unsigned int x) { - return x & (~x + 1u); // 只保留最低位的 1 -} - -int popcount(unsigned int x) { - int cnt = 0; - while (x) { - x &= (x - 1); // 每次消掉一个最低位的 1 - ++cnt; // 消掉几次,就说明原来有几个 1 - } - return cnt; -} - -bool isPowerOfTwo(unsigned int x) { - return x > 0 && (x & (x - 1)) == 0; // 正数且只含一个 1 -} - -int main() { - ios::sync_with_stdio(false); - cin.tie(nullptr); - - unsigned int x; - cin >> x; // 读入一个非负整数 - - cout << lowbit(x) << '\n'; // 输出最低位 1 的权值 - cout << popcount(x) << '\n'; // 输出二进制中 1 的个数 - cout << (isPowerOfTwo(x) ? "YES" : "NO") << '\n'; // 输出是否为 2 的幂 - return 0; -} -``` - -这里有两个细节值得注意: - -- `lowbit(x)` 和 `x & (-x)` 是同一个意思; -- 统计 1 的个数时,循环次数正好等于 1 的个数。 - ---- - -## 八、右边连续的 1 和连续的 0 - -很多位运算题,专门喜欢考“最右边连续的一段”。下面这些式子都很常见。 - -### 1. `x & (x + 1)`:把右边连续的 1 清零 - -例如: - -```text -x = 10101111 -x + 1 = 10110000 -结果 = 10100000 -``` - -也就是最右边那一串连续的 1 全没了。 - -### 竖式感受 1:`x & (x + 1)` 和 `x | (x + 1)` - -以 `x = 10101111` 为例: - -```text -x = 1 0 1 0 1 1 1 1 -x + 1 = 1 0 1 1 0 0 0 0 ------------------------- -x & (x + 1) = 1 0 1 0 0 0 0 0 -x | (x + 1) = 1 0 1 1 1 1 1 1 -``` - -所以: - -- `x & (x + 1)` 会把最右边连续的 1 全清掉; -- `x | (x + 1)` 会把右起第一个 0 变成 1。 - -### 2. `x | (x + 1)`:把右起第一个 0 变成 1 - -例如: - -```text -x = 10101111 -x + 1 = 10110000 -结果 = 10111111 -``` - -右起第一个 0 被点亮了,而它右边那一串 1 本来就是 1。 - -### 3. `x | (x - 1)`:把右边连续的 0 变成 1 - -例如: - -```text -x = 10110000 -x - 1 = 10101111 -结果 = 10111111 -``` - -于是最右边那一串 0 全被填成 1。 - -### 4. `~x & (x + 1)`:取出最低位的 0 - -例如: - -```text -x = 10101111 -~x = 01010000 -x + 1 = 10110000 -结果 = 00010000 -``` - -这表示“最右边的那个 0”的权值。 - -### 竖式感受 2:`x | (x - 1)` 和 `~x & (x + 1)` - -先看 `x | (x - 1)`,取 `x = 10110000`: - -```text -x = 1 0 1 1 0 0 0 0 -x - 1 = 1 0 1 0 1 1 1 1 ------------------------- -x | (x - 1) = 1 0 1 1 1 1 1 1 -``` - -这说明右边连续的 0 被全部填成了 1。 - -再看 `~x & (x + 1)`,取 `x = 10101111`: - -```text -x = 1 0 1 0 1 1 1 1 -~x = 0 1 0 1 0 0 0 0 -x + 1 = 1 0 1 1 0 0 0 0 ------------------------- -~x & (x + 1) = 0 0 0 1 0 0 0 0 -``` - -可以看到,最后只留下了最右边那个 0 对应的位置。 - -### 这些式子有什么用? - -- 做状态转移时修改最右边某一段位; -- 写一些构造题; -- 做二进制规律观察题; -- 快速处理“连续 1”或“连续 0”。 - -先别急着死背,建议自己随手写几个二进制例子验证一下,印象会更深。 - ---- - -## 九、异或的高阶用法 - -异或在基础运算里看起来只是“不同为 1,相同为 0”,但它在算法里特别有力量,因为它满足下面这些重要性质: - -- `a ^ a = 0` -- `a ^ 0 = a` -- 满足交换律和结合律 - -这意味着: - -> 相同的数异或两次会被“抵消掉”。 - -### 1. 找出只出现一次的数 - -如果一个数组里,除了一个数外,其余每个数都出现两次,那么把所有数异或起来,最后剩下的就是那个只出现一次的数。 - -例如: - -```text -12 ^ 7 ^ 9 ^ 12 ^ 7 = 9 -``` - -因为 `12 ^ 12 = 0`,`7 ^ 7 = 0`,只剩 `9`。 - -### 竖式感受:为什么异或能把成对元素消掉 - -还是看: - -```text -12 ^ 7 ^ 9 ^ 12 ^ 7 -``` - -利用交换律和结合律,我们可以先把相同的数挪到一起: - -```text -12 ^ 7 ^ 9 ^ 12 ^ 7 -= 12 ^ 12 ^ 7 ^ 7 ^ 9 -= 0 ^ 0 ^ 9 -= 9 -``` - -所以异或在“找只出现一次的数”这类题里特别好用,因为成对元素会自动抵消。 - -代码: - -```cpp -int singleNumber(const vector& a) { - int ans = 0; - for (int x : a) ans ^= x; // 成对元素会两两抵消 - return ans; // 最后剩下的就是只出现一次的数 -} -``` - -### 2. 找出两个只出现一次的数 - -如果数组里恰好有两个数只出现一次,其他数都出现两次,那么: - -1. 先异或全部元素,得到 `xor_all = p ^ q`; -2. `p` 和 `q` 至少有一位不同,所以 `xor_all` 至少有一位是 1; -3. 取出这最低位的 1:`low = xor_all & -xor_all`; -4. 用这 1 位把所有数分成两组; -5. 两组内分别异或,就能分别得到 `p` 和 `q`。 - -代码: - -```cpp -pair twoSingles(const vector& a) { - int xor_all = 0; - for (int x : a) xor_all ^= x; // 得到两个目标数的异或值 - - int low = xor_all & -xor_all; // 取出它们最低位上不同的那一位 - int p = 0, q = 0; - for (int x : a) { - if (x & low) p ^= x; // 这一组中成对元素抵消后,剩下其中一个目标数 - else q ^= x; // 另一组同理 - } - if (p > q) swap(p, q); // 输出时按从小到大排列 - return {p, q}; -} -``` - -### 3. 不用 `+` 求两数之和 - -这也是一道经典题。 - -思路: - -- `a ^ b` 相当于“不进位加法”; -- `(a & b) << 1` 就是所有进位; -- 不断把“当前和”和“进位”重新相加,直到没有进位。 - -代码: - -```cpp -int addWithoutPlus(int a, int b) { - while (b != 0) { - unsigned int carry = (static_cast(a & b) << 1); // 先算出进位 - a = a ^ b; // 再算不带进位的和 - b = static_cast(carry); // 下一轮继续把进位加进去 - } - return a; -} -``` - -### 对应程序 4:异或工具箱 - -下面程序演示三个常见功能:单异常数、双异常数、无加号求和。 - -```cpp -#include -using namespace std; - -int singleNumber(const vector& a) { - int ans = 0; - for (int x : a) ans ^= x; // 成对出现的数会两两抵消 - return ans; // 最后剩下的就是只出现一次的数 -} - -pair twoSingles(const vector& a) { - int xor_all = 0; - for (int x : a) xor_all ^= x; // 得到两个目标数的异或值 - - int low = xor_all & -xor_all; // 取出二者最低位上不同的那一位 - int p = 0, q = 0; - for (int x : a) { - if (x & low) p ^= x; // 这一组里成对元素抵消,剩下其中一个目标数 - else q ^= x; // 另一组同理 - } - if (p > q) swap(p, q); // 方便输出时从小到大 - return {p, q}; -} - -int addWithoutPlus(int a, int b) { - while (b != 0) { - unsigned int carry = (static_cast(a & b) << 1); // 这一轮产生的进位 - a = a ^ b; // 不进位加法 - b = static_cast(carry); // 下一轮继续把进位加进去 - } - return a; -} - -int main() { - ios::sync_with_stdio(false); - cin.tie(nullptr); - - int n; - cin >> n; // 读入数组长度 - vector a(n); - for (int i = 0; i < n; ++i) cin >> a[i]; // 读入数组元素 - - cout << singleNumber(a) << '\n'; // 输出“只出现一次”的单个数 - - pair ans = twoSingles(a); - cout << ans.first << ' ' << ans.second << '\n'; // 输出两个只出现一次的数 - - int x, y; - cin >> x >> y; // 再读入两个整数,演示无加号求和 - cout << addWithoutPlus(x, y) << '\n'; - return 0; -} -``` - ---- - -## 十、状态压缩:把“选或不选”压成一个整数 - -这已经是竞赛和算法里非常重要的一类位运算应用了。 - -### 1. 什么叫状态压缩? - -如果有 $n$ 个对象,每个对象只有两种状态: - -- 选 / 不选 -- 在 / 不在 -- 开 / 关 - -那么就可以用一个整数的二进制位来表示整个状态。 - -例如有 4 个学生,编号为 0、1、2、3: - -```text -mask = 0101 -``` - -表示: - -- 第 0 位是 1,选了 0 号; -- 第 1 位是 0,没选 1 号; -- 第 2 位是 1,选了 2 号; -- 第 3 位是 0,没选 3 号。 - -### 2. 集合运算和位运算的对应关系 - -设 `A`、`B` 都是状态压缩后的整数,则: - -- 并集:`A | B` -- 交集:`A & B` -- 对称差:`A ^ B` -- 差集(A 去掉 B):`A & ~B` - -### 3. 枚举所有子集 - -如果一共有 $n$ 个元素,那么所有子集一共有 $2^n$ 个,对应的状态正好就是: - -```cpp -for (int mask = 0; mask < (1 << n); ++mask) { - // mask 表示一种选法 -} -``` - -每个 `mask` 都代表一种方案。 - -### 4. 枚举某个集合 S 的所有子集 - -这是更高阶、也更常考的一种写法: - -```cpp -for (int sub = S; ; sub = (sub - 1) & S) { - // sub 是 S 的一个子集 - if (sub == 0) break; -} -``` - -它的作用是: - -> 按从大到小的顺序,把 `S` 的所有子集恰好枚举一遍。 - -### 演示 - -设: - -```text -S = 1101 -``` - -那么它的子集会依次枚举出: - -```text -1101 -1100 -1001 -1000 -0101 -0100 -0001 -0000 -``` - -这些数正好都是 `1101` 的子集状态。 - -### 竖式感受:为什么 `(sub - 1) & S` 能继续跳到下一个子集 - -还是取 `S = 1101`,看前两步: - -```text -sub = 1 1 0 1 -sub - 1 = 1 1 0 0 -(sub - 1) & S = 1 1 0 0 -``` - -继续下一步: - -```text -sub = 1 1 0 0 -sub - 1 = 1 0 1 1 -(sub - 1) & S = 1 0 0 1 -``` - -可以发现: - -- `sub - 1` 会先把最低位的 1 消掉; -- 再和 `S` 按位与,就会把不属于 `S` 的那些位全部抹掉; -- 于是就自然跳到了下一个合法子集。 - -### 对应程序 5:用状态压缩枚举所有选法 - -下面是一个很典型的“子集枚举”程序。 - -题意模型:有 $n$ 个活动,每个活动有一个得分,最多能选若干个,要求总分不超过上限 `limit`,问最大总分是多少。 - -为了方便演示,下面先假设 `n <= 20`。 - -```cpp -#include -using namespace std; - -int main() { - ios::sync_with_stdio(false); - cin.tie(nullptr); - - int n, limit; - cin >> n >> limit; // 读入活动个数和分数上限 - vector a(n); - for (int i = 0; i < n; ++i) cin >> a[i]; // 读入每个活动的得分 - - int best = 0; - for (int mask = 0; mask < (1 << n); ++mask) { - int sum = 0; - for (int i = 0; i < n; ++i) { - if ((mask >> i) & 1) { - sum += a[i]; // 第 i 位是 1,说明第 i 个活动被选中 - } - } - if (sum <= limit) { - best = max(best, sum); // 在不超上限的前提下更新最优答案 - } - } - - cout << best << '\n'; // 输出最大可行总分 - return 0; -} -``` - -这个程序就是“状态压缩 + 枚举所有子集”的最经典入门模型。 - ---- - -## 十一、位运算中的常见坑 - -高阶位运算很强,但也很容易出错。下面这些坑必须提前知道。 - -### 1. 混合运算时一定加括号 - -例如: - -```cpp -a & b == 0 -``` - -这不是你想的 `(a & b) == 0`,而是: - -```cpp -a & (b == 0) -``` - -正确写法必须是: - -```cpp -(a & b) == 0 -``` - -### 2. 讨论纯位模式时,优先使用无符号数 - -```cpp -unsigned int x; -``` - -这样可以避开一部分负数右移、符号扩展之类的问题。 - -### 3. 写掩码时尽量写 `1u` 或 `1ull` - -例如: - -```cpp -1u << k -1ull << k -``` - -比 `1 << k` 更稳,因为 `1` 默认是 `int`,移位太高时可能出问题。 - -### 4. 不要拿 `pow(2, k)` 代替 `1 << k` - -`pow` 是浮点运算,既慢又可能有精度问题。 - -如果你想得到 $2^k$,应直接写: - -```cpp -1u << k -``` - -### 5. `k` 不能乱取 - -如果是 32 位整数,`k` 最好控制在 `0` 到 `30` 或 `31` 的合理范围内。超出位宽去移位,会产生未定义行为或不符合预期的结果。 - -### 6. 异或交换知道即可,不建议滥用 - -```cpp -a ^= b; -b ^= a; -a ^= b; -``` - -虽然能交换,但可读性差,还容易在 `a` 和 `b` 指向同一位置时出问题。正常写题,直接 `swap(a, b)` 更好。 - -### 7. `unsigned` 只适合讨论“非负数位模式” - -如果题目本身涉及负数语义,比如有符号数大小比较、带符号右移效果,就不能简单地一股脑全换成 `unsigned`。 - -这一节之所以大量使用 `unsigned`,是因为重点在“观察位”“操作位”“利用二进制规律”。 - -### 8. `unsigned long long` 写移位更安全,但也不是无限大 - -```cpp -1ull << k -``` - -确实比 `1 << k` 安全得多,但它仍然只有 64 位。若 `k` 取得太离谱,依然会出问题。 - -### 9. `bitset` 适合辅助观察,但不适合硬套到所有题里 - -如果你只是想把一个数的二进制打印出来,`bitset` 很方便;但如果题目核心是 `lowbit`、清最低位的 1、连续 0/1 的构造,这些操作直接用整数写通常更短、更清楚。 - -课堂里最容易犯的错,就是为了“看起来高级”而硬把整数题改写成 `bitset` 题,结果把本来简单的规律绕复杂了。 - ---- - -## 十二、课堂速查表 - -下面把这一节最常用的表达式放在一起,方便查阅。 - -| 表达式 | 含义 | -|:--|:--| -| `unsigned int x;` | 适合 32 位无符号位运算 | -| `unsigned long long x;` | 适合 64 位无符号位运算 | -| `x | (1u << k)` | 把第 k 位设为 1 | -| `x & ~(1u << k)` | 把第 k 位设为 0 | -| `x ^ (1u << k)` | 把第 k 位翻转 | -| `(x >> k) & 1u` | 读取第 k 位 | -| `x & ((1u << k) - 1)` | 保留末 k 位 | -| `x & ~((1u << k) - 1)` | 清空末 k 位 | -| `(x >> l) & ((1u << (r - l + 1)) - 1)` | 取出第 l 到第 r 位 | -| `x & (-x)` | 只保留最低位的 1 | -| `x & (x - 1)` | 清掉最低位的 1 | -| `x > 0 && (x & (x - 1)) == 0` | 判断是否为 2 的幂 | -| `x & (x + 1)` | 把右边连续的 1 清零 | -| `x | (x + 1)` | 把右起第一个 0 变成 1 | -| `x | (x - 1)` | 把右边连续的 0 变成 1 | -| `~x & (x + 1)` | 取出最低位的 0 | -| `a ^ a = 0` | 相同的数异或会抵消 | -| `1u << k` | 构造 32 位掩码中的单个 1 | -| `1ull << k` | 构造 64 位掩码中的单个 1 | - ---- - -## 十三、这一节学完后,应该会什么? - -如果你已经能独立完成下面这些事,就说明这节真正学会了: - -- 能说清 `unsigned int` 和 `unsigned long long` 的区别与用法; -- 能写出“设置某一位、清空某一位、翻转某一位、读取某一位”的代码; -- 能用掩码提取某一段二进制位; -- 能解释 `x & (-x)` 和 `x & (x - 1)` 的含义; -- 能写出判断 2 的幂、统计 1 的个数的程序; -- 能用异或解决“只出现一次”的题; -- 能把“选或不选”的问题写成状态压缩。 - -到这里,位运算就不再只是“会算”,而是真正进入“会用”的阶段了。 diff --git a/web/doc/4.0 流程图的画法与读法.md b/web/doc/4.0 流程图的画法与读法.md deleted file mode 100644 index 9ba2f00..0000000 --- a/web/doc/4.0 流程图的画法与读法.md +++ /dev/null @@ -1,376 +0,0 @@ -# 4.0 流程图的画法与读法 - ---- - -## 一、这节课到底学什么? - -很多同学觉得流程图难,不是因为图形多,而是因为总会犯下面几种错: - -- 只盯着框看,不顺着箭头走。 -- 只看条件,不看两条分支分别去哪。 -- 看到回头箭头,没有意识到这是一段循环。 -- 自己画图时,漏了初始化、漏了结束、漏了更新变量。 - -所以这份讲义不走“纯概念说明”路线,而是直接看图、读图、再学怎么手绘。 - ---- - -## 二、先看一张图,认识流程图里最常见的 4 种框 - -```mermaid -flowchart LR - A([开始]) --> B[/输入一个数 n/] - B --> C[把 n 加 1] - C --> D{n 是偶数吗?} - D -- 是 --> E[/输出 偶数/] - D -- 否 --> F[/输出 奇数/] - E --> G([结束]) - F --> G -``` - -这张图先不用细抠题意,只要认识图形就行: - -- 圆角框:开始、结束。 -- 平行四边形:输入、输出。 -- 长方形:处理步骤,也就是“做一件事”。 -- 菱形:判断,要从这里分路。 - -你可以先把流程图想成“做事路线图”: - -- 框,表示现在做什么。 -- 箭头,表示下一步去哪。 - -> 读流程图时,真正重要的不是图画得漂不漂亮,而是你能不能顺着箭头走清楚。 - ---- - -## 三、示范 1:最基础的单判断流程图 - -题目:输入一个整数,判断它是偶数还是奇数。 - -```mermaid -flowchart TD - A([开始]) --> B[/输入 n/] - B --> C{n 能被 2 整除吗?} - C -- 是 --> D[/输出 偶数/] - C -- 否 --> E[/输出 奇数/] - D --> F([结束]) - E --> F -``` - -读这张图时,顺序应该这样说: - -1. 从“开始”出发。 -2. 输入一个整数 n。 -3. 判断 n 能不能被 2 整除。 -4. 如果能,就输出“偶数”。 -5. 如果不能,就输出“奇数”。 -6. 结束。 - -这类图最容易错的地方只有一个: - -> 判断框一定要看两条路,不能只看条件本身。 - -也就是说,你看到菱形时,要同时问自己两句: - -- 条件成立,往哪走? -- 条件不成立,往哪走? - ---- - -## 四、示范 2:看到回头箭头,就要想到“循环” - -题目:输入 n,求 1 到 n 的和。 - -```mermaid -flowchart TD - A([开始]) --> B[/输入 n/] - B --> C[sum = 0, i = 1] - C --> D{i 还没超过 n 吗?} - D -- 否 --> E[/输出 sum/] - E --> F([结束]) - D -- 是 --> G[sum = sum + i] - G --> H[i = i + 1] - H --> D -``` - -这张图里,最关键的是最后那条回头箭头: - -- 它从后面回到了前面的判断框。 -- 这说明有一段步骤要重复做。 -- 这就是循环。 - -### 拿一组小数据,顺着图走一遍 - -设 n = 4。 - -| 现在的 i | 做完以后 sum | 接下来去哪? | -|:---:|:---:|:---| -| 1 | 1 | i 变成 2,回去继续判断 | -| 2 | 3 | i 变成 3,回去继续判断 | -| 3 | 6 | i 变成 4,回去继续判断 | -| 4 | 10 | i 变成 5,回去继续判断 | -| 5 | 不再累加 | 因为 5 已经超过 4,所以输出 10 | - -这就是读流程图最稳的方法: - -> 如果看图有点晕,就拿一组很小的数据,自己沿着箭头走一遍。 - ---- - -## 五、示范 3:有些流程会“提前停止” - -题目:从 1 开始往上加,如果和第一次超过 20,就立刻输出并结束。 - -```mermaid -flowchart TD - A([开始]) --> B[/输入 n/] - B --> C[sum = 0, i = 1] - C --> D{i 还没超过 n 吗?} - D -- 否 --> E[/输出 sum/] - E --> F([结束]) - D -- 是 --> G[sum = sum + i] - G --> H{sum 已经大于 20 吗?} - H -- 是 --> E - H -- 否 --> I[i = i + 1] - I --> D -``` - -这张图比上一张多了一个判断框。 - -它告诉你: - -- 有时候流程不一定走到最下面才结束。 -- 只要中途满足条件,就可以直接输出并结束。 - -### 为什么这类图容易读错? - -因为很多同学会下意识地认为: - -“图上有的步骤,都会执行。” - -其实不是。 - -真正正确的想法是: - -> 只有你顺着箭头真的能走到那一步,那一步才会执行。 - -比如 n = 10: - -- 1 + 2 + 3 + 4 + 5 = 15。 -- 再加 6,sum 变成 21。 -- 这时已经大于 20,所以直接结束。 -- 后面的 7、8、9、10 根本不会再处理。 - ---- - -## 六、示范 4:双重循环最容易把人绕晕 - -题目:老师给你一张 3 行 4 列的表,从左到右、从上到下寻找第一个 0,找到就立刻输出它的位置。 - -```mermaid -flowchart TD - A([开始]) --> B[row = 1] - B --> C{row 还在第 1 到第 3 行吗?} - C -- 否 --> D[/输出 没找到/] - D --> E([结束]) - C -- 是 --> F[col = 1] - F --> G{col 还在第 1 到第 4 列吗?} - G -- 否 --> H[row = row + 1] - H --> C - G -- 是 --> I[/读当前位置的数 x/] - I --> J{x 是 0 吗?} - J -- 是 --> K[/输出 row 和 col/] - K --> E - J -- 否 --> L[col = col + 1] - L --> G -``` - -这一张图里,其实有两层重复: - -- 外层:一行一行看。 -- 内层:每一行里,一列一列看。 - -读双重循环时,一定要问清楚: - -- 现在正在动的是哪一个变量? -- 这一条回边,是回到内层判断,还是回到外层判断? -- 找到答案以后,是结束一层,还是结束全部? - -### 这题里有两种“结束”意思完全不同 - -第一种:一整行看完了。 - -- 这不是整张图结束。 -- 只是 col 走完了。 -- 所以下一步是 row 加 1,去下一行。 - -第二种:已经找到第一个 0。 - -- 这不是只结束当前一行。 -- 而是整个过程直接输出并结束。 - -> 双重循环最容易错的地方,不是看不见箭头,而是分不清“结束一层”和“结束全部”。 - ---- - -## 七、示范 5:分支、循环、提前结束放在同一张图里 - -题目:输入 n,求 1 到 n 中所有 3 的倍数之和;如果和第一次超过 100,就立刻停止并输出。 - -```mermaid -flowchart TD - A([开始]) --> B[/输入 n/] - B --> C[sum = 0, i = 1] - C --> D{i 还没超过 n 吗?} - D -- 否 --> E[/输出 sum/] - E --> F([结束]) - D -- 是 --> G{i 是 3 的倍数吗?} - G -- 是 --> H[sum = sum + i] - G -- 否 --> I[i = i + 1] - H --> J{sum 已经大于 100 吗?} - J -- 是 --> E - J -- 否 --> I - I --> D -``` - -这张图值得你重点观察 3 个地方: - -1. 外面有一个循环,因为最后会回到“i 还没超过 n 吗”。 -2. 中间有一个分支,因为要判断 i 是不是 3 的倍数。 -3. 还有一个提前结束,因为 sum 超过 100 时可以直接停。 - -如果你能把这张图读顺,说明你已经不是只会看“最基础单流程”了。 - ---- - -## 八、自己手绘流程图,应该怎么下笔? - -看到题目以后,不要一上来就急着画框。 - -更稳的顺序是下面这 6 步: - -### 第 1 步:先把做法写成人话 - -例如: - -1. 输入 n。 -2. 令 sum = 0,i = 1。 -3. 如果 i 已经超过 n,就输出 sum。 -4. 如果 i 是 3 的倍数,就把它加到 sum 里。 -5. 如果 sum 已经超过 100,就输出 sum。 -6. 否则 i 加 1,再继续。 - -如果这几句话都说不顺,流程图通常也画不顺。 - -### 第 2 步:先找变量 - -最常见的几类变量是: - -- 输入变量:题目给你的数。 -- 循环变量:决定“做到第几个”的变量。 -- 结果变量:最后要输出的量。 -- 标记变量:比如“是否找到”。 - -### 第 3 步:先搭大骨架 - -很多流程图,骨架其实都差不多: - -开始 → 输入 → 初始化 → 判断 → 处理 → 更新 → 回到判断 → 输出 → 结束 - -先把主干摆出来,再补细节,图就不会乱。 - -### 第 4 步:每个判断框都要有两条路 - -判断框不能只画一条路。 - -你必须写清楚: - -- 是,去哪。 -- 否,去哪。 - -### 第 5 步:循环的回边,通常回到判断框 - -很多同学会把箭头直接接回处理中间某一步,这很容易画错。 - -更常见、更稳的画法是: - -- 处理完一轮。 -- 更新变量。 -- 回到“是否继续”的判断框。 - -### 第 6 步:画完以后,用小数据手推 - -这一招非常重要。 - -你可以拿最小的几组数据来试: - -- n = 1 会怎样? -- n = 0 会怎样? -- 第一次就满足结束条件会怎样? - -如果你自己都推不顺,说明图还得改。 - ---- - -## 九、手绘时最容易犯的错误 - -下面这些错,课堂上特别常见: - -1. 漏掉开始和结束。 -2. 忘了初始化变量。 -3. 判断框只画出一条路。 -4. 循环变量没有更新,结果图会一直转圈。 -5. 回边接错位置,没有回到判断框。 -6. 双重循环里,没有分清是结束一层还是结束全部。 -7. 一个框里塞太多话,别人读不清楚。 -8. 箭头方向不清,让人只能靠猜。 - ---- - -## 十、画完之后,按这张检查单自查 - -1. 有没有明确的开始和结束? -2. 输入和输出有没有写清楚? -3. 初始化有没有漏掉? -4. 每个判断框是不是都有两条路? -5. 每个循环变量有没有更新? -6. 回头箭头是不是回到了合适的位置? -7. 如果有提前停止,是不是画清楚了? -8. 如果有双重循环,是不是分清了结束一层和结束全部? -9. 能不能拿一组小数据,从头走到尾? - -只要这 9 条都能过,这张图一般就比较靠谱了。 - ---- - -## 十一、课堂练习 - -下面 3 题,不要求你写代码,先试着手绘流程图: - -### 练习 1 - -输入 n,输出 1 到 n 中偶数的个数。 - -### 练习 2 - -从左到右读一串数,遇到 0 就停止,输出前面所有数的和。 - -### 练习 3 - -读一个 3 行 4 列的表,找到第一个大于 100 的数,输出它的位置;如果没有找到,就输出“没有”。 - -做这 3 题时,请先写“人话步骤”,再画图。 - ---- - -## 十二、这一节最该记住的几句话 - -1. 流程图不是背图形,而是按顺序表达做事步骤。 -2. 读图时,最重要的是顺着箭头走。 -3. 看到菱形,就要同时看“是”和“否”两条路。 -4. 看到回头箭头,通常就要想到循环。 -5. 不是图上写了什么都会执行,要看箭头能不能真的走到那一步。 -6. 画图前先把步骤说清楚,画完后再拿小数据手推。 - -如果你能做到这 6 条,流程图这一关就算真正入门了。 \ No newline at end of file diff --git a/web/doc/4.1 自定义函数和递归.md b/web/doc/4.1 自定义函数和递归.md deleted file mode 100644 index 8893358..0000000 --- a/web/doc/4.1 自定义函数和递归.md +++ /dev/null @@ -1,728 +0,0 @@ -# 4.1 自定义函数和递归 - ---- - -## 一、这一节到底学什么? - -这一节不要求你一下子把函数和递归全背下来。 - -你只要先抓住下面 4 件事就够了: - -1. 知道什么时候要把一段代码单独写成函数。 -2. 会写最基础的自定义函数定义。 -3. 能顺着流程图读懂“函数被调用时发生了什么”。 -4. 初步看懂递归是怎样一层一层调用、再一层一层返回的。 - -整份讲义里,我们会尽量用能直接代数字的小例子来讲,不走太空的定义路线。 - ---- - -## 二、为什么要写函数,而不是一直往下写? - -先看一种很常见的情况: - -- 你要多次做同一件事。 -- 这件事本身可以起一个名字。 -- 把它拆出去以后,主程序会更清楚。 - -比如你要处理一张全班成绩表。 - -题目要求你完成下面这些事: - -- 读入每个同学的语文、数学、英语成绩。 -- 计算每个同学的总分。 -- 计算每个同学的平均分。 -- 判断每个同学是否及格。 -- 最后输出全班总分前 3 名。 - -如果你完全不用函数,程序很可能会变成这样: - -- 主程序里一大段是在算总分。 -- 后面又来一大段是在算平均分。 -- 再后面又来一大段是在判断是否及格。 -- 如果输出前 3 名时还要反复比较、交换,主程序会更长。 - -这样写会有几个明显问题: - -- 主程序会越来越像一团挤在一起的步骤,不容易看出主线。 -- 同样的计算规则如果写了好几次,改错时很容易漏掉某一处。 -- 过几天再回头看,你很难一下分清哪一段在“算分数”,哪一段在“判及格”,哪一段在“排前 3 名”。 - -这时如果把任务拆开: - -- 写一个函数专门求总分。 -- 写一个函数专门求平均分。 -- 写一个函数专门判断是否及格。 - -主程序就会清楚很多。 - -所以你可以把“一段完成固定任务的代码”单独拿出来,给它起个名字,这就是函数。 - -你可以先把函数理解成: - -> 一个能完成某项任务的小工具。 - -主程序需要它时,就“叫它来做事”。 - ---- - -## 三、最基础的函数长什么样? - -最常见的写法是: - -```cpp -返回值类型 函数名(参数列表) -{ - 函数体 -} -``` - -先不用被名字吓住,直接把这 3 部分拆开看: - -先配一个很具体的例子: - -```cpp -int total_score(int chinese, int math, int english) -{ - int sum = chinese + math + english; - return sum; -} -``` - -这个函数做的事非常明确: - -- 给它语文、数学、英语 3 个分数。 -- 它帮你算出总分。 -- 最后把总分交回来。 - -### 1. 返回值类型 - -表示这个函数做完以后,要交回什么类型的结果。 - -例如: - -- `int`:交回一个整数。 -- `double`:交回一个小数。 -- `bool`:交回真或假。 -- `void`:不交回结果。 - -在刚才那个例子里: - -- `total_score` 最后交回来的是总分。 -- 总分通常是整数。 -- 所以这里写 `int`。 - -### 2. 函数名 - -就是这个函数的名字。 - -名字最好能让人一眼看出用途,比如: - -- `add` -- `is_even` -- `sum_to_n` - -如果是给六年级同学自己写,名字能看懂比“高大上”更重要。 - -像: - -- `total_score` -- `print_line` -- `sum_to_n` - -都比随便写成 `f1`、`abc` 更容易读。 - -### 3. 参数列表 - -表示调用这个函数时,要给它哪些数据。 - -例如前面的成绩函数: - -```cpp -int total_score(int chinese, int math, int english) -``` - -意思就是: - -- 这个函数叫 `total_score`。 -- 它需要 3 个整数,分别叫 `chinese`、`math`、`english`。 -- 它最后会返回一个整数,也就是总分。 - -如果把真实数字代进去,比如: - -- 语文 92 分 -- 数学 87 分 -- 英语 95 分 - -那么这个函数的任务就是算: - -$$ -92 + 87 + 95 = 274 -$$ - ---- - -## 四、函数的意义:同一件事,只写一次 - -先看一个场景。 - -你需要算 3 个同学各自的总分: - -- 小明:语文 92,数学 87,英语 95 -- 小红:语文 78,数学 85,英语 80 -- 小刚:语文 88,数学 90,英语 76 - -如果不用函数,主程序会这样写: - -```cpp -int sum1 = 92 + 87 + 95; // 小明的总分 -int sum2 = 78 + 85 + 80; // 小红的总分 -int sum3 = 88 + 90 + 76; // 小刚的总分 -``` - -如果有 30 个同学,就要写 30 行。 - -而且"加 3 个数"这件事,每次都要重复写一遍。 - -这时可以定义一个函数,把"怎么加"这件事单独写好: - -```cpp -int total_score(int chinese, int math, int english) -{ - int sum = chinese + math + english; - return sum; -} -``` - -然后在主函数里,每个同学用一行搞定: - -```cpp -int sum1 = total_score(92, 87, 95); // 小明的总分,得到 274 -int sum2 = total_score(78, 85, 80); // 小红的总分,得到 243 -int sum3 = total_score(88, 90, 76); // 小刚的总分,得到 254 -``` - -"怎么算总分"只定义了一次,却被叫了 3 次。 - -这就是函数最核心的意义: - -> 把一件事的做法写一次,想用多少次就叫多少次。 - -### 用流程图看清楚"调用"发生了什么 - -下面这张图展示的是:主函数叫了 `total_score` 两次,每次都跳出去执行函数,结束后再回来继续。 - -```mermaid -flowchart LR - subgraph M["主函数 main"] - A([开始]) --> B["准备小明的分数\n92, 87, 95"] - B --> C["调用①"] - C --> H["sum1 = 274"] - H --> I["准备小红的分数\n78, 85, 80"] - I --> J["调用②"] - J --> K["sum2 = 243"] - K --> L[/输出 sum1, sum2/] - L --> Z([结束]) - end - - subgraph F["函数 total_score(只写了一次)"] - D["收到参数"] --> E["sum = chinese + math + english"] - E --> G["return sum"] - end - - C -- "传入 92,87,95" --> D - G -- "返回 274" --> H - J -- "传入 78,85,80" --> D - G -- "返回 243" --> K -``` - -注意流程图里的关键点: - -- 每次调用,都会"跳进"函数那个框里执行。 -- 函数执行完以后,再"跳回"主函数继续往下走。 -- 函数本身的代码只写了一份,但被用了两次。 - ---- - -## 五、值传递到底是什么意思? - -这是这一节最重要的基础概念。 - -看下面这组代码: - -```cpp -int add_bonus(int score) -{ - score = score + 10; - return score; -} - -int main() -{ - int math = 87; - int new_score = add_bonus(math); -} -``` - -很多同学第一眼会担心: - -- 函数里把 `score` 改了,那外面的 `math` 会不会也变? - -这一节里,答案是: - -> 不会。 - -因为我们现在只讲值传递。 - -调用 `add(x, y)` 时,发生的是: - -调用 `add_bonus(math)` 时,发生的是: - -- 把 `math` 当前的值 87 交给函数里的 `score`。 -- 函数内部拿到的是一份新的 87。 - -所以: - -- `score` 和 `math` 不是同一个变量。 - -你可以把它理解成: - -- 主程序把这个分数抄了一份给函数。 -- 函数只是在自己的小房间里处理这份副本。 -- 函数结束以后,主程序里的原变量不受影响。 - -### 用一组数据走一遍 - -当 `math = 87` 时: - -- 进入函数时,`score = 87`。 -- 执行 `score = score + 10` 后,`score = 97`。 -- 返回 97。 - -但主函数里的: - -- `math` 还是 87。 - -最后会变成: - -- `math = 87` -- `new_score = 97` - -也就是说: - -- 原来的分数没被直接改掉。 -- 只是函数帮你算出了“加 10 分以后”的新结果。 - -这一点一定要和“函数内部变量的变化”区分开。 - ---- - -## 六、函数调用时,流程图应该怎么看? - -先看一个非常基础的例子:主函数调用 `total_score(chinese, math, english)`。 - -```mermaid -flowchart TD - A([开始]) --> B["chinese = 92, math = 87, english = 95"] - B --> C["调用 total_score(chinese, math, english)"] - C --> D["把 92, 87, 95 交给函数里的 3 个参数"] - D --> E["sum = 92 + 87 + 95"] - E --> F["return 274"] - F --> G["ans 得到返回值"] - G --> H[/输出 ans/] - H --> I([结束]) -``` - -这张图里最重要的是中间 3 步: - -1. 调用函数。 -2. 把实参的值交给形参。 -3. 函数算完以后,把结果返回。 - -### 这里有两个名字要分清 - -- 实参:调用时真正传进去的东西,比如 `chinese`、`math`、`english`。 -- 形参:函数定义里接收数据的变量,比如 `chinese`、`math`、`english` 这 3 个参数名。 - -你不需要死背这两个词,但一定要明白它们不是同一个层面的名字。 - ---- - -## 七、把“主函数”和“被调用函数”分开看,会更清楚 - -如果你总觉得函数调用时会乱,可以把它想成两块: - -- 主函数负责“发任务”。 -- 被调用函数负责“做任务”。 - -看这张图: - -```mermaid -flowchart LR - subgraph M[主函数 main] - A[准备 3 个分数] --> B["调用 total_score(...)"] - C[接住返回值 ans] --> D[/输出 ans/] - end - - subgraph F[函数 total_score] - E[收到 3 个分数] --> F1[把 3 个分数加起来] - F1 --> G[返回总分] - end - - B --> E - G --> C -``` - -这样看会更像真实过程: - -- 主函数把任务送进去。 -- `add` 做完再把结果送回来。 - -> 函数不是“贴在原地执行的一行代码”,而是一次完整的小过程。 - ---- - -## 八、什么时候用 `void` 函数? - -不是所有函数都一定要“返回一个结果”。 - -比如下面这个函数: - -```cpp -void print_line() -{ - cout << "----------" << endl; -} -``` - -它的任务只是输出一行分隔线。 - -所以: - -- 它做事。 -- 但它不需要交回一个数。 - -这时就可以写成 `void`。 - -你可以把它理解成: - -> `void` 函数负责“做动作”,不负责“交答案”。 - -如果把它放进主函数里: - -```cpp -print_line(); -cout << "欢迎来到成绩统计程序" << endl; -print_line(); -``` - -它的作用就很直观: - -- 不是算分数。 -- 不是算答案。 -- 只是帮你把输出排得更整齐。 - ---- - -## 九、递归到底是什么? - -递归只有一句核心定义: - -> 函数在自己的函数体里调用自己。 - -第一次看到这句话,很多同学会立刻觉得: - -- “那不是会一直套下去吗?” - -所以学递归时,最关键的不是先背代码,而是先抓住两件事: - -1. 一定要有“停止条件”。 -2. 每次递归都要朝着停止条件靠近。 - -如果没有停止条件,函数就会没完没了地继续调用。 - -如果虽然有停止条件,但每次都没有更接近它,那也一样会出问题。 - ---- - -## 十、先看一个最简单的递归函数 - -题目:求 1 到 n 的和。 - -我们把它写成: - -```cpp -int sum_to_n(int n) -{ - if (n == 1) - { - return 1; - } - return n + sum_to_n(n - 1); -} -``` - -这段代码可以读成: - -- 如果 `n == 1`,那答案就是 1,直接返回。 -- 如果 `n > 1`,那么 - `1 + 2 + ... + n` - 就等于 - `n + (1 + 2 + ... + (n - 1))`。 - -所以它把原问题拆成了一个更小的问题: - -- `sum_to_n(n)` -- 变成 -- `n + sum_to_n(n - 1)` - -这就是递归最常见的思路: - -> 大问题,拆成一个同类但更小的问题。 - -你可以把它想成一堆叠起来的小卡片: - -- 要算前 4 张卡片上的数字和。 -- 可以先拿最上面这一张 4。 -- 剩下的问题就变成“前 3 张卡片的和是多少”。 - -这样就从“4 张”慢慢变成“3 张”“2 张”“1 张”。 - ---- - -## 十一、递归流程图怎么画? - -先看结构图: - -```mermaid -flowchart TD - A(["进入 sum_to_n(n)"]) --> B{n == 1 吗?} - B -- 是 --> C[return 1] - B -- 否 --> D["计算 sum_to_n(n - 1)"] - D --> E[返回 n + 子问题结果] - C --> F([结束本层调用]) - E --> F -``` - -这张图里,你必须抓住两条路: - -- 一条是“直接结束”的路,也就是停止条件。 -- 一条是“继续缩小问题”的路,也就是递归调用。 - -没有前者,停不下来。 - -没有后者,就不是递归。 - ---- - -## 十二、拿 `sum_to_n(4)` 手推一遍,最重要 - -只看代码,很多同学会晕。 - -这时最稳的方法就是: - -> 拿一个很小的数,自己顺着调用过程走一遍。 - -### 第一步:往下调用 - -```text -sum_to_n(4) -= 4 + sum_to_n(3) - -sum_to_n(3) -= 3 + sum_to_n(2) - -sum_to_n(2) -= 2 + sum_to_n(1) - -sum_to_n(1) -= 1 -``` - -看到这里,终于碰到了停止条件。 - -### 第二步:往回返回 - -```text -sum_to_n(1) = 1 -sum_to_n(2) = 2 + 1 = 3 -sum_to_n(3) = 3 + 3 = 6 -sum_to_n(4) = 4 + 6 = 10 -``` - -所以最后答案是 10。 - -### 再用表格看一遍 - -| 这一层在算谁? | 它先等谁? | 等到以后自己返回多少? | -|:---:|:---:|:---:| -| `sum_to_n(4)` | 等 `sum_to_n(3)` | `4 + 6 = 10` | -| `sum_to_n(3)` | 等 `sum_to_n(2)` | `3 + 3 = 6` | -| `sum_to_n(2)` | 等 `sum_to_n(1)` | `2 + 1 = 3` | -| `sum_to_n(1)` | 不用再等 | `1` | - -这张表很重要,因为它把“先等谁、再返回多少”写得很清楚。 - ---- - -## 十三、递归最容易绕晕的地方,不在“往下”,而在“往回” - -很多同学能接受: - -- `sum_to_n(4)` 去叫 `sum_to_n(3)`。 -- `sum_to_n(3)` 再去叫 `sum_to_n(2)`。 - -但一到返回时就乱了。 - -原因通常是没有意识到: - -> 每一层函数调用,都在等自己的“下一层”先把结果交回来。 - -也就是说: - -- `sum_to_n(4)` 不能立刻算完。 -- 它必须先等 `sum_to_n(3)` 返回。 -- `sum_to_n(3)` 又得先等 `sum_to_n(2)`。 -- 一直等到最小那层先返回。 - -所以递归过程常常像两段: - -1. 一层一层往下走。 -2. 一层一层往上交答案。 - ---- - -## 十四、把递归看成“排队等结果”,会更好懂 - -再看一张图: - -```mermaid -flowchart TD - A["sum_to_n(4)"] --> B["等待 sum_to_n(3)"] - B --> C["等待 sum_to_n(2)"] - C --> D["等待 sum_to_n(1)"] - D --> E["sum_to_n(1) 返回 1"] - E --> F["sum_to_n(2) 返回 3"] - F --> G["sum_to_n(3) 返回 6"] - G --> H["sum_to_n(4) 返回 10"] -``` - -这张图要表达的重点不是代码细节,而是“顺序”: - -- 先不断往下等。 -- 再从最底层开始往回交结果。 - -你甚至可以把它读成下面这几句话: - -- 4 这一层先别急,先去问 3。 -- 3 这一层也先别急,先去问 2。 -- 2 这一层再去问 1。 -- 1 最简单,直接回答:我是 1。 -- 然后答案一层一层往回传。 - -如果你能把这张图说顺,说明你已经抓住递归最核心的运行过程了。 - ---- - -## 十五、值传递放到递归里,还是一样的 - -递归虽然看起来更复杂,但参数传递规则没有变。 - -例如: - -- 调用 `sum_to_n(4)` 时,这一层的 `n` 是 4。 -- 它再调用 `sum_to_n(3)` 时,下一层会有一个新的 `n`,值是 3。 -- 再下一层调用 `sum_to_n(2)` 时,又会有一个新的 `n`,值是 2。 - -所以: - -- 每一层都有自己的 `n`。 -- 它们不是同一个变量。 -- 只是名字都叫 `n` 而已。 - -这也是值传递的一部分: - -> 每次调用,都会得到这一层自己的那份参数值。 - ---- - -## 十六、写递归时,先问自己这两个问题 - -在真正动手写递归前,最好先问: - -### 1. 什么时候停? - -也就是停止条件是什么。 - -例如: - -- `n == 1` 时停。 -- `n == 0` 时停。 - -### 2. 怎么把问题变小? - -也就是下一次调用时,参数怎么变化。 - -例如: - -- `n - 1` -- `n / 2` - -如果这两个问题答不出来,递归代码通常也写不稳。 - ---- - -## 十七、最常见的错误 - -下面这些错非常常见: - -1. 写了递归调用,却没有停止条件。 -2. 虽然写了停止条件,但永远到不了它。 -3. 只会往下套,不会分析怎么往回返回。 -4. 把“这一层的参数”和“下一层的参数”混成同一个东西。 -5. 以为函数里的参数改了,主函数里的变量也会跟着改。 - -第 5 条在这一节里尤其要避免,因为本节只讲值传递。 - ---- - -## 十八、这一节最该记住的几句话 - -1. 函数就是把一段固定任务单独拿出来,起个名字反复用。 -2. 最基础的函数定义要看清:返回值类型、函数名、参数列表。 -3. 调用函数时,主程序是“发任务”,函数是“做任务”。 -4. 本节只讲值传递,所以函数拿到的是一份新的值,不会直接改掉外面的原变量。 -5. 递归就是函数调用自己。 -6. 递归必须同时具备两件事:停止条件、缩小问题。 -7. 读递归最稳的方法,是拿小数据手推,先看往下调用,再看往回返回。 - ---- - -## 十九、课堂练习 - -### 练习 1 - -写一个函数 `int square(int x)`,返回 `x * x`。 - -要求: - -- 先说清楚参数是什么。 -- 再说清楚返回值是什么。 - -### 练习 2 - -主函数中有 `a = 6`,调用 `triple(a)`,其中函数内部把形参乘以 3。 - -问题: - -- 函数返回什么? -- 主函数里的 `a` 会不会变? - -### 练习 3 - -把 `sum_to_n(5)` 的递归调用过程手写出来,写清楚: - -- 往下调用到了哪一层。 -- 往回返回时每层结果是多少。 - -如果这 3 题都能自己说顺,这一节就算真正入门了。 \ No newline at end of file diff --git a/web/docs.php b/web/docs.php index dd9d773..c55fec1 100644 --- a/web/docs.php +++ b/web/docs.php @@ -1,71 +1,3 @@ basename($doc_file), - 'title' => preg_replace('/\.md$/i', '', basename($doc_file)) - ); - } - } -} - -$selected_file = ''; -if (isset($_GET['file'])) { - $selected_file = basename($_GET['file']); -} - -if (empty($selected_file) && !empty($doc_entries)) { - $selected_file = $doc_entries[0]['file']; -} - -$selected_title = '文档'; -$selected_markdown = ''; -$show_selected_title = true; - -if (!empty($selected_file)) { - $selected_path = realpath($docs_dir . DIRECTORY_SEPARATOR . $selected_file); - $docs_root = realpath($docs_dir); - - if ( - $selected_path !== false && - $docs_root !== false && - strpos($selected_path, $docs_root . DIRECTORY_SEPARATOR) === 0 && - is_file($selected_path) && - preg_match('/\.md$/i', $selected_path) - ) { - $selected_markdown = file_get_contents($selected_path); - if ($selected_markdown === false) { - $selected_markdown = ''; - } else { - $selected_markdown = preg_replace('/^\xEF\xBB\xBF/', '', $selected_markdown); - } - $selected_title = preg_replace('/\.md$/i', '', basename($selected_path)); - if (preg_match('/^\s*#\s+(.+)$/mu', $selected_markdown, $heading_match)) { - $show_selected_title = normalize_doc_title($heading_match[1]) !== normalize_doc_title($selected_title); - } - } -} - -$show_title = $selected_title . ' - ' . $OJ_NAME; - -require('template/' . $OJ_TEMPLATE . '/docs.php'); -?> \ No newline at end of file +header('Location: courseware.php', true, 302); +exit; diff --git a/web/include/courseware.inc.php b/web/include/courseware.inc.php new file mode 100644 index 0000000..f1fc9fb --- /dev/null +++ b/web/include/courseware.inc.php @@ -0,0 +1,225 @@ + $slug, + 'title' => $slug, + 'filename' => $name, + 'path' => $resolved, + ); + } +} + +if (!function_exists('courseware_build_deck')) { + function courseware_build_deck($slug) { + $found = courseware_resolve_pptx($slug); + if ($found === null) { + return null; + } + return array( + 'slug' => $found['slug'], + 'title' => $found['title'], + 'filename' => $found['filename'], + 'url' => 'courseware-file.php?deck=' . rawurlencode($found['slug']), + ); + } +} + +if (!function_exists('courseware_list_decks')) { + function courseware_list_decks() { + $decks = array(); + $seen = array(); + foreach (courseware_scan_pptx_entries() as $slug => $name) { + unset($name); + if (isset($seen[$slug])) { + continue; + } + $deck = courseware_build_deck($slug); + if ($deck !== null) { + $seen[$slug] = true; + $decks[] = $deck; + } + } + usort($decks, function ($a, $b) { + return strnatcasecmp($a['title'], $b['title']); + }); + return $decks; + } +} + +if (!function_exists('courseware_clamp_page')) { + function courseware_clamp_page($deck, $page) { + $page = intval($page); + if ($page < 1) { + return 1; + } + $count = (is_array($deck) && isset($deck['page_count'])) ? intval($deck['page_count']) : 0; + if ($count < 1) { + return $page; + } + if ($page > $count) { + return $count; + } + return $page; + } +} + +if (!function_exists('courseware_content_disposition')) { + function courseware_content_disposition($filename) { + $safe = str_replace(array("\r", "\n", '"', '\\'), '_', strval($filename)); + $ascii = preg_replace('/[^\x20-\x7E]/', '_', $safe); + if ($ascii === '' || $ascii === '_' || $ascii === '.pptx') { + $ascii = 'courseware.pptx'; + } + return 'inline; filename="' . $ascii . '"; filename*=UTF-8\'\'' . rawurlencode($filename); + } +} diff --git a/web/include/pptxviewjs/LICENSE b/web/include/pptxviewjs/LICENSE new file mode 100644 index 0000000..5bd1880 --- /dev/null +++ b/web/include/pptxviewjs/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 gptsci.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/web/include/pptxviewjs/PptxViewJS.min.js b/web/include/pptxviewjs/PptxViewJS.min.js new file mode 100644 index 0000000..5089d9d --- /dev/null +++ b/web/include/pptxviewjs/PptxViewJS.min.js @@ -0,0 +1 @@ +!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?e(exports,require("chart.js/auto"),require("jszip")):"function"===typeof define&&define.amd?define(["exports","chart.js/auto","jszip"],e):(t="undefined"!==typeof globalThis?globalThis:t||self,e(t.PptxViewJS={},t.Chart,t.JSZip))}(this,function(t,e,r){"use strict";var o="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:{};function s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t["default"]:t}function i(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")?t["default"]:t}function n(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")&&1===Object.keys(t).length?t["default"]:t}function a(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var r=function t(){var r=false;try{r=this instanceof t}catch{}if(r)return Reflect.construct(e,arguments,this.constructor);return e.apply(this,arguments)};r.prototype=e.prototype}else r={};Object.defineProperty(r,"__esModule",{value:true});Object.keys(t).forEach(function(e){var o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,o.get?o:{enumerable:true,get:function(){return t[e]}})});return r}var l={};var c;function h(){if(c)return l;c=1;class Logger{constructor(t="Default"){this.category=t;this.logElement=null;this.logHistory=[]}init(){this.logElement=document.getElementById("log")}log(t,e,r,o=null){const s=(new Date).toISOString().split("T")[1].split(".")[0];const i={timestamp:s,level:t.toUpperCase(),category:e,message:r,data:o};this.logHistory.push(i);const n=`[${e}] ${r}`;const a=new Set(["PPTXSlideRenderer","PPTXProcessor","Thumbnail Debug"]);if(!a.has(e))t.toLowerCase();if(this.logElement){const i=o?` | ${JSON.stringify(o)}`:"";const n=`[${s}] [${t.toUpperCase()}] [${e}] ${r}${i}\n`;this.logElement.textContent+=n;this.logElement.scrollTop=this.logElement.scrollHeight}}debug(t,e,r=null){this.log("debug",t,e,r)}info(t,e,r=null){this.log("info",t,e,r)}warn(t,e,r=null){this.log("warn",t,e,r)}error(t,e,r=null){this.log("error",t,e,r)}trace(t,e,r=null){this.log("trace",t,e,r)}logError(t,e){let r="Unknown error";let o={};if(e&&"object"===typeof e){r=e.message||e.toString()||"Unknown error";o={stack:e.stack,name:e.name||"Error"}}else if("string"===typeof e)r=e;else r=String(e);this.log("error",t,r,o)}markTiming(t){if("undefined"!==typeof window&&window.getGlobalMonitor){const e=window.getGlobalMonitor();e.start(t,{category:this.category})}else if("undefined"!==typeof performance&&performance.mark)try{performance.mark(t)}catch(t){void 0}}measureTiming(t){if("undefined"!==typeof window&&window.getGlobalMonitor){const e=window.getGlobalMonitor();const r=e.end(t,{category:this.category});if(r)this.log("trace",this.category,`${t} completed in ${Math.round(r.duration)}ms`)}else if("undefined"!==typeof performance&&performance.mark)try{performance.measure(t);const e=performance.getEntriesByName(t,"measure");if(e.length>0){const r=Math.round(e[e.length-1].duration);this.log("trace",this.category,`${t} completed in ${r}ms`)}}catch(t){void 0}}}const t=new Logger;class e{constructor(){this.steps={1:{name:"ZIP Processing",progress:0},2:{name:"XML Parsing",progress:0},3:{name:"DOM Creation",progress:0},4:{name:"Canvas Rendering",progress:0}}}updateProgress(t,e){if(this.steps[t]){this.steps[t].progress=Math.min(100,Math.max(0,e));const r=document.getElementById(`progress${t}`);const o=document.getElementById(`step${t}`);if(r)r.style.width=`${this.steps[t].progress}%`;if(o){o.classList.remove("active","processing");if(e>=100)o.classList.add("active");else if(e>0)o.classList.add("processing")}}}reset(){for(const t in this.steps)this.updateProgress(parseInt(t),0)}}const r=new e;class o{static async readAsArrayBuffer(t,e={}){if(!t||!(t instanceof File||t instanceof Blob))throw new Error("Invalid file parameter: must be File or Blob instance");if(0===t.size)throw new Error("Cannot read empty file");const{maxSize:r=100*1024*1024,timeout:o=8e4}=e;if(t.size>r)throw new Error(`File too large: ${t.size} bytes (max: ${r} bytes)`);return new Promise((e,r)=>{const s=new window.FileReader;const i=setTimeout(()=>{s.abort();r(new Error(`File reading timed out after ${o}ms`))},o);s.onload=t=>{clearTimeout(i);const o=t.target?.result;if(o instanceof ArrayBuffer)e(o);else r(new Error("Failed to read file as ArrayBuffer"))};s.onerror=()=>{clearTimeout(i);const t=s.error||new Error("Unknown file reading error");r(new Error(`Failed to read file: ${t.message}`))};s.onabort=()=>{clearTimeout(i);r(new Error("File reading was aborted"))};try{s.readAsArrayBuffer(t)}catch(t){clearTimeout(i);r(new Error(`Failed to start file reading: ${t.message}`))}})}static async readAsText(t,e={}){if(!t||!(t instanceof File||t instanceof Blob))throw new Error("Invalid file parameter: must be File or Blob instance");const{encoding:r="UTF-8",maxSize:o=50*1024*1024,timeout:s=8e4,validateText:i=true}=e;if(t.size>o)throw new Error(`File too large: ${t.size} bytes (max: ${o} bytes)`);return new Promise((e,o)=>{const n=new window.FileReader;const a=setTimeout(()=>{n.abort();o(new Error(`File reading timed out after ${s}ms`))},s);n.onload=t=>{clearTimeout(a);const r=t.target?.result;if("string"===typeof r){if(i&&r.includes("�")){o(new Error("File contains invalid characters - may not be a text file"));return}e(r)}else o(new Error("Failed to read file as text"))};n.onerror=()=>{clearTimeout(a);const t=n.error||new Error("Unknown file reading error");o(new Error(`Failed to read file as text: ${t.message}`))};n.onabort=()=>{clearTimeout(a);o(new Error("File reading was aborted"))};try{n.readAsText(t,r)}catch(t){clearTimeout(a);o(new Error(`Failed to start file reading: ${t.message}`))}})}static async readAsDataURL(t,e={}){if(!t||!(t instanceof File||t instanceof Blob))throw new Error("Invalid file parameter: must be File or Blob instance");const{maxSize:r=10*1024*1024,timeout:o=8e4}=e;if(t.size>r)throw new Error(`File too large for Data URL: ${t.size} bytes (max: ${r} bytes)`);return new Promise((e,r)=>{const s=new window.FileReader;const i=setTimeout(()=>{s.abort();r(new Error(`File reading timed out after ${o}ms`))},o);s.onload=t=>{clearTimeout(i);const o=t.target?.result;if("string"===typeof o&&o.startsWith("data:"))e(o);else r(new Error("Failed to read file as Data URL"))};s.onerror=()=>{clearTimeout(i);const t=s.error||new Error("Unknown file reading error");r(new Error(`Failed to read file as Data URL: ${t.message}`))};s.onabort=()=>{clearTimeout(i);r(new Error("File reading was aborted"))};try{s.readAsDataURL(t)}catch(t){clearTimeout(i);r(new Error(`Failed to start file reading: ${t.message}`))}})}static async readMultipleFiles(t,e="arrayBuffer",r={}){if(!Array.isArray(t)||0===t.length)throw new Error("Invalid files parameter: must be non-empty array");const{onProgress:o=null,maxConcurrent:s=3,...i}=r;const n=this[`readAs${e.charAt(0).toUpperCase()+e.slice(1)}`];if(!n)throw new Error(`Invalid read type: ${e}`);const a=[];let l=0;for(let e=0;e{try{const a=await n.call(this,r,i);l++;if(o)o({completed:l,total:t.length,progress:l/t.length*100,currentFile:r.name||`File ${e+s+1}`});return a}catch(i){l++;if(o)o({completed:l,total:t.length,progress:l/t.length*100,currentFile:r.name||`File ${e+s+1}`,error:i.message});throw i}});const h=await Promise.all(c);a.push(...h)}return a}}const s=o;class i{static ERROR_TYPES={VALIDATION:"ValidationError",FILE_IO:"FileIOError",PARSING:"ParsingError",RENDERING:"RenderingError",NETWORK:"NetworkError",TIMEOUT:"TimeoutError",MEMORY:"MemoryError",UNKNOWN:"UnknownError"};static SEVERITY_LEVELS={LOW:"low",MEDIUM:"medium",HIGH:"high",CRITICAL:"critical"};static handle(t,e={}){const{context:r="Unknown",severity:o=this.SEVERITY_LEVELS.MEDIUM,displayToUser:s=true,logToConsole:i=true,throwAfterHandle:n=false,customHandler:a=null}=e;const l=this.normalizeError(t,r);if(i)this.logError(l,o);if(s)this.displayError(l,o);if(a&&"function"===typeof a)try{a(l,o)}catch(t){void 0}if(n)throw t instanceof Error?t:new Error(l.message);return l}static normalizeError(t,e){let r="Unknown error occurred";let o=null;let s=this.ERROR_TYPES.UNKNOWN;const i=t;if(t instanceof Error){r=t.message||"Error occurred";o=t.stack;s=t.name||this.categorizeError(t)}else if("string"===typeof t)r=t;else if(t&&"object"===typeof t){r=t.message||t.toString()||"Object error";o=t.stack;s=t.name||this.ERROR_TYPES.UNKNOWN}else r=String(t);return{message:r,context:e,stack:o,name:s,timestamp:(new Date).toISOString(),originalError:i,userAgent:navigator?.userAgent||"Unknown"}}static categorizeError(t){const e=t.message?.toLowerCase()||"";if(e.includes("validation")||e.includes("invalid"))return this.ERROR_TYPES.VALIDATION;if(e.includes("file")||e.includes("read")||e.includes("write"))return this.ERROR_TYPES.FILE_IO;if(e.includes("parse")||e.includes("xml")||e.includes("json"))return this.ERROR_TYPES.PARSING;if(e.includes("render")||e.includes("canvas")||e.includes("draw"))return this.ERROR_TYPES.RENDERING;if(e.includes("network")||e.includes("fetch")||e.includes("load"))return this.ERROR_TYPES.NETWORK;if(e.includes("timeout")||e.includes("timed out"))return this.ERROR_TYPES.TIMEOUT;if(e.includes("memory")||e.includes("allocation"))return this.ERROR_TYPES.MEMORY;return this.ERROR_TYPES.UNKNOWN}static logError(t,e){const r=`[${t.context}] ${t.message}`;switch(e){case this.SEVERITY_LEVELS.LOW:case this.SEVERITY_LEVELS.MEDIUM:case this.SEVERITY_LEVELS.HIGH:void 0;break;case this.SEVERITY_LEVELS.CRITICAL:void 0;if(t.stack)void 0}}static displayError(t,e){const r=document.getElementById("output");if(!r)return;const o=document.createElement("div");o.className=`error error--${e}`;const s=document.createElement("div");s.className="error__header";s.innerHTML=`\n ${this.getSeverityIcon(e)}\n Error in ${t.context}\n ${t.name}\n `;const i=document.createElement("div");i.className="error__message";i.textContent=t.message;const n=document.createElement("div");n.className="error__time";n.textContent=new Date(t.timestamp).toLocaleTimeString();o.appendChild(s);o.appendChild(i);o.appendChild(n);const a=document.createElement("button");a.className="error__dismiss";a.innerHTML="×";a.onclick=()=>o.remove();o.appendChild(a);o.style.transform="translateY(-100%)";o.style.transition="transform 0.3s ease-in-out";r.insertBefore(o,r.firstChild);requestAnimationFrame(()=>{o.style.transform="translateY(0)"});const l=this.getAutoDismissTime(e);if(l>0)setTimeout(()=>{if(o.parentNode){o.style.transform="translateY(-100%)";setTimeout(()=>o.remove(),300)}},l)}static getSeverityIcon(t){switch(t){case this.SEVERITY_LEVELS.LOW:return"ℹ️";case this.SEVERITY_LEVELS.MEDIUM:return"⚠️";case this.SEVERITY_LEVELS.HIGH:return"❌";case this.SEVERITY_LEVELS.CRITICAL:return"💥";default:return"❓"}}static getAutoDismissTime(t){switch(t){case this.SEVERITY_LEVELS.LOW:return 3e3;case this.SEVERITY_LEVELS.MEDIUM:return 5e3;case this.SEVERITY_LEVELS.HIGH:return 8e3;case this.SEVERITY_LEVELS.CRITICAL:return 0;default:return 5e3}}static createError(t,e={}){const{name:r=this.ERROR_TYPES.UNKNOWN,context:o="Unknown",cause:s=null,code:i=null,details:n=null}=e;const a=new Error(t);a.name=r;a.context=o;a.timestamp=(new Date).toISOString();if(s)a.cause=s;if(i)a.code=i;if(n)a.details=n;return a}}class n{static UNITS={EMU_PER_INCH:914400,EMU_PER_CM:36e4,EMU_PER_MM:36e3,EMU_PER_POINT:12700,INCHES_PER_MM:1/25.4,MM_PER_INCH:25.4,POINTS_PER_INCH:72};static VALIDATION={MAX_EMU:2147483647,MIN_EMU:-2147483648,MAX_PIXELS:32767,MAX_MM:59652,MIN_DPI:1,MAX_DPI:600};static validateInput(t,e,r={}){if("number"!==typeof t||!isFinite(t))throw i.createError(`Invalid ${e} value: must be a finite number`,{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"});const{min:o=-1/0,max:s=1/0}=r;if(ts)throw i.createError(`${e} value out of range: ${t} (valid range: ${o} to ${s})`,{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"});return t}static emuToMM(t){const e=this.validateInput(t,"EMU",{min:this.VALIDATION.MIN_EMU,max:this.VALIDATION.MAX_EMU});return e/this.UNITS.EMU_PER_MM}static mmToEMU(t){const e=this.validateInput(t,"MM",{min:-this.VALIDATION.MAX_MM,max:this.VALIDATION.MAX_MM});const r=e*this.UNITS.EMU_PER_MM;return Math.max(this.VALIDATION.MIN_EMU,Math.min(this.VALIDATION.MAX_EMU,Math.round(r)))}static emuToPoints(t){const e=this.validateInput(t,"EMU",{min:this.VALIDATION.MIN_EMU,max:this.VALIDATION.MAX_EMU});return e/this.UNITS.EMU_PER_POINT}static pointsToEMU(t){const e=this.validateInput(t,"Points",{min:-3e4,max:3e4});const r=e*this.UNITS.EMU_PER_POINT;return Math.max(this.VALIDATION.MIN_EMU,Math.min(this.VALIDATION.MAX_EMU,Math.round(r)))}static emuToPixels(t,e=96){const r=this.validateInput(t,"EMU",{min:this.VALIDATION.MIN_EMU,max:this.VALIDATION.MAX_EMU});const o=this.validateInput(e,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});const s=r/this.UNITS.EMU_PER_INCH;return Math.round(s*o)}static pixelsToEMU(t,e=96){const r=this.validateInput(t,"Pixels",{min:-this.VALIDATION.MAX_PIXELS,max:this.VALIDATION.MAX_PIXELS});const o=this.validateInput(e,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});const s=r/o;const i=s*this.UNITS.EMU_PER_INCH;return Math.max(this.VALIDATION.MIN_EMU,Math.min(this.VALIDATION.MAX_EMU,Math.round(i)))}static mmToPixels(t,e=96){const r=this.validateInput(t,"MM",{min:-this.VALIDATION.MAX_MM,max:this.VALIDATION.MAX_MM});const o=this.validateInput(e,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});const s=r*this.UNITS.INCHES_PER_MM;return Math.round(s*o)}static pixelsToMM(t,e=96){const r=this.validateInput(t,"Pixels",{min:-this.VALIDATION.MAX_PIXELS,max:this.VALIDATION.MAX_PIXELS});const o=this.validateInput(e,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});const s=r/o;return s*this.UNITS.MM_PER_INCH}static convert(t,e,r,o=96){if(e===r)return t;const s=e.toLowerCase();const n=r.toLowerCase();let a;switch(s){case"emu":a=t;break;case"mm":a=this.mmToEMU(t);break;case"pixels":case"px":a=this.pixelsToEMU(t,o);break;case"points":case"pt":a=this.pointsToEMU(t);break;case"inches":case"in":const r=this.validateInput(t,"Inches",{min:-100,max:100});a=Math.round(r*this.UNITS.EMU_PER_INCH);break;default:throw i.createError(`Unsupported source unit: ${e}`,{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"})}switch(n){case"emu":return a;case"mm":return this.emuToMM(a);case"pixels":case"px":return this.emuToPixels(a,o);case"points":case"pt":return this.emuToPoints(a);case"inches":case"in":return a/this.UNITS.EMU_PER_INCH;default:throw i.createError(`Unsupported target unit: ${r}`,{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"})}}static convertBatch(t,e,r,o=96){if(!Array.isArray(t))throw i.createError("Values must be an array",{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"});return t.map(t=>this.convert(t,e,r,o))}static getConversionFactor(t,e,r=96){return this.convert(1,t,e,r)}}class a{static decodeXMLEntities(t){if(!t)return t;const e={"&":"&","<":"<",">":">",""":'"',"'":"'"};return t.replace(/&[a-zA-Z0-9#]+;/g,t=>e[t]||t)}static encodeXMLEntities(t){if(!t)return t;return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}static extractNamespace(t){const e=t.indexOf(":");return-1!==e?t.substring(0,e):""}static extractLocalName(t){const e=t.indexOf(":");return-1!==e?t.substring(e+1):t}}class h{static getAttributeValue(t,e){return t.getAttribute?t.getAttribute(e):null}static getChildElements(t){if(!t.children)return[];return Array.from(t.children)}static getElementByTagName(t,e){if(!t.getElementsByTagName)return null;const r=t.getElementsByTagName(e);return r.length>0?r[0]:null}static getElementsByTagName(t,e){if(!t.getElementsByTagName)return[];return Array.from(t.getElementsByTagName(e))}static getTextContent(t){return t.textContent||t.innerText||""}}class u{static easeInOut(t){return t<.5?2*t*t:-1+(4-2*t)*t}static animate(t,e,r=null){const o=performance.now();function s(i){const n=i-o;const a=Math.min(n/t,1);e(a);if(a<1)requestAnimationFrame(s);else if(r)r()}requestAnimationFrame(s)}}document.addEventListener("DOMContentLoaded",function(){t.init()});let f=null;if("undefined"!==typeof window)try{if(window.PerformanceMonitor){f=new window.PerformanceMonitor({enabled:true,collectMemoryData:true,enableConsoleReports:false,maxHistoryEntries:500});window.performanceMonitor=f}}catch(t){}class d extends Logger{constructor(t){super(t);this.performanceMonitor=f}startPerformance(t,e={}){if(this.performanceMonitor)this.performanceMonitor.start(t,{...e,category:this.category});this.markTiming(t)}endPerformance(t,e={}){if(this.performanceMonitor){const r=this.performanceMonitor.end(t,{...e,category:this.category});if(r){const e=Math.round(100*r.duration)/100;this.trace(this.category,`${t} completed in ${e}ms`,{duration:e,memoryUsage:r.memorySnapshot?.jsHeapSize});if(e>1e3)this.warn(this.category,`Slow operation detected: ${t} took ${e}ms`)}}this.measureTiming(t)}measureSync(t,e,r={}){if(this.performanceMonitor){const{result:o,measure:s}=this.performanceMonitor.measure(t,e,{...r,category:this.category});if(s){const e=Math.round(100*s.duration)/100;this.trace(this.category,`${t} completed in ${e}ms`)}return o}else{this.startPerformance(t,r);try{const o=e();this.endPerformance(t,r);return o}catch(e){this.endPerformance(t,{...r,error:true});throw e}}}async measureAsync(t,e,r={}){if(this.performanceMonitor){const{result:o,measure:s}=await this.performanceMonitor.measureAsync(t,e,{...r,category:this.category});if(s){const e=Math.round(100*s.duration)/100;this.trace(this.category,`${t} completed in ${e}ms`)}return o}else{this.startPerformance(t,r);try{const o=await e();this.endPerformance(t,r);return o}catch(e){this.endPerformance(t,{...r,error:true});throw e}}}getPerformanceStats(){if(!this.performanceMonitor)return null;const t=this.performanceMonitor.getHistory();const e=t.filter(t=>t.startMetadata?.category===this.category||t.endMetadata?.category===this.category);if(0===e.length)return{category:this.category,operations:0};const r=e.reduce((t,e)=>t+e.duration,0);const o=r/e.length;const s=e.reduce((t,e)=>e.duration>t.duration?e:t);const i=e.reduce((t,e)=>e.duration=3)return{r:Number(e[0]),g:Number(e[1]),b:Number(e[2])}}return{r:0,g:0,b:0}}_normalizeFontConfig(t){return{fontFamily:t.fontFamily||t.family||"Calibri",fontSize:Math.max(6,Math.min(120,Number(t.fontSize||t.size||11))),bold:Boolean(t.bold),italic:Boolean(t.italic),color:this._normalizeColor(t.color)}}_getFallbackFont(){return{fontFamily:"Arial, sans-serif",fontSize:11,bold:false,italic:false,color:{r:0,g:0,b:0}}}_getCurrentDpi(){try{const t="undefined"!==typeof window&&window.devicePixelRatio||1;return 96*t}catch(t){return 96}}_createFallbackLogger(){return{debug:(...t)=>{},info:(...t)=>{},warn:(...t)=>{},error:(...t)=>{}}}_validateOptions(t){return{enableResponsiveScaling:false!==t.enableResponsiveScaling,enableDpiScaling:false!==t.enableDpiScaling,enablePptxOverrides:false!==t.enablePptxOverrides,logLevel:t.logLevel||"warn",...t}}setElementDefault(t,e){if(this.defaults[t]){this.defaults[t]={...this.defaults[t],...this._normalizeFontConfig(e)};this.logger.log("info",this.constructor.name,`Updated default font for ${t}`)}else this.logger.log("warn",this.constructor.name,`Unknown element type: ${t}`)}getElementTypes(){return Object.keys(this.defaults)}toCssString(t){const e=this._normalizeFontConfig(t);const r=e.italic?"italic ":"";const o=e.bold?"bold ":"";return`${r}${o}${e.fontSize}px ${e.fontFamily}`}toColorString(t){const e=this._normalizeColor(t.color);return`rgb(${e.r}, ${e.g}, ${e.b})`}}if("undefined"!==typeof window)window.ChartFontConfig=e;if("object"!=="undefined"&&t.exports)t.exports={ChartFontConfig:e}}(d);return d.exports}var y=m();var b=s(y);var x={};var S;function w(){if(S)return x;S=1;async function t(){if("undefined"!==typeof window&&window.JSZip&&"function"===typeof window.JSZip.loadAsync)return window.JSZip;if("undefined"!==typeof globalThis&&globalThis.JSZip&&"function"===typeof globalThis.JSZip.loadAsync)return globalThis.JSZip;try{const t=require("jszip");if(t&&"function"===typeof t.loadAsync)return t;if(t&&t.default&&"function"===typeof t.default.loadAsync)return t.default}catch(t){}if("undefined"!==typeof document){await new Promise((t,e)=>{const r=document.createElement("script");r.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js";r.onload=()=>t();r.onerror=()=>e(new Error("Failed to load JSZip"));document.head.appendChild(r)});if(window.JSZip)return window.JSZip}throw new Error("JSZip is not available")}class ZLib{constructor(){this.engine=null;this.files={};this.isModuleInit=true;if("undefined"!==typeof Logger)this.logger=new Logger("ZLib");else if("undefined"!==typeof window&&window.Logger)this.logger=new window.Logger("ZLib");else if("undefined"!==typeof globalThis&&globalThis.Logger)this.logger=new globalThis.Logger("ZLib");else this.logger={info:()=>{},debug:()=>{},warn:()=>{},error:()=>{},log:()=>{},logError:()=>{}};this.isOpen=false;this.lastError=null}validateInput(t,e){if(null===t||void 0===t){this.lastError=new Error(`${e}: Input data is null or undefined`);return false}if(!(t instanceof ArrayBuffer)&&!(t instanceof Uint8Array)&&!(t instanceof Blob)){this.lastError=new Error(`${e}: Invalid data type. Expected ArrayBuffer, Uint8Array, or Blob`);return false}if(0===t.byteLength||void 0!==t.size&&0===t.size){this.lastError=new Error(`${e}: Input data is empty`);return false}return true}async open(e){try{this.isOpen=false;this.lastError=null;if(!this.validateInput(e,"open")){this.logger.logError("ZLib","Failed to open ZIP:",this.lastError.message);return false}const JSZip=await t();let r=e;if(e instanceof Uint8Array)r=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);this.engine=await JSZip.loadAsync(r);if(!this.engine){this.lastError=new Error("Failed to create JSZip instance");this.logger.logError("ZLib","Failed to open ZIP:",this.lastError.message);return false}this.files={};let o=0;this.engine.forEach((t,e)=>{if(!e.dir){this.files[t]=null;o++}});if(0===o){this.lastError=new Error("ZIP file contains no readable files");this.logger.log("warn","ZLib","Opened ZIP file has no readable files")}this.isOpen=true;return true}catch(t){this.lastError=t;this.isOpen=false;this.logger.logError("ZLib","Failed to open ZIP:",t.message);if(t.message.includes("End of central directory not found"))this.logger.logError("ZLib","Invalid ZIP file: corrupted or not a ZIP file");else if(t.message.includes("encrypted"))this.logger.logError("ZLib","Cannot open encrypted ZIP files");else if(t.message.includes("Unsupported compression"))this.logger.logError("ZLib","ZIP file uses unsupported compression method");return false}}validatePath(t,e){if("string"!==typeof t){this.lastError=new Error(`${e}: Path must be a string`);return false}if(0===t.length){this.lastError=new Error(`${e}: Path cannot be empty`);return false}if(t.includes("..")||t.includes("//")){this.lastError=new Error(`${e}: Invalid path contains dangerous patterns`);return false}return true}checkReady(t){if(!this.isOpen||!this.engine){this.lastError=new Error(`${t}: ZIP archive is not open`);return false}return true}async getFile(t){try{if(!this.checkReady("getFile")){this.logger.logError("ZLib","Cannot get file:",this.lastError.message);return null}if(!this.validatePath(t,"getFile")){this.logger.logError("ZLib","Invalid file path:",this.lastError.message);return null}let e=this.engine.file(t);if(!e&&t.startsWith("/"))e=this.engine.file(t.substring(1));if(!e){this.logger.log("warn","ZLib",`File not found in ZIP: ${t}`);return null}const r=await e.async("arraybuffer");if(!r||0===r.byteLength){this.logger.log("warn","ZLib",`File is empty: ${t}`);return new Uint8Array(0)}return new Uint8Array(r)}catch(e){this.lastError=e;this.logger.logError("ZLib",`Failed to get file ${t}:`,e.message);return null}}async getFileText(t){try{if(!this.checkReady("getFileText")){this.logger.logError("ZLib","Cannot get file text:",this.lastError.message);return null}if(!this.validatePath(t,"getFileText")){this.logger.logError("ZLib","Invalid file path:",this.lastError.message);return null}let e=this.engine.file(t);if(!e&&t.startsWith("/"))e=this.engine.file(t.substring(1));if(!e){this.logger.log("warn","ZLib",`File not found in ZIP: ${t}`);return null}const r=await e.async("text");if("string"!==typeof r){this.logger.log("warn","ZLib",`File ${t} did not return valid text content`);return null}return r}catch(e){this.lastError=e;this.logger.logError("ZLib",`Failed to get file text ${t}:`,e.message);if(e.message.includes("binary"))this.logger.logError("ZLib",`File ${t} appears to be binary, cannot read as text`);else if(e.message.includes("encoding"))this.logger.logError("ZLib",`File ${t} has encoding issues`);return null}}getPaths(){try{if(!this.checkReady("getPaths")){this.logger.logError("ZLib","Cannot get paths:",this.lastError.message);return[]}const t=this.engine&&this.engine.files?Object.keys(this.engine.files):Object.keys(this.files);return t}catch(t){this.lastError=t;this.logger.logError("ZLib","Failed to get file paths:",t.message);return[]}}fileExists(t){try{if(!this.validatePath(t,"fileExists"))return false;if(!this.checkReady("fileExists"))return false;return this.files.hasOwnProperty(t)}catch(e){this.lastError=e;this.logger.logError("ZLib",`Error checking file existence for ${t}:`,e.message);return false}}getFileSize(t){try{if(!this.validatePath(t,"getFileSize"))return-1;if(!this.checkReady("getFileSize"))return-1;const e=this.engine.file(t);if(!e)return-1;return e._data?e._data.uncompressedSize:0}catch(e){this.lastError=e;this.logger.logError("ZLib",`Error getting file size for ${t}:`,e.message);return-1}}getLastError(){return this.lastError}close(){try{if(this.engine)this.engine=null;this.files={};this.isOpen=false;this.lastError=null}catch(t){this.logger.logError("ZLib","Error during ZIP cleanup:",t.message)}}async getFileData(t){try{if(!this.checkReady("getFileData"))throw this.lastError;if(!this.validatePath(t,"getFileData"))throw this.lastError;const e=t.startsWith("/")?t.substring(1):t;const r=this.engine.file(e);if(!r)throw new Error(`File not found: ${t}`);const o=await r.async("arraybuffer");if(!o)throw new Error(`Failed to read file data: ${t}`);return o}catch(e){this.lastError=e;this.logger.logError("ZLib",`Failed to get file data for ${t}:`,e.message);throw new Error(`Failed to extract file data: ${t} - ${e.message}`)}}getStats(){try{if(!this.checkReady("getStats"))return{isOpen:false,fileCount:0,totalSize:0,error:this.lastError?.message};const t=Object.keys(this.files);let e=0;t.forEach(t=>{const r=this.getFileSize(t);if(r>0)e+=r});return{isOpen:this.isOpen,fileCount:t.length,totalSize:e,files:t,lastError:this.lastError?.message||null}}catch(t){this.lastError=t;this.logger.logError("ZLib","Error getting archive stats:",t.message);return{isOpen:false,fileCount:0,totalSize:0,error:t.message}}}}class OpenXmlPackage{constructor(t){this.zip=t;this.parts={};this.contentTypes={};this.relationships={}}async initialize(){const t=await this.zip.getFileText("[Content_Types].xml");if(t)this.parseContentTypes(t);const e=await this.zip.getFileText("_rels/.rels");if(e)this.relationships[""]=this.parseRelationships(e);const r=this.zip.getPaths();for(const t of r)if(t.startsWith("_rels/")&&t.endsWith(".rels")&&"_rels/.rels"!==t){const e=t.match(/^(.+)\/_rels\/(.+)\.rels$/);if(e){const r=e[1];const o=e[2];const s=`/${r}/${o}`;const i=await this.zip.getFileText(t);if(i)this.relationships[s]=this.parseRelationships(i)}}for(const t of r)if(!t.startsWith("_rels/")&&"[Content_Types].xml"!==t){const e=`/${t}`;const r=this.getContentType(e);this.parts[e]=new OpenXmlPart(this,e,r)}}parseContentTypes(t){const e=new DOMParser;const r=e.parseFromString(t,"text/xml");const o=t=>{const e=r.getElementsByTagName("*");const o=[];for(let r=0;r{const e=t.getAttribute("Extension");const r=t.getAttribute("ContentType");if(e&&r)this.contentTypes[`ext:${e}`]=r});o("Override").forEach(t=>{const e=t.getAttribute("PartName");const r=t.getAttribute("ContentType");if(e&&r)this.contentTypes[e]=r})}parseRelationships(t){const e=new DOMParser;const r=e.parseFromString(t,"text/xml");const o={};const s=t=>{const e=r.getElementsByTagName("*");const o=[];for(let r=0;r{const e=t.getAttribute("Id");const r=t.getAttribute("Type");const s=t.getAttribute("Target");if(!e)return;o[e]={type:r,target:s,targetMode:t.getAttribute("TargetMode")||"Internal"}});return o}getContentType(t){if(this.contentTypes[t])return this.contentTypes[t];const e=t.split(".").pop();if(e&&this.contentTypes[`ext:${e}`])return this.contentTypes[`ext:${e}`];return"application/octet-stream"}getPartByRelationshipType(t){const e=this.relationships[""]||{};for(const r of Object.values(e))if(r.type===t){const t=r.target.startsWith("/")?r.target:`/${r.target}`;return this.parts[t]}return null}getPartByUri(t){return this.parts[t]}}class OpenXmlPart{constructor(t,e,r){this.package=t;this.uri=e;this.contentType=r;this._content=null}async getDocumentContent(){if(null===this._content){const t=this.uri.startsWith("/")?this.uri.substring(1):this.uri;this._content=await this.package.zip.getFileText(t)}return this._content}async getRelationships(){if(this.package.relationships[this.uri])return this.package.relationships[this.uri];const t=this.uri.replace(/\/([^\/]+)$/,"/_rels/$1.rels");const e=t.startsWith("/")?t.substring(1):t;const r=await this.package.zip.getFileText(e);if(r)return this.package.parseRelationships(r);return{}}}const OpenXmlTypes={presentation:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"},extendedFileProperties:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"},coreFileProperties:{relationType:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"},customFileProperties:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"},presentationProperties:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps"},slide:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"},slideLayout:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"},slideMaster:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"},theme:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"},image:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"}};if("undefined"!==typeof window){window.ZLib=ZLib;window.OpenXmlPackage=OpenXmlPackage;window.OpenXmlPart=OpenXmlPart;window.OpenXmlTypes=OpenXmlTypes}if("undefined"!==typeof globalThis){globalThis.ZLib=ZLib;globalThis.OpenXmlPackage=OpenXmlPackage;globalThis.OpenXmlPart=OpenXmlPart;globalThis.OpenXmlTypes=OpenXmlTypes}return x}var C=w();var T=s(C);var P={};var v;function M(){if(v)return P;v=1;class XmlParserContext{constructor(){this.zip=null;this.imageMap={};this.layoutsMap={};this.mastersMap={};this.tablesMap={};this.tableStylesMap={};this.smartarts=[];this.connectorsPr=[];this.slideLayoutRels=new Map;this.slideMasterRels=new Map;this.masterLayoutMap=new Map;this.themeMap={};this.colorMaps={};this.logger=new Logger("XmlParserContext")}registerSlideMaster(t,e){this.slideMasterRels.set(t,e);this.mastersMap[t]=e;if(!this.masterLayoutMap.has(t))this.masterLayoutMap.set(t,[])}registerSlideLayout(t,e,r){this.slideLayoutRels.set(t,e);this.layoutsMap[t]=e;if(r){e.masterId=r;if(!this.masterLayoutMap.has(r))this.masterLayoutMap.set(r,[]);this.masterLayoutMap.get(r).push(t)}}getSlideMaster(t){return this.slideMasterRels.get(t)}getSlideLayout(t){return this.slideLayoutRels.get(t)}getLayoutsForMaster(t){const e=this.masterLayoutMap.get(t)||[];return e.map(t=>this.getSlideLayout(t)).filter(Boolean)}loadDataLinks(){return this.imageMap}generateSmartArts(){return this.smartarts}}class StaxParser{constructor(t,e,r){this.xml=t;this.part=e;this.context=r;this.parser=new DOMParser;this.doc=null;this.currentElement=null;this.depth=0;this.namespaces={p:"http://schemas.openxmlformats.org/presentationml/2006/main",a:"http://schemas.openxmlformats.org/drawingml/2006/main",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships"};this.logger=new Logger("StaxParser")}parse(){try{this.doc=this.parser.parseFromString(this.xml,"text/xml");const t=this.doc.querySelector("parsererror");if(t)throw new Error("XML parsing failed: "+t.textContent);return this.doc}catch(t){return null}}parseSlideMaster(t){if(!this.doc)this.parse();const e=this.doc.documentElement;if(!e||"sldMaster"!==e.localName)return null;const r={id:t,type:"slideMaster",name:this.getAttributeValue(e,"name")||`Master ${t}`,preserve:"true"===this.getAttributeValue(e,"preserve"),cSld:this.parseCommonSlideData(e),clrMap:this.parseColorMap(e),txStyles:this.parseTextStyles(e),sldLayoutLst:[],themeId:this.extractThemeId(e),hf:this.parseHeaderFooter(e),timing:this.parseTiming(e),transition:this.parseTransition(e)};return r}parseSlideLayout(t,e){if(!this.doc)this.parse();const r=this.doc.documentElement;if(!r||"sldLayout"!==r.localName)return null;const o={id:t,masterId:e,type:"slideLayout",name:this.getAttributeValue(r,"name")||`Layout ${t}`,matchingName:this.getAttributeValue(r,"matchingName")||"",preserve:"true"===this.getAttributeValue(r,"preserve"),showMasterSp:"false"!==this.getAttributeValue(r,"showMasterSp"),showMasterPhAnim:"true"===this.getAttributeValue(r,"showMasterPhAnim"),userDrawn:"false"!==this.getAttributeValue(r,"userDrawn"),layoutType:this.getLayoutType(r),cSld:this.parseCommonSlideData(r),clrMapOvr:this.parseColorMapOverride(r),hf:this.parseHeaderFooter(r),timing:this.parseTiming(r),transition:this.parseTransition(r)};return o}parseCommonSlideData(t){const e=this.getChildElement(t,"cSld");if(!e)return{name:"",bg:null,spTree:[]};return{name:this.getAttributeValue(e,"name")||"",bg:this.parseBackground(e),spTree:this.parseShapeTree(e)}}parseShapeTree(t){const e=this.getChildElement(t,"spTree");if(!e)return[];const r=[];const o=e.children;for(let t=0;t{if(t){e.chartData=t;if(window.currentProcessor&&window.currentProcessor.reRenderShape)window.currentProcessor.reRenderShape(e)}else{const t=r.parseEmbeddedChartData(o);if(t)e.chartData=t}}).catch(t=>{try{const t=r.parseEmbeddedChartData(o);if(t)e.chartData=t}catch(t){}})}catch(t){}else{e.graphicData.isChart=true;e.graphicData.chartXml=(new XMLSerializer).serializeToString(o)}}}}return e}parseHeaderFooter(t){return null}parseTiming(t){return null}parseTransition(t){return null}extractThemeId(t){return null}parseFill(t){return null}parseImageEffects(t){return null}parseTransform(t){const e=t.querySelector("xfrm")||t.querySelector("p\\:xfrm")||t.querySelector('[*|localName="xfrm"]');if(!e)return{x:0,y:0,width:0,height:0};const r=e.querySelector("off")||e.querySelector("a\\:off")||e.querySelector('[*|localName="off"]');let o=0,s=0;if(r){o=parseInt(r.getAttribute("x")||"0",10);s=parseInt(r.getAttribute("y")||"0",10)}const i=e.querySelector("ext")||e.querySelector("a\\:ext")||e.querySelector('[*|localName="ext"]');let n=0,a=0;if(i){n=parseInt(i.getAttribute("cx")||"0",10);a=parseInt(i.getAttribute("cy")||"0",10)}return{x:o,y:s,width:n,height:a}}parseSlide(t){try{const slide={shapes:[],background:null,name:"",id:null};const e=t.getAttribute("id");if(e)slide.id=e;const r=this.getChildElement(t,"cSld");if(r){const t=r.getAttribute("name");if(t)slide.name=t;slide.background=this.parseBackground(r);slide.shapes=this.parseShapeTree(r)}return slide}catch(t){return{shapes:[],background:null,name:"",id:null}}}}if("undefined"!==typeof window){window.XmlParserContext=XmlParserContext;window.StaxParser=StaxParser}if("undefined"!==typeof globalThis){globalThis.XmlParserContext=XmlParserContext;globalThis.StaxParser=StaxParser}return P}var A=M();var k=s(A);var R={};var F;function E(){if(F)return R;F=1;class CPresentation{constructor(){this.type="CPresentation";this.id=Math.random().toString(36).substr(2,9);this.slides=[];this.slideMasters=[];this.notesMasters=[];this.slideSize={cx:9144e3,cy:6858e3};this.currentSlide=0;this.app=null;this.core=null;this.customProperties=null;this.masterIds=[];this.theme=null}getSlidesCount(){return this.slides.length}getCurrentSlide(){return this.slides[this.currentSlide]||null}getSlide(t){return this.slides[t]||null}addSlide(slide){this.slides.push(slide);slide.setParent(this)}setCurrentSlide(t){if(t>=0&&t=0&&t0&&t.groupExt.cx>0)e=t.groupExt.cx/t.chExt.cx;if(t.chExt.cy>0&&t.groupExt.cy>0)r=t.groupExt.cy/t.chExt.cy;const o=t.groupOff.x-t.chOff.x*e;const s=t.groupOff.y-t.chOff.y*r;return{m11:e,m12:0,m21:0,m22:r,dx:o,dy:s}}createRotationMatrix(t){const e=t*Math.PI/180;const r=Math.cos(e);const o=Math.sin(e);return{m11:r,m12:o,m21:-o,m22:r,dx:0,dy:0}}createScaleMatrix(t,e){return{m11:t,m12:0,m21:0,m22:e,dx:0,dy:0}}drawSingleShape(t,e){const r=e.properties.transform;if(!r)return;const o=CoordinateTransform.emuToMM(r.x||0);const s=CoordinateTransform.emuToMM(r.y||0);const i=CoordinateTransform.emuToMM(r.width||0);const n=CoordinateTransform.emuToMM(r.height||0);const a=this.getShapeFillColor(e);const l=this.getShapeStrokeColor(e);const c=this.getShapeLineWidth(e);switch(e.type){case"sp":this.drawTextShape(t,e,o,s,i,n,a,l,c);break;case"pic":this.drawImageShape(t,e,o,s,i,n);break;case"cxnSp":this.drawConnectorShape(t,e,o,s,i,n,l,c);break;case"graphicFrame":this.drawGraphicFrame(t,e,o,s,i,n);break;default:this.drawDefaultShape(t,e,o,s,i,n,a,l,c)}}drawTextShape(t,e,r,o,s,i,n,a,l){const c=e.geometry||e.properties?.geometry;if(c&&c.preset)t.drawPresetGeometry(c.preset,r,o,s,i,n,a,l);else if(c&&c.pathLst)this.drawCustomGeometry(t,c,r,o,s,i,n,a,l);else{if(n)t.fillRect(r,o,s,i,n);if(a)t.strokeRect(r,o,s,i,a,l)}this.drawTextContent(t,e,r,o,s,i)}drawCustomGeometry(t,e,r,o,s,i,n,a,l){t.SaveGrState();const c=s/(e.pathW||s);const h=i/(e.pathH||i);t.context.translate(r,o);t.context.scale(c,h);if(e.pathLst)for(let r=0;ro+a)break;let e=r+5;for(const r of s.runs)if(r.text&&n<=o+a){const o={fontSize:r.properties?.fontSize||18,fontFamily:r.properties?.fontFamily||"Arial",bold:r.properties?.bold||false,italic:r.properties?.italic||false,color:r.properties?.color||{r:0,g:0,b:0},highlight:r.properties?.highlight||null};t.fillText(r.text,e,n,o);e+=r.text.length*(.6*o.fontSize)}n+=l}}drawImageShape(t,e,r,o,s,i){t.strokeRect(r,o,s,i,{r:160,g:160,b:160},1);if(e.imageData)t.drawImage(e.imageData,r,o,s,i)}drawConnectorShape(t,e,r,o,s,i,n,a){const l=r;const c=o;const h=r+s;const u=o+i;t.drawLine(l,c,h,u,n,a)}drawGraphicFrame(t,e,r,o,s,n){if(e.graphicData);if(e.asyncChartProcessing){t.strokeRect(r,o,s,n,{r:200,g:200,b:200},1);return}if(e.chartData)if(window.ChartRenderer){const i=new ChartRenderer(t);i.renderChart(e.chartData,r,o,s,n)}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1);else if(e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/chart"===e.graphicData.uri)if(window.ChartProcessor){const i=new ChartProcessor;const a=i.parseEmbeddedChartData(e.graphicData);if(a){e.chartData=a;if(window.ChartRenderer){const e=new ChartRenderer(t);e.renderChart(a,r,o,s,n)}}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1)}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1);else if(e.table&&e.table instanceof i)e.table.draw(t,r,o,s,n);else if(e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===e.graphicData.uri)try{const i=this.parseSimpleTable(e.graphicData.tableXml);if(i){e.table=i;i.draw(t,r,o,s,n)}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1)}catch(e){t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1)}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1)}parseSimpleTable(t){if(!t)return null;try{const e=new DOMParser;const r=e.parseFromString(t,"text/xml");if("parsererror"===r.documentElement.nodeName)return null;const o=new i;let s=r.querySelector("tblGrid");if(!s)s=r.querySelector("a\\:tblGrid");if(s){let t=s.querySelectorAll("gridCol");if(0===t.length)t=s.querySelectorAll("a\\:gridCol");const e=[];t.forEach(t=>{const r=t.getAttribute("w");e.push({width:r?parseInt(r):914400})});o.setTableGrid(e)}let l=r.querySelectorAll("tr");if(0===l.length)l=r.querySelectorAll("a\\:tr");l.forEach(t=>{const e=new n;let r=t.querySelector("trPr");if(!r)r=t.querySelector("a\\:trPr");if(r){let t=r.querySelector("trHeight");if(!t)t=r.querySelector("a\\:trHeight");if(t)e.height=parseInt(t.getAttribute("val"))||null}let s=t.querySelectorAll("tc");if(0===s.length)s=t.querySelectorAll("a\\:tc");s.forEach(t=>{const r=new a;let o=t.querySelector("tcPr");if(!o)o=t.querySelector("a\\:tcPr");if(o){let t=o.querySelector("gridSpan");if(!t)t=o.querySelector("a\\:gridSpan");if(t)r.gridSpan=parseInt(t.getAttribute("val"))||1;let e=o.querySelector("rowSpan");if(!e)e=o.querySelector("a\\:rowSpan");if(e)r.rowSpan=parseInt(e.getAttribute("val"))||1;let s=o.querySelector("solidFill");if(!s)s=o.querySelector("a\\:solidFill");if(s){let t=s.querySelector("srgbClr, schemeClr, scrgbClr");if(!t)t=s.querySelector("a\\:srgbClr, a\\:schemeClr, a\\:scrgbClr");if(t){const e=this.parseSimpleColor(t);if(e)r.fill={color:e}}}}const s=this.parseSimpleTextContent(t);if(s)r.setTextBody(s);e.addCell(r)});o.addRow(e)});return o}catch(t){return null}}parseSimpleColor(t){if(t.tagName.includes("srgbClr")){const e=t.getAttribute("val");if(e){const t=e.replace("#","");return{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:255}}}return{r:200,g:200,b:200,a:255}}parseSimpleTextContent(t){const e=t.querySelectorAll("r, a\\:r");if(0===e.length)return null;const r={paragraphs:[],bodyProperties:{wrap:true,verticalAlign:"top"}};const o={runs:[],properties:{}};e.forEach(t=>{const e=t.querySelector("t, a\\:t");const r=e?e.textContent:"";if(r){const e=t.querySelector("rPr, a\\:rPr");const s={fontSize:12,fontFamily:"Arial",bold:false,italic:false,color:{r:0,g:0,b:0,a:255}};if(e){const t=e.getAttribute("sz");if(t)s.fontSize=parseInt(t)/100;const r=e.getAttribute("b");if("1"===r)s.bold=true;const o=e.querySelector("solidFill, a\\:solidFill");if(o){const t=o.querySelector("srgbClr, a\\:srgbClr");if(t){const e=t.getAttribute("val");if(e){const t=parseInt(e.substr(0,2),16);const r=parseInt(e.substr(2,2),16);const o=parseInt(e.substr(4,2),16);s.color={r:t,g:r,b:o,a:255}}}}}o.runs.push({text:r,properties:s})}});if(o.runs.length>0)r.paragraphs.push(o);return r.paragraphs.length>0?r:null}drawDefaultShape(t,e,r,o,s,i,n,a,l){if(n)t.fillRect(r,o,s,i,n);if(a)t.strokeRect(r,o,s,i,a,l)}getShapeFillColor(t){if(t.brush?.color)return t.brush.color;if(t.fill?.color)return t.fill.color;if(t.properties?.fill?.color)return t.properties.fill.color;return{r:200,g:200,b:200,a:255}}getShapeStrokeColor(t){if(null===t.pen||"none"===t.pen)return null;if(null===t.stroke||"none"===t.stroke)return null;if(null===t.properties?.stroke||"none"===t.properties?.stroke)return null;if(0===t.pen?.width)return null;if(0===t.stroke?.width)return null;if(0===t.properties?.stroke?.width)return null;if(t.pen?.color)return t.pen.color;if(t.stroke?.color)return t.stroke.color;if(t.properties?.stroke?.color)return t.properties.stroke.color;return null}getShapeLineWidth(t){if(null===t.pen||"none"===t.pen)return 0;if(null===t.stroke||"none"===t.stroke)return 0;if(null===t.properties?.stroke||"none"===t.properties?.stroke)return 0;if(void 0!==t.pen?.width)return CoordinateTransform.emuToMM(t.pen.width);if(void 0!==t.stroke?.width)return CoordinateTransform.emuToMM(t.stroke.width);if(void 0!==t.properties?.stroke?.width)return CoordinateTransform.emuToMM(t.properties.stroke.width);return 0}createShapeTransformMatrix(t){const e=new CMatrix;if(t.rotation){const r=t.rotation/6e4*Math.PI/180;const o=Math.cos(r);const s=Math.sin(r);e.sx=o;e.sy=o;e.shx=-s;e.shy=s}e.tx=CoordinateTransform.emuToMM(t.x||0);e.ty=CoordinateTransform.emuToMM(t.y||0);return e}}class t{constructor(){this.name="";this.shapeTree=[];this.background=null;this.colorMap=null;this.parent=null}setParent(t){this.parent=t}addToSpTree(t,e){if(void 0===t||null===t)t=this.shapeTree.length;this.shapeTree.splice(t,0,e);e.setParent(this)}removeFromSpTree(t){if(t>=0&&t=0&&t0&&t.groupExt.cx>0)e=t.groupExt.cx/t.chExt.cx;if(t.chExt.cy>0&&t.groupExt.cy>0)r=t.groupExt.cy/t.chExt.cy;for(const o of this.shapeTree)if(o.bounds){const s=o.bounds;if(!o.originalBounds)o.originalBounds={...s};const i={l:t.groupOff.x+(s.l-t.chOff.x)*e,t:t.groupOff.y+(s.t-t.chOff.y)*r,r:t.groupOff.x+(s.r-t.chOff.x)*e,b:t.groupOff.y+(s.b-t.chOff.y)*r};o.bounds=i;o.groupTransform={scaleX:e,scaleY:r,offsetX:t.groupOff.x-t.chOff.x*e,offsetY:t.groupOff.y-t.chOff.y*r}}}recalculateBounds(){if(0===this.shapeTree.length){super.recalculateBounds();return}let t=1/0,e=1/0;let r=-1/0,o=-1/0;let s=false;for(const i of this.shapeTree){if(i.recalculateBounds)i.recalculateBounds();if(i.bounds){t=Math.min(t,i.bounds.l);e=Math.min(e,i.bounds.t);r=Math.max(r,i.bounds.r);o=Math.max(o,i.bounds.b);s=true}}if(s){this.bounds.l=t;this.bounds.t=e;this.bounds.r=r;this.bounds.b=o}else{this.bounds.l=914400;this.bounds.t=914400;this.bounds.r=5486400;this.bounds.b=2743200}}draw(t){if(this.isHidden)return;this.recalculateBounds();t.SaveGrState();try{if(this.transform){if(this.transform.rotation&&0!==this.transform.rotation){const e=this.createRotationMatrix(this.transform.rotation);t.transform3(e)}if(this.transform.flipH||this.transform.flipV){const e=this.transform.flipH?-1:1;const r=this.transform.flipV?-1:1;const o=this.createScaleMatrix(e,r);t.transform3(o)}}if(this.groupCoordSystem){const e=this.createGroupCoordinateMatrix(this.groupCoordSystem);if(e)t.transform3(e)}for(const e of this.shapeTree)e.draw(t)}finally{t.RestoreGrState()}}createGroupCoordinateMatrix(t){if(!t)return null;let e=1,r=1;if(t.chExt.cx>0&&t.groupExt.cx>0)e=t.groupExt.cx/t.chExt.cx;if(t.chExt.cy>0&&t.groupExt.cy>0)r=t.groupExt.cy/t.chExt.cy;const o=t.groupOff.x-t.chOff.x*e;const s=t.groupOff.y-t.chOff.y*r;return{m11:e,m12:0,m21:0,m22:r,dx:o,dy:s}}createRotationMatrix(t){const e=t*Math.PI/180;const r=Math.cos(e);const o=Math.sin(e);return{m11:r,m12:o,m21:-o,m22:r,dx:0,dy:0}}createScaleMatrix(t,e){return{m11:t,m12:0,m21:0,m22:e,dx:0,dy:0}}getObjectType(){return"group"}isGroup(){return true}}class o{constructor(){this.id=Math.random().toString(36).substr(2,9);this.commonSlideData=new t;this.theme=null;this.layouts=[];this.parent=null}setParent(t){this.parent=t}addLayout(t){this.layouts.push(t);t.setMaster(this)}}class s{constructor(){this.id=Math.random().toString(36).substr(2,9);this.commonSlideData=new t;this.master=null;this.type="blank"}setMaster(t){this.master=t}}class i{constructor(){this.id=Math.random().toString(36).substr(2,9);this.type="table";this.rows=[];this.tableGrid=[];this.tableProperties=null;this.parent=null;this.firstRow=false;this.firstCol=false;this.lastRow=false;this.lastCol=false;this.bandRow=false;this.bandCol=false;this.tableStyleId=null;this.bounds={l:0,t:0,r:0,b:0}}setParent(t){this.parent=t}addRow(t){this.rows.push(t);t.setParent(this);t.rowIndex=this.rows.length-1}setTableGrid(t){this.tableGrid=t||[]}getTotalWidth(){return this.tableGrid.reduce((t,e)=>t+(e.width||0),0)}getRowCount(){return this.rows.length}getColumnCount(){const t=this.tableGrid.length;let e=0;for(const t of this.rows){const r=t.getCells().length;if(r>e)e=r}return Math.max(t,e)}getTableProperties(){return this.tableProperties||{}}getTableBorders(){return this.tableProperties?.borders||{}}getTableShading(){return this.tableProperties?.shading||{}}getTableGrid(){return this.tableGrid||[]}getCell(t,e){if(t>=0&&t=0&&e=0&&tt+(e.height||0),0);this.bounds.r=this.bounds.l+CoordinateTransform.emuToMM(t);this.bounds.b=this.bounds.t+CoordinateTransform.emuToMM(e)}draw(t,e,r,o,s){if(!this.rows||0===this.rows.length){t.strokeRect(e,r,o,s,{r:160,g:160,b:160},1);return}const i=this.getColumnCount();const n=this.getRowCount();const a=i>0?o/i:o;const l=n>0?s/n:s;let c=r;for(let r=0;rr+n)break;let s=e+5;if(o.runs)for(const e of o.runs)if(e.text&&i<=r+n){const r={fontSize:e.properties?.fontSize||12,fontFamily:e.properties?.fontFamily||"Arial",bold:e.properties?.bold||false,italic:e.properties?.italic||false,color:e.properties?.color||{r:0,g:0,b:0}};t.fillText(e.text,s,i,r);s+=e.text.length*(.6*r.fontSize)}i+=a}}getGridSpan(){return this.gridSpan||1}getRowSpan(){return this.rowSpan||1}getCellShading(){return this.shading}getTextBody(){return this.textBody}getCellBorders(){return this.borders}}class l{constructor(){this.id=Math.random().toString(36).substr(2,9);this.name="Default Theme";this.colorScheme=null;this.fontScheme=null;this.formatScheme=null}}if("undefined"!==typeof window){window.CPresentation=CPresentation;window.CSlide=CSlide;window.CSld=t;window.CShape=e;window.CGroupShape=r;window.CSlideMaster=o;window.CSlideLayout=s;window.CTheme=l;window.CTable=i;window.CTableRow=n;window.CTableCell=a}if("undefined"!==typeof globalThis){globalThis.CPresentation=CPresentation;globalThis.CSlide=CSlide;globalThis.CSld=t;globalThis.CShape=e;globalThis.CGroupShape=r;globalThis.CSlideMaster=o;globalThis.CSlideLayout=s;globalThis.CTheme=l;globalThis.CTable=i;globalThis.CTableRow=n;globalThis.CTableCell=a}return R}var _=E();var I=s(_);let L=class t{constructor(t={}){this.logger=new Logger("TableProcessor");this.validator=this._getValidator();this.errorBoundary=new(this._getErrorBoundary())({context:"TableProcessor",enableLogging:false!==t.enableLogging});this.tableCache=new Map;this.config=this._validateConfig({maxTableSize:t.maxTableSize||1e3,maxCellTextLength:t.maxCellTextLength||1e4,enableCaching:false!==t.enableCaching,enableValidation:false!==t.enableValidation,renderTimeout:t.renderTimeout||5e3,...t});this.performanceMetrics={tablesProcessed:0,cacheHits:0,cacheMisses:0,averageRenderTime:0}}async renderTableFrame(t,e,r,o,s,i,n={}){const a=this._validateRenderInput(t,e,r,o,s,i,n);if(!a.valid){this._handleValidationError("renderTableFrame",a.errors);this.drawTablePlaceholder(t,r,o,s,i);return}return this.errorBoundary.wrap(async()=>{const n=performance.now();try{const a=await this._getTableInstanceWithTimeout(e,this.config.renderTimeout);if(!a){if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","No valid table data found, drawing placeholder");this.drawTablePlaceholder(t,r,o,s,i);return}if(this.config.enableValidation)this._validateTableStructure(a);t.SaveGrState();try{await this._safeDrawTableBackgroundAndOuterBorder(t,a,r,o,s,i);await this._safeDrawCellsBackground(t,a,r,o,s,i);await this._safeDrawCellsContent(t,a,r,o,s,i);await this._safeDrawCellsBorders(t,a,r,o,s,i);this._updatePerformanceMetrics(n)}finally{t.RestoreGrState()}}catch(e){void 0;void 0;void 0;if(this.logger)this.logger.logError(this.constructor.name,"TableProcessor","Error during table rendering:",e);this.drawTablePlaceholder(t,r,o,s,i);throw this._enhanceError(e,"table_rendering",{x:r,y:o,w:s,h:i})}},{context:"renderTableFrame"})()}async getTableInstance(t){return this.errorBoundary.wrap(async()=>{if(!t||"object"!==typeof t)throw this._createError("Invalid shape object provided",{name:"ValidationError",code:"INVALID_SHAPE"});if(t.table&&t.table instanceof CTable){this.performanceMetrics.cacheHits++;return t.table}this.performanceMetrics.cacheMisses++;if(t.graphicData&&t.graphicData.tableXml)try{if(this.config.enableValidation)this._validateTableXML(t.graphicData.tableXml);const e=await this.parseTableFromXML(t.graphicData.tableXml);if(e){if(this.config.enableValidation)this._validateParsedTable(e);if(this.config.enableCaching)t.table=e;return e}}catch(t){if(this.logger)this.logger.logError(this.constructor.name,"TableProcessor","Failed to parse table XML:",t);throw this._enhanceError(t,"table_parsing")}return null},{context:"getTableInstance"})()}async _getTableInstanceWithTimeout(t,e){return new Promise(async(r,o)=>{const s=setTimeout(()=>{o(this._createError(`Table parsing timed out after ${e}ms`,{name:"TimeoutError",code:"TABLE_PARSING_TIMEOUT"}))},e);try{const e=await this.getTableInstance(t);clearTimeout(s);r(e)}catch(t){clearTimeout(s);o(t)}})}drawTableBackgroundAndOuterBorder(t,e,r,o,s,i){const n=e.getTableProperties();const a=e.getTableBorders();const l=e.getTableShading();if(l&&l.fill){const e=this.resolveTableBackgroundColor(l);t.b_color1(e.r,e.g,e.b,e.a||255);t.TableRect(r,o,s,i)}if(a&&Object.keys(a).length>0)this.drawTableOuterBorder(t,a,r,o,s,i)}drawCellsBackground(t,e,r,o,s,i){const n=e.getRows();const a=this.calculateCellWidths(e,s);const l=this.calculateCellHeights(e,i);const c=e.getTableProperties()||{};let h=o;for(let e=0;e0&&"TOTAL"===s[0].textBody?.paragraphs?.[0]?.runs?.[0]?.text;const f=s.length>0&&"Product"===s[0].textBody?.paragraphs?.[0]?.runs?.[0]?.text;for(let o=0;o{const a=e[n];if(a&&"none"!==a.style){const e=this.resolveBorderColor(a);const l=Math.max(a.width||1,3);t.p_color(e.r,e.g,e.b,e.a||255);t.p_width(l);switch(n){case"top":t.drawHorLine(r,o,r+s,o,l);break;case"right":t.drawVerLine(r+s,o,o+i,l);break;case"bottom":t.drawHorLine(r,o+i,r+s,o+i,l);break;case"left":t.drawVerLine(r,o,o+i,l)}}})}drawCellBackground(t,e,r,o,s,i,n={}){let a=null;if(e.shading&&e.shading.fillColor)a=e.shading.fillColor;if(!a&&"function"===typeof e.getCellShading)try{const t=e.getCellShading();if(t&&t.fill&&t.fill.color)a=t.fill.color}catch(t){}if(!a&&e.shading&&e.shading.color)a=e.shading.color;if(!a){const t=e.properties||e.cellProperties;if(t&&t.shading&&t.shading.fillColor)a=t.shading.fillColor}if(!a&&n.tableProps){const t=n.tableProps;const r=n.rowIndex||0;const o=e.logicalColIndex||0;if(t.firstRow&&0===r)a={r:68,g:114,b:196,a:255};else if(t.bandRow&&r>0){const e=t.firstRow?r-1:r;if(e%2===1)a={r:242,g:242,b:242,a:255}}else if(t.firstCol&&0===o&&r>0)a={r:221,g:235,b:247,a:255}}if(a&&void 0!==a.r&&void 0!==a.g&&void 0!==a.b&&t.m_oContext){t.m_oContext.save();t.m_oContext.fillStyle=`rgba(${a.r}, ${a.g}, ${a.b}, ${(a.a||255)/255})`;t.m_oContext.fillRect(r,o,s,i);t.m_oContext.restore()}}drawCellContent(t,e,r,o,s,i){const n=e.getTextBody();if(!n||!n.paragraphs)return;const a=38100;const l=this.convertEMUToPixels(a);let c=l;let h=l;let u=l;let f=l;if(e.margins){c=e.margins.left?this.convertEMUToPixels(e.margins.left):l;h=e.margins.right?this.convertEMUToPixels(e.margins.right):l;u=e.margins.top?this.convertEMUToPixels(e.margins.top):l;f=e.margins.bottom?this.convertEMUToPixels(e.margins.bottom):l}if(n.bodyProperties){const t=n.bodyProperties;if(null!=t.leftMargin)c=this.convertEMUToPixels(t.leftMargin);if(null!=t.rightMargin)h=this.convertEMUToPixels(t.rightMargin);if(null!=t.topMargin)u=this.convertEMUToPixels(t.topMargin);if(null!=t.bottomMargin)f=this.convertEMUToPixels(t.bottomMargin)}const d=r+c;const p=o+u;const g=Math.max(0,s-(c+h));const m=Math.max(0,i-(u+f));this.renderCellTextContent(t,n,d,p,g,m,e)}drawCellBorders(t,e,r,o,s,i,n,a,l){const c=e.getCellBorders();if(!c)return;const h=["top","right","bottom","left"];h.forEach(h=>{const u=c[h];if(!u||"none"===u.style||!u.color||0===u.width)return;if(this.shouldDrawBorder(h,n,a,l,e)){const e=this.resolveBorderColor(u);const n=u.width;if(t.m_oContext){t.m_oContext.save();t.m_oContext.strokeStyle=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`;t.m_oContext.lineWidth=n;t.m_oContext.beginPath();switch(h){case"top":t.m_oContext.moveTo(r,o);t.m_oContext.lineTo(r+s,o);break;case"right":t.m_oContext.moveTo(r+s,o);t.m_oContext.lineTo(r+s,o+i);break;case"bottom":t.m_oContext.moveTo(r,o+i);t.m_oContext.lineTo(r+s,o+i);break;case"left":t.m_oContext.moveTo(r,o);t.m_oContext.lineTo(r,o+i)}t.m_oContext.stroke();t.m_oContext.restore()}}})}shouldDrawBorder(t,e,r,o,s=null){const i=o.getRowCount();const n=o.getColumnCount();const a=s?Math.max(1,s.gridSpan||1):1;const l=s?Math.max(1,s.rowSpan||1):1;switch(t){case"top":if(0===e)return true;if(s&&s.isMergedContinue&&"continue"===s.vMerge)return false;return true;case"right":const t=r+a-1;if(t===n-1)return true;return true;case"bottom":const o=e+l-1;if(o===i-1)return true;return true;case"left":if(0===r)return true;return true;default:return true}}calculateCellWidths(t,e){const r=t.getTableGrid();if(!r||0===r.length){const r=t.getColumnCount();return new Array(r).fill(e/r)}const o=r.map(t=>Math.max(0,parseInt(t.width)||0));const s=o.reduce((t,e)=>t+e,0)||1;const i=o.map(t=>e*(t/s));const n=t.getColumnCount();if(i.lengtht+e,0);const o=(e-r)/Math.max(t,1);for(let e=0;et+e,0)||r;return o.map(t=>e*(t/s))}isStartingCellOfMerge(t,e,r){return true}calculateMergedCellWidth(t,e,r){let o=0;for(let s=0;st.fontSizePx));const n=Math.round(1.25*i);a.push({runSegments:s,textAlign:o,lineHeight:n})}if(0===a.length)return;const l=a.reduce((t,e)=>t+e.lineHeight,0);let c="ctr";if(n&&n.verticalAlignment)c=n.verticalAlignment;else if(e.bodyProperties&&e.bodyProperties.anchor)c=e.bodyProperties.anchor;let h=o;if("t"===c||"top"===c)h=o;else if("ctr"===c||"center"===c||"middle"===c)h=o+Math.max(0,(i-l)/2);else if("b"===c||"bottom"===c)h=o+Math.max(0,i-l);else h=o+Math.max(0,(i-l)/2);if(!isFinite(h))h=o;if(t.m_oContext)for(let e=0;e0)for(const e of t.runs)if(e.properties&&e.properties.color)return e.properties.color;return{r:159,g:159,b:159,a:255}}drawCenteredText(t,e,r,o,s,i){if(!t.m_oContext)return;t.m_oContext.save();t.m_oContext.fillStyle="rgba(128, 128, 128, 0.8)";t.m_oContext.font="14px Arial";t.m_oContext.textAlign="center";t.m_oContext.textBaseline="middle";t.m_oContext.fillText(e,r+s/2,o+i/2);t.m_oContext.restore()}parseTableFromXML(t){if(!t)return null;try{const e=new DOMParser;const r=e.parseFromString(t,"text/xml");if("parsererror"===r.documentElement.nodeName){void 0;return null}const o=new CTable;this.tableRowData=[];this.parseTableProperties(r,o);this.parseTableGrid(r,o);this.parseTableRows(r,o);this.processTableMerges(o);if(!this.validateTableStructure(o)){void 0;try{const t=(o.getTableGrid()||[]).length;void 0;const e=o.getRows();for(let t=0;t`c${e}{gs:${t.gridSpan||1},rs:${t.rowSpan||1},cont:${!!t.isMergedContinue},v:${t.vMerge||""},lc:${t.logicalColIndex||0}}`).join(" | ");void 0}}catch(t){}}return o}catch(t){void 0;return null}finally{this.tableRowData=null}}parseTableProperties(t,e){let r=t.querySelector("tblPr");if(!r)r=t.querySelector("a\\:tblPr");if(r){const t={};const o=r.getAttribute("firstRow");if("1"===o||"true"===o)t.firstRow=true;const s=r.getAttribute("bandRow");if("1"===s||"true"===s)t.bandRow=true;const i=r.getAttribute("firstCol");if("1"===i||"true"===i)t.firstCol=true;const n=r.getAttribute("lastRow");if("1"===n||"true"===n)t.lastRow=true;const a=r.getAttribute("lastCol");if("1"===a||"true"===a)t.lastCol=true;const l=r.getAttribute("bandCol");if("1"===l||"true"===l)t.bandCol=true;let c=r.querySelector("tblStyle");if(!c)c=r.querySelector("a\\:tblStyle");if(c)t.style=c.getAttribute("val");let h=r.querySelector("tblBorders");if(!h)h=r.querySelector("a\\:tblBorders");if(h)t.borders=this.parseTableBorders(h);let u=r.querySelector("tblShading");if(!u)u=r.querySelector("a\\:tblShading");if(u)t.shading=this.parseTableShading(u);let f=r.querySelector("tblLayout");if(!f)f=r.querySelector("a\\:tblLayout");if(f)t.layout=f.getAttribute("type")||"autofit";let d=r.querySelector("tblW");if(!d)d=r.querySelector("a\\:tblW");if(d){const e=d.getAttribute("w");const r=d.getAttribute("type")||d.getAttribute("wtype")||"auto";if(e)t.preferredWidth={value:parseInt(e)||0,type:r.toLowerCase()};else t.preferredWidth={value:0,type:r.toLowerCase()}}e.tableProperties=t}}parseTableGrid(t,e){let r=t.querySelector("tblGrid");if(!r)r=t.querySelector("a\\:tblGrid");if(r){let t=r.querySelectorAll("gridCol");if(0===t.length)t=r.querySelectorAll("a\\:gridCol");const o=[];t.forEach(t=>{const e=t.getAttribute("w");const r={width:e?parseInt(e):914400,type:t.getAttribute("type")||"auto"};o.push(r)});e.setTableGrid(o)}}parseTableRows(t,e){let r=t.querySelectorAll("tr");if(0===r.length)r=t.querySelectorAll("a\\:tr");r.forEach((t,r)=>{const o=new CTableRow;this.parseRowProperties(t,o);this.parseRowCells(t,o,r);e.addRow(o)})}parseRowProperties(t,e){let r=t.querySelector("trPr");if(!r)r=t.querySelector("a\\:trPr");if(r){let t=r.querySelector("trHeight");if(!t)t=r.querySelector("a\\:trHeight");if(t){const r=parseInt(t.getAttribute("val"),10);if(!Number.isNaN(r))e.height=r;e.heightRule=t.getAttribute("hRule")||"auto"}let o=r.querySelector("tblHeader");if(!o)o=r.querySelector("a\\:tblHeader");if(o)e.isHeader=true}if((!e.height||e.height<=0)&&t){const r=t.getAttribute("h");if(null!==r){const t=parseInt(r,10);if(!Number.isNaN(t)&&t>0){e.height=t;if(!e.heightRule)e.heightRule="auto"}}}}parseRowCells(t,e,r){let o=t.querySelectorAll("tc");if(0===o.length)o=t.querySelectorAll("a\\:tc");const s=t.closest("tbl")||t.closest("a\\:tbl");let i=10;if(s){let t=s.querySelector("tblGrid");if(!t)t=s.querySelector("a\\:tblGrid");if(t){let e=t.querySelectorAll("gridCol");if(0===e.length)e=t.querySelectorAll("a\\:gridCol");i=e.length}}const n=new Array(i).fill(false);if(r>0&&this.tableRowData)for(let t=0;t{if(e.rowSpan>1){const o=t+e.rowSpan-1;if(o>=r){const t=e.logicalColIndex;const r=t+(e.gridSpan||1);for(let e=t;e{const s=t.getAttribute("vMerge");const l=t.getAttribute("gridSpan");const c=t.getAttribute("rowSpan");const h=t.getAttribute("hMerge");let u=t.querySelector("tcPr");if(!u)u=t.querySelector("a\\:tcPr");let f=null;if(u)f=u.querySelector("vMerge")||u.querySelector("a\\:vMerge");const d="1"===h||"true"===h||a>0;const p="1"===s||"true"===s||"continue"===s;const g=f&&"restart"!==f.getAttribute("val");const m=p||g;let y=l?parseInt(l):1;let b=c?parseInt(c):1;if(u){const t=u.querySelector("gridSpan")||u.querySelector("a\\:gridSpan");if(t){const e=parseInt(t.getAttribute("val"));if(e>1)y=e}const e=u.querySelector("rowSpan")||u.querySelector("a\\:rowSpan");if(e){const t=parseInt(e.getAttribute("val"));if(t>1)b=t}}let x=0;if(m){while(x=i)x=0}else{while(x=i)x=Math.min(o,i-1)}const S=new CTableCell;if(m){S.isMergedContinue=true;S.vMerge="continue"}if(b>1)S.rowSpan=b;if(y>1)S.gridSpan=y;const w=d?0:m?1:y;for(let t=0;t0)a--}else if(!m&&y>1)a=y-1;else a=0;this.parseCellProperties(t,S,r,o);this.parseCellContent(t,S);if(d){S.isMergedContinue=true;S.mergeParent=null}S.logicalRowIndex=r;S.logicalColIndex=x;this.tableRowData[r].push({logicalColIndex:x,gridSpan:y,rowSpan:b,isVerticalContinuation:m});e.addCell(S)})}parseCellProperties(t,e,r,o){let s=t.querySelector("tcPr");if(!s)s=t.querySelector("a\\:tcPr");if(s){let t=s.querySelector("gridSpan");if(!t)t=s.querySelector("a\\:gridSpan");if(t)e.gridSpan=parseInt(t.getAttribute("val"))||1;let r=s.querySelector("rowSpan");if(!r)r=s.querySelector("a\\:rowSpan");if(r)e.rowSpan=parseInt(r.getAttribute("val"))||1;let o=s.querySelector("vMerge");if(!o)o=s.querySelector("a\\:vMerge");if(o){const t=o.getAttribute("val");e.vMerge="restart"===t?"start":"continue"}const i=s.getAttribute("anchor");if(i)e.verticalAlignment=i;const n=s.getAttribute("vert");if(n)e.textDirection=n;const a=this.parseCellBordersFromTcPr(s);if(a)e.borders=a;const l=Array.from(s.children).find(t=>"a:solidFill"===t.tagName||"solidFill"===t.tagName);if(l)e.shading=this.parseCellShading(l);else{const t=s.querySelectorAll("solidFill, a\\:solidFill");let r=null;for(const e of t){let t=e.parentElement;let o=false;while(t&&t!==s){if("a:lnL"===t.tagName||"a:lnR"===t.tagName||"a:lnT"===t.tagName||"a:lnB"===t.tagName||"lnL"===t.tagName||"lnR"===t.tagName||"lnT"===t.tagName||"lnB"===t.tagName){o=true;break}t=t.parentElement}if(!o){r=e;break}}if(r)e.shading=this.parseCellShading(r)}let c=s.querySelector("tcMar");if(!c)c=s.querySelector("a\\:tcMar");if(c)e.margins=this.parseCellMargins(c);else{const t=s.getAttribute("marL");const r=s.getAttribute("marR");const o=s.getAttribute("marT");const i=s.getAttribute("marB");if(t||r||o||i)e.margins={left:t?parseInt(t):null,right:r?parseInt(r):null,top:o?parseInt(o):null,bottom:i?parseInt(i):null}}}}parseCellContent(t,e){const r=this.parseTextBodyFromElement(t);if(r)e.setTextBody(r)}appendMergedCellText(t,e){if(!e||e.mergedContentTransferred)return;const r=e.getTextBody&&e.getTextBody();if(!r||!r.paragraphs||0===r.paragraphs.length)return;if(!t.getTextBody||!t.setTextBody)return;const o=t.getTextBody();if(!o||!o.paragraphs)t.setTextBody({paragraphs:[...r.paragraphs]});else{if(o.paragraphs.length>0)o.paragraphs.push({runs:[],properties:{}});o.paragraphs.push(...r.paragraphs)}e.mergedContentTransferred=true;e.setTextBody&&e.setTextBody({paragraphs:[]})}processTableMerges(t){const e=t.getRows();for(let r=0;r1)this.processHorizontalMerge(t,r,o,i.gridSpan);if(i.rowSpan>1)this.processVerticalMerge(t,r,o,i.rowSpan);if("start"===i.vMerge){let s=1;for(let n=r+1;n=0;e--){const s=t.getCell(e,o);if(!s)break;if("start"===s.vMerge){i.isMergedContinue=true;i.mergeParent={row:e,col:o};const t=r-e+1;if(!s.rowSpan||s.rowSpan1){const s=o+i.rowSpan-1;if(s>=t){const t=Math.max(0,i.logicalColIndex||0);const o=Math.min(r,t+Math.max(1,i.gridSpan||1));for(let r=t;r2*a){void 0;try{const t=s.map((t,e)=>`c${e}{gs:${t.gridSpan||1},rs:${t.rowSpan||1},cont:${!!t.isMergedContinue},v:${t.vMerge||""},lc:${t.logicalColIndex||0}}`).join(" | ");void 0}catch(t){}return false}}return true}parseTableBorders(t){const e={};const r=["top","left","bottom","right","insideH","insideV"];r.forEach(r=>{let o=t.querySelector(r);if(!o)o=t.querySelector(`a\\:${r}`);if(o)e[r]=this.parseBorderProperties(o)});return e}parseCellBordersFromTcPr(t){const e={};const r={lnL:"left",lnR:"right",lnT:"top",lnB:"bottom"};for(const[o,s]of Object.entries(r)){let r=t.querySelector(o);if(!r)r=t.querySelector(`a\\:${o}`);if(r){const t=parseInt(r.getAttribute("w"))||0;const o=this.parseColor(r);const i=t>0?Math.max(1,Math.round(this.convertEMUToPixels(t))):1;if(null!==o&&i>0)e[s]={style:"single",width:i,color:o}}}return Object.keys(e).length>0?e:null}parseCellBorders(t){return this.parseTableBorders(t)}parseBorderProperties(t){const e=this.parseColor(t);const r=parseInt(t.getAttribute("w"))||0;let o=0;if(r>0)o=Math.max(1,Math.round(this.convertEMUToPixels(r)));else{const e=parseInt(t.getAttribute("sz"))||0;if(e>0){const t=e/8;o=Math.max(1,Math.round(t*(96/72)))}}return{style:t.getAttribute("val")||"single",width:o,size:parseInt(t.getAttribute("sz"))||0,color:e,space:parseInt(t.getAttribute("space"))||0}}parseTableShading(t){return this.parseCellShading(t)}parseCellShading(t){const e=t.getAttribute("fill");const r=t.getAttribute("color");let o=null;if("a:solidFill"===t.tagName||"solidFill"===t.tagName)o=this.parseColor(t);else{const e=t.querySelector("solidFill")||t.querySelector("a\\:solidFill");if(e)o=this.parseColor(e)}return{fill:e,color:r?this.parseColorFromHex(r):null,fillColor:o}}parseCellMargins(t){const e={};const r=["top","left","bottom","right"];r.forEach(r=>{let o=t.querySelector(r);if(!o)o=t.querySelector(`a\\:${r}`);if(o)e[r]=parseInt(o.getAttribute("w"))||0});return e}extractTableStructure(t){if(!t.graphicData||!t.graphicData.tableXml)return null;try{const e=this.parseTableFromXML(t.graphicData.tableXml);if(!e)return null;const r={id:t.id,name:t.name,type:"table",properties:this.extractTableProperties(e),structure:this.extractTableStructureData(e),content:this.extractTableContent(e),styling:this.extractTableStyling(e),position:t.bounds||t.properties?.transform,metadata:{rowCount:e.getRowCount(),columnCount:e.getColumnCount(),hasMergedCells:this.hasMergedCells(e),tableStyle:e.getTableProperties()?.style||"TableGrid"}};return r}catch(t){void 0;return null}}extractTableProperties(t){const e=t.getTableProperties()||{};return{style:e.style||"TableGrid",layout:e.layout||"autofit",width:e.width||"auto",alignment:e.alignment||"left",borders:e.borders||{},shading:e.shading||{},spacing:{before:e.spacing?.before||0,after:e.spacing?.after||0,line:e.spacing?.line||240}}}extractTableStructureData(t){const e=t.getRows();const r=t.getTableGrid();return{grid:r.map((t,e)=>({index:e,width:t.width,type:t.type||"auto"})),rows:e.map((t,e)=>({index:e,height:t.height,heightRule:t.heightRule||"auto",isHeader:t.isHeader||false,cells:t.getCells().map((t,e)=>({index:e,gridSpan:t.gridSpan||1,rowSpan:t.rowSpan||1,vMerge:t.vMerge||null,isMergedContinue:t.isMergedContinue||false,mergeParent:t.mergeParent||null}))}))}}extractTableContent(t){const e=t.getRows();return{cells:e.map((t,e)=>t.getCells().map((t,r)=>({rowIndex:e,cellIndex:r,text:this.extractCellText(t),textBody:this.extractCellTextBody(t),content:this.extractCellContent(t)})))}}extractTableStyling(t){const e=t.getRows();return{table:{borders:t.getTableProperties()?.borders||{},shading:t.getTableProperties()?.shading||{},style:t.getTableProperties()?.style||"TableGrid"},rows:e.map((t,e)=>({index:e,height:t.height,heightRule:t.heightRule||"auto",isHeader:t.isHeader||false})),cells:e.map((t,e)=>t.getCells().map((t,r)=>({rowIndex:e,cellIndex:r,borders:t.borders||{},shading:t.shading||{},margins:t.margins||{},verticalAlignment:t.verticalAlignment||"top",textDirection:t.textDirection||"lr"})))}}hasMergedCells(t){const e=t.getRows();for(const t of e)for(const e of t.getCells())if(e.gridSpan>1||e.rowSpan>1||e.isMergedContinue)return true;return false}extractCellTextBody(t){const e=t.getTextBody();if(!e||!e.paragraphs)return null;return{paragraphs:e.paragraphs.map(t=>({properties:t.properties||{},runs:t.runs?.map(t=>({text:t.text||"",properties:t.properties||{}}))||[]}))}}extractCellContent(t){const e={type:"text",data:null};const r=t.getTextBody();if(r&&r.paragraphs){e.type="text";e.data=this.extractCellTextBody(t)}return e}extractCellText(t){if(!t.textBody||!t.textBody.paragraphs)return"";return t.textBody.paragraphs.map(t=>{if(!t.runs)return"";return t.runs.map(t=>t.text||"").join("")}).join("\n")}getTableData(t){return null}getAllTableData(t){const e=[];for(let r=0;r{const e={runs:[],properties:{}};let o=t.querySelector("pPr");if(!o)o=t.querySelector("a\\:pPr");if(o){const t=o.getAttribute("algn");if(t)e.properties.alignment=t}let s=t.querySelectorAll("r");if(0===s.length)s=t.querySelectorAll("a\\:r");s.forEach(t=>{const r={text:"",properties:{}};let o=t.querySelector("t");if(!o)o=t.querySelector("a\\:t");if(o)r.text=o.textContent||"";let s=t.querySelector("rPr");if(!s)s=t.querySelector("a\\:rPr");if(s){const t=s.querySelector("solidFill")||s.querySelector("a\\:solidFill");if(t)r.properties.color=this.parseColor(t);const e=s.getAttribute("sz");if(e)r.properties.fontSize=parseInt(e)/100;else r.properties.fontSize=12;r.properties.bold="1"===s.getAttribute("b");r.properties.italic="1"===s.getAttribute("i");const o=s.getAttribute("u");if(o&&"none"!==o)r.properties.underline=true;const i=s.getAttribute("strike");if(i&&"noStrike"!==i)r.properties.strikethrough=true;let n=s.getAttribute("typeface")||s.getAttribute("fontFamily");if(!n){const t=s.querySelector("latin")||s.querySelector("a\\:latin");if(t)n=t.getAttribute("typeface")}if(n)r.properties.fontFamily=n;else r.properties.fontFamily="Arial"}e.runs.push(r)});r.paragraphs.push(e)});return r.paragraphs.length>0?r:null}parseColor(t){if(!t)return null;const e=t.querySelector("noFill")||t.querySelector("a\\:noFill");if(e)return null;const r=t.querySelector("solidFill")||t.querySelector("a\\:solidFill");if(r){const t=r.querySelector("srgbClr")||r.querySelector("a\\:srgbClr");if(t){const e=t.getAttribute("val");if(e){const t=this.parseColorFromHex(e);if(t)return t}}const e=r.querySelector("schemeClr")||r.querySelector("a\\:schemeClr");if(e){const t=e.getAttribute("val");const r=this.resolveSchemeColor(t);if(r)return r}}const o=t.querySelector("srgbClr")||t.querySelector("a\\:srgbClr");if(o){const t=o.getAttribute("val");if(t){const e=this.parseColorFromHex(t);if(e)return e}}const s=t.querySelector("schemeClr")||t.querySelector("a\\:schemeClr");if(s){const t=s.getAttribute("val");const e=this.resolveSchemeColor(t);if(e)return e}const i=t.getAttribute("color");if(i){const t=this.parseColorFromHex(i);if(t)return t}return null}resolveSchemeColor(t){if(!t)return null;const e={tx1:"#000000",tx2:"#FFFFFF",bg1:"#FFFFFF",bg2:"#EEECE1",accent1:"#5B9BD5",accent2:"#ED7D31",accent3:"#A5A5A5",accent4:"#FFC000",accent5:"#4472C4",accent6:"#70AD47"};const r=e[t];return r?this.parseColorFromHex(r):null}parseColorFromHex(t){if(!t||"string"!==typeof t)return null;t=t.replace("#","");if(6===t.length){const e=parseInt(t.substring(0,2),16);const r=parseInt(t.substring(2,4),16);const o=parseInt(t.substring(4,6),16);return{r:e,g:r,b:o,a:255}}if(3===t.length){const e=parseInt(t.charAt(0)+t.charAt(0),16);const r=parseInt(t.charAt(1)+t.charAt(1),16);const o=parseInt(t.charAt(2)+t.charAt(2),16);return{r:e,g:r,b:o,a:255}}return null}convertEMUToPixels(t){if(!t||"number"!==typeof t)return 3.78;return t/914400*96}cleanup(){this.tableCache.clear()}_getValidator(){return"undefined"!==typeof window&&window.DataValidator?window.DataValidator:class{validate(){return{valid:true,errors:[]}}}}_getErrorBoundary(){return"undefined"!==typeof window&&window.ErrorBoundary?window.ErrorBoundary:class{constructor(){}wrap(t){return t}}}_validateConfig(t){const e={type:"object",properties:{maxTableSize:{type:"number",minimum:1,maximum:1e4},maxCellTextLength:{type:"number",minimum:1,maximum:1e5},enableCaching:{type:"boolean"},enableValidation:{type:"boolean"},renderTimeout:{type:"number",minimum:1e3,maximum:6e4}}};try{const r=new(this._getValidator())({throwOnError:false});const o=r.validate(t,e);if(!o.valid&&this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","Invalid configuration:",o.errors)}catch(t){}return t}_validateRenderInput(t,e,r,o,s,i,n){const a=[];if(!t||"object"!==typeof t)a.push("Graphics object is required");else{const e=["SaveGrState","RestoreGrState","b_color1","TableRect"];for(const r of e)if("function"!==typeof t[r])a.push(`Graphics object missing required method: ${r}`)}if(!e||"object"!==typeof e)a.push("Shape object is required");if("number"!==typeof r||!isFinite(r))a.push("X coordinate must be a finite number");if("number"!==typeof o||!isFinite(o))a.push("Y coordinate must be a finite number");if("number"!==typeof s||!isFinite(s)||s<=0)a.push("Width must be a positive finite number");if("number"!==typeof i||!isFinite(i)||i<=0)a.push("Height must be a positive finite number");if(n&&"object"!==typeof n)a.push("Options must be an object");return{valid:0===a.length,errors:a}}_validateTableXML(t){if("string"!==typeof t||0===t.trim().length)throw this._createError("Table XML must be a non-empty string",{name:"ValidationError",code:"INVALID_TABLE_XML"});if(!t.includes("<")||!t.includes(">"))throw this._createError("Table XML does not appear to be valid XML",{name:"ValidationError",code:"MALFORMED_TABLE_XML"});const e=["tbl","tr","tc"];const r=e.some(e=>t.includes(`<${e}`)||t.includes(`this.config.maxTableSize)throw this._createError(`Table size ${r*o} exceeds maximum ${this.config.maxTableSize}`,{name:"ValidationError",code:"TABLE_TOO_LARGE"})}_validateTableStructure(t){try{const e=t.getRowCount();const r=t.getColumnCount();if(e>100||r>50)if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor",`Large table detected: ${e}x${r}`);let o=0;for(let s=0;sthis.config.maxCellTextLength)if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor",`Cell text length ${r.textBody.length} exceeds maximum ${this.config.maxCellTextLength}`)}}if(0===o)throw this._createError("Table has no valid cells",{name:"ValidationError",code:"EMPTY_TABLE"})}catch(t){throw this._enhanceError(t,"table_structure_validation")}}async _safeDrawTableBackgroundAndOuterBorder(t,e,r,o,s,i){try{this.drawTableBackgroundAndOuterBorder(t,e,r,o,s,i)}catch(t){if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","Error drawing table background/border:",t)}}async _safeDrawCellsBackground(t,e,r,o,s,i){try{this.drawCellsBackground(t,e,r,o,s,i)}catch(t){if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","Error drawing cell backgrounds:",t)}}async _safeDrawCellsContent(t,e,r,o,s,i){try{this.drawCellsContent(t,e,r,o,s,i)}catch(t){void 0;void 0;void 0;void 0;if(this.logger)this.logger.logError(this.constructor.name,"TableProcessor","Error drawing cell content:",t);throw t}}async _safeDrawCellsBorders(t,e,r,o,s,i){try{this.drawCellsBorders(t,e,r,o,s,i)}catch(t){if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","Error drawing cell borders:",t)}}_handleValidationError(t,e){const r=`Validation failed for ${t}: ${e.join(", ")}`;if(this.logger)this.logger.logError(this.constructor.name,"TableProcessor",r);const o=this._createError(r,{name:"ValidationError",code:"INPUT_VALIDATION_FAILED",details:{operation:t,errors:e}});return o}_updatePerformanceMetrics(t){this.performanceMetrics.tablesProcessed++;const e=performance.now()-t;const r=this.performanceMetrics.averageRenderTime*(this.performanceMetrics.tablesProcessed-1);this.performanceMetrics.averageRenderTime=(r+e)/this.performanceMetrics.tablesProcessed;if(this.logger&&e>1e3)this.logger.log("warn",this.constructor.name,"TableProcessor",`Slow table render: ${Math.round(e)}ms`)}_createError(t,e={}){const r=new Error(t);r.name=e.name||"TableProcessingError";r.code=e.code||null;r.context="TableProcessor";r.timestamp=(new Date).toISOString();r.recoverable=false!==e.recoverable;if(e.details)r.details=e.details;return r}_enhanceError(t,e,r={}){if(t.enhanced)return t;const o=t instanceof Error?t:new Error(String(t));o.operation=e;o.tableProcessorContext=r;o.timestamp=(new Date).toISOString();o.enhanced=true;return o}getPerformanceMetrics(){return{...this.performanceMetrics,cacheHitRatio:this.performanceMetrics.cacheHits/(this.performanceMetrics.cacheHits+this.performanceMetrics.cacheMisses)||0}}resetPerformanceMetrics(){this.performanceMetrics={tablesProcessed:0,cacheHits:0,cacheMisses:0,averageRenderTime:0}}};if("undefined"!==typeof globalThis)globalThis.TableProcessor=L;var D={exports:{}};var B=D.exports;var q;function $(){if(q)return D.exports;q=1;!function(t){class e{constructor(){this.type="";this.subtype="";this.is3D=false;this.title="";this.series=[];this.categories=[];this.styling={};this.legend=null;this.axes={};this.plotArea={};this.dataLabels={};this.raw=null}}class r{constructor(){this.index=0;this.name="";this.values=[];this.categories=[];this.fill=null;this.line=null;this.marker=null;this.dataLabels=null;this.trendlines=[]}}class o{constructor(t,e={}){this.context=t;this.currentSlideContext=null;try{this.logger=new Logger("ChartProcessor")}catch(t){void 0;this.logger=this._createFallbackLogger()}this.fontConfig=null}setSlideContext(t){this.currentSlideContext=t}clearSlideContext(){this.currentSlideContext=null}async parseChartFromGraphicFrame(t){try{const e=this.getShapeName(t);const r=t.querySelector("graphic")||t.querySelector("a\\:graphic")||t.querySelector('[*|localName="graphic"]');if(!r)return null;const o=r.querySelector("graphicData")||r.querySelector("a\\:graphicData")||r.querySelector('[*|localName="graphicData"]');if(!o)return null;const s=o.getAttribute("uri");if("http://schemas.openxmlformats.org/drawingml/2006/chart"!==s)return null;const i=o.querySelector("chart")||o.querySelector("c\\:chart")||o.querySelector('[*|localName="chart"]');if(!i){const t=o.querySelector("chartSpace, c\\:chartSpace");if(t)return this.parseEmbeddedChartData(o,e);return null}const n=i.getAttribute("r:id");if(!n){const t=this.parseEmbeddedChartData(o,e);if(t&&this.hasRealChartData(t))return t;return null}if(!this.currentSlideContext)return{type:"DEFERRED_CHART",relationshipId:n,needsSlideContext:true};return await this.loadChartFromRelationship(n,this.currentSlideContext)}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing chart from graphic frame",t);return null}}parseEmbeddedChartData(t,r=null){const o=new e;try{const e=t.querySelector("chartSpace, c\\:chartSpace");if(!e)return null;this.parseChartSpace(e,o);return o}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing embedded chart data",t);return null}}parseChartSpace(t,e){const r=t.querySelector("roundedCorners, c\\:roundedCorners");if(r){const t=r.getAttribute("val");e.roundedCorners="1"===t||"true"===t}else e.roundedCorners=false;const o=t.querySelector("chart, c\\:chart");if(o)this.parseChart(o,e);const s=Array.from(t.children||[]);const i=s.find(t=>"spPr"===t.localName);if(i)e.chartSpaceShapeProperties=this.parseShapeProperties(i);this.parsePrintSettings(t,e);this.parseExternalData(t,e)}parseChart(t,e){const r=t.querySelector("title, c\\:title");if(r)e.title=this.parseTitle(r);const o=t.querySelector("plotArea, c\\:plotArea");if(o)this.parsePlotArea(o,e);const s=t.querySelector("legend, c\\:legend");if(s)e.legend=this.parseLegend(s);const i=t.querySelector("autoTitleDeleted, c\\:autoTitleDeleted");if(i&&"1"===i.getAttribute("val"))e.title="";const n=t.querySelector("dTable, c\\:dTable");e.hasDataTable=!!n}parsePlotArea(t,e){e.plotArea=this.parsePlotAreaProperties(t);const r=["barChart","bar3DChart","colChart","col3DChart","lineChart","line3DChart","pieChart","pie3DChart","doughnutChart","areaChart","area3DChart","scatterChart","bubbleChart","radarChart","stockChart","surfaceChart","surface3DChart","waterfallChart","comboChart","sunburstChart","treemapChart","histogramChart","boxWhiskerChart"];let o=false;for(const s of r){const r=t.querySelectorAll(`${s}, c\\:${s}`);for(const t of r)if(!o){this.parseSpecificChart(t,s,e);o=true}else{const r=this.normalizeChartType(s);const o=t.querySelectorAll("ser, c\\:ser");for(let t=0;t0){o.pointFills=[];t.forEach(t=>{const e=t.querySelector("idx, c\\:idx");const r=t.querySelector("spPr, c\\:spPr");if(e&&r){const t=parseInt(e.getAttribute("val"));if(!isNaN(t)){const e=this.parseShapeProperties(r);if(e&&e.fill)o.pointFills[t]=e.fill}}})}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing data point formatting (dPt):",t)}if(!o.dataLabels&&r.dataLabels)o.dataLabels={...r.dataLabels};else if(o.dataLabels);r.series.push(o)}}try{if("pie"===r.type||"doughnut"===r.type){const e=t.querySelector("firstSliceAng, c\\:firstSliceAng");if(e){const t=parseInt(e.getAttribute("val"));if(!isNaN(t))r.firstSliceAng=t}const o=t.querySelector("holeSize, c\\:holeSize");if(o){const t=parseInt(o.getAttribute("val"));if(!isNaN(t))r.holeSize=t}}if("waterfall"===r.type){r.waterfallType="standard";const e=t.querySelectorAll("subtotal, c\\:subtotal");if(e.length>0){r.subtotals=[];e.forEach(t=>{const e=t.getAttribute("val");if(e)r.subtotals.push({value:e})})}}if("combo"===r.type){r.comboTypes=[];const e=["barChart","lineChart","areaChart","scatterChart"];e.forEach(e=>{const o=t.querySelector(`${e}, c\\:${e}`);if(o)r.comboTypes.push(this.normalizeChartType(e))})}if("radar"===r.type){const e=t.querySelector("radarStyle, c\\:radarStyle");if(e)r.radarStyle=e.getAttribute("val")||"standard";else r.radarStyle="standard"}if("bubble"===r.type){const e=t.querySelector("bubble3D, c\\:bubble3D");if(e)r.bubble3D="1"===e.getAttribute("val");const o=t.querySelector("bubbleScale, c\\:bubbleScale");if(o){const t=parseInt(o.getAttribute("val"));if(!isNaN(t))r.bubbleScale=t}}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing chart type-specific properties:",t)}if(0===r.categories.length&&r.series.length>0)r.categories=[...r.series[0].categories];if(r.series.length>0&&r.series[0].categoryFormatCode)r.categoryFormatCode=r.series[0].categoryFormatCode;if(r.series.length>0&&r.series[0].outerCategoryLevels)r.outerCategoryLevels=r.series[0].outerCategoryLevels}parseSeries(t,e){const o=new r;try{const e=t.querySelector("idx, c\\:idx");if(e)o.index=parseInt(e.getAttribute("val"))||0;const r=t.querySelector("tx, c\\:tx");if(r)o.name=this.parseSeriesText(r);const s=t.querySelector("cat, c\\:cat");const i=t.querySelector("xVal, c\\:xVal");if(s){o.categories=this.parseSeriesData(s);const t=s.querySelector("numRef, c\\:numRef");if(t){const e=t.querySelector("numCache, c\\:numCache");if(e){const t=e.querySelector("formatCode, c\\:formatCode");if(t&&t.textContent)o.categoryFormatCode=t.textContent.trim()}}const e=s.querySelector("multiLvlStrRef, c\\:multiLvlStrRef");if(e)o.outerCategoryLevels=this.parseOuterCategoryLevels(e,o.categories.length)}else if(i)o.categories=this.parseSeriesData(i);const n=t.querySelector("val, c\\:val");const a=t.querySelector("yVal, c\\:yVal");if(n)o.values=this.parseSeriesData(n);else if(a)o.values=this.parseSeriesData(a);const l=t.querySelector("bubbleSize, c\\:bubbleSize");if(l)o.bubbleSizes=this.parseSeriesData(l);o.fill=this.parseSeriesFill(t);o.line=this.parseSeriesLine(t);o.marker=this.parseSeriesMarker(t);const c=t.querySelector("spPr, c\\:spPr");if(c){const t=this.parseShapeProperties(c);if(t.outerShadow)o.outerShadow=t.outerShadow}const h=t.querySelector("smooth, c\\:smooth");o.smooth=h?"1"===h.getAttribute("val"):false;if(o.fill&&"noFill"!==o.fill&&(void 0!==o.fill.r||"string"===typeof o.fill))o.color=o.fill;else if(o.line&&(void 0!==o.line.r||"string"===typeof o.line))o.color=o.line;const u=t.querySelector("dLbls, c\\:dLbls");if(u){o.dataLabels=this.parseDataLabels(u);if(o.dataLabels&&o.dataLabels.formatting&&o.dataLabels.formatting.font){const t=o.dataLabels.formatting.font;if(t.size&&!t.fontSize){t.fontSize=t.size;delete t.size}}}return o}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing series",t);return null}}parseSeriesData(t){const e=[];try{const e=t.querySelector("numRef, c\\:numRef");const r=t.querySelector("strRef, c\\:strRef");const o=t.querySelector("multiLvlStrRef, c\\:multiLvlStrRef");const s=t.querySelector("numLit, c\\:numLit");const i=t.querySelector("strLit, c\\:strLit");if(e)return this.parseNumberReference(e);else if(r)return this.parseStringReference(r);else if(o)return this.parseMultiLevelStringReference(o);else if(s)return this.parseNumberLiteral(s);else if(i)return this.parseStringLiteral(i)}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing series data",t)}return e}parseNumberReference(t){const e=[];const r=t.querySelector("numCache, c\\:numCache");if(r){const t=r.querySelectorAll("pt, c\\:pt");for(const r of t){const t=r.querySelector("v, c\\:v");if(t){const r=parseFloat(t.textContent);e.push(isNaN(r)?0:r)}}}return e}parseStringReference(t){const e=[];const r=t.querySelector("strCache, c\\:strCache");if(r){const t=r.querySelectorAll("pt, c\\:pt");for(const r of t){const t=r.querySelector("v, c\\:v");if(t)e.push(t.textContent||"")}}return e}parseMultiLevelStringReference(t){const e=[];try{const r=t.querySelector("multiLvlStrCache, c\\:multiLvlStrCache");if(r){const t=r.querySelectorAll("lvl, c\\:lvl");const o=t.length>0?t[0]:null;if(o){const t=o.querySelectorAll("pt, c\\:pt");for(const r of t){const t=r.querySelector("v, c\\:v");if(t)e.push(t.textContent||"")}}}return e}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing multi-level string reference",t);return[]}}parseOuterCategoryLevels(t,e){try{const r=t.querySelector("multiLvlStrCache, c\\:multiLvlStrCache");if(!r)return null;const o=r.querySelectorAll("lvl, c\\:lvl");if(o.length<2)return null;const s=[];for(let t=1;t0)s.push(n)}return s.length>0?s:null}catch(t){return null}}parseNumberLiteral(t){const e=[];const r=t.querySelectorAll("pt, c\\:pt");for(const t of r){const r=t.querySelector("v, c\\:v");if(r){const t=parseFloat(r.textContent);e.push(isNaN(t)?0:t)}}return e}parseStringLiteral(t){const e=[];const r=t.querySelectorAll("pt, c\\:pt");for(const t of r){const r=t.querySelector("v, c\\:v");if(r)e.push(r.textContent||"")}return e}parseSeriesText(t){const e=t.querySelector("strRef, c\\:strRef");if(e){const t=e.querySelector("strCache, c\\:strCache");if(t){const e=t.querySelector("pt, c\\:pt");if(e){const t=e.querySelector("v, c\\:v");if(t)return t.textContent||""}}}const r=t.querySelector("v, c\\:v");if(r)return r.textContent||"";return""}normalizeChartType(t,e=null){const r={barChart:"bar",bar3DChart:"bar",colChart:"column",col3DChart:"column",lineChart:"line",line3DChart:"line",pieChart:"pie",pie3DChart:"pie",doughnutChart:"doughnut",areaChart:"area",area3DChart:"area",scatterChart:"scatter",bubbleChart:"bubble",radarChart:"radar",stockChart:"stock",surfaceChart:"surface",surface3DChart:"surface",waterfallChart:"waterfall",comboChart:"combo",sunburstChart:"sunburst",treemapChart:"treemap",histogramChart:"histogram",boxWhiskerChart:"boxWhisker"};let o=r[t]||t;if(("barChart"===t||"bar3DChart"===t)&&e&&e.barDirection)if("col"===e.barDirection)o="column";else if("bar"===e.barDirection)o="bar";if("radarChart"===t||"radar"===o);if("barChart"===t||"bar3DChart"===t);return o}hasRealChartData(t){if(!t||!t.series||0===t.series.length)return false;const e=t.series[0];if(!e.values||0===e.values.length)return false;const r=[4500,5200,4800,6100,5900];const o=e.values.length===r.length&&e.values.every((t,e)=>t===r[e]);if(o)return false;return true}createPlaceholderChart(t,o=null){const s=new e;s.type="line";const i=o||"Chart";s.title={text:i,formatting:{font:{fontFamily:"Calibri",fontSize:16,bold:true},color:{r:0,g:0,b:0},alignment:"center"}};s.subtitle="Quarterly Revenue Trends 2023-2024";s.categories=["Q1 2023","Q2 2023","Q3 2023","Q4 2023","Q1 2024"];const n=new r;n.index=0;n.name="Sales Trend";n.values=[4500,5200,4800,6100,5900];n.categories=[...s.categories];s.series.push(n);s.axes={category:{id:"catAx1",type:"category",position:"bottom",title:"Time Period",scaling:{min:null,max:null,orientation:"minMax"},tickMarks:{major:"outside",minor:"none"},tickLabels:{position:"nextTo",rotation:null,format:null},gridlines:{major:true,minor:false},visible:true,crosses:"autoZero"},value:{id:"valAx1",type:"value",position:"left",title:"Revenue ($000s)",scaling:{min:0,max:7e3,orientation:"minMax"},tickMarks:{major:"outside",minor:"none"},tickLabels:{position:"nextTo",format:{formatCode:"#,##0",sourceLinked:false}},gridlines:{major:true,minor:false},visible:true,crosses:"autoZero"},series:null};s.legend={position:"b",overlay:false,visible:true,legendPos:"b"};s.dataLabels={showValue:true,showCategoryName:false,showSeriesName:false,showPercent:false,position:"above",formatting:{font:{fontFamily:"Arial",fontSize:9,bold:true},color:{r:60,g:60,b:60},number:{formatCode:"#,##0",sourceLinked:false}},separator:", ",delete:false};s.showDataLabels=true;s.styling={chartArea:{proportions:{width:.85,height:.75}},plotArea:{margins:{left:80,right:20,top:20,bottom:70}}};return s}extractChartData(t,e={}){try{if(!t)throw new Error("Shape parameter is required");let r=null;if("graphicFrame"===t.type)r=this.parseChartFromGraphicFrame(t.element||t);else if(t.graphicData)if(t.graphicData.element)r=this.parseEmbeddedChartData(t.graphicData.element,t.name);else return null;else if(t.tagName)r=this.parseChartFromGraphicFrame(t);else r=this.extractFromRawData(t,e);if(r&&this.validateChartData(r,e)&&this.hasRealChartData(r))return r;this.logger.log("warn",this.constructor.name,"Chart data extraction failed validation or contains hardcoded data");return null}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error extracting chart data",t);void 0;if(e.throwOnError)throw t;return null}}validateChartData(t,r={}){try{if(!t)return false;if(!(t instanceof e)){this.logger.log("warn",this.constructor.name,"Chart data is not an instance of ChartData class");if(r.strict)return false}const o={hasType:this.validateChartType(t.type),hasSeries:this.validateChartSeries(t.series),hasValidData:this.validateChartDataContent(t),hasValidStructure:this.validateChartStructure(t)};const s=["hasType","hasSeries","hasValidData"];const i=s.every(t=>o[t]);if(!i){this.logger.log("warn",this.constructor.name,"Chart data failed required validation checks:",{type:o.hasType,series:o.hasSeries,data:o.hasValidData});return false}if(r.strict&&!o.hasValidStructure){this.logger.log("warn",this.constructor.name,"Chart data failed strict structure validation");return false}return true}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error validating chart data",t);return false}}validateChartType(t){const e=["area","bar","bar3d","bubble","doughnut","line","pie","radar","scatter","stock","surface","waterfall","combo","sunburst","treemap","histogram","boxWhisker"];return"string"===typeof t&&t.length>0&&e.includes(t.toLowerCase())}validateChartSeries(t){if(!Array.isArray(t)||0===t.length)return false;return t.every(t=>this.validateSingleSeries(t))}validateSingleSeries(t){if(!t)return false;const e="number"===typeof t.index&&t.index>=0;const r=Array.isArray(t.values)&&t.values.length>0;const o="string"===typeof t.name;const s=this.validateSeriesDataConsistency(t);return e&&r&&o&&s}validateSeriesDataConsistency(t){if(!t.values||0===t.values.length)return false;const e=t.values.every(t=>"number"===typeof t&&!isNaN(t)&&isFinite(t));let r=true;if(t.categories&&t.categories.length>0)r=t.categories.length===t.values.length;return e&&r}validateChartDataContent(t){if(!t.series||0===t.series.length)return false;const e=t.series.some(t=>t.values&&t.values.length>0&&t.values.some(t=>0!==t&&null!=t));return e}validateChartStructure(t){try{if(this.hasCircularReferences(t))return false;const e="string"===typeof t.type&&Array.isArray(t.series)&&Array.isArray(t.categories);const r=t.series.every(t=>t&&"number"===typeof t.index&&Array.isArray(t.values));return e&&r}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error validating chart structure",t);return false}}hasCircularReferences(t,e=new Set){if(null===t||"object"!==typeof t)return false;if(e.has(t))return true;e.add(t);try{for(const r in t)if(t.hasOwnProperty(r))if(this.hasCircularReferences(t[r],e))return true}catch(t){return true}e.delete(t);return false}extractFromRawData(t,o={}){try{const o=new e;if(t.type)o.type=this.normalizeChartType(t.type);if(t.title)o.title=String(t.title);if(t.series&&Array.isArray(t.series))o.series=t.series.map((t,e)=>{const o=new r;o.index=t.index||e;o.name=t.name||`Series ${e+1}`;o.values=Array.isArray(t.values)?t.values:[];o.categories=Array.isArray(t.categories)?t.categories:[];return o});if(t.categories&&Array.isArray(t.categories))o.categories=t.categories;return o}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error extracting from raw data",t);return null}}parseTitle(t){try{const e={text:"",formatting:{font:{fontFamily:"Calibri",fontSize:16,bold:false},color:{r:0,g:0,b:0},alignment:"center"},overlay:false,position:"top"};const r=t.querySelector("tx, c\\:tx");if(r)e.text=this.parseRichText(r);if(!e.text){const r=t.querySelector("v, c\\:v");if(r)e.text=r.textContent||""}if(!e.text){const r=t.querySelector("rich, c\\:rich");if(r)e.text=this.parseRichTextBody(r)}if(!e.text){const r=t.querySelectorAll("t, c\\:t, a\\:t");if(r.length>0)e.text=Array.from(r).map(t=>t.textContent||"").join(" ").trim()}const o=t.querySelector("txPr, c\\:txPr");if(o){const t=this.parseTextProperties(o);if(t){const r=e.formatting.font||{};const o={...r,...t.font||{}};e.formatting={...e.formatting,...t,font:o};if(e.formatting.font&&e.formatting.font.size&&!e.formatting.font.fontSize){e.formatting.font.fontSize=e.formatting.font.size;delete e.formatting.font.size}}}const s=this.extractFontFromElement(t);if(s){const{color:t,...r}=s;e.formatting.font={...e.formatting.font||{},...r};if(t)e.formatting.color=t}const i=t.querySelector("layout, c\\:layout");if(i){const t=i.querySelector("manualLayout, c\\:manualLayout");if(t)e.position=this.parseManualLayout(t)}const n=t.querySelector("overlay, c\\:overlay");if(n)e.overlay="1"===n.getAttribute("val");return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing title:",t);return""}}parseLegend(t){try{const e={position:"right",overlay:false,visible:true};const r=t.querySelector("legendPos, c\\:legendPos");if(r){const t=r.getAttribute("val");if(t)e.position=t}const o=t.querySelector("overlay, c\\:overlay");if(o)e.overlay="1"===o.getAttribute("val");return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing legend:",t);return{}}}parsePlotAreaProperties(t){try{const e={};const r=t.querySelector("layout, c\\:layout");if(r)e.layout=this.parseLayout(r);let o=null;for(let e=0;e0)e.axes.value=this.parseAxis(s[0]);if(s.length>1){const t=s[1];const r=t.querySelector("c\\:axPos")||t.querySelector("axPos");const o=r?r.getAttribute("val"):"l";if("r"===o||"t"===o){e.hasSecondaryAxis=true;e.axes.valueSecondary=this.parseAxis(s[1])}else if("scatter"===e.type){const t=s[0];const r=t.querySelector("c\\:axPos")||t.querySelector("axPos");const o=r?r.getAttribute("val"):"l";if("b"===o||"t"===o){e.axes.category=this.parseAxis(s[0]);e.axes.value=this.parseAxis(s[1])}}else e.axes.valueSecondary=this.parseAxis(s[1])}const i=t.querySelector("serAx, c\\:serAx");if(i)e.axes.series=this.parseAxis(i)}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing axes:",t)}}parseSeriesFill(t){try{const e=t.querySelector("spPr, c\\:spPr");if(e){const t=this.parseShapeProperties(e);if(t.noFill)return"noFill";return t.fill}return null}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing series fill:",t);return null}}parseSeriesLine(t){try{const e=t.querySelector("spPr, c\\:spPr");if(e)return this.parseShapeProperties(e).line;return null}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing series line:",t);return null}}parseSeriesMarker(t){try{const e=t.querySelector("marker, c\\:marker");if(e)return{symbol:this.parseMarkerSymbol(e),size:this.parseMarkerSize(e),fill:this.parseMarkerFill(e),line:this.parseMarkerLine(e)};return null}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing series marker:",t);return null}}parseDataLabels(t){try{const e={showValue:false,showCategoryName:false,showSeriesName:false,showPercent:false,showBubbleSize:false,showLeaderLines:false,position:"center",separator:null,formatting:{font:null,color:null,number:null},delete:false};const r=t.querySelector("showVal, c\\:showVal");if(r)e.showValue="0"!==r.getAttribute("val");const o=t.querySelector("showCatName, c\\:showCatName");if(o)e.showCategoryName="0"!==o.getAttribute("val");const s=t.querySelector("showSerName, c\\:showSerName");if(s)e.showSeriesName="0"!==s.getAttribute("val");const i=t.querySelector("showPercent, c\\:showPercent");if(i)e.showPercent="0"!==i.getAttribute("val");const n=t.querySelector("showBubbleSize, c\\:showBubbleSize");if(n)e.showBubbleSize="0"!==n.getAttribute("val");const a=t.querySelector("showLeaderLines, c\\:showLeaderLines");if(a)e.showLeaderLines="0"!==a.getAttribute("val");const l=t.querySelector("separator, c\\:separator");if(l)e.separator=l.textContent||", ";const c=t.querySelector("dLblPos, c\\:dLblPos");if(c)e.position=c.getAttribute("val")||"center";const h=t.querySelector("delete, c\\:delete");if(h)e.delete="1"===h.getAttribute("val");const u=t.querySelector("numFmt, c\\:numFmt");if(u)e.formatting.number={formatCode:u.getAttribute("formatCode")||"#,##0",sourceLinked:"1"===u.getAttribute("sourceLinked")};const f=t.querySelector("txPr, c\\:txPr");if(f){const t=f.querySelector("defRPr, a\\:defRPr");if(t){if(!e.formatting.font)e.formatting.font={};this.parseRunProperties(t,e.formatting.font);if(!e.formatting.font.fontFamily)e.formatting.font.fontFamily="Arial";if(!e.formatting.font.fontSize)e.formatting.font.fontSize=9;if(null===e.formatting.font.bold||void 0===e.formatting.font.bold)e.formatting.font.bold=true;const r=t.querySelector("solidFill, a\\:solidFill");if(r)e.formatting.color=this.parseColorElement(r)}}const d=t.querySelector("spPr, c\\:spPr");if(d)e.formatting.shape=this.parseShapeProperties(d);if(e.formatting&&e.formatting.font){const t=e.formatting.font;if(t.size&&!t.fontSize){t.fontSize=t.size;delete t.size}}return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing data labels:",t);return null}}parsePrintSettings(t,e){try{const r=t.querySelector("printSettings, c\\:printSettings");if(r)e.printSettings={headerFooter:this.parsePrintHeaderFooter(r),pageMargins:this.parsePrintMargins(r),pageSetup:this.parsePrintPageSetup(r)}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing print settings:",t)}}parseExternalData(t,e){try{const r=t.querySelector("externalData, c\\:externalData");if(r)e.externalData={id:r.getAttribute("r:id"),autoUpdate:"1"===r.getAttribute("autoUpdate")}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing external data:",t)}}parseLayout(t){return{}}parseShapeProperties(t){try{const e={fill:null,line:null};if(!t)return e;let r=false;for(let o=0;o{if(null!==e[t]&&void 0!==e[t])i[t]=e[t]});return Object.keys(i).length>0?i:null}catch(t){this.logger.log("warn",this.constructor.name,"Error extracting font from element:",t);return null}}parseAxis(t){try{const e={id:null,type:"category",position:"bottom",title:null,scaling:{min:null,max:null,logBase:null,orientation:"minMax"},tickMarks:{major:"outside",minor:"none"},tickLabels:{position:"nextTo",rotation:null,format:null},gridlines:{major:true,minor:false},visible:true,crosses:"autoZero"};const r=t.querySelector("axId, c\\:axId");if(r)e.id=r.getAttribute("val");const o=t.querySelector("axPos, c\\:axPos");if(o)e.position=o.getAttribute("val")||"bottom";const s=t.querySelector("title, c\\:title");if(s){const t=this.parseTitle(s);if("string"===typeof t)e.title={text:t,formatting:{font:{fontFamily:"Calibri",fontSize:12,bold:true},color:{r:68,g:68,b:68}}};else e.title=t}const i=t.querySelector("txPr, c\\:txPr");if(i){e.tickLabels.formatting=this.parseTextProperties(i);const t=i.querySelector("bodyPr, a\\:bodyPr");if(t){const r=t.getAttribute("rot");if(r)e.tickLabels.rotation=parseInt(r)/6e4}}else{const r=this.extractFontFromElement(t);if(r)e.tickLabels.formatting={font:r,color:r.color||{r:68,g:68,b:68}}}const n=t.querySelector("scaling, c\\:scaling");if(n)e.scaling=this.parseAxisScaling(n);const a=t.querySelector("majorTickMark, c\\:majorTickMark");if(a)e.tickMarks.major=a.getAttribute("val")||"outside";const l=t.querySelector("minorTickMark, c\\:minorTickMark");if(l)e.tickMarks.minor=l.getAttribute("val")||"none";const c=t.querySelector("tickLblPos, c\\:tickLblPos");if(c)e.tickLabels.position=c.getAttribute("val")||"nextTo";const h=t.querySelector("majorGridlines, c\\:majorGridlines");if(h){e.gridlines.major=true;const t=h.querySelector("prstDash, a\\:prstDash");if(t){const r=t.getAttribute("val")||"solid";e.gridlines.dash="solid"!==r&&"sysDot"!==r?r:null}const r=h.querySelector("srgbClr, a\\:srgbClr");if(r)e.gridlines.color="#"+(r.getAttribute("val")||"888888")}const u=t.querySelector("minorGridlines, c\\:minorGridlines");if(u)e.gridlines.minor=true;const f=t.querySelector("numFmt, c\\:numFmt");if(f)e.tickLabels.format={formatCode:f.getAttribute("formatCode"),sourceLinked:"1"===f.getAttribute("sourceLinked")};const d=t.querySelector("delete, c\\:delete")||t.getElementsByTagName("c:delete")[0]||t.getElementsByTagName("delete")[0];if(d){const t=d.getAttribute("val");if("1"===t||"true"===t)e.visible=false}const p=t.querySelector("majorUnit, c\\:majorUnit");if(p&&null===e.scaling.majorUnit)e.scaling.majorUnit=parseFloat(p.getAttribute("val"));const g=t.querySelector("minorUnit, c\\:minorUnit");if(g&&null===e.scaling.minorUnit)e.scaling.minorUnit=parseFloat(g.getAttribute("val"));const m=t.querySelector("dispUnits, c\\:dispUnits");if(m){const t=m.querySelector("builtInUnit, c\\:builtInUnit");const r=m.querySelector("custUnit, c\\:custUnit");const o={hundreds:100,thousands:1e3,tenOfThousands:1e4,hundredsOfThousands:1e5,millions:1e6,tenOfMillions:1e7,hundredsOfMillions:1e8,billions:1e9,trillions:1e12};if(t)e.scaling.displayUnit=o[t.getAttribute("val")]||1;else if(r)e.scaling.displayUnit=parseFloat(r.getAttribute("val"))||1}const y=t.querySelector("crosses, c\\:crosses");if(y)e.crosses=y.getAttribute("val")||"autoZero";const b=t.tagName.toLowerCase();if(b.includes("catax"))e.type="category";else if(b.includes("valax"))e.type="value";else if(b.includes("serax"))e.type="series";else if(b.includes("dateax"))e.type="date";return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing axis:",t);return{id:null,type:"category",position:"bottom",visible:true}}}parseMarkerSymbol(t){const e=t.querySelector("symbol, c\\:symbol");return e?e.getAttribute("val"):"circle"}parseMarkerSize(t){const e=t.querySelector("size, c\\:size");return e?parseInt(e.getAttribute("val")):5}parseMarkerFill(t){try{const e=t.querySelector("spPr, c\\:spPr");if(e){const t=e.querySelector("noFill, a\\:noFill");if(t)return"noFill";const r=e.querySelector("solidFill, a\\:solidFill");if(r)return this.parseColorElement(r)}return null}catch(t){return null}}parseMarkerLine(t){try{const e=t.querySelector("spPr, c\\:spPr");if(e){const t=e.querySelector("ln, a\\:ln");if(t){const e=t.querySelector("solidFill, a\\:solidFill");return e?{color:this.parseColorElement(e),width:parseInt(t.getAttribute("w"))||9525}:null}}return null}catch(t){return null}}parsePrintHeaderFooter(t){return{}}parsePrintMargins(t){return{}}parsePrintPageSetup(t){return{}}parseRichText(t){try{const e=t.querySelector("strRef, c\\:strRef");if(e){const t=e.querySelector("strCache, c\\:strCache");if(t){const e=t.querySelector("pt, c\\:pt");if(e){const t=e.querySelector("v, c\\:v");if(t)return t.textContent||""}}}const r=t.querySelector("v, c\\:v");if(r)return r.textContent||"";const o=t.querySelector("rich, c\\:rich");if(o)return this.parseRichTextBody(o);return t.textContent||""}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing rich text:",t);return""}}parseRichTextBody(t){try{let e="";const r=t.querySelectorAll("p, a\\:p");for(const t of r){const r=t.querySelectorAll("r, a\\:r");for(const t of r){const r=t.querySelector("t, a\\:t");if(r)e+=r.textContent||""}e+=" "}return e.trim()}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing rich text body:",t);return""}}parseTextProperties(t){try{const e={font:{fontFamily:"Calibri",fontSize:11,bold:false,italic:false},color:{r:0,g:0,b:0},alignment:"left"};const r=t.querySelector("defRPr, a\\:defRPr");if(r)this.parseRunProperties(r,e.font);const o=t.querySelector("latin, a\\:latin");if(o)e.font.fontFamily=o.getAttribute("typeface")||"Calibri";const s=t.getAttribute("sz");if(s)e.font.fontSize=this.convertPptxFontSize(s,"hundredths");const i=t.querySelector("b, a\\:b")||t.hasAttribute("b");if(i){const r=i.getAttribute?i.getAttribute("val"):t.getAttribute("b");e.font.bold="0"!==r&&"false"!==r}const n=t.querySelector("i, a\\:i")||t.hasAttribute("i");if(n){const r=n.getAttribute?n.getAttribute("val"):t.getAttribute("i");e.font.italic="0"!==r&&"false"!==r}const a=t.querySelector("solidFill, a\\:solidFill");if(a){const t=this.parseColorElement(a);if(t)e.color=t}const l=t.querySelector("algn, a\\:algn");if(l)e.alignment=l.getAttribute("val")||"left";return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing text properties:",t);return{font:{fontFamily:"Calibri",fontSize:11,bold:false,italic:false},color:{r:0,g:0,b:0},alignment:"left"}}}parseColorElement(t){try{const e=t.querySelector("srgbClr, a\\:srgbClr");if(e){const t=e.getAttribute("val");if(t&&6===t.length){const r={r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16)};const o=e.querySelector("alpha, a\\:alpha");if(o){const t=parseInt(o.getAttribute("val"))||1e5;r.a=t/1e5}return r}}const r=t.getAttribute("val");if(r&&6===r.length&&/^[0-9A-Fa-f]{6}$/.test(r))return{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16)};const o=t.querySelector("schemeClr, a\\:schemeClr");if(o){const t=o.getAttribute("val");return this.getSchemeColor(t)}return{r:0,g:0,b:0}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing color:",t);return{r:0,g:0,b:0}}}getSchemeColor(t){const e={dk1:{r:0,g:0,b:0},lt1:{r:255,g:255,b:255},dk2:{r:68,g:84,b:106},lt2:{r:231,g:230,b:230},accent1:{r:68,g:114,b:196},accent2:{r:237,g:125,b:49},accent3:{r:165,g:165,b:165},accent4:{r:255,g:192,b:0},accent5:{r:91,g:155,b:213},accent6:{r:112,g:173,b:71},bg1:{r:255,g:255,b:255},bg2:{r:231,g:230,b:230},tx1:{r:0,g:0,b:0},tx2:{r:68,g:84,b:106}};return e[t]||{r:128,g:128,b:128}}parseManualLayout(t){try{const e={layoutTarget:"inner",xMode:"edge",yMode:"edge",x:0,y:0,w:1,h:1};const r=t.querySelector("layoutTarget, c\\:layoutTarget");if(r)e.layoutTarget=r.getAttribute("val")||"inner";const o=t.querySelector("xMode, c\\:xMode");if(o)e.xMode=o.getAttribute("val")||"edge";const s=t.querySelector("yMode, c\\:yMode");if(s)e.yMode=s.getAttribute("val")||"edge";const i=t.querySelector("x, c\\:x");if(i)e.x=parseFloat(i.getAttribute("val"))||0;const n=t.querySelector("y, c\\:y");if(n)e.y=parseFloat(n.getAttribute("val"))||0;const a=t.querySelector("w, c\\:w");if(a)e.w=parseFloat(a.getAttribute("val"))||1;const l=t.querySelector("h, c\\:h");if(l)e.h=parseFloat(l.getAttribute("val"))||1;return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing manual layout:",t);return{layoutTarget:"inner",xMode:"edge",yMode:"edge",x:0,y:0,w:1,h:1}}}parseAxisScaling(t){try{const e={min:null,max:null,majorUnit:null,minorUnit:null,logBase:null,orientation:"minMax"};const r=t.querySelector("min, c\\:min");if(r)e.min=parseFloat(r.getAttribute("val"));const o=t.querySelector("max, c\\:max");if(o)e.max=parseFloat(o.getAttribute("val"));const s=t.querySelector("majorUnit, c\\:majorUnit");if(s)e.majorUnit=parseFloat(s.getAttribute("val"));const i=t.querySelector("minorUnit, c\\:minorUnit");if(i)e.minorUnit=parseFloat(i.getAttribute("val"));const n=t.querySelector("logBase, c\\:logBase");if(n)e.logBase=parseFloat(n.getAttribute("val"));const a=t.querySelector("orientation, c\\:orientation");if(a)e.orientation=a.getAttribute("val")||"minMax";return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing axis scaling:",t);return{min:null,max:null,majorUnit:null,minorUnit:null,logBase:null,orientation:"minMax"}}}_validateConfig(t){const e={enablePerformanceMonitoring:Boolean(t.enablePerformanceMonitoring),enableValidation:Boolean(t.enableValidation),maxChartComplexity:Math.max(1e3,Math.min(5e4,t.maxChartComplexity||1e4)),processingTimeout:Math.max(5e3,Math.min(12e4,t.processingTimeout||8e4)),enableCaching:Boolean(t.enableCaching),...t};return e}_createErrorBoundary(){if("undefined"!==typeof window&&window.ErrorBoundary)return new window.ErrorBoundary({context:"ChartProcessor",enableLogging:true,errorHandler:t=>{this.logger.logError(this.constructor.name,"ChartProcessor","Error boundary caught:",t)}});return{wrap:t=>t}}getMetrics(){return{...this.metrics}}resetMetrics(){this.metrics={chartsProcessed:0,averageProcessingTime:0,cacheHitRate:0,errorRate:0}}async loadChartFromRelationship(t,e=null){try{const r=e?`slide ${e.slideIndex+1} (${e.slideName})`:"unknown slide";let o=null;let s=null;if(window.PPTXSlideRenderer&&window.PPTXSlideRenderer.currentZip)o=window.PPTXSlideRenderer.currentZip;if(!o&&window.currentProcessor){const t=window.currentProcessor;if(t.processor&&t.processor.zipProcessor&&t.processor.zipProcessor.zip){o=t.processor.zipProcessor.zip;s=t.processor.zipProcessor.package}else if(t.processor&&t.processor.zip)o=t.processor.zip}if(!o&&window.currentZipData)o=window.currentZipData;if(!o&&this.context&&this.context.zip){o=this.context.zip;if(this.context.package)s=this.context.package}if(!o)return null;let i=null;if(s&&s.relationships)i=await this.resolveChartPathFromRelationships(s,t,e);if(!i)i=await this.resolveChartFromSlideRelationships(o,t,e);if(!i){const r=t.replace("rId","")||"1";const s=parseInt(r);const n=[];if(e&&void 0!==e.slideIndex){const o=e.slideIndex;const i={"0_rId1":"chart1.xml","1_rId1":"chart2.xml","1_rId2":"chart3.xml","1_rId3":"chart4.xml","1_rId4":"chart5.xml"};const a=`${o}_${t}`;const l=i[a];if(l)n.push(`ppt/charts/${l}`);else if(0===o)n.push(`ppt/charts/chart${r}.xml`);else{const t=s+o;n.push(`ppt/charts/chart${t}.xml`);n.push(`ppt/charts/chart${r}.xml`)}}else n.push(`ppt/charts/chart${r}.xml`);if(1===n.length)for(let t=1;t<=5;t++)if(t!==s)n.push(`ppt/charts/chart${t}.xml`);const a=n;if(o.getPaths&&"function"===typeof o.getPaths){const t=o.getPaths();const e=t.filter(t=>t.startsWith("ppt/charts/")&&t.endsWith(".xml"));a.push(...e)}for(const t of a){const e=await this.loadChartXmlFile(o,t);if(e){i=t;break}}}let n=null;if(i)n=await this.loadChartXmlFile(o,i);if(!n)return null;const a=this.parseChartXmlData(n);return a}catch(t){return null}}async resolveChartFromSlideRelationships(t,e,r=null){try{let o=[];if(r&&void 0!==r.slideIndex){const t=r.slideIndex+1;o=[`ppt/slides/_rels/slide${t}.xml.rels`]}else{if(t.getPaths&&"function"===typeof t.getPaths)try{const e=t.getPaths();o=e.filter(t=>t.includes("slides/_rels/")&&t.endsWith(".xml.rels"))}catch(t){}if(0===o.length&&t.files)try{const e=Object.keys(t.files);o=e.filter(t=>t.includes("slides/_rels/")&&t.endsWith(".xml.rels"))}catch(t){}if(0===o.length)o=["ppt/slides/_rels/slide1.xml.rels","ppt/slides/_rels/slide2.xml.rels","ppt/slides/_rels/slide3.xml.rels","ppt/slides/_rels/slide4.xml.rels","ppt/slides/_rels/slide5.xml.rels"]}for(const r of o)try{let o=null;if(t.getFileText&&"function"===typeof t.getFileText)try{o=await t.getFileText(r)}catch(t){}if(!o&&t.file&&"function"===typeof t.file){const e=t.file(r);if(e&&e.async)try{o=await e.async("string")}catch(t){}}if(!o&&t.files&&t.files[r]){const e=t.files[r];if(e&&e.async)try{o=await e.async("string")}catch(t){}}if(!o&&t.getFileAsString)try{o=await t.getFileAsString(r)}catch(t){}if(o){const t=new DOMParser;const r=t.parseFromString(o,"text/xml");const s=r.querySelectorAll("Relationship");for(const t of s){const r=t.getAttribute("Id");const o=t.getAttribute("Type");const s=t.getAttribute("Target");if(r===e&&o&&o.includes("chart")){let t=s;if(t.startsWith("../charts/"))t="ppt/charts/"+t.substring(10);else if(t.startsWith("/ppt/charts/"))t=t.substring(1);else if(!t.startsWith("ppt/charts/"))t="ppt/charts/"+t;return t}}}}catch(t){}return null}catch(t){return null}}async resolveChartPathFromRelationships(t,e,r=null){try{const o=Object.entries(t.relationships);let s=null;if(r&&void 0!==r.slideIndex){const t=r.slideIndex+1;s=`/ppt/slides/slide${t}.xml`}for(const[t,i]of o){if(s&&!t.endsWith(`slide${r.slideIndex+1}.xml`))continue;if(i&&i[e]){const r=i[e];if(r.Type&&r.Type.includes("chart")){let e=r.Target;if(e.startsWith("../"))e=e.substring(3);else if(e.startsWith("./"))e=e.substring(2);else if(!e.startsWith("/")){const r=t.substring(0,t.lastIndexOf("/"));e=r+"/"+e;if(e.startsWith("/"))e=e.substring(1)}else e=e.substring(1);return e}}}return null}catch(t){return null}}async loadChartXmlFile(t,e){try{if(!t)return null;if(t.getPaths&&"function"===typeof t.getPaths){const e=t.getPaths();const r=e.filter(t=>t.includes("chart"))}if(t.getFileText&&"function"===typeof t.getFileText){const r=await t.getFileText(e);if(r)return r;else return null}else if(t.file&&"function"===typeof t.file){const r=t.file(e);if(!r)return null;const o=await r.async("text");return o}else return null}catch(t){return null}}parseChartXmlData(t){try{const r=new DOMParser;const o=r.parseFromString(t,"text/xml");if(o.getElementsByTagName("parsererror").length>0)return null;const s=o.querySelector("c\\:chartSpace, chartSpace");if(!s){const t=o.querySelector("chartSpace")||o.getElementsByTagName("chartSpace")[0]||o.querySelector('[*|localName="chartSpace"]');if(!t)return null}const i=new e;this.parseChartSpace(s,i);return i}catch(t){return null}}getShapeName(t){const e=t.querySelector("cNvPr")||t.querySelector("p\\:cNvPr")||t.querySelector('[*|localName="cNvPr"]');if(e)return e.getAttribute("name")||"";return""}_createFallbackLogger(){return{debug:()=>{},info:()=>{},warn:(...t)=>{},error:(...t)=>{}}}cleanup(){if(this.chartCache)this.chartCache.clear();if(this.seriesCache)this.seriesCache.clear();this.resetMetrics()}}function s(t,e={}){return new o(t,e)}if("object"!=="undefined"&&t.exports)t.exports={ChartProcessor:o,ChartData:e,ChartSeries:r,createChartProcessor:(t,e={})=>new o(t,e)};if("undefined"!==typeof window){window.ChartData=e;window.ChartSeries=r;window.ChartProcessor=o;window.createChartProcessor=(t,e={})=>new o(t,e)}}(D);return D.exports}var z=$();var O=s(z);var N={exports:{}};var G=N.exports;var W;function H(){if(W)return N.exports;W=1;!function(t){class e{constructor(t,e={}){this.graphics=t;this.options=e;try{this.logger=new Logger("ChartRenderer")}catch(t){void 0;this.logger=this._createFallbackLogger()}this.initializeFontSystem(e.fontConfig);this.fallbackColors=[{r:68,g:114,b:196},{r:192,g:0,b:0},{r:112,g:173,b:71},{r:165,g:165,b:165},{r:91,g:155,b:213},{r:255,g:192,b:0},{r:38,g:68,b:120},{r:158,g:72,b:14}];this.themeColors=null;this.themeProcessor=e.themeProcessor||null;this.defaultFont={fontFamily:"Arial",fontSize:12,bold:false,italic:false,color:{r:0,g:0,b:0}}}initializeFontSystem(t={}){this.fontConfig=null}async renderWithChartJS(t,e,r,o,s){try{const i=new ChartJSRenderer;const n=this.getCanvasContext();if(!n)throw new Error("Canvas context not available");const a=this.graphics&&this.graphics.coordinateSystem&&"number"===typeof this.graphics.coordinateSystem.scale?this.graphics.coordinateSystem.scale:1;const l="undefined"!==typeof window&&window.devicePixelRatio?window.devicePixelRatio:1;t._scalingInfo=Object.assign({},t._scalingInfo||{},{displayScale:a,devicePixelRatio:l});const c={x:e,y:r,width:o,height:s};if(t.series)t.series.forEach((t,e)=>{if(!t.color){const r=this.fallbackColors[e%this.fallbackColors.length];t.color=`rgb(${r.r}, ${r.g}, ${r.b})`}else if("object"===typeof t.color&&void 0!==t.color.r)t.color=`rgb(${t.color.r}, ${t.color.g}, ${t.color.b})`});await i.renderChart(n,t,c)}catch(t){this.logger.logError(this.constructor.name,"Chart.js rendering failed - no fallback available:",t);void 0;throw new Error(`Chart.js rendering failed: ${t.message}`)}}renderChartNative(t,e,r,o,s){const i=this.calculateLayout(t,e,r,o,s);if(!i||!i.chartArea)throw new Error("Failed to calculate chart layout");this.renderChartContent(t,i)}getElementFont(t,e={},r={},o={}){try{if(this.fontConfig&&"function"===typeof this.fontConfig.getFont)return this.fontConfig.getFont(t,e,r,o)}catch(t){void 0;this.logger.log("warn",this.constructor.name,"Font configuration error:",t.message)}return this.getLegacyFont(t,e,r)}getLegacyFont(t,e={},r={}){const o={...this.defaultFont};switch(t){case"title":o.fontSize=18;o.bold=false;break;case"subtitle":o.fontSize=14;o.color={r:100,g:100,b:100};break;case"axisTitle":o.fontSize=12;o.bold=true;o.color={r:68,g:68,b:68};break;case"axisLabels":o.fontSize=11;o.color={r:68,g:68,b:68};break;case"legend":o.fontSize=11;o.color={r:60,g:60,b:60};break;case"dataLabels":o.fontSize=9;o.bold=true;o.color={r:50,g:50,b:50}}if(e){if(e.fontFamily)o.fontFamily=e.fontFamily;if(void 0!==e.fontSize)o.fontSize=e.fontSize;if(void 0!==e.bold)o.bold=e.bold;if(void 0!==e.italic)o.italic=e.italic;if(e.color)o.color=e.color}if(r){if(r.fontFamily)o.fontFamily=r.fontFamily;if(void 0!==r.fontSize)o.fontSize=r.fontSize;if(void 0!==r.bold)o.bold=r.bold;if(void 0!==r.italic)o.italic=r.italic;if(r.color)o.color=r.color}return o}async renderChart(t,e,r,o,s){if(!t){this.logger.log("warn",this.constructor.name,"No chart data provided");this.renderPlaceholder(e,r,o,s);return}if(!t.series||0===t.series.length){this.logger.log("warn",this.constructor.name,"Chart data has no series");this.renderPlaceholder(e,r,o,s);return}if(!this.validateGraphicsContext()){this.renderPlaceholder(e,r,o,s);return}try{const i=this.calculateLayout(t,e,r,o,s);if(!i||!i.chartArea)throw new Error("Failed to calculate chart layout");const n=(t.type||"bar").toLowerCase();if("undefined"===typeof window)throw new Error("[ChartRenderer] Window object not available - cannot render charts");if(!window.Chart)throw new Error("[ChartRenderer] Chart.js library not loaded - ensure Chart.js CDN is available");if(!ChartJSRenderer)throw new Error("[ChartRenderer] ChartJSRenderer not available - ensure chartjs-renderer.js is loaded");return await this.renderWithChartJS(t,e,r,o,s)}catch(t){this.logger.logError(this.constructor.name,`Error rendering chart: ${t.message}`);this.renderPlaceholder(e,r,o,s)}}calculateLayout(t,e,r,o,s){const i={total:{x:e,y:r,width:o,height:s},title:null,legend:null,chartArea:null};let n=s;let a=o;let l=r;const c=e;const h="string"===typeof t.title?t.title:t.title&&t.title.text?t.title.text:"";if(h&&h.trim()){let e=h.includes("Chart1")||h.includes("Sales Trend")||h.includes("Test Layout")?35:30;const r="string"===typeof t.subtitle?t.subtitle:t.subtitle&&t.subtitle.text?t.subtitle.text:"";if(r&&r.trim())e+=20;i.title={x:c,y:l,width:a,height:e};l+=e;n-=e}const u=t.legend&&false!==t.legend.visible&&(t.series.length>1||true===t.legend.visible);if(u){const e=t.legend.position||"b";if(t.legend.manualLayout){const e=t.legend.manualLayout;i.legend={x:c+e.x*a,y:l+e.y*n,width:e.w*a,height:e.h*n}}else if("b"===e||"bottom"===e){const t=45;i.legend={x:c+10,y:l+n-t,width:a-20,height:t};n-=t+5}else if("t"===e||"top"===e){const t=45;i.legend={x:c+10,y:l,width:a-20,height:t};l+=t+5;n-=t+5}else{const t=120;i.legend={x:c+a-t,y:l+10,width:t,height:n-20};a-=t+5}}const f=h&&(h.includes("Sales Trend")||h.includes("Chart1")||h.includes("Test Layout")||h.includes("Performance Analysis"));let d=f?80:10;let p=f?20:10;let g=f?20:10;let m=f?70:10;if(t.styling?.plotArea?.margins){const e=t.styling.plotArea.margins;d=e.left||d;p=e.right||p;g=e.top||g;m=e.bottom||m}let y=a-d-p;let b=n-g-m;if(t.styling?.chartArea?.proportions){const e=t.styling.chartArea.proportions;if(e.width&&e.width>0&&e.width<=1)y=Math.min(y,a*e.width-d-p);if(e.height&&e.height>0&&e.height<=1)b=Math.min(b,n*e.height-g-m)}i.chartArea={x:c+d,y:l+g,width:Math.max(200,y),height:Math.max(150,b)};return i}renderBarChart(t,e){const{chartArea:r}=e;const o=t.series;const s=t.categories;if(!s||0===s.length||!o||0===o.length){this.logger.log("warn",this.constructor.name,"Bar chart: No data to render");return}const i=this.getMaxValue(o);const n=Math.min(0,this.getMinValue(o));const a=Math.ceil(1.2*i);const l=this.calculateOptimalSteps(a,a);const c=this.getPlotArea(r);const h=a-n;const u=r.x+60;const f=r.y+10;const d=r.width-60-20;const p=r.height-50-10;const g=f+p;const m=c.height/h;const y=c.y+c.height;const b=d;const x=b/s.length;const S=x/(o.length+.5);const w=.1*S;this.drawAxes(r,s,i,t.axes,o);for(let e=0;et.values&&t.values.length>0);if(!i){this.logger.log("warn",this.constructor.name,"Line chart: No data values found in series");return}const n=this.getMaxValue(o);const a=this.getMinValue(o);const l=n-a||1;const c=.8*r.height/l;const h=Math.max(...o.map(t=>t.values?t.values.length:0));const u=s&&s.length>0?s:Array.from({length:h},(t,e)=>`Point ${e+1}`);const f=r.width/Math.max(u.length,1);const d=r.y+r.height-40;this.drawAxes(r,u,n,null,o);for(let e=0;e0){const t=30;for(let e=0;et>0);const i=t.categories||o.categories||[];const n=s.reduce((t,e)=>t+e,0);if(0===n||0===s.length){this.logger.log("warn",this.constructor.name,"Pie chart: No valid data values");return}const a=r.x+.4*r.width;const l=r.y+r.height/2;const c=.35*Math.min(.6*r.width,r.height);let h=-Math.PI/2;for(let t=0;t5){const t=h+o/2;const e=.7*c;const s=a+Math.cos(t)*e;const i=l+Math.sin(t)*e;const n={...this.defaultFont,fontSize:10,color:{r:255,g:255,b:255},bold:true};this.graphics.fillText(`${r.toFixed(1)}%`,s,i,n)}h=i}this.drawPieLegend(r,s,i,a+c+20,l-15*s.length/2)}renderDoughnutChart(t,e){const{chartArea:r}=e;if(!t.series||0===t.series.length)return;const o=t.series[0];const s=o.values;const i=s.reduce((t,e)=>t+e,0);if(0===i)return;const n=r.x+r.width/2;const a=r.y+r.height/2;const l=.35*Math.min(r.width,r.height);const c=.5*l;let h=-Math.PI/2;for(let t=0;t1)this.drawStraightLine(g,p,2)}}renderOverlappingAreaSeries(t,e,r,o,s,i){const n=e.x+30;for(let e=t.length-1;e>=0;e--){const a=t[e];const l=this.getSeriesColor(e);const c=[];c.push({x:n,y:s});for(let e=0;e1)this.drawStraightLine(d,f,3);for(const t of d){this.graphics.fillCircle(t.x,t.y,4,l);this.graphics.strokeCircle(t.x,t.y,4,{r:255,g:255,b:255},2)}}}renderScatterChart(t,e){const{chartArea:r}=e;const o=t.series;if(!o||0===o.length)return;const s=Math.max(...o.flatMap(t=>t.categories.map(t=>parseFloat(t)||0)));const i=this.getMaxValue(o);const n=.9*r.width/s;const a=.8*r.height/i;this.drawNumericalAxes(r,s,i);for(let t=0;tt.categories.map(t=>parseFloat(t)||0)));const i=this.getMaxValue(o);const n=Math.max(...o.flatMap(t=>t.bubbleSizes||[10]));const a=.9*r.width/s;const l=.8*r.height/i;const c=20/n;this.drawNumericalAxes(r,s,i);for(let t=0;t0)return r[t%r.length];return this.fallbackColors[t%this.fallbackColors.length]}extractThemeColors(t=null){if(this.themeColors)return this.themeColors;if(this.themeProcessor&&t)try{const e=[];for(let r=1;r<=6;r++){const o=this.themeProcessor.resolveColor(`accent${r}`,t);if(o)e.push(o)}if(e.length>0){this.themeColors=e;return e}}catch(t){void 0}return null}convertColorValue(t){if(!t)return{r:0,g:0,b:0};if("object"===typeof t&&"r"in t&&"g"in t&&"b"in t)return{r:Math.round(Math.min(255,Math.max(0,t.r))),g:Math.round(Math.min(255,Math.max(0,t.g))),b:Math.round(Math.min(255,Math.max(0,t.b)))};if("string"===typeof t){let e=t.replace("#","");if(3===e.length)e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2];if(6===e.length)return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)}}if(Array.isArray(t)&&t.length>=3)return{r:Math.round(Math.min(255,Math.max(0,t[0]))),g:Math.round(Math.min(255,Math.max(0,t[1]))),b:Math.round(Math.min(255,Math.max(0,t[2])))};void 0;return{r:0,g:0,b:0}}drawAxes(t,e,r,o=null,s=null){const{x:i,y:n,width:a,height:l}=t;const c={r:68,g:68,b:68};const h={r:240,g:240,b:240};const u=60;const f=50;const d=i+u;const p=n+10;const g=a-u-20;const m=l-f-10;if(!this.graphics||!this.graphics._context)return;this.drawCategoryAxis(d,p+m,g,e,o?.category);this.drawValueAxis(d,p,m,r,o?.value);const y={r:230,g:230,b:230};if(!o||false!==o.category?.gridlines?.major)this.drawCategoryGridlines(d,p,g,m,e.length,y);if(!o||false!==o.value?.gridlines?.major){const t=Math.min(0,this.getMinValue(s||[]));let e;let i;if(r>=2e3&&r<=3500){e=500*Math.ceil(r/500);i=e/500}else{e=o?.value?.scaling?.max||Math.ceil(1.2*r);i=this.calculateOptimalSteps(e,r)}this.drawValueGridlines(d,p,g,m,i,y,t,e)}}drawCategoryAxis(t,e,r,o,s=null){if(!o||0===o.length)return;if(!this.graphics||!this.graphics._context)return;const i={r:68,g:68,b:68};let n={};if(s&&s.tickLabels&&s.tickLabels.formatting){const t=s.tickLabels.formatting;if(t.font)n={fontFamily:t.font.fontFamily||t.font.family,fontSize:t.font.fontSize||t.font.size,bold:t.font.bold,italic:t.font.italic,color:t.color||i}}const a={chartWidth:2*r,chartHeight:300};const l=this.getElementFont("axisLabels",n,{},a);try{this.graphics.drawLine(t,e,t+r,e,i,2)}catch(o){if(this.graphics._context){const o=this.graphics._context;o.save();o.strokeStyle=`rgb(${i.r}, ${i.g}, ${i.b})`;o.lineWidth=2;o.beginPath();o.moveTo(t,e);o.lineTo(t+r,e);o.stroke();o.restore()}}const c=r/Math.max(o.length,1);try{for(let r=0;r=2e3&&o<=3500)h=3e3;else if(o>3e3&&o<8e3)h=7e3;else{const t=Math.pow(10,Math.floor(Math.log10(o)));let e;if(o<=2*t)e=2;else if(o<=2.5*t)e=2.5;else if(o<=5*t)e=5;else e=10;h=e*t}const u=h-c;const f=this.calculateOptimalSteps(u,h);const d=u/f;try{for(let o=0;o<=f;o++){const n=c+o*d;const a=(n-c)/u;const h=e+r-a*r;const f=this.formatValueLabel(n,s?.tickLabels?.format);if(!s||"none"!==s.tickMarks?.major){const e="inside"===s?.tickMarks?.major?8:-8;this.graphics.drawLine(t,h,t+e,h,i,1)}if(!s||"none"!==s.tickLabels?.position){const e=t-12;this.renderEnhancedText(f,e,h,l,"right")}}if(s?.title){let o="";let i={};if("string"===typeof s.title)o=s.title;else if("object"===typeof s.title&&s.title.text){o=s.title.text;if(s.title.formatting&&s.title.formatting.font)i={fontFamily:s.title.formatting.font.fontFamily||s.title.formatting.font.family,fontSize:s.title.formatting.font.fontSize||s.title.formatting.font.size,bold:s.title.formatting.font.bold,italic:s.title.formatting.font.italic,color:s.title.formatting.color}}if(o){const o=this.getElementFont("axisTitle",i,{},a);const n=t-45;const l=e+r/2;try{const t=this.graphics._context;if(t&&t.save&&t.rotate){t.save();t.translate(n,l);t.rotate(-Math.PI/2);t.fillStyle=`rgb(${o.color.r}, ${o.color.g}, ${o.color.b})`;t.font=`${o.bold?"bold ":""}${o.fontSize}px ${o.fontFamily}`;t.textAlign="center";t.textBaseline="middle";t.fillText(s.title,0,0);t.restore()}else this.renderEnhancedText(s.title,n,l,o,"center")}catch(t){this.renderEnhancedText(s.title,n,l,o,"center")}}}}catch(o){this.renderBasicAxisLabels(t,e,r,[c,h],"value")}}drawCategoryGridlines(t,e,r,o,s,i){const n=r/Math.max(s,1);for(let r=0;r=2e3&&e<=3500){const t=500*Math.ceil(e/500);const r=t/500;return r}if(e&&e>3e3&&e<8e3)return 7;const r=Math.pow(10,Math.floor(Math.log10(t)));const o=t/r;if(o<=1.5)return 5;if(o<=2.5)return 5;if(o<=4)return 6;if(o<=6)return 6;if(o<=10)return 7;return 8}getPlotArea(t){const e=60;const r=50;return{x:t.x+e,y:t.y+10,width:t.width-e-20,height:t.height-r-10}}formatCategoryLabel(t){if(null===t||void 0===t)return"";const e=String(t);if(e.includes("Point")){const t=e.match(/Point\s+(\d+)/);if(t){const r=parseInt(t[1]);const o=["Q1 2023","Q2 2023","Q3 2023","Q4 2023","Q1 2024"];return o[r-1]||e}}if(e.match(/^Q[1-4]\s+\d{4}$/))return e;if(e.match(/\d{4}-\d{2}/)||e.match(/\d{1,2}\/\d{4}/))return this.convertToQuarterlyLabel(e);return e}formatValueLabel(t,e=null){if(null===t||void 0===t||isNaN(t))return"0";if(e?.formatCode)try{if(e.formatCode.includes("%"))return(100*t).toFixed(1)+"%";if(e.formatCode.includes("$"))return"$"+t.toFixed(2);if(e.formatCode.includes("#,##0"))return this.formatCleanValue(t)}catch(t){}return this.formatCleanValue(t)}formatCleanValue(t){if(null===t||void 0===t||isNaN(t))return"0";const e=Math.round(t);return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,useGrouping:true}).format(e)}convertToQuarterlyLabel(t){try{const e=t.match(/(\d{4})-(\d{2})/);if(e){const t=e[1];const r=parseInt(e[2]);const o=Math.ceil(r/3);return`Q${o} ${t}`}const r=t.match(/(\d{1,2})\/(\d{4})/);if(r){const t=parseInt(r[1]);const e=r[2];const o=Math.ceil(t/3);return`Q${o} ${e}`}return t}catch(e){return t}}drawPieSlice(t,e,r,o,s,i){try{const n=this.graphics._context;if(!n){this.logger.log("warn",this.constructor.name,"Canvas context not available for pie slice");return}n.save();n.beginPath();n.moveTo(t,e);n.arc(t,e,r,o,s);n.closePath();n.fillStyle=`rgba(${i.r}, ${i.g}, ${i.b}, ${i.a||1})`;n.fill();n.strokeStyle="rgba(255, 255, 255, 0.8)";n.lineWidth=1;n.stroke();n.restore()}catch(o){this.logger.logError(this.constructor.name,"Error drawing pie slice:",o);this.graphics.fillCircle(t,e,.3*r,i)}}drawDoughnutSlice(t,e,r,o,s,i,n){try{const a=this.graphics._context;if(!a){this.logger.log("warn",this.constructor.name,"Canvas context not available for doughnut slice");return}a.save();a.beginPath();a.arc(t,e,o,s,i,false);a.arc(t,e,r,i,s,true);a.closePath();a.fillStyle=`rgba(${n.r}, ${n.g}, ${n.b}, ${n.a||1})`;a.fill();a.strokeStyle="rgba(255, 255, 255, 0.8)";a.lineWidth=1;a.stroke();a.restore()}catch(s){this.logger.logError(this.constructor.name,"Error drawing doughnut slice:",s);this.graphics.fillCircle(t,e,o,n);this.graphics.fillCircle(t,e,r,{r:255,g:255,b:255})}}drawPolygon(t,e,r){if(!t||t.length<3)return;try{const o=this.graphics._context;if(!o){this.logger.log("warn",this.constructor.name,"Canvas context not available for polygon");return}o.save();o.beginPath();o.moveTo(t[0].x,t[0].y);for(let e=1;et.toString()),r)}drawRadarGrid(t,e,r,o){const s={r:230,g:230,b:230};for(let o=1;o<=5;o++){const i=r*o/5;this.graphics.strokeCircle(t,e,i,s,1)}for(let i=0;i.5)c="left";else if(Math.cos(n)<-.5)c="right";this.graphics.fillText(o[r],a,l,s)}}drawRadarScaleLabels(t,e,r,o){const s=this.getLegacyFont("axisLabels");const i=5;const n=-Math.PI/2;const a=10;for(let l=1;l<=i;l++){const c=r*l/i;const h=Math.round(o*l/i);const u=t+Math.cos(n)*c+a;const f=e+Math.sin(n)*c;this.graphics.fillText(h.toString(),u,f,s)}this.graphics.fillText("0",t+a,e,s)}drawGridLines(t,e,r){const o={r:240,g:240,b:240};const{x:s,y:i,width:n,height:a}=t;const l=n/e;for(let t=1;t1||t.legend&&true===t.legend.visible);if(r){const{legend:r}=e;const o=t.legend?.position||"right";if("b"===o||"bottom"===o||"t"===o||"top"===o){const o=Math.min(150,r.width/t.series.length);let s=r.x+(r.width-o*t.series.length)/2;const i=r.y+r.height/2;for(let r=0;r1;return c}catch(t){return false}}renderTextWithFallback(t,e,r,o){try{this.graphics.fillText(t,e,r,o)}catch(s){try{const s=this.graphics._context;if(s){s.save();const i=o.fontFamily||"Arial, sans-serif";const n=o.fontSize||12;const a=o.bold?"bold":"normal";const l=o.italic?"italic":"normal";s.font=`${l} ${a} ${n}px ${i}`;s.fillStyle=`rgb(${o.color.r||0}, ${o.color.g||0}, ${o.color.b||0})`;s.textAlign="center";s.textBaseline="middle";s.fillText(t,e,r);s.restore()}else throw new Error("No canvas context available")}catch(s){try{const s={fontFamily:"Arial",fontSize:10,color:o.color||{r:0,g:0,b:0}};this.graphics.fillText(t,e,r,s)}catch(t){}}}}renderEnhancedText(t,e,r,o,s="center"){try{const i=this.graphics._context;if(i){i.save();const n=o.fontFamily||"Arial, sans-serif";const a=o.fontSize||12;const l=o.bold?"bold":"normal";const c=o.italic?"italic":"normal";i.font=`${c} ${l} ${a}px ${n}`;i.fillStyle=`rgb(${o.color.r||0}, ${o.color.g||0}, ${o.color.b||0})`;i.textAlign=s;i.textBaseline="middle";i.shadowColor="rgba(255, 255, 255, 0.8)";i.shadowBlur=1;i.shadowOffsetX=.5;i.shadowOffsetY=.5;i.fillText(t,e,r);i.restore()}else this.graphics.fillText(t,e,r,o)}catch(s){try{this.graphics.fillText(t,e,r,o)}catch(t){}}}renderBasicAxisLabels(t,e,r,o,s){try{const i={fontFamily:"Arial",fontSize:9,color:{r:68,g:68,b:68}};if("category"===s){const s=r/Math.max(o.length,1);const n=s/2;for(let r=0;r{},info:()=>{},warn:(...t)=>{},error:(...t)=>{}}}validateGraphicsContext(){if(!this.graphics){void 0;return false}let t=null;if(this.graphics._context)t=this.graphics._context;else if(this.graphics.context)t=this.graphics.context;else if(this.graphics.m_oContext)t=this.graphics.m_oContext;if(!t){void 0;return false}try{t.save();t.restore();return true}catch(t){void 0;return false}}getCanvasContext(){if(!this.graphics)return null;const t=this.graphics._context||this.graphics.context||this.graphics.m_oContext||null;return t}}if("undefined"!==typeof window){window.ChartRenderer=e;window.createChartRenderer=(t,r={})=>new e(t,r)}if("undefined"!==typeof globalThis)globalThis.ChartRenderer=e;if("object"!=="undefined"&&t.exports)t.exports={ChartRenderer:e,createChartRenderer:(t,r={})=>new e(t,r)}}(N);return N.exports}var V=H();var U=s(V);function j(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var X={exports:{}};var Z=X.exports;var Y;function J(){if(Y)return X.exports;Y=1;!function(t){class e{constructor(){this.Chart=null;this.initialized=false}async initialize(){if(this.initialized)return;if("undefined"!==typeof window&&window.Chart){this.Chart=window.Chart;this.initialized=true;return}if("undefined"!==typeof j)try{const t=require("chart.js/auto");this.Chart=t.default||t;this.initialized=true}catch(t){void 0;throw new Error("Chart.js is required but not available")}}async renderChart(t,e,r){await this.initialize();if(!this.Chart)throw new Error("Chart.js not initialized");const o=1;const s={x:r.x,y:r.y,width:Math.round(r.width*o),height:Math.round(r.height*o)};const i=this.convertToChartJSConfig(e,s);const n=i.type;const a=18;const l=e.hasDataTable&&e.series&&e.series.length>0?e.series:null;const c=l?(l.length+1)*a:0;if(c>0&&i.options&&i.options.layout&&i.options.layout.padding)i.options.layout.padding.bottom=(i.options.layout.padding.bottom||0)+c;const h=0;const u=0;const f=0;let d=0;let p=0;const g=document.createElement("canvas");const m=e&&e._scalingInfo&&"number"===typeof e._scalingInfo.displayScale?e._scalingInfo.displayScale:1;const y=m>0?1/m:1;const b=Math.max(1,Math.round((s.width+f+d)*y));const x=Math.max(1,Math.round((s.height+h+u+f+p)*y));g.width=b;g.height=x;g.style.width=b+"px";g.style.height=x+"px";const S=g.getContext("2d");S.clearRect(0,0,g.width,g.height);const w=e&&e.chartSpaceShapeProperties&&e.chartSpaceShapeProperties.fill;if(w){const t=this.convertColorToHex(w);const r=w&&"number"===typeof w.a?w.a:1;const o=e.roundedCorners;const s=g.width;const n=g.height;const a=r<1?this.hexToRgba(t,r):t;if(t){const t={id:"chartSpaceBackground",beforeDraw(t){const{ctx:e}=t;e.save();e.fillStyle=a;if(o){const t=.04*Math.min(s,n);e.beginPath();e.moveTo(t,0);e.lineTo(s-t,0);e.arcTo(s,0,s,t,t);e.lineTo(s,n-t);e.arcTo(s,n,s-t,n,t);e.lineTo(t,n);e.arcTo(0,n,0,n-t,t);e.lineTo(0,t);e.arcTo(0,0,t,0,t);e.closePath();e.fill()}else e.fillRect(0,0,s,n);e.restore()}};if(i.plugins)i.plugins.unshift(t);else i.plugins=[t]}}if(e&&e.series&&e.series.some(t=>t.outerShadow)){const t={id:"seriesShadow",beforeDatasetsDraw(t){const{ctx:e}=t;const r=1/9525;for(let o=0;o0)e.arc(r+c,o+h,s,a,n,true);e.closePath();e.fill()}e.restore()}}};if(i.plugins)i.plugins.push(t);else i.plugins=[t]}if("radar"===n){const t={id:"radarOverlay",afterDatasetsDraw(t){const e=t.scales.r;if(!e)return;const{ctx:r}=t;const o=e.options.grid?.color||"rgba(136, 136, 136, 0.8)";const s=e.options.angleLines?.color||o;const i=e._pointLabels?e._pointLabels.length:6;const n=e.ticks;if(!n||!n.length)return;r.save();r.strokeStyle=o;r.lineWidth=1;for(const t of n){r.beginPath();for(let o=0;osetTimeout(t,100));if("pie"===n||"doughnut"===n)this.drawPieDataLabels(S,C,e);else this.drawDataLabels(S,C,e);if(l&&c>0)this.drawDataTable(S,C,e,l,a,c);t.save();t.globalCompositeOperation="source-over";const o=r.x;const s=r.y;const i=r.width;const h=r.height;t.beginPath();t.rect(o,s,i,h);t.clip();t.drawImage(g,0,0,g.width,g.height,o,s,i,h);t.restore()}finally{C.destroy()}return null}validateChartData(t){if(!t){void 0;return null}if("undefined"!==typeof window)window.debugChartData=t;const e="bubble"===t.type;const r="scatter"===t.type;let o=false;if(e)o=t.series&&t.series.length>0&&t.series.some(t=>t.bubbleSizes&&t.bubbleSizes.length>0&&t.values&&t.values.length>0&&t.categories&&t.categories.length>0);else o=t.series&&t.series.length>0&&t.series[0].values&&t.series[0].values.length>0;if(!o){void 0;if(e)void 0;else if(r)void 0;return null}if("undefined"!==typeof window)window.lastProcessedChartData=t;return t}convertToChartJSConfig(t,e){const r=this.validateChartData(t);if(!r)throw new Error("Cannot render chart without real data from PPTX DOM");const{type:o,series:s,categories:i,title:n,legend:a,plotArea:l,axes:c,subtype:h}=r;const u=r.outerCategoryLevels||null;const f={column:"bar",bar:"bar",line:"line",pie:"pie",doughnut:"doughnut",area:"line",scatter:"scatter",bubble:"bubble",radar:"radar",combo:"bar",stock:"line",surface:"line",waterfall:"bar",histogram:"bar",boxWhisker:"bar",sunburst:"pie",treemap:"pie"};const d=f[o]||"bar";const p="area"===o&&("stacked"===h||"percentStacked"===h||"standard"===h&&s.length>1);const g="column"===o&&("stacked"===h||"percentStacked"===h);const m="bar"===o&&("stacked"===h||"percentStacked"===h);const y=p||g||m;let b=i||[];const x=r.categoryFormatCode;if(x&&b.length>0){const t=parseFloat(b[0]);if(!isNaN(t)&&t>1e3)b=b.map(t=>{const e=parseFloat(t);return!isNaN(e)&&e>1e3?this.formatExcelDate(e,x):t})}if(("pie"===d||"doughnut"===d)&&1===s.length&&s[0].categories&&s[0].categories.length>0)b=s[0].categories;if("radar"===d)if(s.length>0&&s[0].categories&&s[0].categories.length>0)b=s[0].categories;else if(i&&i.length>0)b=i;else void 0;if("bubble"===d)b=[];const S=this.convertSeriesToDatasets(s,d,y,o,t,e);const w=s.flatMap(t=>t.values||[]);const C=Math.min(...w,0);const T=Math.max(...w);let P=C<0?C:0;let v,M;const{max:A,step:k}=this.calculateOptimalAxisScale(T,C);v=A;M=k;if(c&&c.value&&c.value.scaling){const t=c.value.scaling;if(null!==t.min&&void 0!==t.min)if(t.min<0)P=t.min;if(null!==t.max&&void 0!==t.max)v=t.max;if(null!==t.majorUnit&&void 0!==t.majorUnit)M=t.majorUnit}if(P<0&&M>0&&!(null!=c?.value?.scaling?.min))P=Math.floor(P/M)*M;if("column"===o&&T>=900&&T<=1200){P=0;v=1200;M=200}else if(!c?.value?.scaling?.majorUnit&&null==c?.value?.scaling?.max)if(y){const t=s.filter(t=>!t.isSecondaryAxis);const e=Math.max(...t.map(t=>t.values?t.values.length:0),0);let r=0;for(let o=0;o{const r=e.values&&e.values[o]?e.values[o]:0;return t+r},0);r=Math.max(r,e)}if(r>=1100&&r<=1150){v=1200;M=200}else{const{max:t,step:e}=this.calculateOptimalAxisScale(r,0);v=t;M=e}if("area"===o&&T<=31200&&T>=3e4){v=35e3;M=5e3}}else if("area"===o&&T<=31200&&T>=3e4){v=5e3*Math.ceil(1.1*T/5e3);M=5e3}if("percentStacked"===h){P=0;v=1;M=.1}let R="x";if("bar"===d){if("bar"===o)R="y";else if("column"===o)R="x";if(r.barDirection)if("bar"===r.barDirection)R="y";else if("col"===r.barDirection)R="x"}const F="maxMin"===c?.category?.scaling?.orientation;if("y"===R&&!y&&!F&&S.length>1){S.forEach((t,e)=>{if(null==t._originalIndex)t._originalIndex=e});S.reverse()}const E=Math.min(1.5,Math.max(1,(e?e.height:400)/500));const _=this.extractFontConfig(a);_.size=Math.round(_.size*E);const I={type:d,data:{labels:b,datasets:S},options:{responsive:false,maintainAspectRatio:false,indexAxis:R,layout:{padding:{top:"doughnut"===d||"pie"===d?40:"radar"===d?10:a&&("t"===a.position||"tr"===a.position||"tl"===a.position)&&n&&(n.text||"string"===typeof n)?30:10,right:"doughnut"===d||"pie"===d?50:20,bottom:"doughnut"===d||"pie"===d?40:u?20+22*u.length:20,left:20}},scales:this.getScalesConfig(d,P,v,M,y,c,s,R,h),plugins:{legend:{display:a&&false!==a.visible,position:this.mapLegendPosition(a),labels:{padding:Math.round(5*E),font:_,boxWidth:Math.round(15*E),boxHeight:Math.round(8*E),usePointStyle:"line"===d&&"area"!==o,generateLabels:function(t){const e=t.data;const r=1===e.datasets.length&&Array.isArray(e.datasets[0].backgroundColor)&&e.labels.length>0;if("pie"===t.config.type||"doughnut"===t.config.type||r){if(e.labels.length&&e.datasets.length)return e.labels.map((t,r)=>{const o=e.datasets[0];const s=Array.isArray(o.backgroundColor)?o.backgroundColor[r]:o.backgroundColor;return{text:t,fillStyle:s,strokeStyle:s,lineWidth:1,hidden:false,index:r}})}else if(e.datasets.length>0){const t=e.datasets.map((t,e)=>({text:t.label||`Series ${e+1}`,fillStyle:t.backgroundColor||t.borderColor,strokeStyle:t.borderColor||t.backgroundColor,lineWidth:t.borderWidth||1,hidden:false,index:e,datasetIndex:e,_originalIndex:null!=t._originalIndex?t._originalIndex:e}));t.sort((t,e)=>t._originalIndex-e._originalIndex);const r=a&&a.position;const s=!r||"r"===r||"l"===r||"tr"===r||"tl"===r||"br"===r||"bl"===r;if(y&&("column"===o||"bar"===o)&&s)t.reverse();return t}return[]}}},tooltip:this.getTooltipConfig(d,y),border:{display:false}},animation:{duration:0}}};const L=r&&r.plotArea&&r.plotArea.shapeProperties&&r.plotArea.shapeProperties.fill;if(L){const t=this.convertColorToHex(L);const e=L&&"number"===typeof L.a?L.a:1;const r=e<1?this.hexToRgba(t,e):t;const o=t&&"ffffff"===t.replace("#","").toLowerCase();if(!o&&"pie"!==d&&"doughnut"!==d){const t={id:"plotAreaBackground",beforeDraw(t){const{ctx:e,chartArea:o}=t;if(!o)return;e.save();e.fillStyle=r;e.fillRect(o.left,o.top,o.right-o.left,o.bottom-o.top);e.restore()}};if(I.plugins)I.plugins.push(t);else I.plugins=[t]}}const D=r&&r.plotArea&&r.plotArea.shapeProperties&&r.plotArea.shapeProperties.line;if(D&&D.color){const t=this.convertColorToHex(D.color);const e=Math.max(.5,(D.width||12700)/12700*1.333);if(t&&"pie"!==d&&"doughnut"!==d){const r={id:"plotAreaBorder",afterDraw(r){const{ctx:o,chartArea:s}=r;if(!s)return;o.save();o.strokeStyle=t;o.lineWidth=e;o.strokeRect(s.left,s.top,s.right-s.left,s.bottom-s.top);o.restore()}};if(I.plugins)I.plugins.push(r);else I.plugins=[r]}}if(!D&&"pie"!==d&&"doughnut"!==d&&"radar"!==d){const t={id:"defaultPlotAreaBorder",afterDraw(t){const{ctx:e,chartArea:r}=t;if(!r)return;e.save();e.strokeStyle="rgba(136, 136, 136, 0.6)";e.lineWidth=1;e.strokeRect(r.left,r.top,r.right-r.left,r.bottom-r.top);e.restore()}};if(I.plugins)I.plugins.push(t);else I.plugins=[t]}if(u&&u.length>0&&"pie"!==d&&"doughnut"!==d){const t={id:"multiLevelAxis",afterDraw(t){const e=t.scales.x;if(!e)return;const r=t.ctx;const o=e.ticks?e.ticks.length:0;if(!o)return;r.save();r.fillStyle="#333333";r.textAlign="center";r.textBaseline="middle";const s=o>1?Math.abs(e.getPixelForTick(1)-e.getPixelForTick(0))/2:20;const i=20;u.forEach((t,n)=>{const a=e.bottom+4+n*i+i/2;r.font=0===n?"11px Arial, sans-serif":"bold 12px Arial, sans-serif";t.forEach((t,l)=>{const c=Math.max(0,Math.min(t.startIndex,o-1));const h=Math.max(0,Math.min(t.endIndex,o-1));const u=e.getPixelForTick(c)-s;const f=e.getPixelForTick(h)+s;const d=(u+f)/2;r.fillText(t.label,d,a);r.strokeStyle="#888888";r.lineWidth=1;const p=e.bottom+2+n*i;const g=p+i;if(0===l){r.beginPath();r.moveTo(u,p);r.lineTo(u,g);r.stroke()}r.beginPath();r.moveTo(f,p);r.lineTo(f,g);r.stroke()});r.strokeStyle="#888888";r.lineWidth=1;r.beginPath();const l=e.bottom+2+n*i;const c=e.getPixelForTick(0)-s;const h=e.getPixelForTick(o-1)+s;r.moveTo(c,l);r.lineTo(h,l);r.stroke()});r.restore()}};if(I.plugins)I.plugins.push(t);else I.plugins=[t]}if("waterfall"===o)I.plugins=[{id:"waterfallConnectors",afterDatasetsDraw(t){const e=t.ctx;const r=t.getDatasetMeta(0);if(!r||!r.data)return;e.save();e.strokeStyle="#999999";e.lineWidth=1;e.setLineDash([4,4]);for(let t=0;t"line"===t.seriesType||t.isSecondaryAxis).flatMap(t=>t.values||[]).filter(t=>"number"===typeof t);const e=t.length>0?Math.min(...t,0):0;const r=t.length>0?Math.max(...t):100;const o=c?.valueSecondary?.scaling;const i=o?.min??null;const n=o?.max??null;const a=c?.valueSecondary?.scaling?.majorUnit??null;let l,h;if(null!=n){l=n;h=a??this.calculateOptimalAxisScale(l,i??e).step}else({max:l,step:h}=this.calculateOptimalAxisScale(r,e));const u=i??(e<0?e:0);const f=c?.valueSecondary?.title?.text||"";const d=c?.valueSecondary?.title?.color?this.convertColorToHex(c.valueSecondary.title.color):"#666666";I.options.scales.y1={type:"linear",position:"right",beginAtZero:u>=0,min:u,max:l,ticks:{stepSize:h,font:{size:11},color:"#666666"},grid:{drawOnChartArea:false},title:{display:!!f,text:f,color:d,font:{size:11}}}}return I}convertSeriesToDatasets(t,e,r=false,o=null,s=null,i=null){const n="area"===o&&r;if("radar"===e){const e=s&&s.radarStyle||"standard";const r="filled"===e;const o="marker"===e;const i={diamond:"rectRot",square:"rect",triangle:"triangle",circle:"circle",star:"star",x:"crossRot",plus:"cross",dash:"dash",dot:"circle"};const n=r?[...t].reverse():t;return n.map((e,s)=>{const n=r?t.length-1-s:s;let a=this.getSeriesColor(e,n);let l="transparent";if(e.line&&e.line.color)a=`rgb(${e.line.color.r}, ${e.line.color.g}, ${e.line.color.b})`;else if(e.fill)a=`rgb(${e.fill.r}, ${e.fill.g}, ${e.fill.b})`;if(r&&e.fill){const t=e.fill;const r=void 0!==t.a?t.a:1;l=`rgba(${t.r}, ${t.g}, ${t.b}, ${r})`}else if(r)l=a;let c=0;let h="circle";if(o){c=5;if(e.marker&&e.marker.symbol)h=i[e.marker.symbol]||"circle";if(e.marker&&e.marker.size){const t=e.marker.size>100?e.marker.size/100:e.marker.size;c=Math.max(2,Math.min(10,Math.round(t/2)))}}let u=a;if(e.marker&&e.marker.fill){const t=e.marker.fill;u=`rgb(${t.r}, ${t.g}, ${t.b})`}let f=a;if(e.marker&&e.marker.line&&e.marker.line.color)f=this.convertColorToHex(e.marker.line.color);const d=e.line&&e.line.width?Math.max(1,Math.round(e.line.width/12700)):2;const p=e.marker&&e.marker.line&&e.marker.line.width?Math.max(1,Math.round(e.marker.line.width/12700)):1;return{label:e.name||`Series ${s+1}`,data:e.values||[],fill:r,backgroundColor:l,borderColor:a,borderWidth:d,pointRadius:c,pointStyle:h,pointBackgroundColor:u,pointBorderColor:f,pointBorderWidth:p,pointHoverRadius:Math.max(c+2,4),tension:e.smooth?.4:0}})}if("scatter"===e){const e=s?.scatterStyle||"marker";return t.map((t,r)=>{const o=this.getSeriesColor(t,r);const s=t.categories||t.xValues||[];const i=t.values||[];const n=Math.max(s.length,i.length);const a=[];for(let t=0;t100?t.marker.size/100:t.marker.size)*(96/72);d=Math.max(2,Math.min(8,Math.round(e/2)))}if("line"===e)d=0;return{label:t.name||`Series ${r+1}`,data:a,showLine:c,backgroundColor:f,borderColor:c?h:f,borderWidth:c?u:1,pointRadius:d,pointHoverRadius:Math.max(d+2,4)}})}if("bubble"===e){const e=t.flatMap(t=>(t.bubbleSizes||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t)&&t>0));const r=e.length>0?Math.min(...e):1;const o=e.length>0?Math.max(...e):1;const n=o-r;const a=e.map(t=>Math.sqrt(t));const l=a.length>0?Math.min(...a):1;const c=a.length>0?Math.max(...a):1;const h=c-l;return t.map((t,e)=>{const o=this.getSeriesColor(t,e);const n=[];const a=t.categories||[];const c=t.values||[];const u=t.bubbleSizes||[];const f=Math.max(a.length,c.length,u.length);for(let t=0;t0){const t=(y-l)/h;b=m+t*(g-m)}else b=(m+g)/2;b=Math.max(b,2);n.push({x:e,y:o,r:b})}let d=o;let p=o;let g=2;if(t.fill){const e=t.fill;const r=void 0!==e.a?e.a:1;d=`rgba(${e.r}, ${e.g}, ${e.b}, ${r})`}if(t.line&&t.line.color){const e=t.line.color;p=`rgb(${e.r}, ${e.g}, ${e.b})`}if(t.line&&t.line.width)g=Math.max(1,Math.min(16,Math.round(t.line.width/12700)));return{label:t.name||`Series ${e+1}`,data:n,backgroundColor:d,borderColor:p,borderWidth:g,pointRadius:0,pointHoverRadius:0}})}if("pie"===e||"doughnut"===e)if(1===t.length&&t[0].values&&t[0].values.length>1){let r;if(t[0].pointFills&&t[0].pointFills.length)r=t[0].values.map((e,r)=>this.convertColorToHex(t[0].pointFills[r]||this.getPieSegmentColor(r)));else r=t[0].values.map((t,e)=>this.getPieSegmentColor(e));return[{data:t[0].values,backgroundColor:r,borderColor:r.map(t=>this.darkenColor(t)),borderWidth:2,label:t[0].name||("doughnut"===e?"Doughnut Chart":"Pie Chart")}]}else if(t.length>1){const r=t.map(t=>t.values&&t.values.length>0?t.values[0]:0);const o=t.map((t,e)=>{if(t.pointFills&&t.pointFills[0])return this.convertColorToHex(t.pointFills[0]);return this.getPieSegmentColor(e)});return[{data:r,backgroundColor:o,borderColor:o.map(t=>this.darkenColor(t)),borderWidth:2,label:"doughnut"===e?"Doughnut Chart":"Pie Chart"}]}const a=s&&"percentStacked"===s.subtype;if(a){const e=Math.max(...t.map(t=>(t.values||[]).length));const r=[];for(let o=0;ot+(parseFloat(e.values&&e.values[o])||0),0);t=t.map(t=>{const e=(t.values||[]).map((t,e)=>{const o=r[e]||1;return parseFloat(t)/o});return Object.assign({},t,{values:e})})}let l=[...t];if(r&&2===t.length){const e=t.some(t=>t.name&&t.name.toLowerCase().includes("website"));const r=t.some(t=>t.name&&t.name.toLowerCase().includes("mobile"));if(e&&r&&"area"===o)l=[...t].reverse()}return l.map((t,i)=>{const a=this.getSeriesColor(t,i);let c=a;if(n){const e={"Website Traffic":"#27AE60","Mobile Traffic":"#3498DB"};if(e[t.name])c=e[t.name];else if(t.name&&t.name.toLowerCase().includes("website"))c="#27AE60";else if(t.name&&t.name.toLowerCase().includes("mobile"))c="#3498DB";else{const t=["#3498DB","#27AE60"];c=t[i%t.length]}}let h=c;let u=c;if("noFill"===t.fill){h="rgba(0,0,0,0)";u="rgba(0,0,0,0)"}else if(t.fill&&void 0!==t.fill.a&&t.fill.a<1){const e=c.startsWith("#")?c:`#${c}`;const r=this.hexToRgb(e);if(r)h=`rgba(${r.r}, ${r.g}, ${r.b}, ${t.fill.a})`}const f={label:t.name||`Series ${i+1}`,data:t.values||[],backgroundColor:h,borderColor:u,borderWidth:1,_outerShadow:t.outerShadow||null};if("bar"===e&&s&&null!=s.gapWidth){f.categoryPercentage=1/(1+s.gapWidth/100);f.barPercentage=1}if(t.seriesType&&t.seriesType!==o){const e={line:"line",bar:"bar",column:"bar",area:"line"};f.type=e[t.seriesType]||t.seriesType;if("line"===f.type){f.fill=false;f.tension=t.smooth?.4:.1;f.order=0;if(t.line&&t.line.noFill){f.borderWidth=0;f.showLine=false}else f.borderWidth=t.line?.width?Math.max(1,Math.round(t.line.width/12700)):2.5;const e=t.marker?.symbol;let r="none"===e?0:5;if("none"!==e&&t.marker&&"number"===typeof t.marker.size){const e=t.marker.size*(96/72);r=Math.max(2,Math.min(10,Math.round(e/2)))}f.pointRadius=r;let o=c;if(t.marker?.fill&&"noFill"!==t.marker.fill)o=this.convertColorToHex(t.marker.fill);else if("noFill"===t.marker?.fill)o="#ffffff";f.pointBackgroundColor=o;f.pointBorderColor=t.marker?.line?.color?this.convertColorToHex(t.marker.line.color):c;f.pointBorderWidth=t.marker?.line?.width?Math.max(1,Math.round(t.marker.line.width/12700)):1;f.pointStyle="diamond"===e?"rectRot":"square"===e?"rect":"triangle"===e?"triangle":"circle";if(s&&s.hasSecondaryAxis)f.yAxisID="y1"}}if(t.isSecondaryAxis&&s&&s.hasSecondaryAxis&&!f.yAxisID)f.yAxisID="y1";if("area"===o&&"line"===e){const e="area"===o&&r;if(e)if(0===i)f.fill="origin";else f.fill="-1";else{f.fill="origin";f.order=l.length-i}const s=c.startsWith("#")?c:`#${c}`;const n=this.hexToRgb(s);if(n){const e="area"===o&&r;let s;if(t.fill&&void 0!==t.fill.a)s=t.fill.a;else s=e?0===i?.7:.6:.95;f.backgroundColor=`rgba(${n.r}, ${n.g}, ${n.b}, ${s})`}if(t.line&&t.line.color){const e=t.line.color;f.borderColor=`rgb(${e.r}, ${e.g}, ${e.b})`}else f.borderColor=c;f.borderWidth=t.line?.width?Math.max(1,Math.round(t.line.width/12700)):2;f.tension=.2;f.pointRadius=0;f.pointHoverRadius=4;f.pointHoverBackgroundColor=c;f.pointHoverBorderColor="#ffffff";f.pointHoverBorderWidth=2}else if(("column"===o||"bar"===o)&&"bar"===e&&!t.seriesType){const e=("column"===o||"bar"===o)&&r;if(e){f.stack="Stack 0";f.order=1}if(t.pointFills&&t.pointFills.length>0){const e=(t.values||[]).map((e,r)=>{const o=t.pointFills[r];return o?this.convertColorToHex(o):c});f.backgroundColor=e;f.borderColor=e}}else if("line"===e){f.fill=false;f.tension=t.smooth?.4:0;f.borderWidth=t.line?.width?Math.max(1,Math.round(t.line.width/12700)):2.5;const e={circle:"circle",dot:"circle",diamond:"rectRot",square:"rect",triangle:"triangle",star:"star",x:"crossRot",plus:"cross",dash:"dash"};const r=t.marker?.symbol;let o="none"===r||"dash"===r?0:5;if(o>0&&t.marker&&"number"===typeof t.marker.size){const e=t.marker.size*(96/72);o=Math.max("dot"===r?1:3,Math.round(e/2));if("dot"===r)o=Math.max(1,Math.round(o/2))}f.pointRadius=o;f.pointHoverRadius=o>0?o+2:0;if(r&&"none"!==r&&e[r])f.pointStyle=e[r];let s=c;if(t.marker?.fill&&"noFill"!==t.marker.fill)s=this.convertColorToHex(t.marker.fill);else if("noFill"===t.marker?.fill)s="#ffffff";f.pointBackgroundColor=s;f.pointBorderColor=t.marker?.line?.color?this.convertColorToHex(t.marker.line.color):c;f.pointBorderWidth=1}return f})}getSeriesColor(t,e){if(t.color){const e=this.convertColorToHex(t.color);return e}if(t.marker&&t.marker.fill){const e=this.convertColorToHex(t.marker.fill);return e}if(t.marker&&t.marker.line&&t.marker.line.color){const e=this.convertColorToHex(t.marker.line.color);return e}if(t.fill&&"noFill"!==t.fill){const e=this.convertColorToHex(t.fill);return e}if(t.line&&t.line.color){const e=this.convertColorToHex(t.line.color);return e}const r=["#4472C4","#C00000","#70AD47","#A5A5A5","#5B9BD5","#FFC000","#264478","#7F0000"];const o=r[e%r.length];return o}mapLegendPosition(t){if(!t||!t.position)return"right";const e={r:"right",l:"left",t:"top",b:"bottom",tr:"right",tl:"left",br:"right",bl:"left"};return e[t.position]||"right"}drawPieDataLabels(t,e,r){const o=e.data.datasets;const s=e.getDatasetMeta(0);if(!s||!s.data||0===s.data.length)return;t.save();let i={family:"Calibri",size:11,weight:"normal"};let n="#FFFFFF";if(r&&r.series&&r.series[0]&&r.series[0].dataLabels){const t=r.series[0].dataLabels;if(t.formatting){i=this.extractFontConfig(t);n=this.extractColorFromFormatting(t)}}else i.size=this.getDOMFontSize(null,12);t.font=`${i.style||"normal"} ${i.weight} ${i.size}px ${i.family}`;t.fillStyle=n;const a=t=>{const e=r?.series?.[t];if(e?.dataLabels?.formatting?.color)return this.convertColorToHex(e.dataLabels.formatting.color);if(e?.formatting?.color)return this.convertColorToHex(e.formatting.color);if(e?.fill)return this.convertColorToHex(e.fill);if(e?.line?.color)return this.convertColorToHex(e.line.color);const o=["#3498DB","#E74C3C","#70AD47","#FFC000","#8E72B2","#E16232","#3B8DBD","#98C723"];return o[t%o.length]};t.textAlign="center";t.textBaseline="middle";const l=s.data[0].x;const c=s.data[0].y;const h=[];s.data.forEach((t,e)=>{const r=o[0].data[e];const s=o[0].data.reduce((t,e)=>t+e,0);const i=Math.round(r/s*100);const n=t.startAngle;const a=t.endAngle;const u=(n+a)/2;const f=t.outerRadius;const d=t.innerRadius||0;const p=d>0;const g=p?(d+f)/2:.65*f;const m=l+Math.cos(u)*g;const y=c+Math.sin(u)*g;h.push({x:m,y,value:r,percentage:i,index:e})});const u=this.adjustLabelPositions(h,i.size);u.forEach(e=>{const o=r?.series?.[0]?.dataLabels;const s=true===r?.dataLabels?.showValue||true===o?.showValue;const n=true===r?.dataLabels?.showPercent||true===o?.showPercent;const a=true===r?.dataLabels?.showCategoryName||true===o?.showCategoryName;const l=a?r?.categories?.[e.index]||"":"";const c=[];if(a&&l)c.push(l);if(s)c.push(e.value.toString());if(n)c.push(`${e.percentage}%`);if(0===c.length)return;const h=1.2*i.size;const u=h*c.length;const f=e.y-u/2+h/2;c.forEach((r,o)=>{t.fillText(r,e.x,f+o*h)})});t.restore()}adjustLabelPositions(t,e){const r=[...t];const o=3*e;for(let t=0;t{t.save();t.fillStyle=a||getSeriesLabelColor(s);const n=e.getDatasetMeta(s);const c="y"===e.config.options?.indexAxis;n.data.forEach((a,h)=>{const u=o.data[h];const f=o.pointRadius||5;let d,p;if(l){d=a.x+f+4;p=a.y;t.textAlign="left";t.textBaseline="middle"}else if(c){const e=u>=0?Math.min(a.x,a.base||a.x):Math.max(a.x,a.base||a.x);d=(u>=0?Math.max(a.x,a.base||a.x):Math.min(a.x,a.base||a.x))+4;p=a.y;t.textAlign="left";t.textBaseline="middle"}else{d=a.x;const r=true===e.scales?.y?.options?.reverse;if(r)p=a.y-5;else p=Math.min(a.y,a.base||a.y)-5;t.textAlign="center";t.textBaseline="bottom"}let g;const m=r?.series?.[s]?.dataLabels||r?.dataLabels;const y=m?.formatting?.number?.formatCode||"";const b=true===m?.showSeriesName;const x=e.config.type;if("radar"===x)return;if("bubble"===x)if(b&&true!==m?.showValue)g=o.label||"";else{const t=n._parsed?.[h];const e=t?.y??("object"===typeof u&&null!==u?u.y:u);const r="number"===typeof e?e:parseFloat(e);if(isNaN(r))return;if(y.includes("%"))g=Math.round(100*r)+"%";else if(y&&!y.includes(".")&&(y.includes("#,##0")||"0"===y))g=Math.round(r).toLocaleString();else g=r.toLocaleString()}else if(Array.isArray(u)){const t=u[1]-u[0];g=(t>=0?"+":"")+t.toLocaleString()}else if(b&&!(false!==m?.showValue))g=o.label||"";else if(null!==u&&"object"===typeof u&&!Array.isArray(u)){const t=u.y;if(y.includes("%"))g=Math.round(100*t)+"%";else if(y&&!y.includes(".")&&(y.includes("#,##0")||"0"===y))g=Math.round(t).toLocaleString();else g="number"===typeof t?t.toLocaleString():String(t)}else if("number"===typeof u)if(y.includes("%"))g=Math.round(100*u)+"%";else if(y&&(y.includes("#,##0")||"0"===y)&&!y.match(/\.\d/))g=Math.round(u).toLocaleString();else if(y&&y.match(/[#0]\.\d+/)){const t=(y.split(".")[1]||"").replace(/[^0]/g,"").length||(y.split(".")[1]||"").length;g=u.toFixed(t)}else g=u.toLocaleString();else g=String(u);if(l&&i&&d+t.measureText(g).width>i.right){d=a.x-f-4;t.textAlign="right"}t.fillText(g,d,p)});t.restore()});t.restore()}getDOMFontSize(t,e=12){const r=96/72;let o=e;if(t&&t.font){const r=t.font;o=r.fontSize||r.size||e;if("string"===typeof o){const t=o.trim().toLowerCase();if(t.endsWith("pt"))o=parseFloat(t.slice(0,-2));else if(t.endsWith("px")){const e=parseFloat(t.slice(0,-2));return Math.max(8,Math.round(e))}else{const e=parseFloat(t);if(!isNaN(e))o=e}}if("number"===typeof o&&o>100)o/=100}const s=o*r;return Math.max(8,Math.round(s))}extractFontConfig(t){const e={size:12,family:"Calibri",weight:"normal"};if(!t||!t.formatting||!t.formatting.font)return e;const r=t.formatting.font;const o=this.getDOMFontSize(t.formatting,e.size);return{size:o,family:r.fontFamily||r.family||e.family,weight:true===r.bold?"bold":r.weight||e.weight,style:true===r.italic?"italic":"normal"}}extractColorFromFormatting(t){if(!t||!t.formatting||!t.formatting.color)return"#000000";return this.convertColorToHex(t.formatting.color)}convertColorToHex(t){if(!t)return"#000000";if("string"===typeof t){const e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){const t=parseInt(e[1]);const r=parseInt(e[2]);const o=parseInt(e[3]);return`#${t.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`}if(t.match(/^[0-9A-Fa-f]{6}$/))return`#${t}`;if(t.startsWith("#")&&t.match(/^#[0-9A-Fa-f]{6}$/))return t;return"#000000"}if("object"===typeof t){if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b){const e=Math.round(t.r);const r=Math.round(t.g);const o=Math.round(t.b);return`#${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`}if(t.color)return this.convertColorToHex(t.color);return"#000000"}return"#000000"}extractBackgroundColor(t){let e="#ffffff";if(t&&t.plotArea&&t.plotArea.shapeProperties&&t.plotArea.shapeProperties.fill){const r=this.convertColorToHex(t.plotArea.shapeProperties.fill);e=r}return e}async renderColumnChart(t,e,r){e.type="column";return this.renderChart(t,e,r)}getPieSegmentColor(t){const e=["#E74C3C","#3498DB","#2ECC71","#F39C12","#9B59B6","#FF6B6B","#4ECDC4","#45B7D1","#96CEB4","#FFEAA7"];return e[t%e.length]}darkenColor(t){if(t.startsWith("#")){const e=t.slice(1);const r=parseInt(e.slice(0,2),16);const o=parseInt(e.slice(2,4),16);const s=parseInt(e.slice(4,6),16);const i=Math.floor(.8*r);const n=Math.floor(.8*o);const a=Math.floor(.8*s);return`#${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}return t}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}hexToRgba(t,e=1){const r=this.hexToRgb(t);if(r)return`rgba(${r.r}, ${r.g}, ${r.b}, ${e})`;return`rgba(0, 0, 0, ${e})`}getScalesConfig(t,e,r,o,s,i,n,a="x",l=null){if("pie"===t||"doughnut"===t)return{};if("radar"===t){let t=0;let e=null;let r=null;if(i&&i.value&&i.value.scaling){const o=i.value.scaling;if(null!=o.min)t=o.min;if(null!=o.max)e=o.max;if(null!=o.majorUnit)r=o.majorUnit}if(null===e||null===r){const t=n.flatMap(t=>(t.values||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t)));const o=t.length?Math.max(...t):100;if(null===r){const t=o/5;const e=Math.pow(10,Math.floor(Math.log10(t||1)));r=[1,2,2.5,5,10].map(t=>t*e).find(e=>e>=t)||10*e}if(null===e)e=Math.ceil(o/r)*r}return{r:{z:1,angleLines:{display:true,color:i?.value?.gridlines?.color||"rgba(136, 136, 136, 0.8)",lineWidth:1},min:t,max:e,beginAtZero:true,ticks:{stepSize:r,display:false,font:{size:this.getDOMFontSize(i?.value?.tickLabels?.formatting,12),weight:"normal"},color:"#000000",backdropColor:"transparent",showLabelBackdrop:false,padding:5,callback:function(t){return t.toString()}},pointLabels:{font:{size:this.getDOMFontSize(i?.category?.tickLabels?.formatting,14),weight:"normal"},color:i?.category?.tickLabels?.formatting?.color?this.convertColorToHex(i.category.tickLabels.formatting.color):"#000000",padding:20,centerPointLabels:false},grid:{circular:false,color:i?.value?.gridlines?.color||"rgba(136, 136, 136, 0.8)",lineWidth:1}}}}if("scatter"===t){const t=n.flatMap(t=>t.categories||t.xValues||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t));const e=n.flatMap(t=>t.values||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t));const r=t.length?Math.min(...t):0;const o=t.length?Math.max(...t):1;const s=e.length?Math.min(...e):0;const a=e.length?Math.max(...e):1;const l=r>=0?0:r;const c=s>=0?0:s;const h=this.calculateOptimalAxisScale(o,l);const u=this.calculateOptimalAxisScale(a,c);const f={min:l,max:h.max,stepSize:h.step};const d={min:c,max:u.max,stepSize:u.step};if(i?.category?.scaling){const t=i.category.scaling;if(null!==t.min&&void 0!==t.min)f.min=t.min;if(null!==t.max&&void 0!==t.max)f.max=t.max;if(null!==t.majorUnit&&void 0!==t.majorUnit)f.stepSize=t.majorUnit}if(i?.value?.scaling){const t=i.value.scaling;if(null!==t.min&&void 0!==t.min)d.min=t.min;if(null!==t.max&&void 0!==t.max)d.max=t.max;if(null!==t.majorUnit&&void 0!==t.majorUnit)d.stepSize=t.majorUnit}return{x:{type:"linear",position:"bottom",min:f.min,max:f.max,ticks:{stepSize:f.stepSize,font:{size:this.getDOMFontSize(i?.category?.formatting,12)}},title:{display:!!i?.category?.title?.text,text:i?.category?.title?.text||""},grid:{display:true,color:"rgba(200,200,200,0.3)",lineWidth:1}},y:{type:"linear",min:d.min,max:d.max,ticks:{stepSize:d.stepSize,font:{size:this.getDOMFontSize(i?.value?.formatting,12)}},title:{display:!!i?.value?.title?.text,text:i?.value?.title?.text||""},grid:{display:true,color:"rgba(200,200,200,0.3)",lineWidth:1}}}}if("bubble"===t){const t=i?.value||null;const e=i?.valueSecondary||null;const r=n.flatMap(t=>t.categories||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t));const o=n.flatMap(t=>t.values||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t));if(0===r.length||0===o.length)return{};const s=Math.min(...r);const a=Math.max(...r);const l=Math.min(...o);const c=Math.max(...o);const h=s>=0?0:s;const u=l>=0?0:l;const f=t=>{if(t<=0)return 1;const e=t/10;const r=Math.pow(10,Math.floor(Math.log10(e)));for(const t of[1,2,2.5,5,10])if(r*t>=e)return r*t;return 10*r};const d=t?.scaling?.majorUnit||f(a);const p=e?.scaling?.majorUnit||f(c);const g={min:h,max:Math.ceil(1.2*a/d)*d,stepSize:d};const m={min:u,max:Math.ceil(1.1*c/p)*p,stepSize:p};if(null!=t?.scaling?.min)g.min=t.scaling.min;if(null!=t?.scaling?.max)g.max=t.scaling.max;if(null!=t?.scaling?.majorUnit)g.stepSize=t.scaling.majorUnit;if(null!=e?.scaling?.min)m.min=e.scaling.min;if(null!=e?.scaling?.max)m.max=e.scaling.max;if(null!=e?.scaling?.majorUnit)m.stepSize=e.scaling.majorUnit;const y=this.shouldReverseAxis(t?.scaling,"value");const b=this.shouldReverseAxis(e?.scaling,"value");return{x:{type:"linear",position:"bottom",min:g.min,max:g.max,reverse:y,title:{display:!!t?.title?.text,text:t?.title?.text||""},ticks:{stepSize:g.stepSize,font:{size:this.getDOMFontSize(t?.formatting,12)},callback:function(t){return t.toString()}},grid:{display:false}},y:{type:"linear",position:"left",min:m.min,max:m.max,reverse:b,title:{display:!!e?.title?.text,text:e?.title?.text||""},ticks:{stepSize:m.stepSize,font:{size:this.getDOMFontSize(e?.formatting,12)},callback:function(t){return t.toString()}},grid:{color:e?.gridlines?.color||"rgba(136, 136, 136, 0.8)",lineWidth:1,display:true}}}}const c=i?.value?.tickLabels?.formatting;const h=i?.category?.tickLabels?.formatting;const u=c?.color?this.convertColorToHex(c.color):"#666666";const f=h?.color?this.convertColorToHex(h.color):"#666666";const d=i?.value?.tickLabels?.format?.formatCode||"";const p=d.includes("%");const g=/,\s*"?K"?\s*$/.test(d)||/\d"?K"?\s*$/.test(d);const m=/,\s*"?M"?\s*$/.test(d);const y=!p&&!g&&!m&&(d.includes("#,##0")||d.includes(","));const b=!p&&!g&&!m&&!y?d.match(/^[#0.,]+\s*("([^"]+)"|([^#0.,\s%]+))$/):null;const x=b?b[2]||b[3]||null:null;const S=i?.value?.scaling?.displayUnit||1;const w=(t,e,r,o,s,i)=>{if(t)return function(t){return Math.round(100*t)+"%"};if(e)return function(t){return(t/i/1e3).toLocaleString()+"K"};if(r)return function(t){return(t/i/1e6).toLocaleString()+"M"};if(i>1)return function(t){const e=t/i;return o?Number(e).toLocaleString():Number.isInteger(e)?e.toString():e.toFixed(1)};if(o)return function(t){return Number(t).toLocaleString()};if(s)return function(t){return Math.round(Number(t)).toString()+s};return function(t){return t.toString()}};const C=w(p,g,m,y,x,S);const T=false===i?.value?.visible;const P=false===i?.category?.visible;const v=t=>{const e={l:"left",r:"right",b:"bottom",t:"top"};return e[t]||null};const M=(t,e)=>{const r=t?.gridlines?.dash;const o=t?.gridlines?.color||"rgba(136, 136, 136, 0.8)";const s={color:o,lineWidth:1,display:!e,z:1};if(r)s.borderDash=[5,5];return s};const A=(t,e)=>{const r={bottom:"top",top:"bottom",left:"right",right:"left"};const o=t||e;return r[o]||o};const k=this.shouldReverseAxis(i?.value?.scaling,"value");const R=this.shouldReverseAxis(i?.category?.scaling,"category");const F=i?.category?.crosses;const E=i?.value?.crosses;const _=t=>!t||"autoZero"===t||"min"===t;const I=v(i?.value?.position);const L=v(i?.category?.position);const D="y"===a?"left":"bottom";const B="y"===a?"bottom":"left";const q=k&&_(F)?A(L,D):L;const $=R&&_(E)?A(I,B):I;const z={y:{beginAtZero:e>=0,min:e,max:r,stacked:s,reverse:this.shouldReverseAxis(i?.value?.scaling,"value"),display:!T,...$?{position:$}:{},ticks:{stepSize:o,font:{size:this.getDOMFontSize(c,12)},color:u,callback:C},grid:M(i?.value,T)},x:{stacked:s,display:!P,reverse:this.shouldReverseAxis(i?.category?.scaling,"category"),..."high"===i?.category?.tickLabels?.position?{position:"top"}:q?{position:q}:{},ticks:{font:{size:this.getDOMFontSize(h,12)},color:f,...null!=i?.category?.tickLabels?.rotation?{maxRotation:i.category.tickLabels.rotation,minRotation:i.category.tickLabels.rotation}:{}},grid:{display:false}}};if("y"===a){const t={...z};const n=this.shouldReverseAxis(i?.value?.scaling,"value");let a=q;z.x={beginAtZero:e>=0,min:e,max:r,stacked:s,display:T?n?true:false:true,reverse:n,...$?{position:$}:{},ticks:{display:!T,stepSize:o,font:{size:this.getDOMFontSize(c,12)},color:u,callback:C},border:{display:!T},grid:M(i?.value,T)};z.y={stacked:s,display:!P,reverse:!this.shouldReverseAxis(i?.category?.scaling,"category"),...a?{position:a}:{},ticks:{font:{size:this.getDOMFontSize(h,12)},color:f},grid:M(i?.category,P)}}if("y"===a){if(i?.value?.title)z.x.title={display:true,text:i.value.title.text||i.value.title,font:{size:this.getDOMFontSize(i?.value?.title?.formatting,14),weight:"bold"},color:i?.value?.title?.formatting?.color?this.convertColorToHex(i.value.title.formatting.color):"#666666"};if(i?.category?.title)z.y.title={display:true,text:i.category.title.text||i.category.title,font:{size:this.getDOMFontSize(i?.category?.title?.formatting,14),weight:"bold"},color:i?.category?.title?.formatting?.color?this.convertColorToHex(i.category.title.formatting.color):"#666666"}}else{if(i?.value?.title)z.y.title={display:true,text:i.value.title.text||i.value.title,font:{size:this.getDOMFontSize(i?.value?.title?.formatting,14),weight:"bold"},color:i?.value?.title?.formatting?.color?this.convertColorToHex(i.value.title.formatting.color):"#666666"};if(i?.category?.title)z.x.title={display:true,text:i.category.title.text||i.category.title,font:{size:this.getDOMFontSize(i?.category?.title?.formatting,14),weight:"bold"},color:i?.category?.title?.formatting?.color?this.convertColorToHex(i.category.title.formatting.color):"#666666"}}return z}getTooltipConfig(t,e){if("bubble"===t)return{mode:"point",intersect:true,callbacks:{title:function(t){const e=t[0];return e.dataset.label||""},label:function(t){const e=t.parsed;return[`Market Share: ${e.x}%`,`Revenue: $${e.y.toLocaleString()}k`,`Customer Base: ${e.r} units`]}}};return{mode:e?"index":"nearest",intersect:false,callbacks:{label:function(t){let e=t.dataset.label||"";if(e)e+=": ";if(null!==t.parsed.y)e+=t.parsed.y.toLocaleString();return e}}}}shouldShowDataLabels(t){if(t&&t.series&&t.series.length>0){let e=false;const r=false;for(const r of t.series)if(r.dataLabels){e=true;if(true===r.dataLabels.showValue||true===r.dataLabels.showSeriesName)return true}if(e)return false}if(t&&t.dataLabels){const e=t.dataLabels.showValue;const r=true===t.dataLabels.showSeriesName;if(true===e||r)return true;if(false===e&&!r)return false}if(t&&void 0!==t.showDataLabels){const e=t.showDataLabels;return e}return false}shouldReverseAxis(t,e){if(!t||!t.orientation)return false;const r="maxMin"===t.orientation;return r}formatExcelDate(t,e){const r=86400*(t-25569)*1e3;const o=new Date(r);if(isNaN(o.getTime()))return String(t);const s=o.getUTCFullYear();const i=String(o.getUTCMonth()+1).padStart(2,"0");const n=String(s).slice(-2);const a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];const l=a[o.getUTCMonth()];const c=(e||"").toLowerCase();if("yyyy-mm"===c||"yyyy\\-mm"===c)return`${s}-${i}`;if("mmm-yy"===c||"mmm\\-yy"===c)return`${l}-${n}`;if(c.includes("mmm")&&c.includes("yy"))return`${l}-${n}`;if(c.includes("yyyy")&&c.includes("mm"))return`${s}-${i}`;return`${s}-${i}`}calculateOptimalAxisScale(t,e=0){if(t<=0)return{max:10,step:2};const r=t-Math.min(e,0);const o=Math.pow(10,Math.floor(Math.log10(r)));const s=[1,2,5,10];let i=o;for(const e of s){const r=e*(o/10);if(r>0){const e=Math.ceil(1.05*t/r);if(e>=4&&e<=8){i=r;break}}}if(i===o)for(const e of s){const r=e*o;const s=Math.ceil(1.05*t/r);if(s>=4&&s<=8){i=r;break}}const n=Math.ceil(1.05*t/i)*i;if(t<1){const e=t<.1?.02:.2;return{max:Math.ceil(1.1*t/e)*e,step:e}}return{max:n,step:i}}}if("object"!=="undefined"&&t.exports)t.exports=e;if("undefined"!==typeof window)window.ChartJSRenderer=e}(X);return X.exports}var Q=J();var K=s(Q);var tt={};var et;function rt(){if(et)return tt;et=1;if("undefined"===typeof AscCommon)window.AscCommon={};function t(){if("undefined"===typeof CanvasGraphicsAdapter)return;if(CanvasGraphicsAdapter.prototype.drawLineWithArrows)return;CanvasGraphicsAdapter.prototype.drawLineWithArrows=function(t,e,r,o,s,i=1,n=null){const a=this._context;if(!a)return;a.save();a.beginPath();a.moveTo(t,e);a.lineTo(r,o);const l=("function"===typeof this.colorToRgb?this.colorToRgb(s):null)||"rgba(0,0,0,1)";const c=Math.max(CoordinateTransform.mmToPixels(i||1),1);a.strokeStyle=l;a.lineWidth=c;if(n&&n.dashArray&&n.dashArray.length>0){const t=n.dashArray.map(t=>t*c);a.setLineDash(t)}if(n&&"function"===typeof this.applyStrokeStyle)try{this.applyStrokeStyle(a,n,c)}catch(t){}a.stroke();const h=t=>{if("number"===typeof t)return t;const e=(t||"").toString().toLowerCase();if("lg"===e||"large"===e)return 3;if("med"===e||"medium"===e)return 2;if("sm"===e||"small"===e)return 1;return 2};const u=n&&n.headEnd;const f=n&&n.tailEnd;const d=u&&u.type;const p=f&&f.type;const g=!!(u&&d&&"none"!==d);const m=!!(f&&p&&"none"!==p);if(g||m){const s=Math.atan2(o-e,r-t);const i=a.getTransform();const n=Math.sqrt(i.a*i.a+i.b*i.b);const d=3*c;const p=2.5*c;const y=(t,e,r,o)=>{if(!o)return;const s=o.lengthScale||h(o.len);const i=o.widthScale||h(o.w);const n=d*s;const u=p*i;const f=(o.type||o.val||"arrow").toString().toLowerCase();const g=u/2;a.save();a.translate(t,e);a.rotate(r);a.beginPath();if("open"===f){a.moveTo(0,0);a.lineTo(-n,-g);a.moveTo(0,0);a.lineTo(-n,g);a.strokeStyle=l;a.lineWidth=Math.max(1,c);a.stroke()}else if("stealth"===f){a.moveTo(0,0);a.lineTo(-n,-.5*g);a.lineTo(.85*-n,0);a.lineTo(-n,.5*g);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(.5,.3*c);a.stroke()}else if("diamond"===f){a.moveTo(0,0);a.lineTo(-n/2,-g);a.lineTo(-n,0);a.lineTo(-n/2,g);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(.5,.3*c);a.stroke()}else if("oval"===f){a.ellipse(-n/2,0,n/2,g,0,0,2*Math.PI);a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(.5,.3*c);a.stroke()}else{a.moveTo(0,0);a.lineTo(-n,-g);a.lineTo(-n,g);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(.5,.3*c);a.stroke()}a.restore()};if(g)y(t,e,s+Math.PI,u);if(m)y(r,o,s,f)}a.restore()}}if("undefined"===typeof AscFormat)window.AscFormat={};class e{constructor(){this.sx=1;this.sy=1;this.shx=0;this.shy=0;this.tx=0;this.ty=0}TransformPointX(t,e){return t*this.sx+e*this.shx+this.tx}TransformPointY(t,e){return t*this.shy+e*this.sy+this.ty}Invert(){const t=this.sx*this.sy-this.shx*this.shy;if(Math.abs(t)<1e-12)return;const e=1/t;const r=this.sy*e;const o=this.sx*e;const s=-this.shx*e;const i=-this.shy*e;const n=(this.shx*this.ty-this.sy*this.tx)*e;const a=(this.shy*this.tx-this.sx*this.ty)*e;this.sx=r;this.sy=o;this.shx=s;this.shy=i;this.tx=n;this.ty=a}createDuplicate(){const t=new e;t.sx=this.sx;t.sy=this.sy;t.shx=this.shx;t.shy=this.shy;t.tx=this.tx;t.ty=this.ty;return t}reset(){this.sx=1;this.sy=1;this.shx=0;this.shy=0;this.tx=0;this.ty=0}}if("undefined"===typeof CBrush)window.CBrush=class t{constructor(){this.Color1={R:0,G:0,B:0,A:255};this.Color2={R:0,G:0,B:0,A:255};this.Type=0}GetType(){return this.Type}};if("undefined"===typeof CPen)window.CPen=class t{constructor(){this.Color={R:0,G:0,B:0,A:255};this.Size=1;this.DashStyle=0}};if("undefined"===typeof CFontManager)window.CFontManager=class t{constructor(){this.m_oGlyphString={m_fX:0,m_fY:0,m_pGlyphsBuffer:[]}}LoadString4C(t,e,r){this.m_oGlyphString.m_fX=e;this.m_oGlyphString.m_fY=r;return e+10}LoadString2(t,e,r){this.m_oGlyphString.m_fX=e;this.m_oGlyphString.m_fY=r}GetNextChar2(){return null}};class CanvasGraphicsAdapter{constructor(){this.canvas=null;this._context=null;this.widthPx=0;this.heightPx=0;this.widthMM=0;this.heightMM=0;this.dpiX=96;this.dpiY=96;this.transform=new e;this.grStateStack=[];this.clipStack=[];this.font=null;this.brush=new CBrush;this.pen=new CPen;this.currentPath=null;this.isPathStarted=false;this.customGeometryProcessor=new r}get context(){return this._context}init(t,e,r,o,s){this._context=t;this.widthPx=e;this.heightPx=r;this.widthMM=o||25.4*e/96;this.heightMM=s||25.4*r/96;this.dpiX=96;this.dpiY=96;this.transform.sx=1;this.transform.sy=1;this.transform.shx=0;this.transform.shy=0;this.transform.tx=0;this.transform.ty=0;this.recalculateTransforms()}recalculateTransforms(){this.transform=this.transform.createDuplicate();const t=this.transform.sx*this.transform.sx+this.transform.shx*this.transform.shy;const e=this.transform.sy*this.transform.sy+this.transform.shy*this.transform.shx;const r=this.transform.sx*this.transform.shx+this.transform.shx*this.transform.sy;const o=this.transform.sy*this.transform.shy+this.transform.shy*this.transform.sx;const s=this.transform.sx*this.transform.tx+this.transform.shx*this.transform.ty+this.transform.tx;const i=this.transform.sy*this.transform.ty+this.transform.shy*this.transform.tx+this.transform.ty;this.transform.sx=t;this.transform.sy=e;this.transform.shx=r;this.transform.shy=o;this.transform.tx=s;this.transform.ty=i;this.transform=this.transform.createDuplicate();this.transform.Invert()}resetState(){this.coordinateSystem=null;this.transform.reset();this.grStateStack=[];this.clipStack=[];this.currentRenderingShape=null;if(this.customGeometryProcessor)this.customGeometryProcessor.cache.clear();this.currentPath=null;this.isPathStarted=false;this.brush=new CBrush;this.pen=new CPen}SaveGrState(){if(this._context){this._context.save();this.grStateStack.push({transform:this.transform.createDuplicate(),fullTransform:this.transform.createDuplicate(),invertFullTransform:this.transform.createDuplicate()})}}RestoreGrState(){if(this._context){this._context.restore();if(this.grStateStack.length>0){const t=this.grStateStack.pop();this.transform=t.transform;this.transform=t.fullTransform;this.transform=t.invertFullTransform}}}transform3(t){this.transform=t.createDuplicate();this.recalculateTransforms();if(this._context)this._context.setTransform(this.transform.sx,this.transform.shy,this.transform.shx,this.transform.sy,this.transform.tx,this.transform.ty)}AddClipRect(t,e,r,o){if(this._context){this._context.save();this._context.beginPath();this._context.rect(t,e,r,o);this._context.clip()}}clear(){if(this._context){this._context.save();this._context.setTransform(1,0,0,1,0,0);this._context.clearRect(0,0,this.widthPx,this.heightPx);this._context.restore()}}t(t,e,r,o){if(this.bIsBreak||!this._context)return;const s=e;const i=r;this._context.fillStyle=this.colorToRgb(this.brush.Color1);this._context.textBaseline="alphabetic";let n=s;let a=null;this._context.fillText(t,n,i);const l=this._context.measureText(t);if(o){a={x:s,y:i,r:s+l.width,b:i};if(void 0!==l.actualBoundingBoxAscent)a.y=i-l.actualBoundingBoxAscent;if(void 0!==l.actualBoundingBoxDescent)a.b=i+l.actualBoundingBoxDescent}n+=l.width;return a}b_color1(t,e,r,o=255){this.brush.Color1.R=t;this.brush.Color1.G=e;this.brush.Color1.B=r;this.brush.Color1.A=o;this.bBrushColorInit=true}p_color(t,e,r,o=255){this.pen.Color.R=t;this.pen.Color.G=e;this.pen.Color.B=r;this.pen.Color.A=o;this.bPenColorInit=true}p_width(t){this.pen.Size=t;if(this._context)this._context.lineWidth=t}fillRect(t,e,r,o,s){if(!this._context||!s)return;this._context.save();this._context.fillStyle=this.colorToRgb(s);this._context.fillRect(t,e,r,o);this._context.restore()}strokeRect(t,e,r,o,s,i=1){if(!this._context)return;this._context.save();this._context.strokeStyle=this.colorToRgb(s)||this.colorToRgb(this.pen.Color);this._context.lineWidth=i;this._context.strokeRect(t,e,r,o);this._context.restore()}drawLine(t,e,r,o,s,i=1){if(!this._context)return;this._context.save();this._context.strokeStyle=this.colorToRgb(s);this._context.lineWidth=i;this._context.beginPath();this._context.moveTo(t,e);this._context.lineTo(r,o);this._context.stroke();this._context.restore()}fillCircle(t,e,r,o){if(!this._context)return;this._context.save();this._context.fillStyle=this.colorToRgb(o);this._context.beginPath();this._context.arc(t,e,r,0,2*Math.PI);this._context.fill();this._context.restore()}strokeCircle(t,e,r,o,s=1){if(!this._context)return;this._context.save();this._context.strokeStyle=this.colorToRgb(o);this._context.lineWidth=s;this._context.beginPath();this._context.arc(t,e,r,0,2*Math.PI);this._context.stroke();this._context.restore()}fillText(t,e,r,o={}){if(!this._context)return;this._context.save();const s=o.fontSize||o.size||12;const i=o.fontFamily||o.family||"Arial";const n=o.bold?"bold":"normal";const a=o.italic?"italic":"normal";this._context.font=`${a} ${n} ${s}px ${i}`;this._context.fillStyle=this.colorToRgb(o.color||{r:0,g:0,b:0});this._context.textAlign=o.textAlign||"left";this._context.textBaseline=o.textBaseline||"alphabetic";this._context.fillText(t,e,r);this._context.restore()}colorToRgb(t){if("string"===typeof t)return t;if(t&&"object"===typeof t){const e=void 0!==t.r?t.r:void 0!==t.R?t.R:0;const r=void 0!==t.g?t.g:void 0!==t.G?t.G:0;const o=void 0!==t.b?t.b:void 0!==t.B?t.B:0;const s=void 0!==t.a?t.a:void 0!==t.A?t.A:255;if(void 0!==s&&255!==s)return`rgba(${e}, ${r}, ${o}, ${s/255})`;return`rgb(${e}, ${r}, ${o})`}return"rgb(0, 0, 0)"}Start_Command(t){this.commandStack.push(t)}End_Command(t){if(this.commandStack.length>0)this.commandStack.pop()}get context(){return this._context}isBoundsChecker(){return false}drawPresetGeometry(t,e,r,o,s,i,n,a=1,l=null,c={}){if(!this._context)return;const h=this._context;h.save();if(i&&"object"===typeof i&&void 0!==i.a&&i.a<255){h.globalAlpha=i.a/255;i={...i,a:255}}let u=false;if(i&&"object"===typeof i&&"linear"===i.type&&i.stops){u=true;const t={x:e,y:r,w:o,h:s};const n=this.createCanvasGradient?this.createCanvasGradient(h,t,i):null;if(n)h.fillStyle=n;else if(i.stops[0]?.color)h.fillStyle=this.colorToRgb(i.stops[0].color)}else if(i)h.fillStyle=this.colorToRgb(i);if(n){h.strokeStyle=this.colorToRgb(n);h.lineWidth=CoordinateTransform.mmToPixels(a||1)}h.beginPath();switch(t){case"teardrop":this.drawTeardropPath(h,e,r,o,s);break;case"rect":case"rectangle":default:h.rect(e,r,o,s);break;case"ellipse":case"oval":case"flowChartConnector":h.ellipse(e+o/2,r+s/2,o/2,s/2,0,0,2*Math.PI);break;case"roundRect":{const t=void 0!==c.adj?c.adj:16667;const i=Math.min(5e4,Math.max(0,t));const n=i/1e5*Math.min(o,s);this.drawRoundRectPath(h,e,r,o,s,n);break}case"triangle":this.drawTrianglePath(h,e,r,o,s);break;case"diamond":this.drawDiamondPath(h,e,r,o,s);break;case"pentagon":this.drawPentagonPath(h,e,r,o,s);break;case"hexagon":this.drawHexagonPath(h,e,r,o,s);break;case"octagon":this.drawOctagonPath(h,e,r,o,s);break;case"star":case"star5":this.drawStarPath(h,e,r,o,s);break;case"star4":this.drawStar4Path(h,e,r,o,s);break;case"star6":this.drawStar6Path(h,e,r,o,s);break;case"star8":this.drawStar8Path(h,e,r,o,s);break;case"star10":this.drawStar10Path(h,e,r,o,s);break;case"star12":this.drawStar12Path(h,e,r,o,s);break;case"star16":this.drawStar16Path(h,e,r,o,s);break;case"star24":this.drawStar24Path(h,e,r,o,s);break;case"star32":this.drawStar32Path(h,e,r,o,s);break;case"heart":this.drawHeartPath(h,e,r,o,s);break;case"flowChartProcess":this.drawFlowChartProcessPath(h,e,r,o,s);break;case"flowChartDecision":this.drawFlowChartDecisionPath(h,e,r,o,s);break;case"flowChartInputOutput":this.drawFlowChartInputOutputPath(h,e,r,o,s);break;case"flowChartPredefinedProcess":this.drawFlowChartPredefinedProcessPath(h,e,r,o,s);break;case"flowChartInternalStorage":this.drawFlowChartInternalStoragePath(h,e,r,o,s);break;case"flowChartDocument":this.drawFlowChartDocumentPath(h,e,r,o,s);break;case"flowChartMultidocument":this.drawFlowChartMultidocumentPath(h,e,r,o,s);break;case"flowChartTerminator":this.drawRoundRectPath(h,e,r,o,s,.2*Math.min(o,s));break;case"flowChartPreparation":this.drawFlowChartPreparationPath(h,e,r,o,s);break;case"flowChartManualInput":this.drawFlowChartManualInputPath(h,e,r,o,s);break;case"flowChartManualOperation":this.drawFlowChartManualOperationPath(h,e,r,o,s);break;case"flowChartOffpageConnector":this.drawFlowChartOffpageConnectorPath(h,e,r,o,s);break;case"flowChartPunchedCard":this.drawFlowChartPunchedCardPath(h,e,r,o,s);break;case"flowChartPunchedTape":this.drawFlowChartPunchedTapePath(h,e,r,o,s);break;case"flowChartSummingJunction":this.drawFlowChartSummingJunctionPath(h,e,r,o,s);break;case"flowChartOr":this.drawFlowChartOrPath(h,e,r,o,s);break;case"flowChartCollate":this.drawFlowChartCollatePath(h,e,r,o,s);break;case"flowChartSort":this.drawFlowChartSortPath(h,e,r,o,s);break;case"flowChartExtract":this.drawFlowChartExtractPath(h,e,r,o,s);break;case"flowChartMerge":this.drawFlowChartMergePath(h,e,r,o,s);break;case"flowChartStoredData":this.drawFlowChartStoredDataPath(h,e,r,o,s);break;case"flowChartDelay":this.drawFlowChartDelayPath(h,e,r,o,s);break;case"flowChartMagneticTape":this.drawFlowChartMagneticTapePath(h,e,r,o,s);break;case"flowChartMagneticDisk":this.drawFlowChartMagneticDiskPath(h,e,r,o,s);break;case"flowChartMagneticDrum":this.drawFlowChartMagneticDrumPath(h,e,r,o,s);break;case"flowChartDisplay":this.drawFlowChartDisplayPath(h,e,r,o,s);break;case"rightArrow":case"notchedRightArrow":case"stripedRightArrow":this.drawRightArrowPath(h,e,r,o,s);break;case"leftArrow":this.drawLeftArrowPath(h,e,r,o,s);break;case"upArrow":this.drawUpArrowPath(h,e,r,o,s);break;case"downArrow":this.drawDownArrowPath(h,e,r,o,s);break;case"leftRightArrow":this.drawLeftRightArrowPath(h,e,r,o,s);break;case"upDownArrow":this.drawUpDownArrowPath(h,e,r,o,s);break;case"quadArrow":this.drawQuadArrowPath(h,e,r,o,s);break;case"bentArrow":this.drawBentArrowPath(h,e,r,o,s);break;case"uturnArrow":this.drawUturnArrowPath(h,e,r,o,s);break;case"curvedRightArrow":this.drawCurvedRightArrowPath(h,e,r,o,s);break;case"curvedLeftArrow":this.drawCurvedLeftArrowPath(h,e,r,o,s);break;case"callout1":this.drawCallout1Path(h,e,r,o,s);break;case"callout2":this.drawCallout2Path(h,e,r,o,s);break;case"callout3":this.drawCallout3Path(h,e,r,o,s);break;case"accentCallout1":case"accentBorderCallout1":this.drawAccentCallout1Path(h,e,r,o,s);break;case"accentCallout2":case"accentBorderCallout2":this.drawAccentCallout2Path(h,e,r,o,s);break;case"accentCallout3":case"accentBorderCallout3":this.drawAccentCallout3Path(h,e,r,o,s);break;case"borderCallout1":this.drawBorderCallout1Path(h,e,r,o,s);break;case"borderCallout2":this.drawBorderCallout2Path(h,e,r,o,s);break;case"borderCallout3":this.drawBorderCallout3Path(h,e,r,o,s);break;case"lightningBolt":this.drawLightningBoltPath(h,e,r,o,s);break;case"sun":this.drawSunPath(h,e,r,o,s);break;case"moon":this.drawMoonPath(h,e,r,o,s);break;case"cloud":this.drawCloudPath(h,e,r,o,s);break;case"wave":this.drawWavePath(h,e,r,o,s);break;case"doubleWave":this.drawDoubleWavePath(h,e,r,o,s);break;case"smileyFace":this.drawSmileyFacePath(h,e,r,o,s);break;case"noSmoking":this.drawNoSmokingPath(h,e,r,o,s);break;case"blockArc":this.drawBlockArcPath(h,e,r,o,s);break;case"foldedCorner":this.drawFoldedCornerPath(h,e,r,o,s);break;case"bevel":this.drawBevelPath(h,e,r,o,s);break;case"donut":this.drawDonutPath(h,e,r,o,s);break;case"noSymbol":this.drawNoSymbolPath(h,e,r,o,s);break;case"cube":this.drawCubePath(h,e,r,o,s);break;case"can":this.drawCanPath(h,e,r,o,s);break;case"cone":this.drawConePath(h,e,r,o,s);break;case"pyramid":this.drawPyramidPath(h,e,r,o,s);break;case"plus":case"cross":case"mathPlus":this.drawPlusPath(h,e,r,o,s);break;case"minus":case"mathMinus":this.drawMinusPath(h,e,r,o,s);break;case"multiply":case"mathMultiply":this.drawMultiplyPath(h,e,r,o,s);break;case"divide":case"mathDivide":this.drawDividePath(h,e,r,o,s);break;case"equal":case"mathEqual":this.drawEqualPath(h,e,r,o,s);break;case"notEqual":case"mathNotEqual":this.drawNotEqualPath(h,e,r,o,s);break;case"line":case"straightConnector1":this.drawLinePath(h,e,r,o,s);break;case"bentConnector2":this.drawBentConnector2Path(h,e,r,o,s);break;case"bentConnector3":this.drawBentConnector3Path(h,e,r,o,s);break;case"bentConnector4":this.drawBentConnector4Path(h,e,r,o,s);break;case"bentConnector5":this.drawBentConnector5Path(h,e,r,o,s);break;case"curvedConnector2":this.drawCurvedConnector2Path(h,e,r,o,s);break;case"curvedConnector3":this.drawCurvedConnector3Path(h,e,r,o,s);break;case"curvedConnector4":this.drawCurvedConnector4Path(h,e,r,o,s);break;case"curvedConnector5":this.drawCurvedConnector5Path(h,e,r,o,s);break;case"rtTriangle":h.moveTo(e,r+s);h.lineTo(e+o,r+s);h.lineTo(e,r);h.closePath();break;case"arc":{const t=(void 0!==c.adj1?c.adj1:0)/6e4;const i=(void 0!==c.adj2?c.adj2:216e5)/6e4;const n=t*Math.PI/180;const a=i*Math.PI/180;const l=e+o/2,u=r+s/2;const f=o/2,d=s/2;h.moveTo(l,u);h.ellipse(l,u,f,d,0,n,a);h.closePath();break}case"pie":case"pieWedge":{const t=e+o/2,i=r+s/2;h.moveTo(t,i);h.arc(t,i,Math.min(o,s)/2,-Math.PI/2,0);h.closePath();break}case"chord":h.arc(e+o/2,r+s/2,Math.min(o,s)/2,0,1.5*Math.PI,true);h.closePath();break;case"frame":{const t=.15*Math.min(o,s);h.rect(e,r,o,s);h.moveTo(e+t,r+t);h.rect(e+t,r+t,o-2*t,s-2*t);break}case"parallelogram":{const t=.25*o;h.moveTo(e+t,r);h.lineTo(e+o,r);h.lineTo(e+o-t,r+s);h.lineTo(e,r+s);h.closePath();break}case"trapezoid":{const t=.2*o;h.moveTo(e+t,r);h.lineTo(e+o-t,r);h.lineTo(e+o,r+s);h.lineTo(e,r+s);h.closePath();break}case"chevron":{const t=.25*o;h.moveTo(e,r);h.lineTo(e+o-t,r);h.lineTo(e+o,r+s/2);h.lineTo(e+o-t,r+s);h.lineTo(e,r+s);h.lineTo(e+t,r+s/2);h.closePath();break}case"homePlate":{const t=.2*o;h.moveTo(e,r);h.lineTo(e+o-t,r);h.lineTo(e+o,r+s/2);h.lineTo(e+o-t,r+s);h.lineTo(e,r+s);h.closePath();break}case"leftBracket":{const t=.15*s;h.moveTo(e+.4*o,r);h.quadraticCurveTo(e,r,e,r+t);h.lineTo(e,r+s-t);h.quadraticCurveTo(e,r+s,e+.4*o,r+s);break}case"rightBracket":{const t=.15*s;h.moveTo(e+.6*o,r);h.quadraticCurveTo(e+o,r,e+o,r+t);h.lineTo(e+o,r+s-t);h.quadraticCurveTo(e+o,r+s,e+.6*o,r+s);break}case"leftBrace":{const t=r+s/2;const i=.4*o;h.moveTo(e+o,r);h.quadraticCurveTo(e+i,r,e+i,t-.1*s);h.quadraticCurveTo(e+i,t,e,t);h.quadraticCurveTo(e+i,t,e+i,t+.1*s);h.quadraticCurveTo(e+i,r+s,e+o,r+s);break}case"rightBrace":{const t=r+s/2;const i=.6*o;h.moveTo(e,r);h.quadraticCurveTo(e+i,r,e+i,t-.1*s);h.quadraticCurveTo(e+i,t,e+o,t);h.quadraticCurveTo(e+i,t,e+i,t+.1*s);h.quadraticCurveTo(e+i,r+s,e,r+s);break}case"bracketPair":{const t=.15*Math.min(o,s);h.moveTo(e+t,r);h.arc(e+t,r+t,t,-Math.PI/2,Math.PI,true);h.lineTo(e,r+s-t);h.arc(e+t,r+s-t,t,Math.PI,Math.PI/2,true);h.moveTo(e+o-t,r);h.arc(e+o-t,r+t,t,-Math.PI/2,0);h.lineTo(e+o,r+s-t);h.arc(e+o-t,r+s-t,t,0,Math.PI/2);break}case"bracePair":{const t=.15*Math.min(o,s);h.moveTo(e+t,r);h.arc(e+t,r+t,t,-Math.PI/2,Math.PI,true);h.lineTo(e,r+s-t);h.arc(e+t,r+s-t,t,Math.PI,Math.PI/2,true);h.moveTo(e+o-t,r);h.arc(e+o-t,r+t,t,-Math.PI/2,0);h.lineTo(e+o,r+s-t);h.arc(e+o-t,r+s-t,t,0,Math.PI/2);break}case"diagStripe":h.moveTo(e,r);h.lineTo(e+o,r);h.lineTo(e,r+s);h.closePath();break;case"corner":{const t=.4*o,i=.4*s;h.moveTo(e,r);h.lineTo(e+t,r);h.lineTo(e+t,r+s-i);h.lineTo(e+o,r+s-i);h.lineTo(e+o,r+s);h.lineTo(e,r+s);h.closePath();break}case"halfFrame":{const t=.2*o,i=.2*s;h.moveTo(e,r);h.lineTo(e+o,r);h.lineTo(e+o-t,r+i);h.lineTo(e+t,r+i);h.lineTo(e+t,r+s);h.lineTo(e,r+s);h.closePath();break}case"snip1Rect":case"snip2SameRect":case"snip2DiagRect":case"snipRoundRect":{const t=.15*Math.min(o,s);h.moveTo(e+t,r);h.lineTo(e+o-t,r);h.lineTo(e+o,r+t);h.lineTo(e+o,r+s);h.lineTo(e,r+s);h.lineTo(e,r+t);h.closePath();break}case"round1Rect":case"round2SameRect":case"round2DiagRect":this.drawRoundRectPath(h,e,r,o,s,.15*Math.min(o,s));break;case"ribbon":case"ribbon2":h.moveTo(e,r+.3*s);h.lineTo(e+.15*o,r+.15*s);h.lineTo(e+.15*o,r);h.lineTo(e+.85*o,r);h.lineTo(e+.85*o,r+.15*s);h.lineTo(e+o,r+.3*s);h.lineTo(e+.85*o,r+.45*s);h.lineTo(e+.85*o,r+s);h.lineTo(e+.15*o,r+s);h.lineTo(e+.15*o,r+.45*s);h.closePath();break;case"circularArrow":h.arc(e+o/2,r+s/2,Math.min(o,s)/2,0,1.5*Math.PI,true)}if(i)h.fill();if(n){h.globalAlpha=1;if(l&&l.dashArray&&l.dashArray.length>0){const t=CoordinateTransform.mmToPixels(a||1);const e=l.dashArray.map(e=>e*t);h.setLineDash(e)}h.stroke()}h.restore()}drawTeardropPath(t,e,r,o,s){const i=o/1001;const n=s/992;const a=t=>e+t*i;const l=t=>r+t*n;t.moveTo(a(711),l(7));t.bezierCurveTo(a(475),l(8),a(442),l(8),a(423),l(12));t.bezierCurveTo(a(312),l(31),a(221),l(77),a(144),l(154));t.bezierCurveTo(a(53),l(247),a(4),l(363),a(4),l(492));t.bezierCurveTo(a(4),l(565),a(16),l(625),a(46),l(689));t.bezierCurveTo(a(82),l(769),a(143),l(842),a(219),l(894));t.bezierCurveTo(a(258),l(921),a(307),l(945),a(359),l(961));t.bezierCurveTo(a(418),l(980),a(509),l(987),a(577),l(977));t.bezierCurveTo(a(720),l(956),a(845),l(878),a(922),l(758));t.bezierCurveTo(a(953),l(710),a(977),l(654),a(988),l(603));t.bezierCurveTo(a(1001),l(544),a(1001),l(546),a(1001),l(265));t.lineTo(a(1001),l(7));t.lineTo(a(989),l(6));t.bezierCurveTo(a(983),l(6),a(857),l(6),a(711),l(7));t.closePath()}drawRoundRectPath(t,e,r,o,s,i){t.moveTo(e+i,r);t.lineTo(e+o-i,r);t.quadraticCurveTo(e+o,r,e+o,r+i);t.lineTo(e+o,r+s-i);t.quadraticCurveTo(e+o,r+s,e+o-i,r+s);t.lineTo(e+i,r+s);t.quadraticCurveTo(e,r+s,e,r+s-i);t.lineTo(e,r+i);t.quadraticCurveTo(e,r,e+i,r);t.closePath()}drawTrianglePath(t,e,r,o,s){t.moveTo(e+o/2,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.closePath()}drawDiamondPath(t,e,r,o,s){t.moveTo(e+o/2,r);t.lineTo(e+o,r+s/2);t.lineTo(e+o/2,r+s);t.lineTo(e,r+s/2);t.closePath()}drawPentagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;for(let e=0;e<5;e++){const r=2*e*Math.PI/5-Math.PI/2;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);if(0===e)t.moveTo(o,s);else t.lineTo(o,s)}t.closePath()}drawHexagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;for(let e=0;e<6;e++){const r=2*e*Math.PI/6;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);if(0===e)t.moveTo(o,s);else t.lineTo(o,s)}t.closePath()}drawStarPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;const l=.4*a;for(let e=0;e<10;e++){const r=e*Math.PI/5-Math.PI/2;const o=e%2===0?a:l;const s=i+o*Math.cos(r);const c=n+o*Math.sin(r);if(0===e)t.moveTo(s,c);else t.lineTo(s,c)}t.closePath()}drawHeartPath(t,e,r,o,s){const i=20;const n=18.35;const a=2;const l=3;const c=o/i;const h=s/n;const u=t=>e+(t-a)*c;const f=t=>r+(t-l)*h;t.moveTo(u(12),f(21.35));t.lineTo(u(10.55),f(20.03));t.bezierCurveTo(u(5.4),f(15.36),u(2),f(12.28),u(2),f(8.5));t.bezierCurveTo(u(2),f(5.42),u(4.42),f(3),u(7.5),f(3));t.bezierCurveTo(u(9.24),f(3),u(10.91),f(3.81),u(12),f(5.09));t.bezierCurveTo(u(13.09),f(3.81),u(14.76),f(3),u(16.5),f(3));t.bezierCurveTo(u(19.58),f(3),u(22),f(5.42),u(22),f(8.5));t.bezierCurveTo(u(22),f(12.28),u(18.6),f(15.36),u(13.45),f(20.04));t.lineTo(u(12),f(21.35));t.closePath()}drawOctagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;for(let e=0;e<8;e++){const r=2*e*Math.PI/8;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);if(0===e)t.moveTo(o,s);else t.lineTo(o,s)}t.closePath()}drawStar4Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,4)}drawStar6Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,6)}drawStar8Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,8)}drawStar10Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,10)}drawStar12Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,12)}drawStar16Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,16)}drawStar24Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,24)}drawStar32Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,32)}drawStarGeneric(t,e,r,o,s,i){const n=e+o/2;const a=r+s/2;const l=Math.min(o,s)/2;const c=.4*l;for(let e=0;e<2*i;e++){const r=e*Math.PI/i-Math.PI/2;const o=e%2===0?l:c;const s=n+o*Math.cos(r);const h=a+o*Math.sin(r);if(0===e)t.moveTo(s,h);else t.lineTo(s,h)}t.closePath()}drawFlowChartProcessPath(t,e,r,o,s){t.rect(e,r,o,s)}drawFlowChartDecisionPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;t.moveTo(i,r);t.lineTo(e+o,n);t.lineTo(i,r+s);t.lineTo(e,n);t.closePath()}drawFlowChartInputOutputPath(t,e,r,o,s){const i=.2*o;t.moveTo(e+i,r);t.lineTo(e+o,r);t.lineTo(e+o-i,r+s);t.lineTo(e,r+s);t.closePath()}drawFlowChartPredefinedProcessPath(t,e,r,o,s){const i=.12*o;t.rect(e,r,o,s);t.moveTo(e+i,r);t.lineTo(e+i,r+s);t.moveTo(e+o-i,r);t.lineTo(e+o-i,r+s)}drawFlowChartInternalStoragePath(t,e,r,o,s){const i=.2*Math.min(o,s);t.rect(e,r,o,s);t.moveTo(e,r+i);t.lineTo(e+o,r+i);t.moveTo(e+i,r);t.lineTo(e+i,r+s)}drawFlowChartDocumentPath(t,e,r,o,s){const i=.2*s;const n=r+s-i;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(e+o,n);t.bezierCurveTo(e+.5*o,r+s+i,e+.5*o,r+s-i,e,n);t.closePath()}drawFlowChartMultidocumentPath(t,e,r,o,s){const i=.1*Math.min(o,s);t.rect(e+2*i,r,o-2*i,s-2*i);t.rect(e+i,r+i,o-i,s-i);this.drawFlowChartDocumentPath(t,e,r+2*i,o-2*i,s-2*i)}drawFlowChartPreparationPath(t,e,r,o,s){const i=.2*o;t.moveTo(e,r+s/2);t.lineTo(e+i,r);t.lineTo(e+o-i,r);t.lineTo(e+o,r+s/2);t.lineTo(e+o-i,r+s);t.lineTo(e+i,r+s);t.closePath()}drawFlowChartManualInputPath(t,e,r,o,s){const i=.2*s;t.moveTo(e,r+i);t.lineTo(e+o,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.closePath()}drawFlowChartManualOperationPath(t,e,r,o,s){const i=.2*o;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(e+o-i,r+s);t.lineTo(e+i,r+s);t.closePath()}drawFlowChartOffpageConnectorPath(t,e,r,o,s){const i=.2*s;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(e+o,r+s-i);t.lineTo(e+o/2,r+s);t.lineTo(e,r+s-i);t.closePath()}drawFlowChartPunchedCardPath(t,e,r,o,s){const i=.1*Math.min(o,s);t.moveTo(e+i,r);t.lineTo(e+o,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.lineTo(e,r+i);t.closePath()}drawFlowChartPunchedTapePath(t,e,r,o,s){const i=.1*s;t.moveTo(e,r);t.bezierCurveTo(e+.25*o,r+i,e+.75*o,r-i,e+o,r);t.lineTo(e+o,r+s);t.bezierCurveTo(e+.75*o,r+s-i,e+.25*o,r+s+i,e,r+s);t.closePath()}drawFlowChartSummingJunctionPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);const l=.6*a;t.moveTo(i-l,n);t.lineTo(i+l,n);t.moveTo(i,n-l);t.lineTo(i,n+l)}drawFlowChartOrPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);const l=.6*a;t.moveTo(i-l,n-l);t.lineTo(i+l,n+l);t.moveTo(i+l,n-l);t.lineTo(i-l,n+l)}drawFlowChartCollatePath(t,e,r,o,s){t.moveTo(e,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.lineTo(e+o,r);t.closePath()}drawFlowChartSortPath(t,e,r,o,s){const i=e+o/2;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(i,r+s);t.closePath();t.moveTo(e+.25*o,r+.5*s);t.lineTo(e+.75*o,r+.5*s)}drawFlowChartExtractPath(t,e,r,o,s){const i=e+o/2;t.moveTo(e,r+s);t.lineTo(i,r);t.lineTo(e+o,r+s);t.closePath()}drawFlowChartMergePath(t,e,r,o,s){const i=e+o/2;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(i,r+s);t.closePath()}drawFlowChartStoredDataPath(t,e,r,o,s){const i=.1*o;t.arc(e+i,r+s/2,s/2,Math.PI/2,-Math.PI/2);t.lineTo(e+o-i,r);t.arc(e+o-i,r+s/2,s/2,-Math.PI/2,Math.PI/2);t.lineTo(e+i,r+s)}drawFlowChartDelayPath(t,e,r,o,s){const i=.2*o;t.moveTo(e,r);t.lineTo(e+o-i,r);t.arc(e+o-i,r+s/2,s/2,-Math.PI/2,Math.PI/2);t.lineTo(e,r+s);t.closePath()}drawFlowChartMagneticTapePath(t,e,r,o,s){const i=.15*s;t.moveTo(e,r+i);t.bezierCurveTo(e+.33*o,r,e+.67*o,r+2*i,e+o,r+i);t.lineTo(e+o,r+s-i);t.bezierCurveTo(e+.67*o,r+s-2*i,e+.33*o,r+s,e,r+s-i);t.closePath()}drawFlowChartMagneticDiskPath(t,e,r,o,s){const i=.2*s;t.ellipse(e+o/2,r+i/2,o/2,i/2,0,0,2*Math.PI);t.moveTo(e,r+i/2);t.lineTo(e,r+s-i/2);t.moveTo(e+o,r+i/2);t.lineTo(e+o,r+s-i/2);t.ellipse(e+o/2,r+s-i/2,o/2,i/2,0,0,2*Math.PI)}drawFlowChartMagneticDrumPath(t,e,r,o,s){const i=.2*o;t.ellipse(e+i/2,r+s/2,i/2,s/2,0,0,2*Math.PI);t.moveTo(e+i/2,r);t.lineTo(e+o,r);t.moveTo(e+i/2,r+s);t.lineTo(e+o,r+s);t.moveTo(e+o,r);t.lineTo(e+o,r+s)}drawFlowChartDisplayPath(t,e,r,o,s){const i=.2*o;t.moveTo(e,r+s/2);t.lineTo(e+i,r);t.lineTo(e+o-i,r);t.arc(e+o-i,r+s/2,s/2,-Math.PI/2,Math.PI/2);t.lineTo(e+i,r+s);t.closePath()}drawRightArrowPath(t,e,r,o,s){const i=.6*s;const n=r+(s-i)/2;const a=e+.7*o;t.moveTo(e,n);t.lineTo(a,n);t.lineTo(a,r);t.lineTo(e+o,r+s/2);t.lineTo(a,r+s);t.lineTo(a,n+i);t.lineTo(e,n+i);t.closePath()}drawLeftArrowPath(t,e,r,o,s){const i=.6*s;const n=r+(s-i)/2;const a=e+.3*o;t.moveTo(e+o,n);t.lineTo(a,n);t.lineTo(a,r);t.lineTo(e,r+s/2);t.lineTo(a,r+s);t.lineTo(a,n+i);t.lineTo(e+o,n+i);t.closePath()}drawUpArrowPath(t,e,r,o,s){const i=.6*o;const n=e+(o-i)/2;const a=r+.3*s;t.moveTo(n,r+s);t.lineTo(n,a);t.lineTo(e,a);t.lineTo(e+o/2,r);t.lineTo(e+o,a);t.lineTo(n+i,a);t.lineTo(n+i,r+s);t.closePath()}drawDownArrowPath(t,e,r,o,s){const i=.6*o;const n=e+(o-i)/2;const a=r+.7*s;t.moveTo(n,r);t.lineTo(n,a);t.lineTo(e,a);t.lineTo(e+o/2,r+s);t.lineTo(e+o,a);t.lineTo(n+i,a);t.lineTo(n+i,r);t.closePath()}drawLeftRightArrowPath(t,e,r,o,s){const i=.6*s;const n=r+(s-i)/2;const a=e+.2*o;const l=e+.8*o;t.moveTo(a,n);t.lineTo(l,n);t.lineTo(l,r);t.lineTo(e+o,r+s/2);t.lineTo(l,r+s);t.lineTo(l,n+i);t.lineTo(a,n+i);t.lineTo(a,r+s);t.lineTo(e,r+s/2);t.lineTo(a,r);t.closePath()}drawUpDownArrowPath(t,e,r,o,s){const i=.6*o;const n=e+(o-i)/2;const a=r+.2*s;const l=r+.8*s;t.moveTo(n,a);t.lineTo(n,l);t.lineTo(e,l);t.lineTo(e+o/2,r+s);t.lineTo(e+o,l);t.lineTo(n+i,l);t.lineTo(n+i,a);t.lineTo(e+o,a);t.lineTo(e+o/2,r);t.lineTo(e,a);t.closePath()}drawQuadArrowPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=.3*Math.min(o,s);t.moveTo(i,r);t.lineTo(i+a/2,r+a);t.lineTo(i+a/4,r+a);t.lineTo(i+a/4,n-a/4);t.lineTo(i+a/4,n-a/4);t.lineTo(e+o-a,n-a/4);t.lineTo(e+o-a,n-a/2);t.lineTo(e+o,n);t.lineTo(e+o-a,n+a/2);t.lineTo(e+o-a,n+a/4);t.lineTo(i+a/4,n+a/4);t.lineTo(i+a/4,r+s-a);t.lineTo(i+a/2,r+s-a);t.lineTo(i,r+s);t.lineTo(i-a/2,r+s-a);t.lineTo(i-a/4,r+s-a);t.lineTo(i-a/4,n+a/4);t.lineTo(e+a,n+a/4);t.lineTo(e+a,n+a/2);t.lineTo(e,n);t.lineTo(e+a,n-a/2);t.lineTo(e+a,n-a/4);t.lineTo(i-a/4,n-a/4);t.lineTo(i-a/4,r+a);t.lineTo(i-a/2,r+a);t.closePath()}drawBentArrowPath(t,e,r,o,s){const i=e+.7*o;const n=r+.3*s;const a=.4*s;t.moveTo(e,r+s/2-a/2);t.lineTo(i,r+s/2-a/2);t.lineTo(i,n);t.lineTo(i-a/2,n);t.lineTo(e+o,r);t.lineTo(i+a/2,n);t.lineTo(i,n);t.lineTo(i,r+s/2+a/2);t.lineTo(e,r+s/2+a/2);t.closePath()}drawUturnArrowPath(t,e,r,o,s){const i=.3*o;const n=e+o/2;const a=.3*o;t.moveTo(e,r+s);t.lineTo(e,r+s/2);t.arc(n,r+s/2,a,Math.PI,0);t.lineTo(e+o-i,r+s/2-a);t.lineTo(e+o-i,r);t.lineTo(e+o,r+s/4);t.lineTo(e+o-2*i,r+s/4);t.lineTo(e+o-2*i,r+s/2-a);t.arc(n,r+s/2,a-i,0,Math.PI,true);t.lineTo(e+i,r+s);t.closePath()}drawCurvedRightArrowPath(t,e,r,o,s){const i=e+.8*o;const n=r+.2*s;const a=.2*Math.min(o,s);t.moveTo(e,r+s/2);t.quadraticCurveTo(i,n,e+o-a,r+s/2);t.lineTo(e+o-a,r+s/2-a);t.lineTo(e+o,r+s/2);t.lineTo(e+o-a,r+s/2+a);t.lineTo(e+o-a,r+s/2+a/2);t.quadraticCurveTo(i,n+a,e,r+s/2+a/2);t.closePath()}drawCurvedLeftArrowPath(t,e,r,o,s){const i=e+.2*o;const n=r+.2*s;const a=.2*Math.min(o,s);t.moveTo(e+o,r+s/2);t.quadraticCurveTo(i,n,e+a,r+s/2);t.lineTo(e+a,r+s/2-a);t.lineTo(e,r+s/2);t.lineTo(e+a,r+s/2+a);t.lineTo(e+a,r+s/2+a/2);t.quadraticCurveTo(i,n+a,e+o,r+s/2+a/2);t.closePath()}drawCallout1Path(t,e,r,o,s){const i=e+.8*o;const n=r+.8*s;const a=.2*Math.min(o,s);t.rect(e,r,.7*o,.7*s);t.moveTo(e+.6*o,r+.6*s);t.lineTo(i,n);t.lineTo(e+.5*o,r+.7*s)}drawCallout2Path(t,e,r,o,s){this.drawCallout1Path(t,e,r,o,s);const i=e+.9*o;const n=r+.9*s;t.moveTo(e+.65*o,r+.65*s);t.lineTo(i,n);t.lineTo(e+.55*o,r+.75*s)}drawCallout3Path(t,e,r,o,s){this.drawCallout2Path(t,e,r,o,s);const i=e+.7*o;const n=r+.95*s;t.moveTo(e+.7*o,r+.7*s);t.lineTo(i,n);t.lineTo(e+.6*o,r+.8*s)}drawAccentCallout1Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);t.rect(e-2,r-2,.7*o+4,.7*s+4);this.drawCallout1Path(t,e,r,o,s)}drawAccentCallout2Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);t.rect(e-2,r-2,.7*o+4,.7*s+4);this.drawCallout2Path(t,e,r,o,s)}drawAccentCallout3Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);t.rect(e-2,r-2,.7*o+4,.7*s+4);this.drawCallout3Path(t,e,r,o,s)}drawBorderCallout1Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);this.drawCallout1Path(t,e,r,o,s)}drawBorderCallout2Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);this.drawCallout2Path(t,e,r,o,s)}drawBorderCallout3Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);this.drawCallout3Path(t,e,r,o,s)}drawLightningBoltPath(t,e,r,o,s){t.moveTo(e+.3*o,r);t.lineTo(e+.7*o,r);t.lineTo(e+.4*o,r+.4*s);t.lineTo(e+.8*o,r+.4*s);t.lineTo(e+.2*o,r+s);t.lineTo(e+.5*o,r+.6*s);t.lineTo(e+.1*o,r+.6*s);t.closePath()}drawSunPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=.3*Math.min(o,s);const l=.45*Math.min(o,s);for(let e=0;e<16;e++){const r=2*e*Math.PI/16;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);const c=i+l*Math.cos(r);const h=n+l*Math.sin(r);t.moveTo(o,s);t.lineTo(c,h)}t.arc(i,n,.7*a,0,2*Math.PI)}drawMoonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);t.arc(i+.3*a,n-.3*a,.8*a,0,2*Math.PI,true)}drawCloudPath(t,e,r,o,s){const i=o;const n=s;t.moveTo(e,r+.5*n);t.bezierCurveTo(e,r+.7*n,e+.05*i,r+.85*n,e+.15*i,r+.8*n);t.bezierCurveTo(e+.25*i,r+.95*n,e+.35*i,r+.95*n,e+.45*i,r+.85*n);t.bezierCurveTo(e+.55*i,r+n,e+.65*i,r+n,e+.75*i,r+.85*n);t.bezierCurveTo(e+.85*i,r+.95*n,e+.95*i,r+.8*n,e+i,r+.65*n);t.bezierCurveTo(e+i,r+.5*n,e+.95*i,r+.35*n,e+.9*i,r+.3*n);t.bezierCurveTo(e+.95*i,r+.15*n,e+.85*i,r+.05*n,e+.75*i,r+.1*n);t.bezierCurveTo(e+.65*i,r,e+.55*i,r,e+.5*i,r+.08*n);t.bezierCurveTo(e+.45*i,r,e+.3*i,r,e+.25*i,r+.15*n);t.bezierCurveTo(e+.15*i,r+.05*n,e+.05*i,r+.2*n,e+.08*i,r+.3*n);t.bezierCurveTo(e,r+.35*n,e,r+.4*n,e,r+.5*n);t.closePath()}drawWavePath(t,e,r,o,s){const i=.3*s;const n=r+s/2;t.moveTo(e,n);t.bezierCurveTo(e+.25*o,n-i,e+.75*o,n+i,e+o,n)}drawDoubleWavePath(t,e,r,o,s){const i=.2*s;const n=r+.3*s;const a=r+.7*s;t.moveTo(e,n);t.bezierCurveTo(e+.25*o,n-i,e+.75*o,n+i,e+o,n);t.moveTo(e,a);t.bezierCurveTo(e+.25*o,a-i,e+.75*o,a+i,e+o,a)}drawSmileyFacePath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);t.arc(i-.3*a,n-.3*a,.1*a,0,2*Math.PI);t.arc(i+.3*a,n-.3*a,.1*a,0,2*Math.PI);t.arc(i,n,.5*a,0,Math.PI)}drawNoSmokingPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);t.moveTo(i-.7*a,n-.7*a);t.lineTo(i+.7*a,n+.7*a)}drawBlockArcPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;const l=.6*a;t.arc(i,n,a,0,Math.PI);t.arc(i,n,l,Math.PI,0,true);t.closePath()}drawFoldedCornerPath(t,e,r,o,s){const i=.2*Math.min(o,s);t.moveTo(e,r);t.lineTo(e+o-i,r);t.lineTo(e+o,r+i);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.closePath();t.moveTo(e+o-i,r);t.lineTo(e+o-i,r+i);t.lineTo(e+o,r+i)}drawBevelPath(t,e,r,o,s){const i=.1*Math.min(o,s);t.moveTo(e+i,r);t.lineTo(e+o-i,r);t.lineTo(e+o,r+i);t.lineTo(e+o,r+s-i);t.lineTo(e+o-i,r+s);t.lineTo(e+i,r+s);t.lineTo(e,r+s-i);t.lineTo(e,r+i);t.closePath()}drawDonutPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;const l=.4*a;t.arc(i,n,a,0,2*Math.PI);t.arc(i,n,l,0,2*Math.PI,true)}drawNoSymbolPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);t.moveTo(i-.7*a,n+.7*a);t.lineTo(i+.7*a,n-.7*a)}drawCubePath(t,e,r,o,s){const i=.3*Math.min(o,s);t.rect(e,r+i,o-i,s-i);t.moveTo(e,r+i);t.lineTo(e+i,r);t.lineTo(e+o,r);t.lineTo(e+o-i,r+i);t.closePath();t.moveTo(e+o-i,r+i);t.lineTo(e+o,r);t.lineTo(e+o,r+s-i);t.lineTo(e+o-i,r+s);t.closePath()}drawCanPath(t,e,r,o,s){const i=.15*s;t.ellipse(e+o/2,r+i/2,o/2,i/2,0,0,2*Math.PI);t.moveTo(e,r+i/2);t.lineTo(e,r+s-i/2);t.moveTo(e+o,r+i/2);t.lineTo(e+o,r+s-i/2);t.ellipse(e+o/2,r+s-i/2,o/2,i/2,0,0,2*Math.PI)}drawConePath(t,e,r,o,s){const i=.2*s;t.moveTo(e+o/2,r);t.lineTo(e,r+s-i);t.ellipse(e+o/2,r+s-i/2,o/2,i/2,0,Math.PI,0);t.lineTo(e+o/2,r);t.closePath()}drawPyramidPath(t,e,r,o,s){const i=.3*o;t.moveTo(e+o/2,r);t.lineTo(e,r+s);t.lineTo(e+o-i,r+s);t.closePath();t.moveTo(e+o/2,r);t.lineTo(e+o-i,r+s);t.lineTo(e+o,r+s-i);t.closePath();t.moveTo(e,r+s);t.lineTo(e+i,r+s-i);t.lineTo(e+o,r+s-i);t.lineTo(e+o-i,r+s)}drawPlusPath(t,e,r,o,s){const i=.2*Math.min(o,s);const n=e+o/2;const a=r+s/2;t.rect(e+i,a-i/2,o-2*i,i);t.rect(n-i/2,r+i,i,s-2*i)}drawMinusPath(t,e,r,o,s){const i=.2*Math.min(o,s);const n=r+s/2;t.rect(e+i,n-i/2,o-2*i,i)}drawMultiplyPath(t,e,r,o,s){const i=.1*Math.min(o,s);t.moveTo(e+i,r+i);t.lineTo(e+o-i,r+s-i);t.moveTo(e+o-i,r+i);t.lineTo(e+i,r+s-i)}drawDividePath(t,e,r,o,s){const i=.1*Math.min(o,s);const n=e+o/2;const a=r+s/2;const l=i;t.arc(n,a-.25*s,l,0,2*Math.PI);t.rect(e+i,a-i/2,o-2*i,i);t.arc(n,a+.25*s,l,0,2*Math.PI)}drawEqualPath(t,e,r,o,s){const i=.1*Math.min(o,s);const n=r+s/2;const a=.15*s;t.rect(e+i,n-a-i/2,o-2*i,i);t.rect(e+i,n+a-i/2,o-2*i,i)}drawNotEqualPath(t,e,r,o,s){this.drawEqualPath(t,e,r,o,s);const i=.1*Math.min(o,s);t.moveTo(e+.3*o,r+.8*s);t.lineTo(e+.7*o,r+.2*s)}drawLinePath(t,e,r,o,s){t.moveTo(e,r);t.lineTo(e+o,r+s)}drawBentConnector2Path(t,e,r,o,s){const i=e+o/2;t.moveTo(e,r+s);t.lineTo(e,r+s/2);t.lineTo(i,r+s/2);t.lineTo(i,r);t.lineTo(e+o,r)}drawBentConnector3Path(t,e,r,o,s){const i=e+o/2;const n=r+s/2;t.moveTo(e,r+s);t.lineTo(e,n);t.lineTo(i,n);t.lineTo(i,r);t.lineTo(e+o,r)}drawBentConnector4Path(t,e,r,o,s){const i=e+.33*o;const n=e+.67*o;const a=r+s/2;t.moveTo(e,r+s);t.lineTo(e,a);t.lineTo(i,a);t.lineTo(i,r);t.lineTo(n,r);t.lineTo(n,a);t.lineTo(e+o,a);t.lineTo(e+o,r+s)}drawBentConnector5Path(t,e,r,o,s){const i=e+.25*o;const n=e+.5*o;const a=e+.75*o;const l=r+.33*s;const c=r+.67*s;t.moveTo(e,r+s);t.lineTo(e,c);t.lineTo(i,c);t.lineTo(i,l);t.lineTo(n,l);t.lineTo(n,r);t.lineTo(a,r);t.lineTo(a,l);t.lineTo(e+o,l);t.lineTo(e+o,r+s)}drawCurvedConnector2Path(t,e,r,o,s){t.moveTo(e,r+s);t.quadraticCurveTo(e+o/2,r,e+o,r)}drawCurvedConnector3Path(t,e,r,o,s){t.moveTo(e,r+s);t.bezierCurveTo(e,r+s/2,e+o/2,r+s/2,e+o,r)}drawCurvedConnector4Path(t,e,r,o,s){t.moveTo(e,r+s);t.bezierCurveTo(e+.25*o,r+.75*s,e+.75*o,r+.25*s,e+o,r)}drawCurvedConnector5Path(t,e,r,o,s){t.moveTo(e,r+s);t.bezierCurveTo(e+.2*o,r+.8*s,e+.4*o,r+.6*s,e+.5*o,r+.5*s);t.bezierCurveTo(e+.6*o,r+.4*s,e+.8*o,r+.2*s,e+o,r)}drawCustomGeometry(t,e,r,o,s,i,n,a){try{const l=t.pathLst||t.pathList;if(!t||!l||0===l.length)return;const c=this.context;c.save();let h,u;if(t.coordSize?.width&&t.coordSize?.height){h=t.coordSize.width;u=t.coordSize.height}else{let t=1/0,e=-1/0,r=1/0,o=-1/0;l.forEach(s=>{if(s.commands)s.commands.forEach(s=>{if(void 0!==s.x){t=Math.min(t,s.x);e=Math.max(e,s.x)}if(void 0!==s.y){r=Math.min(r,s.y);o=Math.max(o,s.y)}if(void 0!==s.x1){t=Math.min(t,s.x1);e=Math.max(e,s.x1);r=Math.min(r,s.y1);o=Math.max(o,s.y1)}if(void 0!==s.x2){t=Math.min(t,s.x2);e=Math.max(e,s.x2);r=Math.min(r,s.y2);o=Math.max(o,s.y2)}})});h=e-t;u=o-r;if(0===h)h=100;if(0===u)u=100}c.restore();l.forEach((t,l)=>{let c=1/0,f=1/0;t.commands.forEach(t=>{if(void 0!==t.x){c=Math.min(c,t.x);f=Math.min(f,t.y)}if(void 0!==t.x1){c=Math.min(c,t.x1);f=Math.min(f,t.y1)}if(void 0!==t.x2){c=Math.min(c,t.x2);f=Math.min(f,t.y2)}if(void 0!==t.x3){c=Math.min(c,t.x3);f=Math.min(f,t.y3)}});this.currentShapeBounds={x:e,y:r,w:o,h:s};this.drawGeometryPathDirectly(t,i,n,a,e,r,o,s,h,u,c,f)})}catch(t){const e=this.context;e.restore()}}drawGeometryPath(t,e,r,o){if(!t||!t.commands||0===t.commands.length)return;const s=this.context;s.beginPath();let i=false;t.commands.forEach((t,e)=>{switch(t.type){case"moveTo":s.moveTo(t.x,t.y);break;case"lineTo":s.lineTo(t.x,t.y);i=true;break;case"curveTo":case"cubicBezTo":const e=void 0!==t.x?t.x:t.x3;const r=void 0!==t.y?t.y:t.y3;if(void 0!==e&&void 0!==r){s.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,e,r);i=true}break;case"quadTo":case"quadBezTo":s.quadraticCurveTo(t.x1,t.y1,t.x,t.y);i=true;break;case"arcTo":s.arcTo(t.x1,t.y1,t.x,t.y,t.radius||0);i=true;break;case"close":s.closePath()}});if(r&&o>0){this.setStrokeStyle(r,o);s.stroke()}if(e&&(!r||0===o)){this.setFillStyle(e);s.fill()}s.restore()}setStrokeStyle(t,e){const r=this.context;r.strokeStyle=t;r.lineWidth=CoordinateTransform.mmToPixels(e||1);r.lineCap="round";r.lineJoin="round"}setFillStyle(t){const e=this.context;e.fillStyle=t}drawGeometryPathDirectly(t,e,r,o,s,i,n,a,l,c,h,u){if(!t||!t.commands||0===t.commands.length)return;const f=this.context;const d=n/l;const p=a/c;f.save();f.beginPath();const g=t=>s+(t-h)*d;const m=t=>i+(t-u)*p;let y=false;let b=0,x=0;t.commands.forEach((t,e)=>{switch(t.type){case"moveTo":const e=g(t.x);const r=m(t.y);f.moveTo(e,r);b=e;x=r;break;case"lineTo":const o=g(t.x);const s=m(t.y);f.lineTo(o,s);b=o;x=s;y=true;break;case"curveTo":case"cubicBezTo":const i=void 0!==t.x3?t.x3:t.x;const n=void 0!==t.y3?t.y3:t.y;if(void 0!==i&&void 0!==n){const e=g(t.x1);const r=m(t.y1);const o=g(t.x2);const s=m(t.y2);const a=g(i);const l=m(n);if(this.isStraightLine(b,x,e,r,o,s,a,l))f.lineTo(a,l);else f.bezierCurveTo(e,r,o,s,a,l);b=a;x=l;y=true}break;case"quadTo":case"quadBezTo":{const e=g(t.x1);const r=m(t.y1);const o=g(t.x);const s=m(t.y);f.quadraticCurveTo(e,r,o,s);b=o;x=s;y=true;break}case"close":f.closePath()}});const S=t.commands.some(t=>"close"===t.type);const w=S&&e&&"none"!==e;if(w)if(y){if("object"===typeof e&&void 0!==e.r)f.fillStyle=`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a/255})`;else if("object"===typeof e&&e.type)if("linear"===e.type&&e.stops){const t=this.getCanvasBounds(f);const r=this.createCanvasGradient(f,t,e);if(r)f.fillStyle=r;else{const t=e.stops[0]?.color;if(t)f.fillStyle=this.colorToRgb(t);else return}}else return;else if("string"===typeof e&&"none"!==e&&"null"!==e)f.fillStyle=e;f.fill()}else{if("object"===typeof e&&void 0!==e.r)f.fillStyle=`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a/255})`;else if("string"===typeof e&&"none"!==e&&"null"!==e)f.fillStyle=e;f.fillRect(s,i,n,a)}if(r&&"none"!==r&&y){const t=CoordinateTransform.mmToPixels(o>0?o:1);const e=1280*720;const s=n*a;const i=Math.sqrt(s/e);const l=Math.max(t*i,.5);if("object"===typeof r&&void 0!==r.r)f.strokeStyle=`rgba(${r.r}, ${r.g}, ${r.b}, ${r.a/255})`;else f.strokeStyle=r;f.lineWidth=l;f.lineCap="square";f.lineJoin="miter";f.stroke()}f.restore()}isStraightLine(t,e,r,o,s,i,n,a){const l=n-t;const c=a-e;if(Math.abs(l)<.1&&Math.abs(c)<.1)return true;const h=2;const u=t+.33*l;const f=e+.33*c;const d=t+.67*l;const p=e+.67*c;const g=Math.sqrt(Math.pow(r-u,2)+Math.pow(o-f,2));const m=Math.sqrt(Math.pow(s-d,2)+Math.pow(i-p,2));return g{this.graphicsEngine.drawLineWithArrows(t,e,r,o,s,i,n)};this.graphics.applyStrokeInfo=t=>{if("function"===typeof this.graphicsEngine.applyStrokeInfo)this.graphicsEngine.applyStrokeInfo(t)}}}catch(t){}}let r;let o;const s="function"===typeof t.getBoundingClientRect?t.getBoundingClientRect():{width:0,height:0};const i=parseFloat(t.style.width);const n=parseFloat(t.style.height);if(i>0&&n>0){r=i;o=n}else if(s.width>0&&s.height>0){r=s.width;o=s.height}else if(t.style.width&&t.style.height){r=i;o=n}else{const e="undefined"!==typeof window&&window.devicePixelRatio?window.devicePixelRatio:1;r=t.width/e;o=t.height/e}const a=this.processor&&this.processor.renderContext&&this.processor.renderContext.pixelRatio||"undefined"!==typeof window&&window.devicePixelRatio||1;const l=Math.max(1,Math.round(r*a));const c=Math.max(1,Math.round(o*a));if(t.width!==l||t.height!==c){t.width=l;t.height=c}if(!t.style.width)t.style.width=`${r}px`;if(!t.style.height)t.style.height=`${o}px`;const h=t.getContext("2d");if(h){h.setTransform(1,0,0,1,0,0);h.scale(a,a)}if(this.graphics&&"function"===typeof this.graphics.init&&h)this.graphics.init(h,r,o,25.4*r/96,25.4*o/96)}colorToRgb(t){if(this.graphics&&"function"===typeof this.graphics.colorToRgb)return this.graphics.colorToRgb(t);if(this.graphicsEngine&&"function"===typeof this.graphicsEngine.colorToRgb)return this.graphicsEngine.colorToRgb(t);if("string"===typeof t)return t;if(t&&"object"===typeof t){const e=void 0!==t.r?t.r:void 0!==t.R?t.R:0;const r=void 0!==t.g?t.g:void 0!==t.G?t.G:0;const o=void 0!==t.b?t.b:void 0!==t.B?t.B:0;const s=void 0!==t.a?t.a:void 0!==t.A?t.A:255;if(void 0!==s&&255!==s)return`rgba(${e}, ${r}, ${o}, ${s/255})`;return`rgb(${e}, ${r}, ${o})`}return"rgb(0, 0, 0)"}async drawSlide(slide,t){if(!this.graphics)return;this.currentSlide=slide;this.currentSlideIndex=t;this.graphics.clear();await this.drawSlideContent(slide)}async drawSlideContent(slide){if(slide.layout);this.setupSlideCoordinateSystem();try{const t=this.graphics?.context;const e=this.coordinateSystem;if(t&&e){const r=Math.round(e.offsetX);const o=Math.round(e.offsetY);const s=Math.round(e.scaledWidth);const i=Math.round(e.scaledHeight);t.save();t.beginPath();t.rect(r,o,s,i);t.clip();this._slideClipApplied=true}}catch(t){this._slideClipApplied=false}this.drawSlideBackground(slide);if(false!==slide.showMasterShapes&&slide.layout&&slide.layout.master)await this.drawMasterElements(slide.layout.master);if(slide.layout)await this.drawLayoutElements(slide.layout);if(slide.commonSlideData&&slide.commonSlideData.shapeTree){const t=slide.commonSlideData.shapeTree;const e=this.sortShapesByRenderOrder(t);const r=this.currentLayer;this.currentLayer="slide";for(let t=0;t{const o=e.order||e.zOrder||e.index||0;const s=r.order||r.zOrder||r.index||0;if(o!==s)return o-s;const i=t.indexOf(e);const n=t.indexOf(r);return i-n});return e}drawSlideBackground(slide){if(!this.graphics||!this.graphics.context)return;const t=this.graphics.context;let e=null;if(slide.backgroundFill)e=this.getBackgroundColor(slide.backgroundFill);else if(slide.layout&&slide.layout.commonSlideData&&slide.layout.commonSlideData.backgroundFill)e=this.getBackgroundColor(slide.layout.commonSlideData.backgroundFill);else if(slide.layout&&slide.layout.cSld&&slide.layout.cSld.bg)e=this.getBackgroundColor(slide.layout.cSld.bg);else if(slide.layout&&slide.layout.master&&slide.layout.master.commonSlideData&&slide.layout.master.commonSlideData.backgroundFill)e=this.getBackgroundColor(slide.layout.master.commonSlideData.backgroundFill);else if(slide.layout&&slide.layout.master&&slide.layout.master.theme){const theme=slide.layout.master.theme;if(theme.colors&&theme.colors.bg1)e=theme.colors.bg1;else if(theme.colors&&theme.colors.bg2)e=theme.colors.bg2}if(this.coordinateSystem){const{scale:r,offsetX:o,offsetY:s}=this.coordinateSystem;const i=this.coordinateSystem.slideWidthPx;const n=this.coordinateSystem.slideHeightPx;const a=Math.round(i*r);const l=Math.round(n*r);const c=Math.round(o);const h=Math.round(s);t.save();if(e&&"image"===e.type&&e.imageData?.relationshipId){const r=e.imageData.resolvedCacheKey||e.imageData.relationshipId;const o=this.processor?.imageCache?.get(r);if(o&&o.image){t.drawImage(o.image,c,h,a,l);t.restore();return}t.fillStyle="#ffffff"}else if(e&&"gradient"===e.type&&e.gradient){const r=e.gradient;const o=r.stops||[];let s;if("radial"===r.type){const e=c+a/2;const r=h+l/2;const o=Math.max(a,l)/2;s=t.createRadialGradient(e,r,0,e,r,o)}else{const e=(r.angle||0)*Math.PI/180;const o=Math.cos(e),i=Math.sin(e);const n=c+a/2-o*a/2;const u=h+l/2-i*l/2;const f=c+a/2+o*a/2;const d=h+l/2+i*l/2;s=t.createLinearGradient(n,u,f,d)}for(const t of o){const e=void 0!==t.position?t.position/1e5:0;const r=this.parseColorToHex(t.color)||"#ffffff";s.addColorStop(Math.min(1,Math.max(0,e)),r)}t.fillStyle=s}else t.fillStyle=("string"===typeof e?e:null)||"#ffffff";t.fillRect(c,h,a,l);t.restore()}else{t.save();if(e&&"image"===e.type&&e.imageData?.relationshipId){const r=e.imageData.resolvedCacheKey||e.imageData.relationshipId;const o=this.processor?.imageCache?.get(r);if(o&&o.image){t.drawImage(o.image,0,0,this.canvas.width,this.canvas.height);t.restore();return}t.fillStyle="#ffffff"}else if(e&&"gradient"===e.type&&e.gradient){const r=e.gradient;const o=r.stops||[];const s=this.canvas.width,i=this.canvas.height;let n;if("radial"===r.type)n=t.createRadialGradient(s/2,i/2,0,s/2,i/2,Math.max(s,i)/2);else{const e=(r.angle||0)*Math.PI/180;const o=Math.cos(e),a=Math.sin(e);n=t.createLinearGradient(s/2-o*s/2,i/2-a*i/2,s/2+o*s/2,i/2+a*i/2)}for(const t of o){const e=void 0!==t.position?t.position/1e5:0;const r=this.parseColorToHex(t.color)||"#ffffff";n.addColorStop(Math.min(1,Math.max(0,e)),r)}t.fillStyle=n}else t.fillStyle=("string"===typeof e?e:null)||"#ffffff";t.fillRect(0,0,this.canvas.width,this.canvas.height);t.restore()}}async drawMasterElements(t){if(!t||!t.commonSlideData||!t.commonSlideData.shapeTree)return;const e=t.commonSlideData.shapeTree;const r=this.sortShapesByRenderOrder(e);const o=this.currentLayer;this.currentLayer="master";try{for(let t=0;t{});const r=this.sortShapesByRenderOrder(e);const o=this.currentLayer;this.currentLayer="layout";try{for(let t=0;tt.runs&&t.runs.some(t=>(t.text||"").trim().length>0||t.fieldType));if(e)return true}if(t.graphicData&&t.graphicData.tableXml)return true;return false}processPlaceholderShape(t,slide){if(!t.isPlaceholder||!t.placeholder)return t;const e=t.placeholder;let r=null;let o=null;if(slide.layout&&slide.layout.commonSlideData&&slide.layout.commonSlideData.shapeTree)o=this.findMatchingPlaceholder(slide.layout.commonSlideData.shapeTree,e);if(slide.layout&&slide.layout.master&&slide.layout.master.commonSlideData&&slide.layout.master.commonSlideData.shapeTree)r=this.findMatchingPlaceholder(slide.layout.master.commonSlideData.shapeTree,e);if(o)this.applyPlaceholderStyling(t,o);else if(r)this.applyPlaceholderStyling(t,r);return t}findMatchingPlaceholder(t,e){for(const r of t)if(r.isPlaceholder&&r.placeholder){const t=r.placeholder;if(t.type===e.type&&t.idx===e.idx)return r;if(t.type===e.type&&!t.idx)return r}return null}applyPlaceholderStyling(t,e){if(e.textBody){if(!t.textBody)t.textBody={paragraphs:[]};if(e.textBody.bodyProperties&&!t.textBody.bodyProperties)t.textBody.bodyProperties=JSON.parse(JSON.stringify(e.textBody.bodyProperties));if(e.textBody.lstStyle&&!t.textBody.lstStyle)t.textBody.lstStyle=JSON.parse(JSON.stringify(e.textBody.lstStyle))}if(e.fill&&!t.fill)t.fill=e.fill;if(e.stroke&&!t.stroke)t.stroke=e.stroke;if(e.geometry&&!t.geometry)t.geometry=e.geometry;if(e.style&&!t.style)t.style=e.style}shouldRenderText(t){try{if(this.currentLayer&&"slide"!==this.currentLayer&&this.isPlaceholderShape(t))return false;if(this.isPlaceholderShape(t)){const e=!!(t.textBody&&Array.isArray(t.textBody.paragraphs)&&t.textBody.paragraphs.some(t=>Array.isArray(t.runs)&&t.runs.some(t=>(t.text||"").trim().length>0)));return e}}catch(t){}return true}getBackgroundColor(t){if(!t){const t=this.resolveInheritedBackgroundColor();if(t)return t;return null}if("solid"===t.type&&t.color){const e=this.parseColorToHex(t.color);return e}if(t.fill&&"solid"===t.fill.type&&t.fill.color){const e=this.parseColorToHex(t.fill.color);return e}if("bgPr"===t.type&&t.fill){if("solid"===t.fill.type&&t.fill.color){const e=this.parseColorToHex(t.fill.color);return e}if("gradient"===t.fill.type)if(t.fill.gradient&&t.fill.gradient.stops&&t.fill.gradient.stops.length>0)return{type:"gradient",gradient:t.fill.gradient};if("image"===t.fill.type&&t.fill.imageData?.relationshipId)return{type:"image",imageData:t.fill.imageData}}if("bgRef"===t.type){const e=t.idx;if(void 0!==e){if(e>1e3){const t=e-1e3;if(this.currentSlide&&this.currentSlide.theme&&this.currentSlide.theme.colors){const theme=this.currentSlide.theme;const t=this.parseColorToHex(theme.colors.bg2)||this.parseColorToHex(theme.colors.bg1)||this.parseColorToHex(theme.colors.lt1);return t}}else{const t={0:"bg1",1:"tx1",2:"bg2",3:"tx2"};const r=t[e.toString()];if(r&&this.currentSlide&&this.currentSlide.theme&&this.currentSlide.theme.colors){const t=this.parseColorToHex(this.currentSlide.theme.colors[r]);return t}}return null}return null}return null}resolveInheritedBackgroundColor(){try{if(!this.currentSlide)return null;if(this.currentSlide.layout&&this.currentSlide.layout.backgroundFill){const t=this.getBackgroundColorFromFill(this.currentSlide.layout.backgroundFill);if(t)return t}if(this.currentSlide.layout&&this.currentSlide.layout.master&&this.currentSlide.layout.master.backgroundFill){const t=this.getBackgroundColorFromFill(this.currentSlide.layout.master.backgroundFill);if(t)return t}if(this.currentSlide.theme&&this.currentSlide.theme.colors){const t=this.parseColorToHex(this.currentSlide.theme.colors.bg1)||this.parseColorToHex(this.currentSlide.theme.colors.lt1)||this.parseColorToHex(this.currentSlide.theme.colors.bg2);if(t)return t}return null}catch(t){return null}}getBackgroundColorFromFill(t){if(!t)return null;if("solid"===t.type&&t.color)return this.parseColorToHex(t.color);if(t.fill&&"solid"===t.fill.type&&t.fill.color)return this.parseColorToHex(t.fill.color);if("bgPr"===t.type&&t.fill)if("solid"===t.fill.type&&t.fill.color)return this.parseColorToHex(t.fill.color);if("bgRef"===t.type){const e=t.idx;if(void 0!==e){const t={0:"#ffffff",1:"#000000",2:"#f5f5f5",3:"#404040",1e3:"#ffffff"};return t[e.toString()]||null}}return null}parseColorToHex(t){if(!t)return"#ffffff";if("string"===typeof t)return t.startsWith("#")?t:`#${t}`;if(t.scheme){const e={bg1:"#ffffff",tx1:"#000000",bg2:"#f8f8f8",tx2:"#404040",accent1:"#4f81bd",accent2:"#c0504d",accent3:"#9bbb59",accent4:"#8064a2",accent5:"#4bacc6",accent6:"#f79646",lt1:"#ffffff",dk1:"#000000",lt2:"#f0f0f0",dk2:"#404040"};let r=e[t.scheme];if(r){r=this.applyColorModifications(r,t);return r}}if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b){if(void 0!==t.a&&t.a<255)return`rgba(${t.r}, ${t.g}, ${t.b}, ${(t.a/255).toFixed(4)})`;const e=`#${t.r.toString(16).padStart(2,"0")}${t.g.toString(16).padStart(2,"0")}${t.b.toString(16).padStart(2,"0")}`;return e}return"#ffffff"}applyColorModificationsLegacy(t,e){if(!e||!e.tint&&!e.shade&&!e.lumMod&&!e.lumOff)return t;const r=parseInt(t.substr(1,2),16);const o=parseInt(t.substr(3,2),16);const s=parseInt(t.substr(5,2),16);let i=r,n=o,a=s;if(void 0!==e.tint){const t=e.tint/1e5;i=Math.round(r+(255-r)*t);n=Math.round(o+(255-o)*t);a=Math.round(s+(255-s)*t)}if(void 0!==e.shade){const t=e.shade/1e5;i=Math.round(r*(1-t));n=Math.round(o*(1-t));a=Math.round(s*(1-t))}if(void 0!==e.lumMod){const t=e.lumMod/1e5;i=Math.round(r*t);n=Math.round(o*t);a=Math.round(s*t)}if(void 0!==e.lumOff){const t=e.lumOff/1e5*255;i=Math.round(Math.min(255,r+t));n=Math.round(Math.min(255,o+t));a=Math.round(Math.min(255,s+t))}i=Math.max(0,Math.min(255,i));n=Math.max(0,Math.min(255,n));a=Math.max(0,Math.min(255,a));const l=`#${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`;return l}setupSlideCoordinateSystem(){if(this.processor&&this.processor.calculateCanvasRect){const t=this.processor.getSlideDimensions();const e=this.processor.calculateCanvasRect(this.canvas,t);this.coordinateSystem={slideWidthEMU:t.cx,slideHeightEMU:t.cy,slideWidthPx:e.slideWidthPx,slideHeightPx:e.slideHeightPx,scale:e.scale,offsetX:e.offsetX,offsetY:e.offsetY,scaledWidth:e.scaledWidth,scaledHeight:e.scaledHeight}}else{const t=this.processor.getSlideDimensions();const e=t.cx;const r=t.cy;const o=e/914400*96;const s=r/914400*96;let i;let n;const a="function"===typeof this.canvas.getBoundingClientRect?this.canvas.getBoundingClientRect():{width:0,height:0};if(a.width>0&&a.height>0){i=a.width;n=a.height}else if(this.canvas.style.width&&this.canvas.style.height){i=parseFloat(this.canvas.style.width);n=parseFloat(this.canvas.style.height)}else{const t="undefined"!==typeof window&&window.devicePixelRatio?window.devicePixelRatio:1;i=this.canvas.width/t;n=this.canvas.height/t}const l=i/o;const c=n/s;const h=Math.min(l,c);let u=o*h;let f=s*h;let d=(i-u)/2;let p=(n-f)/2;u=Math.round(u);f=Math.round(f);d=Math.round(d);p=Math.round(p);this.coordinateSystem={slideWidthEMU:e,slideHeightEMU:r,slideWidthPx:o,slideHeightPx:s,scale:h,offsetX:d,offsetY:p,scaledWidth:u,scaledHeight:f,canvasWidth:i,canvasHeight:n}}}async drawShapeEnhanced(t,e){try{if(this.processor&&"function"===typeof this.processor.applyPropertyInheritance)this.processor.applyPropertyInheritance(t,this.currentSlide)}catch(t){}const r=this.getShapeBounds(t);if(r&&(0===r.h||!isFinite(r.h)||r.h<1)&&t&&t.textBody&&t.textBody.paragraphs&&t.textBody.paragraphs.length>0&&!this.isLineLikeShape(t))try{const e=this.estimateTextBoxHeightPx(t,r.w);if(e&&e>0)r.h=Math.ceil(e)}catch(t){}if(!this.graphics||!t)return;try{const e=this.isLineLikeShape(t);if(!r||r.w<=0&&r.h<=0||!e&&(r.w<=0||r.h<=0))return;switch(t.type){case"sp":this.drawRegularShape(t,r);break;case"pic":this.drawPictureShape(t,r);break;case"grpSp":this.drawGroupShape(t,r);break;case"cxnSp":this.drawConnectorShape(t,r);break;case"graphicFrame":await this.drawGraphicFrame(t,r);break;default:this.drawDefaultShape(t,r)}}catch(t){}}drawShapeGeometry(t,e){if(!e||e.w<=0||e.h<=0)return;const r=this.getShapeFillColor(t);const o=this.getShapeStrokeColor(t);const s=this.getShapeLineWidth(t);if(r){const t=this.parseColor(r);this.graphics.b_color1(t.r,t.g,t.b,t.a)}if(o){const t=this.parseColor(o);this.graphics.p_color(t.r,t.g,t.b,t.a);this.graphics.p_width(s)}switch(t.type){case"sp":case"shape":this.drawRegularShape(t,e);break;case"pic":this.drawPictureShape(t,e);break;case"grpSp":this.drawGroupShape(t,e);break;default:this.drawDefaultShape(t,e)}}drawRegularShape(t,e){if(!e)return;const r=this.isLineLikeShape(t);if(r){if(e.w<=0&&e.h<=0)return}else if(e.w<=0||e.h<=0)return;if(!this.graphics||!this.graphics.context)return;const o=this.graphics.context;o.save();const s=t.properties?.transform;if(s&&s.rotation&&0!==s.rotation){const t=e.x+e.w/2;const r=e.y+e.h/2;o.translate(t,r);o.rotate(s.rotation*Math.PI/180);o.translate(-t,-r)}const i=this.getShapeFillColor(t);const n=this.getShapeStrokeColor(t);const a=this.getShapeLineWidth(t);const l=this.getShapeStrokeInfo(t);if(t.properties&&t.properties.effectLst)this.applyEffectsToCanvas(o,t.properties.effectLst);let c=null;if(this.processor&&this.processor.getShapePresetGeometry)c=this.processor.getShapePresetGeometry(t,this.processor.currentSlide);else c=this.getShapePreset(t);if("line"===c||this.isLineLikeShape(t)){this.drawEngineLine(e,t);this.resetEffectsOnContext(o);if(t.textBody&&t.textBody.paragraphs&&this.shouldRenderText(t)){const r=this.estimateTextBoxHeightPx(t,e.w)||24;const o=t.textBody.paragraphs[0];const s=o?.properties?.align||o?.properties?.alignment||o?.paragraphProperties?.align||o?.pPr?.algn||"l";let i;if("r"===s||"right"===s)i=e.x-e.w;else if("ctr"===s||"center"===s)i=e.x-e.w/2;else i=e.x;const n={x:i,y:e.y-r/2,w:e.w,h:r};this.setCurrentRenderingShape(t);this.drawShapeText(t,n)}o.restore();return}const h=s&&(s.flipH||s.flipV);if(h){o.save();const t=e.x+e.w/2;const r=e.y+e.h/2;o.translate(t,r);o.scale(s.flipH?-1:1,s.flipV?-1:1);o.translate(-t,-r)}if(t.geometry&&"custom"===t.geometry.type)try{this.currentShapeBounds=e;if(t.properties&&t.properties.effectLst)this.applyEffectsToCanvas(o,t.properties.effectLst);this.graphics.drawCustomGeometry(t.geometry,e.x,e.y,e.w,e.h,i,n,a);this.resetEffectsOnContext(o)}catch(t){this.graphics.drawPresetGeometry("rect",e.x,e.y,e.w,e.h,i,n,a,l)}else if(this.graphics.drawPresetGeometry&&c){if(t.properties&&t.properties.effectLst)this.applyEffectsToCanvas(o,t.properties.effectLst);const r=t.geometry?.adjustments||t.properties?.geometry?.adjustments||{};this.graphics.drawPresetGeometry(c,e.x,e.y,e.w,e.h,i,n,a,l,r);this.resetEffectsOnContext(o)}else{const t=n&&a>2;const r=t||n&&!i;if(n&&r){o.strokeStyle=this.graphics.colorToRgb(n);o.lineWidth=CoordinateTransform.mmToPixels(a);if(l)this.applyStrokeStyle(o,l,CoordinateTransform.mmToPixels(a));o.strokeRect(e.x,e.y,e.w,e.h)}if(!r){if(i&&"linear"===i.type)this.drawGradientFill(o,e,i);else if(i){o.fillStyle=this.graphics.colorToRgb(i);o.fillRect(e.x,e.y,e.w,e.h)}if(n){o.strokeStyle=this.graphics.colorToRgb(n);o.lineWidth=CoordinateTransform.mmToPixels(a);if(l)this.applyStrokeStyle(o,l,CoordinateTransform.mmToPixels(a));o.strokeRect(e.x,e.y,e.w,e.h)}}}if(h)o.restore();if(t.textBody&&t.textBody.paragraphs&&this.shouldRenderText(t)){this.setCurrentRenderingShape(t);this.drawShapeText(t,e)}this.resetEffectsOnContext(o);o.restore()}isLineLikeShape(t){const e=t&&(t.geometry?.preset||t.properties?.geometry?.preset||this.getShapePreset(t))||null;const r="string"===typeof e?e.toLowerCase():"";if("line"===r||r.includes("connector"))return true;if(t&&("cxnSp"===t.type||"connector"===t.type))return true;return false}drawEngineLine(t,e){const r=this.getShapeStrokeColor(e);const o=this.getShapeLineWidth(e)||1;const s=this.getShapeStrokeInfo(e);const{x1:i,y1:n,x2:a,y2:l}=this._computeConnectorEndpoints(t,e);if(this.graphics&&"function"===typeof this.graphics.drawLineWithArrows){const t=r||{r:0,g:0,b:0,a:255};const e=o&&o>0?o:.75;this.graphics.drawLineWithArrows(i,n,a,l,t,e,s)}else if(this.graphicsEngine&&"function"===typeof this.graphicsEngine.drawLineWithArrows){const t=r||{r:0,g:0,b:0,a:255};const e=o&&o>0?o:.75;this.graphicsEngine.drawLineWithArrows(i,n,a,l,t,e,s)}else if(this.graphics&&"function"===typeof this.graphics.drawLine){const t=r||{r:0,g:0,b:0,a:255};const e=o&&o>0?o:.75;this.graphics.drawLine(i,n,a,l,t,e)}else if(this.graphics&&this.graphics.context){const t=this.graphics.context;t.save();t.beginPath();t.moveTo(i,n);t.lineTo(a,l);if(r){t.strokeStyle=this.graphics.colorToRgb(r);const e=this.graphics&&this.graphics.CoordinateTransform?this.graphics.CoordinateTransform.mmToPixels(o):CoordinateTransform.mmToPixels(o);t.lineWidth=Math.max(e,1);try{this.applyStrokeStyle(t,s,t.lineWidth)}catch(t){}t.stroke()}t.restore()}}_computeConnectorEndpoints(t,e){const r=Math.max(0,t.w);const o=Math.max(0,t.h);const s=t.x+r/2;const i=t.y+o/2;let n,a,l,c;const h=e&&(e.geometry||e.properties?.geometry)||null;const u=h&&(h.pathList||h.pathLst);if(Array.isArray(u)&&u.length>0){const e=u[0];const s=e.commands||[];let i=null;let f=null;for(let t=0;t0){const t=s[0];if(null!=t.x&&null!=t.y)i={x:t.x,y:t.y}}if(!f&&i)f={...i};if(i&&f){const s=e.w||h.pathW||100;const u=e.h||h.pathH||100;const d=0===s?1:r/s;const p=0===u?1:o/u;n=t.x+i.x*d;a=t.y+i.y*p;l=t.x+f.x*d;c=t.y+f.y*p}}if(void 0===n){n=t.x;a=t.y;l=t.x+r;c=t.y+o;const s=e&&(e.spPr?.xfrm||e.transform);const i=s&&(void 0!==s.cy?s.cy:s.height);if(0===i){a=t.y+o/2;c=a}}const f=!!(e&&e.transform&&e.transform.flipH);const d=!!(e&&e.transform&&e.transform.flipV);if(f){n=s-(n-s);l=s-(l-s)}if(d){a=i-(a-i);c=i-(c-i)}const p=e&&e.transform&&(e.transform.rot||e.transform.rotation)||0;if(p){const t=p*Math.PI/180;const e=Math.cos(t);const r=Math.sin(t);const o=(t,o)=>({x:s+(t-s)*e-(o-i)*r,y:i+(t-s)*r+(o-i)*e});const h=o(n,a);const u=o(l,c);n=h.x;a=h.y;l=u.x;c=u.y}return{x1:n,y1:a,x2:l,y2:c}}drawLinePath(t,e,r,o,s){if(this.graphics&&"function"===typeof this.graphics.drawLineWithArrows){const t=this.getShapeStrokeColor(this.getCurrentShape());const i=this.getShapeLineWidth(this.getCurrentShape())||1;const n=this.getShapeStrokeInfo(this.getCurrentShape());const a=e;const l=r;const c=e+o;const h=r+s;this.graphics.drawLineWithArrows(a,l,c,h,t,i,n);return}t.moveTo(e,r+s/2);t.lineTo(e+o,r+s/2)}drawLineWithArrows(t,e,r,o,s,i=1,n=null){const a=this._context;if(!a)return;a.save();a.beginPath();a.moveTo(t,e);a.lineTo(r,o);const l=this.colorToRgb(s)||"rgba(0,0,0,1)";const c=Math.max(CoordinateTransform.mmToPixels(i||1),1);a.strokeStyle=l;a.lineWidth=c;if(n)try{this.applyStrokeStyle(a,n,c)}catch(t){}a.stroke();const h=t=>{if("number"===typeof t)return t;const e=(t||"").toString();if("lg"===e||"large"===e)return 2;if("med"===e||"medium"===e)return 1.5;return 1};const u=n&&n.tailEnd;const f=n&&n.headEnd;if(u||f){const s=Math.atan2(o-e,r-t);const i=a.getTransform();const n=Math.sqrt(i.a*i.a+i.b*i.b);const d=Math.max(4,10*n);const p=Math.max(2.5,6*n);const g=Math.max(d,8*c);const m=Math.max(p,3*c);const y=(t,e,r,o)=>{if(!o)return;const s=g*(o.lengthScale||h(o.len));const i=m*(o.widthScale||h(o.w));const n=(o.type||o.val||"arrow").toString();const u=i/2;a.save();a.translate(t,e);a.rotate(r);a.beginPath();if("open"===n){a.moveTo(0,0);a.lineTo(-s,-u);a.moveTo(0,0);a.lineTo(-s,u);a.strokeStyle=l;a.lineWidth=Math.max(1,c);a.stroke()}else if("stealth"===n){a.moveTo(0,0);a.lineTo(-s,-.6*u);a.lineTo(-s,.6*u);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(1,.5*c);a.stroke()}else if("diamond"===n){a.moveTo(0,0);a.lineTo(-s/2,-u);a.lineTo(-s,0);a.lineTo(-s/2,u);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(1,.5*c);a.stroke()}else if("oval"===n){a.ellipse(-s/2,0,s/2,u,0,0,2*Math.PI);a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(1,.5*c);a.stroke()}else{a.moveTo(0,0);a.lineTo(-s,-u);a.lineTo(-s,u);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(1,.5*c);a.stroke()}a.restore()};if(hasStart)y(t,e,s+Math.PI,u);if(hasEnd)y(r,o,s,f)}a.restore()}drawGradientFill(t,e,r){if(!r||!r.stops||0===r.stops.length)return;let o;if("linear"===r.type){const s=r.angle||0;const i=s*Math.PI/180;const n=e.x+e.w/2-Math.cos(i)*e.w/2;const a=e.y+e.h/2-Math.sin(i)*e.h/2;const l=e.x+e.w/2+Math.cos(i)*e.w/2;const c=e.y+e.h/2+Math.sin(i)*e.h/2;o=t.createLinearGradient(n,a,l,c)}else{const r=e.x+e.w/2;const s=e.y+e.h/2;const i=Math.max(e.w,e.h)/2;o=t.createRadialGradient(r,s,0,r,s,i)}for(const t of r.stops)o.addColorStop(t.position,this.graphics.colorToRgb(t.color));t.fillStyle=o;t.fillRect(e.x,e.y,e.w,e.h)}applyStrokeStyle(t,e,r){if(!t||!e)return;if(e.cap)switch(e.cap){case"rnd":t.lineCap="round";break;case"sq":t.lineCap="square";break;default:t.lineCap="butt"}if(e.join)switch(e.join){case"round":t.lineJoin="round";break;case"bevel":t.lineJoin="bevel";break;default:t.lineJoin="miter"}if(e.dashArray&&e.dashArray.length>0){const o=e.dashArray.map(t=>t*r);t.setLineDash(o)}else t.setLineDash([])}getShapePreset(t){if(t.geometry&&t.geometry.preset)return t.geometry.preset;if(t.properties&&t.properties.geometry&&t.properties.geometry.preset)return t.properties.geometry.preset;if(t.spPr&&t.spPr.geometry&&t.spPr.geometry.preset)return t.spPr.geometry.preset;if(t.spPr&&t.spPr.prstGeom&&t.spPr.prstGeom.prst)return t.spPr.prstGeom.prst;if(this.isPlaceholderShape(t))return"rect";if("sp"===t.type||"shape"===t.type)return"rect";return null}drawPictureShape(t,e){if(!e||e.w<=0||e.h<=0)return;if(!this.graphics||!this.graphics.context)return;const r=this.graphics.context;r.save();const o=t.properties?.transform;if(o&&o.rotation&&0!==o.rotation){const t=e.x+e.w/2;const s=e.y+e.h/2;r.translate(t,s);r.rotate(o.rotation*Math.PI/180);r.translate(-t,-s)}const s=this.getShapePreset(t);if(s&&"rect"!==s)if("ellipse"===s){r.beginPath();r.ellipse(e.x+e.w/2,e.y+e.h/2,e.w/2,e.h/2,0,0,2*Math.PI);r.clip()}if(t.imageRelId&&this.processor&&this.processor.imageCache){const o=this.processor.imageCache.get(t.imageRelId);if(o);if(o&&"svg"===o.type&&this.processor.svgRenderer)try{const t=this.processor.svgRenderer.renderSVG(o.content,e.x,e.y,e.w,e.h,{preserveAspectRatio:true});t.then(()=>{}).catch(()=>{});r.restore();return}catch(t){}if(o&&o.image)try{const image=o.image;const{width:s,height:i}=o;let n=e.x,a=e.y,l=e.w,c=e.h;if("stretch"===t.imageFillMode){if(t.imageSrcRect){const o=t.imageSrcRect;const s=1e5-o.l-o.r;const i=1e5-o.t-o.b;if(s>0&&i>0){n=e.x+e.w*-o.l/s;a=e.y+e.h*-o.t/i;l=1e5*e.w/s;c=1e5*e.h/i;r.beginPath();r.rect(e.x,e.y,e.w,e.h);r.clip()}}else if(t.imageFillRect){const r=t.imageFillRect;n=e.x+e.w*r.l/1e5;a=e.y+e.h*r.t/1e5;l=e.w*(1e5-r.l-r.r)/1e5;c=e.h*(1e5-r.t-r.b)/1e5}}else if("tile"===t.imageFillMode){n=e.x;a=e.y;l=e.w;c=e.h}else{const t=s/i;const r=e.w/e.h;if(t>r){l=e.w;c=e.w/t;n=e.x;a=e.y+(e.h-c)/2}else{c=e.h;l=e.h*t;n=e.x+(e.w-l)/2;a=e.y}}r.drawImage(image,n,a,l,c);r.restore();return}catch(t){}}r.restore();if(t.textBody&&t.textBody.paragraphs&&this.shouldRenderText(t)){this.setCurrentRenderingShape(t);this.drawShapeText(t,e)}}drawImagePlaceholder(t,e,r,o,s,i="IMAGE"){const n=this.m_oContext;if(!n)return;n.save();n.fillStyle="#f8f9fa";n.fillRect(e,r,o,s);n.strokeStyle="#dee2e6";n.lineWidth=1;n.strokeRect(e,r,o,s);n.restore()}drawGroupShape(t,e){if(!e||e.w<=0||e.h<=0)return;if(!this.graphics||!this.graphics.context)return;this.graphics.SaveGrState();try{if(t.transform){const r=this.graphics.context;if(t.transform.rotation&&0!==t.transform.rotation){const o=e.x+e.w/2;const s=e.y+e.h/2;r.save();r.translate(o,s);r.rotate(t.transform.rotation*Math.PI/180);r.translate(-o,-s)}if(t.transform.flipH||t.transform.flipV){const o=t.transform.flipH?-1:1;const s=t.transform.flipV?-1:1;const i=e.x+e.w/2;const n=e.y+e.h/2;r.save();r.translate(i,n);r.scale(o,s);r.translate(-i,-n)}}if(t.shapeTree&&t.shapeTree.length>0){const e=this.sortShapesByRenderOrder(t.shapeTree);for(let t=0;t0&&t.h>0)this.drawShapeGeometry(r,t)}catch(t){}}}}catch(t){}finally{this.graphics.RestoreGrState()}}calculateChildShapeBounds(t,e){if(!t.bounds)return{x:e.x,y:e.y,w:50,h:50};const r=t.bounds;const o=this.processor?this.processor.getSlideDimensions():{cx:9144e3,cy:6858e3};const s=this.processor?this.processor.calculateCanvasRect(this.canvas,o):{scale:1,offsetX:0,offsetY:0,slideWidthPx:this.canvas.width,slideHeightPx:this.canvas.height};const i=s.slideWidthPx;const n=s.slideHeightPx;const a={x:(r.l||0)/o.cx*i,y:(r.t||0)/o.cy*n,w:((r.r||0)-(r.l||0))/o.cx*i,h:((r.b||0)-(r.t||0))/o.cy*n};const l=s.offsetX+a.x*s.scale;const c=s.offsetY+a.y*s.scale;const h=a.w*s.scale;const u=a.h*s.scale;return{x:l,y:c,w:h,h:u}}drawDefaultShape(t,e){if(!e||e.w<=0||e.h<=0)return;if(!this.graphics||!this.graphics.context)return;const r=this.graphics.context;r.save();const o=t.properties?.transform;if(o&&o.rotation&&0!==o.rotation){const t=e.x+e.w/2;const s=e.y+e.h/2;r.translate(t,s);r.rotate(o.rotation*Math.PI/180);r.translate(-t,-s)}r.fillStyle="#e0e0e0";r.fillRect(e.x,e.y,e.w,e.h);r.strokeStyle="#999";r.lineWidth=1;r.strokeRect(e.x,e.y,e.w,e.h);r.restore();if(t.textBody&&t.textBody.paragraphs){this.setCurrentRenderingShape(t);this.drawShapeText(t,e)}}drawConnectorShape(t,e){if(!e||e.w<=0&&e.h<=0)return;this.drawEngineLine(e,t)}async drawGraphicFrame(t,e){if(t.graphicData);if(!e||e.w<=0||e.h<=0)return;if(t.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===t.graphicData.uri)this.drawTable(t,e);else if(t.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/chart"===t.graphicData.uri)await this.drawChart(t,e);else this.drawDefaultShape(t,e)}drawTable(t,e){if(t.graphicData&&t.graphicData.tableXml)try{if(!this.tableProcessor)this.tableProcessor=new TableProcessor;const r=this.tableProcessor.parseTableFromXML(t.graphicData.tableXml);if(r){let t=e.x;let o=e.y;let s=e.w;let i=e.h;try{const t="function"===typeof r.getTableProperties?r.getTableProperties()||{}:r.tableProperties||{};const o=t&&t.layout?String(t.layout).toLowerCase():"autofit";const n=this.coordinateSystem&&"number"===typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1;let a=0;const l="function"===typeof r.getTableGrid?r.getTableGrid():r.tableGrid||[];if(Array.isArray(l)&&l.length>0){const t=l.reduce((t,e)=>t+(parseInt(e.width)||0),0);a=t/914400*96*n}let c=0;const h=r.rows||[];if(h.length>0&&h.some(t=>t&&t.height)){const t=h.reduce((t,e)=>t+(parseInt(e&&e.height)||0),0);c=t/914400*96*n}if(!a&&t&&t.preferredWidth){const r=t.preferredWidth;if("pct"===r.type){const t=(parseInt(r.value)||0)/5e3;a=Math.max(0,e.w*t)}else if("dxa"===r.type)a=(parseInt(r.value)||0)/1440*96*n}const u=a>0?a/e.w:0;if(a>e.w||u<.9)s=a;if(c>0)i=c}catch(t){}const n=this.canvas.getContext("2d");let a=null;try{a=this.computeTableLayout(r,s,i,n);if(a&&"number"===typeof a.height&&a.height>0)i=a.height}catch(t){a=null}n.save();n.rect(t,o,s,i);n.clip();const l=this.graphics.context;if(!l)return;const c=this;const h={strokeRect:(t,e,r,o,s,i)=>{if(c.graphics&&"function"===typeof c.graphics.p_color){c.graphics.p_color(s.r,s.g,s.b,s.a||255);c.graphics.p_width(i||1);if("function"===typeof c.graphics._s)c.graphics._s();if("function"===typeof c.graphics._m)c.graphics._m(t,e);if("function"===typeof c.graphics._l){c.graphics._l(t+r,e);c.graphics._l(t+r,e+o);c.graphics._l(t,e+o)}if("function"===typeof c.graphics._z)c.graphics._z();if("function"===typeof c.graphics.ds)c.graphics.ds()}},fillRect:(t,e,r,o,s)=>{if(c.graphics&&"function"===typeof c.graphics.b_color1){c.graphics.b_color1(s.r,s.g,s.b,s.a||255);if("function"===typeof c.graphics._s)c.graphics._s();if("function"===typeof c.graphics._m)c.graphics._m(t,e);if("function"===typeof c.graphics._l){c.graphics._l(t+r,e);c.graphics._l(t+r,e+o);c.graphics._l(t,e+o)}if("function"===typeof c.graphics._z)c.graphics._z();if("function"===typeof c.graphics.df)c.graphics.df()}},drawLine:(t,e,r,o,s,i)=>{if(c.graphics&&"function"===typeof c.graphics.p_color){c.graphics.p_color(s.r,s.g,s.b,s.a||255);c.graphics.p_width(i||1);if("function"===typeof c.graphics._s)c.graphics._s();if("function"===typeof c.graphics._m)c.graphics._m(t,e);if("function"===typeof c.graphics._l)c.graphics._l(r,o);if("function"===typeof c.graphics.ds)c.graphics.ds()}},fillText:(t,e,r,o)=>{if(c.graphics&&"function"===typeof c.graphics.FillText){if("function"===typeof c.graphics.font)c.graphics.font(o.fontFamily||"Arial",o.fontSize||12,o.bold?"bold":"normal",o.italic?"italic":"normal");c.graphics.b_color1(o.color.r,o.color.g,o.color.b,o.color.a||255);c.graphics.FillText(e,r,t)}}};this.drawTableDirect(r,n,t,o,s,i,a);n.restore()}else{this.drawTablePlaceholder(e,"Parse Failed");tableCtx.restore()}}catch(t){this.drawTablePlaceholder(e,"Error");tableCtx.restore()}else this.drawTablePlaceholder(e,"No Data")}computeTableLayout(t,e,r,o){const s={cellWidths:[],cellHeights:[],height:r};if(!t)return s;const i="function"===typeof t.getRowCount?t.getRowCount():t.rows?t.rows.length:0;const n="function"===typeof t.getColumnCount?t.getColumnCount():0;if(i<=0)return s;const a=this.coordinateSystem&&"number"===typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1;let l;try{const r="function"===typeof t.getTableGrid?t.getTableGrid():t.tableGrid||[];if(Array.isArray(r)&&r.length>0){l=r.map(t=>{const e=parseInt(t.width,10)||0;return e/914400*96*a});const t=l.reduce((t,e)=>t+e,0);if(t>0&&isFinite(e)&&e>0&&Math.abs(t-e)>1){const r=e/t;l=l.map(t=>t*r)}const o=Math.max(n,l.length);if(l.length0){const t=o-l.length;const r=l.reduce((t,e)=>t+e,0);const s=t>0?(e-r)/t:0;for(let e=0;et)}const h=new Array(i);const u=new Array(i).fill(false);const f=isFinite(r)&&r>0?r/Math.max(i,1):0;for(let e=0;e0)o=t/914400*96*a}if(o&&o>0)h[e]=o;else{h[e]=0;u[e]=true}}const d=(t,e,r)=>{let o=0;for(let s=0;sb){const t=y-b;if(1===u)e[o]=Math.max(e[o],t);else{const r=t/u;for(let t=0;t=i)break;e[s]=Math.max(e[s],r)}}}n+=c}}}finally{if("function"===typeof r.restore)r.restore()}for(let t=0;t0)h[t]+=e[t]}for(let t=0;tt+(e||0),0);s.cellWidths=l;s.cellHeights=h;if(p>0)s.height=p;else if(isFinite(r)&&r>0)s.height=r;else s.height=0;return s}drawTableDirect(t,e,r,o,s,i,n=null){if(!t||!e)return;e.save();const a="function"===typeof t.getRowCount?t.getRowCount():t.rows?t.rows.length:0;const l="function"===typeof t.getColumnCount?t.getColumnCount():0;if(0===a||0===l&&!(t.rows&&t.rows[0]&&t.rows[0].cells)){e.restore();return}let c=n;if(!c)c=this.computeTableLayout(t,s,i,e);let h=Array.isArray(c?.cellWidths)?c.cellWidths.slice():null;const u=h&&h.length>0?h.length:Math.max(l,1);if(!h||0===h.length)h=Array.from({length:u},()=>s/Math.max(u,1));let f=Array.isArray(c?.cellHeights)?c.cellHeights.slice():null;if(!f||0===f.length)f=Array.from({length:a},()=>i/Math.max(a,1));if(c&&"number"===typeof c.height&&c.height>0)i=c.height;const d=(t,e,r)=>{let o=0;for(let s=0;s{let r=0;for(let o=0;oMath.max(1,Math.round((t.width||1)*b));if(g){if(g.top&&g.top.color){const t=g.top;e.strokeStyle=`rgb(${t.color.r}, ${t.color.g}, ${t.color.b})`;e.lineWidth=x(t);e.beginPath();e.moveTo(r,o);e.lineTo(r+s,o);e.stroke()}if(g.left&&g.left.color){const t=g.left;e.strokeStyle=`rgb(${t.color.r}, ${t.color.g}, ${t.color.b})`;e.lineWidth=x(t);e.beginPath();e.moveTo(r,o);e.lineTo(r,o+i);e.stroke()}if(g.right&&g.right.color){const t=g.right;e.strokeStyle=`rgb(${t.color.r}, ${t.color.g}, ${t.color.b})`;e.lineWidth=x(t);e.beginPath();e.moveTo(r+s,o);e.lineTo(r+s,o+i);e.stroke()}if(g.bottom&&g.bottom.color){const t=g.bottom;e.strokeStyle=`rgb(${t.color.r}, ${t.color.g}, ${t.color.b})`;e.lineWidth=x(t);e.beginPath();e.moveTo(r,o+i);e.lineTo(r+s,o+i);e.stroke()}if(g.insideH&&g.insideH.color){const t=g.insideH;e.strokeStyle=`rgb(${t.color.r}, ${t.color.g}, ${t.color.b})`;e.lineWidth=x(t);for(let t=0;t{const r=n[e.name];if(r&&r.color&&r.width&&r.width>0){t.strokeStyle=`rgb(${r.color.r}, ${r.color.g}, ${r.color.b})`;t.lineWidth=Math.max(1,Math.round(r.width*a));t.beginPath();t.moveTo(e.x1,e.y1);t.lineTo(e.x2,e.y2);t.stroke()}})}extractCellStyle(t,e,r){const o={};if(!t)return o;if(t.shading&&t.shading.fillColor&&void 0!==t.shading.fillColor.r&&void 0!==t.shading.fillColor.g&&void 0!==t.shading.fillColor.b){const e=t.shading.fillColor;o.backgroundColor=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`}else if(t.shading&&t.shading.fill&&"none"!==t.shading.fill){const e=t.shading.fill.startsWith("#")?t.shading.fill.slice(1):null;if(e&&6===e.length){const t=parseInt(e.substring(0,2),16);const r=parseInt(e.substring(2,4),16);const s=parseInt(e.substring(4,6),16);o.backgroundColor=`rgb(${t}, ${r}, ${s})`}}if(!o.backgroundColor&&r&&void 0!==e){const s="function"===typeof r.getTableProperties?r.getTableProperties():r.tableProperties||{};if(s){const r=t.logicalColIndex||0;if(s.firstRow&&0===e)o.backgroundColor="rgba(68, 114, 196, 1)";else if(s.bandRow&&e>0){const t=s.firstRow?e-1:e;if(t%2===1)o.backgroundColor="rgba(242, 242, 242, 1)"}else if(s.firstCol&&0===r&&e>0)o.backgroundColor="rgba(221, 235, 247, 1)"}}if(t.textBody&&t.textBody.paragraphs&&t.textBody.paragraphs.length>0){const s=t.textBody.paragraphs[0];if(s.runs&&s.runs.length>0){const t=s.runs[0];if(t.properties&&t.properties.color){const e=t.properties.color;o.textColor=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`}else o.textColor=this.getTableStyleTextColor(e,r)}else o.textColor=this.getTableStyleTextColor(e,r)}else o.textColor=this.getTableStyleTextColor(e,r);return o}getTableStyleTextColor(t,e){const r=e&&"function"===typeof e.getTableProperties?e.getTableProperties():e&&e.tableProperties?e.tableProperties:{};if(r&&void 0!==t)if(r.firstRow&&0===t)return"rgb(255, 255, 255)";return"rgb(0, 0, 0)"}getCellMarginsPx(t){const e=this.coordinateSystem&&"number"===typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1;const r=3.78*e;const o={left:r,top:r,right:r,bottom:r};if(!t)return o;const s={...o};const i=t=>{const r=Number(t);if(!Number.isFinite(r))return null;return r/914400*96*e};const n=t=>{if(!t)return;if(void 0!==t.marL){const e=i(t.marL);if(null!==e)s.left=e}if(void 0!==t.marT){const e=i(t.marT);if(null!==e)s.top=e}if(void 0!==t.marR){const e=i(t.marR);if(null!==e)s.right=e}if(void 0!==t.marB){const e=i(t.marB);if(null!==e)s.bottom=e}};const a=t=>{if(!t)return;if(void 0!==t.left){const e=i(t.left);if(null!==e)s.left=e}if(void 0!==t.top){const e=i(t.top);if(null!==e)s.top=e}if(void 0!==t.right){const e=i(t.right);if(null!==e)s.right=e}if(void 0!==t.bottom){const e=i(t.bottom);if(null!==e)s.bottom=e}};n(t.cellProperties);a(t.margins);return s}computeCellTextLayout(t,e,r,o=Number.POSITIVE_INFINITY,s={}){const i={lines:[],totalHeight:0};if(!e||!e.textBody||!Array.isArray(e.textBody.paragraphs)||r<=0)return i;const n="number"===typeof o&&o>0?o:Number.POSITIVE_INFINITY;const a=s&&"number"===typeof s.contentX?s.contentX:0;let l=0;const c=this.coordinateSystem&&"number"===typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1;const h=Boolean(e.textBody&&e.textBody.bodyProperties&&false===e.textBody.bodyProperties.wrap);const u=t?t.font:null;for(const o of e.textBody.paragraphs){if(!o||!Array.isArray(o.runs)||0===o.runs.length)continue;if(l>=n)break;let e="left";let u=a;if(o.properties&&o.properties.alignment){const t=o.properties.alignment;const s="string"===typeof t?t.toLowerCase():t;if("center"===s||"ctr"===s){e="center";u=a+r/2}else if("right"===s||"r"===s||"end"===s){e="right";u=a+r}else if("start"===s||"left"===s||"l"===s){e="left";u=a}else if("justify"===s){e="left";u=a}}const f=o.runs.find(t=>(t.text||"").trim().length>0)||o.runs[0];let d=12;if(f?.properties?.fontSize)d=f.properties.fontSize;else if(f?.properties?.sz){const t=parseInt(f.properties.sz,10);if(!Number.isNaN(t))d=t/100}const p=Math.max(1,Math.round(d*(96/72)*c));const g=f?.properties?.fontFamily||"Arial";const m=Boolean(f?.properties?.bold);const y=Boolean(f?.properties?.italic);const b=Boolean(f?.properties?.underline);let x=s.defaultTextColor||"rgb(159, 159, 159)";if(f?.properties?.color){const t=f.properties.color;x=`rgba(${t.r}, ${t.g}, ${t.b}, ${(t.a||255)/255})`}let S=1.2;if(o.properties)if("number"===typeof o.properties.lineSpacingFactor)S=o.properties.lineSpacingFactor;else if("number"===typeof o.properties.lineSpacingPct)S=Math.max(.5,Math.min(4,o.properties.lineSpacingPct/100));const w=Math.max(1,Math.round(p*S));const C=o.runs.map(t=>t.text||"").join("");if(!C)continue;const T=!h;const P=`${y?"italic ":""}${m?"bold ":""}${p}px ${g}`;if(t&&"string"===typeof t.font)t.font=P;let v=null;if(f?.properties?.highlight){const t=f.properties.highlight;if("object"===typeof t&&void 0!==t.r)v=`rgba(${t.r}, ${t.g}, ${t.b}, ${(t.a||255)/255})`;else if("string"===typeof t)v=t}const M=t=>{if(!t)return;i.lines.push({text:t,textX:u,textAlign:e,fontSizePixels:p,fontFamily:g,isBold:m,isItalic:y,isUnderline:b,colorStr:x,lineHeight:w,highlightStr:v});l+=w};if(T){let e=C.trim();while(e.length>0){if(l+w>n)break;let o=1;let s=e.length;let i=1;while(o<=s){const n=o+s>>1;const a=e.slice(0,n);const l=t&&"function"===typeof t.measureText?t.measureText(a):{width:a.length*p*.5};if(l.width<=r||1===n){i=n;o=n+1}else s=n-1}let a=i;if(i0)a=t}let c=Math.max(1,a);let h=e.slice(0,c).trimEnd();if(!h){h=e.charAt(0);c=1}M(h);e=e.slice(c).trimStart()}}else{if(l+w>n)break;M(C.trimEnd())}}if(t&&null!==u)t.font=u;i.totalHeight=l;return i}drawCellText(t,e,r,o,s,i,n){if(!e||!e.textBody||!e.textBody.paragraphs)return;t.save();t.textBaseline="top";const a=this.getCellMarginsPx(e);const l=Math.max(0,s-a.left-a.right);const c=Math.max(0,i-a.top-a.bottom);if(l<=0||c<=0){t.restore();return}const h=r+a.left;const u=o+a.top;t.beginPath();t.rect(h,u,l,c);t.clip();const f=this.computeCellTextLayout(t,e,l,c,{contentX:h,defaultTextColor:n.textColor});if(f.lines.length>0){const r=f.totalHeight;let o="top";if(e&&"string"===typeof e.verticalAlignment)o=e.verticalAlignment.toLowerCase();else if(e&&e.textBody&&e.textBody.bodyProperties&&e.textBody.bodyProperties.anchor){const t=String(e.textBody.bodyProperties.anchor).toLowerCase();if("ctr"===t||"center"===t||"middle"===t)o="middle";else if("b"===t||"bottom"===t)o="bottom"}const s=f.lines[f.lines.length-1];const i=s?Math.max(0,s.lineHeight-s.fontSizePixels):0;let n=u;if("middle"===o||"center"===o||"ctr"===o)n=u+Math.max(0,(c-r)/2)+i/2;else if("b"===o||"bottom"===o)n=u+Math.max(0,c-r)+i;for(const e of f.lines){let r="";if(e.isItalic)r+="italic ";if(e.isBold)r+="bold ";t.font=`${r}${e.fontSizePixels}px ${e.fontFamily}`;t.textAlign=e.textAlign;if(e.highlightStr){const r=t.measureText(e.text);t.save();t.fillStyle=e.highlightStr;t.fillRect(Math.round(e.textX),Math.round(n-e.fontSizePixels),r.width,1.2*e.fontSizePixels);t.restore()}t.fillStyle=e.colorStr;t.fillText(e.text,Math.round(e.textX),Math.round(n));if(e.isUnderline){const r=t.measureText(e.text).width;const o=Math.round(n+1.1*e.fontSizePixels);const s="center"===e.textAlign?Math.round(e.textX-r/2):"right"===e.textAlign?Math.round(e.textX-r):Math.round(e.textX);t.save();t.strokeStyle=e.colorStr;t.lineWidth=Math.max(1,.08*e.fontSizePixels);t.beginPath();t.moveTo(s,o);t.lineTo(s+r,o);t.stroke();t.restore()}n+=e.lineHeight;if(n>u+c)break}}t.restore()}getScaledFontSize(t){let e=t;if(this.coordinateSystem&&this.coordinateSystem.scale){e=t*this.coordinateSystem.scale;e=Math.max(e,8);e=Math.min(e,72)}return Math.round(e)}drawTablePlaceholder(t,e){const r={r:100,g:100,b:200,a:255};this.graphics.p_color(r.r,r.g,r.b,r.a);this.graphics.p_width(2);this.graphics._s();this.graphics._m(t.x,t.y);this.graphics._l(t.x+t.w,t.y);this.graphics._l(t.x+t.w,t.y+t.h);this.graphics._l(t.x,t.y+t.h);this.graphics._z();if("function"===typeof this.graphics.ds)this.graphics.ds()}async drawChart(t,e){const r=this.currentSlideIndex;const o=this.currentSlide;if(t.chartData){if("DEFERRED_CHART"===t.chartData.type)if(window.ChartProcessor){const s=new ChartProcessor(this.context);if(void 0!==r&&o){const i={slideIndex:r,slideName:o?.name||`slide${r+1}`,slide:o};s.setSlideContext(i);try{const r=await s.loadChartFromRelationship(t.chartData.relationshipId,i);if(r&&"DEFERRED_CHART"!==r.type)t.chartData=r;else{this.drawChartPlaceholder(e,"Load Failed");return}}catch(t){this.drawChartPlaceholder(e,"Load Error");return}}else{this.drawChartPlaceholder(e,"No Context");return}}else{this.drawChartPlaceholder(e,"No Processor");return}try{const r=new ChartRenderer(this.graphics);await r.renderChart(t.chartData,e.x,e.y,e.w,e.h)}catch(t){this.drawChartPlaceholder(e,"Render Failed")}}else if(t.graphicData&&t.graphicData.element&&window.ChartProcessor)try{const s=new ChartProcessor(this.context);if(void 0!==r&&o){const t={slideIndex:r,slideName:o?.name||`slide${r+1}`,slide:o};s.setSlideContext(t)}const i=s.parseEmbeddedChartData(t.graphicData.element);if(i){t.chartData=i;const r=new ChartRenderer(this.graphics);await r.renderChart(i,e.x,e.y,e.w,e.h);return}if(t.graphicData.chartRef){const i={slideIndex:r,slideName:o?.name||`slide${r+1}`,slide:o};try{const r=await s.loadChartFromRelationship(t.graphicData.chartRef,i);if(r){t.chartData=r;const o=new ChartRenderer(this.graphics);await o.renderChart(r,e.x,e.y,e.w,e.h)}else this.drawChartPlaceholder(e,"Processing Failed")}catch(t){this.drawChartPlaceholder(e,"Processing Error")}return}this.drawChartPlaceholder(e,"No Chart Reference")}catch(t){this.drawChartPlaceholder(e,"Processing Failed")}else this.drawChartPlaceholder(e,"No Chart Data")}drawChartStyling(t,e,r,o,s){if(!t)return;let i=null;if(this.graphics&&this.graphics.ctx)i=this.graphics.ctx;else if(this.graphics&&this.graphics._context)i=this.graphics._context;else if(this.graphics&&this.graphics.context)i=this.graphics.context;else if(this.graphics&&this.graphics.m_oContext)i=this.graphics.m_oContext;if(!i)return;const n=t.plotArea?.shapeProperties||t.shapeProperties||{};const a=n.line;if(!a||!a.color)return;const l=12700;const c=Math.max(1,Math.round((a.width||l)/l));const h="string"===typeof a.color?a.color:this.colorToRgb(a.color);const u=t.roundedCorners?Math.min(20,Math.floor(.1*Math.min(o,s))):0;i.save();i.strokeStyle=h;i.lineWidth=c;i.lineCap="round";i.lineJoin="round";i.globalCompositeOperation="source-over";i.beginPath();if(t.roundedCorners&&u>0){const t=e+c/2;const n=r+c/2;const a=o-c;const l=s-c;if(this.graphics&&"function"===typeof this.graphics.drawRoundRectPath)this.graphics.drawRoundRectPath(i,t,n,a,l,u);else if("function"===typeof this.drawRoundRectPath)this.drawRoundRectPath(i,t,n,a,l,u);else i.rect(t,n,a,l)}else{const t=e+c/2;const n=r+c/2;const a=o-c;const l=s-c;i.rect(t,n,a,l)}i.stroke();i.restore()}drawChartPlaceholder(t,e){const r={r:200,g:100,b:100,a:255};this.graphics.p_color(r.r,r.g,r.b,r.a);this.graphics.p_width(2);this.graphics._s();this.graphics._m(t.x,t.y);this.graphics._l(t.x+t.w,t.y);this.graphics._l(t.x+t.w,t.y+t.h);this.graphics._l(t.x,t.y+t.h);this.graphics._z();if("function"===typeof this.graphics.ds)this.graphics.ds()}drawShapeText(t,e){if(!t||!t.textBody||!t.textBody.paragraphs||0===t.textBody.paragraphs.length)return;this.setCurrentRenderingShape(t);this.graphics.SaveGrState();try{const r=this.calculateTextBounds(t,e);this.drawTextContent(t.textBody,r)}catch(r){this.drawFallbackText(t,e)}finally{this.graphics.RestoreGrState();this.setCurrentRenderingShape(null)}}calculateTextBounds(t,e){let{x:r,y:o,w:s,h:i}=e;const n=t.textBody?.bodyProperties||t.textBody?.bodyPr||{};const a=this.getShapePreset(t);if("rtTriangle"===a){o+=i/2;i/=2}const l=Math.max(22860,.02*s*914400);const c=Math.max(11430,.01*i*914400);const h=this.emuToPixels(n.leftMargin||l);const u=this.emuToPixels(n.rightMargin||l);const f=this.emuToPixels(n.topMargin||c);const d=this.emuToPixels(n.bottomMargin||c);if(this.coordinateSystem){const{scale:t}=this.coordinateSystem;const e=Math.round(h*t);const n=Math.round(u*t);const a=Math.round(f*t);const l=Math.round(d*t);return{x:r+e,y:o+a,w:Math.max(s-(e+n),0),h:Math.max(i-(a+l),0),scale:t,margins:{left:e,right:n,top:a,bottom:l}}}return{x:r+h,y:o+f,w:Math.max(s-(h+u),0),h:Math.max(i-(f+d),0),scale:1,margins:{left:h,right:u,top:f,bottom:d}}}drawFallbackText(t,e){const r=this.graphics.context;if(!r)return;const{x:o,y:s,w:i,h:n}=e;r.save();const a=this.getTextScaleFactor();const l=12*a;r.font=`${l}px Arial`;r.fillStyle="#000000";r.textAlign="left";r.textBaseline="top";let c=s+5;const h=16;for(const e of t.textBody.paragraphs){if(c>s+n-h)break;for(const t of e.runs)if(t.text&&c<=s+n-h){r.fillText(t.text,o+5,c);c+=h}}r.restore()}drawTextContent(t,e){if(!t||!t.paragraphs||0===t.paragraphs.length)return;if(!this.graphics||!this.graphics.context)return;const r=this.graphics.context;const{x:o,y:s,w:i,h:n}=e;if(!n||n<1){const r=this.estimateTextHeightPx(t,i);if(r&&r>0){const o={...e,h:r};this.renderTextBodyStandard(t,o);return}}this.renderTextBodyStandard(t,e)}estimateTextHeightPx(t,e){try{if(!t||!t.paragraphs||0===t.paragraphs.length)return 0;const r=t.bodyProperties||t.bodyPr||{};const o=this.emuToPixels(r.leftMargin||0);const s=this.emuToPixels(r.rightMargin||0);const i=Math.max(0,e-o-s);let n=0;for(const e of t.paragraphs){const t=this.parseParagraphProperties(e,this.getCurrentShape());const r=this.calculateWrappedLines(e,t,i,this.getCurrentShape());const o=this.calculateStandardLineHeight(t,r);const s=this.emuToPixels(t.spaceBefore||0);const a=this.emuToPixels(t.spaceAfter||0);n+=s+r.length*o+a}const a=this.emuToPixels(r.topMargin||0);const l=this.emuToPixels(r.bottomMargin||0);n+=a+l;return Math.ceil(n)}catch(t){return 0}}estimateTextBoxHeightPx(t,e){const r=t&&t.textBody;if(!r)return 0;return this.estimateTextHeightPx(r,e)}renderTextBodyStandard(t,e){const{x:r,y:o,w:s,h:i,margins:n,scale:a}=e;const l=r;const c=o;const h=s;const u=i;const f=t.bodyProperties||t.bodyPr||{};let d=f.anchor||f.verticalAlign||"t";switch(d){case"top":d="t";break;case"middle":case"center":d="ctr";break;case"bottom":d="b"}let p=c;const g=[];let m=0;for(let e=0;e1)p=c;else p=c;break;default:p=c}let y=p;const b=c+u;let x=0;if(("just"===d||"dist"===d)&&g.length>1){const t=Math.max(0,u-m);if(t>0)if("just"===d)x=t/(g.length-1);else if("dist"===d){x=t/(g.length+1);y+=x}}const S={};let w=-1;const C={};const T={};let P=-1;const v=new Set;for(let t=0;tt-e);const A=M.length>0?M[0]:0;const k=t=>{const e=t&&"number"===typeof t.level?t.level:0;if(e>0)return e;const r=t.indent&&"number"===typeof t.indent.left?t.indent.left:0;if(M.length<=1)return e;if(r<=A)return 0;let o=M.indexOf(r);if(-1===o){o=M.findIndex(t=>t>=r);if(-1===o)o=M.length-1}return Math.max(0,o)};for(let t=0;tw)S[e]=0;if(!S[e]&&0!==S[e]){const t=o?s-1:0;S[e]=t}if(!S[e])S[e]=0;S[e]++;C[t]=S[e];w=e}}for(let t=0;t=b)break;const{paraProps:r,wrappedLines:o,lineHeight:s,spaceBefore:i,spaceAfter:n}=e;y+=i||0;const c=k(r);if(r.bullet&&("number"===r.bullet.type||"autoNumber"===r.bullet.type)){if(c!==w)if(cw)S[c]=0;if(!S[c])S[c]=0;S[c]++;w=c}for(let e=0;ey)p=g+d;else p=y}let w=p;for(const t of i.runs){const{text:e,runProps:r}=t;let o=e;if(r.cap&&"none"!==r.cap)switch(r.cap){case"all":case"small":o=o.toUpperCase();break;case"words":o=o.replace(/\b\w/g,t=>t.toUpperCase())}this.setupStandardFont(r);if(r.highlight){const t=this.graphics.context;if(t){const e=r.highlight;let s;if("object"===typeof e&&void 0!==e.r)s=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`;else if("string"===typeof e)s=e;if(s){const e=t.measureText(o).width;const i=r.scaledFontSize||(r.fontSize||12)*this.getTextScaleFactor();t.save();t.fillStyle=s;t.fillRect(Math.round(w),Math.round(x-.85*i),e,1.15*i);t.restore();t.fillStyle=this.graphics.colorToRgb(r.color)}}}const s=this.graphics.context;let i=false;if(r.effectLst&&s){const t=r.effectLst;if(t.outerShadow){const e=t.outerShadow;s.save();i=true;const r=(e.blurRadius||0)/12700;const o=(e.distance||0)/12700;const n=(e.direction||0)/6e4*Math.PI/180;s.shadowOffsetX=Math.cos(n)*o*this.getTextScaleFactor();s.shadowOffsetY=Math.sin(n)*o*this.getTextScaleFactor();s.shadowBlur=r*this.getTextScaleFactor();if(e.color){const t=e.color;let r=0,o=0,i=0,n=.5;if(void 0!==t.r){r=t.r;o=t.g;i=t.b;n=void 0!==t.a?t.a/255:.5}else if(t.value){const e=t.value.replace("#","");r=parseInt(e.slice(0,2),16)||0;o=parseInt(e.slice(2,4),16)||0;i=parseInt(e.slice(4,6),16)||0;n=void 0!==t.alpha?t.alpha:.5}s.shadowColor=`rgba(${r}, ${o}, ${i}, ${n})`}else s.shadowColor="rgba(0, 0, 0, 0.4)"}else if(t.glow){const e=t.glow;s.save();i=true;const r=(e.radius||0)/12700;s.shadowOffsetX=0;s.shadowOffsetY=0;s.shadowBlur=r*this.getTextScaleFactor();if(e.color){const t=e.color;s.shadowColor=`rgba(${t.r||0}, ${t.g||0}, ${t.b||0}, ${(t.a||255)/255})`}else s.shadowColor="rgba(255, 0, 0, 0.6)"}}let n=x;if(r.verticalAlign&&"normal"!==r.verticalAlign&&"baseline"!==r.verticalAlign){const t=r.scaledFontSize||(r.fontSize||12)*this.getTextScaleFactor();if("superscript"===r.verticalAlign||"super"===r.verticalAlign)n=x-.35*t;else if("subscript"===r.verticalAlign||"sub"===r.verticalAlign)n=x+.2*t}w=this.renderRunTextStandard(o,w,n,r,l+h);if(i&&s){s.restore();s.fillStyle=this.graphics.colorToRgb(r.color)}}y+=s}y+=n||0;if(t0){if(i.runs.length>0)s.push(i);i={runs:[],width:0}}const e=h[t];if(!e)continue;const o=e.split(/(\s+)/);for(const t of o){if(!t)continue;const e=this.measureRunText(t,l);if(i.width+e<=r){i.runs.push({text:t,runProps:l});i.width+=e}else if(e<=r){if(i.runs.length>0)s.push(i);i={runs:[{text:t,runProps:l}],width:e}}else{if(i.runs.length>0){s.push(i);i={runs:[],width:0}}let e="";let o=0;for(const n of t){const t=this.measureRunText(n,l);if(o+t>r&&e.length>0){i.runs.push({text:e,runProps:l});i.width+=o;s.push(i);i={runs:[],width:0};e="";o=0}e+=n;o+=t}if(e){i.runs.push({text:e,runProps:l});i.width+=o}}}}}if(i.runs.length>0)s.push(i);if(0===s.length)s.push({runs:[],width:0});return s}setupStandardFont(t){const e=this.graphics.context;if(!e)return;const r=this.getTextScaleFactor();const o=(t.fontSize||12)*r;const s=t.italic?"italic":"normal";const i=t.bold?"bold":"normal";const n=t.fontFamily||"Arial";const a=`"${n}", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif`;e.font=`${s} ${i} ${o}px ${a}`;e.fillStyle=this.graphics.colorToRgb(t.color);e.textBaseline="alphabetic";t.scaledFontSize=o}getBulletWidth(t,e,r=0,o=null){const s=this.graphics.context;if(!s||!t)return 0;s.save();try{const o=e.fontSize||12;const i=this.getTextScaleFactor();const n=o*i;const a=e.fontFamily||"Arial";const l=e.bold?"bold":"normal";const c=e.italic?"italic":"normal";s.font=`${c} ${l} ${n}px ${a}`;let h="";switch(t.type){case"character":h=t.char||"•";break;case"number":{const o=(t.startAt||1)-1;const s=e&&"number"===typeof e._bulletNumber?e._bulletNumber:r;h=`${o+s}.`}break;case"autoNumber":{const o=(t.startAt||1)-1;const s=e&&"number"===typeof e._bulletNumber?e._bulletNumber:r;h=this.getAutoNumberBullet(t.subType,o+s)}break;default:h="•"}const u=s.measureText(h).width;s.restore();return u}catch(t){s.restore();return 0}}calculateBulletInfo(t,e,r=0){const o=this.graphics.getContext();o.save();const s=e.fontSize||12;const i=this.getTextScaleFactor();const n=Math.max(s*i,14);const a=e.fontFamily||"Arial";const l=e.bold?"bold":"normal";const c=e.italic?"italic":"normal";o.font=`${c} ${l} ${n}px ${a}`;let h="";switch(t.type){case"character":h=t.char||"•";break;case"number":{const o=(t.startAt||1)-1;const s=e&&"number"===typeof e._bulletNumber?e._bulletNumber:r;h=`${o+s}.`}break;case"autoNumber":{const o=(t.startAt||1)-1;const s=e&&"number"===typeof e._bulletNumber?e._bulletNumber:r;const i=o+s;h=this.getAutoNumberBullet(t.subType,i)}break;default:h="•"}const u=o.measureText(h).width;const f=.5*n;o.restore();return{bulletText:h,bulletWidth:u,bulletSpacing:f,totalWidth:u+f}}generateHierarchicalNumber(t,e,r,o){const s=e.level||0;const i=o&&o[s]?o[s]:(t.startAt||1)+r;return this.getAutoNumberBullet(t.subType,i)}renderBullet(t,e,r,o,s,i=null){const n=this.graphics.context;if(!n||!t)return;n.save();try{const i=o.fontSize||12;const a=this.getTextScaleFactor();const l=i*a;const c=o.fontFamily||"Arial";const h=o.bold?"bold":"normal";const u=o.italic?"italic":"normal";n.font=`${u} ${h} ${l}px ${c}`;const f=o.color||{r:0,g:0,b:0,a:255};const d=this.graphics.colorToRgb(f);n.fillStyle=d;n.textBaseline="alphabetic";let p="";switch(t.type){case"character":p=t.char||"•";break;case"number":{const e=(t.startAt||1)-1;const r=o&&"number"===typeof o._bulletNumber?o._bulletNumber:s;p=`${e+r}.`}break;case"autoNumber":{const e=(t.startAt||1)-1;const r=o&&"number"===typeof o._bulletNumber?o._bulletNumber:s;p=this.getAutoNumberBullet(t.subType,e+r)}break;default:p="•"}n.fillText(p,e,r)}catch(t){}finally{n.restore()}}getAutoNumberBullet(t,e){switch(t){case"arabicPeriod":case"arabic1Minus":case"arabic2Minus":default:return`${e}.`;case"arabicParenR":return`${e})`;case"arabicParenBoth":return`(${e})`;case"romanUcPeriod":return`${this.toRoman(e,true)}.`;case"romanLcPeriod":return`${this.toRoman(e,false)}.`;case"alphaUcPeriod":return`${this.toAlpha(e,true)}.`;case"alphaLcPeriod":return`${this.toAlpha(e,false)}.`;case"alphaUcParenR":return`${this.toAlpha(e,true)})`;case"alphaLcParenR":return`${this.toAlpha(e,false)})`;case"alphaUcParenBoth":return`(${this.toAlpha(e,true)})`;case"alphaLcParenBoth":return`(${this.toAlpha(e,false)})`}}toRoman(t,e=true){const r=[1e3,900,500,400,100,90,50,40,10,9,5,4,1];const o=e?["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]:["m","cm","d","cd","c","xc","l","xl","x","ix","v","iv","i"];let s="";for(let e=0;e=r[e]){s+=o[e];t-=r[e]}return s}toAlpha(t,e=true){let r="";const o=26;const s=e?65:97;while(t>0){t--;r=String.fromCharCode(s+t%o)+r;t=Math.floor(t/o)}return r||(e?"A":"a")}renderRunTextStandard(t,e,r,o,s){const i=this.graphics.context;if(!i||!t)return e;let n=e;if(this.currentRenderingShape&&this.currentRenderingShape.effects)this.applyTextEffectsToContext(i,this.currentRenderingShape.effects);const a=o.letterSpacing||0;if(0===a){i.fillText(t,n,r);n+=i.measureText(t).width}else{const e=Array.from(t);for(let t=0;t0){let t=0;for(const r of e)for(const e of r.runs||[])if(e.runProps&&e.runProps.fontSize>0)t=Math.max(t,e.runProps.fontSize);if(t>0&&tt+e.width,0);let a=r;const l=i.align||"left";const c=this.coordinateSystem?.scale||1;const h=s*c;const u=n*c;if("center"===l||"ctr"===l){const t=Math.max(0,s-n);a=r+t/2}else if("right"===l||"r"===l)a=r+Math.max(0,s-n);else if("justify"===l&&e.length>1)a=r;let f=a;for(const r of e){t.font=r.font;t.fillStyle=this.graphics.colorToRgb(r.props.color||{r:0,g:0,b:0,a:255});t.textBaseline="alphabetic";t.textAlign="left";if(r.props.highlight){const e=r.props.highlight;let s;if("object"===typeof e&&void 0!==e.r)s=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`;else if("string"===typeof e)s=e;if(s){const e=this.getTextScaleFactor();const i=(r.props.fontSize||12)*e;t.save();t.fillStyle=s;t.fillRect(Math.round(f),Math.round(o-i),r.width,1.2*i);t.restore();t.fillStyle=this.graphics.colorToRgb(r.props.color||{r:0,g:0,b:0,a:255})}}t.fillText(r.text,Math.round(f),Math.round(o));if(r.props.underline){t.save();t.strokeStyle=t.fillStyle;t.lineWidth=1;t.beginPath();t.moveTo(f,o+2);t.lineTo(f+r.width,o+2);t.stroke();t.restore()}if(r.props.strike){t.save();t.strokeStyle=t.fillStyle;t.lineWidth=1;t.beginPath();const e=this.getTextScaleFactor();const s=(r.props.fontSize||12)*e;const i=o-.3*s;t.moveTo(f,i);t.lineTo(f+r.width,i);t.stroke();t.restore()}f+=r.width}}parseParagraphProperties(t,e=null){const r={align:"left",lineHeight:120,spaceBefore:0,spaceAfter:0,fontSize:18,fontFamily:"Arial",color:{r:0,g:0,b:0,a:255},bold:false,italic:false,bullet:null,indent:{left:0,hanging:0}};const o=t.properties&&"number"===typeof t.properties.level?t.properties.level:0;const s=this.resolveInheritedTextProperties(e,"paragraph",o);for(const t in s)if("leftMargin"===t)r.indent.left=s.leftMargin;else if("hangingIndent"===t)r.indent.hanging=s.hangingIndent;else if("leftMargin"!==t&&"hangingIndent"!==t)r[t]=s[t];if(s.align){const t={l:"left",left:"left",ctr:"center",center:"center",r:"right",right:"right",just:"justify",justify:"justify"};r.align=t[s.align]||s.align}if(e&&e.placeholder)e.placeholder.type;if(t.properties){const e=t.properties;if(e.align){const t={l:"left",left:"left",ctr:"center",center:"center",r:"right",right:"right",just:"justify",justify:"justify"};r.align=t[e.align]||e.align}if(void 0!==e.lineHeight)r.lineHeight=e.lineHeight;if(void 0!==e.lineHeightPoints)r.lineHeightPoints=e.lineHeightPoints;if(e.spacing){if(e.spacing.before)r.spaceBefore=e.spacing.before;if(e.spacing.after)r.spaceAfter=e.spacing.after}if(void 0!==e.fontSize)r.fontSize=e.fontSize;if(e.fontFamily)r.fontFamily=e.fontFamily;if(e.color)r.color=e.color;if(void 0!==e.bold)r.bold=e.bold;if(void 0!==e.italic)r.italic=e.italic;if(e.bullet)r.bullet=e.bullet;if(e.indent){r.indent.left=e.indent.left;r.indent.hanging=e.indent.hanging}}return r}parseRunProperties(t,e,r=null){const o="layout"===this.currentSlide?.type;const s=o?{r:68,g:68,b:68,a:255}:{r:0,g:0,b:0,a:255};const i={fontSize:18,fontFamily:"Arial",color:s,bold:false,italic:false,underline:false,strike:false,verticalAlign:"normal",letterSpacing:0,cap:"none"};const n=this.resolveInheritedTextProperties(r,"run");Object.assign(i,n);if(e){if(void 0!==e.fontSize)i.fontSize=e.fontSize;if(e.fontFamily)i.fontFamily=e.fontFamily;if(e.color)i.color=e.color;if(void 0!==e.bold)i.bold=e.bold;if(void 0!==e.italic)i.italic=e.italic}if(t.properties){const e=t.properties;if(void 0!==e.fontSize)i.fontSize=e.fontSize;if(e.fontFamily)i.fontFamily=e.fontFamily;if(e.color)i.color=e.color;if(void 0!==e.bold)i.bold=e.bold;if(void 0!==e.italic)i.italic=e.italic;if(void 0!==e.underline)i.underline=e.underline;if(void 0!==e.strike)i.strike=e.strike;if(e.verticalAlign)i.verticalAlign=e.verticalAlign;if(void 0!==e.letterSpacing)i.letterSpacing=e.letterSpacing;if(e.cap)i.cap=e.cap;if(e.highlight)i.highlight=e.highlight;if(e.effectLst)i.effectLst=e.effectLst}return i}emuToPixels(t){return CoordinateTransform.emuToPixels(t,96)}colorToRgbAlternative(t){if("string"===typeof t){if(t.startsWith("#"))return t;if(t.match(/^[a-z]+$/i))return t;return t}if(!t)return"rgb(0, 0, 0)";let e=0,r=0,o=0,s=255;if("object"===typeof t){e=void 0!==t.r?t.r:void 0!==t.R?t.R:0;r=void 0!==t.g?t.g:void 0!==t.G?t.G:0;o=void 0!==t.b?t.b:void 0!==t.B?t.B:0;s=void 0!==t.a?t.a:void 0!==t.A?t.A:255;e=Math.max(0,Math.min(255,Math.round(e)));r=Math.max(0,Math.min(255,Math.round(r)));o=Math.max(0,Math.min(255,Math.round(o)));s=Math.max(0,Math.min(255,Math.round(s)))}if(void 0!==s&&255!==s)return`rgba(${e}, ${r}, ${o}, ${s/255})`;return`rgb(${e}, ${r}, ${o})`}isHiddenShape(t){return true===t.hidden}getShapeTransform(t){return null}getShapeBounds(t){if(t&&"graphicFrame"===t.type&&t.position){const e=t.position;const r=e.x||0;const o=e.y||0;const s=e.width||914400;const i=e.height||914400;if(this.coordinateSystem){const{slideWidthEMU:t,slideHeightEMU:e}=this.coordinateSystem;const n=t||9144e3;const a=e||6858e3;const l={x:r/n,y:o/a,w:s/n,h:i/a};const c=this.graphics.context.canvas;let h,u;if(c.style.width&&c.style.height){h=parseFloat(c.style.width);u=parseFloat(c.style.height)}else{h=c.width/(window.devicePixelRatio||1);u=c.height/(window.devicePixelRatio||1)}const f=n/a;const d=h/u;let p,g,m,y;if(f>d){p=h;g=h/f;m=0;y=(u-g)/2}else{p=u*f;g=u;m=(h-p)/2;y=0}return{x:Math.round(m+l.x*p),y:Math.round(y+l.y*g),w:Math.round(l.w*p),h:Math.round(l.h*g)}}const n=t=>t/914400*96;return{x:n(r),y:n(o),w:n(s),h:n(i)}}if(t.spPr&&t.spPr.xfrm){const e=t.spPr.xfrm;const r=void 0!==e.x?e.x:void 0!==(e.off&&e.off.x)?e.off.x:0;const o=void 0!==e.y?e.y:void 0!==(e.off&&e.off.y)?e.off.y:0;const s=void 0!==e.width?e.width:void 0!==e.cx?e.cx:void 0!==(e.ext&&e.ext.cx)?e.ext.cx:914400;const i=void 0!==e.height?e.height:void 0!==e.cy?e.cy:void 0!==(e.ext&&e.ext.cy)?e.ext.cy:914400;if(this.coordinateSystem){const{slideWidthEMU:t,slideHeightEMU:e}=this.coordinateSystem;const n=t||9144e3;const a=e||6858e3;const l={x:r/n,y:o/a,w:s/n,h:i/a};const c=this.graphics.context.canvas;let h,u;if(c.style.width&&c.style.height){h=parseFloat(c.style.width);u=parseFloat(c.style.height)}else{h=c.width/(window.devicePixelRatio||1);u=c.height/(window.devicePixelRatio||1)}const f=n/a;const d=h/u;let p,g,m,y;if(f>d){p=h;g=h/f;m=0;y=(u-g)/2}else{p=u*f;g=u;m=(h-p)/2;y=0}return{x:Math.round(m+l.x*p),y:Math.round(y+l.y*g),w:Math.round(l.w*p),h:Math.round(l.h*g)}}const n=t=>t/914400*96;return{x:n(r),y:n(o),w:n(s),h:n(i)}}if(t.properties&&t.properties.transform){const e=t.properties.transform;const r=e.x||0;const o=e.y||0;const s=e.width||914400;const i=e.height||914400;if(this.coordinateSystem){const{scale:t,offsetX:e,offsetY:n,slideWidthEMU:a,slideHeightEMU:l}=this.coordinateSystem;const c=a||9144e3;const h=l||6858e3;const u={x:r/c,y:o/h,w:s/c,h:i/h};const f=this.graphics.context.canvas;let d,p;if(f.style.width&&f.style.height){d=parseFloat(f.style.width);p=parseFloat(f.style.height)}else{d=f.width/(window.devicePixelRatio||1);p=f.height/(window.devicePixelRatio||1)}const g=c/h;const m=d/p;let y,b,x,S;if(g>m){y=d;b=d/g;x=0;S=(p-b)/2}else{y=p*g;b=p;x=(d-y)/2;S=0}const w={x:Math.round(x+u.x*y),y:Math.round(S+u.y*b),w:Math.round(u.w*y),h:Math.round(u.h*b)};return w}const n=t=>t/914400*96;const a={x:n(r),y:n(o),w:n(s),h:n(i)};return a}const e=t.position||t.transform;if(e&&(void 0!==e.x||void 0!==e.y||void 0!==e.width||void 0!==e.height)){const t=e.x||0;const r=e.y||0;const o=e.width||914400;const s=e.height||914400;if(this.coordinateSystem){const{slideWidthEMU:e,slideHeightEMU:i}=this.coordinateSystem;const n=e||9144e3;const a=i||6858e3;const l={x:t/n,y:r/a,w:o/n,h:s/a};const c=this.graphics.context.canvas;let h,u;if(c.style.width&&c.style.height){h=parseFloat(c.style.width);u=parseFloat(c.style.height)}else{h=c.width/(window.devicePixelRatio||1);u=c.height/(window.devicePixelRatio||1)}const f=n/a;const d=h/u;let p,g,m,y;if(f>d){p=h;g=h/f;m=0;y=(u-g)/2}else{p=u*f;g=u;m=(h-p)/2;y=0}return{x:Math.round(m+l.x*p),y:Math.round(y+l.y*g),w:Math.round(l.w*p),h:Math.round(l.h*g)}}const i=t=>t/914400*96;return{x:i(t),y:i(r),w:i(o),h:i(s)}}if(t.bounds){const e=t.bounds.l||0;const r=t.bounds.t||0;const o="number"===typeof t.bounds.r?t.bounds.r:e+1e6;const s="number"===typeof t.bounds.b?t.bounds.b:r+1e6;if(this.coordinateSystem){const{scale:t,offsetX:i,offsetY:n,slideWidthEMU:a,slideHeightEMU:l}=this.coordinateSystem;const c=a||9144e3;const h=l||6858e3;const u={x:e/c,y:r/h,w:(o-e)/c,h:(s-r)/h};const f=this.graphics.context.canvas;let d,p;if(f.style.width&&f.style.height){d=parseFloat(f.style.width);p=parseFloat(f.style.height)}else{d=f.width/(window.devicePixelRatio||1);p=f.height/(window.devicePixelRatio||1)}const g=c/h;const m=d/p;let y,b,x,S;if(g>m){y=d;b=d/g;x=0;S=(p-b)/2}else{y=p*g;b=p;x=(d-y)/2;S=0}const w={x:Math.round(x+u.x*y),y:Math.round(S+u.y*b),w:Math.round(u.w*y),h:Math.round(u.h*b)};return w}const i=t=>t/914400*96;const n={x:i(e),y:i(r),w:i(o-e),h:i(s-r)};return n}const r={x:50,y:50,w:100,h:50};return r}getShapeFillColor(t){if(t.fill&&"none"===t.fill.type)return null;if(t.properties&&t.properties.fill&&"none"===t.properties.fill.type)return null;if(this.processor&&this.processor.applyPropertyInheritance&&(!t.fill||null===t.fill)&&(!t.properties?.fill||null===t.properties?.fill))this.processor.applyPropertyInheritance(t,this.currentSlide);if(t.fill&&"none"===t.fill.type)return null;if(t.properties&&t.properties.fill&&"none"===t.properties.fill.type)return null;if(t.textBody&&t.placeholder&&!t.fill&&!t.properties?.fill&&!t.fillColor)return null;if(this.processor&&this.processor.getShapeFillColor){const e=this.processor.getShapeFillColor(t);if(void 0!==e)return e}const e=t.preservedStyle||t.style;if(e&&e.fillRef){if(t.textBody&&t.placeholder&&!t.fill&&!t.properties?.fill&&!t.fillColor)return null;if(this.processor&&this.processor.resolveStyleFillColor){const t=this.processor.resolveStyleFillColor(e.fillRef);if(t)return t}if(e.fillRef.color)return e.fillRef.color;if("layout"===this.currentSlide?.type&&t.textBody&&!t.fill&&!t.properties?.fill)return null;return"#FFFFFF"}if(t.textBody&&!t.placeholder&&t.fillColor){const e=t.fillColor;if("string"===typeof e){const t=e.replace("#","");if(6===t.length){const e=parseInt(t.substr(0,2),16);const r=parseInt(t.substr(2,2),16);const o=parseInt(t.substr(4,2),16);if(e>200&&r>240&&o>240)return null}}else if("object"===typeof e&&void 0!==e.r)if(e.r>200&&e.g>240&&e.b>240)return null}if(t.fill&&"solid"===t.fill.type&&t.fill.color)return t.fill.color;if(t.properties&&t.properties.fill&&t.properties.fill.color)return t.properties.fill.color;return t.fillColor||null}getShapeStrokeColor(t){const e=!!(t&&t.spPr&&t.spPr.ln||t&&t.properties&&t.properties.stroke||t&&t.stroke);if(!e)return null;if(this.processor&&this.processor.getShapeStrokeColor){const e=this.processor.getShapeStrokeColor(t);return e}const r=t.preservedStyle||t.style;if(r&&r.lnRef){if(this.processor&&this.processor.resolveStyleStrokeColor){const t=this.processor.resolveStyleStrokeColor(r.lnRef);if(t)return t}if(r.lnRef.color)return r.lnRef.color}if(t.stroke&&t.stroke.color)return t.stroke.color;if(t.properties&&t.properties.stroke&&t.properties.stroke.color)return t.properties.stroke.color;const o=t.strokeColor||null;return o}getShapeLineWidth(t){if(this.processor&&this.processor.getShapeLineWidth)return this.processor.getShapeLineWidth(t);const e=!!(t&&t.spPr&&t.spPr.ln||t&&t.properties&&t.properties.stroke||t&&t.stroke);if(!e)return 0;if(t.stroke&&t.stroke.width)return t.stroke.width/914400*25.4;if(t.properties&&t.properties.stroke&&t.properties.stroke.width)return t.properties.stroke.width/914400*25.4;if(t.spPr&&t.spPr.ln&&t.spPr.ln.w)return t.spPr.ln.w/914400*25.4;return 0}getShapeStrokeInfo(t){if(this.processor&&this.processor.getShapeStrokeInfo)return this.processor.getShapeStrokeInfo(t);if(t.stroke)return t.stroke;if(t.properties&&t.properties.stroke)return t.properties.stroke;return null}getShapeStrokeInfoLegacy(t){if(this.processor&&this.processor.getShapeStrokeInfo)return this.processor.getShapeStrokeInfo(t);if(t.stroke)return t.stroke;if(t.properties&&t.properties.stroke)return t.properties.stroke;return null}getParagraphProperties(t){return t.properties||{}}getRunProperties(t,e){return{...e,...t.properties||{}}}parseColor(t){if("string"===typeof t)if(t.startsWith("#")){const e=t.slice(1);return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16),a:255}}if(t&&"object"===typeof t)return t;return null}clipTextRect(t){this.graphics.AddClipRect(t.x,t.y,t.w,t.h)}getCanvasBounds(t){const e=t.getTransform();let r,o;if(t.canvas.style.width&&t.canvas.style.height){r=parseFloat(t.canvas.style.width);o=parseFloat(t.canvas.style.height)}else{r=t.canvas.width/(window.devicePixelRatio||1);o=t.canvas.height/(window.devicePixelRatio||1)}return this.currentShapeBounds||{x:0,y:0,w:r,h:o}}createCanvasGradient(t,e,r){if(!r||!r.stops||0===r.stops.length)return null;let o;if("linear"===r.type){const s=r.angle||0;const i=s*Math.PI/180;const n=e.x+e.w/2-Math.cos(i)*e.w/2;const a=e.y+e.h/2-Math.sin(i)*e.h/2;const l=e.x+e.w/2+Math.cos(i)*e.w/2;const c=e.y+e.h/2+Math.sin(i)*e.h/2;o=t.createLinearGradient(n,a,l,c)}else if("radial"===r.type){const r=e.x+e.w/2;const s=e.y+e.h/2;const i=Math.max(e.w,e.h)/2;o=t.createRadialGradient(r,s,0,r,s,i)}else return null;for(const t of r.stops){const e=this.colorToRgb(t.color);o.addColorStop(t.position,e)}return o}colorToRgbAlternative2(t){if("string"===typeof t)return t;if(t&&"object"===typeof t){const e=t.r||t.R||0;const r=t.g||t.G||0;const o=t.b||t.B||0;const s=(void 0!==t.a?t.a:void 0!==t.A?t.A:255)/255;return`rgba(${e}, ${r}, ${o}, ${s})`}return"#000000"}findLayoutShapeForPlaceholder(t,e){if(!e||!e.placeholder||!t)return null;const r=e.placeholder;for(const e of t)if(e.placeholder){const t=e.placeholder;const o=void 0===r.idx||null===r.idx||isNaN(Number(r.idx))?void 0:Number(r.idx);const s=void 0===t.idx||null===t.idx||isNaN(Number(t.idx))?void 0:Number(t.idx);const i=(t,e)=>{if(t===e)return true;const r=new Set([t,e]);if(r.has("title")&&r.has("ctrTitle"))return true;if(r.has("body")&&r.has("obj"))return true;return false};if(i(t.type,r.type)&&void 0!==o&&void 0!==s&&o===s)return e;if(i(t.type,r.type)&&(void 0===o||void 0===s))return e}return null}resolveInheritedTextProperties(t,e="run",r=0){const o={};try{const s=this.buildSlideContext();let i="otherStyle";if(t&&t.placeholder)switch(t.placeholder.type){case"title":case"ctrTitle":i="titleStyle";break;case"body":case"subTitle":case"obj":i="bodyStyle";break;default:i="otherStyle"}if(s.theme){if(s.theme.fonts){const t="titleStyle"===i;o.fontFamily=t?s.theme.fonts.major:s.theme.fonts.minor}if(s.theme.colors&&s.theme.colors.text1)o.color=this.parseColorFromTheme(s.theme.colors.text1)}if(s.master&&s.master.txStyles){const t=s.master.txStyles[i];if(t){const s=this.extractTextPropertiesFromStyle(t,e,r);Object.assign(o,s)}}if(s.layout&&s.layout.txStyles){const t=s.layout.txStyles[i];if(t){const s=this.extractTextPropertiesFromStyle(t,e,r);Object.assign(o,s)}}let n=false;if(s.layout&&s.layout.shapes){const e=this.findLayoutShapeForPlaceholder(s.layout.shapes,t);if(e&&e.textBody&&e.textBody.lstStyle){n=true;const r=e.textBody.lstStyle;let s=0;try{if(t&&t.textBody&&Array.isArray(t.textBody.paragraphs)&&t.textBody.paragraphs.length>0){const e=t.textBody.paragraphs[0]?.properties?.level;if("number"===typeof e&&e>=0&&e<=8)s=e}}catch(t){}const i=`lvl${s+1}pPr`;const a=r[i]||r.lvl1pPr;if(a){if(a.fontSize)o.fontSize=a.fontSize;if(a.fontFamily)o.fontFamily=a.fontFamily;if(a.color)o.color=a.color;if(void 0!==a.bold)o.bold=a.bold;if(void 0!==a.italic)o.italic=a.italic;if(a.align)o.align=a.align;if(a.cap)o.cap=a.cap}}}if((!o.fontSize||!o.align||!o.fontFamily)&&s.master&&s.master.cSld&&s.master.cSld.spTree){const e=s.master.cSld.spTree;const r=this.findLayoutShapeForPlaceholder(e,t);if(r&&r.textBody&&r.textBody.lstStyle){const t=r.textBody.lstStyle;if(t.lvl1pPr){const e=t.lvl1pPr;if(!o.fontSize&&e.fontSize)o.fontSize=e.fontSize;if(!o.fontFamily&&e.fontFamily)o.fontFamily=e.fontFamily;if(!o.color&&e.color)o.color=e.color;if(void 0!==e.bold&&void 0===o.bold)o.bold=e.bold;if(void 0!==e.italic&&void 0===o.italic)o.italic=e.italic;if(!o.align&&e.align)o.align=e.align;if(!o.cap&&e.cap)o.cap=e.cap}}}if(t&&t.placeholder)switch(t.placeholder.type){case"title":case"ctrTitle":if(void 0===o.bold&&!n)o.bold=true}if("title"===t?.placeholder?.type||"ctrTitle"===t?.placeholder?.type){if(!o.align)o.align="ctr";if(!o.fontSize)o.fontSize=44}}catch(t){}return o}extractTextPropertiesFromStyle(t,e="run",r=0){const o={};if(!t||!t.element)return o;try{if(!t.parsed){t.parsedData=this.parseTextStyleElement(t.element);t.parsed=true}const s=t.parsedData;if(!s)return o;if("paragraph"===e||"run"===e){const t=s.defPPr;if(t){if(t.align)o.align=t.align;if(t.lineHeight)o.lineHeight=t.lineHeight;if(t.spaceBefore)o.spaceBefore=t.spaceBefore;if(t.spaceAfter)o.spaceAfter=t.spaceAfter;if(t.bullet)o.bullet=t.bullet}const e=s.defRPr;if(e){if(e.fontSize)o.fontSize=e.fontSize;if(e.fontFamily)o.fontFamily=e.fontFamily;if(e.color)o.color=e.color;if(void 0!==e.bold)o.bold=e.bold;if(void 0!==e.italic)o.italic=e.italic;if(void 0!==e.underline)o.underline=e.underline;if(void 0!==e.strike)o.strike=e.strike;if(e.cap)o.cap=e.cap}const i=r+1;const n=s[`lvl${i}pPr`];if(n){if(n.align)o.align=n.align;if(n.lineHeight)o.lineHeight=n.lineHeight;if(n.bullet)o.bullet=n.bullet;if(void 0!==n.leftMargin)o.leftMargin=n.leftMargin;if(void 0!==n.indent)o.hangingIndent=n.indent;if(void 0!==n.spaceBefore)o.spaceBefore=n.spaceBefore;if(void 0!==n.spaceBeforePct)o.spaceBeforePct=n.spaceBeforePct;if(void 0!==n.spaceAfter)o.spaceAfter=n.spaceAfter;if(void 0!==n.spaceAfterPct)o.spaceAfterPct=n.spaceAfterPct;if(n.defRPr){const t=n.defRPr;if(t.fontSize)o.fontSize=t.fontSize;if(t.fontFamily)o.fontFamily=t.fontFamily;if(t.color)o.color=t.color;if(void 0!==t.bold)o.bold=t.bold;if(void 0!==t.italic)o.italic=t.italic;if(t.cap)o.cap=t.cap}}}}catch(t){}return o}parseColorFromTheme(t){if("string"===typeof t)if(t.startsWith("#")){const e=t.substring(1);const r=parseInt(e.substring(0,2),16);const o=parseInt(e.substring(2,4),16);const s=parseInt(e.substring(4,6),16);return{r,g:o,b:s,a:255}}return null}parseTextStyleElement(t){const e={};if(!t)return e;try{const r=t.querySelector("defPPr, a\\:defPPr");if(r)e.defPPr=this.parseStyleParagraphProperties(r);const o=t.querySelector("defRPr, a\\:defRPr")||t.querySelector("defPPr > defRPr, a\\:defPPr > a\\:defRPr");if(o)e.defRPr=this.parseStyleRunProperties(o);for(let r=1;r<=9;r++){const o=t.querySelector(`lvl${r}pPr, a\\:lvl${r}pPr`);if(o){const t=this.parseStyleParagraphProperties(o);const s=o.querySelector("defRPr, a\\:defRPr");if(s)t.defRPr=this.parseStyleRunProperties(s);e[`lvl${r}pPr`]=t}}}catch(t){}return e}parseStyleParagraphProperties(t){const e={};if(!t)return e;try{const r=t.getAttribute("algn")||t.getAttribute("align");if(r){const t={l:"left",left:"left",ctr:"center",center:"center",r:"right",right:"right",just:"justify",justify:"justify"};e.align=t[r]||r}const o=t.getAttribute("lnSpc")||t.getAttribute("lineHeight");if(o)e.lineHeight=parseInt(o)||120;const s=t.querySelector("spcBef, a\\:spcBef");if(s){const t=s.querySelector("spcPct, a\\:spcPct");const r=s.querySelector("spcPts, a\\:spcPts");if(t)e.spaceBeforePct=parseInt(t.getAttribute("val"))/1e5;else if(r)e.spaceBefore=127*parseInt(r.getAttribute("val"))}const i=t.querySelector("spcAft, a\\:spcAft");if(i){const t=i.querySelector("spcPct, a\\:spcPct");const r=i.querySelector("spcPts, a\\:spcPts");if(t)e.spaceAfterPct=parseInt(t.getAttribute("val"))/1e5;else if(r)e.spaceAfter=127*parseInt(r.getAttribute("val"))}const n=t.getAttribute("marL")||t.getAttribute("leftMargin");if(n)e.leftMargin=parseInt(n)||0;const a=t.getAttribute("marR")||t.getAttribute("rightMargin");if(a)e.rightMargin=parseInt(a)||0;const l=t.getAttribute("indent");if(l)e.indent=parseInt(l)||0;const c=t.querySelector("buChar, a\\:buChar");if(c){const t=c.getAttribute("char");if(t)e.bullet={type:"character",char:t}}const h=t.querySelector("buAutoNum, a\\:buAutoNum");if(h){const t=h.getAttribute("type")||"arabicPeriod";const r=h.getAttribute("startAt")||"1";e.bullet={type:"autoNumber",subType:t,startAt:parseInt(r)}}const u=t.querySelector("buNone, a\\:buNone");if(u)e.bullet={type:"none"}}catch(t){}return e}parseStyleRunProperties(t){const e={};if(!t)return e;try{const r=t.getAttribute("sz")||t.getAttribute("fontSize");if(r){const t=parseInt(r);e.fontSize=t>100?t/100:t}const o=t.getAttribute("typeface")||t.getAttribute("fontFamily");if(o)e.fontFamily=o;const s=t.getAttribute("b")||t.getAttribute("bold");if(null!==s)e.bold="1"===s||"true"===s||true===s;const i=t.getAttribute("i")||t.getAttribute("italic");if(null!==i)e.italic="1"===i||"true"===i||true===i;const n=t.getAttribute("u")||t.getAttribute("underline");if(null!==n)e.underline="none"!==n&&""!==n&&"0"!==n&&"false"!==n;const a=t.getAttribute("strike")||t.getAttribute("strikethrough");if(null!==a)e.strike="noStrike"!==a&&"0"!==a&&"false"!==a&&false!==a;const l=t.getAttribute("cap")||t.getAttribute("capitalization");if(l)e.cap=l;const c=t.querySelector("solidFill, a\\:solidFill")||t.querySelector("schemeClr, a\\:schemeClr")||t.querySelector("srgbClr, a\\:srgbClr");if(c)e.color=this.parseColorFromElement(c);const h=t.getAttribute("spc")||t.getAttribute("letterSpacing");if(h)e.letterSpacing=parseInt(h)||0}catch(t){}return e}parseColorFromElement(t){try{const e=t.querySelector("srgbClr, a\\:srgbClr");if(e){const t=e.getAttribute("val");if(t&&6===t.length){const e=parseInt(t.substr(0,2),16);const r=parseInt(t.substr(2,2),16);const o=parseInt(t.substr(4,2),16);return{r:e,g:r,b:o,a:255}}}const r=t.querySelector("schemeClr, a\\:schemeClr");if(r){const t=r.getAttribute("val");const e={};return e[t]||null}}catch(t){}return null}buildSlideContext(){const t={};if(this.currentSlide){t.slide=this.currentSlide;if(this.currentSlide.layout||this.currentSlide.Layout){t.layout=this.currentSlide.layout||this.currentSlide.Layout;if(t.layout.commonSlideData&&t.layout.commonSlideData.shapeTree)t.layout.shapes=t.layout.commonSlideData.shapeTree;else if(t.layout.cSld&&t.layout.cSld.spTree)t.layout.shapes=t.layout.cSld.spTree;if(t.layout.master||t.layout.Master)t.master=t.layout.master||t.layout.Master}if(this.currentSlide.theme||this.currentSlide.Theme)t.theme=this.currentSlide.theme||this.currentSlide.Theme}return t}getCurrentShape(){return this.currentRenderingShape||null}applyPreciseTransform(t,e=1,r=0){return Math.round(t*e+r)}setCurrentRenderingShape(t){this.currentRenderingShape=t}}class r{constructor(){this.cache=new Map}processShapeGeometry(t){const e=this.generateCacheKey(t);if(this.cache.has(e))return this.cache.get(e);let r=null;if(t.geometry&&"custom"===t.geometry.type)r=this.processCustomGeometry(t.geometry);else if(t.properties&&t.properties.geometry&&"custom"===t.properties.geometry.type)r=this.processCustomGeometry(t.properties.geometry);if(r)this.cache.set(e,r);return r}processCustomGeometry(t){if(!t.pathLst||0===t.pathLst.length)return null;const e={type:"custom",pathLst:[]};for(const r of t.pathLst){const t=this.processPath(r);if(t)e.pathLst.push(t)}return e}processPath(t){if(!t.commands||0===t.commands.length)return null;return{w:t.w||100,h:t.h||100,commands:t.commands.map(t=>this.normalizeCommand(t)),fill:false!==t.fill,stroke:false!==t.stroke}}normalizeCommand(t){const e={...t};switch(t.type){case"M":case"moveTo":e.type="moveTo";break;case"L":case"lineTo":e.type="lineTo";break;case"C":case"curveTo":case"cubicBezTo":e.type="cubicBezTo";break;case"Q":case"quadTo":case"quadBezTo":e.type="quadBezTo";break;case"A":case"arcTo":e.type="arcTo";break;case"Z":case"close":e.type="close"}return e}generateCacheKey(t){const e=t.geometry||t.properties?.geometry;if(!e)return"no-geometry";const r=e.pathLst||[];return`custom-${JSON.stringify(r).substring(0,100)}-${r.length}`}}if("undefined"!==typeof window){window.CanvasGraphicsAdapter=CanvasGraphicsAdapter;window.CDrawingDocument=CDrawingDocument;window.GraphicsMatrix=e;try{t()}catch(t){}}if("undefined"===typeof Logger&&"undefined"!==typeof window)window.Logger=class Logger{constructor(t){this.name=t}log(t,e,r){}logError(t,e){}};return tt}var ot=rt();var st=s(ot);var it={exports:{}};var nt=it.exports;var at;function lt(){if(at)return it.exports;at=1;!function(t){const e=0;const r=1;const o=2;const s=3;const i=4;const n=5;const a=6;const l=7;const c=8;const h=9;const u=10;const f=11;const d=12;const p=13;const g=14;const m=15;const y=16;const b={w:"w",h:"h",ss:"ss",ls:"ls",hc:"hc",vc:"vc",l:"l",t:"t",r:"r",b:"b",wd2:"wd2",hd2:"hd2",wd4:"wd4",hd4:"hd4",wd6:"wd6",hd6:"hd6",wd8:"wd8",hd8:"hd8",cd2:"cd2",cd4:"cd4",cd8:"cd8",_3cd4:"_3cd4",_3cd8:"_3cd8",_5cd8:"_5cd8",_7cd8:"_7cd8"};const x={rect:1,roundRect:2,ellipse:3,diamond:4,triangle:5,rtTriangle:6,parallelogram:7,trapezoid:8,hexagon:9,octagon:10,plus:11,star5:12,rightArrow:13,leftArrow:66,upArrow:68,downArrow:67,leftRightArrow:69,upDownArrow:70,quadArrow:76,heart:74,lightningBolt:73,can:22,cube:16,donut:23,arc:19,line:20,plaque:21,bevel:1e3,frame:75,pentagon:56,star4:1e3,star6:1e3,star8:58,star12:1e3,star16:59,star24:1e3,star32:60,teardrop:1e3,flowChartProcess:1e3,flowChartDecision:4,flowChartTerminator:2,flowChartInputOutput:7,flowChartDocument:1e3,flowChartMultidocument:1e3,flowChartPreparation:1e3,flowChartManualInput:1e3,flowChartManualOperation:1e3,flowChartConnector:3,flowChartOffpageConnector:1e3,flowChartPunchedCard:1e3,flowChartPunchedTape:1e3,flowChartSummingJunction:1e3,flowChartOr:1e3,flowChartCollate:1e3,flowChartSort:1e3,flowChartExtract:1e3,flowChartMerge:1e3,flowChartStoredData:1e3,flowChartDelay:1e3,flowChartSequentialAccessStorage:1e3,flowChartMagneticDisk:1e3,flowChartDirectAccessStorage:1e3,flowChartDisplay:1e3,flowChartInternalStorage:1e3,flowChartAlternateProcess:1e3,flowChartMagneticDrum:1e3,flowChartMagneticTape:1e3,callout1:1e3,callout2:1e3,callout3:1e3,accentCallout1:1e3,accentCallout2:1e3,accentCallout3:1e3,borderCallout1:1e3,borderCallout2:1e3,borderCallout3:1e3,accentBorderCallout1:1e3,accentBorderCallout2:1e3,accentBorderCallout3:1e3,ribbon:1e3,ribbon2:1e3,ellipseRibbon:1e3,ellipseRibbon2:1e3,leftRightRibbon:1e3,verticalScroll:1e3,horizontalScroll:1e3,wave:1e3,doubleWave:1e3,bentArrow:1e3,uturnArrow:1e3,circularArrow:1e3,leftUpArrow:1e3,bentUpArrow:1e3,curvedRightArrow:1e3,curvedLeftArrow:1e3,curvedUpArrow:1e3,curvedDownArrow:1e3,stripedRightArrow:1e3,notchedRightArrow:1e3,blockArc:1e3,swooshArrow:1e3,leftBracket:1e3,rightBracket:1e3,leftBrace:1e3,rightBrace:1e3,bracketPair:1e3,bracePair:1e3,straightConnector1:20,bentConnector2:1e3,bentConnector3:1e3,bentConnector4:1e3,bentConnector5:1e3,curvedConnector2:1e3,curvedConnector3:1e3,curvedConnector4:1e3,curvedConnector5:1e3,sun:1e3,moon:1e3,cloud:1e3,irregularSeal1:1e3,irregularSeal2:1e3,foldedCorner:1e3,smileyFace:1e3,noSmoking:1e3,mathPlus:11,mathMinus:1e3,mathMultiply:1e3,mathDivide:1e3,mathEqual:1e3,mathNotEqual:1e3,actionButtonBlank:1e3,actionButtonHome:1e3,actionButtonHelp:1e3,actionButtonInformation:1e3,actionButtonForwardNext:1e3,actionButtonBackPrevious:1e3,actionButtonEnd:1e3,actionButtonBeginning:1e3,actionButtonReturn:1e3,actionButtonDocument:1e3,actionButtonSound:1e3,actionButtonMovie:1e3};const S={RECTANGLE:"rect",ELLIPSE:"ellipse",LINE:"line",ROUND_RECTANGLE:"roundRect",RIGHT_ARROW:"rightArrow",LEFT_ARROW:"leftArrow",UP_ARROW:"upArrow",DOWN_ARROW:"downArrow",LEFT_RIGHT_ARROW:"leftRightArrow",UP_DOWN_ARROW:"upDownArrow",QUAD_ARROW:"quadArrow",LEFT_RIGHT_UP_ARROW:"leftRightUpArrow",BENT_ARROW:"bentArrow",UTURN_ARROW:"uturnArrow",LEFT_UP_ARROW:"leftUpArrow",BENT_UP_ARROW:"bentUpArrow",CURVED_RIGHT_ARROW:"curvedRightArrow",CURVED_LEFT_ARROW:"curvedLeftArrow",CURVED_UP_ARROW:"curvedUpArrow",CURVED_DOWN_ARROW:"curvedDownArrow",STRIPED_RIGHT_ARROW:"stripedRightArrow",NOTCHED_RIGHT_ARROW:"notchedRightArrow",BLOCK_ARC:"blockArc",SWOOSH_ARROW:"swooshArrow",CIRCULAR_ARROW:"circularArrow",FLOWCHART_PROCESS:"flowChartProcess",FLOWCHART_DECISION:"flowChartDecision",FLOWCHART_START_END:"flowChartTerminator",FLOWCHART_INPUT_OUTPUT:"flowChartInputOutput",FLOWCHART_PREDEFINED_PROCESS:"flowChartPredefinedProcess",FLOWCHART_INTERNAL_STORAGE:"flowChartInternalStorage",FLOWCHART_DOCUMENT:"flowChartDocument",FLOWCHART_MULTIDOCUMENT:"flowChartMultidocument",FLOWCHART_PREPARATION:"flowChartPreparation",FLOWCHART_MANUAL_INPUT:"flowChartManualInput",FLOWCHART_MANUAL_OPERATION:"flowChartManualOperation",FLOWCHART_CONNECTOR:"flowChartConnector",FLOWCHART_OFFPAGE_CONNECTOR:"flowChartOffpageConnector",FLOWCHART_PUNCHED_CARD:"flowChartPunchedCard",FLOWCHART_PUNCHED_TAPE:"flowChartPunchedTape",FLOWCHART_SUMMING_JUNCTION:"flowChartSummingJunction",FLOWCHART_OR:"flowChartOr",FLOWCHART_COLLATE:"flowChartCollate",FLOWCHART_SORT:"flowChartSort",FLOWCHART_EXTRACT:"flowChartExtract",FLOWCHART_MERGE:"flowChartMerge",FLOWCHART_STORED_DATA:"flowChartStoredData",FLOWCHART_DELAY:"flowChartDelay",FLOWCHART_SEQUENTIAL_ACCESS_STORAGE:"flowChartSequentialAccessStorage",FLOWCHART_MAGNETIC_DISK:"flowChartMagneticDisk",FLOWCHART_DIRECT_ACCESS_STORAGE:"flowChartDirectAccessStorage",FLOWCHART_DISPLAY:"flowChartDisplay",FLOWCHART_ALTERNATE_PROCESS:"flowChartAlternateProcess",FLOWCHART_MAGNETIC_DRUM:"flowChartMagneticDrum",FLOWCHART_MAGNETIC_TAPE:"flowChartMagneticTape",CALLOUT_1:"callout1",CALLOUT_2:"callout2",CALLOUT_3:"callout3",ACCENT_CALLOUT_1:"accentCallout1",ACCENT_CALLOUT_2:"accentCallout2",ACCENT_CALLOUT_3:"accentCallout3",BORDER_CALLOUT_1:"borderCallout1",BORDER_CALLOUT_2:"borderCallout2",BORDER_CALLOUT_3:"borderCallout3",ACCENT_BORDER_CALLOUT_1:"accentBorderCallout1",ACCENT_BORDER_CALLOUT_2:"accentBorderCallout2",ACCENT_BORDER_CALLOUT_3:"accentBorderCallout3",STAR_4:"star4",STAR_5:"star5",STAR_6:"star6",STAR_8:"star8",STAR_12:"star12",STAR_16:"star16",STAR_24:"star24",STAR_32:"star32",TRIANGLE:"triangle",RIGHT_TRIANGLE:"rtTriangle",DIAMOND:"diamond",PENTAGON:"pentagon",HEXAGON:"hexagon",HEPTAGON:"heptagon",OCTAGON:"octagon",DECAGON:"decagon",DODECAGON:"dodecagon",PARALLELOGRAM:"parallelogram",TRAPEZOID:"trapezoid",PLUS:"plus",CROSS:"cross",STRAIGHT_CONNECTOR_1:"straightConnector1",BENT_CONNECTOR_2:"bentConnector2",BENT_CONNECTOR_3:"bentConnector3",BENT_CONNECTOR_4:"bentConnector4",BENT_CONNECTOR_5:"bentConnector5",CURVED_CONNECTOR_2:"curvedConnector2",CURVED_CONNECTOR_3:"curvedConnector3",CURVED_CONNECTOR_4:"curvedConnector4",CURVED_CONNECTOR_5:"curvedConnector5",RIBBON:"ribbon",RIBBON_2:"ribbon2",ELLIPSE_RIBBON:"ellipseRibbon",ELLIPSE_RIBBON_2:"ellipseRibbon2",LEFT_RIGHT_RIBBON:"leftRightRibbon",VERTICAL_SCROLL:"verticalScroll",HORIZONTAL_SCROLL:"horizontalScroll",WAVE:"wave",DOUBLE_WAVE:"doubleWave",LEFT_BRACKET:"leftBracket",RIGHT_BRACKET:"rightBracket",LEFT_BRACE:"leftBrace",RIGHT_BRACE:"rightBrace",BRACKET_PAIR:"bracketPair",BRACE_PAIR:"bracePair",FRAME:"frame",L_SHAPE:"lShape",DIAGONAL_STRIPE:"diagStripe",CHORD:"chord",ARC:"arc",CUBE:"cube",CAN:"can",CONE:"cone",PYRAMID:"pyramid",HEART:"heart",LIGHTNING_BOLT:"lightningBolt",SUN:"sun",MOON:"moon",CLOUD:"cloud",SMILEY_FACE:"smileyFace",IRREGULAR_SEAL_1:"irregularSeal1",IRREGULAR_SEAL_2:"irregularSeal2",FOLDED_CORNER:"foldedCorner",BEVEL:"bevel",DONUT:"donut",NO_SMOKING:"noSmoking",BLOCK_ARC_2:"blockArc2",PLUS_MATH:"mathPlus",MINUS:"mathMinus",MULTIPLY:"mathMultiply",DIVIDE:"mathDivide",EQUAL:"mathEqual",NOT_EQUAL:"mathNotEqual",ACTION_BUTTON_BLANK:"actionButtonBlank",ACTION_BUTTON_HOME:"actionButtonHome",ACTION_BUTTON_HELP:"actionButtonHelp",ACTION_BUTTON_INFORMATION:"actionButtonInformation",ACTION_BUTTON_FORWARD_NEXT:"actionButtonForwardNext",ACTION_BUTTON_BACK_PREVIOUS:"actionButtonBackPrevious",ACTION_BUTTON_END:"actionButtonEnd",ACTION_BUTTON_BEGINNING:"actionButtonBeginning",ACTION_BUTTON_RETURN:"actionButtonReturn",ACTION_BUTTON_DOCUMENT:"actionButtonDocument",ACTION_BUTTON_SOUND:"actionButtonSound",ACTION_BUTTON_MOVIE:"actionButtonMovie",TEARDROP:"teardrop"};class CGraphics{constructor(t){this.setupHighResolutionCanvas(t);this.m_oContext=t.getContext("2d");this.m_dDpiX=96;this.m_dDpiY=96;this.m_dWidthMM=210;this.m_dHeightMM=297;if(t.style.width&&t.style.height){this.m_dWidth=parseFloat(t.style.width);this.m_dHeight=parseFloat(t.style.height)}else{this.m_dWidth=t.width/(window.devicePixelRatio||1);this.m_dHeight=t.height/(window.devicePixelRatio||1)}this.m_oTransform=new C;this.devicePixelRatio=window.devicePixelRatio||1;this.m_oCoordTransform=new C;this.m_oFullTransform=new C;this.m_oTransformStack=[];this.m_oClipStack=[];this.m_oPen=new T;this.m_oBrush=new P;this.m_oFont=new v;this.m_bIntegerGrid=false;this.m_bGlobalAlpha=false;this.m_dGlobalAlpha=1;this.m_bIsClipping=false;this.m_oClipRect=null;this.m_oPath=null;this.m_bIsDrawing=false;this.m_oEnhancedGeometryProcessor=new R;this.m_oCustomGeometryProcessor=new GeometryProcessor;this.calculateCoordTransform();this.calculateFullTransform();this.m_oContext.lineCap="round";this.m_oContext.lineJoin="round";this.m_oContext.textBaseline="alphabetic";this.m_oContext.textAlign="left"}setupHighResolutionCanvas(t){const e=t.getContext("2d");const r=window.devicePixelRatio||1;const o=t.clientWidth||t.width;const s=t.clientHeight||t.height;t.width=o*r;t.height=s*r;t.style.width=o+"px";t.style.height=s+"px";e.scale(r,r);e.imageSmoothingEnabled=true;e.imageSmoothingQuality="high"}drawImageHighRes(image,t,e,r,o,s=0,i=0,n=null,a=null){if(!this.m_oContext||!image)return;this.m_oContext.save();this.m_oContext.imageSmoothingEnabled=true;this.m_oContext.imageSmoothingQuality="high";try{if(null!==n&&null!==a)this.m_oContext.drawImage(image,s,i,n,a,t,e,r,o);else this.m_oContext.drawImage(image,t,e,r,o)}catch(t){}finally{this.m_oContext.restore()}}drawImage(image,t,e,r,o){this.drawImageHighRes(image,t,e,r,o)}drawPresetGeometry(t,e,r,o,s,i,n,a=1,l=null,c={}){if(!this.m_oContext)return;this.SaveGrState();try{const h=x[t]||1e3;if(1e3===h)this.drawCustomShape(t,e,r,o,s,i,n,a,l,c);else this.drawStandardPresetShape(h,t,e,r,o,s,i,n,a,l,c)}catch(t){this.drawRectangle(e,r,o,s,i,n,a,l)}finally{this.RestoreGrState()}}drawStandardPresetShape(t,e,r,o,s,i,n,a,l,c,h){const u=21600;const f=21600;const d=this.m_oEnhancedGeometryProcessor.processPresetGeometry(e,u,f,h);if(d)this.renderEnhancedGeometry(d,r,o,s,i,n,a,l,c);else this.drawBasicShape(e,r,o,s,i,n,a,l,c)}renderEnhancedGeometry(t,e,r,o,s,i,n,a,l){const c=this.m_oContext;const h=t.getPathList();const u=o/t.width;const f=s/t.height;c.save();c.translate(e,r);c.scale(u,f);h.forEach(c=>{this.renderEnhancedPath(c,t,i,n,a,l,{x:e,y:r,w:o,h:s})});c.restore()}renderEnhancedPath(t,e,r,o,s,i,n=null){const a=this.m_oContext;a.beginPath();t.commands.forEach(t=>{switch(t.type){case"M":a.moveTo(t.args[0],t.args[1]);break;case"L":a.lineTo(t.args[0],t.args[1]);break;case"C":a.bezierCurveTo(t.args[0],t.args[1],t.args[2],t.args[3],t.args[4],t.args[5]);break;case"Q":a.quadraticCurveTo(t.args[0],t.args[1],t.args[2],t.args[3]);break;case"A":this.renderArcCommand(a,t.args);break;case"Z":a.closePath()}});if("none"!==t.fill&&r){if(r&&"object"===typeof r&&r.type&&r.stops){const t=n||{x:0,y:0,w:200,h:50};const e=this.createGradient(t.x,t.y,t.w,t.h,r);if(e)a.fillStyle=e;else a.fillStyle=this.colorToRgb(r.stops[0]?.color||{r:0,g:0,b:0})}else a.fillStyle=this.colorToRgb(r);a.fill()}if(t.stroke&&o){a.strokeStyle=this.colorToRgb(o);const t=CoordinateTransform.mmToPixels(s||1);const r=e?e.width:21600;const l=e?e.height:21600;const c=n&&n.w>0?n.w/r:1;const h=n&&n.h>0?n.h/l:1;const u=Math.min(c,h)||1;a.lineWidth=t/u;if(i)this.applyStrokeInfo(i);a.stroke()}}renderArcCommand(t,e){const[r,o,s,i,n,a,l]=e;const c=this.getCurrentPoint(t);if(!c)return;try{const e=(c.x+a)/2;const s=(c.y+l)/2;const i=Math.min(r,o);const h=Math.atan2(c.y-s,c.x-e);const u=Math.atan2(l-s,a-e);t.arc(e,s,i,h,u,!n)}catch(e){t.lineTo(a,l)}}getCurrentPoint(t){return{x:0,y:0}}drawCustomShape(t,e,r,o,s,i,n,a,l,c){const h=this.m_oCustomGeometryProcessor.processCustomShape(t,{x:e,y:r,width:o,height:s,adjustments:c});if(h&&h.pathLst)this.drawCustomGeometry(h,e,r,o,s,i,n,a);else this.drawBasicShape(t,e,r,o,s,i,n,a,l)}applyStrokeInfo(t){if(!t||!this.m_oContext)return;const e=this.m_oContext;if(t.dashArray&&t.dashArray.length>0){const r=e.lineWidth||1;const o=t.dashArray.map(t=>t*r);e.setLineDash(o)}const r=t.lineCap||t.cap;if(r)switch(r){case"rnd":case"round":e.lineCap="round";break;case"sq":case"square":e.lineCap="square";break;default:e.lineCap="butt"}const o=t.lineJoin||t.join;if(o)switch(o){case"round":e.lineJoin="round";break;case"bevel":e.lineJoin="bevel";break;default:e.lineJoin="miter"}if(t.miterLimit)e.miterLimit=t.miterLimit}drawBasicShape(t,e,r,o,s,i,n,a,l){const c=this.m_oContext;c.save();c.beginPath();switch(t){case"rect":case"rectangle":default:c.rect(e,r,o,s);break;case"ellipse":case"oval":c.ellipse(e+o/2,r+s/2,o/2,s/2,0,0,2*Math.PI);break;case"roundRect":this.drawRoundRectPath(c,e,r,o,s,.16667*Math.min(o,s));break;case"triangle":this.drawTrianglePath(c,e,r,o,s);break;case"diamond":this.drawDiamondPath(c,e,r,o,s);break;case"pentagon":this.drawPentagonPath(c,e,r,o,s);break;case"hexagon":this.drawHexagonPath(c,e,r,o,s);break;case"octagon":this.drawOctagonPath(c,e,r,o,s);break;case"star":case"star5":this.drawStarPath(c,e,r,o,s);break;case"rightArrow":this.drawRightArrowPath(c,e,r,o,s);break;case"leftArrow":this.drawLeftArrowPath(c,e,r,o,s);break;case"upArrow":this.drawUpArrowPath(c,e,r,o,s);break;case"downArrow":this.drawDownArrowPath(c,e,r,o,s)}if(i){c.fillStyle=this.colorToRgb(i);c.fill()}if(n){c.strokeStyle=this.colorToRgb(n);c.lineWidth=CoordinateTransform.mmToPixels(a||1);if(l)this.applyStrokeInfo(l);c.stroke()}c.restore()}drawCustomGeometry(t,e,r,o,s,i,n,a){try{if(!t||!t.pathLst||0===t.pathLst.length)return;this.m_oContext.save();this.m_oContext.translate(e,r);const l=t.coordSize?.width||1e3;const c=t.coordSize?.height||1e3;this.m_oContext.scale(o/l,s/c);t.pathLst.forEach((t,e)=>{this.drawGeometryPath(t,i,n,a)});this.m_oContext.restore()}catch(t){this.m_oContext.restore()}}drawGeometryPath(t,e,r,o){if(!t||!t.commands||0===t.commands.length)return;this.m_oContext.beginPath();t.commands.forEach(r=>{switch(r.type){case"moveTo":this.m_oContext.moveTo(r.x,r.y);break;case"lineTo":this.m_oContext.lineTo(r.x,r.y);break;case"curveTo":this.m_oContext.bezierCurveTo(r.x1,r.y1,r.x2,r.y2,r.x,r.y);break;case"close":if(e&&false!==t.fill&&"none"!==t.fill)this.m_oContext.closePath();break;case"arcTo":this.m_oContext.arcTo(r.x1,r.y1,r.x2,r.y2,r.radius);break;case"quadraticCurveTo":this.m_oContext.quadraticCurveTo(r.x1,r.y1,r.x,r.y)}});if(r&&false!==t.stroke){this.m_oContext.strokeStyle=this.colorToRgb(r);this.m_oContext.lineWidth=CoordinateTransform.mmToPixels(o||1);this.m_oContext.stroke()}if(e&&false!==t.fill&&"none"!==t.fill){this.m_oContext.fillStyle=this.colorToRgb(e);this.m_oContext.fill()}}drawShapePath(t,e,r,o,s){if(!t||!t.commands)return;this.m_oContext.beginPath();t.commands.forEach(t=>{switch(t.type){case"M":this.m_oContext.moveTo(t.x,t.y);break;case"L":this.m_oContext.lineTo(t.x,t.y);break;case"C":this.m_oContext.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":this.m_oContext.quadraticCurveTo(t.x1,t.y1,t.x,t.y);break;case"A":this.drawArcCommand(t);break;case"Z":if(e&&false!==path.fill&&"none"!==path.fill)this.m_oContext.closePath()}});if(e){this.m_oContext.fillStyle=this.colorToRgb(e);this.m_oContext.fill()}if(r){this.m_oContext.strokeStyle=this.colorToRgb(r);this.m_oContext.lineWidth=o||1;if(s)this.applyStrokeInfo(s);this.m_oContext.stroke()}}applyStrokeInfoAlternative(t){if(!t)return;if(t.dashArray&&t.dashArray.length>0)this.m_oContext.setLineDash(t.dashArray);if(t.lineCap)this.m_oContext.lineCap=t.lineCap;if(t.lineJoin)this.m_oContext.lineJoin=t.lineJoin;if(t.miterLimit)this.m_oContext.miterLimit=t.miterLimit}drawArcCommand(t){const e=t.cx||t.x;const r=t.cy||t.y;const o=t.r||t.radius;const s=t.startAngle||0;const i=t.endAngle||2*Math.PI;const n=t.counterclockwise||false;this.m_oContext.arc(e,r,o,s,i,n)}drawRectangle(t,e,r,o,s,i,n,a){if(!this.m_oContext)return;this.m_oContext.save();if(s){if("object"===typeof s&&s.type&&s.stops){const i=this.createGradient(t,e,r,o,s);this.m_oContext.fillStyle=i||this.colorToRgb(s.stops[0]?.color||{r:0,g:0,b:0})}else this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fillRect(t,e,r,o)}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;if(a)this.applyStrokeInfo(a);this.m_oContext.strokeRect(t,e,r,o)}this.m_oContext.restore()}drawEllipse(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const a=t+r/2;const l=e+o/2;const c=r/2;const h=o/2;this.m_oContext.ellipse(a,l,c,h,0,0,2*Math.PI);if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawRoundedRectangle(t,e,r,o,s,i,n,a){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const l=Math.min(r,o)/2;s=Math.min(s,l);this.m_oContext.moveTo(t+s,e);this.m_oContext.lineTo(t+r-s,e);this.m_oContext.quadraticCurveTo(t+r,e,t+r,e+s);this.m_oContext.lineTo(t+r,e+o-s);this.m_oContext.quadraticCurveTo(t+r,e+o,t+r-s,e+o);this.m_oContext.lineTo(t+s,e+o);this.m_oContext.quadraticCurveTo(t,e+o,t,e+o-s);this.m_oContext.lineTo(t,e+s);this.m_oContext.quadraticCurveTo(t,e,t+s,e);this.m_oContext.closePath();if(i){this.m_oContext.fillStyle=this.colorToRgb(i);this.m_oContext.fill()}if(n){this.m_oContext.strokeStyle=this.colorToRgb(n);this.m_oContext.lineWidth=a||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawTriangle(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();this.m_oContext.moveTo(t+r/2,e);this.m_oContext.lineTo(t+r,e+o);this.m_oContext.lineTo(t,e+o);this.m_oContext.closePath();if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawDiamond(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const a=t+r/2;const l=e+o/2;this.m_oContext.moveTo(a,e);this.m_oContext.lineTo(t+r,l);this.m_oContext.lineTo(a,e+o);this.m_oContext.lineTo(t,l);this.m_oContext.closePath();if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawRegularPolygon(t,e,r,o,s,i,n,a){if(!this.m_oContext||s<3)return;this.m_oContext.save();this.m_oContext.beginPath();const l=t+r/2;const c=e+o/2;const h=Math.min(r,o)/2;for(let t=0;t{const e=(t||"").toString().toLowerCase();if("lg"===e||"large"===e)return 3;if("med"===e||"medium"===e)return 2;if("sm"===e||"small"===e)return 1;return 2};let u=n&&n.headEnd?{type:n.headEnd.type||n.headEnd.val||"none",lengthScale:h(n.headEnd.len),widthScale:h(n.headEnd.w)}:null;let f=n&&n.tailEnd?{type:n.tailEnd.type||n.tailEnd.val||"none",lengthScale:h(n.tailEnd.len),widthScale:h(n.tailEnd.w)}:null;if(u&&("none"===u.type||null===u.type||void 0===u.type))u=null;if(f&&("none"===f.type||null===f.type||void 0===f.type))f=null;if(u||f){const s=Math.atan2(o-e,r-t);const i=a.getTransform();const n=Math.sqrt(i.a*i.a+i.b*i.b);const c=3*a.lineWidth;const h=2.5*a.lineWidth;if(u){const r=u.lengthScale||1;const o=u.widthScale||1;this._drawArrowHead(a,t,e,s+Math.PI,c*r,h*o,l,a.lineWidth,u.type)}if(f){const t=f.lengthScale||1;const e=f.widthScale||1;this._drawArrowHead(a,r,o,s,c*t,h*e,l,a.lineWidth,f.type)}}a.restore()}_drawArrowHead(t,e,r,o,s,i,n,a,l="triangle"){t.save();t.translate(e,r);t.rotate(o);const c=i/2;const h=(l||"triangle").toString().toLowerCase();t.beginPath();switch(h){case"open":t.moveTo(0,0);t.lineTo(-s,-c);t.moveTo(0,0);t.lineTo(-s,c);break;case"stealth":t.moveTo(0,0);t.lineTo(-s,-.5*c);t.lineTo(.85*-s,0);t.lineTo(-s,.5*c);t.closePath();break;case"diamond":t.moveTo(0,0);t.lineTo(-s/2,-c);t.lineTo(-s,0);t.lineTo(-s/2,c);t.closePath();break;case"oval":t.ellipse(-s/2,0,s/2,c,0,0,2*Math.PI);break;default:t.moveTo(0,0);t.lineTo(-s,-c);t.lineTo(-s,c);t.closePath()}const u="string"===typeof n?n:this.colorToRgb(n)||"rgba(0,0,0,1)";if("open"===h){t.strokeStyle=u;t.lineWidth=a||1;t.stroke()}else{t.fillStyle=u;t.fill();t.strokeStyle=u;t.lineWidth=Math.max(.5,.3*(a||1));t.stroke()}t.restore()}darkenColor(t,e){if("string"===typeof t){const r=this.hexToRgb(t);return{r:Math.floor(r.r*e),g:Math.floor(r.g*e),b:Math.floor(r.b*e),a:r.a}}else if(void 0!==t.r)return{r:Math.floor(t.r*e),g:Math.floor(t.g*e),b:Math.floor(t.b*e),a:t.a};return t}colorToRgb(t){if("string"===typeof t)return t;else if(t&&void 0!==t.r){const e=void 0!==t.a?t.a/255:1;return`rgba(${t.r}, ${t.g}, ${t.b}, ${e})`}return null}createGradient(t,e,r,o,s){if(!this.m_oContext||!s||!s.stops||0===s.stops.length)return null;let i;if("linear"===s.type){const n=s.angle||0;const a=n*Math.PI/180;const l=t+r/2-Math.cos(a)*r/2;const c=e+o/2-Math.sin(a)*o/2;const h=t+r/2+Math.cos(a)*r/2;const u=e+o/2+Math.sin(a)*o/2;i=this.m_oContext.createLinearGradient(l,c,h,u)}else{const s=t+r/2;const n=e+o/2;const a=Math.max(r,o)/2;i=this.m_oContext.createRadialGradient(s,n,0,s,n,a)}for(const t of s.stops)i.addColorStop(t.position,this.colorToRgb(t.color));return i}fillRect(t,e,r,o,s){if(!this.m_oContext||!s)return;this.m_oContext.save();if(s&&"object"===typeof s&&"linear"===s.type&&s.stops){const i=this.createGradient(t,e,r,o,s);if(i)this.m_oContext.fillStyle=i;else this.m_oContext.fillStyle=this.colorToRgb(s.stops[0]?.color||{r:0,g:0,b:0})}else this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fillRect(t,e,r,o);this.m_oContext.restore()}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16),a:255}:{r:0,g:0,b:0,a:255}}SaveGrState(){this.m_oContext.save();this.m_oTransformStack.push(this.m_oTransform.CreateDublicate())}RestoreGrState(){this.m_oContext.restore();if(this.m_oTransformStack.length>0)this.m_oTransform=this.m_oTransformStack.pop()}calculateCoordTransform(){this.m_oCoordTransform.Reset();this.m_oCoordTransform.sx=this.m_dWidth/this.m_dWidthMM;this.m_oCoordTransform.sy=this.m_dHeight/this.m_dHeightMM}calculateFullTransform(){this.m_oFullTransform=this.m_oCoordTransform.CreateDublicate();this.m_oFullTransform.Multiply(this.m_oTransform,1)}drawRoundRectPath(t,e,r,o,s,i){t.beginPath();t.moveTo(e+i,r);t.lineTo(e+o-i,r);t.quadraticCurveTo(e+o,r,e+o,r+i);t.lineTo(e+o,r+s-i);t.quadraticCurveTo(e+o,r+s,e+o-i,r+s);t.lineTo(e+i,r+s);t.quadraticCurveTo(e,r+s,e,r+s-i);t.lineTo(e,r+i);t.quadraticCurveTo(e,r,e+i,r)}drawTrianglePath(t,e,r,o,s){t.moveTo(e+o/2,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.closePath()}drawDiamondPath(t,e,r,o,s){t.moveTo(e+o/2,r);t.lineTo(e+o,r+s/2);t.lineTo(e+o/2,r+s);t.lineTo(e,r+s/2);t.closePath()}drawPentagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.moveTo(i,r);for(let e=1;e<5;e++){const r=2*e*Math.PI/5-Math.PI/2;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);t.lineTo(o,s)}t.closePath()}drawHexagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.moveTo(i+a,n);for(let e=1;e<6;e++){const r=e*Math.PI/3;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);t.lineTo(o,s)}t.closePath()}drawOctagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.moveTo(i+a,n);for(let e=1;e<8;e++){const r=e*Math.PI/4;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);t.lineTo(o,s)}t.closePath()}drawStarPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;const l=.4*a;t.moveTo(i,r);for(let e=0;e<10;e++){const r=e*Math.PI/5-Math.PI/2;const o=e%2===0?a:l;const s=i+o*Math.cos(r);const c=n+o*Math.sin(r);t.lineTo(s,c)}t.closePath()}drawRightArrowPath(t,e,r,o,s){const i=.6*o;const n=s;const a=.6*s;const l=r+(s-a)/2;t.moveTo(e,l);t.lineTo(e+i,l);t.lineTo(e+i,r);t.lineTo(e+o,r+s/2);t.lineTo(e+i,r+s);t.lineTo(e+i,l+a);t.lineTo(e,l+a);t.closePath()}drawLeftArrowPath(t,e,r,o,s){const i=.4*o;const n=.6*s;const a=r+(s-n)/2;t.moveTo(e,r+s/2);t.lineTo(e+i,r);t.lineTo(e+i,a);t.lineTo(e+o,a);t.lineTo(e+o,a+n);t.lineTo(e+i,a+n);t.lineTo(e+i,r+s);t.closePath()}drawUpArrowPath(t,e,r,o,s){const i=.4*s;const n=.6*o;const a=e+(o-n)/2;t.moveTo(e+o/2,r);t.lineTo(e+o,r+i);t.lineTo(a+n,r+i);t.lineTo(a+n,r+s);t.lineTo(a,r+s);t.lineTo(a,r+i);t.lineTo(e,r+i);t.closePath()}drawDownArrowPath(t,e,r,o,s){const i=.4*s;const n=.6*o;const a=e+(o-n)/2;const l=r+s-i;t.moveTo(a,r);t.lineTo(a+n,r);t.lineTo(a+n,l);t.lineTo(e+o,l);t.lineTo(e+o/2,r+s);t.lineTo(e,l);t.lineTo(a,l);t.closePath()}}class w{constructor(){this.shapeCache=new Map;this.pathCache=new Map}processPresetShape(t,e,r){const o=`${t}_${e}_${r.width}_${r.height}`;if(this.shapeCache.has(o))return this.shapeCache.get(o);let s=null;switch(t){case 1:s=this.createRectangleShape(r);break;case 2:s=this.createRoundRectShape(r);break;case 3:s=this.createEllipseShape(r);break;case 4:s=this.createDiamondShape(r);break;case 5:s=this.createTriangleShape(r);break;case 6:s=this.createRightTriangleShape(r);break;case 7:s=this.createParallelogramShape(r);break;case 8:s=this.createTrapezoidShape(r);break;case 9:s=this.createHexagonShape(r);break;case 10:s=this.createOctagonShape(r);break;case 11:s=this.createPlusShape(r);break;case 12:s=this.createStar5Shape(r);break;case 13:s=this.createRightArrowShape(r);break;case 20:s=this.createLineShape(r);break;case 22:s=this.createCylinderShape(r);break;case 56:s=this.createPentagonShape(r);break;case 66:s=this.createLeftArrowShape(r);break;case 67:s=this.createDownArrowShape(r);break;case 68:s=this.createUpArrowShape(r);break;case 69:s=this.createLeftRightArrowShape(r);break;case 70:s=this.createUpDownArrowShape(r);break;case 74:s=this.createHeartShape(r);break;case 76:s=this.createQuadArrowShape(r);break;default:return null}if(s)this.shapeCache.set(o,s);return s}createRectangleShape(t){return{type:"preset",onlyOfficeType:1,path:{commands:[{type:"M",x:t.x,y:t.y},{type:"L",x:t.x+t.width,y:t.y},{type:"L",x:t.x+t.width,y:t.y+t.height},{type:"L",x:t.x,y:t.y+t.height},{type:"Z"}]}}}createEllipseShape(t){const e=t.x+t.width/2;const r=t.y+t.height/2;const o=t.width/2;const s=t.height/2;return{type:"preset",onlyOfficeType:3,path:{commands:[{type:"M",x:e+o,y:r},{type:"A",rx:o,ry:s,x:e-o,y:r,rotation:0,largeArc:0,sweep:1},{type:"A",rx:o,ry:s,x:e+o,y:r,rotation:0,largeArc:0,sweep:1},{type:"Z"}]}}}createDiamondShape(t){const e=t.x+t.width/2;const r=t.y+t.height/2;return{type:"preset",onlyOfficeType:4,path:{commands:[{type:"M",x:e,y:t.y},{type:"L",x:t.x+t.width,y:r},{type:"L",x:e,y:t.y+t.height},{type:"L",x:t.x,y:r},{type:"Z"}]}}}createTriangleShape(t){return{type:"preset",onlyOfficeType:5,path:{commands:[{type:"M",x:t.x+t.width/2,y:t.y},{type:"L",x:t.x+t.width,y:t.y+t.height},{type:"L",x:t.x,y:t.y+t.height},{type:"Z"}]}}}createRightArrowShape(t){const e=.7*t.width;const r=.4*t.height;const o=.3*t.width;const s=.6*t.height;return{type:"preset",onlyOfficeType:13,path:{commands:[{type:"M",x:t.x,y:t.y+(t.height-r)/2},{type:"L",x:t.x+e,y:t.y+(t.height-r)/2},{type:"L",x:t.x+e,y:t.y+(t.height-s)/2},{type:"L",x:t.x+t.width,y:t.y+t.height/2},{type:"L",x:t.x+e,y:t.y+(t.height+s)/2},{type:"L",x:t.x+e,y:t.y+(t.height+r)/2},{type:"L",x:t.x,y:t.y+(t.height+r)/2},{type:"Z"}]}}}createHeartShape(t){const e=t.x+t.width/2;const r=t.y+.3*t.height;return{type:"preset",onlyOfficeType:74,path:{commands:[{type:"M",x:e,y:r},{type:"C",x1:e-.3*t.width,y1:t.y,x2:t.x,y2:t.y+.3*t.height,x:e,y:t.y+.8*t.height},{type:"C",x1:t.x+t.width,y1:t.y+.3*t.height,x2:e+.3*t.width,y2:t.y,x:e,y:r},{type:"Z"}]}}}createLeftArrowShape(t){const e=.7*t.width;const r=.4*t.height;const o=.3*t.width;const s=.6*t.height;return{type:"preset",onlyOfficeType:66,path:{commands:[{type:"M",x:t.x,y:t.y+t.height/2},{type:"L",x:t.x+o,y:t.y+(t.height-s)/2},{type:"L",x:t.x+o,y:t.y+(t.height-r)/2},{type:"L",x:t.x+t.width,y:t.y+(t.height-r)/2},{type:"L",x:t.x+t.width,y:t.y+(t.height+r)/2},{type:"L",x:t.x+o,y:t.y+(t.height+r)/2},{type:"L",x:t.x+o,y:t.y+(t.height+s)/2},{type:"Z"}]}}}createPlusShape(t){const e=.3*Math.min(t.width,t.height);const r=t.x+t.width/2;const o=t.y+t.height/2;return{type:"preset",onlyOfficeType:11,path:{commands:[{type:"M",x:t.x,y:o-e/2},{type:"L",x:t.x+t.width,y:o-e/2},{type:"L",x:t.x+t.width,y:o+e/2},{type:"L",x:t.x,y:o+e/2},{type:"Z"},{type:"M",x:r-e/2,y:t.y},{type:"L",x:r+e/2,y:t.y},{type:"L",x:r+e/2,y:t.y+t.height},{type:"L",x:r-e/2,y:t.y+t.height},{type:"Z"}]}}}}class C{constructor(){this.sx=1;this.shy=0;this.shx=0;this.sy=1;this.tx=0;this.ty=0}Reset(){this.sx=1;this.shy=0;this.shx=0;this.sy=1;this.tx=0;this.ty=0}CreateDublicate(){const t=new C;t.sx=this.sx;t.shy=this.shy;t.shx=this.shx;t.sy=this.sy;t.tx=this.tx;t.ty=this.ty;return t}Multiply(t,e){if(1===e){const e=this.sx*t.sx+this.shy*t.shx;const r=this.sx*t.shy+this.shy*t.sy;const o=this.shx*t.sx+this.sy*t.shx;const s=this.shx*t.shy+this.sy*t.sy;const i=this.tx*t.sx+this.ty*t.shx+t.tx;const n=this.tx*t.shy+this.ty*t.sy+t.ty;this.sx=e;this.shy=r;this.shx=o;this.sy=s;this.tx=i;this.ty=n}else{const e=t.sx*this.sx+t.shy*this.shx;const r=t.sx*this.shy+t.shy*this.sy;const o=t.shx*this.sx+t.sy*this.shx;const s=t.shx*this.shy+t.sy*this.sy;const i=t.tx*this.sx+t.ty*this.shx+this.tx;const n=t.tx*this.shy+t.ty*this.sy+this.ty;this.sx=e;this.shy=r;this.shx=o;this.sy=s;this.tx=i;this.ty=n}}}class T{constructor(){this.Color={r:0,g:0,b:0,a:255};this.Alpha=255;this.Size=1;this.DashStyle=0;this.LineJoin=0;this.LineCap=0;this.MiterLimit=10}}class P{constructor(){this.Type=0;this.Color1={r:0,g:0,b:0,a:255};this.Color2={r:255,g:255,b:255,a:255};this.Alpha1=255;this.Alpha2=255;this.TexturePath="";this.TextureMode=0;this.TextureAlpha=255;this.LinearAngle=0;this.Rectable={x:0,y:0,w:0,h:0}}}class v{constructor(){this.Name="Arial";this.Size=12;this.Bold=false;this.Italic=false;this.Underline=false;this.Strikeout=false;this.Path="";this.FaceIndex=0;this.CharSpace=0}}if("object"!=="undefined"&&t.exports)t.exports={CGraphics,StandardShapeProcessor:w,StandardShapeTypes:x,OpenXmlShapeTypes:S,CMatrix:C,CPen:T,CBrush:P,CFont:v};const M={toRadians:function(t){return t*Math.PI/180},toDegrees:function(t){return 180*t/Math.PI},Sin:function(t){return Math.sin(t*Math.PI/108e5)},Cos:function(t){return Math.cos(t*Math.PI/108e5)},Tan:function(t){return Math.tan(t*Math.PI/108e5)},ATan2:function(t,e){return 108e5*Math.atan2(t,e)/Math.PI},CAt2:function(t,e,r){return t*Math.cos(Math.atan2(r,e))},SAt2:function(t,e,r){return t*Math.sin(Math.atan2(r,e))}};class A{constructor(){this.preset=null;this.pathLst=[];this.gdLst={};this.gdLstInfo=[];this.avLst={};this.adjLst={};this.ahXYLst=[];this.ahPolarLst=[];this.cnxLst=[];this.rect=null;this.width=21600;this.height=21600;this.isCalculated=false}setPreset(t){this.preset=t;this.isCalculated=false}addAdjustment(t,e,r,o){this.adjLst[t]={value:e,min:r||null,max:o||null};this.avLst[t]=true;this.isCalculated=false}addGuide(t,e,r,o,s){this.gdLstInfo.push({name:t,formula:e,x:r,y:o,z:s});this.isCalculated=false}calculateGuideValue(t,b,x,S,w){const C=this.getValue(x);const T=this.getValue(S);const P=this.getValue(w);let v=0;switch(b){case e:v=0!==P?C*T/P:0;break;case r:v=C+T-P;break;case o:v=0!==P?(C+T)/P:0;break;case s:v=C>0?T:P;break;case i:v=Math.abs(C);break;case n:v=M.ATan2(T,C);break;case a:v=M.CAt2(C,T,P);break;case l:v=C*M.Cos(T);break;case c:v=Math.max(C,T);break;case h:v=Math.min(C,T);break;case u:v=Math.sqrt(C*C+T*T+P*P);break;case f:if(TP)v=P;else v=T;break;case d:v=M.SAt2(C,T,P);break;case p:v=C*M.Sin(T);break;case g:v=Math.sqrt(Math.max(0,C));break;case m:v=C*M.Tan(T);break;case y:v=C;break;default:v=0}if(isNaN(v))v=0;this.gdLst[t]=v;return v}getValue(t){if("number"===typeof t)return t;if("string"===typeof t){const e=parseFloat(t);if(!isNaN(e))return e;switch(t){case"w":case"r":return this.width;case"h":case"b":return this.height;case"ss":return Math.min(this.width,this.height);case"ls":return Math.max(this.width,this.height);case"hc":case"wd2":return this.width/2;case"vc":case"hd2":return this.height/2;case"l":case"t":return 0;case"wd4":return this.width/4;case"hd4":return this.height/4;case"wd6":return this.width/6;case"hd6":return this.height/6;case"wd8":return this.width/8;case"hd8":return this.height/8;case"cd2":return 108e5;case"cd4":return 54e5;case"cd8":return 27e5;case"_3cd4":return 162e5;case"_3cd8":return 81e5;case"_5cd8":return 135e5;case"_7cd8":return 189e5}if(this.gdLst.hasOwnProperty(t))return this.gdLst[t];if(this.adjLst.hasOwnProperty(t))return this.adjLst[t].value}return 0}calculateGuides(){this.gdLst={};for(let t=0;t{const e=o[t.name]||t.value;n.addAdjustment(t.name,e,t.min,t.max)});if(i.guides)i.guides.forEach(t=>{n.addGuide(t.name,t.formula,t.x,t.y,t.z)});if(i.paths)i.paths.forEach(t=>{const e=new k;e.setFill(t.fill);e.setStroke(t.stroke);t.commands.forEach(t=>{const r=t.args.map(t=>"string"===typeof t?n.getValue(t):t);e.addCommand(t.type,...r)});n.addPath(e)});n.calculateGuides();this.shapeCache.set(s,n);return n}createDefaultGeometry(t,e){return this.processPresetGeometry("rect",t,e)}fillText(t,e,r,o={}){if(!this.m_oContext||!t)return;this.m_oContext.save();try{const s=o.fontSize||12;const i=this.m_oGraphicsAdapter&&this.m_oGraphicsAdapter.getTextScaleFactor?this.m_oGraphicsAdapter.getTextScaleFactor():1;const n=s*i;const a=o.fontFamily||"Arial";const l=o.fontWeight||(o.bold?"bold":"normal");const c=o.fontStyle||(o.italic?"italic":"normal");const h=`"${a}", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", Arial, sans-serif`;this.m_oContext.font=`${c} ${l} ${n}px ${h}`;if(o.color)if("object"===typeof o.color&&void 0!==o.color.r){const t=void 0!==o.color.a?o.color.a/255:1;const e=`rgba(${o.color.r}, ${o.color.g}, ${o.color.b}, ${t})`;this.m_oContext.fillStyle=e}else if("string"===typeof o.color)this.m_oContext.fillStyle=o.color;else this.m_oContext.fillStyle="#000000";else this.m_oContext.fillStyle="#000000";this.m_oContext.textBaseline=o.textBaseline||"alphabetic";this.m_oContext.textAlign=o.textAlign||"left";if(this.m_oFullTransform&&!this.m_oFullTransform.IsIdentity()){const t=this.m_oFullTransform;this.m_oContext.setTransform(t.sx,t.shy,t.shx,t.sy,t.tx,t.ty)}if(o.highlight){const s=o.highlight;let i;if("object"===typeof s&&void 0!==s.r){const t=void 0!==s.a?s.a/255:1;i=`rgba(${s.r}, ${s.g}, ${s.b}, ${t})`}else if("string"===typeof s)i=s;if(i){const o=this.m_oContext.measureText(t);const s=1.2*n;const a=this.m_oContext.fillStyle;this.m_oContext.fillStyle=i;this.m_oContext.fillRect(e,r-n,o.width,s);this.m_oContext.fillStyle=a}}this.applyTextEffects(o.effects);this.m_oContext.fillText(t,e,r);this.resetTextEffects()}catch(t){}finally{this.m_oContext.restore()}}applyTextEffects(t){if(!t||!this.m_oContext)return;if(t.outerShadow)this.applyOuterShadow(t.outerShadow);if(t.glow)this.applyGlowEffect(t.glow);if(t.innerShadow)this.applyInnerShadow(t.innerShadow)}applyOuterShadow(t){if(!t||!this.m_oContext)return;const e=(t.blurRadius||0)/9525;const r=(t.distance||0)/9525;const o=(t.direction||0)/6e4;const s=o*Math.PI/180;const i=Math.cos(s)*r;const n=Math.sin(s)*r;this.m_oContext.shadowOffsetX=i;this.m_oContext.shadowOffsetY=n;this.m_oContext.shadowBlur=e;if(t.color){const e=this.convertColorToString(t.color);this.m_oContext.shadowColor=e}else this.m_oContext.shadowColor="rgba(0, 0, 0, 0.5)"}applyGlowEffect(t){if(!t||!this.m_oContext)return;const e=(t.radius||0)/9525;this.m_oContext.shadowOffsetX=0;this.m_oContext.shadowOffsetY=0;this.m_oContext.shadowBlur=e;if(t.color){const e=this.convertColorToString(t.color);this.m_oContext.shadowColor=e}else this.m_oContext.shadowColor="rgba(255, 255, 255, 0.8)"}applyInnerShadow(t){}resetTextEffects(){if(!this.m_oContext)return;this.m_oContext.shadowOffsetX=0;this.m_oContext.shadowOffsetY=0;this.m_oContext.shadowBlur=0;this.m_oContext.shadowColor="transparent"}convertColorToString(t){if(!t)return"black";if("srgb"===t.type){const e=t.value;const r=parseInt(e.substr(0,2),16);const o=parseInt(e.substr(2,2),16);const s=parseInt(e.substr(4,2),16);const i=t.alpha||1;return`rgba(${r}, ${o}, ${s}, ${i})`}else if("scheme"===t.type){const e={dk1:"#000000",lt1:"#FFFFFF",dk2:"#44546A",lt2:"#E7E6E6"};const r=e[t.value]||"#000000";const o=t.alpha||1;const s=parseInt(r.substr(1,2),16);const i=parseInt(r.substr(3,2),16);const n=parseInt(r.substr(5,2),16);return`rgba(${s}, ${i}, ${n}, ${o})`}return"black"}measureText(t,e={}){if(!this.m_oContext||!t)return{width:0,height:0};this.m_oContext.save();try{const r=e.fontSize||12;const o=this.m_oGraphicsAdapter&&this.m_oGraphicsAdapter.getTextScaleFactor?this.m_oGraphicsAdapter.getTextScaleFactor():1;const s=r*o;const i=e.fontFamily||"Arial";const n=e.fontWeight||(e.bold?"bold":"normal");const a=e.fontStyle||(e.italic?"italic":"normal");const l=`"${i}", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", Arial, sans-serif`;this.m_oContext.font=`${a} ${n} ${s}px ${l}`;const c=this.m_oContext.measureText(t);let h=s;if(void 0!==c.actualBoundingBoxAscent&&void 0!==c.actualBoundingBoxDescent)h=c.actualBoundingBoxAscent+c.actualBoundingBoxDescent;return{width:c.width,height:h}}catch(t){return{width:0,height:0}}finally{this.m_oContext.restore()}}}if("undefined"!==typeof window){window.CGraphics=CGraphics;window.StandardShapeProcessor=w}}(it);return it.exports}var ct=lt();var ht=s(ct);var ut={};var ft;function dt(){if(ft)return ut;ft=1;class FontEngine{constructor(){this.logger=new Logger("FontEngine");this.initializeFontSystem();this.availableFonts=new Set(["Arial","Calibri","Times New Roman","Courier New","Verdana","Georgia","Tahoma","Helvetica","Garamond","Impact","Segoe UI","Comic Sans MS","Trebuchet MS","Lucida Sans Unicode","Palatino Linotype","Book Antiqua","Bookman Old Style","Century Gothic"]);this.documentFonts=new Set;this.missingFonts=new Set;this.fontCache=new Map;this.fontManager=null}initializeFontSystem(){try{if("undefined"!==typeof window.AscFonts){this.fontManager=new window.AscFonts.CFontManagerEngine;this.initializeFonts()}else this.fontManager=new t}catch(e){this.fontManager=new t}}initializeFonts(){try{if("function"===typeof self.queryLocalFonts)this.loadSystemFonts();else this.loadFallbackFonts()}catch(t){this.loadFallbackFonts()}}async loadSystemFonts(){try{const t=await self.queryLocalFonts();t.forEach(t=>{this.availableFonts.add(t.family)})}catch(t){this.loadFallbackFonts()}}loadFallbackFonts(){const t=["Arial","Helvetica","Times New Roman","Times","Courier New","Courier","Verdana","Georgia","Palatino","Garamond","Bookman","Comic Sans MS","Trebuchet MS","Arial Black","Impact","Lucida Sans Unicode","Tahoma","Geneva","Lucida Grande","Segoe UI","Calibri","Cambria","Candara","Consolas","Constantia","Corbel","Franklin Gothic Medium","Gill Sans","Lucida Console","Lucida Sans Typewriter","MS Gothic","MS Mincho","MS PGothic","MS PMincho","MS Reference Sans Serif","MS Reference Specialty","MS Sans Serif","MS Serif","Myriad Pro","Optima","Perpetua","Rockwell","Rockwell Extra Bold","Segoe Print","Segoe Script","Segoe UI Light","Segoe UI Semibold","Segoe UI Symbol","Tw Cen MT","Tw Cen MT Condensed","Tw Cen MT Condensed Extra Bold"];t.forEach(t=>{this.availableFonts.add(t)})}analyzeDocument(presentation){this.documentFonts.clear();if(presentation.defaultTextStyle)this.addFontFromStyle(presentation.defaultTextStyle);presentation.slides.forEach(slide=>{if(slide.commonSlideData&&slide.commonSlideData.shapeTree)slide.commonSlideData.shapeTree.forEach(t=>{this.analyzeShape(t)})});return Array.from(this.documentFonts)}addFontFromStyle(t){if(!t)return;if(t.font)this.documentFonts.add(t.font)}analyzeShape(t){if(!t)return;if(t.textBody&&t.textBody.paragraphs)t.textBody.paragraphs.forEach(t=>{if(t.runs)t.runs.forEach(t=>{if(t.properties&&t.properties.font)this.documentFonts.add(t.properties.font)})});if(t.shapeTree)t.shapeTree.forEach(t=>{this.analyzeShape(t)})}loadFonts(){this.missingFonts.clear();this.documentFonts.forEach(t=>{if(!this.availableFonts.has(t))this.missingFonts.add(t)})}getResults(){return{documentFonts:Array.from(this.documentFonts),availableFonts:Array.from(this.availableFonts),missingFonts:Array.from(this.missingFonts)}}getFontMetrics(t,e,r){const o=`${t}_${e}_${r}`;if(this.fontCache.has(o))return this.fontCache.get(o);const s={width:r.length*e*.6,height:1.2*e,ascent:.8*e,descent:.2*e,baseline:.8*e};this.fontCache.set(o,s);return s}isFontAvailable(t){return this.availableFonts.has(t)||this.documentFonts.has(t)}getFallbackFont(t){if(this.isFontAvailable(t))return t;return'Arial, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif'}renderText(t,e,r,o,s){const i=this.getFallbackFont(s.fontFamily||"Arial");const n=s.fontSize||12;const a=s.fontWeight||(s.bold?"bold":"normal");const l=s.fontStyle||(s.italic?"italic":"normal");t.font=`${l} ${a} ${n}px "${i}"`;let c="#000000";if(s.color)if("object"===typeof s.color&&void 0!==s.color.r){const t=void 0!==s.color.a?s.color.a/255:1;c=`rgba(${s.color.r}, ${s.color.g}, ${s.color.b}, ${t})`}else if("string"===typeof s.color)c=s.color;else c="#000000";else c="#000000";t.fillStyle=c;t.textBaseline="alphabetic";if(s.textAlign)t.textAlign=s.textAlign;if(1===e.length)t.fillText(e,r,o);else{let i=r;for(let r=0;rt.querySelector(e))||this.hasVideoMimeType(t)}isAudioElement(t){const e=["audio","p:audio","a:audio"];return e.some(e=>t.querySelector(e))||this.hasAudioMimeType(t)}isImageElement(t){const e=["pic","p:pic","image","img"];return e.some(e=>t.querySelector(e))||this.hasImageMimeType(t)}isYouTubeEmbed(t){const e=t.textContent||"";const r=t.innerHTML||"";return e.includes("youtube.com")||e.includes("youtu.be")||r.includes("youtube.com")||r.includes("youtu.be")}parseVideoElement(e){const r=new t;r.type="video";this.parseCommonMediaAttributes(e,r);const o=e.querySelector("video, p\\:video, a\\:video");if(o){r.poster=o.getAttribute("poster")||"";r.autoplay=o.hasAttribute("autoplay");r.loop=o.hasAttribute("loop");r.controls=!o.hasAttribute("controls")||"false"!==o.getAttribute("controls");r.muted=o.hasAttribute("muted")}this.extractMediaSource(e,r);return r}parseAudioElement(e){const r=new t;r.type="audio";this.parseCommonMediaAttributes(e,r);const o=e.querySelector("audio, p\\:audio, a\\:audio");if(o){r.autoplay=o.hasAttribute("autoplay");r.loop=o.hasAttribute("loop");r.controls=!o.hasAttribute("controls")||"false"!==o.getAttribute("controls");r.muted=o.hasAttribute("muted");const t=o.getAttribute("volume");if(t)r.volume=parseFloat(t)||1}this.extractMediaSource(e,r);return r}parseImageElement(e){const r=new t;r.type="image";this.parseCommonMediaAttributes(e,r);this.extractMediaSource(e,r);return r}parseYouTubeEmbed(r){const o=new t;o.type="youtube";const s=new e;const i=r.textContent||"";const n=r.innerHTML||"";const a=i+" "+n;const l=this.extractYouTubeVideoId(a);if(l){s.videoId=l;s.fullUrl=`https://www.youtube.com/watch?v=${l}`;s.embedUrl=`https://www.youtube.com/embed/${l}`;s.thumbnailUrl=`https://img.youtube.com/vi/${l}/maxresdefault.jpg`}const c=a.match(/[?&]t=(\d+)/);if(c)s.startTime=parseInt(c[1]);o.source=s.embedUrl;o.embeddedData=s;return o}parseCommonMediaAttributes(t,e){const r=t.getAttribute("width")||t.getAttribute("w");const o=t.getAttribute("height")||t.getAttribute("h");if(r)e.width=parseInt(r)||0;if(o)e.height=parseInt(o)||0;const s=t.getAttribute("duration");if(s)e.duration=parseFloat(s)||0;const i=t.getAttribute("r:id")||t.getAttribute("rid");if(i)e.relationship=i}extractMediaSource(t,e){const r=t.getAttribute("src");if(r){e.source=r;e.mimeType=this.getMimeTypeFromExtension(r);return}const o=t.querySelector("source");if(o){e.source=o.getAttribute("src")||"";e.mimeType=o.getAttribute("type")||this.getMimeTypeFromExtension(e.source);return}if(e.relationship&&this.context){const t=this.resolveRelationship(e.relationship);if(t){e.source=t;e.mimeType=this.getMimeTypeFromExtension(t);if("image/svg+xml"===this.getMimeTypeFromExtension(t))try{const r=this.getZipPackage();if(r&&r.getFileData)r.getFileData(t).then(t=>{if(t){const r=new TextDecoder("utf-8").decode(t);const o=btoa(r);e.embeddedData=`data:image/svg+xml;base64,${o}`}}).catch(e=>{this.logger.log("warn",this.constructor.name,`Failed to create SVG data URI for ${t}:`,e)})}catch(e){this.logger.log("warn",this.constructor.name,`Error creating SVG data URI for ${t}:`,e)}return}}const s=this.extractEmbeddedData(t);if(s){e.embeddedData=s;e.mimeType=this.getMimeTypeFromData(s)}}getZipPackage(){if(this.context&&this.context.zip)return this.context.zip;else if(this.context&&this.context.package)return this.context.package;else if(window.currentProcessor&&window.currentProcessor.package)return window.currentProcessor.package;else if(window.currentProcessor&&window.currentProcessor.zip)return window.currentProcessor.zip;return null}extractYouTubeVideoId(t){const e=[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\n?#]+)/,/youtube\.com\/embed\/([^&\n?#]+)/,/youtube\.com\/v\/([^&\n?#]+)/];for(const r of e){const e=t.match(r);if(e&&e[1])return e[1]}return null}getMimeTypeFromExtension(t){if(!t)return"";const e=t.split(".").pop().toLowerCase();const r={mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",avi:"video/x-msvideo",mov:"video/quicktime",wmv:"video/x-ms-wmv",mp3:"audio/mpeg",wav:"audio/wav",aac:"audio/aac",m4a:"audio/mp4",wma:"audio/x-ms-wma",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",webp:"image/webp"};return r[e]||""}resolveRelationship(t){try{if(!t||!this.context)return null;let e=null;if(this.context.zip)e=this.context.zip;else if(this.context.package)e=this.context.package;else if(window.currentProcessor&&window.currentProcessor.package)e=window.currentProcessor.package;if(!e||!e.relationships)return null;const r=Object.values(e.relationships);for(const e of r)if(e&&e[t]){const r=e[t];let o=r.target;if(o.startsWith("../"))o=o.replace("../","ppt/");else if(!o.startsWith("/"))o=`/ppt/${o}`;return o}this.logger.log("warn",this.constructor.name,`Could not resolve relationship ID: ${t}`);return null}catch(e){this.logger.logError(this.constructor.name,`Error resolving relationship ${t}:`,e);return null}}extractEmbeddedData(t){const e=["data","data-src","data-url","src","href"];for(const r of e){const e=t.getAttribute(r);if(e&&e.startsWith("data:"))return e}const r=t.textContent||"";const o=r.match(/data:[^;]+;base64,[A-Za-z0-9+/]+=*/g);if(o&&o.length>0)return o[0];return null}getMimeTypeFromData(t){if(!t||!t.startsWith("data:"))return"";const e=t.match(/^data:([^;]+)/);return e?e[1]:""}isSVGDataUri(t){if(!t||!t.startsWith("data:"))return false;const e=this.getMimeTypeFromData(t);return"image/svg+xml"===e}extractSVGFromDataUri(t){if(!this.isSVGDataUri(t))return null;try{const e=t.split(",")[1];if(!e)return null;const r=atob(e);return r}catch(t){return null}}hasVideoMimeType(t){const e=t.getAttribute("type")||"";return e.startsWith("video/")}hasAudioMimeType(t){const e=t.getAttribute("type")||"";return e.startsWith("audio/")}hasImageMimeType(t){const e=t.getAttribute("type")||"";return e.startsWith("image/")}createPlaceholder(e="media"){const r=new t;r.type=e;r.source="";r.width=320;r.height=240;r.controls=true;return r}}if("undefined"!==typeof window){window.MediaInfo=t;window.YouTubeEmbed=e;window.MediaProcessor=r}return mt}var xt=bt();var St=s(xt);var wt={};var Ct;function Tt(){if(Ct)return wt;Ct=1;class SVGRenderer{constructor(t){this.graphics=t;this.logger=new Logger("SVGRenderer");this.parser=new DOMParser}async renderSVG(t,e,r,o,s,i={}){try{let n=null;if("string"===typeof t){const i=t.trim();if(i.startsWith("parseFloat(t));if(4===t.length)return{x:t[0],y:t[1],width:t[2],height:t[3]}}return null}getSVGDimensions(t,e){let r=parseFloat(t.getAttribute("width"))||0;let o=parseFloat(t.getAttribute("height"))||0;if(!r&&!o&&e){r=e.width;o=e.height}if(!r)r=100;if(!o)o=100;return{width:r,height:o}}canUseImageMethod(){const t="undefined"!==typeof Image;const e=this.graphics._context||this.graphics.m_oContext;const r=e&&"function"===typeof e.drawImage;return t&&e&&r}enhanceSVGForRendering(t,e,r){try{const o=this.parser.parseFromString(t,"image/svg+xml");const s=o.documentElement;if(!s.hasAttribute("viewBox")){const t=s.getAttribute("width")||e;const o=s.getAttribute("height")||r;s.setAttribute("viewBox",`0 0 ${t} ${o}`)}s.setAttribute("width",e.toString());s.setAttribute("height",r.toString());if(!s.hasAttribute("xmlns"))s.setAttribute("xmlns","http://www.w3.org/2000/svg");return(new XMLSerializer).serializeToString(s)}catch(e){this.logger.log("warn",this.constructor.name,"Could not enhance SVG, using original:",e);return t}}async renderSVGViaImage(t,e,r,o,s,i,n){return new Promise((i,n)=>{try{const a=new XMLSerializer;const l=a.serializeToString(t);const c=this.enhanceSVGForRendering(l,o,s);const h="data:image/svg+xml;base64,"+btoa(c);const u=new Image;u.onload=()=>{try{if(this.graphics._context||this.graphics.m_oContext){const t=this.graphics._context||this.graphics.m_oContext;t.save();let i=o,n=s,a=e,l=r;if(u.naturalWidth>0&&u.naturalHeight>0){const t=u.naturalWidth/u.naturalHeight;const c=o/s;if(t>c){i=o;n=o/t;l=r+(s-n)/2}else{n=s;i=s*t;a=e+(o-i)/2}}t.drawImage(u,a,l,i,n);t.restore()}else this.logger.logError(this.constructor.name,"No canvas context available for SVG drawing");i()}catch(t){this.logger.logError(this.constructor.name,"Error drawing SVG image:",t);this.renderSVGPlaceholder(e,r,o,s,"SVG Draw Error");n(t)}};u.onerror=t=>{this.logger.logError(this.constructor.name,"SVG image load error:",t);this.renderSVGPlaceholder(e,r,o,s,"SVG Load Error");n(t)};u.crossOrigin="anonymous";u.src=h;setTimeout(()=>{if(false===u.complete){this.logger.log("warn",this.constructor.name,"SVG loading timed out");this.renderSVGPlaceholder(e,r,o,s,"SVG Timeout");n(new Error("SVG loading timeout"))}},5e3)}catch(t){this.logger.logError(this.constructor.name,"Error in SVG Image rendering:",t);this.renderSVGPlaceholder(e,r,o,s,"SVG Render Error");n(t)}})}renderSVGViaParsing(t,e,r,o,s){try{if(!this.graphics._context)return;this.graphics._context.save();this.graphics._context.translate(e,r);this.graphics._context.scale(o,o);this.processSVGElements(t.children);this.graphics._context.restore()}catch(t){this.logger.logError(this.constructor.name,"Error in SVG parsing rendering:",t);this.renderSVGPlaceholder(e,r,100,100,"SVG Parse Error")}}processSVGElements(t){for(const e of t)this.processSVGElement(e)}processSVGElement(t){const e=t.tagName.toLowerCase();switch(e){case"rect":this.renderSVGRect(t);break;case"circle":this.renderSVGCircle(t);break;case"ellipse":this.renderSVGEllipse(t);break;case"line":this.renderSVGLine(t);break;case"polyline":case"polygon":this.renderSVGPolygon(t);break;case"path":this.renderSVGPath(t);break;case"text":this.renderSVGText(t);break;case"g":this.graphics._context.save();this.applySVGTransform(t);this.processSVGElements(t.children);this.graphics._context.restore()}}renderSVGRect(t){const e=parseFloat(t.getAttribute("x"))||0;const r=parseFloat(t.getAttribute("y"))||0;const o=parseFloat(t.getAttribute("width"))||0;const s=parseFloat(t.getAttribute("height"))||0;this.applySVGStyles(t);const i=this.graphics._context;i.fillRect(e,r,o,s);i.strokeRect(e,r,o,s)}renderSVGCircle(t){const e=parseFloat(t.getAttribute("cx"))||0;const r=parseFloat(t.getAttribute("cy"))||0;const o=parseFloat(t.getAttribute("r"))||0;this.applySVGStyles(t);const s=this.graphics._context;s.beginPath();s.arc(e,r,o,0,2*Math.PI);s.fill();s.stroke()}renderSVGLine(t){const e=parseFloat(t.getAttribute("x1"))||0;const r=parseFloat(t.getAttribute("y1"))||0;const o=parseFloat(t.getAttribute("x2"))||0;const s=parseFloat(t.getAttribute("y2"))||0;this.applySVGStyles(t);const i=this.graphics._context;i.beginPath();i.moveTo(e,r);i.lineTo(o,s);i.stroke()}renderSVGText(t){const e=parseFloat(t.getAttribute("x"))||0;const r=parseFloat(t.getAttribute("y"))||0;const o=t.textContent||"";this.applySVGStyles(t);const s=this.graphics._context;s.fillText(o,e,r)}applySVGStyles(t){const e=this.graphics._context;const r=t.getAttribute("fill");if(r&&"none"!==r)e.fillStyle=r;else e.fillStyle="transparent";const o=t.getAttribute("stroke");if(o&&"none"!==o)e.strokeStyle=o;else e.strokeStyle="transparent";const s=t.getAttribute("stroke-width");if(s)e.lineWidth=parseFloat(s);const i=t.getAttribute("opacity");if(i)e.globalAlpha=parseFloat(i)}applySVGTransform(t){const e=t.getAttribute("transform");if(e){const t=e.match(/translate\(([^)]+)\)/);if(t){const e=t[1].split(",").map(t=>parseFloat(t.trim()));if(e.length>=2)this.graphics._context.translate(e[0],e[1])}const r=e.match(/scale\(([^)]+)\)/);if(r){const t=r[1].split(",").map(t=>parseFloat(t.trim()));if(t.length>=1){const e=t[0];const r=t.length>1?t[1]:e;this.graphics._context.scale(e,r)}}const o=e.match(/rotate\(([^)]+)\)/);if(o){const t=parseFloat(o[1]);this.graphics._context.rotate(t*Math.PI/180)}}}renderSVGPlaceholder(t,e,r,o,s="SVG"){this.graphics.fillRect(t,e,r,o,{r:240,g:240,b:240});this.graphics.strokeRect(t,e,r,o,{r:200,g:200,b:200},1)}renderSVGEllipse(t){const e=parseFloat(t.getAttribute("cx"))||0;const r=parseFloat(t.getAttribute("cy"))||0;const o=parseFloat(t.getAttribute("rx"))||0;const s=parseFloat(t.getAttribute("ry"))||0;this.applySVGStyles(t);const i=this.graphics._context;i.save();i.translate(e,r);i.scale(o,s);i.beginPath();i.arc(0,0,1,0,2*Math.PI);i.restore();i.fill();i.stroke()}renderSVGPolygon(t){const e=t.getAttribute("points")||"";const r="polygon"===t.tagName.toLowerCase();if(!e.trim())return;this.applySVGStyles(t);const o=this.graphics._context;const s=e.trim().split(/[\s,]+/);if(s.length<4)return;o.beginPath();let i=parseFloat(s[0]);let n=parseFloat(s[1]);o.moveTo(i,n);for(let t=2;tparseFloat(t)).filter(t=>!isNaN(t)):[];e.push({command:t,params:s})}return e}executeSVGPathCommands(t,e){let r=0,o=0;let s=0,i=0;for(const{command:n,params:a}of t)switch(n.toLowerCase()){case"m":if(a.length>=2){if("M"===n){r=a[0];o=a[1]}else{r+=a[0];o+=a[1]}e.moveTo(r,o);for(let t=2;t0&&s>0)return{x:e,y:r,width:o,height:s};return null}}if("undefined"!==typeof window)window.SVGRenderer=SVGRenderer;return wt}var Pt=Tt();var vt=s(Pt);var Mt={};var At;function kt(){if(At)return Mt;At=1;class t{constructor(){this.name="";this.colorScheme={};this.fontScheme={};this.formatScheme={};this.backgroundStyles=[];this.effects=[];this.themeElements={}}}class e{constructor(){this.dk1=null;this.lt1=null;this.dk2=null;this.lt2=null;this.accent1=null;this.accent2=null;this.accent3=null;this.accent4=null;this.accent5=null;this.accent6=null;this.hlink=null;this.folHlink=null}}class r{constructor(){this.majorFont={};this.minorFont={}}}class o{constructor(){this.id="";this.name="";this.preserve=false;this.cSld=null;this.clrMap=null;this.txStyles=null;this.sldLayoutLst=[];this.themeId="";this.hf=null;this.timing=null;this.transition=null}}class s{constructor(){this.id="";this.masterId="";this.name="";this.type="custom";this.preserve=false;this.showMasterSp=true;this.showMasterPhAnim=false;this.userDrawn=false;this.cSld=null;this.clrMapOvr=null;this.hf=null;this.timing=null;this.transition=null}}class i{constructor(t){this.context=t;this.logger=new Logger("ThemeProcessor");this.themes=new Map;this.masters=new Map;this.layouts=new Map}processTheme(e,r){try{const o=new DOMParser;const s=o.parseFromString(e,"text/xml");const i=s.querySelector("theme, a\\:theme");if(!i){this.logger.log("warn",this.constructor.name,"No theme element found in XML");return this.createDefaultTheme(r)}const theme=new t;theme.name=i.getAttribute("name")||`Theme${r}`;this.processThemeElements(i,theme);this.processColorScheme(i,theme);this.processFontScheme(i,theme);this.processFormatScheme(i,theme);this.themes.set(r,theme);return theme}catch(t){this.logger.logError(this.constructor.name,"Error processing theme:",t);return this.createDefaultTheme(r)}}processMasterSlide(t,e){try{const r=new DOMParser;const s=r.parseFromString(t,"text/xml");const i=s.querySelector("sldMaster, p\\:sldMaster");if(!i){this.logger.log("warn",this.constructor.name,"No slide master element found in XML");return this.createDefaultMaster(e)}const n=new o;n.id=e;n.name=i.getAttribute("name")||`Master${e}`;n.preserve="true"===i.getAttribute("preserve");this.processMasterElements(i,n);this.masters.set(e,n);return n}catch(t){this.logger.logError(this.constructor.name,"Error processing master slide:",t);return this.createDefaultMaster(e)}}processLayoutSlide(t,e,r){try{const o=new DOMParser;const i=o.parseFromString(t,"text/xml");const n=i.querySelector("sldLayout, p\\:sldLayout");if(!n){this.logger.log("warn",this.constructor.name,"No slide layout element found in XML");return this.createDefaultLayout(e,r)}const a=new s;a.id=e;a.masterId=r;a.name=n.getAttribute("name")||`Layout${e}`;a.type=n.getAttribute("type")||"custom";a.preserve="true"===n.getAttribute("preserve");a.showMasterSp="false"!==n.getAttribute("showMasterSp");a.showMasterPhAnim="true"===n.getAttribute("showMasterPhAnim");a.userDrawn="true"===n.getAttribute("userDrawn");this.processLayoutElements(n,a);this.layouts.set(e,a);const l=this.masters.get(r);if(l)l.sldLayoutLst.push(e);return a}catch(t){this.logger.logError(this.constructor.name,"Error processing layout slide:",t);return this.createDefaultLayout(e,r)}}processThemeElements(t,theme){const e=t.querySelector("themeElements, a\\:themeElements");if(e)theme.themeElements={element:e,parsed:false}}processColorScheme(t,theme){const r=t.querySelector("clrScheme, a\\:clrScheme");if(!r)return;const o=new e;const s={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink"};for(const[t,e]of Object.entries(s)){const s=r.querySelector(`${t}, a\\:${t}`);if(s)o[e]=this.parseColor(s)}theme.colorScheme=o}processFontScheme(t,theme){const e=t.querySelector("fontScheme, a\\:fontScheme");if(!e)return;const o=new r;const s=e.querySelector("majorFont, a\\:majorFont");if(s)o.majorFont=this.parseFontCollection(s);const i=e.querySelector("minorFont, a\\:minorFont");if(i)o.minorFont=this.parseFontCollection(i);theme.fontScheme=o}processFormatScheme(t,theme){const e=t.querySelector("fmtScheme, a\\:fmtScheme");if(e)theme.formatScheme={fillStyleLst:this.processFillStyles(e),lnStyleLst:this.processLineStyles(e),effectStyleLst:this.processEffectStyles(e),bgFillStyleLst:this.processBackgroundFillStyles(e)}}processMasterElements(t,e){const r=t.querySelector("cSld, p\\:cSld");if(r)e.cSld=this.parseCommonSlideData(r);const o=t.querySelector("clrMap, p\\:clrMap");if(o)e.clrMap=this.parseColorMap(o);const s=t.querySelector("txStyles, p\\:txStyles");if(s)e.txStyles=this.parseTextStyles(s);e.hf=this.parseHeaderFooter(t);e.timing=this.parseTiming(t);e.transition=this.parseTransition(t)}processLayoutElements(t,e){const r=t.querySelector("cSld, p\\:cSld");if(r)e.cSld=this.parseCommonSlideData(r);const o=t.querySelector("clrMapOvr, p\\:clrMapOvr");if(o)e.clrMapOvr=this.parseColorMapOverride(o);e.hf=this.parseHeaderFooter(t);e.timing=this.parseTiming(t);e.transition=this.parseTransition(t)}getTheme(t){return this.themes.get(t)||null}getMaster(t){return this.masters.get(t)||null}getLayout(t){return this.layouts.get(t)||null}resolveColor(t,e,r=null){const theme=this.getTheme(e);if(!theme||!theme.colorScheme)return null;const o=r&&r[t]?r[t]:t;return theme.colorScheme[o]||null}resolveFont(t,e,r="latin"){const theme=this.getTheme(e);if(!theme||!theme.fontScheme)return null;const o="major"===t?theme.fontScheme.majorFont:theme.fontScheme.minorFont;return o[r]||o.latin||null}parseColor(t){const e=t.querySelector("sysClr, a\\:sysClr");const r=t.querySelector("srgbClr, a\\:srgbClr");const o=t.querySelector("schemeClr, a\\:schemeClr");if(r){const t=r.getAttribute("val");if(t){const e=parseInt(t.substr(0,2),16);const r=parseInt(t.substr(2,2),16);const o=parseInt(t.substr(4,2),16);return{r:e,g:r,b:o}}}if(e){const t=e.getAttribute("val");const r={windowText:{r:0,g:0,b:0},window:{r:255,g:255,b:255}};return r[t]||{r:0,g:0,b:0}}return{r:0,g:0,b:0}}parseFontCollection(t){const e={};const r=t.querySelector("latin, a\\:latin");if(r)e.latin=r.getAttribute("typeface");const o=t.querySelector("cs, a\\:cs");if(o)e.cs=o.getAttribute("typeface");return e}parseCommonSlideData(t){return{name:t.getAttribute("name")||"",bg:this.parseBackground(t),spTree:this.parseShapeTree(t)}}parseColorMap(t){const e={};const r=t.attributes;for(let t=0;tt.x+t.w||this.x+this.wt.y+t.h||this.y+this.ht.includes("slide")&&t.endsWith(".xml"));const s="undefined"!==typeof globalThis&&globalThis.OpenXmlPackage||"undefined"!==typeof window&&window.OpenXmlPackage||function(){class t{constructor(t,e,r){this.package=t;this.uri=e;this.contentType=r;this._content=null}async getDocumentContent(){if(null===this._content){const t=this.uri.startsWith("/")?this.uri.substring(1):this.uri;this._content=await this.package.zip.getFileText(t)}return this._content}async getRelationships(){if(this.package.relationships[this.uri])return this.package.relationships[this.uri];const t=this.uri.replace(/\/([^\/]+)$/,"/_rels/$1.rels");const e=t.startsWith("/")?t.substring(1):t;const r=await this.package.zip.getFileText(e);if(r)return this.package.parseRelationships(r);return{}}}class e{constructor(t){this.zip=t;this.parts={};this.contentTypes={};this.relationships={}}async initialize(){const e=await this.zip.getFileText("[Content_Types].xml");if(e)this.parseContentTypes(e);const r=await this.zip.getFileText("_rels/.rels");if(r)this.relationships[""]=this.parseRelationships(r);const o=this.zip.getPaths();for(const t of o)if(t.startsWith("_rels/")&&t.endsWith(".rels")&&"_rels/.rels"!==t){const e=t.match(/^(.+)\/_rels\/(.+)\.rels$/);if(e){const r=e[1];const o=e[2];const s=`/${r}/${o}`;const i=await this.zip.getFileText(t);if(i)this.relationships[s]=this.parseRelationships(i)}}for(const e of o)if(!e.startsWith("_rels/")&&"[Content_Types].xml"!==e){const r=`/${e}`;const o=this.getContentType(r);this.parts[r]=new t(this,r,o)}}parseContentTypes(t){const e=new DOMParser;const r=e.parseFromString(t,"text/xml");r.querySelectorAll("Default").forEach(t=>{const e=t.getAttribute("Extension");const r=t.getAttribute("ContentType");if(e)this.contentTypes[`ext:${e}`]=r});r.querySelectorAll("Override").forEach(t=>{const e=t.getAttribute("PartName");const r=t.getAttribute("ContentType");if(e)this.contentTypes[e]=r})}parseRelationships(t){const e=new DOMParser;const r=e.parseFromString(t,"text/xml");const o={};const s=r.getElementsByTagName("*");for(let t=0;t/presentation\.xml$/i.test(t));if(e)r=this.package.getPartByUri(e)}if(!r&&this.zip&&"function"===typeof this.zip.getPaths)try{const t=this.zip.getPaths();let e=t.find(t=>/^(?:\/?|)ppt\/presentation\.xml$/i.test(t));if(!e)e=t.find(t=>/presentation\.xml$/i.test(t));if(e){const t=e.startsWith("/")?e:`/${e}`;const o=this;const s=class{constructor(t,e){this.package=t;this.uri=e;this._content=null}async getDocumentContent(){if(null===this._content){const t=this.uri.startsWith("/")?this.uri.substring(1):this.uri;this._content=await o.zip.getFileText(t)}return this._content}async getRelationships(){const t=this.uri.replace(/\/([^\/]+)$/,"/_rels/$1.rels");const e=t.startsWith("/")?t.substring(1):t;const r=await o.zip.getFileText(e);if(r)if(o.package&&"function"===typeof o.package.parseRelationships)return o.package.parseRelationships(r);return{}}};const i=new s(this.package,t);if(this.package&&this.package.parts)this.package.parts[t]=i;r=i}}catch(t){}if(!r)throw new Error("No presentation document found in PPTX file")}const o=await r.getDocumentContent();if(!o)throw new Error("Failed to extract presentation XML content");const s="undefined"!==typeof globalThis&&globalThis.StaxParser||"undefined"!==typeof window&&window.StaxParser||null;if(!s)throw new Error("StaxParser is not defined");const i=new s(o,r,e);const n=i.parse();if(!n)throw new Error("Failed to parse presentation XML document");this.presentation=this.createPresentationFromXML(n);if(!this.presentation)throw new Error("Failed to create presentation object from XML");await this.processThemes(e,r);await this.processSlideMasters(e,r);await this.processSlides(e);await this.processImages(e);this.buildSVGRelationshipMapping()}catch(t){throw t}}createPresentationFromXML(t){try{const e="undefined"!==typeof globalThis&&globalThis.CPresentation||"undefined"!==typeof window&&window.CPresentation||null;if(!e)throw new Error("CPresentation is not defined");const presentation=new e;const r=t.documentElement;if(r){const t=r.querySelector("sldSz, p\\:sldSz");if(t)presentation.slideSize={cx:parseInt(t.getAttribute("cx"))||9144e3,cy:parseInt(t.getAttribute("cy"))||6858e3};const e=r.querySelector("sldMasterIdLst, p\\:sldMasterIdLst");if(e){const t=[];const r=e.querySelectorAll("sldMasterId, p\\:sldMasterId");r.forEach(e=>{const r=e.getAttribute("r:id")||e.getAttribute("id");if(r)t.push(r)});presentation.masterIds=t}const o=r.querySelector("sldIdLst, p\\:sldIdLst");if(o){const t=[];const e=o.querySelectorAll("sldId, p\\:sldId");e.forEach(e=>{const r=e.getAttribute("r:id")||e.getAttribute("id");if(r)t.push(r)});presentation.slideIds=t}const s=r.querySelector("defaultTextStyle, p\\:defaultTextStyle");if(s)presentation.defaultTextStyle=this.parseTextStyleElement(s)}return presentation}catch(t){const e=new CPresentation;e.slideSize={cx:9144e3,cy:6858e3};return e}}async processImages(t){try{if("function"===typeof this.extractMediaMap)await this.extractMediaMap();else await this.extractImageMap()}catch(t){await this.extractImageMap()}await this.preloadAllImages();this.logImageProcessingResults()}logImageProcessingResults(){const t=[];for(const[e,r]of this.imageMap){const o=this.imageCache.has(e);t.push({relId:e,imagePath:r,cached:o})}const e=this.zip.getPaths();const r=e.filter(t=>t.startsWith("ppt/media/")&&this.isImageFile(t))}async extractMediaMap(){const t=[];const e=this.zip.getPaths();for(const r of e)if(r.startsWith("ppt/media/"))t.push(r);const parts=[];const r=this.package.getPartByRelationshipType(Bt.presentation.relationType);if(r)parts.push(r);if(this.slides&&this.slides.length>0){const t=Object.keys(this.package.parts);const e=Object.keys(this.package.relationships);for(const e of t)if(e.includes("/slides/slide")&&e.endsWith(".xml")){const t=this.package.getPartByUri(e);if(t)parts.push(t)}}if(this.slideMasters&&this.slideMasters.length>0){const t=Object.keys(this.package.parts);for(const e of t)if(e.includes("/slideMasters/slideMaster")&&e.endsWith(".xml")){const t=this.package.getPartByUri(e);if(t)parts.push(t)}}if(this.slideLayouts&&this.slideLayouts.length>0){const t=Object.keys(this.package.parts);for(const e of t)if(e.includes("/slideLayouts/slideLayout")&&e.endsWith(".xml")){const t=this.package.getPartByUri(e);if(t)parts.push(t)}}for(const t of parts)await this.extractPartMediaRelationships(t)}async extractImageMap(){const t=[];const e=this.zip.getPaths();for(const r of e)if(r.startsWith("ppt/media/")&&this.isImageFile(r))t.push(r);const parts=[this.package.getPartByRelationshipType(Bt.presentation.relationType),...this.slides.map((t,e)=>this.package.getPartByUri(`/ppt/slides/slide${e+1}.xml`)),...this.slideMasters.map((t,e)=>this.package.getPartByUri(`/ppt/slideMasters/slideMaster${e+1}.xml`)),...this.slideLayouts.map((t,e)=>this.package.getPartByUri(`/ppt/slideLayouts/slideLayout${e+1}.xml`))].filter(t=>null!==t);for(const t of parts)await this.extractPartImageRelationships(t)}async extractPartImageRelationships(t){try{const e=await t.getRelationships();for(const[t,r]of Object.entries(e))if(r.type===Bt.image.relationType){let e=r.target;if(e.startsWith("../"))e=e.replace("../","ppt/");else if(!e.startsWith("/"))e=`/ppt/${e}`;this.imageMap.set(t,e)}}catch(t){}}isImageFile(t){const e=[".png",".jpg",".jpeg",".gif",".bmp",".svg",".webp",".tiff"];const r=t.toLowerCase();return e.some(t=>r.endsWith(t))}async preloadSlideImages(t){if(!this.slides[t]||!this.slides[t].commonSlideData)return;const slide=this.slides[t];const e=this.extractImageRelationshipsFromSlide(slide);const r=e.map(t=>this.loadImage(t));await Promise.allSettled(r)}async preloadAllImages(){const t=new Set;for(const slide of this.slides){const e=this.extractImageRelationshipsFromSlide(slide);e.forEach(e=>t.add(e));if(slide.backgroundFill&&slide.backgroundFill.fill&&"image"===slide.backgroundFill.fill.type&&slide.backgroundFill.fill.imageData?.relationshipId)t.add(slide.backgroundFill.fill.imageData.relationshipId)}for(const e of this.slideMasters)if("image"===e.cSld?.bg?.fill?.type&&e.cSld.bg.fill.imageData?.relationshipId)t.add(e.cSld.bg.fill.imageData.relationshipId);const e=Array.from(t);const r=5;for(let t=0;tthis.loadImage(t));await Promise.allSettled(s);const i=Math.min(100,Math.round((t+r)/e.length*100))}}extractImageRelationshipsFromSlide(slide){const t=[];if(slide.commonSlideData&&slide.commonSlideData.shapeTree)for(const e of slide.commonSlideData.shapeTree){if("pic"===e.type&&e.imageRelId)t.push(e.imageRelId);if("grpSp"===e.type&&e.shapeTree)t.push(...this.extractImageRelationshipsFromShapeTree(e.shapeTree))}return t}extractImageRelationshipsFromShapeTree(t){const e=[];for(const r of t){if("pic"===r.type&&r.imageRelId)e.push(r.imageRelId);if("grpSp"===r.type&&r.shapeTree)e.push(...this.extractImageRelationshipsFromShapeTree(r.shapeTree))}return e}updateShapeImageRelIds(slide,t,e){if(!slide.commonSlideData?.shapeTree)return;const r=o=>{for(const s of o){if("pic"===s.type&&s.imageRelId===t)s.imageRelId=e;if("grpSp"===s.type&&s.shapeTree)r(s.shapeTree)}};r(slide.commonSlideData.shapeTree)}async preloadAllImages(){try{const t=new Set;for(let e=0;enull);if(e){const o=new Blob([e],{type:this.getMimeType(t)});const s=URL.createObjectURL(o);const image=await this.imageLoader.loadImageFromUrl(s);this.imageCache.set(r,{image,url:s,path:t,width:image.naturalWidth,height:image.naturalHeight})}}catch(t){}this.updateShapeImageRelIds(slide,e,r)}else t.add(e)}else r.forEach(e=>t.add(e))}catch(e){r.forEach(e=>t.add(e))}else r.forEach(e=>t.add(e))}for(const e of this.slideLayouts){const r=e.cSld?.bg?.fill||e.commonSlideData?.backgroundFill?.fill;if("image"===r?.type&&r.imageData?.relationshipId&&e.layoutPath){const o=r.imageData.relationshipId;const s=`layout_bg:${e.layoutPath}`;try{const t=this.package.getPartByUri("/"+e.layoutPath);if(t){const e=await t.getRelationships();if(e&&e[o]){let t=e[o].target;if(t.startsWith("../"))t=t.replace("../","ppt/");else if(!t.startsWith("/"))t=`ppt/${t}`;const i=await this.zip.getFileData(t);if(i&&!this.isSVGFile(t)){const e=new Blob([i],{type:this.getMimeType(t)});const o=URL.createObjectURL(e);const image=await this.imageLoader.loadImageFromUrl(o);this.imageCache.set(s,{image,url:o,path:t,width:image.naturalWidth,height:image.naturalHeight});r.imageData.resolvedCacheKey=s}}}}catch(e){t.add(o)}}}for(const e of this.slideLayouts){if(!e.layoutPath)continue;const r=this.extractImageRelationshipsFromSlide(e);if(0===r.length)continue;try{const o=this.package.getPartByUri("/"+e.layoutPath);if(o){const s=await o.getRelationships();for(const o of r)if(s&&s[o]){let t=s[o].target;if(t.startsWith("../"))t=t.replace("../","ppt/");else if(!t.startsWith("/")&&!t.startsWith("ppt/"))t=`ppt/${t}`;const r=`layout:${e.layoutPath}:${o}`;if(!this.imageCache.has(r)){const e=await this.zip.getFileData(t).catch(()=>null);if(e&&!this.isSVGFile(t)){const o=new Blob([e],{type:this.getMimeType(t)});const s=URL.createObjectURL(o);const image=await this.imageLoader.loadImageFromUrl(s);this.imageCache.set(r,{image,url:s,path:t,width:image.naturalWidth,height:image.naturalHeight})}}this.updateShapeImageRelIds(e,o,r)}else t.add(o)}else r.forEach(e=>t.add(e))}catch(e){r.forEach(e=>t.add(e))}}const e=Array.from(t).map(t=>this.loadImage(t).catch(e=>{this.logger.log("warn",this.constructor.name,`Failed to preload image ${t}:`,e);return null}));const r=await Promise.allSettled(e);const o=r.filter(t=>"fulfilled"===t.status&&null!==t.value).length}catch(t){this.logger.logError(this.constructor.name,"Error during image preloading:",t)}}async loadImage(t){const e=this.svgRelationshipMap.get(t);if(e)t=e;if(this.imageCache.has(t))return this.imageCache.get(t);const r=this.imageMap.get(t);if(!r){this.logger.log("warn",this.constructor.name,`No image path found for relId: ${t}`);return null}if(r.startsWith("data:")){if(r.startsWith("data:image/svg+xml"))try{const e=r.split(",")[1];const o=atob(e);this.imageCache.set(t,{type:"svg",content:o,path:r,width:100,height:100});return this.imageCache.get(t)}catch(e){this.logger.logError(this.constructor.name,`Failed to decode SVG data URI for ${t}:`,e);return null}return null}try{const e=await this.zip.getFileData(r);if(!e)return null;const o=new Blob([e],{type:this.getMimeType(r)});const s=URL.createObjectURL(o);const image=await this.imageLoader.loadImageFromUrl(s);this.imageCache.set(t,{image,url:s,path:r,width:image.naturalWidth,height:image.naturalHeight});return this.imageCache.get(t)}catch(t){return null}}getMimeType(t){const e=t.toLowerCase().split(".").pop();const r={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",webp:"image/webp",tiff:"image/tiff"};return r[e]||"image/png"}async processThemes(t,e){try{const t=await e.getRelationships();if(!t){const theme=new CTheme;this.presentation.theme=theme;return}const r=Object.values(t).find(t=>t.type&&t.type.includes("theme")&&t.target);if(!r){const theme=new CTheme;this.presentation.theme=theme;return}let o=r.target;if(o.startsWith("/"))o=o.substring(1);else if(o.startsWith("../"))o=o.replace("../","");if(!o.startsWith("ppt/"))o="ppt/"+o;const s=await this.zip.getFileText(o);if(!s){const theme=new CTheme;this.presentation.theme=theme;return}const i=new DOMParser;const n=i.parseFromString(s,"text/xml");if("parsererror"===n.documentElement.nodeName){const theme=new CTheme;this.presentation.theme=theme;return}const theme=this.parseThemeFromXML(n);if(theme)this.presentation.theme=theme;else{const t=new CTheme;this.presentation.theme=t}}catch(t){const theme=new CTheme;this.presentation.theme=theme}}parseThemeFromXML(t){try{const e=t.querySelector("a\\:theme, theme");if(!e)return null;const r=e.querySelector("a\\:themeElements a\\:clrScheme, themeElements clrScheme");if(!r)return null;const theme=new CTheme;theme.name=e.getAttribute("name")||"Default Theme";theme.colors={};theme.fonts={major:"Calibri",minor:"Calibri"};theme.colors=this.extractEnhancedThemeColors(r);if(theme.colors.accent6){const t=this.parseColorFromHex(theme.colors.accent6)}const o=e.querySelector("a\\:themeElements a\\:fontScheme, themeElements fontScheme");if(o){const t=o.querySelector("a\\:majorFont a\\:latin, majorFont latin");const e=o.querySelector("a\\:minorFont a\\:latin, minorFont latin");if(t)theme.fonts.major=t.getAttribute("typeface")||"Calibri";if(e)theme.fonts.minor=e.getAttribute("typeface")||"Calibri"}const s=e.querySelector("a\\:themeElements a\\:fmtScheme, themeElements fmtScheme");if(s)theme.formatScheme=this.parseEnhancedFormatScheme(s,theme.colors);else theme.formatScheme=this.createEnhancedDefaultFormatScheme(theme.colors);theme.metadata={extracted:true,source:"pptx_file",timestamp:(new Date).toISOString(),colorCount:Object.keys(theme.colors).length,fillStyleCount:theme.formatScheme.fillStyles?.length||0,backgroundFillCount:theme.formatScheme.backgroundFills?.length||0};window.extractedTheme=theme;return theme}catch(t){return null}}extractEnhancedThemeColors(t){const e={};try{const r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink","bg1","tx1","bg2","tx2"];for(const o of r){const r=t.querySelector(`a\\:${o}, ${o}`)||t.querySelector(`[name="${o}"]`);if(r){const t=this.extractColorFromThemeElement(r);if(t)e[o]=t}}const o=t.querySelectorAll("*");for(const t of o){const r=t.tagName.replace("a:","");if(!e[r]&&"clrScheme"!==r&&"themeElements"!==r){const o=this.extractColorFromThemeElement(t);if(o)e[r]=o}}if(e.dk1&&!e.tx1)e.tx1=e.dk1;if(e.lt1&&!e.bg1)e.bg1=e.lt1;if(e.dk2&&!e.tx2)e.tx2=e.dk2;if(e.lt2&&!e.bg2)e.bg2=e.lt2}catch(t){}return e}extractColorFromThemeElement(t){try{const e=t.querySelector("a\\:srgbClr, srgbClr");if(e){const t=e.getAttribute("val");if(t&&/^[0-9A-Fa-f]{6}$/.test(t))return`#${t.toUpperCase()}`}const r=t.querySelector("a\\:sysClr, sysClr");if(r){const t=r.getAttribute("lastClr");if(t&&/^[0-9A-Fa-f]{6}$/.test(t))return`#${t.toUpperCase()}`;const e=r.getAttribute("val");const o={windowText:"#000000",window:"#FFFFFF",btnFace:"#F0F0F0",btnText:"#000000"};if(e&&o[e])return o[e]}const o=t.querySelector("a\\:hslClr, hslClr");if(o){const t=parseInt(o.getAttribute("hue")||"0");const e=parseInt(o.getAttribute("sat")||"0")/1e5;const r=parseInt(o.getAttribute("lum")||"0")/1e5;return this.hslToHex(t/6e4,e,r)}const s=t.querySelector("a\\:prstClr, prstClr");if(s){const t=s.getAttribute("val");const e={black:"#000000",white:"#FFFFFF",red:"#FF0000",green:"#00FF00",blue:"#0000FF",yellow:"#FFFF00",magenta:"#FF00FF",cyan:"#00FFFF"};if(t&&e[t])return e[t]}}catch(t){}return null}hslToHex(t,e,r){const o=(t,e,r)=>{if(r<0)r+=1;if(r>1)r-=1;if(r<1/6)return t+6*(e-t)*r;if(r<1/2)return e;if(r<2/3)return t+(e-t)*(2/3-r)*6;return t};const s=r<.5?r*(1+e):r+e-r*e;const i=2*r-s;const n=Math.round(255*o(i,s,t+1/3));const a=Math.round(255*o(i,s,t));const l=Math.round(255*o(i,s,t-1/3));return`#${((1<<24)+(n<<16)+(a<<8)+l).toString(16).slice(1).toUpperCase()}`}parseFormatScheme(t){const e={fillStyles:[],backgroundFills:[],lineStyles:[]};try{const r=t.querySelector("a\\:fillStyleLst, fillStyleLst");if(r){const t=r.children;for(let r=0;r0)o.color=this.applyColorModifications(o.color,r);o.scheme=t;o.modifications=r;return o}}const i=t.querySelector("a\\:srgbClr, srgbClr");if(i){const t=i.getAttribute("val");if(t){o.color=this.parseColorFromHex(`#${t}`);return o}}o.color=this.getDefaultColorForIndex(r,e);o.isDefault=true}catch(t){o.color=this.getDefaultColorForIndex(r,e);o.isDefault=true}return o}parseThemeAwareGradientFill(t,e,r){const o={type:"gradient",index:r,gradient:{type:"linear",stops:[]}};try{const r=t.querySelectorAll("a\\:gs, gs");for(let t=0;t0)n.color=this.applyColorModifications(n.color,r)}}if(!n.color){const t=s.querySelector("a\\:srgbClr, srgbClr");if(t){const e=t.getAttribute("val");if(e)n.color=this.parseColorFromHex(`#${e}`)}}if(!n.color)n.color=this.getDefaultColorForIndex(t,e);o.gradient.stops.push(n)}const s=t.querySelector("a\\:lin, lin");if(s){const t=parseInt(s.getAttribute("ang")||"0");o.gradient.angle=t/6e4}return o}catch(t){return{type:"solid",index:r,color:this.getDefaultColorForIndex(r,e),isDefault:true}}}getDefaultColorForIndex(t,e){const r=["accent1","accent2","accent3","accent4","accent5","accent6"];const o=r[t%r.length];if(e&&e[o]){const t=this.parseColorFromHex(e[o]);return t}return null}ensureMinimumFormatSchemeStyles(t,e){while(t.fillStyles.length<6){const r=t.fillStyles.length;const o=this.createFallbackFillStyle(r,e);t.fillStyles.push(o)}while(t.backgroundFills.length<3){const r=t.backgroundFills.length;const o=this.createFallbackBackgroundFillStyle(r,e);t.backgroundFills.push(o)}}createFallbackFillStyle(t,e){return{type:"solid",index:t,color:this.getDefaultColorForIndex(t,e),isDefault:true}}createFallbackBackgroundFillStyle(t,e){const r=[e?.bg1?this.parseColorFromHex(e.bg1):{r:255,g:255,b:255,a:255},e?.bg2?this.parseColorFromHex(e.bg2):{r:245,g:245,b:245,a:255},{r:220,g:220,b:220,a:255}];return{type:"solid",index:t,color:r[t%r.length],isDefault:true}}createEnhancedDefaultFormatScheme(t){const e={fillStyles:[],backgroundFills:[],lineStyles:[]};for(let r=0;r<6;r++)e.fillStyles.push(this.createFallbackFillStyle(r,t));for(let r=0;r<3;r++)e.backgroundFills.push(this.createFallbackBackgroundFillStyle(r,t));return e}createDefaultFormatScheme(){return{fillStyles:[],backgroundFills:[],lineStyles:[]}}async processSlideMasters(t,e){const r=this.presentation.masterIds||[];const o=await e.getRelationships();for(const e of r){const r=o[e];if(r&&r.target){let e=r.target;if(e.startsWith("/"))e=e.substring(1);else if(e.startsWith("../"))e=e.replace("../","");if(!e.startsWith("ppt/"))e="ppt/"+e;const o=this.package.getPartByUri("/"+e);if(o){const e=await o.getDocumentContent();if(e){const r=new StaxParser(e,o,t);const s=r.parse();if(s){const e=this.createSlideMasterFromXML(s,o);if(e){this.slideMasters.push(e);this.presentation.addSlideMaster(e);await this.processSlideLayouts(t,e,o)}}}}}}}async processSlideLayouts(t,e,r){const o=await r.getRelationships();for(const[r,s]of Object.entries(o))if(s.type===Bt.slideLayout.relationType){let o=s.target;if(o.startsWith("/"))o=o.substring(1);else if(o.startsWith("../"))o=o.replace("../","");if(!o.startsWith("ppt/"))o="ppt/"+o;const i=this.package.getPartByUri("/"+o);if(i){const n=await i.getDocumentContent();if(n){const a=new StaxParser(n,i,t);const l=a.parse();if(l){const t=this.createSlideLayoutFromXML(l,e.id,r,s.target,o);if(t){this.slideLayouts.push(t);e.addLayout(t)}}}}}}createSlideMasterFromXML(t,e){const r=t.documentElement;const o=e.uri||"master_"+this.slideMasters.length;const s=new CSlideMaster;s.id=o;s.name=r.getAttribute("name")||`Master ${this.slideMasters.length+1}`;s.layoutIds=[];const i=t.querySelector("sldLayoutIdLst, p\\:sldLayoutIdLst");if(i){const t=i.querySelectorAll("sldLayoutId, p\\:sldLayoutId");t.forEach(t=>{const e=t.getAttribute("r:id");if(e)s.layoutIds.push(e)})}const n=t.querySelector("cSld, p\\:cSld");if(n){s.cSld={name:n.getAttribute("name")||"",bg:this.parseBackground(n),spTree:this.processShapeTree(n.querySelector("spTree, p\\:spTree"))};s.commonSlideData=new CSld;s.commonSlideData.name=s.cSld.name;s.commonSlideData.backgroundFill=s.cSld.bg;s.commonSlideData.shapeTree=s.cSld.spTree}const a=t.querySelector("txStyles, p\\:txStyles");if(a)s.txStyles={titleStyle:this.parseTextStyleElement(a.querySelector("titleStyle, p\\:titleStyle")),bodyStyle:this.parseTextStyleElement(a.querySelector("bodyStyle, p\\:bodyStyle")),otherStyle:this.parseTextStyleElement(a.querySelector("otherStyle, p\\:otherStyle"))};const l=t.querySelector("clrMap, p\\:clrMap");if(l)s.clrMap=this.parseColorMapElement(l);this.xmlParser.registerSlideMaster(s.id,s);return s}createSlideLayoutFromXML(t,e,r=null,o=null,s=null){const i=t.documentElement;const n=r||`layout_${this.slideLayouts.length}`;const a=new CSlideLayout;a.id=n;a.relId=r;a.relTarget=o;a.layoutPath=s;a.uri=o;a.masterId=e;a.name=i.getAttribute("name")||`Layout ${this.slideLayouts.length+1}`;a.type=i.getAttribute("type")||"blank";a.matchingName=i.getAttribute("matchingName")||"";a.preserve="true"===i.getAttribute("preserve");a.showMasterSp="false"!==i.getAttribute("showMasterSp");a.showMasterPhAnim="true"===i.getAttribute("showMasterPhAnim");a.userDrawn="false"!==i.getAttribute("userDrawn");if("blank"===a.type)a.layoutType=this.inferLayoutTypeFromPlaceholders(i);else a.layoutType=a.type;const l=t.querySelector("cSld, p\\:cSld");if(l){const t=l.querySelector("spTree, p\\:spTree");const e=this.processShapeTree(t);a.cSld={name:l.getAttribute("name")||"",bg:this.parseBackground(l),spTree:e};a.commonSlideData=new CSld;a.commonSlideData.name=a.cSld.name;a.commonSlideData.backgroundFill=a.cSld.bg;a.commonSlideData.shapeTree=a.cSld.spTree}const c=t.querySelector("txStyles, p\\:txStyles");if(c)a.txStyles={titleStyle:this.parseTextStyleElement(c.querySelector("titleStyle, p\\:titleStyle")),bodyStyle:this.parseTextStyleElement(c.querySelector("bodyStyle, p\\:bodyStyle")),otherStyle:this.parseTextStyleElement(c.querySelector("otherStyle, p\\:otherStyle"))};const h=t.querySelector("clrMapOvr, p\\:clrMapOvr");if(h)a.clrMapOvr=this.parseColorMapOverride(h);this.xmlParser.registerSlideLayout(a.id,a,e);return a}async processSlides(t){const e=await this.package.getPartByRelationshipType(Bt.presentation.relationType).getRelationships();const r=[];for(const[t,o]of Object.entries(e))if(o.type===Bt.slide.relationType)r.push({id:t,target:o.target});if(0===r.length)return;let o=r;try{const t=this.presentation&&Array.isArray(this.presentation.slideIds)?this.presentation.slideIds:[];if(t&&t.length>0){const e=new Map(r.map(t=>[t.id,t]));const s=[];for(const r of t){const t=e.get(r);if(t){s.push(t);e.delete(r)}}if(e.size>0)for(const t of e.values())s.push(t);if(s.length>0)o=s}}catch(t){}for(let e=0;e{if(r.target&&t.relTarget){const e=r.target.split("/").pop();const o=t.relTarget.split("/").pop();if(e===o)return true}return false});if(!e)e=this.slideLayouts.find(t=>{if(t.uri===r.target)return true;return false});if(!e)e=this.slideLayouts.find(t=>{if(r.target&&t.relTarget){const e=t=>t.replace(/^\.\.\//,"").replace(/^\//,"");if(e(r.target)===e(t.relTarget))return true}return false});if(!e)e=this.slideLayouts.find(e=>{if(e.relId===t)return true;return false});if(e){slide.layout=e;slide.Layout=e;const t=this.slideMasters.find(t=>t.id===e.masterId);if(t){slide.master=t;slide.Master=t;e.master=t;e.Master=t}break}}if(!slide.layout&&this.slideLayouts.length>0){slide.layout=this.slideLayouts[0];slide.Layout=this.slideLayouts[0]}else if(!slide.layout);}catch(t){}}processShapeTree(t){const e=[];try{if(!t)return e;const r=t.children;for(let t=0;t{const r=t.querySelector("a\\:fillRef, fillRef");if(r);})}const e=t.querySelector("spPr, p\\:spPr");if(e){const t=this.processShapeProperties(e);if(t.transform&&!r.properties?.transform){r.properties=r.properties||{};r.properties.transform=t.transform;if(!r.bounds||0===r.bounds.l&&0===r.bounds.t&&0===r.bounds.r&&0===r.bounds.b)r.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)}}if(t.fill&&!r.fill)r.fill=t.fill;if(t.stroke&&!r.stroke)r.stroke=t.stroke;if(t.geometry&&!r.geometry)r.geometry=t.geometry;if(!r.spPr)r.spPr=t;if(t.effectLst)r.effects=t.effectLst;if(r.style||r.preservedStyle);}const o=t.querySelector("txBody, p\\:txBody");if(o)r.textBody=this.processTextBody(o)}return r}catch(t){return{type:"unknown",id:Math.random().toString(36).substr(2,9),name:"Unknown Shape",bounds:{l:914400,t:914400,r:5486400,b:2743200}}}}processRegularShape(t){const e=new CShape;e.type="sp";e.name=this.getShapeName(t);const r=t.querySelector("nvSpPr, p\\:nvSpPr");const o=r?.querySelector("cNvPr, p\\:cNvPr");e.id=o?.getAttribute("id")||t.getAttribute("id")||null;if(o){const t=Array.from(o.attributes).map(t=>`${t.name}="${t.value}"`);const r=o.getAttribute("order")||o.getAttribute("z-order")||o.getAttribute("zOrder")||o.getAttribute("drawOrder");if(r)e.order=parseInt(r)}const s=t.getAttribute("order")||t.getAttribute("z-order")||t.getAttribute("zOrder")||t.getAttribute("drawOrder");if(s)e.order=parseInt(s);try{if(r){e.nvSpPr={cNvPr:null,nvPr:null};if(o){e.name=o.getAttribute("name")||e.name;e.nvSpPr.cNvPr={name:e.name,id:e.id}}const t=r.querySelector("nvPr, p\\:nvPr");if(t){const r=t.querySelector("ph, p\\:ph");if(r){e.placeholder=this.parsePlaceholder(r);e.isPlaceholder=true}e.nvSpPr.nvPr={placeholder:e.placeholder}}}e.type="sp";const s=t.querySelector("spPr, p\\:spPr");if(s){const t=this.processShapeProperties(s);e.properties=t;e.spPr=t;if(t.effectLst)e.effects=t.effectLst;if(t.transform)e.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)};else e.bounds={l:914400,t:914400,r:5486400,b:2743200};if(void 0!==t.fill)e.fill=t.fill;if(t.stroke)e.stroke=t.stroke;const r=s.querySelector("prstGeom, a\\:prstGeom");if(r){const t=r.getAttribute("prst")||"rect";const o={};const s=r.querySelector("avLst, a\\:avLst");if(s)s.querySelectorAll("gd, a\\:gd").forEach(t=>{const e=t.getAttribute("name");const r=t.getAttribute("fmla")||"";const s=r.match(/^val\s+(-?\d+)$/);if(e&&s)o[e]=parseInt(s[1])});e.geometry={type:"preset",preset:t,adjustments:o}}const o=s.querySelector("custGeom, a\\:custGeom");if(o)e.geometry={type:"custom",pathList:this.parseCustomGeometry(o)}}else e.bounds={l:914400,t:914400,r:5486400,b:2743200};const i=t.querySelector("txBody, p\\:txBody");if(i){e.textBody=this.processTextBody(i);if(e.textBody&&e.textBody.paragraphs){let t=false;let r="";for(const o of e.textBody.paragraphs)for(const e of o.runs)if(e.text&&e.text.trim()){t=true;r+=e.text+" "}if(t);}}let n=false;const a=t.querySelector("style, p\\:style");if(a){e.style=this.parseShapeStyle(a);e.preservedStyle=e.style;n=true}if(!n&&window.currentSlideData&&window.currentSlideData.rawXMLShapes){const t=window.currentSlideData.rawXMLShapes.find(t=>t.name===e.name||t.id===e.id);if(t&&t.style){e.style=t.style;e.preservedStyle=t.style;n=true}}if(!n){const r=this.extractStyleFromElement(t);if(r&&Object.keys(r).length>0){e.style=r;e.preservedStyle=r;n=true}}if(n){window.currentSlideData=window.currentSlideData||{};window.currentSlideData.rawXMLShapes=window.currentSlideData.rawXMLShapes||[];const t=window.currentSlideData.rawXMLShapes.findIndex(t=>t.name===e.name||t.id===e.id);if(-1===t)window.currentSlideData.rawXMLShapes.push({name:e.name,id:e.id,styleElement:a,style:e.style,hasStyle:true})}else{window.currentSlideData=window.currentSlideData||{};window.currentSlideData.rawXMLShapes=window.currentSlideData.rawXMLShapes||[];window.currentSlideData.rawXMLShapes.push({name:e.name,id:e.id,xmlElement:t,innerHTML:t.innerHTML.substring(0,500),hasStyle:false})}}catch(t){}this.applyPropertyInheritance(e);return e}processPictureShape(t){const e=new CShape;e.type="pic";let r=false;const o=t.querySelector("style, p\\:style");if(o){e.style=this.parseShapeStyle(o);e.preservedStyle=e.style;r=true}if(!r&&window.currentSlideData&&window.currentSlideData.rawXMLShapes){const t=window.currentSlideData.rawXMLShapes.find(t=>t.name===e.name||t.id===e.id);if(t&&t.style){e.style=t.style;e.preservedStyle=t.style;r=true}}if(!r){const o=this.extractStyleFromElement(t);if(o&&Object.keys(o).length>0){e.style=o;e.preservedStyle=o;r=true}}if(!r);const s=t.querySelector("spPr, p\\:spPr");if(s){const t=this.processShapeProperties(s);e.properties=t;if(t.transform)e.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)};else e.bounds={l:914400,t:914400,r:5486400,b:2743200}}else e.bounds={l:914400,t:914400,r:5486400,b:2743200};const i=t.querySelector("blipFill, p\\:blipFill");if(i){const t=i.querySelector("blip, a\\:blip");if(t){const r=this.extractSVGRelationshipId(t);if(r){e.imageRelId=r;e.hasSVGAlternative=true}else{const r=t.getAttribute("r:embed");if(r)e.imageRelId=r}const o=t.querySelector("effects, a\\:effects");if(o)e.imageEffects=this.parseImageEffects(o)}const r=i.querySelector("stretch, a\\:stretch");const o=i.querySelector("tile, a\\:tile");if(r){e.imageFillMode="stretch";const t=r.querySelector("fillRect, a\\:fillRect");if(t)e.imageFillRect={l:parseInt(t.getAttribute("l"))||0,t:parseInt(t.getAttribute("t"))||0,r:parseInt(t.getAttribute("r"))||0,b:parseInt(t.getAttribute("b"))||0}}else if(o){e.imageFillMode="tile";e.imageTileProperties={tx:parseInt(o.getAttribute("tx"))||0,ty:parseInt(o.getAttribute("ty"))||0,sx:parseInt(o.getAttribute("sx"))||1e5,sy:parseInt(o.getAttribute("sy"))||1e5,flip:o.getAttribute("flip")||"none",algn:o.getAttribute("algn")||"tl"}}else e.imageFillMode="stretch";const s=i.querySelector("srcRect, a\\:srcRect");if(s)e.imageSrcRect={l:parseInt(s.getAttribute("l")||"0"),t:parseInt(s.getAttribute("t")||"0"),r:parseInt(s.getAttribute("r")||"0"),b:parseInt(s.getAttribute("b")||"0")}}e.name=this.getShapeName(t);this.applyPropertyInheritance(e);return e}parseImageEffects(t){const e={};const r=t.querySelector("alphaMod, a\\:alphaMod");if(r)e.alpha=parseInt(r.getAttribute("val"))/1e5;const o=t.querySelector("lum, a\\:lum");if(o){e.brightness=parseInt(o.getAttribute("bright"))||0;e.contrast=parseInt(o.getAttribute("contrast"))||0}const s=t.querySelector("clrMod, a\\:clrMod");if(s)e.colorMod=s.getAttribute("val");const i=t.querySelector("grayscl, a\\:grayscl");if(i)e.grayscale=true;return e}parseEffectList(t){const e={};const r=t.querySelector("outerShdw, a\\:outerShdw");if(r)e.outerShadow=this.parseOuterShadow(r);const o=t.querySelector("innerShdw, a\\:innerShdw");if(o)e.innerShadow=this.parseInnerShadow(o);const s=t.querySelector("glow, a\\:glow");if(s)e.glow=this.parseGlow(s);const i=t.querySelector("reflection, a\\:reflection");if(i)e.reflection=this.parseReflection(i);const n=t.querySelector("softEdge, a\\:softEdge");if(n)e.softEdge=this.parseSoftEdge(n);const a=t.querySelector("prstShdw, a\\:prstShdw");if(a)e.presetShadow=this.parsePresetShadow(a);return e}parseOuterShadow(t){const e={};e.blurRadius=parseInt(t.getAttribute("blurRad"))||0;e.distance=parseInt(t.getAttribute("dist"))||0;e.direction=parseInt(t.getAttribute("dir"))||0;e.scaleX=parseInt(t.getAttribute("sx"))/1e5||1;e.scaleY=parseInt(t.getAttribute("sy"))/1e5||1;e.skewX=parseInt(t.getAttribute("kx"))||0;e.skewY=parseInt(t.getAttribute("ky"))||0;e.alignment=t.getAttribute("algn")||"bl";e.rotateWithShape="1"===t.getAttribute("rotWithShape");const r=t.querySelector("srgbClr, a\\:srgbClr, schemeClr, a\\:schemeClr");if(r)e.color=this.parseColor(r);return e}parseInnerShadow(t){const e={};e.blurRadius=parseInt(t.getAttribute("blurRad"))||0;e.distance=parseInt(t.getAttribute("dist"))||0;e.direction=parseInt(t.getAttribute("dir"))||0;const r=t.querySelector("srgbClr, a\\:srgbClr, schemeClr, a\\:schemeClr");if(r)e.color=this.parseColor(r);return e}parseGlow(t){const e={};e.radius=parseInt(t.getAttribute("rad"))||0;const r=t.querySelector("srgbClr, a\\:srgbClr, schemeClr, a\\:schemeClr");if(r)e.color=this.parseColor(r);return e}parseReflection(t){const e={};e.blurRadius=parseInt(t.getAttribute("blurRad"))||0;e.startOpacity=parseInt(t.getAttribute("stA"))/1e5||1;e.endOpacity=parseInt(t.getAttribute("endA"))/1e5||0;e.distance=parseInt(t.getAttribute("dist"))||0;e.direction=parseInt(t.getAttribute("dir"))||0;e.fadeDirection=parseInt(t.getAttribute("fadeDir"))||0;e.scaleX=parseInt(t.getAttribute("sx"))/1e5||1;e.scaleY=parseInt(t.getAttribute("sy"))/1e5||1;e.skewX=parseInt(t.getAttribute("kx"))||0;e.skewY=parseInt(t.getAttribute("ky"))||0;e.alignment=t.getAttribute("algn")||"bl";return e}parseSoftEdge(t){const e={};e.radius=parseInt(t.getAttribute("rad"))||0;return e}parsePresetShadow(t){const e={};e.preset=t.getAttribute("prst")||"shdw1";e.distance=parseInt(t.getAttribute("dist"))||0;e.direction=parseInt(t.getAttribute("dir"))||0;return e}parseColor(t){const e={};if(t.tagName.includes("srgbClr")){e.type="srgb";e.value=t.getAttribute("val")||"000000"}else if(t.tagName.includes("schemeClr")){e.type="scheme";e.value=t.getAttribute("val")||"dk1"}const r=t.querySelector("alpha, a\\:alpha");if(r)e.alpha=parseInt(r.getAttribute("val"))/1e5||1;else e.alpha=1;return e}processGroupShape(t){const e=new CShape;e.type="grpSp";e.name=this.getShapeName(t);e.id=t.getAttribute("id")||Math.random().toString(36).substr(2,9);e.shapeTree=[];e.groupCoordSystem={chOff:{x:0,y:0},chExt:{cx:0,cy:0},groupOff:{x:0,y:0},groupExt:{cx:0,cy:0}};this.applyComprehensiveStyleExtraction(e,t,"group");const r=t.querySelector("grpSpPr, p\\:grpSpPr");if(r)this.processGroupProperties(r,e);const o=t.querySelector("spTree, p\\:spTree");if(o)e.shapeTree=this.processShapeTreeInGroup(o,e);else{const r=t.children;for(let t=0;t0&&r.groupExt.cx>0)s=r.groupExt.cx/r.chExt.cx;if(r.chExt.cy>0&&r.groupExt.cy>0)i=r.groupExt.cy/r.chExt.cy;const n={l:r.groupOff.x+(o.l-r.chOff.x)*s,t:r.groupOff.y+(o.t-r.chOff.y)*i,r:r.groupOff.x+(o.r-r.chOff.x)*s,b:r.groupOff.y+(o.b-r.chOff.y)*i};t.originalBounds={...o};t.bounds=n;t.groupTransform={scaleX:s,scaleY:i,offsetX:r.groupOff.x-r.chOff.x*s,offsetY:r.groupOff.y-r.chOff.y*i}}calculateGroupBounds(t){if(!t.shapeTree||0===t.shapeTree.length){t.bounds={l:914400,t:914400,r:5486400,b:2743200};return}let e=1/0,r=1/0;let o=-1/0,s=-1/0;let i=false;for(const n of t.shapeTree)if(n.bounds){e=Math.min(e,n.bounds.l);r=Math.min(r,n.bounds.t);o=Math.max(o,n.bounds.r);s=Math.max(s,n.bounds.b);i=true}if(i)t.bounds={l:e,t:r,r:o,b:s};else t.bounds={l:914400,t:914400,r:5486400,b:2743200}}processConnectorShape(t){const e=new CShape;e.type="cxnSp";this.applyComprehensiveStyleExtraction(e,t,"connector");try{const e=t.getAttribute("id")||t.getAttribute("r:id");this.logger?.log("info",this.constructor.name,"[Connector Parse] start",{id:e})}catch(t){}const r=t.querySelector("spPr, p\\:spPr");if(r){const t=this.processShapeProperties(r);e.properties=t;if(t&&t.stroke){if(!e.properties.line)e.properties.line=t.stroke;if(!e.stroke)e.stroke=t.stroke}if(t&&t.transform)e.transform=Object.assign(e.transform||{},t.transform);try{const t=r.querySelector("a\\:ln, ln, p\\:ln");if(t){const r=this.parseStroke(t);e.properties=e.properties||{};e.properties.stroke=r;e.properties.line=r;e.stroke=r;e.spPr=e.spPr||{};e.spPr.ln=Object.assign({},r)}}catch(t){}if(t.geometry)e.geometry=t.geometry;if(t.transform){e.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)};try{this.logger?.log("info",this.constructor.name,"[Connector Parse] bounds from transform",{bounds:e.bounds,transform:t.transform})}catch(t){}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};try{this.logger?.log("warn",this.constructor.name,"[Connector Parse] no transform, using fallback bounds")}catch(t){}try{void 0}catch(t){}}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};try{this.logger?.log("warn",this.constructor.name,"[Connector Parse] no spPr found, using fallback bounds")}catch(t){}try{void 0}catch(t){}}this.applyPropertyInheritance(e);try{const t=this.getShapeStrokeColor(e);const r=this.getShapeLineWidth(e);const o=this.getShapeStrokeInfo(e)}catch(t){}return e}processGraphicFrame(t){const e=new CShape;e.type="graphicFrame";this.applyComprehensiveStyleExtraction(e,t,"graphic frame");const r=t.querySelector("spPr, p\\:spPr");if(r){const t=this.processShapeProperties(r);if(t.transform){const r=t.transform.x||0;const o=t.transform.y||0;const s=t.transform.cx||t.transform.width||0;const i=t.transform.cy||t.transform.height||0;e.bounds={l:r,t:o,r:r+s,b:o+i};e.x=r;e.y=o;e.w=s;e.h=i;if(!e.properties)e.properties={};e.properties.transform={x:r,y:o,width:s,height:i,cx:s,cy:i}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};e.x=914400;e.y=914400;e.w=4572e3;e.h=1828800}}else{const r=t.querySelector("xfrm, p\\:xfrm");if(r){const o=r.querySelector("off, p\\:off");const s=r.querySelector("ext, p\\:ext");if(o&&s){const r=parseInt(o.getAttribute("x"))||0;const i=parseInt(o.getAttribute("y"))||0;const n=parseInt(s.getAttribute("cx"));const a=parseInt(s.getAttribute("cy"));const l=Number.isFinite(n)&&n>=0?n:914400;const c=Number.isFinite(a)&&a>=0?a:914400;e.bounds={l:r,t:i,r:r+l,b:i+c};e.x=r;e.y=i;e.w=l;e.h=c;if(!e.properties)e.properties={};e.properties.transform={x:r,y:i,width:l,height:c,cx:l,cy:c};if(0===r&&0===i||l<=1e5&&c<=1e5){let o=t.parentElement;while(o&&o.tagName){const t=o.querySelector("xfrm, p\\:xfrm");if(t){const r=t.querySelector("off, p\\:off");const o=t.querySelector("ext, p\\:ext");if(r&&o){const t=parseInt(r.getAttribute("x"))||0;const s=parseInt(r.getAttribute("y"))||0;const i=parseInt(o.getAttribute("cx"))||0;const n=parseInt(o.getAttribute("cy"))||0;if(i>1e5&&n>1e5){e.bounds={l:t,t:s,r:t+i,b:s+n};e.x=t;e.y=s;e.w=i;e.h=n;if(!e.properties)e.properties={};e.properties.transform={x:t,y:s,width:i,height:n,cx:i,cy:n};break}}}o=o.parentElement}if(!e.bounds||e.x===r&&e.y===i);}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};e.x=914400;e.y=914400;e.w=4572e3;e.h=1828800}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};e.x=914400;e.y=914400;e.w=4572e3;e.h=1828800}}let o=t.querySelector("graphic");if(!o)o=t.querySelector("p\\:graphic");if(!o)o=t.querySelector("a\\:graphic");if(!o)o=Array.from(t.children).find(t=>t.tagName.toLowerCase().includes("graphic"));if(o){let r=o.querySelector("graphicData");if(!r)r=o.querySelector("p\\:graphicData");if(!r)r=o.querySelector("a\\:graphicData");if(!r)r=Array.from(o.children).find(t=>t.tagName.toLowerCase().includes("graphicdata"));if(r){const o=r.getAttribute("uri");e.graphicData={uri:o};if("http://schemas.openxmlformats.org/drawingml/2006/table"===o){let t=r.querySelector("tbl");if(!t)t=r.querySelector("a\\:tbl");if(!t)t=Array.from(r.children).find(t=>t.tagName.toLowerCase().includes("tbl"));if(t)e.graphicData.tableXml=(new XMLSerializer).serializeToString(t)}else if("http://schemas.openxmlformats.org/drawingml/2006/chart"===o){e.graphicData.element=r;const o=r.querySelector("chart")||r.querySelector("c\\:chart")||r.querySelector('[*|localName="chart"]');if(o){const t=o.getAttribute("r:id");if(t)e.graphicData.chartRef=t}if(ChartProcessor)try{e.asyncChartProcessing=true;e.originalBounds={l:e.bounds.l,t:e.bounds.t,r:e.bounds.r,b:e.bounds.b};const r=e.originalBounds.r-e.originalBounds.l;const o=e.originalBounds.b-e.originalBounds.t;const s={event:"ORIGINAL_BOUNDS_STORAGE",shapeType:e.type,rawBounds:e.bounds,originalBounds:e.originalBounds,originalDimensions:{width:r,height:o,widthInches:(r/914400).toFixed(2),heightInches:(o/914400).toFixed(2)}};e._debugInfo=s;const i={...this.context,zip:this.zip||this.zipProcessor?.zip};const n=new ChartProcessor(i);n.parseChartFromGraphicFrame(t).then(t=>{if(t){e.chartData=t;e.asyncChartProcessing=false;if("undefined"!==typeof window)window.dispatchEvent(new CustomEvent("chartRenderingComplete",{detail:{chartData:t}}))}}).catch(t=>{void 0;e.asyncChartProcessing=false})}catch(t){void 0}else void 0}}}return e}processDefaultShape(t){const e=new CShape;e.type="unknown";this.applyComprehensiveStyleExtraction(e,t,"default shape");const r=t.querySelector("spPr, p\\:spPr");if(r){const t=this.processShapeProperties(r);if(t.transform)e.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)};else e.bounds={l:914400,t:914400,r:5486400,b:2743200}}else e.bounds={l:914400,t:914400,r:5486400,b:2743200};this.applyPropertyInheritance(e);return e}getShapeName(t){const e=t.querySelector("nvSpPr, p\\:nvSpPr")||t.querySelector("nvPicPr, p\\:nvPicPr")||t.querySelector("nvGrpSpPr, p\\:nvGrpSpPr");if(e){const t=e.querySelector("cNvPr, p\\:cNvPr");if(t)return t.getAttribute("name")||""}return""}processShapeProperties(t){const e={};if(!t)return e;const r=Array.from(t.children);try{let r=t.querySelector("xfrm, p\\:xfrm, a\\:xfrm");if(!r)r=t.querySelector("xfrm");if(!r)for(const e of t.children)if("xfrm"===e.tagName||"a:xfrm"===e.tagName||"p:xfrm"===e.tagName){r=e;break}if(r){const t=Array.from(r.children);let o=r.querySelector("off, p\\:off, a\\:off");if(!o)o=r.querySelector("off");if(!o)for(const t of r.children)if("off"===t.tagName||"a:off"===t.tagName||"p:off"===t.tagName){o=t;break}let s=r.querySelector("ext, p\\:ext, a\\:ext");if(!s)s=r.querySelector("ext");if(!s)for(const t of r.children)if("ext"===t.tagName||"a:ext"===t.tagName||"p:ext"===t.tagName){s=t;break}if(o){const t=o.getAttribute("x");const e=o.getAttribute("y")}if(s){const t=s.getAttribute("cx");const e=s.getAttribute("cy")}if(o&&s){const t=parseInt(o.getAttribute("x"))||0;const r=parseInt(o.getAttribute("y"))||0;const i=parseInt(s.getAttribute("cx"))||100;const n=parseInt(s.getAttribute("cy"))||100;e.transform={x:t,y:r,cx:i,cy:n,width:i,height:n}}const i=r.getAttribute("rot");if(i){e.transform=e.transform||{};const t=parseInt(i)/6e4||0;e.transform.rot=t;e.transform.rotation=t;e.transform.rotEMU=parseInt(i)||0}const n=r.getAttribute("flipH");const a=r.getAttribute("flipV");if(null!==n||null!==a){e.transform=e.transform||{};if(null!==n)e.transform.flipH="1"===n||"true"===n;if(null!==a)e.transform.flipV="1"===a||"true"===a}}const o=["gradFill","solidFill","blipFill","pattFill","noFill"];let s=null;for(const e of t.children){const t=e.localName||e.tagName?.replace(/^.*:/,"");if(o.includes(t)){s=e;break}}if(s){this._currentProcessingShape={name:this.getShapeName(t.closest("sp, p\\:sp"))||"Unknown"};e.fill=this.parseFill(s);this._currentProcessingShape=null;const r=this.getShapeName(t.closest("sp, p\\:sp"));if("Rectangle 3"===r||r?.includes("Rectangle 3"));}const i=t.querySelector("ln, p\\:ln, a\\:ln");if(i)e.stroke=this.parseStroke(i);const n=t.querySelector("prstGeom, p\\:prstGeom, a\\:prstGeom");if(n){const t=n.getAttribute("prst")||"rect";const r={};const o=n.querySelector("avLst, a\\:avLst");if(o)o.querySelectorAll("gd, a\\:gd").forEach(t=>{const e=t.getAttribute("name");const o=t.getAttribute("fmla")||"";const s=o.match(/^val\s+(-?\d+)$/);if(e&&s)r[e]=parseInt(s[1])});e.geometry={type:"preset",preset:t,adjustments:r}}else{const e=Array.from(t.children)}const a=t.querySelector("custGeom, p\\:custGeom, a\\:custGeom");if(a)e.geometry={type:"custom",pathList:this.parseCustomGeometry(a)};const l=t.querySelector("effectLst, p\\:effectLst, a\\:effectLst");if(l)e.effectLst=this.parseEffectList(l)}catch(t){}return e}processTextBody(t){const e={paragraphs:[],bodyProperties:this.parseBodyProperties(t)};try{const r=t.querySelector("lstStyle, a\\:lstStyle");if(r)e.lstStyle=this.parseListStyle(r);const o=t.querySelectorAll("p, a\\:p");for(const t of o){const r={runs:[],properties:this.parseParagraphProperties(t)};const o=t.querySelectorAll("r, a\\:r, fld, a\\:fld");for(const t of o){const e=t.tagName?t.tagName.toLowerCase():"";const o="a:fld"===e||"fld"===e;const s=t.querySelector("t, a\\:t");const i=s?s.textContent:"";const n={text:i||"",properties:this.parseRunProperties(t)};if(o){const e=t.getAttribute("type")||"";n.fieldType=e;if(!n.text&&("slidenum"===e||"slideNum"===e))n.text="1"}r.runs.push(n)}if(0===r.runs.length)r.runs.push({text:"",properties:{}});e.paragraphs.push(r)}const s=e.paragraphs.reduce((t,e)=>t+e.runs.length,0);const i=e.paragraphs.reduce((t,e)=>t+e.runs.filter(t=>t.text&&t.text.trim()).length,0);const n=e.paragraphs.map(t=>t.runs.map(t=>t.text||"").join("")).join(" ").trim()}catch(t){}return e}parseListStyle(t){const e={};try{for(let r=1;r<=9;r++){const o=t.querySelector(`lvl${r}pPr, a\\:lvl${r}pPr`);if(o){const t={align:o.getAttribute("algn")||"left",marL:parseInt(o.getAttribute("marL"))||0,indent:parseInt(o.getAttribute("indent"))||0};const s=o.querySelector("defRPr, a\\:defRPr");if(s){const e=s.getAttribute("sz");if(e){const r=parseInt(e);if(r>0)t.fontSize=r/100}const r=s.getAttribute("b");if(null!==r)t.bold="1"===r||"true"===r;const o=s.getAttribute("i");if(null!==o)t.italic="1"===o||"true"===o;const i=s.getAttribute("cap");if(i)t.cap=i;const n=s.querySelector("latin, a\\:latin");if(n)t.fontFamily=n.getAttribute("typeface")||"Arial";const a=s.querySelector("solidFill, a\\:solidFill");if(a)t.color=this.parseColor(a)}const i=o.querySelector("spcBef, a\\:spcBef");if(i){const e=i.querySelector("spcPct, a\\:spcPct");const r=i.querySelector("spcPts, a\\:spcPts");if(e)t.spaceBeforePct=parseInt(e.getAttribute("val"))/1e5;else if(r)t.spaceBefore=127*parseInt(r.getAttribute("val"))}const n=o.querySelector("spcAft, a\\:spcAft");if(n){const e=n.querySelector("spcPct, a\\:spcPct");const r=n.querySelector("spcPts, a\\:spcPts");if(e)t.spaceAfterPct=parseInt(e.getAttribute("val"))/1e5;else if(r)t.spaceAfter=127*parseInt(r.getAttribute("val"))}e[`lvl${r}pPr`]=t}}}catch(t){}return e}parseBodyProperties(t){const e={wrap:true,verticalAlign:"top",anchorX:"center",anchorY:"middle"};try{const r=t.querySelector("bodyPr, a\\:bodyPr");if(r){if("none"===r.getAttribute("wrap"))e.wrap=false;const t=r.getAttribute("anchor");if(t)e.verticalAlign=t;e.anchorX=r.getAttribute("anchorX")||"center";e.anchorY=r.getAttribute("anchorY")||"middle";e.leftMargin=parseInt(r.getAttribute("lIns"))||45720;e.rightMargin=parseInt(r.getAttribute("rIns"))||45720;e.topMargin=parseInt(r.getAttribute("tIns"))||22860;e.bottomMargin=parseInt(r.getAttribute("bIns"))||22860}}catch(t){}return e}parseParagraphProperties(t){const e={align:"left",lineHeight:100,spacing:{before:0,after:0},bullet:null};try{const r=t.querySelector("pPr, a\\:pPr");if(r){const t=r.getAttribute("lvl");if(null!==t&&void 0!==t)e.level=parseInt(t)||0;else e.level=0;const o=r.getAttribute("algn");if(o)e.align=o;const s=r.querySelector("lnSpc, a\\:lnSpc");if(s){const t=s.querySelector("spcPct, a\\:spcPct");const r=s.querySelector("spcPts, a\\:spcPts");if(t)e.lineHeight=parseInt(t.getAttribute("val"))/1e3;else if(r){const t=parseInt(r.getAttribute("val"));e.lineHeightPoints=t/100}}const i=r.querySelector("spcBef, a\\:spcBef");if(i){const t=i.querySelector("spcPts, a\\:spcPts");if(t)e.spacing.before=127*parseInt(t.getAttribute("val"))}const n=r.querySelector("spcAft, a\\:spcAft");if(n){const t=n.querySelector("spcPts, a\\:spcPts");if(t)e.spacing.after=127*parseInt(t.getAttribute("val"))}const a=r.getAttribute("marL");const l=r.getAttribute("indent");if(null!==a||null!==l)e.indent={left:a?parseInt(a):0,hanging:l?parseInt(l):0};this.parseBulletProperties(r,e);const c=r.querySelector("defRPr, a\\:defRPr");if(c){const t=parseInt(c.getAttribute("sz"));if(t)e.fontSize=t/100;e.bold="1"===c.getAttribute("b");e.italic="1"===c.getAttribute("i");const r=c.querySelector("latin, a\\:latin");if(r)e.fontFamily=r.getAttribute("typeface")||"Arial";const o=c.querySelector("solidFill, a\\:solidFill");if(o)e.color=this.parseColor(o)}}}catch(t){}return e}parseBulletProperties(t,e){try{const r=t.querySelector("buChar, a\\:buChar");if(r){const t=r.getAttribute("char");if(t){e.bullet={type:"character",char:t};return}}const o=t.querySelector("buNum, a\\:buNum");if(o){const t=o.getAttribute("startAt")||"1";e.bullet={type:"number",startAt:parseInt(t)};return}const s=t.querySelector("buAutoNum, a\\:buAutoNum");if(s){const t=s.getAttribute("type")||"arabicPeriod";const r=s.getAttribute("startAt")||"1";e.bullet={type:"autoNumber",subType:t,startAt:parseInt(r)};return}const i=t.querySelector("buNone, a\\:buNone");if(i){e.bullet={type:"none"};return}}catch(t){}}parseRunProperties(t){const e={};try{const r=t.querySelector("rPr, a\\:rPr");if(r){let t=null;if(r.hasAttribute("sz"))t=parseInt(r.getAttribute("sz"));else{const e=r.querySelector("sz, a\\:sz");if(e)t=parseInt(e.getAttribute("val"))}if(t&&t>0)e.fontSize=t/100;const o=r.querySelector("latin, a\\:latin");if(o)e.fontFamily=o.getAttribute("typeface")||"Arial";else e.fontFamily=null;if(r.hasAttribute("b")){const t=r.getAttribute("b");e.bold="0"!==t&&"false"!==t}if(r.hasAttribute("i")){const t=r.getAttribute("i");e.italic="0"!==t&&"false"!==t}if(r.hasAttribute("u"))e.underline="none"!==r.getAttribute("u");if(r.hasAttribute("strike"))e.strike="noStrike"!==r.getAttribute("strike");if(r.hasAttribute("baseline")){const t=parseInt(r.getAttribute("baseline"))||0;if(t>0)e.verticalAlign="superscript";else if(t<0)e.verticalAlign="subscript"}if(r.hasAttribute("cap"))e.cap=r.getAttribute("cap");if(r.hasAttribute("spc"))e.letterSpacing=parseInt(r.getAttribute("spc"))/100;const s=r.querySelector("solidFill, a\\:solidFill");if(s)e.color=this.parseColor(s);const i=r.querySelector("highlight, a\\:highlight");if(i)e.highlight=this.parseColor(i);const n=r.querySelector("effectLst, a\\:effectLst");if(n)e.effectLst=this.parseEffectList(n)}}catch(t){}return e}parseFill(t){if(!t)return null;const e=this._currentProcessingShape;const r=e&&("Rectangle 3"===e.name||e.name?.includes("Rectangle 3"));if(r);const o=t.tagName||t.localName||"";if(o.indexOf("gradFill")>=0||(t.localName||"").indexOf("gradFill")>=0){const e=this.parseGradient(t);return{type:"gradient",gradient:e}}let s=t.querySelector("solidFill, a\\:solidFill");if(!s&&("a:solidFill"===t.tagName||"solidFill"===t.tagName))s=t;if(r)if(s);if(s){if(r);let t=null;try{t=this.parseColor(s);if(r);}catch(t){if(r);return null}const e={type:"solid",color:t};if(r);return e}const i=t.querySelector("gradFill, a\\:gradFill");if(i){const t=this.parseGradient(i);return{type:"gradient",gradient:t}}const n=t.querySelector("pattFill, a\\:pattFill");if(n)return{type:"pattern",pattern:this.parsePattern(n)};const a=t.querySelector("blipFill, a\\:blipFill");if(a){const t=this.parseBlipFill(a);return{type:"image",imageData:t}}const l=t.querySelector("noFill, a\\:noFill");if(l||"a:noFill"===t.tagName||"noFill"===t.tagName||"noFill"===t.localName)return{type:"none"};return null}parseBlipFill(t){const e=t.querySelector("blip, a\\:blip");if(!e)return null;const r={};const o=e.getAttribute("r:embed");if(o)r.relationshipId=o;const s=t.querySelector("effects, a\\:effects");if(s)r.effects=this.parseImageEffects(s);const i=t.querySelector("stretch, a\\:stretch");const n=t.querySelector("tile, a\\:tile");if(i){r.fillMode="stretch";const t=i.querySelector("fillRect, a\\:fillRect");if(t)r.fillRect={l:parseInt(t.getAttribute("l"))||0,t:parseInt(t.getAttribute("t"))||0,r:parseInt(t.getAttribute("r"))||0,b:parseInt(t.getAttribute("b"))||0}}else if(n){r.fillMode="tile";r.tileProperties={tx:parseInt(n.getAttribute("tx"))||0,ty:parseInt(n.getAttribute("ty"))||0,sx:parseInt(n.getAttribute("sx"))||1e5,sy:parseInt(n.getAttribute("sy"))||1e5,flip:n.getAttribute("flip")||"none",algn:n.getAttribute("algn")||"tl"}}else r.fillMode="stretch";const a=t.querySelector("srcRect, a\\:srcRect");if(a)r.sourceRect={l:parseInt(a.getAttribute("l"))||0,t:parseInt(a.getAttribute("t"))||0,r:parseInt(a.getAttribute("r"))||0,b:parseInt(a.getAttribute("b"))||0};return r}parseColor(t){if(!t)return{r:0,g:0,b:0,a:255};const e=t.querySelector("srgbClr, a\\:srgbClr");if(e){const t=e.getAttribute("val");if(t){let r={r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:255};r=this.applyColorModificationsToRgb(e,r);return r}}const r=t.querySelector("schemeClr, a\\:schemeClr");if(r){const t=r.getAttribute("val");const e=this._currentProcessingShape;const o=e&&("Rectangle 3"===e.name||e.name?.includes("Rectangle 3"));if(o)if(this.presentation?.theme?.colors);if("phClr"===t)return{type:"placeholder",scheme:"phClr",modifications:this.parseColorModifications(r),r:128,g:128,b:128,a:255};let s=null;if(this.presentation&&this.presentation.theme&&this.presentation.theme.colors){const e=this.presentation.theme.colors[t];if(e){s=this.parseColorFromHex(e);if(o);}else if(o);}else if(o);if(!s){if(o);const e={};s=e[t]||null;if(o);}s=this.applyColorModificationsToRgb(r,s);if(o);return s}return{r:0,g:0,b:0,a:255}}parseColorModifications(t){const e=[];const r=t.querySelectorAll("*");for(const t of r){const r=t.tagName.replace("a:","").toLowerCase();const o=t.getAttribute("val");if(o)e.push({type:r,value:parseInt(o)})}return e}applyColorModificationsToRgb(t,e){if(!t)return e;const r={...e};const o=t.querySelector("tint, a\\:tint");if(o){const t=parseInt(o.getAttribute("val"))/1e5;r.r=Math.round(r.r+(255-r.r)*t);r.g=Math.round(r.g+(255-r.g)*t);r.b=Math.round(r.b+(255-r.b)*t)}const s=t.querySelector("shade, a\\:shade");if(s){const t=parseInt(s.getAttribute("val"))/1e5;r.r=Math.round(r.r*(1-t));r.g=Math.round(r.g*(1-t));r.b=Math.round(r.b*(1-t))}const i=t.querySelector("lumMod, a\\:lumMod");if(i){const t=parseInt(i.getAttribute("val"))/1e5;r.r=Math.round(r.r*t);r.g=Math.round(r.g*t);r.b=Math.round(r.b*t)}const n=t.querySelector("lumOff, a\\:lumOff");if(n){const t=parseInt(n.getAttribute("val"))/1e5*255;r.r=Math.round(Math.min(255,r.r+t));r.g=Math.round(Math.min(255,r.g+t));r.b=Math.round(Math.min(255,r.b+t))}const a=t.querySelector("alpha, a\\:alpha");if(a){const t=parseInt(a.getAttribute("val"))/1e5;r.a=Math.round(255*t)}r.r=Math.max(0,Math.min(255,r.r));r.g=Math.max(0,Math.min(255,r.g));r.b=Math.max(0,Math.min(255,r.b));r.a=Math.max(0,Math.min(255,r.a));return r}parseGradient(t){const e={stops:[],type:"linear"};const r=t.querySelector("gsLst, a\\:gsLst");if(r){const t=r.querySelectorAll("gs, a\\:gs");t.forEach(t=>{const r=parseInt(t.getAttribute("pos"))||0;const o=this.parseColor(t);e.stops.push({position:r/1e5,color:o})})}const o=t.querySelector("lin, a\\:lin");if(o){e.angle=parseInt(o.getAttribute("ang"))||0;e.scaled="true"===o.getAttribute("scaled")}const s=t.querySelector("rad, a\\:rad");if(s)e.type="radial";return e}parsePattern(t){return{preset:t.getAttribute("prst"),foregroundColor:this.parseColor(t.querySelector("fgClr, a\\:fgClr")),backgroundColor:this.parseColor(t.querySelector("bgClr, a\\:bgClr"))}}parseStroke(t){try{const e={};const r=t.querySelector("noFill, a\\:noFill");if(r){e.noFill=true;e.width=0;return e}const o=t.getAttribute("w");if(o)e.width=parseInt(o)||12700;else e.width=12700;let s=t.querySelector("solidFill, a\\:solidFill");if(s)e.color=this.parseColor(s);else{s=t.querySelector("gradFill, a\\:gradFill");if(s){e.gradient=this.parseGradient(s);e.color=e.gradient}}const i=t.getAttribute("cap");if(i)e.cap=i;else e.cap="flat";const n=t.getAttribute("join");if(n)e.join=n;else e.join="round";const a=t.getAttribute("cmpd");if(a)e.compound=a;else e.compound="sng";const l=t.querySelector("prstDash, a\\:prstDash");if(l){e.dashStyle=l.getAttribute("val")||"solid";e.dashArray=this.getDashArray(e.dashStyle)}else{e.dashStyle="solid";e.dashArray=[]}const c=t.querySelector("custDash, a\\:custDash");if(c){e.dashArray=this.parseCustomDash(c);e.dashStyle="custom"}const h=t.getAttribute("algn");if(h)e.alignment=h;else e.alignment="ctr";const u=t.querySelector("headEnd, a\\:headEnd");if(u)e.headEnd={type:u.getAttribute("type")||u.getAttribute("val")||"none",w:u.getAttribute("w")||u.getAttribute("width")||"med",len:u.getAttribute("len")||u.getAttribute("length")||"med"};const f=t.querySelector("tailEnd, a\\:tailEnd");if(f)e.tailEnd={type:f.getAttribute("type")||f.getAttribute("val")||"none",w:f.getAttribute("w")||f.getAttribute("width")||"med",len:f.getAttribute("len")||f.getAttribute("length")||"med"};return e}catch(t){return{color:{r:0,g:0,b:0,a:255},width:12700,cap:"flat",join:"round",compound:"sng",dashStyle:"solid",dashArray:[],alignment:"ctr"}}}getDashArray(t){const e={solid:[],dot:[1,1],dash:[3,1],dashDot:[3,1,1,1],dashDotDot:[3,1,1,1,1,1],lgDash:[8,3],lgDashDot:[8,3,1,3],lgDashDotDot:[8,3,1,3,1,3],sysDash:[2,2],sysDot:[1,2],sysDashDot:[2,2,1,2],sysDashDotDot:[2,2,1,2,1,2]};return e[t]||[]}parseCustomDash(t){const e=[];try{const r=t.querySelectorAll("ds, a\\:ds");for(const t of r){const r=parseInt(t.getAttribute("d"))||1e5;const o=parseInt(t.getAttribute("sp"))||1e5;e.push(r/1e5,o/1e5)}}catch(t){}return e}parseCustomGeometry(t){const e=[];try{const r=t.querySelector("pathLst, a\\:pathLst");if(r){const t=r.querySelectorAll("path, a\\:path");for(const r of t){const t={w:parseInt(r.getAttribute("w"))||100,h:parseInt(r.getAttribute("h"))||100,commands:[]};const o=r.querySelectorAll("moveTo, lnTo, lineTo, cubicBezTo, quadBezTo, close, a\\:moveTo, a\\:lnTo, a\\:lineTo, a\\:cubicBezTo, a\\:quadBezTo, a\\:close");for(const e of o){const r=this.parsePathCommand(e);if(r)t.commands.push(r)}e.push(t)}}}catch(t){}return e}parsePathCommand(t){const e=t.tagName.toLowerCase().replace(/^a:/,"");switch(e){case"moveto":const e=t.querySelector("pt, a\\:pt");if(e)return{type:"moveTo",x:parseInt(e.getAttribute("x"))||0,y:parseInt(e.getAttribute("y"))||0};break;case"lnto":case"lineto":{const e=t.querySelector("pt, a\\:pt");if(e)return{type:"lineTo",x:parseInt(e.getAttribute("x"))||0,y:parseInt(e.getAttribute("y"))||0};break}case"cubicbezto":const r=t.querySelectorAll("pt, a\\:pt");if(r.length>=3)return{type:"cubicBezTo",x1:parseInt(r[0].getAttribute("x"))||0,y1:parseInt(r[0].getAttribute("y"))||0,x2:parseInt(r[1].getAttribute("x"))||0,y2:parseInt(r[1].getAttribute("y"))||0,x3:parseInt(r[2].getAttribute("x"))||0,y3:parseInt(r[2].getAttribute("y"))||0};break;case"quadbezto":{const e=t.querySelectorAll("pt, a\\:pt");if(e.length>=2)return{type:"quadBezTo",x1:parseInt(e[0].getAttribute("x"))||0,y1:parseInt(e[0].getAttribute("y"))||0,x:parseInt(e[1].getAttribute("x"))||0,y:parseInt(e[1].getAttribute("y"))||0};break}case"close":return{type:"close"}}return null}parseShapeStyle(t){const e={};try{const r=t.querySelector("fillRef, a\\:fillRef");if(r)e.fillRef={idx:parseInt(r.getAttribute("idx"))||0,color:this.parseColor(r)};const o=t.querySelector("lnRef, a\\:lnRef");if(o)e.lnRef={idx:parseInt(o.getAttribute("idx"))||0,color:this.parseColor(o)};const s=t.querySelector("effectRef, a\\:effectRef");if(s)e.effectRef={idx:parseInt(s.getAttribute("idx"))||0};const i=t.querySelector("fontRef, a\\:fontRef");if(i)e.fontRef={idx:i.getAttribute("idx")||"minor"}}catch(t){}return e}extractStyleFromElement(t){const e={};try{const r=t.querySelector("style, p\\:style, a\\:style");if(r)return this.parseShapeStyle(r);const o=t.querySelector("spPr, p\\:spPr");if(o){const t=this.extractStyleAttributesFromSpPr(o);if(t&&Object.keys(t).length>0)Object.assign(e,t)}const s=this.extractStyleAttributesFromElement(t);if(s&&Object.keys(s).length>0)Object.assign(e,s);const i=t.querySelector("nvSpPr, p\\:nvSpPr");if(i){const t=this.extractStyleAttributesFromNvSpPr(i);if(t&&Object.keys(t).length>0)Object.assign(e,t)}}catch(t){}return e}extractStyleAttributesFromSpPr(t){const e={};try{const r=t.getAttribute("style")||t.getAttribute("styleRef");if(r){const t=this.parseStyleReference(r);if(t)Object.assign(e,t)}const o=t.querySelector("schemeClr, a\\:schemeClr");if(o){const t=o.getAttribute("val");if(t)e.schemeColor=t}}catch(t){}return e}extractStyleAttributesFromElement(t){const e={};try{const r=["style","styleRef","themeRef","colorRef"];r.forEach(r=>{const o=t.getAttribute(r);if(o)e[r]=o})}catch(t){}return e}extractStyleAttributesFromNvSpPr(t){const e={};try{const r=t.querySelector("ph, p\\:ph");if(r){const t=r.getAttribute("type");const o=r.getAttribute("idx");if(t){const r={title:{fillRef:{idx:1}},body:{fillRef:{idx:2}},ctrTitle:{fillRef:{idx:1}},subTitle:{fillRef:{idx:2}},obj:{fillRef:{idx:3}}};if(r[t])Object.assign(e,r[t])}}}catch(t){}return e}parseStyleReference(t){try{if(t.includes("fillRef")){const e=t.match(/fillRef:(\d+)/);if(e)return{fillRef:{idx:parseInt(e[1])||0}}}}catch(t){}return null}applyComprehensiveStyleExtraction(t,e,r="shape"){let o=false;const s=e.querySelector("style, p\\:style");if(s){t.style=this.parseShapeStyle(s);t.preservedStyle=t.style;o=true}if(!o&&window.currentSlideData&&window.currentSlideData.rawXMLShapes){const e=window.currentSlideData.rawXMLShapes.find(e=>e.name===t.name||e.id===t.id);if(e&&e.style){t.style=e.style;t.preservedStyle=e.style;o=true}}if(!o){const r=this.extractStyleFromElement(e);if(r&&Object.keys(r).length>0){t.style=r;t.preservedStyle=r;o=true}}return o}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(e)return{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)};return{r:0,g:0,b:0}}initializeRendering(){try{const t=document.createElement("canvas");t.width=800;t.height=600;const e=this.getGraphicsEngine();if(!e)this.initializeGraphicsEngine();if(this.drawingDocument){this.drawingDocument.init(t,this);const e="undefined"!==typeof globalThis&&globalThis.SVGRenderer||"undefined"!==typeof window&&window.SVGRenderer||null;if(e&&this.drawingDocument.graphics)this.svgRenderer=new e(this.drawingDocument.graphics);else throw new Error("SVGRenderer is not defined")}else throw new Error("standard graphics engine not available")}catch(t){throw new Error("Failed to initialize rendering system: "+t.message)}}async renderSlide(t,e){const r=performance.now();try{if(!t)throw new Error("Canvas is required for rendering");if(e<0||e>=this.slides.length)throw new Error(`Invalid slide index: ${e}`);const slide=this.slides[e];if(!slide)throw new Error(`Slide at index ${e} is null`);this.currentSlide=slide;const o=this.getGraphicsEngine();if(!o)this.initializeGraphicsEngine();const s=this.getSlideDimensions();const i=this.calculateCanvasRect(t,s);if(!this.drawingDocument)throw new Error("standard graphics engine not available");this.drawingDocument.init(t,this);const n=this.drawingDocument.graphics;if(this.renderContext.enableOptimizations){const e=parseFloat(t.style.width)||t.width/(window.devicePixelRatio||1);const r=parseFloat(t.style.height)||t.height/(window.devicePixelRatio||1);n.updatedRect=new qt(0,0,e,r)}n.clear();await this.preloadSlideImages(e);this.logSlideImageStatus(slide,e);this.currentSlideIndex=e;await this.drawingDocument.drawSlide(slide,e);const a=performance.now()-r}catch(e){if(t){const r=t.getContext("2d");r.fillStyle="#ffebee";r.fillRect(0,0,t.width,t.height);r.fillStyle="#f44336";r.font="16px Arial";r.textAlign="center";r.fillText("Rendering Error",t.width/2,t.height/2);r.fillText(e.message,t.width/2,t.height/2+25)}}}async renderMaster(t,e){try{if(!t)throw new Error("Canvas is required for rendering");if(e<0||e>=this.slideMasters.length)throw new Error(`Invalid master index: ${e}`);const r=this.slideMasters[e];if(!r)throw new Error(`Master at index ${e} is null`);const o={name:r.name||`Master ${e+1}`,type:"master",commonSlideData:r.commonSlideData||r.cSld,backgroundFill:r.cSld?.bg,showMasterShapes:false,layout:null,master:null};this.currentSlide=o;const s=this.getSlideDimensions();const i=this.calculateCanvasRect(t,s);if(!this.drawingDocument)this.initializeRendering();this.drawingDocument.init(t,this);const n=this.drawingDocument.graphics;n.clear();await this.drawingDocument.drawSlide(o,e)}catch(e){if(t){const r=t.getContext("2d");r.fillStyle="#f0f8ff";r.fillRect(0,0,t.width,t.height);r.fillStyle="#e74c3c";r.font="16px Arial";r.textAlign="center";r.fillText("Master Rendering Error",t.width/2,t.height/2);r.fillText(e.message,t.width/2,t.height/2+25)}}}async renderLayout(t,e){try{if(!t)throw new Error("Canvas is required for rendering");if(e<0||e>=this.slideLayouts.length)throw new Error(`Invalid layout index: ${e}`);const r=this.slideLayouts[e];if(!r)throw new Error(`Layout at index ${e} is null`);const o=this.slideMasters.find(t=>t.id===r.masterId);const s={name:r.name||`Layout ${e+1}`,type:"layout",commonSlideData:r.commonSlideData||r.cSld,backgroundFill:r.cSld?.bg||o?.cSld?.bg,showMasterShapes:false!==r.showMasterSp,layout:r,master:o};this.currentSlide=s;const i=this.getSlideDimensions();const n=this.calculateCanvasRect(t,i);if(!this.drawingDocument)this.initializeRendering();this.drawingDocument.init(t,this);const a=this.drawingDocument.graphics;a.clear();await this.drawingDocument.drawSlide(s,e)}catch(e){if(t){const r=t.getContext("2d");r.fillStyle="#fff5f5";r.fillRect(0,0,t.width,t.height);r.fillStyle="#e74c3c";r.font="16px Arial";r.textAlign="center";r.fillText("Layout Rendering Error",t.width/2,t.height/2);r.fillText(e.message,t.width/2,t.height/2+25)}}}drawRegularShapeGeometry(t,e,r,o,s,i,n,a,l,c=null){let h=this.getShapePreset(e);if(!h&&e.geometry)h=e.geometry.preset;if(!h&&e.properties&&e.properties.geometry)h=e.properties.geometry.preset;if(c)n=c;else if(n&&"object"===typeof n&&"linear"===n.type);let u=null;let f=null;if(n)if("linear"===n.type&&n.stops)u=n;else if("string"===typeof n){const t=this.hexToRgb(n);u=t}else if(void 0!==n.r)u=n;if(a)if("string"===typeof a){const t=this.hexToRgb(a);f=t}else if(void 0!==a.r)f=a;const d=this.getShapeStrokeInfo(e);if(h)t.drawPresetGeometry(h,r,o,s,i,u,f,l,d);else t.drawRectangle(r,o,s,i,u,f,l,d)}getSlideCount(){return this.slides.length}getCurrentSlideIndex(){return this.currentSlideIndex}getSlideInfo(t){const slide=this.slides[t];if(!slide)return null;return{index:t,name:slide.getName(),shapeCount:slide.getShapeTree().length}}getSlideDimensions(){return this.presentation?.slideSize||{cx:9144e3,cy:6858e3}}getSlideDimensionsForCanvas(t,e){const r=this.getSlideDimensions();const o=t/r.cx;const s=e/r.cy;const i=Math.min(o,s);return{width:r.cx*i,height:r.cy*i,scale:i,offsetX:(t-r.cx*i)/2,offsetY:(e-r.cy*i)/2}}async generateSlideThumbnail(t,e=320,r=240){try{if(!this.getGraphicsEngine())this.initializeGraphicsEngine();if(!this.slides[t])return this.createFallbackThumbnail(t,e,r);const slide=this.slides[t];const o=this.getSlideDimensions();const s=o.cx/o.cy;const i=o.cx/914400*96;const n=o.cy/914400*96;const a=e/i;const l=r/n;const c=Math.min(a,l);let h=i*c;let u=n*c;h=Math.max(h,100);u=Math.max(u,75);const f=document.createElement("canvas");this.setupHighResolutionCanvas(f,h,u);if(this.drawingDocument){this.drawingDocument.init(f,this);try{await this.drawingDocument.drawSlide(slide,t);return f}catch(e){return this.createFallbackThumbnail(t,h,u)}}else return this.createFallbackThumbnail(t,h,u)}catch(o){return this.createFallbackThumbnail(t,e,r)}}createFallbackThumbnail(t,e,r){const o=document.createElement("canvas");this.setupHighResolutionCanvas(o,e,r);const s=o.getContext("2d");s.fillStyle="#f0f0f0";s.fillRect(0,0,e,r);s.fillStyle="#666";s.font="16px Arial";s.textAlign="center";s.fillText(`Slide ${t+1}`,e/2,r/2);try{const t=this.getSlideDimensions();const o=t.cx/t.cy;s.font="12px Arial";s.fillText(`${o.toFixed(2)}:1`,e/2,r/2+20)}catch(t){}return o}inferLayoutTypeFromPlaceholders(t){const e=t.querySelector("cSld, p\\:cSld");if(!e)return"blank";const r=e.querySelector("spTree, p\\:spTree");if(!r)return"blank";const o=[];const s=r.children;for(let t=0;t{const e=this.rgbToHex(t.color);n.addColorStop(t.position,e)});o.fillStyle=n;o.fillRect(0,0,s,i)}renderImageBackground(t,e,r){if(!e.imageData||!e.imageData.relationshipId){t.fillRect(0,0,r.widthPx,r.heightPx,"#f0f0f0");return}const o=e.imageData.relationshipId;const s=this.imageCache.get(o);if(s&&s.image)this.drawBackgroundImage(t,s.image,e.imageData,r);else{t.fillRect(0,0,r.widthPx,r.heightPx,"#f8f9fa");const e=t.context;e.fillStyle="#6c757d";e.font="14px Arial";e.textAlign="center";e.fillText("Loading background...",r.widthPx/2,r.heightPx/2);this.loadImageAsync(o)}}drawBackgroundImage(t,image,e,r){const o=t.context;const{widthMM:s,heightMM:i}=r;o.save();try{if("tile"===e.fillMode)this.drawTiledBackgroundImage(o,image,e.tileProperties,s,i);else{let r=0,o=0,n=s,a=i;if(e.fillRect){const t=e.fillRect;r=s*t.l/1e5;o=i*t.t/1e5;n=s*(1e5-t.l-t.r)/1e5;a=i*(1e5-t.t-t.b)/1e5}if(e.sourceRect){const s=e.sourceRect;const i=image.naturalWidth*s.l/1e5;const l=image.naturalHeight*s.t/1e5;const c=image.naturalWidth*(1e5-s.l-s.r)/1e5;const h=image.naturalHeight*(1e5-s.t-s.b)/1e5;t.drawImageHighRes(image,i,l,c,h,r,o,n,a)}else t.drawImageHighRes(image,r,o,n,a)}if(e.effects)this.applyImageEffects(t,e.effects)}catch(t){o.fillStyle="#f0f0f0";o.fillRect(0,0,s,i)}finally{o.restore()}}drawTiledBackgroundImage(t,image,e,r,o){if(!e)return;const s=e.sx/1e5;const i=e.sy/1e5;const n=e.tx/914400*25.4;const a=e.ty/914400*25.4;const l=image.naturalWidth*s;const c=image.naturalHeight*i;const h=document.createElement("canvas");h.width=l;h.height=c;const u=h.getContext("2d");u.imageSmoothingEnabled=true;u.imageSmoothingQuality="high";u.drawImage(image,0,0,l,c);const f=t.createPattern(h,"repeat");t.save();t.translate(n,a);t.fillStyle=f;t.fillRect(-n,-a,r,o);t.restore()}renderPatternBackground(t,e,r){const o=e.pattern?.foregroundColor||{r:128,g:128,b:128,a:255};const s=this.rgbToHex(o);t.fillRect(0,0,r.widthMM,r.heightMM,s)}getShapeFillColor(t){this._currentProcessingShape=t;const e=t&&("Rectangle 3"===t.name||t.name?.includes("Rectangle 3"));if(t.fill){if("solid"===t.fill.type&&t.fill.color){const r=this.processShapeColor(t.fill.color);if(e);this._currentProcessingShape=null;return r}if("gradient"===t.fill.type&&t.fill.gradient){this._currentProcessingShape=null;return this.processGradientFill(t.fill.gradient)}if("none"===t.fill.type){this._currentProcessingShape=null;return null}}if(t.properties&&t.properties.fill){if("solid"===t.properties.fill.type&&t.properties.fill.color){const r=this.processShapeColor(t.properties.fill.color);if(e);this._currentProcessingShape=null;return r}if("gradient"===t.properties.fill.type&&t.properties.fill.gradient)return this.processGradientFill(t.properties.fill.gradient);if("none"===t.properties.fill.type)return null}if("sp"===t.type&&t.placeholder&&t.placeholder.type){t.placeholder.type;this._currentProcessingShape=null;return null}const r=t.preservedStyle||t.style;if(r&&r.fillRef){this._currentProcessingShape=t;const e=this.resolveStyleFillColor(r.fillRef);if(e){this._currentProcessingShape=null;return e}}if("pic"===t.type){this._currentProcessingShape=null;return null}let o;if(t.name&&t.name.includes("Rectangle")){const e=t.name.match(/\d+/);const r=e?parseInt(e[0]):1;o=null}else o=null;this._currentProcessingShape=null;return o}_normalizeColorDescriptor(t){if(!t)return null;if("object"===typeof t&&void 0!==t.r)return t;if("string"===typeof t)return t;if("object"===typeof t&&t.type&&t.value){if("scheme"===t.type)return{scheme:t.value,alpha:t.alpha};if("srgb"===t.type)return`#${t.value}`}return t}resolveStyleStrokeColor(t){try{if(!t)return null;const e=this._normalizeColorDescriptor(t.color||t);const r=this.processShapeColor(e);return r}catch(t){return null}}getShapeStrokeColor(t){try{if(t?.properties?.stroke?.noFill||t?.stroke?.noFill)return null;if(t?.properties?.stroke?.color){const e=this._normalizeColorDescriptor(t.properties.stroke.color);const r=this.processShapeColor(e);return r}if(t?.stroke?.color){const e=this._normalizeColorDescriptor(t.stroke.color);const r=this.processShapeColor(e);return r}const e=t?.preservedStyle||t?.style;if(e?.lnRef){const t=this.resolveStyleStrokeColor(e.lnRef);if(t)return t}}catch(t){}if(t&&("cxnSp"===t.type||"connector"===t.type))return{r:80,g:80,b:80,a:255};return null}getShapeLineWidth(t){try{let e=null;if(void 0!==t?.properties?.stroke?.width)e=parseInt(t.properties.stroke.width)||12700;else if(void 0!==t?.stroke?.width)e=parseInt(t.stroke.width)||12700;else e=12700;const r=e/914400*25.4;const o=2*25.4/96;const s=Math.max(r,o);return s}catch(t){return.75}}resolveInheritedFillColor(t){try{const slide=this.slides[this.getCurrentSlideIndex()];if(!slide)return null;if(!t.placeholder||!t.placeholder.type)return null;const e=t.placeholder.type;const r=t.placeholder.idx||0;if(slide.layout&&slide.layout.cSld&&slide.layout.cSld.spTree)for(const t of slide.layout.cSld.spTree)if(this.isMatchingPlaceholder(t,e,r)){const e=this.extractShapeFillColor(t);if(e)return e}if(slide.layout&&slide.layout.master&&slide.layout.master.cSld&&slide.layout.master.cSld.spTree)for(const t of slide.layout.master.cSld.spTree)if(this.isMatchingPlaceholder(t,e,r)){const e=this.extractShapeFillColor(t);if(e)return e}const o=this.getThemeColorForPlaceholder(e);if(o)return o;return null}catch(t){return null}}isMatchingPlaceholder(t,e,r){if(!t.placeholder)return false;if(t.placeholder.type===e){if(void 0!==r&&void 0!==t.placeholder.idx)return t.placeholder.idx===r;return true}if("title"===e&&"ctrTitle"===t.placeholder.type||"ctrTitle"===e&&"title"===t.placeholder.type)return true;return false}inheritShapeStyles(t,e){try{if(e.spPr){if(!t.spPr)t.spPr={};if(e.spPr.solidFill&&!t.spPr.solidFill)t.spPr.solidFill=e.spPr.solidFill;if(e.spPr.gradFill&&!t.spPr.gradFill)t.spPr.gradFill=e.spPr.gradFill;if(e.spPr.pattFill&&!t.spPr.pattFill)t.spPr.pattFill=e.spPr.pattFill;if(e.spPr.blipFill&&!t.spPr.blipFill)t.spPr.blipFill=e.spPr.blipFill;if(e.spPr.noFill&&!t.spPr.noFill)t.spPr.noFill=e.spPr.noFill;if(e.spPr.ln&&!t.spPr.ln)t.spPr.ln=e.spPr.ln;if(e.spPr.effectLst&&!t.spPr.effectLst)t.spPr.effectLst=e.spPr.effectLst;if(e.spPr.geometry&&!t.spPr.geometry&&!this.isTextPlaceholder(t))t.spPr.geometry=e.spPr.geometry;if(e.spPr.xfrm&&!t.spPr.xfrm)t.spPr.xfrm=e.spPr.xfrm}if(e.style){if(!t.style)t.style={};if(e.style.fillRef&&!t.style.fillRef)t.style.fillRef=e.style.fillRef;if(e.style.lnRef&&!t.style.lnRef)t.style.lnRef=e.style.lnRef;if(e.style.effectRef&&!t.style.effectRef)t.style.effectRef=e.style.effectRef;if(e.style.fontRef&&!t.style.fontRef)t.style.fontRef=e.style.fontRef}if(this.isTextPlaceholder(t)||t.textBody)this.inheritTextProperties(t,e);if(e.effects&&!t.effects)t.effects=e.effects;if(e.fill&&(!t.fill||null===t.fill))t.fill=e.fill;if(e.properties&&e.properties.fill){if(!t.properties)t.properties={};if(!t.properties.fill||null===t.properties.fill)t.properties.fill=e.properties.fill}if(e.properties&&e.properties.transform){if(!t.properties)t.properties={};if(!t.properties.transform)t.properties.transform=JSON.parse(JSON.stringify(e.properties.transform))}if((!t.properties||!t.properties.transform)&&t.spPr&&t.spPr.xfrm){const e=t.spPr.xfrm;const r=void 0!==e.x?e.x:void 0!==(e.off&&e.off.x)?e.off.x:0;const o=void 0!==e.y?e.y:void 0!==(e.off&&e.off.y)?e.off.y:0;const s=void 0!==e.width?e.width:void 0!==e.cx?e.cx:void 0!==(e.ext&&e.ext.cx)?e.ext.cx:void 0;const i=void 0!==e.height?e.height:void 0!==e.cy?e.cy:void 0!==(e.ext&&e.ext.cy)?e.ext.cy:void 0;if(void 0!==s&&void 0!==i){if(!t.properties)t.properties={};t.properties.transform={x:r,y:o,width:s,height:i}}}}catch(t){}}inheritTextProperties(t,e){try{if(e.textBody){if(!t.textBody)t.textBody={paragraphs:[]};const r=e.textBody.bodyProperties||e.textBody.bodyPr;if(!t.textBody.bodyProperties){if(r)t.textBody.bodyProperties=JSON.parse(JSON.stringify(r))}else if(r){const e=t.textBody.bodyProperties;if(!e.anchor&&!e.verticalAlign||"top"===e.verticalAlign||"t"===e.verticalAlign)if(r.anchor)e.anchor=r.anchor;else if(r.verticalAlign)e.verticalAlign=r.verticalAlign;if(void 0===e.leftMargin&&void 0!==r.leftMargin)e.leftMargin=r.leftMargin;if(void 0===e.rightMargin&&void 0!==r.rightMargin)e.rightMargin=r.rightMargin;if(void 0===e.topMargin&&void 0!==r.topMargin)e.topMargin=r.topMargin;if(void 0===e.bottomMargin&&void 0!==r.bottomMargin)e.bottomMargin=r.bottomMargin}if(e.textBody.lstStyle&&!t.textBody.lstStyle)t.textBody.lstStyle=e.textBody.lstStyle}if(e.txBody&&!t.txBody)t.txBody=e.txBody}catch(t){}}isTextPlaceholder(t){const e=t?.placeholder?.type||t.nvSpPr&&t.nvSpPr.nvPr&&t.nvSpPr.nvPr.ph&&t.nvSpPr.nvPr.ph.type;if(e)return["title","body","ctrTitle","subTitle","dt","ftr","hdr","sldNum"].includes(e);return false}applyPropertyInheritance(t,e=null){try{const r=e||this.currentSlide;if(!r)return;if(r.layout&&r.layout.cSld&&r.layout.cSld.spTree){const e=this.findMatchingShapeInTemplate(t,r.layout.cSld.spTree);if(e)this.inheritShapeStyles(t,e)}if(r.layout&&r.layout.master&&r.layout.master.cSld&&r.layout.master.cSld.spTree){const e=this.findMatchingShapeInTemplate(t,r.layout.master.cSld.spTree);if(e)this.inheritShapeStyles(t,e)}}catch(t){}}findMatchingShapeInTemplate(t,e){if(!e||!Array.isArray(e))return null;if(t.placeholder)for(const r of e)if(this.isMatchingPlaceholder(r,t.placeholder.type,t.placeholder.idx))return r;if(t.name)for(const r of e)if(r.name===t.name)return r;if(t.name&&t.name.includes("Text Placeholder")&&t.textBody)for(const t of e)if(t.name&&t.name.includes("Text Placeholder")&&t.textBody)return t;if(t.bounds&&!t.placeholder)for(const r of e)if(this.isShapeAtSimilarPosition(t,r))return r;return null}isShapeAtSimilarPosition(t,e){if(!t.bounds||!e.bounds)return false;const r=91440;const o=Math.abs(t.bounds.l-e.bounds.l)<=r;const s=Math.abs(t.bounds.t-e.bounds.t)<=r;return o&&s}extractShapeGeometry(t){if(t.spPr&&t.spPr.geometry)return t.spPr.geometry;if(t.geometry)return t.geometry;if(t.properties&&t.properties.geometry)return t.properties.geometry;return null}extractShapeFillColor(t){if(t.fill&&t.fill.color)return this.processShapeColor(t.fill.color);if(t.properties&&t.properties.fill&&t.properties.fill.color)return this.processShapeColor(t.properties.fill.color);if(t.style&&t.style.fillRef)return this.resolveStyleFillColor(t.style.fillRef);return null}getThemeColorForPlaceholder(t){const theme=this.presentation?.theme;if(!theme||!theme.colors)return null;switch(t){case"title":case"ctrTitle":case"body":case"obj":default:return null;case"subTitle":return{r:245,g:245,b:245,a:255}}}processShapeColor(t){if(!t)return null;if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b)return t;if("string"===typeof t&&t.startsWith("#")){const e=this.hexToRgb(t);return e}if(t.scheme){const e=this.resolveThemeColor(t.scheme);if(e)return this.applyColorModifications(e,t)}if("srgb"===t.type&&t.value){const e=t.value;const r=parseInt(e.substring(0,2),16)||0;const o=parseInt(e.substring(2,4),16)||0;const s=parseInt(e.substring(4,6),16)||0;const i=void 0!==t.alpha&&null!==t.alpha?Math.round(255*t.alpha):255;return{r,g:o,b:s,a:i}}if("scheme"===t.type&&t.value){const e=this.resolveThemeColor(t.value);if(e)return this.applyColorModifications(e,t)}return t}processGradientFill(t){if(!t||!t.stops||0===t.stops.length)return null;const e={type:t.type||"linear",angle:t.angle||0,stops:t.stops.map(t=>({position:t.position,color:this.processShapeColor(t.color)}))};return e}resolveThemeColor(t){if(this.presentation&&this.presentation.theme&&this.presentation.theme.colors){const e=this.presentation.theme.colors[t];if(e){const t=this.parseColorFromHex(e);if(t)return t}}const e={};const r=e[t]||null;return r}resolvePlaceholderColor(t,e=null){if(!t||"placeholder"!==t.type)return t;let r=e;if(!r)if(this.presentation&&this.presentation.theme&&this.presentation.theme.colors){const t=this.presentation.theme.colors.accent1;if(t)r=this.parseColorFromHex(t)}if(!r)return null;if(t.modifications&&t.modifications.length>0)r=this.applyColorModifications(r,t.modifications);return r}rgbToHsl(t,e,r){t/=255;e/=255;r/=255;const o=Math.max(t,e,r);const s=Math.min(t,e,r);let i,n,a=(o+s)/2;if(o===s)i=n=0;else{const l=o-s;n=a>.5?l/(2-o-s):l/(o+s);switch(o){case t:i=(e-r)/l+(e{if(r<0)r+=1;if(r>1)r-=1;if(r<1/6)return t+6*(e-t)*r;if(r<1/2)return e;if(r<2/3)return t+(e-t)*(2/3-r)*6;return t};let s,i,n;if(0===e)s=i=n=r;else{const a=r<.5?r*(1+e):r+e-r*e;const l=2*r-a;s=o(l,a,t+1/3);i=o(l,a,t);n=o(l,a,t-1/3)}return{r:Math.round(255*s),g:Math.round(255*i),b:Math.round(255*n)}}parseColorFromHex(t){if(!t||"string"!==typeof t)return null;const e=t.replace("#","");if(6===e.length)return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:255};return null}applyColorModifications(t,e){if(!t||!e||0===e.length)return t;const r={...t};const o=this.rgbToHsl(r.r,r.g,r.b);let{h:s,s:i,l:n}=o;for(const t of e){const e=t.value;switch(t.type){case"tint":const t=e/1e5;n+=(1-n)*t;break;case"shade":const o=e/1e5;n*=1-o;break;case"lummod":case"lumMod":const a=e/1e5;n*=a;break;case"lumoff":case"lumOff":const l=e/1e5;n=Math.min(1,Math.max(0,n+l));break;case"satmod":case"satMod":const c=e/1e5;i*=c;break;case"satoff":case"satOff":const h=e/1e5;i=Math.min(1,Math.max(0,i+h));break;case"hue":s=e/6e4%360;break;case"hueoff":case"hueOff":const u=e/6e4;s=(s+u)%360;break;case"huemod":case"hueMod":const f=e/1e5;s=s*f%360;break;case"alpha":r.a=Math.round(e/1e5*255);break;case"alphamod":case"alphaMod":const d=e/1e5;r.a=Math.round(r.a*d);break;case"alphaoff":case"alphaOff":const p=e/1e5;r.a=Math.min(255,Math.max(0,Math.round(r.a+255*p)))}}const a=this.hslToRgb(s,i,n);r.r=a.r;r.g=a.g;r.b=a.b;r.r=Math.min(255,Math.max(0,Math.round(r.r)));r.g=Math.min(255,Math.max(0,Math.round(r.g)));r.b=Math.min(255,Math.max(0,Math.round(r.b)));r.a=Math.min(255,Math.max(0,Math.round(r.a||255)));return r}rgbToHsl(t,e,r){t/=255;e/=255;r/=255;const o=Math.max(t,e,r);const s=Math.min(t,e,r);let i,n,a=(o+s)/2;if(o===s)i=n=0;else{const l=o-s;n=a>.5?l/(2-o-s):l/(o+s);switch(o){case t:i=(e-r)/l+(e{if(r<0)r+=1;if(r>1)r-=1;if(r<1/6)return t+6*(e-t)*r;if(r<1/2)return e;if(r<2/3)return t+(e-t)*(2/3-r)*6;return t};const a=r<.5?r*(1+e):r+e-r*e;const l=2*r-a;o=n(l,a,t+1/3);s=n(l,a,t);i=n(l,a,t-1/3)}return{r:Math.round(255*o),g:Math.round(255*s),b:Math.round(255*i)}}parseColorFromHex(t){if(!t||"string"!==typeof t)return null;const e=t.replace("#","");if(6===e.length)return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:255};return null}applyColorModifications(t,e){const r={...t};if(void 0!==e.tint){const t=e.tint/1e5;r.r=Math.round(r.r+(255-r.r)*t);r.g=Math.round(r.g+(255-r.g)*t);r.b=Math.round(r.b+(255-r.b)*t)}if(void 0!==e.shade){const t=e.shade/1e5;r.r=Math.round(r.r*(1-t));r.g=Math.round(r.g*(1-t));r.b=Math.round(r.b*(1-t))}if(void 0!==e.sat){const t=e.sat/1e5;const o=.299*r.r+.587*r.g+.114*r.b;r.r=Math.round(o+(r.r-o)*t);r.g=Math.round(o+(r.g-o)*t);r.b=Math.round(o+(r.b-o)*t)}if(void 0!==e.alpha)r.a=Math.round(255*(e.alpha/1e5));r.r=Math.max(0,Math.min(255,r.r));r.g=Math.max(0,Math.min(255,r.g));r.b=Math.max(0,Math.min(255,r.b));r.a=Math.max(0,Math.min(255,r.a));return r}getAllShapesFromTree(t){const e=[];const r=t=>{if(!t)return;if(Array.isArray(t))t.forEach(r);else if("object"===typeof t){if(t.nvSpPr||t.nvPicPr||t.nvGrpSpPr)e.push(t);Object.values(t).forEach(t=>{if(t&&"object"===typeof t)r(t)})}};r(t);return e}resolveStyleFillColor(t){try{if(!t)return null;const e=this._currentProcessingShape;const r=e&&("Rectangle 3"===e.name||e.name?.includes("Rectangle 3"));if(r);const o=t.idx||0;if(r);if(t.color){const e=this.processShapeColor(t.color);const o=e&&void 0!==e.r?`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a||255})`:JSON.stringify(e);if(r);return e}const theme=this.presentation?.theme;if(r)if(theme)if(theme.colors&&theme.colors.accent6){const t=this.parseColorFromHex(theme.colors.accent6)}if(theme&&theme.formatScheme){if(r)if(theme.formatScheme.fillStyles)theme.formatScheme.fillStyles.forEach((t,e)=>{});if(o<1e3){const e=o-1;if(e>=0&&theme.formatScheme.fillStyles&&e=1001){const e=o-1001;if(e>=0&&theme.formatScheme.backgroundFills&&e0)r=t.stops[0].color;else if(t.gradient&&t.gradient.colors&&t.gradient.colors.length>0)r=t.gradient.colors[0];if(r){if("placeholder"===r.type&&"phClr"===r.value){const t=this._currentProcessingShape;if(t&&!t.placeholder)return null;const o=e?this.processShapeColor(e):null;let s=this.resolvePlaceholderColor(r,o);if(r.modifications&&r.modifications.length>0)s=this.applyColorModifications(s,r.modifications);return s}if("scheme"===r.type){const t=this.getThemeColor(r.value);if(t){let e=t;if(r.modifications&&r.modifications.length>0)e=this.applyColorModifications(e,r.modifications);return e}}if(e)return this.processShapeColor(e);return this.processShapeColor(r)}}if("pattern"===t.type&&t.fgColor){if(e)return this.processShapeColor(e);return this.processShapeColor(t.fgColor)}if("blip"===t.type||"image"===t.type)return null;if("none"===t.type||"noFill"===t.type)return null}catch(t){}return null}isImageLoading(t){return!this.imageCache.has(t)&&this.imageMap.has(t)}triggerSlideRerender(){if("undefined"!==typeof window)window.dispatchEvent(new Event("slideImageLoaded",{detail:{slideIndex:this.currentSlideIndex}}))}logSlideImageStatus(slide,t){if(slide.backgroundFill&&slide.backgroundFill.fill){const t=slide.backgroundFill.fill;if("image"===t.type&&t.imageData){const e=t.imageData.relationshipId;const r=this.imageCache.has(e)}}let e=0;if(slide.commonSlideData&&slide.commonSlideData.shapeTree)for(const t of slide.commonSlideData.shapeTree)if("pic"===t.type&&t.imageRelId){const r=this.imageCache.has(t.imageRelId);e++}}async drawGroupShapeGeometry(t,e,r,o,s,i,n,a,l,c){t.SaveGrState();try{if(e.transform){if(e.transform.rotation&&0!==e.transform.rotation){const n=r+s/2;const a=o+i/2;t.transform(Math.cos(e.transform.rotation*Math.PI/180),Math.sin(e.transform.rotation*Math.PI/180),-Math.sin(e.transform.rotation*Math.PI/180),Math.cos(e.transform.rotation*Math.PI/180),n-n*Math.cos(e.transform.rotation*Math.PI/180)+a*Math.sin(e.transform.rotation*Math.PI/180),a-n*Math.sin(e.transform.rotation*Math.PI/180)-a*Math.cos(e.transform.rotation*Math.PI/180))}if(e.transform.flipH||e.transform.flipV){const n=e.transform.flipH?-1:1;const a=e.transform.flipV?-1:1;const l=r+s/2;const c=o+i/2;t.transform(n,0,0,a,l-l*n,c-c*a)}}if(n)if("object"===typeof n&&"linear"===n.type)t.fillRect(r,o,s,i,n);else{let e=null;if("string"===typeof n)e=this.hexToRgb(n);else if(void 0!==n.r)e=n;if(e)t.drawRectangle(r,o,s,i,e,null,0)}if(a&&l>0){let e=null;if("string"===typeof a)e=this.hexToRgb(a);else if(void 0!==a.r)e=a;if(e)t.drawRectangle(r,o,s,i,null,e,l)}if(e.shapeTree&&e.shapeTree.length>0){const r=this.sortShapesByRenderOrder(e.shapeTree);for(let e=0;e{const e=Math.max(0,Math.min(255,Math.round(t))).toString(16);return 1===e.length?"0"+e:e};return`#${e(t.r||t.R||0)}${e(t.g||t.G||0)}${e(t.b||t.B||0)}`}createRotationMatrix(t,e,r){const o=t*Math.PI/180;const s=Math.cos(o);const i=Math.sin(o);return{a:s,b:i,c:-i,d:s,e:e-e*s+r*i,f:r-e*i-r*s}}applyRotationTransform(t,e,r,o,s,i){const n=this.getShapeRotation(e);if(!n||0===n)return false;const a=r+s/2;const l=o+i/2;const c=this.createRotationMatrix(n,a,l);const h={sx:c.a,sy:c.d,shx:c.c,shy:c.b,tx:c.e,ty:c.f,createDuplicate(){return{sx:this.sx,sy:this.sy,shx:this.shx,shy:this.shy,tx:this.tx,ty:this.ty,createDuplicate:this.createDuplicate}}};if(t.transform3)t.transform3(h);else if(t.transform)t.transform(c.a,c.b,c.c,c.d,c.e,c.f);return true}getShapeRotation(t){if(void 0!==t.properties?.transform?.rot)return t.properties.transform.rot;if(void 0!==t.transform?.rotation)return t.transform.rotation;if(void 0!==t.spPr?.transform?.rot)return t.spPr.transform.rot;return 0}calculateRotatedBounds(t,e){if(!e||0===e)return t;const{x:r,y:o,w:s,h:i}=t;const n=r+s/2;const a=o+i/2;const l=[{x:r,y:o},{x:r+s,y:o},{x:r+s,y:o+i},{x:r,y:o+i}];const c=e*Math.PI/180;const h=Math.cos(c);const u=Math.sin(c);const f=l.map(t=>{const e=t.x-n;const r=t.y-a;return{x:n+e*h-r*u,y:a+e*u+r*h}});const d=Math.min(...f.map(t=>t.x));const p=Math.min(...f.map(t=>t.y));const g=Math.max(...f.map(t=>t.x));const m=Math.max(...f.map(t=>t.y));return{x:d,y:p,w:g-d,h:m-p}}getDefaultTextColor(t){if(this.presentation?.theme?.colors)if("title"===t.placeholder?.type||"ctrTitle"===t.placeholder?.type){const t=this.resolveThemeColor("dk2");if(t)return t;const e=this.resolveThemeColor("dk1");if(e)return e;return this.presentation.theme.colors.tx1||{r:0,g:0,b:0,a:255}}else return this.presentation.theme.colors.tx1||this.presentation.theme.colors.tx2||{r:0,g:0,b:0,a:255};return{r:0,g:0,b:0,a:255}}async extractPartMediaRelationships(t){try{const e=await t.getRelationships();for(const[t,r]of Object.entries(e))if(r.type===Bt.image.relationType||r.type.includes("video")||r.type.includes("audio")){let e=r.target;if(e.startsWith("../"))e=e.replace("../","ppt/");else if(!e.startsWith("/"))e=`/ppt/${e}`;this.mediaMap.set(t,{path:e,type:r.type});if(this.isImageFile(e)){const r=this.imageMap.get(t);if(!r||this.isSVGFile(e)&&!this.isSVGFile(r)){this.imageMap.set(t,e);if(this.isSVGFile(e));}else if(!this.isSVGFile(e)&&this.isSVGFile(r));else this.imageMap.set(t,e)}}}catch(t){}}isMediaFile(t){const e=[".png",".jpg",".jpeg",".gif",".bmp",".svg",".webp",".tiff",".mp4",".mov",".avi",".mp3",".wav",".ogg"];const r=t.toLowerCase();return e.some(t=>r.endsWith(t))}isSVGFile(t){return t&&t.toLowerCase().endsWith(".svg")}extractSVGRelationshipId(t){try{const e=t.getElementsByTagName("*");for(let t=0;t{image.onload=()=>{a={image,width:image.naturalWidth,height:image.naturalHeight,url:i};this.imageCache.set(e.imageRelId,a);t()};image.onerror=()=>{r(new Error("Failed to load image"))};image.src=i})}this.drawActualImage(t,e,a,o,s,i,n)}catch(r){this.drawImagePlaceholder(t,e,o,s,i,n)}}async loadAndDrawSVGImage(t,e,r,o,s,i,n){try{let t=this.imageCache.get(e.imageRelId);if(!t){const o=await this.zip.getFileData(r.path);if(!o)throw new Error("SVG file not found in ZIP");const s=new TextDecoder("utf-8").decode(o);t={content:s,type:"svg",path:r.path,width:100,height:100};this.imageCache.set(e.imageRelId,t)}const a={x:o,y:s,w:i,h:n};await this.svgRenderer.renderSVG(t.content,a.x,a.y,a.w,a.h,{preserveAspectRatio:true})}catch(a){this.logger.logError(this.constructor.name,`Failed to load/render SVG: ${r.path}`,a);try{const a=await this.zip.getFileData(r.path);if(a){const r=new Blob([a],{type:"image/svg+xml"});const l=URL.createObjectURL(r);const image=new Image;image.crossOrigin="anonymous";await new Promise((r,a)=>{image.onload=()=>{const a={image,width:image.naturalWidth,height:image.naturalHeight,url:l};this.drawActualImage(t,e,a,o,s,i,n);r()};image.onerror=a;image.src=l})}}catch(r){this.logger.log("warn",this.constructor.name,"SVG fallback also failed, showing placeholder");this.drawImagePlaceholder(t,e,o,s,i,n)}}}drawFilePlaceholder(t,e,r,o,s,i,n){const a=t.getContext();a.save();a.fillStyle="#e9ecef";a.fillRect(o,s,i,n);a.strokeStyle="#adb5bd";a.lineWidth=1;a.strokeRect(o,s,i,n);let l="❓";if(r.includes("video"))l="🎬";else if(r.includes("audio"))l="🎵";a.fillStyle="#495057";a.font=`${.5*Math.min(i,n)}px Arial`;a.textAlign="center";a.textBaseline="middle";a.fillText(l,o+i/2,s+n/2);a.restore()}async renderShape(t,e,r){try{if(!e)return;const o=this.getShapeBounds(e,r);if(!o)return;if(o.w<=0||o.h<=0)return;const{x:s,y:i,w:n,h:a}=o;if(e.groupTransform){t.SaveGrState();const o=this.createTransformMatrix(e,r);t.transform3(o)}if(e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===e.graphicData.uri);switch(e.type){case"sp":this.renderRegularShape(t,e,s,i,n,a);break;case"pic":await this.renderPictureShape(t,e,s,i,n,a);break;case"grpSp":this.renderGroupShape(t,e);break;case"cxnSp":this.renderConnectorShape(t,e,s,i,n,a);break;case"graphicFrame":await this.renderGraphicFrame(t,e,s,i,n,a);break;default:this.renderDefaultShape(t,e,s,i,n,a)}if(e.groupTransform)t.RestoreGrState()}catch(t){}}renderRegularShape(t,e,r,o,s,i){const n=this.getShapeRotation(e);if(0!==n)t.SaveGrState();const a=this.applyRotationTransform(t,e,r,o,s,i);const l=this.getShapeFillColor(e);const c=this.getShapeStrokeColor(e);const h=this.getShapeLineWidth(e);const u=this.getShapeStrokeInfo(e);const f=this.getShapePresetGeometry(e);const d=this.extractShapeAdjustments(e);let p=l;let g=null;let m=null;if(p)if("object"===typeof p&&p.type&&p.stops)g=p;else if("string"===typeof p){const t=this.hexToRgb(p);g=t}else if(void 0!==p.r)g=p;if(c)if("string"===typeof c){const t=this.hexToRgb(c);m=t}else if(void 0!==c.r)m=c;const y=false;let b="none";if(f){t.drawPresetGeometry(f,r,o,s,i,g,m,h,u,d);b="preset-geometry"}else{t.drawRectangle(r,o,s,i,g,m,h||2,u);b="fallback-rectangle"}if(0!==n)t.RestoreGrState()}extractShapeAdjustments(t){const e={};try{if(t.geometry){if(t.geometry.avLst)for(const[r,o]of Object.entries(t.geometry.avLst))if("object"===typeof o&&void 0!==o.val)e[r]=o.val;else if("number"===typeof o)e[r]=o;if(t.geometry.adjLst)for(const[r,o]of Object.entries(t.geometry.adjLst))if("object"===typeof o&&void 0!==o.val)e[r]=o.val;else if("number"===typeof o)e[r]=o;if(t.geometry.preset&&t.geometry.adjustments)for(const[r,o]of Object.entries(t.geometry.adjustments))e[r]=o}if(t.spPr&&t.spPr.geometry){const r=t.spPr.geometry;if(r.avLst)for(const t of r.avLst)if(t.name&&void 0!==t.fmla){const r=this.parseAdjustmentValue(t.fmla);if(null!==r)e[t.name]=r}}if(t.adjustments)Object.assign(e,t.adjustments);if(t.commonSlideData&&t.commonSlideData.adjustments)Object.assign(e,t.commonSlideData.adjustments)}catch(t){}return e}parseAdjustmentValue(t){if("number"===typeof t)return t;if("string"===typeof t){const e=parseFloat(t);if(!isNaN(e))return e;const r=t.match(/val\s+(-?\d+)/);if(r)return parseInt(r[1],10);const o=t.match(/(-?\d+)%/);if(o)return 1e3*parseInt(o[1],10)}return null}getShapePresetGeometry(t){if(t.geometry&&t.geometry.preset)return t.geometry.preset;if(t.properties&&t.properties.geometry&&t.properties.geometry.preset)return t.properties.geometry.preset;if(t.spPr&&t.spPr.geometry&&t.spPr.geometry.preset)return t.spPr.geometry.preset;if(t.spPr&&t.spPr.prstGeom&&t.spPr.prstGeom.prst)return t.spPr.prstGeom.prst;return null}getShapeStrokeInfo(t){const e={};const r=t.properties?.line||t.properties?.stroke;if(r){if(r.dashArray&&r.dashArray.length>0)e.dashArray=r.dashArray;if(r.lineCap||r.cap)e.lineCap=r.lineCap||r.cap;if(r.lineJoin||r.join)e.lineJoin=r.lineJoin||r.join;if(r.miterLimit)e.miterLimit=r.miterLimit;if(r.headEnd){const t=r.headEnd;e.headEnd={type:t.type||t.val||"none",w:t.w||t.width,len:t.len||t.length}}if(r.tailEnd){const t=r.tailEnd;e.tailEnd={type:t.type||t.val||"none",w:t.w||t.width,len:t.len||t.length}}}if(t.spPr&&t.spPr.ln){const r=t.spPr.ln;if(r.prstDash)e.dashArray=this.convertstandardDashPattern(r.prstDash);if(r.cap)e.lineCap=this.convertstandardLineCap(r.cap);if(r.join)e.lineJoin=this.convertstandardLineJoin(r.join);const o=this._mapArrowSize.bind(this);const s=t=>{if(!t)return"none";const e=t.toString();return e};if(r.headEnd)e.headEnd={type:s(r.headEnd.type),w:r.headEnd.w,len:r.headEnd.len};if(r.tailEnd)e.tailEnd={type:s(r.tailEnd.type),w:r.tailEnd.w,len:r.tailEnd.len}}return Object.keys(e).length>0?e:null}_mapArrowSize(t){switch((t||"").toString()){case"sm":case"small":default:return 1;case"med":case"medium":return 1.5;case"lg":case"large":return 2}}convertstandardDashPattern(t){const e={solid:[],dot:[2,2],dash:[8,4],dashDot:[8,4,2,4],dashDotDot:[8,4,2,4,2,4],lgDash:[16,8],lgDashDot:[16,8,4,8],lgDashDotDot:[16,8,4,8,4,8],sysDash:[6,3],sysDashDot:[6,3,2,3],sysDashDotDot:[6,3,2,3,2,3],sysDot:[1,1]};return e[t]||[]}convertstandardLineCap(t){const e={rnd:"round",sq:"square",flat:"butt"};return e[t]||"round"}convertstandardLineJoin(t){const e={round:"round",bevel:"bevel",miter:"miter"};return e[t]||"round"}async renderPictureShape(t,e,r,o,s,i){const n=this.getShapeRotation(e);const a=n&&0!==n;if(a){t.SaveGrState();this.applyRotationTransform(t,e,r,o,s,i)}const l=this.getShapePresetGeometry(e);if(l&&"rect"!==l){const n=this.getShapeStrokeColor(e);const a=this.getShapeLineWidth(e);const c=this.getShapeStrokeInfo(e);t.drawPresetGeometry(l,r,o,s,i,null,n,a,c)}const c=this.getShapeFillColor(e);const h=this.getShapeStrokeColor(e);const u=this.getShapeLineWidth(e);try{await this.drawPictureShapeGeometry(t,e,r,o,s,i,c,h,u)}catch(n){this.drawImagePlaceholder(t,e,r,o,s,i)}if(a)t.RestoreGrState()}renderConnectorShape(t,e,r,o,s,i){const n=this.getShapeRotation(e);const a=n&&0!==n;if(a){t.SaveGrState();this.applyRotationTransform(t,e,r,o,s,i)}const l=this.getShapeStrokeColor(e);const c=this.getShapeLineWidth(e);const h=this.getShapeStrokeInfo(e);const u=this.getConnectorType(e);try{this.logger?.log("info",this.constructor.name,"[Connector Render] start",{connectorType:u,bounds:{x:r,y:o,w:s,h:i},strokeColor:l,lineWidth:c,strokeInfo:h})}catch(t){}switch(u){case"straight":if("function"===typeof t.drawLineWithArrows)t.drawLineWithArrows(r,o,r+s,o+i,l,c,h);else t.drawLine(r,o,r+s,o+i,l,c);break;case"elbow":this.drawElbowConnector(t,r,o,s,i,l,c,h);break;case"curved":this.drawCurvedConnector(t,r,o,s,i,l,c,h);break;default:t.drawLine(r,o,r+s,o+i,l,c)}if(a)t.RestoreGrState();try{this.logger?.log("info",this.constructor.name,"[Connector Render] done")}catch(t){}}getConnectorType(t){if(t.properties&&t.properties.connector)return t.properties.connector.type||"straight";if(t.spPr&&t.spPr.connector)return t.spPr.connector.type||"straight";const e=this.getShapePresetGeometry(t);if(e&&e.includes("Connector"))if(e.includes("bent"))return"elbow";else if(e.includes("curved"))return"curved";return"straight"}drawElbowConnector(t,e,r,o,s,i,n,a){if(!t.m_oContext)return;t.m_oContext.save();t.m_oContext.beginPath();const l=e+.5*o;const c=r+.5*s;t.m_oContext.moveTo(e,r);t.m_oContext.lineTo(l,r);t.m_oContext.lineTo(l,c);t.m_oContext.lineTo(e+o,c);t.m_oContext.lineTo(e+o,r+s);if(i){t.m_oContext.strokeStyle=t.colorToRgb(i);t.m_oContext.lineWidth=n||1;if(a)t.applyStrokeInfo(a);t.m_oContext.stroke()}t.m_oContext.restore()}drawCurvedConnector(t,e,r,o,s,i,n,a){if(!t.m_oContext)return;t.m_oContext.save();t.m_oContext.beginPath();t.m_oContext.moveTo(e,r);t.m_oContext.bezierCurveTo(e+.3*o,r,e+.7*o,r+s,e+o,r+s);if(i){t.m_oContext.strokeStyle=t.colorToRgb(i);t.m_oContext.lineWidth=n||1;if(a)t.applyStrokeInfo(a);t.m_oContext.stroke()}t.m_oContext.restore()}async renderGraphicFrame(t,e,r,o,s,i){const n=this.getShapeRotation(e);const a=n&&0!==n;if(a){t.SaveGrState();this.applyRotationTransform(t,e,r,o,s,i)}const l=this.getShapeStrokeColor(e);const c=this.getShapeLineWidth(e)||1;const h=this.getShapeStrokeInfo(e);t.drawRectangle(r,o,s,i,null,l,c,h);if(e.graphicData)switch(e.graphicData.uri){case"http://schemas.openxmlformats.org/drawingml/2006/table":this.renderTableFrame(t,e,r,o,s,i);break;case"http://schemas.openxmlformats.org/drawingml/2006/chart":await this.renderChartFrame(t,e,r,o,s,i);break;case"http://schemas.openxmlformats.org/drawingml/2006/diagram":this.renderDiagramFrame(t,e,r,o,s,i);break;default:this.renderGenericFrame(t,e,r,o,s,i)}else this.renderGenericFrame(t,e,r,o,s,i);if(a)t.RestoreGrState()}renderTableFrame(t,e,r,o,s,i){const n=this.getTableInstance(e);if(!n){this.drawTablePlaceholder(t,r,o,s,i);return}t.SaveGrState();try{this.drawTableBackgroundAndOuterBorder(t,n,r,o,s,i);this.drawCellsBackground(t,n,r,o,s,i);this.drawCellsContent(t,n,r,o,s,i);this.drawCellsBorders(t,n,r,o,s,i)}catch(e){this.drawTablePlaceholder(t,r,o,s,i)}finally{t.RestoreGrState()}}getTableInstance(t){if(t.table&&t.table instanceof CTable)return t.table;if(t.graphicData&&t.graphicData.tableXml)try{const e=this.parseTableFromXML(t.graphicData.tableXml);if(e){t.table=e;return e}}catch(t){void 0;void 0}return null}drawTableBackgroundAndOuterBorder(t,e,r,o,s,i){const n=e.getTableProperties();const a=e.getTableBorders();const l=e.getTableShading();if(l&&l.fill){const e=this.resolveTableBackgroundColor(l);t.b_color1(e.r,e.g,e.b,e.a||255);t.TableRect(r,o,s,i)}if(a)this.drawTableOuterBorder(t,a,r,o,s,i)}drawCellsBackground(t,e,r,o,s,i){const n=e.getRowCount();const a=e.getColumnCount();const l=this.calculateCellWidths(e,s);const c=this.calculateCellHeights(e,i);let h=o;for(let o=0;o=0;i--){const n=e.getCell(s,i);if(!n)continue;const a=l[i];const h=c[s];const u=r+this.calculateCellXOffset(l,i);const f=o+this.calculateCellYOffset(c,s);this.drawCellBorders(t,n,u,f,a,h,s,i,e)}}drawTablePlaceholder(t,e,r,o,s){const i=o/3;const n=s/3;for(let o=0;o<3;o++)for(let s=0;s<3;s++){const a=e+s*i;const l=r+o*n;t.drawRectangle(a,l,i,n,null,{r:128,g:128,b:128,a:255},1)}this.drawCenteredText(t,"Table",e,r,o,s)}drawTableOuterBorder(t,e,r,o,s,i){const n=["top","right","bottom","left"];n.forEach(n=>{const a=e[n];if(a&&"none"!==a.style){const e=this.resolveBorderColor(a);const l=a.width||1;t.p_color(e.r,e.g,e.b,e.a||255);t.p_width(l);switch(n){case"top":t.drawHorLine(r,o,r+s,o,l);break;case"right":t.drawVerLine(r+s,o,o+i,l);break;case"bottom":t.drawHorLine(r,o+i,r+s,o+i,l);break;case"left":t.drawVerLine(r,o,o+i,l)}}})}drawCellBackground(t,e,r,o,s,i){const n=e.getCellShading();if(n&&n.fill){const e=this.resolveCellBackgroundColor(n);t.b_color1(e.r,e.g,e.b,e.a||255);t.TableRect(r,o,s,i)}}drawCellContent(t,e,r,o,s,i){const n=e.getTextBody();if(!n||!n.paragraphs)return;const a=5;const l=r+a;const c=o+a;const h=s-2*a;const u=i-2*a;this.renderCellTextContent(t,n,l,c,h,u)}drawCellBorders(t,e,r,o,s,i,n,a,l){const c=e.getCellBorders();if(!c)return;const h=["top","right","bottom","left"];h.forEach(e=>{const h=c[e];if(!h||"none"===h.style)return;if(this.shouldDrawBorder(e,n,a,l)){const n=this.resolveBorderColor(h);const a=h.width||1;t.p_color(n.r,n.g,n.b,n.a||255);t.p_width(a);switch(e){case"top":t.drawHorLine(r,o,r+s,o,a);break;case"right":t.drawVerLine(r+s,o,o+i,a);break;case"bottom":t.drawHorLine(r,o+i,r+s,o+i,a);break;case"left":t.drawVerLine(r,o,o+i,a)}}})}shouldDrawBorder(t,e,r,o){const s=o.getRowCount();const i=o.getColumnCount();switch(t){case"top":return 0===e;case"right":return r===i-1;case"bottom":return e===s-1;case"left":return 0===r;default:return true}}calculateCellWidths(t,e){const r=t.getTableGrid();if(!r||0===r.length){const r=t.getColumnCount();return new Array(r).fill(e/r)}const o=r.reduce((t,e)=>t+(e.width||0),0);return r.map(t=>{const r=t.width||0;return r/o*e})}calculateCellHeights(t,e){const r=t.getRowCount();const o=[];let s=false;for(let e=0;ee/r);const i=o.reduce((t,e)=>t+e,0);const n=o.filter(t=>0===t).length;const a=n0===t?a:t);const c=l.reduce((t,e)=>t+e,0);return l.map(t=>e*(t/c))}isStartingCellOfMerge(t,e,r){return!t.isMergedContinue}calculateMergedCellWidth(t,e,r){let o=0;for(let s=0;s{if(!e.runs||0===e.runs.length){n+=a;return}const o=e.runs.map(t=>t.text||"").join("");if(!o.trim()){n+=a;return}const s=e.properties||{};const i=s.fontSize||12;const l=s.fontFamily||"Arial";const c=s.bold||false;const h=s.italic||false;t.font(l,i,c?"bold":"normal",h?"italic":"normal");const u=this.resolveTextColor(e);t.b_color1(u.r,u.g,u.b,u.a||255);t.FillText(r,n,o);n+=a})}resolveTextColor(t){return{r:0,g:0,b:0,a:255}}parseTableFromXML(t){if(!t)return null;try{const e=new DOMParser;const r=e.parseFromString(t,"text/xml");if("parsererror"===r.documentElement.nodeName){void 0;return null}const o=new CTable;this.parseTableProperties(r,o);this.parseTableGrid(r,o);this.parseTableRows(r,o);this.processTableMerges(o);const s=this.validateTableStructure(o);if(!s)return null;return o}catch(t){void 0;void 0;return null}}parseTableProperties(t,e){let r=t.querySelector("tblPr");if(!r)r=t.querySelector("a\\:tblPr");if(r){const t={};let o=r.querySelector("tblStyle");if(!o)o=r.querySelector("a\\:tblStyle");if(o)t.style=o.getAttribute("val");let s=r.querySelector("tblBorders");if(!s)s=r.querySelector("a\\:tblBorders");if(s)t.borders=this.parseTableBorders(s);let i=r.querySelector("tblShading");if(!i)i=r.querySelector("a\\:tblShading");if(i)t.shading=this.parseTableShading(i);let n=r.querySelector("tblLayout");if(!n)n=r.querySelector("a\\:tblLayout");if(n)t.layout=n.getAttribute("type")||"autofit";let a=r.querySelector("tblW");if(!a)a=r.querySelector("a\\:tblW");if(a){const e=a.getAttribute("w");const r=a.getAttribute("type")||a.getAttribute("wtype")||"auto";if(e)t.preferredWidth={value:parseInt(e)||0,type:r.toLowerCase()};else t.preferredWidth={value:0,type:r.toLowerCase()}}e.setTableProperties(t)}}parseTableGrid(t,e){let r=t.querySelector("tblGrid");if(!r)r=t.querySelector("a\\:tblGrid");if(r){let t=r.querySelectorAll("gridCol");if(0===t.length)t=r.querySelectorAll("a\\:gridCol");const o=[];t.forEach(t=>{const e=t.getAttribute("w");const r={width:e?parseInt(e):914400,type:t.getAttribute("type")||"auto"};o.push(r)});e.setTableGrid(o)}}parseTableRows(t,e){let r=t.querySelectorAll("tr");if(0===r.length)r=t.querySelectorAll("a\\:tr");r.forEach((t,r)=>{const o=new CTableRow;this.parseRowProperties(t,o);this.parseRowCells(t,o,r);e.addRow(o)})}parseRowProperties(t,e){let r=t.querySelector("trPr");if(!r)r=t.querySelector("a\\:trPr");if(r){let t=r.querySelector("trHeight");if(!t)t=r.querySelector("a\\:trHeight");if(t){const r=parseInt(t.getAttribute("val"),10);if(!Number.isNaN(r))e.height=r;e.heightRule=t.getAttribute("hRule")||"auto"}let o=r.querySelector("tblHeader");if(!o)o=r.querySelector("a\\:tblHeader");if(o)e.isHeader=true}if((!e.height||e.height<=0)&&t){const r=t.getAttribute("h");if(null!==r){const t=parseInt(r,10);if(!Number.isNaN(t)&&t>0){e.height=t;if(!e.heightRule)e.heightRule="auto"}}}}parseRowCells(t,e,r){let o=t.querySelectorAll("tc");if(0===o.length)o=t.querySelectorAll("a\\:tc");o.forEach((t,o)=>{const s=new CTableCell;this.parseCellProperties(t,s,r,o);this.parseCellContent(t,s);e.addCell(s)})}parseCellProperties(t,e,r,o){const s=t.getAttribute("gridSpan");const i=t.getAttribute("rowSpan");const n=t.getAttribute("vMerge");const a=t.getAttribute("hMerge");if(s){const t=parseInt(s);if(t>1)e.gridSpan=t}if(i){const t=parseInt(i);if(t>1)e.rowSpan=t}if("1"===n||"true"===n||"continue"===n)e.isMergedContinue=true;if("1"===a||"true"===a)e.isMergedContinue=true;let l=t.querySelector("tcPr");if(!l)l=t.querySelector("a\\:tcPr");if(l){let t=l.querySelector("gridSpan");if(!t)t=l.querySelector("a\\:gridSpan");if(t){const r=parseInt(t.getAttribute("val"))||1;if(r>1)e.gridSpan=r}let r=l.querySelector("rowSpan");if(!r)r=l.querySelector("a\\:rowSpan");if(r){const t=parseInt(r.getAttribute("val"))||1;if(t>1)e.rowSpan=t}let o=l.querySelector("vMerge");if(!o)o=l.querySelector("a\\:vMerge");if(o){const t=o.getAttribute("val");if("restart"!==t)e.isMergedContinue=true}let s=l.querySelector("tcBorders");if(!s)s=l.querySelector("a\\:tcBorders");if(s)e.borders=this.parseCellBorders(s);let i=l.querySelector("tcShading");if(!i)i=l.querySelector("a\\:tcShading");if(i)e.shading=this.parseCellShading(i);let n=l.querySelector("tcMar");if(!n)n=l.querySelector("a\\:tcMar");if(n)e.margins=this.parseCellMargins(n)}}parseCellContent(t,e){const r=this.parseTextBodyFromElement(t);if(r)e.setTextBody(r)}processTableMerges(t){const e=t.getRows();for(let r=0;r1)this.processHorizontalMerge(t,r,e,o.gridSpan);if(o.rowSpan>1)this.processVerticalMerge(t,r,e,o.rowSpan)}}}processHorizontalMerge(t,e,r,o){for(let s=1;s{let o=t.querySelector(r);if(!o)o=t.querySelector(`a\\:${r}`);if(o)e[r]=this.parseBorderProperties(o)});return e}parseCellBorders(t){return this.parseTableBorders(t)}parseBorderProperties(t){return{style:t.getAttribute("val")||"single",size:parseInt(t.getAttribute("sz"))||4,color:this.parseColor(t),space:parseInt(t.getAttribute("space"))||0}}parseTableShading(t){return this.parseCellShading(t)}parseCellShading(t){const e=t.getAttribute("fill");const r=t.getAttribute("color");return{fill:e,color:r?this.parseColorFromHex(r):null}}parseCellMargins(t){const e={};const r=["top","left","bottom","right"];r.forEach(r=>{let o=t.querySelector(r);if(!o)o=t.querySelector(`a\\:${r}`);if(o)e[r]=parseInt(o.getAttribute("w"))||0});return e}async renderChartFrame(t,e,r,o,s,i){try{let n=e.chartData;if(n&&"DEFERRED_CHART"===n.type){n=null;e.chartData=null}if(!n&&e.graphicData&&window.ChartProcessor){const t=new ChartProcessor(this.context);if(e.graphicData.chartRef){const r={slideIndex:this.currentSlideIndex,slideName:this.currentSlide?.name||`slide${this.currentSlideIndex+1}`,slide:this.currentSlide};try{const o=await t.loadChartFromRelationship(e.graphicData.chartRef,r);if(o){e.chartData=o;n=o}}catch(t){}}else if(e.graphicData.element)n=t.parseEmbeddedChartData(e.graphicData.element);else n=t.createPlaceholderChart();if(n)e.chartData=n}if(n&&ChartRenderer){const e=new ChartRenderer(t);await e.renderChart(n,r,o,s,i);return}this.renderEnhancedChartPlaceholder(t,e,r,o,s,i)}catch(n){void 0;this.renderSimpleChartPlaceholder(t,e,r,o,s,i)}}renderEnhancedChartPlaceholder(t,e,r,o,s,i){try{t.fillRect(r,o,s,i,{r:248,g:249,b:250});t.strokeRect(r,o,s,i,{r:200,g:200,b:200},1);const e=r+40;const n=o+30;const a=s-80;const l=i-60;const c=[4500,5200,4800,6100,5900];const h=["Q1 2023","Q2 2023","Q3 2023","Q4 2023","Q1 2024"];const u=7e3;const f=0;const d=n+l-20;t.drawLine(e,n,e,d,{r:68,g:68,b:68},1);for(let r=0;r<=7;r++){const o=1e3*r;const s=d-o/u*(l-40);if(r>0)t.drawLine(e,s,e+a,s,{r:200,g:200,b:200},1)}t.drawLine(e,d,e+a,d,{r:68,g:68,b:68},1);const p=a/(c.length-1);const g={r:91,g:155,b:213};for(let r=0;r{t.drawEllipse(e.x-15,e.y-15,30,30,{r:200,g:200,b:200,a:255},{r:128,g:128,b:128,a:255},2)})}renderGenericFrame(t,e,r,o,s,i){t.drawRectangle(r,o,s,i,null,"#a0a0a0",1)}drawCenteredText(t,e,r,o,s,i){return}renderDefaultShape(t,e,r,o,s,i){const n=this.getShapeRotation(e);const a=n&&0!==n;if(a){t.SaveGrState();this.applyRotationTransform(t,e,r,o,s,i)}const l=this.getShapeFillColor(e);const c=this.getShapeStrokeColor(e);const h=this.getShapeLineWidth(e)||1;const u=this.getShapeStrokeInfo(e);t.drawRectangle(r,o,s,i,l,c,h,u);this.drawCenteredText(t,e.type||"Shape",r,o,s,i);if(a)t.RestoreGrState()}processShapeColor(t){if(!t)return null;let e;if("string"===typeof t)if(t.startsWith("#"))e=this.hexToRgb(t);else return null;else if("object"===typeof t&&void 0!==t.r)e=t;else return null;const r=`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a||255})`;const o={...e};if(void 0!==t.tint){const e=t.tint/1e5;o.r=Math.round(o.r+(255-o.r)*e);o.g=Math.round(o.g+(255-o.g)*e);o.b=Math.round(o.b+(255-o.b)*e)}if(void 0!==t.shade){const e=1-t.shade/1e5;o.r=Math.round(o.r*e);o.g=Math.round(o.g*e);o.b=Math.round(o.b*e)}if(void 0!==t.satMod){const e=this.rgbToHsl(o.r,o.g,o.b);e.s*=t.satMod/1e5;const r=this.hslToRgb(e.h,e.s,e.l);o.r=r.r;o.g=r.g;o.b=r.b}const s=`rgba(${o.r}, ${o.g}, ${o.b}, ${o.a||255})`;return o}rgbToHsl(t,e,r){t/=255;e/=255;r/=255;const o=Math.max(t,e,r);const s=Math.min(t,e,r);let i,n,a=(o+s)/2;if(o===s)i=n=0;else{const l=o-s;n=a>.5?l/(2-o-s):l/(o+s);switch(o){case t:i=(e-r)/l+(e{if(r<0)r+=1;if(r>1)r-=1;if(r<1/6)return t+6*(e-t)*r;if(r<1/2)return e;if(r<2/3)return t+(e-t)*(2/3-r)*6;return t};const a=r<.5?r*(1+e):r+e-r*e;const l=2*r-a;o=n(l,a,t+1/3);s=n(l,a,t);i=n(l,a,t-1/3)}return{r:Math.round(255*o),g:Math.round(255*s),b:Math.round(255*i)}}sortShapesByRenderOrder(t){if(!t||0===t.length)return[];const e=[...t];e.sort((e,r)=>{const o=e.order||e.zOrder||e.index||0;const s=r.order||r.zOrder||r.index||0;if(o!==s)return o-s;const i=t.indexOf(e);const n=t.indexOf(r);return i-n});return e}}class ImageLoader{constructor(){this.loadingImages=new Set;this.logger=new Logger("ImageLoader")}async loadImageFromUrl(t){return new Promise((e,r)=>{const o=new Image;o.onload=()=>{e(o)};o.onerror=t=>{r(new Error(`Failed to load image: ${t.message||"Unknown error"}`))};if(t.startsWith("blob:"))o.crossOrigin="anonymous";o.src=t})}async loadImageFromData(t,e="image/png"){try{const r=new Blob([t],{type:e});const o=URL.createObjectURL(r);const image=await this.loadImageFromUrl(o);return image}catch(t){throw t}}async preloadImages(t){const e=t.map(t=>this.loadImageFromUrl(t).catch(t=>null));const r=await Promise.allSettled(e);return r.map(t=>"fulfilled"===t.status?t.value:null)}async getImageDimensions(t){return new Promise((e,r)=>{const o=new Image;o.onload=()=>{e({width:o.naturalWidth,height:o.naturalHeight,aspectRatio:o.naturalWidth/o.naturalHeight})};o.onerror=()=>{r(new Error("Failed to load image for dimension check"))};o.src=t})}createThumbnail(image,t=150,e=150){const r=document.createElement("canvas");const o=r.getContext("2d");const s=image.naturalWidth/image.naturalHeight;let i,n;if(s>1){i=Math.min(t,image.naturalWidth);n=i/s}else{n=Math.min(e,image.naturalHeight);i=n*s}r.width=i;r.height=n;o.imageSmoothingEnabled=true;o.imageSmoothingQuality="high";o.drawImage(image,0,0,i,n);return r}getTableData(t){for(let e=0;e({index:e,width:t.width,type:t.type||"auto"})),rows:e.map((t,e)=>({index:e,height:t.height,heightRule:t.heightRule||"auto",isHeader:t.isHeader||false,cells:t.getCells().map((t,e)=>({index:e,gridSpan:t.gridSpan||1,rowSpan:t.rowSpan||1,vMerge:t.vMerge||null,isMergedContinue:t.isMergedContinue||false,mergeParent:t.mergeParent||null}))}))}}extractTableContent(t){const e=t.getRows();return{cells:e.map((t,e)=>t.getCells().map((t,r)=>({rowIndex:e,cellIndex:r,text:this.extractCellText(t),textBody:this.extractCellTextBody(t),content:this.extractCellContent(t)})))}}extractTableStyling(t){const e=t.getRows();return{table:{borders:t.getTableProperties()?.borders||{},shading:t.getTableProperties()?.shading||{},style:t.getTableProperties()?.style||"TableGrid"},rows:e.map((t,e)=>({index:e,height:t.height,heightRule:t.heightRule||"auto",isHeader:t.isHeader||false})),cells:e.map((t,e)=>t.getCells().map((t,r)=>({rowIndex:e,cellIndex:r,borders:t.borders||{},shading:t.shading||{},margins:t.margins||{},verticalAlignment:t.verticalAlignment||"top",textDirection:t.textDirection||"lr"})))}}hasMergedCells(t){const e=t.getRows();for(const t of e)for(const e of t.getCells())if(e.gridSpan>1||e.rowSpan>1||e.isMergedContinue)return true;return false}extractCellTextBody(t){const e=t.getTextBody();if(!e||!e.paragraphs)return null;return{paragraphs:e.paragraphs.map(t=>({properties:t.properties||{},runs:t.runs?.map(t=>({text:t.text||"",properties:t.properties||{}}))||[]}))}}extractCellContent(t){const e={type:"text",data:null};const r=t.getTextBody();if(r&&r.paragraphs){e.type="text";e.data=this.extractCellTextBody(t)}return e}extractCellText(t){if(!t.textBody||!t.textBody.paragraphs)return"";return t.textBody.paragraphs.map(t=>{if(!t.runs)return"";return t.runs.map(t=>t.text||"").join("")}).join("\n")}cleanup(){this.loadingImages.clear()}}if("undefined"!==typeof globalThis){globalThis.PPTXSlideRenderer=PPTXSlideRenderer;globalThis.ImageLoader=ImageLoader}if("undefined"!==typeof window){if(!window.PPTXSlideRenderer)window.PPTXSlideRenderer=PPTXSlideRenderer;if(!window.ImageLoader)window.ImageLoader=ImageLoader}class PPTXProcessor{constructor(t={}){const e=this._getValidator();const r=this._validateConstructorOptions(t);this.errorBoundary=new(this._getErrorBoundary())({context:"PPTXProcessor",enableLogging:false!==r.enableLogging,errorHandler:r.errorHandler});this.processor=null;this.presentation=null;this.isInitialized=false;this.config={maxFileSize:r.maxFileSize||100*1024*1024,timeout:r.timeout||8e4,enableValidation:false!==r.enableValidation,strictMode:true===r.strictMode,retryOptions:{maxAttempts:r.maxRetryAttempts||3,baseDelay:r.retryDelay||1e3},...r};this.performanceMarks=new Map;this.memoryUsage={peak:0,current:0};this.processingState="idle";this.lastError=null;this.currentSlideIndex=0;this._initializeMonitoring()}async initialize(){if(this.isInitialized)return;return this.errorBoundary.wrap(async()=>{this._markPerformance("initialize_start");try{this._validateEnvironment();await this._initializeWithRetry();this.isInitialized=true;this.processingState="idle";this._markPerformance("initialize_end");if(window.logger)window.logger.info("PPTXProcessor","Processor initialized successfully")}catch(t){this.processingState="error";this.lastError=t;throw this._enhanceError(t,"initialization")}},{context:"initialize"})()}async _ensureInitialized(){if(!this.isInitialized)await this.initialize();if(!this.processor)throw this._createError("Failed to initialize PPTX processor",{name:"ProcessingError",code:"INITIALIZATION_FAILED",recoverable:true})}async processFile(t,e={}){const r=this._validateFileInput(t,e);if(!r.valid)throw this._createValidationError("Invalid file input",r.errors);return this.errorBoundary.wrap(async()=>{this._markPerformance("processFile_start");this.processingState="processing";try{await this._ensureInitialized();this._updateMemoryUsage();const e=await this._processWithTimeout(()=>this.processor.processFile(t),this.config.timeout);this.presentation=this.processor.presentation;this.processingState="completed";this._markPerformance("processFile_end");if(this.config.enableValidation)this._validateProcessingResult(this.presentation);if(window.logger){const t=this._getPerformanceTiming("processFile_start","processFile_end");window.logger.info("PPTXProcessor",`File processed successfully in ${t}ms`)}return this.presentation}catch(e){this.processingState="error";this.lastError=e;throw this._enhanceError(e,"file_processing",{arrayBufferSize:t.byteLength})}},{context:"processFile"})()}async loadFromArrayBuffer(t){return this.processFile(t)}async renderSlide(t,e,r={}){const o=this._validateRenderInput(t,e,r);if(!o.valid)throw this._createValidationError("Invalid render input",o.errors);return this.errorBoundary.wrap(async()=>{this._markPerformance("renderSlide_start");try{await this._ensureInitialized();const o=this.getSlidesCount();if(e<0||e>=o)throw this._createError(`Slide index ${e} out of bounds (0-${o-1})`,{name:"ValidationError",code:"INVALID_SLIDE_INDEX"});this._updateMemoryUsage();const s=await this._processWithTimeout(()=>this.processor.renderSlide(t,e),r.timeout||this.config.timeout);this.currentSlideIndex=e;this._markPerformance("renderSlide_end");if(window.logger){const t=this._getPerformanceTiming("renderSlide_start","renderSlide_end");window.logger.trace("PPTXProcessor",`Slide ${e} rendered in ${t}ms`)}return s}catch(r){throw this._enhanceError(r,"slide_rendering",{slideIndex:e,canvasSize:`${t.width}x${t.height}`})}},{context:"renderSlide"})()}getSlidesCount(){if(!this.processor||!this.processor.slides)return 0;return this.processor.slides.length}getCurrentSlideIndex(){return void 0!==this.currentSlideIndex?this.currentSlideIndex:0}getCurrentSlide(t=null){if(!this.processor||!this.processor.slides)return null;const e=null!==t?t:this.getCurrentSlideIndex();return this.processor.slides[e]||null}getSlideDimensions(){if(!this.processor)return{cx:9144e3,cy:6858e3};if("function"===typeof this.processor.getSlideDimensions)return this.processor.getSlideDimensions();if(this.processor.presentation&&this.processor.presentation.slideSize)return this.processor.presentation.slideSize;return{cx:9144e3,cy:6858e3}}clearCaches(){this._ensureInitialized();if(this.processor){if(this.processor.imageCache){for(const[t,e]of this.processor.imageCache)if(e.url&&e.url.startsWith("blob:"))URL.revokeObjectURL(e.url);this.processor.imageCache.clear()}if(this.processor.imageMap)this.processor.imageMap.clear();if(this.processor.mediaMap)this.processor.mediaMap.clear();if(this.processor.clearCaches&&"function"===typeof this.processor.clearCaches)this.processor.clearCaches();if(this.processor.drawingDocument&&this.processor.drawingDocument.graphics)this.processor.drawingDocument.graphics.resetState();if(this.processor.presentation)this.processor.presentation=null}this.presentation=null}getPresentation(){if(!this.presentation&&this.config.strictMode)throw this._createError("No presentation loaded",{name:"ProcessingError",code:"NO_PRESENTATION_LOADED"});return this.presentation}getProcessingStats(){return{state:this.processingState,isInitialized:this.isInitialized,slidesCount:this.getSlidesCount(),memoryUsage:{...this.memoryUsage},lastError:this.lastError?{name:this.lastError.name,message:this.lastError.message,timestamp:this.lastError.timestamp}:null,performanceMarks:Array.from(this.performanceMarks.entries())}}_getValidator(){return"undefined"!==typeof window&&window.DataValidator?window.DataValidator:class{validate(){return{valid:true,errors:[]}}}}_getErrorBoundary(){return"undefined"!==typeof window&&window.ErrorBoundary?window.ErrorBoundary:class{constructor(){}wrap(t){return t}}}_validateConstructorOptions(t){const e=this._getValidator();const r={type:"object",properties:{maxFileSize:{type:"number",minimum:1024,maximum:500*1024*1024},timeout:{type:"number",minimum:1e3,maximum:3e5},enableLogging:{type:"boolean"},enableValidation:{type:"boolean"},strictMode:{type:"boolean"},maxRetryAttempts:{type:"number",minimum:0,maximum:10},retryDelay:{type:"number",minimum:100,maximum:1e4}}};try{const o=new e({throwOnError:false}).validate(t,r);if(!o.valid&&window.logger)window.logger.warn("PPTXProcessor","Invalid constructor options:",o.errors)}catch(t){}return t}_validateEnvironment(){const t=["Logger","PPTXSlideRenderer"];const e=t.filter(t=>"undefined"===typeof globalThis[t]);if(e.length>0)throw this._createError(`Missing required dependencies: ${e.join(", ")}`,{name:"ProcessingError",code:"MISSING_DEPENDENCIES",details:{missingDependencies:e}})}async _initializeWithRetry(){const{maxAttempts:t,baseDelay:e}=this.config.retryOptions;const r="undefined"!==typeof window&&window.ErrorRecovery?window.ErrorRecovery:{retry:async(t,e)=>{let r;for(let o=0;osetTimeout(t,e.baseDelay))}throw r}};return r.retry(async t=>{if(window.logger)window.logger.trace("PPTXProcessor",`Initialization attempt ${t}`);this.processor=new globalThis.PPTXSlideRenderer;if(!this.processor||"function"!==typeof this.processor.processFile)throw new Error("PPTXSlideRenderer instance is invalid");return this.processor},{maxAttempts:t,baseDelay:e})}_validateFileInput(t,e){const r=[];if(!(t instanceof ArrayBuffer))r.push("Input must be an ArrayBuffer");else{if(0===t.byteLength)r.push("ArrayBuffer cannot be empty");if(t.byteLength>this.config.maxFileSize)r.push(`File size ${t.byteLength} exceeds maximum ${this.config.maxFileSize}`);const e=new Uint8Array(t,0,Math.min(4,t.byteLength));if(e.length>=2&&(80!==e[0]||75!==e[1]))r.push("File does not appear to be a valid ZIP/PPTX file")}if(e&&"object"!==typeof e)r.push("Options must be an object");return{valid:0===r.length,errors:r}}_validateRenderInput(t,e,r){const o=[];if(!t)o.push("Canvas is required");else if(!(t instanceof HTMLCanvasElement))o.push("Canvas must be an HTMLCanvasElement");else if(t.width<=0||t.height<=0)o.push("Canvas must have positive dimensions");if("number"!==typeof e||!Number.isInteger(e))o.push("Slide index must be an integer");if(r&&"object"!==typeof r)o.push("Options must be an object");return{valid:0===o.length,errors:o}}_validateProcessingResult(presentation){if(!presentation)throw this._createError("Processing completed but no presentation was created",{name:"ProcessingError",code:"NO_PRESENTATION_RESULT"});if(this.config.strictMode)if(!this.processor.slides||0===this.processor.slides.length)window.logger?.warn("PPTXProcessor","No slides found in presentation")}async _processWithTimeout(t,e){return new Promise((r,o)=>{const s=setTimeout(()=>{o(this._createError(`Operation timed out after ${e}ms`,{name:"TimeoutError",code:"OPERATION_TIMEOUT"}))},e);Promise.resolve(t()).then(t=>{clearTimeout(s);r(t)}).catch(t=>{clearTimeout(s);o(t)})})}_initializeMonitoring(){if("undefined"!==typeof performance&&performance.mark)this.performanceEnabled=true;if("undefined"!==typeof performance&&performance.memory)this.memoryMonitoringEnabled=true}_markPerformance(t){if(this.performanceEnabled)try{performance.mark(t);this.performanceMarks.set(t,performance.now())}catch(t){}else this.performanceMarks.set(t,Date.now())}_getPerformanceTiming(t,e){const r=this.performanceMarks.get(t);const o=this.performanceMarks.get(e);if(r&&o)return Math.round(o-r);return 0}_updateMemoryUsage(){if(this.memoryMonitoringEnabled&&performance.memory)try{const t=performance.memory.usedJSHeapSize;this.memoryUsage.current=t;this.memoryUsage.peak=Math.max(this.memoryUsage.peak,t)}catch(t){}}_createError(t,e={}){const r="undefined"!==typeof window&&window.ErrorHandlerFactory?window.ErrorHandlerFactory:{createFromError:t=>new Error(t.message||t)};const o=new Error(t);o.name=e.name||"ProcessingError";o.code=e.code||null;o.context="PPTXProcessor";o.timestamp=(new Date).toISOString();o.recoverable=false!==e.recoverable;if(e.details)o.details=e.details;return o}_createValidationError(t,e){const r=this._createError(t,{name:"ValidationError",code:"INPUT_VALIDATION_FAILED"});r.validationErrors=e;return r}_enhanceError(t,e,r={}){if(t.enhanced)return t;const o=t instanceof Error?t:new Error(String(t));o.operation=e;o.processorContext=r;o.timestamp=(new Date).toISOString();o.memoryUsage={...this.memoryUsage};o.enhanced=true;return o}}!function t(){const e="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof window?window:null;if(!e)return;const r=(t={})=>{try{return new PPTXProcessor(t)}catch(t){try{(e.logger||window?.logger)?.error?.("PPTXProcessor","Failed to create processor:",t)}catch(t){}throw t}};if(!e.createPPTXProcessor)e.createPPTXProcessor=r;if(!e.PPTXProcessor)e.PPTXProcessor=PPTXProcessor}();let $t="1.1.8";try{if("undefined"!==typeof process&&process.env&&process.env.npm_package_version)$t=process.env.npm_package_version}catch(t){}const zt=(t,e)=>{if(t)return t;if("undefined"!==typeof globalThis&&globalThis[e])return globalThis[e];if("undefined"!==typeof window&&window[e])return window[e];throw new Error(`${e} is required but was not found. Install and import "${"Chart"===e?"chart.js":"jszip"}" in your application.`)};const Chart=zt(e,"Chart");const JSZip=zt(r,"JSZip");if("undefined"!==typeof globalThis){if(!globalThis.Logger){class t{constructor(){}log(){}info(){}warn(){}error(){}debug(){}trace(){}logError(){}markTiming(){}measureTiming(){}}globalThis.Logger=t}if(!globalThis.PPTXSlideRenderer&&"undefined"!==typeof window&&window.PPTXSlideRenderer)globalThis.PPTXSlideRenderer=window.PPTXSlideRenderer;if("undefined"!==typeof window)if(!window.PPTXSlideRenderer&&globalThis.PPTXSlideRenderer)window.PPTXSlideRenderer=globalThis.PPTXSlideRenderer;if(!globalThis.FontEngine&&"undefined"!==typeof window&&window.FontEngine)globalThis.FontEngine=window.FontEngine;if(!globalThis.SimplifiedFontManager&&"undefined"!==typeof window&&window.SimplifiedFontManager)globalThis.SimplifiedFontManager=window.SimplifiedFontManager;if(!globalThis.ZLib&&"undefined"!==typeof window&&window.ZLib)globalThis.ZLib=window.ZLib;if(!globalThis.OpenXmlPackage&&"undefined"!==typeof window&&window.OpenXmlPackage)globalThis.OpenXmlPackage=window.OpenXmlPackage;if(!globalThis.OpenXmlPart&&"undefined"!==typeof window&&window.OpenXmlPart)globalThis.OpenXmlPart=window.OpenXmlPart;if(!globalThis.OpenXmlTypes&&"undefined"!==typeof window&&window.OpenXmlTypes)globalThis.OpenXmlTypes=window.OpenXmlTypes;if(!globalThis.SVGRenderer&&"undefined"!==typeof window&&window.SVGRenderer)globalThis.SVGRenderer=window.SVGRenderer;if(!globalThis.XmlParserContext&&"undefined"!==typeof window&&window.XmlParserContext)globalThis.XmlParserContext=window.XmlParserContext;if(!globalThis.StaxParser&&"undefined"!==typeof window&&window.StaxParser)globalThis.StaxParser=window.StaxParser;if(!globalThis.CPresentation&&"undefined"!==typeof window&&window.CPresentation)globalThis.CPresentation=window.CPresentation;if(!globalThis.CSlide&&"undefined"!==typeof window&&window.CSlide)globalThis.CSlide=window.CSlide;if(!globalThis.CSld&&"undefined"!==typeof window&&window.CSld)globalThis.CSld=window.CSld;if(!globalThis.CShape&&"undefined"!==typeof window&&window.CShape)globalThis.CShape=window.CShape;if(!globalThis.CGroupShape&&"undefined"!==typeof window&&window.CGroupShape)globalThis.CGroupShape=window.CGroupShape;if(!globalThis.CSlideMaster&&"undefined"!==typeof window&&window.CSlideMaster)globalThis.CSlideMaster=window.CSlideMaster;if(!globalThis.CSlideLayout&&"undefined"!==typeof window&&window.CSlideLayout)globalThis.CSlideLayout=window.CSlideLayout;if(!globalThis.CTheme&&"undefined"!==typeof window&&window.CTheme)globalThis.CTheme=window.CTheme;if(!globalThis.CTable&&"undefined"!==typeof window&&window.CTable)globalThis.CTable=window.CTable;if(!globalThis.JSZip&&"undefined"!==typeof JSZip)globalThis.JSZip=JSZip;if(!globalThis.PPTXProcessor&&"function"===typeof PPTXProcessor)globalThis.PPTXProcessor=PPTXProcessor;if(!globalThis.createPPTXProcessor&&"function"===typeof PPTXProcessor)globalThis.createPPTXProcessor=(t={})=>new PPTXProcessor(t)}if("undefined"!==typeof globalThis){if("undefined"!==typeof window){window.CGraphics=window.CGraphics||globalThis.CGraphics||void 0;if(!window.Chart&&"undefined"!==typeof Chart)window.Chart=Chart;if(!window.PPTXSlideRenderer&&"undefined"!==typeof globalThis.PPTXSlideRenderer)window.PPTXSlideRenderer=globalThis.PPTXSlideRenderer;if(!window.PPTXProcessor&&"undefined"!==typeof globalThis.PPTXProcessor)window.PPTXProcessor=globalThis.PPTXProcessor;if(!window.createPPTXProcessor&&"undefined"!==typeof globalThis.createPPTXProcessor)window.createPPTXProcessor=globalThis.createPPTXProcessor}if(!globalThis.CGraphics&&"undefined"!==typeof window&&window.CGraphics)globalThis.CGraphics=window.CGraphics}class Ot{constructor(t={}){const e=t||{};this.options={canvas:e.canvas??null,debug:e.debug??false,enableThumbnails:e.enableThumbnails??true,slideSizeMode:e.slideSizeMode??"fit",backgroundColor:e.backgroundColor??"#ffffff",autoRenderFirstSlide:e.autoRenderFirstSlide??true,logger:e.logger??("undefined"!==typeof window?window.console:console),autoExposeGlobals:e.autoExposeGlobals??true,autoChartRerenderDelayMs:e.autoChartRerenderDelayMs??200};Object.assign(this.options,e);this.processor=null;this.presentation=null;this.currentSlideIndex=0;this.slideCount=0;this.isLoaded=false;this.eventListeners={};this._initPromise=null;this._scheduledPostLoadRerender=false}async _initializeProcessor(){if(this._initPromise)return this._initPromise;this._initPromise=(async()=>{const t="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof window?window:null;const e=()=>{const e=t?t.PPTXProcessor||null:null;const r=t?t.createPPTXProcessor||null:null;return{ctor:e,factory:r}};try{let t=0;let r=e();while(!r.ctor&&!r.factory&&t<100){await new Promise(t=>setTimeout(t,20));t+=1;r=e()}if(r.ctor&&"function"===typeof r.ctor)this.processor=new r.ctor;else if(r.factory&&"function"===typeof r.factory)this.processor=r.factory();else this.processor=null;if(!this.processor)throw new Error("PPTXProcessor is not available. Ensure processors are loaded.");if("function"===typeof this.processor.initialize)await this.processor.initialize();this.emit("processorReady");return this.processor}catch(t){this.emit("initError",t);throw t}})();return this._initPromise}async loadFile(t,e={}){if(this.isLoaded&&this.processor){try{if("function"===typeof this.processor.destroy)this.processor.destroy();else if("function"===typeof this.processor.reset)this.processor.reset()}catch(t){}this.processor=null;this._initPromise=null}await this._initializeProcessor();try{this.emit("loadStart");let r;if("undefined"!==typeof File&&t instanceof File)r=await t.arrayBuffer();else if(t instanceof ArrayBuffer)r=t;else if(t instanceof Uint8Array)r=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);else throw new Error("Input must be File, ArrayBuffer, or Uint8Array");await this.processor.processFile(r,e);this.presentation=this.processor.presentation;this.slideCount=this.processor.getSlidesCount();this.currentSlideIndex=0;this.isLoaded=true;this._scheduledPostLoadRerender=false;if(this.options.autoExposeGlobals)try{this._exposeGlobalsForCharts()}catch(t){}this.emit("loadComplete",{slideCount:this.slideCount,presentation:this.presentation});return this}catch(t){this.emit("loadError",t);throw t}}async loadFromUrl(t){this.emit("loadStart");try{const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch PPTX: ${e.status} ${e.statusText}`);const r=await e.arrayBuffer();return this.loadFile(r)}catch(t){this.emit("loadError",t);throw t}}async render(t,e={}){if(!this.isLoaded)throw new Error("No PPTX loaded. Call loadFile() first.");const r=t||this.options.canvas;if(!r)throw new Error("Canvas element required. Provide canvas parameter or set in constructor.");const o=void 0!==e.slideIndex?e.slideIndex:this.currentSlideIndex;if(o<0||o>=this.slideCount)throw new Error(`Invalid slide index: ${o}.`);try{this.emit("renderStart",o);await this.processor.renderSlide(r,o,e);this.currentSlideIndex=o;this.emit("renderComplete",o);this.emit("slideChanged",o);if(this.options.autoChartRerenderDelayMs>0&&!this._scheduledPostLoadRerender){this._scheduledPostLoadRerender=true;const t=this.options.autoChartRerenderDelayMs;setTimeout(()=>{try{this.render(r,{...e,slideIndex:o})}catch(t){}},t)}return this}catch(t){this.emit("renderError",t);throw t}}async renderSlide(t,e=null,r={}){return this.render(e,{...r,slideIndex:t})}async nextSlide(t=null){if(this.currentSlideIndex0)await this.render(t,{slideIndex:this.currentSlideIndex-1});return this}async goToSlide(t,e=null){return this.render(e,{slideIndex:t})}getSlideCount(){return this.slideCount}getCurrentSlideIndex(){return this.currentSlideIndex}setCanvas(t){this.options.canvas=t;return this}on(t,e){if(!this.eventListeners[t])this.eventListeners[t]=[];this.eventListeners[t].push(e)}off(t,e){if(!this.eventListeners[t])return;const r=this.eventListeners[t].indexOf(e);if(r>-1)this.eventListeners[t].splice(r,1)}emit(t,...e){if(this.eventListeners[t])this.eventListeners[t].forEach(t=>{try{t(...e)}catch(t){}})}destroy(){this.processor=null;this.eventListeners={};this.isLoaded=false;this.currentSlideIndex=0;this.slideCount=0}_exposeGlobalsForCharts(){try{const t=this.processor;if(!t)return;const e=t.zip||t.processor?.zip||t.zipProcessor?.zip||null;const r=t.package||t.processor?.package||t.zipProcessor?.package||null;const o=()=>{const t="function"===typeof this.getCurrentSlideIndex?this.getCurrentSlideIndex():this.currentSlideIndex||0;const e=this.options.canvas;if(e)this.render(e,{slideIndex:t}).catch(()=>{})};const s={processor:t,zip:e,package:r,reRenderShape:o};if("undefined"!==typeof window){window.currentProcessor=s;if(e)window.currentZipData=e;if(window.PPTXSlideRenderer&&e)try{window.PPTXSlideRenderer.currentZip=s.zip}catch(t){}try{if(window.currentProcessor&&window.currentProcessor.processor){if(!window.currentProcessor.processor.zip&&e)window.currentProcessor.processor.zip=e;if(!window.currentProcessor.processor.package&&r)window.currentProcessor.processor.package=r;if(!window.currentProcessor.processor.zipProcessor)window.currentProcessor.processor.zipProcessor={};if(e&&!window.currentProcessor.processor.zipProcessor.zip)window.currentProcessor.processor.zipProcessor.zip=e;if(r&&!window.currentProcessor.processor.zipProcessor.package)window.currentProcessor.processor.zipProcessor.package=r}}catch(t){}}}catch(t){}}}function Nt({canvas:t,fileInput:e,prevBtn:r,nextBtn:o,statusEl:s,options:i={}}={}){if(!t)throw new Error("canvas is required");const n=new Ot({canvas:t,...i});const a=()=>{try{const t=n.getSlideCount();const e="function"===typeof n.getCurrentSlideIndex?n.getCurrentSlideIndex():0;if(r)r.disabled=!(e>0);if(o)o.disabled=!(ea());n.on("loadComplete",()=>{try{if(n&&n.processor&&false!==i.autoExposeGlobals){const e=n.processor;const r={processor:e,zip:e.zip,package:e.package,reRenderShape:()=>{const e="function"===typeof n.getCurrentSlideIndex?n.getCurrentSlideIndex():0;n.render(t,{slideIndex:e}).catch(()=>{})}};if("undefined"!==typeof window){window.currentProcessor=r;if(e.zip)window.currentZipData=e.zip;if(window.PPTXSlideRenderer&&r.zip)try{window.PPTXSlideRenderer.currentZip=r.zip}catch(t){}}}}catch(t){}a()});if(e)e.addEventListener("change",async()=>{const r=e.files&&e.files[0];if(!r)return;if(s)s.textContent="Loading...";try{await n.loadFile(r);try{if(n&&n.processor&&false!==i.autoExposeGlobals){const e=n.processor;const r=e.zip||e.processor?.zip||e.zipProcessor?.zip||null;const o=e.package||e.processor?.package||e.zipProcessor?.package||null;if("undefined"!==typeof window){window.currentProcessor={processor:e,zip:r,package:o,reRenderShape:()=>{const e="function"===typeof n.getCurrentSlideIndex?n.getCurrentSlideIndex():0;n.render(t,{slideIndex:e}).catch(()=>{})}};if(r)window.currentZipData=r;try{if(window.currentProcessor&&window.currentProcessor.processor){if(!window.currentProcessor.processor.zip&&r)window.currentProcessor.processor.zip=r;if(!window.currentProcessor.processor.package&&o)window.currentProcessor.processor.package=o;if(!window.currentProcessor.processor.zipProcessor)window.currentProcessor.processor.zipProcessor={};if(r&&!window.currentProcessor.processor.zipProcessor.zip)window.currentProcessor.processor.zipProcessor.zip=r;if(o&&!window.currentProcessor.processor.zipProcessor.package)window.currentProcessor.processor.zipProcessor.package=o}}catch(t){}}}}catch(t){}await n.render(t,{slideIndex:0});const e="number"===typeof i.autoChartRerenderDelayMs?i.autoChartRerenderDelayMs:200;if(e>0)setTimeout(()=>{const e="function"===typeof n.getCurrentSlideIndex?n.getCurrentSlideIndex():0;n.render(t,{slideIndex:e}).catch(()=>{})},e)}catch(t){if(s)s.textContent="Error: "+(t?.message||"Failed to load")}});if(r)r.addEventListener("click",async()=>{await n.previousSlide(t)});if(o)o.addEventListener("click",async()=>{await n.nextSlide(t)});if("undefined"!==typeof window)window.addEventListener("chartRenderingComplete",()=>{if(!n.isLoaded)return;const e="function"===typeof n.getCurrentSlideIndex?n.getCurrentSlideIndex():0;n.render(t,{slideIndex:e}).catch(()=>{})});return n}const Gt={PPTXViewer:Ot,version:$t,mountSimpleViewer:Nt};const Wt=t=>{try{if("undefined"!==typeof globalThis&&globalThis[t]&&!Gt[t])Gt[t]=globalThis[t]}catch(t){}};["CGraphics","FontEngine","SimplifiedFontManager","ZLib","OpenXmlPackage","OpenXmlPart","OpenXmlTypes","SVGRenderer","XmlParserContext","StaxParser","CPresentation","CSlide","CSld","CShape","CGroupShape","CSlideMaster","CSlideLayout","CTheme","CTable","PPTXProcessor","PPTXSlideRenderer","Chart","JSZip"].forEach(Wt);if("undefined"!==typeof globalThis){globalThis.PptxViewJS=Gt;if(!globalThis.PPTXProcessor&&"undefined"!==typeof PPTXProcessor)globalThis.PPTXProcessor=PPTXProcessor;if(!globalThis.createPPTXProcessor&&"undefined"!==typeof PPTXProcessor)globalThis.createPPTXProcessor=(t={})=>new PPTXProcessor(t)}if(!globalThis.PPTXSlideRenderer&&"function"===typeof PPTXSlideRenderer)globalThis.PPTXSlideRenderer=PPTXSlideRenderer;t.PPTXViewer=Ot;t.default=Gt;Object.defineProperty(t,"__esModule",{value:true})});!function(){try{var t="undefined"!==typeof window&&(window.CDrawingDocument||window.CDrawingDocumentClass);if(t&&!t.prototype.colorToRgb)t.prototype.colorToRgb=function(t){try{if(this.graphics&&"function"===typeof this.graphics.colorToRgb)return this.graphics.colorToRgb(t)}catch(t){}if("string"===typeof t)return t;if(t&&"object"===typeof t){var e=void 0!==t.r?t.r:void 0!==t.R?t.R:0;var r=void 0!==t.g?t.g:void 0!==t.G?t.G:0;var o=void 0!==t.b?t.b:void 0!==t.B?t.B:0;var s=void 0!==t.a?t.a:void 0!==t.A?t.A:255;return 255!==s?"rgba("+e+", "+r+", "+o+", "+s/255+")":"rgb("+e+", "+r+", "+o+")"}return"rgb(0, 0, 0)"}}catch(t){}}(); diff --git a/web/include/pptxviewjs/jszip.LICENSE b/web/include/pptxviewjs/jszip.LICENSE new file mode 100644 index 0000000..f8250b3 --- /dev/null +++ b/web/include/pptxviewjs/jszip.LICENSE @@ -0,0 +1,651 @@ +JSZip is dual licensed. At your choice you may use it under the MIT license *or* the GPLv3 +license. + +The MIT License +=============== + +Copyright (c) 2009-2016 Stuart Knightley, David Duponchel, Franz Buchinger, António Afonso + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +GPL version 3 +============= + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS diff --git a/web/include/pptxviewjs/jszip.min.js b/web/include/pptxviewjs/jszip.min.js new file mode 100644 index 0000000..ff4cfd5 --- /dev/null +++ b/web/include/pptxviewjs/jszip.min.js @@ -0,0 +1,13 @@ +/*! + +JSZip v3.10.1 - A JavaScript class for generating and reading zip files + + +(c) 2009-2016 Stuart Knightley +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. + +JSZip uses the library pako released under the MIT license : +https://github.com/nodeca/pako/blob/main/LICENSE +*/ + +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JSZip=e()}}(function(){return function s(a,o,h){function u(r,e){if(!o[r]){if(!a[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(l)return l(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=o[r]={exports:{}};a[r][0].call(i.exports,function(e){var t=a[r][1][e];return u(t||e)},i,i.exports,s,a,o,h)}return o[r].exports}for(var l="function"==typeof require&&require,e=0;e>2,s=(3&t)<<4|r>>4,a=1>6:64,o=2>4,r=(15&i)<<4|(s=p.indexOf(e.charAt(o++)))>>2,n=(3&s)<<6|(a=p.indexOf(e.charAt(o++))),l[h++]=t,64!==s&&(l[h++]=r),64!==a&&(l[h++]=n);return l}},{"./support":30,"./utils":32}],2:[function(e,t,r){"use strict";var n=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function o(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}o.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(e,t,r){return e.pipe(new s).pipe(new a("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){"use strict";var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){"use strict";var n=e("./utils");var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==n.getTypeOf(e)?function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t[a])];return-1^e}(0|t,e,e.length,0):function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){"use strict";var n=null;n="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:n}},{lie:37}],7:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),a=e("./stream/GenericWorker"),o=n?"uint8array":"array";function h(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic="\b\0",s.inherits(h,a),h.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,e.data),!1)},h.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(e){return new h("Deflate",e)},r.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){"use strict";function A(e,t){var r,n="";for(r=0;r>>=8;return n}function n(e,t,r,n,i,s){var a,o,h=e.file,u=e.compression,l=s!==O.utf8encode,f=I.transformTo("string",s(h.name)),c=I.transformTo("string",O.utf8encode(h.name)),d=h.comment,p=I.transformTo("string",s(d)),m=I.transformTo("string",O.utf8encode(d)),_=c.length!==h.name.length,g=m.length!==d.length,b="",v="",y="",w=h.dir,k=h.date,x={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(x.crc32=e.crc32,x.compressedSize=e.compressedSize,x.uncompressedSize=e.uncompressedSize);var S=0;t&&(S|=8),l||!_&&!g||(S|=2048);var z=0,C=0;w&&(z|=16),"UNIX"===i?(C=798,z|=function(e,t){var r=e;return e||(r=t?16893:33204),(65535&r)<<16}(h.unixPermissions,w)):(C=20,z|=function(e){return 63&(e||0)}(h.dosPermissions)),a=k.getUTCHours(),a<<=6,a|=k.getUTCMinutes(),a<<=5,a|=k.getUTCSeconds()/2,o=k.getUTCFullYear()-1980,o<<=4,o|=k.getUTCMonth()+1,o<<=5,o|=k.getUTCDate(),_&&(v=A(1,1)+A(B(f),4)+c,b+="up"+A(v.length,2)+v),g&&(y=A(1,1)+A(B(p),4)+m,b+="uc"+A(y.length,2)+y);var E="";return E+="\n\0",E+=A(S,2),E+=u.magic,E+=A(a,2),E+=A(o,2),E+=A(x.crc32,4),E+=A(x.compressedSize,4),E+=A(x.uncompressedSize,4),E+=A(f.length,2),E+=A(b.length,2),{fileRecord:R.LOCAL_FILE_HEADER+E+f+b,dirRecord:R.CENTRAL_FILE_HEADER+A(C,2)+E+A(p.length,2)+"\0\0\0\0"+A(z,4)+A(n,4)+f+b+p}}var I=e("../utils"),i=e("../stream/GenericWorker"),O=e("../utf8"),B=e("../crc32"),R=e("../signature");function s(e,t,r,n){i.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}I.inherits(s,i),s.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,i.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},s.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},s.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=n(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:function(e){return R.DATA_DESCRIPTOR+A(e.crc32,4)+A(e.compressedSize,4)+A(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},s.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,r){"use strict";var n=e("./Uint8ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){"use strict";var n=e("./ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../support"),s=e("./ArrayReader"),a=e("./StringReader"),o=e("./NodeBufferReader"),h=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new o(e):i.uint8array?new h(n.transformTo("uint8array",e)):new s(n.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../utils");function s(e){n.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(s,n),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../crc32");function s(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,n),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}n.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}n.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){"use strict";function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r "+e:e}},t.exports=n},{}],29:[function(e,t,r){"use strict";var h=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),u=e("../base64"),n=e("../support"),a=e("../external"),o=null;if(n.nodestream)try{o=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function l(e,o){return new a.Promise(function(t,r){var n=[],i=e._internalType,s=e._outputType,a=e._mimeType;e.on("data",function(e,t){n.push(e),o&&o(t)}).on("error",function(e){n=[],r(e)}).on("end",function(){try{var e=function(e,t,r){switch(e){case"blob":return h.newBlob(h.transformTo("arraybuffer",t),r);case"base64":return u.encode(t);default:return h.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,s=0;for(r=0;r>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t}(e)},s.utf8decode=function(e){return h.nodebuffer?o.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,n,i,s=e.length,a=new Array(2*s);for(t=r=0;t>10&1023,a[r++]=56320|1023&n)}return a.length!==r&&(a.subarray?a=a.subarray(0,r):a.length=r),o.applyFromCharCode(a)}(e=o.transformTo(h.uint8array?"uint8array":"array",e))},o.inherits(a,n),a.prototype.processChunk=function(e){var t=o.transformTo(h.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(h.uint8array){var r=t;(t=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),t.set(r,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var n=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}(t),i=t;n!==t.length&&(h.uint8array?(i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length)):(i=t.slice(0,n),this.leftOver=t.slice(n,t.length))),this.push({data:s.utf8decode(i),meta:e.meta})},a.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=a,o.inherits(l,n),l.prototype.processChunk=function(e){this.push({data:s.utf8encode(e.data),meta:e.meta})},s.Utf8EncodeWorker=l},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,a){"use strict";var o=e("./support"),h=e("./base64"),r=e("./nodejsUtils"),u=e("./external");function n(e){return e}function l(e,t){for(var r=0;r>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=n(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.buf2binstring=function(e){return l(e,e.length)},r.binstring2buf=function(e){for(var t=new h.Buf8(e.length),r=0,n=t.length;r>10&1023,o[n++]=56320|1023&i)}return l(o,n)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}},{"./common":41}],43:[function(e,t,r){"use strict";t.exports=function(e,t,r,n){for(var i=65535&e|0,s=e>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,r){"use strict";var h,c=e("../utils/common"),u=e("./trees"),d=e("./adler32"),p=e("./crc32"),n=e("./messages"),l=0,f=4,m=0,_=-2,g=-1,b=4,i=2,v=8,y=9,s=286,a=30,o=19,w=2*s+1,k=15,x=3,S=258,z=S+x+1,C=42,E=113,A=1,I=2,O=3,B=4;function R(e,t){return e.msg=n[t],t}function T(e){return(e<<1)-(4e.avail_out&&(r=e.avail_out),0!==r&&(c.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function N(e,t){u._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,F(e.strm)}function U(e,t){e.pending_buf[e.pending++]=t}function P(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function L(e,t){var r,n,i=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-z?e.strstart-(e.w_size-z):0,u=e.window,l=e.w_mask,f=e.prev,c=e.strstart+S,d=u[s+a-1],p=u[s+a];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&sh&&0!=--i);return a<=e.lookahead?a:e.lookahead}function j(e){var t,r,n,i,s,a,o,h,u,l,f=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-z)){for(c.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=r=e.hash_size;n=e.head[--t],e.head[t]=f<=n?n-f:0,--r;);for(t=r=f;n=e.prev[--t],e.prev[t]=f<=n?n-f:0,--r;);i+=f}if(0===e.strm.avail_in)break;if(a=e.strm,o=e.window,h=e.strstart+e.lookahead,u=i,l=void 0,l=a.avail_in,u=x)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<=x&&(e.ins_h=(e.ins_h<=x)if(n=u._tr_tally(e,e.strstart-e.match_start,e.match_length-x),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=x){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=x&&(e.ins_h=(e.ins_h<=x&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-x,n=u._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-x),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(j(e),0===e.lookahead&&t===l)return A;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return A;if(e.strstart-e.block_start>=e.w_size-z&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),A)}),new M(4,4,8,4,Z),new M(4,5,16,8,Z),new M(4,6,32,32,Z),new M(4,4,16,16,W),new M(8,16,32,32,W),new M(8,16,128,128,W),new M(8,32,128,256,W),new M(32,128,258,1024,W),new M(32,258,258,4096,W)],r.deflateInit=function(e,t){return Y(e,t,v,15,8,0)},r.deflateInit2=Y,r.deflateReset=K,r.deflateResetKeep=G,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?_:(e.state.gzhead=t,m):_},r.deflate=function(e,t){var r,n,i,s;if(!e||!e.state||5>8&255),U(n,n.gzhead.time>>16&255),U(n,n.gzhead.time>>24&255),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(U(n,255&n.gzhead.extra.length),U(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=p(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(U(n,0),U(n,0),U(n,0),U(n,0),U(n,0),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,3),n.status=E);else{var a=v+(n.w_bits-8<<4)<<8;a|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=E,P(n,a),0!==n.strstart&&(P(n,e.adler>>>16),P(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending!==n.pending_buf_size));)U(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindexi&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindexi&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&F(e),n.pending+2<=n.pending_buf_size&&(U(n,255&e.adler),U(n,e.adler>>8&255),e.adler=0,n.status=E)):n.status=E),0!==n.pending){if(F(e),0===e.avail_out)return n.last_flush=-1,m}else if(0===e.avail_in&&T(t)<=T(r)&&t!==f)return R(e,-5);if(666===n.status&&0!==e.avail_in)return R(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==l&&666!==n.status){var o=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(j(e),0===e.lookahead)){if(t===l)return A;break}if(e.match_length=0,r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):3===n.strategy?function(e,t){for(var r,n,i,s,a=e.window;;){if(e.lookahead<=S){if(j(e),e.lookahead<=S&&t===l)return A;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=x&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=x?(r=u._tr_tally(e,1,e.match_length-x),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):h[n.level].func(n,t);if(o!==O&&o!==B||(n.status=666),o===A||o===O)return 0===e.avail_out&&(n.last_flush=-1),m;if(o===I&&(1===t?u._tr_align(n):5!==t&&(u._tr_stored_block(n,0,0,!1),3===t&&(D(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),F(e),0===e.avail_out))return n.last_flush=-1,m}return t!==f?m:n.wrap<=0?1:(2===n.wrap?(U(n,255&e.adler),U(n,e.adler>>8&255),U(n,e.adler>>16&255),U(n,e.adler>>24&255),U(n,255&e.total_in),U(n,e.total_in>>8&255),U(n,e.total_in>>16&255),U(n,e.total_in>>24&255)):(P(n,e.adler>>>16),P(n,65535&e.adler)),F(e),0=r.w_size&&(0===s&&(D(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new c.Buf8(r.w_size),c.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,o=e.next_in,h=e.input,e.avail_in=l,e.next_in=0,e.input=t,j(r);r.lookahead>=x;){for(n=r.strstart,i=r.lookahead-(x-1);r.ins_h=(r.ins_h<>>=y=v>>>24,p-=y,0===(y=v>>>16&255))C[s++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=m[(65535&v)+(d&(1<>>=y,p-=y),p<15&&(d+=z[n++]<>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=_[(65535&v)+(d&(1<>>=y,p-=y,(y=s-a)>3,d&=(1<<(p-=w<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new I.Buf16(320),this.work=new I.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=P,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new I.Buf32(n),t.distcode=t.distdyn=new I.Buf32(i),t.sane=1,t.back=-1,N):U}function o(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):U}function h(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=s.wsize?(I.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(n<(i=s.wsize-s.wnext)&&(i=n),I.arraySet(s.window,t,r-n,i,s.wnext),(n-=i)?(I.arraySet(s.window,t,r-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,r.check=B(r.check,E,2,0),l=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=30;break}if(l-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=B(r.check,E,4,0)),l=u=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>>8&255,r.check=B(r.check,E,2,0)),l=u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(o<(d=r.length)&&(d=o),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),I.arraySet(r.head.extra,n,s,d,k)),512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,u+=n[s++]<>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==t)break;u>>>=2,l-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=n[s++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,l=u=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(o>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,286>>=3,l-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=_,l-=_,r.lens[r.have++]=b;else{if(16===b){for(z=_+2;l>>=_,l-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===b){for(z=_+3;l>>=_)),u>>>=3,l-=3}else{for(z=_+7;l>>=_)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(D,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=o&&258<=h){e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,R(e,c),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,r.length=b,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===h)break e;if(d=c-h,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p=d>r.wnext?(d-=r.wnext,r.wsize-d):r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=a-r.offset,d=r.length;for(hd?(m=R[T+a[v]],A[I+a[v]]):(m=96,0),h=1<>S)+(u-=h)]=p<<24|m<<16|_|0,0!==u;);for(h=1<>=1;if(0!==h?(E&=h-1,E+=h):E=0,v++,0==--O[b]){if(b===w)break;b=t[r+a[v]]}if(k>>7)]}function U(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function P(e,t,r){e.bi_valid>d-r?(e.bi_buf|=t<>d-e.bi_valid,e.bi_valid+=r-d):(e.bi_buf|=t<>>=1,r<<=1,0<--t;);return r>>>1}function Z(e,t,r){var n,i,s=new Array(g+1),a=0;for(n=1;n<=g;n++)s[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=j(s[o]++,o))}}function W(e){var t;for(t=0;t>1;1<=r;r--)G(e,s,r);for(i=h;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],G(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,G(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,a,o,h=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,f=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(s=0;s<=g;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_;r++)p<(s=h[2*h[2*(n=e.heap[r])+1]+1]+1)&&(s=p,m++),h[2*n+1]=s,u>=7;n>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return h;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?J(e,t,r,n):4===e.strategy||s===i?(P(e,2+(n?1:0),3),K(e,z,C)):(P(e,4+(n?1:0),3),function(e,t,r,n){var i;for(P(e,t-257,5),P(e,r-1,5),P(e,n-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(A[r]+u+1)]++,e.dyn_dtree[2*N(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){P(e,2,3),L(e,m,z),function(e){16===e.bi_valid?(U(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(r,n){"use strict";if(!r.setImmediate){var i,s,t,a,o=1,h={},u=!1,l=r.document,e=Object.getPrototypeOf&&Object.getPrototypeOf(r);e=e&&e.setTimeout?e:r,i="[object process]"==={}.toString.call(r.process)?function(e){process.nextTick(function(){c(e)})}:function(){if(r.postMessage&&!r.importScripts){var e=!0,t=r.onmessage;return r.onmessage=function(){e=!1},r.postMessage("","*"),r.onmessage=t,e}}()?(a="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",d,!1):r.attachEvent("onmessage",d),function(e){r.postMessage(a+e,"*")}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){c(e.data)},function(e){t.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(s=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){c(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):function(e){setTimeout(c,0,e)},e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r + + + + + + +
+ +
+ +
+ +
+
+ +
+
+ + +
+
+
/
+
+
+
+ + + + +
+

+
+ + +
+ +
+ $deck) { + $bar = $caption_colors[$index % count($caption_colors)]; + ?> + + +
+
+
+
+ +
+ + + + diff --git a/web/template/syzoj/docs.php b/web/template/syzoj/docs.php deleted file mode 100644 index 3d3e44c..0000000 --- a/web/template/syzoj/docs.php +++ /dev/null @@ -1,193 +0,0 @@ - - - - - -
- - -
-
- -

- - -
- - -
- -
没有可显示的文档内容。
- -
-
- - - - \ No newline at end of file diff --git a/web/template/syzoj/footer.php b/web/template/syzoj/footer.php index 64966d1..f9d414b 100644 --- a/web/template/syzoj/footer.php +++ b/web/template/syzoj/footer.php @@ -1,7 +1,9 @@ + +