@zwbigi/ink-xy 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -0
- package/.next/app-path-routes-manifest.json +33 -0
- package/.next/build-manifest.json +20 -0
- package/.next/diagnostics/build-diagnostics.json +6 -0
- package/.next/diagnostics/framework.json +1 -0
- package/.next/export-marker.json +6 -0
- package/.next/images-manifest.json +68 -0
- package/.next/next-minimal-server.js.nft.json +1 -0
- package/.next/next-server.js.nft.json +1 -0
- package/.next/package.json +1 -0
- package/.next/prerender-manifest.json +114 -0
- package/.next/react-loadable-manifest.json +1993 -0
- package/.next/required-server-files.js +341 -0
- package/.next/required-server-files.json +341 -0
- package/.next/routes-manifest.json +252 -0
- package/.next/server/app/_global-error/page.js +32 -0
- package/.next/server/app/_global-error/page.js.nft.json +1 -0
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -0
- package/.next/server/app/_global-error.html +1 -0
- package/.next/server/app/_global-error.meta +16 -0
- package/.next/server/app/_global-error.rsc +14 -0
- package/.next/server/app/_global-error.segments/_full.segment.rsc +14 -0
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_head.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_index.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
- package/.next/server/app/_not-found/page.js +2 -0
- package/.next/server/app/_not-found/page.js.nft.json +1 -0
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
- package/.next/server/app/_not-found.html +1 -0
- package/.next/server/app/_not-found.meta +16 -0
- package/.next/server/app/_not-found.rsc +16 -0
- package/.next/server/app/_not-found.segments/_full.segment.rsc +16 -0
- package/.next/server/app/_not-found.segments/_head.segment.rsc +6 -0
- package/.next/server/app/_not-found.segments/_index.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -0
- package/.next/server/app/api/agent/[id]/events/route.js +3 -0
- package/.next/server/app/api/agent/[id]/events/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/[id]/events/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/[id]/route.js +1 -0
- package/.next/server/app/api/agent/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/[id]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/describe-image/route.js +15 -0
- package/.next/server/app/api/agent/describe-image/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/describe-image/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/new/route.js +8 -0
- package/.next/server/app/api/agent/new/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/new/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/all-providers/route.js +1 -0
- package/.next/server/app/api/auth/all-providers/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/all-providers/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -0
- package/.next/server/app/api/auth/api-key/[provider]/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/api-key/[provider]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/login/[provider]/route.js +3 -0
- package/.next/server/app/api/auth/login/[provider]/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/login/[provider]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/logout/[provider]/route.js +1 -0
- package/.next/server/app/api/auth/logout/[provider]/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/logout/[provider]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/providers/route.js +1 -0
- package/.next/server/app/api/auth/providers/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/providers/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/default-cwd/route.js +1 -0
- package/.next/server/app/api/default-cwd/route.js.nft.json +1 -0
- package/.next/server/app/api/default-cwd/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/files/[...path]/route.js +6 -0
- package/.next/server/app/api/files/[...path]/route.js.nft.json +1 -0
- package/.next/server/app/api/files/[...path]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/gem-xy/[id]/route.js +1 -0
- package/.next/server/app/api/gem-xy/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/gem-xy/[id]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/gem-xy/route.js +1 -0
- package/.next/server/app/api/gem-xy/route.js.nft.json +1 -0
- package/.next/server/app/api/gem-xy/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/home/route.js +1 -0
- package/.next/server/app/api/home/route.js.nft.json +1 -0
- package/.next/server/app/api/home/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/inkos/route.js +13 -0
- package/.next/server/app/api/inkos/route.js.nft.json +1 -0
- package/.next/server/app/api/inkos/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models/route.js +1 -0
- package/.next/server/app/api/models/route.js.nft.json +1 -0
- package/.next/server/app/api/models/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models-config/route.js +1 -0
- package/.next/server/app/api/models-config/route.js.nft.json +1 -0
- package/.next/server/app/api/models-config/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/register-cwd/route.js +1 -0
- package/.next/server/app/api/register-cwd/route.js.nft.json +1 -0
- package/.next/server/app/api/register-cwd/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/context/route.js +3 -0
- package/.next/server/app/api/sessions/[id]/context/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/context/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/lock/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/lock/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/lock/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/new/route.js +1 -0
- package/.next/server/app/api/sessions/new/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/new/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/route.js +3 -0
- package/.next/server/app/api/sessions/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/install/route.js +1 -0
- package/.next/server/app/api/skills/install/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/install/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/route.js +6 -0
- package/.next/server/app/api/skills/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/search/route.js +1 -0
- package/.next/server/app/api/skills/search/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/search/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/tts/synthesize/route.js +1 -0
- package/.next/server/app/api/tts/synthesize/route.js.nft.json +1 -0
- package/.next/server/app/api/tts/synthesize/route_client-reference-manifest.js +1 -0
- package/.next/server/app/favicon.ico/route.js +1 -0
- package/.next/server/app/favicon.ico/route.js.nft.json +1 -0
- package/.next/server/app/favicon.ico.body +0 -0
- package/.next/server/app/favicon.ico.meta +1 -0
- package/.next/server/app/index.html +1 -0
- package/.next/server/app/index.meta +14 -0
- package/.next/server/app/index.rsc +15 -0
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +6 -0
- package/.next/server/app/index.segments/_full.segment.rsc +15 -0
- package/.next/server/app/index.segments/_head.segment.rsc +6 -0
- package/.next/server/app/index.segments/_index.segment.rsc +5 -0
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -0
- package/.next/server/app/page.js +162 -0
- package/.next/server/app/page.js.nft.json +1 -0
- package/.next/server/app/page_client-reference-manifest.js +1 -0
- package/.next/server/app-paths-manifest.json +33 -0
- package/.next/server/chunks/162.js +1 -0
- package/.next/server/chunks/433.js +6 -0
- package/.next/server/chunks/601.js +27 -0
- package/.next/server/chunks/63.js +45 -0
- package/.next/server/chunks/632.js +1 -0
- package/.next/server/chunks/65.js +1 -0
- package/.next/server/chunks/741.js +18 -0
- package/.next/server/chunks/813.js +1 -0
- package/.next/server/functions-config-manifest.json +4 -0
- package/.next/server/interception-route-rewrite-manifest.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -0
- package/.next/server/middleware-manifest.json +6 -0
- package/.next/server/middleware-react-loadable-manifest.js +1 -0
- package/.next/server/next-font-manifest.js +1 -0
- package/.next/server/next-font-manifest.json +1 -0
- package/.next/server/pages/404.html +1 -0
- package/.next/server/pages/500.html +1 -0
- package/.next/server/pages-manifest.json +4 -0
- package/.next/server/prefetch-hints.json +1 -0
- package/.next/server/server-reference-manifest.js +1 -0
- package/.next/server/server-reference-manifest.json +1 -0
- package/.next/server/webpack-runtime.js +1 -0
- package/.next/static/BvG0z8aA5rKvDREWCzBf_/_buildManifest.js +1 -0
- package/.next/static/BvG0z8aA5rKvDREWCzBf_/_ssgManifest.js +1 -0
- package/.next/static/chunks/1966.1560d0f43ac9a41a.js +1 -0
- package/.next/static/chunks/2479.43f5228b4208e28b.js +1 -0
- package/.next/static/chunks/3794-fa2c7d47374be211.js +32 -0
- package/.next/static/chunks/3899.cf10152d8085e352.js +1 -0
- package/.next/static/chunks/4bd1b696-c2f6e0877b6c10aa.js +1 -0
- package/.next/static/chunks/5f4842b5.50bf54b97ff395f3.js +1 -0
- package/.next/static/chunks/7547-9d656d23f0b75f2a.js +1 -0
- package/.next/static/chunks/7918f2c1.3a26cf7b64cb2eff.js +6 -0
- package/.next/static/chunks/8451.cfb7d6db11fbfb19.js +1 -0
- package/.next/static/chunks/app/_global-error/page-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/_not-found/page-cba500a03cba1d1e.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/events/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/agent/describe-image/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/agent/new/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/auth/all-providers/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/auth/login/[provider]/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/auth/providers/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/default-cwd/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/files/[...path]/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/gem-xy/[id]/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/gem-xy/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/home/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/inkos/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/models/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/models-config/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/register-cwd/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/context/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/lock/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/sessions/new/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/sessions/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/skills/install/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/skills/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/skills/search/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/api/tts/synthesize/route-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/app/layout-6c9568b1e18484e3.js +1 -0
- package/.next/static/chunks/app/page-0e8b420d9a738e0f.js +161 -0
- package/.next/static/chunks/ca377847.a378e365b1b60c48.js +1 -0
- package/.next/static/chunks/framework-3052651e402fc2ca.js +1 -0
- package/.next/static/chunks/main-268a9d5ff935d846.js +5 -0
- package/.next/static/chunks/main-app-a115908f58a6cf38.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/global-error-2c0ae34a7b36f2f6.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-7f5e7bebe7a745ed.js +1 -0
- package/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/.next/static/chunks/webpack-a98a562c28a00d6f.js +1 -0
- package/.next/static/css/cb335cfd27b5f824.css +3 -0
- package/.next/static/media/15605e25b523335c-s.woff2 +0 -0
- package/.next/static/media/1a3dce5cfb5f7760-s.woff2 +0 -0
- package/.next/static/media/1cdd02902f937a18-s.woff2 +0 -0
- package/.next/static/media/4c4b3b30b6bcb2be-s.woff2 +0 -0
- package/.next/static/media/641a7b8a5800ee0e-s.woff2 +0 -0
- package/.next/static/media/7deddc85b7ffd1dc-s.p.woff2 +0 -0
- package/.next/static/media/ec14413c594b3356-s.p.woff2 +0 -0
- package/.next/trace +4 -0
- package/.next/trace-build +1 -0
- package/.next/types/app/api/agent/[id]/events/route.ts +351 -0
- package/.next/types/app/api/agent/[id]/route.ts +351 -0
- package/.next/types/app/api/agent/describe-image/route.ts +351 -0
- package/.next/types/app/api/agent/new/route.ts +351 -0
- package/.next/types/app/api/auth/all-providers/route.ts +351 -0
- package/.next/types/app/api/auth/api-key/[provider]/route.ts +351 -0
- package/.next/types/app/api/auth/login/[provider]/route.ts +351 -0
- package/.next/types/app/api/auth/logout/[provider]/route.ts +351 -0
- package/.next/types/app/api/auth/providers/route.ts +351 -0
- package/.next/types/app/api/default-cwd/route.ts +351 -0
- package/.next/types/app/api/files/[...path]/route.ts +351 -0
- package/.next/types/app/api/gem-xy/[id]/route.ts +351 -0
- package/.next/types/app/api/gem-xy/route.ts +351 -0
- package/.next/types/app/api/home/route.ts +351 -0
- package/.next/types/app/api/inkos/route.ts +351 -0
- package/.next/types/app/api/models/route.ts +351 -0
- package/.next/types/app/api/models-config/route.ts +351 -0
- package/.next/types/app/api/register-cwd/route.ts +351 -0
- package/.next/types/app/api/sessions/[id]/context/route.ts +351 -0
- package/.next/types/app/api/sessions/[id]/lock/route.ts +351 -0
- package/.next/types/app/api/sessions/[id]/route.ts +351 -0
- package/.next/types/app/api/sessions/new/route.ts +351 -0
- package/.next/types/app/api/sessions/route.ts +351 -0
- package/.next/types/app/api/skills/install/route.ts +351 -0
- package/.next/types/app/api/skills/route.ts +351 -0
- package/.next/types/app/api/skills/search/route.ts +351 -0
- package/.next/types/app/api/tts/synthesize/route.ts +351 -0
- package/.next/types/app/layout.ts +87 -0
- package/.next/types/app/page.ts +87 -0
- package/.next/types/package.json +1 -0
- package/.next/types/routes.d.ts +99 -0
- package/.next/types/validator.ts +313 -0
- package/README.md +183 -0
- package/bin/pi-web.js +78 -0
- package/electron/main.js +127 -0
- package/next.config.ts +13 -0
- package/package.json +116 -0
- package/public/favicon.ico +0 -0
- package/public/file.svg +1 -0
- package/public/generate_favicon.py +38 -0
- package/public/globe.svg +1 -0
- package/public/icon.png +0 -0
- package/public/next.svg +1 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9900],{9603:(e,t,r)=>{let i;r.d(t,{PPTXViewer:()=>G});var a,o,l,s,n,h,c,u,d,p,g,f,m,y,b=r(6062),S=r(4453),x=r.n(S),w=r(1463);"u">typeof globalThis||("u">typeof window?window:void 0!==r.g?r.g:"u">typeof self&&self);!function(){if(a)return;a=1;class e{constructor(e="Default"){this.category=e,this.logElement=null,this.logHistory=[]}init(){this.logElement=document.getElementById("log")}log(e,t,r,i=null){let a=new Date().toISOString().split("T")[1].split(".")[0],o={timestamp:a,level:e.toUpperCase(),category:t,message:r,data:i};this.logHistory.push(o);let l=`[${t}] ${r}`;if(!new Set(["PPTXSlideRenderer","PPTXProcessor","Thumbnail Debug"]).has(t))switch(e.toLowerCase()){case"error":console.error(l,i);break;case"warn":console.warn(l,i);break;case"info":console.info(l,i);break;case"debug":console.debug(l,i);break;default:console.log(l,i)}if(this.logElement){let o=i?` | ${JSON.stringify(i)}`:"",l=`[${a}] [${e.toUpperCase()}] [${t}] ${r}${o}
|
|
2
|
+
`;this.logElement.textContent+=l,this.logElement.scrollTop=this.logElement.scrollHeight}}debug(e,t,r=null){this.log("debug",e,t,r)}info(e,t,r=null){this.log("info",e,t,r)}warn(e,t,r=null){this.log("warn",e,t,r)}error(e,t,r=null){this.log("error",e,t,r)}trace(e,t,r=null){this.log("trace",e,t,r)}logError(e,t){let r="Unknown error",i={};t&&"object"==typeof t?(r=t.message||t.toString()||"Unknown error",i={stack:t.stack,name:t.name||"Error"}):r="string"==typeof t?t:String(t),this.log("error",e,r,i)}markTiming(e){if("u">typeof window&&window.getGlobalMonitor)window.getGlobalMonitor().start(e,{category:this.category});else if("u">typeof performance&&performance.mark)try{performance.mark(e)}catch(t){console.time(e)}}measureTiming(e){if("u">typeof window&&window.getGlobalMonitor){let t=window.getGlobalMonitor().end(e,{category:this.category});t&&this.log("trace",this.category,`${e} completed in ${Math.round(t.duration)}ms`)}else if("u">typeof performance&&performance.mark)try{performance.measure(e);let t=performance.getEntriesByName(e,"measure");if(t.length>0){let r=Math.round(t[t.length-1].duration);this.log("trace",this.category,`${e} completed in ${r}ms`)}}catch(t){console.timeEnd(e)}}}let t=new e;class r{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(e,t){if(this.steps[e]){this.steps[e].progress=Math.min(100,Math.max(0,t));let r=document.getElementById(`progress${e}`),i=document.getElementById(`step${e}`);r&&(r.style.width=`${this.steps[e].progress}%`),i&&(i.classList.remove("active","processing"),t>=100?i.classList.add("active"):t>0&&i.classList.add("processing"))}}reset(){for(let e in this.steps)this.updateProgress(parseInt(e),0)}}let i=new r;class o{static async readAsArrayBuffer(e,t={}){if(!e||!(e instanceof File||e instanceof Blob))throw Error("Invalid file parameter: must be File or Blob instance");if(0===e.size)throw Error("Cannot read empty file");let{maxSize:r=0x6400000,timeout:i=8e4}=t;if(e.size>r)throw Error(`File too large: ${e.size} bytes (max: ${r} bytes)`);return new Promise((t,r)=>{let a=new window.FileReader,o=setTimeout(()=>{a.abort(),r(Error(`File reading timed out after ${i}ms`))},i);a.onload=e=>{clearTimeout(o);let i=e.target?.result;i instanceof ArrayBuffer?t(i):r(Error("Failed to read file as ArrayBuffer"))},a.onerror=()=>{clearTimeout(o);let e=a.error||Error("Unknown file reading error");r(Error(`Failed to read file: ${e.message}`))},a.onabort=()=>{clearTimeout(o),r(Error("File reading was aborted"))};try{a.readAsArrayBuffer(e)}catch(e){clearTimeout(o),r(Error(`Failed to start file reading: ${e.message}`))}})}static async readAsText(e,t={}){if(!e||!(e instanceof File||e instanceof Blob))throw Error("Invalid file parameter: must be File or Blob instance");let{encoding:r="UTF-8",maxSize:i=0x3200000,timeout:a=8e4,validateText:o=!0}=t;if(e.size>i)throw Error(`File too large: ${e.size} bytes (max: ${i} bytes)`);return new Promise((t,i)=>{let l=new window.FileReader,s=setTimeout(()=>{l.abort(),i(Error(`File reading timed out after ${a}ms`))},a);l.onload=e=>{clearTimeout(s);let r=e.target?.result;if("string"==typeof r){if(o&&r.includes("�"))return void i(Error("File contains invalid characters - may not be a text file"));t(r)}else i(Error("Failed to read file as text"))},l.onerror=()=>{clearTimeout(s);let e=l.error||Error("Unknown file reading error");i(Error(`Failed to read file as text: ${e.message}`))},l.onabort=()=>{clearTimeout(s),i(Error("File reading was aborted"))};try{l.readAsText(e,r)}catch(e){clearTimeout(s),i(Error(`Failed to start file reading: ${e.message}`))}})}static async readAsDataURL(e,t={}){if(!e||!(e instanceof File||e instanceof Blob))throw Error("Invalid file parameter: must be File or Blob instance");let{maxSize:r=0xa00000,timeout:i=8e4}=t;if(e.size>r)throw Error(`File too large for Data URL: ${e.size} bytes (max: ${r} bytes)`);return new Promise((t,r)=>{let a=new window.FileReader,o=setTimeout(()=>{a.abort(),r(Error(`File reading timed out after ${i}ms`))},i);a.onload=e=>{clearTimeout(o);let i=e.target?.result;"string"==typeof i&&i.startsWith("data:")?t(i):r(Error("Failed to read file as Data URL"))},a.onerror=()=>{clearTimeout(o);let e=a.error||Error("Unknown file reading error");r(Error(`Failed to read file as Data URL: ${e.message}`))},a.onabort=()=>{clearTimeout(o),r(Error("File reading was aborted"))};try{a.readAsDataURL(e)}catch(e){clearTimeout(o),r(Error(`Failed to start file reading: ${e.message}`))}})}static async readMultipleFiles(e,t="arrayBuffer",r={}){if(!Array.isArray(e)||0===e.length)throw Error("Invalid files parameter: must be non-empty array");let{onProgress:i=null,maxConcurrent:a=3,...o}=r,l=this[`readAs${t.charAt(0).toUpperCase()+t.slice(1)}`];if(!l)throw Error(`Invalid read type: ${t}`);let s=[],n=0;for(let t=0;t<e.length;t+=a){let r=e.slice(t,t+a).map(async(r,a)=>{try{let s=await l.call(this,r,o);return n++,i&&i({completed:n,total:e.length,progress:n/e.length*100,currentFile:r.name||`File ${t+a+1}`}),s}catch(o){throw n++,i&&i({completed:n,total:e.length,progress:n/e.length*100,currentFile:r.name||`File ${t+a+1}`,error:o.message}),o}}),h=await Promise.all(r);s.push(...h)}return s}}class l{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(e,t={}){let{context:r="Unknown",severity:i=this.SEVERITY_LEVELS.MEDIUM,displayToUser:a=!0,logToConsole:o=!0,throwAfterHandle:l=!1,customHandler:s=null}=t,n=this.normalizeError(e,r);if(o&&this.logError(n,i),a&&this.displayError(n,i),s&&"function"==typeof s)try{s(n,i)}catch(e){console.error("Error in custom error handler:",e)}if(l)throw e instanceof Error?e:Error(n.message);return n}static normalizeError(e,t){let r="Unknown error occurred",i=null,a=this.ERROR_TYPES.UNKNOWN;return e instanceof Error?(r=e.message||"Error occurred",i=e.stack,a=e.name||this.categorizeError(e)):"string"==typeof e?r=e:e&&"object"==typeof e?(r=e.message||e.toString()||"Object error",i=e.stack,a=e.name||this.ERROR_TYPES.UNKNOWN):r=String(e),{message:r,context:t,stack:i,name:a,timestamp:new Date().toISOString(),originalError:e,userAgent:navigator?.userAgent||"Unknown"}}static categorizeError(e){let t=e.message?.toLowerCase()||"";return t.includes("validation")||t.includes("invalid")?this.ERROR_TYPES.VALIDATION:t.includes("file")||t.includes("read")||t.includes("write")?this.ERROR_TYPES.FILE_IO:t.includes("parse")||t.includes("xml")||t.includes("json")?this.ERROR_TYPES.PARSING:t.includes("render")||t.includes("canvas")||t.includes("draw")?this.ERROR_TYPES.RENDERING:t.includes("network")||t.includes("fetch")||t.includes("load")?this.ERROR_TYPES.NETWORK:t.includes("timeout")||t.includes("timed out")?this.ERROR_TYPES.TIMEOUT:t.includes("memory")||t.includes("allocation")?this.ERROR_TYPES.MEMORY:this.ERROR_TYPES.UNKNOWN}static logError(e,t){let r=`[${e.context}] ${e.message}`;switch(t){case this.SEVERITY_LEVELS.LOW:console.info("\uD83D\uDD35",r,e);break;case this.SEVERITY_LEVELS.MEDIUM:console.warn("\uD83D\uDFE1",r,e);break;case this.SEVERITY_LEVELS.HIGH:console.error("\uD83D\uDD34",r,e);break;case this.SEVERITY_LEVELS.CRITICAL:console.error("\uD83D\uDCA5",r,e),e.stack&&console.error("Stack trace:",e.stack);break;default:console.log(r,e)}}static displayError(e,t){let r=document.getElementById("output");if(!r)return;let i=document.createElement("div");i.className=`error error--${t}`;let a=document.createElement("div");a.className="error__header",a.innerHTML=`
|
|
3
|
+
<span class="error__icon">${this.getSeverityIcon(t)}</span>
|
|
4
|
+
<span class="error__title">Error in ${e.context}</span>
|
|
5
|
+
<span class="error__type">${e.name}</span>
|
|
6
|
+
`;let o=document.createElement("div");o.className="error__message",o.textContent=e.message;let l=document.createElement("div");l.className="error__time",l.textContent=new Date(e.timestamp).toLocaleTimeString(),i.appendChild(a),i.appendChild(o),i.appendChild(l);let s=document.createElement("button");s.className="error__dismiss",s.innerHTML="\xd7",s.onclick=()=>i.remove(),i.appendChild(s),i.style.transform="translateY(-100%)",i.style.transition="transform 0.3s ease-in-out",r.insertBefore(i,r.firstChild),requestAnimationFrame(()=>{i.style.transform="translateY(0)"});let n=this.getAutoDismissTime(t);n>0&&setTimeout(()=>{i.parentNode&&(i.style.transform="translateY(-100%)",setTimeout(()=>i.remove(),300))},n)}static getSeverityIcon(e){switch(e){case this.SEVERITY_LEVELS.LOW:return"ℹ️";case this.SEVERITY_LEVELS.MEDIUM:return"⚠️";case this.SEVERITY_LEVELS.HIGH:return"❌";case this.SEVERITY_LEVELS.CRITICAL:return"\uD83D\uDCA5";default:return"❓"}}static getAutoDismissTime(e){switch(e){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(e,t={}){let{name:r=this.ERROR_TYPES.UNKNOWN,context:i="Unknown",cause:a=null,code:o=null,details:l=null}=t,s=Error(e);return s.name=r,s.context=i,s.timestamp=new Date().toISOString(),a&&(s.cause=a),o&&(s.code=o),l&&(s.details=l),s}}class s{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:0x7fffffff,MIN_EMU:-0x80000000,MAX_PIXELS:32767,MAX_MM:59652,MIN_DPI:1,MAX_DPI:600};static validateInput(e,t,r={}){if("number"!=typeof e||!isFinite(e))throw l.createError(`Invalid ${t} value: must be a finite number`,{name:l.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"});let{min:i=-1/0,max:a=1/0}=r;if(e<i||e>a)throw l.createError(`${t} value out of range: ${e} (valid range: ${i} to ${a})`,{name:l.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"});return e}static emuToMM(e){return this.validateInput(e,"EMU",{min:this.VALIDATION.MIN_EMU,max:this.VALIDATION.MAX_EMU})/this.UNITS.EMU_PER_MM}static mmToEMU(e){let t=this.validateInput(e,"MM",{min:-this.VALIDATION.MAX_MM,max:this.VALIDATION.MAX_MM})*this.UNITS.EMU_PER_MM;return Math.max(this.VALIDATION.MIN_EMU,Math.min(this.VALIDATION.MAX_EMU,Math.round(t)))}static emuToPoints(e){return this.validateInput(e,"EMU",{min:this.VALIDATION.MIN_EMU,max:this.VALIDATION.MAX_EMU})/this.UNITS.EMU_PER_POINT}static pointsToEMU(e){let t=this.validateInput(e,"Points",{min:-3e4,max:3e4})*this.UNITS.EMU_PER_POINT;return Math.max(this.VALIDATION.MIN_EMU,Math.min(this.VALIDATION.MAX_EMU,Math.round(t)))}static emuToPixels(e,t=96){let r=this.validateInput(e,"EMU",{min:this.VALIDATION.MIN_EMU,max:this.VALIDATION.MAX_EMU}),i=this.validateInput(t,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});return Math.round(r/this.UNITS.EMU_PER_INCH*i)}static pixelsToEMU(e,t=96){let r=this.validateInput(e,"Pixels",{min:-this.VALIDATION.MAX_PIXELS,max:this.VALIDATION.MAX_PIXELS})/this.validateInput(t,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI})*this.UNITS.EMU_PER_INCH;return Math.max(this.VALIDATION.MIN_EMU,Math.min(this.VALIDATION.MAX_EMU,Math.round(r)))}static mmToPixels(e,t=96){let r=this.validateInput(e,"MM",{min:-this.VALIDATION.MAX_MM,max:this.VALIDATION.MAX_MM}),i=this.validateInput(t,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});return Math.round(r*this.UNITS.INCHES_PER_MM*i)}static pixelsToMM(e,t=96){return this.validateInput(e,"Pixels",{min:-this.VALIDATION.MAX_PIXELS,max:this.VALIDATION.MAX_PIXELS})/this.validateInput(t,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI})*this.UNITS.MM_PER_INCH}static convert(e,t,r,i=96){let a;if(t===r)return e;let o=t.toLowerCase(),s=r.toLowerCase();switch(o){case"emu":a=e;break;case"mm":a=this.mmToEMU(e);break;case"pixels":case"px":a=this.pixelsToEMU(e,i);break;case"points":case"pt":a=this.pointsToEMU(e);break;case"inches":case"in":a=Math.round(this.validateInput(e,"Inches",{min:-100,max:100})*this.UNITS.EMU_PER_INCH);break;default:throw l.createError(`Unsupported source unit: ${t}`,{name:l.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"})}switch(s){case"emu":return a;case"mm":return this.emuToMM(a);case"pixels":case"px":return this.emuToPixels(a,i);case"points":case"pt":return this.emuToPoints(a);case"inches":case"in":return a/this.UNITS.EMU_PER_INCH;default:throw l.createError(`Unsupported target unit: ${r}`,{name:l.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"})}}static convertBatch(e,t,r,i=96){if(!Array.isArray(e))throw l.createError("Values must be an array",{name:l.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"});return e.map(e=>this.convert(e,t,r,i))}static getConversionFactor(e,t,r=96){return this.convert(1,e,t,r)}}class n{static decodeXMLEntities(e){if(!e)return e;let t={"&":"&","<":"<",">":">",""":'"',"'":"'"};return e.replace(/&[a-zA-Z0-9#]+;/g,e=>t[e]||e)}static encodeXMLEntities(e){return e?e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):e}static extractNamespace(e){let t=e.indexOf(":");return -1!==t?e.substring(0,t):""}static extractLocalName(e){let t=e.indexOf(":");return -1!==t?e.substring(t+1):e}}class h{static getAttributeValue(e,t){return e.getAttribute?e.getAttribute(t):null}static getChildElements(e){return e.children?Array.from(e.children):[]}static getElementByTagName(e,t){if(!e.getElementsByTagName)return null;let r=e.getElementsByTagName(t);return r.length>0?r[0]:null}static getElementsByTagName(e,t){return e.getElementsByTagName?Array.from(e.getElementsByTagName(t)):[]}static getTextContent(e){return e.textContent||e.innerText||""}}class c{static easeInOut(e){return e<.5?2*e*e:-1+(4-2*e)*e}static animate(e,t,r=null){let i=performance.now();requestAnimationFrame(function a(o){let l=Math.min((o-i)/e,1);t(l),l<1?requestAnimationFrame(a):r&&r()})}}document.addEventListener("DOMContentLoaded",function(){t.init()});let u=null;if("u">typeof window)try{window.PerformanceMonitor&&(u=new window.PerformanceMonitor({enabled:!0,collectMemoryData:!0,enableConsoleReports:!1,maxHistoryEntries:500}),window.performanceMonitor=u)}catch(e){}class d extends e{constructor(e){super(e),this.performanceMonitor=u}startPerformance(e,t={}){this.performanceMonitor&&this.performanceMonitor.start(e,{...t,category:this.category}),this.markTiming(e)}endPerformance(e,t={}){if(this.performanceMonitor){let r=this.performanceMonitor.end(e,{...t,category:this.category});if(r){let t=Math.round(100*r.duration)/100;this.trace(this.category,`${e} completed in ${t}ms`,{duration:t,memoryUsage:r.memorySnapshot?.jsHeapSize}),t>1e3&&this.warn(this.category,`Slow operation detected: ${e} took ${t}ms`)}}this.measureTiming(e)}measureSync(e,t,r={}){if(this.performanceMonitor){let{result:i,measure:a}=this.performanceMonitor.measure(e,t,{...r,category:this.category});if(a){let t=Math.round(100*a.duration)/100;this.trace(this.category,`${e} completed in ${t}ms`)}return i}this.startPerformance(e,r);try{let i=t();return this.endPerformance(e,r),i}catch(t){throw this.endPerformance(e,{...r,error:!0}),t}}async measureAsync(e,t,r={}){if(this.performanceMonitor){let{result:i,measure:a}=await this.performanceMonitor.measureAsync(e,t,{...r,category:this.category});if(a){let t=Math.round(100*a.duration)/100;this.trace(this.category,`${e} completed in ${t}ms`)}return i}this.startPerformance(e,r);try{let i=await t();return this.endPerformance(e,r),i}catch(t){throw this.endPerformance(e,{...r,error:!0}),t}}getPerformanceStats(){if(!this.performanceMonitor)return null;let e=this.performanceMonitor.getHistory().filter(e=>e.startMetadata?.category===this.category||e.endMetadata?.category===this.category);if(0===e.length)return{category:this.category,operations:0};let t=e.reduce((e,t)=>e+t.duration,0),r=t/e.length,i=e.reduce((e,t)=>t.duration>e.duration?t:e),a=e.reduce((e,t)=>t.duration<e.duration?t:e);return{category:this.category,operations:e.length,totalDuration:Math.round(t),averageDuration:Math.round(100*r)/100,slowestOperation:{name:i.name,duration:Math.round(100*i.duration)/100},fastestOperation:{name:a.name,duration:Math.round(100*a.duration)/100}}}}let p=new d;"u">typeof window&&(window.Logger=e,window.EnhancedLogger=d,window.ProgressTracker=r,window.FileReader=o,window.ErrorHandler=l,window.CoordinateTransform=s,window.StringUtils=n,window.DOMUtils=h,window.AnimationUtils=c,window.logger=t,window.enhancedLogger=p,window.progressTracker=i,u&&(window.performanceMonitor=u))}();var C={exports:{}};C.exports,!function(){if(o)return C.exports;o=1;class e{constructor(e={}){this.options=this._validateOptions(e);try{this.logger="u">typeof Logger?new Logger("ChartFontConfig"):this._createFallbackLogger()}catch(e){this.logger=this._createFallbackLogger()}this.initializeDefaults(),this.initializeScaling()}initializeDefaults(){this.defaults={global:{fontFamily:"Calibri",fontSize:11,bold:!1,italic:!1,color:{r:0,g:0,b:0}},title:{fontFamily:"Calibri",fontSize:18,bold:!1,italic:!1,color:{r:0,g:0,b:0}},subtitle:{fontFamily:"Calibri",fontSize:14,bold:!1,italic:!1,color:{r:100,g:100,b:100}},axisTitle:{fontFamily:"Calibri",fontSize:12,bold:!0,italic:!1,color:{r:68,g:68,b:68}},axisLabels:{fontFamily:"Calibri",fontSize:11,bold:!1,italic:!1,color:{r:68,g:68,b:68}},legend:{fontFamily:"Calibri",fontSize:11,bold:!1,italic:!1,color:{r:60,g:60,b:60}},dataLabels:{fontFamily:"Calibri",fontSize:9,bold:!0,italic:!1,color:{r:50,g:50,b:50}},tickMarks:{fontFamily:"Calibri",fontSize:10,bold:!1,italic:!1,color:{r:68,g:68,b:68}}}}initializeScaling(){this.scaling={enabled:!1!==this.options.enableResponsiveScaling,baseDimensions:{width:400,height:300},scaleFactors:{min:.7,max:1.5},dpiSupport:{enabled:!1!==this.options.enableDpiScaling,baseDpi:96,currentDpi:this._getCurrentDpi()}}}getFont(e,t={},r={},i={}){try{let a=this.defaults[e]||this.defaults.global,o=this._applyPptxOverrides(a,t),l=this._applyCustomOverrides(o,r),s=this._applyScaling(l,i),n=this._normalizeFontConfig(s);return this.logger.log("debug",this.constructor.name,`Font resolved for ${e}:`,{base:a,pptx:t,custom:r,final:n}),n}catch(t){return this.logger.logError(this.constructor.name,`Error resolving font for ${e}:`,t),this._getFallbackFont()}}_applyPptxOverrides(e,t){let r={...e};return t&&"object"==typeof t&&(t.fontFamily?r.fontFamily=t.fontFamily:t.family?r.fontFamily=t.family:t.typeface&&(r.fontFamily=t.typeface),void 0!==t.fontSize?r.fontSize=this._convertPptxFontSize(t.fontSize):void 0!==t.size?r.fontSize=this._convertPptxFontSize(t.size):void 0!==t.sz&&(r.fontSize=this._convertPptxFontSize(t.sz,"hundredths")),void 0!==t.bold?r.bold=!!t.bold:void 0!==t.b&&(r.bold="0"!==t.b&&!1!==t.b),void 0!==t.italic?r.italic=!!t.italic:void 0!==t.i&&(r.italic="0"!==t.i&&!1!==t.i),t.color&&(r.color=this._normalizeColor(t.color))),r}_applyCustomOverrides(e,t){let r={...e};return t&&"object"==typeof t&&(t.fontFamily&&(r.fontFamily=t.fontFamily),t.family&&(r.fontFamily=t.family),void 0!==t.fontSize?r.fontSize=Number(t.fontSize):void 0!==t.size&&(r.fontSize=Number(t.size)),void 0!==t.bold&&(r.bold=!!t.bold),void 0!==t.italic&&(r.italic=!!t.italic),t.color&&(r.color=this._normalizeColor(t.color))),r}_applyScaling(e,t){let r={...e};if(!this.scaling.enabled||!t.chartWidth||!t.chartHeight)return r;try{let i=t.chartWidth/this.scaling.baseDimensions.width,a=t.chartHeight/this.scaling.baseDimensions.height,o=Math.max(this.scaling.scaleFactors.min,Math.min(this.scaling.scaleFactors.max,(i+a)/2)),l=1;this.scaling.dpiSupport.enabled&&t.dpi?l=t.dpi/this.scaling.dpiSupport.baseDpi:this.scaling.dpiSupport.enabled&&(l=this.scaling.dpiSupport.currentDpi/this.scaling.dpiSupport.baseDpi);let s=e.fontSize||11,n=Math.round(s*o*l);r.fontSize=Math.max(8,n),this.logger.log("debug",this.constructor.name,"Font scaling applied:",{original:s,dimensionScale:o,dpiScale:l,final:r.fontSize})}catch(e){this.logger.log("warn",this.constructor.name,"Error applying font scaling:",e)}return r}_convertPptxFontSize(e,t="points"){let r=Number(e);if(isNaN(r))return 11;switch(t){case"hundredths":return Math.max(6,Math.round(r/100));case"emu":return Math.max(6,Math.round(r/12700));default:return Math.max(6,Math.round(r))}}_normalizeColor(e){if(!e)return{r:0,g:0,b:0};if(void 0!==e.r&&void 0!==e.g&&void 0!==e.b)return{r:Math.max(0,Math.min(255,Number(e.r))),g:Math.max(0,Math.min(255,Number(e.g))),b:Math.max(0,Math.min(255,Number(e.b)))};if("string"==typeof e&&e.startsWith("#")){let t=e.slice(1);if(6===t.length)return{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16)}}if("string"==typeof e&&e.startsWith("rgb")){let t=e.match(/\d+/g);if(t&&t.length>=3)return{r:Number(t[0]),g:Number(t[1]),b:Number(t[2])}}return{r:0,g:0,b:0}}_normalizeFontConfig(e){return{fontFamily:e.fontFamily||e.family||"Calibri",fontSize:Math.max(6,Math.min(120,Number(e.fontSize||e.size||11))),bold:!!e.bold,italic:!!e.italic,color:this._normalizeColor(e.color)}}_getFallbackFont(){return{fontFamily:"Arial, sans-serif",fontSize:11,bold:!1,italic:!1,color:{r:0,g:0,b:0}}}_getCurrentDpi(){try{let e="u">typeof window&&window.devicePixelRatio||1;return 96*e}catch(e){return 96}}_createFallbackLogger(){return{debug:(...e)=>{},info:(...e)=>{},warn:(...e)=>{},error:(...e)=>{}}}_validateOptions(e){return{enableResponsiveScaling:!1!==e.enableResponsiveScaling,enableDpiScaling:!1!==e.enableDpiScaling,enablePptxOverrides:!1!==e.enablePptxOverrides,logLevel:e.logLevel||"warn",...e}}setElementDefault(e,t){this.defaults[e]?(this.defaults[e]={...this.defaults[e],...this._normalizeFontConfig(t)},this.logger.log("info",this.constructor.name,`Updated default font for ${e}`)):this.logger.log("warn",this.constructor.name,`Unknown element type: ${e}`)}getElementTypes(){return Object.keys(this.defaults)}toCssString(e){let t=this._normalizeFontConfig(e),r=t.italic?"italic ":"",i=t.bold?"bold ":"";return`${r}${i}${t.fontSize}px ${t.fontFamily}`}toColorString(e){let t=this._normalizeColor(e.color);return`rgb(${t.r}, ${t.g}, ${t.b})`}}"u">typeof window&&(window.ChartFontConfig=e),C.exports&&(C.exports={ChartFontConfig:e}),C.exports}();!function(){if(l)return;async function e(){if("u">typeof window&&window.JSZip&&"function"==typeof window.JSZip.loadAsync)return window.JSZip;if("u">typeof globalThis&&globalThis.JSZip&&"function"==typeof globalThis.JSZip.loadAsync)return globalThis.JSZip;try{let e=r(4453);if(e&&"function"==typeof e.loadAsync)return e;if(e&&e.default&&"function"==typeof e.default.loadAsync)return e.default}catch(e){}if("u">typeof document&&(await new Promise((e,t)=>{let r=document.createElement("script");r.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js",r.onload=()=>e(),r.onerror=()=>t(Error("Failed to load JSZip")),document.head.appendChild(r)}),window.JSZip))return window.JSZip;throw Error("JSZip is not available")}l=1;class t{constructor(){this.engine=null,this.files={},this.isModuleInit=!0,"u">typeof Logger?this.logger=new Logger("ZLib"):"u">typeof window&&window.Logger?this.logger=new window.Logger("ZLib"):"u">typeof globalThis&&globalThis.Logger?this.logger=new globalThis.Logger("ZLib"):this.logger={info:()=>{},debug:()=>{},warn:()=>{},error:()=>{},log:()=>{},logError:()=>{}},this.isOpen=!1,this.lastError=null}validateInput(e,t){return null==e?(this.lastError=Error(`${t}: Input data is null or undefined`),!1):e instanceof ArrayBuffer||e instanceof Uint8Array||e instanceof Blob?0!==e.byteLength&&(void 0===e.size||0!==e.size)||(this.lastError=Error(`${t}: Input data is empty`),!1):(this.lastError=Error(`${t}: Invalid data type. Expected ArrayBuffer, Uint8Array, or Blob`),!1)}async open(t){try{if(this.isOpen=!1,this.lastError=null,!this.validateInput(t,"open"))return this.logger.logError("ZLib","Failed to open ZIP:",this.lastError.message),!1;let r=await e(),i=t;if(t instanceof Uint8Array&&(i=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)),this.engine=await r.loadAsync(i),!this.engine)return this.lastError=Error("Failed to create JSZip instance"),this.logger.logError("ZLib","Failed to open ZIP:",this.lastError.message),!1;this.files={};let a=0;return this.engine.forEach((e,t)=>{!t.dir&&(this.files[e]=null,a++)}),0===a&&(this.lastError=Error("ZIP file contains no readable files"),this.logger.log("warn","ZLib","Opened ZIP file has no readable files")),this.isOpen=!0,!0}catch(e){return this.lastError=e,this.isOpen=!1,this.logger.logError("ZLib","Failed to open ZIP:",e.message),e.message.includes("End of central directory not found")?this.logger.logError("ZLib","Invalid ZIP file: corrupted or not a ZIP file"):e.message.includes("encrypted")?this.logger.logError("ZLib","Cannot open encrypted ZIP files"):e.message.includes("Unsupported compression")&&this.logger.logError("ZLib","ZIP file uses unsupported compression method"),!1}}validatePath(e,t){return"string"!=typeof e?(this.lastError=Error(`${t}: Path must be a string`),!1):0===e.length?(this.lastError=Error(`${t}: Path cannot be empty`),!1):!(e.includes("..")||e.includes("//"))||(this.lastError=Error(`${t}: Invalid path contains dangerous patterns`),!1)}checkReady(e){return!!this.isOpen&&!!this.engine||(this.lastError=Error(`${e}: ZIP archive is not open`),!1)}async getFile(e){try{if(!this.checkReady("getFile"))return this.logger.logError("ZLib","Cannot get file:",this.lastError.message),null;if(!this.validatePath(e,"getFile"))return this.logger.logError("ZLib","Invalid file path:",this.lastError.message),null;let t=this.engine.file(e);if(!t&&e.startsWith("/")&&(t=this.engine.file(e.substring(1))),!t)return this.logger.log("warn","ZLib",`File not found in ZIP: ${e}`),null;let r=await t.async("arraybuffer");if(!r||0===r.byteLength)return this.logger.log("warn","ZLib",`File is empty: ${e}`),new Uint8Array(0);return new Uint8Array(r)}catch(t){return this.lastError=t,this.logger.logError("ZLib",`Failed to get file ${e}:`,t.message),null}}async getFileText(e){try{if(!this.checkReady("getFileText"))return this.logger.logError("ZLib","Cannot get file text:",this.lastError.message),null;if(!this.validatePath(e,"getFileText"))return this.logger.logError("ZLib","Invalid file path:",this.lastError.message),null;let t=this.engine.file(e);if(!t&&e.startsWith("/")&&(t=this.engine.file(e.substring(1))),!t)return this.logger.log("warn","ZLib",`File not found in ZIP: ${e}`),null;let r=await t.async("text");if("string"!=typeof r)return this.logger.log("warn","ZLib",`File ${e} did not return valid text content`),null;return r}catch(t){return this.lastError=t,this.logger.logError("ZLib",`Failed to get file text ${e}:`,t.message),t.message.includes("binary")?this.logger.logError("ZLib",`File ${e} appears to be binary, cannot read as text`):t.message.includes("encoding")&&this.logger.logError("ZLib",`File ${e} has encoding issues`),null}}getPaths(){try{if(!this.checkReady("getPaths"))return this.logger.logError("ZLib","Cannot get paths:",this.lastError.message),[];return this.engine&&this.engine.files?Object.keys(this.engine.files):Object.keys(this.files)}catch(e){return this.lastError=e,this.logger.logError("ZLib","Failed to get file paths:",e.message),[]}}fileExists(e){try{if(!this.validatePath(e,"fileExists")||!this.checkReady("fileExists"))return!1;return this.files.hasOwnProperty(e)}catch(t){return this.lastError=t,this.logger.logError("ZLib",`Error checking file existence for ${e}:`,t.message),!1}}getFileSize(e){try{if(!this.validatePath(e,"getFileSize")||!this.checkReady("getFileSize"))return -1;let t=this.engine.file(e);if(!t)return -1;return t._data?t._data.uncompressedSize:0}catch(t){return this.lastError=t,this.logger.logError("ZLib",`Error getting file size for ${e}:`,t.message),-1}}getLastError(){return this.lastError}close(){try{this.engine&&(this.engine=null),this.files={},this.isOpen=!1,this.lastError=null}catch(e){this.logger.logError("ZLib","Error during ZIP cleanup:",e.message)}}async getFileData(e){try{if(!this.checkReady("getFileData")||!this.validatePath(e,"getFileData"))throw this.lastError;let t=e.startsWith("/")?e.substring(1):e,r=this.engine.file(t);if(!r)throw Error(`File not found: ${e}`);let i=await r.async("arraybuffer");if(!i)throw Error(`Failed to read file data: ${e}`);return i}catch(t){throw this.lastError=t,this.logger.logError("ZLib",`Failed to get file data for ${e}:`,t.message),Error(`Failed to extract file data: ${e} - ${t.message}`)}}getStats(){try{if(!this.checkReady("getStats"))return{isOpen:!1,fileCount:0,totalSize:0,error:this.lastError?.message};let e=Object.keys(this.files),t=0;return e.forEach(e=>{let r=this.getFileSize(e);r>0&&(t+=r)}),{isOpen:this.isOpen,fileCount:e.length,totalSize:t,files:e,lastError:this.lastError?.message||null}}catch(e){return this.lastError=e,this.logger.logError("ZLib","Error getting archive stats:",e.message),{isOpen:!1,fileCount:0,totalSize:0,error:e.message}}}}class i{constructor(e){this.zip=e,this.parts={},this.contentTypes={},this.relationships={}}async initialize(){let e=await this.zip.getFileText("[Content_Types].xml");e&&this.parseContentTypes(e);let t=await this.zip.getFileText("_rels/.rels");t&&(this.relationships[""]=this.parseRelationships(t));let r=this.zip.getPaths();for(let e of r)if(e.startsWith("_rels/")&&e.endsWith(".rels")&&"_rels/.rels"!==e){let t=e.match(/^(.+)\/_rels\/(.+)\.rels$/);if(t){let r=t[1],i=t[2],a=`/${r}/${i}`,o=await this.zip.getFileText(e);o&&(this.relationships[a]=this.parseRelationships(o))}}for(let e of r)if(!e.startsWith("_rels/")&&"[Content_Types].xml"!==e){let t=`/${e}`,r=this.getContentType(t);this.parts[t]=new a(this,t,r)}}parseContentTypes(e){let t=new DOMParser().parseFromString(e,"text/xml"),r=e=>{let r=t.getElementsByTagName("*"),i=[];for(let t=0;t<r.length;t++)r[t].localName===e&&i.push(r[t]);return i};r("Default").forEach(e=>{let t=e.getAttribute("Extension"),r=e.getAttribute("ContentType");t&&r&&(this.contentTypes[`ext:${t}`]=r)}),r("Override").forEach(e=>{let t=e.getAttribute("PartName"),r=e.getAttribute("ContentType");t&&r&&(this.contentTypes[t]=r)})}parseRelationships(e){let t=new DOMParser().parseFromString(e,"text/xml"),r={};return(e=>{let r=t.getElementsByTagName("*"),i=[];for(let t=0;t<r.length;t++)r[t].localName===e&&i.push(r[t]);return i})("Relationship").forEach(e=>{let t=e.getAttribute("Id"),i=e.getAttribute("Type"),a=e.getAttribute("Target");t&&(r[t]={type:i,target:a,targetMode:e.getAttribute("TargetMode")||"Internal"})}),r}getContentType(e){if(this.contentTypes[e])return this.contentTypes[e];let t=e.split(".").pop();return t&&this.contentTypes[`ext:${t}`]?this.contentTypes[`ext:${t}`]:"application/octet-stream"}getPartByRelationshipType(e){for(let t of Object.values(this.relationships[""]||{}))if(t.type===e){let e=t.target.startsWith("/")?t.target:`/${t.target}`;return this.parts[e]}return null}getPartByUri(e){return this.parts[e]}}class a{constructor(e,t,r){this.package=e,this.uri=t,this.contentType=r,this._content=null}async getDocumentContent(){if(null===this._content){let e=this.uri.startsWith("/")?this.uri.substring(1):this.uri;this._content=await this.package.zip.getFileText(e)}return this._content}async getRelationships(){if(this.package.relationships[this.uri])return this.package.relationships[this.uri];let e=this.uri.replace(/\/([^\/]+)$/,"/_rels/$1.rels"),t=e.startsWith("/")?e.substring(1):e,r=await this.package.zip.getFileText(t);return r?this.package.parseRelationships(r):{}}}let o={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"}};"u">typeof window&&(window.ZLib=t,window.OpenXmlPackage=i,window.OpenXmlPart=a,window.OpenXmlTypes=o),"u">typeof globalThis&&(globalThis.ZLib=t,globalThis.OpenXmlPackage=i,globalThis.OpenXmlPart=a,globalThis.OpenXmlTypes=o)}();!function(){if(!s){s=1;class e{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(e,t){this.slideMasterRels.set(e,t),this.mastersMap[e]=t,this.masterLayoutMap.has(e)||this.masterLayoutMap.set(e,[])}registerSlideLayout(e,t,r){this.slideLayoutRels.set(e,t),this.layoutsMap[e]=t,r&&(t.masterId=r,this.masterLayoutMap.has(r)||this.masterLayoutMap.set(r,[]),this.masterLayoutMap.get(r).push(e))}getSlideMaster(e){return this.slideMasterRels.get(e)}getSlideLayout(e){return this.slideLayoutRels.get(e)}getLayoutsForMaster(e){return(this.masterLayoutMap.get(e)||[]).map(e=>this.getSlideLayout(e)).filter(Boolean)}loadDataLinks(){return this.imageMap}generateSmartArts(){return this.smartarts}}class t{constructor(e,t,r){this.xml=e,this.part=t,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");let e=this.doc.querySelector("parsererror");if(e)throw Error("XML parsing failed: "+e.textContent);return this.doc}catch(e){return null}}parseSlideMaster(e){this.doc||this.parse();let t=this.doc.documentElement;return t&&"sldMaster"===t.localName?{id:e,type:"slideMaster",name:this.getAttributeValue(t,"name")||`Master ${e}`,preserve:"true"===this.getAttributeValue(t,"preserve"),cSld:this.parseCommonSlideData(t),clrMap:this.parseColorMap(t),txStyles:this.parseTextStyles(t),sldLayoutLst:[],themeId:this.extractThemeId(t),hf:this.parseHeaderFooter(t),timing:this.parseTiming(t),transition:this.parseTransition(t)}:null}parseSlideLayout(e,t){this.doc||this.parse();let r=this.doc.documentElement;return r&&"sldLayout"===r.localName?{id:e,masterId:t,type:"slideLayout",name:this.getAttributeValue(r,"name")||`Layout ${e}`,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)}:null}parseCommonSlideData(e){let t=this.getChildElement(e,"cSld");return t?{name:this.getAttributeValue(t,"name")||"",bg:this.parseBackground(t),spTree:this.parseShapeTree(t)}:{name:"",bg:null,spTree:[]}}parseShapeTree(e){let t=this.getChildElement(e,"spTree");if(!t)return[];let r=[],i=t.children;for(let e=0;e<i.length;e++){let t=i[e],a=this.parseShape(t);a&&r.push(a)}return r}parseShape(e){switch(e.localName){case"sp":return this.parseRegularShape(e);case"pic":return this.parsePictureShape(e);case"grpSp":return this.parseGroupShape(e);case"cxnSp":return this.parseConnectorShape(e);case"graphicFrame":return this.parseGraphicFrame(e);default:return null}}parseRegularShape(e){let t=this.parsePlaceholder(e);return{type:"sp",id:this.getAttributeValue(e,"id"),name:this.getShapeName(e),properties:this.parseShapeProperties(e),textBody:this.parseTextBody(e),style:this.parseShapeStyle(e),placeholder:t,isPlaceholder:!!t}}getLayoutType(e){let t=this.getAttributeValue(e,"type");if(t)return t;let r=this.getChildElement(e,"cSld");if(r){let e=this.getChildElement(r,"spTree");if(e){let t=this.getPlaceholderTypes(e);return this.inferLayoutType(t)}}return"blank"}getPlaceholderTypes(e){let t=[],r=e.children;for(let e=0;e<r.length;e++){let i=r[e],a=this.parsePlaceholder(i);a&&t.push(a.type)}return t}inferLayoutType(e){return e.includes("title")&&e.includes("body")?"titleAndContent":e.includes("title")?"titleOnly":e.includes("body")?"contentOnly":0===e.length?"blank":"custom"}parsePlaceholder(e){let t=this.getChildElement(e,"nvSpPr")||this.getChildElement(e,"nvPicPr")||this.getChildElement(e,"nvGrpSpPr");if(!t)return null;let r=this.getChildElement(t,"nvPr");if(!r)return null;let i=this.getChildElement(r,"ph");if(!i)return null;let a=this.getAttributeValue(i,"idx"),o=null==a||isNaN(parseInt(a,10))?void 0:parseInt(a,10);return{type:this.getAttributeValue(i,"type")||"obj",idx:o,orient:this.getAttributeValue(i,"orient"),sz:this.getAttributeValue(i,"sz")}}parseTextStyles(e){let t=this.getChildElement(e,"txStyles");return t?{titleStyle:this.parseTextStyle(this.getChildElement(t,"titleStyle")),bodyStyle:this.parseTextStyle(this.getChildElement(t,"bodyStyle")),otherStyle:this.parseTextStyle(this.getChildElement(t,"otherStyle"))}:null}parseTextStyle(e){return e?{element:e,parsed:!1}:null}parseColorMap(e){let t=this.getChildElement(e,"clrMap");if(!t)return null;let r={},i=t.attributes;for(let e=0;e<i.length;e++){let t=i[e];r[t.name]=t.value}return r}parseColorMapOverride(e){let t=this.getChildElement(e,"clrMapOvr");if(!t)return null;let r=this.getChildElement(t,"masterClrMapping");if(r)return this.parseColorMap(r);let i=this.getChildElement(t,"overrideClrMapping");return i?this.parseColorMap(i):null}parseBackground(e){let t=this.getChildElement(e,"bg");if(!t)return null;let r=this.getChildElement(t,"bgPr");if(r)return{type:"bgPr",fill:this.parseFill(r)};let i=this.getChildElement(t,"bgRef");return i?{type:"bgRef",idx:this.getAttributeValue(i,"idx")}:null}getChildElement(e,t){if(!e)return null;for(let r of Object.keys(this.namespaces)){let i=e.querySelector(`${r}\\:${t}, ${t}`);if(i)return i}return e.querySelector(t)}getAttributeValue(e,t){return e?e.getAttribute(t):null}getTextContent(e){return e?e.textContent:""}getElementsByTagName(e){return this.doc||this.parse(),this.doc?this.doc.getElementsByTagName(e):[]}getElementsByTagNameNS(e,t){return this.doc||this.parse(),this.doc?this.doc.getElementsByTagNameNS(e,t):[]}parseShapeProperties(e){return{}}parseTextBody(e){return null}parseShapeStyle(e){return null}getShapeName(e){let t=e.querySelector("cNvPr")||e.querySelector("p\\:cNvPr")||e.querySelector('[*|localName="cNvPr"]');return t&&t.getAttribute("name")||""}parsePictureShape(e){let t=this.parsePlaceholder(e),r={type:"pic",id:this.getAttributeValue(e,"id"),name:this.getShapeName(e),properties:this.parseShapeProperties(e),style:this.parseShapeStyle(e),placeholder:t,isPlaceholder:!!t},i=e.querySelector("blipFill, p\\:blipFill");if(i){let e=i.querySelector("blip, a\\:blip");if(e){let t=this.extractSVGRelationshipId(e);if(t)r.imageRelId=t,r.hasSVGAlternative=!0;else{let t=e.getAttribute("r:embed")||e.getAttribute("r:id");t&&(r.imageRelId=t)}let a=e.querySelector("effectLst, a\\:effectLst");a&&(r.imageEffects=this.parseImageEffects(a));let o=i.getAttribute("dpi")||i.getAttribute("rotWithShape");o&&(r.imageFillMode=o)}}return r.transform=this.parseTransform(e),r}extractSVGRelationshipId(e){try{let t=e.querySelector('extLst, a\\:extLst, [*|localName="extLst"]');if(!t)return null;for(let e of t.querySelectorAll('ext, a\\:ext, [*|localName="ext"]')){let t=e.getAttribute("uri");if("{96DAC541-7B7A-43D3-8B79-37D633B846F1}"===t){let t=e.querySelector('svgBlip, asvg\\:svgBlip, [*|localName="svgBlip"]');if(t){let e=t.getAttribute("r:embed")||t.getAttribute("r:id");if(e)return e}}}return null}catch(e){return null}}parseGroupShape(e){return{type:"grpSp"}}parseConnectorShape(e){return{type:"cxnSp"}}parseGraphicFrame(e){let t={type:"graphicFrame",name:this.getShapeName(e),position:this.parseTransform(e)},r=e.querySelector("graphic")||e.querySelector("a\\:graphic")||e.querySelector('[*|localName="graphic"]');if(r){let i=r.querySelector("graphicData")||r.querySelector("a\\:graphicData")||r.querySelector('[*|localName="graphicData"]');if(i){let r=i.getAttribute("uri");if(t.graphicData={uri:r},"http://schemas.openxmlformats.org/drawingml/2006/table"===r){let e=i.querySelector("tbl");e&&(t.graphicData.tableXml=new XMLSerializer().serializeToString(e))}else if("http://schemas.openxmlformats.org/drawingml/2006/chart"===r){t.graphicData.element=i;let r=i.querySelector("chart, c\\:chart");if(r){let e=r.getAttribute("r:id");e&&(t.graphicData.chartRef=e)}if(window.ChartProcessor)try{let r=new ChartProcessor(this.context);r.parseChartFromGraphicFrame(e).then(e=>{if(e)t.chartData=e,window.currentProcessor&&window.currentProcessor.reRenderShape&&window.currentProcessor.reRenderShape(t);else{let e=r.parseEmbeddedChartData(i);e&&(t.chartData=e)}}).catch(e=>{try{let e=r.parseEmbeddedChartData(i);e&&(t.chartData=e)}catch(e){}})}catch(e){}else t.graphicData.isChart=!0,t.graphicData.chartXml=new XMLSerializer().serializeToString(i)}}}return t}parseHeaderFooter(e){return null}parseTiming(e){return null}parseTransition(e){return null}extractThemeId(e){return null}parseFill(e){return null}parseImageEffects(e){return null}parseTransform(e){let t=e.querySelector("xfrm")||e.querySelector("p\\:xfrm")||e.querySelector('[*|localName="xfrm"]');if(!t)return{x:0,y:0,width:0,height:0};let r=t.querySelector("off")||t.querySelector("a\\:off")||t.querySelector('[*|localName="off"]'),i=0,a=0;r&&(i=parseInt(r.getAttribute("x")||"0",10),a=parseInt(r.getAttribute("y")||"0",10));let o=t.querySelector("ext")||t.querySelector("a\\:ext")||t.querySelector('[*|localName="ext"]'),l=0,s=0;return o&&(l=parseInt(o.getAttribute("cx")||"0",10),s=parseInt(o.getAttribute("cy")||"0",10)),{x:i,y:a,width:l,height:s}}parseSlide(e){try{let t={shapes:[],background:null,name:"",id:null},r=e.getAttribute("id");r&&(t.id=r);let i=this.getChildElement(e,"cSld");if(i){let e=i.getAttribute("name");e&&(t.name=e),t.background=this.parseBackground(i),t.shapes=this.parseShapeTree(i)}return t}catch(e){return{shapes:[],background:null,name:"",id:null}}}}"u">typeof window&&(window.XmlParserContext=e,window.StaxParser=t),"u">typeof globalThis&&(globalThis.XmlParserContext=e,globalThis.StaxParser=t)}}();!function(){if(!n){n=1;class e{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(e){return this.slides[e]||null}addSlide(e){this.slides.push(e),e.setParent(this)}setCurrentSlide(e){e>=0&&e<this.slides.length&&(this.currentSlide=e)}getSlideDimensions(){return{width:CoordinateTransform.emuToMM(this.slideSize.cx),height:CoordinateTransform.emuToMM(this.slideSize.cy)}}addSlideMaster(e){this.slideMasters.push(e),e.setParent(this)}draw(e){let t=this.getCurrentSlide();t&&t.draw(e)}}class t{constructor(){this.id=Math.random().toString(36).substr(2,9),this.commonSlideData=new r,this.layout=null,this.notes=null,this.timing=null,this.transition=null,this.showMasterShapes=!0,this.width=254,this.height=190.5,this.parent=null,this.bounds={l:0,t:0,r:254,b:190.5},this.backgroundFill=null}setParent(e){this.parent=e}getName(){return this.commonSlideData?this.commonSlideData.name:""}getShapeTree(){return this.commonSlideData?this.commonSlideData.shapeTree:[]}addToSpTree(e,t){this.commonSlideData||(this.commonSlideData=new r),null==e&&(e=this.commonSlideData.shapeTree.length),this.commonSlideData.shapeTree.splice(e,0,t),t.setParent(this)}removeFromSpTree(e){return e>=0&&e<this.commonSlideData.shapeTree.length?this.commonSlideData.shapeTree.splice(e,1)[0]:null}getBackground(){return this.backgroundFill||this.commonSlideData?.background}draw(e){e&&(this.drawBackground(e),this.showMasterShapes&&this.layout&&this.layout.master&&this.drawMasterElements(e),this.layout&&this.drawLayoutElements(e),this.drawShapeTree(e))}drawBackground(e){}drawGradientBackground(e,t){let r=t.colors&&t.colors[0]?t.colors[0]:{r:255,g:255,b:255};e.fillRect(0,0,this.width,this.height,r)}drawImageBackground(e,t){e.fillRect(0,0,this.width,this.height,{r:240,g:240,b:240})}drawMasterElements(e){if(this.layout&&this.layout.master&&this.layout.master.commonSlideData)for(let t of this.layout.master.commonSlideData.shapeTree)t.isPlaceholder||this.drawShape(e,t)}drawLayoutElements(e){if(this.layout&&this.layout.commonSlideData)for(let t of this.layout.commonSlideData.shapeTree)t.isPlaceholder||this.drawShape(e,t)}drawShapeTree(e){let t=this.getShapeTree();for(let r=0;r<t.length;r++){let i=t[r];i&&!i.isHidden&&this.drawShape(e,i)}}drawShape(e,t){if(t&&t.properties){e.SaveGrState();try{if(t.properties.transform){let r=this.createShapeTransformMatrix(t.properties.transform);e.transform3(r)}"grpSp"===t.type||t.isGroup?.()?this.drawGroupShape(e,t):this.drawSingleShape(e,t)}finally{e.RestoreGrState()}}}drawGroupShape(e,t){if(t.shapeTree&&0!==t.shapeTree.length){e.SaveGrState();try{if(t.transform){if(t.transform.rotation&&0!==t.transform.rotation){let r=this.createRotationMatrix(t.transform.rotation);e.transform3(r)}if(t.transform.flipH||t.transform.flipV){let r=t.transform.flipH?-1:1,i=t.transform.flipV?-1:1,a=this.createScaleMatrix(r,i);e.transform3(a)}}if(t.groupCoordSystem){let r=this.createGroupCoordinateMatrix(t.groupCoordSystem);r&&e.transform3(r)}for(let r of t.shapeTree)this.drawShape(e,r)}finally{e.RestoreGrState()}}}createGroupCoordinateMatrix(e){if(!e)return null;let t=1,r=1;e.chExt.cx>0&&e.groupExt.cx>0&&(t=e.groupExt.cx/e.chExt.cx),e.chExt.cy>0&&e.groupExt.cy>0&&(r=e.groupExt.cy/e.chExt.cy);let i=e.groupOff.x-e.chOff.x*t,a=e.groupOff.y-e.chOff.y*r;return{m11:t,m12:0,m21:0,m22:r,dx:i,dy:a}}createRotationMatrix(e){let t=e*Math.PI/180,r=Math.cos(t),i=Math.sin(t);return{m11:r,m12:i,m21:-i,m22:r,dx:0,dy:0}}createScaleMatrix(e,t){return{m11:e,m12:0,m21:0,m22:t,dx:0,dy:0}}drawSingleShape(e,t){let r=t.properties.transform;if(!r)return;let i=CoordinateTransform.emuToMM(r.x||0),a=CoordinateTransform.emuToMM(r.y||0),o=CoordinateTransform.emuToMM(r.width||0),l=CoordinateTransform.emuToMM(r.height||0),s=this.getShapeFillColor(t),n=this.getShapeStrokeColor(t),h=this.getShapeLineWidth(t);switch(t.type){case"sp":this.drawTextShape(e,t,i,a,o,l,s,n,h);break;case"pic":this.drawImageShape(e,t,i,a,o,l);break;case"cxnSp":this.drawConnectorShape(e,t,i,a,o,l,n,h);break;case"graphicFrame":this.drawGraphicFrame(e,t,i,a,o,l);break;default:this.drawDefaultShape(e,t,i,a,o,l,s,n,h)}}drawTextShape(e,t,r,i,a,o,l,s,n){let h=t.geometry||t.properties?.geometry;h&&h.preset?e.drawPresetGeometry(h.preset,r,i,a,o,l,s,n):h&&h.pathLst?this.drawCustomGeometry(e,h,r,i,a,o,l,s,n):(l&&e.fillRect(r,i,a,o,l),s&&e.strokeRect(r,i,a,o,s,n)),this.drawTextContent(e,t,r,i,a,o)}drawCustomGeometry(e,t,r,i,a,o,l,s,n){e.SaveGrState();let h=a/(t.pathW||a),c=o/(t.pathH||o);if(e.context.translate(r,i),e.context.scale(h,c),t.pathLst)for(let r=0;r<t.pathLst.length;r++){let i=t.pathLst[r],a=l;"none"===i.fill||!1===i.fill?a=null:!Object.prototype.hasOwnProperty.call(i,"fill")&&s&&(a=null),this.drawGeometryPath(e,i,a,s,n)}e.RestoreGrState()}drawGeometryPath(e,t,r,i,a){if(t.commands&&0!==t.commands.length){e._s();for(let i=0;i<t.commands.length;i++){let a=t.commands[i];switch(a.type){case"M":case"moveTo":e._m(a.x,a.y);break;case"L":case"lineTo":e._l(a.x,a.y);break;case"C":case"curveTo":e._c(a.x1,a.y1,a.x2,a.y2,a.x,a.y);break;case"Z":case"close":r&&"none"!==t.fill&&!1!==t.fill&&e._z();break;case"Q":case"quadTo":{let t=a.cpx+(a.x-a.cpx)*2/3,r=a.cpy+(a.y-a.cpy)*2/3;e._c(a.cpx,a.cpy,t,r,a.x,a.y);break}case"A":case"arcTo":if(a.rx&&a.ry&&a.x&&a.y){let t=(e.context.lastX||0+a.x)/2,r=(e.context.lastY||0+a.y)/2;e._c(t,r,t,r,a.x,a.y)}else e._l(a.x,a.y)}}i&&!1!==t.stroke&&(e.p_color(i.r,i.g,i.b,i.a||255),e.p_width(a||1),e.ds()),r&&"none"!==t.fill&&!1!==t.fill&&(e.b_color1(r.r,r.g,r.b,r.a||255),e.df()),e._e()}}drawTextContent(e,t,r,i,a,o){if(!t.textBody||!t.textBody.paragraphs)return;let l=i+5,s=o-10;for(let a of t.textBody.paragraphs){if(l>i+s)break;let t=r+5;for(let r of a.runs)if(r.text&&l<=i+s){let i={fontSize:r.properties?.fontSize||18,fontFamily:r.properties?.fontFamily||"Arial",bold:r.properties?.bold||!1,italic:r.properties?.italic||!1,color:r.properties?.color||{r:0,g:0,b:0},highlight:r.properties?.highlight||null};e.fillText(r.text,t,l,i),t+=r.text.length*(.6*i.fontSize)}l+=14}}drawImageShape(e,t,r,i,a,o){e.strokeRect(r,i,a,o,{r:160,g:160,b:160},1),t.imageData&&e.drawImage(t.imageData,r,i,a,o)}drawConnectorShape(e,t,r,i,a,o,l,s){e.drawLine(r,i,r+a,i+o,l,s)}drawGraphicFrame(e,t,r,i,a,o){if(t.graphicData,t.asyncChartProcessing)return void e.strokeRect(r,i,a,o,{r:200,g:200,b:200},1);if(t.chartData)window.ChartRenderer?new ChartRenderer(e).renderChart(t.chartData,r,i,a,o):e.strokeRect(r,i,a,o,{r:160,g:160,b:160},1);else if(t.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/chart"===t.graphicData.uri)if(window.ChartProcessor){let l=new ChartProcessor().parseEmbeddedChartData(t.graphicData);l?(t.chartData=l,window.ChartRenderer&&new ChartRenderer(e).renderChart(l,r,i,a,o)):e.strokeRect(r,i,a,o,{r:160,g:160,b:160},1)}else e.strokeRect(r,i,a,o,{r:160,g:160,b:160},1);else if(t.table&&t.table instanceof s)t.table.draw(e,r,i,a,o);else if(t.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===t.graphicData.uri)try{let l=this.parseSimpleTable(t.graphicData.tableXml);l?(t.table=l,l.draw(e,r,i,a,o)):e.strokeRect(r,i,a,o,{r:160,g:160,b:160},1)}catch(t){e.strokeRect(r,i,a,o,{r:160,g:160,b:160},1)}else e.strokeRect(r,i,a,o,{r:160,g:160,b:160},1)}parseSimpleTable(e){if(!e)return null;try{let t=new DOMParser().parseFromString(e,"text/xml");if("parsererror"===t.documentElement.nodeName)return null;let r=new s,i=t.querySelector("tblGrid");if(i||(i=t.querySelector("a\\:tblGrid")),i){let e=i.querySelectorAll("gridCol");0===e.length&&(e=i.querySelectorAll("a\\:gridCol"));let t=[];e.forEach(e=>{let r=e.getAttribute("w");t.push({width:r?parseInt(r):914400})}),r.setTableGrid(t)}let a=t.querySelectorAll("tr");return 0===a.length&&(a=t.querySelectorAll("a\\:tr")),a.forEach(e=>{let t=new h,i=e.querySelector("trPr");if(i||(i=e.querySelector("a\\:trPr")),i){let e=i.querySelector("trHeight");e||(e=i.querySelector("a\\:trHeight")),e&&(t.height=parseInt(e.getAttribute("val"))||null)}let a=e.querySelectorAll("tc");0===a.length&&(a=e.querySelectorAll("a\\:tc")),a.forEach(e=>{let r=new c,i=e.querySelector("tcPr");if(i||(i=e.querySelector("a\\:tcPr")),i){let e=i.querySelector("gridSpan");e||(e=i.querySelector("a\\:gridSpan")),e&&(r.gridSpan=parseInt(e.getAttribute("val"))||1);let t=i.querySelector("rowSpan");t||(t=i.querySelector("a\\:rowSpan")),t&&(r.rowSpan=parseInt(t.getAttribute("val"))||1);let a=i.querySelector("solidFill");if(a||(a=i.querySelector("a\\:solidFill")),a){let e=a.querySelector("srgbClr, schemeClr, scrgbClr");if(e||(e=a.querySelector("a\\:srgbClr, a\\:schemeClr, a\\:scrgbClr")),e){let t=this.parseSimpleColor(e);t&&(r.fill={color:t})}}}let a=this.parseSimpleTextContent(e);a&&r.setTextBody(a),t.addCell(r)}),r.addRow(t)}),r}catch(e){return null}}parseSimpleColor(e){if(e.tagName.includes("srgbClr")){let t=e.getAttribute("val");if(t){let e=t.replace("#","");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{r:200,g:200,b:200,a:255}}parseSimpleTextContent(e){let t=e.querySelectorAll("r, a\\:r");if(0===t.length)return null;let r={paragraphs:[],bodyProperties:{wrap:!0,verticalAlign:"top"}},i={runs:[],properties:{}};return t.forEach(e=>{let t=e.querySelector("t, a\\:t"),r=t?t.textContent:"";if(r){let t=e.querySelector("rPr, a\\:rPr"),a={fontSize:12,fontFamily:"Arial",bold:!1,italic:!1,color:{r:0,g:0,b:0,a:255}};if(t){let e=t.getAttribute("sz");e&&(a.fontSize=parseInt(e)/100),"1"===t.getAttribute("b")&&(a.bold=!0);let r=t.querySelector("solidFill, a\\:solidFill");if(r){let e=r.querySelector("srgbClr, a\\:srgbClr");if(e){let t=e.getAttribute("val");if(t){let e=parseInt(t.substr(0,2),16);a.color={r:e,g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:255}}}}}i.runs.push({text:r,properties:a})}}),i.runs.length>0&&r.paragraphs.push(i),r.paragraphs.length>0?r:null}drawDefaultShape(e,t,r,i,a,o,l,s,n){l&&e.fillRect(r,i,a,o,l),s&&e.strokeRect(r,i,a,o,s,n)}getShapeFillColor(e){return e.brush?.color?e.brush.color:e.fill?.color?e.fill.color:e.properties?.fill?.color?e.properties.fill.color:{r:200,g:200,b:200,a:255}}getShapeStrokeColor(e){return null===e.pen||"none"===e.pen||null===e.stroke||"none"===e.stroke||e.properties?.stroke===null||e.properties?.stroke==="none"||e.pen?.width===0||e.stroke?.width===0||e.properties?.stroke?.width===0?null:e.pen?.color?e.pen.color:e.stroke?.color?e.stroke.color:e.properties?.stroke?.color?e.properties.stroke.color:null}getShapeLineWidth(e){return null===e.pen||"none"===e.pen||null===e.stroke||"none"===e.stroke||e.properties?.stroke===null||e.properties?.stroke==="none"?0:e.pen?.width!==void 0?CoordinateTransform.emuToMM(e.pen.width):e.stroke?.width!==void 0?CoordinateTransform.emuToMM(e.stroke.width):e.properties?.stroke?.width!==void 0?CoordinateTransform.emuToMM(e.properties.stroke.width):0}createShapeTransformMatrix(e){let t=new CMatrix;if(e.rotation){let r=e.rotation/6e4*Math.PI/180,i=Math.cos(r),a=Math.sin(r);t.sx=i,t.sy=i,t.shx=-a,t.shy=a}return t.tx=CoordinateTransform.emuToMM(e.x||0),t.ty=CoordinateTransform.emuToMM(e.y||0),t}}class r{constructor(){this.name="",this.shapeTree=[],this.background=null,this.colorMap=null,this.parent=null}setParent(e){this.parent=e}addToSpTree(e,t){null==e&&(e=this.shapeTree.length),this.shapeTree.splice(e,0,t),t.setParent(this)}removeFromSpTree(e){return e>=0&&e<this.shapeTree.length?this.shapeTree.splice(e,1)[0]:null}}class i{constructor(){this.id=Math.random().toString(36).substr(2,9),this.type="sp",this.properties={transform:{x:0,y:0,width:1e5,height:1e5,rotation:0}},this.geometry=null,this.textBody=null,this.fill=null,this.stroke=null,this.brush=null,this.pen=null,this.parent=null,this.isHidden=!1,this.isPlaceholder=!1,this.effects=null,this.bounds={l:0,t:0,r:0,b:0},this.transform=null,this.style=null,this.preservedStyle=null,this.nvSpPr=null,this.spPr=null,this.name=null,this.chartData=null,this.mediaInfo=null,this.svgContent=null,this.graphicData=null}setParent(e){this.parent=e}isGroup(){return"grpSp"===this.type}getObjectType(){switch(this.type){case"sp":return"shape";case"pic":return"image";case"grpSp":return"group";case"cxnSp":return"connector";case"graphicFrame":if(this.chartData)return"chart";if(this.graphicData?.uri==="http://schemas.openxmlformats.org/drawingml/2006/table")return"table";if(this.graphicData?.uri==="http://schemas.openxmlformats.org/drawingml/2006/chart")return"chart";return"graphic";default:return"unknown"}}setGeometry(e){this.geometry=e}setTextBody(e){this.textBody=e}setChartData(e){this.chartData=e}isChart(){return null!==this.chartData||this.graphicData?.uri==="http://schemas.openxmlformats.org/drawingml/2006/chart"}isTable(){return this.graphicData?.uri==="http://schemas.openxmlformats.org/drawingml/2006/table"}setMediaInfo(e){this.mediaInfo=e}setSvgContent(e){this.svgContent=e}recalculateBounds(){let e=this.properties.transform;e&&(this.bounds.l=CoordinateTransform.emuToMM(e.x),this.bounds.t=CoordinateTransform.emuToMM(e.y),this.bounds.r=this.bounds.l+CoordinateTransform.emuToMM(e.width),this.bounds.b=this.bounds.t+CoordinateTransform.emuToMM(e.height))}draw(e){if(!this.isHidden)switch(this.recalculateBounds(),this.getObjectType()){case"group":this.drawGroupShape(e);break;case"image":this.drawImageShape(e);break;case"connector":this.drawConnectorShape(e);break;case"graphic":this.drawGraphicFrame(e);break;default:this.drawShape(e)}}drawShape(e){let t=this.bounds.l,r=this.bounds.t,i=this.bounds.r-this.bounds.l,a=this.bounds.b-this.bounds.t;this.geometry&&this.geometry.preset?e.drawPresetGeometry(this.geometry.preset,t,r,i,a,this.getFillColor(),this.getStrokeColor(),this.getLineWidth()):(this.getFillColor()&&e.fillRect(t,r,i,a,this.getFillColor()),this.getStrokeColor()&&e.strokeRect(t,r,i,a,this.getStrokeColor(),this.getLineWidth())),this.textBody&&this.drawTextContent(e,t,r,i,a)}drawGroupShape(e){if(this.shapeTree){for(let t of(e.SaveGrState(),this.transform&&e.transform3(this.transform),this.shapeTree))t.draw(e);e.RestoreGrState()}}drawImageShape(e){let t=this.bounds.l,r=this.bounds.t,i=this.bounds.r-this.bounds.l,a=this.bounds.b-this.bounds.t;e.strokeRect(t,r,i,a,{r:160,g:160,b:160},1)}drawConnectorShape(e){let t=this.bounds.l,r=this.bounds.t,i=this.bounds.r-this.bounds.l,a=this.bounds.b-this.bounds.t;e.drawLine(t,r,t+i,r+a,this.getStrokeColor(),this.getLineWidth())}drawGraphicFrame(e){let t=this.bounds.l,r=this.bounds.t,i=this.bounds.r-this.bounds.l,a=this.bounds.b-this.bounds.t;if(this.asyncChartProcessing)return void e.strokeRect(t,r,i,a,{r:200,g:200,b:200},1);if(this.chartData)window.ChartRenderer?new ChartRenderer(e).renderChart(this.chartData,t,r,i,a):e.strokeRect(t,r,i,a,{r:160,g:160,b:160},1);else if(this.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/chart"===this.graphicData.uri)if(window.ChartProcessor){let o=new ChartProcessor().parseEmbeddedChartData(this.graphicData);o?(this.chartData=o,window.ChartRenderer&&new ChartRenderer(e).renderChart(o,t,r,i,a)):e.strokeRect(t,r,i,a,{r:160,g:160,b:160},1)}else e.strokeRect(t,r,i,a,{r:160,g:160,b:160},1);else e.strokeRect(t,r,i,a,{r:160,g:160,b:160},1)}drawTextContent(e,t,r,i,a){if(!this.textBody||!this.textBody.paragraphs)return;let o=r+5;for(let r of this.textBody.paragraphs)for(let i of r.runs)i.text&&(e.fillText(i.text,t+5,o,i.properties||{}),o+=15)}getFillColor(){return null===this.fill?null:this.fill?.color||this.brush?.color||null}getStrokeColor(){return null===this.stroke?null:this.stroke?.color||this.pen?.color||{r:0,g:0,b:0}}getLineWidth(){let e=this.stroke?.width||this.pen?.width||12700;return CoordinateTransform.emuToMM(e)}}class a extends i{constructor(){super(),this.type="grpSp",this.shapeTree=[],this.groupCoordSystem={chOff:{x:0,y:0},chExt:{cx:0,cy:0},groupOff:{x:0,y:0},groupExt:{cx:0,cy:0}},this.transform={rotation:0,flipH:!1,flipV:!1,groupOff:{x:0,y:0},groupExt:{cx:0,cy:0}}}addToSpTree(e,t){null==e&&(e=this.shapeTree.length),this.shapeTree.splice(e,0,t),t.setParent&&t.setParent(this),t.inGroup=!0,t.parentGroup=this,this.recalculateBounds()}removeFromSpTree(e){if(e>=0&&e<this.shapeTree.length){let t=this.shapeTree.splice(e,1)[0];return t.setParent&&t.setParent(null),t.inGroup=!1,t.parentGroup=null,this.recalculateBounds(),t}return null}setGroupCoordSystem(e,t,r,i){this.groupCoordSystem={chOff:e||{x:0,y:0},chExt:t||{cx:0,cy:0},groupOff:r||{x:0,y:0},groupExt:i||{cx:0,cy:0}},this.transform.groupOff={...this.groupCoordSystem.groupOff},this.transform.groupExt={...this.groupCoordSystem.groupExt},this.transformChildShapes()}transformChildShapes(){if(!this.shapeTree||0===this.shapeTree.length)return;let e=this.groupCoordSystem,t=1,r=1;for(let i of(e.chExt.cx>0&&e.groupExt.cx>0&&(t=e.groupExt.cx/e.chExt.cx),e.chExt.cy>0&&e.groupExt.cy>0&&(r=e.groupExt.cy/e.chExt.cy),this.shapeTree))if(i.bounds){let a=i.bounds;i.originalBounds||(i.originalBounds={...a}),i.bounds={l:e.groupOff.x+(a.l-e.chOff.x)*t,t:e.groupOff.y+(a.t-e.chOff.y)*r,r:e.groupOff.x+(a.r-e.chOff.x)*t,b:e.groupOff.y+(a.b-e.chOff.y)*r},i.groupTransform={scaleX:t,scaleY:r,offsetX:e.groupOff.x-e.chOff.x*t,offsetY:e.groupOff.y-e.chOff.y*r}}}recalculateBounds(){if(0===this.shapeTree.length)return void super.recalculateBounds();let e=1/0,t=1/0,r=-1/0,i=-1/0,a=!1;for(let o of this.shapeTree)o.recalculateBounds&&o.recalculateBounds(),o.bounds&&(e=Math.min(e,o.bounds.l),t=Math.min(t,o.bounds.t),r=Math.max(r,o.bounds.r),i=Math.max(i,o.bounds.b),a=!0);a?(this.bounds.l=e,this.bounds.t=t,this.bounds.r=r,this.bounds.b=i):(this.bounds.l=914400,this.bounds.t=914400,this.bounds.r=5486400,this.bounds.b=2743200)}draw(e){if(!this.isHidden){this.recalculateBounds(),e.SaveGrState();try{if(this.transform){if(this.transform.rotation&&0!==this.transform.rotation){let t=this.createRotationMatrix(this.transform.rotation);e.transform3(t)}if(this.transform.flipH||this.transform.flipV){let t=this.transform.flipH?-1:1,r=this.transform.flipV?-1:1,i=this.createScaleMatrix(t,r);e.transform3(i)}}if(this.groupCoordSystem){let t=this.createGroupCoordinateMatrix(this.groupCoordSystem);t&&e.transform3(t)}for(let t of this.shapeTree)t.draw(e)}finally{e.RestoreGrState()}}}createGroupCoordinateMatrix(e){if(!e)return null;let t=1,r=1;e.chExt.cx>0&&e.groupExt.cx>0&&(t=e.groupExt.cx/e.chExt.cx),e.chExt.cy>0&&e.groupExt.cy>0&&(r=e.groupExt.cy/e.chExt.cy);let i=e.groupOff.x-e.chOff.x*t,a=e.groupOff.y-e.chOff.y*r;return{m11:t,m12:0,m21:0,m22:r,dx:i,dy:a}}createRotationMatrix(e){let t=e*Math.PI/180,r=Math.cos(t),i=Math.sin(t);return{m11:r,m12:i,m21:-i,m22:r,dx:0,dy:0}}createScaleMatrix(e,t){return{m11:e,m12:0,m21:0,m22:t,dx:0,dy:0}}getObjectType(){return"group"}isGroup(){return!0}}class o{constructor(){this.id=Math.random().toString(36).substr(2,9),this.commonSlideData=new r,this.theme=null,this.layouts=[],this.parent=null}setParent(e){this.parent=e}addLayout(e){this.layouts.push(e),e.setMaster(this)}}class l{constructor(){this.id=Math.random().toString(36).substr(2,9),this.commonSlideData=new r,this.master=null,this.type="blank"}setMaster(e){this.master=e}}class s{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=!1,this.firstCol=!1,this.lastRow=!1,this.lastCol=!1,this.bandRow=!1,this.bandCol=!1,this.tableStyleId=null,this.bounds={l:0,t:0,r:0,b:0}}setParent(e){this.parent=e}addRow(e){this.rows.push(e),e.setParent(this),e.rowIndex=this.rows.length-1}setTableGrid(e){this.tableGrid=e||[]}getTotalWidth(){return this.tableGrid.reduce((e,t)=>e+(t.width||0),0)}getRowCount(){return this.rows.length}getColumnCount(){let e=this.tableGrid.length,t=0;for(let e of this.rows){let r=e.getCells().length;r>t&&(t=r)}return Math.max(e,t)}getTableProperties(){return this.tableProperties||{}}getTableBorders(){return this.tableProperties?.borders||{}}getTableShading(){return this.tableProperties?.shading||{}}getTableGrid(){return this.tableGrid||[]}getCell(e,t){if(e>=0&&e<this.rows.length){let r=this.rows[e];if(t>=0&&t<r.cells.length)return r.cells[t]}return null}getRow(e){return e>=0&&e<this.rows.length?this.rows[e]:null}getRows(){return this.rows}recalculateBounds(){let e=this.getTotalWidth(),t=this.rows.reduce((e,t)=>e+(t.height||0),0);this.bounds.r=this.bounds.l+CoordinateTransform.emuToMM(e),this.bounds.b=this.bounds.t+CoordinateTransform.emuToMM(t)}draw(e,t,r,i,a){if(!this.rows||0===this.rows.length)return void e.strokeRect(t,r,i,a,{r:160,g:160,b:160},1);let o=this.getColumnCount(),l=this.getRowCount(),s=o>0?i/o:i,n=l>0?a/l:a,h=r;for(let r=0;r<this.rows.length;r++){let a=this.rows[r],o=a.height?CoordinateTransform.emuToMM(a.height):n;a.draw(e,t,h,i,o,s,this.tableGrid),h+=o}}}class h{constructor(){this.id=Math.random().toString(36).substr(2,9),this.type="tableRow",this.cells=[],this.height=null,this.parent=null,this.rowIndex=0}setParent(e){this.parent=e}addCell(e){this.cells.push(e),e.setParent(this),e.cellIndex=this.cells.length-1}getCellCount(){return this.cells.length}draw(e,t,r,i,a,o,l){if(!this.cells||0===this.cells.length)return;let s=t;for(let t=0;t<this.cells.length;t++){let i=this.cells[t],n=o;l&&l[t]&&l[t].width&&(n=CoordinateTransform.emuToMM(l[t].width)),i.draw(e,s,r,n,a),s+=n}e.drawLine(t,r+a,t+i,r+a,{r:200,g:200,b:200},1)}getCell(e){return this.cells[e]||null}getCells(){return this.cells}}class c{constructor(){this.id=Math.random().toString(36).substr(2,9),this.type="tableCell",this.textBody=null,this.cellProperties=null,this.parent=null,this.cellIndex=0,this.gridSpan=1,this.rowSpan=1,this.fill=null,this.borders={top:null,right:null,bottom:null,left:null}}setParent(e){this.parent=e}setTextBody(e){this.textBody=e}draw(e,t,r,i,a){this.fill&&this.fill.color&&e.fillRect(t,r,i,a,this.fill.color),this.textBody&&this.textBody.paragraphs&&this.drawCellText(e,t,r,i,a)}drawCellText(e,t,r,i,a){if(!this.textBody||!this.textBody.paragraphs)return;let o=r+5,l=a-10;for(let i of this.textBody.paragraphs){if(o>r+l)break;let a=t+5;if(i.runs){for(let t of i.runs)if(t.text&&o<=r+l){let r={fontSize:t.properties?.fontSize||12,fontFamily:t.properties?.fontFamily||"Arial",bold:t.properties?.bold||!1,italic:t.properties?.italic||!1,color:t.properties?.color||{r:0,g:0,b:0}};e.fillText(t.text,a,o,r),a+=t.text.length*(.6*r.fontSize)}}o+=14}}getGridSpan(){return this.gridSpan||1}getRowSpan(){return this.rowSpan||1}getCellShading(){return this.shading}getTextBody(){return this.textBody}getCellBorders(){return this.borders}}class u{constructor(){this.id=Math.random().toString(36).substr(2,9),this.name="Default Theme",this.colorScheme=null,this.fontScheme=null,this.formatScheme=null}}"u">typeof window&&(window.CPresentation=e,window.CSlide=t,window.CSld=r,window.CShape=i,window.CGroupShape=a,window.CSlideMaster=o,window.CSlideLayout=l,window.CTheme=u,window.CTable=s,window.CTableRow=h,window.CTableCell=c),"u">typeof globalThis&&(globalThis.CPresentation=e,globalThis.CSlide=t,globalThis.CSld=r,globalThis.CShape=i,globalThis.CGroupShape=a,globalThis.CSlideMaster=o,globalThis.CSlideLayout=l,globalThis.CTheme=u,globalThis.CTable=s,globalThis.CTableRow=h,globalThis.CTableCell=c)}}();let T=class{constructor(e={}){this.logger=new Logger("TableProcessor"),this.validator=this._getValidator(),this.errorBoundary=new(this._getErrorBoundary())({context:"TableProcessor",enableLogging:!1!==e.enableLogging}),this.tableCache=new Map,this.config=this._validateConfig({maxTableSize:e.maxTableSize||1e3,maxCellTextLength:e.maxCellTextLength||1e4,enableCaching:!1!==e.enableCaching,enableValidation:!1!==e.enableValidation,renderTimeout:e.renderTimeout||5e3,...e}),this.performanceMetrics={tablesProcessed:0,cacheHits:0,cacheMisses:0,averageRenderTime:0}}async renderTableFrame(e,t,r,i,a,o,l={}){let s=this._validateRenderInput(e,t,r,i,a,o,l);if(!s.valid){this._handleValidationError("renderTableFrame",s.errors),this.drawTablePlaceholder(e,r,i,a,o);return}return this.errorBoundary.wrap(async()=>{let l=performance.now();try{let s=await this._getTableInstanceWithTimeout(t,this.config.renderTimeout);if(!s){this.logger&&this.logger.log("warn",this.constructor.name,"TableProcessor","No valid table data found, drawing placeholder"),this.drawTablePlaceholder(e,r,i,a,o);return}this.config.enableValidation&&this._validateTableStructure(s),e.SaveGrState();try{await this._safeDrawTableBackgroundAndOuterBorder(e,s,r,i,a,o),await this._safeDrawCellsBackground(e,s,r,i,a,o),await this._safeDrawCellsContent(e,s,r,i,a,o),await this._safeDrawCellsBorders(e,s,r,i,a,o),this._updatePerformanceMetrics(l)}finally{e.RestoreGrState()}}catch(t){throw console.error("[TableProcessor] MAIN RENDER ERROR:",t.message),console.error("[TableProcessor] Error stack:",t.stack),console.error("[TableProcessor] Error name:",t.name),this.logger&&this.logger.logError(this.constructor.name,"TableProcessor","Error during table rendering:",t),this.drawTablePlaceholder(e,r,i,a,o),this._enhanceError(t,"table_rendering",{x:r,y:i,w:a,h:o})}},{context:"renderTableFrame"})()}async getTableInstance(e){return this.errorBoundary.wrap(async()=>{if(!e||"object"!=typeof e)throw this._createError("Invalid shape object provided",{name:"ValidationError",code:"INVALID_SHAPE"});if(e.table&&e.table instanceof CTable)return this.performanceMetrics.cacheHits++,e.table;if(this.performanceMetrics.cacheMisses++,e.graphicData&&e.graphicData.tableXml)try{this.config.enableValidation&&this._validateTableXML(e.graphicData.tableXml);let t=await this.parseTableFromXML(e.graphicData.tableXml);if(t)return this.config.enableValidation&&this._validateParsedTable(t),this.config.enableCaching&&(e.table=t),t}catch(e){throw this.logger&&this.logger.logError(this.constructor.name,"TableProcessor","Failed to parse table XML:",e),this._enhanceError(e,"table_parsing")}return null},{context:"getTableInstance"})()}async _getTableInstanceWithTimeout(e,t){return new Promise(async(r,i)=>{let a=setTimeout(()=>{i(this._createError(`Table parsing timed out after ${t}ms`,{name:"TimeoutError",code:"TABLE_PARSING_TIMEOUT"}))},t);try{let t=await this.getTableInstance(e);clearTimeout(a),r(t)}catch(e){clearTimeout(a),i(e)}})}drawTableBackgroundAndOuterBorder(e,t,r,i,a,o){t.getTableProperties();let l=t.getTableBorders(),s=t.getTableShading();if(s&&s.fill){let t=this.resolveTableBackgroundColor(s);e.b_color1(t.r,t.g,t.b,t.a||255),e.TableRect(r,i,a,o)}l&&Object.keys(l).length>0&&this.drawTableOuterBorder(e,l,r,i,a,o)}drawCellsBackground(e,t,r,i,a,o){let l=t.getRows(),s=this.calculateCellWidths(t,a),n=this.calculateCellHeights(t,o),h=t.getTableProperties()||{},c=i;for(let t=0;t<l.length;t++){let i=l[t].getCells(),a=n[t],o=i.length>0&&i[0].textBody?.paragraphs?.[0]?.runs?.[0]?.text==="TOTAL",u=i.length>0&&i[0].textBody?.paragraphs?.[0]?.runs?.[0]?.text==="Product";for(let a=0;a<i.length;a++){let l=i[a],d=Math.max(1,l.gridSpan||1),p=Math.max(1,l.rowSpan||1);if(!l.isMergedContinue){let i=l.logicalColIndex||0,a=r+this.calculateCellXOffset(s,i),g=this.calculateMergedCellWidth(s,i,d),f=this.calculateMergedCellHeight(n,t,p);this.drawCellBackground(e,l,a,c,g,f,{isHeaderRow:u,isTotalRow:o,rowIndex:t,tableProps:h})}}c+=a}}drawCellsContent(e,t,r,i,a,o){let l=t.getRows(),s=this.calculateCellWidths(t,a),n=this.calculateCellHeights(t,o),h=i;for(let t=0;t<l.length;t++){let i=l[t].getCells(),a=n[t];for(let a=0;a<i.length;a++){let o=i[a],l=Math.max(1,o.gridSpan||1),c=Math.max(1,o.rowSpan||1);if(!o.isMergedContinue){let i=o.logicalColIndex||0,a=r+this.calculateCellXOffset(s,i),u=this.calculateMergedCellWidth(s,i,l),d=this.calculateMergedCellHeight(n,t,c);this.drawCellContent(e,o,a,h,u,d)}}h+=a}}drawCellsBorders(e,t,r,i,a,o){let l=t.getRows(),s=this.calculateCellWidths(t,a),n=this.calculateCellHeights(t,o),h=i;for(let i=0;i<l.length;i++){let a=l[i].getCells(),o=n[i];for(let o=0;o<a.length;o++){let l=a[o],c=Math.max(1,l.gridSpan||1),u=Math.max(1,l.rowSpan||1);if(!l.isMergedContinue){let a=l.logicalColIndex||0,o=r+this.calculateCellXOffset(s,a),d=this.calculateMergedCellWidth(s,a,c),p=this.calculateMergedCellHeight(n,i,u);this.drawCellBorders(e,l,o,h,d,p,i,a,t)}}h+=o}}drawTablePlaceholder(e,t,r,i,a){let o=i/3,l=a/3;for(let i=0;i<3;i++)for(let a=0;a<3;a++){let s=t+a*o,n=r+i*l;e.drawRectangle(s,n,o,l,null,{r:128,g:128,b:128,a:255},1)}this.drawCenteredText(e,"Table",t,r,i,a)}drawTableOuterBorder(e,t,r,i,a,o){["top","right","bottom","left"].forEach(l=>{let s=t[l];if(s&&"none"!==s.style){let t=this.resolveBorderColor(s),n=Math.max(s.width||1,3);switch(e.p_color(t.r,t.g,t.b,t.a||255),e.p_width(n),l){case"top":e.drawHorLine(r,i,r+a,i,n);break;case"right":e.drawVerLine(r+a,i,i+o,n);break;case"bottom":e.drawHorLine(r,i+o,r+a,i+o,n);break;case"left":e.drawVerLine(r,i,i+o,n)}}})}drawCellBackground(e,t,r,i,a,o,l={}){let s=null;if(t.shading&&t.shading.fillColor&&(s=t.shading.fillColor),!s&&"function"==typeof t.getCellShading)try{let e=t.getCellShading();e&&e.fill&&e.fill.color&&(s=e.fill.color)}catch(e){}if(!s&&t.shading&&t.shading.color&&(s=t.shading.color),!s){let e=t.properties||t.cellProperties;e&&e.shading&&e.shading.fillColor&&(s=e.shading.fillColor)}if(!s&&l.tableProps){let e=l.tableProps,r=l.rowIndex||0,i=t.logicalColIndex||0;e.firstRow&&0===r?s={r:68,g:114,b:196,a:255}:e.bandRow&&r>0?(e.firstRow?r-1:r)%2==1&&(s={r:242,g:242,b:242,a:255}):e.firstCol&&0===i&&r>0&&(s={r:221,g:235,b:247,a:255})}s&&void 0!==s.r&&void 0!==s.g&&void 0!==s.b&&e.m_oContext&&(e.m_oContext.save(),e.m_oContext.fillStyle=`rgba(${s.r}, ${s.g}, ${s.b}, ${(s.a||255)/255})`,e.m_oContext.fillRect(r,i,a,o),e.m_oContext.restore())}drawCellContent(e,t,r,i,a,o){let l=t.getTextBody();if(!l||!l.paragraphs)return;let s=this.convertEMUToPixels(38100),n=s,h=s,c=s,u=s;if(t.margins&&(n=t.margins.left?this.convertEMUToPixels(t.margins.left):s,h=t.margins.right?this.convertEMUToPixels(t.margins.right):s,c=t.margins.top?this.convertEMUToPixels(t.margins.top):s,u=t.margins.bottom?this.convertEMUToPixels(t.margins.bottom):s),l.bodyProperties){let e=l.bodyProperties;null!=e.leftMargin&&(n=this.convertEMUToPixels(e.leftMargin)),null!=e.rightMargin&&(h=this.convertEMUToPixels(e.rightMargin)),null!=e.topMargin&&(c=this.convertEMUToPixels(e.topMargin)),null!=e.bottomMargin&&(u=this.convertEMUToPixels(e.bottomMargin))}let d=r+n,p=i+c,g=Math.max(0,a-(n+h)),f=Math.max(0,o-(c+u));this.renderCellTextContent(e,l,d,p,g,f,t)}drawCellBorders(e,t,r,i,a,o,l,s,n){let h=t.getCellBorders();h&&["top","right","bottom","left"].forEach(c=>{let u=h[c];if(u&&"none"!==u.style&&u.color&&0!==u.width&&this.shouldDrawBorder(c,l,s,n,t)){let t=this.resolveBorderColor(u),l=u.width;if(e.m_oContext){switch(e.m_oContext.save(),e.m_oContext.strokeStyle=`rgba(${t.r}, ${t.g}, ${t.b}, ${(t.a||255)/255})`,e.m_oContext.lineWidth=l,e.m_oContext.beginPath(),c){case"top":e.m_oContext.moveTo(r,i),e.m_oContext.lineTo(r+a,i);break;case"right":e.m_oContext.moveTo(r+a,i),e.m_oContext.lineTo(r+a,i+o);break;case"bottom":e.m_oContext.moveTo(r,i+o),e.m_oContext.lineTo(r+a,i+o);break;case"left":e.m_oContext.moveTo(r,i),e.m_oContext.lineTo(r,i+o)}e.m_oContext.stroke(),e.m_oContext.restore()}}})}shouldDrawBorder(e,t,r,i,a=null){return i.getRowCount(),i.getColumnCount(),a&&a.gridSpan,a&&a.rowSpan,"top"!==e||0===t||(!a||!a.isMergedContinue||"continue"!==a.vMerge)&&!0}calculateCellWidths(e,t){let r=e.getTableGrid();if(!r||0===r.length){let r=e.getColumnCount();return Array(r).fill(t/r)}let i=r.map(e=>Math.max(0,parseInt(e.width)||0)),a=i.reduce((e,t)=>e+t,0)||1,o=i.map(e=>e/a*t),l=e.getColumnCount();if(o.length<l){let e=l-o.length,r=(t-o.reduce((e,t)=>e+t,0))/Math.max(e,1);for(let t=0;t<e;t++)o.push(r)}return o}calculateCellHeights(e,t){let r=e.getRowCount();if(r<=0)return[];let i=[];for(let t=0;t<r;t++){let r=e.getRow(t),a=r&&r.height,o=null!=a?Number(a):NaN;i.push(isNaN(o)?1:Math.max(o,1))}let a=i.reduce((e,t)=>e+t,0)||r;return i.map(e=>e/a*t)}isStartingCellOfMerge(e,t,r){return!0}calculateMergedCellWidth(e,t,r){let i=0;for(let a=0;a<r;a++)t+a<e.length&&(i+=e[t+a]);return i}calculateMergedCellHeight(e,t,r){let i=0;for(let a=0;a<r;a++)t+a<e.length&&(i+=e[t+a]);return i}calculateCellXOffset(e,t){let r=0;for(let i=0;i<t;i++)r+=e[i];return r}calculateCellYOffset(e,t){let r=0;for(let i=0;i<t;i++)r+=e[i];return r}resolveTableBackgroundColor(e){if(e&&e.fill){let t=this.parseColorFromHex(e.fill);if(t)return t}return{r:255,g:255,b:255,a:255}}resolveCellBackgroundColor(e){if(e&&e.fillColor)return e.fillColor;if(e&&e.fill){let t=this.parseColorFromHex(e.fill);if(t)return t}if(e&&e.color){let t=this.parseColorFromHex(e.color);if(t)return t}return{r:255,g:255,b:255,a:255}}resolveBorderColor(e){return e&&e.color?e.color:{r:0,g:0,b:0,a:255}}renderCellTextContent(e,t,r,i,a,o,l=null){if(!t.paragraphs||0===t.paragraphs.length)return;let s=[];for(let e=0;e<t.paragraphs.length;e++){let r=t.paragraphs[e];if(!r.runs||0===r.runs.length)continue;let i="left";if(r.properties&&r.properties.alignment){let e=r.properties.alignment;"center"===e||"ctr"===e?i="center":"right"===e||"r"===e?i="right":("just"===e||"justify"===e)&&(i="left")}let a=[];for(let e of r.runs){let t=e.text||"";if(!t)continue;let r=e.properties||{},i=12;r.fontSize?i=r.fontSize:r.sz&&(i=parseInt(r.sz)/100);let o=Math.max(10,Math.round(1.33*i)),l=r.fontFamily||"Arial",s=r.bold?"bold":"normal",n=r.italic?"italic":"normal",h=r.underline||!1,c=r.strikethrough||!1,u=r.color||{r:0,g:0,b:0},d=`rgb(${u.r}, ${u.g}, ${u.b})`;a.push({text:t,fontSizePx:o,fontFamily:l,fontWeight:s,fontStyle:n,underline:h,strikethrough:c,color:d})}if(0===a.length)continue;let o=Math.round(1.25*Math.max(...a.map(e=>e.fontSizePx)));s.push({runSegments:a,textAlign:i,lineHeight:o})}if(0===s.length)return;let n=s.reduce((e,t)=>e+t.lineHeight,0),h="ctr";l&&l.verticalAlignment?h=l.verticalAlignment:t.bodyProperties&&t.bodyProperties.anchor&&(h=t.bodyProperties.anchor);let c=i;if(isFinite(c="t"===h||"top"===h?i:"ctr"===h||"center"===h||"middle"===h?i+Math.max(0,(o-n)/2):"b"===h||"bottom"===h?i+Math.max(0,o-n):i+Math.max(0,(o-n)/2))||(c=i),e.m_oContext)for(let t=0;t<s.length;t++){let i=s[t],o=c+i.lineHeight/2,l=0;for(let t of(e.m_oContext.save(),i.runSegments))e.m_oContext.font=`${t.fontStyle} ${t.fontWeight} ${t.fontSizePx}px ${t.fontFamily}`,l+=e.m_oContext.measureText(t.text).width;e.m_oContext.restore();let n=r;for(let t of("center"===i.textAlign?n=r+(a-l)/2:"right"===i.textAlign&&(n=r+a-l),i.runSegments)){if(e.m_oContext.save(),e.m_oContext.fillStyle=t.color,e.m_oContext.font=`${t.fontStyle} ${t.fontWeight} ${t.fontSizePx}px ${t.fontFamily}`,e.m_oContext.textAlign="left",e.m_oContext.textBaseline="middle",e.m_oContext.fillText(t.text,n,o),t.underline){let r=e.m_oContext.measureText(t.text).width;e.m_oContext.strokeStyle=t.color,e.m_oContext.lineWidth=1,e.m_oContext.beginPath(),e.m_oContext.moveTo(n,o+.1*t.fontSizePx),e.m_oContext.lineTo(n+r,o+.1*t.fontSizePx),e.m_oContext.stroke()}if(t.strikethrough){let r=e.m_oContext.measureText(t.text).width;e.m_oContext.strokeStyle=t.color,e.m_oContext.lineWidth=1,e.m_oContext.beginPath(),e.m_oContext.moveTo(n,o),e.m_oContext.lineTo(n+r,o),e.m_oContext.stroke()}n+=e.m_oContext.measureText(t.text).width,e.m_oContext.restore()}c+=i.lineHeight}}resolveTextColor(e){if(e&&e.runs&&e.runs.length>0){for(let t of e.runs)if(t.properties&&t.properties.color)return t.properties.color}return{r:159,g:159,b:159,a:255}}drawCenteredText(e,t,r,i,a,o){e.m_oContext&&(e.m_oContext.save(),e.m_oContext.fillStyle="rgba(128, 128, 128, 0.8)",e.m_oContext.font="14px Arial",e.m_oContext.textAlign="center",e.m_oContext.textBaseline="middle",e.m_oContext.fillText(t,r+a/2,i+o/2),e.m_oContext.restore())}parseTableFromXML(e){if(!e)return null;try{let t=new DOMParser().parseFromString(e,"text/xml");if("parsererror"===t.documentElement.nodeName)return console.warn("XML parsing error in table XML"),null;let r=new CTable;if(this.tableRowData=[],this.parseTableProperties(t,r),this.parseTableGrid(t,r),this.parseTableRows(t,r),this.processTableMerges(r),!this.validateTableStructure(r)){console.warn("Table structure validation failed");try{let e=(r.getTableGrid()||[]).length;console.warn("[TableProcessor][DEBUG] Grid columns:",e);let t=r.getRows();for(let e=0;e<Math.min(t.length,6);e++){let r=t[e].getCells(),i=r.map((e,t)=>`c${t}{gs:${e.gridSpan||1},rs:${e.rowSpan||1},cont:${!!e.isMergedContinue},v:${e.vMerge||""},lc:${e.logicalColIndex||0}}`).join(" | ");console.warn(`[TableProcessor][DEBUG] Row ${e} cells(${r.length}): ${i}`)}}catch(e){}}return r}catch(e){return console.warn("Error parsing table XML:",e),null}finally{this.tableRowData=null}}parseTableProperties(e,t){let r=e.querySelector("tblPr");if(r||(r=e.querySelector("a\\:tblPr")),r){let e={},i=r.getAttribute("firstRow");("1"===i||"true"===i)&&(e.firstRow=!0);let a=r.getAttribute("bandRow");("1"===a||"true"===a)&&(e.bandRow=!0);let o=r.getAttribute("firstCol");("1"===o||"true"===o)&&(e.firstCol=!0);let l=r.getAttribute("lastRow");("1"===l||"true"===l)&&(e.lastRow=!0);let s=r.getAttribute("lastCol");("1"===s||"true"===s)&&(e.lastCol=!0);let n=r.getAttribute("bandCol");("1"===n||"true"===n)&&(e.bandCol=!0);let h=r.querySelector("tblStyle");h||(h=r.querySelector("a\\:tblStyle")),h&&(e.style=h.getAttribute("val"));let c=r.querySelector("tblBorders");c||(c=r.querySelector("a\\:tblBorders")),c&&(e.borders=this.parseTableBorders(c));let u=r.querySelector("tblShading");u||(u=r.querySelector("a\\:tblShading")),u&&(e.shading=this.parseTableShading(u));let d=r.querySelector("tblLayout");d||(d=r.querySelector("a\\:tblLayout")),d&&(e.layout=d.getAttribute("type")||"autofit");let p=r.querySelector("tblW");if(p||(p=r.querySelector("a\\:tblW")),p){let t=p.getAttribute("w"),r=p.getAttribute("type")||p.getAttribute("wtype")||"auto";t?e.preferredWidth={value:parseInt(t)||0,type:r.toLowerCase()}:e.preferredWidth={value:0,type:r.toLowerCase()}}t.tableProperties=e}}parseTableGrid(e,t){let r=e.querySelector("tblGrid");if(r||(r=e.querySelector("a\\:tblGrid")),r){let e=r.querySelectorAll("gridCol");0===e.length&&(e=r.querySelectorAll("a\\:gridCol"));let i=[];e.forEach(e=>{let t=e.getAttribute("w"),r={width:t?parseInt(t):914400,type:e.getAttribute("type")||"auto"};i.push(r)}),t.setTableGrid(i)}}parseTableRows(e,t){let r=e.querySelectorAll("tr");0===r.length&&(r=e.querySelectorAll("a\\:tr")),r.forEach((e,r)=>{let i=new CTableRow;this.parseRowProperties(e,i),this.parseRowCells(e,i,r),t.addRow(i)})}parseRowProperties(e,t){let r=e.querySelector("trPr");if(r||(r=e.querySelector("a\\:trPr")),r){let e=r.querySelector("trHeight");if(e||(e=r.querySelector("a\\:trHeight")),e){let r=parseInt(e.getAttribute("val"),10);Number.isNaN(r)||(t.height=r),t.heightRule=e.getAttribute("hRule")||"auto"}let i=r.querySelector("tblHeader");i||(i=r.querySelector("a\\:tblHeader")),i&&(t.isHeader=!0)}if((!t.height||t.height<=0)&&e){let r=e.getAttribute("h");if(null!==r){let e=parseInt(r,10);!Number.isNaN(e)&&e>0&&(t.height=e,t.heightRule||(t.heightRule="auto"))}}}parseRowCells(e,t,r){let i=e.querySelectorAll("tc");0===i.length&&(i=e.querySelectorAll("a\\:tc"));let a=e.closest("tbl")||e.closest("a\\:tbl"),o=10;if(a){let e=a.querySelector("tblGrid");if(e||(e=a.querySelector("a\\:tblGrid")),e){let t=e.querySelectorAll("gridCol");0===t.length&&(t=e.querySelectorAll("a\\:gridCol")),o=t.length}}let l=Array(o).fill(!1);if(r>0&&this.tableRowData)for(let e=0;e<r;e++){let t=this.tableRowData[e];t&&t.forEach(t=>{if(t.rowSpan>1&&e+t.rowSpan-1>=r){let e=t.logicalColIndex,r=e+(t.gridSpan||1);for(let t=e;t<r;t++)t<o&&(l[t]=!0)}})}this.tableRowData||(this.tableRowData=[]),this.tableRowData[r]=[];let s=0;i.forEach((e,i)=>{let a=e.getAttribute("vMerge"),n=e.getAttribute("gridSpan"),h=e.getAttribute("rowSpan"),c=e.getAttribute("hMerge"),u=e.querySelector("tcPr");u||(u=e.querySelector("a\\:tcPr"));let d=null;u&&(d=u.querySelector("vMerge")||u.querySelector("a\\:vMerge"));let p="1"===c||"true"===c||s>0,g=d&&"restart"!==d.getAttribute("val"),f="1"===a||"true"===a||"continue"===a||g,m=n?parseInt(n):1,y=h?parseInt(h):1;if(u){let e=u.querySelector("gridSpan")||u.querySelector("a\\:gridSpan");if(e){let t=parseInt(e.getAttribute("val"));t>1&&(m=t)}let t=u.querySelector("rowSpan")||u.querySelector("a\\:rowSpan");if(t){let e=parseInt(t.getAttribute("val"));e>1&&(y=e)}}let b=0;if(f){for(;b<o&&!l[b];)b++;b>=o&&(b=0)}else{for(;b<o&&l[b];)b++;b>=o&&(b=Math.min(i,o-1))}let S=new CTableCell;f&&(S.isMergedContinue=!0,S.vMerge="continue"),y>1&&(S.rowSpan=y),m>1&&(S.gridSpan=m);let x=p?0:f?1:m;for(let e=0;e<x&&b+e<o;e++)l[b+e]=!0;p?s>0&&s--:s=!f&&m>1?m-1:0,this.parseCellProperties(e,S,r,i),this.parseCellContent(e,S),p&&(S.isMergedContinue=!0,S.mergeParent=null),S.logicalRowIndex=r,S.logicalColIndex=b,this.tableRowData[r].push({logicalColIndex:b,gridSpan:m,rowSpan:y,isVerticalContinuation:f}),t.addCell(S)})}parseCellProperties(e,t,r,i){let a=e.querySelector("tcPr");if(a||(a=e.querySelector("a\\:tcPr")),a){let e=a.querySelector("gridSpan");e||(e=a.querySelector("a\\:gridSpan")),e&&(t.gridSpan=parseInt(e.getAttribute("val"))||1);let r=a.querySelector("rowSpan");r||(r=a.querySelector("a\\:rowSpan")),r&&(t.rowSpan=parseInt(r.getAttribute("val"))||1);let i=a.querySelector("vMerge");i||(i=a.querySelector("a\\:vMerge")),i&&(t.vMerge="restart"===i.getAttribute("val")?"start":"continue");let o=a.getAttribute("anchor");o&&(t.verticalAlignment=o);let l=a.getAttribute("vert");l&&(t.textDirection=l);let s=this.parseCellBordersFromTcPr(a);s&&(t.borders=s);let n=Array.from(a.children).find(e=>"a:solidFill"===e.tagName||"solidFill"===e.tagName);if(n)t.shading=this.parseCellShading(n);else{let e=a.querySelectorAll("solidFill, a\\:solidFill"),r=null;for(let t of e){let e=t.parentElement,i=!1;for(;e&&e!==a;){if("a:lnL"===e.tagName||"a:lnR"===e.tagName||"a:lnT"===e.tagName||"a:lnB"===e.tagName||"lnL"===e.tagName||"lnR"===e.tagName||"lnT"===e.tagName||"lnB"===e.tagName){i=!0;break}e=e.parentElement}if(!i){r=t;break}}r&&(t.shading=this.parseCellShading(r))}let h=a.querySelector("tcMar");if(h||(h=a.querySelector("a\\:tcMar")),h)t.margins=this.parseCellMargins(h);else{let e=a.getAttribute("marL"),r=a.getAttribute("marR"),i=a.getAttribute("marT"),o=a.getAttribute("marB");(e||r||i||o)&&(t.margins={left:e?parseInt(e):null,right:r?parseInt(r):null,top:i?parseInt(i):null,bottom:o?parseInt(o):null})}}}parseCellContent(e,t){let r=this.parseTextBodyFromElement(e);r&&t.setTextBody(r)}appendMergedCellText(e,t){if(!t||t.mergedContentTransferred)return;let r=t.getTextBody&&t.getTextBody();if(!r||!r.paragraphs||0===r.paragraphs.length||!e.getTextBody||!e.setTextBody)return;let i=e.getTextBody();i&&i.paragraphs?(i.paragraphs.length>0&&i.paragraphs.push({runs:[],properties:{}}),i.paragraphs.push(...r.paragraphs)):e.setTextBody({paragraphs:[...r.paragraphs]}),t.mergedContentTransferred=!0,t.setTextBody&&t.setTextBody({paragraphs:[]})}processTableMerges(e){let t=e.getRows();for(let r=0;r<t.length;r++){let i=t[r].getCells();for(let a=0;a<i.length;a++){let o=i[a];if(o.gridSpan>1&&this.processHorizontalMerge(e,r,a,o.gridSpan),o.rowSpan>1&&this.processVerticalMerge(e,r,a,o.rowSpan),"start"===o.vMerge){let i=1;for(let l=r+1;l<t.length;l++){let t=e.getCell(l,a);if(!t)break;if("continue"===t.vMerge)t.isMergedContinue=!0,t.mergeParent={row:r,col:a},this.appendMergedCellText(o,t),i++;else break}(!o.rowSpan||o.rowSpan<i)&&(o.rowSpan=i)}else if("continue"===o.vMerge&&!o.isMergedContinue)for(let t=r-1;t>=0;t--){let i=e.getCell(t,a);if(!i)break;if("start"===i.vMerge){o.isMergedContinue=!0,o.mergeParent={row:t,col:a};let e=r-t+1;(!i.rowSpan||i.rowSpan<e)&&(i.rowSpan=e);break}if("continue"!==i.vMerge)break}}}}processHorizontalMerge(e,t,r,i){for(let a=1;a<i;a++){let i=e.getCell(t,r+a);if(i){i.isMergedContinue=!0,i.mergeParent={row:t,col:r};let a=e.getCell(t,r);a&&this.appendMergedCellText(a,i)}}}processVerticalMerge(e,t,r,i){for(let a=1;a<i;a++){let i=e.getCell(t+a,r);if(i){i.isMergedContinue=!0,i.mergeParent={row:t,col:r};let a=e.getCell(t,r);a&&this.appendMergedCellText(a,i)}}}validateTableStructure(e){let t=e.getRows();if(0===t.length)return!1;let r=e.getTableGrid().length||e.getColumnCount();if(0===r)return!1;for(let e=0;e<t.length;e++){let i=t[e].getCells(),a=0;for(let e of i)e.isMergedContinue||(a+=Math.max(1,e.gridSpan||1));let o=0;if(this.tableRowData){let t=Array(r).fill(!1);for(let i=0;i<e;i++)for(let a of this.tableRowData[i]||[])if(a&&a.rowSpan>1&&i+a.rowSpan-1>=e){let e=Math.max(0,a.logicalColIndex||0),i=Math.min(r,e+Math.max(1,a.gridSpan||1));for(let r=e;r<i;r++)t[r]=!0}o=t.filter(Boolean).length}let l=Math.max(0,r-o);if(0!==l&&(a<.5*l||a>2*l)){console.warn(`Row ${e}: total span ${a} mismatches available columns ${l} (grid cols ${r}, covered from above ${o})`);try{let t=i.map((e,t)=>`c${t}{gs:${e.gridSpan||1},rs:${e.rowSpan||1},cont:${!!e.isMergedContinue},v:${e.vMerge||""},lc:${e.logicalColIndex||0}}`).join(" | ");console.warn(`[TableProcessor][DEBUG] Row ${e} cells(${i.length}): ${t}`)}catch(e){}return!1}}return!0}parseTableBorders(e){let t={};return["top","left","bottom","right","insideH","insideV"].forEach(r=>{let i=e.querySelector(r);i||(i=e.querySelector(`a\\:${r}`)),i&&(t[r]=this.parseBorderProperties(i))}),t}parseCellBordersFromTcPr(e){let t={};for(let[r,i]of Object.entries({lnL:"left",lnR:"right",lnT:"top",lnB:"bottom"})){let a=e.querySelector(r);if(a||(a=e.querySelector(`a\\:${r}`)),a){let e=parseInt(a.getAttribute("w"))||0,r=this.parseColor(a),o=e>0?Math.max(1,Math.round(this.convertEMUToPixels(e))):1;null!==r&&o>0&&(t[i]={style:"single",width:o,color:r})}}return Object.keys(t).length>0?t:null}parseCellBorders(e){return this.parseTableBorders(e)}parseBorderProperties(e){let t=this.parseColor(e),r=parseInt(e.getAttribute("w"))||0,i=0;if(r>0)i=Math.max(1,Math.round(this.convertEMUToPixels(r)));else{let t=parseInt(e.getAttribute("sz"))||0;t>0&&(i=Math.max(1,Math.round(96/72*(t/8))))}return{style:e.getAttribute("val")||"single",width:i,size:parseInt(e.getAttribute("sz"))||0,color:t,space:parseInt(e.getAttribute("space"))||0}}parseTableShading(e){return this.parseCellShading(e)}parseCellShading(e){let t=e.getAttribute("fill"),r=e.getAttribute("color"),i=null;if("a:solidFill"===e.tagName||"solidFill"===e.tagName)i=this.parseColor(e);else{let t=e.querySelector("solidFill")||e.querySelector("a\\:solidFill");t&&(i=this.parseColor(t))}return{fill:t,color:r?this.parseColorFromHex(r):null,fillColor:i}}parseCellMargins(e){let t={};return["top","left","bottom","right"].forEach(r=>{let i=e.querySelector(r);i||(i=e.querySelector(`a\\:${r}`)),i&&(t[r]=parseInt(i.getAttribute("w"))||0)}),t}extractTableStructure(e){if(!e.graphicData||!e.graphicData.tableXml)return null;try{let t=this.parseTableFromXML(e.graphicData.tableXml);if(!t)return null;return{id:e.id,name:e.name,type:"table",properties:this.extractTableProperties(t),structure:this.extractTableStructureData(t),content:this.extractTableContent(t),styling:this.extractTableStyling(t),position:e.bounds||e.properties?.transform,metadata:{rowCount:t.getRowCount(),columnCount:t.getColumnCount(),hasMergedCells:this.hasMergedCells(t),tableStyle:t.getTableProperties()?.style||"TableGrid"}}}catch(e){return console.warn("Error extracting table structure:",e),null}}extractTableProperties(e){let t=e.getTableProperties()||{};return{style:t.style||"TableGrid",layout:t.layout||"autofit",width:t.width||"auto",alignment:t.alignment||"left",borders:t.borders||{},shading:t.shading||{},spacing:{before:t.spacing?.before||0,after:t.spacing?.after||0,line:t.spacing?.line||240}}}extractTableStructureData(e){let t=e.getRows();return{grid:e.getTableGrid().map((e,t)=>({index:t,width:e.width,type:e.type||"auto"})),rows:t.map((e,t)=>({index:t,height:e.height,heightRule:e.heightRule||"auto",isHeader:e.isHeader||!1,cells:e.getCells().map((e,t)=>({index:t,gridSpan:e.gridSpan||1,rowSpan:e.rowSpan||1,vMerge:e.vMerge||null,isMergedContinue:e.isMergedContinue||!1,mergeParent:e.mergeParent||null}))}))}}extractTableContent(e){return{cells:e.getRows().map((e,t)=>e.getCells().map((e,r)=>({rowIndex:t,cellIndex:r,text:this.extractCellText(e),textBody:this.extractCellTextBody(e),content:this.extractCellContent(e)})))}}extractTableStyling(e){let t=e.getRows();return{table:{borders:e.getTableProperties()?.borders||{},shading:e.getTableProperties()?.shading||{},style:e.getTableProperties()?.style||"TableGrid"},rows:t.map((e,t)=>({index:t,height:e.height,heightRule:e.heightRule||"auto",isHeader:e.isHeader||!1})),cells:t.map((e,t)=>e.getCells().map((e,r)=>({rowIndex:t,cellIndex:r,borders:e.borders||{},shading:e.shading||{},margins:e.margins||{},verticalAlignment:e.verticalAlignment||"top",textDirection:e.textDirection||"lr"})))}}hasMergedCells(e){for(let t of e.getRows())for(let e of t.getCells())if(e.gridSpan>1||e.rowSpan>1||e.isMergedContinue)return!0;return!1}extractCellTextBody(e){let t=e.getTextBody();return t&&t.paragraphs?{paragraphs:t.paragraphs.map(e=>({properties:e.properties||{},runs:e.runs?.map(e=>({text:e.text||"",properties:e.properties||{}}))||[]}))}:null}extractCellContent(e){let t={type:"text",data:null},r=e.getTextBody();return r&&r.paragraphs&&(t.type="text",t.data=this.extractCellTextBody(e)),t}extractCellText(e){return e.textBody&&e.textBody.paragraphs?e.textBody.paragraphs.map(e=>e.runs?e.runs.map(e=>e.text||"").join(""):"").join("\n"):""}getTableData(e){return null}getAllTableData(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r];if(i&&i.shapes){for(let e of i.shapes)if(e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===e.graphicData.uri){let i=this.extractTableStructure(e);i&&(i.slideIndex=r,i.shapeId=e.id,i.shapeName=e.name,t.push(i))}}}return t}parseTextBodyFromElement(e){let t=e.querySelector("txBody");if(t||(t=e.querySelector("a\\:txBody")),!t)return null;let r={paragraphs:[]};try{let e=t.querySelector("bodyPr");if(e||(e=t.querySelector("a\\:bodyPr")),e){let t={wrap:!0},i=e.getAttribute("wrap");i&&"none"===i.toLowerCase()&&(t.wrap=!1);let a=e.getAttribute("anchor");a&&(t.anchor=a);let o=e.getAttribute("rot");o&&(t.rotation=parseInt(o)||0);let l=e.getAttribute("lIns"),s=e.getAttribute("rIns"),n=e.getAttribute("tIns"),h=e.getAttribute("bIns");l&&(t.leftMargin=parseInt(l)||0),s&&(t.rightMargin=parseInt(s)||0),n&&(t.topMargin=parseInt(n)||0),h&&(t.bottomMargin=parseInt(h)||0),r.bodyProperties=t}}catch(e){}let i=t.querySelectorAll("p");return 0===i.length&&(i=t.querySelectorAll("a\\:p")),i.forEach(e=>{let t={runs:[],properties:{}},i=e.querySelector("pPr");if(i||(i=e.querySelector("a\\:pPr")),i){let e=i.getAttribute("algn");e&&(t.properties.alignment=e)}let a=e.querySelectorAll("r");0===a.length&&(a=e.querySelectorAll("a\\:r")),a.forEach(e=>{let r={text:"",properties:{}},i=e.querySelector("t");i||(i=e.querySelector("a\\:t")),i&&(r.text=i.textContent||"");let a=e.querySelector("rPr");if(a||(a=e.querySelector("a\\:rPr")),a){let e=a.querySelector("solidFill")||a.querySelector("a\\:solidFill");e&&(r.properties.color=this.parseColor(e));let t=a.getAttribute("sz");t?r.properties.fontSize=parseInt(t)/100:r.properties.fontSize=12,r.properties.bold="1"===a.getAttribute("b"),r.properties.italic="1"===a.getAttribute("i");let i=a.getAttribute("u");i&&"none"!==i&&(r.properties.underline=!0);let o=a.getAttribute("strike");o&&"noStrike"!==o&&(r.properties.strikethrough=!0);let l=a.getAttribute("typeface")||a.getAttribute("fontFamily");if(!l){let e=a.querySelector("latin")||a.querySelector("a\\:latin");e&&(l=e.getAttribute("typeface"))}l?r.properties.fontFamily=l:r.properties.fontFamily="Arial"}t.runs.push(r)}),r.paragraphs.push(t)}),r.paragraphs.length>0?r:null}parseColor(e){if(!e||e.querySelector("noFill")||e.querySelector("a\\:noFill"))return null;let t=e.querySelector("solidFill")||e.querySelector("a\\:solidFill");if(t){let e=t.querySelector("srgbClr")||t.querySelector("a\\:srgbClr");if(e){let t=e.getAttribute("val");if(t){let e=this.parseColorFromHex(t);if(e)return e}}let r=t.querySelector("schemeClr")||t.querySelector("a\\:schemeClr");if(r){let e=r.getAttribute("val"),t=this.resolveSchemeColor(e);if(t)return t}}let r=e.querySelector("srgbClr")||e.querySelector("a\\:srgbClr");if(r){let e=r.getAttribute("val");if(e){let t=this.parseColorFromHex(e);if(t)return t}}let i=e.querySelector("schemeClr")||e.querySelector("a\\:schemeClr");if(i){let e=i.getAttribute("val"),t=this.resolveSchemeColor(e);if(t)return t}let a=e.getAttribute("color");if(a){let e=this.parseColorFromHex(a);if(e)return e}return null}resolveSchemeColor(e){if(!e)return null;let t={tx1:"#000000",tx2:"#FFFFFF",bg1:"#FFFFFF",bg2:"#EEECE1",accent1:"#5B9BD5",accent2:"#ED7D31",accent3:"#A5A5A5",accent4:"#FFC000",accent5:"#4472C4",accent6:"#70AD47"}[e];return t?this.parseColorFromHex(t):null}parseColorFromHex(e){if(!e||"string"!=typeof e)return null;if(6===(e=e.replace("#","")).length){let t=parseInt(e.substring(0,2),16);return{r:t,g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:255}}if(3===e.length){let t=parseInt(e.charAt(0)+e.charAt(0),16);return{r:t,g:parseInt(e.charAt(1)+e.charAt(1),16),b:parseInt(e.charAt(2)+e.charAt(2),16),a:255}}return null}convertEMUToPixels(e){return e&&"number"==typeof e?e/914400*96:3.78}cleanup(){this.tableCache.clear()}_getValidator(){return"u">typeof window&&window.DataValidator?window.DataValidator:class{validate(){return{valid:!0,errors:[]}}}}_getErrorBoundary(){return"u">typeof window&&window.ErrorBoundary?window.ErrorBoundary:class{wrap(e){return e}}}_validateConfig(e){try{let t=new(this._getValidator())({throwOnError:!1}).validate(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}}});!t.valid&&this.logger&&this.logger.log("warn",this.constructor.name,"TableProcessor","Invalid configuration:",t.errors)}catch(e){}return e}_validateRenderInput(e,t,r,i,a,o,l){let s=[];if(e&&"object"==typeof e)for(let t of["SaveGrState","RestoreGrState","b_color1","TableRect"])"function"!=typeof e[t]&&s.push(`Graphics object missing required method: ${t}`);else s.push("Graphics object is required");return t&&"object"==typeof t||s.push("Shape object is required"),"number"==typeof r&&isFinite(r)||s.push("X coordinate must be a finite number"),"number"==typeof i&&isFinite(i)||s.push("Y coordinate must be a finite number"),("number"!=typeof a||!isFinite(a)||a<=0)&&s.push("Width must be a positive finite number"),("number"!=typeof o||!isFinite(o)||o<=0)&&s.push("Height must be a positive finite number"),l&&"object"!=typeof l&&s.push("Options must be an object"),{valid:0===s.length,errors:s}}_validateTableXML(e){if("string"!=typeof e||0===e.trim().length)throw this._createError("Table XML must be a non-empty string",{name:"ValidationError",code:"INVALID_TABLE_XML"});if(!e.includes("<")||!e.includes(">"))throw this._createError("Table XML does not appear to be valid XML",{name:"ValidationError",code:"MALFORMED_TABLE_XML"});if(!["tbl","tr","tc"].some(t=>e.includes(`<${t}`)||e.includes(`<a:${t}`)))throw this._createError("Table XML missing required table elements",{name:"ValidationError",code:"INCOMPLETE_TABLE_XML"})}_validateParsedTable(e){if(!e)throw this._createError("Parsed table is null or undefined",{name:"ValidationError",code:"NULL_PARSED_TABLE"});for(let t of["getRowCount","getColumnCount","getCell"])if("function"!=typeof e[t])throw this._createError(`Parsed table missing required method: ${t}`,{name:"ValidationError",code:"INVALID_TABLE_STRUCTURE"});let t=e.getRowCount(),r=e.getColumnCount();if(t<=0||r<=0)throw this._createError(`Invalid table dimensions: ${t}x${r}`,{name:"ValidationError",code:"INVALID_TABLE_DIMENSIONS"});if(t*r>this.config.maxTableSize)throw this._createError(`Table size ${t*r} exceeds maximum ${this.config.maxTableSize}`,{name:"ValidationError",code:"TABLE_TOO_LARGE"})}_validateTableStructure(e){try{let t=e.getRowCount(),r=e.getColumnCount();(t>100||r>50)&&this.logger&&this.logger.log("warn",this.constructor.name,"TableProcessor",`Large table detected: ${t}x${r}`);let i=0;for(let a=0;a<Math.min(t,10);a++)for(let t=0;t<r;t++){let r=e.getCell(a,t);r&&(i++,r.textBody&&"string"==typeof r.textBody&&r.textBody.length>this.config.maxCellTextLength&&this.logger&&this.logger.log("warn",this.constructor.name,"TableProcessor",`Cell text length ${r.textBody.length} exceeds maximum ${this.config.maxCellTextLength}`))}if(0===i)throw this._createError("Table has no valid cells",{name:"ValidationError",code:"EMPTY_TABLE"})}catch(e){throw this._enhanceError(e,"table_structure_validation")}}async _safeDrawTableBackgroundAndOuterBorder(e,t,r,i,a,o){try{this.drawTableBackgroundAndOuterBorder(e,t,r,i,a,o)}catch(e){this.logger&&this.logger.log("warn",this.constructor.name,"TableProcessor","Error drawing table background/border:",e)}}async _safeDrawCellsBackground(e,t,r,i,a,o){try{this.drawCellsBackground(e,t,r,i,a,o)}catch(e){this.logger&&this.logger.log("warn",this.constructor.name,"TableProcessor","Error drawing cell backgrounds:",e)}}async _safeDrawCellsContent(e,t,r,i,a,o){try{this.drawCellsContent(e,t,r,i,a,o)}catch(e){throw console.error("[TableProcessor] DETAILED ERROR drawing cell content:"),console.error("[TableProcessor] Error message:",e.message),console.error("[TableProcessor] Error stack:",e.stack),console.error("[TableProcessor] Error object:",e),this.logger&&this.logger.logError(this.constructor.name,"TableProcessor","Error drawing cell content:",e),e}}async _safeDrawCellsBorders(e,t,r,i,a,o){try{this.drawCellsBorders(e,t,r,i,a,o)}catch(e){this.logger&&this.logger.log("warn",this.constructor.name,"TableProcessor","Error drawing cell borders:",e)}}_handleValidationError(e,t){let r=`Validation failed for ${e}: ${t.join(", ")}`;return this.logger&&this.logger.logError(this.constructor.name,"TableProcessor",r),this._createError(r,{name:"ValidationError",code:"INPUT_VALIDATION_FAILED",details:{operation:e,errors:t}})}_updatePerformanceMetrics(e){this.performanceMetrics.tablesProcessed++;let t=performance.now()-e,r=this.performanceMetrics.averageRenderTime*(this.performanceMetrics.tablesProcessed-1);this.performanceMetrics.averageRenderTime=(r+t)/this.performanceMetrics.tablesProcessed,this.logger&&t>1e3&&this.logger.log("warn",this.constructor.name,"TableProcessor",`Slow table render: ${Math.round(t)}ms`)}_createError(e,t={}){let r=Error(e);return r.name=t.name||"TableProcessingError",r.code=t.code||null,r.context="TableProcessor",r.timestamp=new Date().toISOString(),r.recoverable=!1!==t.recoverable,t.details&&(r.details=t.details),r}_enhanceError(e,t,r={}){if(e.enhanced)return e;let i=e instanceof Error?e:Error(String(e));return i.operation=t,i.tableProcessorContext=r,i.timestamp=new Date().toISOString(),i.enhanced=!0,i}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}}};"u">typeof globalThis&&(globalThis.TableProcessor=T);var P={exports:{}};P.exports,!function(){if(h)return P.exports;h=1;class e{constructor(){this.type="",this.subtype="",this.is3D=!1,this.title="",this.series=[],this.categories=[],this.styling={},this.legend=null,this.axes={},this.plotArea={},this.dataLabels={},this.raw=null}}class t{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 r{constructor(e,t={}){this.context=e,this.currentSlideContext=null;try{this.logger=new Logger("ChartProcessor")}catch(e){console.warn("[ChartProcessor] Logger initialization failed, using fallback:",e),this.logger=this._createFallbackLogger()}this.fontConfig=null}setSlideContext(e){this.currentSlideContext=e}clearSlideContext(){this.currentSlideContext=null}async parseChartFromGraphicFrame(e){try{let t=this.getShapeName(e),r=e.querySelector("graphic")||e.querySelector("a\\:graphic")||e.querySelector('[*|localName="graphic"]');if(!r)return null;let i=r.querySelector("graphicData")||r.querySelector("a\\:graphicData")||r.querySelector('[*|localName="graphicData"]');if(!i)return null;let a=i.getAttribute("uri");if("http://schemas.openxmlformats.org/drawingml/2006/chart"!==a)return null;let o=i.querySelector("chart")||i.querySelector("c\\:chart")||i.querySelector('[*|localName="chart"]');if(!o){if(i.querySelector("chartSpace, c\\:chartSpace"))return this.parseEmbeddedChartData(i,t);return null}let l=o.getAttribute("r:id");if(!l){let e=this.parseEmbeddedChartData(i,t);if(e&&this.hasRealChartData(e))return e;return null}if(!this.currentSlideContext)return{type:"DEFERRED_CHART",relationshipId:l,needsSlideContext:!0};return await this.loadChartFromRelationship(l,this.currentSlideContext)}catch(e){return this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing chart from graphic frame",e),null}}parseEmbeddedChartData(t,r=null){let i=new e;try{let e=t.querySelector("chartSpace, c\\:chartSpace");if(!e)return null;return this.parseChartSpace(e,i),i}catch(e){return this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing embedded chart data",e),null}}parseChartSpace(e,t){let r=e.querySelector("roundedCorners, c\\:roundedCorners");if(r){let e=r.getAttribute("val");t.roundedCorners="1"===e||"true"===e}else t.roundedCorners=!1;let i=e.querySelector("chart, c\\:chart");i&&this.parseChart(i,t);let a=Array.from(e.children||[]).find(e=>"spPr"===e.localName);a&&(t.chartSpaceShapeProperties=this.parseShapeProperties(a)),this.parsePrintSettings(e,t),this.parseExternalData(e,t)}parseChart(e,t){let r=e.querySelector("title, c\\:title");r&&(t.title=this.parseTitle(r));let i=e.querySelector("plotArea, c\\:plotArea");i&&this.parsePlotArea(i,t);let a=e.querySelector("legend, c\\:legend");a&&(t.legend=this.parseLegend(a));let o=e.querySelector("autoTitleDeleted, c\\:autoTitleDeleted");o&&"1"===o.getAttribute("val")&&(t.title=""),t.hasDataTable=!!e.querySelector("dTable, c\\:dTable")}parsePlotArea(e,t){t.plotArea=this.parsePlotAreaProperties(e);let r=!1;for(let i of["barChart","bar3DChart","colChart","col3DChart","lineChart","line3DChart","pieChart","pie3DChart","doughnutChart","areaChart","area3DChart","scatterChart","bubbleChart","radarChart","stockChart","surfaceChart","surface3DChart","waterfallChart","comboChart","sunburstChart","treemapChart","histogramChart","boxWhiskerChart"])for(let a of e.querySelectorAll(`${i}, c\\:${i}`))if(r){let e=this.normalizeChartType(i),r=a.querySelectorAll("ser, c\\:ser");for(let i=0;i<r.length;i++){let a=this.parseSeries(r[i],e);a&&(a.seriesType=e,a.isSecondaryAxis=!0,t.series.push(a))}t.isCombo=!0}else this.parseSpecificChart(a,i,t),r=!0;this.parseAxes(e,t);let i=e.querySelector("dLbls, c\\:dLbls");i&&(t.dataLabels=this.parseDataLabels(i),t.dataLabels&&t.dataLabels.showValue&&(t.showDataLabels=!0))}parseSpecificChart(e,t,r){r.rawType=t,r.is3D=t.includes("3D"),this.parseChartSubtype(e,r),r.type=this.normalizeChartType(r.rawType,r);let i=e.querySelector("dLbls, c\\:dLbls");i&&(r.dataLabels=this.parseDataLabels(i),r.dataLabels&&r.dataLabels.showValue&&(r.showDataLabels=!0));let a=e.querySelectorAll("ser, c\\:ser");for(let e=0;e<a.length;e++){let t=a[e],i=this.parseSeries(t,r.type);if(i){try{let e=t.querySelectorAll("dPt, c\\:dPt");e&&e.length>0&&(i.pointFills=[],e.forEach(e=>{let t=e.querySelector("idx, c\\:idx"),r=e.querySelector("spPr, c\\:spPr");if(t&&r){let e=parseInt(t.getAttribute("val"));if(!isNaN(e)){let t=this.parseShapeProperties(r);t&&t.fill&&(i.pointFills[e]=t.fill)}}}))}catch(e){this.logger.log("warn",this.constructor.name,"Error parsing data point formatting (dPt):",e)}!i.dataLabels&&r.dataLabels?i.dataLabels={...r.dataLabels}:i.dataLabels,r.series.push(i)}}try{if("pie"===r.type||"doughnut"===r.type){let t=e.querySelector("firstSliceAng, c\\:firstSliceAng");if(t){let e=parseInt(t.getAttribute("val"));isNaN(e)||(r.firstSliceAng=e)}let i=e.querySelector("holeSize, c\\:holeSize");if(i){let e=parseInt(i.getAttribute("val"));isNaN(e)||(r.holeSize=e)}}if("waterfall"===r.type){r.waterfallType="standard";let t=e.querySelectorAll("subtotal, c\\:subtotal");t.length>0&&(r.subtotals=[],t.forEach(e=>{let t=e.getAttribute("val");t&&r.subtotals.push({value:t})}))}if("combo"===r.type&&(r.comboTypes=[],["barChart","lineChart","areaChart","scatterChart"].forEach(t=>{e.querySelector(`${t}, c\\:${t}`)&&r.comboTypes.push(this.normalizeChartType(t))})),"radar"===r.type){let t=e.querySelector("radarStyle, c\\:radarStyle");t?r.radarStyle=t.getAttribute("val")||"standard":r.radarStyle="standard"}if("bubble"===r.type){let t=e.querySelector("bubble3D, c\\:bubble3D");t&&(r.bubble3D="1"===t.getAttribute("val"));let i=e.querySelector("bubbleScale, c\\:bubbleScale");if(i){let e=parseInt(i.getAttribute("val"));isNaN(e)||(r.bubbleScale=e)}}}catch(e){this.logger.log("warn",this.constructor.name,"Error parsing chart type-specific properties:",e)}0===r.categories.length&&r.series.length>0&&(r.categories=[...r.series[0].categories]),r.series.length>0&&r.series[0].categoryFormatCode&&(r.categoryFormatCode=r.series[0].categoryFormatCode),r.series.length>0&&r.series[0].outerCategoryLevels&&(r.outerCategoryLevels=r.series[0].outerCategoryLevels)}parseSeries(e,r){let i=new t;try{let t=e.querySelector("idx, c\\:idx");t&&(i.index=parseInt(t.getAttribute("val"))||0);let r=e.querySelector("tx, c\\:tx");r&&(i.name=this.parseSeriesText(r));let a=e.querySelector("cat, c\\:cat"),o=e.querySelector("xVal, c\\:xVal");if(a){i.categories=this.parseSeriesData(a);let e=a.querySelector("numRef, c\\:numRef");if(e){let t=e.querySelector("numCache, c\\:numCache");if(t){let e=t.querySelector("formatCode, c\\:formatCode");e&&e.textContent&&(i.categoryFormatCode=e.textContent.trim())}}let t=a.querySelector("multiLvlStrRef, c\\:multiLvlStrRef");t&&(i.outerCategoryLevels=this.parseOuterCategoryLevels(t,i.categories.length))}else o&&(i.categories=this.parseSeriesData(o));let l=e.querySelector("val, c\\:val"),s=e.querySelector("yVal, c\\:yVal");l?i.values=this.parseSeriesData(l):s&&(i.values=this.parseSeriesData(s));let n=e.querySelector("bubbleSize, c\\:bubbleSize");n&&(i.bubbleSizes=this.parseSeriesData(n)),i.fill=this.parseSeriesFill(e),i.line=this.parseSeriesLine(e),i.marker=this.parseSeriesMarker(e);let h=e.querySelector("spPr, c\\:spPr");if(h){let e=this.parseShapeProperties(h);e.outerShadow&&(i.outerShadow=e.outerShadow)}let c=e.querySelector("smooth, c\\:smooth");i.smooth=!!c&&"1"===c.getAttribute("val"),i.fill&&"noFill"!==i.fill&&(void 0!==i.fill.r||"string"==typeof i.fill)?i.color=i.fill:i.line&&(void 0!==i.line.r||"string"==typeof i.line)&&(i.color=i.line);let u=e.querySelector("dLbls, c\\:dLbls");if(u&&(i.dataLabels=this.parseDataLabels(u),i.dataLabels&&i.dataLabels.formatting&&i.dataLabels.formatting.font)){let e=i.dataLabels.formatting.font;e.size&&!e.fontSize&&(e.fontSize=e.size,delete e.size)}return i}catch(e){return this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing series",e),null}}parseSeriesData(e){try{let t=e.querySelector("numRef, c\\:numRef"),r=e.querySelector("strRef, c\\:strRef"),i=e.querySelector("multiLvlStrRef, c\\:multiLvlStrRef"),a=e.querySelector("numLit, c\\:numLit"),o=e.querySelector("strLit, c\\:strLit");if(t)return this.parseNumberReference(t);if(r)return this.parseStringReference(r);if(i)return this.parseMultiLevelStringReference(i);else if(a)return this.parseNumberLiteral(a);else if(o)return this.parseStringLiteral(o)}catch(e){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing series data",e)}return[]}parseNumberReference(e){let t=[],r=e.querySelector("numCache, c\\:numCache");if(r)for(let e of r.querySelectorAll("pt, c\\:pt")){let r=e.querySelector("v, c\\:v");if(r){let e=parseFloat(r.textContent);t.push(isNaN(e)?0:e)}}return t}parseStringReference(e){let t=[],r=e.querySelector("strCache, c\\:strCache");if(r)for(let e of r.querySelectorAll("pt, c\\:pt")){let r=e.querySelector("v, c\\:v");r&&t.push(r.textContent||"")}return t}parseMultiLevelStringReference(e){let t=[];try{let r=e.querySelector("multiLvlStrCache, c\\:multiLvlStrCache");if(r){let e=r.querySelectorAll("lvl, c\\:lvl"),i=e.length>0?e[0]:null;if(i)for(let e of i.querySelectorAll("pt, c\\:pt")){let r=e.querySelector("v, c\\:v");r&&t.push(r.textContent||"")}}return t}catch(e){return this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing multi-level string reference",e),[]}}parseOuterCategoryLevels(e,t){try{let r=e.querySelector("multiLvlStrCache, c\\:multiLvlStrCache");if(!r)return null;let i=r.querySelectorAll("lvl, c\\:lvl");if(i.length<2)return null;let a=[];for(let e=1;e<i.length;e++){let r=i[e].querySelectorAll("pt, c\\:pt"),o=[],l=null;for(let e of r){let r=parseInt(e.getAttribute("idx")),i=e.querySelector("v, c\\:v"),a=i?(i.textContent||"").trim():"";a&&(l&&(l.endIndex=r-1),l={label:a,startIndex:r,endIndex:t-1},o.push(l))}o.length>0&&a.push(o)}return a.length>0?a:null}catch(e){return null}}parseNumberLiteral(e){let t=[];for(let r of e.querySelectorAll("pt, c\\:pt")){let e=r.querySelector("v, c\\:v");if(e){let r=parseFloat(e.textContent);t.push(isNaN(r)?0:r)}}return t}parseStringLiteral(e){let t=[];for(let r of e.querySelectorAll("pt, c\\:pt")){let e=r.querySelector("v, c\\:v");e&&t.push(e.textContent||"")}return t}parseSeriesText(e){let t=e.querySelector("strRef, c\\:strRef");if(t){let e=t.querySelector("strCache, c\\:strCache");if(e){let t=e.querySelector("pt, c\\:pt");if(t){let e=t.querySelector("v, c\\:v");if(e)return e.textContent||""}}}let r=e.querySelector("v, c\\:v");return r&&r.textContent||""}normalizeChartType(e,t=null){let 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"}[e]||e;return("barChart"===e||"bar3DChart"===e)&&t&&t.barDirection&&("col"===t.barDirection?r="column":"bar"===t.barDirection&&(r="bar")),r}hasRealChartData(e){if(!e||!e.series||0===e.series.length)return!1;let t=e.series[0];if(!t.values||0===t.values.length)return!1;let r=[4500,5200,4800,6100,5900];return!(t.values.length===r.length&&t.values.every((e,t)=>e===r[t]))}createPlaceholderChart(r,i=null){let a=new e;a.type="line",a.title={text:i||"Chart",formatting:{font:{fontFamily:"Calibri",fontSize:16,bold:!0},color:{r:0,g:0,b:0},alignment:"center"}},a.subtitle="Quarterly Revenue Trends 2023-2024",a.categories=["Q1 2023","Q2 2023","Q3 2023","Q4 2023","Q1 2024"];let o=new t;return o.index=0,o.name="Sales Trend",o.values=[4500,5200,4800,6100,5900],o.categories=[...a.categories],a.series.push(o),a.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:!0,minor:!1},visible:!0,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:!1}},gridlines:{major:!0,minor:!1},visible:!0,crosses:"autoZero"},series:null},a.legend={position:"b",overlay:!1,visible:!0,legendPos:"b"},a.dataLabels={showValue:!0,showCategoryName:!1,showSeriesName:!1,showPercent:!1,position:"above",formatting:{font:{fontFamily:"Arial",fontSize:9,bold:!0},color:{r:60,g:60,b:60},number:{formatCode:"#,##0",sourceLinked:!1}},separator:", ",delete:!1},a.showDataLabels=!0,a.styling={chartArea:{proportions:{width:.85,height:.75}},plotArea:{margins:{left:80,right:20,top:20,bottom:70}}},a}extractChartData(e,t={}){try{if(!e)throw Error("Shape parameter is required");let r=null;if("graphicFrame"===e.type)r=this.parseChartFromGraphicFrame(e.element||e);else if(e.graphicData)if(!e.graphicData.element)return null;else r=this.parseEmbeddedChartData(e.graphicData.element,e.name);else r=e.tagName?this.parseChartFromGraphicFrame(e):this.extractFromRawData(e,t);if(r&&this.validateChartData(r,t)&&this.hasRealChartData(r))return r;return this.logger.log("warn",this.constructor.name,"Chart data extraction failed validation or contains hardcoded data"),null}catch(e){if(this.logger.logError(this.constructor.name,"ChartProcessor","Error extracting chart data",e),console.error("[ChartProcessor] Error extracting chart data",e),t.throwOnError)throw e;return null}}validateChartData(t,r={}){try{if(!t||!(t instanceof e)&&(this.logger.log("warn",this.constructor.name,"Chart data is not an instance of ChartData class"),r.strict))return!1;let i={hasType:this.validateChartType(t.type),hasSeries:this.validateChartSeries(t.series),hasValidData:this.validateChartDataContent(t),hasValidStructure:this.validateChartStructure(t)};if(!["hasType","hasSeries","hasValidData"].every(e=>i[e]))return this.logger.log("warn",this.constructor.name,"Chart data failed required validation checks:",{type:i.hasType,series:i.hasSeries,data:i.hasValidData}),!1;if(r.strict&&!i.hasValidStructure)return this.logger.log("warn",this.constructor.name,"Chart data failed strict structure validation"),!1;return!0}catch(e){return this.logger.logError(this.constructor.name,"ChartProcessor","Error validating chart data",e),!1}}validateChartType(e){return"string"==typeof e&&e.length>0&&["area","bar","bar3d","bubble","doughnut","line","pie","radar","scatter","stock","surface","waterfall","combo","sunburst","treemap","histogram","boxWhisker"].includes(e.toLowerCase())}validateChartSeries(e){return!!Array.isArray(e)&&0!==e.length&&e.every(e=>this.validateSingleSeries(e))}validateSingleSeries(e){if(!e)return!1;let t="number"==typeof e.index&&e.index>=0,r=Array.isArray(e.values)&&e.values.length>0,i="string"==typeof e.name,a=this.validateSeriesDataConsistency(e);return t&&r&&i&&a}validateSeriesDataConsistency(e){if(!e.values||0===e.values.length)return!1;let t=e.values.every(e=>"number"==typeof e&&!isNaN(e)&&isFinite(e)),r=!0;return e.categories&&e.categories.length>0&&(r=e.categories.length===e.values.length),t&&r}validateChartDataContent(e){return!!e.series&&0!==e.series.length&&e.series.some(e=>e.values&&e.values.length>0&&e.values.some(e=>0!==e&&null!=e))}validateChartStructure(e){try{if(this.hasCircularReferences(e))return!1;let t="string"==typeof e.type&&Array.isArray(e.series)&&Array.isArray(e.categories),r=e.series.every(e=>e&&"number"==typeof e.index&&Array.isArray(e.values));return t&&r}catch(e){return this.logger.logError(this.constructor.name,"ChartProcessor","Error validating chart structure",e),!1}}hasCircularReferences(e,t=new Set){if(null===e||"object"!=typeof e)return!1;if(t.has(e))return!0;t.add(e);try{for(let r in e)if(e.hasOwnProperty(r)&&this.hasCircularReferences(e[r],t))return!0}catch(e){return!0}return t.delete(e),!1}extractFromRawData(r,i={}){try{let i=new e;return r.type&&(i.type=this.normalizeChartType(r.type)),r.title&&(i.title=String(r.title)),r.series&&Array.isArray(r.series)&&(i.series=r.series.map((e,r)=>{let i=new t;return i.index=e.index||r,i.name=e.name||`Series ${r+1}`,i.values=Array.isArray(e.values)?e.values:[],i.categories=Array.isArray(e.categories)?e.categories:[],i})),r.categories&&Array.isArray(r.categories)&&(i.categories=r.categories),i}catch(e){return this.logger.logError(this.constructor.name,"ChartProcessor","Error extracting from raw data",e),null}}parseTitle(e){try{let t={text:"",formatting:{font:{fontFamily:"Calibri",fontSize:16,bold:!1},color:{r:0,g:0,b:0},alignment:"center"},overlay:!1,position:"top"},r=e.querySelector("tx, c\\:tx");if(r&&(t.text=this.parseRichText(r)),!t.text){let r=e.querySelector("v, c\\:v");r&&(t.text=r.textContent||"")}if(!t.text){let r=e.querySelector("rich, c\\:rich");r&&(t.text=this.parseRichTextBody(r))}if(!t.text){let r=e.querySelectorAll("t, c\\:t, a\\:t");r.length>0&&(t.text=Array.from(r).map(e=>e.textContent||"").join(" ").trim())}let i=e.querySelector("txPr, c\\:txPr");if(i){let e=this.parseTextProperties(i);if(e){let r={...t.formatting.font||{},...e.font||{}};t.formatting={...t.formatting,...e,font:r},t.formatting.font&&t.formatting.font.size&&!t.formatting.font.fontSize&&(t.formatting.font.fontSize=t.formatting.font.size,delete t.formatting.font.size)}}let a=this.extractFontFromElement(e);if(a){let{color:e,...r}=a;t.formatting.font={...t.formatting.font||{},...r},e&&(t.formatting.color=e)}let o=e.querySelector("layout, c\\:layout");if(o){let e=o.querySelector("manualLayout, c\\:manualLayout");e&&(t.position=this.parseManualLayout(e))}let l=e.querySelector("overlay, c\\:overlay");return l&&(t.overlay="1"===l.getAttribute("val")),t}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing title:",e),""}}parseLegend(e){try{let t={position:"right",overlay:!1,visible:!0},r=e.querySelector("legendPos, c\\:legendPos");if(r){let e=r.getAttribute("val");e&&(t.position=e)}let i=e.querySelector("overlay, c\\:overlay");return i&&(t.overlay="1"===i.getAttribute("val")),t}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing legend:",e),{}}}parsePlotAreaProperties(e){try{let t={},r=e.querySelector("layout, c\\:layout");r&&(t.layout=this.parseLayout(r));let i=null;for(let t=0;t<e.childNodes.length;t++){let r=e.childNodes[t],a=r.tagName||r.localName||"";if("spPr"===a||"c:spPr"===a||a.endsWith(":spPr")){i=r;break}}return i&&(t.shapeProperties=this.parseShapeProperties(i)),t}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing plot area properties:",e),{}}}parseChartSubtype(e,t){try{let r=e.querySelector("grouping, c\\:grouping");r?t.subtype=r.getAttribute("val")||"clustered":"area"===t.type?t.subtype="standard":"bar"===t.type||"column"===t.type?t.subtype="clustered":"line"===t.type&&(t.subtype="standard");let i=e.querySelector("barDir, c\\:barDir");i&&(t.barDirection=i.getAttribute("val")||"col");let a=e.querySelector("gapWidth, c\\:gapWidth");a&&(t.gapWidth=parseInt(a.getAttribute("val"))||150);let o=e.querySelector("scatterStyle, c\\:scatterStyle");o&&(t.scatterStyle=o.getAttribute("val")||"marker"),"area"!==t.type||t.subtype||(t.subtype="standard"),"area"===t.type&&t.subtype}catch(e){this.logger.log("warn",this.constructor.name,"Error parsing chart subtype:",e),"area"===t.type&&(t.subtype="standard")}}parseAxes(e,t){try{t.axes={category:null,value:null,series:null};let r=e.querySelector("catAx, c\\:catAx"),i=e.querySelector("dateAx, c\\:dateAx");r?t.axes.category=this.parseAxis(r):i&&(t.axes.category=this.parseAxis(i));let a=e.querySelectorAll("valAx, c\\:valAx");if(a.length>0&&(t.axes.value=this.parseAxis(a[0])),a.length>1){let e=a[1],r=e.querySelector("c\\:axPos")||e.querySelector("axPos"),i=r?r.getAttribute("val"):"l";if("r"===i||"t"===i)t.hasSecondaryAxis=!0,t.axes.valueSecondary=this.parseAxis(a[1]);else if("scatter"===t.type){let e=a[0],r=e.querySelector("c\\:axPos")||e.querySelector("axPos"),i=r?r.getAttribute("val"):"l";("b"===i||"t"===i)&&(t.axes.category=this.parseAxis(a[0]),t.axes.value=this.parseAxis(a[1]))}else t.axes.valueSecondary=this.parseAxis(a[1])}let o=e.querySelector("serAx, c\\:serAx");o&&(t.axes.series=this.parseAxis(o))}catch(e){this.logger.log("warn",this.constructor.name,"Error parsing axes:",e)}}parseSeriesFill(e){try{let t=e.querySelector("spPr, c\\:spPr");if(t){let e=this.parseShapeProperties(t);if(e.noFill)return"noFill";return e.fill}return null}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing series fill:",e),null}}parseSeriesLine(e){try{let t=e.querySelector("spPr, c\\:spPr");if(t)return this.parseShapeProperties(t).line;return null}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing series line:",e),null}}parseSeriesMarker(e){try{let t=e.querySelector("marker, c\\:marker");if(t)return{symbol:this.parseMarkerSymbol(t),size:this.parseMarkerSize(t),fill:this.parseMarkerFill(t),line:this.parseMarkerLine(t)};return null}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing series marker:",e),null}}parseDataLabels(e){try{let t={showValue:!1,showCategoryName:!1,showSeriesName:!1,showPercent:!1,showBubbleSize:!1,showLeaderLines:!1,position:"center",separator:null,formatting:{font:null,color:null,number:null},delete:!1},r=e.querySelector("showVal, c\\:showVal");r&&(t.showValue="0"!==r.getAttribute("val"));let i=e.querySelector("showCatName, c\\:showCatName");i&&(t.showCategoryName="0"!==i.getAttribute("val"));let a=e.querySelector("showSerName, c\\:showSerName");a&&(t.showSeriesName="0"!==a.getAttribute("val"));let o=e.querySelector("showPercent, c\\:showPercent");o&&(t.showPercent="0"!==o.getAttribute("val"));let l=e.querySelector("showBubbleSize, c\\:showBubbleSize");l&&(t.showBubbleSize="0"!==l.getAttribute("val"));let s=e.querySelector("showLeaderLines, c\\:showLeaderLines");s&&(t.showLeaderLines="0"!==s.getAttribute("val"));let n=e.querySelector("separator, c\\:separator");n&&(t.separator=n.textContent||", ");let h=e.querySelector("dLblPos, c\\:dLblPos");h&&(t.position=h.getAttribute("val")||"center");let c=e.querySelector("delete, c\\:delete");c&&(t.delete="1"===c.getAttribute("val"));let u=e.querySelector("numFmt, c\\:numFmt");u&&(t.formatting.number={formatCode:u.getAttribute("formatCode")||"#,##0",sourceLinked:"1"===u.getAttribute("sourceLinked")});let d=e.querySelector("txPr, c\\:txPr");if(d){let e=d.querySelector("defRPr, a\\:defRPr");if(e){t.formatting.font||(t.formatting.font={}),this.parseRunProperties(e,t.formatting.font),t.formatting.font.fontFamily||(t.formatting.font.fontFamily="Arial"),t.formatting.font.fontSize||(t.formatting.font.fontSize=9),(null===t.formatting.font.bold||void 0===t.formatting.font.bold)&&(t.formatting.font.bold=!0);let r=e.querySelector("solidFill, a\\:solidFill");r&&(t.formatting.color=this.parseColorElement(r))}}let p=e.querySelector("spPr, c\\:spPr");if(p&&(t.formatting.shape=this.parseShapeProperties(p)),t.formatting&&t.formatting.font){let e=t.formatting.font;e.size&&!e.fontSize&&(e.fontSize=e.size,delete e.size)}return t}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing data labels:",e),null}}parsePrintSettings(e,t){try{let r=e.querySelector("printSettings, c\\:printSettings");r&&(t.printSettings={headerFooter:this.parsePrintHeaderFooter(r),pageMargins:this.parsePrintMargins(r),pageSetup:this.parsePrintPageSetup(r)})}catch(e){this.logger.log("warn",this.constructor.name,"Error parsing print settings:",e)}}parseExternalData(e,t){try{let r=e.querySelector("externalData, c\\:externalData");r&&(t.externalData={id:r.getAttribute("r:id"),autoUpdate:"1"===r.getAttribute("autoUpdate")})}catch(e){this.logger.log("warn",this.constructor.name,"Error parsing external data:",e)}}parseLayout(e){return{}}parseShapeProperties(e){try{let t={fill:null,line:null};if(!e)return t;let r=!1;for(let i=0;i<e.childNodes.length&&!r;i++){let a=e.childNodes[i],o=(a.localName||a.tagName||"").replace(/^[^:]+:/,"");if("noFill"===o)t.fill=null,t.noFill=!0,r=!0;else if("solidFill"===o)t.fill=this.parseColorElement(a),r=!0;else if("gradFill"===o){let e=a.querySelector("gs, a\\:gs");if(e){let r=e.querySelector("solidFill, a\\:solidFill");r&&(t.fill=this.parseColorElement(r))}r=!0}else if("pattFill"===o){let e=a.querySelector("fgClr, a\\:fgClr");if(e){let r=e.querySelector("solidFill, a\\:solidFill, srgbClr, a\\:srgbClr");r&&(t.fill=this.parseColorElement(r))}r=!0}}let i=e.querySelector("effectLst, a\\:effectLst");if(i){let e=i.querySelector("outerShdw, a\\:outerShdw");if(e){let r=parseInt(e.getAttribute("blurRad"))||0,i=parseInt(e.getAttribute("dist"))||0,a=parseInt(e.getAttribute("dir"))||0,o=e.querySelector("srgbClr, a\\:srgbClr"),l="#000000",s=1;if(o){l="#"+(o.getAttribute("val")||"000000");let e=o.querySelector("alpha, a\\:alpha");e&&(s=(parseInt(e.getAttribute("val"))||1e5)/1e5)}t.outerShadow={blurRad:r,dist:i,dir:a,color:l,alpha:s}}}let a=e.querySelector("ln, a\\:ln");if(a)if(t.line={width:parseInt(a.getAttribute("w"))||1,color:null,style:"solid",noFill:!1},a.querySelector("noFill, a\\:noFill"))t.line.noFill=!0;else{let e=a.querySelector("solidFill, a\\:solidFill");e&&(t.line.color=this.parseColorElement(e))}return t}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing shape properties:",e),{fill:null,line:null}}}parseRunProperties(e,t){try{let r=e.querySelector("latin, a\\:latin");r&&(t.fontFamily=r.getAttribute("typeface")||t.fontFamily);let i=e.getAttribute("sz");i&&(t.fontSize=this.convertPptxFontSize(i,"hundredths"));let a=e.getAttribute("b");null!==a&&(t.bold="0"!==a&&"false"!==a);let o=e.getAttribute("i");null!==o&&(t.italic="0"!==o&&"false"!==o);let l=e.getAttribute("u");null!==l&&(t.underline="none"!==l&&"0"!==l);let s=e.getAttribute("strike");null!==s&&(t.strikethrough="noStrike"!==s&&"0"!==s)}catch(e){this.logger.log("warn",this.constructor.name,"Error parsing run properties:",e)}}convertPptxFontSize(e,t="points"){let r,i=Number(e);if(isNaN(i)||i<=0)return 11;switch(t){case"hundredths":r=i/100;break;case"emu":r=i/12700;break;case"twips":r=i/20;break;default:r=i}return Math.max(6,Math.min(120,Math.round(r)))}extractFontFromElement(e){try{let t={fontFamily:null,fontSize:null,bold:null,italic:null,color:null},r=e.querySelector("txPr, c\\:txPr");if(r){let e=this.parseTextProperties(r);e&&e.font&&(Object.assign(t,e.font),e.color&&(t.color=e.color))}let i=e.querySelector("defRPr, a\\:defRPr");if(i){this.parseRunProperties(i,t);let e=i.querySelector("solidFill, a\\:solidFill");e&&(t.color=this.parseColorElement(e))}let a=e.querySelector("rPr, a\\:rPr");a&&this.parseRunProperties(a,t);let o={};return Object.keys(t).forEach(e=>{null!==t[e]&&void 0!==t[e]&&(o[e]=t[e])}),Object.keys(o).length>0?o:null}catch(e){return this.logger.log("warn",this.constructor.name,"Error extracting font from element:",e),null}}parseAxis(e){try{let t={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:!0,minor:!1},visible:!0,crosses:"autoZero"},r=e.querySelector("axId, c\\:axId");r&&(t.id=r.getAttribute("val"));let i=e.querySelector("axPos, c\\:axPos");i&&(t.position=i.getAttribute("val")||"bottom");let a=e.querySelector("title, c\\:title");if(a){let e=this.parseTitle(a);"string"==typeof e?t.title={text:e,formatting:{font:{fontFamily:"Calibri",fontSize:12,bold:!0},color:{r:68,g:68,b:68}}}:t.title=e}let o=e.querySelector("txPr, c\\:txPr");if(o){t.tickLabels.formatting=this.parseTextProperties(o);let e=o.querySelector("bodyPr, a\\:bodyPr");if(e){let r=e.getAttribute("rot");r&&(t.tickLabels.rotation=parseInt(r)/6e4)}}else{let r=this.extractFontFromElement(e);r&&(t.tickLabels.formatting={font:r,color:r.color||{r:68,g:68,b:68}})}let l=e.querySelector("scaling, c\\:scaling");l&&(t.scaling=this.parseAxisScaling(l));let s=e.querySelector("majorTickMark, c\\:majorTickMark");s&&(t.tickMarks.major=s.getAttribute("val")||"outside");let n=e.querySelector("minorTickMark, c\\:minorTickMark");n&&(t.tickMarks.minor=n.getAttribute("val")||"none");let h=e.querySelector("tickLblPos, c\\:tickLblPos");h&&(t.tickLabels.position=h.getAttribute("val")||"nextTo");let c=e.querySelector("majorGridlines, c\\:majorGridlines");if(c){t.gridlines.major=!0;let e=c.querySelector("prstDash, a\\:prstDash");if(e){let r=e.getAttribute("val")||"solid";t.gridlines.dash="solid"!==r&&"sysDot"!==r?r:null}let r=c.querySelector("srgbClr, a\\:srgbClr");r&&(t.gridlines.color="#"+(r.getAttribute("val")||"888888"))}e.querySelector("minorGridlines, c\\:minorGridlines")&&(t.gridlines.minor=!0);let u=e.querySelector("numFmt, c\\:numFmt");u&&(t.tickLabels.format={formatCode:u.getAttribute("formatCode"),sourceLinked:"1"===u.getAttribute("sourceLinked")});let d=e.querySelector("delete, c\\:delete")||e.getElementsByTagName("c:delete")[0]||e.getElementsByTagName("delete")[0];if(d){let e=d.getAttribute("val");("1"===e||"true"===e)&&(t.visible=!1)}let p=e.querySelector("majorUnit, c\\:majorUnit");p&&null===t.scaling.majorUnit&&(t.scaling.majorUnit=parseFloat(p.getAttribute("val")));let g=e.querySelector("minorUnit, c\\:minorUnit");g&&null===t.scaling.minorUnit&&(t.scaling.minorUnit=parseFloat(g.getAttribute("val")));let f=e.querySelector("dispUnits, c\\:dispUnits");if(f){let e=f.querySelector("builtInUnit, c\\:builtInUnit"),r=f.querySelector("custUnit, c\\:custUnit");e?t.scaling.displayUnit=({hundreds:100,thousands:1e3,tenOfThousands:1e4,hundredsOfThousands:1e5,millions:1e6,tenOfMillions:1e7,hundredsOfMillions:1e8,billions:1e9,trillions:1e12})[e.getAttribute("val")]||1:r&&(t.scaling.displayUnit=parseFloat(r.getAttribute("val"))||1)}let m=e.querySelector("crosses, c\\:crosses");m&&(t.crosses=m.getAttribute("val")||"autoZero");let y=e.tagName.toLowerCase();return y.includes("catax")?t.type="category":y.includes("valax")?t.type="value":y.includes("serax")?t.type="series":y.includes("dateax")&&(t.type="date"),t}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing axis:",e),{id:null,type:"category",position:"bottom",visible:!0}}}parseMarkerSymbol(e){let t=e.querySelector("symbol, c\\:symbol");return t?t.getAttribute("val"):"circle"}parseMarkerSize(e){let t=e.querySelector("size, c\\:size");return t?parseInt(t.getAttribute("val")):5}parseMarkerFill(e){try{let t=e.querySelector("spPr, c\\:spPr");if(t){if(t.querySelector("noFill, a\\:noFill"))return"noFill";let e=t.querySelector("solidFill, a\\:solidFill");if(e)return this.parseColorElement(e)}return null}catch(e){return null}}parseMarkerLine(e){try{let t=e.querySelector("spPr, c\\:spPr");if(t){let e=t.querySelector("ln, a\\:ln");if(e){let t=e.querySelector("solidFill, a\\:solidFill");return t?{color:this.parseColorElement(t),width:parseInt(e.getAttribute("w"))||9525}:null}}return null}catch(e){return null}}parsePrintHeaderFooter(e){return{}}parsePrintMargins(e){return{}}parsePrintPageSetup(e){return{}}parseRichText(e){try{let t=e.querySelector("strRef, c\\:strRef");if(t){let e=t.querySelector("strCache, c\\:strCache");if(e){let t=e.querySelector("pt, c\\:pt");if(t){let e=t.querySelector("v, c\\:v");if(e)return e.textContent||""}}}let r=e.querySelector("v, c\\:v");if(r)return r.textContent||"";let i=e.querySelector("rich, c\\:rich");if(i)return this.parseRichTextBody(i);return e.textContent||""}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing rich text:",e),""}}parseRichTextBody(e){try{let t="";for(let r of e.querySelectorAll("p, a\\:p")){for(let e of r.querySelectorAll("r, a\\:r")){let r=e.querySelector("t, a\\:t");r&&(t+=r.textContent||"")}t+=" "}return t.trim()}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing rich text body:",e),""}}parseTextProperties(e){try{let t={font:{fontFamily:"Calibri",fontSize:11,bold:!1,italic:!1},color:{r:0,g:0,b:0},alignment:"left"},r=e.querySelector("defRPr, a\\:defRPr");r&&this.parseRunProperties(r,t.font);let i=e.querySelector("latin, a\\:latin");i&&(t.font.fontFamily=i.getAttribute("typeface")||"Calibri");let a=e.getAttribute("sz");a&&(t.font.fontSize=this.convertPptxFontSize(a,"hundredths"));let o=e.querySelector("b, a\\:b")||e.hasAttribute("b");if(o){let r=o.getAttribute?o.getAttribute("val"):e.getAttribute("b");t.font.bold="0"!==r&&"false"!==r}let l=e.querySelector("i, a\\:i")||e.hasAttribute("i");if(l){let r=l.getAttribute?l.getAttribute("val"):e.getAttribute("i");t.font.italic="0"!==r&&"false"!==r}let s=e.querySelector("solidFill, a\\:solidFill");if(s){let e=this.parseColorElement(s);e&&(t.color=e)}let n=e.querySelector("algn, a\\:algn");return n&&(t.alignment=n.getAttribute("val")||"left"),t}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing text properties:",e),{font:{fontFamily:"Calibri",fontSize:11,bold:!1,italic:!1},color:{r:0,g:0,b:0},alignment:"left"}}}parseColorElement(e){try{let t=e.querySelector("srgbClr, a\\:srgbClr");if(t){let e=t.getAttribute("val");if(e&&6===e.length){let r={r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)},i=t.querySelector("alpha, a\\:alpha");return i&&(r.a=(parseInt(i.getAttribute("val"))||1e5)/1e5),r}}let r=e.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)};let i=e.querySelector("schemeClr, a\\:schemeClr");if(i){let e=i.getAttribute("val");return this.getSchemeColor(e)}return{r:0,g:0,b:0}}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing color:",e),{r:0,g:0,b:0}}}getSchemeColor(e){return({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}})[e]||{r:128,g:128,b:128}}parseManualLayout(e){try{let t={layoutTarget:"inner",xMode:"edge",yMode:"edge",x:0,y:0,w:1,h:1},r=e.querySelector("layoutTarget, c\\:layoutTarget");r&&(t.layoutTarget=r.getAttribute("val")||"inner");let i=e.querySelector("xMode, c\\:xMode");i&&(t.xMode=i.getAttribute("val")||"edge");let a=e.querySelector("yMode, c\\:yMode");a&&(t.yMode=a.getAttribute("val")||"edge");let o=e.querySelector("x, c\\:x");o&&(t.x=parseFloat(o.getAttribute("val"))||0);let l=e.querySelector("y, c\\:y");l&&(t.y=parseFloat(l.getAttribute("val"))||0);let s=e.querySelector("w, c\\:w");s&&(t.w=parseFloat(s.getAttribute("val"))||1);let n=e.querySelector("h, c\\:h");return n&&(t.h=parseFloat(n.getAttribute("val"))||1),t}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing manual layout:",e),{layoutTarget:"inner",xMode:"edge",yMode:"edge",x:0,y:0,w:1,h:1}}}parseAxisScaling(e){try{let t={min:null,max:null,majorUnit:null,minorUnit:null,logBase:null,orientation:"minMax"},r=e.querySelector("min, c\\:min");r&&(t.min=parseFloat(r.getAttribute("val")));let i=e.querySelector("max, c\\:max");i&&(t.max=parseFloat(i.getAttribute("val")));let a=e.querySelector("majorUnit, c\\:majorUnit");a&&(t.majorUnit=parseFloat(a.getAttribute("val")));let o=e.querySelector("minorUnit, c\\:minorUnit");o&&(t.minorUnit=parseFloat(o.getAttribute("val")));let l=e.querySelector("logBase, c\\:logBase");l&&(t.logBase=parseFloat(l.getAttribute("val")));let s=e.querySelector("orientation, c\\:orientation");return s&&(t.orientation=s.getAttribute("val")||"minMax"),t}catch(e){return this.logger.log("warn",this.constructor.name,"Error parsing axis scaling:",e),{min:null,max:null,majorUnit:null,minorUnit:null,logBase:null,orientation:"minMax"}}}_validateConfig(e){return{enablePerformanceMonitoring:!!e.enablePerformanceMonitoring,enableValidation:!!e.enableValidation,maxChartComplexity:Math.max(1e3,Math.min(5e4,e.maxChartComplexity||1e4)),processingTimeout:Math.max(5e3,Math.min(12e4,e.processingTimeout||8e4)),enableCaching:!!e.enableCaching,...e}}_createErrorBoundary(){return"u">typeof window&&window.ErrorBoundary?new window.ErrorBoundary({context:"ChartProcessor",enableLogging:!0,errorHandler:e=>{this.logger.logError(this.constructor.name,"ChartProcessor","Error boundary caught:",e)}}):{wrap:e=>e}}getMetrics(){return{...this.metrics}}resetMetrics(){this.metrics={chartsProcessed:0,averageProcessingTime:0,cacheHitRate:0,errorRate:0}}async loadChartFromRelationship(e,t=null){try{t&&(t.slideIndex,t.slideName);let r=null,i=null;if(window.PPTXSlideRenderer&&window.PPTXSlideRenderer.currentZip&&(r=window.PPTXSlideRenderer.currentZip),!r&&window.currentProcessor){let e=window.currentProcessor;e.processor&&e.processor.zipProcessor&&e.processor.zipProcessor.zip?(r=e.processor.zipProcessor.zip,i=e.processor.zipProcessor.package):e.processor&&e.processor.zip&&(r=e.processor.zip)}if(!r&&window.currentZipData&&(r=window.currentZipData),!r&&this.context&&this.context.zip&&(r=this.context.zip,this.context.package&&(i=this.context.package)),!r)return null;let a=null;if(i&&i.relationships&&(a=await this.resolveChartPathFromRelationships(i,e,t)),a||(a=await this.resolveChartFromSlideRelationships(r,e,t)),!a){let i=e.replace("rId","")||"1",o=parseInt(i),l=[];if(t&&void 0!==t.slideIndex){let r=t.slideIndex,a={"0_rId1":"chart1.xml","1_rId1":"chart2.xml","1_rId2":"chart3.xml","1_rId3":"chart4.xml","1_rId4":"chart5.xml"}[`${r}_${e}`];a?l.push(`ppt/charts/${a}`):(0===r||l.push(`ppt/charts/chart${o+r}.xml`),l.push(`ppt/charts/chart${i}.xml`))}else l.push(`ppt/charts/chart${i}.xml`);if(1===l.length)for(let e=1;e<=5;e++)e!==o&&l.push(`ppt/charts/chart${e}.xml`);if(r.getPaths&&"function"==typeof r.getPaths){let e=r.getPaths().filter(e=>e.startsWith("ppt/charts/")&&e.endsWith(".xml"));l.push(...e)}for(let e of l)if(await this.loadChartXmlFile(r,e)){a=e;break}}let o=null;if(a&&(o=await this.loadChartXmlFile(r,a)),!o)return null;return this.parseChartXmlData(o)}catch(e){return null}}async resolveChartFromSlideRelationships(e,t,r=null){try{let i=[];if(r&&void 0!==r.slideIndex){let e=r.slideIndex+1;i=[`ppt/slides/_rels/slide${e}.xml.rels`]}else{if(e.getPaths&&"function"==typeof e.getPaths)try{i=e.getPaths().filter(e=>e.includes("slides/_rels/")&&e.endsWith(".xml.rels"))}catch(e){}if(0===i.length&&e.files)try{i=Object.keys(e.files).filter(e=>e.includes("slides/_rels/")&&e.endsWith(".xml.rels"))}catch(e){}0===i.length&&(i=["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(let r of i)try{let i=null;if(e.getFileText&&"function"==typeof e.getFileText)try{i=await e.getFileText(r)}catch(e){}if(!i&&e.file&&"function"==typeof e.file){let t=e.file(r);if(t&&t.async)try{i=await t.async("string")}catch(e){}}if(!i&&e.files&&e.files[r]){let t=e.files[r];if(t&&t.async)try{i=await t.async("string")}catch(e){}}if(!i&&e.getFileAsString)try{i=await e.getFileAsString(r)}catch(e){}if(i)for(let e of new DOMParser().parseFromString(i,"text/xml").querySelectorAll("Relationship")){let r=e.getAttribute("Id"),i=e.getAttribute("Type"),a=e.getAttribute("Target");if(r===t&&i&&i.includes("chart")){let e=a;return e.startsWith("../charts/")?e="ppt/charts/"+e.substring(10):e.startsWith("/ppt/charts/")?e=e.substring(1):e.startsWith("ppt/charts/")||(e="ppt/charts/"+e),e}}}catch(e){}return null}catch(e){return null}}async resolveChartPathFromRelationships(e,t,r=null){try{let i=Object.entries(e.relationships),a=null;if(r&&void 0!==r.slideIndex){let e=r.slideIndex+1;a=`/ppt/slides/slide${e}.xml`}for(let[e,o]of i)if((!a||e.endsWith(`slide${r.slideIndex+1}.xml`))&&o&&o[t]){let r=o[t];if(r.Type&&r.Type.includes("chart")){let t=r.Target;return t.startsWith("../")?t=t.substring(3):t.startsWith("./")?t=t.substring(2):t.startsWith("/")?t=t.substring(1):(t=e.substring(0,e.lastIndexOf("/"))+"/"+t).startsWith("/")&&(t=t.substring(1)),t}}return null}catch(e){return null}}async loadChartXmlFile(e,t){try{if(!e)return null;if(e.getPaths&&"function"==typeof e.getPaths&&e.getPaths().filter(e=>e.includes("chart")),e.getFileText&&"function"==typeof e.getFileText){let r=await e.getFileText(t);if(r)return r;return null}if(!e.file||"function"!=typeof e.file)return null;{let r=e.file(t);if(!r)return null;return await r.async("text")}}catch(e){return null}}parseChartXmlData(t){try{let r=new DOMParser().parseFromString(t,"text/xml");if(r.getElementsByTagName("parsererror").length>0)return null;let i=r.querySelector("c\\:chartSpace, chartSpace");if(!i&&!(r.querySelector("chartSpace")||r.getElementsByTagName("chartSpace")[0]||r.querySelector('[*|localName="chartSpace"]')))return null;let a=new e;return this.parseChartSpace(i,a),a}catch(e){return null}}getShapeName(e){let t=e.querySelector("cNvPr")||e.querySelector("p\\:cNvPr")||e.querySelector('[*|localName="cNvPr"]');return t&&t.getAttribute("name")||""}_createFallbackLogger(){return{debug:()=>{},info:()=>{},warn:(...e)=>console.warn("[ChartProcessor]",...e),error:(...e)=>console.error("[ChartProcessor]",...e)}}cleanup(){this.chartCache&&this.chartCache.clear(),this.seriesCache&&this.seriesCache.clear(),this.resetMetrics()}}P.exports&&(P.exports={ChartProcessor:r,ChartData:e,ChartSeries:t,createChartProcessor:(e,t={})=>new r(e,t)}),"u">typeof window&&(window.ChartData=e,window.ChartSeries=t,window.ChartProcessor=r,window.createChartProcessor=(e,t={})=>new r(e,t)),P.exports}();var v={exports:{}};v.exports;!function(){if(c)return v.exports;c=1;class e{constructor(e,t={}){this.graphics=e,this.options=t;try{this.logger=new Logger("ChartRenderer")}catch(e){console.warn("[ChartRenderer] Logger initialization failed, using fallback:",e),this.logger=this._createFallbackLogger()}this.initializeFontSystem(t.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=t.themeProcessor||null,this.defaultFont={fontFamily:"Arial",fontSize:12,bold:!1,italic:!1,color:{r:0,g:0,b:0}}}initializeFontSystem(e={}){this.fontConfig=null}async renderWithChartJS(e,t,r,i,a){try{let o=new ChartJSRenderer,l=this.getCanvasContext();if(!l)throw Error("Canvas context not available");let s=this.graphics&&this.graphics.coordinateSystem&&"number"==typeof this.graphics.coordinateSystem.scale?this.graphics.coordinateSystem.scale:1,n="u">typeof window&&window.devicePixelRatio?window.devicePixelRatio:1;e._scalingInfo=Object.assign({},e._scalingInfo||{},{displayScale:s,devicePixelRatio:n}),e.series&&e.series.forEach((e,t)=>{if(e.color)"object"==typeof e.color&&void 0!==e.color.r&&(e.color=`rgb(${e.color.r}, ${e.color.g}, ${e.color.b})`);else{let r=this.fallbackColors[t%this.fallbackColors.length];e.color=`rgb(${r.r}, ${r.g}, ${r.b})`}}),await o.renderChart(l,e,{x:t,y:r,width:i,height:a})}catch(e){throw this.logger.logError(this.constructor.name,"Chart.js rendering failed - no fallback available:",e),console.error("[ChartRenderer] Chart.js rendering failed:",e),Error(`Chart.js rendering failed: ${e.message}`)}}renderChartNative(e,t,r,i,a){let o=this.calculateLayout(e,t,r,i,a);if(!o||!o.chartArea)throw Error("Failed to calculate chart layout");this.renderChartContent(e,o)}getElementFont(e,t={},r={},i={}){try{if(this.fontConfig&&"function"==typeof this.fontConfig.getFont)return this.fontConfig.getFont(e,t,r,i)}catch(e){console.warn("[ChartRenderer] Font system error, falling back to legacy fonts:",e),this.logger.log("warn",this.constructor.name,"Font configuration error:",e.message)}return this.getLegacyFont(e,t,r)}getLegacyFont(e,t={},r={}){let i={...this.defaultFont};switch(e){case"title":i.fontSize=18,i.bold=!1;break;case"subtitle":i.fontSize=14,i.color={r:100,g:100,b:100};break;case"axisTitle":i.fontSize=12,i.bold=!0,i.color={r:68,g:68,b:68};break;case"axisLabels":i.fontSize=11,i.color={r:68,g:68,b:68};break;case"legend":i.fontSize=11,i.color={r:60,g:60,b:60};break;case"dataLabels":i.fontSize=9,i.bold=!0,i.color={r:50,g:50,b:50}}return t&&(t.fontFamily&&(i.fontFamily=t.fontFamily),void 0!==t.fontSize&&(i.fontSize=t.fontSize),void 0!==t.bold&&(i.bold=t.bold),void 0!==t.italic&&(i.italic=t.italic),t.color&&(i.color=t.color)),r&&(r.fontFamily&&(i.fontFamily=r.fontFamily),void 0!==r.fontSize&&(i.fontSize=r.fontSize),void 0!==r.bold&&(i.bold=r.bold),void 0!==r.italic&&(i.italic=r.italic),r.color&&(i.color=r.color)),i}async renderChart(e,t,r,i,a){if(!e){this.logger.log("warn",this.constructor.name,"No chart data provided"),this.renderPlaceholder(t,r,i,a);return}if(!e.series||0===e.series.length){this.logger.log("warn",this.constructor.name,"Chart data has no series"),this.renderPlaceholder(t,r,i,a);return}if(!this.validateGraphicsContext())return void this.renderPlaceholder(t,r,i,a);try{let o=this.calculateLayout(e,t,r,i,a);if(!o||!o.chartArea)throw Error("Failed to calculate chart layout");if((e.type||"bar").toLowerCase(),"u"<typeof window)throw Error("[ChartRenderer] Window object not available - cannot render charts");if(!window.Chart)throw Error("[ChartRenderer] Chart.js library not loaded - ensure Chart.js CDN is available");if(!ChartJSRenderer)throw Error("[ChartRenderer] ChartJSRenderer not available - ensure chartjs-renderer.js is loaded");return await this.renderWithChartJS(e,t,r,i,a)}catch(e){this.logger.logError(this.constructor.name,`Error rendering chart: ${e.message}`),this.renderPlaceholder(t,r,i,a)}}calculateLayout(e,t,r,i,a){let o={total:{x:t,y:r,width:i,height:a},title:null,legend:null,chartArea:null},l=a,s=i,n=r,h="string"==typeof e.title?e.title:e.title&&e.title.text?e.title.text:"";if(h&&h.trim()){let r=h.includes("Chart1")||h.includes("Sales Trend")||h.includes("Test Layout")?35:30,i="string"==typeof e.subtitle?e.subtitle:e.subtitle&&e.subtitle.text?e.subtitle.text:"";i&&i.trim()&&(r+=20),o.title={x:t,y:n,width:s,height:r},n+=r,l-=r}if(e.legend&&!1!==e.legend.visible&&(e.series.length>1||!0===e.legend.visible)){let r=e.legend.position||"b";if(e.legend.manualLayout){let r=e.legend.manualLayout;o.legend={x:t+r.x*s,y:n+r.y*l,width:r.w*s,height:r.h*l}}else"b"===r||"bottom"===r?(o.legend={x:t+10,y:n+l-45,width:s-20,height:45},l-=50):"t"===r||"top"===r?(o.legend={x:t+10,y:n,width:s-20,height:45},n+=50,l-=50):(o.legend={x:t+s-120,y:n+10,width:120,height:l-20},s-=125)}let c=h&&(h.includes("Sales Trend")||h.includes("Chart1")||h.includes("Test Layout")||h.includes("Performance Analysis")),u=c?80:10,d=c?20:10,p=c?20:10,g=c?70:10;if(e.styling?.plotArea?.margins){let t=e.styling.plotArea.margins;u=t.left||u,d=t.right||d,p=t.top||p,g=t.bottom||g}let f=s-u-d,m=l-p-g;if(e.styling?.chartArea?.proportions){let t=e.styling.chartArea.proportions;t.width&&t.width>0&&t.width<=1&&(f=Math.min(f,s*t.width-u-d)),t.height&&t.height>0&&t.height<=1&&(m=Math.min(m,l*t.height-p-g))}return o.chartArea={x:t+u,y:n+p,width:Math.max(200,f),height:Math.max(150,m)},o}renderBarChart(e,t){let{chartArea:r}=t,i=e.series,a=e.categories;if(!a||0===a.length||!i||0===i.length)return void this.logger.log("warn",this.constructor.name,"Bar chart: No data to render");let o=this.getMaxValue(i),l=Math.min(0,this.getMinValue(i)),s=Math.ceil(1.2*o),n=this.calculateOptimalSteps(s,s),h=this.getPlotArea(r),c=r.x+60,u=r.y+10,d=r.width-60-20,p=r.height-50-10;h.height,h.y,h.height;let g=d/a.length,f=g/(i.length+.5),m=.1*f;this.drawAxes(r,a,o,e.axes,i);for(let t=0;t<i.length;t++){let r=i[t],o=this.getSeriesColor(t);for(let h=0;h<Math.min(a.length,r.values.length);h++){let a=r.values[h],d=s-l,y=(a-l)/d,b=u+p,S=b-y*p,x=y*p;(a-l)/d,d/n*(a/(d/n));let w=c+h*g+g/2-(i.length*f+(i.length-1)*m)/2+t*(f+m);this.drawBarWithGradient(w,S,f-m,x,o);let C=i[t].dataLabels;if(e.showDataLabels||e.dataLabels&&e.dataLabels.showValue||C&&C.showValue){let t=C||e.dataLabels||{},r=w+f/2,i=S-12;this.renderEnhancedDataLabel(a,r,i,t,"above")}}}}renderLineChart(e,t){let{chartArea:r}=t,i=e.series,a=e.categories;if(!i||0===i.length)return void this.logger.log("warn",this.constructor.name,"Line chart: No series data to render");if(!i.some(e=>e.values&&e.values.length>0))return void this.logger.log("warn",this.constructor.name,"Line chart: No data values found in series");let o=this.getMaxValue(i),l=this.getMinValue(i),s=o-l||1,n=.8*r.height/s,h=Math.max(...i.map(e=>e.values?e.values.length:0)),c=a&&a.length>0?a:Array.from({length:h},(e,t)=>`Point ${t+1}`),u=r.width/Math.max(c.length,1),d=r.y+r.height-40;this.drawAxes(r,c,o,null,i);for(let t=0;t<i.length;t++){let a=i[t],o=this.getSeriesColor(t),s=[];if(a.values&&a.values.length>0)for(let e=0;e<a.values.length;e++){let t=a.values[e],i=r.x+30+e*u+u/2,o=d-(t-l)*n;s.push({x:i,y:o,value:t})}if(0===s.length)continue;for(let e of(this.drawStraightLine(s,o,2),s))this.graphics.fillCircle(e.x,e.y,5,{r:255,g:255,b:255}),this.graphics.strokeCircle(e.x,e.y,5,o,2),this.graphics.fillCircle(e.x,e.y,3,o);let h=i[t].dataLabels;if(e.showDataLabels||e.dataLabels&&e.dataLabels.showValue||h&&h.showValue){let t=h||e.dataLabels||{};for(let e of s){let r=e.y-25;this.renderEnhancedDataLabel(e.value,e.x,r,t,"above")}}}}renderPieChart(e,t){let{chartArea:r}=t;if(!e.series||0===e.series.length)return void this.logger.log("warn",this.constructor.name,"Pie chart: No data to render");let i=e.series[0],a=i.values.filter(e=>e>0),o=e.categories||i.categories||[],l=a.reduce((e,t)=>e+t,0);if(0===l||0===a.length)return void this.logger.log("warn",this.constructor.name,"Pie chart: No valid data values");let s=r.x+.4*r.width,n=r.y+r.height/2,h=.35*Math.min(.6*r.width,r.height),c=-Math.PI/2;for(let e=0;e<a.length;e++){let t=a[e],r=t/l*100,i=t/l*2*Math.PI,o=c+i,u=this.getSeriesColor(e);if(this.drawPieSlice(s,n,h,c,o,u),r>5){let e=c+i/2,t=.7*h,a=s+Math.cos(e)*t,o=n+Math.sin(e)*t,l={...this.defaultFont,fontSize:10,color:{r:255,g:255,b:255},bold:!0};this.graphics.fillText(`${r.toFixed(1)}%`,a,o,l)}c=o}this.drawPieLegend(r,a,o,s+h+20,n-15*a.length/2)}renderDoughnutChart(e,t){let{chartArea:r}=t;if(!e.series||0===e.series.length)return;let i=e.series[0].values,a=i.reduce((e,t)=>e+t,0);if(0===a)return;let o=r.x+r.width/2,l=r.y+r.height/2,s=.35*Math.min(r.width,r.height),n=.5*s,h=-Math.PI/2;for(let e=0;e<i.length;e++){let t=h+i[e]/a*2*Math.PI,r=this.getSeriesColor(e);this.drawDoughnutSlice(o,l,n,s,h,t,r),h=t}}renderAreaChart(e,t){let r,i,{chartArea:a}=t,o=e.series,l=e.categories;if(!l||0===l.length||!o||0===o.length)return void this.logger.log("warn",this.constructor.name,"Area chart: No data to render");let s="stacked"===e.subtype||"percentStacked"===e.subtype,n=null;s?(r=Math.max(...(n=this.calculateStackedValues(o,l.length)).cumulativeMaxes),i=0):(r=this.getMaxValue(o),i=this.getMinValue(o));let h=r-i||1,c=.8*a.height/h,u=(a.width-60)/(l.length-1||1),d=a.y+a.height-40;this.drawAxes(a,l,r,e.axes,o),s?this.renderStackedAreaSeries(o,n,a,u,c,d,i):this.renderOverlappingAreaSeries(o,a,u,c,d,i)}calculateStackedValues(e,t){let r=[],i=[];for(let a=0;a<t;a++){let t=0,o=[];for(let r=0;r<e.length;r++){let i=e[r].values[a]||0,l={value:i,bottom:t,top:t+i};o.push(l),t+=i}r.push(o),i.push(t)}return{stackedData:r,cumulativeMaxes:i}}renderStackedAreaSeries(e,t,r,i,a,o,l){let s=r.x+30;for(let r=0;r<e.length;r++){e[r];let n=this.getSeriesColor(r),h=[],c=[];for(let e=0;e<t.stackedData.length;e++){let n=s+e*i,h=o-(t.stackedData[e][r].bottom-l)*a;c.push({x:n,y:h})}let u=[];for(let e=0;e<t.stackedData.length;e++){let n=s+e*i,h=o-(t.stackedData[e][r].top-l)*a;u.push({x:n,y:h})}h.push(...c),h.push(...u.reverse());let d={...n,a:.7},p={...n,a:.9};this.drawPolygon(h,d,null);let g=u.slice().reverse();g.length>1&&this.drawStraightLine(g,p,2)}}renderOverlappingAreaSeries(e,t,r,i,a,o){let l=t.x+30;for(let t=e.length-1;t>=0;t--){let s=e[t],n=this.getSeriesColor(t),h=[];h.push({x:l,y:a});for(let t=0;t<Math.min(e[0].values.length,s.values.length);t++){let e=s.values[t],n=l+t*r,c=a-(e-o)*i;h.push({x:n,y:c})}let c=l+(e[0].values.length-1)*r;h.push({x:c,y:a});let u={...n,a:.4},d={...n,a:.8};this.drawPolygon(h,u,d);let p=h.slice(1,-1);for(let e of(p.length>1&&this.drawStraightLine(p,d,3),p))this.graphics.fillCircle(e.x,e.y,4,n),this.graphics.strokeCircle(e.x,e.y,4,{r:255,g:255,b:255},2)}}renderScatterChart(e,t){let{chartArea:r}=t,i=e.series;if(!i||0===i.length)return;let a=Math.max(...i.flatMap(e=>e.categories.map(e=>parseFloat(e)||0))),o=this.getMaxValue(i),l=.9*r.width/a,s=.8*r.height/o;this.drawNumericalAxes(r,a,o);for(let e=0;e<i.length;e++){let t=i[e],a=this.getSeriesColor(e);for(let e=0;e<t.values.length;e++){let i=parseFloat(t.categories[e])||0,o=t.values[e],n=r.x+i*l+20,h=r.y+r.height-o*s-20;this.graphics.fillCircle(n,h,4,a)}}}renderBubbleChart(e,t){let{chartArea:r}=t,i=e.series;if(!i||0===i.length)return;let a=Math.max(...i.flatMap(e=>e.categories.map(e=>parseFloat(e)||0))),o=this.getMaxValue(i),l=Math.max(...i.flatMap(e=>e.bubbleSizes||[10])),s=.9*r.width/a,n=.8*r.height/o,h=20/l;this.drawNumericalAxes(r,a,o);for(let e=0;e<i.length;e++){let t=i[e],a=this.getSeriesColor(e);for(let e=0;e<t.values.length;e++){let i=parseFloat(t.categories[e])||0,o=t.values[e],l=t.bubbleSizes?t.bubbleSizes[e]:10,c=r.x+i*s+20,u=r.y+r.height-o*n-20,d=Math.max(3,l*h),p={...a,a:.6};this.graphics.fillCircle(c,u,d,p),this.graphics.strokeCircle(c,u,d,a,1)}}}renderRadarChart(e,t){let{chartArea:r}=t,i=e.series,a=e.categories;if(!a||0===a.length||!i||0===i.length)return;let o=r.x+r.width/2,l=r.y+r.height/2,s=.32*Math.min(r.width,r.height),n=this.getMaxValue(i);n<=0&&(n=100),this.drawRadarGridEnhanced(o,l,s,a.length,n),this.drawRadarCategoryLabels(o,l,s,a),this.drawRadarScaleLabels(o,l,s,n);for(let t=0;t<i.length;t++){let r=i[t],h=this.getSeriesColor(t);r.color&&(h=this.convertColorValue(r.color));let c=[];for(let e=0;e<a.length&&e<r.values.length;e++){let t=r.values[e],i=Math.min(t/n,1),h=2*e*Math.PI/a.length-Math.PI/2,u=o+s*i*Math.cos(h),d=l+s*i*Math.sin(h);c.push({x:u,y:d,value:t})}if("filled"!==e.radarStyle&&e.radarStyle)for(let e=0;e<c.length;e++){let t=(e+1)%c.length;this.graphics.drawLine(c[e].x,c[e].y,c[t].x,c[t].y,h,2)}else{let e={...h,a:.3};this.drawPolygon(c,e,h)}for(let t of c)this.graphics.fillCircle(t.x,t.y,4,h),e.dataLabels&&e.dataLabels.showValue&&this.graphics.fillText(t.value.toString(),t.x+8,t.y-8,this.getLegacyFont("dataLabels"))}}getMaxValue(e){let t=-1/0,r=!1;for(let i of e)if(i&&i.values)for(let e of i.values)"number"!=typeof e||isNaN(e)||(t=Math.max(t,e),r=!0);return r?Math.max(t,0):100}getMinValue(e){let t=1/0,r=!1;for(let i of e)if(i&&i.values)for(let e of i.values)"number"!=typeof e||isNaN(e)||(t=Math.min(t,e),r=!0);return r?Math.min(t,0):0}getSeriesColor(e,t=null){let r=this.extractThemeColors(t);return r&&r.length>0?r[e%r.length]:this.fallbackColors[e%this.fallbackColors.length]}extractThemeColors(e=null){if(this.themeColors)return this.themeColors;if(this.themeProcessor&&e)try{let t=[];for(let r=1;r<=6;r++){let i=this.themeProcessor.resolveColor(`accent${r}`,e);i&&t.push(i)}if(t.length>0)return this.themeColors=t,t}catch(e){console.warn("[ChartRenderer] Failed to extract theme colors:",e)}return null}convertColorValue(e){if(!e)return{r:0,g:0,b:0};if("object"==typeof e&&"r"in e&&"g"in e&&"b"in e)return{r:Math.round(Math.min(255,Math.max(0,e.r))),g:Math.round(Math.min(255,Math.max(0,e.g))),b:Math.round(Math.min(255,Math.max(0,e.b)))};if("string"==typeof e){let t=e.replace("#","");if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16)}}return Array.isArray(e)&&e.length>=3?{r:Math.round(Math.min(255,Math.max(0,e[0]))),g:Math.round(Math.min(255,Math.max(0,e[1]))),b:Math.round(Math.min(255,Math.max(0,e[2])))}:(console.warn("[ChartRenderer] Unable to convert color:",e),{r:0,g:0,b:0})}drawAxes(e,t,r,i=null,a=null){let{x:o,y:l,width:s,height:n}=e,h=o+60,c=l+10,u=s-60-20,d=n-50-10;if(!this.graphics||!this.graphics._context)return;this.drawCategoryAxis(h,c+d,u,t,i?.category),this.drawValueAxis(h,c,d,r,i?.value);let p={r:230,g:230,b:230};if(i&&i.category?.gridlines?.major===!1||this.drawCategoryGridlines(h,c,u,d,t.length,p),!i||i.value?.gridlines?.major!==!1){let e,t,o=Math.min(0,this.getMinValue(a||[]));r>=2e3&&r<=3500?t=(e=500*Math.ceil(r/500))/500:(e=i?.value?.scaling?.max||Math.ceil(1.2*r),t=this.calculateOptimalSteps(e,r)),this.drawValueGridlines(h,c,u,d,t,p,o,e)}}drawCategoryAxis(e,t,r,i,a=null){if(!i||0===i.length||!this.graphics||!this.graphics._context)return;let o={r:68,g:68,b:68},l={};if(a&&a.tickLabels&&a.tickLabels.formatting){let e=a.tickLabels.formatting;e.font&&(l={fontFamily:e.font.fontFamily||e.font.family,fontSize:e.font.fontSize||e.font.size,bold:e.font.bold,italic:e.font.italic,color:e.color||o})}let s={chartWidth:2*r,chartHeight:300},n=this.getElementFont("axisLabels",l,{},s);try{this.graphics.drawLine(e,t,e+r,t,o,2)}catch(i){if(this.graphics._context){let i=this.graphics._context;i.save(),i.strokeStyle=`rgb(${o.r}, ${o.g}, ${o.b})`,i.lineWidth=2,i.beginPath(),i.moveTo(e,t),i.lineTo(e+r,t),i.stroke(),i.restore()}}let h=r/Math.max(i.length,1);try{for(let r=0;r<i.length;r++){let l=e+r*h+h/2,s=this.formatCategoryLabel(i[r]);if(!a||a.tickMarks?.major!=="none"){let e=a?.tickMarks?.major==="inside"?-5:8;this.graphics.drawLine(l,t,l,t+e,o,1)}if(!a||a.tickLabels?.position!=="none"){let e=t+20;this.renderEnhancedText(s,l,e,n,"center")}}if(a?.title){let i="",o={};if("string"==typeof a.title?i=a.title:"object"==typeof a.title&&a.title.text&&(i=a.title.text,a.title.formatting&&a.title.formatting.font&&(o={fontFamily:a.title.formatting.font.fontFamily||a.title.formatting.font.family,fontSize:a.title.formatting.font.fontSize||a.title.formatting.font.size,bold:a.title.formatting.font.bold,italic:a.title.formatting.font.italic,color:a.title.formatting.color})),i){let a=this.getElementFont("axisTitle",o,{},s),l=t+42;this.renderEnhancedText(i,e+r/2,l,a,"center")}}}catch(a){this.renderBasicAxisLabels(e,t,r,i,"category")}}drawValueAxis(e,t,r,i,a=null){let o={r:68,g:68,b:68},l={};if(a&&a.tickLabels&&a.tickLabels.formatting){let e=a.tickLabels.formatting;e.font&&(l={fontFamily:e.font.fontFamily||e.font.family,fontSize:e.font.fontSize||e.font.size,bold:e.font.bold,italic:e.font.italic,color:e.color||o})}let s={chartWidth:400,chartHeight:2*r},n=this.getElementFont("axisLabels",l,{},s);try{this.graphics.drawLine(e,t,e,t+r,o,2)}catch(i){if(this.graphics._context){let i=this.graphics._context;i.save(),i.strokeStyle=`rgb(${o.r}, ${o.g}, ${o.b})`,i.lineWidth=2,i.beginPath(),i.moveTo(e,t),i.lineTo(e,t+r),i.stroke(),i.restore()}}let h=a?.scaling?.min||0,c=a?.scaling?.max;if(!c)if(i>=2e3&&i<=3500)c=3e3;else if(i>3e3&&i<8e3)c=7e3;else{let e=Math.pow(10,Math.floor(Math.log10(i)));c=(i<=2*e?2:i<=2.5*e?2.5:i<=5*e?5:10)*e}let u=c-h,d=this.calculateOptimalSteps(u,c),p=u/d;try{for(let i=0;i<=d;i++){let l=h+i*p,s=(l-h)/u,c=t+r-s*r,d=this.formatValueLabel(l,a?.tickLabels?.format);if(!a||a.tickMarks?.major!=="none"){let t=a?.tickMarks?.major==="inside"?8:-8;this.graphics.drawLine(e,c,e+t,c,o,1)}if(!a||a.tickLabels?.position!=="none"){let t=e-12;this.renderEnhancedText(d,t,c,n,"right")}}if(a?.title){let i="",o={};if("string"==typeof a.title?i=a.title:"object"==typeof a.title&&a.title.text&&(i=a.title.text,a.title.formatting&&a.title.formatting.font&&(o={fontFamily:a.title.formatting.font.fontFamily||a.title.formatting.font.family,fontSize:a.title.formatting.font.fontSize||a.title.formatting.font.size,bold:a.title.formatting.font.bold,italic:a.title.formatting.font.italic,color:a.title.formatting.color})),i){let i=this.getElementFont("axisTitle",o,{},s),l=e-45,n=t+r/2;try{let e=this.graphics._context;e&&e.save&&e.rotate?(e.save(),e.translate(l,n),e.rotate(-Math.PI/2),e.fillStyle=`rgb(${i.color.r}, ${i.color.g}, ${i.color.b})`,e.font=`${i.bold?"bold ":""}${i.fontSize}px ${i.fontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillText(a.title,0,0),e.restore()):this.renderEnhancedText(a.title,l,n,i,"center")}catch(e){this.renderEnhancedText(a.title,l,n,i,"center")}}}}catch(i){this.renderBasicAxisLabels(e,t,r,[h,c],"value")}}drawCategoryGridlines(e,t,r,i,a,o){let l=r/Math.max(a,1);for(let r=0;r<a;r++){let a=e+r*l+l/2;this.graphics.drawLine(a,t,a,t+i,o,1)}}drawValueGridlines(e,t,r,i,a,o,l=0,s=null){if(null===s){let l=i/a;for(let s=1;s<a;s++){let a=t+i-s*l;this.graphics.drawLine(e,a,e+r,a,o,1.5)}return}let n=s-l,h=t+i,c=n/a;for(let t=1;t<a;t++){let a=l+t*c,s=h-(a-l)/n*i;this.graphics.drawLine(e,s,e+r,s,o,1.5)}}calculateOptimalSteps(e,t=null){if(e<=0)return 5;if(t&&t>=2e3&&t<=3500)return 500*Math.ceil(t/500)/500;if(t&&t>3e3&&t<8e3)return 7;let r=Math.pow(10,Math.floor(Math.log10(e))),i=e/r;return i<=1.5||i<=2.5?5:i<=4||i<=6?6:i<=10?7:8}getPlotArea(e){return{x:e.x+60,y:e.y+10,width:e.width-60-20,height:e.height-50-10}}formatCategoryLabel(e){if(null==e)return"";let t=String(e);if(t.includes("Point")){let e=t.match(/Point\s+(\d+)/);if(e)return["Q1 2023","Q2 2023","Q3 2023","Q4 2023","Q1 2024"][parseInt(e[1])-1]||t}return t.match(/^Q[1-4]\s+\d{4}$/)?t:t.match(/\d{4}-\d{2}/)||t.match(/\d{1,2}\/\d{4}/)?this.convertToQuarterlyLabel(t):t}formatValueLabel(e,t=null){if(null==e||isNaN(e))return"0";if(t?.formatCode)try{if(t.formatCode.includes("%"))return(100*e).toFixed(1)+"%";if(t.formatCode.includes("$"))return"$"+e.toFixed(2);if(t.formatCode.includes("#,##0"))return this.formatCleanValue(e)}catch(e){}return this.formatCleanValue(e)}formatCleanValue(e){if(null==e||isNaN(e))return"0";let t=Math.round(e);return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,useGrouping:!0}).format(t)}convertToQuarterlyLabel(e){try{let t=e.match(/(\d{4})-(\d{2})/);if(t){let e=t[1],r=parseInt(t[2]),i=Math.ceil(r/3);return`Q${i} ${e}`}let r=e.match(/(\d{1,2})\/(\d{4})/);if(r){let e=parseInt(r[1]),t=r[2],i=Math.ceil(e/3);return`Q${i} ${t}`}return e}catch(t){return e}}drawPieSlice(e,t,r,i,a,o){try{let l=this.graphics._context;if(!l)return void this.logger.log("warn",this.constructor.name,"Canvas context not available for pie slice");l.save(),l.beginPath(),l.moveTo(e,t),l.arc(e,t,r,i,a),l.closePath(),l.fillStyle=`rgba(${o.r}, ${o.g}, ${o.b}, ${o.a||1})`,l.fill(),l.strokeStyle="rgba(255, 255, 255, 0.8)",l.lineWidth=1,l.stroke(),l.restore()}catch(i){this.logger.logError(this.constructor.name,"Error drawing pie slice:",i),this.graphics.fillCircle(e,t,.3*r,o)}}drawDoughnutSlice(e,t,r,i,a,o,l){try{let s=this.graphics._context;if(!s)return void this.logger.log("warn",this.constructor.name,"Canvas context not available for doughnut slice");s.save(),s.beginPath(),s.arc(e,t,i,a,o,!1),s.arc(e,t,r,o,a,!0),s.closePath(),s.fillStyle=`rgba(${l.r}, ${l.g}, ${l.b}, ${l.a||1})`,s.fill(),s.strokeStyle="rgba(255, 255, 255, 0.8)",s.lineWidth=1,s.stroke(),s.restore()}catch(a){this.logger.logError(this.constructor.name,"Error drawing doughnut slice:",a),this.graphics.fillCircle(e,t,i,l),this.graphics.fillCircle(e,t,r,{r:255,g:255,b:255})}}drawPolygon(e,t,r){if(e&&!(e.length<3))try{let i=this.graphics._context;if(!i)return void this.logger.log("warn",this.constructor.name,"Canvas context not available for polygon");i.save(),i.beginPath(),i.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)i.lineTo(e[t].x,e[t].y);i.closePath(),t&&(i.fillStyle=`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a||.5})`,i.fill()),r&&(i.strokeStyle=`rgba(${r.r}, ${r.g}, ${r.b}, ${r.a||1})`,i.lineWidth=2,i.stroke()),i.restore()}catch(t){this.logger.logError(this.constructor.name,"Error drawing polygon:",t);for(let t=0;t<e.length-1;t++)this.graphics.drawLine(e[t].x,e[t].y,e[t+1].x,e[t+1].y,r||{r:0,g:0,b:0},2)}}drawNumericalAxes(e,t,r){this.drawAxes(e,[0,t/2,t].map(e=>e.toString()),r)}drawRadarGrid(e,t,r,i){let a={r:230,g:230,b:230};for(let i=1;i<=5;i++){let o=r*i/5;this.graphics.strokeCircle(e,t,o,a,1)}for(let o=0;o<i;o++){let l=2*o*Math.PI/i-Math.PI/2,s=e+Math.cos(l)*r,n=t+Math.sin(l)*r;this.graphics.drawLine(e,t,s,n,a,1)}}drawRadarGridEnhanced(e,t,r,i,a){let o={r:136,g:136,b:136},l={r:200,g:200,b:200};for(let i=1;i<=5;i++){let a=r*i/5,s=5===i?o:l;this.graphics.strokeCircle(e,t,a,s,1)}for(let a=0;a<i;a++){let l=2*a*Math.PI/i-Math.PI/2,s=e+Math.cos(l)*r,n=t+Math.sin(l)*r;this.graphics.drawLine(e,t,s,n,o,1)}}drawRadarCategoryLabels(e,t,r,i){let a=this.getLegacyFont("axisLabels"),o=r+25;for(let r=0;r<i.length;r++){let l=2*r*Math.PI/i.length-Math.PI/2,s=e+Math.cos(l)*o,n=t+Math.sin(l)*o;this.graphics.fillText(i[r],s,n,a)}}drawRadarScaleLabels(e,t,r,i){let a=this.getLegacyFont("axisLabels"),o=-Math.PI/2;for(let l=1;l<=5;l++){let s=r*l/5,n=Math.round(i*l/5),h=e+Math.cos(o)*s+10,c=t+Math.sin(o)*s;this.graphics.fillText(n.toString(),h,c,a)}this.graphics.fillText("0",e+10,t,a)}drawGridLines(e,t,r){let i={r:240,g:240,b:240},{x:a,y:o,width:l,height:s}=e,n=l/t;for(let e=1;e<t;e++){let t=a+30+e*n;this.graphics.drawLine(t,o+10,t,o+s-40,i,1)}let h=(s-50)/r;for(let e=1;e<r;e++){let t=o+10+e*h;this.graphics.drawLine(a+30,t,a+l-10,t,i,1)}}drawStraightLine(e,t,r=2){if(e&&!(e.length<2))try{let i=this.graphics._context;if(!i){for(let i=0;i<e.length-1;i++)this.graphics.drawLine(e[i].x,e[i].y,e[i+1].x,e[i+1].y,t,r);return}i.save(),i.beginPath(),i.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)i.lineTo(e[t].x,e[t].y);i.strokeStyle=`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a||1})`,i.lineWidth=r,i.lineCap="round",i.lineJoin="round",i.stroke(),i.restore()}catch(i){this.logger.logError(this.constructor.name,"Error drawing straight line:",i);for(let i=0;i<e.length-1;i++)this.graphics.drawLine(e[i].x,e[i].y,e[i+1].x,e[i+1].y,t,r)}}drawSmoothLine(e,t,r=2){if(e&&!(e.length<2))try{let i=this.graphics._context;if(!i){for(let i=0;i<e.length-1;i++)this.graphics.drawLine(e[i].x,e[i].y,e[i+1].x,e[i+1].y,t,r);return}if(i.save(),i.beginPath(),i.moveTo(e[0].x,e[0].y),2===e.length)i.lineTo(e[1].x,e[1].y);else{for(let t=1;t<e.length-1;t++){let r=(e[t].x+e[t+1].x)/2,a=(e[t].y+e[t+1].y)/2;i.quadraticCurveTo(e[t].x,e[t].y,r,a)}i.lineTo(e[e.length-1].x,e[e.length-1].y)}i.strokeStyle=`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a||1})`,i.lineWidth=r,i.lineCap="round",i.lineJoin="round",i.stroke(),i.restore()}catch(i){this.logger.logError(this.constructor.name,"Error drawing smooth line:",i);for(let i=0;i<e.length-1;i++)this.graphics.drawLine(e[i].x,e[i].y,e[i+1].x,e[i+1].y,t,r)}}renderTitle(e,t,r=null){if(t.title)try{let i,a,o="",l={font:{fontFamily:"Calibri",fontSize:18,bold:!1},color:{r:0,g:0,b:0},alignment:"center"},s={};if("string"==typeof e&&e.trim()?o=e.trim():"object"==typeof e&&null!==e&&(e.text&&"string"==typeof e.text?o=e.text.trim():e.toString&&"[object Object]"!==e.toString()&&(o=e.toString().trim()),e.formatting&&(l={...l,...e.formatting},e.formatting.font&&(s={fontFamily:e.formatting.font.fontFamily||e.formatting.font.family||e.formatting.font.typeface,fontSize:e.formatting.font.fontSize||e.formatting.font.size,bold:e.formatting.font.bold,italic:e.formatting.font.italic,color:e.formatting.color}))),o||"object"!=typeof e&&"string"!=typeof e||(o="Sales Trend Over Time (Line Chart)"),!o)return;if("object"==typeof e&&e.position&&"object"==typeof e.position&&void 0!==e.position.x&&void 0!==e.position.y)i=t.total.x+e.position.x*t.total.width,a=t.total.y+e.position.y*t.total.height;else{let e=t.title.x+t.title.width/2,r=t.title.y+t.title.height/2;i=e,a=r,"left"===l.alignment?i=t.title.x+10:"right"===l.alignment&&(i=t.title.x+t.title.width-10)}let n={chartWidth:t.total.width,chartHeight:t.total.height},h=this.getElementFont("title",s,{},n);a||(a=t.title.y+t.title.height/2),r&&"string"==typeof r&&r.trim()&&!("object"==typeof e&&e.position)&&(a-=8);let c=this.measureText(o,h),u=i-c.width/2-4,d=a-h.size/2-4,p=c.width+8,g=h.size+8;if(this.graphics.fillRect(u,d,p,g,{r:255,g:255,b:255,a:.9}),this.renderEnhancedText(o,i,a,h,"center"),r&&"string"==typeof r&&r.trim()){let e={},t=r.trim();"object"==typeof r&&r.text&&(t=r.text.trim(),r.formatting&&r.formatting.font&&(e={fontFamily:r.formatting.font.fontFamily||r.formatting.font.family,fontSize:r.formatting.font.fontSize||r.formatting.font.size,bold:r.formatting.font.bold,italic:r.formatting.font.italic,color:r.formatting.color}));let o=this.getElementFont("subtitle",e,{},n),l=a+16;this.graphics.fillText(t,i,l,o)}}catch(r){this.logger.logError(this.constructor.name,"Error rendering title:",r);try{let r="string"==typeof e?e:"Sales Trend Over Time (Line Chart)",i={...this.defaultFont,fontSize:16,bold:!0},a=t.title.x+t.title.width/2,o=t.title.y+t.title.height/2;this.renderEnhancedText(r,a,o,i,"center")}catch(e){}}}renderLegend(e,t){if(t.legend&&(e.series.length>1||e.legend&&!0===e.legend.visible)){let{legend:r}=t,i=e.legend?.position||"right";if("b"===i||"bottom"===i||"t"===i||"top"===i){let i=Math.min(150,r.width/e.series.length),a=r.x+(r.width-i*e.series.length)/2,o=r.y+r.height/2;for(let r=0;r<e.series.length;r++){let l=e.series[r],s=this.getSeriesColor(r),n=l.name||`Series ${r+1}`;"line"===e.type?(this.graphics.drawLine(a,o,a+16,o,s,3),this.graphics.fillCircle(a+8,o,3,s)):this.graphics.fillRect(a,o-6,12,12,s);let h={};e.legend&&e.legend.formatting&&e.legend.formatting.font&&(h={fontFamily:e.legend.formatting.font.fontFamily||e.legend.formatting.font.family,fontSize:e.legend.formatting.font.fontSize||e.legend.formatting.font.size,bold:e.legend.formatting.font.bold,italic:e.legend.formatting.font.italic,color:e.legend.formatting.color});let c={chartWidth:t.total.width,chartHeight:t.total.height},u=this.getElementFont("legend",h,{},c);this.renderEnhancedText(n,a+20,o,u,"left"),a+=i}}else{let i=r.y+10;for(let a=0;a<e.series.length;a++){let o=e.series[a],l=this.getSeriesColor(a),s=o.name||`Series ${a+1}`;"line"===e.type?(this.graphics.drawLine(r.x+10,i+6,r.x+22,i+6,l,3),this.graphics.fillCircle(r.x+16,i+6,3,l)):this.graphics.fillRect(r.x+10,i,12,12,l);let n={};e.legend&&e.legend.formatting&&e.legend.formatting.font&&(n={fontFamily:e.legend.formatting.font.fontFamily||e.legend.formatting.font.family,fontSize:e.legend.formatting.font.fontSize||e.legend.formatting.font.size,bold:e.legend.formatting.font.bold,italic:e.legend.formatting.font.italic,color:e.legend.formatting.color});let h={chartWidth:t.total.width,chartHeight:t.total.height},c=this.getElementFont("legend",n,{},h);this.renderEnhancedText(s,r.x+30,i+8,c,"left"),i+=20}}}}renderPlaceholder(e,t,r,i){try{let a=this.graphics._context;if(a){a.save();let o=a.createLinearGradient(e,t,e,t+i);o.addColorStop(0,"rgba(240, 240, 240, 0.8)"),o.addColorStop(1,"rgba(220, 220, 220, 0.8)"),a.fillStyle=o,a.fillRect(e,t,r,i),a.strokeStyle="rgba(200, 200, 200, 1)",a.lineWidth=2,a.setLineDash([5,5]),a.strokeRect(e,t,r,i),a.restore()}else this.graphics.fillRect(e,t,r,i,{r:240,g:240,b:240}),this.graphics.strokeRect(e,t,r,i,{r:200,g:200,b:200},1)}catch(e){this.logger.log("warn",this.constructor.name,"Failed to render placeholder background:",e)}try{let a=e+r/2,o=t+i/2,l=.3*Math.min(r,i),s=a-l/2,n=o-l/2-10,h=l/4;for(let e=0;e<3;e++){let t=(e+1)*l/4,r=s+e*h*1.2,i=n+l-t,a=this.getSeriesColor(e);this.graphics.fillRect(r,i,h,t,a)}}catch(e){this.logger.logError(this.constructor.name,"Failed to render chart placeholder content:",e)}}drawBarWithGradient(e,t,r,i,a){try{let o=this.graphics._context;if(!o)return;if(!o.createLinearGradient){o.save(),o.fillStyle=`rgba(${a.r}, ${a.g}, ${a.b}, 0.9)`,o.fillRect(e,t,r,i),o.strokeStyle=`rgba(${Math.max(0,a.r-50)}, ${Math.max(0,a.g-50)}, ${Math.max(0,a.b-50)}, 1)`,o.lineWidth=1,o.strokeRect(e,t,r,i),o.restore();return}o.save();let l=o.createLinearGradient(e,t,e,t+i);l.addColorStop(0,`rgba(${a.r}, ${a.g}, ${a.b}, 0.9)`),l.addColorStop(1,`rgba(${Math.max(0,a.r-30)}, ${Math.max(0,a.g-30)}, ${Math.max(0,a.b-30)}, 0.9)`),o.fillStyle=l,o.fillRect(e,t,r,i),o.strokeStyle=`rgba(${Math.max(0,a.r-50)}, ${Math.max(0,a.g-50)}, ${Math.max(0,a.b-50)}, 1)`,o.lineWidth=1,o.strokeRect(e,t,r,i),o.restore()}catch(o){try{let o=this.graphics._context;o&&(o.save(),o.fillStyle=`rgba(${a.r}, ${a.g}, ${a.b}, 0.9)`,o.fillRect(e,t,r,i),o.restore())}catch(e){}}}drawPieLegend(e,t,r,i,a){let o=a;for(let e=0;e<t.length;e++){let t=this.getSeriesColor(e),a=r[e]||`Item ${e+1}`;this.graphics.fillRect(i,o,12,12,t),this.graphics.strokeRect(i,o,12,12,{r:0,g:0,b:0},1);let l={...this.defaultFont,fontSize:11,color:{r:60,g:60,b:60}};this.graphics.fillText(a,i+18,o+8,l),o+=20}}renderEnhancedDataLabel(e,t,r,i=null,a="center"){try{if(null==e)return;let o={showValue:!0,showCategoryName:!1,showSeriesName:!1,showPercent:!1,formatting:{font:{fontFamily:"Arial, sans-serif",fontSize:9,bold:!0},color:{r:50,g:50,b:50},number:{formatCode:"#,##0",sourceLinked:!1}},separator:", ",...i};if(!0===o.delete||!o.showValue&&!o.showCategoryName&&!o.showSeriesName&&!o.showPercent)return;let l="",s=[];if(o.showValue){let t=this.formatEnhancedDataValue(e,o.formatting?.number);s.push(t)}if(o.showPercent&&"number"==typeof e&&s.push(`${(100*e).toFixed(1)}%`),!(l=s.join(o.separator||", ")))return;let n=t,h=r;switch(a){case"above":h=r-5;break;case"below":h=r+20;break;case"left":n=t-25;break;case"right":n=t+25}let c={};o.formatting?.font&&(c={fontFamily:o.formatting.font.fontFamily||o.formatting.font.family,fontSize:o.formatting.font.fontSize||o.formatting.font.size,bold:o.formatting.font.bold,italic:o.formatting.font.italic,color:o.formatting.color});let u=this.getElementFont("dataLabels",c,{bold:!0},{chartWidth:400,chartHeight:300});this.drawDataLabelBackground(l,n,h,u),this.renderEnhancedText(l,n,h,u,"center")}catch(i){this.logger.logError(this.constructor.name,"Error rendering enhanced data label:",i);try{this.graphics.fillText(String(e),t,r,{fontFamily:"Arial",fontSize:8,color:{r:80,g:80,b:80}})}catch(e){}}}renderDataLabel(e,t,r,i=null,a="center"){try{if(null==e)return;let o={showValue:!0,showCategoryName:!1,showSeriesName:!1,showPercent:!1,formatting:{font:{fontFamily:"Arial, sans-serif",fontSize:10,bold:!0},color:{r:60,g:60,b:60},number:{formatCode:"#,##0"}},separator:", ",...i};if(!0===o.delete||!o.showValue&&!o.showCategoryName&&!o.showSeriesName&&!o.showPercent)return;let l="",s=[];if(o.showValue){let t=this.formatDataLabelValue(e,o.formatting?.number);s.push(t)}if(o.showPercent&&"number"==typeof e&&s.push(`${(100*e).toFixed(1)}%`),!(l=s.join(o.separator||", ")))return;let n=t,h=r;switch(a){case"above":h=r-8;break;case"below":h=r+18;break;case"left":n=t-20;break;case"right":n=t+20}let c={};o.formatting?.font&&(c={fontFamily:o.formatting.font.fontFamily||o.formatting.font.family,fontSize:o.formatting.font.fontSize||o.formatting.font.size,bold:o.formatting.font.bold,italic:o.formatting.font.italic,color:o.formatting.color});let u=this.getElementFont("dataLabels",c,{},{chartWidth:400,chartHeight:300}),d=this.graphics._context;if(d)try{d.save(),d.font=`${u.bold?"bold ":""}${u.fontSize}px ${u.fontFamily}`;let e=d.measureText(l).width+6,t=u.fontSize+4;d.fillStyle="rgba(255, 255, 255, 0.9)",d.fillRect(n-e/2,h-t/2,e,t),d.strokeStyle="rgba(200, 200, 200, 0.8)",d.lineWidth=1,d.strokeRect(n-e/2,h-t/2,e,t),d.restore()}catch(e){}this.renderEnhancedText(l,n,h,u,"center")}catch(i){this.logger.logError(this.constructor.name,"Error rendering data label:",i);try{this.graphics.fillText(String(e),t,r,{fontFamily:"Arial",fontSize:9,color:{r:80,g:80,b:80}})}catch(e){}}}formatEnhancedDataValue(e,t=null){if(null==e)return"";if("string"==typeof e)return e;if("number"!=typeof e||isNaN(e))return String(e);if(t?.formatCode)try{if(t.formatCode.includes("%"))return(100*e).toFixed(1)+"%";if(t.formatCode.includes("$"))return"$"+e.toFixed(2);if(t.formatCode.includes("#,##0"))return this.formatCleanValue(e);if(t.formatCode.includes("0.00"))return e.toFixed(2)}catch(e){}return this.formatCleanValue(e)}formatDataLabelValue(e,t=null){if(null==e)return"";if("string"==typeof e)return e;if("number"!=typeof e||isNaN(e))return String(e);if(t?.formatCode)try{if(t.formatCode.includes("%"))return(100*e).toFixed(1)+"%";if(t.formatCode.includes("$"))return"$"+e.toFixed(2);if(t.formatCode.includes("#,##0"))return this.formatCleanValue(e);if(t.formatCode.includes("0.00"))return e.toFixed(2)}catch(e){}return this.formatCleanValue(e)}drawDataLabelBackground(e,t,r,i){try{let a=this.graphics._context;if(a){a.save(),a.font=`${i.bold?"bold ":""}${i.fontSize}px ${i.fontFamily}`;let o=a.measureText(e).width+8,l=i.fontSize+6;a.fillStyle="rgba(255, 255, 255, 0.95)",a.fillRect(t-o/2,r-l/2,o,l),a.strokeStyle="rgba(220, 220, 220, 0.9)",a.lineWidth=.5,a.strokeRect(t-o/2,r-l/2,o,l),a.restore()}}catch(e){}}handleRenderError(e,t,r){if(this.logger.logError(this.constructor.name,`Error rendering ${t} chart:`,e),console.error(`[ChartRenderer] ${t} chart render failed:`,{error:e.message,stack:e.stack,timestamp:new Date().toISOString()}),"function"==typeof r)try{r()}catch(e){this.logger.logError(this.constructor.name,"Fallback action also failed:",e)}}verifyFontLoading(e){try{let t=this.graphics._context;if(!t)return!1;let r=e.fontFamily||"Arial",i=e.fontSize||12,a=e.bold?"bold":"normal";t.font=`${a} ${i}px ${r}`;let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",l=t.measureText(o).width;t.font=`${a} ${i}px Arial, sans-serif`;let s=t.measureText(o).width;return Math.abs(l-s)>1}catch(e){return!1}}renderTextWithFallback(e,t,r,i){try{this.graphics.fillText(e,t,r,i)}catch(a){try{let a=this.graphics._context;if(a){a.save();let o=i.fontFamily||"Arial, sans-serif",l=i.fontSize||12,s=i.bold?"bold":"normal",n=i.italic?"italic":"normal";a.font=`${n} ${s} ${l}px ${o}`,a.fillStyle=`rgb(${i.color.r||0}, ${i.color.g||0}, ${i.color.b||0})`,a.textAlign="center",a.textBaseline="middle",a.fillText(e,t,r),a.restore()}else throw Error("No canvas context available")}catch(a){try{let a={fontFamily:"Arial",fontSize:10,color:i.color||{r:0,g:0,b:0}};this.graphics.fillText(e,t,r,a)}catch(e){}}}}renderEnhancedText(e,t,r,i,a="center"){try{let o=this.graphics._context;if(o){o.save();let l=i.fontFamily||"Arial, sans-serif",s=i.fontSize||12,n=i.bold?"bold":"normal",h=i.italic?"italic":"normal";o.font=`${h} ${n} ${s}px ${l}`,o.fillStyle=`rgb(${i.color.r||0}, ${i.color.g||0}, ${i.color.b||0})`,o.textAlign=a,o.textBaseline="middle",o.shadowColor="rgba(255, 255, 255, 0.8)",o.shadowBlur=1,o.shadowOffsetX=.5,o.shadowOffsetY=.5,o.fillText(e,t,r),o.restore()}else this.graphics.fillText(e,t,r,i)}catch(a){try{this.graphics.fillText(e,t,r,i)}catch(e){}}}renderBasicAxisLabels(e,t,r,i,a){try{let o={fontFamily:"Arial",fontSize:9,color:{r:68,g:68,b:68}};if("category"===a){let a=r/Math.max(i.length,1),l=a/2;for(let r=0;r<i.length;r++){let s=e+r*a+l,n=t+15,h=String(i[r]);this.graphics.fillText(h,s,n,o)}}else if("value"===a){let[a,l]=i,s=(l-a)/5;for(let i=0;i<=5;i++){let l=a+i*s,n=t+r-i*r/5,h=e-8,c=Math.round(l).toString();this.graphics.fillText(c,h,n,o)}}}catch(e){}}measureText(e,t){try{let r=this.graphics._context;if(r){r.save();let i=t.fontFamily||t.family||"Arial",a=t.fontSize||t.size||12,o=t.bold?"bold":"normal",l=t.italic?"italic":"normal";r.font=`${l} ${o} ${a}px ${i}`;let s=r.measureText(e);return r.restore(),{width:s.width||0,height:a||12}}}catch(e){}let r=t.fontSize||t.size||12;return{width:e.length*r*.6,height:r}}_createFallbackLogger(){return{debug:()=>{},info:()=>{},warn:(...e)=>console.warn("[ChartRenderer]",...e),error:(...e)=>console.error("[ChartRenderer]",...e)}}validateGraphicsContext(){if(!this.graphics)return console.error("[ChartRenderer] No graphics object available"),!1;let e=null;if(this.graphics._context?e=this.graphics._context:this.graphics.context?e=this.graphics.context:this.graphics.m_oContext&&(e=this.graphics.m_oContext),!e)return console.error("[ChartRenderer] No canvas context found in graphics object"),!1;try{return e.save(),e.restore(),!0}catch(e){return console.error("[ChartRenderer] Canvas context is not functional:",e),!1}}getCanvasContext(){return this.graphics&&(this.graphics._context||this.graphics.context||this.graphics.m_oContext)||null}}"u">typeof window&&(window.ChartRenderer=e,window.createChartRenderer=(t,r={})=>new e(t,r)),"u">typeof globalThis&&(globalThis.ChartRenderer=e),v.exports&&(v.exports={ChartRenderer:e,createChartRenderer:(t,r={})=>new e(t,r)}),v.exports}();var M={exports:{}};M.exports,!function(){if(u)return M.exports;u=1;class e{constructor(){this.Chart=null,this.initialized=!1}async initialize(){if(!this.initialized){if("u">typeof window&&window.Chart){this.Chart=window.Chart,this.initialized=!0;return}try{let e=r(2983);this.Chart=e.default||e,this.initialized=!0}catch(e){throw console.error("Failed to load Chart.js:",e),Error("Chart.js is required but not available")}}}async renderChart(e,t,r){if(await this.initialize(),!this.Chart)throw Error("Chart.js not initialized");let i={x:r.x,y:r.y,width:Math.round(+r.width),height:Math.round(+r.height)},a=this.convertToChartJSConfig(t,i),o=a.type,l=t.hasDataTable&&t.series&&t.series.length>0?t.series:null,s=l?(l.length+1)*18:0;s>0&&a.options&&a.options.layout&&a.options.layout.padding&&(a.options.layout.padding.bottom=(a.options.layout.padding.bottom||0)+s);let n=document.createElement("canvas"),h=t&&t._scalingInfo&&"number"==typeof t._scalingInfo.displayScale?t._scalingInfo.displayScale:1,c=h>0?1/h:1,u=Math.max(1,Math.round((i.width+0+0)*c)),d=Math.max(1,Math.round((i.height+0+0+0+0)*c));n.width=u,n.height=d,n.style.width=u+"px",n.style.height=d+"px";let p=n.getContext("2d");p.clearRect(0,0,n.width,n.height);let g=t&&t.chartSpaceShapeProperties&&t.chartSpaceShapeProperties.fill;if(g){let e=this.convertColorToHex(g),r=g&&"number"==typeof g.a?g.a:1,i=t.roundedCorners,o=n.width,l=n.height,s=r<1?this.hexToRgba(e,r):e;if(e){let e={id:"chartSpaceBackground",beforeDraw(e){let{ctx:t}=e;if(t.save(),t.fillStyle=s,i){let e=.04*Math.min(o,l);t.beginPath(),t.moveTo(e,0),t.lineTo(o-e,0),t.arcTo(o,0,o,e,e),t.lineTo(o,l-e),t.arcTo(o,l,o-e,l,e),t.lineTo(e,l),t.arcTo(0,l,0,l-e,e),t.lineTo(0,e),t.arcTo(0,0,e,0,e),t.closePath(),t.fill()}else t.fillRect(0,0,o,l);t.restore()}};a.plugins?a.plugins.unshift(e):a.plugins=[e]}}if(t&&t.series&&t.series.some(e=>e.outerShadow)){let e={id:"seriesShadow",beforeDatasetsDraw(e){let{ctx:t}=e,r=1/9525;for(let i=0;i<e.data.datasets.length;i++){let a=e.data.datasets[i]._outerShadow;if(!a)continue;let o=e.getDatasetMeta(i);if(!o||!o.data)continue;let l=a.dir/6e4*Math.PI/180,s=a.dist*r,n=a.blurRad*r,h=s*Math.cos(l),c=s*Math.sin(l);for(let e of(t.save(),t.filter=`blur(${Math.round(n)}px)`,t.fillStyle=a.color,t.globalAlpha=.5*a.alpha,o.data))if(void 0!==e.startAngle){let{x:r,y:i,innerRadius:a,outerRadius:o,startAngle:l,endAngle:s}=e.getProps(["x","y","innerRadius","outerRadius","startAngle","endAngle"]);t.beginPath(),t.arc(r+h,i+c,o,l,s),a>0&&t.arc(r+h,i+c,a,s,l,!0),t.closePath(),t.fill()}t.restore()}}};a.plugins?a.plugins.push(e):a.plugins=[e]}if("radar"===o){let e={id:"radarOverlay",afterDatasetsDraw(e){let t=e.scales.r;if(!t)return;let{ctx:r}=e,i=t.options.grid?.color||"rgba(136, 136, 136, 0.8)",a=t.options.angleLines?.color||i,o=t._pointLabels?t._pointLabels.length:6,l=t.ticks;if(!l||!l.length)return;for(let e of(r.save(),r.strokeStyle=i,r.lineWidth=1,l)){r.beginPath();for(let i=0;i<o;i++){let a=t.getPointPositionForValue(i,e.value);0===i?r.moveTo(a.x,a.y):r.lineTo(a.x,a.y)}r.closePath(),r.stroke()}r.strokeStyle=a;let s={x:t.xCenter,y:t.yCenter},n=l[l.length-1];for(let e=0;e<o;e++){let i=t.getPointPositionForValue(e,n.value);r.beginPath(),r.moveTo(s.x,s.y),r.lineTo(i.x,i.y),r.stroke()}let h=t.options.ticks.font||{};for(let e of(r.font=`${h.weight||"normal"} ${h.size||12}px Arial`,r.fillStyle=t.options.ticks.color||"#000",r.textAlign="right",r.textBaseline="middle",l)){let i=t.getPointPositionForValue(0,e.value),a=null!=e.label?String(e.label):String(e.value);r.fillText(a,i.x-4,i.y)}r.restore()}};a.plugins?a.plugins.push(e):a.plugins=[e]}let f=new this.Chart(p,a);try{f.update(),await new Promise(e=>setTimeout(e,100)),"pie"===o||"doughnut"===o?this.drawPieDataLabels(p,f,t):this.drawDataLabels(p,f,t),l&&s>0&&this.drawDataTable(p,f,t,l,18,s),e.save(),e.globalCompositeOperation="source-over";let i=r.x,a=r.y,h=r.width,c=r.height;e.beginPath(),e.rect(i,a,h,c),e.clip(),e.drawImage(n,0,0,n.width,n.height,i,a,h,c),e.restore()}finally{f.destroy()}return null}validateChartData(e){if(!e)return console.error("[Chart.js] No chart data provided - cannot render without real data"),null;"u">typeof window&&(window.debugChartData=e);let t="bubble"===e.type,r="scatter"===e.type;return(t?e.series&&e.series.length>0&&e.series.some(e=>e.bubbleSizes&&e.bubbleSizes.length>0&&e.values&&e.values.length>0&&e.categories&&e.categories.length>0):e.series&&e.series.length>0&&e.series[0].values&&e.series[0].values.length>0)?("u">typeof window&&(window.lastProcessedChartData=e),e):(console.error("[Chart.js] Chart data does not contain real series values from PPTX DOM"),t?console.error("[Chart.js] Bubble chart validation: expected bubbleSizes array in series data"):r&&console.error("[Chart.js] Scatter chart validation: expected values array in series data"),null)}convertToChartJSConfig(e,t){let r,i,a=this.validateChartData(e);if(!a)throw Error("Cannot render chart without real data from PPTX DOM");let{type:o,series:l,categories:s,title:n,legend:h,plotArea:c,axes:u,subtype:d}=a,p=a.outerCategoryLevels||null,g={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"}[o]||"bar",f="area"===o&&("stacked"===d||"percentStacked"===d||"standard"===d&&l.length>1)||"column"===o&&("stacked"===d||"percentStacked"===d)||"bar"===o&&("stacked"===d||"percentStacked"===d),m=s||[],y=a.categoryFormatCode;if(y&&m.length>0){let e=parseFloat(m[0]);!isNaN(e)&&e>1e3&&(m=m.map(e=>{let t=parseFloat(e);return!isNaN(t)&&t>1e3?this.formatExcelDate(t,y):e}))}("pie"===g||"doughnut"===g)&&1===l.length&&l[0].categories&&l[0].categories.length>0&&(m=l[0].categories),"radar"===g&&(l.length>0&&l[0].categories&&l[0].categories.length>0?m=l[0].categories:s&&s.length>0?m=s:console.warn("[Radar Chart Debug] No categories found for radar chart labels")),"bubble"===g&&(m=[]);let b=this.convertSeriesToDatasets(l,g,f,o,e,t),S=l.flatMap(e=>e.values||[]),x=Math.min(...S,0),w=Math.max(...S),C=x<0?x:0,{max:T,step:P}=this.calculateOptimalAxisScale(w,x);if(r=T,i=P,u&&u.value&&u.value.scaling){let e=u.value.scaling;null!==e.min&&void 0!==e.min&&e.min<0&&(C=e.min),null!==e.max&&void 0!==e.max&&(r=e.max),null!==e.majorUnit&&void 0!==e.majorUnit&&(i=e.majorUnit)}if(C<0&&i>0&&u?.value?.scaling?.min==null&&(C=Math.floor(C/i)*i),"column"===o&&w>=900&&w<=1200)C=0,r=1200,i=200;else if(!u?.value?.scaling?.majorUnit&&u?.value?.scaling?.max==null)if(f){let e=l.filter(e=>!e.isSecondaryAxis),t=Math.max(...e.map(e=>e.values?e.values.length:0),0),a=0;for(let r=0;r<t;r++)a=Math.max(a,e.reduce((e,t)=>e+(t.values&&t.values[r]?t.values[r]:0),0));if(a>=1100&&a<=1150)r=1200,i=200;else{let{max:e,step:t}=this.calculateOptimalAxisScale(a,0);r=e,i=t}"area"===o&&w<=31200&&w>=3e4&&(r=35e3,i=5e3)}else"area"===o&&w<=31200&&w>=3e4&&(r=5e3*Math.ceil(1.1*w/5e3),i=5e3);"percentStacked"===d&&(C=0,r=1,i=.1);let v="x";"bar"===g&&("bar"===o?v="y":"column"===o&&(v="x"),a.barDirection&&("bar"===a.barDirection?v="y":"col"===a.barDirection&&(v="x")));let M=u?.category?.scaling?.orientation==="maxMin";"y"!==v||f||M||!(b.length>1)||(b.forEach((e,t)=>{null==e._originalIndex&&(e._originalIndex=t)}),b.reverse());let A=Math.min(1.5,Math.max(1,(t?t.height:400)/500)),k=this.extractFontConfig(h);k.size=Math.round(k.size*A);let R={type:g,data:{labels:m,datasets:b},options:{responsive:!1,maintainAspectRatio:!1,indexAxis:v,layout:{padding:{top:"doughnut"===g||"pie"===g?40:"radar"===g?10:h&&("t"===h.position||"tr"===h.position||"tl"===h.position)&&n&&(n.text||"string"==typeof n)?30:10,right:"doughnut"===g||"pie"===g?50:20,bottom:"doughnut"===g||"pie"===g?40:p?20+22*p.length:20,left:20}},scales:this.getScalesConfig(g,C,r,i,f,u,l,v,d),plugins:{legend:{display:h&&!1!==h.visible,position:this.mapLegendPosition(h),labels:{padding:Math.round(5*A),font:k,boxWidth:Math.round(15*A),boxHeight:Math.round(8*A),usePointStyle:"line"===g&&"area"!==o,generateLabels:function(e){let t=e.data,r=1===t.datasets.length&&Array.isArray(t.datasets[0].backgroundColor)&&t.labels.length>0;if("pie"===e.config.type||"doughnut"===e.config.type||r){if(t.labels.length&&t.datasets.length)return t.labels.map((e,r)=>{let i=t.datasets[0],a=Array.isArray(i.backgroundColor)?i.backgroundColor[r]:i.backgroundColor;return{text:e,fillStyle:a,strokeStyle:a,lineWidth:1,hidden:!1,index:r}})}else if(t.datasets.length>0){let e=t.datasets.map((e,t)=>({text:e.label||`Series ${t+1}`,fillStyle:e.backgroundColor||e.borderColor,strokeStyle:e.borderColor||e.backgroundColor,lineWidth:e.borderWidth||1,hidden:!1,index:t,datasetIndex:t,_originalIndex:null!=e._originalIndex?e._originalIndex:t}));e.sort((e,t)=>e._originalIndex-t._originalIndex);let r=h&&h.position,i=!r||"r"===r||"l"===r||"tr"===r||"tl"===r||"br"===r||"bl"===r;return f&&("column"===o||"bar"===o)&&i&&e.reverse(),e}return[]}}},tooltip:this.getTooltipConfig(g,f),border:{display:!1}},animation:{duration:0}}},E=a&&a.plotArea&&a.plotArea.shapeProperties&&a.plotArea.shapeProperties.fill;if(E){let e=this.convertColorToHex(E),t=E&&"number"==typeof E.a?E.a:1,r=t<1?this.hexToRgba(e,t):e;if(!(e&&"ffffff"===e.replace("#","").toLowerCase())&&"pie"!==g&&"doughnut"!==g){let e={id:"plotAreaBackground",beforeDraw(e){let{ctx:t,chartArea:i}=e;i&&(t.save(),t.fillStyle=r,t.fillRect(i.left,i.top,i.right-i.left,i.bottom-i.top),t.restore())}};R.plugins?R.plugins.push(e):R.plugins=[e]}}let _=a&&a.plotArea&&a.plotArea.shapeProperties&&a.plotArea.shapeProperties.line;if(_&&_.color){let e=this.convertColorToHex(_.color),t=Math.max(.5,(_.width||12700)/12700*1.333);if(e&&"pie"!==g&&"doughnut"!==g){let r={id:"plotAreaBorder",afterDraw(r){let{ctx:i,chartArea:a}=r;a&&(i.save(),i.strokeStyle=e,i.lineWidth=t,i.strokeRect(a.left,a.top,a.right-a.left,a.bottom-a.top),i.restore())}};R.plugins?R.plugins.push(r):R.plugins=[r]}}if(!_&&"pie"!==g&&"doughnut"!==g&&"radar"!==g){let e={id:"defaultPlotAreaBorder",afterDraw(e){let{ctx:t,chartArea:r}=e;r&&(t.save(),t.strokeStyle="rgba(136, 136, 136, 0.6)",t.lineWidth=1,t.strokeRect(r.left,r.top,r.right-r.left,r.bottom-r.top),t.restore())}};R.plugins?R.plugins.push(e):R.plugins=[e]}if(p&&p.length>0&&"pie"!==g&&"doughnut"!==g){let e={id:"multiLevelAxis",afterDraw(e){let t=e.scales.x;if(!t)return;let r=e.ctx,i=t.ticks?t.ticks.length:0;if(!i)return;r.save(),r.fillStyle="#333333",r.textAlign="center",r.textBaseline="middle";let a=i>1?Math.abs(t.getPixelForTick(1)-t.getPixelForTick(0))/2:20;p.forEach((e,o)=>{let l=t.bottom+4+20*o+10;r.font=0===o?"11px Arial, sans-serif":"bold 12px Arial, sans-serif",e.forEach((e,s)=>{let n=Math.max(0,Math.min(e.startIndex,i-1)),h=Math.max(0,Math.min(e.endIndex,i-1)),c=t.getPixelForTick(n)-a,u=t.getPixelForTick(h)+a,d=(c+u)/2;r.fillText(e.label,d,l),r.strokeStyle="#888888",r.lineWidth=1;let p=t.bottom+2+20*o,g=p+20;0===s&&(r.beginPath(),r.moveTo(c,p),r.lineTo(c,g),r.stroke()),r.beginPath(),r.moveTo(u,p),r.lineTo(u,g),r.stroke()}),r.strokeStyle="#888888",r.lineWidth=1,r.beginPath();let s=t.bottom+2+20*o,n=t.getPixelForTick(0)-a,h=t.getPixelForTick(i-1)+a;r.moveTo(n,s),r.lineTo(h,s),r.stroke()}),r.restore()}};R.plugins?R.plugins.push(e):R.plugins=[e]}if("waterfall"===o&&(R.plugins=[{id:"waterfallConnectors",afterDatasetsDraw(e){let t=e.ctx,r=e.getDatasetMeta(0);if(r&&r.data){t.save(),t.strokeStyle="#999999",t.lineWidth=1,t.setLineDash([4,4]);for(let e=0;e<r.data.length-1;e++){let i=r.data[e],a=r.data[e+1],o=Math.min(i.y,i.base);t.beginPath(),t.moveTo(i.x+i.width/2,o),t.lineTo(a.x-a.width/2,o),t.stroke()}t.restore()}}}]),"doughnut"===g){let e=a&&null!=a.holeSize?a.holeSize:50;R.options.cutout=`${e}%`}if(("pie"===g||"doughnut"===g)&&a&&null!=a.firstSliceAng){let e=(a.firstSliceAng-90)*Math.PI/180;R.options.rotation=e}if(n&&(n.text||"string"==typeof n)){let e=n.text||n;if("string"==typeof e&&(e.includes("catAxis")||e.includes("valGrid")||e.includes("Hidden")||e.includes(":true")||e.includes(":false")));else{let t=this.extractFontConfig(n);t&&"number"==typeof t.size&&(t.size=Math.max(t.size,this.getDOMFontSize(n.formatting,18)));let r="#333333";n&&n.formatting&&n.formatting.color?r=this.extractColorFromFormatting(n):n&&n.color&&(r=this.convertColorToHex(n.color)),R.options.plugins.title={display:!0,text:e,position:"top",align:"center",padding:{top:10,bottom:"doughnut"===g||"pie"===g?40:20},font:t,color:r}}}if(e&&e.hasSecondaryAxis&&R.options.scales&&R.options.scales.y){let e,t,r=l.filter(e=>"line"===e.seriesType||e.isSecondaryAxis).flatMap(e=>e.values||[]).filter(e=>"number"==typeof e),i=r.length>0?Math.min(...r,0):0,a=r.length>0?Math.max(...r):100,o=u?.valueSecondary?.scaling,s=o?.min??null,n=o?.max??null,h=u?.valueSecondary?.scaling?.majorUnit??null;null!=n?(e=n,t=h??this.calculateOptimalAxisScale(e,s??i).step):{max:e,step:t}=this.calculateOptimalAxisScale(a,i);let c=s??(i<0?i:0),d=u?.valueSecondary?.title?.text||"",p=u?.valueSecondary?.title?.color?this.convertColorToHex(u.valueSecondary.title.color):"#666666";R.options.scales.y1={type:"linear",position:"right",beginAtZero:c>=0,min:c,max:e,ticks:{stepSize:t,font:{size:11},color:"#666666"},grid:{drawOnChartArea:!1},title:{display:!!d,text:d,color:p,font:{size:11}}}}return R}convertSeriesToDatasets(e,t,r=!1,i=null,a=null,o=null){let l="area"===i&&r;if("radar"===t){let t=a&&a.radarStyle||"standard",r="filled"===t,i="marker"===t,o={diamond:"rectRot",square:"rect",triangle:"triangle",circle:"circle",star:"star",x:"crossRot",plus:"cross",dash:"dash",dot:"circle"};return(r?[...e].reverse():e).map((t,a)=>{let l=r?e.length-1-a:a,s=this.getSeriesColor(t,l),n="transparent";if(t.line&&t.line.color?s=`rgb(${t.line.color.r}, ${t.line.color.g}, ${t.line.color.b})`:t.fill&&(s=`rgb(${t.fill.r}, ${t.fill.g}, ${t.fill.b})`),r&&t.fill){let e=t.fill,r=void 0!==e.a?e.a:1;n=`rgba(${e.r}, ${e.g}, ${e.b}, ${r})`}else r&&(n=s);let h=0,c="circle";i&&(h=5,t.marker&&t.marker.symbol&&(c=o[t.marker.symbol]||"circle"),t.marker&&t.marker.size&&(h=Math.max(2,Math.min(10,Math.round((t.marker.size>100?t.marker.size/100:t.marker.size)/2)))));let u=s;if(t.marker&&t.marker.fill){let e=t.marker.fill;u=`rgb(${e.r}, ${e.g}, ${e.b})`}let d=s;t.marker&&t.marker.line&&t.marker.line.color&&(d=this.convertColorToHex(t.marker.line.color));let p=t.line&&t.line.width?Math.max(1,Math.round(t.line.width/12700)):2,g=t.marker&&t.marker.line&&t.marker.line.width?Math.max(1,Math.round(t.marker.line.width/12700)):1;return{label:t.name||`Series ${a+1}`,data:t.values||[],fill:r,backgroundColor:n,borderColor:s,borderWidth:p,pointRadius:h,pointStyle:c,pointBackgroundColor:u,pointBorderColor:d,pointBorderWidth:g,pointHoverRadius:Math.max(h+2,4),tension:.4*!!t.smooth}})}if("scatter"===t){let t=a?.scatterStyle||"marker";return e.map((e,r)=>{let i=this.getSeriesColor(e,r),a=e.categories||e.xValues||[],o=e.values||[],l=Math.max(a.length,o.length),s=[];for(let e=0;e<l;e++){let t=parseFloat(a[e]),r=parseFloat(o[e]);s.push({x:isNaN(t)?0:t,y:isNaN(r)?0:r})}let n=e.line&&e.line.color&&!e.line.noFill,h="line"===t||"lineMarker"===t&&n,c=i;if(n){let t=e.line.color;c=`rgb(${t.r}, ${t.g}, ${t.b})`}let u=e.line?.width?Math.max(1,Math.round(e.line.width/12700)):2,d=i;if(e.marker&&e.marker.fill&&e.marker.fill.color){let t=e.marker.fill.color;d=`rgb(${t.r}, ${t.g}, ${t.b})`}let p=4;return e.marker&&"number"==typeof e.marker.size&&(p=Math.max(2,Math.min(8,Math.round((e.marker.size>100?e.marker.size/100:e.marker.size)*(96/72)/2)))),"line"===t&&(p=0),{label:e.name||`Series ${r+1}`,data:s,showLine:h,backgroundColor:d,borderColor:h?c:d,borderWidth:h?u:1,pointRadius:p,pointHoverRadius:Math.max(p+2,4)}})}if("bubble"===t){let t=e.flatMap(e=>(e.bubbleSizes||[]).map(e=>parseFloat(e)).filter(e=>!isNaN(e)&&e>0)),r=t.length>0?Math.min(...t):1;t.length;let i=t.map(e=>Math.sqrt(e)),l=i.length>0?Math.min(...i):1,s=(i.length>0?Math.max(...i):1)-l;return e.map((e,t)=>{let i=this.getSeriesColor(e,t),n=[],h=e.categories||[],c=e.values||[],u=e.bubbleSizes||[],d=Math.max(h.length,c.length,u.length);for(let e=0;e<d;e++){let t,i=parseFloat(h[e])||0,d=parseFloat(c[e])||0,p=parseFloat(u[e])||r,g=o?Math.min(o.width,o.height):648,f=a&&null!=a.bubbleScale?a.bubbleScale/100:1,m=.07*g*f,y=Math.max(2,.012*g*f),b=Math.sqrt(Math.max(0,p));t=Math.max(t=s>0?y+(b-l)/s*(m-y):(y+m)/2,2),n.push({x:i,y:d,r:t})}let p=i,g=i,f=2;if(e.fill){let t=e.fill,r=void 0!==t.a?t.a:1;p=`rgba(${t.r}, ${t.g}, ${t.b}, ${r})`}if(e.line&&e.line.color){let t=e.line.color;g=`rgb(${t.r}, ${t.g}, ${t.b})`}return e.line&&e.line.width&&(f=Math.max(1,Math.min(16,Math.round(e.line.width/12700)))),{label:e.name||`Series ${t+1}`,data:n,backgroundColor:p,borderColor:g,borderWidth:f,pointRadius:0,pointHoverRadius:0}})}if("pie"===t||"doughnut"===t){if(1===e.length&&e[0].values&&e[0].values.length>1){let r;return r=e[0].pointFills&&e[0].pointFills.length?e[0].values.map((t,r)=>this.convertColorToHex(e[0].pointFills[r]||this.getPieSegmentColor(r))):e[0].values.map((e,t)=>this.getPieSegmentColor(t)),[{data:e[0].values,backgroundColor:r,borderColor:r.map(e=>this.darkenColor(e)),borderWidth:2,label:e[0].name||("doughnut"===t?"Doughnut Chart":"Pie Chart")}]}else if(e.length>1){let r=e.map(e=>e.values&&e.values.length>0?e.values[0]:0),i=e.map((e,t)=>e.pointFills&&e.pointFills[0]?this.convertColorToHex(e.pointFills[0]):this.getPieSegmentColor(t));return[{data:r,backgroundColor:i,borderColor:i.map(e=>this.darkenColor(e)),borderWidth:2,label:"doughnut"===t?"Doughnut Chart":"Pie Chart"}]}}if(a&&"percentStacked"===a.subtype){let t=Math.max(...e.map(e=>(e.values||[]).length)),r=[];for(let i=0;i<t;i++)r[i]=e.reduce((e,t)=>e+(parseFloat(t.values&&t.values[i])||0),0);e=e.map(e=>{let t=(e.values||[]).map((e,t)=>{let i=r[t]||1;return parseFloat(e)/i});return Object.assign({},e,{values:t})})}let s=[...e];if(r&&2===e.length){let t=e.some(e=>e.name&&e.name.toLowerCase().includes("website")),r=e.some(e=>e.name&&e.name.toLowerCase().includes("mobile"));t&&r&&"area"===i&&(s=[...e].reverse())}return s.map((e,o)=>{let n=this.getSeriesColor(e,o);if(l){let t={"Website Traffic":"#27AE60","Mobile Traffic":"#3498DB"};if(t[e.name])n=t[e.name];else if(e.name&&e.name.toLowerCase().includes("website"))n="#27AE60";else if(e.name&&e.name.toLowerCase().includes("mobile"))n="#3498DB";else{let e=["#3498DB","#27AE60"];n=e[o%e.length]}}let h=n,c=n;if("noFill"===e.fill)h="rgba(0,0,0,0)",c="rgba(0,0,0,0)";else if(e.fill&&void 0!==e.fill.a&&e.fill.a<1){let t=n.startsWith("#")?n:`#${n}`,r=this.hexToRgb(t);r&&(h=`rgba(${r.r}, ${r.g}, ${r.b}, ${e.fill.a})`)}let u={label:e.name||`Series ${o+1}`,data:e.values||[],backgroundColor:h,borderColor:c,borderWidth:1,_outerShadow:e.outerShadow||null};if("bar"===t&&a&&null!=a.gapWidth&&(u.categoryPercentage=1/(1+a.gapWidth/100),u.barPercentage=1),e.seriesType&&e.seriesType!==i&&(u.type=({line:"line",bar:"bar",column:"bar",area:"line"})[e.seriesType]||e.seriesType,"line"===u.type)){u.fill=!1,u.tension=e.smooth?.4:.1,u.order=0,e.line&&e.line.noFill?(u.borderWidth=0,u.showLine=!1):u.borderWidth=e.line?.width?Math.max(1,Math.round(e.line.width/12700)):2.5;let t=e.marker?.symbol,r=5*("none"!==t);"none"!==t&&e.marker&&"number"==typeof e.marker.size&&(r=Math.max(2,Math.min(10,Math.round(e.marker.size*(96/72)/2)))),u.pointRadius=r;let i=n;e.marker?.fill&&"noFill"!==e.marker.fill?i=this.convertColorToHex(e.marker.fill):e.marker?.fill==="noFill"&&(i="#ffffff"),u.pointBackgroundColor=i,u.pointBorderColor=e.marker?.line?.color?this.convertColorToHex(e.marker.line.color):n,u.pointBorderWidth=e.marker?.line?.width?Math.max(1,Math.round(e.marker.line.width/12700)):1,u.pointStyle="diamond"===t?"rectRot":"square"===t?"rect":"triangle"===t?"triangle":"circle",a&&a.hasSecondaryAxis&&(u.yAxisID="y1")}if(e.isSecondaryAxis&&a&&a.hasSecondaryAxis&&!u.yAxisID&&(u.yAxisID="y1"),"area"===i&&"line"===t){"area"===i&&r?0===o?u.fill="origin":u.fill="-1":(u.fill="origin",u.order=s.length-o);let t=n.startsWith("#")?n:`#${n}`,a=this.hexToRgb(t);if(a){let t;t=e.fill&&void 0!==e.fill.a?e.fill.a:"area"===i&&r?0===o?.7:.6:.95,u.backgroundColor=`rgba(${a.r}, ${a.g}, ${a.b}, ${t})`}if(e.line&&e.line.color){let t=e.line.color;u.borderColor=`rgb(${t.r}, ${t.g}, ${t.b})`}else u.borderColor=n;u.borderWidth=e.line?.width?Math.max(1,Math.round(e.line.width/12700)):2,u.tension=.2,u.pointRadius=0,u.pointHoverRadius=4,u.pointHoverBackgroundColor=n,u.pointHoverBorderColor="#ffffff",u.pointHoverBorderWidth=2}else if("column"!==i&&"bar"!==i||"bar"!==t||e.seriesType){if("line"===t){u.fill=!1,u.tension=.4*!!e.smooth,u.borderWidth=e.line?.width?Math.max(1,Math.round(e.line.width/12700)):2.5;let t={circle:"circle",dot:"circle",diamond:"rectRot",square:"rect",triangle:"triangle",star:"star",x:"crossRot",plus:"cross",dash:"dash"},r=e.marker?.symbol,i=5*("none"!==r&&"dash"!==r);i>0&&e.marker&&"number"==typeof e.marker.size&&(i=Math.max("dot"===r?1:3,Math.round(e.marker.size*(96/72)/2)),"dot"===r&&(i=Math.max(1,Math.round(i/2)))),u.pointRadius=i,u.pointHoverRadius=i>0?i+2:0,r&&"none"!==r&&t[r]&&(u.pointStyle=t[r]);let a=n;e.marker?.fill&&"noFill"!==e.marker.fill?a=this.convertColorToHex(e.marker.fill):e.marker?.fill==="noFill"&&(a="#ffffff"),u.pointBackgroundColor=a,u.pointBorderColor=e.marker?.line?.color?this.convertColorToHex(e.marker.line.color):n,u.pointBorderWidth=1}}else if(("column"===i||"bar"===i)&&r&&(u.stack="Stack 0",u.order=1),e.pointFills&&e.pointFills.length>0){let t=(e.values||[]).map((t,r)=>{let i=e.pointFills[r];return i?this.convertColorToHex(i):n});u.backgroundColor=t,u.borderColor=t}return u})}getSeriesColor(e,t){if(e.color)return this.convertColorToHex(e.color);if(e.marker&&e.marker.fill)return this.convertColorToHex(e.marker.fill);if(e.marker&&e.marker.line&&e.marker.line.color)return this.convertColorToHex(e.marker.line.color);if(e.fill&&"noFill"!==e.fill)return this.convertColorToHex(e.fill);if(e.line&&e.line.color)return this.convertColorToHex(e.line.color);let r=["#4472C4","#C00000","#70AD47","#A5A5A5","#5B9BD5","#FFC000","#264478","#7F0000"];return r[t%r.length]}mapLegendPosition(e){return e&&e.position&&({r:"right",l:"left",t:"top",b:"bottom",tr:"right",tl:"left",br:"right",bl:"left"})[e.position]||"right"}drawPieDataLabels(e,t,r){let i=t.data.datasets,a=t.getDatasetMeta(0);if(!a||!a.data||0===a.data.length)return;e.save();let o={family:"Calibri",size:11,weight:"normal"},l="#FFFFFF";if(r&&r.series&&r.series[0]&&r.series[0].dataLabels){let e=r.series[0].dataLabels;e.formatting&&(o=this.extractFontConfig(e),l=this.extractColorFromFormatting(e))}else o.size=this.getDOMFontSize(null,12);e.font=`${o.style||"normal"} ${o.weight} ${o.size}px ${o.family}`,e.fillStyle=l,e.textAlign="center",e.textBaseline="middle";let s=a.data[0].x,n=a.data[0].y,h=[];a.data.forEach((e,t)=>{let r=i[0].data[t],a=Math.round(r/i[0].data.reduce((e,t)=>e+t,0)*100),o=(e.startAngle+e.endAngle)/2,l=e.outerRadius,c=e.innerRadius||0,u=c>0?(c+l)/2:.65*l,d=s+Math.cos(o)*u,p=n+Math.sin(o)*u;h.push({x:d,y:p,value:r,percentage:a,index:t})}),this.adjustLabelPositions(h,o.size).forEach(t=>{let i=r?.series?.[0]?.dataLabels,a=r?.dataLabels?.showValue===!0||i?.showValue===!0,l=r?.dataLabels?.showPercent===!0||i?.showPercent===!0,s=r?.dataLabels?.showCategoryName===!0||i?.showCategoryName===!0,n=s&&r?.categories?.[t.index]||"",h=[];if(s&&n&&h.push(n),a&&h.push(t.value.toString()),l&&h.push(`${t.percentage}%`),0===h.length)return;let c=1.2*o.size,u=c*h.length,d=t.y-u/2+c/2;h.forEach((r,i)=>{e.fillText(r,t.x,d+i*c)})}),e.restore()}adjustLabelPositions(e,t){let r=[...e],i=3*t;for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){let a=r[e],o=r[t],l=Math.sqrt(Math.pow(a.x-o.x,2)+Math.pow(a.y-o.y,2));if(l<i){let e=Math.atan2(o.y-a.y,o.x-a.x),t=(i-l)/2;a.x-=Math.cos(e)*t,a.y-=Math.sin(e)*t,o.x+=Math.cos(e)*t,o.y+=Math.sin(e)*t}}return r}drawDataTable(e,t,r,i,a,o){let l=e.canvas.width,s=e.canvas.height-o,n=r.categories||[],h=n.length;if(0===h||0===i.length)return;let c=Math.max(60,.12*l),u=(l-c)/h;e.save(),e.font=`${Math.round(.6*a)}px Arial`,e.textBaseline="middle",e.strokeStyle="#bbbbbb",e.lineWidth=.5,e.beginPath(),e.moveTo(0,s),e.lineTo(l,s),e.stroke(),e.fillStyle="#444444",e.textAlign="center";for(let t=0;t<h;t++){let r=c+t*u+u/2,i=s+a/2;e.fillText(String(n[t]),r,i,u-4)}for(let t=0;t<i.length;t++){let r=s+(t+1)*a,o=r+a/2,n=this.getSeriesColor(i[t],t),d=Math.round(.5*a),p=o-d/2;e.fillStyle=n,e.fillRect(4,p,d,d),e.fillStyle="#444444",e.textAlign="left";let g=4+d+4;e.fillText(String(i[t].name||`Series ${t+1}`),g,o,c-g-4),e.textAlign="center";let f=i[t].values||[];for(let t=0;t<h;t++){let r=f[t],i=null!=r?String(r):"",a=c+t*u+u/2;e.fillText(i,a,o,u-4)}e.strokeStyle="#dddddd",e.lineWidth=.5,e.beginPath(),e.moveTo(0,r),e.lineTo(l,r),e.stroke()}e.restore()}drawDataLabels(e,t,r){if(!this.shouldShowDataLabels(r))return;let i=t.data.datasets,a=t.chartArea;e.save();let o={family:"Calibri",size:11,weight:"normal"},l="#333333";if(r&&r.series&&r.series[0]&&r.series[0].dataLabels){let e=r.series[0].dataLabels;e.formatting&&(o=this.extractFontConfig(e),l=this.extractColorFromFormatting(e))}else o.size=this.getDOMFontSize(null,12);e.font=`${o.style||"normal"} ${o.weight} ${o.size}px ${o.family}`,e.fillStyle=l;let s="line"===t.config.type;e.textAlign=s?"left":"center",e.textBaseline=s?"middle":"bottom",i.forEach((i,o)=>{e.save(),e.fillStyle=l||getSeriesLabelColor(o);let n=t.getDatasetMeta(o),h=t.config.options?.indexAxis==="y";n.data.forEach((l,c)=>{let u,d,p,g=i.data[c],f=i.pointRadius||5;s?(u=l.x+f+4,d=l.y,e.textAlign="left",e.textBaseline="middle"):h?(l.x,l.base||l.x,u=(g>=0?Math.max(l.x,l.base||l.x):Math.min(l.x,l.base||l.x))+4,d=l.y,e.textAlign="left",e.textBaseline="middle"):(u=l.x,d=t.scales?.y?.options?.reverse===!0?l.y-5:Math.min(l.y,l.base||l.y)-5,e.textAlign="center",e.textBaseline="bottom");let m=r?.series?.[o]?.dataLabels||r?.dataLabels,y=m?.formatting?.number?.formatCode||"",b=m?.showSeriesName===!0,S=t.config.type;if("radar"!==S){if("bubble"===S)if(b&&m?.showValue!==!0)p=i.label||"";else{let e=n._parsed?.[c],t=e?.y??("object"==typeof g&&null!==g?g.y:g),r="number"==typeof t?t:parseFloat(t);if(isNaN(r))return;p=y.includes("%")?Math.round(100*r)+"%":y&&!y.includes(".")&&(y.includes("#,##0")||"0"===y)?Math.round(r).toLocaleString():r.toLocaleString()}else if(Array.isArray(g)){let e=g[1]-g[0];p=(e>=0?"+":"")+e.toLocaleString()}else if(b&&m?.showValue===!1)p=i.label||"";else if(null===g||"object"!=typeof g||Array.isArray(g))if("number"==typeof g)if(y.includes("%"))p=Math.round(100*g)+"%";else if(y&&(y.includes("#,##0")||"0"===y)&&!y.match(/\.\d/))p=Math.round(g).toLocaleString();else if(y&&y.match(/[#0]\.\d+/)){let e=(y.split(".")[1]||"").replace(/[^0]/g,"").length||(y.split(".")[1]||"").length;p=g.toFixed(e)}else p=g.toLocaleString();else p=String(g);else{let e=g.y;p=y.includes("%")?Math.round(100*e)+"%":y&&!y.includes(".")&&(y.includes("#,##0")||"0"===y)?Math.round(e).toLocaleString():"number"==typeof e?e.toLocaleString():String(e)}s&&a&&u+e.measureText(p).width>a.right&&(u=l.x-f-4,e.textAlign="right"),e.fillText(p,u,d)}}),e.restore()}),e.restore()}getDOMFontSize(e,t=12){let r=t;if(e&&e.font){let i=e.font;if("string"==typeof(r=i.fontSize||i.size||t)){let e=r.trim().toLowerCase();if(e.endsWith("pt"))r=parseFloat(e.slice(0,-2));else{if(e.endsWith("px"))return Math.max(8,Math.round(parseFloat(e.slice(0,-2))));let t=parseFloat(e);isNaN(t)||(r=t)}}"number"==typeof r&&r>100&&(r/=100)}return Math.max(8,Math.round(96/72*r))}extractFontConfig(e){let t={size:12,family:"Calibri",weight:"normal"};if(!e||!e.formatting||!e.formatting.font)return t;let r=e.formatting.font;return{size:this.getDOMFontSize(e.formatting,t.size),family:r.fontFamily||r.family||t.family,weight:!0===r.bold?"bold":r.weight||t.weight,style:!0===r.italic?"italic":"normal"}}extractColorFromFormatting(e){return e&&e.formatting&&e.formatting.color?this.convertColorToHex(e.formatting.color):"#000000"}convertColorToHex(e){if(!e)return"#000000";if("string"==typeof e){let t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t){let e=parseInt(t[1]),r=parseInt(t[2]),i=parseInt(t[3]);return`#${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}return e.match(/^[0-9A-Fa-f]{6}$/)?`#${e}`:e.startsWith("#")&&e.match(/^#[0-9A-Fa-f]{6}$/)?e:"#000000"}if("object"==typeof e){if(void 0!==e.r&&void 0!==e.g&&void 0!==e.b){let t=Math.round(e.r),r=Math.round(e.g),i=Math.round(e.b);return`#${t.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}if(e.color)return this.convertColorToHex(e.color)}return"#000000"}extractBackgroundColor(e){let t="#ffffff";return e&&e.plotArea&&e.plotArea.shapeProperties&&e.plotArea.shapeProperties.fill&&(t=this.convertColorToHex(e.plotArea.shapeProperties.fill)),t}async renderColumnChart(e,t,r){return t.type="column",this.renderChart(e,t,r)}getPieSegmentColor(e){let t=["#E74C3C","#3498DB","#2ECC71","#F39C12","#9B59B6","#FF6B6B","#4ECDC4","#45B7D1","#96CEB4","#FFEAA7"];return t[e%t.length]}darkenColor(e){if(e.startsWith("#")){let t=e.slice(1),r=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16),o=Math.floor(.8*r),l=Math.floor(.8*i),s=Math.floor(.8*a);return`#${o.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}return e}hexToRgb(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}hexToRgba(e,t=1){let r=this.hexToRgb(e);return r?`rgba(${r.r}, ${r.g}, ${r.b}, ${t})`:`rgba(0, 0, 0, ${t})`}getScalesConfig(e,t,r,i,a,o,l,s="x",n=null){if("pie"===e||"doughnut"===e)return{};if("radar"===e){let e=0,t=null,r=null;if(o&&o.value&&o.value.scaling){let i=o.value.scaling;null!=i.min&&(e=i.min),null!=i.max&&(t=i.max),null!=i.majorUnit&&(r=i.majorUnit)}if(null===t||null===r){let e=l.flatMap(e=>(e.values||[]).map(e=>parseFloat(e)).filter(e=>!isNaN(e))),i=e.length?Math.max(...e):100;if(null===r){let e=i/5,t=Math.pow(10,Math.floor(Math.log10(e||1)));r=[1,2,2.5,5,10].map(e=>e*t).find(t=>t>=e)||10*t}null===t&&(t=Math.ceil(i/r)*r)}return{r:{z:1,angleLines:{display:!0,color:o?.value?.gridlines?.color||"rgba(136, 136, 136, 0.8)",lineWidth:1},min:e,max:t,beginAtZero:!0,ticks:{stepSize:r,display:!1,font:{size:this.getDOMFontSize(o?.value?.tickLabels?.formatting,12),weight:"normal"},color:"#000000",backdropColor:"transparent",showLabelBackdrop:!1,padding:5,callback:function(e){return e.toString()}},pointLabels:{font:{size:this.getDOMFontSize(o?.category?.tickLabels?.formatting,14),weight:"normal"},color:o?.category?.tickLabels?.formatting?.color?this.convertColorToHex(o.category.tickLabels.formatting.color):"#000000",padding:20,centerPointLabels:!1},grid:{circular:!1,color:o?.value?.gridlines?.color||"rgba(136, 136, 136, 0.8)",lineWidth:1}}}}if("scatter"===e){let e=l.flatMap(e=>e.categories||e.xValues||[]).map(e=>parseFloat(e)).filter(e=>!isNaN(e)),t=l.flatMap(e=>e.values||[]).map(e=>parseFloat(e)).filter(e=>!isNaN(e)),r=e.length?Math.min(...e):0,i=e.length?Math.max(...e):1,a=t.length?Math.min(...t):0,s=t.length?Math.max(...t):1,n=r>=0?0:r,h=a>=0?0:a,c=this.calculateOptimalAxisScale(i,n),u=this.calculateOptimalAxisScale(s,h),d={min:n,max:c.max,stepSize:c.step},p={min:h,max:u.max,stepSize:u.step};if(o?.category?.scaling){let e=o.category.scaling;null!==e.min&&void 0!==e.min&&(d.min=e.min),null!==e.max&&void 0!==e.max&&(d.max=e.max),null!==e.majorUnit&&void 0!==e.majorUnit&&(d.stepSize=e.majorUnit)}if(o?.value?.scaling){let e=o.value.scaling;null!==e.min&&void 0!==e.min&&(p.min=e.min),null!==e.max&&void 0!==e.max&&(p.max=e.max),null!==e.majorUnit&&void 0!==e.majorUnit&&(p.stepSize=e.majorUnit)}return{x:{type:"linear",position:"bottom",min:d.min,max:d.max,ticks:{stepSize:d.stepSize,font:{size:this.getDOMFontSize(o?.category?.formatting,12)}},title:{display:!!o?.category?.title?.text,text:o?.category?.title?.text||""},grid:{display:!0,color:"rgba(200,200,200,0.3)",lineWidth:1}},y:{type:"linear",min:p.min,max:p.max,ticks:{stepSize:p.stepSize,font:{size:this.getDOMFontSize(o?.value?.formatting,12)}},title:{display:!!o?.value?.title?.text,text:o?.value?.title?.text||""},grid:{display:!0,color:"rgba(200,200,200,0.3)",lineWidth:1}}}}if("bubble"===e){let e=o?.value||null,t=o?.valueSecondary||null,r=l.flatMap(e=>e.categories||[]).map(e=>parseFloat(e)).filter(e=>!isNaN(e)),i=l.flatMap(e=>e.values||[]).map(e=>parseFloat(e)).filter(e=>!isNaN(e));if(0===r.length||0===i.length)return{};let a=Math.min(...r),s=Math.max(...r),n=Math.min(...i),h=Math.max(...i),c=e=>{if(e<=0)return 1;let t=e/10,r=Math.pow(10,Math.floor(Math.log10(t)));for(let e of[1,2,2.5,5,10])if(r*e>=t)return r*e;return 10*r},u=e?.scaling?.majorUnit||c(s),d=t?.scaling?.majorUnit||c(h),p={min:a>=0?0:a,max:Math.ceil(1.2*s/u)*u,stepSize:u},g={min:n>=0?0:n,max:Math.ceil(1.1*h/d)*d,stepSize:d};e?.scaling?.min!=null&&(p.min=e.scaling.min),e?.scaling?.max!=null&&(p.max=e.scaling.max),e?.scaling?.majorUnit!=null&&(p.stepSize=e.scaling.majorUnit),t?.scaling?.min!=null&&(g.min=t.scaling.min),t?.scaling?.max!=null&&(g.max=t.scaling.max),t?.scaling?.majorUnit!=null&&(g.stepSize=t.scaling.majorUnit);let f=this.shouldReverseAxis(e?.scaling,"value"),m=this.shouldReverseAxis(t?.scaling,"value");return{x:{type:"linear",position:"bottom",min:p.min,max:p.max,reverse:f,title:{display:!!e?.title?.text,text:e?.title?.text||""},ticks:{stepSize:p.stepSize,font:{size:this.getDOMFontSize(e?.formatting,12)},callback:function(e){return e.toString()}},grid:{display:!1}},y:{type:"linear",position:"left",min:g.min,max:g.max,reverse:m,title:{display:!!t?.title?.text,text:t?.title?.text||""},ticks:{stepSize:g.stepSize,font:{size:this.getDOMFontSize(t?.formatting,12)},callback:function(e){return e.toString()}},grid:{color:t?.gridlines?.color||"rgba(136, 136, 136, 0.8)",lineWidth:1,display:!0}}}}let h=o?.value?.tickLabels?.formatting,c=o?.category?.tickLabels?.formatting,u=h?.color?this.convertColorToHex(h.color):"#666666",d=c?.color?this.convertColorToHex(c.color):"#666666",p=o?.value?.tickLabels?.format?.formatCode||"",g=p.includes("%"),f=/,\s*"?K"?\s*$/.test(p)||/\d"?K"?\s*$/.test(p),m=/,\s*"?M"?\s*$/.test(p),y=!g&&!f&&!m&&(p.includes("#,##0")||p.includes(",")),b=g||f||m||y?null:p.match(/^[#0.,]+\s*("([^"]+)"|([^#0.,\s%]+))$/),S=b&&(b[2]||b[3])||null,x=o?.value?.scaling?.displayUnit||1,w=g?function(e){return Math.round(100*e)+"%"}:f?function(e){return(e/x/1e3).toLocaleString()+"K"}:m?function(e){return(e/x/1e6).toLocaleString()+"M"}:x>1?function(e){let t=e/x;return y?Number(t).toLocaleString():Number.isInteger(t)?t.toString():t.toFixed(1)}:y?function(e){return Number(e).toLocaleString()}:S?function(e){return Math.round(Number(e)).toString()+S}:function(e){return e.toString()},C=o?.value?.visible===!1,T=o?.category?.visible===!1,P=e=>({l:"left",r:"right",b:"bottom",t:"top"})[e]||null,v=(e,t)=>{let r=e?.gridlines?.dash,i={color:e?.gridlines?.color||"rgba(136, 136, 136, 0.8)",lineWidth:1,display:!t,z:1};return r&&(i.borderDash=[5,5]),i},M=(e,t)=>{let r=e||t;return({bottom:"top",top:"bottom",left:"right",right:"left"})[r]||r},A=this.shouldReverseAxis(o?.value?.scaling,"value"),k=this.shouldReverseAxis(o?.category?.scaling,"category"),R=o?.category?.crosses,E=o?.value?.crosses,_=e=>!e||"autoZero"===e||"min"===e,F=P(o?.value?.position),I=P(o?.category?.position),L=A&&_(R)?M(I,"y"===s?"left":"bottom"):I,D=k&&_(E)?M(F,"y"===s?"bottom":"left"):F,B={y:{beginAtZero:t>=0,min:t,max:r,stacked:a,reverse:this.shouldReverseAxis(o?.value?.scaling,"value"),display:!C,...D?{position:D}:{},ticks:{stepSize:i,font:{size:this.getDOMFontSize(h,12)},color:u,callback:w},grid:v(o?.value,C)},x:{stacked:a,display:!T,reverse:this.shouldReverseAxis(o?.category?.scaling,"category"),...o?.category?.tickLabels?.position==="high"?{position:"top"}:L?{position:L}:{},ticks:{font:{size:this.getDOMFontSize(c,12)},color:d,...o?.category?.tickLabels?.rotation!=null?{maxRotation:o.category.tickLabels.rotation,minRotation:o.category.tickLabels.rotation}:{}},grid:{display:!1}}};if("y"===s){({...B});let e=this.shouldReverseAxis(o?.value?.scaling,"value");B.x={beginAtZero:t>=0,min:t,max:r,stacked:a,display:!C||!!e,reverse:e,...D?{position:D}:{},ticks:{display:!C,stepSize:i,font:{size:this.getDOMFontSize(h,12)},color:u,callback:w},border:{display:!C},grid:v(o?.value,C)},B.y={stacked:a,display:!T,reverse:!this.shouldReverseAxis(o?.category?.scaling,"category"),...L?{position:L}:{},ticks:{font:{size:this.getDOMFontSize(c,12)},color:d},grid:v(o?.category,T)}}return"y"===s?(o?.value?.title&&(B.x.title={display:!0,text:o.value.title.text||o.value.title,font:{size:this.getDOMFontSize(o?.value?.title?.formatting,14),weight:"bold"},color:o?.value?.title?.formatting?.color?this.convertColorToHex(o.value.title.formatting.color):"#666666"}),o?.category?.title&&(B.y.title={display:!0,text:o.category.title.text||o.category.title,font:{size:this.getDOMFontSize(o?.category?.title?.formatting,14),weight:"bold"},color:o?.category?.title?.formatting?.color?this.convertColorToHex(o.category.title.formatting.color):"#666666"})):(o?.value?.title&&(B.y.title={display:!0,text:o.value.title.text||o.value.title,font:{size:this.getDOMFontSize(o?.value?.title?.formatting,14),weight:"bold"},color:o?.value?.title?.formatting?.color?this.convertColorToHex(o.value.title.formatting.color):"#666666"}),o?.category?.title&&(B.x.title={display:!0,text:o.category.title.text||o.category.title,font:{size:this.getDOMFontSize(o?.category?.title?.formatting,14),weight:"bold"},color:o?.category?.title?.formatting?.color?this.convertColorToHex(o.category.title.formatting.color):"#666666"})),B}getTooltipConfig(e,t){return"bubble"===e?{mode:"point",intersect:!0,callbacks:{title:function(e){return e[0].dataset.label||""},label:function(e){let t=e.parsed;return[`Market Share: ${t.x}%`,`Revenue: $${t.y.toLocaleString()}k`,`Customer Base: ${t.r} units`]}}}:{mode:t?"index":"nearest",intersect:!1,callbacks:{label:function(e){let t=e.dataset.label||"";return t&&(t+=": "),null!==e.parsed.y&&(t+=e.parsed.y.toLocaleString()),t}}}}shouldShowDataLabels(e){if(e&&e.series&&e.series.length>0){let t=!1;for(let r of e.series)if(r.dataLabels&&(t=!0,!0===r.dataLabels.showValue||!0===r.dataLabels.showSeriesName))return!0;if(t)return!1}if(e&&e.dataLabels){let t=e.dataLabels.showValue,r=!0===e.dataLabels.showSeriesName;if(!0===t||r)return!0;if(!1===t&&!r)return!1}return!!e&&void 0!==e.showDataLabels&&e.showDataLabels}shouldReverseAxis(e,t){return!!e&&!!e.orientation&&"maxMin"===e.orientation}formatExcelDate(e,t){let r=new Date((e-25569)*864e5);if(isNaN(r.getTime()))return String(e);let i=r.getUTCFullYear(),a=String(r.getUTCMonth()+1).padStart(2,"0"),o=String(i).slice(-2),l=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.getUTCMonth()],s=(t||"").toLowerCase();return"yyyy-mm"===s||"yyyy\\-mm"===s?`${i}-${a}`:"mmm-yy"===s||"mmm\\-yy"===s||s.includes("mmm")&&s.includes("yy")?`${l}-${o}`:(s.includes("yyyy")&&s.includes("mm"),`${i}-${a}`)}calculateOptimalAxisScale(e,t=0){if(e<=0)return{max:10,step:2};let r=Math.pow(10,Math.floor(Math.log10(e-Math.min(t,0)))),i=[1,2,5,10],a=r;for(let t of i){let i=r/10*t;if(i>0){let t=Math.ceil(1.05*e/i);if(t>=4&&t<=8){a=i;break}}}if(a===r)for(let t of i){let i=t*r,o=Math.ceil(1.05*e/i);if(o>=4&&o<=8){a=i;break}}let o=Math.ceil(1.05*e/a)*a;if(e<1){let t=e<.1?.02:.2;return{max:Math.ceil(1.1*e/t)*t,step:t}}return{max:o,step:a}}}M.exports&&(M.exports=e),"u">typeof window&&(window.ChartJSRenderer=e),M.exports}();!function(){if(!d){d=1,"u"<typeof AscCommon&&(window.AscCommon={}),"u"<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(e,t){return e*this.sx+t*this.shx+this.tx}TransformPointY(e,t){return e*this.shy+t*this.sy+this.ty}Invert(){let e=this.sx*this.sy-this.shx*this.shy;if(1e-12>Math.abs(e))return;let t=1/e,r=this.sy*t,i=this.sx*t,a=-this.shx*t,o=-this.shy*t,l=(this.shx*this.ty-this.sy*this.tx)*t,s=(this.shy*this.tx-this.sx*this.ty)*t;this.sx=r,this.sy=i,this.shx=a,this.shy=o,this.tx=l,this.ty=s}createDuplicate(){let t=new e;return t.sx=this.sx,t.sy=this.sy,t.shx=this.shx,t.shy=this.shy,t.tx=this.tx,t.ty=this.ty,t}reset(){this.sx=1,this.sy=1,this.shx=0,this.shy=0,this.tx=0,this.ty=0}}"u"<typeof CBrush&&(window.CBrush=class{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}}),"u"<typeof CPen&&(window.CPen=class{constructor(){this.Color={R:0,G:0,B:0,A:255},this.Size=1,this.DashStyle=0}}),"u"<typeof CFontManager&&(window.CFontManager=class{constructor(){this.m_oGlyphString={m_fX:0,m_fY:0,m_pGlyphsBuffer:[]}}LoadString4C(e,t,r){return this.m_oGlyphString.m_fX=t,this.m_oGlyphString.m_fY=r,t+10}LoadString2(e,t,r){this.m_oGlyphString.m_fX=t,this.m_oGlyphString.m_fY=r}GetNextChar2(){return null}});class t{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=!1,this.customGeometryProcessor=new i}get context(){return this._context}init(e,t,r,i,a){this._context=e,this.widthPx=t,this.heightPx=r,this.widthMM=i||25.4*t/96,this.heightMM=a||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();let e=this.transform.sx*this.transform.sx+this.transform.shx*this.transform.shy,t=this.transform.sy*this.transform.sy+this.transform.shy*this.transform.shx,r=this.transform.sx*this.transform.shx+this.transform.shx*this.transform.sy,i=this.transform.sy*this.transform.shy+this.transform.shy*this.transform.sx,a=this.transform.sx*this.transform.tx+this.transform.shx*this.transform.ty+this.transform.tx,o=this.transform.sy*this.transform.ty+this.transform.shy*this.transform.tx+this.transform.ty;this.transform.sx=e,this.transform.sy=t,this.transform.shx=r,this.transform.shy=i,this.transform.tx=a,this.transform.ty=o,this.transform=this.transform.createDuplicate(),this.transform.Invert()}resetState(){this.coordinateSystem=null,this.transform.reset(),this.grStateStack=[],this.clipStack=[],this.currentRenderingShape=null,this.customGeometryProcessor&&this.customGeometryProcessor.cache.clear(),this.currentPath=null,this.isPathStarted=!1,this.brush=new CBrush,this.pen=new CPen}SaveGrState(){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(),this.grStateStack.length>0)){let e=this.grStateStack.pop();this.transform=e.transform,this.transform=e.fullTransform,this.transform=e.invertFullTransform}}transform3(e){this.transform=e.createDuplicate(),this.recalculateTransforms(),this._context&&this._context.setTransform(this.transform.sx,this.transform.shy,this.transform.shx,this.transform.sy,this.transform.tx,this.transform.ty)}AddClipRect(e,t,r,i){this._context&&(this._context.save(),this._context.beginPath(),this._context.rect(e,t,r,i),this._context.clip())}clear(){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(e,t,r,i){if(this.bIsBreak||!this._context)return;this._context.fillStyle=this.colorToRgb(this.brush.Color1),this._context.textBaseline="alphabetic";let a=t,o=null;this._context.fillText(e,a,r);let l=this._context.measureText(e);return i&&(o={x:t,y:r,r:t+l.width,b:r},void 0!==l.actualBoundingBoxAscent&&(o.y=r-l.actualBoundingBoxAscent),void 0!==l.actualBoundingBoxDescent&&(o.b=r+l.actualBoundingBoxDescent)),a+=l.width,o}b_color1(e,t,r,i=255){this.brush.Color1.R=e,this.brush.Color1.G=t,this.brush.Color1.B=r,this.brush.Color1.A=i,this.bBrushColorInit=!0}p_color(e,t,r,i=255){this.pen.Color.R=e,this.pen.Color.G=t,this.pen.Color.B=r,this.pen.Color.A=i,this.bPenColorInit=!0}p_width(e){this.pen.Size=e,this._context&&(this._context.lineWidth=e)}fillRect(e,t,r,i,a){this._context&&a&&(this._context.save(),this._context.fillStyle=this.colorToRgb(a),this._context.fillRect(e,t,r,i),this._context.restore())}strokeRect(e,t,r,i,a,o=1){this._context&&(this._context.save(),this._context.strokeStyle=this.colorToRgb(a)||this.colorToRgb(this.pen.Color),this._context.lineWidth=o,this._context.strokeRect(e,t,r,i),this._context.restore())}drawLine(e,t,r,i,a,o=1){this._context&&(this._context.save(),this._context.strokeStyle=this.colorToRgb(a),this._context.lineWidth=o,this._context.beginPath(),this._context.moveTo(e,t),this._context.lineTo(r,i),this._context.stroke(),this._context.restore())}fillCircle(e,t,r,i){this._context&&(this._context.save(),this._context.fillStyle=this.colorToRgb(i),this._context.beginPath(),this._context.arc(e,t,r,0,2*Math.PI),this._context.fill(),this._context.restore())}strokeCircle(e,t,r,i,a=1){this._context&&(this._context.save(),this._context.strokeStyle=this.colorToRgb(i),this._context.lineWidth=a,this._context.beginPath(),this._context.arc(e,t,r,0,2*Math.PI),this._context.stroke(),this._context.restore())}fillText(e,t,r,i={}){if(!this._context)return;this._context.save();let a=i.fontSize||i.size||12,o=i.fontFamily||i.family||"Arial",l=i.bold?"bold":"normal",s=i.italic?"italic":"normal";this._context.font=`${s} ${l} ${a}px ${o}`,this._context.fillStyle=this.colorToRgb(i.color||{r:0,g:0,b:0}),this._context.textAlign=i.textAlign||"left",this._context.textBaseline=i.textBaseline||"alphabetic",this._context.fillText(e,t,r),this._context.restore()}colorToRgb(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=void 0!==e.r?e.r:void 0!==e.R?e.R:0,r=void 0!==e.g?e.g:void 0!==e.G?e.G:0,i=void 0!==e.b?e.b:void 0!==e.B?e.B:0,a=void 0!==e.a?e.a:void 0!==e.A?e.A:255;return void 0!==a&&255!==a?`rgba(${t}, ${r}, ${i}, ${a/255})`:`rgb(${t}, ${r}, ${i})`}return"rgb(0, 0, 0)"}Start_Command(e){this.commandStack.push(e)}End_Command(e){this.commandStack.length>0&&this.commandStack.pop()}get context(){return this._context}isBoundsChecker(){return!1}drawPresetGeometry(e,t,r,i,a,o,l,s=1,n=null,h={}){if(!this._context)return;let c=this._context;if(c.save(),o&&"object"==typeof o&&void 0!==o.a&&o.a<255&&(c.globalAlpha=o.a/255,o={...o,a:255}),o&&"object"==typeof o&&"linear"===o.type&&o.stops){let e=this.createCanvasGradient?this.createCanvasGradient(c,{x:t,y:r,w:i,h:a},o):null;e?c.fillStyle=e:o.stops[0]?.color&&(c.fillStyle=this.colorToRgb(o.stops[0].color))}else o&&(c.fillStyle=this.colorToRgb(o));switch(l&&(c.strokeStyle=this.colorToRgb(l),c.lineWidth=CoordinateTransform.mmToPixels(s||1)),c.beginPath(),e){case"teardrop":this.drawTeardropPath(c,t,r,i,a);break;case"rect":case"rectangle":default:c.rect(t,r,i,a);break;case"ellipse":case"oval":case"flowChartConnector":c.ellipse(t+i/2,r+a/2,i/2,a/2,0,0,2*Math.PI);break;case"roundRect":{let e=Math.min(5e4,Math.max(0,void 0!==h.adj?h.adj:16667))/1e5*Math.min(i,a);this.drawRoundRectPath(c,t,r,i,a,e);break}case"triangle":this.drawTrianglePath(c,t,r,i,a);break;case"diamond":this.drawDiamondPath(c,t,r,i,a);break;case"pentagon":this.drawPentagonPath(c,t,r,i,a);break;case"hexagon":this.drawHexagonPath(c,t,r,i,a);break;case"octagon":this.drawOctagonPath(c,t,r,i,a);break;case"star":case"star5":this.drawStarPath(c,t,r,i,a);break;case"star4":this.drawStar4Path(c,t,r,i,a);break;case"star6":this.drawStar6Path(c,t,r,i,a);break;case"star8":this.drawStar8Path(c,t,r,i,a);break;case"star10":this.drawStar10Path(c,t,r,i,a);break;case"star12":this.drawStar12Path(c,t,r,i,a);break;case"star16":this.drawStar16Path(c,t,r,i,a);break;case"star24":this.drawStar24Path(c,t,r,i,a);break;case"star32":this.drawStar32Path(c,t,r,i,a);break;case"heart":this.drawHeartPath(c,t,r,i,a);break;case"flowChartProcess":this.drawFlowChartProcessPath(c,t,r,i,a);break;case"flowChartDecision":this.drawFlowChartDecisionPath(c,t,r,i,a);break;case"flowChartInputOutput":this.drawFlowChartInputOutputPath(c,t,r,i,a);break;case"flowChartPredefinedProcess":this.drawFlowChartPredefinedProcessPath(c,t,r,i,a);break;case"flowChartInternalStorage":this.drawFlowChartInternalStoragePath(c,t,r,i,a);break;case"flowChartDocument":this.drawFlowChartDocumentPath(c,t,r,i,a);break;case"flowChartMultidocument":this.drawFlowChartMultidocumentPath(c,t,r,i,a);break;case"flowChartTerminator":this.drawRoundRectPath(c,t,r,i,a,.2*Math.min(i,a));break;case"flowChartPreparation":this.drawFlowChartPreparationPath(c,t,r,i,a);break;case"flowChartManualInput":this.drawFlowChartManualInputPath(c,t,r,i,a);break;case"flowChartManualOperation":this.drawFlowChartManualOperationPath(c,t,r,i,a);break;case"flowChartOffpageConnector":this.drawFlowChartOffpageConnectorPath(c,t,r,i,a);break;case"flowChartPunchedCard":this.drawFlowChartPunchedCardPath(c,t,r,i,a);break;case"flowChartPunchedTape":this.drawFlowChartPunchedTapePath(c,t,r,i,a);break;case"flowChartSummingJunction":this.drawFlowChartSummingJunctionPath(c,t,r,i,a);break;case"flowChartOr":this.drawFlowChartOrPath(c,t,r,i,a);break;case"flowChartCollate":this.drawFlowChartCollatePath(c,t,r,i,a);break;case"flowChartSort":this.drawFlowChartSortPath(c,t,r,i,a);break;case"flowChartExtract":this.drawFlowChartExtractPath(c,t,r,i,a);break;case"flowChartMerge":this.drawFlowChartMergePath(c,t,r,i,a);break;case"flowChartStoredData":this.drawFlowChartStoredDataPath(c,t,r,i,a);break;case"flowChartDelay":this.drawFlowChartDelayPath(c,t,r,i,a);break;case"flowChartMagneticTape":this.drawFlowChartMagneticTapePath(c,t,r,i,a);break;case"flowChartMagneticDisk":this.drawFlowChartMagneticDiskPath(c,t,r,i,a);break;case"flowChartMagneticDrum":this.drawFlowChartMagneticDrumPath(c,t,r,i,a);break;case"flowChartDisplay":this.drawFlowChartDisplayPath(c,t,r,i,a);break;case"rightArrow":case"notchedRightArrow":case"stripedRightArrow":this.drawRightArrowPath(c,t,r,i,a);break;case"leftArrow":this.drawLeftArrowPath(c,t,r,i,a);break;case"upArrow":this.drawUpArrowPath(c,t,r,i,a);break;case"downArrow":this.drawDownArrowPath(c,t,r,i,a);break;case"leftRightArrow":this.drawLeftRightArrowPath(c,t,r,i,a);break;case"upDownArrow":this.drawUpDownArrowPath(c,t,r,i,a);break;case"quadArrow":this.drawQuadArrowPath(c,t,r,i,a);break;case"bentArrow":this.drawBentArrowPath(c,t,r,i,a);break;case"uturnArrow":this.drawUturnArrowPath(c,t,r,i,a);break;case"curvedRightArrow":this.drawCurvedRightArrowPath(c,t,r,i,a);break;case"curvedLeftArrow":this.drawCurvedLeftArrowPath(c,t,r,i,a);break;case"callout1":this.drawCallout1Path(c,t,r,i,a);break;case"callout2":this.drawCallout2Path(c,t,r,i,a);break;case"callout3":this.drawCallout3Path(c,t,r,i,a);break;case"accentCallout1":case"accentBorderCallout1":this.drawAccentCallout1Path(c,t,r,i,a);break;case"accentCallout2":case"accentBorderCallout2":this.drawAccentCallout2Path(c,t,r,i,a);break;case"accentCallout3":case"accentBorderCallout3":this.drawAccentCallout3Path(c,t,r,i,a);break;case"borderCallout1":this.drawBorderCallout1Path(c,t,r,i,a);break;case"borderCallout2":this.drawBorderCallout2Path(c,t,r,i,a);break;case"borderCallout3":this.drawBorderCallout3Path(c,t,r,i,a);break;case"lightningBolt":this.drawLightningBoltPath(c,t,r,i,a);break;case"sun":this.drawSunPath(c,t,r,i,a);break;case"moon":this.drawMoonPath(c,t,r,i,a);break;case"cloud":this.drawCloudPath(c,t,r,i,a);break;case"wave":this.drawWavePath(c,t,r,i,a);break;case"doubleWave":this.drawDoubleWavePath(c,t,r,i,a);break;case"smileyFace":this.drawSmileyFacePath(c,t,r,i,a);break;case"noSmoking":this.drawNoSmokingPath(c,t,r,i,a);break;case"blockArc":this.drawBlockArcPath(c,t,r,i,a);break;case"foldedCorner":this.drawFoldedCornerPath(c,t,r,i,a);break;case"bevel":this.drawBevelPath(c,t,r,i,a);break;case"donut":this.drawDonutPath(c,t,r,i,a);break;case"noSymbol":this.drawNoSymbolPath(c,t,r,i,a);break;case"cube":this.drawCubePath(c,t,r,i,a);break;case"can":this.drawCanPath(c,t,r,i,a);break;case"cone":this.drawConePath(c,t,r,i,a);break;case"pyramid":this.drawPyramidPath(c,t,r,i,a);break;case"plus":case"cross":case"mathPlus":this.drawPlusPath(c,t,r,i,a);break;case"minus":case"mathMinus":this.drawMinusPath(c,t,r,i,a);break;case"multiply":case"mathMultiply":this.drawMultiplyPath(c,t,r,i,a);break;case"divide":case"mathDivide":this.drawDividePath(c,t,r,i,a);break;case"equal":case"mathEqual":this.drawEqualPath(c,t,r,i,a);break;case"notEqual":case"mathNotEqual":this.drawNotEqualPath(c,t,r,i,a);break;case"line":case"straightConnector1":this.drawLinePath(c,t,r,i,a);break;case"bentConnector2":this.drawBentConnector2Path(c,t,r,i,a);break;case"bentConnector3":this.drawBentConnector3Path(c,t,r,i,a);break;case"bentConnector4":this.drawBentConnector4Path(c,t,r,i,a);break;case"bentConnector5":this.drawBentConnector5Path(c,t,r,i,a);break;case"curvedConnector2":this.drawCurvedConnector2Path(c,t,r,i,a);break;case"curvedConnector3":this.drawCurvedConnector3Path(c,t,r,i,a);break;case"curvedConnector4":this.drawCurvedConnector4Path(c,t,r,i,a);break;case"curvedConnector5":this.drawCurvedConnector5Path(c,t,r,i,a);break;case"rtTriangle":c.moveTo(t,r+a),c.lineTo(t+i,r+a),c.lineTo(t,r),c.closePath();break;case"arc":{let e=(void 0!==h.adj1?h.adj1:0)/6e4,o=(void 0!==h.adj2?h.adj2:216e5)/6e4,l=e*Math.PI/180,s=o*Math.PI/180,n=t+i/2,u=r+a/2,d=i/2,p=a/2;c.moveTo(n,u),c.ellipse(n,u,d,p,0,l,s),c.closePath();break}case"pie":case"pieWedge":{let e=t+i/2,o=r+a/2;c.moveTo(e,o),c.arc(e,o,Math.min(i,a)/2,-Math.PI/2,0),c.closePath();break}case"chord":c.arc(t+i/2,r+a/2,Math.min(i,a)/2,0,1.5*Math.PI,!0),c.closePath();break;case"frame":{let e=.15*Math.min(i,a);c.rect(t,r,i,a),c.moveTo(t+e,r+e),c.rect(t+e,r+e,i-2*e,a-2*e);break}case"parallelogram":{let e=.25*i;c.moveTo(t+e,r),c.lineTo(t+i,r),c.lineTo(t+i-e,r+a),c.lineTo(t,r+a),c.closePath();break}case"trapezoid":{let e=.2*i;c.moveTo(t+e,r),c.lineTo(t+i-e,r),c.lineTo(t+i,r+a),c.lineTo(t,r+a),c.closePath();break}case"chevron":{let e=.25*i;c.moveTo(t,r),c.lineTo(t+i-e,r),c.lineTo(t+i,r+a/2),c.lineTo(t+i-e,r+a),c.lineTo(t,r+a),c.lineTo(t+e,r+a/2),c.closePath();break}case"homePlate":{let e=.2*i;c.moveTo(t,r),c.lineTo(t+i-e,r),c.lineTo(t+i,r+a/2),c.lineTo(t+i-e,r+a),c.lineTo(t,r+a),c.closePath();break}case"leftBracket":{let e=.15*a;c.moveTo(t+.4*i,r),c.quadraticCurveTo(t,r,t,r+e),c.lineTo(t,r+a-e),c.quadraticCurveTo(t,r+a,t+.4*i,r+a);break}case"rightBracket":{let e=.15*a;c.moveTo(t+.6*i,r),c.quadraticCurveTo(t+i,r,t+i,r+e),c.lineTo(t+i,r+a-e),c.quadraticCurveTo(t+i,r+a,t+.6*i,r+a);break}case"leftBrace":{let e=r+a/2,o=.4*i;c.moveTo(t+i,r),c.quadraticCurveTo(t+o,r,t+o,e-.1*a),c.quadraticCurveTo(t+o,e,t,e),c.quadraticCurveTo(t+o,e,t+o,e+.1*a),c.quadraticCurveTo(t+o,r+a,t+i,r+a);break}case"rightBrace":{let e=r+a/2,o=.6*i;c.moveTo(t,r),c.quadraticCurveTo(t+o,r,t+o,e-.1*a),c.quadraticCurveTo(t+o,e,t+i,e),c.quadraticCurveTo(t+o,e,t+o,e+.1*a),c.quadraticCurveTo(t+o,r+a,t,r+a);break}case"bracketPair":{let e=.15*Math.min(i,a);c.moveTo(t+e,r),c.arc(t+e,r+e,e,-Math.PI/2,Math.PI,!0),c.lineTo(t,r+a-e),c.arc(t+e,r+a-e,e,Math.PI,Math.PI/2,!0),c.moveTo(t+i-e,r),c.arc(t+i-e,r+e,e,-Math.PI/2,0),c.lineTo(t+i,r+a-e),c.arc(t+i-e,r+a-e,e,0,Math.PI/2);break}case"bracePair":{let e=.15*Math.min(i,a);c.moveTo(t+e,r),c.arc(t+e,r+e,e,-Math.PI/2,Math.PI,!0),c.lineTo(t,r+a-e),c.arc(t+e,r+a-e,e,Math.PI,Math.PI/2,!0),c.moveTo(t+i-e,r),c.arc(t+i-e,r+e,e,-Math.PI/2,0),c.lineTo(t+i,r+a-e),c.arc(t+i-e,r+a-e,e,0,Math.PI/2);break}case"diagStripe":c.moveTo(t,r),c.lineTo(t+i,r),c.lineTo(t,r+a),c.closePath();break;case"corner":{let e=.4*i,o=.4*a;c.moveTo(t,r),c.lineTo(t+e,r),c.lineTo(t+e,r+a-o),c.lineTo(t+i,r+a-o),c.lineTo(t+i,r+a),c.lineTo(t,r+a),c.closePath();break}case"halfFrame":{let e=.2*i,o=.2*a;c.moveTo(t,r),c.lineTo(t+i,r),c.lineTo(t+i-e,r+o),c.lineTo(t+e,r+o),c.lineTo(t+e,r+a),c.lineTo(t,r+a),c.closePath();break}case"snip1Rect":case"snip2SameRect":case"snip2DiagRect":case"snipRoundRect":{let e=.15*Math.min(i,a);c.moveTo(t+e,r),c.lineTo(t+i-e,r),c.lineTo(t+i,r+e),c.lineTo(t+i,r+a),c.lineTo(t,r+a),c.lineTo(t,r+e),c.closePath();break}case"round1Rect":case"round2SameRect":case"round2DiagRect":this.drawRoundRectPath(c,t,r,i,a,.15*Math.min(i,a));break;case"ribbon":case"ribbon2":c.moveTo(t,r+.3*a),c.lineTo(t+.15*i,r+.15*a),c.lineTo(t+.15*i,r),c.lineTo(t+.85*i,r),c.lineTo(t+.85*i,r+.15*a),c.lineTo(t+i,r+.3*a),c.lineTo(t+.85*i,r+.45*a),c.lineTo(t+.85*i,r+a),c.lineTo(t+.15*i,r+a),c.lineTo(t+.15*i,r+.45*a),c.closePath();break;case"circularArrow":c.arc(t+i/2,r+a/2,Math.min(i,a)/2,0,1.5*Math.PI,!0)}if(o&&c.fill(),l){if(c.globalAlpha=1,n&&n.dashArray&&n.dashArray.length>0){let e=CoordinateTransform.mmToPixels(s||1),t=n.dashArray.map(t=>t*e);c.setLineDash(t)}c.stroke()}c.restore()}drawTeardropPath(e,t,r,i,a){let o=i/1001,l=a/992;e.moveTo(t+711*o,r+7*l),e.bezierCurveTo(t+475*o,r+8*l,t+442*o,r+8*l,t+423*o,r+12*l),e.bezierCurveTo(t+312*o,r+31*l,t+221*o,r+77*l,t+144*o,r+154*l),e.bezierCurveTo(t+53*o,r+247*l,t+4*o,r+363*l,t+4*o,r+492*l),e.bezierCurveTo(t+4*o,r+565*l,t+16*o,r+625*l,t+46*o,r+689*l),e.bezierCurveTo(t+82*o,r+769*l,t+143*o,r+842*l,t+219*o,r+894*l),e.bezierCurveTo(t+258*o,r+921*l,t+307*o,r+945*l,t+359*o,r+961*l),e.bezierCurveTo(t+418*o,r+980*l,t+509*o,r+987*l,t+577*o,r+977*l),e.bezierCurveTo(t+720*o,r+956*l,t+845*o,r+878*l,t+922*o,r+758*l),e.bezierCurveTo(t+953*o,r+710*l,t+977*o,r+654*l,t+988*o,r+603*l),e.bezierCurveTo(t+1001*o,r+544*l,t+1001*o,r+546*l,t+1001*o,r+265*l),e.lineTo(t+1001*o,r+7*l),e.lineTo(t+989*o,r+6*l),e.bezierCurveTo(t+983*o,r+6*l,t+857*o,r+6*l,t+711*o,r+7*l),e.closePath()}drawRoundRectPath(e,t,r,i,a,o){e.moveTo(t+o,r),e.lineTo(t+i-o,r),e.quadraticCurveTo(t+i,r,t+i,r+o),e.lineTo(t+i,r+a-o),e.quadraticCurveTo(t+i,r+a,t+i-o,r+a),e.lineTo(t+o,r+a),e.quadraticCurveTo(t,r+a,t,r+a-o),e.lineTo(t,r+o),e.quadraticCurveTo(t,r,t+o,r),e.closePath()}drawTrianglePath(e,t,r,i,a){e.moveTo(t+i/2,r),e.lineTo(t+i,r+a),e.lineTo(t,r+a),e.closePath()}drawDiamondPath(e,t,r,i,a){e.moveTo(t+i/2,r),e.lineTo(t+i,r+a/2),e.lineTo(t+i/2,r+a),e.lineTo(t,r+a/2),e.closePath()}drawPentagonPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;for(let t=0;t<5;t++){let r=2*t*Math.PI/5-Math.PI/2,i=o+s*Math.cos(r),a=l+s*Math.sin(r);0===t?e.moveTo(i,a):e.lineTo(i,a)}e.closePath()}drawHexagonPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;for(let t=0;t<6;t++){let r=2*t*Math.PI/6,i=o+s*Math.cos(r),a=l+s*Math.sin(r);0===t?e.moveTo(i,a):e.lineTo(i,a)}e.closePath()}drawStarPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2,n=.4*s;for(let t=0;t<10;t++){let r=t*Math.PI/5-Math.PI/2,i=t%2==0?s:n,a=o+i*Math.cos(r),h=l+i*Math.sin(r);0===t?e.moveTo(a,h):e.lineTo(a,h)}e.closePath()}drawHeartPath(e,t,r,i,a){let o=i/20,l=a/18.35,s=e=>t+(e-2)*o,n=e=>r+(e-3)*l;e.moveTo(s(12),n(21.35)),e.lineTo(s(10.55),n(20.03)),e.bezierCurveTo(s(5.4),n(15.36),s(2),n(12.28),s(2),n(8.5)),e.bezierCurveTo(s(2),n(5.42),s(4.42),n(3),s(7.5),n(3)),e.bezierCurveTo(s(9.24),n(3),s(10.91),n(3.81),s(12),n(5.09)),e.bezierCurveTo(s(13.09),n(3.81),s(14.76),n(3),s(16.5),n(3)),e.bezierCurveTo(s(19.58),n(3),s(22),n(5.42),s(22),n(8.5)),e.bezierCurveTo(s(22),n(12.28),s(18.6),n(15.36),s(13.45),n(20.04)),e.lineTo(s(12),n(21.35)),e.closePath()}drawOctagonPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;for(let t=0;t<8;t++){let r=2*t*Math.PI/8,i=o+s*Math.cos(r),a=l+s*Math.sin(r);0===t?e.moveTo(i,a):e.lineTo(i,a)}e.closePath()}drawStar4Path(e,t,r,i,a){this.drawStarGeneric(e,t,r,i,a,4)}drawStar6Path(e,t,r,i,a){this.drawStarGeneric(e,t,r,i,a,6)}drawStar8Path(e,t,r,i,a){this.drawStarGeneric(e,t,r,i,a,8)}drawStar10Path(e,t,r,i,a){this.drawStarGeneric(e,t,r,i,a,10)}drawStar12Path(e,t,r,i,a){this.drawStarGeneric(e,t,r,i,a,12)}drawStar16Path(e,t,r,i,a){this.drawStarGeneric(e,t,r,i,a,16)}drawStar24Path(e,t,r,i,a){this.drawStarGeneric(e,t,r,i,a,24)}drawStar32Path(e,t,r,i,a){this.drawStarGeneric(e,t,r,i,a,32)}drawStarGeneric(e,t,r,i,a,o){let l=t+i/2,s=r+a/2,n=Math.min(i,a)/2,h=.4*n;for(let t=0;t<2*o;t++){let r=t*Math.PI/o-Math.PI/2,i=t%2==0?n:h,a=l+i*Math.cos(r),c=s+i*Math.sin(r);0===t?e.moveTo(a,c):e.lineTo(a,c)}e.closePath()}drawFlowChartProcessPath(e,t,r,i,a){e.rect(t,r,i,a)}drawFlowChartDecisionPath(e,t,r,i,a){let o=t+i/2,l=r+a/2;e.moveTo(o,r),e.lineTo(t+i,l),e.lineTo(o,r+a),e.lineTo(t,l),e.closePath()}drawFlowChartInputOutputPath(e,t,r,i,a){let o=.2*i;e.moveTo(t+o,r),e.lineTo(t+i,r),e.lineTo(t+i-o,r+a),e.lineTo(t,r+a),e.closePath()}drawFlowChartPredefinedProcessPath(e,t,r,i,a){let o=.12*i;e.rect(t,r,i,a),e.moveTo(t+o,r),e.lineTo(t+o,r+a),e.moveTo(t+i-o,r),e.lineTo(t+i-o,r+a)}drawFlowChartInternalStoragePath(e,t,r,i,a){let o=.2*Math.min(i,a);e.rect(t,r,i,a),e.moveTo(t,r+o),e.lineTo(t+i,r+o),e.moveTo(t+o,r),e.lineTo(t+o,r+a)}drawFlowChartDocumentPath(e,t,r,i,a){let o=.2*a,l=r+a-o;e.moveTo(t,r),e.lineTo(t+i,r),e.lineTo(t+i,l),e.bezierCurveTo(t+.5*i,r+a+o,t+.5*i,r+a-o,t,l),e.closePath()}drawFlowChartMultidocumentPath(e,t,r,i,a){let o=.1*Math.min(i,a);e.rect(t+2*o,r,i-2*o,a-2*o),e.rect(t+o,r+o,i-o,a-o),this.drawFlowChartDocumentPath(e,t,r+2*o,i-2*o,a-2*o)}drawFlowChartPreparationPath(e,t,r,i,a){let o=.2*i;e.moveTo(t,r+a/2),e.lineTo(t+o,r),e.lineTo(t+i-o,r),e.lineTo(t+i,r+a/2),e.lineTo(t+i-o,r+a),e.lineTo(t+o,r+a),e.closePath()}drawFlowChartManualInputPath(e,t,r,i,a){e.moveTo(t,r+.2*a),e.lineTo(t+i,r),e.lineTo(t+i,r+a),e.lineTo(t,r+a),e.closePath()}drawFlowChartManualOperationPath(e,t,r,i,a){let o=.2*i;e.moveTo(t,r),e.lineTo(t+i,r),e.lineTo(t+i-o,r+a),e.lineTo(t+o,r+a),e.closePath()}drawFlowChartOffpageConnectorPath(e,t,r,i,a){let o=.2*a;e.moveTo(t,r),e.lineTo(t+i,r),e.lineTo(t+i,r+a-o),e.lineTo(t+i/2,r+a),e.lineTo(t,r+a-o),e.closePath()}drawFlowChartPunchedCardPath(e,t,r,i,a){let o=.1*Math.min(i,a);e.moveTo(t+o,r),e.lineTo(t+i,r),e.lineTo(t+i,r+a),e.lineTo(t,r+a),e.lineTo(t,r+o),e.closePath()}drawFlowChartPunchedTapePath(e,t,r,i,a){let o=.1*a;e.moveTo(t,r),e.bezierCurveTo(t+.25*i,r+o,t+.75*i,r-o,t+i,r),e.lineTo(t+i,r+a),e.bezierCurveTo(t+.75*i,r+a-o,t+.25*i,r+a+o,t,r+a),e.closePath()}drawFlowChartSummingJunctionPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.arc(o,l,s,0,2*Math.PI);let n=.6*s;e.moveTo(o-n,l),e.lineTo(o+n,l),e.moveTo(o,l-n),e.lineTo(o,l+n)}drawFlowChartOrPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.arc(o,l,s,0,2*Math.PI);let n=.6*s;e.moveTo(o-n,l-n),e.lineTo(o+n,l+n),e.moveTo(o+n,l-n),e.lineTo(o-n,l+n)}drawFlowChartCollatePath(e,t,r,i,a){e.moveTo(t,r),e.lineTo(t+i,r+a),e.lineTo(t,r+a),e.lineTo(t+i,r),e.closePath()}drawFlowChartSortPath(e,t,r,i,a){e.moveTo(t,r),e.lineTo(t+i,r),e.lineTo(t+i/2,r+a),e.closePath(),e.moveTo(t+.25*i,r+.5*a),e.lineTo(t+.75*i,r+.5*a)}drawFlowChartExtractPath(e,t,r,i,a){e.moveTo(t,r+a),e.lineTo(t+i/2,r),e.lineTo(t+i,r+a),e.closePath()}drawFlowChartMergePath(e,t,r,i,a){e.moveTo(t,r),e.lineTo(t+i,r),e.lineTo(t+i/2,r+a),e.closePath()}drawFlowChartStoredDataPath(e,t,r,i,a){let o=.1*i;e.arc(t+o,r+a/2,a/2,Math.PI/2,-Math.PI/2),e.lineTo(t+i-o,r),e.arc(t+i-o,r+a/2,a/2,-Math.PI/2,Math.PI/2),e.lineTo(t+o,r+a)}drawFlowChartDelayPath(e,t,r,i,a){let o=.2*i;e.moveTo(t,r),e.lineTo(t+i-o,r),e.arc(t+i-o,r+a/2,a/2,-Math.PI/2,Math.PI/2),e.lineTo(t,r+a),e.closePath()}drawFlowChartMagneticTapePath(e,t,r,i,a){let o=.15*a;e.moveTo(t,r+o),e.bezierCurveTo(t+.33*i,r,t+.67*i,r+2*o,t+i,r+o),e.lineTo(t+i,r+a-o),e.bezierCurveTo(t+.67*i,r+a-2*o,t+.33*i,r+a,t,r+a-o),e.closePath()}drawFlowChartMagneticDiskPath(e,t,r,i,a){let o=.2*a;e.ellipse(t+i/2,r+o/2,i/2,o/2,0,0,2*Math.PI),e.moveTo(t,r+o/2),e.lineTo(t,r+a-o/2),e.moveTo(t+i,r+o/2),e.lineTo(t+i,r+a-o/2),e.ellipse(t+i/2,r+a-o/2,i/2,o/2,0,0,2*Math.PI)}drawFlowChartMagneticDrumPath(e,t,r,i,a){let o=.2*i;e.ellipse(t+o/2,r+a/2,o/2,a/2,0,0,2*Math.PI),e.moveTo(t+o/2,r),e.lineTo(t+i,r),e.moveTo(t+o/2,r+a),e.lineTo(t+i,r+a),e.moveTo(t+i,r),e.lineTo(t+i,r+a)}drawFlowChartDisplayPath(e,t,r,i,a){let o=.2*i;e.moveTo(t,r+a/2),e.lineTo(t+o,r),e.lineTo(t+i-o,r),e.arc(t+i-o,r+a/2,a/2,-Math.PI/2,Math.PI/2),e.lineTo(t+o,r+a),e.closePath()}drawRightArrowPath(e,t,r,i,a){let o=.6*a,l=r+(a-o)/2,s=t+.7*i;e.moveTo(t,l),e.lineTo(s,l),e.lineTo(s,r),e.lineTo(t+i,r+a/2),e.lineTo(s,r+a),e.lineTo(s,l+o),e.lineTo(t,l+o),e.closePath()}drawLeftArrowPath(e,t,r,i,a){let o=.6*a,l=r+(a-o)/2,s=t+.3*i;e.moveTo(t+i,l),e.lineTo(s,l),e.lineTo(s,r),e.lineTo(t,r+a/2),e.lineTo(s,r+a),e.lineTo(s,l+o),e.lineTo(t+i,l+o),e.closePath()}drawUpArrowPath(e,t,r,i,a){let o=.6*i,l=t+(i-o)/2,s=r+.3*a;e.moveTo(l,r+a),e.lineTo(l,s),e.lineTo(t,s),e.lineTo(t+i/2,r),e.lineTo(t+i,s),e.lineTo(l+o,s),e.lineTo(l+o,r+a),e.closePath()}drawDownArrowPath(e,t,r,i,a){let o=.6*i,l=t+(i-o)/2,s=r+.7*a;e.moveTo(l,r),e.lineTo(l,s),e.lineTo(t,s),e.lineTo(t+i/2,r+a),e.lineTo(t+i,s),e.lineTo(l+o,s),e.lineTo(l+o,r),e.closePath()}drawLeftRightArrowPath(e,t,r,i,a){let o=.6*a,l=r+(a-o)/2,s=t+.2*i,n=t+.8*i;e.moveTo(s,l),e.lineTo(n,l),e.lineTo(n,r),e.lineTo(t+i,r+a/2),e.lineTo(n,r+a),e.lineTo(n,l+o),e.lineTo(s,l+o),e.lineTo(s,r+a),e.lineTo(t,r+a/2),e.lineTo(s,r),e.closePath()}drawUpDownArrowPath(e,t,r,i,a){let o=.6*i,l=t+(i-o)/2,s=r+.2*a,n=r+.8*a;e.moveTo(l,s),e.lineTo(l,n),e.lineTo(t,n),e.lineTo(t+i/2,r+a),e.lineTo(t+i,n),e.lineTo(l+o,n),e.lineTo(l+o,s),e.lineTo(t+i,s),e.lineTo(t+i/2,r),e.lineTo(t,s),e.closePath()}drawQuadArrowPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=.3*Math.min(i,a);e.moveTo(o,r),e.lineTo(o+s/2,r+s),e.lineTo(o+s/4,r+s),e.lineTo(o+s/4,l-s/4),e.lineTo(o+s/4,l-s/4),e.lineTo(t+i-s,l-s/4),e.lineTo(t+i-s,l-s/2),e.lineTo(t+i,l),e.lineTo(t+i-s,l+s/2),e.lineTo(t+i-s,l+s/4),e.lineTo(o+s/4,l+s/4),e.lineTo(o+s/4,r+a-s),e.lineTo(o+s/2,r+a-s),e.lineTo(o,r+a),e.lineTo(o-s/2,r+a-s),e.lineTo(o-s/4,r+a-s),e.lineTo(o-s/4,l+s/4),e.lineTo(t+s,l+s/4),e.lineTo(t+s,l+s/2),e.lineTo(t,l),e.lineTo(t+s,l-s/2),e.lineTo(t+s,l-s/4),e.lineTo(o-s/4,l-s/4),e.lineTo(o-s/4,r+s),e.lineTo(o-s/2,r+s),e.closePath()}drawBentArrowPath(e,t,r,i,a){let o=t+.7*i,l=r+.3*a,s=.4*a;e.moveTo(t,r+a/2-s/2),e.lineTo(o,r+a/2-s/2),e.lineTo(o,l),e.lineTo(o-s/2,l),e.lineTo(t+i,r),e.lineTo(o+s/2,l),e.lineTo(o,l),e.lineTo(o,r+a/2+s/2),e.lineTo(t,r+a/2+s/2),e.closePath()}drawUturnArrowPath(e,t,r,i,a){let o=.3*i,l=t+i/2,s=.3*i;e.moveTo(t,r+a),e.lineTo(t,r+a/2),e.arc(l,r+a/2,s,Math.PI,0),e.lineTo(t+i-o,r+a/2-s),e.lineTo(t+i-o,r),e.lineTo(t+i,r+a/4),e.lineTo(t+i-2*o,r+a/4),e.lineTo(t+i-2*o,r+a/2-s),e.arc(l,r+a/2,s-o,0,Math.PI,!0),e.lineTo(t+o,r+a),e.closePath()}drawCurvedRightArrowPath(e,t,r,i,a){let o=t+.8*i,l=r+.2*a,s=.2*Math.min(i,a);e.moveTo(t,r+a/2),e.quadraticCurveTo(o,l,t+i-s,r+a/2),e.lineTo(t+i-s,r+a/2-s),e.lineTo(t+i,r+a/2),e.lineTo(t+i-s,r+a/2+s),e.lineTo(t+i-s,r+a/2+s/2),e.quadraticCurveTo(o,l+s,t,r+a/2+s/2),e.closePath()}drawCurvedLeftArrowPath(e,t,r,i,a){let o=t+.2*i,l=r+.2*a,s=.2*Math.min(i,a);e.moveTo(t+i,r+a/2),e.quadraticCurveTo(o,l,t+s,r+a/2),e.lineTo(t+s,r+a/2-s),e.lineTo(t,r+a/2),e.lineTo(t+s,r+a/2+s),e.lineTo(t+s,r+a/2+s/2),e.quadraticCurveTo(o,l+s,t+i,r+a/2+s/2),e.closePath()}drawCallout1Path(e,t,r,i,a){e.rect(t,r,.7*i,.7*a),e.moveTo(t+.6*i,r+.6*a),e.lineTo(t+.8*i,r+.8*a),e.lineTo(t+.5*i,r+.7*a)}drawCallout2Path(e,t,r,i,a){this.drawCallout1Path(e,t,r,i,a),e.moveTo(t+.65*i,r+.65*a),e.lineTo(t+.9*i,r+.9*a),e.lineTo(t+.55*i,r+.75*a)}drawCallout3Path(e,t,r,i,a){this.drawCallout2Path(e,t,r,i,a),e.moveTo(t+.7*i,r+.7*a),e.lineTo(t+.7*i,r+.95*a),e.lineTo(t+.6*i,r+.8*a)}drawAccentCallout1Path(e,t,r,i,a){e.rect(t,r,.7*i,.7*a),e.rect(t-2,r-2,.7*i+4,.7*a+4),this.drawCallout1Path(e,t,r,i,a)}drawAccentCallout2Path(e,t,r,i,a){e.rect(t,r,.7*i,.7*a),e.rect(t-2,r-2,.7*i+4,.7*a+4),this.drawCallout2Path(e,t,r,i,a)}drawAccentCallout3Path(e,t,r,i,a){e.rect(t,r,.7*i,.7*a),e.rect(t-2,r-2,.7*i+4,.7*a+4),this.drawCallout3Path(e,t,r,i,a)}drawBorderCallout1Path(e,t,r,i,a){e.rect(t,r,.7*i,.7*a),this.drawCallout1Path(e,t,r,i,a)}drawBorderCallout2Path(e,t,r,i,a){e.rect(t,r,.7*i,.7*a),this.drawCallout2Path(e,t,r,i,a)}drawBorderCallout3Path(e,t,r,i,a){e.rect(t,r,.7*i,.7*a),this.drawCallout3Path(e,t,r,i,a)}drawLightningBoltPath(e,t,r,i,a){e.moveTo(t+.3*i,r),e.lineTo(t+.7*i,r),e.lineTo(t+.4*i,r+.4*a),e.lineTo(t+.8*i,r+.4*a),e.lineTo(t+.2*i,r+a),e.lineTo(t+.5*i,r+.6*a),e.lineTo(t+.1*i,r+.6*a),e.closePath()}drawSunPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=.3*Math.min(i,a),n=.45*Math.min(i,a);for(let t=0;t<16;t++){let r=2*t*Math.PI/16,i=o+s*Math.cos(r),a=l+s*Math.sin(r),h=o+n*Math.cos(r),c=l+n*Math.sin(r);e.moveTo(i,a),e.lineTo(h,c)}e.arc(o,l,.7*s,0,2*Math.PI)}drawMoonPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.arc(o,l,s,0,2*Math.PI),e.arc(o+.3*s,l-.3*s,.8*s,0,2*Math.PI,!0)}drawCloudPath(e,t,r,i,a){e.moveTo(t,r+.5*a),e.bezierCurveTo(t,r+.7*a,t+.05*i,r+.85*a,t+.15*i,r+.8*a),e.bezierCurveTo(t+.25*i,r+.95*a,t+.35*i,r+.95*a,t+.45*i,r+.85*a),e.bezierCurveTo(t+.55*i,r+a,t+.65*i,r+a,t+.75*i,r+.85*a),e.bezierCurveTo(t+.85*i,r+.95*a,t+.95*i,r+.8*a,t+i,r+.65*a),e.bezierCurveTo(t+i,r+.5*a,t+.95*i,r+.35*a,t+.9*i,r+.3*a),e.bezierCurveTo(t+.95*i,r+.15*a,t+.85*i,r+.05*a,t+.75*i,r+.1*a),e.bezierCurveTo(t+.65*i,r,t+.55*i,r,t+.5*i,r+.08*a),e.bezierCurveTo(t+.45*i,r,t+.3*i,r,t+.25*i,r+.15*a),e.bezierCurveTo(t+.15*i,r+.05*a,t+.05*i,r+.2*a,t+.08*i,r+.3*a),e.bezierCurveTo(t,r+.35*a,t,r+.4*a,t,r+.5*a),e.closePath()}drawWavePath(e,t,r,i,a){let o=.3*a,l=r+a/2;e.moveTo(t,l),e.bezierCurveTo(t+.25*i,l-o,t+.75*i,l+o,t+i,l)}drawDoubleWavePath(e,t,r,i,a){let o=.2*a,l=r+.3*a,s=r+.7*a;e.moveTo(t,l),e.bezierCurveTo(t+.25*i,l-o,t+.75*i,l+o,t+i,l),e.moveTo(t,s),e.bezierCurveTo(t+.25*i,s-o,t+.75*i,s+o,t+i,s)}drawSmileyFacePath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.arc(o,l,s,0,2*Math.PI),e.arc(o-.3*s,l-.3*s,.1*s,0,2*Math.PI),e.arc(o+.3*s,l-.3*s,.1*s,0,2*Math.PI),e.arc(o,l,.5*s,0,Math.PI)}drawNoSmokingPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.arc(o,l,s,0,2*Math.PI),e.moveTo(o-.7*s,l-.7*s),e.lineTo(o+.7*s,l+.7*s)}drawBlockArcPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.arc(o,l,s,0,Math.PI),e.arc(o,l,.6*s,Math.PI,0,!0),e.closePath()}drawFoldedCornerPath(e,t,r,i,a){let o=.2*Math.min(i,a);e.moveTo(t,r),e.lineTo(t+i-o,r),e.lineTo(t+i,r+o),e.lineTo(t+i,r+a),e.lineTo(t,r+a),e.closePath(),e.moveTo(t+i-o,r),e.lineTo(t+i-o,r+o),e.lineTo(t+i,r+o)}drawBevelPath(e,t,r,i,a){let o=.1*Math.min(i,a);e.moveTo(t+o,r),e.lineTo(t+i-o,r),e.lineTo(t+i,r+o),e.lineTo(t+i,r+a-o),e.lineTo(t+i-o,r+a),e.lineTo(t+o,r+a),e.lineTo(t,r+a-o),e.lineTo(t,r+o),e.closePath()}drawDonutPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.arc(o,l,s,0,2*Math.PI),e.arc(o,l,.4*s,0,2*Math.PI,!0)}drawNoSymbolPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.arc(o,l,s,0,2*Math.PI),e.moveTo(o-.7*s,l+.7*s),e.lineTo(o+.7*s,l-.7*s)}drawCubePath(e,t,r,i,a){let o=.3*Math.min(i,a);e.rect(t,r+o,i-o,a-o),e.moveTo(t,r+o),e.lineTo(t+o,r),e.lineTo(t+i,r),e.lineTo(t+i-o,r+o),e.closePath(),e.moveTo(t+i-o,r+o),e.lineTo(t+i,r),e.lineTo(t+i,r+a-o),e.lineTo(t+i-o,r+a),e.closePath()}drawCanPath(e,t,r,i,a){let o=.15*a;e.ellipse(t+i/2,r+o/2,i/2,o/2,0,0,2*Math.PI),e.moveTo(t,r+o/2),e.lineTo(t,r+a-o/2),e.moveTo(t+i,r+o/2),e.lineTo(t+i,r+a-o/2),e.ellipse(t+i/2,r+a-o/2,i/2,o/2,0,0,2*Math.PI)}drawConePath(e,t,r,i,a){let o=.2*a;e.moveTo(t+i/2,r),e.lineTo(t,r+a-o),e.ellipse(t+i/2,r+a-o/2,i/2,o/2,0,Math.PI,0),e.lineTo(t+i/2,r),e.closePath()}drawPyramidPath(e,t,r,i,a){let o=.3*i;e.moveTo(t+i/2,r),e.lineTo(t,r+a),e.lineTo(t+i-o,r+a),e.closePath(),e.moveTo(t+i/2,r),e.lineTo(t+i-o,r+a),e.lineTo(t+i,r+a-o),e.closePath(),e.moveTo(t,r+a),e.lineTo(t+o,r+a-o),e.lineTo(t+i,r+a-o),e.lineTo(t+i-o,r+a)}drawPlusPath(e,t,r,i,a){let o=.2*Math.min(i,a),l=t+i/2,s=r+a/2;e.rect(t+o,s-o/2,i-2*o,o),e.rect(l-o/2,r+o,o,a-2*o)}drawMinusPath(e,t,r,i,a){let o=.2*Math.min(i,a),l=r+a/2;e.rect(t+o,l-o/2,i-2*o,o)}drawMultiplyPath(e,t,r,i,a){let o=.1*Math.min(i,a);e.moveTo(t+o,r+o),e.lineTo(t+i-o,r+a-o),e.moveTo(t+i-o,r+o),e.lineTo(t+o,r+a-o)}drawDividePath(e,t,r,i,a){let o=.1*Math.min(i,a),l=t+i/2,s=r+a/2;e.arc(l,s-.25*a,o,0,2*Math.PI),e.rect(t+o,s-o/2,i-2*o,o),e.arc(l,s+.25*a,o,0,2*Math.PI)}drawEqualPath(e,t,r,i,a){let o=.1*Math.min(i,a),l=r+a/2,s=.15*a;e.rect(t+o,l-s-o/2,i-2*o,o),e.rect(t+o,l+s-o/2,i-2*o,o)}drawNotEqualPath(e,t,r,i,a){this.drawEqualPath(e,t,r,i,a),e.moveTo(t+.3*i,r+.8*a),e.lineTo(t+.7*i,r+.2*a)}drawLinePath(e,t,r,i,a){e.moveTo(t,r),e.lineTo(t+i,r+a)}drawBentConnector2Path(e,t,r,i,a){let o=t+i/2;e.moveTo(t,r+a),e.lineTo(t,r+a/2),e.lineTo(o,r+a/2),e.lineTo(o,r),e.lineTo(t+i,r)}drawBentConnector3Path(e,t,r,i,a){let o=t+i/2,l=r+a/2;e.moveTo(t,r+a),e.lineTo(t,l),e.lineTo(o,l),e.lineTo(o,r),e.lineTo(t+i,r)}drawBentConnector4Path(e,t,r,i,a){let o=t+.33*i,l=t+.67*i,s=r+a/2;e.moveTo(t,r+a),e.lineTo(t,s),e.lineTo(o,s),e.lineTo(o,r),e.lineTo(l,r),e.lineTo(l,s),e.lineTo(t+i,s),e.lineTo(t+i,r+a)}drawBentConnector5Path(e,t,r,i,a){let o=t+.25*i,l=t+.5*i,s=t+.75*i,n=r+.33*a,h=r+.67*a;e.moveTo(t,r+a),e.lineTo(t,h),e.lineTo(o,h),e.lineTo(o,n),e.lineTo(l,n),e.lineTo(l,r),e.lineTo(s,r),e.lineTo(s,n),e.lineTo(t+i,n),e.lineTo(t+i,r+a)}drawCurvedConnector2Path(e,t,r,i,a){e.moveTo(t,r+a),e.quadraticCurveTo(t+i/2,r,t+i,r)}drawCurvedConnector3Path(e,t,r,i,a){e.moveTo(t,r+a),e.bezierCurveTo(t,r+a/2,t+i/2,r+a/2,t+i,r)}drawCurvedConnector4Path(e,t,r,i,a){e.moveTo(t,r+a),e.bezierCurveTo(t+.25*i,r+.75*a,t+.75*i,r+.25*a,t+i,r)}drawCurvedConnector5Path(e,t,r,i,a){e.moveTo(t,r+a),e.bezierCurveTo(t+.2*i,r+.8*a,t+.4*i,r+.6*a,t+.5*i,r+.5*a),e.bezierCurveTo(t+.6*i,r+.4*a,t+.8*i,r+.2*a,t+i,r)}drawCustomGeometry(e,t,r,i,a,o,l,s){try{let n,h,c=e.pathLst||e.pathList;if(!e||!c||0===c.length)return;let u=this.context;if(u.save(),e.coordSize?.width&&e.coordSize?.height)n=e.coordSize.width,h=e.coordSize.height;else{let e=1/0,t=-1/0,r=1/0,i=-1/0;c.forEach(a=>{a.commands&&a.commands.forEach(a=>{void 0!==a.x&&(e=Math.min(e,a.x),t=Math.max(t,a.x)),void 0!==a.y&&(r=Math.min(r,a.y),i=Math.max(i,a.y)),void 0!==a.x1&&(e=Math.min(e,a.x1),t=Math.max(t,a.x1),r=Math.min(r,a.y1),i=Math.max(i,a.y1)),void 0!==a.x2&&(e=Math.min(e,a.x2),t=Math.max(t,a.x2),r=Math.min(r,a.y2),i=Math.max(i,a.y2))})}),n=t-e,h=i-r,0===n&&(n=100),0===h&&(h=100)}u.restore(),c.forEach((e,c)=>{let u=1/0,d=1/0;e.commands.forEach(e=>{void 0!==e.x&&(u=Math.min(u,e.x),d=Math.min(d,e.y)),void 0!==e.x1&&(u=Math.min(u,e.x1),d=Math.min(d,e.y1)),void 0!==e.x2&&(u=Math.min(u,e.x2),d=Math.min(d,e.y2)),void 0!==e.x3&&(u=Math.min(u,e.x3),d=Math.min(d,e.y3))}),this.currentShapeBounds={x:t,y:r,w:i,h:a},this.drawGeometryPathDirectly(e,o,l,s,t,r,i,a,n,h,u,d)})}catch(e){this.context.restore()}}drawGeometryPath(e,t,r,i){if(!e||!e.commands||0===e.commands.length)return;let a=this.context;a.beginPath(),e.commands.forEach((e,t)=>{switch(e.type){case"moveTo":a.moveTo(e.x,e.y);break;case"lineTo":a.lineTo(e.x,e.y);break;case"curveTo":case"cubicBezTo":let r=void 0!==e.x?e.x:e.x3,i=void 0!==e.y?e.y:e.y3;void 0!==r&&void 0!==i&&a.bezierCurveTo(e.x1,e.y1,e.x2,e.y2,r,i);break;case"quadTo":case"quadBezTo":a.quadraticCurveTo(e.x1,e.y1,e.x,e.y);break;case"arcTo":a.arcTo(e.x1,e.y1,e.x,e.y,e.radius||0);break;case"close":a.closePath()}}),r&&i>0&&(this.setStrokeStyle(r,i),a.stroke()),t&&(!r||0===i)&&(this.setFillStyle(t),a.fill()),a.restore()}setStrokeStyle(e,t){let r=this.context;r.strokeStyle=e,r.lineWidth=CoordinateTransform.mmToPixels(t||1),r.lineCap="round",r.lineJoin="round"}setFillStyle(e){this.context.fillStyle=e}drawGeometryPathDirectly(e,t,r,i,a,o,l,s,n,h,c,u){if(!e||!e.commands||0===e.commands.length)return;let d=this.context,p=l/n,g=s/h;d.save(),d.beginPath();let f=e=>a+(e-c)*p,m=e=>o+(e-u)*g,y=!1,b=0,S=0;if(e.commands.forEach((e,t)=>{switch(e.type){case"moveTo":let r=f(e.x),i=m(e.y);d.moveTo(r,i),b=r,S=i;break;case"lineTo":let a=f(e.x),o=m(e.y);d.lineTo(a,o),b=a,S=o,y=!0;break;case"curveTo":case"cubicBezTo":let l=void 0!==e.x3?e.x3:e.x,s=void 0!==e.y3?e.y3:e.y;if(void 0!==l&&void 0!==s){let t=f(e.x1),r=m(e.y1),i=f(e.x2),a=m(e.y2),o=f(l),n=m(s);this.isStraightLine(b,S,t,r,i,a,o,n)?d.lineTo(o,n):d.bezierCurveTo(t,r,i,a,o,n),b=o,S=n,y=!0}break;case"quadTo":case"quadBezTo":{let t=f(e.x1),r=m(e.y1),i=f(e.x),a=m(e.y);d.quadraticCurveTo(t,r,i,a),b=i,S=a,y=!0;break}case"close":d.closePath()}}),e.commands.some(e=>"close"===e.type)&&t&&"none"!==t)if(y){if("object"==typeof t&&void 0!==t.r)d.fillStyle=`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a/255})`;else if("object"==typeof t&&t.type)if("linear"!==t.type||!t.stops)return;else{let e=this.getCanvasBounds(d),r=this.createCanvasGradient(d,e,t);if(r)d.fillStyle=r;else{let e=t.stops[0]?.color;if(!e)return;d.fillStyle=this.colorToRgb(e)}}else"string"==typeof t&&"none"!==t&&"null"!==t&&(d.fillStyle=t);d.fill()}else"object"==typeof t&&void 0!==t.r?d.fillStyle=`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a/255})`:"string"==typeof t&&"none"!==t&&"null"!==t&&(d.fillStyle=t),d.fillRect(a,o,l,s);if(r&&"none"!==r&&y){let e=Math.max(CoordinateTransform.mmToPixels(i>0?i:1)*Math.sqrt(l*s/921600),.5);"object"==typeof r&&void 0!==r.r?d.strokeStyle=`rgba(${r.r}, ${r.g}, ${r.b}, ${r.a/255})`:d.strokeStyle=r,d.lineWidth=e,d.lineCap="square",d.lineJoin="miter",d.stroke()}d.restore()}isStraightLine(e,t,r,i,a,o,l,s){let n=l-e,h=s-t;if(.1>Math.abs(n)&&.1>Math.abs(h))return!0;let c=Math.sqrt(Math.pow(r-(e+.33*n),2)+Math.pow(i-(t+.33*h),2)),u=Math.sqrt(Math.pow(a-(e+.67*n),2)+Math.pow(o-(t+.67*h),2));return c<2&&u<2}_s(){this._context.beginPath()}_m(e,t){this._context.moveTo(e,t)}_l(e,t){this._context.lineTo(e,t)}_c(e,t,r,i,a,o){this._context.bezierCurveTo(e,t,r,i,a,o)}_z(){this._context.closePath()}ds(){this._context.stroke()}df(){this._context.fill()}fillText(e,t,r,i={}){if(this._context&&e){this._context.save();try{let a=i.fontSize||12,o=this.getTextScaleFactor(),l=i.fontFamily||"Arial",s=i.fontWeight||(i.bold?"bold":"normal"),n=i.fontStyle||(i.italic?"italic":"normal");if(this._context.font=`${n} ${s} ${a*o}px "${l}"`,i.color)if("object"==typeof i.color&&void 0!==i.color.r){let e=void 0!==i.color.a?i.color.a/255:1,t=`rgba(${i.color.r}, ${i.color.g}, ${i.color.b}, ${e})`;this._context.fillStyle=t}else"string"==typeof i.color?this._context.fillStyle=i.color:this._context.fillStyle="#000000";else this._context.fillStyle="#000000";this._context.textBaseline=i.textBaseline||"alphabetic",this._context.textAlign=i.textAlign||"left",this._context.fillText(e,t,r)}catch(e){}finally{this._context.restore()}}}measureText(e,t={}){if(!this._context||!e)return{width:0,height:0};this._context.save();try{let r=t.fontSize||12,i=this.getTextScaleFactor(),a=r*i,o=t.fontFamily||"Arial",l=t.fontWeight||(t.bold?"bold":"normal"),s=t.fontStyle||(t.italic?"italic":"normal");this._context.font=`${s} ${l} ${a}px "${o}"`;let n=this._context.measureText(e),h=a;return void 0!==n.actualBoundingBoxAscent&&void 0!==n.actualBoundingBoxDescent&&(h=n.actualBoundingBoxAscent+n.actualBoundingBoxDescent),{width:n.width,height:h}}catch(e){return{width:0,height:0}}finally{this._context.restore()}}getCanvasBounds(e){let t,r;return e.getTransform(),e.canvas.style.width&&e.canvas.style.height?(t=parseFloat(e.canvas.style.width),r=parseFloat(e.canvas.style.height)):(t=e.canvas.width/(window.devicePixelRatio||1),r=e.canvas.height/(window.devicePixelRatio||1)),this.currentShapeBounds||{x:0,y:0,w:t,h:r}}createCanvasGradient(e,t,r){let i;if(!r||!r.stops||0===r.stops.length)return null;if("linear"===r.type){let a=(r.angle||0)*Math.PI/180,o=t.x+t.w/2-Math.cos(a)*t.w/2,l=t.y+t.h/2-Math.sin(a)*t.h/2,s=t.x+t.w/2+Math.cos(a)*t.w/2,n=t.y+t.h/2+Math.sin(a)*t.h/2;i=e.createLinearGradient(o,l,s,n)}else{if("radial"!==r.type)return null;let a=t.x+t.w/2,o=t.y+t.h/2,l=Math.max(t.w,t.h)/2;i=e.createRadialGradient(a,o,0,a,o,l)}for(let e of r.stops){let t=this.colorToRgb(e.color);i.addColorStop(e.position,t)}return i}colorToRgb(e){if(this.graphics&&"function"==typeof this.graphics.colorToRgb)return this.graphics.colorToRgb(e);if(this.graphicsEngine&&"function"==typeof this.graphicsEngine.colorToRgb)return this.graphicsEngine.colorToRgb(e);if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=void 0!==e.r?e.r:void 0!==e.R?e.R:0,r=void 0!==e.g?e.g:void 0!==e.G?e.G:0,i=void 0!==e.b?e.b:void 0!==e.B?e.B:0,a=void 0!==e.a?e.a:void 0!==e.A?e.A:255;return void 0!==a&&255!==a?`rgba(${t}, ${r}, ${i}, ${a/255})`:`rgb(${t}, ${r}, ${i})`}return"rgb(0, 0, 0)"}}class r{constructor(){this.graphics=null,this.canvas=null,this.processor=null,this.logger=new Logger("CDrawingDocument"),this.currentLayer=null}init(e,r=null){let i,a;if(this.canvas=e,this.processor=r,this.graphics)this.graphics.resetState();else{this.graphics=new t;try{let t="u">typeof globalThis&&globalThis.CGraphics?globalThis.CGraphics:"u">typeof window&&window.CGraphics?window.CGraphics:null;"function"==typeof t&&(this.graphicsEngine=new t(e),this.graphics.drawLineWithArrows=(e,t,r,i,a,o=1,l=null)=>{this.graphicsEngine.drawLineWithArrows(e,t,r,i,a,o,l)},this.graphics.applyStrokeInfo=e=>{"function"==typeof this.graphicsEngine.applyStrokeInfo&&this.graphicsEngine.applyStrokeInfo(e)})}catch(e){}}let o="function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():{width:0,height:0},l=parseFloat(e.style.width),s=parseFloat(e.style.height);if(l>0&&s>0)i=l,a=s;else if(o.width>0&&o.height>0)i=o.width,a=o.height;else if(e.style.width&&e.style.height)i=l,a=s;else{let t="u">typeof window&&window.devicePixelRatio?window.devicePixelRatio:1;i=e.width/t,a=e.height/t}let n=this.processor&&this.processor.renderContext&&this.processor.renderContext.pixelRatio||"u">typeof window&&window.devicePixelRatio||1,h=Math.max(1,Math.round(i*n)),c=Math.max(1,Math.round(a*n));(e.width!==h||e.height!==c)&&(e.width=h,e.height=c),e.style.width||(e.style.width=`${i}px`),e.style.height||(e.style.height=`${a}px`);let u=e.getContext("2d");u&&(u.setTransform(1,0,0,1,0,0),u.scale(n,n)),this.graphics&&"function"==typeof this.graphics.init&&u&&this.graphics.init(u,i,a,25.4*i/96,25.4*a/96)}colorToRgb(e){if(this.graphics&&"function"==typeof this.graphics.colorToRgb)return this.graphics.colorToRgb(e);if(this.graphicsEngine&&"function"==typeof this.graphicsEngine.colorToRgb)return this.graphicsEngine.colorToRgb(e);if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=void 0!==e.r?e.r:void 0!==e.R?e.R:0,r=void 0!==e.g?e.g:void 0!==e.G?e.G:0,i=void 0!==e.b?e.b:void 0!==e.B?e.B:0,a=void 0!==e.a?e.a:void 0!==e.A?e.A:255;return void 0!==a&&255!==a?`rgba(${t}, ${r}, ${i}, ${a/255})`:`rgb(${t}, ${r}, ${i})`}return"rgb(0, 0, 0)"}async drawSlide(e,t){this.graphics&&(this.currentSlide=e,this.currentSlideIndex=t,this.graphics.clear(),await this.drawSlideContent(e))}async drawSlideContent(e){e.layout,this.setupSlideCoordinateSystem();try{let e=this.graphics?.context,t=this.coordinateSystem;if(e&&t){let r=Math.round(t.offsetX),i=Math.round(t.offsetY),a=Math.round(t.scaledWidth),o=Math.round(t.scaledHeight);e.save(),e.beginPath(),e.rect(r,i,a,o),e.clip(),this._slideClipApplied=!0}}catch(e){this._slideClipApplied=!1}if(this.drawSlideBackground(e),!1!==e.showMasterShapes&&e.layout&&e.layout.master&&await this.drawMasterElements(e.layout.master),e.layout&&await this.drawLayoutElements(e.layout),e.commonSlideData&&e.commonSlideData.shapeTree){let t=e.commonSlideData.shapeTree,r=this.sortShapesByRenderOrder(t),i=this.currentLayer;this.currentLayer="slide";for(let e=0;e<r.length;e++){let t=r[e];!this.isHiddenShape(t)&&(!this.isPlaceholderShape(t)||this.placeholderHasContent(t))&&await this.drawShapeEnhanced(t,e)}this.currentLayer=i}try{this._slideClipApplied&&this.graphics?.context&&this.graphics.context.restore()}catch(e){}}sortShapesByRenderOrder(e){if(!e||0===e.length)return[];let t=[...e];return t.sort((t,r)=>{let i=t.order||t.zOrder||t.index||0,a=r.order||r.zOrder||r.index||0;return i!==a?i-a:e.indexOf(t)-e.indexOf(r)}),t}drawSlideBackground(e){if(!this.graphics||!this.graphics.context)return;let t=this.graphics.context,r=null;if(e.backgroundFill)r=this.getBackgroundColor(e.backgroundFill);else if(e.layout&&e.layout.commonSlideData&&e.layout.commonSlideData.backgroundFill)r=this.getBackgroundColor(e.layout.commonSlideData.backgroundFill);else if(e.layout&&e.layout.cSld&&e.layout.cSld.bg)r=this.getBackgroundColor(e.layout.cSld.bg);else if(e.layout&&e.layout.master&&e.layout.master.commonSlideData&&e.layout.master.commonSlideData.backgroundFill)r=this.getBackgroundColor(e.layout.master.commonSlideData.backgroundFill);else if(e.layout&&e.layout.master&&e.layout.master.theme){let t=e.layout.master.theme;t.colors&&t.colors.bg1?r=t.colors.bg1:t.colors&&t.colors.bg2&&(r=t.colors.bg2)}if(this.coordinateSystem){let{scale:e,offsetX:i,offsetY:a}=this.coordinateSystem,o=this.coordinateSystem.slideWidthPx,l=this.coordinateSystem.slideHeightPx,s=Math.round(o*e),n=Math.round(l*e),h=Math.round(i),c=Math.round(a);if(t.save(),r&&"image"===r.type&&r.imageData?.relationshipId){let e=r.imageData.resolvedCacheKey||r.imageData.relationshipId,i=this.processor?.imageCache?.get(e);if(i&&i.image){t.drawImage(i.image,h,c,s,n),t.restore();return}t.fillStyle="#ffffff"}else if(r&&"gradient"===r.type&&r.gradient){let e,i=r.gradient,a=i.stops||[];if("radial"===i.type){let r=h+s/2,i=c+n/2,a=Math.max(s,n)/2;e=t.createRadialGradient(r,i,0,r,i,a)}else{let r=(i.angle||0)*Math.PI/180,a=Math.cos(r),o=Math.sin(r),l=h+s/2-a*s/2,u=c+n/2-o*n/2,d=h+s/2+a*s/2,p=c+n/2+o*n/2;e=t.createLinearGradient(l,u,d,p)}for(let t of a){let r=void 0!==t.position?t.position/1e5:0,i=this.parseColorToHex(t.color)||"#ffffff";e.addColorStop(Math.min(1,Math.max(0,r)),i)}t.fillStyle=e}else t.fillStyle=("string"==typeof r?r:null)||"#ffffff";t.fillRect(h,c,s,n),t.restore()}else{if(t.save(),r&&"image"===r.type&&r.imageData?.relationshipId){let e=r.imageData.resolvedCacheKey||r.imageData.relationshipId,i=this.processor?.imageCache?.get(e);if(i&&i.image){t.drawImage(i.image,0,0,this.canvas.width,this.canvas.height),t.restore();return}t.fillStyle="#ffffff"}else if(r&&"gradient"===r.type&&r.gradient){let e,i=r.gradient,a=i.stops||[],o=this.canvas.width,l=this.canvas.height;if("radial"===i.type)e=t.createRadialGradient(o/2,l/2,0,o/2,l/2,Math.max(o,l)/2);else{let r=(i.angle||0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r);e=t.createLinearGradient(o/2-a*o/2,l/2-s*l/2,o/2+a*o/2,l/2+s*l/2)}for(let t of a){let r=void 0!==t.position?t.position/1e5:0,i=this.parseColorToHex(t.color)||"#ffffff";e.addColorStop(Math.min(1,Math.max(0,r)),i)}t.fillStyle=e}else t.fillStyle=("string"==typeof r?r:null)||"#ffffff";t.fillRect(0,0,this.canvas.width,this.canvas.height),t.restore()}}async drawMasterElements(e){if(!e||!e.commonSlideData||!e.commonSlideData.shapeTree)return;let t=e.commonSlideData.shapeTree,r=this.sortShapesByRenderOrder(t),i=this.currentLayer;this.currentLayer="master";try{for(let e=0;e<r.length;e++){let t=r[e];!this.isHiddenShape(t)&&(!this.isPlaceholderShape(t)||this.placeholderHasContent(t))&&await this.drawShapeEnhanced(t,e)}}finally{this.currentLayer=i}}async drawLayoutElements(e){if(!e||!e.commonSlideData||!e.commonSlideData.shapeTree)return;let t=e.commonSlideData.shapeTree;t.forEach((e,t)=>{});let r=this.sortShapesByRenderOrder(t),i=this.currentLayer;this.currentLayer="layout";try{for(let e=0;e<r.length;e++){let t=r[e];!this.isHiddenShape(t)&&(!this.isPlaceholderShape(t)||this.placeholderHasContent(t))&&await this.drawShapeEnhanced(t,e)}}finally{this.currentLayer=i}}isPlaceholderShape(e){return!!e.placeholder||!!e.phType||!!e.isPlaceholder||!!e.properties&&!!e.properties.placeholder||!!e.nvSpPr&&!!e.nvSpPr.nvPr&&!!e.nvSpPr.nvPr.ph}placeholderHasContent(e){return!!(e.fill&&"none"!==e.fill.type&&"noFill"!==e.fill.type||e.imageRelId||"pic"===e.type||e.chartData||e.textBody&&e.textBody.paragraphs&&e.textBody.paragraphs.some(e=>e.runs&&e.runs.some(e=>(e.text||"").trim().length>0||e.fieldType)))||!!e.graphicData&&!!e.graphicData.tableXml}processPlaceholderShape(e,t){if(!e.isPlaceholder||!e.placeholder)return e;let r=e.placeholder,i=null,a=null;return t.layout&&t.layout.commonSlideData&&t.layout.commonSlideData.shapeTree&&(a=this.findMatchingPlaceholder(t.layout.commonSlideData.shapeTree,r)),t.layout&&t.layout.master&&t.layout.master.commonSlideData&&t.layout.master.commonSlideData.shapeTree&&(i=this.findMatchingPlaceholder(t.layout.master.commonSlideData.shapeTree,r)),a?this.applyPlaceholderStyling(e,a):i&&this.applyPlaceholderStyling(e,i),e}findMatchingPlaceholder(e,t){for(let r of e)if(r.isPlaceholder&&r.placeholder){let e=r.placeholder;if(e.type===t.type&&e.idx===t.idx||e.type===t.type&&!e.idx)return r}return null}applyPlaceholderStyling(e,t){t.textBody&&(e.textBody||(e.textBody={paragraphs:[]}),t.textBody.bodyProperties&&!e.textBody.bodyProperties&&(e.textBody.bodyProperties=JSON.parse(JSON.stringify(t.textBody.bodyProperties))),t.textBody.lstStyle&&!e.textBody.lstStyle&&(e.textBody.lstStyle=JSON.parse(JSON.stringify(t.textBody.lstStyle)))),t.fill&&!e.fill&&(e.fill=t.fill),t.stroke&&!e.stroke&&(e.stroke=t.stroke),t.geometry&&!e.geometry&&(e.geometry=t.geometry),t.style&&!e.style&&(e.style=t.style)}shouldRenderText(e){try{if(this.currentLayer&&"slide"!==this.currentLayer&&this.isPlaceholderShape(e))return!1;if(this.isPlaceholderShape(e))return!!(e.textBody&&Array.isArray(e.textBody.paragraphs)&&e.textBody.paragraphs.some(e=>Array.isArray(e.runs)&&e.runs.some(e=>(e.text||"").trim().length>0)))}catch(e){}return!0}getBackgroundColor(e){if(!e){let e=this.resolveInheritedBackgroundColor();return e||null}if("solid"===e.type&&e.color)return this.parseColorToHex(e.color);if(e.fill&&"solid"===e.fill.type&&e.fill.color)return this.parseColorToHex(e.fill.color);if("bgPr"===e.type&&e.fill){if("solid"===e.fill.type&&e.fill.color)return this.parseColorToHex(e.fill.color);if("gradient"===e.fill.type&&e.fill.gradient&&e.fill.gradient.stops&&e.fill.gradient.stops.length>0)return{type:"gradient",gradient:e.fill.gradient};if("image"===e.fill.type&&e.fill.imageData?.relationshipId)return{type:"image",imageData:e.fill.imageData}}if("bgRef"===e.type){let t=e.idx;if(void 0!==t)if(t>1e3){if(this.currentSlide&&this.currentSlide.theme&&this.currentSlide.theme.colors){let e=this.currentSlide.theme;return this.parseColorToHex(e.colors.bg2)||this.parseColorToHex(e.colors.bg1)||this.parseColorToHex(e.colors.lt1)}}else{let e={0:"bg1",1:"tx1",2:"bg2",3:"tx2"}[t.toString()];if(e&&this.currentSlide&&this.currentSlide.theme&&this.currentSlide.theme.colors)return this.parseColorToHex(this.currentSlide.theme.colors[e])}}return null}resolveInheritedBackgroundColor(){try{if(!this.currentSlide)return null;if(this.currentSlide.layout&&this.currentSlide.layout.backgroundFill){let e=this.getBackgroundColorFromFill(this.currentSlide.layout.backgroundFill);if(e)return e}if(this.currentSlide.layout&&this.currentSlide.layout.master&&this.currentSlide.layout.master.backgroundFill){let e=this.getBackgroundColorFromFill(this.currentSlide.layout.master.backgroundFill);if(e)return e}if(this.currentSlide.theme&&this.currentSlide.theme.colors){let e=this.parseColorToHex(this.currentSlide.theme.colors.bg1)||this.parseColorToHex(this.currentSlide.theme.colors.lt1)||this.parseColorToHex(this.currentSlide.theme.colors.bg2);if(e)return e}return null}catch(e){return null}}getBackgroundColorFromFill(e){if(!e)return null;if("solid"===e.type&&e.color)return this.parseColorToHex(e.color);if(e.fill&&"solid"===e.fill.type&&e.fill.color||"bgPr"===e.type&&e.fill&&"solid"===e.fill.type&&e.fill.color)return this.parseColorToHex(e.fill.color);if("bgRef"===e.type){let t=e.idx;if(void 0!==t)return({0:"#ffffff",1:"#000000",2:"#f5f5f5",3:"#404040",1e3:"#ffffff"})[t.toString()]||null}return null}parseColorToHex(e){if(!e)return"#ffffff";if("string"==typeof e)return e.startsWith("#")?e:`#${e}`;if(e.scheme){let t={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"}[e.scheme];if(t)return this.applyColorModifications(t,e)}return void 0!==e.r&&void 0!==e.g&&void 0!==e.b?void 0!==e.a&&e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a/255).toFixed(4)})`:`#${e.r.toString(16).padStart(2,"0")}${e.g.toString(16).padStart(2,"0")}${e.b.toString(16).padStart(2,"0")}`:"#ffffff"}applyColorModificationsLegacy(e,t){if(!t||!t.tint&&!t.shade&&!t.lumMod&&!t.lumOff)return e;let r=parseInt(e.substr(1,2),16),i=parseInt(e.substr(3,2),16),a=parseInt(e.substr(5,2),16),o=r,l=i,s=a;if(void 0!==t.tint){let e=t.tint/1e5;o=Math.round(r+(255-r)*e),l=Math.round(i+(255-i)*e),s=Math.round(a+(255-a)*e)}if(void 0!==t.shade){let e=t.shade/1e5;o=Math.round(r*(1-e)),l=Math.round(i*(1-e)),s=Math.round(a*(1-e))}if(void 0!==t.lumMod){let e=t.lumMod/1e5;o=Math.round(r*e),l=Math.round(i*e),s=Math.round(a*e)}if(void 0!==t.lumOff){let e=t.lumOff/1e5*255;o=Math.round(Math.min(255,r+e)),l=Math.round(Math.min(255,i+e)),s=Math.round(Math.min(255,a+e))}return o=Math.max(0,Math.min(255,o)),l=Math.max(0,Math.min(255,l)),s=Math.max(0,Math.min(255,s)),`#${o.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}setupSlideCoordinateSystem(){if(this.processor&&this.processor.calculateCanvasRect){let e=this.processor.getSlideDimensions(),t=this.processor.calculateCanvasRect(this.canvas,e);this.coordinateSystem={slideWidthEMU:e.cx,slideHeightEMU:e.cy,slideWidthPx:t.slideWidthPx,slideHeightPx:t.slideHeightPx,scale:t.scale,offsetX:t.offsetX,offsetY:t.offsetY,scaledWidth:t.scaledWidth,scaledHeight:t.scaledHeight}}else{let e,t,r=this.processor.getSlideDimensions(),i=r.cx,a=r.cy,o=i/914400*96,l=a/914400*96,s="function"==typeof this.canvas.getBoundingClientRect?this.canvas.getBoundingClientRect():{width:0,height:0};if(s.width>0&&s.height>0)e=s.width,t=s.height;else if(this.canvas.style.width&&this.canvas.style.height)e=parseFloat(this.canvas.style.width),t=parseFloat(this.canvas.style.height);else{let r="u">typeof window&&window.devicePixelRatio?window.devicePixelRatio:1;e=this.canvas.width/r,t=this.canvas.height/r}let n=Math.min(e/o,t/l),h=o*n,c=l*n,u=(e-h)/2,d=(t-c)/2;h=Math.round(h),c=Math.round(c),u=Math.round(u),d=Math.round(d),this.coordinateSystem={slideWidthEMU:i,slideHeightEMU:a,slideWidthPx:o,slideHeightPx:l,scale:n,offsetX:u,offsetY:d,scaledWidth:h,scaledHeight:c,canvasWidth:e,canvasHeight:t}}}async drawShapeEnhanced(e,t){try{this.processor&&"function"==typeof this.processor.applyPropertyInheritance&&this.processor.applyPropertyInheritance(e,this.currentSlide)}catch(e){}let r=this.getShapeBounds(e);if(r&&(0===r.h||!isFinite(r.h)||r.h<1)&&e&&e.textBody&&e.textBody.paragraphs&&e.textBody.paragraphs.length>0&&!this.isLineLikeShape(e))try{let t=this.estimateTextBoxHeightPx(e,r.w);t&&t>0&&(r.h=Math.ceil(t))}catch(e){}if(this.graphics&&e)try{let t=this.isLineLikeShape(e);if(!r||r.w<=0&&r.h<=0||!t&&(r.w<=0||r.h<=0))return;switch(e.type){case"sp":this.drawRegularShape(e,r);break;case"pic":this.drawPictureShape(e,r);break;case"grpSp":this.drawGroupShape(e,r);break;case"cxnSp":this.drawConnectorShape(e,r);break;case"graphicFrame":await this.drawGraphicFrame(e,r);break;default:this.drawDefaultShape(e,r)}}catch(e){}}drawShapeGeometry(e,t){if(!t||t.w<=0||t.h<=0)return;let r=this.getShapeFillColor(e),i=this.getShapeStrokeColor(e),a=this.getShapeLineWidth(e);if(r){let e=this.parseColor(r);this.graphics.b_color1(e.r,e.g,e.b,e.a)}if(i){let e=this.parseColor(i);this.graphics.p_color(e.r,e.g,e.b,e.a),this.graphics.p_width(a)}switch(e.type){case"sp":case"shape":this.drawRegularShape(e,t);break;case"pic":this.drawPictureShape(e,t);break;case"grpSp":this.drawGroupShape(e,t);break;default:this.drawDefaultShape(e,t)}}drawRegularShape(e,t){if(!t)return;if(this.isLineLikeShape(e)){if(t.w<=0&&t.h<=0)return}else if(t.w<=0||t.h<=0)return;if(!this.graphics||!this.graphics.context)return;let r=this.graphics.context;r.save();let i=e.properties?.transform;if(i&&i.rotation&&0!==i.rotation){let e=t.x+t.w/2,a=t.y+t.h/2;r.translate(e,a),r.rotate(i.rotation*Math.PI/180),r.translate(-e,-a)}let a=this.getShapeFillColor(e),o=this.getShapeStrokeColor(e),l=this.getShapeLineWidth(e),s=this.getShapeStrokeInfo(e);e.properties&&e.properties.effectLst&&this.applyEffectsToCanvas(r,e.properties.effectLst);let n=null;if("line"===(n=this.processor&&this.processor.getShapePresetGeometry?this.processor.getShapePresetGeometry(e,this.processor.currentSlide):this.getShapePreset(e))||this.isLineLikeShape(e)){if(this.drawEngineLine(t,e),this.resetEffectsOnContext(r),e.textBody&&e.textBody.paragraphs&&this.shouldRenderText(e)){let r=this.estimateTextBoxHeightPx(e,t.w)||24,i=e.textBody.paragraphs[0],a=i?.properties?.align||i?.properties?.alignment||i?.paragraphProperties?.align||i?.pPr?.algn||"l",o={x:"r"===a||"right"===a?t.x-t.w:"ctr"===a||"center"===a?t.x-t.w/2:t.x,y:t.y-r/2,w:t.w,h:r};this.setCurrentRenderingShape(e),this.drawShapeText(e,o)}r.restore();return}let h=i&&(i.flipH||i.flipV);if(h){r.save();let e=t.x+t.w/2,a=t.y+t.h/2;r.translate(e,a),r.scale(i.flipH?-1:1,i.flipV?-1:1),r.translate(-e,-a)}if(e.geometry&&"custom"===e.geometry.type)try{this.currentShapeBounds=t,e.properties&&e.properties.effectLst&&this.applyEffectsToCanvas(r,e.properties.effectLst),this.graphics.drawCustomGeometry(e.geometry,t.x,t.y,t.w,t.h,a,o,l),this.resetEffectsOnContext(r)}catch(e){this.graphics.drawPresetGeometry("rect",t.x,t.y,t.w,t.h,a,o,l,s)}else if(this.graphics.drawPresetGeometry&&n){e.properties&&e.properties.effectLst&&this.applyEffectsToCanvas(r,e.properties.effectLst);let i=e.geometry?.adjustments||e.properties?.geometry?.adjustments||{};this.graphics.drawPresetGeometry(n,t.x,t.y,t.w,t.h,a,o,l,s,i),this.resetEffectsOnContext(r)}else{let e=o&&l>2||o&&!a;o&&e&&(r.strokeStyle=this.graphics.colorToRgb(o),r.lineWidth=CoordinateTransform.mmToPixels(l),s&&this.applyStrokeStyle(r,s,CoordinateTransform.mmToPixels(l)),r.strokeRect(t.x,t.y,t.w,t.h)),!e&&(a&&"linear"===a.type?this.drawGradientFill(r,t,a):a&&(r.fillStyle=this.graphics.colorToRgb(a),r.fillRect(t.x,t.y,t.w,t.h)),o&&(r.strokeStyle=this.graphics.colorToRgb(o),r.lineWidth=CoordinateTransform.mmToPixels(l),s&&this.applyStrokeStyle(r,s,CoordinateTransform.mmToPixels(l)),r.strokeRect(t.x,t.y,t.w,t.h)))}h&&r.restore(),e.textBody&&e.textBody.paragraphs&&this.shouldRenderText(e)&&(this.setCurrentRenderingShape(e),this.drawShapeText(e,t)),this.resetEffectsOnContext(r),r.restore()}isLineLikeShape(e){let t=e&&(e.geometry?.preset||e.properties?.geometry?.preset||this.getShapePreset(e))||null,r="string"==typeof t?t.toLowerCase():"";return!!("line"===r||r.includes("connector"))||!!e&&("cxnSp"===e.type||"connector"===e.type)}drawEngineLine(e,t){let r=this.getShapeStrokeColor(t),i=this.getShapeLineWidth(t)||1,a=this.getShapeStrokeInfo(t),{x1:o,y1:l,x2:s,y2:n}=this._computeConnectorEndpoints(e,t);if(this.graphics&&"function"==typeof this.graphics.drawLineWithArrows){let e=r||{r:0,g:0,b:0,a:255},t=i&&i>0?i:.75;this.graphics.drawLineWithArrows(o,l,s,n,e,t,a)}else if(this.graphicsEngine&&"function"==typeof this.graphicsEngine.drawLineWithArrows){let e=r||{r:0,g:0,b:0,a:255},t=i&&i>0?i:.75;this.graphicsEngine.drawLineWithArrows(o,l,s,n,e,t,a)}else if(this.graphics&&"function"==typeof this.graphics.drawLine){let e=r||{r:0,g:0,b:0,a:255},t=i&&i>0?i:.75;this.graphics.drawLine(o,l,s,n,e,t)}else if(this.graphics&&this.graphics.context){let e=this.graphics.context;if(e.save(),e.beginPath(),e.moveTo(o,l),e.lineTo(s,n),r){e.strokeStyle=this.graphics.colorToRgb(r),e.lineWidth=Math.max(this.graphics&&this.graphics.CoordinateTransform?this.graphics.CoordinateTransform.mmToPixels(i):CoordinateTransform.mmToPixels(i),1);try{this.applyStrokeStyle(e,a,e.lineWidth)}catch(e){}e.stroke()}e.restore()}}_computeConnectorEndpoints(e,t){let r,i,a,o,l=Math.max(0,e.w),s=Math.max(0,e.h),n=e.x+l/2,h=e.y+s/2,c=t&&(t.geometry||t.properties?.geometry)||null,u=c&&(c.pathList||c.pathLst);if(Array.isArray(u)&&u.length>0){let t=u[0],n=t.commands||[],h=null,d=null;for(let e=0;e<n.length;e++){let t=n[e];h||"moveTo"!==t.type||(h={x:t.x,y:t.y}),"lineTo"===t.type?d={x:t.x,y:t.y}:"cubicBezTo"===t.type?d={x:t.x3,y:t.y3}:"moveTo"===t.type&&!d&&h&&(d={x:t.x,y:t.y})}if(!h&&n.length>0){let e=n[0];null!=e.x&&null!=e.y&&(h={x:e.x,y:e.y})}if(!d&&h&&(d={...h}),h&&d){let n=t.w||c.pathW||100,u=t.h||c.pathH||100,p=0===n?1:l/n,g=0===u?1:s/u;r=e.x+h.x*p,i=e.y+h.y*g,a=e.x+d.x*p,o=e.y+d.y*g}}if(void 0===r){r=e.x,i=e.y,a=e.x+l,o=e.y+s;let n=t&&(t.spPr?.xfrm||t.transform);0===(n&&(void 0!==n.cy?n.cy:n.height))&&(o=i=e.y+s/2)}let d=!!(t&&t.transform&&t.transform.flipH),p=!!(t&&t.transform&&t.transform.flipV);d&&(r=n-(r-n),a=n-(a-n)),p&&(i=h-(i-h),o=h-(o-h));let g=t&&t.transform&&(t.transform.rot||t.transform.rotation)||0;if(g){let e=g*Math.PI/180,t=Math.cos(e),l=Math.sin(e),s=(e,r)=>({x:n+(e-n)*t-(r-h)*l,y:h+(e-n)*l+(r-h)*t}),c=s(r,i),u=s(a,o);r=c.x,i=c.y,a=u.x,o=u.y}return{x1:r,y1:i,x2:a,y2:o}}drawLinePath(e,t,r,i,a){if(this.graphics&&"function"==typeof this.graphics.drawLineWithArrows){let e=this.getShapeStrokeColor(this.getCurrentShape()),o=this.getShapeLineWidth(this.getCurrentShape())||1,l=this.getShapeStrokeInfo(this.getCurrentShape()),s=t+i;this.graphics.drawLineWithArrows(t,r,s,r+a,e,o,l);return}e.moveTo(t,r+a/2),e.lineTo(t+i,r+a/2)}drawLineWithArrows(e,t,r,i,a,o=1,l=null){let s=this._context;if(!s)return;s.save(),s.beginPath(),s.moveTo(e,t),s.lineTo(r,i);let n=this.colorToRgb(a)||"rgba(0,0,0,1)",h=Math.max(CoordinateTransform.mmToPixels(o||1),1);if(s.strokeStyle=n,s.lineWidth=h,l)try{this.applyStrokeStyle(s,l,h)}catch(e){}s.stroke();let c=e=>{if("number"==typeof e)return e;let t=(e||"").toString();return"lg"===t||"large"===t?2:"med"===t||"medium"===t?1.5:1},u=l&&l.tailEnd,d=l&&l.headEnd;if(u||d){let a=Math.atan2(i-t,r-e),o=s.getTransform(),l=Math.sqrt(o.a*o.a+o.b*o.b),p=Math.max(Math.max(4,10*l),8*h),g=Math.max(Math.max(2.5,6*l),3*h),f=(e,t,r,i)=>{if(!i)return;let a=p*(i.lengthScale||c(i.len)),o=g*(i.widthScale||c(i.w)),l=(i.type||i.val||"arrow").toString(),u=o/2;s.save(),s.translate(e,t),s.rotate(r),s.beginPath(),"open"===l?(s.moveTo(0,0),s.lineTo(-a,-u),s.moveTo(0,0),s.lineTo(-a,u),s.strokeStyle=n,s.lineWidth=Math.max(1,h)):("stealth"===l?(s.moveTo(0,0),s.lineTo(-a,-(.6*u)),s.lineTo(-a,.6*u),s.closePath()):"diamond"===l?(s.moveTo(0,0),s.lineTo(-a/2,-u),s.lineTo(-a,0),s.lineTo(-a/2,u),s.closePath()):"oval"===l?s.ellipse(-a/2,0,a/2,u,0,0,2*Math.PI):(s.moveTo(0,0),s.lineTo(-a,-u),s.lineTo(-a,u),s.closePath()),s.fillStyle=n,s.fill(),s.strokeStyle=n,s.lineWidth=Math.max(1,.5*h)),s.stroke(),s.restore()};hasStart&&f(e,t,a+Math.PI,u),hasEnd&&f(r,i,a,d)}s.restore()}drawGradientFill(e,t,r){let i;if(r&&r.stops&&0!==r.stops.length){if("linear"===r.type){let a=(r.angle||0)*Math.PI/180,o=t.x+t.w/2-Math.cos(a)*t.w/2,l=t.y+t.h/2-Math.sin(a)*t.h/2,s=t.x+t.w/2+Math.cos(a)*t.w/2,n=t.y+t.h/2+Math.sin(a)*t.h/2;i=e.createLinearGradient(o,l,s,n)}else{let r=t.x+t.w/2,a=t.y+t.h/2,o=Math.max(t.w,t.h)/2;i=e.createRadialGradient(r,a,0,r,a,o)}for(let e of r.stops)i.addColorStop(e.position,this.graphics.colorToRgb(e.color));e.fillStyle=i,e.fillRect(t.x,t.y,t.w,t.h)}}applyStrokeStyle(e,t,r){if(e&&t){if(t.cap)switch(t.cap){case"rnd":e.lineCap="round";break;case"sq":e.lineCap="square";break;default:e.lineCap="butt"}if(t.join)switch(t.join){case"round":e.lineJoin="round";break;case"bevel":e.lineJoin="bevel";break;default:e.lineJoin="miter"}if(t.dashArray&&t.dashArray.length>0){let i=t.dashArray.map(e=>e*r);e.setLineDash(i)}else e.setLineDash([])}}getShapePreset(e){return e.geometry&&e.geometry.preset?e.geometry.preset:e.properties&&e.properties.geometry&&e.properties.geometry.preset?e.properties.geometry.preset:e.spPr&&e.spPr.geometry&&e.spPr.geometry.preset?e.spPr.geometry.preset:e.spPr&&e.spPr.prstGeom&&e.spPr.prstGeom.prst?e.spPr.prstGeom.prst:this.isPlaceholderShape(e)||"sp"===e.type||"shape"===e.type?"rect":null}drawPictureShape(e,t){if(!t||t.w<=0||t.h<=0||!this.graphics||!this.graphics.context)return;let r=this.graphics.context;r.save();let i=e.properties?.transform;if(i&&i.rotation&&0!==i.rotation){let e=t.x+t.w/2,a=t.y+t.h/2;r.translate(e,a),r.rotate(i.rotation*Math.PI/180),r.translate(-e,-a)}let a=this.getShapePreset(e);if(a&&"rect"!==a&&"ellipse"===a&&(r.beginPath(),r.ellipse(t.x+t.w/2,t.y+t.h/2,t.w/2,t.h/2,0,0,2*Math.PI),r.clip()),e.imageRelId&&this.processor&&this.processor.imageCache){let i=this.processor.imageCache.get(e.imageRelId);if(i&&"svg"===i.type&&this.processor.svgRenderer)try{this.processor.svgRenderer.renderSVG(i.content,t.x,t.y,t.w,t.h,{preserveAspectRatio:!0}).then(()=>{}).catch(()=>{}),r.restore();return}catch(e){}if(i&&i.image)try{let a=i.image,{width:o,height:l}=i,s=t.x,n=t.y,h=t.w,c=t.h;if("stretch"===e.imageFillMode){if(e.imageSrcRect){let i=e.imageSrcRect,a=1e5-i.l-i.r,o=1e5-i.t-i.b;a>0&&o>0&&(s=t.x+-(t.w*i.l)/a,n=t.y+-(t.h*i.t)/o,h=1e5*t.w/a,c=1e5*t.h/o,r.beginPath(),r.rect(t.x,t.y,t.w,t.h),r.clip())}else if(e.imageFillRect){let r=e.imageFillRect;s=t.x+t.w*r.l/1e5,n=t.y+t.h*r.t/1e5,h=t.w*(1e5-r.l-r.r)/1e5,c=t.h*(1e5-r.t-r.b)/1e5}}else if("tile"===e.imageFillMode)s=t.x,n=t.y,h=t.w,c=t.h;else{let e=o/l,r=t.w/t.h;e>r?(h=t.w,c=t.w/e,s=t.x,n=t.y+(t.h-c)/2):(c=t.h,h=t.h*e,s=t.x+(t.w-h)/2,n=t.y)}r.drawImage(a,s,n,h,c),r.restore();return}catch(e){}}r.restore(),e.textBody&&e.textBody.paragraphs&&this.shouldRenderText(e)&&(this.setCurrentRenderingShape(e),this.drawShapeText(e,t))}drawImagePlaceholder(e,t,r,i,a,o="IMAGE"){let l=this.m_oContext;l&&(l.save(),l.fillStyle="#f8f9fa",l.fillRect(t,r,i,a),l.strokeStyle="#dee2e6",l.lineWidth=1,l.strokeRect(t,r,i,a),l.restore())}drawGroupShape(e,t){if(t&&!(t.w<=0)&&!(t.h<=0)&&this.graphics&&this.graphics.context){this.graphics.SaveGrState();try{if(e.transform){let r=this.graphics.context;if(e.transform.rotation&&0!==e.transform.rotation){let i=t.x+t.w/2,a=t.y+t.h/2;r.save(),r.translate(i,a),r.rotate(e.transform.rotation*Math.PI/180),r.translate(-i,-a)}if(e.transform.flipH||e.transform.flipV){let i=e.transform.flipH?-1:1,a=e.transform.flipV?-1:1,o=t.x+t.w/2,l=t.y+t.h/2;r.save(),r.translate(o,l),r.scale(i,a),r.translate(-o,-l)}}if(e.shapeTree&&e.shapeTree.length>0){let t=this.sortShapesByRenderOrder(e.shapeTree);for(let e=0;e<t.length;e++){let r=t[e];try{let e=this.getShapeBounds(r);e&&e.w>0&&e.h>0&&this.drawShapeGeometry(r,e)}catch(e){}}}}catch(e){}finally{this.graphics.RestoreGrState()}}}calculateChildShapeBounds(e,t){if(!e.bounds)return{x:t.x,y:t.y,w:50,h:50};let r=e.bounds,i=this.processor?this.processor.getSlideDimensions():{cx:9144e3,cy:6858e3},a=this.processor?this.processor.calculateCanvasRect(this.canvas,i):{scale:1,offsetX:0,offsetY:0,slideWidthPx:this.canvas.width,slideHeightPx:this.canvas.height},o=a.slideWidthPx,l=a.slideHeightPx,s={x:(r.l||0)/i.cx*o,y:(r.t||0)/i.cy*l,w:((r.r||0)-(r.l||0))/i.cx*o,h:((r.b||0)-(r.t||0))/i.cy*l},n=a.offsetX+s.x*a.scale,h=a.offsetY+s.y*a.scale;return{x:n,y:h,w:s.w*a.scale,h:s.h*a.scale}}drawDefaultShape(e,t){if(!t||t.w<=0||t.h<=0||!this.graphics||!this.graphics.context)return;let r=this.graphics.context;r.save();let i=e.properties?.transform;if(i&&i.rotation&&0!==i.rotation){let e=t.x+t.w/2,a=t.y+t.h/2;r.translate(e,a),r.rotate(i.rotation*Math.PI/180),r.translate(-e,-a)}r.fillStyle="#e0e0e0",r.fillRect(t.x,t.y,t.w,t.h),r.strokeStyle="#999",r.lineWidth=1,r.strokeRect(t.x,t.y,t.w,t.h),r.restore(),e.textBody&&e.textBody.paragraphs&&(this.setCurrentRenderingShape(e),this.drawShapeText(e,t))}drawConnectorShape(e,t){!t||t.w<=0&&t.h<=0||this.drawEngineLine(t,e)}async drawGraphicFrame(e,t){e.graphicData,!t||t.w<=0||t.h<=0||(e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===e.graphicData.uri?this.drawTable(e,t):e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/chart"===e.graphicData.uri?await this.drawChart(e,t):this.drawDefaultShape(e,t))}drawTable(e,t){if(e.graphicData&&e.graphicData.tableXml)try{this.tableProcessor||(this.tableProcessor=new TableProcessor);let r=this.tableProcessor.parseTableFromXML(e.graphicData.tableXml);if(r){let e=t.x,i=t.y,a=t.w,o=t.h;try{let e="function"==typeof r.getTableProperties?r.getTableProperties()||{}:r.tableProperties||{};e&&e.layout&&String(e.layout).toLowerCase();let i=this.coordinateSystem&&"number"==typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1,l=0,s="function"==typeof r.getTableGrid?r.getTableGrid():r.tableGrid||[];Array.isArray(s)&&s.length>0&&(l=s.reduce((e,t)=>e+(parseInt(t.width)||0),0)/914400*96*i);let n=0,h=r.rows||[];if(h.length>0&&h.some(e=>e&&e.height)&&(n=h.reduce((e,t)=>e+(parseInt(t&&t.height)||0),0)/914400*96*i),!l&&e&&e.preferredWidth){let r=e.preferredWidth;if("pct"===r.type){let e=(parseInt(r.value)||0)/5e3;l=Math.max(0,t.w*e)}else"dxa"===r.type&&(l=(parseInt(r.value)||0)/1440*96*i)}let c=l>0?l/t.w:0;(l>t.w||c<.9)&&(a=l),n>0&&(o=n)}catch(e){}let l=this.canvas.getContext("2d"),s=null;try{(s=this.computeTableLayout(r,a,o,l))&&"number"==typeof s.height&&s.height>0&&(o=s.height)}catch(e){s=null}if(l.save(),l.rect(e,i,a,o),l.clip(),!this.graphics.context)return;this.drawTableDirect(r,l,e,i,a,o,s),l.restore()}else this.drawTablePlaceholder(t,"Parse Failed"),tableCtx.restore()}catch(e){this.drawTablePlaceholder(t,"Error"),tableCtx.restore()}else this.drawTablePlaceholder(t,"No Data")}computeTableLayout(e,t,r,i){let a,o={cellWidths:[],cellHeights:[],height:r};if(!e)return o;let l="function"==typeof e.getRowCount?e.getRowCount():e.rows?e.rows.length:0,s="function"==typeof e.getColumnCount?e.getColumnCount():0;if(l<=0)return o;let n=this.coordinateSystem&&"number"==typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1;try{let r="function"==typeof e.getTableGrid?e.getTableGrid():e.tableGrid||[];if(Array.isArray(r)&&r.length>0){let e=(a=r.map(e=>(parseInt(e.width,10)||0)/914400*96*n)).reduce((e,t)=>e+t,0);if(e>0&&isFinite(t)&&t>0&&Math.abs(e-t)>1){let r=t/e;a=a.map(e=>e*r)}let i=Math.max(s,a.length);if(a.length<i&&i>0){let e=i-a.length,r=a.reduce((e,t)=>e+t,0),o=e>0?(t-r)/e:0;for(let t=0;t<e;t++)a.push(o)}}}catch(e){a=void 0}let h=Math.max(s,Array.isArray(a)?a.length:0);if(!Array.isArray(a)||0===a.length){let e=t/Math.max(h||1,1);a=Array.from({length:Math.max(h,1)},()=>e)}let c=Array(l),u=Array(l).fill(!1),d=isFinite(r)&&r>0?r/Math.max(l,1):0;for(let t=0;t<l;t++){let r=e.rows?e.rows[t]:null,i=null;if(r&&void 0!==r.height&&null!==r.height){let e=parseInt(r.height,10);!Number.isNaN(e)&&e>0&&(i=e/914400*96*n)}i&&i>0?c[t]=i:(c[t]=0,u[t]=!0)}let p=(e,t,r)=>{let i=0;for(let a=0;a<r;a++)i+=e[t+a]||0;return i};if(i&&"function"==typeof i.measureText){let t=Array(l).fill(0);"function"==typeof i.save&&i.save();try{i.textBaseline="top";for(let r=0;r<l;r++){let o=e.rows?e.rows[r]:null;if(!o||!Array.isArray(o.cells))continue;let s=0;for(let e=0;e<o.cells.length;e++){let n=o.cells[e],h=Math.max(1,n?.gridSpan||1),u=Math.max(1,n?.rowSpan||1);if(n&&n.isMergedContinue){"continue"===n.vMerge&&(s+=1);continue}let d=p(a,s,h),g=this.getCellMarginsPx(n),f=Math.max(0,d-g.left-g.right);if(f<=0){s+=h;continue}let m=this.computeCellTextLayout(i,n,f,1/0,{contentX:0}).totalHeight+g.top+g.bottom;if(m<=0){s+=h;continue}let y=p(c,r,u);if(m>y){let e=m-y;if(1===u)t[r]=Math.max(t[r],e);else{let i=e/u;for(let e=0;e<u;e++){let a=r+e;if(a>=l)break;t[a]=Math.max(t[a],i)}}}s+=h}}}finally{"function"==typeof i.restore&&i.restore()}for(let e=0;e<l;e++)t[e]>0&&(c[e]+=t[e])}for(let e=0;e<l;e++)(void 0===c[e]||c[e]<=0)&&u[e]&&(c[e]=d||0),c[e]<=0&&(c[e]=0);let g=c.reduce((e,t)=>e+(t||0),0);return o.cellWidths=a,o.cellHeights=c,g>0?o.height=g:isFinite(r)&&r>0?o.height=r:o.height=0,o}drawTableDirect(e,t,r,i,a,o,l=null){if(!e||!t)return;t.save();let s="function"==typeof e.getRowCount?e.getRowCount():e.rows?e.rows.length:0,n="function"==typeof e.getColumnCount?e.getColumnCount():0;if(0===s||0===n&&!(e.rows&&e.rows[0]&&e.rows[0].cells))return void t.restore();let h=l;h||(h=this.computeTableLayout(e,a,o,t));let c=Array.isArray(h?.cellWidths)?h.cellWidths.slice():null,u=c&&c.length>0?c.length:Math.max(n,1);c&&0!==c.length||(c=Array.from({length:u},()=>a/Math.max(u,1)));let d=Array.isArray(h?.cellHeights)?h.cellHeights.slice():null;d&&0!==d.length||(d=Array.from({length:s},()=>o/Math.max(s,1))),h&&"number"==typeof h.height&&h.height>0&&(o=h.height);let p=(e,t,r)=>{let i=0;for(let a=0;a<r;a++)i+=e[t+a]||0;return i},g=(e,t)=>{let r=0;for(let i=0;i<t;i++)r+=e[i]||0;return r},f=null;try{let t="function"==typeof e.getTableProperties?e.getTableProperties():e.tableProperties||{};f=t&&t.borders?t.borders:null}catch(e){f=null}let m=i,y=[];for(let i=0;i<s;i++){let a=d[i],o=e.rows[i];if(!o)continue;let l=0;for(let a=0;a<o.cells.length;a++){let s=o.cells[a],n=Math.max(1,s?.gridSpan||1),h=Math.max(1,s?.rowSpan||1);if(s&&s.isMergedContinue){"continue"===s.vMerge&&(l+=1);continue}let u=r+g(c,l),f=m,y=p(c,l,n),b=p(d,i,h),S=this.extractCellStyle(s,i,e);S.backgroundColor&&(t.fillStyle=S.backgroundColor,t.fillRect(u,f,y,b)),this.drawCellBordersFromPPTX(t,s,u,f,y,b),s&&s.textBody&&this.drawCellText(t,s,u,f,y,b,S),l+=n}m+=a,y.push(m)}let b=this.coordinateSystem&&"number"==typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1,S=e=>Math.max(1,Math.round((e.width||1)*b));if(f){if(f.top&&f.top.color){let e=f.top;t.strokeStyle=`rgb(${e.color.r}, ${e.color.g}, ${e.color.b})`,t.lineWidth=S(e),t.beginPath(),t.moveTo(r,i),t.lineTo(r+a,i),t.stroke()}if(f.left&&f.left.color){let e=f.left;t.strokeStyle=`rgb(${e.color.r}, ${e.color.g}, ${e.color.b})`,t.lineWidth=S(e),t.beginPath(),t.moveTo(r,i),t.lineTo(r,i+o),t.stroke()}if(f.right&&f.right.color){let e=f.right;t.strokeStyle=`rgb(${e.color.r}, ${e.color.g}, ${e.color.b})`,t.lineWidth=S(e),t.beginPath(),t.moveTo(r+a,i),t.lineTo(r+a,i+o),t.stroke()}if(f.bottom&&f.bottom.color){let e=f.bottom;t.strokeStyle=`rgb(${e.color.r}, ${e.color.g}, ${e.color.b})`,t.lineWidth=S(e),t.beginPath(),t.moveTo(r,i+o),t.lineTo(r+a,i+o),t.stroke()}if(f.insideH&&f.insideH.color){let e=f.insideH;t.strokeStyle=`rgb(${e.color.r}, ${e.color.g}, ${e.color.b})`,t.lineWidth=S(e);for(let e=0;e<y.length-1;e++){let i=y[e];t.beginPath(),t.moveTo(r,i),t.lineTo(r+a,i),t.stroke()}}if(f.insideV&&f.insideV.color){let e=f.insideV;t.strokeStyle=`rgb(${e.color.r}, ${e.color.g}, ${e.color.b})`,t.lineWidth=S(e);let a=r;for(let e=0;e<c.length-1;e++)a+=c[e],t.beginPath(),t.moveTo(a,i),t.lineTo(a,i+o),t.stroke()}}t.restore()}drawCellBordersFromPPTX(e,t,r,i,a,o){if(!t||!t.borders)return;let l=t.borders,s=this.coordinateSystem&&"number"==typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1;[{name:"top",x1:r,y1:i,x2:r+a,y2:i},{name:"right",x1:r+a,y1:i,x2:r+a,y2:i+o},{name:"bottom",x1:r,y1:i+o,x2:r+a,y2:i+o},{name:"left",x1:r,y1:i,x2:r,y2:i+o}].forEach(t=>{let r=l[t.name];r&&r.color&&r.width&&r.width>0&&(e.strokeStyle=`rgb(${r.color.r}, ${r.color.g}, ${r.color.b})`,e.lineWidth=Math.max(1,Math.round(r.width*s)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke())})}extractCellStyle(e,t,r){let i={};if(!e)return i;if(e.shading&&e.shading.fillColor&&void 0!==e.shading.fillColor.r&&void 0!==e.shading.fillColor.g&&void 0!==e.shading.fillColor.b){let t=e.shading.fillColor;i.backgroundColor=`rgba(${t.r}, ${t.g}, ${t.b}, ${(t.a||255)/255})`}else if(e.shading&&e.shading.fill&&"none"!==e.shading.fill){let t=e.shading.fill.startsWith("#")?e.shading.fill.slice(1):null;if(t&&6===t.length){let e=parseInt(t.substring(0,2),16),r=parseInt(t.substring(2,4),16),a=parseInt(t.substring(4,6),16);i.backgroundColor=`rgb(${e}, ${r}, ${a})`}}if(!i.backgroundColor&&r&&void 0!==t){let a="function"==typeof r.getTableProperties?r.getTableProperties():r.tableProperties||{};if(a){let r=e.logicalColIndex||0;a.firstRow&&0===t?i.backgroundColor="rgba(68, 114, 196, 1)":a.bandRow&&t>0?(a.firstRow?t-1:t)%2==1&&(i.backgroundColor="rgba(242, 242, 242, 1)"):a.firstCol&&0===r&&t>0&&(i.backgroundColor="rgba(221, 235, 247, 1)")}}if(e.textBody&&e.textBody.paragraphs&&e.textBody.paragraphs.length>0){let a=e.textBody.paragraphs[0];if(a.runs&&a.runs.length>0){let e=a.runs[0];if(e.properties&&e.properties.color){let t=e.properties.color;i.textColor=`rgba(${t.r}, ${t.g}, ${t.b}, ${(t.a||255)/255})`}else i.textColor=this.getTableStyleTextColor(t,r)}else i.textColor=this.getTableStyleTextColor(t,r)}else i.textColor=this.getTableStyleTextColor(t,r);return i}getTableStyleTextColor(e,t){let r=t&&"function"==typeof t.getTableProperties?t.getTableProperties():t&&t.tableProperties?t.tableProperties:{};return r&&void 0!==e&&r.firstRow&&0===e?"rgb(255, 255, 255)":"rgb(0, 0, 0)"}getCellMarginsPx(e){let t=this.coordinateSystem&&"number"==typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1,r=3.78*t,i={left:r,top:r,right:r,bottom:r};if(!e)return i;let a={...i},o=e=>{let r=Number(e);return Number.isFinite(r)?r/914400*96*t:null};return(e=>{if(e){if(void 0!==e.marL){let t=o(e.marL);null!==t&&(a.left=t)}if(void 0!==e.marT){let t=o(e.marT);null!==t&&(a.top=t)}if(void 0!==e.marR){let t=o(e.marR);null!==t&&(a.right=t)}if(void 0!==e.marB){let t=o(e.marB);null!==t&&(a.bottom=t)}}})(e.cellProperties),(e=>{if(e){if(void 0!==e.left){let t=o(e.left);null!==t&&(a.left=t)}if(void 0!==e.top){let t=o(e.top);null!==t&&(a.top=t)}if(void 0!==e.right){let t=o(e.right);null!==t&&(a.right=t)}if(void 0!==e.bottom){let t=o(e.bottom);null!==t&&(a.bottom=t)}}})(e.margins),a}computeCellTextLayout(e,t,r,i=1/0,a={}){let o={lines:[],totalHeight:0};if(!t||!t.textBody||!Array.isArray(t.textBody.paragraphs)||r<=0)return o;let l="number"==typeof i&&i>0?i:1/0,s=a&&"number"==typeof a.contentX?a.contentX:0,n=0,h=this.coordinateSystem&&"number"==typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1,c=!!(t.textBody&&t.textBody.bodyProperties&&!1===t.textBody.bodyProperties.wrap),u=e?e.font:null;for(let i of t.textBody.paragraphs){if(!i||!Array.isArray(i.runs)||0===i.runs.length)continue;if(n>=l)break;let t="left",u=s;if(i.properties&&i.properties.alignment){let e=i.properties.alignment,a="string"==typeof e?e.toLowerCase():e;"center"===a||"ctr"===a?(t="center",u=s+r/2):"right"===a||"r"===a||"end"===a?(t="right",u=s+r):"start"===a||"left"===a||"l"===a?(t="left",u=s):"justify"===a&&(t="left",u=s)}let d=i.runs.find(e=>(e.text||"").trim().length>0)||i.runs[0],p=12;if(d?.properties?.fontSize)p=d.properties.fontSize;else if(d?.properties?.sz){let e=parseInt(d.properties.sz,10);Number.isNaN(e)||(p=e/100)}let g=Math.max(1,Math.round(96/72*p*h)),f=d?.properties?.fontFamily||"Arial",m=!!d?.properties?.bold,y=!!d?.properties?.italic,b=!!d?.properties?.underline,S=a.defaultTextColor||"rgb(159, 159, 159)";if(d?.properties?.color){let e=d.properties.color;S=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`}let x=1.2;i.properties&&("number"==typeof i.properties.lineSpacingFactor?x=i.properties.lineSpacingFactor:"number"==typeof i.properties.lineSpacingPct&&(x=Math.max(.5,Math.min(4,i.properties.lineSpacingPct/100))));let w=Math.max(1,Math.round(g*x)),C=i.runs.map(e=>e.text||"").join("");if(!C)continue;let T=!c,P=`${y?"italic ":""}${m?"bold ":""}${g}px ${f}`;e&&"string"==typeof e.font&&(e.font=P);let v=null;if(d?.properties?.highlight){let e=d.properties.highlight;"object"==typeof e&&void 0!==e.r?v=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`:"string"==typeof e&&(v=e)}let M=e=>{e&&(o.lines.push({text:e,textX:u,textAlign:t,fontSizePixels:g,fontFamily:f,isBold:m,isItalic:y,isUnderline:b,colorStr:S,lineHeight:w,highlightStr:v}),n+=w)};if(T){let t=C.trim();for(;t.length>0&&!(n+w>l);){let i=1,a=t.length,o=1;for(;i<=a;){let l=i+a>>1,s=t.slice(0,l);(e&&"function"==typeof e.measureText?e.measureText(s):{width:s.length*g*.5}).width<=r||1===l?(o=l,i=l+1):a=l-1}let l=o;if(o<t.length){let e=t.slice(0,o).lastIndexOf(" ");e>0&&(l=e)}let s=Math.max(1,l),n=t.slice(0,s).trimEnd();n||(n=t.charAt(0),s=1),M(n),t=t.slice(s).trimStart()}}else{if(n+w>l)break;M(C.trimEnd())}}return e&&null!==u&&(e.font=u),o.totalHeight=n,o}drawCellText(e,t,r,i,a,o,l){if(!t||!t.textBody||!t.textBody.paragraphs)return;e.save(),e.textBaseline="top";let s=this.getCellMarginsPx(t),n=Math.max(0,a-s.left-s.right),h=Math.max(0,o-s.top-s.bottom);if(n<=0||h<=0)return void e.restore();let c=r+s.left,u=i+s.top;e.beginPath(),e.rect(c,u,n,h),e.clip();let d=this.computeCellTextLayout(e,t,n,h,{contentX:c,defaultTextColor:l.textColor});if(d.lines.length>0){let r=d.totalHeight,i="top";if(t&&"string"==typeof t.verticalAlignment)i=t.verticalAlignment.toLowerCase();else if(t&&t.textBody&&t.textBody.bodyProperties&&t.textBody.bodyProperties.anchor){let e=String(t.textBody.bodyProperties.anchor).toLowerCase();"ctr"===e||"center"===e||"middle"===e?i="middle":("b"===e||"bottom"===e)&&(i="bottom")}let a=d.lines[d.lines.length-1],o=a?Math.max(0,a.lineHeight-a.fontSizePixels):0,l=u;for(let t of("middle"===i||"center"===i||"ctr"===i?l=u+Math.max(0,(h-r)/2)+o/2:("b"===i||"bottom"===i)&&(l=u+Math.max(0,h-r)+o),d.lines)){let r="";if(t.isItalic&&(r+="italic "),t.isBold&&(r+="bold "),e.font=`${r}${t.fontSizePixels}px ${t.fontFamily}`,e.textAlign=t.textAlign,t.highlightStr){let r=e.measureText(t.text);e.save(),e.fillStyle=t.highlightStr,e.fillRect(Math.round(t.textX),Math.round(l-t.fontSizePixels),r.width,1.2*t.fontSizePixels),e.restore()}if(e.fillStyle=t.colorStr,e.fillText(t.text,Math.round(t.textX),Math.round(l)),t.isUnderline){let r=e.measureText(t.text).width,i=Math.round(l+1.1*t.fontSizePixels),a="center"===t.textAlign?Math.round(t.textX-r/2):"right"===t.textAlign?Math.round(t.textX-r):Math.round(t.textX);e.save(),e.strokeStyle=t.colorStr,e.lineWidth=Math.max(1,.08*t.fontSizePixels),e.beginPath(),e.moveTo(a,i),e.lineTo(a+r,i),e.stroke(),e.restore()}if((l+=t.lineHeight)>u+h)break}}e.restore()}getScaledFontSize(e){let t=e;return this.coordinateSystem&&this.coordinateSystem.scale&&(t=Math.min(t=Math.max(t=e*this.coordinateSystem.scale,8),72)),Math.round(t)}drawTablePlaceholder(e,t){this.graphics.p_color(100,100,200,255),this.graphics.p_width(2),this.graphics._s(),this.graphics._m(e.x,e.y),this.graphics._l(e.x+e.w,e.y),this.graphics._l(e.x+e.w,e.y+e.h),this.graphics._l(e.x,e.y+e.h),this.graphics._z(),"function"==typeof this.graphics.ds&&this.graphics.ds()}async drawChart(e,t){let r=this.currentSlideIndex,i=this.currentSlide;if(e.chartData){if("DEFERRED_CHART"===e.chartData.type)if(!window.ChartProcessor)return void this.drawChartPlaceholder(t,"No Processor");else{let a=new ChartProcessor(this.context);if(void 0===r||!i)return void this.drawChartPlaceholder(t,"No Context");{let o={slideIndex:r,slideName:i?.name||`slide${r+1}`,slide:i};a.setSlideContext(o);try{let r=await a.loadChartFromRelationship(e.chartData.relationshipId,o);if(!r||"DEFERRED_CHART"===r.type)return void this.drawChartPlaceholder(t,"Load Failed");e.chartData=r}catch(e){this.drawChartPlaceholder(t,"Load Error");return}}}try{let r=new ChartRenderer(this.graphics);await r.renderChart(e.chartData,t.x,t.y,t.w,t.h)}catch(e){this.drawChartPlaceholder(t,"Render Failed")}}else if(e.graphicData&&e.graphicData.element&&window.ChartProcessor)try{let a=new ChartProcessor(this.context);if(void 0!==r&&i){let e={slideIndex:r,slideName:i?.name||`slide${r+1}`,slide:i};a.setSlideContext(e)}let o=a.parseEmbeddedChartData(e.graphicData.element);if(o){e.chartData=o;let r=new ChartRenderer(this.graphics);await r.renderChart(o,t.x,t.y,t.w,t.h);return}if(e.graphicData.chartRef){let o={slideIndex:r,slideName:i?.name||`slide${r+1}`,slide:i};try{let r=await a.loadChartFromRelationship(e.graphicData.chartRef,o);if(r){e.chartData=r;let i=new ChartRenderer(this.graphics);await i.renderChart(r,t.x,t.y,t.w,t.h)}else this.drawChartPlaceholder(t,"Processing Failed")}catch(e){this.drawChartPlaceholder(t,"Processing Error")}return}this.drawChartPlaceholder(t,"No Chart Reference")}catch(e){this.drawChartPlaceholder(t,"Processing Failed")}else this.drawChartPlaceholder(t,"No Chart Data")}drawChartStyling(e,t,r,i,a){if(!e)return;let o=null;if(this.graphics&&this.graphics.ctx?o=this.graphics.ctx:this.graphics&&this.graphics._context?o=this.graphics._context:this.graphics&&this.graphics.context?o=this.graphics.context:this.graphics&&this.graphics.m_oContext&&(o=this.graphics.m_oContext),!o)return;let l=(e.plotArea?.shapeProperties||e.shapeProperties||{}).line;if(!l||!l.color)return;let s=Math.max(1,Math.round((l.width||12700)/12700)),n="string"==typeof l.color?l.color:this.colorToRgb(l.color),h=e.roundedCorners?Math.min(20,Math.floor(.1*Math.min(i,a))):0;if(o.save(),o.strokeStyle=n,o.lineWidth=s,o.lineCap="round",o.lineJoin="round",o.globalCompositeOperation="source-over",o.beginPath(),e.roundedCorners&&h>0){let e=t+s/2,l=r+s/2,n=i-s,c=a-s;this.graphics&&"function"==typeof this.graphics.drawRoundRectPath?this.graphics.drawRoundRectPath(o,e,l,n,c,h):"function"==typeof this.drawRoundRectPath?this.drawRoundRectPath(o,e,l,n,c,h):o.rect(e,l,n,c)}else{let e=t+s/2,l=r+s/2,n=i-s,h=a-s;o.rect(e,l,n,h)}o.stroke(),o.restore()}drawChartPlaceholder(e,t){this.graphics.p_color(200,100,100,255),this.graphics.p_width(2),this.graphics._s(),this.graphics._m(e.x,e.y),this.graphics._l(e.x+e.w,e.y),this.graphics._l(e.x+e.w,e.y+e.h),this.graphics._l(e.x,e.y+e.h),this.graphics._z(),"function"==typeof this.graphics.ds&&this.graphics.ds()}drawShapeText(e,t){if(e&&e.textBody&&e.textBody.paragraphs&&0!==e.textBody.paragraphs.length){this.setCurrentRenderingShape(e),this.graphics.SaveGrState();try{let r=this.calculateTextBounds(e,t);this.drawTextContent(e.textBody,r)}catch(r){this.drawFallbackText(e,t)}finally{this.graphics.RestoreGrState(),this.setCurrentRenderingShape(null)}}}calculateTextBounds(e,t){let{x:r,y:i,w:a,h:o}=t,l=e.textBody?.bodyProperties||e.textBody?.bodyPr||{};"rtTriangle"===this.getShapePreset(e)&&(i+=o/2,o/=2);let s=Math.max(22860,.02*a*914400),n=Math.max(11430,.01*o*914400),h=this.emuToPixels(l.leftMargin||s),c=this.emuToPixels(l.rightMargin||s),u=this.emuToPixels(l.topMargin||n),d=this.emuToPixels(l.bottomMargin||n);if(this.coordinateSystem){let{scale:e}=this.coordinateSystem,t=Math.round(h*e),l=Math.round(c*e),s=Math.round(u*e),n=Math.round(d*e);return{x:r+t,y:i+s,w:Math.max(a-(t+l),0),h:Math.max(o-(s+n),0),scale:e,margins:{left:t,right:l,top:s,bottom:n}}}return{x:r+h,y:i+u,w:Math.max(a-(h+c),0),h:Math.max(o-(u+d),0),scale:1,margins:{left:h,right:c,top:u,bottom:d}}}drawFallbackText(e,t){let r=this.graphics.context;if(!r)return;let{x:i,y:a,w:o,h:l}=t;r.save();let s=this.getTextScaleFactor();r.font=`${12*s}px Arial`,r.fillStyle="#000000",r.textAlign="left",r.textBaseline="top";let n=a+5;for(let t of e.textBody.paragraphs){if(n>a+l-16)break;for(let e of t.runs)e.text&&n<=a+l-16&&(r.fillText(e.text,i+5,n),n+=16)}r.restore()}drawTextContent(e,t){if(!e||!e.paragraphs||0===e.paragraphs.length||!this.graphics||!this.graphics.context)return;this.graphics.context;let{x:r,y:i,w:a,h:o}=t;if(!o||o<1){let r=this.estimateTextHeightPx(e,a);if(r&&r>0){let i={...t,h:r};this.renderTextBodyStandard(e,i);return}}this.renderTextBodyStandard(e,t)}estimateTextHeightPx(e,t){try{if(!e||!e.paragraphs||0===e.paragraphs.length)return 0;let r=e.bodyProperties||e.bodyPr||{},i=this.emuToPixels(r.leftMargin||0),a=this.emuToPixels(r.rightMargin||0),o=Math.max(0,t-i-a),l=0;for(let t of e.paragraphs){let e=this.parseParagraphProperties(t,this.getCurrentShape()),r=this.calculateWrappedLines(t,e,o,this.getCurrentShape()),i=this.calculateStandardLineHeight(e,r),a=this.emuToPixels(e.spaceBefore||0),s=this.emuToPixels(e.spaceAfter||0);l+=a+r.length*i+s}let s=this.emuToPixels(r.topMargin||0),n=this.emuToPixels(r.bottomMargin||0);return l+=s+n,Math.ceil(l)}catch(e){return 0}}estimateTextBoxHeightPx(e,t){let r=e&&e.textBody;return r?this.estimateTextHeightPx(r,t):0}renderTextBodyStandard(e,t){let{x:r,y:i,w:a,h:o,margins:l,scale:s}=t,n=e.bodyProperties||e.bodyPr||{},h=n.anchor||n.verticalAlign||"t";switch(h){case"top":h="t";break;case"middle":case"center":h="ctr";break;case"bottom":h="b"}let c=i,u=[],d=0;for(let t=0;t<e.paragraphs.length;t++){let r=e.paragraphs[t],i=this.getCurrentShape(),o=this.parseParagraphProperties(r,i),l=this.calculateWrappedLines(r,o,a,i),n=this.calculateStandardLineHeight(o,l),h=this.emuToPixels(o.spaceBefore||0)*s,c=this.emuToPixels(o.spaceAfter||0)*s;o.spaceBeforePct&&!o.spaceBefore&&(h=o.spaceBeforePct*n),o.spaceAfterPct&&!o.spaceAfter&&(c=o.spaceAfterPct*n);let p=h+l.length*n+c;u.push({paragraph:r,paraProps:o,wrappedLines:l,lineHeight:n,spaceBefore:h,spaceAfter:c,height:p}),d+=p}switch(h){case"ctr":case"middle":c=i+(o-d)/2;break;case"b":case"bottom":c=i+o-d;break;case"just":e.paragraphs.length,c=i;break;default:c=i}let p=c,g=i+o,f=0;if(("just"===h||"dist"===h)&&u.length>1){let e=Math.max(0,o-d);e>0&&("just"===h?f=e/(u.length-1):"dist"===h&&(p+=f=e/(u.length+1)))}let m={},y=-1,b={},S=new Set;for(let e=0;e<u.length;e++){let{paraProps:t}=u[e];if(t&&t.bullet&&("number"===t.bullet.type||"autoNumber"===t.bullet.type)){let e=t.indent&&"number"==typeof t.indent.left?t.indent.left:0;S.add(e)}}let x=Array.from(S).sort((e,t)=>e-t),w=x.length>0?x[0]:0,C=e=>{let t=e&&"number"==typeof e.level?e.level:0;if(t>0)return t;let r=e.indent&&"number"==typeof e.indent.left?e.indent.left:0;if(x.length<=1)return t;if(r<=w)return 0;let i=x.indexOf(r);return -1===i&&-1===(i=x.findIndex(e=>e>=r))&&(i=x.length-1),Math.max(0,i)};for(let e=0;e<u.length;e++){let t=u[e].paraProps;if(t.bullet&&("number"===t.bullet.type||"autoNumber"===t.bullet.type)){let r=C(t),i=void 0!==t.bullet.startAt,a=i?t.bullet.startAt:1;if(r!==y)if(r<y)for(let e=r+1;e<=9;e++)delete m[e];else r>y&&(m[r]=0);if(!m[r]&&0!==m[r]){let e=i?a-1:0;m[r]=e}m[r]||(m[r]=0),m[r]++,b[e]=m[r],y=r}}for(let e=0;e<u.length;e++){let t=u[e];if(p>=g)break;let{paraProps:i,wrappedLines:o,lineHeight:l,spaceBefore:n,spaceAfter:h}=t;p+=n||0;let c=C(i);if(i.bullet&&("number"===i.bullet.type||"autoNumber"===i.bullet.type)){if(c!==y)if(c<y)for(let e=c+1;e<=9;e++)delete m[e];else c>y&&(m[c]=0);m[c]||(m[c]=0),m[c]++,y=c}for(let t=0;t<o.length;t++){let n=o[t],h=this.emuToPixels(i.indent?.left||0)*s,u=this.emuToPixels(i.indent?.hanging||0)*s,d=h;0===t&&0!==u&&(d+=u);let g=i.align||"left",f=r+Math.max(0,d);"center"===g||"ctr"===g?f=r+d+(a-n.width-d)/2:("right"===g||"r"===g)&&(f=r+a-n.width);let y=i.fontSize||12,S=this.getTextScaleFactor(),x=p+y*S*.8;if(0===t&&i.bullet&&"none"!==i.bullet.type){let t=r+h+u,a="number"===i.bullet.type||"autoNumber"===i.bullet.type?m[c]||1:e;i._bulletNumber=b[e];let o=n.runs&&n.runs[0]&&n.runs[0].runProps&&n.runs[0].runProps.fontSize?n.runs[0].runProps.fontSize:i.fontSize||12,l={...i,fontSize:o},s=this.getBulletWidth(i.bullet,l,a,m);this.renderBullet(i.bullet,t,x,l,a,m);let d=o*S*.3,p=t+s,g=r+h;f=p+d>g?p+d:g}let w=f;for(let e of n.runs){let{text:t,runProps:i}=e,o=t;if(i.cap&&"none"!==i.cap)switch(i.cap){case"all":case"small":o=o.toUpperCase();break;case"words":o=o.replace(/\b\w/g,e=>e.toUpperCase())}if(this.setupStandardFont(i),i.highlight){let e=this.graphics.context;if(e){let t,r=i.highlight;if("object"==typeof r&&void 0!==r.r?t=`rgba(${r.r}, ${r.g}, ${r.b}, ${(r.a||255)/255})`:"string"==typeof r&&(t=r),t){let r=e.measureText(o).width,a=i.scaledFontSize||(i.fontSize||12)*this.getTextScaleFactor();e.save(),e.fillStyle=t,e.fillRect(Math.round(w),Math.round(x-.85*a),r,1.15*a),e.restore(),e.fillStyle=this.graphics.colorToRgb(i.color)}}}let l=this.graphics.context,s=!1;if(i.effectLst&&l){let e=i.effectLst;if(e.outerShadow){let t=e.outerShadow;l.save(),s=!0;let r=(t.blurRadius||0)/12700,i=(t.distance||0)/12700,a=(t.direction||0)/6e4*Math.PI/180;if(l.shadowOffsetX=Math.cos(a)*i*this.getTextScaleFactor(),l.shadowOffsetY=Math.sin(a)*i*this.getTextScaleFactor(),l.shadowBlur=r*this.getTextScaleFactor(),t.color){let e=t.color,r=0,i=0,a=0,o=.5;if(void 0!==e.r)r=e.r,i=e.g,a=e.b,o=void 0!==e.a?e.a/255:.5;else if(e.value){let t=e.value.replace("#","");r=parseInt(t.slice(0,2),16)||0,i=parseInt(t.slice(2,4),16)||0,a=parseInt(t.slice(4,6),16)||0,o=void 0!==e.alpha?e.alpha:.5}l.shadowColor=`rgba(${r}, ${i}, ${a}, ${o})`}else l.shadowColor="rgba(0, 0, 0, 0.4)"}else if(e.glow){let t=e.glow;l.save(),s=!0;let r=(t.radius||0)/12700;if(l.shadowOffsetX=0,l.shadowOffsetY=0,l.shadowBlur=r*this.getTextScaleFactor(),t.color){let e=t.color;l.shadowColor=`rgba(${e.r||0}, ${e.g||0}, ${e.b||0}, ${(e.a||255)/255})`}else l.shadowColor="rgba(255, 0, 0, 0.6)"}}let n=x;if(i.verticalAlign&&"normal"!==i.verticalAlign&&"baseline"!==i.verticalAlign){let e=i.scaledFontSize||(i.fontSize||12)*this.getTextScaleFactor();"superscript"===i.verticalAlign||"super"===i.verticalAlign?n=x-.35*e:("subscript"===i.verticalAlign||"sub"===i.verticalAlign)&&(n=x+.2*e)}w=this.renderRunTextStandard(o,w,n,i,r+a),s&&l&&(l.restore(),l.fillStyle=this.graphics.colorToRgb(i.color))}p+=l}p+=h||0,e<u.length-1&&(p+=f)}}calculateWrappedLines(e,t,r,i){let a=[],o={runs:[],width:0},l=!0;for(let s of e.runs){if(!s.text)continue;let e=l;l=!1;let n=this.parseRunProperties(s,t,i),h=s.text;if(e&&t.bullet&&("autoNumber"===t.bullet.type||"number"===t.bullet.type)&&(h=h.replace(/^\s*\d+[.)]\s*/,"")),s.fieldType&&"slidenum"===(s.fieldType||"").toLowerCase()&&(h=String(void 0!==this.currentSlideIndex&&null!==this.currentSlideIndex?this.currentSlideIndex+1:parseInt(h,10)||1)),!h)continue;let c=h.split("\n");for(let e=0;e<c.length;e++){e>0&&(o.runs.length>0&&a.push(o),o={runs:[],width:0});let t=c[e];if(t)for(let e of t.split(/(\s+)/)){if(!e)continue;let t=this.measureRunText(e,n);if(o.width+t<=r)o.runs.push({text:e,runProps:n}),o.width+=t;else if(t<=r)o.runs.length>0&&a.push(o),o={runs:[{text:e,runProps:n}],width:t};else{o.runs.length>0&&(a.push(o),o={runs:[],width:0});let t="",i=0;for(let l of e){let e=this.measureRunText(l,n);i+e>r&&t.length>0&&(o.runs.push({text:t,runProps:n}),o.width+=i,a.push(o),o={runs:[],width:0},t="",i=0),t+=l,i+=e}t&&(o.runs.push({text:t,runProps:n}),o.width+=i)}}}}return o.runs.length>0&&a.push(o),0===a.length&&a.push({runs:[],width:0}),a}setupStandardFont(e){let t=this.graphics.context;if(!t)return;let r=this.getTextScaleFactor(),i=(e.fontSize||12)*r,a=e.italic?"italic":"normal",o=e.bold?"bold":"normal",l=e.fontFamily||"Arial",s=`"${l}", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif`;t.font=`${a} ${o} ${i}px ${s}`,t.fillStyle=this.graphics.colorToRgb(e.color),t.textBaseline="alphabetic",e.scaledFontSize=i}getBulletWidth(e,t,r=0,i=null){let a=this.graphics.context;if(!a||!e)return 0;a.save();try{let i=t.fontSize||12,o=this.getTextScaleFactor(),l=t.fontFamily||"Arial",s=t.bold?"bold":"normal",n=t.italic?"italic":"normal";a.font=`${n} ${s} ${i*o}px ${l}`;let h="";switch(e.type){case"character":h=e.char||"•";break;case"number":{let i=(e.startAt||1)-1,a=t&&"number"==typeof t._bulletNumber?t._bulletNumber:r;h=`${i+a}.`}break;case"autoNumber":{let i=(e.startAt||1)-1,a=t&&"number"==typeof t._bulletNumber?t._bulletNumber:r;h=this.getAutoNumberBullet(e.subType,i+a)}break;default:h="•"}let c=a.measureText(h).width;return a.restore(),c}catch(e){return a.restore(),0}}calculateBulletInfo(e,t,r=0){let i=this.graphics.getContext();i.save();let a=Math.max((t.fontSize||12)*this.getTextScaleFactor(),14),o=t.fontFamily||"Arial",l=t.bold?"bold":"normal",s=t.italic?"italic":"normal";i.font=`${s} ${l} ${a}px ${o}`;let n="";switch(e.type){case"character":n=e.char||"•";break;case"number":{let i=(e.startAt||1)-1,a=t&&"number"==typeof t._bulletNumber?t._bulletNumber:r;n=`${i+a}.`}break;case"autoNumber":{let i=(e.startAt||1)-1,a=t&&"number"==typeof t._bulletNumber?t._bulletNumber:r;n=this.getAutoNumberBullet(e.subType,i+a)}break;default:n="•"}let h=i.measureText(n).width,c=.5*a;return i.restore(),{bulletText:n,bulletWidth:h,bulletSpacing:c,totalWidth:h+c}}generateHierarchicalNumber(e,t,r,i){let a=t.level||0,o=i&&i[a]?i[a]:(e.startAt||1)+r;return this.getAutoNumberBullet(e.subType,o)}renderBullet(e,t,r,i,a,o=null){let l=this.graphics.context;if(l&&e){l.save();try{let o=i.fontSize||12,s=this.getTextScaleFactor(),n=i.fontFamily||"Arial",h=i.bold?"bold":"normal",c=i.italic?"italic":"normal";l.font=`${c} ${h} ${o*s}px ${n}`;let u=i.color||{r:0,g:0,b:0,a:255};l.fillStyle=this.graphics.colorToRgb(u),l.textBaseline="alphabetic";let d="";switch(e.type){case"character":d=e.char||"•";break;case"number":{let t=(e.startAt||1)-1,r=i&&"number"==typeof i._bulletNumber?i._bulletNumber:a;d=`${t+r}.`}break;case"autoNumber":{let t=(e.startAt||1)-1,r=i&&"number"==typeof i._bulletNumber?i._bulletNumber:a;d=this.getAutoNumberBullet(e.subType,t+r)}break;default:d="•"}l.fillText(d,t,r)}catch(e){}finally{l.restore()}}}getAutoNumberBullet(e,t){switch(e){case"arabicPeriod":case"arabic1Minus":case"arabic2Minus":default:return`${t}.`;case"arabicParenR":return`${t})`;case"arabicParenBoth":return`(${t})`;case"romanUcPeriod":return`${this.toRoman(t,!0)}.`;case"romanLcPeriod":return`${this.toRoman(t,!1)}.`;case"alphaUcPeriod":return`${this.toAlpha(t,!0)}.`;case"alphaLcPeriod":return`${this.toAlpha(t,!1)}.`;case"alphaUcParenR":return`${this.toAlpha(t,!0)})`;case"alphaLcParenR":return`${this.toAlpha(t,!1)})`;case"alphaUcParenBoth":return`(${this.toAlpha(t,!0)})`;case"alphaLcParenBoth":return`(${this.toAlpha(t,!1)})`}}toRoman(e,t=!0){let r=[1e3,900,500,400,100,90,50,40,10,9,5,4,1],i=t?["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"],a="";for(let t=0;t<r.length;t++)for(;e>=r[t];)a+=i[t],e-=r[t];return a}toAlpha(e,t=!0){let r="",i=t?65:97;for(;e>0;)r=String.fromCharCode(i+--e%26)+r,e=Math.floor(e/26);return r||(t?"A":"a")}renderRunTextStandard(e,t,r,i,a){let o=this.graphics.context;if(!o||!e)return t;let l=t;this.currentRenderingShape&&this.currentRenderingShape.effects&&this.applyTextEffectsToContext(o,this.currentRenderingShape.effects);let s=i.letterSpacing||0;if(0===s)o.fillText(e,l,r),l+=o.measureText(e).width;else{let t=Array.from(e);for(let e=0;e<t.length;e++){let i=t[e];o.fillText(i,l,r),l+=o.measureText(i).width+s}}return this.resetTextEffectsOnContext(o),this.drawTextDecorations(t,r,l-t,i),l}applyEffectsToCanvas(e,t){t&&e&&(t.outerShadow&&this.applyOuterShadowToContext(e,t.outerShadow),t.glow&&this.applyGlowEffectToContext(e,t.glow),t.innerShadow)}applyTextEffectsToContext(e,t){t&&e&&(t.outerShadow&&this.applyOuterShadowToContext(e,t.outerShadow),t.glow&&this.applyGlowEffectToContext(e,t.glow),t.innerShadow)}applyOuterShadowToContext(e,t){if(!t||!e)return;let r=(t.blurRadius||0)/9525,i=(t.distance||0)/9525,a=(t.direction||0)/6e4,o=this.coordinateSystem&&this.coordinateSystem.scale||1,l=a*Math.PI/180,s=Math.cos(l)*i,n=Math.sin(l)*i;e.shadowOffsetX=s,e.shadowOffsetY=n,e.shadowBlur=r*o,t.color?e.shadowColor=this.convertColorToString(t.color):e.shadowColor="rgba(0, 0, 0, 0.5)"}applyGlowEffectToContext(e,t){if(!t||!e)return;let r=(t.radius||0)/9525;e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=r,t.color?e.shadowColor=this.convertColorToString(t.color):e.shadowColor="rgba(255, 255, 255, 0.8)"}resetEffectsOnContext(e){e&&(e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,e.shadowColor="transparent")}resetTextEffectsOnContext(e){e&&(e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,e.shadowColor="transparent")}convertColorToString(e){if(!e)return"black";if("srgb"===e.type){let t=e.value,r=parseInt(t.substr(0,2),16),i=parseInt(t.substr(2,2),16),a=parseInt(t.substr(4,2),16),o=e.alpha||1;return`rgba(${r}, ${i}, ${a}, ${o})`}if("scheme"===e.type){let t={dk1:"#000000",lt1:"#FFFFFF",dk2:"#44546A",lt2:"#E7E6E6"}[e.value]||"#000000",r=e.alpha||1,i=parseInt(t.substr(1,2),16),a=parseInt(t.substr(3,2),16),o=parseInt(t.substr(5,2),16);return`rgba(${i}, ${a}, ${o}, ${r})`}return"black"}getTextScaleFactor(){if(!this.coordinateSystem)return 1;let{scale:e}=this.coordinateSystem;return 1.33*e}calculateStandardLineHeight(e,t=null){if(e.lineHeightPoints){let t=this.coordinateSystem&&this.coordinateSystem.scale||1;return e.lineHeightPoints*(96/72)*t}let r=e.fontSize||12;if(t&&t.length>0){let e=0;for(let r of t)for(let t of r.runs||[])t.runProps&&t.runProps.fontSize>0&&(e=Math.max(e,t.runProps.fontSize));e>0&&e<r&&(r=1.2*e)}return r*this.getTextScaleFactor()*(e.lineHeight||100)/100}measureRunText(e,t){let r=this.graphics.context;if(!r||!e)return 0;r.save(),this.setupStandardFont(t);let i=0,a=t.letterSpacing||0;if(0===a)i=r.measureText(e).width;else for(let t=0;t<e.length;t++){let o=e.charAt(t);i+=r.measureText(o).width+a}return r.restore(),i}drawTextDecorations(e,t,r,i){let a=this.graphics.context,o=i.scaledFontSize||i.fontSize||12;if(i.underline&&(a.save(),a.strokeStyle=a.fillStyle,a.lineWidth=Math.max(1,.05*o),a.beginPath(),a.moveTo(e,t+2),a.lineTo(e+r,t+2),a.stroke(),a.restore()),i.strike){a.save(),a.strokeStyle=a.fillStyle,a.lineWidth=Math.max(1,.05*o),a.beginPath();let i=t-.3*o;a.moveTo(e,i),a.lineTo(e+r,i),a.stroke(),a.restore()}}measureRunTextAlternative(e,t){let r=this.graphics.context;r.save(),this.setupStandardFont(t);let i=0;for(let a=0;a<e.length;a++){let o=e.charAt(a);i+=r.measureText(o).width+(t.letterSpacing||0)}return r.restore(),i}calculateStandardLineHeightAlternative(e){let t=e.fontSize||12;return Math.max(t*(e.lineHeight||120)/100,1.2*t)}renderTextLine(e,t,r,i,a,o){if(0===t.length)return;let l=t.reduce((e,t)=>e+t.width,0),s=r,n=o.align||"left";this.coordinateSystem?.scale,"center"===n||"ctr"===n?s=r+Math.max(0,a-l)/2:"right"===n||"r"===n?s=r+Math.max(0,a-l):"justify"===n&&t.length>1&&(s=r);let h=s;for(let r of t){if(e.font=r.font,e.fillStyle=this.graphics.colorToRgb(r.props.color||{r:0,g:0,b:0,a:255}),e.textBaseline="alphabetic",e.textAlign="left",r.props.highlight){let t,a=r.props.highlight;if("object"==typeof a&&void 0!==a.r?t=`rgba(${a.r}, ${a.g}, ${a.b}, ${(a.a||255)/255})`:"string"==typeof a&&(t=a),t){let a=this.getTextScaleFactor(),o=(r.props.fontSize||12)*a;e.save(),e.fillStyle=t,e.fillRect(Math.round(h),Math.round(i-o),r.width,1.2*o),e.restore(),e.fillStyle=this.graphics.colorToRgb(r.props.color||{r:0,g:0,b:0,a:255})}}if(e.fillText(r.text,Math.round(h),Math.round(i)),r.props.underline&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=1,e.beginPath(),e.moveTo(h,i+2),e.lineTo(h+r.width,i+2),e.stroke(),e.restore()),r.props.strike){e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=1,e.beginPath();let t=this.getTextScaleFactor(),a=i-.3*((r.props.fontSize||12)*t);e.moveTo(h,a),e.lineTo(h+r.width,a),e.stroke(),e.restore()}h+=r.width}}parseParagraphProperties(e,t=null){let r={align:"left",lineHeight:120,spaceBefore:0,spaceAfter:0,fontSize:18,fontFamily:"Arial",color:{r:0,g:0,b:0,a:255},bold:!1,italic:!1,bullet:null,indent:{left:0,hanging:0}},i=e.properties&&"number"==typeof e.properties.level?e.properties.level:0,a=this.resolveInheritedTextProperties(t,"paragraph",i);for(let e in a)"leftMargin"===e?r.indent.left=a.leftMargin:"hangingIndent"===e?r.indent.hanging=a.hangingIndent:"leftMargin"!==e&&"hangingIndent"!==e&&(r[e]=a[e]);if(a.align&&(r.align=({l:"left",left:"left",ctr:"center",center:"center",r:"right",right:"right",just:"justify",justify:"justify"})[a.align]||a.align),t&&t.placeholder&&t.placeholder.type,e.properties){let t=e.properties;t.align&&(r.align=({l:"left",left:"left",ctr:"center",center:"center",r:"right",right:"right",just:"justify",justify:"justify"})[t.align]||t.align),void 0!==t.lineHeight&&(r.lineHeight=t.lineHeight),void 0!==t.lineHeightPoints&&(r.lineHeightPoints=t.lineHeightPoints),t.spacing&&(t.spacing.before&&(r.spaceBefore=t.spacing.before),t.spacing.after&&(r.spaceAfter=t.spacing.after)),void 0!==t.fontSize&&(r.fontSize=t.fontSize),t.fontFamily&&(r.fontFamily=t.fontFamily),t.color&&(r.color=t.color),void 0!==t.bold&&(r.bold=t.bold),void 0!==t.italic&&(r.italic=t.italic),t.bullet&&(r.bullet=t.bullet),t.indent&&(r.indent.left=t.indent.left,r.indent.hanging=t.indent.hanging)}return r}parseRunProperties(e,t,r=null){let i={fontSize:18,fontFamily:"Arial",color:this.currentSlide?.type==="layout"?{r:68,g:68,b:68,a:255}:{r:0,g:0,b:0,a:255},bold:!1,italic:!1,underline:!1,strike:!1,verticalAlign:"normal",letterSpacing:0,cap:"none"};if(Object.assign(i,this.resolveInheritedTextProperties(r,"run")),t&&(void 0!==t.fontSize&&(i.fontSize=t.fontSize),t.fontFamily&&(i.fontFamily=t.fontFamily),t.color&&(i.color=t.color),void 0!==t.bold&&(i.bold=t.bold),void 0!==t.italic&&(i.italic=t.italic)),e.properties){let t=e.properties;void 0!==t.fontSize&&(i.fontSize=t.fontSize),t.fontFamily&&(i.fontFamily=t.fontFamily),t.color&&(i.color=t.color),void 0!==t.bold&&(i.bold=t.bold),void 0!==t.italic&&(i.italic=t.italic),void 0!==t.underline&&(i.underline=t.underline),void 0!==t.strike&&(i.strike=t.strike),t.verticalAlign&&(i.verticalAlign=t.verticalAlign),void 0!==t.letterSpacing&&(i.letterSpacing=t.letterSpacing),t.cap&&(i.cap=t.cap),t.highlight&&(i.highlight=t.highlight),t.effectLst&&(i.effectLst=t.effectLst)}return i}emuToPixels(e){return CoordinateTransform.emuToPixels(e,96)}colorToRgbAlternative(e){if("string"==typeof e)return e.startsWith("#")||e.match(/^[a-z]+$/i),e;if(!e)return"rgb(0, 0, 0)";let t=0,r=0,i=0,a=255;return("object"==typeof e&&(t=void 0!==e.r?e.r:void 0!==e.R?e.R:0,r=void 0!==e.g?e.g:void 0!==e.G?e.G:0,i=void 0!==e.b?e.b:void 0!==e.B?e.B:0,a=void 0!==e.a?e.a:void 0!==e.A?e.A:255,t=Math.max(0,Math.min(255,Math.round(t))),r=Math.max(0,Math.min(255,Math.round(r))),i=Math.max(0,Math.min(255,Math.round(i))),a=Math.max(0,Math.min(255,Math.round(a)))),void 0!==a&&255!==a)?`rgba(${t}, ${r}, ${i}, ${a/255})`:`rgb(${t}, ${r}, ${i})`}isHiddenShape(e){return!0===e.hidden}getShapeTransform(e){return null}getShapeBounds(e){if(e&&"graphicFrame"===e.type&&e.position){let t=e.position,r=t.x||0,i=t.y||0,a=t.width||914400,o=t.height||914400;if(this.coordinateSystem){let e,t,l,s,n,h,{slideWidthEMU:c,slideHeightEMU:u}=this.coordinateSystem,d=c||9144e3,p=u||6858e3,g={x:r/d,y:i/p,w:a/d,h:o/p},f=this.graphics.context.canvas;f.style.width&&f.style.height?(e=parseFloat(f.style.width),t=parseFloat(f.style.height)):(e=f.width/(window.devicePixelRatio||1),t=f.height/(window.devicePixelRatio||1));let m=d/p;return m>e/t?(l=e,n=0,h=(t-(s=e/m))/2):(l=t*m,s=t,n=(e-l)/2,h=0),{x:Math.round(n+g.x*l),y:Math.round(h+g.y*s),w:Math.round(g.w*l),h:Math.round(g.h*s)}}return{x:r/914400*96,y:i/914400*96,w:a/914400*96,h:o/914400*96}}if(e.spPr&&e.spPr.xfrm){let t=e.spPr.xfrm,r=void 0!==t.x?t.x:(t.off&&t.off.x)!==void 0?t.off.x:0,i=void 0!==t.y?t.y:(t.off&&t.off.y)!==void 0?t.off.y:0,a=void 0!==t.width?t.width:void 0!==t.cx?t.cx:(t.ext&&t.ext.cx)!==void 0?t.ext.cx:914400,o=void 0!==t.height?t.height:void 0!==t.cy?t.cy:(t.ext&&t.ext.cy)!==void 0?t.ext.cy:914400;if(this.coordinateSystem){let e,t,l,s,n,h,{slideWidthEMU:c,slideHeightEMU:u}=this.coordinateSystem,d=c||9144e3,p=u||6858e3,g={x:r/d,y:i/p,w:a/d,h:o/p},f=this.graphics.context.canvas;f.style.width&&f.style.height?(e=parseFloat(f.style.width),t=parseFloat(f.style.height)):(e=f.width/(window.devicePixelRatio||1),t=f.height/(window.devicePixelRatio||1));let m=d/p;return m>e/t?(l=e,n=0,h=(t-(s=e/m))/2):(l=t*m,s=t,n=(e-l)/2,h=0),{x:Math.round(n+g.x*l),y:Math.round(h+g.y*s),w:Math.round(g.w*l),h:Math.round(g.h*s)}}return{x:r/914400*96,y:i/914400*96,w:a/914400*96,h:o/914400*96}}if(e.properties&&e.properties.transform){let t=e.properties.transform,r=t.x||0,i=t.y||0,a=t.width||914400,o=t.height||914400;if(this.coordinateSystem){let e,t,l,s,n,h,{scale:c,offsetX:u,offsetY:d,slideWidthEMU:p,slideHeightEMU:g}=this.coordinateSystem,f=p||9144e3,m=g||6858e3,y={x:r/f,y:i/m,w:a/f,h:o/m},b=this.graphics.context.canvas;b.style.width&&b.style.height?(e=parseFloat(b.style.width),t=parseFloat(b.style.height)):(e=b.width/(window.devicePixelRatio||1),t=b.height/(window.devicePixelRatio||1));let S=f/m;return S>e/t?(l=e,n=0,h=(t-(s=e/S))/2):(l=t*S,s=t,n=(e-l)/2,h=0),{x:Math.round(n+y.x*l),y:Math.round(h+y.y*s),w:Math.round(y.w*l),h:Math.round(y.h*s)}}return{x:r/914400*96,y:i/914400*96,w:a/914400*96,h:o/914400*96}}let t=e.position||e.transform;if(t&&(void 0!==t.x||void 0!==t.y||void 0!==t.width||void 0!==t.height)){let e=t.x||0,r=t.y||0,i=t.width||914400,a=t.height||914400;if(this.coordinateSystem){let t,o,l,s,n,h,{slideWidthEMU:c,slideHeightEMU:u}=this.coordinateSystem,d=c||9144e3,p=u||6858e3,g={x:e/d,y:r/p,w:i/d,h:a/p},f=this.graphics.context.canvas;f.style.width&&f.style.height?(t=parseFloat(f.style.width),o=parseFloat(f.style.height)):(t=f.width/(window.devicePixelRatio||1),o=f.height/(window.devicePixelRatio||1));let m=d/p;return m>t/o?(l=t,n=0,h=(o-(s=t/m))/2):(l=o*m,s=o,n=(t-l)/2,h=0),{x:Math.round(n+g.x*l),y:Math.round(h+g.y*s),w:Math.round(g.w*l),h:Math.round(g.h*s)}}return{x:e/914400*96,y:r/914400*96,w:i/914400*96,h:a/914400*96}}if(e.bounds){let t=e.bounds.l||0,r=e.bounds.t||0,i="number"==typeof e.bounds.r?e.bounds.r:t+1e6,a="number"==typeof e.bounds.b?e.bounds.b:r+1e6;if(this.coordinateSystem){let e,o,l,s,n,h,{scale:c,offsetX:u,offsetY:d,slideWidthEMU:p,slideHeightEMU:g}=this.coordinateSystem,f=p||9144e3,m=g||6858e3,y={x:t/f,y:r/m,w:(i-t)/f,h:(a-r)/m},b=this.graphics.context.canvas;b.style.width&&b.style.height?(e=parseFloat(b.style.width),o=parseFloat(b.style.height)):(e=b.width/(window.devicePixelRatio||1),o=b.height/(window.devicePixelRatio||1));let S=f/m;return S>e/o?(l=e,n=0,h=(o-(s=e/S))/2):(l=o*S,s=o,n=(e-l)/2,h=0),{x:Math.round(n+y.x*l),y:Math.round(h+y.y*s),w:Math.round(y.w*l),h:Math.round(y.h*s)}}return{x:t/914400*96,y:r/914400*96,w:(i-t)/914400*96,h:(a-r)/914400*96}}return{x:50,y:50,w:100,h:50}}getShapeFillColor(e){if(e.fill&&"none"===e.fill.type||e.properties&&e.properties.fill&&"none"===e.properties.fill.type||(this.processor&&this.processor.applyPropertyInheritance&&(!e.fill||null===e.fill)&&(!e.properties?.fill||e.properties?.fill===null)&&this.processor.applyPropertyInheritance(e,this.currentSlide),e.fill&&"none"===e.fill.type||e.properties&&e.properties.fill&&"none"===e.properties.fill.type||e.textBody&&e.placeholder&&!e.fill&&!e.properties?.fill&&!e.fillColor))return null;if(this.processor&&this.processor.getShapeFillColor){let t=this.processor.getShapeFillColor(e);if(void 0!==t)return t}let t=e.preservedStyle||e.style;if(t&&t.fillRef){if(e.textBody&&e.placeholder&&!e.fill&&!e.properties?.fill&&!e.fillColor)return null;if(this.processor&&this.processor.resolveStyleFillColor){let e=this.processor.resolveStyleFillColor(t.fillRef);if(e)return e}return t.fillRef.color?t.fillRef.color:this.currentSlide?.type!=="layout"||!e.textBody||e.fill||e.properties?.fill?"#FFFFFF":null}if(e.textBody&&!e.placeholder&&e.fillColor){let t=e.fillColor;if("string"==typeof t){let e=t.replace("#","");if(6===e.length){let t=parseInt(e.substr(0,2),16),r=parseInt(e.substr(2,2),16),i=parseInt(e.substr(4,2),16);if(t>200&&r>240&&i>240)return null}}else if("object"==typeof t&&void 0!==t.r&&t.r>200&&t.g>240&&t.b>240)return null}return e.fill&&"solid"===e.fill.type&&e.fill.color?e.fill.color:e.properties&&e.properties.fill&&e.properties.fill.color?e.properties.fill.color:e.fillColor||null}getShapeStrokeColor(e){if(!(e&&e.spPr&&e.spPr.ln||e&&e.properties&&e.properties.stroke||e&&e.stroke))return null;if(this.processor&&this.processor.getShapeStrokeColor)return this.processor.getShapeStrokeColor(e);let t=e.preservedStyle||e.style;if(t&&t.lnRef){if(this.processor&&this.processor.resolveStyleStrokeColor){let e=this.processor.resolveStyleStrokeColor(t.lnRef);if(e)return e}if(t.lnRef.color)return t.lnRef.color}return e.stroke&&e.stroke.color?e.stroke.color:e.properties&&e.properties.stroke&&e.properties.stroke.color?e.properties.stroke.color:e.strokeColor||null}getShapeLineWidth(e){return this.processor&&this.processor.getShapeLineWidth?this.processor.getShapeLineWidth(e):e&&e.spPr&&e.spPr.ln||e&&e.properties&&e.properties.stroke||e&&e.stroke?e.stroke&&e.stroke.width?e.stroke.width/914400*25.4:e.properties&&e.properties.stroke&&e.properties.stroke.width?e.properties.stroke.width/914400*25.4:e.spPr&&e.spPr.ln&&e.spPr.ln.w?e.spPr.ln.w/914400*25.4:0:0}getShapeStrokeInfo(e){return this.processor&&this.processor.getShapeStrokeInfo?this.processor.getShapeStrokeInfo(e):e.stroke?e.stroke:e.properties&&e.properties.stroke?e.properties.stroke:null}getShapeStrokeInfoLegacy(e){return this.processor&&this.processor.getShapeStrokeInfo?this.processor.getShapeStrokeInfo(e):e.stroke?e.stroke:e.properties&&e.properties.stroke?e.properties.stroke:null}getParagraphProperties(e){return e.properties||{}}getRunProperties(e,t){return{...t,...e.properties||{}}}parseColor(e){if("string"==typeof e&&e.startsWith("#")){let t=e.slice(1);return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16),a:255}}return e&&"object"==typeof e?e:null}clipTextRect(e){this.graphics.AddClipRect(e.x,e.y,e.w,e.h)}getCanvasBounds(e){let t,r;return e.getTransform(),e.canvas.style.width&&e.canvas.style.height?(t=parseFloat(e.canvas.style.width),r=parseFloat(e.canvas.style.height)):(t=e.canvas.width/(window.devicePixelRatio||1),r=e.canvas.height/(window.devicePixelRatio||1)),this.currentShapeBounds||{x:0,y:0,w:t,h:r}}createCanvasGradient(e,t,r){let i;if(!r||!r.stops||0===r.stops.length)return null;if("linear"===r.type){let a=(r.angle||0)*Math.PI/180,o=t.x+t.w/2-Math.cos(a)*t.w/2,l=t.y+t.h/2-Math.sin(a)*t.h/2,s=t.x+t.w/2+Math.cos(a)*t.w/2,n=t.y+t.h/2+Math.sin(a)*t.h/2;i=e.createLinearGradient(o,l,s,n)}else{if("radial"!==r.type)return null;let a=t.x+t.w/2,o=t.y+t.h/2,l=Math.max(t.w,t.h)/2;i=e.createRadialGradient(a,o,0,a,o,l)}for(let e of r.stops){let t=this.colorToRgb(e.color);i.addColorStop(e.position,t)}return i}colorToRgbAlternative2(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=e.r||e.R||0,r=e.g||e.G||0,i=e.b||e.B||0,a=(void 0!==e.a?e.a:void 0!==e.A?e.A:255)/255;return`rgba(${t}, ${r}, ${i}, ${a})`}return"#000000"}findLayoutShapeForPlaceholder(e,t){if(!t||!t.placeholder||!e)return null;let r=t.placeholder;for(let t of e)if(t.placeholder){let e=t.placeholder,i=void 0===r.idx||null===r.idx||isNaN(Number(r.idx))?void 0:Number(r.idx),a=void 0===e.idx||null===e.idx||isNaN(Number(e.idx))?void 0:Number(e.idx),o=(e,t)=>{if(e===t)return!0;let r=new Set([e,t]);return!!(r.has("title")&&r.has("ctrTitle")||r.has("body")&&r.has("obj"))};if(o(e.type,r.type)&&void 0!==i&&void 0!==a&&i===a||o(e.type,r.type)&&(void 0===i||void 0===a))return t}return null}resolveInheritedTextProperties(e,t="run",r=0){let i={};try{let a=this.buildSlideContext(),o="otherStyle";if(e&&e.placeholder)switch(e.placeholder.type){case"title":case"ctrTitle":o="titleStyle";break;case"body":case"subTitle":case"obj":o="bodyStyle";break;default:o="otherStyle"}if(a.theme&&(a.theme.fonts&&(i.fontFamily="titleStyle"===o?a.theme.fonts.major:a.theme.fonts.minor),a.theme.colors&&a.theme.colors.text1&&(i.color=this.parseColorFromTheme(a.theme.colors.text1))),a.master&&a.master.txStyles){let e=a.master.txStyles[o];if(e){let a=this.extractTextPropertiesFromStyle(e,t,r);Object.assign(i,a)}}if(a.layout&&a.layout.txStyles){let e=a.layout.txStyles[o];if(e){let a=this.extractTextPropertiesFromStyle(e,t,r);Object.assign(i,a)}}let l=!1;if(a.layout&&a.layout.shapes){let t=this.findLayoutShapeForPlaceholder(a.layout.shapes,e);if(t&&t.textBody&&t.textBody.lstStyle){l=!0;let r=t.textBody.lstStyle,a=0;try{if(e&&e.textBody&&Array.isArray(e.textBody.paragraphs)&&e.textBody.paragraphs.length>0){let t=e.textBody.paragraphs[0]?.properties?.level;"number"==typeof t&&t>=0&&t<=8&&(a=t)}}catch(e){}let o=r[`lvl${a+1}pPr`]||r.lvl1pPr;o&&(o.fontSize&&(i.fontSize=o.fontSize),o.fontFamily&&(i.fontFamily=o.fontFamily),o.color&&(i.color=o.color),void 0!==o.bold&&(i.bold=o.bold),void 0!==o.italic&&(i.italic=o.italic),o.align&&(i.align=o.align),o.cap&&(i.cap=o.cap))}}if((!i.fontSize||!i.align||!i.fontFamily)&&a.master&&a.master.cSld&&a.master.cSld.spTree){let t=a.master.cSld.spTree,r=this.findLayoutShapeForPlaceholder(t,e);if(r&&r.textBody&&r.textBody.lstStyle){let e=r.textBody.lstStyle;if(e.lvl1pPr){let t=e.lvl1pPr;!i.fontSize&&t.fontSize&&(i.fontSize=t.fontSize),!i.fontFamily&&t.fontFamily&&(i.fontFamily=t.fontFamily),!i.color&&t.color&&(i.color=t.color),void 0!==t.bold&&void 0===i.bold&&(i.bold=t.bold),void 0!==t.italic&&void 0===i.italic&&(i.italic=t.italic),!i.align&&t.align&&(i.align=t.align),!i.cap&&t.cap&&(i.cap=t.cap)}}}if(e&&e.placeholder)switch(e.placeholder.type){case"title":case"ctrTitle":void 0!==i.bold||l||(i.bold=!0)}(e?.placeholder?.type==="title"||e?.placeholder?.type==="ctrTitle")&&(i.align||(i.align="ctr"),i.fontSize||(i.fontSize=44))}catch(e){}return i}extractTextPropertiesFromStyle(e,t="run",r=0){let i={};if(!e||!e.element)return i;try{e.parsed||(e.parsedData=this.parseTextStyleElement(e.element),e.parsed=!0);let a=e.parsedData;if(!a)return i;if("paragraph"===t||"run"===t){let e=a.defPPr;e&&(e.align&&(i.align=e.align),e.lineHeight&&(i.lineHeight=e.lineHeight),e.spaceBefore&&(i.spaceBefore=e.spaceBefore),e.spaceAfter&&(i.spaceAfter=e.spaceAfter),e.bullet&&(i.bullet=e.bullet));let t=a.defRPr;t&&(t.fontSize&&(i.fontSize=t.fontSize),t.fontFamily&&(i.fontFamily=t.fontFamily),t.color&&(i.color=t.color),void 0!==t.bold&&(i.bold=t.bold),void 0!==t.italic&&(i.italic=t.italic),void 0!==t.underline&&(i.underline=t.underline),void 0!==t.strike&&(i.strike=t.strike),t.cap&&(i.cap=t.cap));let o=a[`lvl${r+1}pPr`];if(o&&(o.align&&(i.align=o.align),o.lineHeight&&(i.lineHeight=o.lineHeight),o.bullet&&(i.bullet=o.bullet),void 0!==o.leftMargin&&(i.leftMargin=o.leftMargin),void 0!==o.indent&&(i.hangingIndent=o.indent),void 0!==o.spaceBefore&&(i.spaceBefore=o.spaceBefore),void 0!==o.spaceBeforePct&&(i.spaceBeforePct=o.spaceBeforePct),void 0!==o.spaceAfter&&(i.spaceAfter=o.spaceAfter),void 0!==o.spaceAfterPct&&(i.spaceAfterPct=o.spaceAfterPct),o.defRPr)){let e=o.defRPr;e.fontSize&&(i.fontSize=e.fontSize),e.fontFamily&&(i.fontFamily=e.fontFamily),e.color&&(i.color=e.color),void 0!==e.bold&&(i.bold=e.bold),void 0!==e.italic&&(i.italic=e.italic),e.cap&&(i.cap=e.cap)}}}catch(e){}return i}parseColorFromTheme(e){if("string"==typeof e&&e.startsWith("#")){let t=e.substring(1),r=parseInt(t.substring(0,2),16);return{r,g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:255}}return null}parseTextStyleElement(e){let t={};if(!e)return t;try{let r=e.querySelector("defPPr, a\\:defPPr");r&&(t.defPPr=this.parseStyleParagraphProperties(r));let i=e.querySelector("defRPr, a\\:defRPr")||e.querySelector("defPPr > defRPr, a\\:defPPr > a\\:defRPr");i&&(t.defRPr=this.parseStyleRunProperties(i));for(let r=1;r<=9;r++){let i=e.querySelector(`lvl${r}pPr, a\\:lvl${r}pPr`);if(i){let e=this.parseStyleParagraphProperties(i),a=i.querySelector("defRPr, a\\:defRPr");a&&(e.defRPr=this.parseStyleRunProperties(a)),t[`lvl${r}pPr`]=e}}}catch(e){}return t}parseStyleParagraphProperties(e){let t={};if(!e)return t;try{let r=e.getAttribute("algn")||e.getAttribute("align");r&&(t.align=({l:"left",left:"left",ctr:"center",center:"center",r:"right",right:"right",just:"justify",justify:"justify"})[r]||r);let i=e.getAttribute("lnSpc")||e.getAttribute("lineHeight");i&&(t.lineHeight=parseInt(i)||120);let a=e.querySelector("spcBef, a\\:spcBef");if(a){let e=a.querySelector("spcPct, a\\:spcPct"),r=a.querySelector("spcPts, a\\:spcPts");e?t.spaceBeforePct=parseInt(e.getAttribute("val"))/1e5:r&&(t.spaceBefore=127*parseInt(r.getAttribute("val")))}let o=e.querySelector("spcAft, a\\:spcAft");if(o){let e=o.querySelector("spcPct, a\\:spcPct"),r=o.querySelector("spcPts, a\\:spcPts");e?t.spaceAfterPct=parseInt(e.getAttribute("val"))/1e5:r&&(t.spaceAfter=127*parseInt(r.getAttribute("val")))}let l=e.getAttribute("marL")||e.getAttribute("leftMargin");l&&(t.leftMargin=parseInt(l)||0);let s=e.getAttribute("marR")||e.getAttribute("rightMargin");s&&(t.rightMargin=parseInt(s)||0);let n=e.getAttribute("indent");n&&(t.indent=parseInt(n)||0);let h=e.querySelector("buChar, a\\:buChar");if(h){let e=h.getAttribute("char");e&&(t.bullet={type:"character",char:e})}let c=e.querySelector("buAutoNum, a\\:buAutoNum");if(c){let e=c.getAttribute("type")||"arabicPeriod",r=c.getAttribute("startAt")||"1";t.bullet={type:"autoNumber",subType:e,startAt:parseInt(r)}}e.querySelector("buNone, a\\:buNone")&&(t.bullet={type:"none"})}catch(e){}return t}parseStyleRunProperties(e){let t={};if(!e)return t;try{let r=e.getAttribute("sz")||e.getAttribute("fontSize");if(r){let e=parseInt(r);t.fontSize=e>100?e/100:e}let i=e.getAttribute("typeface")||e.getAttribute("fontFamily");i&&(t.fontFamily=i);let a=e.getAttribute("b")||e.getAttribute("bold");null!==a&&(t.bold="1"===a||"true"===a||!0===a);let o=e.getAttribute("i")||e.getAttribute("italic");null!==o&&(t.italic="1"===o||"true"===o||!0===o);let l=e.getAttribute("u")||e.getAttribute("underline");null!==l&&(t.underline="none"!==l&&""!==l&&"0"!==l&&"false"!==l);let s=e.getAttribute("strike")||e.getAttribute("strikethrough");null!==s&&(t.strike="noStrike"!==s&&"0"!==s&&"false"!==s&&!1!==s);let n=e.getAttribute("cap")||e.getAttribute("capitalization");n&&(t.cap=n);let h=e.querySelector("solidFill, a\\:solidFill")||e.querySelector("schemeClr, a\\:schemeClr")||e.querySelector("srgbClr, a\\:srgbClr");h&&(t.color=this.parseColorFromElement(h));let c=e.getAttribute("spc")||e.getAttribute("letterSpacing");c&&(t.letterSpacing=parseInt(c)||0)}catch(e){}return t}parseColorFromElement(e){try{let t=e.querySelector("srgbClr, a\\:srgbClr");if(t){let e=t.getAttribute("val");if(e&&6===e.length){let t=parseInt(e.substr(0,2),16),r=parseInt(e.substr(2,2),16),i=parseInt(e.substr(4,2),16);return{r:t,g:r,b:i,a:255}}}let r=e.querySelector("schemeClr, a\\:schemeClr");if(r)return({})[r.getAttribute("val")]||null}catch(e){}return null}buildSlideContext(){let e={};return this.currentSlide&&(e.slide=this.currentSlide,(this.currentSlide.layout||this.currentSlide.Layout)&&(e.layout=this.currentSlide.layout||this.currentSlide.Layout,e.layout.commonSlideData&&e.layout.commonSlideData.shapeTree?e.layout.shapes=e.layout.commonSlideData.shapeTree:e.layout.cSld&&e.layout.cSld.spTree&&(e.layout.shapes=e.layout.cSld.spTree),(e.layout.master||e.layout.Master)&&(e.master=e.layout.master||e.layout.Master)),(this.currentSlide.theme||this.currentSlide.Theme)&&(e.theme=this.currentSlide.theme||this.currentSlide.Theme)),e}getCurrentShape(){return this.currentRenderingShape||null}applyPreciseTransform(e,t=1,r=0){return Math.round(e*t+r)}setCurrentRenderingShape(e){this.currentRenderingShape=e}}class i{constructor(){this.cache=new Map}processShapeGeometry(e){let t=this.generateCacheKey(e);if(this.cache.has(t))return this.cache.get(t);let r=null;return e.geometry&&"custom"===e.geometry.type?r=this.processCustomGeometry(e.geometry):e.properties&&e.properties.geometry&&"custom"===e.properties.geometry.type&&(r=this.processCustomGeometry(e.properties.geometry)),r&&this.cache.set(t,r),r}processCustomGeometry(e){if(!e.pathLst||0===e.pathLst.length)return null;let t={type:"custom",pathLst:[]};for(let r of e.pathLst){let e=this.processPath(r);e&&t.pathLst.push(e)}return t}processPath(e){return e.commands&&0!==e.commands.length?{w:e.w||100,h:e.h||100,commands:e.commands.map(e=>this.normalizeCommand(e)),fill:!1!==e.fill,stroke:!1!==e.stroke}:null}normalizeCommand(e){let t={...e};switch(e.type){case"M":case"moveTo":t.type="moveTo";break;case"L":case"lineTo":t.type="lineTo";break;case"C":case"curveTo":case"cubicBezTo":t.type="cubicBezTo";break;case"Q":case"quadTo":case"quadBezTo":t.type="quadBezTo";break;case"A":case"arcTo":t.type="arcTo";break;case"Z":case"close":t.type="close"}return t}generateCacheKey(e){let t=e.geometry||e.properties?.geometry;if(!t)return"no-geometry";let r=t.pathLst||[];return`custom-${JSON.stringify(r).substring(0,100)}-${r.length}`}}if("u">typeof window){window.CanvasGraphicsAdapter=t,window.CDrawingDocument=r,window.GraphicsMatrix=e;try{void 0===t||t.prototype.drawLineWithArrows||(t.prototype.drawLineWithArrows=function(e,t,r,i,a,o=1,l=null){let s=this._context;if(!s)return;s.save(),s.beginPath(),s.moveTo(e,t),s.lineTo(r,i);let n=("function"==typeof this.colorToRgb?this.colorToRgb(a):null)||"rgba(0,0,0,1)",h=Math.max(CoordinateTransform.mmToPixels(o||1),1);if(s.strokeStyle=n,s.lineWidth=h,l&&l.dashArray&&l.dashArray.length>0){let e=l.dashArray.map(e=>e*h);s.setLineDash(e)}if(l&&"function"==typeof this.applyStrokeStyle)try{this.applyStrokeStyle(s,l,h)}catch(e){}s.stroke();let c=e=>{if("number"==typeof e)return e;let t=(e||"").toString().toLowerCase();return"lg"===t||"large"===t?3:"med"===t||"medium"===t?2:"sm"===t||"small"===t?1:2},u=l&&l.headEnd,d=l&&l.tailEnd,p=u&&u.type,g=d&&d.type,f=!!(u&&p&&"none"!==p),m=!!(d&&g&&"none"!==g);if(f||m){let a=Math.atan2(i-t,r-e),o=s.getTransform();o.a,o.a,o.b,o.b;let l=3*h,p=2.5*h,g=(e,t,r,i)=>{if(!i)return;let a=i.lengthScale||c(i.len),o=i.widthScale||c(i.w),u=l*a,d=(i.type||i.val||"arrow").toString().toLowerCase(),g=p*o/2;s.save(),s.translate(e,t),s.rotate(r),s.beginPath(),"open"===d?(s.moveTo(0,0),s.lineTo(-u,-g),s.moveTo(0,0),s.lineTo(-u,g),s.strokeStyle=n,s.lineWidth=Math.max(1,h)):("stealth"===d?(s.moveTo(0,0),s.lineTo(-u,-(.5*g)),s.lineTo(-(.85*u),0),s.lineTo(-u,.5*g),s.closePath()):"diamond"===d?(s.moveTo(0,0),s.lineTo(-u/2,-g),s.lineTo(-u,0),s.lineTo(-u/2,g),s.closePath()):"oval"===d?s.ellipse(-u/2,0,u/2,g,0,0,2*Math.PI):(s.moveTo(0,0),s.lineTo(-u,-g),s.lineTo(-u,g),s.closePath()),s.fillStyle=n,s.fill(),s.strokeStyle=n,s.lineWidth=Math.max(.5,.3*h)),s.stroke(),s.restore()};f&&g(e,t,a+Math.PI,u),m&&g(r,i,a,d)}s.restore()})}catch(e){}}"u"<typeof Logger&&"u">typeof window&&(window.Logger=class{constructor(e){this.name=e}log(e,t,r){}logError(e,t){}})}}();var A={exports:{}};A.exports,p||(p=1,function(e){let t={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};class r{constructor(e){this.setupHighResolutionCanvas(e),this.m_oContext=e.getContext("2d"),this.m_dDpiX=96,this.m_dDpiY=96,this.m_dWidthMM=210,this.m_dHeightMM=297,e.style.width&&e.style.height?(this.m_dWidth=parseFloat(e.style.width),this.m_dHeight=parseFloat(e.style.height)):(this.m_dWidth=e.width/(window.devicePixelRatio||1),this.m_dHeight=e.height/(window.devicePixelRatio||1)),this.m_oTransform=new a,this.devicePixelRatio=window.devicePixelRatio||1,this.m_oCoordTransform=new a,this.m_oFullTransform=new a,this.m_oTransformStack=[],this.m_oClipStack=[],this.m_oPen=new o,this.m_oBrush=new l,this.m_oFont=new s,this.m_bIntegerGrid=!1,this.m_bGlobalAlpha=!1,this.m_dGlobalAlpha=1,this.m_bIsClipping=!1,this.m_oClipRect=null,this.m_oPath=null,this.m_bIsDrawing=!1,this.m_oEnhancedGeometryProcessor=new c,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(e){let t=e.getContext("2d"),r=window.devicePixelRatio||1,i=e.clientWidth||e.width,a=e.clientHeight||e.height;e.width=i*r,e.height=a*r,e.style.width=i+"px",e.style.height=a+"px",t.scale(r,r),t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high"}drawImageHighRes(e,t,r,i,a,o=0,l=0,s=null,n=null){if(this.m_oContext&&e){this.m_oContext.save(),this.m_oContext.imageSmoothingEnabled=!0,this.m_oContext.imageSmoothingQuality="high";try{null!==s&&null!==n?this.m_oContext.drawImage(e,o,l,s,n,t,r,i,a):this.m_oContext.drawImage(e,t,r,i,a)}catch(e){}finally{this.m_oContext.restore()}}}drawImage(e,t,r,i,a){this.drawImageHighRes(e,t,r,i,a)}drawPresetGeometry(e,r,i,a,o,l,s,n=1,h=null,c={}){if(this.m_oContext){this.SaveGrState();try{let u=t[e]||1e3;1e3===u?this.drawCustomShape(e,r,i,a,o,l,s,n,h,c):this.drawStandardPresetShape(u,e,r,i,a,o,l,s,n,h,c)}catch(e){this.drawRectangle(r,i,a,o,l,s,n,h)}finally{this.RestoreGrState()}}}drawStandardPresetShape(e,t,r,i,a,o,l,s,n,h,c){let u=this.m_oEnhancedGeometryProcessor.processPresetGeometry(t,21600,21600,c);u?this.renderEnhancedGeometry(u,r,i,a,o,l,s,n,h):this.drawBasicShape(t,r,i,a,o,l,s,n,h)}renderEnhancedGeometry(e,t,r,i,a,o,l,s,n){let h=this.m_oContext,c=e.getPathList(),u=i/e.width,d=a/e.height;h.save(),h.translate(t,r),h.scale(u,d),c.forEach(h=>{this.renderEnhancedPath(h,e,o,l,s,n,{x:t,y:r,w:i,h:a})}),h.restore()}renderEnhancedPath(e,t,r,i,a,o,l=null){let s=this.m_oContext;if(s.beginPath(),e.commands.forEach(e=>{switch(e.type){case"M":s.moveTo(e.args[0],e.args[1]);break;case"L":s.lineTo(e.args[0],e.args[1]);break;case"C":s.bezierCurveTo(e.args[0],e.args[1],e.args[2],e.args[3],e.args[4],e.args[5]);break;case"Q":s.quadraticCurveTo(e.args[0],e.args[1],e.args[2],e.args[3]);break;case"A":this.renderArcCommand(s,e.args);break;case"Z":s.closePath()}}),"none"!==e.fill&&r){if(r&&"object"==typeof r&&r.type&&r.stops){let e=l||{x:0,y:0,w:200,h:50},t=this.createGradient(e.x,e.y,e.w,e.h,r);t?s.fillStyle=t:s.fillStyle=this.colorToRgb(r.stops[0]?.color||{r:0,g:0,b:0})}else s.fillStyle=this.colorToRgb(r);s.fill()}if(e.stroke&&i){s.strokeStyle=this.colorToRgb(i);let e=CoordinateTransform.mmToPixels(a||1),r=t?t.width:21600,n=t?t.height:21600;s.lineWidth=e/(Math.min(l&&l.w>0?l.w/r:1,l&&l.h>0?l.h/n:1)||1),o&&this.applyStrokeInfo(o),s.stroke()}}renderArcCommand(e,t){let[r,i,a,o,l,s,n]=t,h=this.getCurrentPoint(e);if(h)try{let t=(h.x+s)/2,a=(h.y+n)/2,o=Math.min(r,i),c=Math.atan2(h.y-a,h.x-t),u=Math.atan2(n-a,s-t);e.arc(t,a,o,c,u,!l)}catch(t){e.lineTo(s,n)}}getCurrentPoint(e){return{x:0,y:0}}drawCustomShape(e,t,r,i,a,o,l,s,n,h){let c=this.m_oCustomGeometryProcessor.processCustomShape(e,{x:t,y:r,width:i,height:a,adjustments:h});c&&c.pathLst?this.drawCustomGeometry(c,t,r,i,a,o,l,s):this.drawBasicShape(e,t,r,i,a,o,l,s,n)}applyStrokeInfo(e){if(!e||!this.m_oContext)return;let t=this.m_oContext;if(e.dashArray&&e.dashArray.length>0){let r=t.lineWidth||1,i=e.dashArray.map(e=>e*r);t.setLineDash(i)}let r=e.lineCap||e.cap;if(r)switch(r){case"rnd":case"round":t.lineCap="round";break;case"sq":case"square":t.lineCap="square";break;default:t.lineCap="butt"}let i=e.lineJoin||e.join;if(i)switch(i){case"round":t.lineJoin="round";break;case"bevel":t.lineJoin="bevel";break;default:t.lineJoin="miter"}e.miterLimit&&(t.miterLimit=e.miterLimit)}drawBasicShape(e,t,r,i,a,o,l,s,n){let h=this.m_oContext;switch(h.save(),h.beginPath(),e){case"rect":case"rectangle":default:h.rect(t,r,i,a);break;case"ellipse":case"oval":h.ellipse(t+i/2,r+a/2,i/2,a/2,0,0,2*Math.PI);break;case"roundRect":this.drawRoundRectPath(h,t,r,i,a,.16667*Math.min(i,a));break;case"triangle":this.drawTrianglePath(h,t,r,i,a);break;case"diamond":this.drawDiamondPath(h,t,r,i,a);break;case"pentagon":this.drawPentagonPath(h,t,r,i,a);break;case"hexagon":this.drawHexagonPath(h,t,r,i,a);break;case"octagon":this.drawOctagonPath(h,t,r,i,a);break;case"star":case"star5":this.drawStarPath(h,t,r,i,a);break;case"rightArrow":this.drawRightArrowPath(h,t,r,i,a);break;case"leftArrow":this.drawLeftArrowPath(h,t,r,i,a);break;case"upArrow":this.drawUpArrowPath(h,t,r,i,a);break;case"downArrow":this.drawDownArrowPath(h,t,r,i,a)}o&&(h.fillStyle=this.colorToRgb(o),h.fill()),l&&(h.strokeStyle=this.colorToRgb(l),h.lineWidth=CoordinateTransform.mmToPixels(s||1),n&&this.applyStrokeInfo(n),h.stroke()),h.restore()}drawCustomGeometry(e,t,r,i,a,o,l,s){try{if(!e||!e.pathLst||0===e.pathLst.length)return;this.m_oContext.save(),this.m_oContext.translate(t,r);let n=e.coordSize?.width||1e3,h=e.coordSize?.height||1e3;this.m_oContext.scale(i/n,a/h),e.pathLst.forEach((e,t)=>{this.drawGeometryPath(e,o,l,s)}),this.m_oContext.restore()}catch(e){this.m_oContext.restore()}}drawGeometryPath(e,t,r,i){e&&e.commands&&0!==e.commands.length&&(this.m_oContext.beginPath(),e.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":t&&!1!==e.fill&&"none"!==e.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)}}),r&&!1!==e.stroke&&(this.m_oContext.strokeStyle=this.colorToRgb(r),this.m_oContext.lineWidth=CoordinateTransform.mmToPixels(i||1),this.m_oContext.stroke()),t&&!1!==e.fill&&"none"!==e.fill&&(this.m_oContext.fillStyle=this.colorToRgb(t),this.m_oContext.fill()))}drawShapePath(e,t,r,i,a){e&&e.commands&&(this.m_oContext.beginPath(),e.commands.forEach(e=>{switch(e.type){case"M":this.m_oContext.moveTo(e.x,e.y);break;case"L":this.m_oContext.lineTo(e.x,e.y);break;case"C":this.m_oContext.bezierCurveTo(e.x1,e.y1,e.x2,e.y2,e.x,e.y);break;case"Q":this.m_oContext.quadraticCurveTo(e.x1,e.y1,e.x,e.y);break;case"A":this.drawArcCommand(e);break;case"Z":t&&!1!==path.fill&&"none"!==path.fill&&this.m_oContext.closePath()}}),t&&(this.m_oContext.fillStyle=this.colorToRgb(t),this.m_oContext.fill()),r&&(this.m_oContext.strokeStyle=this.colorToRgb(r),this.m_oContext.lineWidth=i||1,a&&this.applyStrokeInfo(a),this.m_oContext.stroke()))}applyStrokeInfoAlternative(e){e&&(e.dashArray&&e.dashArray.length>0&&this.m_oContext.setLineDash(e.dashArray),e.lineCap&&(this.m_oContext.lineCap=e.lineCap),e.lineJoin&&(this.m_oContext.lineJoin=e.lineJoin),e.miterLimit&&(this.m_oContext.miterLimit=e.miterLimit))}drawArcCommand(e){let t=e.cx||e.x,r=e.cy||e.y,i=e.r||e.radius,a=e.startAngle||0,o=e.endAngle||2*Math.PI,l=e.counterclockwise||!1;this.m_oContext.arc(t,r,i,a,o,l)}drawRectangle(e,t,r,i,a,o,l,s){if(this.m_oContext){if(this.m_oContext.save(),a){if("object"==typeof a&&a.type&&a.stops){let o=this.createGradient(e,t,r,i,a);this.m_oContext.fillStyle=o||this.colorToRgb(a.stops[0]?.color||{r:0,g:0,b:0})}else this.m_oContext.fillStyle=this.colorToRgb(a);this.m_oContext.fillRect(e,t,r,i)}o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,s&&this.applyStrokeInfo(s),this.m_oContext.strokeRect(e,t,r,i)),this.m_oContext.restore()}}drawEllipse(e,t,r,i,a,o,l){this.m_oContext&&(this.m_oContext.save(),this.m_oContext.beginPath(),this.m_oContext.ellipse(e+r/2,t+i/2,r/2,i/2,0,0,2*Math.PI),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.stroke()),this.m_oContext.restore())}drawRoundedRectangle(e,t,r,i,a,o,l,s){this.m_oContext&&(this.m_oContext.save(),this.m_oContext.beginPath(),a=Math.min(a,Math.min(r,i)/2),this.m_oContext.moveTo(e+a,t),this.m_oContext.lineTo(e+r-a,t),this.m_oContext.quadraticCurveTo(e+r,t,e+r,t+a),this.m_oContext.lineTo(e+r,t+i-a),this.m_oContext.quadraticCurveTo(e+r,t+i,e+r-a,t+i),this.m_oContext.lineTo(e+a,t+i),this.m_oContext.quadraticCurveTo(e,t+i,e,t+i-a),this.m_oContext.lineTo(e,t+a),this.m_oContext.quadraticCurveTo(e,t,e+a,t),this.m_oContext.closePath(),o&&(this.m_oContext.fillStyle=this.colorToRgb(o),this.m_oContext.fill()),l&&(this.m_oContext.strokeStyle=this.colorToRgb(l),this.m_oContext.lineWidth=s||1,this.m_oContext.stroke()),this.m_oContext.restore())}drawTriangle(e,t,r,i,a,o,l){this.m_oContext&&(this.m_oContext.save(),this.m_oContext.beginPath(),this.m_oContext.moveTo(e+r/2,t),this.m_oContext.lineTo(e+r,t+i),this.m_oContext.lineTo(e,t+i),this.m_oContext.closePath(),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.stroke()),this.m_oContext.restore())}drawDiamond(e,t,r,i,a,o,l){if(!this.m_oContext)return;this.m_oContext.save(),this.m_oContext.beginPath();let s=e+r/2,n=t+i/2;this.m_oContext.moveTo(s,t),this.m_oContext.lineTo(e+r,n),this.m_oContext.lineTo(s,t+i),this.m_oContext.lineTo(e,n),this.m_oContext.closePath(),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.stroke()),this.m_oContext.restore()}drawRegularPolygon(e,t,r,i,a,o,l,s){if(!this.m_oContext||a<3)return;this.m_oContext.save(),this.m_oContext.beginPath();let n=e+r/2,h=t+i/2,c=Math.min(r,i)/2;for(let e=0;e<a;e++){let t=2*e*Math.PI/a-Math.PI/2,r=n+c*Math.cos(t),i=h+c*Math.sin(t);0===e?this.m_oContext.moveTo(r,i):this.m_oContext.lineTo(r,i)}this.m_oContext.closePath(),o&&(this.m_oContext.fillStyle=this.colorToRgb(o),this.m_oContext.fill()),l&&(this.m_oContext.strokeStyle=this.colorToRgb(l),this.m_oContext.lineWidth=s||1,this.m_oContext.stroke()),this.m_oContext.restore()}drawStar(e,t,r,i,a,o,l,s){if(!this.m_oContext||a<3)return;this.m_oContext.save(),this.m_oContext.beginPath();let n=e+r/2,h=t+i/2,c=Math.min(r,i)/2,u=.4*c;for(let e=0;e<2*a;e++){let t=e*Math.PI/a-Math.PI/2,r=e%2==0?c:u,i=n+r*Math.cos(t),o=h+r*Math.sin(t);0===e?this.m_oContext.moveTo(i,o):this.m_oContext.lineTo(i,o)}this.m_oContext.closePath(),o&&(this.m_oContext.fillStyle=this.colorToRgb(o),this.m_oContext.fill()),l&&(this.m_oContext.strokeStyle=this.colorToRgb(l),this.m_oContext.lineWidth=s||1,this.m_oContext.stroke()),this.m_oContext.restore()}drawRightArrow(e,t,r,i,a,o,l){if(!this.m_oContext)return;this.m_oContext.save(),this.m_oContext.beginPath();let s=.7*r,n=.4*i,h=.6*i;this.m_oContext.moveTo(e,t+(i-n)/2),this.m_oContext.lineTo(e+s,t+(i-n)/2),this.m_oContext.lineTo(e+s,t+(i-h)/2),this.m_oContext.lineTo(e+r,t+i/2),this.m_oContext.lineTo(e+s,t+(i+h)/2),this.m_oContext.lineTo(e+s,t+(i+n)/2),this.m_oContext.lineTo(e,t+(i+n)/2),this.m_oContext.closePath(),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.stroke()),this.m_oContext.restore()}drawLeftArrow(e,t,r,i,a,o,l){if(!this.m_oContext)return;this.m_oContext.save(),this.m_oContext.beginPath();let s=.4*i,n=.3*r,h=.6*i;this.m_oContext.moveTo(e,t+i/2),this.m_oContext.lineTo(e+n,t+(i-h)/2),this.m_oContext.lineTo(e+n,t+(i-s)/2),this.m_oContext.lineTo(e+r,t+(i-s)/2),this.m_oContext.lineTo(e+r,t+(i+s)/2),this.m_oContext.lineTo(e+n,t+(i+s)/2),this.m_oContext.lineTo(e+n,t+(i+h)/2),this.m_oContext.closePath(),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.stroke()),this.m_oContext.restore()}drawHeart(e,t,r,i,a,o,l){if(!this.m_oContext)return;this.m_oContext.save(),this.m_oContext.beginPath();let s=e+r/2,n=t+.3*i;this.m_oContext.moveTo(s,n),this.m_oContext.bezierCurveTo(s-.3*r,t,e,t+.3*i,s,t+.8*i),this.m_oContext.bezierCurveTo(e+r,t+.3*i,s+.3*r,t,s,n),this.m_oContext.closePath(),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.stroke()),this.m_oContext.restore()}drawTeardrop(e,t,r,i,a,o,l){if(!this.m_oContext)return;this.m_oContext.save(),this.m_oContext.beginPath();let s=e+r/2,n=t+.7*i,h=.3*Math.min(r,i);this.m_oContext.arc(s,n,h,0,2*Math.PI),this.m_oContext.moveTo(s,n-h),this.m_oContext.quadraticCurveTo(s-.5*h,t+.2*i,s,t),this.m_oContext.quadraticCurveTo(s+.5*h,t+.2*i,s,n-h),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.stroke()),this.m_oContext.restore()}drawCylinder(e,t,r,i,a,o,l){if(!this.m_oContext)return;this.m_oContext.save();let s=.15*i,n=r/2,h=s/2,c=e+r/2;a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fillRect(e,t+h,r,i-s)),this.m_oContext.beginPath(),this.m_oContext.ellipse(c,t+h,n,h,0,0,2*Math.PI),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),this.m_oContext.beginPath(),this.m_oContext.ellipse(c,t+i-h,n,h,0,0,2*Math.PI),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.beginPath(),this.m_oContext.moveTo(e,t+h),this.m_oContext.lineTo(e,t+i-h),this.m_oContext.moveTo(e+r,t+h),this.m_oContext.lineTo(e+r,t+i-h),this.m_oContext.stroke(),this.m_oContext.beginPath(),this.m_oContext.ellipse(c,t+h,n,h,0,0,2*Math.PI),this.m_oContext.stroke(),this.m_oContext.beginPath(),this.m_oContext.ellipse(c,t+i-h,n,h,0,0,2*Math.PI),this.m_oContext.stroke()),this.m_oContext.restore()}drawCube(e,t,r,i,a,o,l){if(!this.m_oContext)return;this.m_oContext.save();let s=.3*Math.min(r,i);if(a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fillRect(e,t+s,r-s,i-s)),this.m_oContext.beginPath(),this.m_oContext.moveTo(e,t+s),this.m_oContext.lineTo(e+s,t),this.m_oContext.lineTo(e+r,t),this.m_oContext.lineTo(e+r-s,t+s),this.m_oContext.closePath(),a){let e=this.darkenColor(a,.8);this.m_oContext.fillStyle=this.colorToRgb(e),this.m_oContext.fill()}if(this.m_oContext.beginPath(),this.m_oContext.moveTo(e+r-s,t+s),this.m_oContext.lineTo(e+r,t),this.m_oContext.lineTo(e+r,t+i-s),this.m_oContext.lineTo(e+r-s,t+i),this.m_oContext.closePath(),a){let e=this.darkenColor(a,.6);this.m_oContext.fillStyle=this.colorToRgb(e),this.m_oContext.fill()}o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.strokeRect(e,t+s,r-s,i-s),this.m_oContext.beginPath(),this.m_oContext.moveTo(e,t+s),this.m_oContext.lineTo(e+s,t),this.m_oContext.lineTo(e+r,t),this.m_oContext.lineTo(e+r-s,t+s),this.m_oContext.closePath(),this.m_oContext.stroke(),this.m_oContext.beginPath(),this.m_oContext.moveTo(e+r-s,t+s),this.m_oContext.lineTo(e+r,t),this.m_oContext.lineTo(e+r,t+i-s),this.m_oContext.lineTo(e+r-s,t+i),this.m_oContext.closePath(),this.m_oContext.stroke(),this.m_oContext.beginPath(),this.m_oContext.moveTo(e,t+s),this.m_oContext.lineTo(e+s,t),this.m_oContext.moveTo(e+r-s,t+s),this.m_oContext.lineTo(e+r,t),this.m_oContext.moveTo(e+r-s,t+i),this.m_oContext.lineTo(e+r,t+i-s),this.m_oContext.stroke()),this.m_oContext.restore()}drawPlus(e,t,r,i,a,o,l){if(!this.m_oContext)return;this.m_oContext.save(),this.m_oContext.beginPath();let s=.3*Math.min(r,i),n=e+r/2,h=t+i/2;this.m_oContext.moveTo(e,h-s/2),this.m_oContext.lineTo(e+r,h-s/2),this.m_oContext.lineTo(e+r,h+s/2),this.m_oContext.lineTo(e,h+s/2),this.m_oContext.closePath(),this.m_oContext.moveTo(n-s/2,t),this.m_oContext.lineTo(n+s/2,t),this.m_oContext.lineTo(n+s/2,t+i),this.m_oContext.lineTo(n-s/2,t+i),this.m_oContext.closePath(),a&&(this.m_oContext.fillStyle=this.colorToRgb(a),this.m_oContext.fill()),o&&(this.m_oContext.strokeStyle=this.colorToRgb(o),this.m_oContext.lineWidth=l||1,this.m_oContext.stroke()),this.m_oContext.restore()}drawLine(e,t,r,i,a,o){if(!this.m_oContext)return;this.m_oContext.save(),this.m_oContext.beginPath(),this.m_oContext.moveTo(e,t),this.m_oContext.lineTo(r,i);let l=this.colorToRgb(a)||"rgba(0,0,0,1)";this.m_oContext.strokeStyle=l;let s=CoordinateTransform.mmToPixels(o||1);this.m_oContext.lineWidth=s,this.m_oContext.stroke(),this.m_oContext.restore()}drawLineWithArrows(e,t,r,i,a,o=1,l=null){if(!this.m_oContext)return;let s=this.m_oContext;s.save(),s.beginPath(),s.moveTo(e,t),s.lineTo(r,i);let n=this.colorToRgb(a)||"rgba(0,0,0,1)";s.strokeStyle=n,s.lineWidth=Math.max(CoordinateTransform.mmToPixels(o||1),1),l&&this.applyStrokeInfo(l),s.stroke();let h=e=>{let t=(e||"").toString().toLowerCase();return"lg"===t||"large"===t?3:"med"===t||"medium"===t?2:"sm"===t||"small"===t?1:2},c=l&&l.headEnd?{type:l.headEnd.type||l.headEnd.val||"none",lengthScale:h(l.headEnd.len),widthScale:h(l.headEnd.w)}:null,u=l&&l.tailEnd?{type:l.tailEnd.type||l.tailEnd.val||"none",lengthScale:h(l.tailEnd.len),widthScale:h(l.tailEnd.w)}:null;if(c&&("none"===c.type||null===c.type||void 0===c.type)&&(c=null),u&&("none"===u.type||null===u.type||void 0===u.type)&&(u=null),c||u){let a=Math.atan2(i-t,r-e),o=s.getTransform();o.a,o.a,o.b,o.b;let l=3*s.lineWidth,h=2.5*s.lineWidth;if(c){let r=c.lengthScale||1,i=c.widthScale||1;this._drawArrowHead(s,e,t,a+Math.PI,l*r,h*i,n,s.lineWidth,c.type)}if(u){let e=u.lengthScale||1,t=u.widthScale||1;this._drawArrowHead(s,r,i,a,l*e,h*t,n,s.lineWidth,u.type)}}s.restore()}_drawArrowHead(e,t,r,i,a,o,l,s,n="triangle"){e.save(),e.translate(t,r),e.rotate(i);let h=o/2,c=(n||"triangle").toString().toLowerCase();switch(e.beginPath(),c){case"open":e.moveTo(0,0),e.lineTo(-a,-h),e.moveTo(0,0),e.lineTo(-a,h);break;case"stealth":e.moveTo(0,0),e.lineTo(-a,-(.5*h)),e.lineTo(-(.85*a),0),e.lineTo(-a,.5*h),e.closePath();break;case"diamond":e.moveTo(0,0),e.lineTo(-a/2,-h),e.lineTo(-a,0),e.lineTo(-a/2,h),e.closePath();break;case"oval":e.ellipse(-a/2,0,a/2,h,0,0,2*Math.PI);break;default:e.moveTo(0,0),e.lineTo(-a,-h),e.lineTo(-a,h),e.closePath()}let u="string"==typeof l?l:this.colorToRgb(l)||"rgba(0,0,0,1)";"open"===c?(e.strokeStyle=u,e.lineWidth=s||1):(e.fillStyle=u,e.fill(),e.strokeStyle=u,e.lineWidth=Math.max(.5,.3*(s||1))),e.stroke(),e.restore()}darkenColor(e,t){if("string"==typeof e){let r=this.hexToRgb(e);return{r:Math.floor(r.r*t),g:Math.floor(r.g*t),b:Math.floor(r.b*t),a:r.a}}return void 0!==e.r?{r:Math.floor(e.r*t),g:Math.floor(e.g*t),b:Math.floor(e.b*t),a:e.a}:e}colorToRgb(e){if("string"==typeof e)return e;if(e&&void 0!==e.r){let t=void 0!==e.a?e.a/255:1;return`rgba(${e.r}, ${e.g}, ${e.b}, ${t})`}return null}createGradient(e,t,r,i,a){let o;if(!this.m_oContext||!a||!a.stops||0===a.stops.length)return null;if("linear"===a.type){let l=(a.angle||0)*Math.PI/180,s=e+r/2-Math.cos(l)*r/2,n=t+i/2-Math.sin(l)*i/2,h=e+r/2+Math.cos(l)*r/2,c=t+i/2+Math.sin(l)*i/2;o=this.m_oContext.createLinearGradient(s,n,h,c)}else{let a=e+r/2,l=t+i/2,s=Math.max(r,i)/2;o=this.m_oContext.createRadialGradient(a,l,0,a,l,s)}for(let e of a.stops)o.addColorStop(e.position,this.colorToRgb(e.color));return o}fillRect(e,t,r,i,a){if(this.m_oContext&&a){if(this.m_oContext.save(),a&&"object"==typeof a&&"linear"===a.type&&a.stops){let o=this.createGradient(e,t,r,i,a);o?this.m_oContext.fillStyle=o:this.m_oContext.fillStyle=this.colorToRgb(a.stops[0]?.color||{r:0,g:0,b:0})}else this.m_oContext.fillStyle=this.colorToRgb(a);this.m_oContext.fillRect(e,t,r,i),this.m_oContext.restore()}}hexToRgb(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[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(),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(e,t,r,i,a,o){e.beginPath(),e.moveTo(t+o,r),e.lineTo(t+i-o,r),e.quadraticCurveTo(t+i,r,t+i,r+o),e.lineTo(t+i,r+a-o),e.quadraticCurveTo(t+i,r+a,t+i-o,r+a),e.lineTo(t+o,r+a),e.quadraticCurveTo(t,r+a,t,r+a-o),e.lineTo(t,r+o),e.quadraticCurveTo(t,r,t+o,r)}drawTrianglePath(e,t,r,i,a){e.moveTo(t+i/2,r),e.lineTo(t+i,r+a),e.lineTo(t,r+a),e.closePath()}drawDiamondPath(e,t,r,i,a){e.moveTo(t+i/2,r),e.lineTo(t+i,r+a/2),e.lineTo(t+i/2,r+a),e.lineTo(t,r+a/2),e.closePath()}drawPentagonPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.moveTo(o,r);for(let t=1;t<5;t++){let r=2*t*Math.PI/5-Math.PI/2,i=o+s*Math.cos(r),a=l+s*Math.sin(r);e.lineTo(i,a)}e.closePath()}drawHexagonPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.moveTo(o+s,l);for(let t=1;t<6;t++){let r=t*Math.PI/3,i=o+s*Math.cos(r),a=l+s*Math.sin(r);e.lineTo(i,a)}e.closePath()}drawOctagonPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2;e.moveTo(o+s,l);for(let t=1;t<8;t++){let r=t*Math.PI/4,i=o+s*Math.cos(r),a=l+s*Math.sin(r);e.lineTo(i,a)}e.closePath()}drawStarPath(e,t,r,i,a){let o=t+i/2,l=r+a/2,s=Math.min(i,a)/2,n=.4*s;e.moveTo(o,r);for(let t=0;t<10;t++){let r=t*Math.PI/5-Math.PI/2,i=t%2==0?s:n,a=o+i*Math.cos(r),h=l+i*Math.sin(r);e.lineTo(a,h)}e.closePath()}drawRightArrowPath(e,t,r,i,a){let o=.6*i,l=.6*a,s=r+(a-l)/2;e.moveTo(t,s),e.lineTo(t+o,s),e.lineTo(t+o,r),e.lineTo(t+i,r+a/2),e.lineTo(t+o,r+a),e.lineTo(t+o,s+l),e.lineTo(t,s+l),e.closePath()}drawLeftArrowPath(e,t,r,i,a){let o=.4*i,l=.6*a,s=r+(a-l)/2;e.moveTo(t,r+a/2),e.lineTo(t+o,r),e.lineTo(t+o,s),e.lineTo(t+i,s),e.lineTo(t+i,s+l),e.lineTo(t+o,s+l),e.lineTo(t+o,r+a),e.closePath()}drawUpArrowPath(e,t,r,i,a){let o=.4*a,l=.6*i,s=t+(i-l)/2;e.moveTo(t+i/2,r),e.lineTo(t+i,r+o),e.lineTo(s+l,r+o),e.lineTo(s+l,r+a),e.lineTo(s,r+a),e.lineTo(s,r+o),e.lineTo(t,r+o),e.closePath()}drawDownArrowPath(e,t,r,i,a){let o=.6*i,l=t+(i-o)/2,s=r+a-.4*a;e.moveTo(l,r),e.lineTo(l+o,r),e.lineTo(l+o,s),e.lineTo(t+i,s),e.lineTo(t+i/2,r+a),e.lineTo(t,s),e.lineTo(l,s),e.closePath()}}class i{constructor(){this.shapeCache=new Map,this.pathCache=new Map}processPresetShape(e,t,r){let i=`${e}_${t}_${r.width}_${r.height}`;if(this.shapeCache.has(i))return this.shapeCache.get(i);let a=null;switch(e){case 1:a=this.createRectangleShape(r);break;case 2:a=this.createRoundRectShape(r);break;case 3:a=this.createEllipseShape(r);break;case 4:a=this.createDiamondShape(r);break;case 5:a=this.createTriangleShape(r);break;case 6:a=this.createRightTriangleShape(r);break;case 7:a=this.createParallelogramShape(r);break;case 8:a=this.createTrapezoidShape(r);break;case 9:a=this.createHexagonShape(r);break;case 10:a=this.createOctagonShape(r);break;case 11:a=this.createPlusShape(r);break;case 12:a=this.createStar5Shape(r);break;case 13:a=this.createRightArrowShape(r);break;case 20:a=this.createLineShape(r);break;case 22:a=this.createCylinderShape(r);break;case 56:a=this.createPentagonShape(r);break;case 66:a=this.createLeftArrowShape(r);break;case 67:a=this.createDownArrowShape(r);break;case 68:a=this.createUpArrowShape(r);break;case 69:a=this.createLeftRightArrowShape(r);break;case 70:a=this.createUpDownArrowShape(r);break;case 74:a=this.createHeartShape(r);break;case 76:a=this.createQuadArrowShape(r);break;default:return null}return a&&this.shapeCache.set(i,a),a}createRectangleShape(e){return{type:"preset",onlyOfficeType:1,path:{commands:[{type:"M",x:e.x,y:e.y},{type:"L",x:e.x+e.width,y:e.y},{type:"L",x:e.x+e.width,y:e.y+e.height},{type:"L",x:e.x,y:e.y+e.height},{type:"Z"}]}}}createEllipseShape(e){let t=e.x+e.width/2,r=e.y+e.height/2,i=e.width/2,a=e.height/2;return{type:"preset",onlyOfficeType:3,path:{commands:[{type:"M",x:t+i,y:r},{type:"A",rx:i,ry:a,x:t-i,y:r,rotation:0,largeArc:0,sweep:1},{type:"A",rx:i,ry:a,x:t+i,y:r,rotation:0,largeArc:0,sweep:1},{type:"Z"}]}}}createDiamondShape(e){let t=e.x+e.width/2,r=e.y+e.height/2;return{type:"preset",onlyOfficeType:4,path:{commands:[{type:"M",x:t,y:e.y},{type:"L",x:e.x+e.width,y:r},{type:"L",x:t,y:e.y+e.height},{type:"L",x:e.x,y:r},{type:"Z"}]}}}createTriangleShape(e){return{type:"preset",onlyOfficeType:5,path:{commands:[{type:"M",x:e.x+e.width/2,y:e.y},{type:"L",x:e.x+e.width,y:e.y+e.height},{type:"L",x:e.x,y:e.y+e.height},{type:"Z"}]}}}createRightArrowShape(e){let t=.7*e.width,r=.4*e.height;e.width;let i=.6*e.height;return{type:"preset",onlyOfficeType:13,path:{commands:[{type:"M",x:e.x,y:e.y+(e.height-r)/2},{type:"L",x:e.x+t,y:e.y+(e.height-r)/2},{type:"L",x:e.x+t,y:e.y+(e.height-i)/2},{type:"L",x:e.x+e.width,y:e.y+e.height/2},{type:"L",x:e.x+t,y:e.y+(e.height+i)/2},{type:"L",x:e.x+t,y:e.y+(e.height+r)/2},{type:"L",x:e.x,y:e.y+(e.height+r)/2},{type:"Z"}]}}}createHeartShape(e){let t=e.x+e.width/2,r=e.y+.3*e.height;return{type:"preset",onlyOfficeType:74,path:{commands:[{type:"M",x:t,y:r},{type:"C",x1:t-.3*e.width,y1:e.y,x2:e.x,y2:e.y+.3*e.height,x:t,y:e.y+.8*e.height},{type:"C",x1:e.x+e.width,y1:e.y+.3*e.height,x2:t+.3*e.width,y2:e.y,x:t,y:r},{type:"Z"}]}}}createLeftArrowShape(e){e.width;let t=.4*e.height,r=.3*e.width,i=.6*e.height;return{type:"preset",onlyOfficeType:66,path:{commands:[{type:"M",x:e.x,y:e.y+e.height/2},{type:"L",x:e.x+r,y:e.y+(e.height-i)/2},{type:"L",x:e.x+r,y:e.y+(e.height-t)/2},{type:"L",x:e.x+e.width,y:e.y+(e.height-t)/2},{type:"L",x:e.x+e.width,y:e.y+(e.height+t)/2},{type:"L",x:e.x+r,y:e.y+(e.height+t)/2},{type:"L",x:e.x+r,y:e.y+(e.height+i)/2},{type:"Z"}]}}}createPlusShape(e){let t=.3*Math.min(e.width,e.height),r=e.x+e.width/2,i=e.y+e.height/2;return{type:"preset",onlyOfficeType:11,path:{commands:[{type:"M",x:e.x,y:i-t/2},{type:"L",x:e.x+e.width,y:i-t/2},{type:"L",x:e.x+e.width,y:i+t/2},{type:"L",x:e.x,y:i+t/2},{type:"Z"},{type:"M",x:r-t/2,y:e.y},{type:"L",x:r+t/2,y:e.y},{type:"L",x:r+t/2,y:e.y+e.height},{type:"L",x:r-t/2,y:e.y+e.height},{type:"Z"}]}}}}class a{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(){let e=new a;return e.sx=this.sx,e.shy=this.shy,e.shx=this.shx,e.sy=this.sy,e.tx=this.tx,e.ty=this.ty,e}Multiply(e,t){if(1===t){let t=this.sx*e.sx+this.shy*e.shx,r=this.sx*e.shy+this.shy*e.sy,i=this.shx*e.sx+this.sy*e.shx,a=this.shx*e.shy+this.sy*e.sy,o=this.tx*e.sx+this.ty*e.shx+e.tx,l=this.tx*e.shy+this.ty*e.sy+e.ty;this.sx=t,this.shy=r,this.shx=i,this.sy=a,this.tx=o,this.ty=l}else{let t=e.sx*this.sx+e.shy*this.shx,r=e.sx*this.shy+e.shy*this.sy,i=e.shx*this.sx+e.sy*this.shx,a=e.shx*this.shy+e.sy*this.sy,o=e.tx*this.sx+e.ty*this.shx+this.tx,l=e.tx*this.shy+e.ty*this.sy+this.ty;this.sx=t,this.shy=r,this.shx=i,this.sy=a,this.tx=o,this.ty=l}}}class o{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 l{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 s{constructor(){this.Name="Arial",this.Size=12,this.Bold=!1,this.Italic=!1,this.Underline=!1,this.Strikeout=!1,this.Path="",this.FaceIndex=0,this.CharSpace=0}}e.exports&&(e.exports={CGraphics:r,StandardShapeProcessor:i,StandardShapeTypes:t,OpenXmlShapeTypes:{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"},CMatrix:a,CPen:o,CBrush:l,CFont:s});class n{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=!1}setPreset(e){this.preset=e,this.isCalculated=!1}addAdjustment(e,t,r,i){this.adjLst[e]={value:t,min:r||null,max:i||null},this.avLst[e]=!0,this.isCalculated=!1}addGuide(e,t,r,i,a){this.gdLstInfo.push({name:e,formula:t,x:r,y:i,z:a}),this.isCalculated=!1}calculateGuideValue(e,t,r,i,a){let o=this.getValue(r),l=this.getValue(i),s=this.getValue(a),n=0;switch(t){case 0:n=0!==s?o*l/s:0;break;case 1:n=o+l-s;break;case 2:n=0!==s?(o+l)/s:0;break;case 3:n=o>0?l:s;break;case 4:n=Math.abs(o);break;case 5:n=108e5*Math.atan2(l,o)/Math.PI;break;case 6:n=o*Math.cos(Math.atan2(s,l));break;case 7:n=o*Math.cos(l*Math.PI/108e5);break;case 8:n=Math.max(o,l);break;case 9:n=Math.min(o,l);break;case 10:n=Math.sqrt(o*o+l*l+s*s);break;case 11:n=l<o?o:l>s?s:l;break;case 12:n=o*Math.sin(Math.atan2(s,l));break;case 13:n=o*Math.sin(l*Math.PI/108e5);break;case 14:n=Math.sqrt(Math.max(0,o));break;case 15:n=o*Math.tan(l*Math.PI/108e5);break;case 16:n=o;break;default:n=0}return isNaN(n)&&(n=0),this.gdLst[e]=n,n}getValue(e){if("number"==typeof e)return e;if("string"==typeof e){let t=parseFloat(e);if(!isNaN(t))return t;switch(e){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(e))return this.gdLst[e];if(this.adjLst.hasOwnProperty(e))return this.adjLst[e].value}return 0}calculateGuides(){this.gdLst={};for(let e=0;e<this.gdLstInfo.length;e++){let t=this.gdLstInfo[e];this.calculateGuideValue(t.name,t.formula,t.x,t.y,t.z)}this.isCalculated=!0}recalculate(e,t){this.width=e||21600,this.height=t||21600,this.calculateGuides()}addPath(e){this.pathLst.push(e)}getPathList(){return this.isCalculated||this.calculateGuides(),this.pathLst}}class h{constructor(){this.commands=[],this.fill="norm",this.stroke=!0,this.w=void 0,this.h=void 0,this.extrusionOk=!1}addCommand(e,...t){this.commands.push({type:e,args:t})}moveTo(e,t){this.addCommand("M",e,t)}lineTo(e,t){this.addCommand("L",e,t)}curveTo(e,t,r,i,a,o){this.addCommand("C",e,t,r,i,a,o)}quadTo(e,t,r,i){this.addCommand("Q",e,t,r,i)}arcTo(e,t,r,i,a,o,l){this.addCommand("A",e,t,r,i,a,o,l)}close(){this.addCommand("Z")}setFill(e){this.fill=e}setStroke(e){this.stroke=e}}class c{constructor(){this.shapeCache=new Map,this.presetDefinitions=new Map,this.initializePresetDefinitions()}initializePresetDefinitions(){this.presetDefinitions.set("rect",{guides:[],paths:[{commands:[{type:"M",args:["l","t"]},{type:"L",args:["r","t"]},{type:"L",args:["r","b"]},{type:"L",args:["l","b"]},{type:"Z",args:[]}],fill:"norm",stroke:!0}],connections:[{ang:"cd4",x:"hc",y:"t"},{ang:"0",x:"r",y:"vc"},{ang:"_3cd4",x:"hc",y:"b"},{ang:"cd2",x:"l",y:"vc"}],textRect:{l:"l",t:"t",r:"r",b:"b"}}),this.presetDefinitions.set("roundRect",{adjustments:[{name:"adj",formula:16,value:16667}],guides:[{name:"a",formula:11,x:"0",y:"adj",z:"50000"},{name:"x1",formula:0,x:"ss",y:"a",z:"100000"},{name:"y1",formula:0,x:"ss",y:"a",z:"100000"},{name:"x2",formula:1,x:"r",y:"0",z:"x1"},{name:"y2",formula:1,x:"b",y:"0",z:"y1"},{name:"il",formula:0,x:"x1",y:"29289",z:"100000"},{name:"ir",formula:1,x:"r",y:"0",z:"il"},{name:"it",formula:0,x:"y1",y:"29289",z:"100000"},{name:"ib",formula:1,x:"b",y:"0",z:"it"}],paths:[{commands:[{type:"M",args:["l","y1"]},{type:"Q",args:["l","t","x1","t"]},{type:"L",args:["x2","t"]},{type:"Q",args:["r","t","r","y1"]},{type:"L",args:["r","y2"]},{type:"Q",args:["r","b","x2","b"]},{type:"L",args:["x1","b"]},{type:"Q",args:["l","b","l","y2"]},{type:"Z",args:[]}],fill:"norm",stroke:!0}],handles:[{type:"xy",gdRefX:"adj",minX:"0",maxX:"50000",x:"x1",y:"t"}],connections:[{ang:"cd4",x:"hc",y:"t"},{ang:"0",x:"r",y:"vc"},{ang:"_3cd4",x:"hc",y:"b"},{ang:"cd2",x:"l",y:"vc"}],textRect:{l:"il",t:"it",r:"ir",b:"ib"}}),this.presetDefinitions.set("ellipse",{guides:[{name:"idx",formula:0,x:"wd2",y:"2700000",z:"21600000"},{name:"idy",formula:0,x:"hd2",y:"2700000",z:"21600000"},{name:"il",formula:1,x:"hc",y:"0",z:"idx"},{name:"ir",formula:1,x:"hc",y:"idx",z:"0"},{name:"it",formula:1,x:"vc",y:"0",z:"idy"},{name:"ib",formula:1,x:"vc",y:"idy",z:"0"}],paths:[{commands:[{type:"M",args:["l","vc"]},{type:"A",args:["wd2","hd2","0","1","1","r","vc"]},{type:"A",args:["wd2","hd2","0","1","1","l","vc"]},{type:"Z",args:[]}],fill:"norm",stroke:!0}],connections:[{ang:"cd4",x:"hc",y:"t"},{ang:"0",x:"r",y:"vc"},{ang:"_3cd4",x:"hc",y:"b"},{ang:"cd2",x:"l",y:"vc"}],textRect:{l:"il",t:"it",r:"ir",b:"ib"}})}processPresetGeometry(e,t,r,i={}){let a=`${e}_${t}_${r}_${JSON.stringify(i)}`;if(this.shapeCache.has(a))return this.shapeCache.get(a);let o=this.presetDefinitions.get(e);if(!o)return this.createDefaultGeometry(t,r);let l=new n;return l.setPreset(e),l.recalculate(t,r),o.adjustments&&o.adjustments.forEach(e=>{let t=i[e.name]||e.value;l.addAdjustment(e.name,t,e.min,e.max)}),o.guides&&o.guides.forEach(e=>{l.addGuide(e.name,e.formula,e.x,e.y,e.z)}),o.paths&&o.paths.forEach(e=>{let t=new h;t.setFill(e.fill),t.setStroke(e.stroke),e.commands.forEach(e=>{let r=e.args.map(e=>"string"==typeof e?l.getValue(e):e);t.addCommand(e.type,...r)}),l.addPath(t)}),l.calculateGuides(),this.shapeCache.set(a,l),l}createDefaultGeometry(e,t){return this.processPresetGeometry("rect",e,t)}fillText(e,t,r,i={}){if(this.m_oContext&&e){this.m_oContext.save();try{let a=i.fontSize||12,o=this.m_oGraphicsAdapter&&this.m_oGraphicsAdapter.getTextScaleFactor?this.m_oGraphicsAdapter.getTextScaleFactor():1,l=a*o,s=i.fontFamily||"Arial",n=i.fontWeight||(i.bold?"bold":"normal"),h=i.fontStyle||(i.italic?"italic":"normal"),c=`"${s}", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", Arial, sans-serif`;if(this.m_oContext.font=`${h} ${n} ${l}px ${c}`,i.color)if("object"==typeof i.color&&void 0!==i.color.r){let e=void 0!==i.color.a?i.color.a/255:1,t=`rgba(${i.color.r}, ${i.color.g}, ${i.color.b}, ${e})`;this.m_oContext.fillStyle=t}else"string"==typeof i.color?this.m_oContext.fillStyle=i.color:this.m_oContext.fillStyle="#000000";else this.m_oContext.fillStyle="#000000";if(this.m_oContext.textBaseline=i.textBaseline||"alphabetic",this.m_oContext.textAlign=i.textAlign||"left",this.m_oFullTransform&&!this.m_oFullTransform.IsIdentity()){let e=this.m_oFullTransform;this.m_oContext.setTransform(e.sx,e.shy,e.shx,e.sy,e.tx,e.ty)}if(i.highlight){let a,o=i.highlight;if("object"==typeof o&&void 0!==o.r){let e=void 0!==o.a?o.a/255:1;a=`rgba(${o.r}, ${o.g}, ${o.b}, ${e})`}else"string"==typeof o&&(a=o);if(a){let i=this.m_oContext.measureText(e),o=this.m_oContext.fillStyle;this.m_oContext.fillStyle=a,this.m_oContext.fillRect(t,r-l,i.width,1.2*l),this.m_oContext.fillStyle=o}}this.applyTextEffects(i.effects),this.m_oContext.fillText(e,t,r),this.resetTextEffects()}catch(e){}finally{this.m_oContext.restore()}}}applyTextEffects(e){e&&this.m_oContext&&(e.outerShadow&&this.applyOuterShadow(e.outerShadow),e.glow&&this.applyGlowEffect(e.glow),e.innerShadow&&this.applyInnerShadow(e.innerShadow))}applyOuterShadow(e){if(!e||!this.m_oContext)return;let t=(e.blurRadius||0)/9525,r=(e.distance||0)/9525,i=(e.direction||0)/6e4*Math.PI/180,a=Math.cos(i)*r,o=Math.sin(i)*r;if(this.m_oContext.shadowOffsetX=a,this.m_oContext.shadowOffsetY=o,this.m_oContext.shadowBlur=t,e.color){let t=this.convertColorToString(e.color);this.m_oContext.shadowColor=t}else this.m_oContext.shadowColor="rgba(0, 0, 0, 0.5)"}applyGlowEffect(e){if(!e||!this.m_oContext)return;let t=(e.radius||0)/9525;if(this.m_oContext.shadowOffsetX=0,this.m_oContext.shadowOffsetY=0,this.m_oContext.shadowBlur=t,e.color){let t=this.convertColorToString(e.color);this.m_oContext.shadowColor=t}else this.m_oContext.shadowColor="rgba(255, 255, 255, 0.8)"}applyInnerShadow(e){}resetTextEffects(){this.m_oContext&&(this.m_oContext.shadowOffsetX=0,this.m_oContext.shadowOffsetY=0,this.m_oContext.shadowBlur=0,this.m_oContext.shadowColor="transparent")}convertColorToString(e){if(!e)return"black";if("srgb"===e.type){let t=e.value,r=parseInt(t.substr(0,2),16),i=parseInt(t.substr(2,2),16),a=parseInt(t.substr(4,2),16),o=e.alpha||1;return`rgba(${r}, ${i}, ${a}, ${o})`}if("scheme"===e.type){let t={dk1:"#000000",lt1:"#FFFFFF",dk2:"#44546A",lt2:"#E7E6E6"}[e.value]||"#000000",r=e.alpha||1,i=parseInt(t.substr(1,2),16),a=parseInt(t.substr(3,2),16),o=parseInt(t.substr(5,2),16);return`rgba(${i}, ${a}, ${o}, ${r})`}return"black"}measureText(e,t={}){if(!this.m_oContext||!e)return{width:0,height:0};this.m_oContext.save();try{let r=t.fontSize||12,i=this.m_oGraphicsAdapter&&this.m_oGraphicsAdapter.getTextScaleFactor?this.m_oGraphicsAdapter.getTextScaleFactor():1,a=r*i,o=t.fontFamily||"Arial",l=t.fontWeight||(t.bold?"bold":"normal"),s=t.fontStyle||(t.italic?"italic":"normal"),n=`"${o}", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", Arial, sans-serif`;this.m_oContext.font=`${s} ${l} ${a}px ${n}`;let h=this.m_oContext.measureText(e),c=a;return void 0!==h.actualBoundingBoxAscent&&void 0!==h.actualBoundingBoxDescent&&(c=h.actualBoundingBoxAscent+h.actualBoundingBoxDescent),{width:h.width,height:c}}catch(e){return{width:0,height:0}}finally{this.m_oContext.restore()}}}"u">typeof window&&(window.CGraphics=r,window.StandardShapeProcessor=i)}(A)),A.exports;!function(){if(!g){g=1;class e{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{void 0!==window.AscFonts?(this.fontManager=new window.AscFonts.CFontManagerEngine,this.initializeFonts()):this.fontManager=new t}catch(e){this.fontManager=new t}}initializeFonts(){try{"function"==typeof self.queryLocalFonts?this.loadSystemFonts():this.loadFallbackFonts()}catch(e){this.loadFallbackFonts()}}async loadSystemFonts(){try{(await self.queryLocalFonts()).forEach(e=>{this.availableFonts.add(e.family)})}catch(e){this.loadFallbackFonts()}}loadFallbackFonts(){["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"].forEach(e=>{this.availableFonts.add(e)})}analyzeDocument(e){return this.documentFonts.clear(),e.defaultTextStyle&&this.addFontFromStyle(e.defaultTextStyle),e.slides.forEach(e=>{e.commonSlideData&&e.commonSlideData.shapeTree&&e.commonSlideData.shapeTree.forEach(e=>{this.analyzeShape(e)})}),Array.from(this.documentFonts)}addFontFromStyle(e){e&&e.font&&this.documentFonts.add(e.font)}analyzeShape(e){e&&(e.textBody&&e.textBody.paragraphs&&e.textBody.paragraphs.forEach(e=>{e.runs&&e.runs.forEach(e=>{e.properties&&e.properties.font&&this.documentFonts.add(e.properties.font)})}),e.shapeTree&&e.shapeTree.forEach(e=>{this.analyzeShape(e)}))}loadFonts(){this.missingFonts.clear(),this.documentFonts.forEach(e=>{this.availableFonts.has(e)||this.missingFonts.add(e)})}getResults(){return{documentFonts:Array.from(this.documentFonts),availableFonts:Array.from(this.availableFonts),missingFonts:Array.from(this.missingFonts)}}getFontMetrics(e,t,r){let i=`${e}_${t}_${r}`;if(this.fontCache.has(i))return this.fontCache.get(i);let a={width:r.length*t*.6,height:1.2*t,ascent:.8*t,descent:.2*t,baseline:.8*t};return this.fontCache.set(i,a),a}isFontAvailable(e){return this.availableFonts.has(e)||this.documentFonts.has(e)}getFallbackFont(e){return this.isFontAvailable(e)?e:'Arial, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif'}renderText(e,t,r,i,a){let o=this.getFallbackFont(a.fontFamily||"Arial"),l=a.fontSize||12,s=a.fontWeight||(a.bold?"bold":"normal"),n=a.fontStyle||(a.italic?"italic":"normal");e.font=`${n} ${s} ${l}px "${o}"`;let h="#000000";if(a.color)if("object"==typeof a.color&&void 0!==a.color.r){let e=void 0!==a.color.a?a.color.a/255:1;h=`rgba(${a.color.r}, ${a.color.g}, ${a.color.b}, ${e})`}else h="string"==typeof a.color?a.color:"#000000";else h="#000000";if(e.fillStyle=h,e.textBaseline="alphabetic",a.textAlign&&(e.textAlign=a.textAlign),1===t.length)e.fillText(t,r,i);else{let o=r;for(let r=0;r<t.length;r++){let l=t.charAt(r);e.fillText(l,o,i),o+=e.measureText(l).width,a.letterSpacing&&(o+=a.letterSpacing)}}}measureText(e,t,r){let i=this.getFallbackFont(r.fontFamily||"Arial"),a=r.fontSize||12,o=r.fontWeight||(r.bold?"bold":"normal"),l=r.fontStyle||(r.italic?"italic":"normal");e.save(),e.font=`${l} ${o} ${a}px "${i}"`;let s=0,n=a;for(let i=0;i<t.length;i++){let a=t.charAt(i),o=e.measureText(a);s+=o.width,r.letterSpacing&&(s+=r.letterSpacing),void 0!==o.actualBoundingBoxAscent&&void 0!==o.actualBoundingBoxDescent&&(n=Math.max(n,o.actualBoundingBoxAscent+o.actualBoundingBoxDescent))}return e.restore(),{width:s,height:n}}}class t{constructor(){this.library=null,this.manager=null}openFont(e,t){return{SetFace:function(e,t){this.face=e,this.manager=t},IsSuccess:function(){return!0}}}setHintsProps(e,t){this.hinting=e,this.subpixHinting=t}destroy(){this.library=null,this.manager=null}}"u">typeof window&&(window.FontEngine=e,window.SimplifiedFontManager=t)}}();!function(){if(!f){f=1;class e{constructor(){this.type="",this.source="",this.mimeType="",this.duration=0,this.width=0,this.height=0,this.poster="",this.autoplay=!1,this.loop=!1,this.controls=!0,this.muted=!1,this.volume=1,this.startTime=0,this.endTime=0,this.relationship=null,this.embeddedData=null,this.thumbnail=null}}class t{constructor(){this.videoId="",this.startTime=0,this.endTime=0,this.autoplay=!1,this.showControls=!0,this.showInfo=!1,this.loop=!1,this.fullUrl="",this.embedUrl="",this.thumbnailUrl=""}}class r{constructor(e){this.context=e,this.logger=new Logger("MediaProcessor"),this.supportedVideoTypes=["mp4","webm","ogg","avi","mov","wmv"],this.supportedAudioTypes=["mp3","wav","ogg","aac","m4a","wma"],this.supportedImageTypes=["jpg","jpeg","png","gif","bmp","svg","webp"]}parseMediaFromElement(e){try{if(this.isVideoElement(e))return this.parseVideoElement(e);if(this.isAudioElement(e))return this.parseAudioElement(e);if(this.isImageElement(e))return this.parseImageElement(e);else if(this.isYouTubeEmbed(e))return this.parseYouTubeEmbed(e);return null}catch(e){return this.logger.logError(this.constructor.name,"Error parsing media element:",e),null}}isVideoElement(e){return["video","p:video","a:video"].some(t=>e.querySelector(t))||this.hasVideoMimeType(e)}isAudioElement(e){return["audio","p:audio","a:audio"].some(t=>e.querySelector(t))||this.hasAudioMimeType(e)}isImageElement(e){return["pic","p:pic","image","img"].some(t=>e.querySelector(t))||this.hasImageMimeType(e)}isYouTubeEmbed(e){let t=e.textContent||"",r=e.innerHTML||"";return t.includes("youtube.com")||t.includes("youtu.be")||r.includes("youtube.com")||r.includes("youtu.be")}parseVideoElement(t){let r=new e;r.type="video",this.parseCommonMediaAttributes(t,r);let i=t.querySelector("video, p\\:video, a\\:video");return i&&(r.poster=i.getAttribute("poster")||"",r.autoplay=i.hasAttribute("autoplay"),r.loop=i.hasAttribute("loop"),r.controls=!i.hasAttribute("controls")||"false"!==i.getAttribute("controls"),r.muted=i.hasAttribute("muted")),this.extractMediaSource(t,r),r}parseAudioElement(t){let r=new e;r.type="audio",this.parseCommonMediaAttributes(t,r);let i=t.querySelector("audio, p\\:audio, a\\:audio");if(i){r.autoplay=i.hasAttribute("autoplay"),r.loop=i.hasAttribute("loop"),r.controls=!i.hasAttribute("controls")||"false"!==i.getAttribute("controls"),r.muted=i.hasAttribute("muted");let e=i.getAttribute("volume");e&&(r.volume=parseFloat(e)||1)}return this.extractMediaSource(t,r),r}parseImageElement(t){let r=new e;return r.type="image",this.parseCommonMediaAttributes(t,r),this.extractMediaSource(t,r),r}parseYouTubeEmbed(r){let i=new e;i.type="youtube";let a=new t,o=(r.textContent||"")+" "+(r.innerHTML||""),l=this.extractYouTubeVideoId(o);l&&(a.videoId=l,a.fullUrl=`https://www.youtube.com/watch?v=${l}`,a.embedUrl=`https://www.youtube.com/embed/${l}`,a.thumbnailUrl=`https://img.youtube.com/vi/${l}/maxresdefault.jpg`);let s=o.match(/[?&]t=(\d+)/);return s&&(a.startTime=parseInt(s[1])),i.source=a.embedUrl,i.embeddedData=a,i}parseCommonMediaAttributes(e,t){let r=e.getAttribute("width")||e.getAttribute("w"),i=e.getAttribute("height")||e.getAttribute("h");r&&(t.width=parseInt(r)||0),i&&(t.height=parseInt(i)||0);let a=e.getAttribute("duration");a&&(t.duration=parseFloat(a)||0);let o=e.getAttribute("r:id")||e.getAttribute("rid");o&&(t.relationship=o)}extractMediaSource(e,t){let r=e.getAttribute("src");if(r){t.source=r,t.mimeType=this.getMimeTypeFromExtension(r);return}let i=e.querySelector("source");if(i){t.source=i.getAttribute("src")||"",t.mimeType=i.getAttribute("type")||this.getMimeTypeFromExtension(t.source);return}if(t.relationship&&this.context){let e=this.resolveRelationship(t.relationship);if(e){if(t.source=e,t.mimeType=this.getMimeTypeFromExtension(e),"image/svg+xml"===this.getMimeTypeFromExtension(e))try{let r=this.getZipPackage();r&&r.getFileData&&r.getFileData(e).then(e=>{if(e){let r=new TextDecoder("utf-8").decode(e),i=btoa(r);t.embeddedData=`data:image/svg+xml;base64,${i}`}}).catch(t=>{this.logger.log("warn",this.constructor.name,`Failed to create SVG data URI for ${e}:`,t)})}catch(t){this.logger.log("warn",this.constructor.name,`Error creating SVG data URI for ${e}:`,t)}return}}let a=this.extractEmbeddedData(e);a&&(t.embeddedData=a,t.mimeType=this.getMimeTypeFromData(a))}getZipPackage(){return this.context&&this.context.zip?this.context.zip:this.context&&this.context.package?this.context.package:window.currentProcessor&&window.currentProcessor.package?window.currentProcessor.package:window.currentProcessor&&window.currentProcessor.zip?window.currentProcessor.zip:null}extractYouTubeVideoId(e){for(let t of[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\n?#]+)/,/youtube\.com\/embed\/([^&\n?#]+)/,/youtube\.com\/v\/([^&\n?#]+)/]){let r=e.match(t);if(r&&r[1])return r[1]}return null}getMimeTypeFromExtension(e){return e?({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"})[e.split(".").pop().toLowerCase()]||"":""}resolveRelationship(e){try{if(!e||!this.context)return null;let t=null;if(this.context.zip?t=this.context.zip:this.context.package?t=this.context.package:window.currentProcessor&&window.currentProcessor.package&&(t=window.currentProcessor.package),!t||!t.relationships)return null;for(let r of Object.values(t.relationships))if(r&&r[e]){let t=r[e].target;return t.startsWith("../")?t=t.replace("../","ppt/"):t.startsWith("/")||(t=`/ppt/${t}`),t}return this.logger.log("warn",this.constructor.name,`Could not resolve relationship ID: ${e}`),null}catch(t){return this.logger.logError(this.constructor.name,`Error resolving relationship ${e}:`,t),null}}extractEmbeddedData(e){for(let t of["data","data-src","data-url","src","href"]){let r=e.getAttribute(t);if(r&&r.startsWith("data:"))return r}let t=(e.textContent||"").match(/data:[^;]+;base64,[A-Za-z0-9+/]+=*/g);return t&&t.length>0?t[0]:null}getMimeTypeFromData(e){if(!e||!e.startsWith("data:"))return"";let t=e.match(/^data:([^;]+)/);return t?t[1]:""}isSVGDataUri(e){return!!e&&!!e.startsWith("data:")&&"image/svg+xml"===this.getMimeTypeFromData(e)}extractSVGFromDataUri(e){if(!this.isSVGDataUri(e))return null;try{let t=e.split(",")[1];if(!t)return null;return atob(t)}catch(e){return null}}hasVideoMimeType(e){return(e.getAttribute("type")||"").startsWith("video/")}hasAudioMimeType(e){return(e.getAttribute("type")||"").startsWith("audio/")}hasImageMimeType(e){return(e.getAttribute("type")||"").startsWith("image/")}createPlaceholder(t="media"){let r=new e;return r.type=t,r.source="",r.width=320,r.height=240,r.controls=!0,r}}"u">typeof window&&(window.MediaInfo=e,window.YouTubeEmbed=t,window.MediaProcessor=r)}}();!function(){if(!m){m=1;class e{constructor(e){this.graphics=e,this.logger=new Logger("SVGRenderer"),this.parser=new DOMParser}async renderSVG(e,t,r,i,a,o={}){try{let l=null;if("string"==typeof e){let o=e.trim();if(o.startsWith("<svg"))l=this.parser.parseFromString(o,"image/svg+xml").documentElement;else if(o.startsWith("data:image/svg+xml")){let e=o.split(",")[1],t=atob(e);l=this.parser.parseFromString(t,"image/svg+xml").documentElement}else{if(!o.includes("<svg"))return void this.renderSVGPlaceholder(t,r,i,a,"External SVG");l=this.parser.parseFromString(o,"image/svg+xml").documentElement}}else e instanceof Element&&(l=e);if(!l||"svg"!==l.tagName)return void this.renderSVGPlaceholder(t,r,i,a,"Invalid SVG");let s=this.getSVGViewBox(l),n=this.getSVGDimensions(l,s),h=i/n.width,c=a/n.height,u=!1!==o.preserveAspectRatio?Math.min(h,c):Math.max(h,c);this.canUseImageMethod()?await this.renderSVGViaImage(l,t,r,i,a,u,o):this.renderSVGViaParsing(l,t,r,u,o)}catch(e){this.logger.logError(this.constructor.name,"Error rendering SVG:",e),this.renderSVGPlaceholder(t,r,i,a,"SVG Error")}}getSVGViewBox(e){let t=e.getAttribute("viewBox");if(t){let e=t.split(/\s+/).map(e=>parseFloat(e));if(4===e.length)return{x:e[0],y:e[1],width:e[2],height:e[3]}}return null}getSVGDimensions(e,t){let r=parseFloat(e.getAttribute("width"))||0,i=parseFloat(e.getAttribute("height"))||0;return r||i||!t||(r=t.width,i=t.height),r||(r=100),i||(i=100),{width:r,height:i}}canUseImageMethod(){let e="u">typeof Image,t=this.graphics._context||this.graphics.m_oContext,r=t&&"function"==typeof t.drawImage;return e&&t&&r}enhanceSVGForRendering(e,t,r){try{let i=this.parser.parseFromString(e,"image/svg+xml").documentElement;if(!i.hasAttribute("viewBox")){let e=i.getAttribute("width")||t,a=i.getAttribute("height")||r;i.setAttribute("viewBox",`0 0 ${e} ${a}`)}return i.setAttribute("width",t.toString()),i.setAttribute("height",r.toString()),i.hasAttribute("xmlns")||i.setAttribute("xmlns","http://www.w3.org/2000/svg"),new XMLSerializer().serializeToString(i)}catch(t){return this.logger.log("warn",this.constructor.name,"Could not enhance SVG, using original:",t),e}}async renderSVGViaImage(e,t,r,i,a,o,l){return new Promise((o,l)=>{try{let s=new XMLSerializer().serializeToString(e),n=this.enhanceSVGForRendering(s,i,a),h="data:image/svg+xml;base64,"+btoa(n),c=new Image;c.onload=()=>{try{if(this.graphics._context||this.graphics.m_oContext){let e=this.graphics._context||this.graphics.m_oContext;e.save();let o=i,l=a,s=t,n=r;if(c.naturalWidth>0&&c.naturalHeight>0){let e=c.naturalWidth/c.naturalHeight,h=i/a;e>h?(o=i,l=i/e,n=r+(a-l)/2):(l=a,o=a*e,s=t+(i-o)/2)}e.drawImage(c,s,n,o,l),e.restore()}else this.logger.logError(this.constructor.name,"No canvas context available for SVG drawing");o()}catch(e){this.logger.logError(this.constructor.name,"Error drawing SVG image:",e),this.renderSVGPlaceholder(t,r,i,a,"SVG Draw Error"),l(e)}},c.onerror=e=>{this.logger.logError(this.constructor.name,"SVG image load error:",e),this.renderSVGPlaceholder(t,r,i,a,"SVG Load Error"),l(e)},c.crossOrigin="anonymous",c.src=h,setTimeout(()=>{!1===c.complete&&(this.logger.log("warn",this.constructor.name,"SVG loading timed out"),this.renderSVGPlaceholder(t,r,i,a,"SVG Timeout"),l(Error("SVG loading timeout")))},5e3)}catch(e){this.logger.logError(this.constructor.name,"Error in SVG Image rendering:",e),this.renderSVGPlaceholder(t,r,i,a,"SVG Render Error"),l(e)}})}renderSVGViaParsing(e,t,r,i,a){try{if(!this.graphics._context)return;this.graphics._context.save(),this.graphics._context.translate(t,r),this.graphics._context.scale(i,i),this.processSVGElements(e.children),this.graphics._context.restore()}catch(e){this.logger.logError(this.constructor.name,"Error in SVG parsing rendering:",e),this.renderSVGPlaceholder(t,r,100,100,"SVG Parse Error")}}processSVGElements(e){for(let t of e)this.processSVGElement(t)}processSVGElement(e){switch(e.tagName.toLowerCase()){case"rect":this.renderSVGRect(e);break;case"circle":this.renderSVGCircle(e);break;case"ellipse":this.renderSVGEllipse(e);break;case"line":this.renderSVGLine(e);break;case"polyline":case"polygon":this.renderSVGPolygon(e);break;case"path":this.renderSVGPath(e);break;case"text":this.renderSVGText(e);break;case"g":this.graphics._context.save(),this.applySVGTransform(e),this.processSVGElements(e.children),this.graphics._context.restore()}}renderSVGRect(e){let t=parseFloat(e.getAttribute("x"))||0,r=parseFloat(e.getAttribute("y"))||0,i=parseFloat(e.getAttribute("width"))||0,a=parseFloat(e.getAttribute("height"))||0;this.applySVGStyles(e);let o=this.graphics._context;o.fillRect(t,r,i,a),o.strokeRect(t,r,i,a)}renderSVGCircle(e){let t=parseFloat(e.getAttribute("cx"))||0,r=parseFloat(e.getAttribute("cy"))||0,i=parseFloat(e.getAttribute("r"))||0;this.applySVGStyles(e);let a=this.graphics._context;a.beginPath(),a.arc(t,r,i,0,2*Math.PI),a.fill(),a.stroke()}renderSVGLine(e){let t=parseFloat(e.getAttribute("x1"))||0,r=parseFloat(e.getAttribute("y1"))||0,i=parseFloat(e.getAttribute("x2"))||0,a=parseFloat(e.getAttribute("y2"))||0;this.applySVGStyles(e);let o=this.graphics._context;o.beginPath(),o.moveTo(t,r),o.lineTo(i,a),o.stroke()}renderSVGText(e){let t=parseFloat(e.getAttribute("x"))||0,r=parseFloat(e.getAttribute("y"))||0,i=e.textContent||"";this.applySVGStyles(e),this.graphics._context.fillText(i,t,r)}applySVGStyles(e){let t=this.graphics._context,r=e.getAttribute("fill");r&&"none"!==r?t.fillStyle=r:t.fillStyle="transparent";let i=e.getAttribute("stroke");i&&"none"!==i?t.strokeStyle=i:t.strokeStyle="transparent";let a=e.getAttribute("stroke-width");a&&(t.lineWidth=parseFloat(a));let o=e.getAttribute("opacity");o&&(t.globalAlpha=parseFloat(o))}applySVGTransform(e){let t=e.getAttribute("transform");if(t){let e=t.match(/translate\(([^)]+)\)/);if(e){let t=e[1].split(",").map(e=>parseFloat(e.trim()));t.length>=2&&this.graphics._context.translate(t[0],t[1])}let r=t.match(/scale\(([^)]+)\)/);if(r){let e=r[1].split(",").map(e=>parseFloat(e.trim()));if(e.length>=1){let t=e[0],r=e.length>1?e[1]:t;this.graphics._context.scale(t,r)}}let i=t.match(/rotate\(([^)]+)\)/);if(i){let e=parseFloat(i[1]);this.graphics._context.rotate(e*Math.PI/180)}}}renderSVGPlaceholder(e,t,r,i,a="SVG"){this.graphics.fillRect(e,t,r,i,{r:240,g:240,b:240}),this.graphics.strokeRect(e,t,r,i,{r:200,g:200,b:200},1)}renderSVGEllipse(e){let t=parseFloat(e.getAttribute("cx"))||0,r=parseFloat(e.getAttribute("cy"))||0,i=parseFloat(e.getAttribute("rx"))||0,a=parseFloat(e.getAttribute("ry"))||0;this.applySVGStyles(e);let o=this.graphics._context;o.save(),o.translate(t,r),o.scale(i,a),o.beginPath(),o.arc(0,0,1,0,2*Math.PI),o.restore(),o.fill(),o.stroke()}renderSVGPolygon(e){let t=e.getAttribute("points")||"",r="polygon"===e.tagName.toLowerCase();if(!t.trim())return;this.applySVGStyles(e);let i=this.graphics._context,a=t.trim().split(/[\s,]+/);if(a.length<4)return;i.beginPath();let o=parseFloat(a[0]),l=parseFloat(a[1]);i.moveTo(o,l);for(let e=2;e<a.length;e+=2)e+1<a.length&&(o=parseFloat(a[e]),l=parseFloat(a[e+1]),i.lineTo(o,l));r&&i.closePath(),i.fill(),i.stroke()}renderSVGPath(e){let t=e.getAttribute("d")||"";if(t.trim()){this.applySVGStyles(e);try{let e=this.graphics._context,r=this.parseSVGPathData(t);e.beginPath(),this.executeSVGPathCommands(r,e),e.fill(),e.stroke()}catch(r){this.logger.log("warn",this.constructor.name,"Error parsing SVG path:",r);let t=this.getElementBoundingBox(e);if(t){this.applySVGStyles(e);let r=this.graphics._context;r.fillRect(t.x,t.y,t.width,t.height),r.strokeRect(t.x,t.y,t.width,t.height)}}}}parseSVGPathData(e){let t,r=[],i=/([MmLlHhVvCcSsQqTtAaZz])((?:\s*[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?\s*,?\s*)*)/g;for(;null!==(t=i.exec(e));){let e=t[1],i=t[2].trim(),a=i?i.split(/[\s,]+/).map(e=>parseFloat(e)).filter(e=>!isNaN(e)):[];r.push({command:e,params:a})}return r}executeSVGPathCommands(e,t){let r=0,i=0;for(let{command:a,params:o}of e)switch(a.toLowerCase()){case"m":if(o.length>=2){"M"===a?(r=o[0],i=o[1]):(r+=o[0],i+=o[1]),t.moveTo(r,i);for(let e=2;e<o.length;e+=2)e+1<o.length&&("M"===a?(r=o[e],i=o[e+1]):(r+=o[e],i+=o[e+1]),t.lineTo(r,i))}break;case"l":for(let e=0;e<o.length;e+=2)e+1<o.length&&("L"===a?(r=o[e],i=o[e+1]):(r+=o[e],i+=o[e+1]),t.lineTo(r,i));break;case"h":for(let e=0;e<o.length;e++)"H"===a?r=o[e]:r+=o[e],t.lineTo(r,i);break;case"v":for(let e=0;e<o.length;e++)"V"===a?i=o[e]:i+=o[e],t.lineTo(r,i);break;case"c":for(let e=0;e<o.length;e+=6)if(e+5<o.length){let l,s,n,h,c,u;"C"===a?(l=o[e],s=o[e+1],n=o[e+2],h=o[e+3],c=o[e+4],u=o[e+5]):(l=r+o[e],s=i+o[e+1],n=r+o[e+2],h=i+o[e+3],c=r+o[e+4],u=i+o[e+5]),t.bezierCurveTo(l,s,n,h,c,u),r=c,i=u}break;case"q":for(let e=0;e<o.length;e+=4)if(e+3<o.length){let l,s,n,h;"Q"===a?(l=o[e],s=o[e+1],n=o[e+2],h=o[e+3]):(l=r+o[e],s=i+o[e+1],n=r+o[e+2],h=i+o[e+3]),t.quadraticCurveTo(l,s,n,h),r=n,i=h}break;case"a":for(let e=0;e<o.length;e+=7)if(e+6<o.length){let l,s,n=o[e],h=o[e+1],c=o[e+2]*Math.PI/180,u=o[e+3],d=o[e+4];"A"===a?(l=o[e+5],s=o[e+6]):(l=r+o[e+5],s=i+o[e+6]),this.drawEllipticalArc(t,r,i,n,h,c,u,d,l,s),r=l,i=s}break;case"z":t.closePath()}}drawEllipticalArc(e,t,r,i,a,o,l,s,n,h){e.lineTo(n,h)}getElementBoundingBox(e){let t=parseFloat(e.getAttribute("x"))||0,r=parseFloat(e.getAttribute("y"))||0,i=parseFloat(e.getAttribute("width"))||10,a=parseFloat(e.getAttribute("height"))||10;return i>0&&a>0?{x:t,y:r,width:i,height:a}:null}}"u">typeof window&&(window.SVGRenderer=e)}}();!function(){if(!y){y=1;class e{constructor(){this.name="",this.colorScheme={},this.fontScheme={},this.formatScheme={},this.backgroundStyles=[],this.effects=[],this.themeElements={}}}class t{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 i{constructor(){this.id="",this.name="",this.preserve=!1,this.cSld=null,this.clrMap=null,this.txStyles=null,this.sldLayoutLst=[],this.themeId="",this.hf=null,this.timing=null,this.transition=null}}class a{constructor(){this.id="",this.masterId="",this.name="",this.type="custom",this.preserve=!1,this.showMasterSp=!0,this.showMasterPhAnim=!1,this.userDrawn=!1,this.cSld=null,this.clrMapOvr=null,this.hf=null,this.timing=null,this.transition=null}}class o{constructor(e){this.context=e,this.logger=new Logger("ThemeProcessor"),this.themes=new Map,this.masters=new Map,this.layouts=new Map}processTheme(t,r){try{let i=new DOMParser().parseFromString(t,"text/xml").querySelector("theme, a\\:theme");if(!i)return this.logger.log("warn",this.constructor.name,"No theme element found in XML"),this.createDefaultTheme(r);let a=new e;return a.name=i.getAttribute("name")||`Theme${r}`,this.processThemeElements(i,a),this.processColorScheme(i,a),this.processFontScheme(i,a),this.processFormatScheme(i,a),this.themes.set(r,a),a}catch(e){return this.logger.logError(this.constructor.name,"Error processing theme:",e),this.createDefaultTheme(r)}}processMasterSlide(e,t){try{let r=new DOMParser().parseFromString(e,"text/xml").querySelector("sldMaster, p\\:sldMaster");if(!r)return this.logger.log("warn",this.constructor.name,"No slide master element found in XML"),this.createDefaultMaster(t);let a=new i;return a.id=t,a.name=r.getAttribute("name")||`Master${t}`,a.preserve="true"===r.getAttribute("preserve"),this.processMasterElements(r,a),this.masters.set(t,a),a}catch(e){return this.logger.logError(this.constructor.name,"Error processing master slide:",e),this.createDefaultMaster(t)}}processLayoutSlide(e,t,r){try{let i=new DOMParser().parseFromString(e,"text/xml").querySelector("sldLayout, p\\:sldLayout");if(!i)return this.logger.log("warn",this.constructor.name,"No slide layout element found in XML"),this.createDefaultLayout(t,r);let o=new a;o.id=t,o.masterId=r,o.name=i.getAttribute("name")||`Layout${t}`,o.type=i.getAttribute("type")||"custom",o.preserve="true"===i.getAttribute("preserve"),o.showMasterSp="false"!==i.getAttribute("showMasterSp"),o.showMasterPhAnim="true"===i.getAttribute("showMasterPhAnim"),o.userDrawn="true"===i.getAttribute("userDrawn"),this.processLayoutElements(i,o),this.layouts.set(t,o);let l=this.masters.get(r);return l&&l.sldLayoutLst.push(t),o}catch(e){return this.logger.logError(this.constructor.name,"Error processing layout slide:",e),this.createDefaultLayout(t,r)}}processThemeElements(e,t){let r=e.querySelector("themeElements, a\\:themeElements");r&&(t.themeElements={element:r,parsed:!1})}processColorScheme(e,r){let i=e.querySelector("clrScheme, a\\:clrScheme");if(!i)return;let a=new t;for(let[e,t]of Object.entries({dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink"})){let r=i.querySelector(`${e}, a\\:${e}`);r&&(a[t]=this.parseColor(r))}r.colorScheme=a}processFontScheme(e,t){let i=e.querySelector("fontScheme, a\\:fontScheme");if(!i)return;let a=new r,o=i.querySelector("majorFont, a\\:majorFont");o&&(a.majorFont=this.parseFontCollection(o));let l=i.querySelector("minorFont, a\\:minorFont");l&&(a.minorFont=this.parseFontCollection(l)),t.fontScheme=a}processFormatScheme(e,t){let r=e.querySelector("fmtScheme, a\\:fmtScheme");r&&(t.formatScheme={fillStyleLst:this.processFillStyles(r),lnStyleLst:this.processLineStyles(r),effectStyleLst:this.processEffectStyles(r),bgFillStyleLst:this.processBackgroundFillStyles(r)})}processMasterElements(e,t){let r=e.querySelector("cSld, p\\:cSld");r&&(t.cSld=this.parseCommonSlideData(r));let i=e.querySelector("clrMap, p\\:clrMap");i&&(t.clrMap=this.parseColorMap(i));let a=e.querySelector("txStyles, p\\:txStyles");a&&(t.txStyles=this.parseTextStyles(a)),t.hf=this.parseHeaderFooter(e),t.timing=this.parseTiming(e),t.transition=this.parseTransition(e)}processLayoutElements(e,t){let r=e.querySelector("cSld, p\\:cSld");r&&(t.cSld=this.parseCommonSlideData(r));let i=e.querySelector("clrMapOvr, p\\:clrMapOvr");i&&(t.clrMapOvr=this.parseColorMapOverride(i)),t.hf=this.parseHeaderFooter(e),t.timing=this.parseTiming(e),t.transition=this.parseTransition(e)}getTheme(e){return this.themes.get(e)||null}getMaster(e){return this.masters.get(e)||null}getLayout(e){return this.layouts.get(e)||null}resolveColor(e,t,r=null){let i=this.getTheme(t);if(!i||!i.colorScheme)return null;let a=r&&r[e]?r[e]:e;return i.colorScheme[a]||null}resolveFont(e,t,r="latin"){let i=this.getTheme(t);if(!i||!i.fontScheme)return null;let a="major"===e?i.fontScheme.majorFont:i.fontScheme.minorFont;return a[r]||a.latin||null}parseColor(e){let t=e.querySelector("sysClr, a\\:sysClr"),r=e.querySelector("srgbClr, a\\:srgbClr");if(e.querySelector("schemeClr, a\\:schemeClr"),r){let e=r.getAttribute("val");if(e){let t=parseInt(e.substr(0,2),16);return{r:t,g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)}}}return t&&({windowText:{r:0,g:0,b:0},window:{r:255,g:255,b:255}})[t.getAttribute("val")]||{r:0,g:0,b:0}}parseFontCollection(e){let t={},r=e.querySelector("latin, a\\:latin");r&&(t.latin=r.getAttribute("typeface"));let i=e.querySelector("cs, a\\:cs");return i&&(t.cs=i.getAttribute("typeface")),t}parseCommonSlideData(e){return{name:e.getAttribute("name")||"",bg:this.parseBackground(e),spTree:this.parseShapeTree(e)}}parseColorMap(e){let t={},r=e.attributes;for(let e=0;e<r.length;e++){let i=r[e];t[i.name]=i.value}return t}parseColorMapOverride(e){return{}}parseTextStyles(e){return{titleStyle:{},bodyStyle:{},otherStyle:{}}}parseShapeTree(e){return[]}parseBackground(e){return null}parseHeaderFooter(e){return null}parseTiming(e){return null}parseTransition(e){return null}processFillStyles(e){return[]}processLineStyles(e){return[]}processEffectStyles(e){return[]}processBackgroundFillStyles(e){return[]}createDefaultTheme(i){let a=new e;return a.name=`Default Theme ${i}`,a.colorScheme=new t,a.fontScheme=new r,a}createDefaultMaster(e){let t=new i;return t.id=e,t.name=`Default Master ${e}`,t}createDefaultLayout(e,t){let r=new a;return r.id=e,r.masterId=t,r.name=`Default Layout ${e}`,r.type="blank",r}}"u">typeof window&&(window.ThemeInfo=e,window.ColorScheme=t,window.FontScheme=r,window.MasterSlide=i,window.LayoutSlide=a,window.ThemeProcessor=o)}}();let k="u">typeof globalThis&&globalThis.Logger?globalThis.Logger:class{log(){}info(){}warn(){}error(){}debug(){}trace(){}logError(){}},R="u">typeof globalThis&&globalThis.FontEngine?globalThis.FontEngine:class{},E="u">typeof globalThis&&globalThis.CanvasGraphicsAdapter?globalThis.CanvasGraphicsAdapter:class{resetState(){}},_="u">typeof globalThis&&globalThis.CDrawingDocument?globalThis.CDrawingDocument:class{constructor(){this.graphics=null,this.canvas=null,this.processor=null,this.logger=new k("CDrawingDocument")}init(e,t=null){this.canvas=e,this.processor=t,this.graphics?this.graphics.resetState&&this.graphics.resetState():this.graphics=new E}},F="u">typeof globalThis&&globalThis.ZLib?globalThis.ZLib:class{constructor(){this.files={},this.isOpen=!1}async open(e){return this.isOpen=!0,!0}async getFileText(e){return null}async getFile(e){return null}getPaths(){return[]}},I="u">typeof globalThis&&globalThis.OpenXmlTypes||"u">typeof window&&window.OpenXmlTypes||{presentation:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"},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"}};class L{constructor(e=0,t=0,r=0,i=0){this.x=e,this.y=t,this.w=r,this.h=i}isIntersectOther(e){return!(this.x>e.x+e.w||this.x+this.w<e.x||this.y>e.y+e.h||this.y+this.h<e.y)}}class D{constructor(){this.logger=new k("PPTXProcessor"),this.zip=null,this.package=null,this.presentation=null,this.slides=[],this.slideMasters=[],this.slideLayouts=[],this.fontEngine=new R,this.drawingDocument=null,this.initializeGraphicsEngine(),this.currentSlideIndex=0,this.xmlParser=null,this.imageMap=new Map,this.mediaMap=new Map,this.imageCache=new Map,this.svgRelationshipMap=new Map,this.imageLoader=new B,this.renderContext={enableOptimizations:!0,enableBoundsChecking:!0,enableViewportCulling:!0,enableTextAntialiasing:!0,enableShapeAntialiasing:!0,quality:"high",dpi:96,pixelRatio:window.devicePixelRatio||1}}setupHighResolutionCanvas(e,t,r,i=null){let a=i||this.renderContext.pixelRatio||window.devicePixelRatio||1;e.style.width=t+"px",e.style.height=r+"px",e.width=t*a,e.height=r*a;let o=e.getContext("2d");return o.scale(a,a),o.imageSmoothingEnabled=!0,o.imageSmoothingQuality="high",e}setRenderingDPI(e){this.renderContext.dpi=e,this.renderContext.pixelRatio=e/96}getRenderingDPI(){return this.renderContext.dpi}setPixelRatio(e){this.renderContext.pixelRatio=e,this.renderContext.dpi=96*e}initializeGraphicsEngine(){"u">typeof CDrawingDocument?this.drawingDocument=new CDrawingDocument:this.drawingDocument=new _,this.svgRenderer=null}getGraphicsEngine(){return this.drawingDocument}async processFile(e){try{return this.updateProgress(1,"processing"),await this.processZIP(e),this.updateProgress(1,"active",100),this.updateProgress(2,"processing"),await this.processXMLToDOM(),this.updateProgress(2,"active",100),this.updateProgress(3,"processing"),this.fontEngine.analyzeDocument(this.presentation),this.fontEngine.loadFonts(),this.updateProgress(3,"active",100),this.updateProgress(4,"processing"),this.initializeRendering(),this.updateProgress(4,"active",100),this.updateProgress(5,"processing"),await this.preloadAllImages(),this.updateProgress(5,"active",100),this.updateProgress(6,"active",100),!0}catch(e){throw e}}updateProgress(e,t,r=0){let i=document.getElementById(`progress${e}`);i&&(i.style.width=`${r}%`);let a=document.getElementById(`step${e}`);a&&(a.classList.remove("active","processing"),t&&a.classList.add(t))}async processZIP(e){if(this.zip="u">typeof ZLib?new ZLib:new F,!await this.zip.open(e))throw Error("Failed to open ZIP archive");this.zip.getPaths().filter(e=>e.includes("slide")&&e.endsWith(".xml"));let t="u">typeof globalThis&&globalThis.OpenXmlPackage||"u">typeof window&&window.OpenXmlPackage||function(){class e{constructor(e,t,r){this.package=e,this.uri=t,this.contentType=r,this._content=null}async getDocumentContent(){if(null===this._content){let e=this.uri.startsWith("/")?this.uri.substring(1):this.uri;this._content=await this.package.zip.getFileText(e)}return this._content}async getRelationships(){if(this.package.relationships[this.uri])return this.package.relationships[this.uri];let e=this.uri.replace(/\/([^\/]+)$/,"/_rels/$1.rels"),t=e.startsWith("/")?e.substring(1):e,r=await this.package.zip.getFileText(t);return r?this.package.parseRelationships(r):{}}}class t{constructor(e){this.zip=e,this.parts={},this.contentTypes={},this.relationships={}}async initialize(){let t=await this.zip.getFileText("[Content_Types].xml");t&&this.parseContentTypes(t);let r=await this.zip.getFileText("_rels/.rels");r&&(this.relationships[""]=this.parseRelationships(r));let i=this.zip.getPaths();for(let e of i)if(e.startsWith("_rels/")&&e.endsWith(".rels")&&"_rels/.rels"!==e){let t=e.match(/^(.+)\/_rels\/(.+)\.rels$/);if(t){let r=t[1],i=t[2],a=`/${r}/${i}`,o=await this.zip.getFileText(e);o&&(this.relationships[a]=this.parseRelationships(o))}}for(let t of i)if(!t.startsWith("_rels/")&&"[Content_Types].xml"!==t){let r=`/${t}`,i=this.getContentType(r);this.parts[r]=new e(this,r,i)}}parseContentTypes(e){let t=new DOMParser().parseFromString(e,"text/xml");t.querySelectorAll("Default").forEach(e=>{let t=e.getAttribute("Extension"),r=e.getAttribute("ContentType");t&&(this.contentTypes[`ext:${t}`]=r)}),t.querySelectorAll("Override").forEach(e=>{let t=e.getAttribute("PartName"),r=e.getAttribute("ContentType");t&&(this.contentTypes[t]=r)})}parseRelationships(e){let t=new DOMParser().parseFromString(e,"text/xml"),r={},i=t.getElementsByTagName("*");for(let e=0;e<i.length;e++){let t=i[e];if("Relationship"===t.localName){let e=t.getAttribute("Id"),i=t.getAttribute("Type"),a=t.getAttribute("Target");e&&(r[e]={type:i,target:a,targetMode:t.getAttribute("TargetMode")||"Internal"})}}return r}getContentType(e){if(this.contentTypes[e])return this.contentTypes[e];let t=e.split(".").pop();return t&&this.contentTypes[`ext:${t}`]?this.contentTypes[`ext:${t}`]:"application/octet-stream"}getPartByRelationshipType(e){for(let t of Object.values(this.relationships[""]||{}))if(t.type===e){let e=t.target.startsWith("/")?t.target:`/${t.target}`;return this.parts[e]}return null}getPartByUri(e){return this.parts[e]||null}}return t}();this.package=new t(this.zip),await this.package.initialize();try{this.package&&this.package.relationships&&Object.keys(this.package.relationships)}catch(e){}}async processXMLToDOM(){try{let e="u">typeof globalThis&&globalThis.XmlParserContext?globalThis.XmlParserContext:"u">typeof window?window.XmlParserContext:null;this.xmlParser=e?new e:{zip:null},this.xmlParser.zip=this.zip;let t=this.xmlParser,r=this.package.getPartByRelationshipType(I.presentation?I.presentation.relationType:void 0);if(!r){if(!(r=this.package.getPartByUri("/ppt/presentation.xml")||this.package.getPartByUri("ppt/presentation.xml"))){let e=Object.keys(this.package.parts||{}).find(e=>/presentation\.xml$/i.test(e));e&&(r=this.package.getPartByUri(e))}if(!r&&this.zip&&"function"==typeof this.zip.getPaths)try{let e=this.zip.getPaths(),t=e.find(e=>/^(?:\/?|)ppt\/presentation\.xml$/i.test(e));if(t||(t=e.find(e=>/presentation\.xml$/i.test(e))),t){let e=t.startsWith("/")?t:`/${t}`,i=this,a=new class{constructor(e,t){this.package=e,this.uri=t,this._content=null}async getDocumentContent(){if(null===this._content){let e=this.uri.startsWith("/")?this.uri.substring(1):this.uri;this._content=await i.zip.getFileText(e)}return this._content}async getRelationships(){let e=this.uri.replace(/\/([^\/]+)$/,"/_rels/$1.rels"),t=e.startsWith("/")?e.substring(1):e,r=await i.zip.getFileText(t);return r&&i.package&&"function"==typeof i.package.parseRelationships?i.package.parseRelationships(r):{}}}(this.package,e);this.package&&this.package.parts&&(this.package.parts[e]=a),r=a}}catch(e){}if(!r)throw Error("No presentation document found in PPTX file")}let i=await r.getDocumentContent();if(!i)throw Error("Failed to extract presentation XML content");let a="u">typeof globalThis&&globalThis.StaxParser||"u">typeof window&&window.StaxParser||null;if(!a)throw Error("StaxParser is not defined");let o=new a(i,r,t).parse();if(!o)throw Error("Failed to parse presentation XML document");if(this.presentation=this.createPresentationFromXML(o),!this.presentation)throw Error("Failed to create presentation object from XML");await this.processThemes(t,r),await this.processSlideMasters(t,r),await this.processSlides(t),await this.processImages(t),this.buildSVGRelationshipMapping()}catch(e){throw e}}createPresentationFromXML(e){try{let t="u">typeof globalThis&&globalThis.CPresentation||"u">typeof window&&window.CPresentation||null;if(!t)throw Error("CPresentation is not defined");let r=new t,i=e.documentElement;if(i){let e=i.querySelector("sldSz, p\\:sldSz");e&&(r.slideSize={cx:parseInt(e.getAttribute("cx"))||9144e3,cy:parseInt(e.getAttribute("cy"))||6858e3});let t=i.querySelector("sldMasterIdLst, p\\:sldMasterIdLst");if(t){let e=[];t.querySelectorAll("sldMasterId, p\\:sldMasterId").forEach(t=>{let r=t.getAttribute("r:id")||t.getAttribute("id");r&&e.push(r)}),r.masterIds=e}let a=i.querySelector("sldIdLst, p\\:sldIdLst");if(a){let e=[];a.querySelectorAll("sldId, p\\:sldId").forEach(t=>{let r=t.getAttribute("r:id")||t.getAttribute("id");r&&e.push(r)}),r.slideIds=e}let o=i.querySelector("defaultTextStyle, p\\:defaultTextStyle");o&&(r.defaultTextStyle=this.parseTextStyleElement(o))}return r}catch(t){let e=new CPresentation;return e.slideSize={cx:9144e3,cy:6858e3},e}}async processImages(e){try{"function"==typeof this.extractMediaMap?await this.extractMediaMap():await this.extractImageMap()}catch(e){await this.extractImageMap()}await this.preloadAllImages(),this.logImageProcessingResults()}logImageProcessingResults(){let e=[];for(let[t,r]of this.imageMap){let i=this.imageCache.has(t);e.push({relId:t,imagePath:r,cached:i})}this.zip.getPaths().filter(e=>e.startsWith("ppt/media/")&&this.isImageFile(e))}async extractMediaMap(){let e=[];for(let t of this.zip.getPaths())t.startsWith("ppt/media/")&&e.push(t);let t=[],r=this.package.getPartByRelationshipType(I.presentation.relationType);if(r&&t.push(r),this.slides&&this.slides.length>0){let e=Object.keys(this.package.parts);for(let r of(Object.keys(this.package.relationships),e))if(r.includes("/slides/slide")&&r.endsWith(".xml")){let e=this.package.getPartByUri(r);e&&t.push(e)}}if(this.slideMasters&&this.slideMasters.length>0){for(let e of Object.keys(this.package.parts))if(e.includes("/slideMasters/slideMaster")&&e.endsWith(".xml")){let r=this.package.getPartByUri(e);r&&t.push(r)}}if(this.slideLayouts&&this.slideLayouts.length>0){for(let e of Object.keys(this.package.parts))if(e.includes("/slideLayouts/slideLayout")&&e.endsWith(".xml")){let r=this.package.getPartByUri(e);r&&t.push(r)}}for(let e of t)await this.extractPartMediaRelationships(e)}async extractImageMap(){let e=[];for(let t of this.zip.getPaths())t.startsWith("ppt/media/")&&this.isImageFile(t)&&e.push(t);for(let e of[this.package.getPartByRelationshipType(I.presentation.relationType),...this.slides.map((e,t)=>this.package.getPartByUri(`/ppt/slides/slide${t+1}.xml`)),...this.slideMasters.map((e,t)=>this.package.getPartByUri(`/ppt/slideMasters/slideMaster${t+1}.xml`)),...this.slideLayouts.map((e,t)=>this.package.getPartByUri(`/ppt/slideLayouts/slideLayout${t+1}.xml`))].filter(e=>null!==e))await this.extractPartImageRelationships(e)}async extractPartImageRelationships(e){try{let t=await e.getRelationships();for(let[e,r]of Object.entries(t))if(r.type===I.image.relationType){let t=r.target;t.startsWith("../")?t=t.replace("../","ppt/"):t.startsWith("/")||(t=`/ppt/${t}`),this.imageMap.set(e,t)}}catch(e){}}isImageFile(e){let t=e.toLowerCase();return[".png",".jpg",".jpeg",".gif",".bmp",".svg",".webp",".tiff"].some(e=>t.endsWith(e))}async preloadSlideImages(e){if(!this.slides[e]||!this.slides[e].commonSlideData)return;let t=this.slides[e],r=this.extractImageRelationshipsFromSlide(t).map(e=>this.loadImage(e));await Promise.allSettled(r)}async preloadAllImages(){let e=new Set;for(let t of this.slides)this.extractImageRelationshipsFromSlide(t).forEach(t=>e.add(t)),t.backgroundFill&&t.backgroundFill.fill&&"image"===t.backgroundFill.fill.type&&t.backgroundFill.fill.imageData?.relationshipId&&e.add(t.backgroundFill.fill.imageData.relationshipId);for(let t of this.slideMasters)t.cSld?.bg?.fill?.type==="image"&&t.cSld.bg.fill.imageData?.relationshipId&&e.add(t.cSld.bg.fill.imageData.relationshipId);let t=Array.from(e);for(let e=0;e<t.length;e+=5){let r=t.slice(e,e+5).map(e=>this.loadImage(e));await Promise.allSettled(r),t.length}}extractImageRelationshipsFromSlide(e){let t=[];if(e.commonSlideData&&e.commonSlideData.shapeTree)for(let r of e.commonSlideData.shapeTree)"pic"===r.type&&r.imageRelId&&t.push(r.imageRelId),"grpSp"===r.type&&r.shapeTree&&t.push(...this.extractImageRelationshipsFromShapeTree(r.shapeTree));return t}extractImageRelationshipsFromShapeTree(e){let t=[];for(let r of e)"pic"===r.type&&r.imageRelId&&t.push(r.imageRelId),"grpSp"===r.type&&r.shapeTree&&t.push(...this.extractImageRelationshipsFromShapeTree(r.shapeTree));return t}updateShapeImageRelIds(e,t,r){if(!e.commonSlideData?.shapeTree)return;let i=e=>{for(let a of e)"pic"===a.type&&a.imageRelId===t&&(a.imageRelId=r),"grpSp"===a.type&&a.shapeTree&&i(a.shapeTree)};i(e.commonSlideData.shapeTree)}async preloadAllImages(){try{let e=new Set;for(let t=0;t<this.slides.length;t++){let r=this.slides[t],i=this.extractImageRelationshipsFromSlide(r);if(0!==i.length)if(r.partUri)try{let t=this.package.getPartByUri(r.partUri);if(t){let a=await t.getRelationships(),o=r.partUri.replace(/^\//,"");for(let t of i)if(a&&a[t]){let e=a[t].target;e.startsWith("../")?e=e.replace("../","ppt/"):e.startsWith("/")||e.startsWith("ppt/")||(e=`ppt/${e}`);let i=`slide:${o}:${t}`;if(!this.imageCache.has(i))try{let t=await this.zip.getFileData(e).catch(()=>null);if(t){let r=new Blob([t],{type:this.getMimeType(e)}),a=URL.createObjectURL(r),o=await this.imageLoader.loadImageFromUrl(a);this.imageCache.set(i,{image:o,url:a,path:e,width:o.naturalWidth,height:o.naturalHeight})}}catch(e){}this.updateShapeImageRelIds(r,t,i)}else e.add(t)}else i.forEach(t=>e.add(t))}catch(t){i.forEach(t=>e.add(t))}else i.forEach(t=>e.add(t))}for(let t of this.slideLayouts){let r=t.cSld?.bg?.fill||t.commonSlideData?.backgroundFill?.fill;if(r?.type==="image"&&r.imageData?.relationshipId&&t.layoutPath){let i=r.imageData.relationshipId,a=`layout_bg:${t.layoutPath}`;try{let e=this.package.getPartByUri("/"+t.layoutPath);if(e){let t=await e.getRelationships();if(t&&t[i]){let e=t[i].target;e.startsWith("../")?e=e.replace("../","ppt/"):e.startsWith("/")||(e=`ppt/${e}`);let o=await this.zip.getFileData(e);if(o&&!this.isSVGFile(e)){let t=new Blob([o],{type:this.getMimeType(e)}),i=URL.createObjectURL(t),l=await this.imageLoader.loadImageFromUrl(i);this.imageCache.set(a,{image:l,url:i,path:e,width:l.naturalWidth,height:l.naturalHeight}),r.imageData.resolvedCacheKey=a}}}}catch(t){e.add(i)}}}for(let t of this.slideLayouts){if(!t.layoutPath)continue;let r=this.extractImageRelationshipsFromSlide(t);if(0!==r.length)try{let i=this.package.getPartByUri("/"+t.layoutPath);if(i){let a=await i.getRelationships();for(let i of r)if(a&&a[i]){let e=a[i].target;e.startsWith("../")?e=e.replace("../","ppt/"):e.startsWith("/")||e.startsWith("ppt/")||(e=`ppt/${e}`);let r=`layout:${t.layoutPath}:${i}`;if(!this.imageCache.has(r)){let t=await this.zip.getFileData(e).catch(()=>null);if(t&&!this.isSVGFile(e)){let i=new Blob([t],{type:this.getMimeType(e)}),a=URL.createObjectURL(i),o=await this.imageLoader.loadImageFromUrl(a);this.imageCache.set(r,{image:o,url:a,path:e,width:o.naturalWidth,height:o.naturalHeight})}}this.updateShapeImageRelIds(t,i,r)}else e.add(i)}else r.forEach(t=>e.add(t))}catch(t){r.forEach(t=>e.add(t))}}let t=Array.from(e).map(e=>this.loadImage(e).catch(t=>(this.logger.log("warn",this.constructor.name,`Failed to preload image ${e}:`,t),null)));(await Promise.allSettled(t)).filter(e=>"fulfilled"===e.status&&null!==e.value).length}catch(e){this.logger.logError(this.constructor.name,"Error during image preloading:",e)}}async loadImage(e){let t=this.svgRelationshipMap.get(e);if(t&&(e=t),this.imageCache.has(e))return this.imageCache.get(e);let r=this.imageMap.get(e);if(!r)return this.logger.log("warn",this.constructor.name,`No image path found for relId: ${e}`),null;if(r.startsWith("data:")){if(r.startsWith("data:image/svg+xml"))try{let t=r.split(",")[1],i=atob(t);return this.imageCache.set(e,{type:"svg",content:i,path:r,width:100,height:100}),this.imageCache.get(e)}catch(t){this.logger.logError(this.constructor.name,`Failed to decode SVG data URI for ${e}:`,t)}return null}try{let t=await this.zip.getFileData(r);if(!t)return null;let i=new Blob([t],{type:this.getMimeType(r)}),a=URL.createObjectURL(i),o=await this.imageLoader.loadImageFromUrl(a);return this.imageCache.set(e,{image:o,url:a,path:r,width:o.naturalWidth,height:o.naturalHeight}),this.imageCache.get(e)}catch(e){return null}}getMimeType(e){return({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"})[e.toLowerCase().split(".").pop()]||"image/png"}async processThemes(e,t){try{let e=await t.getRelationships();if(!e){let e=new CTheme;this.presentation.theme=e;return}let r=Object.values(e).find(e=>e.type&&e.type.includes("theme")&&e.target);if(!r){let e=new CTheme;this.presentation.theme=e;return}let i=r.target;i.startsWith("/")?i=i.substring(1):i.startsWith("../")&&(i=i.replace("../","")),i.startsWith("ppt/")||(i="ppt/"+i);let a=await this.zip.getFileText(i);if(!a){let e=new CTheme;this.presentation.theme=e;return}let o=new DOMParser().parseFromString(a,"text/xml");if("parsererror"===o.documentElement.nodeName){let e=new CTheme;this.presentation.theme=e;return}let l=this.parseThemeFromXML(o);if(l)this.presentation.theme=l;else{let e=new CTheme;this.presentation.theme=e}}catch(t){let e=new CTheme;this.presentation.theme=e}}parseThemeFromXML(e){try{let t=e.querySelector("a\\:theme, theme");if(!t)return null;let r=t.querySelector("a\\:themeElements a\\:clrScheme, themeElements clrScheme");if(!r)return null;let i=new CTheme;i.name=t.getAttribute("name")||"Default Theme",i.colors={},i.fonts={major:"Calibri",minor:"Calibri"},i.colors=this.extractEnhancedThemeColors(r),i.colors.accent6&&this.parseColorFromHex(i.colors.accent6);let a=t.querySelector("a\\:themeElements a\\:fontScheme, themeElements fontScheme");if(a){let e=a.querySelector("a\\:majorFont a\\:latin, majorFont latin"),t=a.querySelector("a\\:minorFont a\\:latin, minorFont latin");e&&(i.fonts.major=e.getAttribute("typeface")||"Calibri"),t&&(i.fonts.minor=t.getAttribute("typeface")||"Calibri")}let o=t.querySelector("a\\:themeElements a\\:fmtScheme, themeElements fmtScheme");return o?i.formatScheme=this.parseEnhancedFormatScheme(o,i.colors):i.formatScheme=this.createEnhancedDefaultFormatScheme(i.colors),i.metadata={extracted:!0,source:"pptx_file",timestamp:new Date().toISOString(),colorCount:Object.keys(i.colors).length,fillStyleCount:i.formatScheme.fillStyles?.length||0,backgroundFillCount:i.formatScheme.backgroundFills?.length||0},window.extractedTheme=i,i}catch(e){return null}}extractEnhancedThemeColors(e){let t={};try{for(let r of["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink","bg1","tx1","bg2","tx2"]){let i=e.querySelector(`a\\:${r}, ${r}`)||e.querySelector(`[name="${r}"]`);if(i){let e=this.extractColorFromThemeElement(i);e&&(t[r]=e)}}for(let r of e.querySelectorAll("*")){let e=r.tagName.replace("a:","");if(!t[e]&&"clrScheme"!==e&&"themeElements"!==e){let i=this.extractColorFromThemeElement(r);i&&(t[e]=i)}}t.dk1&&!t.tx1&&(t.tx1=t.dk1),t.lt1&&!t.bg1&&(t.bg1=t.lt1),t.dk2&&!t.tx2&&(t.tx2=t.dk2),t.lt2&&!t.bg2&&(t.bg2=t.lt2)}catch(e){}return t}extractColorFromThemeElement(e){try{let t=e.querySelector("a\\:srgbClr, srgbClr");if(t){let e=t.getAttribute("val");if(e&&/^[0-9A-Fa-f]{6}$/.test(e))return`#${e.toUpperCase()}`}let r=e.querySelector("a\\:sysClr, sysClr");if(r){let e=r.getAttribute("lastClr");if(e&&/^[0-9A-Fa-f]{6}$/.test(e))return`#${e.toUpperCase()}`;let t=r.getAttribute("val"),i={windowText:"#000000",window:"#FFFFFF",btnFace:"#F0F0F0",btnText:"#000000"};if(t&&i[t])return i[t]}let i=e.querySelector("a\\:hslClr, hslClr");if(i){let e=parseInt(i.getAttribute("hue")||"0"),t=parseInt(i.getAttribute("sat")||"0")/1e5,r=parseInt(i.getAttribute("lum")||"0")/1e5;return this.hslToHex(e/6e4,t,r)}let a=e.querySelector("a\\:prstClr, prstClr");if(a){let e=a.getAttribute("val"),t={black:"#000000",white:"#FFFFFF",red:"#FF0000",green:"#00FF00",blue:"#0000FF",yellow:"#FFFF00",magenta:"#FF00FF",cyan:"#00FFFF"};if(e&&t[e])return t[e]}}catch(e){}return null}hslToHex(e,t,r){let i=(e,t,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6)?e+(t-e)*6*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e,a=r<.5?r*(1+t):r+t-r*t,o=2*r-a,l=Math.round(255*i(o,a,e+1/3)),s=Math.round(255*i(o,a,e)),n=Math.round(255*i(o,a,e-1/3));return`#${(0x1000000+(l<<16)+(s<<8)+n).toString(16).slice(1).toUpperCase()}`}parseFormatScheme(e){let t={fillStyles:[],backgroundFills:[],lineStyles:[]};try{let r=e.querySelector("a\\:fillStyleLst, fillStyleLst");if(r){let e=r.children;for(let r=0;r<e.length;r++){let i=e[r],a=this.parseThemeFillStyle(i);a&&t.fillStyles.push(a)}}let i=e.querySelector("a\\:bgFillStyleLst, bgFillStyleLst");if(i){let e=i.children;for(let r=0;r<e.length;r++){let i=e[r],a=this.parseThemeFillStyle(i);a&&t.backgroundFills.push(a)}}let a=e.querySelector("a\\:lnStyleLst, lnStyleLst");if(a)for(let e of a.children){let r=this.parseThemeLineStyle(e);r&&t.lineStyles.push(r)}}catch(e){}return 0===t.fillStyles.length&&(t.fillStyles=this.createDefaultFormatScheme().fillStyles),0===t.backgroundFills.length&&(t.backgroundFills=this.createDefaultFormatScheme().backgroundFills),t}parseThemeFillStyle(e){try{switch(e.tagName.replace("a:","").toLowerCase()){case"solidfill":let t=this.parseFill(e);if(t&&t.color&&"placeholder"===t.color.type)return{type:"solid",color:t.color,rawElement:e.outerHTML};if(t)return t;return{type:"solid",color:{r:128,g:128,b:128,a:255},rawElement:e.outerHTML};case"gradfill":let r=this.parseFill(e);if(r&&"gradient"===r.type)return{type:"gradient",...r,rawElement:e.outerHTML};let i=e.querySelectorAll("a\\:gs, gs"),a=[];for(let e=0;e<i.length;e++){let t=i[e],r=parseFloat(t.getAttribute("pos")||"0")/1e5,o=t.querySelector("a\\:schemeClr, schemeClr, a\\:srgbClr, srgbClr, a\\:hslClr, hslClr"),l={type:"placeholder",value:"phClr"};if(o){let e=o.tagName.replace("a:","").toLowerCase();if("schemeclr"===e){let e=o.getAttribute("val")||"phClr",r=this.parseColorModifications(t),i=this.parseColorModifications(o),a=[...r,...i];l={type:"phClr"===e?"placeholder":"scheme",value:e,modifications:a}}else if("srgbclr"===e){let e=o.getAttribute("val");e&&(l=this.parseColorFromHex(`#${e}`))}}a.push({position:r,color:l})}return 0===a.length&&a.push({position:0,color:{type:"placeholder",value:"phClr"}},{position:1,color:{type:"placeholder",value:"phClr"}}),{type:"gradient",direction:"linear",angle:0,stops:a,rawElement:e.outerHTML};case"blipfill":case"pattfill":return this.parseFill(e);case"nofill":return{type:"none"};default:return{type:"solid",color:{r:128,g:128,b:128,a:255},rawElement:e.outerHTML}}}catch(t){return{type:"solid",color:{r:128,g:128,b:128,a:255},rawElement:e.outerHTML}}}parseThemeLineStyle(e){try{return this.parseStroke(e)}catch(e){return null}}parseEnhancedFormatScheme(e,t){let r={fillStyles:[],backgroundFills:[],lineStyles:[]};try{let i=e.querySelector("a\\:fillStyleLst, fillStyleLst");if(i){let e=i.children;for(let i=0;i<e.length;i++){let a=e[i],o=this.parseThemeAwareFillStyle(a,t,i);if(o)r.fillStyles.push(o);else{let e=this.createFallbackFillStyle(i,t);r.fillStyles.push(e)}}}let a=e.querySelector("a\\:bgFillStyleLst, bgFillStyleLst");if(a){let e=a.children;for(let i=0;i<e.length;i++){let a=e[i],o=this.parseThemeAwareFillStyle(a,t,i);if(o)r.backgroundFills.push(o);else{let e=this.createFallbackBackgroundFillStyle(i,t);r.backgroundFills.push(e)}}}}catch(e){}return this.ensureMinimumFormatSchemeStyles(r,t),r}parseThemeAwareFillStyle(e,t,r){try{let i=e.tagName.replace("a:","").toLowerCase();if("solidfill"===i)return this.parseThemeAwareSolidFill(e,t,r);if("gradfill"===i)return this.parseThemeAwareGradientFill(e,t,r);if("nofill"===i)return{type:"none",index:r};let a=this.parseThemeFillStyle(e);if(a)return a.index=r,a;return null}catch(e){return null}}parseThemeAwareSolidFill(e,t,r){let i={type:"solid",index:r,color:null};try{let a=e.querySelector("a\\:schemeClr, schemeClr");if(a){let e=a.getAttribute("val");if(e&&t[e]){i.color=this.parseColorFromHex(t[e]);let r=this.parseColorModifications(a);return r.length>0&&(i.color=this.applyColorModifications(i.color,r)),i.scheme=e,i.modifications=r,i}}let o=e.querySelector("a\\:srgbClr, srgbClr");if(o){let e=o.getAttribute("val");if(e)return i.color=this.parseColorFromHex(`#${e}`),i}i.color=this.getDefaultColorForIndex(r,t),i.isDefault=!0}catch(e){i.color=this.getDefaultColorForIndex(r,t),i.isDefault=!0}return i}parseThemeAwareGradientFill(e,t,r){let i={type:"gradient",index:r,gradient:{type:"linear",stops:[]}};try{let r=e.querySelectorAll("a\\:gs, gs");for(let e=0;e<r.length;e++){let a=r[e],o={position:parseFloat(a.getAttribute("pos")||"0")/1e5,color:null},l=a.querySelector("a\\:schemeClr, schemeClr");if(l){let e=l.getAttribute("val");if(e&&t[e]){o.color=this.parseColorFromHex(t[e]);let r=this.parseColorModifications(l);r.length>0&&(o.color=this.applyColorModifications(o.color,r))}}if(!o.color){let e=a.querySelector("a\\:srgbClr, srgbClr");if(e){let t=e.getAttribute("val");t&&(o.color=this.parseColorFromHex(`#${t}`))}}o.color||(o.color=this.getDefaultColorForIndex(e,t)),i.gradient.stops.push(o)}let a=e.querySelector("a\\:lin, lin");if(a){let e=parseInt(a.getAttribute("ang")||"0");i.gradient.angle=e/6e4}return i}catch(e){return{type:"solid",index:r,color:this.getDefaultColorForIndex(r,t),isDefault:!0}}}getDefaultColorForIndex(e,t){let r=["accent1","accent2","accent3","accent4","accent5","accent6"],i=r[e%r.length];return t&&t[i]?this.parseColorFromHex(t[i]):null}ensureMinimumFormatSchemeStyles(e,t){for(;e.fillStyles.length<6;){let r=e.fillStyles.length,i=this.createFallbackFillStyle(r,t);e.fillStyles.push(i)}for(;e.backgroundFills.length<3;){let r=e.backgroundFills.length,i=this.createFallbackBackgroundFillStyle(r,t);e.backgroundFills.push(i)}}createFallbackFillStyle(e,t){return{type:"solid",index:e,color:this.getDefaultColorForIndex(e,t),isDefault:!0}}createFallbackBackgroundFillStyle(e,t){let r=[t?.bg1?this.parseColorFromHex(t.bg1):{r:255,g:255,b:255,a:255},t?.bg2?this.parseColorFromHex(t.bg2):{r:245,g:245,b:245,a:255},{r:220,g:220,b:220,a:255}];return{type:"solid",index:e,color:r[e%r.length],isDefault:!0}}createEnhancedDefaultFormatScheme(e){let t={fillStyles:[],backgroundFills:[],lineStyles:[]};for(let r=0;r<6;r++)t.fillStyles.push(this.createFallbackFillStyle(r,e));for(let r=0;r<3;r++)t.backgroundFills.push(this.createFallbackBackgroundFillStyle(r,e));return t}createDefaultFormatScheme(){return{fillStyles:[],backgroundFills:[],lineStyles:[]}}async processSlideMasters(e,t){let r=this.presentation.masterIds||[],i=await t.getRelationships();for(let t of r){let r=i[t];if(r&&r.target){let t=r.target;t.startsWith("/")?t=t.substring(1):t.startsWith("../")&&(t=t.replace("../","")),t.startsWith("ppt/")||(t="ppt/"+t);let i=this.package.getPartByUri("/"+t);if(i){let t=await i.getDocumentContent();if(t){let r=new StaxParser(t,i,e).parse();if(r){let t=this.createSlideMasterFromXML(r,i);t&&(this.slideMasters.push(t),this.presentation.addSlideMaster(t),await this.processSlideLayouts(e,t,i))}}}}}}async processSlideLayouts(e,t,r){for(let[i,a]of Object.entries(await r.getRelationships()))if(a.type===I.slideLayout.relationType){let r=a.target;r.startsWith("/")?r=r.substring(1):r.startsWith("../")&&(r=r.replace("../","")),r.startsWith("ppt/")||(r="ppt/"+r);let o=this.package.getPartByUri("/"+r);if(o){let l=await o.getDocumentContent();if(l){let s=new StaxParser(l,o,e).parse();if(s){let e=this.createSlideLayoutFromXML(s,t.id,i,a.target,r);e&&(this.slideLayouts.push(e),t.addLayout(e))}}}}}createSlideMasterFromXML(e,t){let r=e.documentElement,i=t.uri||"master_"+this.slideMasters.length,a=new CSlideMaster;a.id=i,a.name=r.getAttribute("name")||`Master ${this.slideMasters.length+1}`,a.layoutIds=[];let o=e.querySelector("sldLayoutIdLst, p\\:sldLayoutIdLst");o&&o.querySelectorAll("sldLayoutId, p\\:sldLayoutId").forEach(e=>{let t=e.getAttribute("r:id");t&&a.layoutIds.push(t)});let l=e.querySelector("cSld, p\\:cSld");l&&(a.cSld={name:l.getAttribute("name")||"",bg:this.parseBackground(l),spTree:this.processShapeTree(l.querySelector("spTree, p\\:spTree"))},a.commonSlideData=new CSld,a.commonSlideData.name=a.cSld.name,a.commonSlideData.backgroundFill=a.cSld.bg,a.commonSlideData.shapeTree=a.cSld.spTree);let s=e.querySelector("txStyles, p\\:txStyles");s&&(a.txStyles={titleStyle:this.parseTextStyleElement(s.querySelector("titleStyle, p\\:titleStyle")),bodyStyle:this.parseTextStyleElement(s.querySelector("bodyStyle, p\\:bodyStyle")),otherStyle:this.parseTextStyleElement(s.querySelector("otherStyle, p\\:otherStyle"))});let n=e.querySelector("clrMap, p\\:clrMap");return n&&(a.clrMap=this.parseColorMapElement(n)),this.xmlParser.registerSlideMaster(a.id,a),a}createSlideLayoutFromXML(e,t,r=null,i=null,a=null){let o=e.documentElement,l=r||`layout_${this.slideLayouts.length}`,s=new CSlideLayout;s.id=l,s.relId=r,s.relTarget=i,s.layoutPath=a,s.uri=i,s.masterId=t,s.name=o.getAttribute("name")||`Layout ${this.slideLayouts.length+1}`,s.type=o.getAttribute("type")||"blank",s.matchingName=o.getAttribute("matchingName")||"",s.preserve="true"===o.getAttribute("preserve"),s.showMasterSp="false"!==o.getAttribute("showMasterSp"),s.showMasterPhAnim="true"===o.getAttribute("showMasterPhAnim"),s.userDrawn="false"!==o.getAttribute("userDrawn"),"blank"===s.type?s.layoutType=this.inferLayoutTypeFromPlaceholders(o):s.layoutType=s.type;let n=e.querySelector("cSld, p\\:cSld");if(n){let e=n.querySelector("spTree, p\\:spTree"),t=this.processShapeTree(e);s.cSld={name:n.getAttribute("name")||"",bg:this.parseBackground(n),spTree:t},s.commonSlideData=new CSld,s.commonSlideData.name=s.cSld.name,s.commonSlideData.backgroundFill=s.cSld.bg,s.commonSlideData.shapeTree=s.cSld.spTree}let h=e.querySelector("txStyles, p\\:txStyles");h&&(s.txStyles={titleStyle:this.parseTextStyleElement(h.querySelector("titleStyle, p\\:titleStyle")),bodyStyle:this.parseTextStyleElement(h.querySelector("bodyStyle, p\\:bodyStyle")),otherStyle:this.parseTextStyleElement(h.querySelector("otherStyle, p\\:otherStyle"))});let c=e.querySelector("clrMapOvr, p\\:clrMapOvr");return c&&(s.clrMapOvr=this.parseColorMapOverride(c)),this.xmlParser.registerSlideLayout(s.id,s,t),s}async processSlides(e){let t=await this.package.getPartByRelationshipType(I.presentation.relationType).getRelationships(),r=[];for(let[e,i]of Object.entries(t))i.type===I.slide.relationType&&r.push({id:e,target:i.target});if(0===r.length)return;let i=r;try{let e=this.presentation&&Array.isArray(this.presentation.slideIds)?this.presentation.slideIds:[];if(e&&e.length>0){let t=new Map(r.map(e=>[e.id,e])),a=[];for(let r of e){let e=t.get(r);e&&(a.push(e),t.delete(r))}if(t.size>0)for(let e of t.values())a.push(e);a.length>0&&(i=a)}}catch(e){}for(let t=0;t<i.length;t++)try{let r=i[t].target;r.startsWith("/")?r=r.substring(1):r.startsWith("../")&&(r=r.replace("../","")),r.startsWith("ppt/")||(r="ppt/"+r);let a="/"+r,o=this.package.getPartByUri(a);if(!o)continue;await this.processSlidePart(o,e,t)}catch(e){}}createSlideFromXML(e){try{let t=new CSlide;this.currentSlide=t;let r=e.querySelector("cSld, p\\:cSld");if(r){t.commonSlideData=new CSld;let e=r.querySelector("spTree, p\\:spTree");if(e){let r=this.processShapeTree(e);t.commonSlideData.shapeTree=r}r.querySelector("bg, p\\:bg")&&(t.backgroundFill=this.parseBackground(r))}let i=e.documentElement;if(i){t.showMasterShapes="0"!==i.getAttribute("showMasterSp");let e=i.querySelector("name, p\\:name");e&&(t.name=e.textContent||"")}return t}catch(t){let e=new CSlide;return e.commonSlideData=new CSld,e.commonSlideData.shapeTree=[],e}}async processSlidePart(e,t,r){let i=await e.getDocumentContent();if(!i)return;let a=new StaxParser(i,e,t).parse();if(!a)return;let o=this.createSlideFromXML(a);o&&(o.partUri=e.uri,await this.linkSlideToLayoutAndMaster(o,e,t,r),this.slides.push(o),this.presentation.addSlide(o))}async linkSlideToLayoutAndMaster(e,t,r,i){try{let r=await t.getRelationships();for(let[t,i]of Object.entries(r))if(i.type===I.slideLayout.relationType){let r=this.slideLayouts.find(e=>{if(i.target&&e.relTarget){let t=i.target.split("/").pop(),r=e.relTarget.split("/").pop();if(t===r)return!0}return!1});if(r||(r=this.slideLayouts.find(e=>e.uri===i.target)),r||(r=this.slideLayouts.find(e=>{if(i.target&&e.relTarget){let t=e=>e.replace(/^\.\.\//,"").replace(/^\//,"");if(t(i.target)===t(e.relTarget))return!0}return!1})),r||(r=this.slideLayouts.find(e=>e.relId===t)),r){e.layout=r,e.Layout=r;let t=this.slideMasters.find(e=>e.id===r.masterId);t&&(e.master=t,e.Master=t,r.master=t,r.Master=t);break}}!e.layout&&this.slideLayouts.length>0?(e.layout=this.slideLayouts[0],e.Layout=this.slideLayouts[0]):e.layout}catch(e){}}processShapeTree(e){let t=[];try{if(!e)return t;let r=e.children;for(let e=0;e<r.length;e++)try{let i=r[e],a=this.processShapeElement(i);a&&t.push(a)}catch(e){}}catch(e){}return t}processShapeElement(e){try{if(!e)return null;let t=e.localName||e.tagName?.toLowerCase(),r=null;switch(t){case"sp":case"p:sp":r=this.processRegularShape(e);break;case"pic":case"p:pic":r=this.processPictureShape(e);break;case"grpsp":case"grpSp":case"p:grpSp":case"p:grpsp":r=this.processGroupShape(e);break;case"cxnsp":case"cxnSp":case"p:cxnSp":case"p:cxnsp":r=this.processConnectorShape(e);break;case"graphicframe":case"graphicFrame":case"p:graphicFrame":case"p:graphicframe":r=this.processGraphicFrame(e);break;default:let i=["nvsppr","p:nvsppr","nvpicpr","p:nvpicpr","nvgrpsppr","p:nvgrpsppr","nvGrpSpPr","p:nvGrpSpPr","nvpr","p:nvpr","cnvpr","p:cnvpr","cnvsppr","p:cnvsppr","style","p:style","txstyles","p:txstyles","extlst","p:extlst","ext","p:ext","grpsppr","p:grpsppr","grpSpPr","p:grpSpPr","sppr","p:sppr","picpr","p:picpr","cxnsppr","p:cxnsppr"];if(i.includes(t)||i.includes(t.toLowerCase()))return null;r=this.processDefaultShape(e)}if(r){r.id=e.getAttribute("id")||Math.random().toString(36).substr(2,9),r.name=this.getShapeName(e)||`Shape_${r.id}`,("Rectangle 3"===r.name||r.name?.includes("Rectangle 3"))&&e.querySelectorAll("p\\:style, style").forEach((e,t)=>{e.querySelector("a\\:fillRef, fillRef")});let t=e.querySelector("spPr, p\\:spPr");if(t){let e=this.processShapeProperties(t);e.transform&&!r.properties?.transform&&(r.properties=r.properties||{},r.properties.transform=e.transform,r.bounds&&(0!==r.bounds.l||0!==r.bounds.t||0!==r.bounds.r||0!==r.bounds.b)||(r.bounds={l:e.transform.x||0,t:e.transform.y||0,r:(e.transform.x||0)+(e.transform.cx||e.transform.width||0),b:(e.transform.y||0)+(e.transform.cy||e.transform.height||0)})),e.fill&&!r.fill&&(r.fill=e.fill),e.stroke&&!r.stroke&&(r.stroke=e.stroke),e.geometry&&!r.geometry&&(r.geometry=e.geometry),r.spPr||(r.spPr=e),e.effectLst&&(r.effects=e.effectLst),r.style||r.preservedStyle}let i=e.querySelector("txBody, p\\:txBody");i&&(r.textBody=this.processTextBody(i))}return r}catch(e){return{type:"unknown",id:Math.random().toString(36).substr(2,9),name:"Unknown Shape",bounds:{l:914400,t:914400,r:5486400,b:2743200}}}}processRegularShape(e){let t=new CShape;t.type="sp",t.name=this.getShapeName(e);let r=e.querySelector("nvSpPr, p\\:nvSpPr"),i=r?.querySelector("cNvPr, p\\:cNvPr");if(t.id=i?.getAttribute("id")||e.getAttribute("id")||null,i){Array.from(i.attributes).map(e=>`${e.name}="${e.value}"`);let e=i.getAttribute("order")||i.getAttribute("z-order")||i.getAttribute("zOrder")||i.getAttribute("drawOrder");e&&(t.order=parseInt(e))}let a=e.getAttribute("order")||e.getAttribute("z-order")||e.getAttribute("zOrder")||e.getAttribute("drawOrder");a&&(t.order=parseInt(a));try{if(r){t.nvSpPr={cNvPr:null,nvPr:null},i&&(t.name=i.getAttribute("name")||t.name,t.nvSpPr.cNvPr={name:t.name,id:t.id});let e=r.querySelector("nvPr, p\\:nvPr");if(e){let r=e.querySelector("ph, p\\:ph");r&&(t.placeholder=this.parsePlaceholder(r),t.isPlaceholder=!0),t.nvSpPr.nvPr={placeholder:t.placeholder}}}t.type="sp";let a=e.querySelector("spPr, p\\:spPr");if(a){let e=this.processShapeProperties(a);t.properties=e,t.spPr=e,e.effectLst&&(t.effects=e.effectLst),e.transform?t.bounds={l:e.transform.x||0,t:e.transform.y||0,r:(e.transform.x||0)+(e.transform.cx||e.transform.width||0),b:(e.transform.y||0)+(e.transform.cy||e.transform.height||0)}:t.bounds={l:914400,t:914400,r:5486400,b:2743200},void 0!==e.fill&&(t.fill=e.fill),e.stroke&&(t.stroke=e.stroke);let r=a.querySelector("prstGeom, a\\:prstGeom");if(r){let e=r.getAttribute("prst")||"rect",i={},a=r.querySelector("avLst, a\\:avLst");a&&a.querySelectorAll("gd, a\\:gd").forEach(e=>{let t=e.getAttribute("name"),r=(e.getAttribute("fmla")||"").match(/^val\s+(-?\d+)$/);t&&r&&(i[t]=parseInt(r[1]))}),t.geometry={type:"preset",preset:e,adjustments:i}}let i=a.querySelector("custGeom, a\\:custGeom");i&&(t.geometry={type:"custom",pathList:this.parseCustomGeometry(i)})}else t.bounds={l:914400,t:914400,r:5486400,b:2743200};let o=e.querySelector("txBody, p\\:txBody");if(o&&(t.textBody=this.processTextBody(o),t.textBody&&t.textBody.paragraphs)){for(let e of t.textBody.paragraphs)for(let t of e.runs)t.text&&t.text.trim()&&t.text}let l=!1,s=e.querySelector("style, p\\:style");if(s&&(t.style=this.parseShapeStyle(s),t.preservedStyle=t.style,l=!0),!l&&window.currentSlideData&&window.currentSlideData.rawXMLShapes){let e=window.currentSlideData.rawXMLShapes.find(e=>e.name===t.name||e.id===t.id);e&&e.style&&(t.style=e.style,t.preservedStyle=e.style,l=!0)}if(!l){let r=this.extractStyleFromElement(e);r&&Object.keys(r).length>0&&(t.style=r,t.preservedStyle=r,l=!0)}if(l){window.currentSlideData=window.currentSlideData||{},window.currentSlideData.rawXMLShapes=window.currentSlideData.rawXMLShapes||[];let e=window.currentSlideData.rawXMLShapes.findIndex(e=>e.name===t.name||e.id===t.id);-1===e&&window.currentSlideData.rawXMLShapes.push({name:t.name,id:t.id,styleElement:s,style:t.style,hasStyle:!0})}else window.currentSlideData=window.currentSlideData||{},window.currentSlideData.rawXMLShapes=window.currentSlideData.rawXMLShapes||[],window.currentSlideData.rawXMLShapes.push({name:t.name,id:t.id,xmlElement:e,innerHTML:e.innerHTML.substring(0,500),hasStyle:!1})}catch(e){}return this.applyPropertyInheritance(t),t}processPictureShape(e){let t=new CShape;t.type="pic";let r=!1,i=e.querySelector("style, p\\:style");if(i&&(t.style=this.parseShapeStyle(i),t.preservedStyle=t.style,r=!0),!r&&window.currentSlideData&&window.currentSlideData.rawXMLShapes){let e=window.currentSlideData.rawXMLShapes.find(e=>e.name===t.name||e.id===t.id);e&&e.style&&(t.style=e.style,t.preservedStyle=e.style,r=!0)}if(!r){let i=this.extractStyleFromElement(e);i&&Object.keys(i).length>0&&(t.style=i,t.preservedStyle=i,r=!0)}let a=e.querySelector("spPr, p\\:spPr");if(a){let e=this.processShapeProperties(a);t.properties=e,e.transform?t.bounds={l:e.transform.x||0,t:e.transform.y||0,r:(e.transform.x||0)+(e.transform.cx||e.transform.width||0),b:(e.transform.y||0)+(e.transform.cy||e.transform.height||0)}:t.bounds={l:914400,t:914400,r:5486400,b:2743200}}else t.bounds={l:914400,t:914400,r:5486400,b:2743200};let o=e.querySelector("blipFill, p\\:blipFill");if(o){let e=o.querySelector("blip, a\\:blip");if(e){let r=this.extractSVGRelationshipId(e);if(r)t.imageRelId=r,t.hasSVGAlternative=!0;else{let r=e.getAttribute("r:embed");r&&(t.imageRelId=r)}let i=e.querySelector("effects, a\\:effects");i&&(t.imageEffects=this.parseImageEffects(i))}let r=o.querySelector("stretch, a\\:stretch"),i=o.querySelector("tile, a\\:tile");if(r){t.imageFillMode="stretch";let e=r.querySelector("fillRect, a\\:fillRect");e&&(t.imageFillRect={l:parseInt(e.getAttribute("l"))||0,t:parseInt(e.getAttribute("t"))||0,r:parseInt(e.getAttribute("r"))||0,b:parseInt(e.getAttribute("b"))||0})}else i?(t.imageFillMode="tile",t.imageTileProperties={tx:parseInt(i.getAttribute("tx"))||0,ty:parseInt(i.getAttribute("ty"))||0,sx:parseInt(i.getAttribute("sx"))||1e5,sy:parseInt(i.getAttribute("sy"))||1e5,flip:i.getAttribute("flip")||"none",algn:i.getAttribute("algn")||"tl"}):t.imageFillMode="stretch";let a=o.querySelector("srcRect, a\\:srcRect");a&&(t.imageSrcRect={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 t.name=this.getShapeName(e),this.applyPropertyInheritance(t),t}parseImageEffects(e){let t={},r=e.querySelector("alphaMod, a\\:alphaMod");r&&(t.alpha=parseInt(r.getAttribute("val"))/1e5);let i=e.querySelector("lum, a\\:lum");i&&(t.brightness=parseInt(i.getAttribute("bright"))||0,t.contrast=parseInt(i.getAttribute("contrast"))||0);let a=e.querySelector("clrMod, a\\:clrMod");return a&&(t.colorMod=a.getAttribute("val")),e.querySelector("grayscl, a\\:grayscl")&&(t.grayscale=!0),t}parseEffectList(e){let t={},r=e.querySelector("outerShdw, a\\:outerShdw");r&&(t.outerShadow=this.parseOuterShadow(r));let i=e.querySelector("innerShdw, a\\:innerShdw");i&&(t.innerShadow=this.parseInnerShadow(i));let a=e.querySelector("glow, a\\:glow");a&&(t.glow=this.parseGlow(a));let o=e.querySelector("reflection, a\\:reflection");o&&(t.reflection=this.parseReflection(o));let l=e.querySelector("softEdge, a\\:softEdge");l&&(t.softEdge=this.parseSoftEdge(l));let s=e.querySelector("prstShdw, a\\:prstShdw");return s&&(t.presetShadow=this.parsePresetShadow(s)),t}parseOuterShadow(e){let t={};t.blurRadius=parseInt(e.getAttribute("blurRad"))||0,t.distance=parseInt(e.getAttribute("dist"))||0,t.direction=parseInt(e.getAttribute("dir"))||0,t.scaleX=parseInt(e.getAttribute("sx"))/1e5||1,t.scaleY=parseInt(e.getAttribute("sy"))/1e5||1,t.skewX=parseInt(e.getAttribute("kx"))||0,t.skewY=parseInt(e.getAttribute("ky"))||0,t.alignment=e.getAttribute("algn")||"bl",t.rotateWithShape="1"===e.getAttribute("rotWithShape");let r=e.querySelector("srgbClr, a\\:srgbClr, schemeClr, a\\:schemeClr");return r&&(t.color=this.parseColor(r)),t}parseInnerShadow(e){let t={};t.blurRadius=parseInt(e.getAttribute("blurRad"))||0,t.distance=parseInt(e.getAttribute("dist"))||0,t.direction=parseInt(e.getAttribute("dir"))||0;let r=e.querySelector("srgbClr, a\\:srgbClr, schemeClr, a\\:schemeClr");return r&&(t.color=this.parseColor(r)),t}parseGlow(e){let t={};t.radius=parseInt(e.getAttribute("rad"))||0;let r=e.querySelector("srgbClr, a\\:srgbClr, schemeClr, a\\:schemeClr");return r&&(t.color=this.parseColor(r)),t}parseReflection(e){let t={};return t.blurRadius=parseInt(e.getAttribute("blurRad"))||0,t.startOpacity=parseInt(e.getAttribute("stA"))/1e5||1,t.endOpacity=parseInt(e.getAttribute("endA"))/1e5||0,t.distance=parseInt(e.getAttribute("dist"))||0,t.direction=parseInt(e.getAttribute("dir"))||0,t.fadeDirection=parseInt(e.getAttribute("fadeDir"))||0,t.scaleX=parseInt(e.getAttribute("sx"))/1e5||1,t.scaleY=parseInt(e.getAttribute("sy"))/1e5||1,t.skewX=parseInt(e.getAttribute("kx"))||0,t.skewY=parseInt(e.getAttribute("ky"))||0,t.alignment=e.getAttribute("algn")||"bl",t}parseSoftEdge(e){let t={};return t.radius=parseInt(e.getAttribute("rad"))||0,t}parsePresetShadow(e){let t={};return t.preset=e.getAttribute("prst")||"shdw1",t.distance=parseInt(e.getAttribute("dist"))||0,t.direction=parseInt(e.getAttribute("dir"))||0,t}parseColor(e){let t={};e.tagName.includes("srgbClr")?(t.type="srgb",t.value=e.getAttribute("val")||"000000"):e.tagName.includes("schemeClr")&&(t.type="scheme",t.value=e.getAttribute("val")||"dk1");let r=e.querySelector("alpha, a\\:alpha");return r?t.alpha=parseInt(r.getAttribute("val"))/1e5||1:t.alpha=1,t}processGroupShape(e){let t=new CShape;t.type="grpSp",t.name=this.getShapeName(e),t.id=e.getAttribute("id")||Math.random().toString(36).substr(2,9),t.shapeTree=[],t.groupCoordSystem={chOff:{x:0,y:0},chExt:{cx:0,cy:0},groupOff:{x:0,y:0},groupExt:{cx:0,cy:0}},this.applyComprehensiveStyleExtraction(t,e,"group");let r=e.querySelector("grpSpPr, p\\:grpSpPr");r&&this.processGroupProperties(r,t);let i=e.querySelector("spTree, p\\:spTree");if(i)t.shapeTree=this.processShapeTreeInGroup(i,t);else{let r=e.children;for(let e=0;e<r.length;e++){let i=r[e],a=i.tagName.toLowerCase();if("sp"===a||"p:sp"===a||"pic"===a||"p:pic"===a||"grpsp"===a||"p:grpsp"===a||"cxnsp"===a||"p:cxnsp"===a)try{let e=this.processShapeElement(i);e&&(e.inGroup=!0,e.parentGroup=t,this.transformChildShapeCoordinates(e,t),t.shapeTree.push(e))}catch(e){}}}return t.bounds||this.calculateGroupBounds(t),this.applyPropertyInheritance(t),t}processGroupProperties(e,t){let r=e.querySelector("xfrm, a\\:xfrm");if(r){let e=this.processGroupTransform(r);t.transform=e,t.groupCoordSystem=e.groupCoordSystem,e.groupOff&&e.groupExt&&(t.bounds={l:e.groupOff.x,t:e.groupOff.y,r:e.groupOff.x+e.groupExt.cx,b:e.groupOff.y+e.groupExt.cy})}let i=this.processShapeProperties(e);i.fill&&(t.fill=i.fill),i.stroke&&(t.stroke=i.stroke)}processGroupTransform(e){let t={rotation:0,flipH:!1,flipV:!1,groupOff:{x:0,y:0},groupExt:{cx:0,cy:0},groupCoordSystem:{chOff:{x:0,y:0},chExt:{cx:0,cy:0},groupOff:{x:0,y:0},groupExt:{cx:0,cy:0}}},r=e.getAttribute("rot");r&&(t.rotation=parseInt(r)/6e4),t.flipH="1"===e.getAttribute("flipH")||"true"===e.getAttribute("flipH"),t.flipV="1"===e.getAttribute("flipV")||"true"===e.getAttribute("flipV");let i=e.querySelector("off, a\\:off");i&&(t.groupOff.x=parseInt(i.getAttribute("x"))||0,t.groupOff.y=parseInt(i.getAttribute("y"))||0);let a=e.querySelector("ext, a\\:ext");a&&(t.groupExt.cx=parseInt(a.getAttribute("cx"))||0,t.groupExt.cy=parseInt(a.getAttribute("cy"))||0);let o=e.querySelector("chOff, a\\:chOff");o&&(t.groupCoordSystem.chOff.x=parseInt(o.getAttribute("x"))||0,t.groupCoordSystem.chOff.y=parseInt(o.getAttribute("y"))||0);let l=e.querySelector("chExt, a\\:chExt");return l&&(t.groupCoordSystem.chExt.cx=parseInt(l.getAttribute("cx"))||0,t.groupCoordSystem.chExt.cy=parseInt(l.getAttribute("cy"))||0),t.groupCoordSystem.groupOff={...t.groupOff},t.groupCoordSystem.groupExt={...t.groupExt},t}processShapeTreeInGroup(e,t){let r=[];try{if(!e)return r;let i=e.children;for(let e=0;e<i.length;e++)try{let a=i[e],o=this.processShapeElement(a);o&&(o.inGroup=!0,o.parentGroup=t,this.transformChildShapeCoordinates(o,t),r.push(o))}catch(e){}}catch(e){}return r}transformChildShapeCoordinates(e,t){if(!e.bounds||!t.groupCoordSystem)return;let r=t.groupCoordSystem,i=e.bounds,a=1,o=1;r.chExt.cx>0&&r.groupExt.cx>0&&(a=r.groupExt.cx/r.chExt.cx),r.chExt.cy>0&&r.groupExt.cy>0&&(o=r.groupExt.cy/r.chExt.cy);let l={l:r.groupOff.x+(i.l-r.chOff.x)*a,t:r.groupOff.y+(i.t-r.chOff.y)*o,r:r.groupOff.x+(i.r-r.chOff.x)*a,b:r.groupOff.y+(i.b-r.chOff.y)*o};e.originalBounds={...i},e.bounds=l,e.groupTransform={scaleX:a,scaleY:o,offsetX:r.groupOff.x-r.chOff.x*a,offsetY:r.groupOff.y-r.chOff.y*o}}calculateGroupBounds(e){if(!e.shapeTree||0===e.shapeTree.length){e.bounds={l:914400,t:914400,r:5486400,b:2743200};return}let t=1/0,r=1/0,i=-1/0,a=-1/0,o=!1;for(let l of e.shapeTree)l.bounds&&(t=Math.min(t,l.bounds.l),r=Math.min(r,l.bounds.t),i=Math.max(i,l.bounds.r),a=Math.max(a,l.bounds.b),o=!0);o?e.bounds={l:t,t:r,r:i,b:a}:e.bounds={l:914400,t:914400,r:5486400,b:2743200}}processConnectorShape(e){let t=new CShape;t.type="cxnSp",this.applyComprehensiveStyleExtraction(t,e,"connector");try{let t=e.getAttribute("id")||e.getAttribute("r:id");this.logger?.log("info",this.constructor.name,"[Connector Parse] start",{id:t})}catch(e){}let r=e.querySelector("spPr, p\\:spPr");if(r){let e=this.processShapeProperties(r);t.properties=e,e&&e.stroke&&(t.properties.line||(t.properties.line=e.stroke),t.stroke||(t.stroke=e.stroke)),e&&e.transform&&(t.transform=Object.assign(t.transform||{},e.transform));try{let e=r.querySelector("a\\:ln, ln, p\\:ln");if(e){let r=this.parseStroke(e);t.properties=t.properties||{},t.properties.stroke=r,t.properties.line=r,t.stroke=r,t.spPr=t.spPr||{},t.spPr.ln=Object.assign({},r)}}catch(e){}if(e.geometry&&(t.geometry=e.geometry),e.transform){t.bounds={l:e.transform.x||0,t:e.transform.y||0,r:(e.transform.x||0)+(e.transform.cx||e.transform.width||0),b:(e.transform.y||0)+(e.transform.cy||e.transform.height||0)};try{this.logger?.log("info",this.constructor.name,"[Connector Parse] bounds from transform",{bounds:t.bounds,transform:e.transform})}catch(e){}}else{t.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(e){}try{console.warn("[Connector Parse] no transform; using fallback bounds",t.bounds)}catch(e){}}}else{t.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(e){}try{console.warn("[Connector Parse] no spPr; using fallback bounds",t.bounds)}catch(e){}}this.applyPropertyInheritance(t);try{this.getShapeStrokeColor(t),this.getShapeLineWidth(t),this.getShapeStrokeInfo(t)}catch(e){}return t}processGraphicFrame(e){let t=new CShape;t.type="graphicFrame",this.applyComprehensiveStyleExtraction(t,e,"graphic frame");let r=e.querySelector("spPr, p\\:spPr");if(r){let e=this.processShapeProperties(r);if(e.transform){let r=e.transform.x||0,i=e.transform.y||0,a=e.transform.cx||e.transform.width||0,o=e.transform.cy||e.transform.height||0;t.bounds={l:r,t:i,r:r+a,b:i+o},t.x=r,t.y=i,t.w=a,t.h=o,t.properties||(t.properties={}),t.properties.transform={x:r,y:i,width:a,height:o,cx:a,cy:o}}else t.bounds={l:914400,t:914400,r:5486400,b:2743200},t.x=914400,t.y=914400,t.w=4572e3,t.h=1828800}else{let r=e.querySelector("xfrm, p\\:xfrm");if(r){let i=r.querySelector("off, p\\:off"),a=r.querySelector("ext, p\\:ext");if(i&&a){let r=parseInt(i.getAttribute("x"))||0,o=parseInt(i.getAttribute("y"))||0,l=parseInt(a.getAttribute("cx")),s=parseInt(a.getAttribute("cy")),n=Number.isFinite(l)&&l>=0?l:914400,h=Number.isFinite(s)&&s>=0?s:914400;if(t.bounds={l:r,t:o,r:r+n,b:o+h},t.x=r,t.y=o,t.w=n,t.h=h,t.properties||(t.properties={}),t.properties.transform={x:r,y:o,width:n,height:h,cx:n,cy:h},0===r&&0===o||n<=1e5&&h<=1e5){let i=e.parentElement;for(;i&&i.tagName;){let e=i.querySelector("xfrm, p\\:xfrm");if(e){let r=e.querySelector("off, p\\:off"),i=e.querySelector("ext, p\\:ext");if(r&&i){let e=parseInt(r.getAttribute("x"))||0,a=parseInt(r.getAttribute("y"))||0,o=parseInt(i.getAttribute("cx"))||0,l=parseInt(i.getAttribute("cy"))||0;if(o>1e5&&l>1e5){t.bounds={l:e,t:a,r:e+o,b:a+l},t.x=e,t.y=a,t.w=o,t.h=l,t.properties||(t.properties={}),t.properties.transform={x:e,y:a,width:o,height:l,cx:o,cy:l};break}}}i=i.parentElement}t.bounds&&t.x===r&&t.y}}else t.bounds={l:914400,t:914400,r:5486400,b:2743200},t.x=914400,t.y=914400,t.w=4572e3,t.h=1828800}else t.bounds={l:914400,t:914400,r:5486400,b:2743200},t.x=914400,t.y=914400,t.w=4572e3,t.h=1828800}let i=e.querySelector("graphic");if(i||(i=e.querySelector("p\\:graphic")),i||(i=e.querySelector("a\\:graphic")),i||(i=Array.from(e.children).find(e=>e.tagName.toLowerCase().includes("graphic"))),i){let r=i.querySelector("graphicData");if(r||(r=i.querySelector("p\\:graphicData")),r||(r=i.querySelector("a\\:graphicData")),r||(r=Array.from(i.children).find(e=>e.tagName.toLowerCase().includes("graphicdata"))),r){let i=r.getAttribute("uri");if(t.graphicData={uri:i},"http://schemas.openxmlformats.org/drawingml/2006/table"===i){let e=r.querySelector("tbl");e||(e=r.querySelector("a\\:tbl")),e||(e=Array.from(r.children).find(e=>e.tagName.toLowerCase().includes("tbl"))),e&&(t.graphicData.tableXml=new XMLSerializer().serializeToString(e))}else if("http://schemas.openxmlformats.org/drawingml/2006/chart"===i){t.graphicData.element=r;let i=r.querySelector("chart")||r.querySelector("c\\:chart")||r.querySelector('[*|localName="chart"]');if(i){let e=i.getAttribute("r:id");e&&(t.graphicData.chartRef=e)}if(ChartProcessor)try{t.asyncChartProcessing=!0,t.originalBounds={l:t.bounds.l,t:t.bounds.t,r:t.bounds.r,b:t.bounds.b};let r=t.originalBounds.r-t.originalBounds.l,i=t.originalBounds.b-t.originalBounds.t,a={event:"ORIGINAL_BOUNDS_STORAGE",shapeType:t.type,rawBounds:t.bounds,originalBounds:t.originalBounds,originalDimensions:{width:r,height:i,widthInches:(r/914400).toFixed(2),heightInches:(i/914400).toFixed(2)}};t._debugInfo=a;let o={...this.context,zip:this.zip||this.zipProcessor?.zip};new ChartProcessor(o).parseChartFromGraphicFrame(e).then(e=>{e&&(t.chartData=e,t.asyncChartProcessing=!1,"u">typeof window&&window.dispatchEvent(new CustomEvent("chartRenderingComplete",{detail:{chartData:e}})))}).catch(e=>{console.error("[Chart Debug] Failed to parse chart data in slide-renderer:",e),t.asyncChartProcessing=!1})}catch(e){console.error("[Chart Debug] Failed to schedule chart parsing in slide-renderer:",e)}else console.warn("[Chart Debug] ChartProcessor not available on window object in slide-renderer")}}}return t}processDefaultShape(e){let t=new CShape;t.type="unknown",this.applyComprehensiveStyleExtraction(t,e,"default shape");let r=e.querySelector("spPr, p\\:spPr");if(r){let e=this.processShapeProperties(r);e.transform?t.bounds={l:e.transform.x||0,t:e.transform.y||0,r:(e.transform.x||0)+(e.transform.cx||e.transform.width||0),b:(e.transform.y||0)+(e.transform.cy||e.transform.height||0)}:t.bounds={l:914400,t:914400,r:5486400,b:2743200}}else t.bounds={l:914400,t:914400,r:5486400,b:2743200};return this.applyPropertyInheritance(t),t}getShapeName(e){let t=e.querySelector("nvSpPr, p\\:nvSpPr")||e.querySelector("nvPicPr, p\\:nvPicPr")||e.querySelector("nvGrpSpPr, p\\:nvGrpSpPr");if(t){let e=t.querySelector("cNvPr, p\\:cNvPr");if(e)return e.getAttribute("name")||""}return""}processShapeProperties(e){let t={};if(!e)return t;Array.from(e.children);try{let r=e.querySelector("xfrm, p\\:xfrm, a\\:xfrm");if(r||(r=e.querySelector("xfrm")),!r){for(let t of e.children)if("xfrm"===t.tagName||"a:xfrm"===t.tagName||"p:xfrm"===t.tagName){r=t;break}}if(r){Array.from(r.children);let e=r.querySelector("off, p\\:off, a\\:off");if(e||(e=r.querySelector("off")),!e){for(let t of r.children)if("off"===t.tagName||"a:off"===t.tagName||"p:off"===t.tagName){e=t;break}}let i=r.querySelector("ext, p\\:ext, a\\:ext");if(i||(i=r.querySelector("ext")),!i){for(let e of r.children)if("ext"===e.tagName||"a:ext"===e.tagName||"p:ext"===e.tagName){i=e;break}}if(e&&(e.getAttribute("x"),e.getAttribute("y")),i&&(i.getAttribute("cx"),i.getAttribute("cy")),e&&i){let r=parseInt(e.getAttribute("x"))||0,a=parseInt(e.getAttribute("y"))||0,o=parseInt(i.getAttribute("cx"))||100,l=parseInt(i.getAttribute("cy"))||100;t.transform={x:r,y:a,cx:o,cy:l,width:o,height:l}}let a=r.getAttribute("rot");if(a){t.transform=t.transform||{};let e=parseInt(a)/6e4||0;t.transform.rot=e,t.transform.rotation=e,t.transform.rotEMU=parseInt(a)||0}let o=r.getAttribute("flipH"),l=r.getAttribute("flipV");(null!==o||null!==l)&&(t.transform=t.transform||{},null!==o&&(t.transform.flipH="1"===o||"true"===o),null!==l&&(t.transform.flipV="1"===l||"true"===l))}let i=["gradFill","solidFill","blipFill","pattFill","noFill"],a=null;for(let t of e.children){let e=t.localName||t.tagName?.replace(/^.*:/,"");if(i.includes(e)){a=t;break}}if(a){this._currentProcessingShape={name:this.getShapeName(e.closest("sp, p\\:sp"))||"Unknown"},t.fill=this.parseFill(a),this._currentProcessingShape=null;let r=this.getShapeName(e.closest("sp, p\\:sp"));"Rectangle 3"===r||r?.includes("Rectangle 3")}let o=e.querySelector("ln, p\\:ln, a\\:ln");o&&(t.stroke=this.parseStroke(o));let l=e.querySelector("prstGeom, p\\:prstGeom, a\\:prstGeom");if(l){let e=l.getAttribute("prst")||"rect",r={},i=l.querySelector("avLst, a\\:avLst");i&&i.querySelectorAll("gd, a\\:gd").forEach(e=>{let t=e.getAttribute("name"),i=(e.getAttribute("fmla")||"").match(/^val\s+(-?\d+)$/);t&&i&&(r[t]=parseInt(i[1]))}),t.geometry={type:"preset",preset:e,adjustments:r}}else Array.from(e.children);let s=e.querySelector("custGeom, p\\:custGeom, a\\:custGeom");s&&(t.geometry={type:"custom",pathList:this.parseCustomGeometry(s)});let n=e.querySelector("effectLst, p\\:effectLst, a\\:effectLst");n&&(t.effectLst=this.parseEffectList(n))}catch(e){}return t}processTextBody(e){let t={paragraphs:[],bodyProperties:this.parseBodyProperties(e)};try{let r=e.querySelector("lstStyle, a\\:lstStyle");for(let i of(r&&(t.lstStyle=this.parseListStyle(r)),e.querySelectorAll("p, a\\:p"))){let e={runs:[],properties:this.parseParagraphProperties(i)};for(let t of i.querySelectorAll("r, a\\:r, fld, a\\:fld")){let r=t.tagName?t.tagName.toLowerCase():"",i="a:fld"===r||"fld"===r,a=t.querySelector("t, a\\:t"),o={text:(a?a.textContent:"")||"",properties:this.parseRunProperties(t)};if(i){let e=t.getAttribute("type")||"";o.fieldType=e,o.text||"slidenum"!==e&&"slideNum"!==e||(o.text="1")}e.runs.push(o)}0===e.runs.length&&e.runs.push({text:"",properties:{}}),t.paragraphs.push(e)}t.paragraphs.reduce((e,t)=>e+t.runs.length,0),t.paragraphs.reduce((e,t)=>e+t.runs.filter(e=>e.text&&e.text.trim()).length,0),t.paragraphs.map(e=>e.runs.map(e=>e.text||"").join("")).join(" ").trim()}catch(e){}return t}parseListStyle(e){let t={};try{for(let r=1;r<=9;r++){let i=e.querySelector(`lvl${r}pPr, a\\:lvl${r}pPr`);if(i){let e={align:i.getAttribute("algn")||"left",marL:parseInt(i.getAttribute("marL"))||0,indent:parseInt(i.getAttribute("indent"))||0},a=i.querySelector("defRPr, a\\:defRPr");if(a){let t=a.getAttribute("sz");if(t){let r=parseInt(t);r>0&&(e.fontSize=r/100)}let r=a.getAttribute("b");null!==r&&(e.bold="1"===r||"true"===r);let i=a.getAttribute("i");null!==i&&(e.italic="1"===i||"true"===i);let o=a.getAttribute("cap");o&&(e.cap=o);let l=a.querySelector("latin, a\\:latin");l&&(e.fontFamily=l.getAttribute("typeface")||"Arial");let s=a.querySelector("solidFill, a\\:solidFill");s&&(e.color=this.parseColor(s))}let o=i.querySelector("spcBef, a\\:spcBef");if(o){let t=o.querySelector("spcPct, a\\:spcPct"),r=o.querySelector("spcPts, a\\:spcPts");t?e.spaceBeforePct=parseInt(t.getAttribute("val"))/1e5:r&&(e.spaceBefore=127*parseInt(r.getAttribute("val")))}let l=i.querySelector("spcAft, a\\:spcAft");if(l){let t=l.querySelector("spcPct, a\\:spcPct"),r=l.querySelector("spcPts, a\\:spcPts");t?e.spaceAfterPct=parseInt(t.getAttribute("val"))/1e5:r&&(e.spaceAfter=127*parseInt(r.getAttribute("val")))}t[`lvl${r}pPr`]=e}}}catch(e){}return t}parseBodyProperties(e){let t={wrap:!0,verticalAlign:"top",anchorX:"center",anchorY:"middle"};try{let r=e.querySelector("bodyPr, a\\:bodyPr");if(r){"none"===r.getAttribute("wrap")&&(t.wrap=!1);let e=r.getAttribute("anchor");e&&(t.verticalAlign=e),t.anchorX=r.getAttribute("anchorX")||"center",t.anchorY=r.getAttribute("anchorY")||"middle",t.leftMargin=parseInt(r.getAttribute("lIns"))||45720,t.rightMargin=parseInt(r.getAttribute("rIns"))||45720,t.topMargin=parseInt(r.getAttribute("tIns"))||22860,t.bottomMargin=parseInt(r.getAttribute("bIns"))||22860}}catch(e){}return t}parseParagraphProperties(e){let t={align:"left",lineHeight:100,spacing:{before:0,after:0},bullet:null};try{let r=e.querySelector("pPr, a\\:pPr");if(r){let e=r.getAttribute("lvl");null!=e?t.level=parseInt(e)||0:t.level=0;let i=r.getAttribute("algn");i&&(t.align=i);let a=r.querySelector("lnSpc, a\\:lnSpc");if(a){let e=a.querySelector("spcPct, a\\:spcPct"),r=a.querySelector("spcPts, a\\:spcPts");e?t.lineHeight=parseInt(e.getAttribute("val"))/1e3:r&&(t.lineHeightPoints=parseInt(r.getAttribute("val"))/100)}let o=r.querySelector("spcBef, a\\:spcBef");if(o){let e=o.querySelector("spcPts, a\\:spcPts");e&&(t.spacing.before=127*parseInt(e.getAttribute("val")))}let l=r.querySelector("spcAft, a\\:spcAft");if(l){let e=l.querySelector("spcPts, a\\:spcPts");e&&(t.spacing.after=127*parseInt(e.getAttribute("val")))}let s=r.getAttribute("marL"),n=r.getAttribute("indent");(null!==s||null!==n)&&(t.indent={left:s?parseInt(s):0,hanging:n?parseInt(n):0}),this.parseBulletProperties(r,t);let h=r.querySelector("defRPr, a\\:defRPr");if(h){let e=parseInt(h.getAttribute("sz"));e&&(t.fontSize=e/100),t.bold="1"===h.getAttribute("b"),t.italic="1"===h.getAttribute("i");let r=h.querySelector("latin, a\\:latin");r&&(t.fontFamily=r.getAttribute("typeface")||"Arial");let i=h.querySelector("solidFill, a\\:solidFill");i&&(t.color=this.parseColor(i))}}}catch(e){}return t}parseBulletProperties(e,t){try{let r=e.querySelector("buChar, a\\:buChar");if(r){let e=r.getAttribute("char");if(e){t.bullet={type:"character",char:e};return}}let i=e.querySelector("buNum, a\\:buNum");if(i){let e=i.getAttribute("startAt")||"1";t.bullet={type:"number",startAt:parseInt(e)};return}let a=e.querySelector("buAutoNum, a\\:buAutoNum");if(a){let e=a.getAttribute("type")||"arabicPeriod",r=a.getAttribute("startAt")||"1";t.bullet={type:"autoNumber",subType:e,startAt:parseInt(r)};return}if(e.querySelector("buNone, a\\:buNone")){t.bullet={type:"none"};return}}catch(e){}}parseRunProperties(e){let t={};try{let r=e.querySelector("rPr, a\\:rPr");if(r){let e=null;if(r.hasAttribute("sz"))e=parseInt(r.getAttribute("sz"));else{let t=r.querySelector("sz, a\\:sz");t&&(e=parseInt(t.getAttribute("val")))}e&&e>0&&(t.fontSize=e/100);let i=r.querySelector("latin, a\\:latin");if(i?t.fontFamily=i.getAttribute("typeface")||"Arial":t.fontFamily=null,r.hasAttribute("b")){let e=r.getAttribute("b");t.bold="0"!==e&&"false"!==e}if(r.hasAttribute("i")){let e=r.getAttribute("i");t.italic="0"!==e&&"false"!==e}if(r.hasAttribute("u")&&(t.underline="none"!==r.getAttribute("u")),r.hasAttribute("strike")&&(t.strike="noStrike"!==r.getAttribute("strike")),r.hasAttribute("baseline")){let e=parseInt(r.getAttribute("baseline"))||0;e>0?t.verticalAlign="superscript":e<0&&(t.verticalAlign="subscript")}r.hasAttribute("cap")&&(t.cap=r.getAttribute("cap")),r.hasAttribute("spc")&&(t.letterSpacing=parseInt(r.getAttribute("spc"))/100);let a=r.querySelector("solidFill, a\\:solidFill");a&&(t.color=this.parseColor(a));let o=r.querySelector("highlight, a\\:highlight");o&&(t.highlight=this.parseColor(o));let l=r.querySelector("effectLst, a\\:effectLst");l&&(t.effectLst=this.parseEffectList(l))}}catch(e){}return t}parseFill(e){if(!e)return null;let t=this._currentProcessingShape,r=t&&("Rectangle 3"===t.name||t.name?.includes("Rectangle 3"));if((e.tagName||e.localName||"").indexOf("gradFill")>=0||(e.localName||"").indexOf("gradFill")>=0)return{type:"gradient",gradient:this.parseGradient(e)};let i=e.querySelector("solidFill, a\\:solidFill");if(i||"a:solidFill"!==e.tagName&&"solidFill"!==e.tagName||(i=e),i){let e=null;try{e=this.parseColor(i)}catch(e){return null}return{type:"solid",color:e}}let a=e.querySelector("gradFill, a\\:gradFill");if(a)return{type:"gradient",gradient:this.parseGradient(a)};let o=e.querySelector("pattFill, a\\:pattFill");if(o)return{type:"pattern",pattern:this.parsePattern(o)};let l=e.querySelector("blipFill, a\\:blipFill");return l?{type:"image",imageData:this.parseBlipFill(l)}:e.querySelector("noFill, a\\:noFill")||"a:noFill"===e.tagName||"noFill"===e.tagName||"noFill"===e.localName?{type:"none"}:null}parseBlipFill(e){let t=e.querySelector("blip, a\\:blip");if(!t)return null;let r={},i=t.getAttribute("r:embed");i&&(r.relationshipId=i);let a=e.querySelector("effects, a\\:effects");a&&(r.effects=this.parseImageEffects(a));let o=e.querySelector("stretch, a\\:stretch"),l=e.querySelector("tile, a\\:tile");if(o){r.fillMode="stretch";let e=o.querySelector("fillRect, a\\:fillRect");e&&(r.fillRect={l:parseInt(e.getAttribute("l"))||0,t:parseInt(e.getAttribute("t"))||0,r:parseInt(e.getAttribute("r"))||0,b:parseInt(e.getAttribute("b"))||0})}else l?(r.fillMode="tile",r.tileProperties={tx:parseInt(l.getAttribute("tx"))||0,ty:parseInt(l.getAttribute("ty"))||0,sx:parseInt(l.getAttribute("sx"))||1e5,sy:parseInt(l.getAttribute("sy"))||1e5,flip:l.getAttribute("flip")||"none",algn:l.getAttribute("algn")||"tl"}):r.fillMode="stretch";let s=e.querySelector("srcRect, a\\:srcRect");return s&&(r.sourceRect={l:parseInt(s.getAttribute("l"))||0,t:parseInt(s.getAttribute("t"))||0,r:parseInt(s.getAttribute("r"))||0,b:parseInt(s.getAttribute("b"))||0}),r}parseColor(e){if(!e)return{r:0,g:0,b:0,a:255};let t=e.querySelector("srgbClr, a\\:srgbClr");if(t){let e=t.getAttribute("val");if(e){let r={r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:255};return this.applyColorModificationsToRgb(t,r)}}let r=e.querySelector("schemeClr, a\\:schemeClr");if(r){let e=r.getAttribute("val"),t=this._currentProcessingShape;if(t&&("Rectangle 3"===t.name||t.name?.includes("Rectangle 3"))&&this.presentation?.theme?.colors,"phClr"===e)return{type:"placeholder",scheme:"phClr",modifications:this.parseColorModifications(r),r:128,g:128,b:128,a:255};let i=null;if(this.presentation&&this.presentation.theme&&this.presentation.theme.colors){let t=this.presentation.theme.colors[e];t&&(i=this.parseColorFromHex(t))}return i||(i=({})[e]||null),this.applyColorModificationsToRgb(r,i)}return{r:0,g:0,b:0,a:255}}parseColorModifications(e){let t=[];for(let r of e.querySelectorAll("*")){let e=r.tagName.replace("a:","").toLowerCase(),i=r.getAttribute("val");i&&t.push({type:e,value:parseInt(i)})}return t}applyColorModificationsToRgb(e,t){if(!e)return t;let r={...t},i=e.querySelector("tint, a\\:tint");if(i){let e=parseInt(i.getAttribute("val"))/1e5;r.r=Math.round(r.r+(255-r.r)*e),r.g=Math.round(r.g+(255-r.g)*e),r.b=Math.round(r.b+(255-r.b)*e)}let a=e.querySelector("shade, a\\:shade");if(a){let e=parseInt(a.getAttribute("val"))/1e5;r.r=Math.round(r.r*(1-e)),r.g=Math.round(r.g*(1-e)),r.b=Math.round(r.b*(1-e))}let o=e.querySelector("lumMod, a\\:lumMod");if(o){let e=parseInt(o.getAttribute("val"))/1e5;r.r=Math.round(r.r*e),r.g=Math.round(r.g*e),r.b=Math.round(r.b*e)}let l=e.querySelector("lumOff, a\\:lumOff");if(l){let e=parseInt(l.getAttribute("val"))/1e5*255;r.r=Math.round(Math.min(255,r.r+e)),r.g=Math.round(Math.min(255,r.g+e)),r.b=Math.round(Math.min(255,r.b+e))}let s=e.querySelector("alpha, a\\:alpha");return s&&(r.a=Math.round(255*(parseInt(s.getAttribute("val"))/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)),r}parseGradient(e){let t={stops:[],type:"linear"},r=e.querySelector("gsLst, a\\:gsLst");r&&r.querySelectorAll("gs, a\\:gs").forEach(e=>{let r=parseInt(e.getAttribute("pos"))||0,i=this.parseColor(e);t.stops.push({position:r/1e5,color:i})});let i=e.querySelector("lin, a\\:lin");return i&&(t.angle=parseInt(i.getAttribute("ang"))||0,t.scaled="true"===i.getAttribute("scaled")),e.querySelector("rad, a\\:rad")&&(t.type="radial"),t}parsePattern(e){return{preset:e.getAttribute("prst"),foregroundColor:this.parseColor(e.querySelector("fgClr, a\\:fgClr")),backgroundColor:this.parseColor(e.querySelector("bgClr, a\\:bgClr"))}}parseStroke(e){try{let t={};if(e.querySelector("noFill, a\\:noFill"))return t.noFill=!0,t.width=0,t;let r=e.getAttribute("w");r?t.width=parseInt(r)||12700:t.width=12700;let i=e.querySelector("solidFill, a\\:solidFill");i?t.color=this.parseColor(i):(i=e.querySelector("gradFill, a\\:gradFill"))&&(t.gradient=this.parseGradient(i),t.color=t.gradient);let a=e.getAttribute("cap");a?t.cap=a:t.cap="flat";let o=e.getAttribute("join");o?t.join=o:t.join="round";let l=e.getAttribute("cmpd");l?t.compound=l:t.compound="sng";let s=e.querySelector("prstDash, a\\:prstDash");s?(t.dashStyle=s.getAttribute("val")||"solid",t.dashArray=this.getDashArray(t.dashStyle)):(t.dashStyle="solid",t.dashArray=[]);let n=e.querySelector("custDash, a\\:custDash");n&&(t.dashArray=this.parseCustomDash(n),t.dashStyle="custom");let h=e.getAttribute("algn");h?t.alignment=h:t.alignment="ctr";let c=e.querySelector("headEnd, a\\:headEnd");c&&(t.headEnd={type:c.getAttribute("type")||c.getAttribute("val")||"none",w:c.getAttribute("w")||c.getAttribute("width")||"med",len:c.getAttribute("len")||c.getAttribute("length")||"med"});let u=e.querySelector("tailEnd, a\\:tailEnd");return u&&(t.tailEnd={type:u.getAttribute("type")||u.getAttribute("val")||"none",w:u.getAttribute("w")||u.getAttribute("width")||"med",len:u.getAttribute("len")||u.getAttribute("length")||"med"}),t}catch(e){return{color:{r:0,g:0,b:0,a:255},width:12700,cap:"flat",join:"round",compound:"sng",dashStyle:"solid",dashArray:[],alignment:"ctr"}}}getDashArray(e){return({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]})[e]||[]}parseCustomDash(e){let t=[];try{for(let r of e.querySelectorAll("ds, a\\:ds")){let e=parseInt(r.getAttribute("d"))||1e5,i=parseInt(r.getAttribute("sp"))||1e5;t.push(e/1e5,i/1e5)}}catch(e){}return t}parseCustomGeometry(e){let t=[];try{let r=e.querySelector("pathLst, a\\:pathLst");if(r)for(let e of r.querySelectorAll("path, a\\:path")){let r={w:parseInt(e.getAttribute("w"))||100,h:parseInt(e.getAttribute("h"))||100,commands:[]};for(let t of e.querySelectorAll("moveTo, lnTo, lineTo, cubicBezTo, quadBezTo, close, a\\:moveTo, a\\:lnTo, a\\:lineTo, a\\:cubicBezTo, a\\:quadBezTo, a\\:close")){let e=this.parsePathCommand(t);e&&r.commands.push(e)}t.push(r)}}catch(e){}return t}parsePathCommand(e){switch(e.tagName.toLowerCase().replace(/^a:/,"")){case"moveto":let t=e.querySelector("pt, a\\:pt");if(t)return{type:"moveTo",x:parseInt(t.getAttribute("x"))||0,y:parseInt(t.getAttribute("y"))||0};break;case"lnto":case"lineto":{let t=e.querySelector("pt, a\\:pt");if(t)return{type:"lineTo",x:parseInt(t.getAttribute("x"))||0,y:parseInt(t.getAttribute("y"))||0};break}case"cubicbezto":let r=e.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":{let t=e.querySelectorAll("pt, a\\:pt");if(t.length>=2)return{type:"quadBezTo",x1:parseInt(t[0].getAttribute("x"))||0,y1:parseInt(t[0].getAttribute("y"))||0,x:parseInt(t[1].getAttribute("x"))||0,y:parseInt(t[1].getAttribute("y"))||0};break}case"close":return{type:"close"}}return null}parseShapeStyle(e){let t={};try{let r=e.querySelector("fillRef, a\\:fillRef");r&&(t.fillRef={idx:parseInt(r.getAttribute("idx"))||0,color:this.parseColor(r)});let i=e.querySelector("lnRef, a\\:lnRef");i&&(t.lnRef={idx:parseInt(i.getAttribute("idx"))||0,color:this.parseColor(i)});let a=e.querySelector("effectRef, a\\:effectRef");a&&(t.effectRef={idx:parseInt(a.getAttribute("idx"))||0});let o=e.querySelector("fontRef, a\\:fontRef");o&&(t.fontRef={idx:o.getAttribute("idx")||"minor"})}catch(e){}return t}extractStyleFromElement(e){let t={};try{let r=e.querySelector("style, p\\:style, a\\:style");if(r)return this.parseShapeStyle(r);let i=e.querySelector("spPr, p\\:spPr");if(i){let e=this.extractStyleAttributesFromSpPr(i);e&&Object.keys(e).length>0&&Object.assign(t,e)}let a=this.extractStyleAttributesFromElement(e);a&&Object.keys(a).length>0&&Object.assign(t,a);let o=e.querySelector("nvSpPr, p\\:nvSpPr");if(o){let e=this.extractStyleAttributesFromNvSpPr(o);e&&Object.keys(e).length>0&&Object.assign(t,e)}}catch(e){}return t}extractStyleAttributesFromSpPr(e){let t={};try{let r=e.getAttribute("style")||e.getAttribute("styleRef");if(r){let e=this.parseStyleReference(r);e&&Object.assign(t,e)}let i=e.querySelector("schemeClr, a\\:schemeClr");if(i){let e=i.getAttribute("val");e&&(t.schemeColor=e)}}catch(e){}return t}extractStyleAttributesFromElement(e){let t={};try{["style","styleRef","themeRef","colorRef"].forEach(r=>{let i=e.getAttribute(r);i&&(t[r]=i)})}catch(e){}return t}extractStyleAttributesFromNvSpPr(e){let t={};try{let r=e.querySelector("ph, p\\:ph");if(r){let e=r.getAttribute("type");if(r.getAttribute("idx"),e){let r={title:{fillRef:{idx:1}},body:{fillRef:{idx:2}},ctrTitle:{fillRef:{idx:1}},subTitle:{fillRef:{idx:2}},obj:{fillRef:{idx:3}}};r[e]&&Object.assign(t,r[e])}}}catch(e){}return t}parseStyleReference(e){try{if(e.includes("fillRef")){let t=e.match(/fillRef:(\d+)/);if(t)return{fillRef:{idx:parseInt(t[1])||0}}}}catch(e){}return null}applyComprehensiveStyleExtraction(e,t,r="shape"){let i=!1,a=t.querySelector("style, p\\:style");if(a&&(e.style=this.parseShapeStyle(a),e.preservedStyle=e.style,i=!0),!i&&window.currentSlideData&&window.currentSlideData.rawXMLShapes){let t=window.currentSlideData.rawXMLShapes.find(t=>t.name===e.name||t.id===e.id);t&&t.style&&(e.style=t.style,e.preservedStyle=t.style,i=!0)}if(!i){let r=this.extractStyleFromElement(t);r&&Object.keys(r).length>0&&(e.style=r,e.preservedStyle=r,i=!0)}return i}hexToRgb(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:{r:0,g:0,b:0}}initializeRendering(){try{let e=document.createElement("canvas");if(e.width=800,e.height=600,this.getGraphicsEngine()||this.initializeGraphicsEngine(),this.drawingDocument){this.drawingDocument.init(e,this);let t="u">typeof globalThis&&globalThis.SVGRenderer||"u">typeof window&&window.SVGRenderer||null;if(t&&this.drawingDocument.graphics)this.svgRenderer=new t(this.drawingDocument.graphics);else throw Error("SVGRenderer is not defined")}else throw Error("standard graphics engine not available")}catch(e){throw Error("Failed to initialize rendering system: "+e.message)}}async renderSlide(e,t){performance.now();try{if(!e)throw Error("Canvas is required for rendering");if(t<0||t>=this.slides.length)throw Error(`Invalid slide index: ${t}`);let r=this.slides[t];if(!r)throw Error(`Slide at index ${t} is null`);this.currentSlide=r,this.getGraphicsEngine()||this.initializeGraphicsEngine();let i=this.getSlideDimensions();if(this.calculateCanvasRect(e,i),!this.drawingDocument)throw Error("standard graphics engine not available");this.drawingDocument.init(e,this);let a=this.drawingDocument.graphics;if(this.renderContext.enableOptimizations){let t=parseFloat(e.style.width)||e.width/(window.devicePixelRatio||1),r=parseFloat(e.style.height)||e.height/(window.devicePixelRatio||1);a.updatedRect=new L(0,0,t,r)}a.clear(),await this.preloadSlideImages(t),this.logSlideImageStatus(r,t),this.currentSlideIndex=t,await this.drawingDocument.drawSlide(r,t),performance.now()}catch(t){if(e){let r=e.getContext("2d");r.fillStyle="#ffebee",r.fillRect(0,0,e.width,e.height),r.fillStyle="#f44336",r.font="16px Arial",r.textAlign="center",r.fillText("Rendering Error",e.width/2,e.height/2),r.fillText(t.message,e.width/2,e.height/2+25)}}}async renderMaster(e,t){try{if(!e)throw Error("Canvas is required for rendering");if(t<0||t>=this.slideMasters.length)throw Error(`Invalid master index: ${t}`);let r=this.slideMasters[t];if(!r)throw Error(`Master at index ${t} is null`);let i={name:r.name||`Master ${t+1}`,type:"master",commonSlideData:r.commonSlideData||r.cSld,backgroundFill:r.cSld?.bg,showMasterShapes:!1,layout:null,master:null};this.currentSlide=i;let a=this.getSlideDimensions();this.calculateCanvasRect(e,a),this.drawingDocument||this.initializeRendering(),this.drawingDocument.init(e,this),this.drawingDocument.graphics.clear(),await this.drawingDocument.drawSlide(i,t)}catch(t){if(e){let r=e.getContext("2d");r.fillStyle="#f0f8ff",r.fillRect(0,0,e.width,e.height),r.fillStyle="#e74c3c",r.font="16px Arial",r.textAlign="center",r.fillText("Master Rendering Error",e.width/2,e.height/2),r.fillText(t.message,e.width/2,e.height/2+25)}}}async renderLayout(e,t){try{if(!e)throw Error("Canvas is required for rendering");if(t<0||t>=this.slideLayouts.length)throw Error(`Invalid layout index: ${t}`);let r=this.slideLayouts[t];if(!r)throw Error(`Layout at index ${t} is null`);let i=this.slideMasters.find(e=>e.id===r.masterId),a={name:r.name||`Layout ${t+1}`,type:"layout",commonSlideData:r.commonSlideData||r.cSld,backgroundFill:r.cSld?.bg||i?.cSld?.bg,showMasterShapes:!1!==r.showMasterSp,layout:r,master:i};this.currentSlide=a;let o=this.getSlideDimensions();this.calculateCanvasRect(e,o),this.drawingDocument||this.initializeRendering(),this.drawingDocument.init(e,this),this.drawingDocument.graphics.clear(),await this.drawingDocument.drawSlide(a,t)}catch(t){if(e){let r=e.getContext("2d");r.fillStyle="#fff5f5",r.fillRect(0,0,e.width,e.height),r.fillStyle="#e74c3c",r.font="16px Arial",r.textAlign="center",r.fillText("Layout Rendering Error",e.width/2,e.height/2),r.fillText(t.message,e.width/2,e.height/2+25)}}}drawRegularShapeGeometry(e,t,r,i,a,o,l,s,n,h=null){let c=this.getShapePreset(t);!c&&t.geometry&&(c=t.geometry.preset),!c&&t.properties&&t.properties.geometry&&(c=t.properties.geometry.preset),h?l=h:l&&"object"==typeof l&&l.type;let u=null,d=null;l&&("linear"===l.type&&l.stops?u=l:"string"==typeof l?u=this.hexToRgb(l):void 0!==l.r&&(u=l)),s&&("string"==typeof s?d=this.hexToRgb(s):void 0!==s.r&&(d=s));let p=this.getShapeStrokeInfo(t);c?e.drawPresetGeometry(c,r,i,a,o,u,d,n,p):e.drawRectangle(r,i,a,o,u,d,n,p)}getSlideCount(){return this.slides.length}getCurrentSlideIndex(){return this.currentSlideIndex}getSlideInfo(e){let t=this.slides[e];return t?{index:e,name:t.getName(),shapeCount:t.getShapeTree().length}:null}getSlideDimensions(){return this.presentation?.slideSize||{cx:9144e3,cy:6858e3}}getSlideDimensionsForCanvas(e,t){let r=this.getSlideDimensions(),i=Math.min(e/r.cx,t/r.cy);return{width:r.cx*i,height:r.cy*i,scale:i,offsetX:(e-r.cx*i)/2,offsetY:(t-r.cy*i)/2}}async generateSlideThumbnail(e,t=320,r=240){try{if(this.getGraphicsEngine()||this.initializeGraphicsEngine(),!this.slides[e])return this.createFallbackThumbnail(e,t,r);let i=this.slides[e],a=this.getSlideDimensions();a.cx,a.cy;let o=a.cx/914400*96,l=a.cy/914400*96,s=t/o,n=r/l,h=Math.min(s,n),c=o*h,u=l*h;c=Math.max(c,100),u=Math.max(u,75);let d=document.createElement("canvas");if(this.setupHighResolutionCanvas(d,c,u),!this.drawingDocument)return this.createFallbackThumbnail(e,c,u);this.drawingDocument.init(d,this);try{return await this.drawingDocument.drawSlide(i,e),d}catch(t){return this.createFallbackThumbnail(e,c,u)}}catch(i){return this.createFallbackThumbnail(e,t,r)}}createFallbackThumbnail(e,t,r){let i=document.createElement("canvas");this.setupHighResolutionCanvas(i,t,r);let a=i.getContext("2d");a.fillStyle="#f0f0f0",a.fillRect(0,0,t,r),a.fillStyle="#666",a.font="16px Arial",a.textAlign="center",a.fillText(`Slide ${e+1}`,t/2,r/2);try{let e=this.getSlideDimensions(),i=e.cx/e.cy;a.font="12px Arial",a.fillText(`${i.toFixed(2)}:1`,t/2,r/2+20)}catch(e){}return i}inferLayoutTypeFromPlaceholders(e){let t=e.querySelector("cSld, p\\:cSld");if(!t)return"blank";let r=t.querySelector("spTree, p\\:spTree");if(!r)return"blank";let i=[],a=r.children;for(let e=0;e<a.length;e++){let t=a[e],r=this.extractPlaceholderInfo(t);r&&i.push(r.type)}return i.includes("title")&&i.includes("body")?"titleAndContent":i.includes("title")?"titleOnly":i.includes("body")?"contentOnly":0===i.length?"blank":"custom"}extractPlaceholderInfo(e){let t=e.querySelector("nvSpPr, p\\:nvSpPr")||e.querySelector("nvPicPr, p\\:nvPicPr")||e.querySelector("nvGrpSpPr, p\\:nvGrpSpPr");if(!t)return null;let r=t.querySelector("nvPr, p\\:nvPr");if(!r)return null;let i=r.querySelector("ph, p\\:ph");return i?{type:i.getAttribute("type")||"obj",idx:i.getAttribute("idx"),orient:i.getAttribute("orient"),sz:i.getAttribute("sz")}:null}parsePlaceholder(e){let t=e.getAttribute("idx"),r=null==t||isNaN(parseInt(t,10))?void 0:parseInt(t,10),i={type:e.getAttribute("type")||"obj",orient:e.getAttribute("orient")||"horz",sz:e.getAttribute("sz")||"full",idx:r},a=e.querySelector("extLst, p\\:extLst");if(a){let e=a.querySelector("ext, p\\:ext");if(e){let t=e.querySelector("phTxt, p\\:phTxt");t&&(i.text=t.textContent)}}return i}parseBackground(e){let t=e.querySelector("bg, p\\:bg");if(!t)return null;let r=t.querySelector("bgPr, p\\:bgPr");if(r)return{type:"bgPr",fill:this.parseFill(r)};let i=t.querySelector("bgRef, p\\:bgRef");return i?{type:"bgRef",idx:i.getAttribute("idx")}:null}parseTextStyleElement(e){return e?{element:e,parsed:!1}:null}parseColorMapElement(e){if(!e)return null;let t={},r=e.attributes;for(let e=0;e<r.length;e++){let i=r[e];t[i.name]=i.value}return t}parseColorMapOverride(e){if(!e)return null;let t=e.querySelector("masterClrMapping, p\\:masterClrMapping");if(t)return this.parseColorMapElement(t);let r=e.querySelector("overrideClrMapping, p\\:overrideClrMapping");return r?this.parseColorMapElement(r):null}calculateCanvasRect(e,t){let r,i,a=t.cx/914400*96,o=t.cy/914400*96;e.style.width&&e.style.height?(r=parseFloat(e.style.width),i=parseFloat(e.style.height)):(r=e.width/(window.devicePixelRatio||1),i=e.height/(window.devicePixelRatio||1));let l=Math.min(r/a,i/o),s=a*l,n=o*l,h=(r-s)/2,c=(i-n)/2,u=Math.round(s),d=Math.round(n),p=Math.round(h),g=Math.round(c);return 1>=Math.abs(u-r)&&1>=Math.abs(d-i)&&(u=Math.round(r),d=Math.round(i),p=0,g=0),l=Math.min(u/a,d/o),{widthPx:Math.round(r),heightPx:Math.round(i),slideWidthPx:a,slideHeightPx:o,scale:l,offsetX:p,offsetY:g,scaledWidth:u,scaledHeight:d,widthMM:t.cx/914400*25.4,heightMM:t.cy/914400*25.4}}calculateShapeBounds(e,t){if(!e||!e.bounds)return{x:0,y:0,w:100,h:100};let r=this.getSlideDimensions(),i=r.cx,a=r.cy,o=t.slideWidthPx,l=t.slideHeightPx,s={x:(e.bounds.l||0)/i*o,y:(e.bounds.t||0)/a*l,w:((e.bounds.r||0)-(e.bounds.l||0))/i*o,h:((e.bounds.b||0)-(e.bounds.t||0))/a*l},n=t.offsetX+s.x*t.scale,h=t.offsetY+s.y*t.scale,c=s.w*t.scale,u=s.h*t.scale,d=this.getShapeRotation(e);return d&&0!==d?this.calculateRotatedBounds({x:n,y:h,w:c,h:u},d):{x:n,y:h,w:c,h:u}}getShapeBounds(e,t){if(!e||!e.bounds)return{x:0,y:0,w:100,h:100};let r=this.getSlideDimensions(),i=r.cx,a=r.cy,o=t.slideWidthPx,l=t.slideHeightPx,s={x:(e.bounds.l||0)/i*o,y:(e.bounds.t||0)/a*l,w:((e.bounds.r||0)-(e.bounds.l||0))/i*o,h:((e.bounds.b||0)-(e.bounds.t||0))/a*l},n=t.offsetX+s.x*t.scale,h=t.offsetY+s.y*t.scale;return{x:n,y:h,w:s.w*t.scale,h:s.h*t.scale}}calculateShapeTransform(e,t){if(!e||!e.properties||!e.properties.transform)return null;let r=e.properties.transform,i=new CMatrix,a=this.getSlideDimensions(),o=a.cx,l=a.cy,s=t.slideWidthPx,n=t.slideHeightPx;if(void 0!==r.x&&void 0!==r.y){let e=r.x/o*s,a=r.y/l*n;i.tx=t.offsetX+e*t.scale,i.ty=t.offsetY+a*t.scale}if(void 0!==r.rot){let e=r.rot*Math.PI/180,a=Math.cos(e),o=Math.sin(e);i.sx=a*t.scale,i.sy=a*t.scale,i.shx=-o*t.scale,i.shy=o*t.scale}else i.sx=t.scale,i.sy=t.scale;return i}drawSlideBackground(e,t,r){t.backgroundFill&&this.renderBackgroundFill(e,t.backgroundFill,r)}renderBackgroundFill(e,t,r){if(!t||!t.fill)return;let i=t.fill;switch(i.type){case"solid":this.renderSolidBackground(e,i,r);break;case"gradient":this.renderGradientBackground(e,i,r);break;case"image":this.renderImageBackground(e,i,r);break;case"pattern":this.renderPatternBackground(e,i,r)}}renderSolidBackground(e,t,r){if(t.color){let i=this.rgbToHex(t.color);e.fillRect(0,0,r.widthPx,r.heightPx,i)}}renderGradientBackground(e,t,r){let i;if(!t.gradient||!t.gradient.stops||0===t.gradient.stops.length){let i=t.gradient?.stops?.[0]?.color||{r:255,g:255,b:255,a:255};e.fillRect(0,0,r.widthPx,r.heightPx,this.rgbToHex(i));return}let a=e.context,{widthPx:o,heightPx:l}=r;if("radial"===t.gradient.type){let e=o/2,t=l/2,r=Math.max(o,l)/2;i=a.createRadialGradient(e,t,0,e,t,r)}else{let e=(t.gradient.angle||0)*Math.PI/180/6e4,r=Math.sqrt(o*o+l*l),s=o/2-Math.cos(e)*r/2,n=l/2-Math.sin(e)*r/2,h=o/2+Math.cos(e)*r/2,c=l/2+Math.sin(e)*r/2;i=a.createLinearGradient(s,n,h,c)}t.gradient.stops.forEach(e=>{let t=this.rgbToHex(e.color);i.addColorStop(e.position,t)}),a.fillStyle=i,a.fillRect(0,0,o,l)}renderImageBackground(e,t,r){if(!t.imageData||!t.imageData.relationshipId)return void e.fillRect(0,0,r.widthPx,r.heightPx,"#f0f0f0");let i=t.imageData.relationshipId,a=this.imageCache.get(i);if(a&&a.image)this.drawBackgroundImage(e,a.image,t.imageData,r);else{e.fillRect(0,0,r.widthPx,r.heightPx,"#f8f9fa");let t=e.context;t.fillStyle="#6c757d",t.font="14px Arial",t.textAlign="center",t.fillText("Loading background...",r.widthPx/2,r.heightPx/2),this.loadImageAsync(i)}}drawBackgroundImage(e,t,r,i){let a=e.context,{widthMM:o,heightMM:l}=i;a.save();try{if("tile"===r.fillMode)this.drawTiledBackgroundImage(a,t,r.tileProperties,o,l);else{let i=0,a=0,s=o,n=l;if(r.fillRect){let e=r.fillRect;i=o*e.l/1e5,a=l*e.t/1e5,s=o*(1e5-e.l-e.r)/1e5,n=l*(1e5-e.t-e.b)/1e5}if(r.sourceRect){let o=r.sourceRect,l=t.naturalWidth*o.l/1e5,h=t.naturalHeight*o.t/1e5,c=t.naturalWidth*(1e5-o.l-o.r)/1e5,u=t.naturalHeight*(1e5-o.t-o.b)/1e5;e.drawImageHighRes(t,l,h,c,u,i,a,s,n)}else e.drawImageHighRes(t,i,a,s,n)}r.effects&&this.applyImageEffects(e,r.effects)}catch(e){a.fillStyle="#f0f0f0",a.fillRect(0,0,o,l)}finally{a.restore()}}drawTiledBackgroundImage(e,t,r,i,a){if(!r)return;let o=r.sx/1e5,l=r.sy/1e5,s=r.tx/914400*25.4,n=r.ty/914400*25.4,h=t.naturalWidth*o,c=t.naturalHeight*l,u=document.createElement("canvas");u.width=h,u.height=c;let d=u.getContext("2d");d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(t,0,0,h,c);let p=e.createPattern(u,"repeat");e.save(),e.translate(s,n),e.fillStyle=p,e.fillRect(-s,-n,i,a),e.restore()}renderPatternBackground(e,t,r){let i=t.pattern?.foregroundColor||{r:128,g:128,b:128,a:255},a=this.rgbToHex(i);e.fillRect(0,0,r.widthMM,r.heightMM,a)}getShapeFillColor(e){let t;if(this._currentProcessingShape=e,e&&("Rectangle 3"===e.name||e.name?.includes("Rectangle 3")),e.fill){if("solid"===e.fill.type&&e.fill.color){let t=this.processShapeColor(e.fill.color);return this._currentProcessingShape=null,t}if("gradient"===e.fill.type&&e.fill.gradient)return this._currentProcessingShape=null,this.processGradientFill(e.fill.gradient);if("none"===e.fill.type)return this._currentProcessingShape=null,null}if(e.properties&&e.properties.fill){if("solid"===e.properties.fill.type&&e.properties.fill.color){let t=this.processShapeColor(e.properties.fill.color);return this._currentProcessingShape=null,t}if("gradient"===e.properties.fill.type&&e.properties.fill.gradient)return this.processGradientFill(e.properties.fill.gradient);if("none"===e.properties.fill.type)return null}if("sp"===e.type&&e.placeholder&&e.placeholder.type)return e.placeholder.type,this._currentProcessingShape=null,null;let r=e.preservedStyle||e.style;if(r&&r.fillRef){this._currentProcessingShape=e;let t=this.resolveStyleFillColor(r.fillRef);if(t)return this._currentProcessingShape=null,t}if("pic"===e.type)return this._currentProcessingShape=null,null;if(e.name&&e.name.includes("Rectangle")){let r=e.name.match(/\d+/);r&&parseInt(r[0]),t=null}else t=null;return this._currentProcessingShape=null,t}_normalizeColorDescriptor(e){if(!e)return null;if("object"==typeof e&&void 0!==e.r||"string"==typeof e)return e;if("object"==typeof e&&e.type&&e.value){if("scheme"===e.type)return{scheme:e.value,alpha:e.alpha};if("srgb"===e.type)return`#${e.value}`}return e}resolveStyleStrokeColor(e){try{if(!e)return null;let t=this._normalizeColorDescriptor(e.color||e);return this.processShapeColor(t)}catch(e){return null}}getShapeStrokeColor(e){try{if(e?.properties?.stroke?.noFill||e?.stroke?.noFill)return null;if(e?.properties?.stroke?.color){let t=this._normalizeColorDescriptor(e.properties.stroke.color);return this.processShapeColor(t)}if(e?.stroke?.color){let t=this._normalizeColorDescriptor(e.stroke.color);return this.processShapeColor(t)}let t=e?.preservedStyle||e?.style;if(t?.lnRef){let e=this.resolveStyleStrokeColor(t.lnRef);if(e)return e}}catch(e){}return e&&("cxnSp"===e.type||"connector"===e.type)?{r:80,g:80,b:80,a:255}:null}getShapeLineWidth(e){try{let t=(e?.properties?.stroke?.width!==void 0?parseInt(e.properties.stroke.width)||12700:e?.stroke?.width!==void 0&&parseInt(e.stroke.width)||12700)/914400*25.4;return Math.max(t,50.8/96)}catch(e){return .75}}resolveInheritedFillColor(e){try{let t=this.slides[this.getCurrentSlideIndex()];if(!t||!e.placeholder||!e.placeholder.type)return null;let r=e.placeholder.type,i=e.placeholder.idx||0;if(t.layout&&t.layout.cSld&&t.layout.cSld.spTree){for(let e of t.layout.cSld.spTree)if(this.isMatchingPlaceholder(e,r,i)){let t=this.extractShapeFillColor(e);if(t)return t}}if(t.layout&&t.layout.master&&t.layout.master.cSld&&t.layout.master.cSld.spTree){for(let e of t.layout.master.cSld.spTree)if(this.isMatchingPlaceholder(e,r,i)){let t=this.extractShapeFillColor(e);if(t)return t}}let a=this.getThemeColorForPlaceholder(r);if(a)return a;return null}catch(e){return null}}isMatchingPlaceholder(e,t,r){return!!e.placeholder&&(e.placeholder.type===t?void 0===r||void 0===e.placeholder.idx||e.placeholder.idx===r:"title"===t&&"ctrTitle"===e.placeholder.type||"ctrTitle"===t&&"title"===e.placeholder.type)}inheritShapeStyles(e,t){try{if(t.spPr&&(e.spPr||(e.spPr={}),t.spPr.solidFill&&!e.spPr.solidFill&&(e.spPr.solidFill=t.spPr.solidFill),t.spPr.gradFill&&!e.spPr.gradFill&&(e.spPr.gradFill=t.spPr.gradFill),t.spPr.pattFill&&!e.spPr.pattFill&&(e.spPr.pattFill=t.spPr.pattFill),t.spPr.blipFill&&!e.spPr.blipFill&&(e.spPr.blipFill=t.spPr.blipFill),t.spPr.noFill&&!e.spPr.noFill&&(e.spPr.noFill=t.spPr.noFill),t.spPr.ln&&!e.spPr.ln&&(e.spPr.ln=t.spPr.ln),t.spPr.effectLst&&!e.spPr.effectLst&&(e.spPr.effectLst=t.spPr.effectLst),!t.spPr.geometry||e.spPr.geometry||this.isTextPlaceholder(e)||(e.spPr.geometry=t.spPr.geometry),t.spPr.xfrm&&!e.spPr.xfrm&&(e.spPr.xfrm=t.spPr.xfrm)),t.style&&(e.style||(e.style={}),t.style.fillRef&&!e.style.fillRef&&(e.style.fillRef=t.style.fillRef),t.style.lnRef&&!e.style.lnRef&&(e.style.lnRef=t.style.lnRef),t.style.effectRef&&!e.style.effectRef&&(e.style.effectRef=t.style.effectRef),t.style.fontRef&&!e.style.fontRef&&(e.style.fontRef=t.style.fontRef)),(this.isTextPlaceholder(e)||e.textBody)&&this.inheritTextProperties(e,t),t.effects&&!e.effects&&(e.effects=t.effects),t.fill&&(!e.fill||null===e.fill)&&(e.fill=t.fill),t.properties&&t.properties.fill&&(e.properties||(e.properties={}),e.properties.fill&&null!==e.properties.fill||(e.properties.fill=t.properties.fill)),t.properties&&t.properties.transform&&(e.properties||(e.properties={}),e.properties.transform||(e.properties.transform=JSON.parse(JSON.stringify(t.properties.transform)))),(!e.properties||!e.properties.transform)&&e.spPr&&e.spPr.xfrm){let t=e.spPr.xfrm,r=void 0!==t.x?t.x:(t.off&&t.off.x)!==void 0?t.off.x:0,i=void 0!==t.y?t.y:(t.off&&t.off.y)!==void 0?t.off.y:0,a=void 0!==t.width?t.width:void 0!==t.cx?t.cx:(t.ext&&t.ext.cx)!==void 0?t.ext.cx:void 0,o=void 0!==t.height?t.height:void 0!==t.cy?t.cy:(t.ext&&t.ext.cy)!==void 0?t.ext.cy:void 0;void 0!==a&&void 0!==o&&(e.properties||(e.properties={}),e.properties.transform={x:r,y:i,width:a,height:o})}}catch(e){}}inheritTextProperties(e,t){try{if(t.textBody){e.textBody||(e.textBody={paragraphs:[]});let r=t.textBody.bodyProperties||t.textBody.bodyPr;if(e.textBody.bodyProperties){if(r){let t=e.textBody.bodyProperties;(t.anchor||t.verticalAlign)&&"top"!==t.verticalAlign&&"t"!==t.verticalAlign||(r.anchor?t.anchor=r.anchor:r.verticalAlign&&(t.verticalAlign=r.verticalAlign)),void 0===t.leftMargin&&void 0!==r.leftMargin&&(t.leftMargin=r.leftMargin),void 0===t.rightMargin&&void 0!==r.rightMargin&&(t.rightMargin=r.rightMargin),void 0===t.topMargin&&void 0!==r.topMargin&&(t.topMargin=r.topMargin),void 0===t.bottomMargin&&void 0!==r.bottomMargin&&(t.bottomMargin=r.bottomMargin)}}else r&&(e.textBody.bodyProperties=JSON.parse(JSON.stringify(r)));t.textBody.lstStyle&&!e.textBody.lstStyle&&(e.textBody.lstStyle=t.textBody.lstStyle)}t.txBody&&!e.txBody&&(e.txBody=t.txBody)}catch(e){}}isTextPlaceholder(e){let t=e?.placeholder?.type||e.nvSpPr&&e.nvSpPr.nvPr&&e.nvSpPr.nvPr.ph&&e.nvSpPr.nvPr.ph.type;return!!t&&["title","body","ctrTitle","subTitle","dt","ftr","hdr","sldNum"].includes(t)}applyPropertyInheritance(e,t=null){try{let r=t||this.currentSlide;if(!r)return;if(r.layout&&r.layout.cSld&&r.layout.cSld.spTree){let t=this.findMatchingShapeInTemplate(e,r.layout.cSld.spTree);t&&this.inheritShapeStyles(e,t)}if(r.layout&&r.layout.master&&r.layout.master.cSld&&r.layout.master.cSld.spTree){let t=this.findMatchingShapeInTemplate(e,r.layout.master.cSld.spTree);t&&this.inheritShapeStyles(e,t)}}catch(e){}}findMatchingShapeInTemplate(e,t){if(!t||!Array.isArray(t))return null;if(e.placeholder){for(let r of t)if(this.isMatchingPlaceholder(r,e.placeholder.type,e.placeholder.idx))return r}if(e.name){for(let r of t)if(r.name===e.name)return r}if(e.name&&e.name.includes("Text Placeholder")&&e.textBody){for(let e of t)if(e.name&&e.name.includes("Text Placeholder")&&e.textBody)return e}if(e.bounds&&!e.placeholder){for(let r of t)if(this.isShapeAtSimilarPosition(e,r))return r}return null}isShapeAtSimilarPosition(e,t){if(!e.bounds||!t.bounds)return!1;let r=91440>=Math.abs(e.bounds.l-t.bounds.l),i=91440>=Math.abs(e.bounds.t-t.bounds.t);return r&&i}extractShapeGeometry(e){return e.spPr&&e.spPr.geometry?e.spPr.geometry:e.geometry?e.geometry:e.properties&&e.properties.geometry?e.properties.geometry:null}extractShapeFillColor(e){return e.fill&&e.fill.color?this.processShapeColor(e.fill.color):e.properties&&e.properties.fill&&e.properties.fill.color?this.processShapeColor(e.properties.fill.color):e.style&&e.style.fillRef?this.resolveStyleFillColor(e.style.fillRef):null}getThemeColorForPlaceholder(e){let t=this.presentation?.theme;if(!t||!t.colors)return null;switch(e){case"title":case"ctrTitle":case"body":case"obj":default:return null;case"subTitle":return{r:245,g:245,b:245,a:255}}}processShapeColor(e){if(!e)return null;if(void 0!==e.r&&void 0!==e.g&&void 0!==e.b)return e;if("string"==typeof e&&e.startsWith("#"))return this.hexToRgb(e);if(e.scheme){let t=this.resolveThemeColor(e.scheme);if(t)return this.applyColorModifications(t,e)}if("srgb"===e.type&&e.value){let t=e.value,r=parseInt(t.substring(0,2),16)||0,i=parseInt(t.substring(2,4),16)||0;return{r,g:i,b:parseInt(t.substring(4,6),16)||0,a:void 0!==e.alpha&&null!==e.alpha?Math.round(255*e.alpha):255}}if("scheme"===e.type&&e.value){let t=this.resolveThemeColor(e.value);if(t)return this.applyColorModifications(t,e)}return e}processGradientFill(e){return e&&e.stops&&0!==e.stops.length?{type:e.type||"linear",angle:e.angle||0,stops:e.stops.map(e=>({position:e.position,color:this.processShapeColor(e.color)}))}:null}resolveThemeColor(e){if(this.presentation&&this.presentation.theme&&this.presentation.theme.colors){let t=this.presentation.theme.colors[e];if(t){let e=this.parseColorFromHex(t);if(e)return e}}return({})[e]||null}resolvePlaceholderColor(e,t=null){if(!e||"placeholder"!==e.type)return e;let r=t;if(!r&&this.presentation&&this.presentation.theme&&this.presentation.theme.colors){let e=this.presentation.theme.colors.accent1;e&&(r=this.parseColorFromHex(e))}return r?(e.modifications&&e.modifications.length>0&&(r=this.applyColorModifications(r,e.modifications)),r):null}rgbToHsl(e,t,r){e/=255,t/=255,r/=255;let i=Math.max(e,t,r),a=Math.min(e,t,r),o,l,s=(i+a)/2;if(i===a)o=l=0;else{let n=i-a;switch(l=s>.5?n/(2-i-a):n/(i+a),i){case e:o=(t-r)/n+6*(t<r);break;case t:o=(r-e)/n+2;break;case r:o=(e-t)/n+4}o/=6}return{h:360*o,s:l,l:s}}hslToRgb(e,t,r){let i,a,o;e/=360;let l=(e,t,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6)?e+(t-e)*6*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e;if(0===t)i=a=o=r;else{let s=r<.5?r*(1+t):r+t-r*t,n=2*r-s;i=l(n,s,e+1/3),a=l(n,s,e),o=l(n,s,e-1/3)}return{r:Math.round(255*i),g:Math.round(255*a),b:Math.round(255*o)}}parseColorFromHex(e){if(!e||"string"!=typeof e)return null;let t=e.replace("#","");return 6===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:255}:null}applyColorModifications(e,t){if(!e||!t||0===t.length)return e;let r={...e},{h:i,s:a,l:o}=this.rgbToHsl(r.r,r.g,r.b);for(let e of t){let t=e.value;switch(e.type){case"tint":let l=t/1e5;o+=(1-o)*l;break;case"shade":o*=1-t/1e5;break;case"lummod":case"lumMod":o*=t/1e5;break;case"lumoff":case"lumOff":o=Math.min(1,Math.max(0,o+t/1e5));break;case"satmod":case"satMod":a*=t/1e5;break;case"satoff":case"satOff":a=Math.min(1,Math.max(0,a+t/1e5));break;case"hue":i=t/6e4%360;break;case"hueoff":case"hueOff":i=(i+t/6e4)%360;break;case"huemod":case"hueMod":i=t/1e5*i%360;break;case"alpha":r.a=Math.round(t/1e5*255);break;case"alphamod":case"alphaMod":let s=t/1e5;r.a=Math.round(r.a*s);break;case"alphaoff":case"alphaOff":let n=t/1e5;r.a=Math.min(255,Math.max(0,Math.round(r.a+255*n)))}}let l=this.hslToRgb(i,a,o);return r.r=l.r,r.g=l.g,r.b=l.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))),r}rgbToHsl(e,t,r){e/=255,t/=255,r/=255;let i=Math.max(e,t,r),a=Math.min(e,t,r),o,l,s=(i+a)/2;if(i===a)o=l=0;else{let n=i-a;switch(l=s>.5?n/(2-i-a):n/(i+a),i){case e:o=(t-r)/n+6*(t<r);break;case t:o=(r-e)/n+2;break;case r:o=(e-t)/n+4}o/=6}return{h:o,s:l,l:s}}hslToRgb(e,t,r){let i,a,o;if(0===t)i=a=o=r;else{let l=(e,t,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6)?e+(t-e)*6*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e,s=r<.5?r*(1+t):r+t-r*t,n=2*r-s;i=l(n,s,e+1/3),a=l(n,s,e),o=l(n,s,e-1/3)}return{r:Math.round(255*i),g:Math.round(255*a),b:Math.round(255*o)}}parseColorFromHex(e){if(!e||"string"!=typeof e)return null;let t=e.replace("#","");return 6===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:255}:null}applyColorModifications(e,t){let r={...e};if(void 0!==t.tint){let e=t.tint/1e5;r.r=Math.round(r.r+(255-r.r)*e),r.g=Math.round(r.g+(255-r.g)*e),r.b=Math.round(r.b+(255-r.b)*e)}if(void 0!==t.shade){let e=t.shade/1e5;r.r=Math.round(r.r*(1-e)),r.g=Math.round(r.g*(1-e)),r.b=Math.round(r.b*(1-e))}if(void 0!==t.sat){let e=t.sat/1e5,i=.299*r.r+.587*r.g+.114*r.b;r.r=Math.round(i+(r.r-i)*e),r.g=Math.round(i+(r.g-i)*e),r.b=Math.round(i+(r.b-i)*e)}return void 0!==t.alpha&&(r.a=Math.round(255*(t.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)),r}getAllShapesFromTree(e){let t=[],r=e=>{e&&(Array.isArray(e)?e.forEach(r):"object"==typeof e&&((e.nvSpPr||e.nvPicPr||e.nvGrpSpPr)&&t.push(e),Object.values(e).forEach(e=>{e&&"object"==typeof e&&r(e)})))};return r(e),t}resolveStyleFillColor(e){try{if(!e)return null;let t=this._currentProcessingShape,r=t&&("Rectangle 3"===t.name||t.name?.includes("Rectangle 3")),i=e.idx||0;if(e.color){let t=this.processShapeColor(e.color);return t&&void 0!==t.r?(t.r,t.g,t.b,t.a):JSON.stringify(t),t}let a=this.presentation?.theme;if(r&&a&&a.colors&&a.colors.accent6&&this.parseColorFromHex(a.colors.accent6),a&&a.formatScheme){if(r&&a.formatScheme.fillStyles&&a.formatScheme.fillStyles.forEach((e,t)=>{}),i<1e3){let t=i-1;if(t>=0&&a.formatScheme.fillStyles&&t<a.formatScheme.fillStyles.length){let r=a.formatScheme.fillStyles[t];if(r.color&&"solid"===r.type)return r.color;if(r.gradient&&"gradient"===r.type)return this.processGradientFill(r.gradient);let i=this.processFillStyleToColor(r,e.color);if(i)return i}}else if(i>=1001){let t=i-1001;if(t>=0&&a.formatScheme.backgroundFills&&t<a.formatScheme.backgroundFills.length){let r=a.formatScheme.backgroundFills[t];if(r.color&&"solid"===r.type)return r.color;let i=this.processFillStyleToColor(r,e.color);if(i)return i}}}return null}catch(e){return null}}processFillStyleToColor(e,t=null){if(!e)return null;try{if("solid"===e.type&&e.color){if("placeholder"===e.color.type&&"phClr"===e.color.scheme){let r=this._currentProcessingShape;if(r&&!r.placeholder)return null;let i=t?this.processShapeColor(t):null;return this.resolvePlaceholderColor(e.color,i)}if(t)return this.processShapeColor(t);return this.processShapeColor(e.color)}if("gradient"===e.type){let r=null;if(e.stops&&e.stops.length>0?r=e.stops[0].color:e.gradient&&e.gradient.colors&&e.gradient.colors.length>0&&(r=e.gradient.colors[0]),r){if("placeholder"===r.type&&"phClr"===r.value){let e=this._currentProcessingShape;if(e&&!e.placeholder)return null;let i=t?this.processShapeColor(t):null,a=this.resolvePlaceholderColor(r,i);return r.modifications&&r.modifications.length>0&&(a=this.applyColorModifications(a,r.modifications)),a}if("scheme"===r.type){let e=this.getThemeColor(r.value);if(e){let t=e;return r.modifications&&r.modifications.length>0&&(t=this.applyColorModifications(t,r.modifications)),t}}if(t)return this.processShapeColor(t);return this.processShapeColor(r)}}if("pattern"===e.type&&e.fgColor){if(t)return this.processShapeColor(t);return this.processShapeColor(e.fgColor)}if("blip"===e.type||"image"===e.type)return null;"none"===e.type||e.type}catch(e){}return null}isImageLoading(e){return!this.imageCache.has(e)&&this.imageMap.has(e)}triggerSlideRerender(){"u">typeof window&&window.dispatchEvent(new Event("slideImageLoaded",{detail:{slideIndex:this.currentSlideIndex}}))}logSlideImageStatus(e,t){if(e.backgroundFill&&e.backgroundFill.fill){let t=e.backgroundFill.fill;if("image"===t.type&&t.imageData){let e=t.imageData.relationshipId;this.imageCache.has(e)}}if(e.commonSlideData&&e.commonSlideData.shapeTree)for(let t of e.commonSlideData.shapeTree)"pic"===t.type&&t.imageRelId&&this.imageCache.has(t.imageRelId)}async drawGroupShapeGeometry(e,t,r,i,a,o,l,s,n,h){e.SaveGrState();try{if(t.transform){if(t.transform.rotation&&0!==t.transform.rotation){let l=r+a/2,s=i+o/2;e.transform(Math.cos(t.transform.rotation*Math.PI/180),Math.sin(t.transform.rotation*Math.PI/180),-Math.sin(t.transform.rotation*Math.PI/180),Math.cos(t.transform.rotation*Math.PI/180),l-l*Math.cos(t.transform.rotation*Math.PI/180)+s*Math.sin(t.transform.rotation*Math.PI/180),s-l*Math.sin(t.transform.rotation*Math.PI/180)-s*Math.cos(t.transform.rotation*Math.PI/180))}if(t.transform.flipH||t.transform.flipV){let l=t.transform.flipH?-1:1,s=t.transform.flipV?-1:1,n=r+a/2,h=i+o/2;e.transform(l,0,0,s,n-n*l,h-h*s)}}if(l)if("object"==typeof l&&"linear"===l.type)e.fillRect(r,i,a,o,l);else{let t=null;"string"==typeof l?t=this.hexToRgb(l):void 0!==l.r&&(t=l),t&&e.drawRectangle(r,i,a,o,t,null,0)}if(s&&n>0){let t=null;"string"==typeof s?t=this.hexToRgb(s):void 0!==s.r&&(t=s),t&&e.drawRectangle(r,i,a,o,null,t,n)}if(t.shapeTree&&t.shapeTree.length>0){let r=this.sortShapesByRenderOrder(t.shapeTree);for(let t=0;t<r.length;t++){let i=r[t];try{await this.renderShape(e,i,h)}catch(e){}}}}catch(e){}finally{e.RestoreGrState()}}drawConnectorShapeGeometry(e,t,r,i,a,o,l,s){e.drawLine(r,i,r+a,i+o,l,s)}drawGraphicFrameGeometry(e,t,r,i,a,o,l,s,n){e.drawRectangle(r,i,a,o,null,"#a0a0a0",1)}drawDefaultShapeGeometry(e,t,r,i,a,o,l,s,n){e.drawRectangle(r,i,a,o,l,"#ff0000",n)}rgbToHex(e){if(!e)return null;let t=e=>{let t=Math.max(0,Math.min(255,Math.round(e))).toString(16);return 1===t.length?"0"+t:t};return`#${t(e.r||e.R||0)}${t(e.g||e.G||0)}${t(e.b||e.B||0)}`}createRotationMatrix(e,t,r){let i=e*Math.PI/180,a=Math.cos(i),o=Math.sin(i);return{a:a,b:o,c:-o,d:a,e:t-t*a+r*o,f:r-t*o-r*a}}applyRotationTransform(e,t,r,i,a,o){let l=this.getShapeRotation(t);if(!l||0===l)return!1;let s=this.createRotationMatrix(l,r+a/2,i+o/2),n={sx:s.a,sy:s.d,shx:s.c,shy:s.b,tx:s.e,ty:s.f,createDuplicate(){return{sx:this.sx,sy:this.sy,shx:this.shx,shy:this.shy,tx:this.tx,ty:this.ty,createDuplicate:this.createDuplicate}}};return e.transform3?e.transform3(n):e.transform&&e.transform(s.a,s.b,s.c,s.d,s.e,s.f),!0}getShapeRotation(e){return e.properties?.transform?.rot!==void 0?e.properties.transform.rot:e.transform?.rotation!==void 0?e.transform.rotation:e.spPr?.transform?.rot!==void 0?e.spPr.transform.rot:0}calculateRotatedBounds(e,t){if(!t||0===t)return e;let{x:r,y:i,w:a,h:o}=e,l=r+a/2,s=i+o/2,n=t*Math.PI/180,h=Math.cos(n),c=Math.sin(n),u=[{x:r,y:i},{x:r+a,y:i},{x:r+a,y:i+o},{x:r,y:i+o}].map(e=>{let t=e.x-l,r=e.y-s;return{x:l+t*h-r*c,y:s+t*c+r*h}}),d=Math.min(...u.map(e=>e.x)),p=Math.min(...u.map(e=>e.y));return{x:d,y:p,w:Math.max(...u.map(e=>e.x))-d,h:Math.max(...u.map(e=>e.y))-p}}getDefaultTextColor(e){if(this.presentation?.theme?.colors)if(e.placeholder?.type!=="title"&&e.placeholder?.type!=="ctrTitle")return this.presentation.theme.colors.tx1||this.presentation.theme.colors.tx2||{r:0,g:0,b:0,a:255};else{let e=this.resolveThemeColor("dk2");if(e)return e;let t=this.resolveThemeColor("dk1");return t||this.presentation.theme.colors.tx1||{r:0,g:0,b:0,a:255}}return{r:0,g:0,b:0,a:255}}async extractPartMediaRelationships(e){try{let t=await e.getRelationships();for(let[e,r]of Object.entries(t))if(r.type===I.image.relationType||r.type.includes("video")||r.type.includes("audio")){let t=r.target;if(t.startsWith("../")?t=t.replace("../","ppt/"):t.startsWith("/")||(t=`/ppt/${t}`),this.mediaMap.set(e,{path:t,type:r.type}),this.isImageFile(t)){let r=this.imageMap.get(e);!r||this.isSVGFile(t)&&!this.isSVGFile(r)?(this.imageMap.set(e,t),this.isSVGFile(t)):!this.isSVGFile(t)&&this.isSVGFile(r)||this.imageMap.set(e,t)}}}catch(e){}}isMediaFile(e){let t=e.toLowerCase();return[".png",".jpg",".jpeg",".gif",".bmp",".svg",".webp",".tiff",".mp4",".mov",".avi",".mp3",".wav",".ogg"].some(e=>t.endsWith(e))}isSVGFile(e){return e&&e.toLowerCase().endsWith(".svg")}extractSVGRelationshipId(e){try{let t=e.getElementsByTagName("*");for(let e=0;e<t.length;e++){let r=t[e];if("svgBlip"===r.localName){let e=r.getAttribute("r:embed")||r.getAttribute("r:id")||r.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","embed");if(e)return e}}return null}catch(e){return console.warn("[WARN] Slide Renderer: Error extracting SVG relationship ID:",e),null}}buildSVGRelationshipMapping(){let e=new Map,t=new Map;for(let[r,i]of this.imageMap.entries()){let a=i.split("/").pop().replace(/\.[^.]+$/,"");this.isSVGFile(i)?t.set(a,r):i.toLowerCase().endsWith(".png")&&e.set(a,r)}for(let[r,i]of e.entries()){let e=t.get(r);if(!e){let i=r.match(/^(image-\d+-)(\d+)$/);if(i){let r=i[1]+(parseInt(i[2])+1);e=t.get(r)}}e&&this.svgRelationshipMap.set(i,e)}}async loadAndDrawImage(e,t,r,i,a,o,l){try{if(this.isSVGFile(r.path)&&this.svgRenderer)return void await this.loadAndDrawSVGImage(e,t,r,i,a,o,l);this.isSVGFile(r.path)&&this.logger.log("warn",this.constructor.name,`SVG detected but no SVG renderer available: ${r.path}`);let s=this.imageCache.get(t.imageRelId);if(!s){let e=await this.zip.getFileData(r.path);if(!e)throw Error("Image file not found in ZIP");let i=this.getMimeType(r.path),a=new Blob([e],{type:i}),o=URL.createObjectURL(a),l=new Image;l.crossOrigin="anonymous",await new Promise((e,r)=>{l.onload=()=>{s={image:l,width:l.naturalWidth,height:l.naturalHeight,url:o},this.imageCache.set(t.imageRelId,s),e()},l.onerror=()=>{r(Error("Failed to load image"))},l.src=o})}this.drawActualImage(e,t,s,i,a,o,l)}catch(r){this.drawImagePlaceholder(e,t,i,a,o,l)}}async loadAndDrawSVGImage(e,t,r,i,a,o,l){try{let e=this.imageCache.get(t.imageRelId);if(!e){let i=await this.zip.getFileData(r.path);if(!i)throw Error("SVG file not found in ZIP");e={content:new TextDecoder("utf-8").decode(i),type:"svg",path:r.path,width:100,height:100},this.imageCache.set(t.imageRelId,e)}await this.svgRenderer.renderSVG(e.content,i,a,o,l,{preserveAspectRatio:!0})}catch(s){this.logger.logError(this.constructor.name,`Failed to load/render SVG: ${r.path}`,s);try{let s=await this.zip.getFileData(r.path);if(s){let r=new Blob([s],{type:"image/svg+xml"}),n=URL.createObjectURL(r),h=new Image;h.crossOrigin="anonymous",await new Promise((r,s)=>{h.onload=()=>{let s={image:h,width:h.naturalWidth,height:h.naturalHeight,url:n};this.drawActualImage(e,t,s,i,a,o,l),r()},h.onerror=s,h.src=n})}}catch(r){this.logger.log("warn",this.constructor.name,"SVG fallback also failed, showing placeholder"),this.drawImagePlaceholder(e,t,i,a,o,l)}}}drawFilePlaceholder(e,t,r,i,a,o,l){let s=e.getContext();s.save(),s.fillStyle="#e9ecef",s.fillRect(i,a,o,l),s.strokeStyle="#adb5bd",s.lineWidth=1,s.strokeRect(i,a,o,l);let n="❓";r.includes("video")?n="\uD83C\uDFAC":r.includes("audio")&&(n="\uD83C\uDFB5"),s.fillStyle="#495057",s.font=`${.5*Math.min(o,l)}px Arial`,s.textAlign="center",s.textBaseline="middle",s.fillText(n,i+o/2,a+l/2),s.restore()}async renderShape(e,t,r){try{if(!t)return;let i=this.getShapeBounds(t,r);if(!i||i.w<=0||i.h<=0)return;let{x:a,y:o,w:l,h:s}=i;if(t.groupTransform){e.SaveGrState();let i=this.createTransformMatrix(t,r);e.transform3(i)}switch(t.graphicData&&t.graphicData.uri,t.type){case"sp":this.renderRegularShape(e,t,a,o,l,s);break;case"pic":await this.renderPictureShape(e,t,a,o,l,s);break;case"grpSp":this.renderGroupShape(e,t);break;case"cxnSp":this.renderConnectorShape(e,t,a,o,l,s);break;case"graphicFrame":await this.renderGraphicFrame(e,t,a,o,l,s);break;default:this.renderDefaultShape(e,t,a,o,l,s)}t.groupTransform&&e.RestoreGrState()}catch(e){}}renderRegularShape(e,t,r,i,a,o){let l=this.getShapeRotation(t);0!==l&&e.SaveGrState(),this.applyRotationTransform(e,t,r,i,a,o);let s=this.getShapeFillColor(t),n=this.getShapeStrokeColor(t),h=this.getShapeLineWidth(t),c=this.getShapeStrokeInfo(t),u=this.getShapePresetGeometry(t),d=this.extractShapeAdjustments(t),p=null,g=null;s&&("object"==typeof s&&s.type&&s.stops?p=s:"string"==typeof s?p=this.hexToRgb(s):void 0!==s.r&&(p=s)),n&&("string"==typeof n?g=this.hexToRgb(n):void 0!==n.r&&(g=n)),u?e.drawPresetGeometry(u,r,i,a,o,p,g,h,c,d):e.drawRectangle(r,i,a,o,p,g,h||2,c),0!==l&&e.RestoreGrState()}extractShapeAdjustments(e){let t={};try{if(e.geometry){if(e.geometry.avLst)for(let[r,i]of Object.entries(e.geometry.avLst))"object"==typeof i&&void 0!==i.val?t[r]=i.val:"number"==typeof i&&(t[r]=i);if(e.geometry.adjLst)for(let[r,i]of Object.entries(e.geometry.adjLst))"object"==typeof i&&void 0!==i.val?t[r]=i.val:"number"==typeof i&&(t[r]=i);if(e.geometry.preset&&e.geometry.adjustments)for(let[r,i]of Object.entries(e.geometry.adjustments))t[r]=i}if(e.spPr&&e.spPr.geometry){let r=e.spPr.geometry;if(r.avLst){for(let e of r.avLst)if(e.name&&void 0!==e.fmla){let r=this.parseAdjustmentValue(e.fmla);null!==r&&(t[e.name]=r)}}}e.adjustments&&Object.assign(t,e.adjustments),e.commonSlideData&&e.commonSlideData.adjustments&&Object.assign(t,e.commonSlideData.adjustments)}catch(e){}return t}parseAdjustmentValue(e){if("number"==typeof e)return e;if("string"==typeof e){let t=parseFloat(e);if(!isNaN(t))return t;let r=e.match(/val\s+(-?\d+)/);if(r)return parseInt(r[1],10);let i=e.match(/(-?\d+)%/);if(i)return 1e3*parseInt(i[1],10)}return null}getShapePresetGeometry(e){return e.geometry&&e.geometry.preset?e.geometry.preset:e.properties&&e.properties.geometry&&e.properties.geometry.preset?e.properties.geometry.preset:e.spPr&&e.spPr.geometry&&e.spPr.geometry.preset?e.spPr.geometry.preset:e.spPr&&e.spPr.prstGeom&&e.spPr.prstGeom.prst?e.spPr.prstGeom.prst:null}getShapeStrokeInfo(e){let t={},r=e.properties?.line||e.properties?.stroke;if(r){if(r.dashArray&&r.dashArray.length>0&&(t.dashArray=r.dashArray),(r.lineCap||r.cap)&&(t.lineCap=r.lineCap||r.cap),(r.lineJoin||r.join)&&(t.lineJoin=r.lineJoin||r.join),r.miterLimit&&(t.miterLimit=r.miterLimit),r.headEnd){let e=r.headEnd;t.headEnd={type:e.type||e.val||"none",w:e.w||e.width,len:e.len||e.length}}if(r.tailEnd){let e=r.tailEnd;t.tailEnd={type:e.type||e.val||"none",w:e.w||e.width,len:e.len||e.length}}}if(e.spPr&&e.spPr.ln){let r=e.spPr.ln;r.prstDash&&(t.dashArray=this.convertstandardDashPattern(r.prstDash)),r.cap&&(t.lineCap=this.convertstandardLineCap(r.cap)),r.join&&(t.lineJoin=this.convertstandardLineJoin(r.join)),this._mapArrowSize.bind(this);let i=e=>e?e.toString():"none";r.headEnd&&(t.headEnd={type:i(r.headEnd.type),w:r.headEnd.w,len:r.headEnd.len}),r.tailEnd&&(t.tailEnd={type:i(r.tailEnd.type),w:r.tailEnd.w,len:r.tailEnd.len})}return Object.keys(t).length>0?t:null}_mapArrowSize(e){switch((e||"").toString()){case"sm":case"small":default:return 1;case"med":case"medium":return 1.5;case"lg":case"large":return 2}}convertstandardDashPattern(e){return({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]})[e]||[]}convertstandardLineCap(e){return({rnd:"round",sq:"square",flat:"butt"})[e]||"round"}convertstandardLineJoin(e){return({round:"round",bevel:"bevel",miter:"miter"})[e]||"round"}async renderPictureShape(e,t,r,i,a,o){let l=this.getShapeRotation(t),s=l&&0!==l;s&&(e.SaveGrState(),this.applyRotationTransform(e,t,r,i,a,o));let n=this.getShapePresetGeometry(t);if(n&&"rect"!==n){let l=this.getShapeStrokeColor(t),s=this.getShapeLineWidth(t),h=this.getShapeStrokeInfo(t);e.drawPresetGeometry(n,r,i,a,o,null,l,s,h)}let h=this.getShapeFillColor(t),c=this.getShapeStrokeColor(t),u=this.getShapeLineWidth(t);try{await this.drawPictureShapeGeometry(e,t,r,i,a,o,h,c,u)}catch(l){this.drawImagePlaceholder(e,t,r,i,a,o)}s&&e.RestoreGrState()}renderConnectorShape(e,t,r,i,a,o){let l=this.getShapeRotation(t),s=l&&0!==l;s&&(e.SaveGrState(),this.applyRotationTransform(e,t,r,i,a,o));let n=this.getShapeStrokeColor(t),h=this.getShapeLineWidth(t),c=this.getShapeStrokeInfo(t),u=this.getConnectorType(t);try{this.logger?.log("info",this.constructor.name,"[Connector Render] start",{connectorType:u,bounds:{x:r,y:i,w:a,h:o},strokeColor:n,lineWidth:h,strokeInfo:c})}catch(e){}switch(u){case"straight":"function"==typeof e.drawLineWithArrows?e.drawLineWithArrows(r,i,r+a,i+o,n,h,c):e.drawLine(r,i,r+a,i+o,n,h);break;case"elbow":this.drawElbowConnector(e,r,i,a,o,n,h,c);break;case"curved":this.drawCurvedConnector(e,r,i,a,o,n,h,c);break;default:e.drawLine(r,i,r+a,i+o,n,h)}s&&e.RestoreGrState();try{this.logger?.log("info",this.constructor.name,"[Connector Render] done")}catch(e){}}getConnectorType(e){if(e.properties&&e.properties.connector)return e.properties.connector.type||"straight";if(e.spPr&&e.spPr.connector)return e.spPr.connector.type||"straight";let t=this.getShapePresetGeometry(e);if(t&&t.includes("Connector")){if(t.includes("bent"))return"elbow";else if(t.includes("curved"))return"curved"}return"straight"}drawElbowConnector(e,t,r,i,a,o,l,s){if(!e.m_oContext)return;e.m_oContext.save(),e.m_oContext.beginPath();let n=t+.5*i,h=r+.5*a;e.m_oContext.moveTo(t,r),e.m_oContext.lineTo(n,r),e.m_oContext.lineTo(n,h),e.m_oContext.lineTo(t+i,h),e.m_oContext.lineTo(t+i,r+a),o&&(e.m_oContext.strokeStyle=e.colorToRgb(o),e.m_oContext.lineWidth=l||1,s&&e.applyStrokeInfo(s),e.m_oContext.stroke()),e.m_oContext.restore()}drawCurvedConnector(e,t,r,i,a,o,l,s){e.m_oContext&&(e.m_oContext.save(),e.m_oContext.beginPath(),e.m_oContext.moveTo(t,r),e.m_oContext.bezierCurveTo(t+.3*i,r,t+.7*i,r+a,t+i,r+a),o&&(e.m_oContext.strokeStyle=e.colorToRgb(o),e.m_oContext.lineWidth=l||1,s&&e.applyStrokeInfo(s),e.m_oContext.stroke()),e.m_oContext.restore())}async renderGraphicFrame(e,t,r,i,a,o){let l=this.getShapeRotation(t),s=l&&0!==l;s&&(e.SaveGrState(),this.applyRotationTransform(e,t,r,i,a,o));let n=this.getShapeStrokeColor(t),h=this.getShapeLineWidth(t)||1,c=this.getShapeStrokeInfo(t);if(e.drawRectangle(r,i,a,o,null,n,h,c),t.graphicData)switch(t.graphicData.uri){case"http://schemas.openxmlformats.org/drawingml/2006/table":this.renderTableFrame(e,t,r,i,a,o);break;case"http://schemas.openxmlformats.org/drawingml/2006/chart":await this.renderChartFrame(e,t,r,i,a,o);break;case"http://schemas.openxmlformats.org/drawingml/2006/diagram":this.renderDiagramFrame(e,t,r,i,a,o);break;default:this.renderGenericFrame(e,t,r,i,a,o)}else this.renderGenericFrame(e,t,r,i,a,o);s&&e.RestoreGrState()}renderTableFrame(e,t,r,i,a,o){let l=this.getTableInstance(t);if(!l)return void this.drawTablePlaceholder(e,r,i,a,o);e.SaveGrState();try{this.drawTableBackgroundAndOuterBorder(e,l,r,i,a,o),this.drawCellsBackground(e,l,r,i,a,o),this.drawCellsContent(e,l,r,i,a,o),this.drawCellsBorders(e,l,r,i,a,o)}catch(t){this.drawTablePlaceholder(e,r,i,a,o)}finally{e.RestoreGrState()}}getTableInstance(e){if(e.table&&e.table instanceof CTable)return e.table;if(e.graphicData&&e.graphicData.tableXml)try{let t=this.parseTableFromXML(e.graphicData.tableXml);if(t)return e.table=t,t}catch(e){console.error("[GetTableInstance] Error parsing table:",e.message),console.error("[GetTableInstance] Error stack:",e.stack)}return null}drawTableBackgroundAndOuterBorder(e,t,r,i,a,o){t.getTableProperties();let l=t.getTableBorders(),s=t.getTableShading();if(s&&s.fill){let t=this.resolveTableBackgroundColor(s);e.b_color1(t.r,t.g,t.b,t.a||255),e.TableRect(r,i,a,o)}l&&this.drawTableOuterBorder(e,l,r,i,a,o)}drawCellsBackground(e,t,r,i,a,o){let l=t.getRowCount(),s=t.getColumnCount(),n=this.calculateCellWidths(t,a),h=this.calculateCellHeights(t,o),c=i;for(let i=0;i<l;i++){let a=r,o=h[i];for(let r=0;r<s;r++){let o=t.getCell(i,r);if(!o)continue;let l=n[r],s=o.getGridSpan()||1,u=o.getRowSpan()||1,d=this.calculateMergedCellWidth(n,r,s),p=this.calculateMergedCellHeight(h,i,u);this.isStartingCellOfMerge(o,i,r)&&this.drawCellBackground(e,o,a,c,d,p),a+=l}c+=o}}drawCellsContent(e,t,r,i,a,o){let l=t.getRowCount(),s=t.getColumnCount(),n=this.calculateCellWidths(t,a),h=this.calculateCellHeights(t,o),c=i;for(let i=0;i<l;i++){let a=r,o=h[i];for(let r=0;r<s;r++){let o=t.getCell(i,r);if(!o)continue;let l=n[r];if(this.isStartingCellOfMerge(o,i,r)){let t=o.getGridSpan()||1,l=o.getRowSpan()||1,s=this.calculateMergedCellWidth(n,r,t),u=this.calculateMergedCellHeight(h,i,l);this.drawCellContent(e,o,a,c,s,u)}a+=l}c+=o}}drawCellsBorders(e,t,r,i,a,o){let l=t.getRowCount(),s=t.getColumnCount(),n=this.calculateCellWidths(t,a),h=this.calculateCellHeights(t,o);for(let a=0;a<l;a++)for(let o=s-1;o>=0;o--){let l=t.getCell(a,o);if(!l)continue;let s=n[o],c=h[a],u=r+this.calculateCellXOffset(n,o),d=i+this.calculateCellYOffset(h,a);this.drawCellBorders(e,l,u,d,s,c,a,o,t)}}drawTablePlaceholder(e,t,r,i,a){let o=i/3,l=a/3;for(let i=0;i<3;i++)for(let a=0;a<3;a++){let s=t+a*o,n=r+i*l;e.drawRectangle(s,n,o,l,null,{r:128,g:128,b:128,a:255},1)}this.drawCenteredText(e,"Table",t,r,i,a)}drawTableOuterBorder(e,t,r,i,a,o){["top","right","bottom","left"].forEach(l=>{let s=t[l];if(s&&"none"!==s.style){let t=this.resolveBorderColor(s),n=s.width||1;switch(e.p_color(t.r,t.g,t.b,t.a||255),e.p_width(n),l){case"top":e.drawHorLine(r,i,r+a,i,n);break;case"right":e.drawVerLine(r+a,i,i+o,n);break;case"bottom":e.drawHorLine(r,i+o,r+a,i+o,n);break;case"left":e.drawVerLine(r,i,i+o,n)}}})}drawCellBackground(e,t,r,i,a,o){let l=t.getCellShading();if(l&&l.fill){let t=this.resolveCellBackgroundColor(l);e.b_color1(t.r,t.g,t.b,t.a||255),e.TableRect(r,i,a,o)}}drawCellContent(e,t,r,i,a,o){let l=t.getTextBody();l&&l.paragraphs&&this.renderCellTextContent(e,l,r+5,i+5,a-10,o-10)}drawCellBorders(e,t,r,i,a,o,l,s,n){let h=t.getCellBorders();h&&["top","right","bottom","left"].forEach(t=>{let c=h[t];if(c&&"none"!==c.style&&this.shouldDrawBorder(t,l,s,n)){let l=this.resolveBorderColor(c),s=c.width||1;switch(e.p_color(l.r,l.g,l.b,l.a||255),e.p_width(s),t){case"top":e.drawHorLine(r,i,r+a,i,s);break;case"right":e.drawVerLine(r+a,i,i+o,s);break;case"bottom":e.drawHorLine(r,i+o,r+a,i+o,s);break;case"left":e.drawVerLine(r,i,i+o,s)}}})}shouldDrawBorder(e,t,r,i){let a=i.getRowCount(),o=i.getColumnCount();switch(e){case"top":return 0===t;case"right":return r===o-1;case"bottom":return t===a-1;case"left":return 0===r;default:return!0}}calculateCellWidths(e,t){let r=e.getTableGrid();if(!r||0===r.length){let r=e.getColumnCount();return Array(r).fill(t/r)}let i=r.reduce((e,t)=>e+(t.width||0),0);return r.map(e=>(e.width||0)/i*t)}calculateCellHeights(e,t){let r=e.getRowCount(),i=[],a=!1;for(let t=0;t<r;t++){let r=e.getRow(t);r&&r.height?(i.push(r.height),a=!0):i.push(0)}if(!a)return i.map(()=>t/r);let o=i.reduce((e,t)=>e+t,0),l=i.filter(e=>0===e).length,s=l<r?o/(r-l):t/r,n=i.map(e=>0===e?s:e),h=n.reduce((e,t)=>e+t,0);return n.map(e=>e/h*t)}isStartingCellOfMerge(e,t,r){return!e.isMergedContinue}calculateMergedCellWidth(e,t,r){let i=0;for(let a=0;a<r;a++)t+a<e.length&&(i+=e[t+a]);return i}calculateMergedCellHeight(e,t,r){let i=0;for(let a=0;a<r;a++)t+a<e.length&&(i+=e[t+a]);return i}calculateCellXOffset(e,t){let r=0;for(let i=0;i<t;i++)r+=e[i];return r}calculateCellYOffset(e,t){let r=0;for(let i=0;i<t;i++)r+=e[i];return r}resolveTableBackgroundColor(e){return{r:255,g:255,b:255,a:255}}resolveCellBackgroundColor(e){return{r:255,g:255,b:255,a:255}}resolveBorderColor(e){return{r:0,g:0,b:0,a:255}}renderCellTextContent(e,t,r,i,a,o){if(!t.paragraphs||0===t.paragraphs.length)return;let l=i;t.paragraphs.forEach(t=>{if(!t.runs||0===t.runs.length){l+=16;return}let i=t.runs.map(e=>e.text||"").join("");if(!i.trim()){l+=16;return}let a=t.properties||{},o=a.fontSize||12,s=a.fontFamily||"Arial",n=a.bold||!1,h=a.italic||!1;e.font(s,o,n?"bold":"normal",h?"italic":"normal");let c=this.resolveTextColor(t);e.b_color1(c.r,c.g,c.b,c.a||255),e.FillText(r,l,i),l+=16})}resolveTextColor(e){return{r:0,g:0,b:0,a:255}}parseTableFromXML(e){if(!e)return null;try{let t=new DOMParser().parseFromString(e,"text/xml");if("parsererror"===t.documentElement.nodeName)return console.error("[ParseTableXML] XML parsing error"),null;let r=new CTable;if(this.parseTableProperties(t,r),this.parseTableGrid(t,r),this.parseTableRows(t,r),this.processTableMerges(r),!this.validateTableStructure(r))return null;return r}catch(e){return console.error("[ParseTableXML] Exception during table parsing:",e.message),console.error("[ParseTableXML] Error stack:",e.stack),null}}parseTableProperties(e,t){let r=e.querySelector("tblPr");if(r||(r=e.querySelector("a\\:tblPr")),r){let e={},i=r.querySelector("tblStyle");i||(i=r.querySelector("a\\:tblStyle")),i&&(e.style=i.getAttribute("val"));let a=r.querySelector("tblBorders");a||(a=r.querySelector("a\\:tblBorders")),a&&(e.borders=this.parseTableBorders(a));let o=r.querySelector("tblShading");o||(o=r.querySelector("a\\:tblShading")),o&&(e.shading=this.parseTableShading(o));let l=r.querySelector("tblLayout");l||(l=r.querySelector("a\\:tblLayout")),l&&(e.layout=l.getAttribute("type")||"autofit");let s=r.querySelector("tblW");if(s||(s=r.querySelector("a\\:tblW")),s){let t=s.getAttribute("w"),r=s.getAttribute("type")||s.getAttribute("wtype")||"auto";t?e.preferredWidth={value:parseInt(t)||0,type:r.toLowerCase()}:e.preferredWidth={value:0,type:r.toLowerCase()}}t.setTableProperties(e)}}parseTableGrid(e,t){let r=e.querySelector("tblGrid");if(r||(r=e.querySelector("a\\:tblGrid")),r){let e=r.querySelectorAll("gridCol");0===e.length&&(e=r.querySelectorAll("a\\:gridCol"));let i=[];e.forEach(e=>{let t=e.getAttribute("w"),r={width:t?parseInt(t):914400,type:e.getAttribute("type")||"auto"};i.push(r)}),t.setTableGrid(i)}}parseTableRows(e,t){let r=e.querySelectorAll("tr");0===r.length&&(r=e.querySelectorAll("a\\:tr")),r.forEach((e,r)=>{let i=new CTableRow;this.parseRowProperties(e,i),this.parseRowCells(e,i,r),t.addRow(i)})}parseRowProperties(e,t){let r=e.querySelector("trPr");if(r||(r=e.querySelector("a\\:trPr")),r){let e=r.querySelector("trHeight");if(e||(e=r.querySelector("a\\:trHeight")),e){let r=parseInt(e.getAttribute("val"),10);Number.isNaN(r)||(t.height=r),t.heightRule=e.getAttribute("hRule")||"auto"}let i=r.querySelector("tblHeader");i||(i=r.querySelector("a\\:tblHeader")),i&&(t.isHeader=!0)}if((!t.height||t.height<=0)&&e){let r=e.getAttribute("h");if(null!==r){let e=parseInt(r,10);!Number.isNaN(e)&&e>0&&(t.height=e,t.heightRule||(t.heightRule="auto"))}}}parseRowCells(e,t,r){let i=e.querySelectorAll("tc");0===i.length&&(i=e.querySelectorAll("a\\:tc")),i.forEach((e,i)=>{let a=new CTableCell;this.parseCellProperties(e,a,r,i),this.parseCellContent(e,a),t.addCell(a)})}parseCellProperties(e,t,r,i){let a=e.getAttribute("gridSpan"),o=e.getAttribute("rowSpan"),l=e.getAttribute("vMerge"),s=e.getAttribute("hMerge");if(a){let e=parseInt(a);e>1&&(t.gridSpan=e)}if(o){let e=parseInt(o);e>1&&(t.rowSpan=e)}("1"===l||"true"===l||"continue"===l)&&(t.isMergedContinue=!0),("1"===s||"true"===s)&&(t.isMergedContinue=!0);let n=e.querySelector("tcPr");if(n||(n=e.querySelector("a\\:tcPr")),n){let e=n.querySelector("gridSpan");if(e||(e=n.querySelector("a\\:gridSpan")),e){let r=parseInt(e.getAttribute("val"))||1;r>1&&(t.gridSpan=r)}let r=n.querySelector("rowSpan");if(r||(r=n.querySelector("a\\:rowSpan")),r){let e=parseInt(r.getAttribute("val"))||1;e>1&&(t.rowSpan=e)}let i=n.querySelector("vMerge");i||(i=n.querySelector("a\\:vMerge")),i&&"restart"!==i.getAttribute("val")&&(t.isMergedContinue=!0);let a=n.querySelector("tcBorders");a||(a=n.querySelector("a\\:tcBorders")),a&&(t.borders=this.parseCellBorders(a));let o=n.querySelector("tcShading");o||(o=n.querySelector("a\\:tcShading")),o&&(t.shading=this.parseCellShading(o));let l=n.querySelector("tcMar");l||(l=n.querySelector("a\\:tcMar")),l&&(t.margins=this.parseCellMargins(l))}}parseCellContent(e,t){let r=this.parseTextBodyFromElement(e);r&&t.setTextBody(r)}processTableMerges(e){let t=e.getRows();for(let r=0;r<t.length;r++){let i=t[r].getCells();for(let t=0;t<i.length;t++){let a=i[t];a.gridSpan>1&&this.processHorizontalMerge(e,r,t,a.gridSpan),a.rowSpan>1&&this.processVerticalMerge(e,r,t,a.rowSpan)}}}processHorizontalMerge(e,t,r,i){for(let a=1;a<i;a++){let i=e.getCell(t,r+a);i&&(i.isMergedContinue=!0,i.mergeParent={row:t,col:r})}}processVerticalMerge(e,t,r,i){for(let a=1;a<i;a++){let i=e.getCell(t+a,r);i&&(i.isMergedContinue=!0,i.mergeParent={row:t,col:r})}}validateTableStructure(e){let t=e.getRows();if(0===t.length)return!1;let r=e.getTableGrid().length;if(0===r)return!1;for(let e of t){let t=e.getCells();t.length!==r&&console.warn("[Table Validation] Row has",t.length,"cells, expected",r,"- allowing due to merges")}return!0}parseTableBorders(e){let t={};return["top","left","bottom","right","insideH","insideV"].forEach(r=>{let i=e.querySelector(r);i||(i=e.querySelector(`a\\:${r}`)),i&&(t[r]=this.parseBorderProperties(i))}),t}parseCellBorders(e){return this.parseTableBorders(e)}parseBorderProperties(e){return{style:e.getAttribute("val")||"single",size:parseInt(e.getAttribute("sz"))||4,color:this.parseColor(e),space:parseInt(e.getAttribute("space"))||0}}parseTableShading(e){return this.parseCellShading(e)}parseCellShading(e){let t=e.getAttribute("fill"),r=e.getAttribute("color");return{fill:t,color:r?this.parseColorFromHex(r):null}}parseCellMargins(e){let t={};return["top","left","bottom","right"].forEach(r=>{let i=e.querySelector(r);i||(i=e.querySelector(`a\\:${r}`)),i&&(t[r]=parseInt(i.getAttribute("w"))||0)}),t}async renderChartFrame(e,t,r,i,a,o){try{let l=t.chartData;if(l&&"DEFERRED_CHART"===l.type&&(l=null,t.chartData=null),!l&&t.graphicData&&window.ChartProcessor){let e=new ChartProcessor(this.context);if(t.graphicData.chartRef){let r={slideIndex:this.currentSlideIndex,slideName:this.currentSlide?.name||`slide${this.currentSlideIndex+1}`,slide:this.currentSlide};try{let i=await e.loadChartFromRelationship(t.graphicData.chartRef,r);i&&(t.chartData=i,l=i)}catch(e){}}else l=t.graphicData.element?e.parseEmbeddedChartData(t.graphicData.element):e.createPlaceholderChart();l&&(t.chartData=l)}if(l&&ChartRenderer){let t=new ChartRenderer(e);await t.renderChart(l,r,i,a,o);return}this.renderEnhancedChartPlaceholder(e,t,r,i,a,o)}catch(l){console.error("[Chart Debug] Error in renderChartFrame:",l),this.renderSimpleChartPlaceholder(e,t,r,i,a,o)}}renderEnhancedChartPlaceholder(e,t,r,i,a,o){try{e.fillRect(r,i,a,o,{r:248,g:249,b:250}),e.strokeRect(r,i,a,o,{r:200,g:200,b:200},1);let t=r+40,l=i+30,s=a-80,n=o-60,h=[4500,5200,4800,6100,5900],c=l+n-20;e.drawLine(t,l,t,c,{r:68,g:68,b:68},1);for(let r=0;r<=7;r++){let i=1e3*r,a=c-i/7e3*(n-40);r>0&&e.drawLine(t,a,t+s,a,{r:200,g:200,b:200},1)}e.drawLine(t,c,t+s,c,{r:68,g:68,b:68},1);let u=s/(h.length-1),d={r:91,g:155,b:213};for(let r=0;r<h.length;r++){let i=t+r*u,a=(h[r]-0)/7e3,o=c-a*(n-40);if(r<h.length-1){let a=t+(r+1)*u,l=(h[r+1]-0)/7e3,s=c-l*(n-40);e.drawLine(i,o,a,s,d,2)}e.fillCircle(i,o,4,d)}let p=c+40,g=t+s/2;e.drawLine(g-30,p,g-10,p,d,2),e.fillCircle(g-20,p,3,d)}catch(l){console.error("[Chart Debug] Error rendering enhanced placeholder:",l),this.renderSimpleChartPlaceholder(e,t,r,i,a,o)}}renderSimpleChartPlaceholder(e,t,r,i,a,o){let l=a/5,s=.8*o,n=i+o-20;for(let t=0;t<4;t++){let i=r+20+t*l,a=s*(.3+.7*Math.random()),o=n-a;e.drawRectangle(i,o,.8*l,a,{r:100,g:150,b:200,a:255},null,0)}}drawValueLabel(e,t,r,i){e.m_oContext&&(e.m_oContext.save(),e.m_oContext.fillStyle="rgba(80, 80, 80, 1)",e.m_oContext.font="10px Calibri",e.m_oContext.textAlign="center",e.m_oContext.textBaseline="bottom",e.m_oContext.fillText(t,r,i),e.m_oContext.restore())}drawCategoryLabel(e,t,r,i){e.m_oContext&&(e.m_oContext.save(),e.m_oContext.fillStyle="rgba(68, 68, 68, 1)",e.m_oContext.font="10px Calibri",e.m_oContext.textAlign="center",e.m_oContext.textBaseline="top",e.m_oContext.fillText(t,r,i),e.m_oContext.restore())}drawChartTitle(e,t,r,i){e.m_oContext&&(e.m_oContext.save(),e.m_oContext.fillStyle="rgba(0, 0, 0, 1)",e.m_oContext.font="bold 14px Calibri",e.m_oContext.textAlign="center",e.m_oContext.textBaseline="middle",e.m_oContext.fillText(t,r,i),e.m_oContext.restore())}renderDiagramFrame(e,t,r,i,a,o){let l=r+a/2,s=i+o/2,n=Math.min(a,o)/4,h=[{x:l,y:s-n},{x:l+n,y:s},{x:l,y:s+n},{x:l-n,y:s}];for(let t=0;t<h.length;t++){let r=(t+1)%h.length;e.drawLine(h[t].x,h[t].y,h[r].x,h[r].y,{r:128,g:128,b:128,a:255},2)}h.forEach(t=>{e.drawEllipse(t.x-15,t.y-15,30,30,{r:200,g:200,b:200,a:255},{r:128,g:128,b:128,a:255},2)})}renderGenericFrame(e,t,r,i,a,o){e.drawRectangle(r,i,a,o,null,"#a0a0a0",1)}drawCenteredText(e,t,r,i,a,o){}renderDefaultShape(e,t,r,i,a,o){let l=this.getShapeRotation(t),s=l&&0!==l;s&&(e.SaveGrState(),this.applyRotationTransform(e,t,r,i,a,o));let n=this.getShapeFillColor(t),h=this.getShapeStrokeColor(t),c=this.getShapeLineWidth(t)||1,u=this.getShapeStrokeInfo(t);e.drawRectangle(r,i,a,o,n,h,c,u),this.drawCenteredText(e,t.type||"Shape",r,i,a,o),s&&e.RestoreGrState()}processShapeColor(e){let t;if(!e)return null;if("string"==typeof e)if(!e.startsWith("#"))return null;else t=this.hexToRgb(e);else{if("object"!=typeof e||void 0===e.r)return null;t=e}t.r,t.g,t.b,t.a;let r={...t};if(void 0!==e.tint){let 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){let t=1-e.shade/1e5;r.r=Math.round(r.r*t),r.g=Math.round(r.g*t),r.b=Math.round(r.b*t)}if(void 0!==e.satMod){let t=this.rgbToHsl(r.r,r.g,r.b);t.s*=e.satMod/1e5;let i=this.hslToRgb(t.h,t.s,t.l);r.r=i.r,r.g=i.g,r.b=i.b}return r.r,r.g,r.b,r.a,r}rgbToHsl(e,t,r){e/=255,t/=255,r/=255;let i=Math.max(e,t,r),a=Math.min(e,t,r),o,l,s=(i+a)/2;if(i===a)o=l=0;else{let n=i-a;switch(l=s>.5?n/(2-i-a):n/(i+a),i){case e:o=(t-r)/n+6*(t<r);break;case t:o=(r-e)/n+2;break;case r:o=(e-t)/n+4}o/=6}return{h:o,s:l,l:s}}hslToRgb(e,t,r){let i,a,o;if(0===t)i=a=o=r;else{let l=(e,t,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6)?e+(t-e)*6*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e,s=r<.5?r*(1+t):r+t-r*t,n=2*r-s;i=l(n,s,e+1/3),a=l(n,s,e),o=l(n,s,e-1/3)}return{r:Math.round(255*i),g:Math.round(255*a),b:Math.round(255*o)}}sortShapesByRenderOrder(e){if(!e||0===e.length)return[];let t=[...e];return t.sort((t,r)=>{let i=t.order||t.zOrder||t.index||0,a=r.order||r.zOrder||r.index||0;return i!==a?i-a:e.indexOf(t)-e.indexOf(r)}),t}}class B{constructor(){this.loadingImages=new Set,this.logger=new Logger("ImageLoader")}async loadImageFromUrl(e){return new Promise((t,r)=>{let i=new Image;i.onload=()=>{t(i)},i.onerror=e=>{r(Error(`Failed to load image: ${e.message||"Unknown error"}`))},e.startsWith("blob:")&&(i.crossOrigin="anonymous"),i.src=e})}async loadImageFromData(e,t="image/png"){try{let r=new Blob([e],{type:t}),i=URL.createObjectURL(r);return await this.loadImageFromUrl(i)}catch(e){throw e}}async preloadImages(e){let t=e.map(e=>this.loadImageFromUrl(e).catch(e=>null));return(await Promise.allSettled(t)).map(e=>"fulfilled"===e.status?e.value:null)}async getImageDimensions(e){return new Promise((t,r)=>{let i=new Image;i.onload=()=>{t({width:i.naturalWidth,height:i.naturalHeight,aspectRatio:i.naturalWidth/i.naturalHeight})},i.onerror=()=>{r(Error("Failed to load image for dimension check"))},i.src=e})}createThumbnail(e,t=150,r=150){let i,a,o=document.createElement("canvas"),l=o.getContext("2d"),s=e.naturalWidth/e.naturalHeight;return s>1?a=(i=Math.min(t,e.naturalWidth))/s:i=(a=Math.min(r,e.naturalHeight))*s,o.width=i,o.height=a,l.imageSmoothingEnabled=!0,l.imageSmoothingQuality="high",l.drawImage(e,0,0,i,a),o}getTableData(e){for(let t=0;t<this.slides.length;t++){let r=this.slides[t];if(r&&r.shapes){for(let t of r.shapes)if((t.id===e||t.name===e)&&t.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===t.graphicData.uri)return this.extractTableStructure(t)}}return null}getAllTableData(){let e=[];for(let t=0;t<this.slides.length;t++){let r=this.slides[t];if(r&&r.shapes){for(let i of r.shapes)if(i.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===i.graphicData.uri){let r=this.extractTableStructure(i);r&&(r.slideIndex=t,r.shapeId=i.id,r.shapeName=i.name,e.push(r))}}}return e}extractTableStructure(e){if(!e.graphicData||!e.graphicData.tableXml)return null;try{let t=this.parseTableFromXML(e.graphicData.tableXml);if(!t)return null;return{id:e.id,name:e.name,type:"table",properties:this.extractTableProperties(t),structure:this.extractTableStructureData(t),content:this.extractTableContent(t),styling:this.extractTableStyling(t),position:e.bounds||e.properties?.transform,metadata:{rowCount:t.getRowCount(),columnCount:t.getColumnCount(),hasMergedCells:this.hasMergedCells(t),tableStyle:t.getTableProperties()?.style||"TableGrid"}}}catch(e){return null}}extractTableProperties(e){let t=e.getTableProperties()||{};return{style:t.style||"TableGrid",layout:t.layout||"autofit",width:t.width||"auto",alignment:t.alignment||"left",borders:t.borders||{},shading:t.shading||{},spacing:{before:t.spacing?.before||0,after:t.spacing?.after||0,line:t.spacing?.line||240}}}extractTableStructureData(e){let t=e.getRows();return{grid:e.getTableGrid().map((e,t)=>({index:t,width:e.width,type:e.type||"auto"})),rows:t.map((e,t)=>({index:t,height:e.height,heightRule:e.heightRule||"auto",isHeader:e.isHeader||!1,cells:e.getCells().map((e,t)=>({index:t,gridSpan:e.gridSpan||1,rowSpan:e.rowSpan||1,vMerge:e.vMerge||null,isMergedContinue:e.isMergedContinue||!1,mergeParent:e.mergeParent||null}))}))}}extractTableContent(e){return{cells:e.getRows().map((e,t)=>e.getCells().map((e,r)=>({rowIndex:t,cellIndex:r,text:this.extractCellText(e),textBody:this.extractCellTextBody(e),content:this.extractCellContent(e)})))}}extractTableStyling(e){let t=e.getRows();return{table:{borders:e.getTableProperties()?.borders||{},shading:e.getTableProperties()?.shading||{},style:e.getTableProperties()?.style||"TableGrid"},rows:t.map((e,t)=>({index:t,height:e.height,heightRule:e.heightRule||"auto",isHeader:e.isHeader||!1})),cells:t.map((e,t)=>e.getCells().map((e,r)=>({rowIndex:t,cellIndex:r,borders:e.borders||{},shading:e.shading||{},margins:e.margins||{},verticalAlignment:e.verticalAlignment||"top",textDirection:e.textDirection||"lr"})))}}hasMergedCells(e){for(let t of e.getRows())for(let e of t.getCells())if(e.gridSpan>1||e.rowSpan>1||e.isMergedContinue)return!0;return!1}extractCellTextBody(e){let t=e.getTextBody();return t&&t.paragraphs?{paragraphs:t.paragraphs.map(e=>({properties:e.properties||{},runs:e.runs?.map(e=>({text:e.text||"",properties:e.properties||{}}))||[]}))}:null}extractCellContent(e){let t={type:"text",data:null},r=e.getTextBody();return r&&r.paragraphs&&(t.type="text",t.data=this.extractCellTextBody(e)),t}extractCellText(e){return e.textBody&&e.textBody.paragraphs?e.textBody.paragraphs.map(e=>e.runs?e.runs.map(e=>e.text||"").join(""):"").join("\n"):""}cleanup(){this.loadingImages.clear()}}"u">typeof globalThis&&(globalThis.PPTXSlideRenderer=D,globalThis.ImageLoader=B),"u">typeof window&&(window.PPTXSlideRenderer||(window.PPTXSlideRenderer=D),window.ImageLoader||(window.ImageLoader=B));class q{constructor(e={}){this._getValidator();const t=this._validateConstructorOptions(e);this.errorBoundary=new(this._getErrorBoundary())({context:"PPTXProcessor",enableLogging:!1!==t.enableLogging,errorHandler:t.errorHandler}),this.processor=null,this.presentation=null,this.isInitialized=!1,this.config={maxFileSize:t.maxFileSize||0x6400000,timeout:t.timeout||8e4,enableValidation:!1!==t.enableValidation,strictMode:!0===t.strictMode,retryOptions:{maxAttempts:t.maxRetryAttempts||3,baseDelay:t.retryDelay||1e3},...t},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 this.errorBoundary.wrap(async()=>{this._markPerformance("initialize_start");try{this._validateEnvironment(),await this._initializeWithRetry(),this.isInitialized=!0,this.processingState="idle",this._markPerformance("initialize_end"),window.logger&&window.logger.info("PPTXProcessor","Processor initialized successfully")}catch(e){throw this.processingState="error",this.lastError=e,this._enhanceError(e,"initialization")}},{context:"initialize"})()}async _ensureInitialized(){if(this.isInitialized||await this.initialize(),!this.processor)throw this._createError("Failed to initialize PPTX processor",{name:"ProcessingError",code:"INITIALIZATION_FAILED",recoverable:!0})}async processFile(e,t={}){let r=this._validateFileInput(e,t);if(!r.valid)throw this._createValidationError("Invalid file input",r.errors);return this.errorBoundary.wrap(async()=>{this._markPerformance("processFile_start"),this.processingState="processing";try{if(await this._ensureInitialized(),this._updateMemoryUsage(),await this._processWithTimeout(()=>this.processor.processFile(e),this.config.timeout),this.presentation=this.processor.presentation,this.processingState="completed",this._markPerformance("processFile_end"),this.config.enableValidation&&this._validateProcessingResult(this.presentation),window.logger){let e=this._getPerformanceTiming("processFile_start","processFile_end");window.logger.info("PPTXProcessor",`File processed successfully in ${e}ms`)}return this.presentation}catch(t){throw this.processingState="error",this.lastError=t,this._enhanceError(t,"file_processing",{arrayBufferSize:e.byteLength})}},{context:"processFile"})()}async loadFromArrayBuffer(e){return this.processFile(e)}async renderSlide(e,t,r={}){let i=this._validateRenderInput(e,t,r);if(!i.valid)throw this._createValidationError("Invalid render input",i.errors);return this.errorBoundary.wrap(async()=>{this._markPerformance("renderSlide_start");try{await this._ensureInitialized();let i=this.getSlidesCount();if(t<0||t>=i)throw this._createError(`Slide index ${t} out of bounds (0-${i-1})`,{name:"ValidationError",code:"INVALID_SLIDE_INDEX"});this._updateMemoryUsage();let a=await this._processWithTimeout(()=>this.processor.renderSlide(e,t),r.timeout||this.config.timeout);if(this.currentSlideIndex=t,this._markPerformance("renderSlide_end"),window.logger){let e=this._getPerformanceTiming("renderSlide_start","renderSlide_end");window.logger.trace("PPTXProcessor",`Slide ${t} rendered in ${e}ms`)}return a}catch(r){throw this._enhanceError(r,"slide_rendering",{slideIndex:t,canvasSize:`${e.width}x${e.height}`})}},{context:"renderSlide"})()}getSlidesCount(){return this.processor&&this.processor.slides?this.processor.slides.length:0}getCurrentSlideIndex(){return void 0!==this.currentSlideIndex?this.currentSlideIndex:0}getCurrentSlide(e=null){if(!this.processor||!this.processor.slides)return null;let t=null!==e?e:this.getCurrentSlideIndex();return this.processor.slides[t]||null}getSlideDimensions(){return this.processor?"function"==typeof this.processor.getSlideDimensions?this.processor.getSlideDimensions():this.processor.presentation&&this.processor.presentation.slideSize?this.processor.presentation.slideSize:{cx:9144e3,cy:6858e3}:{cx:9144e3,cy:6858e3}}clearCaches(){if(this._ensureInitialized(),this.processor){if(this.processor.imageCache){for(let[e,t]of this.processor.imageCache)t.url&&t.url.startsWith("blob:")&&URL.revokeObjectURL(t.url);this.processor.imageCache.clear()}this.processor.imageMap&&this.processor.imageMap.clear(),this.processor.mediaMap&&this.processor.mediaMap.clear(),this.processor.clearCaches&&"function"==typeof this.processor.clearCaches&&this.processor.clearCaches(),this.processor.drawingDocument&&this.processor.drawingDocument.graphics&&this.processor.drawingDocument.graphics.resetState(),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"u">typeof window&&window.DataValidator?window.DataValidator:class{validate(){return{valid:!0,errors:[]}}}}_getErrorBoundary(){return"u">typeof window&&window.ErrorBoundary?window.ErrorBoundary:class{wrap(e){return e}}}_validateConstructorOptions(e){let t=this._getValidator();try{let r=new t({throwOnError:!1}).validate(e,{type:"object",properties:{maxFileSize:{type:"number",minimum:1024,maximum:524288e3},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}}});!r.valid&&window.logger&&window.logger.warn("PPTXProcessor","Invalid constructor options:",r.errors)}catch(e){}return e}_validateEnvironment(){let e=["Logger","PPTXSlideRenderer"].filter(e=>void 0===globalThis[e]);if(e.length>0)throw this._createError(`Missing required dependencies: ${e.join(", ")}`,{name:"ProcessingError",code:"MISSING_DEPENDENCIES",details:{missingDependencies:e}})}async _initializeWithRetry(){let{maxAttempts:e,baseDelay:t}=this.config.retryOptions;return("u">typeof window&&window.ErrorRecovery?window.ErrorRecovery:{retry:async(e,t)=>{let r;for(let i=0;i<t.maxAttempts;i++)try{return await e(i+1)}catch(e){r=e,i<t.maxAttempts-1&&await new Promise(e=>setTimeout(e,t.baseDelay))}throw r}}).retry(async e=>{if(window.logger&&window.logger.trace("PPTXProcessor",`Initialization attempt ${e}`),this.processor=new globalThis.PPTXSlideRenderer,!this.processor||"function"!=typeof this.processor.processFile)throw Error("PPTXSlideRenderer instance is invalid");return this.processor},{maxAttempts:e,baseDelay:t})}_validateFileInput(e,t){let r=[];if(e instanceof ArrayBuffer){0===e.byteLength&&r.push("ArrayBuffer cannot be empty"),e.byteLength>this.config.maxFileSize&&r.push(`File size ${e.byteLength} exceeds maximum ${this.config.maxFileSize}`);let t=new Uint8Array(e,0,Math.min(4,e.byteLength));t.length>=2&&(80!==t[0]||75!==t[1])&&r.push("File does not appear to be a valid ZIP/PPTX file")}else r.push("Input must be an ArrayBuffer");return t&&"object"!=typeof t&&r.push("Options must be an object"),{valid:0===r.length,errors:r}}_validateRenderInput(e,t,r){let i=[];return e?e instanceof HTMLCanvasElement?(e.width<=0||e.height<=0)&&i.push("Canvas must have positive dimensions"):i.push("Canvas must be an HTMLCanvasElement"):i.push("Canvas is required"),"number"==typeof t&&Number.isInteger(t)||i.push("Slide index must be an integer"),r&&"object"!=typeof r&&i.push("Options must be an object"),{valid:0===i.length,errors:i}}_validateProcessingResult(e){if(!e)throw this._createError("Processing completed but no presentation was created",{name:"ProcessingError",code:"NO_PRESENTATION_RESULT"});this.config.strictMode&&(!this.processor.slides||0===this.processor.slides.length)&&window.logger?.warn("PPTXProcessor","No slides found in presentation")}async _processWithTimeout(e,t){return new Promise((r,i)=>{let a=setTimeout(()=>{i(this._createError(`Operation timed out after ${t}ms`,{name:"TimeoutError",code:"OPERATION_TIMEOUT"}))},t);Promise.resolve(e()).then(e=>{clearTimeout(a),r(e)}).catch(e=>{clearTimeout(a),i(e)})})}_initializeMonitoring(){"u">typeof performance&&performance.mark&&(this.performanceEnabled=!0),"u">typeof performance&&performance.memory&&(this.memoryMonitoringEnabled=!0)}_markPerformance(e){if(this.performanceEnabled)try{performance.mark(e),this.performanceMarks.set(e,performance.now())}catch(e){}else this.performanceMarks.set(e,Date.now())}_getPerformanceTiming(e,t){let r=this.performanceMarks.get(e),i=this.performanceMarks.get(t);return r&&i?Math.round(i-r):0}_updateMemoryUsage(){if(this.memoryMonitoringEnabled&&performance.memory)try{let e=performance.memory.usedJSHeapSize;this.memoryUsage.current=e,this.memoryUsage.peak=Math.max(this.memoryUsage.peak,e)}catch(e){}}_createError(e,t={}){"u">typeof window&&window.ErrorHandlerFactory&&window.ErrorHandlerFactory;let r=Error(e);return r.name=t.name||"ProcessingError",r.code=t.code||null,r.context="PPTXProcessor",r.timestamp=new Date().toISOString(),r.recoverable=!1!==t.recoverable,t.details&&(r.details=t.details),r}_createValidationError(e,t){let r=this._createError(e,{name:"ValidationError",code:"INPUT_VALIDATION_FAILED"});return r.validationErrors=t,r}_enhanceError(e,t,r={}){if(e.enhanced)return e;let i=e instanceof Error?e:Error(String(e));return i.operation=t,i.processorContext=r,i.timestamp=new Date().toISOString(),i.memoryUsage={...this.memoryUsage},i.enhanced=!0,i}}(i="u">typeof globalThis?globalThis:"u">typeof window?window:null)&&(i.createPPTXProcessor||(i.createPPTXProcessor=(e={})=>{try{return new q(e)}catch(e){try{(i.logger||window?.logger)?.error?.("PPTXProcessor","Failed to create processor:",e)}catch(e){}throw e}}),i.PPTXProcessor||(i.PPTXProcessor=q));let $="1.1.8";try{void 0!==w&&w.env&&w.env.npm_package_version&&($=w.env.npm_package_version)}catch(e){}let z=(e,t)=>{if(e)return e;if("u">typeof globalThis&&globalThis[t])return globalThis[t];if("u">typeof window&&window[t])return window[t];throw Error(`${t} is required but was not found. Install and import "${"Chart"===t?"chart.js":"jszip"}" in your application.`)},O=z(b.Ay,"Chart"),N=z(x(),"JSZip");if("u">typeof globalThis){if(!globalThis.Logger){class e{log(){}info(){}warn(){}error(){}debug(){}trace(){}logError(){}markTiming(){}measureTiming(){}}globalThis.Logger=e}!globalThis.PPTXSlideRenderer&&"u">typeof window&&window.PPTXSlideRenderer&&(globalThis.PPTXSlideRenderer=window.PPTXSlideRenderer),"u">typeof window&&!window.PPTXSlideRenderer&&globalThis.PPTXSlideRenderer&&(window.PPTXSlideRenderer=globalThis.PPTXSlideRenderer),!globalThis.FontEngine&&"u">typeof window&&window.FontEngine&&(globalThis.FontEngine=window.FontEngine),!globalThis.SimplifiedFontManager&&"u">typeof window&&window.SimplifiedFontManager&&(globalThis.SimplifiedFontManager=window.SimplifiedFontManager),!globalThis.ZLib&&"u">typeof window&&window.ZLib&&(globalThis.ZLib=window.ZLib),!globalThis.OpenXmlPackage&&"u">typeof window&&window.OpenXmlPackage&&(globalThis.OpenXmlPackage=window.OpenXmlPackage),!globalThis.OpenXmlPart&&"u">typeof window&&window.OpenXmlPart&&(globalThis.OpenXmlPart=window.OpenXmlPart),!globalThis.OpenXmlTypes&&"u">typeof window&&window.OpenXmlTypes&&(globalThis.OpenXmlTypes=window.OpenXmlTypes),!globalThis.SVGRenderer&&"u">typeof window&&window.SVGRenderer&&(globalThis.SVGRenderer=window.SVGRenderer),!globalThis.XmlParserContext&&"u">typeof window&&window.XmlParserContext&&(globalThis.XmlParserContext=window.XmlParserContext),!globalThis.StaxParser&&"u">typeof window&&window.StaxParser&&(globalThis.StaxParser=window.StaxParser),!globalThis.CPresentation&&"u">typeof window&&window.CPresentation&&(globalThis.CPresentation=window.CPresentation),!globalThis.CSlide&&"u">typeof window&&window.CSlide&&(globalThis.CSlide=window.CSlide),!globalThis.CSld&&"u">typeof window&&window.CSld&&(globalThis.CSld=window.CSld),!globalThis.CShape&&"u">typeof window&&window.CShape&&(globalThis.CShape=window.CShape),!globalThis.CGroupShape&&"u">typeof window&&window.CGroupShape&&(globalThis.CGroupShape=window.CGroupShape),!globalThis.CSlideMaster&&"u">typeof window&&window.CSlideMaster&&(globalThis.CSlideMaster=window.CSlideMaster),!globalThis.CSlideLayout&&"u">typeof window&&window.CSlideLayout&&(globalThis.CSlideLayout=window.CSlideLayout),!globalThis.CTheme&&"u">typeof window&&window.CTheme&&(globalThis.CTheme=window.CTheme),!globalThis.CTable&&"u">typeof window&&window.CTable&&(globalThis.CTable=window.CTable),globalThis.JSZip||void 0===N||(globalThis.JSZip=N),globalThis.PPTXProcessor||(globalThis.PPTXProcessor=q),globalThis.createPPTXProcessor||(globalThis.createPPTXProcessor=(e={})=>new q(e))}"u">typeof globalThis&&("u">typeof window&&(window.CGraphics=window.CGraphics||globalThis.CGraphics||void 0,window.Chart||void 0===O||(window.Chart=O),window.PPTXSlideRenderer||void 0===globalThis.PPTXSlideRenderer||(window.PPTXSlideRenderer=globalThis.PPTXSlideRenderer),window.PPTXProcessor||void 0===globalThis.PPTXProcessor||(window.PPTXProcessor=globalThis.PPTXProcessor),window.createPPTXProcessor||void 0===globalThis.createPPTXProcessor||(window.createPPTXProcessor=globalThis.createPPTXProcessor)),!globalThis.CGraphics&&"u">typeof window&&window.CGraphics&&(globalThis.CGraphics=window.CGraphics));class G{constructor(e={}){const t=e||{};this.options={canvas:t.canvas??null,debug:t.debug??!1,enableThumbnails:t.enableThumbnails??!0,slideSizeMode:t.slideSizeMode??"fit",backgroundColor:t.backgroundColor??"#ffffff",autoRenderFirstSlide:t.autoRenderFirstSlide??!0,logger:t.logger??("u">typeof window?window.console:console),autoExposeGlobals:t.autoExposeGlobals??!0,autoChartRerenderDelayMs:t.autoChartRerenderDelayMs??200},Object.assign(this.options,t),this.processor=null,this.presentation=null,this.currentSlideIndex=0,this.slideCount=0,this.isLoaded=!1,this.eventListeners={},this._initPromise=null,this._scheduledPostLoadRerender=!1}async _initializeProcessor(){return this._initPromise||(this._initPromise=(async()=>{let e="u">typeof globalThis?globalThis:"u">typeof window?window:null,t=()=>({ctor:e&&e.PPTXProcessor||null,factory:e&&e.createPPTXProcessor||null});try{let e=0,r=t();for(;!r.ctor&&!r.factory&&e<100;)await new Promise(e=>setTimeout(e,20)),e+=1,r=t();if(r.ctor&&"function"==typeof r.ctor?this.processor=new r.ctor:r.factory&&"function"==typeof r.factory?this.processor=r.factory():this.processor=null,!this.processor)throw Error("PPTXProcessor is not available. Ensure processors are loaded.");return"function"==typeof this.processor.initialize&&await this.processor.initialize(),this.emit("processorReady"),this.processor}catch(e){throw this.emit("initError",e),e}})()),this._initPromise}async loadFile(e,t={}){if(this.isLoaded&&this.processor){try{"function"==typeof this.processor.destroy?this.processor.destroy():"function"==typeof this.processor.reset&&this.processor.reset()}catch(e){}this.processor=null,this._initPromise=null}await this._initializeProcessor();try{let r;if(this.emit("loadStart"),"u">typeof File&&e instanceof File)r=await e.arrayBuffer();else if(e instanceof ArrayBuffer)r=e;else if(e instanceof Uint8Array)r=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);else throw Error("Input must be File, ArrayBuffer, or Uint8Array");if(await this.processor.processFile(r,t),this.presentation=this.processor.presentation,this.slideCount=this.processor.getSlidesCount(),this.currentSlideIndex=0,this.isLoaded=!0,this._scheduledPostLoadRerender=!1,this.options.autoExposeGlobals)try{this._exposeGlobalsForCharts()}catch(e){}return this.emit("loadComplete",{slideCount:this.slideCount,presentation:this.presentation}),this}catch(e){throw this.emit("loadError",e),e}}async loadFromUrl(e){this.emit("loadStart");try{let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch PPTX: ${t.status} ${t.statusText}`);let r=await t.arrayBuffer();return this.loadFile(r)}catch(e){throw this.emit("loadError",e),e}}async render(e,t={}){if(!this.isLoaded)throw Error("No PPTX loaded. Call loadFile() first.");let r=e||this.options.canvas;if(!r)throw Error("Canvas element required. Provide canvas parameter or set in constructor.");let i=void 0!==t.slideIndex?t.slideIndex:this.currentSlideIndex;if(i<0||i>=this.slideCount)throw Error(`Invalid slide index: ${i}.`);try{if(this.emit("renderStart",i),await this.processor.renderSlide(r,i,t),this.currentSlideIndex=i,this.emit("renderComplete",i),this.emit("slideChanged",i),this.options.autoChartRerenderDelayMs>0&&!this._scheduledPostLoadRerender){this._scheduledPostLoadRerender=!0;let e=this.options.autoChartRerenderDelayMs;setTimeout(()=>{try{this.render(r,{...t,slideIndex:i})}catch(e){}},e)}return this}catch(e){throw this.emit("renderError",e),e}}async renderSlide(e,t=null,r={}){return this.render(t,{...r,slideIndex:e})}async nextSlide(e=null){return this.currentSlideIndex<this.slideCount-1&&await this.render(e,{slideIndex:this.currentSlideIndex+1}),this}async previousSlide(e=null){return this.currentSlideIndex>0&&await this.render(e,{slideIndex:this.currentSlideIndex-1}),this}async goToSlide(e,t=null){return this.render(t,{slideIndex:e})}getSlideCount(){return this.slideCount}getCurrentSlideIndex(){return this.currentSlideIndex}setCanvas(e){return this.options.canvas=e,this}on(e,t){this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(t)}off(e,t){if(!this.eventListeners[e])return;let r=this.eventListeners[e].indexOf(t);r>-1&&this.eventListeners[e].splice(r,1)}emit(e,...t){this.eventListeners[e]&&this.eventListeners[e].forEach(e=>{try{e(...t)}catch(e){}})}destroy(){this.processor=null,this.eventListeners={},this.isLoaded=!1,this.currentSlideIndex=0,this.slideCount=0}_exposeGlobalsForCharts(){try{let e=this.processor;if(!e)return;let t=e.zip||e.processor?.zip||e.zipProcessor?.zip||null,r=e.package||e.processor?.package||e.zipProcessor?.package||null,i=()=>{let e="function"==typeof this.getCurrentSlideIndex?this.getCurrentSlideIndex():this.currentSlideIndex||0,t=this.options.canvas;t&&this.render(t,{slideIndex:e}).catch(()=>{})},a={processor:e,zip:t,package:r,reRenderShape:i};if("u">typeof window){if(window.currentProcessor=a,t&&(window.currentZipData=t),window.PPTXSlideRenderer&&t)try{window.PPTXSlideRenderer.currentZip=a.zip}catch(e){}try{window.currentProcessor&&window.currentProcessor.processor&&(!window.currentProcessor.processor.zip&&t&&(window.currentProcessor.processor.zip=t),!window.currentProcessor.processor.package&&r&&(window.currentProcessor.processor.package=r),window.currentProcessor.processor.zipProcessor||(window.currentProcessor.processor.zipProcessor={}),t&&!window.currentProcessor.processor.zipProcessor.zip&&(window.currentProcessor.processor.zipProcessor.zip=t),r&&!window.currentProcessor.processor.zipProcessor.package&&(window.currentProcessor.processor.zipProcessor.package=r))}catch(e){}}}catch(e){}}}let W={PPTXViewer:G,version:$,mountSimpleViewer:function({canvas:e,fileInput:t,prevBtn:r,nextBtn:i,statusEl:a,options:o={}}={}){if(!e)throw Error("canvas is required");let l=new G({canvas:e,...o}),s=()=>{try{let e=l.getSlideCount(),t="function"==typeof l.getCurrentSlideIndex?l.getCurrentSlideIndex():0;r&&(r.disabled=!(t>0)),i&&(i.disabled=!(t<e-1)),a&&(a.textContent=e?`Slide ${t+1} / ${e}`:"")}catch(e){}};return l.on("renderComplete",()=>s()),l.on("loadComplete",()=>{try{if(l&&l.processor&&!1!==o.autoExposeGlobals){let t=l.processor,r={processor:t,zip:t.zip,package:t.package,reRenderShape:()=>{let t="function"==typeof l.getCurrentSlideIndex?l.getCurrentSlideIndex():0;l.render(e,{slideIndex:t}).catch(()=>{})}};if("u">typeof window&&(window.currentProcessor=r,t.zip&&(window.currentZipData=t.zip),window.PPTXSlideRenderer&&r.zip))try{window.PPTXSlideRenderer.currentZip=r.zip}catch(e){}}}catch(e){}s()}),t&&t.addEventListener("change",async()=>{let r=t.files&&t.files[0];if(r){a&&(a.textContent="Loading...");try{await l.loadFile(r);try{if(l&&l.processor&&!1!==o.autoExposeGlobals){let t=l.processor,r=t.zip||t.processor?.zip||t.zipProcessor?.zip||null,i=t.package||t.processor?.package||t.zipProcessor?.package||null;if("u">typeof window){window.currentProcessor={processor:t,zip:r,package:i,reRenderShape:()=>{let t="function"==typeof l.getCurrentSlideIndex?l.getCurrentSlideIndex():0;l.render(e,{slideIndex:t}).catch(()=>{})}},r&&(window.currentZipData=r);try{window.currentProcessor&&window.currentProcessor.processor&&(!window.currentProcessor.processor.zip&&r&&(window.currentProcessor.processor.zip=r),!window.currentProcessor.processor.package&&i&&(window.currentProcessor.processor.package=i),window.currentProcessor.processor.zipProcessor||(window.currentProcessor.processor.zipProcessor={}),r&&!window.currentProcessor.processor.zipProcessor.zip&&(window.currentProcessor.processor.zipProcessor.zip=r),i&&!window.currentProcessor.processor.zipProcessor.package&&(window.currentProcessor.processor.zipProcessor.package=i))}catch(e){}}}}catch(e){}await l.render(e,{slideIndex:0});let t="number"==typeof o.autoChartRerenderDelayMs?o.autoChartRerenderDelayMs:200;t>0&&setTimeout(()=>{let t="function"==typeof l.getCurrentSlideIndex?l.getCurrentSlideIndex():0;l.render(e,{slideIndex:t}).catch(()=>{})},t)}catch(e){a&&(a.textContent="Error: "+(e?.message||"Failed to load"))}}}),r&&r.addEventListener("click",async()=>{await l.previousSlide(e)}),i&&i.addEventListener("click",async()=>{await l.nextSlide(e)}),"u">typeof window&&window.addEventListener("chartRenderingComplete",()=>{if(!l.isLoaded)return;let t="function"==typeof l.getCurrentSlideIndex?l.getCurrentSlideIndex():0;l.render(e,{slideIndex:t}).catch(()=>{})}),l}};["CGraphics","FontEngine","SimplifiedFontManager","ZLib","OpenXmlPackage","OpenXmlPart","OpenXmlTypes","SVGRenderer","XmlParserContext","StaxParser","CPresentation","CSlide","CSld","CShape","CGroupShape","CSlideMaster","CSlideLayout","CTheme","CTable","PPTXProcessor","PPTXSlideRenderer","Chart","JSZip"].forEach(e=>{try{"u">typeof globalThis&&globalThis[e]&&!W[e]&&(W[e]=globalThis[e])}catch(e){}}),"u">typeof globalThis&&(globalThis.PptxViewJS=W,globalThis.PPTXProcessor||(globalThis.PPTXProcessor=q),globalThis.createPPTXProcessor||(globalThis.createPPTXProcessor=(e={})=>new q(e))),globalThis.PPTXSlideRenderer||(globalThis.PPTXSlideRenderer=D)}}]);
|