local-operator-ui 0.36.2 → 0.36.3
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/out/main/index.js +6155 -13
- package/out/preload/index.js +7 -0
- package/out/renderer/assets/{_basePickBy-CcO6nPxQ.js → _basePickBy-DVPdsJYh.js} +1 -1
- package/out/renderer/assets/{_baseUniq-BH2uaUcG.js → _baseUniq-DiBAxxuH.js} +1 -1
- package/out/renderer/assets/{agent-details-page-B3JXwv1Q.js → agent-details-page-Bbf-ap4W.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-DKgp42Gz.js → agent-hub-page-CYf0qdg8.js} +1 -1
- package/out/renderer/assets/{agents-page-Bcgw5NaE.js → agents-page-Ddhn0OiX.js} +3 -3
- package/out/renderer/assets/{arc-yBH7h1fW.js → arc-Dw2y_5Ul.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CHBovRWu.js → architectureDiagram-IEHRJDOE-DEF1EAW4.js} +1 -1
- package/out/renderer/assets/{arrow-up-Di0VTM6O.js → arrow-up-D8Tgt51O.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-vW3btTHI.js → blockDiagram-JOT3LUYC-Si8mcap-.js} +1 -1
- package/out/renderer/assets/{book-open-BklxnVnC.js → book-open-DeWHPw1t.js} +1 -1
- package/out/renderer/assets/browser-page-BXSI_6KL.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-BVQVtCyj.js → browser-webauthn-prompt-bdks5x_s.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-B-omeKTH.js → c4Diagram-VJAJSXHY-D1lx9sOj.js} +1 -1
- package/out/renderer/assets/channel-Cq3l3rsO.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-DbogYOtn.js → chunk-4BMEZGHF-B1OoXuiC.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-B99o2tMG.js → chunk-A2AXSNBT-Cr084INE.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-BHrb34eS.js → chunk-AEK57VVT-6BBu10_U.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-COYEuoan.js → chunk-D6G4REZN-DIlAHP8p.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-D3q2lYwW.js → chunk-RZ5BOZE2-Da0rWE9o.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-CvTfujhG.js → chunk-XZIHB7SX-BtHW2mRW.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DoZsDzLJ.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DoZsDzLJ.js +1 -0
- package/out/renderer/assets/clone-aroLRPNj.js +1 -0
- package/out/renderer/assets/{console-mirror-BThuJoo1.js → console-mirror-BnHVC7eO.js} +1 -1
- package/out/renderer/assets/{consoleCapture-B6L7nb-J.js → consoleCapture-BxykZlLx.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-Csq2qdm5.js → conversation-input-sync-neD8lOHF.js} +5 -5
- package/out/renderer/assets/{dagre-OKDRZEBW-CvnmuVIi.js → dagre-OKDRZEBW-QJnzHJrX.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DUkL0seE.js → diagram-SSKATNLV-CblG8bwr.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DYQJ-990.js → diagram-VNBRO52H-D9VlUgES.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CQWWLpWe.js → erDiagram-Q7BY3M3F-CYdAsxl1.js} +1 -1
- package/out/renderer/assets/{error-boundary-D1EdrZoj.js → error-boundary-Tv9TlaZ8.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CHWTC3wr.js → flowDiagram-4HSFHLVR-EKGuFRMH.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CbYaNbcy.js → ganttDiagram-APWFNJXF-yTSMo4Sy.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-Dz5fATwZ.js → gitGraphDiagram-7IBYFJ6S-e48WwwO4.js} +1 -1
- package/out/renderer/assets/{graph-B4lGCZmF.js → graph-BFjFFISR.js} +1 -1
- package/out/renderer/assets/{index-DhrqAKsM.js → index-CY29neUf.js} +1 -1
- package/out/renderer/assets/index-CZI34YVW.js +829 -0
- package/out/renderer/assets/{index-CcD0LA0Q.js → index-Cb5EO4yE.js} +1 -1
- package/out/renderer/assets/index-hX_aZwq0.js +57 -0
- package/out/renderer/assets/index-vPvXCaIy.css +1 -0
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-CosR91M9.js → infoDiagram-PH2N3AL5-BWXZd-TM.js} +1 -1
- package/out/renderer/assets/{installer-JTz2AD89.js → installer-DjflOef5.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-DTj6yC5Y.js → journeyDiagram-U35MCT3I-DKPVvkIm.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-fHLLpfWW.js → kanban-definition-NDS4AKOZ-ChDhsrXv.js} +1 -1
- package/out/renderer/assets/{layout-BUgJgJ17.js → layout-BOqocwgL.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-CSbcJE7R.js → legacy-agents-page-BSdAE-Bg.js} +1 -1
- package/out/renderer/assets/library-page-BHX5kaQb.js +162 -0
- package/out/renderer/assets/{mermaid.core-DXWoCulQ.js → mermaid.core-CWiad1OO.js} +5 -5
- package/out/renderer/assets/{mesh-page-CYwyEdW1.js → mesh-page-BEVPzgDt.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-C_r984Dl.js → mindmap-definition-ALO5MXBD-2i781X8G.js} +1 -1
- package/out/renderer/assets/{mini-B2a0S_aA.js → mini-Bs0TB08-.js} +1 -1
- package/out/renderer/assets/{notebook-pen-BeIeIauS.js → notebook-pen-CcH01r1l.js} +1 -1
- package/out/renderer/assets/{org-access-B4PFRWtx.js → org-access-CJm_anOl.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-OZbS0xfm.js → org-surface-gate-DbysPTcD.js} +1 -1
- package/out/renderer/assets/{page-header-3Jm521kq.js → page-header-ggruiR-O.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-pPG5qJ25.js → pieDiagram-IB7DONF6-B9lioqV6.js} +1 -1
- package/out/renderer/assets/projects-page-ZT73ye5v.js +40 -0
- package/out/renderer/assets/{publication-validation-r9TKDPj_.js → publication-validation-CyRIAFX-.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-LLUiR4wo.js → quadrantDiagram-7GDLP6J5-D2U4lJl9.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-DfSMH1dj.js → radar-MK3ICKWK-CGhy5L8a.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-CEuhoAow.js → radient-auth-buttons-DneyxZkw.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DhHfvb40.js → requirementDiagram-KVF5MWMF-Cmc8UYRV.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DURUf6SV.js → sankeyDiagram-QLVOVGJD-B_CbdQsw.js} +1 -1
- package/out/renderer/assets/{schedules-page-DiiamPZ_.js → schedules-page-B4YBOXYX.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DTfgNRPc.js → sequenceDiagram-X6HHIX6F-Bafdaefv.js} +1 -1
- package/out/renderer/assets/{settings-page-C3aXNJLk.js → settings-page-7C4s3Pn-.js} +1 -1
- package/out/renderer/assets/{smartart-Dx8zw2rK.js → smartart-CrK5frje.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-Cp2owgQE.js → stateDiagram-DGXRK772-y86P6pOD.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CqZEeEIQ.js +1 -0
- package/out/renderer/assets/{tags-input-chips-Dwb2Ojmj.js → tags-input-chips-GdqiLTXD.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-112iCByD.js → timeline-definition-BDJGKUSR-QGAbBb-D.js} +1 -1
- package/out/renderer/assets/ui-preferences-store-C6eXGzFs.js +1 -0
- package/out/renderer/assets/{use-download-agent-mutation-BGMZQ6m9.js → use-download-agent-mutation-DS3LpOcX.js} +1 -1
- package/out/renderer/assets/{use-memberships-query-Bz3KIW6D.js → use-memberships-query-DUb5oPXP.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-C3LrO077.js → use-session-snapshot-C_Px0a_8.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BfqNCG-d.js → xychartDiagram-VJFVF3MP-xB9WOxhm.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +2 -2
- package/out/renderer/assets/browser-page-dbyV2lDa.js +0 -1
- package/out/renderer/assets/channel-DseeJDH6.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-D-Nl2hgf.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-D-Nl2hgf.js +0 -1
- package/out/renderer/assets/clone-DYXRTfEl.js +0 -1
- package/out/renderer/assets/index-BqKNVosC.js +0 -57
- package/out/renderer/assets/index-C6uEPUVY.js +0 -829
- package/out/renderer/assets/index-CU8sWhx0.css +0 -1
- package/out/renderer/assets/library-page-97CGidrj.js +0 -162
- package/out/renderer/assets/projects-page-UaamBIPv.js +0 -40
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DD26TncZ.js +0 -1
- package/out/renderer/assets/ui-preferences-store-CfAtSgON.js +0 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./smartart-CrK5frje.js","./index-hX_aZwq0.js","./index-vPvXCaIy.css","./index-CZI34YVW.js","./conversation-input-sync-neD8lOHF.js","./ui-preferences-store-C6eXGzFs.js","./error-boundary-Tv9TlaZ8.js","./conversation-input-sync-CAX4_ErH.css","./console-mirror-BnHVC7eO.js","./console-mirror-DOrYoP_4.css","./index-DHKnfVbX.css","./page-header-ggruiR-O.js","./tags-input-chips-GdqiLTXD.js","./arrow-up-D8Tgt51O.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as B,j as f,t as j,c as qe}from"./index-hX_aZwq0.js";import{bb as zt,h as _t,bc as In,aK as _n,bd as pt,be as ti,bf as ni,bg as si,bh as ii,bi as ri,aZ as zn,bj as oi,bk as ai,b5 as li,bl as Dt,bm as ci,bn as di,bo as pn}from"./index-CZI34YVW.js";import{bU as ui,bV as Dn,bW as fi,bX as hi,bY as pi,C as Pn,u as lt,aK as Be,bZ as Oe,d as Fe,b_ as hs,D as Yt,aW as gi,b$ as gn,c0 as mi,c1 as bi,aP as rt,aL as mn,a4 as Se,c2 as ps,c3 as At,c4 as yi,c5 as vi,c6 as wi,c7 as Pt,c8 as ki,bN as Ln,aN as Sn,ar as xi,bF as Qt,c9 as gs,bG as Tn,ca as _i,cb as Pi,cc as Si,cd as Ti,ce as ji,bS as Fi,aO as Ci,a as Mi,c as Ni,cf as Ai,bE as $i}from"./conversation-input-sync-neD8lOHF.js";import{P as Ei}from"./page-header-ggruiR-O.js";import{c as ct,r as ms,m as Lt,s as bs,a as Y,t as ys,x as Ce,a5 as Ri,a6 as Ii,a7 as zi,w as Bn,B as st,X as bt,u as jn,T as Di,a8 as Li,z as Bi,y as Oi,S as On,A as un,I as Ui,h as Gi,a9 as Wi,aa as qi}from"./error-boundary-Tv9TlaZ8.js";import"./ui-preferences-store-C6eXGzFs.js";import{T as Ki}from"./tags-input-chips-GdqiLTXD.js";import{A as Xi}from"./arrow-up-D8Tgt51O.js";var Vi=class extends ui{constructor(e,n){super(e,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Dn()})}getOptimisticResult(e){return e.behavior=Dn(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,n){const{state:t}=e,s=super.createResult(e,n),{isFetching:i,isRefetching:r,isError:o,isRefetchError:l}=s,a=t.fetchMeta?.fetchMore?.direction,c=o&&a==="forward",d=i&&a==="forward",h=o&&a==="backward",u=i&&a==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:hi(n,t.data),hasPreviousPage:fi(n,t.data),isFetchNextPageError:c,isFetchingNextPage:d,isFetchPreviousPageError:h,isFetchingPreviousPage:u,isRefetchError:l&&!c&&!h,isRefetching:r&&!d&&!u}}};function Hi(e,n){return pi(e,Vi,n)}/**
|
|
3
|
+
* @license lucide-react v0.507.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const Yi=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],Un=ct("arrow-down-wide-narrow",Yi);/**
|
|
8
|
+
* @license lucide-react v0.507.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const Qi=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],Zi=ct("arrow-up-narrow-wide",Qi);/**
|
|
13
|
+
* @license lucide-react v0.507.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const Ji=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],er=ct("hash",Ji);/**
|
|
18
|
+
* @license lucide-react v0.507.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const tr=[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]],nr=ct("presentation",tr);/**
|
|
23
|
+
* @license lucide-react v0.507.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const sr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]],ir=ct("sheet",sr);/**
|
|
28
|
+
* @license lucide-react v0.507.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const rr=[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]],or=ct("tags",rr),ar=["generated","created","mentioned"],Gn=[{key:"image",labelKey:"ui.library.category.images",iconKind:"image"},{key:"sound",labelKey:"ui.library.category.sounds",iconKind:"audio"},{key:"document",labelKey:"ui.library.category.documents",iconKind:"markdown"},{key:"presentation",labelKey:"ui.library.category.presentations",iconKind:"pptx"},{key:"video",labelKey:"ui.library.category.video",iconKind:"video"},{key:"spreadsheet",labelKey:"ui.library.category.spreadsheets",iconKind:"spreadsheet"},{key:"code",labelKey:"ui.library.category.code",iconKind:"code"},{key:"other",labelKey:"ui.library.category.other",iconKind:"other"}],lr=[{key:"recent",labelKey:"ui.library.sort.recent"},{key:"name",labelKey:"ui.library.sort.name"},{key:"kind",labelKey:"ui.library.sort.kind"},{key:"size",labelKey:"ui.library.sort.size"},{key:"created",labelKey:"ui.library.sort.created"},{key:"modified",labelKey:"ui.library.sort.modified"},{key:"organized",labelKey:"ui.library.sort.organized"}],Bt={q:"",scope:"final",tagMode:"all",highlighted:!1,sort:"recent",order:"desc"};function cr(e){return e==="name"||e==="kind"?"asc":"desc"}function Wn(e,n){return e.status===n}function dr(e){return!!(e.q.trim()||e.category||e.originGroup||e.tag||e.session||e.highlighted||e.status)}function ur(e){if(e==="unorganized")return!1}function St(e){return e.name.trim()||e.derived_name.trim()||e.id}function vs(e){const n=e.derived_name.trim();return n?n===e.name.trim()?e.ref.display_path:n:e.ref.display_path}function fr(e){const n=new Map;for(const i of e){const r=i.category||"custom",o=n.get(r);o?o.push(i):n.set(r,[i])}const t=["topic","project","type","source","custom"],s=i=>{const r=t.indexOf(i);return r===-1?t.length:r};return[...n.entries()].sort(([i],[r])=>s(i)-s(r)).map(([i,r])=>({category:i,tags:r}))}function Fn(e){if(!Number.isFinite(e)||e<=0)return"0 B";const n=["B","KB","MB","GB","TB"],t=Math.min(n.length-1,Math.floor(Math.log(e)/Math.log(1024))),s=e/1024**t;return`${s>=10||t===0?Math.round(s):s.toFixed(1)} ${n[t]}`}function hr(e,n){if(!e)return"";const t=n-e*1e3;if(t<6e4)return"just now";const s=Math.floor(t/6e4);if(s<60)return`${s}m ago`;const i=Math.floor(s/60);if(i<24)return`${i}h ago`;const r=Math.floor(i/24);if(r<30)return`${r}d ago`;const o=Math.floor(r/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}function pr(e){if(!e||e<0)return"";const n=Math.round(e),t=Math.floor(n/60),s=n%60;return`${t}:${String(s).padStart(2,"0")}`}function Cn(e){switch(e){case"generated":return"ui.library.origin.generated";case"created":return"ui.library.origin.created";case"mentioned":return"ui.library.origin.mentioned";default:return"ui.library.origin.other"}}const Ue={all:["desktop","library"],list:e=>["desktop","library","list",e],detail:e=>["desktop","library","detail",e],tags:["desktop","library","tags"],librarian:["desktop","library","librarian"]},gr=60;function mr(e,n){return{op:"library.list",scope:e.scope,...e.q.trim()?{q:e.q.trim()}:{},...e.category?{category:e.category}:{},...e.originGroup?{origin_group:e.originGroup}:{},...e.tag?{tag:e.tag}:{},...e.session?{session_id:e.session}:{},...e.tag?{tag_mode:e.tagMode}:{},...e.highlighted?{highlighted:!0}:{},...e.status==="favorite"?{favorite:!0}:{},...(()=>{const t=ur(e.status);return t!==void 0?{organized:t}:{}})(),sort:e.sort,order:e.order,limit:gr,...n?{cursor:n}:{}}}function br(e,n){return Hi({queryKey:Ue.list(e),enabled:n,initialPageParam:void 0,queryFn:({pageParam:t})=>Fe(mr(e,t)),getNextPageParam:t=>t.next_cursor??void 0,retry:Yt,refetchInterval:t=>t.state.data?.pages.at(-1)?.state==="building"?2e3:!1,staleTime:1e4})}function yr(e,n){return Pn({queryKey:Ue.detail(e??""),enabled:n&&!!e,queryFn:()=>Fe({op:"library.get",id:e}),retry:Yt,staleTime:5e3})}function vr(e){return Pn({queryKey:Ue.tags,enabled:e,queryFn:()=>Fe({op:"library.tags"}),retry:Yt,staleTime:2e4})}function ws(e){return Pn({queryKey:Ue.librarian,enabled:e,queryFn:()=>Fe({op:"library.librarian",action:"status"}).then(n=>"librarian"in n?n.librarian:n),retry:Yt,staleTime:3e4})}function Ke(e){return e.invalidateQueries({queryKey:Ue.all})}function ks(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.update",id:n.id,fields:n.fields}),onSuccess:n=>(e.setQueryData(Ue.detail(n.id),n),Ke(e)),onError:(n,t)=>{e.invalidateQueries({queryKey:Ue.detail(t.id)}),e.invalidateQueries({queryKey:Ue.all})},retry:Oe})}function wr(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.tags.assign",id:n.id,tags:n.tags,...n.primary?{primary:n.primary}:{}}),onSuccess:n=>(e.setQueryData(Ue.detail(n.id),n),Ke(e)),onError:()=>Ke(e),retry:Oe})}function kr(){const e=lt(),n=()=>Ke(e),t=Be({mutationFn:o=>Fe({op:"library.tags.create",name:o.name,...o.category?{category:o.category}:{}}),onSuccess:n,retry:Oe}),s=Be({mutationFn:o=>Fe({op:"library.tags.update",id:o.id,...o.name!==void 0?{name:o.name}:{},...o.category!==void 0?{category:o.category}:{}}),onSuccess:n,retry:Oe}),i=Be({mutationFn:o=>Fe({op:"library.tags.delete",id:o.id}),onSuccess:n,retry:Oe}),r=Be({mutationFn:o=>Fe({op:"library.tags.merge",id:o.id,into:o.into}),onSuccess:n,retry:Oe});return{create:t,update:s,remove:i,merge:r}}function xr(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.chat.link",id:n.id,sessionId:n.sessionId}),onSuccess:()=>Ke(e),onError:()=>Ke(e),retry:Oe})}function _r(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.chat.clear",id:n.id}),onSuccess:()=>Ke(e),retry:Oe})}function Pr(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.librarian",action:n}).then(t=>"librarian"in t?t.librarian:t),onSuccess:()=>Ke(e),retry:Oe})}function et(e,n,t,s=!1){const[i,r]=B.useState({bytes:null,mimeType:"",error:null,loading:!1});return B.useEffect(()=>{if(!t||!e){r({bytes:null,mimeType:"",error:null,loading:!1});return}let o=!1;return r({bytes:null,mimeType:"",error:null,loading:!0}),hs(n==="thumbnail"?{op:"library.thumbnail",assetId:e,width:480}:{op:"library.content",assetId:e,download:s},null).then(a=>{if(!o){if(a.kind==="bytes"){r({bytes:a.data,mimeType:a.mimeType,error:null,loading:!1});return}r({bytes:null,mimeType:"",error:a.kind==="error"?a.detail:"This preview could not be loaded.",loading:!1})}}),()=>{o=!0}},[e,n,t,s]),i}function Mn(e,n){const[t,s]=B.useState(null);return B.useEffect(()=>{if(!e){s(null);return}const i=new Blob([e],{type:n||"application/octet-stream"}),r=URL.createObjectURL(i);return s(r),()=>URL.revokeObjectURL(r)},[e,n]),t}const Sr=/[\\/]/;function Tr(e){const t=St(e).split(Sr).pop()||e.id;if(t.includes("."))return t;const s=e.ref.display_path||e.ref.path||"",i=s.includes(".")?s.slice(s.lastIndexOf(".")):"";return`${t}${i}`}async function ot(e){const n=await hs({op:"library.content",assetId:e.id,download:!0},null);if(n.kind!=="bytes")throw new Error(n.kind==="error"?n.detail:"The asset content could not be read.");const t=new Blob([n.data],{type:e.ref.content_type||n.mimeType||"application/octet-stream"}),s=URL.createObjectURL(t),i=document.createElement("a");i.href=s,i.download=Tr(e),i.rel="noopener",document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(s),3e4)}const Nn=({asset:e,onAsk:n,onEditMetadata:t,onEditTags:s,onToggleFavorite:i,onOpenConversation:r,onFilterSession:o,triggerClassName:l})=>{const a=async(u,p)=>{try{await navigator.clipboard.writeText(u),mn(p)}catch{Se(j("ui.library.menu.copy_failed"))}},c=async()=>{try{await ot(e),mn(j("ui.library.menu.saved_a_copy"))}catch{Se(j("ui.library.menu.save_failed"))}},d=!!(e.ref.type==="path"&&e.ref.path),h=e.occurrences;return f.jsxs(ms,{children:[f.jsx(Lt,{content:j("ui.library.menu.asset_actions"),children:f.jsx(bs,{asChild:!0,children:f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.menu.asset_actions_label",{name:e.name||e.derived_name}),className:l,onClick:u=>u.stopPropagation(),"data-library-asset-menu":"",children:f.jsx(gi,{"aria-hidden":"true"})})})}),f.jsxs(ys,{align:"end",className:"min-w-52",onClick:u=>u.stopPropagation(),children:[h.length===1?f.jsxs(Ce,{onSelect:()=>r(h[0].session_id),children:[f.jsx(zt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.open_source_conversation")})]}):h.length>1?f.jsxs(Ri,{children:[f.jsxs(Ii,{children:[f.jsx(zt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.open_source_conversation")})]}),f.jsx(zi,{className:"min-w-60",children:h.map(u=>f.jsx(Ce,{onSelect:()=>r(u.session_id),children:f.jsx("span",{className:"truncate",children:u.session_title||u.session_id})},`${u.session_id}:${u.first_seq}`))})]}):null,f.jsxs(Ce,{onSelect:n,children:[f.jsx(zt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.ask_about_asset")})]}),h.length>0&&f.jsxs(Ce,{onSelect:()=>o(h[0].session_id),children:[f.jsx(gn,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.show_from_conversation")})]}),f.jsx(Bn,{}),f.jsxs(Ce,{onSelect:i,children:[f.jsx(_t,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0}),f.jsx("span",{children:e.favorite?j("ui.library.menu.unfavorite"):j("ui.library.menu.favorite")})]}),f.jsxs(Ce,{onSelect:t,children:[f.jsx(mi,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.edit_metadata")})]}),f.jsxs(Ce,{onSelect:s,children:[f.jsx(or,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.edit_tags")})]}),f.jsx(Bn,{}),e.ref.path?f.jsxs(Ce,{onSelect:()=>void a(e.ref.path,j("ui.library.menu.path_copied")),children:[f.jsx(bi,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.copy_path")})]}):null,f.jsxs(Ce,{onSelect:()=>void a(e.id,j("ui.library.menu.asset_id_copied")),children:[f.jsx(er,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.copy_asset_id")})]}),d?f.jsxs(Ce,{onSelect:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(gn,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.reveal_in_finder")})]}):f.jsxs(Ce,{onSelect:()=>void c(),children:[f.jsx(rt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.download")})]}),e.ref.type==="artifact"&&f.jsxs(Ce,{onSelect:()=>void c(),children:[f.jsx(rt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.save_a_copy")})]})]})]})},jr={image:wi,audio:vi,video:yi,pdf:At,pptx:nr,docx:At,markdown:At,html:In,spreadsheet:ir,text:At,code:In,other:ps};function Fr(e){return jr[e]??ps}function dt({kind:e,size:n=20,className:t}){const s=Fr(e);return f.jsx(s,{size:n,"aria-hidden":"true",className:t})}const xs=({group:e})=>f.jsx(st,{variant:e==="generated"?"accent":"neutral",children:j(Cn(e))}),_s=({asset:e,large:n=!1})=>{const[t,s]=ki("300px"),i=e.kind==="image"&&e.exists&&s,r=et(e.id,"thumbnail",i),o=Mn(r.bytes,r.mimeType);return f.jsx("div",{ref:t,className:qe("relative flex shrink-0 items-center justify-center overflow-hidden bg-canvas",n?"aspect-[16/10] w-full":"h-24 w-32"),children:o?f.jsx("img",{src:o,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover"}):f.jsx(dt,{kind:e.kind,size:n?28:22,className:"text-ink-dim"})})},Cr=()=>f.jsx("span",{className:"absolute top-1.5 left-1.5 flex size-5 items-center justify-center rounded-full bg-elevated",title:j("ui.library.card.highlighted"),children:f.jsx(_t,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),Ps=({asset:e})=>{if(e.tags.length===0)return null;const n=e.tags.slice(0,2);return f.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[n.map(t=>f.jsx(st,{variant:"outline",children:t.name},t.id)),e.tags.length>n.length&&f.jsxs("span",{className:"text-meta text-ink-dim",children:["+",e.tags.length-n.length]})]})},Mr=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:qe("group relative flex flex-col overflow-hidden rounded-lg border border-hairline bg-surface",n&&_n),children:[f.jsxs("button",{type:"button",onClick:()=>t.onSelect(e.id),"aria-pressed":n,className:"flex w-full flex-col text-left focus-visible:outline-offset-2",children:[f.jsxs("div",{className:"relative",children:[f.jsx(_s,{asset:e,large:!0}),e.highlighted&&f.jsx(Cr,{}),f.jsx("div",{className:"absolute top-1.5 right-1.5"})]}),f.jsxs("div",{className:"flex w-full flex-col gap-1 p-3",children:[f.jsx("span",{className:"line-clamp-1 text-body-sm font-medium text-ink",children:St(e)}),f.jsx("span",{className:"line-clamp-1 text-meta text-ink-dim",children:vs(e)}),f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx("span",{className:"truncate",children:e.kind}),f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:Fn(e.size_bytes)}),e.duration_s?f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:pr(e.duration_s)})]}):null]}),f.jsx(Ps,{asset:e}),e.occurrences[0]?.session_title&&f.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-meta text-ink-dim",children:[f.jsx(zt,{size:12,"aria-hidden":"true"}),f.jsx("span",{className:"truncate",children:e.occurrences[0].session_title})]}),f.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[f.jsx(xs,{group:e.origin_group}),e.session_count>1&&f.jsx("span",{className:"text-meta text-ink-dim",children:j("ui.library.card.conversations",{count:e.session_count})})]})]})]}),f.jsx("div",{className:"invisible absolute top-1.5 right-1.5 group-focus-within:visible group-hover:visible [@media(pointer:coarse)]:visible",children:f.jsx(Nn,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession,triggerClassName:"bg-elevated"})})]}),Nr=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:qe("group relative flex items-center gap-3 rounded-md border border-hairline bg-surface px-3 py-2",n&&_n),children:[f.jsxs("button",{type:"button",onClick:()=>t.onSelect(e.id),"aria-pressed":n,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[f.jsx(_s,{asset:e}),f.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[f.jsxs("span",{className:"flex items-center gap-1.5 truncate text-body-sm font-medium text-ink",children:[e.highlighted&&f.jsx(_t,{size:12,"aria-hidden":"true",className:"shrink-0 fill-current text-accent"}),St(e)]}),f.jsx("span",{className:"truncate text-meta text-ink-dim",children:vs(e)})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-meta text-ink-muted",children:[f.jsx(Ps,{asset:e}),f.jsx("span",{children:e.kind}),f.jsx("span",{children:Fn(e.size_bytes)}),f.jsx(xs,{group:e.origin_group})]})]}),f.jsx(Nn,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession})]}),Ar=({assets:e,selectedId:n,view:t,hasMore:s,loadingMore:i,onLoadMore:r,...o})=>{const l=B.useRef(null);return B.useEffect(()=>{const a=l.current;if(!a||!s)return;const c=new IntersectionObserver(d=>{d.some(h=>h.isIntersecting)&&r()},{rootMargin:"600px 0px"});return c.observe(a),()=>c.disconnect()},[s,r,e.length]),f.jsxs("div",{className:"flex flex-col gap-4",children:[t==="grid"?f.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(208px,1fr))] gap-4",children:e.map(a=>f.jsx(Mr,{asset:a,selected:a.id===n,...o},a.id))}):f.jsx("div",{className:"flex flex-col gap-1.5",children:e.map(a=>f.jsx(Nr,{asset:a,selected:a.id===n,...o},a.id))}),f.jsxs("div",{ref:l,className:"flex justify-center py-6",children:[i&&f.jsxs("span",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[f.jsx(Pt,{size:14,"aria-hidden":"true",className:"motion-safe:animate-spin"}),j("ui.library.grid.loading_more")]}),!i&&s&&f.jsx(Y,{variant:"ghost",size:"sm",onClick:r,children:j("ui.library.grid.load_more")})]})]})},$r=({view:e})=>e==="list"?f.jsx("div",{className:"flex flex-col gap-1.5","aria-hidden":"true","data-library-skeleton":"",children:Array.from({length:8},(n,t)=>f.jsxs("div",{className:"flex h-28 items-center gap-3 rounded-md border border-hairline bg-surface px-3",children:[f.jsx("div",{className:"h-24 w-32 rounded-sm bg-sunken"}),f.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[f.jsx("div",{className:"h-3 w-1/3 rounded-xs bg-sunken"}),f.jsx("div",{className:"h-3 w-1/2 rounded-xs bg-sunken"})]})]},t))}):f.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(208px,1fr))] gap-4","aria-hidden":"true","data-library-skeleton":"",children:Array.from({length:12},(n,t)=>f.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-hairline bg-surface",children:[f.jsx("div",{className:"aspect-[16/10] bg-sunken"}),f.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[f.jsx("div",{className:"h-3 w-2/3 rounded-xs bg-sunken"}),f.jsx("div",{className:"h-3 w-1/2 rounded-xs bg-sunken"}),f.jsx("div",{className:"h-3 w-1/3 rounded-xs bg-sunken"})]})]},t))}),Er=[{key:"highlighted",labelKey:"ui.library.status.highlighted"},{key:"unorganized",labelKey:"ui.library.status.unorganized"},{key:"favorite",labelKey:"ui.library.status.favorites"}],Ge=({label:e,count:n,active:t,onPress:s,icon:i,indent:r=!1})=>f.jsxs("button",{type:"button",onClick:s,"aria-pressed":t,className:qe("flex h-7 w-full items-center gap-2 rounded-md px-2 text-left text-body-sm",r&&"pl-6",t?_n:"text-ink-muted hover:bg-row-hover hover:text-ink"),children:[i,f.jsx("span",{className:"min-w-0 flex-1 truncate",children:e}),n!==void 0&&f.jsx("span",{className:"text-meta tabular-nums text-ink-dim",children:n})]}),ht=({label:e,children:n})=>f.jsxs("section",{className:"flex flex-col gap-1",children:[f.jsx("h3",{className:"px-2 text-meta font-medium tracking-wide text-ink-dim",children:e}),f.jsx("div",{className:"flex flex-col gap-0.5",children:n})]}),Rr=({filters:e,onChange:n,counts:t,tags:s,total:i,scopeTotal:r})=>{const o=fr(s),l=t?.category??{},a=d=>n({...e,...d}),c=!!(e.category||e.originGroup||e.status||e.tag||e.session||e.highlighted);return f.jsxs("div",{className:"flex h-full flex-col gap-5 overflow-y-auto px-2 py-4","data-library-filter-rail":"",children:[c&&f.jsxs(Y,{variant:"ghost",size:"sm",className:"justify-start",onClick:()=>n({...e,category:void 0,originGroup:void 0,status:void 0,tag:void 0,session:void 0,highlighted:!1}),children:[f.jsx(bt,{"aria-hidden":"true"}),j("ui.library.filter.clear_filters")]}),e.session&&f.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-sunken px-2 py-1.5 text-meta text-ink-muted",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate",children:j("ui.library.filter.one_conversation")}),f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.filter.clear_conversation"),onClick:()=>a({session:void 0}),children:f.jsx(bt,{"aria-hidden":"true"})})]}),f.jsxs(ht,{label:j("ui.library.filter.scope"),children:[f.jsx(Ge,{label:j("ui.library.filter.scope_final"),active:e.scope==="final",onPress:()=>a({scope:"final"})}),f.jsx(Ge,{label:j("ui.library.filter.scope_all"),count:r??void 0,active:e.scope==="all",onPress:()=>a({scope:"all"})})]}),f.jsxs(ht,{label:j("ui.library.filter.categories"),children:[f.jsx(Ge,{label:j("ui.library.category.all"),count:i,active:!e.category,onPress:()=>a({category:void 0})}),Gn.map(d=>f.jsx(Ge,{label:j(d.labelKey),count:l[d.key]??0,active:e.category===d.key,onPress:()=>a({category:e.category===d.key?void 0:d.key}),icon:f.jsx(dt,{kind:d.iconKind,size:14,className:"text-ink-dim"})},d.key)),Object.keys(l).filter(d=>!Gn.some(h=>h.key===d)).sort().map(d=>f.jsx(Ge,{label:d,count:l[d],active:e.category===d,onPress:()=>a({category:e.category===d?void 0:d}),icon:f.jsx(Ln,{size:14,"aria-hidden":"true"})},d))]}),f.jsx(ht,{label:j("ui.library.filter.status"),children:Er.map(d=>f.jsx(Ge,{label:j(d.labelKey),active:Wn(e,d.key),onPress:()=>a({status:Wn(e,d.key)?void 0:d.key}),icon:d.key==="favorite"||d.key==="highlighted"?f.jsx(_t,{size:14,"aria-hidden":"true"}):void 0},d.key))}),f.jsx(ht,{label:j("ui.library.filter.source"),children:ar.filter(d=>e.originGroup===d||e.scope==="all"||(t?.origin_group?.[d]??0)>0).map(d=>f.jsx(Ge,{label:j(Cn(d)),count:t?.origin_group?.[d]??0,active:e.originGroup===d,onPress:()=>a({originGroup:e.originGroup===d?void 0:d})},d))}),o.length>0&&f.jsx(ht,{label:j("ui.library.filter.tags"),children:o.map(d=>f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"px-2 pt-1 text-meta text-ink-dim",children:d.category}),d.tags.map(h=>f.jsx(Ge,{label:h.name,count:h.count??0,active:e.tag===h.id,onPress:()=>a({tag:e.tag===h.id?void 0:h.id}),icon:f.jsx(Ln,{size:13,"aria-hidden":"true"}),indent:!0},h.id))]},d.category))}),e.tag&&f.jsx(st,{variant:"neutral",children:j("ui.library.filter.tag_mode",{mode:e.tagMode.toUpperCase()})})]})},Ir=new Set(["image/png","image/jpeg","image/gif","image/webp"]),zr=1e6;function Dr(e){let n="";for(let s=0;s<e.length;s+=32768)n+=String.fromCharCode(...e.subarray(s,Math.min(s+32768,e.length)));return btoa(n)}function Lr(e){const n=e.ref.display_path||e.ref.path||(e.ref.digest?`attachment digest ${e.ref.digest}`:e.id);return`${St(e)} (${n})`}const Br=({asset:e,focusSignal:n,compact:t=!1})=>{jn();const s=Sn(),i=B.useRef(null),r=()=>{const k=i.current;k&&(k.style.height="24px",k.style.height=`${Math.min(72,Math.max(24,k.scrollHeight))}px`)},[o,l]=B.useState(""),[a,c]=B.useState(!1),[d,h]=B.useState({}),[u,p]=B.useState(null),g=d[e.id]??null,b=u===e.id,_=xr(),y=_r(),w=et(e.id,"content",e.kind==="image");B.useEffect(()=>{l("")},[e.id]),B.useEffect(()=>{n!==0&&i.current?.focus()},[n]);const x=async()=>{const k=o.trim();if(!(!k||a)){c(!0);try{const T=xi.getState();let N=e.chat?.session_id??g??null;if(!N&&(N=await T.createSession(T.cwd||"~"),!N))throw new Error(T.error??j("ui.library.composer.could_not_start"));const M={op:"sessions.message",sessionId:N,requestId:crypto.randomUUID(),text:`${k}
|
|
33
|
+
|
|
34
|
+
${Lr(e)}`},F=e.ref.content_type||w.mimeType;if(e.kind==="image"&&w.bytes&&Ir.has(F)){const S=Dr(w.bytes);S.length<=zr&&(M.images=[{data_b64:S,mime_type:F}])}if(await Fe(M),l(""),!e.chat&&!g)try{await _.mutateAsync({id:e.id,sessionId:N})}catch(S){h($=>({...$,[e.id]:N})),p(e.id),Se(S instanceof Error&&S.message?j("ui.library.composer.link_failed",{message:S.message}):j("ui.library.composer.link_failed_short"));return}if(g)try{await _.mutateAsync({id:e.id,sessionId:N}),h(S=>{const $={...S};return delete $[e.id],$}),p(null)}catch{p(e.id),Se(j("ui.library.composer.link_failed_short"));return}await pt(s,N)}catch(T){Se(T instanceof Error&&T.message?T.message:j("ui.library.composer.not_sent"))}finally{c(!1)}}},P=e.chat,v=async()=>{const k=g??e.chat?.session_id;if(k)try{await _.mutateAsync({id:e.id,sessionId:k}),h(T=>{const N={...T};return delete N[e.id],N}),p(null)}catch{Se(j("ui.library.composer.link_failed_short"))}};return f.jsxs("div",{className:qe("mx-auto flex w-[min(calc(100%-24px),720px)] flex-col justify-end gap-2 pb-4",t?"h-38":"h-44"),"data-library-composer":"",children:[b&&g&&f.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md bg-sunken px-2 py-1 text-meta text-ink","data-library-link-failed":"",children:[f.jsx("span",{className:"min-w-0 flex-1",children:j("ui.library.composer.message_sent_link_failed")}),f.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>void v(),children:j("ui.library.composer.retry_link")}),f.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>void pt(s,g),children:j("ui.library.composer.open_chat")})]}),P&&f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx(ti,{size:13,"aria-hidden":"true"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:j("ui.library.composer.chat_about",{title:P.title||P.session_id})}),f.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>void pt(s,P.session_id),children:j("ui.library.composer.open_chat")}),f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.composer.unlink"),onClick:()=>y.mutate({id:e.id}),children:f.jsx(bt,{"aria-hidden":"true"})})]}),f.jsxs("div",{"data-glass-region":"composer",className:qe("flex items-end gap-2 rounded-lg bg-elevated p-2","focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-accent"),children:[f.jsx(Di,{ref:i,rows:1,value:o,onChange:k=>{l(k.target.value),r()},onKeyDown:k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),x())},placeholder:P?j("ui.library.composer.continue_placeholder"):j("ui.library.composer.ask_placeholder"),"aria-label":j("ui.library.composer.label"),className:"h-6 min-h-6 max-h-18 resize-none overflow-y-auto border-0 bg-transparent px-0 py-0 text-body leading-6 shadow-none focus-visible:outline-none"}),f.jsx(Y,{variant:"primary",size:"icon-sm",disabled:!o.trim()||a,"aria-label":j("ui.library.composer.send"),onClick:()=>void x(),children:a?f.jsx(Pt,{"aria-hidden":"true",className:"motion-safe:animate-spin"}):f.jsx(Xi,{"aria-hidden":"true"})})]})]})};function Or(e,n,t){return{id:`library:${e.id}`,title:e.name.trim()||e.derived_name||e.ref.path||e.id,path:e.ref.path??"",content:n,type:"markdown",readMtimeMs:t??void 0,sizeBytes:e.size_bytes,availability:"present"}}async function Ss(e){const n=e instanceof Uint8Array?e:new Uint8Array(e),t=new DataView(n.buffer,n.byteOffset,n.byteLength),s=101010256,i=101075792,r=117853008;let o=-1;const l=Math.max(0,n.length-65557);for(let g=n.length-22;g>=l;g--)if(t.getUint32(g,!0)===s){o=g;break}if(o===-1)throw new Error("Not a valid ZIP file: EOCD not found");let a,c;const d=o-20;if(d>=0&&t.getUint32(d,!0)===r){const g=Number(t.getBigUint64(d+8,!0));if(t.getUint32(g,!0)!==i)throw new Error("Invalid ZIP64 end record");a=Number(t.getBigUint64(g+48,!0)),c=Number(t.getBigUint64(g+32,!0))}else a=t.getUint32(o+16,!0),c=t.getUint16(o+8,!0);if(a+4>n.length)throw new Error("ZIP central directory offset is outside the file");const h=33639248,u={};let p=a;for(let g=0;g<c&&!(p+46>n.length||t.getUint32(p,!0)!==h);g++){const b=t.getUint16(p+10,!0);let _=t.getUint32(p+20,!0),y=t.getUint32(p+24,!0);const w=t.getUint16(p+28,!0),x=t.getUint16(p+30,!0),P=t.getUint16(p+32,!0);let v=t.getUint32(p+42,!0);const k=Gr(n,p+46,w);if(_===4294967295||y===4294967295||v===4294967295){const S=p+46+w,$=S+x;let R=S;for(;R+4<=$;){const W=t.getUint16(R,!0),Q=t.getUint16(R+2,!0);if(W===1){let D=R+4;y===4294967295&&D+8<=$&&(y=Number(t.getBigUint64(D,!0)),D+=8),_===4294967295&&D+8<=$&&(_=Number(t.getBigUint64(D,!0)),D+=8),v===4294967295&&D+8<=$&&(v=Number(t.getBigUint64(D,!0)));break}R+=4+Q}}if(p+=46+w+x+P,k.endsWith("/")||b!==0&&b!==8||v+30>n.length)continue;const T=t.getUint16(v+26,!0),N=t.getUint16(v+28,!0),M=v+30+T+N;if(M+_>n.length)continue;const F=n.subarray(M,M+_);try{u[k]=b===0?F.slice():await Ur(F)}catch(S){console.warn(`[zip.js] Failed to decompress "${k}":`,S.message)}}return u}async function Ur(e){const n=new DecompressionStream("deflate-raw"),t=n.writable.getWriter(),s=n.readable.getReader();t.write(e),t.close();const i=[];let r=0;for(;;){const{value:a,done:c}=await s.read();if(c)break;i.push(a),r+=a.length}const o=new Uint8Array(r);let l=0;for(const a of i)o.set(a,l),l+=a.length;return o}function Gr(e,n,t){return new TextDecoder().decode(e.subarray(n,n+t))}function xe(e){return new DOMParser().parseFromString(e,"application/xml")}function ue(e,n){if(!e)return[];const t=[],s=e.getElementsByTagName("*");for(let i=0;i<s.length;i++)s[i].localName===n&&t.push(s[i]);return t}function m(e,n){return ue(e,n)[0]??null}function O(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function C(e,n,t=0){const s=O(e,n);return s!==null?parseInt(s,10):t}function Ie(e,n,t){return Math.max(n,Math.min(t,e))}const yt=12700,Wr=Object.freeze(Object.defineProperty({__proto__:null,EMU_PER_PT:yt,attr:O,attrInt:C,clamp:Ie,g1:m,gtn:ue,parseXml:xe},Symbol.toStringTag,{value:"Module"}));function qr(e){if(!e)return{colors:{},majorFont:"Calibri Light",minorFont:"Calibri"};const n=m(e,"clrScheme"),t={};if(n){const o=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];for(const l of o){const a=m(n,l);if(!a)continue;const c=m(a,"srgbClr"),d=m(a,"sysClr");c?t[l]=c.getAttribute("val")||"":d&&(t[l]=d.getAttribute("lastClr")||"")}}const s=m(e,"fontScheme");let i="Calibri Light",r="Calibri";if(s){const o=m(s,"majorFont"),l=m(s,"minorFont");if(o){const a=m(o,"latin");a&&(i=a.getAttribute("typeface")||i)}if(l){const a=m(l,"latin");a&&(r=a.getAttribute("typeface")||r)}}return{colors:t,majorFont:i,minorFont:r}}function Kr(e){if(!e)return{};const n=m(e,"clrMap");if(!n)return{};const t={},s=["bg1","tx1","bg2","tx2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];for(const i of s){const r=n.getAttribute(i);r&&(t[i]=r)}return t}function Xr(e,n){const t={...e.colors};for(const[s,i]of Object.entries(n))t[i]!==void 0&&(t[s]=t[i]);return t}const it={calibri:{google:"Carlito",weights:[400,700],generic:"sans-serif"},"calibri light":{google:"Carlito",weights:[300],generic:"sans-serif"},"calibri (body)":{google:"Carlito",weights:[400,700],generic:"sans-serif"},cambria:{google:"Caladea",weights:[400,700],generic:"serif"},"cambria math":{google:"Caladea",weights:[400],generic:"serif"},aptos:{google:"Inter",weights:[300,400,600,700],generic:"sans-serif"},"aptos display":{google:"Inter",weights:[700,800],generic:"sans-serif"},"aptos narrow":{google:"Inter",weights:[400,700],generic:"sans-serif"},"aptos serif":{google:"Lora",weights:[400,700],generic:"serif"},"aptos mono":{google:"Roboto Mono",weights:[400,700],generic:"monospace"},arial:{google:null,weights:[],generic:"sans-serif"},"arial black":{google:null,weights:[],generic:"sans-serif"},"times new roman":{google:null,weights:[],generic:"serif"},times:{google:null,weights:[],generic:"serif"},helvetica:{google:null,weights:[],generic:"sans-serif"},verdana:{google:null,weights:[],generic:"sans-serif"},tahoma:{google:null,weights:[],generic:"sans-serif"},"trebuchet ms":{google:null,weights:[],generic:"sans-serif"},georgia:{google:null,weights:[],generic:"serif"},"courier new":{google:null,weights:[],generic:"monospace"},courier:{google:null,weights:[],generic:"monospace"},impact:{google:null,weights:[],generic:"sans-serif"},"comic sans ms":{google:null,weights:[],generic:"cursive"},palatino:{google:null,weights:[],generic:"serif"},"lucida console":{google:null,weights:[],generic:"monospace"},"lucida sans unicode":{google:null,weights:[],generic:"sans-serif"},"arial narrow":{google:"Arimo",weights:[400,700],generic:"sans-serif"},candara:{google:"Nunito",weights:[300,400,700],generic:"sans-serif"},consolas:{google:"Roboto Mono",weights:[400,700],generic:"monospace"},constantia:{google:"Libre Baskerville",weights:[400,700],generic:"serif"},corbel:{google:"Lato",weights:[300,400,700],generic:"sans-serif"},"franklin gothic medium":{google:"Libre Franklin",weights:[500],generic:"sans-serif"},"franklin gothic book":{google:"Libre Franklin",weights:[400],generic:"sans-serif"},"franklin gothic heavy":{google:"Libre Franklin",weights:[800],generic:"sans-serif"},"gill sans mt":{google:"Quattrocento Sans",weights:[400,700],generic:"sans-serif"},"gill sans":{google:"Quattrocento Sans",weights:[400,700],generic:"sans-serif"},"century gothic":{google:"Josefin Sans",weights:[300,400,700],generic:"sans-serif"},"century schoolbook":{google:"EB Garamond",weights:[400,700],generic:"serif"},garamond:{google:"EB Garamond",weights:[400,700],generic:"serif"},"palatino linotype":{google:"EB Garamond",weights:[400,700],generic:"serif"},"book antiqua":{google:"EB Garamond",weights:[400,700],generic:"serif"},rockwell:{google:"Roboto Slab",weights:[400,700],generic:"serif"},"rockwell extra bold":{google:"Roboto Slab",weights:[800],generic:"serif"},"segoe ui":{google:"Inter",weights:[300,400,600,700],generic:"sans-serif"},"segoe ui light":{google:"Inter",weights:[300],generic:"sans-serif"},"segoe ui semibold":{google:"Inter",weights:[600],generic:"sans-serif"},"segoe ui semilight":{google:"Inter",weights:[350],generic:"sans-serif"},"helvetica neue":{google:"Nunito Sans",weights:[300,400,700],generic:"sans-serif"},"myriad pro":{google:"Source Sans 3",weights:[300,400,600,700],generic:"sans-serif"},futura:{google:"Josefin Sans",weights:[300,400,700],generic:"sans-serif"},"tw cen mt":{google:"Pathway Gothic One",weights:[400],generic:"sans-serif"},"bookman old style":{google:"Libre Baskerville",weights:[400,700],generic:"serif"},frutiger:{google:"Raleway",weights:[300,400,700],generic:"sans-serif"},optima:{google:"Questrial",weights:[400],generic:"sans-serif"},univers:{google:"Nunito Sans",weights:[300,400,700],generic:"sans-serif"},"open sans":{google:"Open Sans",weights:[300,400,600,700],generic:"sans-serif"},lato:{google:"Lato",weights:[300,400,700],generic:"sans-serif"},montserrat:{google:"Montserrat",weights:[300,400,600,700],generic:"sans-serif"},raleway:{google:"Raleway",weights:[300,400,700],generic:"sans-serif"},roboto:{google:"Roboto",weights:[300,400,700],generic:"sans-serif"},"roboto mono":{google:"Roboto Mono",weights:[400,700],generic:"monospace"},"roboto slab":{google:"Roboto Slab",weights:[300,400,700],generic:"serif"},oswald:{google:"Oswald",weights:[400,700],generic:"sans-serif"},"playfair display":{google:"Playfair Display",weights:[400,700],generic:"serif"},merriweather:{google:"Merriweather",weights:[300,400,700],generic:"serif"},nunito:{google:"Nunito",weights:[300,400,700],generic:"sans-serif"},"nunito sans":{google:"Nunito Sans",weights:[300,400,700],generic:"sans-serif"},poppins:{google:"Poppins",weights:[300,400,600,700],generic:"sans-serif"},inter:{google:"Inter",weights:[300,400,600,700],generic:"sans-serif"},"work sans":{google:"Work Sans",weights:[300,400,600,700],generic:"sans-serif"},"dm sans":{google:"DM Sans",weights:[300,400,500,700],generic:"sans-serif"},"dm serif display":{google:"DM Serif Display",weights:[400],generic:"serif"},ubuntu:{google:"Ubuntu",weights:[300,400,700],generic:"sans-serif"},"ubuntu mono":{google:"Ubuntu Mono",weights:[400,700],generic:"monospace"},"source sans pro":{google:"Source Sans 3",weights:[300,400,600,700],generic:"sans-serif"},"source serif pro":{google:"Source Serif 4",weights:[300,400,700],generic:"serif"},"source code pro":{google:"Source Code Pro",weights:[400,700],generic:"monospace"},"exo 2":{google:"Exo 2",weights:[300,400,700],generic:"sans-serif"},"titillium web":{google:"Titillium Web",weights:[300,400,600,700],generic:"sans-serif"},"fira sans":{google:"Fira Sans",weights:[300,400,600,700],generic:"sans-serif"},"fira mono":{google:"Fira Mono",weights:[400,700],generic:"monospace"},"josefin sans":{google:"Josefin Sans",weights:[300,400,700],generic:"sans-serif"},"josefin slab":{google:"Josefin Slab",weights:[300,400,700],generic:"serif"},barlow:{google:"Barlow",weights:[300,400,600,700],generic:"sans-serif"},"barlow condensed":{google:"Barlow Condensed",weights:[300,400,600,700],generic:"sans-serif"},cabin:{google:"Cabin",weights:[400,700],generic:"sans-serif"},"crimson text":{google:"Crimson Text",weights:[400,700],generic:"serif"},"libre baskerville":{google:"Libre Baskerville",weights:[400,700],generic:"serif"},"libre franklin":{google:"Libre Franklin",weights:[400,700],generic:"sans-serif"},"eb garamond":{google:"EB Garamond",weights:[400,700],generic:"serif"},spectral:{google:"Spectral",weights:[300,400,700],generic:"serif"},arvo:{google:"Arvo",weights:[400,700],generic:"serif"},"pt sans":{google:"PT Sans",weights:[400,700],generic:"sans-serif"},"pt serif":{google:"PT Serif",weights:[400,700],generic:"serif"},"pt mono":{google:"PT Mono",weights:[400],generic:"monospace"},karla:{google:"Karla",weights:[300,400,700],generic:"sans-serif"},mukta:{google:"Mukta",weights:[300,400,700],generic:"sans-serif"},hind:{google:"Hind",weights:[300,400,700],generic:"sans-serif"},"noto sans":{google:"Noto Sans",weights:[300,400,700],generic:"sans-serif"},"noto serif":{google:"Noto Serif",weights:[300,400,700],generic:"serif"}},Ot=new Set,vt=new Map,Ut=new Set;let qn=null,fn=null;function Vr(){return fn||(qn=typeof OffscreenCanvas<"u"?new OffscreenCanvas(300,10):Object.assign(document.createElement("canvas"),{width:300,height:10}),fn=qn.getContext("2d")),fn}const Kn="mmmmmmmmmmlllllllllliiiiiiiiiixxxxxxxxxx",Hr=[20,40];function Ts(e){if(Ut.has(e))return!0;if(typeof document<"u"&&document.fonts&&document.fonts.check(`16px "${e}"`))return Ut.add(e),!0;try{const n=Vr(),t=["monospace","serif"];for(const s of Hr)for(const i of t){n.font=`${s}px ${i}`;const r=n.measureText(Kn).width;n.font=`${s}px "${e}", ${i}`;const o=n.measureText(Kn).width;if(Math.abs(o-r)>.5)return Ut.add(e),!0}}catch{}return!1}async function bn(e,n,t={}){let s;if(typeof n=="string"||n instanceof URL)s=n.toString();else if(n instanceof File||n instanceof Blob)s=await n.arrayBuffer();else if(n instanceof Uint8Array)s=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);else if(n instanceof ArrayBuffer)s=n;else throw new TypeError("registerFont: unsupported source type. Expected string, URL, File, Blob, ArrayBuffer, or Uint8Array.");const i={weight:"normal",style:"normal",...t},r=new FontFace(e,typeof s=="string"?`url(${s})`:s,i);await r.load(),document.fonts.add(r);const o=vt.get(e)??[];o.push(r),vt.set(e,o),Ot.add(e),Ut.add(e);const l=e.toLowerCase().trim();return it[l]?it[l]._custom=!0:it[l]={google:null,weights:[],generic:"sans-serif",_custom:!0},console.log(`[pptx-canvas-renderer] Custom font registered: "${e}" (${i.weight} ${i.style})`),r}async function Yr(e){const n=[];for(const[t,s]of Object.entries(e))if(typeof s=="string")n.push(bn(t,s));else if(Array.isArray(s))for(const i of s){const{url:r,...o}=i;n.push(bn(t,r,o))}await Promise.all(n)}function Qr(e,n){if(!e)return[];const t=m(e,"embeddedFontLst");if(!t)return[];const s=[];for(const i of t.children){if(i.localName!=="embeddedFont")continue;const r=m(i,"font"),o=r?r.getAttribute("typeface"):null;if(!o)continue;const l={regular:!1,bold:!1,italic:!1,boldItalic:!1},a=[];for(const c of["regular","bold","italic","boldItalic"]){const d=m(i,c);if(!d)continue;const h=d.getAttribute("r:id")||d.getAttribute("id"),u=n?.[h];u&&(a.push(u.fullPath),l[c]=!0)}s.push({family:o,hasRegular:l.regular,hasBold:l.bold,hasItalic:l.italic,hasBoldItalic:l.boldItalic,paths:a,note:".fntdata files are a proprietary Microsoft format and cannot be used as web fonts directly. Use registerFont() with a compatible woff2/ttf version instead."})}return s}function Zr(e){if(!e)return"sans-serif";if(e==="+mj-lt"||e==="+mj")return"serif";if(e==="+mn-lt"||e==="+mn")return"sans-serif";if(vt.has(e))return e;const n=e.toLowerCase().trim(),t=it[n];return t?t._custom||t.google===null?e:t.google&&Ts(t.google)?t.google:t.google||e:e}function Jr(e){if(!e)return"sans-serif";const n=e.toLowerCase().trim();return it[n]?.generic??"sans-serif"}async function eo(e,n){const t=[...e];n?.majorFont&&t.push(n.majorFont),n?.minorFont&&t.push(n.minorFont);const s=new Map;for(const o of t){if(!o||o.startsWith("+")||o==="+mj-lt"||o==="+mn-lt"||o==="+mj"||o==="+mn"||vt.has(o))continue;const l=o.toLowerCase().trim(),a=it[l];let c=null,d=[400,700];if(a){if(a._custom||a.google===null)continue;c=a.google,d=a.weights.length?a.weights:[400,700]}else c=o;if(!c||Ot.has(c))continue;if(Ts(c)){Ot.add(c);continue}const h=s.get(c)??new Set;d.forEach(u=>h.add(u)),s.set(c,h)}if(s.size===0)return;for(const o of s.keys())Ot.add(o);const r=`https://fonts.googleapis.com/css2?${[...s.entries()].map(([o,l])=>{const a=[...l].sort((d,h)=>d-h),c=[...a.map(d=>`0,${d}`),...a.map(d=>`1,${d}`)].join(";");return`family=${encodeURIComponent(`${o}:ital,wght@${c}`)}`}).join("&")}&display=swap`;try{const o=document.createElement("link");o.rel="stylesheet",o.href=r,document.head.appendChild(o),await new Promise(l=>{o.onload=l,o.onerror=()=>{console.warn("[pptx-canvas-renderer] Google Fonts failed to load:",r),l()},setTimeout(l,5e3)}),document.fonts?.ready&&await Promise.race([document.fonts.ready,new Promise(l=>setTimeout(l,2e3))])}catch(o){console.warn("[pptx-canvas-renderer] Font loading error:",o)}}function to(e){const n=new Set;for(const t of e){if(!t)continue;const s=t.getElementsByTagName("*");for(let i=0;i<s.length;i++){const r=s[i],o=r.localName;if(o==="latin"||o==="ea"||o==="cs"){const l=r.getAttribute("typeface");l&&!l.startsWith("+")&&n.add(l)}}}return n}function js(e,n,t,s,i=1800,r=null){let o=i;if(r){const y=r.getAttribute("sz");y&&(o=parseInt(y,10))}if(n){const y=n.getAttribute("sz");y&&(o=parseInt(y,10))}if(e){const y=e.getAttribute("sz");y&&(o=parseInt(y,10))}let l=!1,a=!1;if(r&&(r.getAttribute("b")==="1"&&(l=!0),r.getAttribute("i")==="1"&&(a=!0)),n){const y=n.getAttribute("b"),w=n.getAttribute("i");y==="1"?l=!0:y==="0"&&(l=!1),w==="1"?a=!0:w==="0"&&(a=!1)}if(e){const y=e.getAttribute("b"),w=e.getAttribute("i");y==="1"?l=!0:y==="0"&&(l=!1),w==="1"?a=!0:w==="0"&&(a=!1)}let c=s?.minorFont??"Calibri";function d(y){if(!y)return;const w=m(y,"latin"),x=w?w.getAttribute("typeface"):y.getAttribute("typeface");if(x){if(x==="+mj-lt"||x==="+mj"){c=s?.majorFont??c;return}if(x==="+mn-lt"||x==="+mn"){c=s?.minorFont??c;return}c=x}}d(r),d(n),d(e);const h=Zr(c),u=Jr(c),p=o*127*t;return{fontStr:`${a?"italic ":""}${l?"bold":"normal"} ${p}px "${h}", ${u}`,sz:o,szPx:p,bold:l,italic:a,family:h,generic:u,rawFamily:c}}function no(){const e=[];for(const[n,t]of vt)for(const s of t)e.push({family:n,weight:s.weight,style:s.style,status:s.status});return e}function $t(e){const n=e.replace("#","");return{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16)}}function Ve(e,n,t){e/=255,n/=255,t/=255;const s=Math.max(e,n,t),i=Math.min(e,n,t);let r=0,o=0;const l=(s+i)/2;if(s!==i){const a=s-i;switch(o=l>.5?a/(2-s-i):a/(s+i),s){case e:r=((n-t)/a+(n<t?6:0))/6;break;case n:r=((t-e)/a+2)/6;break;case t:r=((e-n)/a+4)/6;break}}return{h:r,l,s:o}}function We(e,n,t){if(t===0){const o=Math.round(n*255);return{r:o,g:o,b:o}}const s=n<.5?n*(1+t):n+t-n*t,i=2*n-s,r=(o,l,a)=>(a<0&&(a+=1),a>1&&(a-=1),a<1/6?o+(l-o)*6*a:a<1/2?l:a<2/3?o+(l-o)*(2/3-a)*6:o);return{r:Math.round(r(i,s,e+1/3)*255),g:Math.round(r(i,s,e)*255),b:Math.round(r(i,s,e-1/3)*255)}}const so={black:"000000",white:"FFFFFF",red:"FF0000",green:"008000",blue:"0000FF",yellow:"FFFF00",cyan:"00FFFF",magenta:"FF00FF",orange:"FFA500",purple:"800080",pink:"FFC0CB",brown:"A52A2A",gray:"808080",grey:"808080",navy:"000080",teal:"008080",maroon:"800000",olive:"808000",lime:"00FF00",aqua:"00FFFF",fuchsia:"FF00FF",silver:"C0C0C0",coral:"FF7F50",salmon:"FA8072",gold:"FFD700",khaki:"F0E68C",lavender:"E6E6FA",beige:"F5F5DC",ivory:"FFFFF0",mintcream:"F5FFFA",azure:"F0FFFF",aliceblue:"F0F8FF",ghostwhite:"F8F8FF",darkred:"8B0000",darkgreen:"006400",darkblue:"00008B",darkcyan:"008B8B",darkmagenta:"8B008B",darkorange:"FF8C00",darkgray:"A9A9A9",darkgrey:"A9A9A9",lightgray:"D3D3D3",lightgrey:"D3D3D3",lightblue:"ADD8E6",lightgreen:"90EE90",lightpink:"FFB6C1",lightyellow:"FFFFE0",lightcyan:"E0FFFF",deepskyblue:"00BFFF",royalblue:"4169E1",steelblue:"4682B4",skyblue:"87CEEB",dodgerblue:"1E90FF",cornflowerblue:"6495ED",mediumblue:"0000CD",midnightblue:"191970",indigo:"4B0082",slateblue:"6A5ACD",blueviolet:"8A2BE2",mediumpurple:"9370DB",orchid:"DA70D6",violet:"EE82EE",plum:"DDA0DD",thistle:"D8BFD8",hotpink:"FF69B4",deeppink:"FF1493",crimson:"DC143C",firebrick:"B22222",tomato:"FF6347",orangered:"FF4500",darkorange2:"FF8C00",chocolate:"D2691E",saddlebrown:"8B4513",sienna:"A0522D",tan:"D2B48C",burlywood:"DEB887",wheat:"F5DEB3",moccasin:"FFE4B5",peachpuff:"FFDAB9",papayawhip:"FFEFD5",mistyrose:"FFE4E1",linen:"FAF0E6",oldlace:"FDF5E6",floralwhite:"FFFAF0",antiquewhite:"FAEBD7",bisque:"FFE4C4",blanchedalmond:"FFEBCD",cornsilk:"FFF8DC",lemonchiffon:"FFFACD",honeydew:"F0FFF0",palegreen:"98FB98",lightseagreen:"20B2AA",mediumseagreen:"3CB371",seagreen:"2E8B57",forestgreen:"228B22",yellowgreen:"9ACD32",olivedrab:"6B8E23",greenyellow:"ADFF2F",chartreuse:"7FFF00",springgreen:"00FF7F",mediumspringgreen:"00FA9A",aquamarine:"7FFFD4",turquoise:"40E0D0",mediumturquoise:"48D1CC",paleturquoise:"AFEEEE",cadetblue:"5F9EA0",powderblue:"B0E0E6",lightsteelblue:"B0C4DE",slategray:"708090",slategrey:"708090",dimgray:"696969",dimgrey:"696969",snow:"FFFAFA",seashell:"FFF5EE",whitesmoke:"F5F5F5",gainsboro:"DCDCDC"};function io(e,n){if(!n)return e;let{r:t,g:s,b:i,a:r=1}=e;for(const o of n.children){const l=o.localName,a=parseInt(o.getAttribute("val")??"0",10);switch(l){case"lumMod":{const c=a/1e5,d=Ve(t,s,i),h=We(d.h,Ie(d.l*c,0,1),d.s);t=h.r,s=h.g,i=h.b;break}case"lumOff":{const c=a/1e5,d=Ve(t,s,i),h=We(d.h,Ie(d.l+c,0,1),d.s);t=h.r,s=h.g,i=h.b;break}case"tint":{const c=a/1e5;t=Math.round(t+(255-t)*(1-c)),s=Math.round(s+(255-s)*(1-c)),i=Math.round(i+(255-i)*(1-c));break}case"shade":{const c=a/1e5;t=Math.round(t*c),s=Math.round(s*c),i=Math.round(i*c);break}case"satMod":{const c=a/1e5,d=Ve(t,s,i),h=We(d.h,d.l,Ie(d.s*c,0,1));t=h.r,s=h.g,i=h.b;break}case"satOff":{const c=a/1e5,d=Ve(t,s,i),h=We(d.h,d.l,Ie(d.s+c,0,1));t=h.r,s=h.g,i=h.b;break}case"hueMod":{const c=a/1e5,d=Ve(t,s,i),h=We(d.h*c%1,d.l,d.s);t=h.r,s=h.g,i=h.b;break}case"hueOff":{const c=a/216e5,d=Ve(t,s,i),h=We(((d.h+c)%1+1)%1,d.l,d.s);t=h.r,s=h.g,i=h.b;break}case"alpha":{r=a/1e5;break}case"alphaOff":{r=Ie(r+a/1e5,0,1);break}case"alphaMod":{r=Ie(r*a/1e5,0,1);break}case"inv":{t=255-t,s=255-s,i=255-i;break}case"gray":{t=s=i=Math.round(.2126*t+.7152*s+.0722*i);break}case"comp":{const c=Ve(t,s,i),d=We((c.h+.5)%1,c.l,c.s);t=d.r,s=d.g,i=d.b;break}}}return{r:Ie(t,0,255),g:Ie(s,0,255),b:Ie(i,0,255),a:r}}function ve(e,n){if(!e)return null;const t=e.localName;let s=null,i=1;if(t==="srgbClr"){const r=e.getAttribute("val")||"";r.length>=6&&(s=$t(r))}else if(t==="schemeClr"){const o=e.getAttribute("val")||"",l=n?.[o];l?s=$t(l):s={r:0,g:0,b:0}}else if(t==="prstClr"){const r=(e.getAttribute("val")||"").toLowerCase(),o=so[r];o&&(s=$t(o))}else if(t==="sysClr"){const r=e.getAttribute("lastClr");r?.length>=6?s=$t(r):s={r:0,g:0,b:0}}else if(t==="hslClr"){const r=C(e,"hue",0)/216e5,o=C(e,"sat",0)/1e5,l=C(e,"lum",0)/1e5;s=We(r,l,o)}else if(t==="scRgbClr"){const r=C(e,"r",0)/1e5,o=C(e,"g",0)/1e5,l=C(e,"b",0)/1e5;s={r:Math.round(Math.pow(r,1/2.2)*255),g:Math.round(Math.pow(o,1/2.2)*255),b:Math.round(Math.pow(l,1/2.2)*255)}}return s?io({...s,a:i},e):null}function pe(e,n){if(!e)return"transparent";const t=n!==void 0?n:e.a??1;return t<1?`rgba(${e.r},${e.g},${e.b},${t.toFixed(3)})`:`rgb(${e.r},${e.g},${e.b})`}function ge(e){if(!e)return null;const n=["srgbClr","schemeClr","prstClr","sysClr","hslClr","scRgbClr"];for(const t of n){const s=m(e,t);if(s)return s}return null}function Xn(e,n){if(!e)return null;const t=m(e,"solidFill");if(!t)return null;const s=ge(t),i=ve(s,n);return i?pe(i):null}function ro(e,n,t){const s=Xn(e,t);return s||Xn(n,t)}function Kt(e,n,t,s,i,r,o){const l=u=>u*Math.PI/180,a=(u,p=5e4)=>(o&&o[u]!==void 0?o[u]:p)/1e5,c=t+i/2,d=s+r/2,h=Math.min(i,r);switch(e.beginPath(),n){case"rect":case"snip1Rect":e.rect(t,s,i,r);break;case"roundRect":{const u=a(0,16667)*h*.5;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.arcTo(t+i,s,t+i,s+u,u),e.lineTo(t+i,s+r-u),e.arcTo(t+i,s+r,t+i-u,s+r,u),e.lineTo(t+u,s+r),e.arcTo(t,s+r,t,s+r-u,u),e.lineTo(t,s+u),e.arcTo(t,s,t+u,s,u),e.closePath();break}case"ellipse":case"oval":e.ellipse(c,d,i/2,r/2,0,0,Math.PI*2);break;case"triangle":case"isoscelesTriangle":e.moveTo(c,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break;case"rightTriangle":e.moveTo(t,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break;case"parallelogram":{const u=a(0,25e3),p=i*u;e.moveTo(t+p,s),e.lineTo(t+i,s),e.lineTo(t+i-p,s+r),e.lineTo(t,s+r),e.closePath();break}case"trapezoid":{const u=a(0,25e3),p=i*u;e.moveTo(t+p,s),e.lineTo(t+i-p,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break}case"diamond":e.moveTo(c,s),e.lineTo(t+i,d),e.lineTo(c,s+r),e.lineTo(t,d),e.closePath();break;case"pentagon":tt(e,c,d,i/2,r/2,5,-Math.PI/2);break;case"hexagon":tt(e,c,d,i/2,r/2,6,0);break;case"heptagon":tt(e,c,d,i/2,r/2,7,-Math.PI/2);break;case"octagon":tt(e,c,d,i/2,r/2,8,Math.PI/8);break;case"decagon":tt(e,c,d,i/2,r/2,10,-Math.PI/2);break;case"dodecagon":tt(e,c,d,i/2,r/2,12,0);break;case"plus":case"cross":{const u=a(0,25e3),p=h*u,g=c-p/2,b=c+p/2,_=d-p/2,y=d+p/2;e.moveTo(g,s),e.lineTo(b,s),e.lineTo(b,_),e.lineTo(t+i,_),e.lineTo(t+i,y),e.lineTo(b,y),e.lineTo(b,s+r),e.lineTo(g,s+r),e.lineTo(g,y),e.lineTo(t,y),e.lineTo(t,_),e.lineTo(g,_),e.closePath();break}case"star4":$e(e,c,d,i/2,r/2,4,a(0,37500));break;case"star5":$e(e,c,d,i/2,r/2,5,a(0,19098),-Math.PI/2);break;case"star6":$e(e,c,d,i/2,r/2,6,a(0,28868),0);break;case"star7":$e(e,c,d,i/2,r/2,7,a(0,34601),-Math.PI/2);break;case"star8":$e(e,c,d,i/2,r/2,8,a(0,29289),Math.PI/8);break;case"star10":$e(e,c,d,i/2,r/2,10,a(0,30902),-Math.PI/2);break;case"star12":$e(e,c,d,i/2,r/2,12,a(0,37720),0);break;case"star16":$e(e,c,d,i/2,r/2,16,a(0,37500),0);break;case"star24":$e(e,c,d,i/2,r/2,24,a(0,37500),0);break;case"star32":$e(e,c,d,i/2,r/2,32,a(0,37500),0);break;case"rightArrow":{const u=a(0,5e4),p=a(1,5e4),g=(r-r*p)/2,b=t+i*(1-u);e.moveTo(t,s+g),e.lineTo(b,s+g),e.lineTo(b,s),e.lineTo(t+i,d),e.lineTo(b,s+r),e.lineTo(b,s+r-g),e.lineTo(t,s+r-g),e.closePath();break}case"leftArrow":{const u=a(0,5e4),p=a(1,5e4),g=(r-r*p)/2,b=t+i*u;e.moveTo(t+i,s+g),e.lineTo(b,s+g),e.lineTo(b,s),e.lineTo(t,d),e.lineTo(b,s+r),e.lineTo(b,s+r-g),e.lineTo(t+i,s+r-g),e.closePath();break}case"upArrow":{const u=a(0,5e4),p=a(1,5e4),g=(i-i*p)/2,b=s+r*u;e.moveTo(t+g,s+r),e.lineTo(t+g,b),e.lineTo(t,b),e.lineTo(c,s),e.lineTo(t+i,b),e.lineTo(t+i-g,b),e.lineTo(t+i-g,s+r),e.closePath();break}case"downArrow":{const u=a(0,5e4),p=a(1,5e4),g=(i-i*p)/2,b=s+r*(1-u);e.moveTo(t+g,s),e.lineTo(t+g,b),e.lineTo(t,b),e.lineTo(c,s+r),e.lineTo(t+i,b),e.lineTo(t+i-g,b),e.lineTo(t+i-g,s),e.closePath();break}case"leftRightArrow":{const u=a(0,25e3),p=a(1,5e4),g=(r-r*p)/2,b=t+i*u,_=t+i*(1-u);e.moveTo(t,d),e.lineTo(b,s),e.lineTo(b,s+g),e.lineTo(_,s+g),e.lineTo(_,s),e.lineTo(t+i,d),e.lineTo(_,s+r),e.lineTo(_,s+r-g),e.lineTo(b,s+r-g),e.lineTo(b,s+r),e.closePath();break}case"upDownArrow":{const u=a(0,25e3),p=a(1,5e4),g=(i-i*p)/2,b=s+r*u,_=s+r*(1-u);e.moveTo(c,s),e.lineTo(t+i,b),e.lineTo(t+i-g,b),e.lineTo(t+i-g,_),e.lineTo(t+i,_),e.lineTo(c,s+r),e.lineTo(t,_),e.lineTo(t+g,_),e.lineTo(t+g,b),e.lineTo(t,b),e.closePath();break}case"chevron":{const u=a(0,5e4),p=i*u;e.moveTo(t,s),e.lineTo(t+i-p,s),e.lineTo(t+i,d),e.lineTo(t+i-p,s+r),e.lineTo(t,s+r),e.lineTo(t+p,d),e.closePath();break}case"pentagon5":case"homePlate":{const u=a(0,5e4);e.moveTo(t,s),e.lineTo(t+i*(1-u),s),e.lineTo(t+i,d),e.lineTo(t+i*(1-u),s+r),e.lineTo(t,s+r),e.closePath();break}case"arc":{const u=a(0,270)*Math.PI/180,p=a(1,288e5/6e4)*Math.PI/180;e.moveTo(c,d),e.arc(c,d,Math.min(i,r)/2,u,u+p),e.closePath();break}case"blockArc":{const u=(a(0,0)*360-90)*Math.PI/180,p=a(1,25e3)*360*Math.PI/180,g=a(2,25e3)*Math.min(i,r)/2,b=Math.min(i,r)/2,_=b-g;e.moveTo(c+b*Math.cos(u),d+b*Math.sin(u)),e.arc(c,d,b,u,u+p),e.arc(c,d,Math.max(1,_),u+p,u,!0),e.closePath();break}case"line":case"straightConnector1":e.moveTo(t,d),e.lineTo(t+i,d);break;case"bentConnector3":case"bentConnector4":case"bentConnector5":case"elbowConnector":e.moveTo(t,s),e.lineTo(t,d),e.lineTo(t+i,d),e.lineTo(t+i,s+r);break;case"curvedConnector3":case"curvedConnector4":e.moveTo(t,s),e.bezierCurveTo(t,s+r/2,t+i,s+r/2,t+i,s+r);break;case"heart":{oo(e,t,s,i,r);break}case"lightningBolt":{e.moveTo(t+i*.6,s),e.lineTo(t+i*.2,s+r*.45),e.lineTo(t+i*.5,s+r*.45),e.lineTo(t+i*.4,s+r),e.lineTo(t+i*.8,s+r*.55),e.lineTo(t+i*.5,s+r*.55),e.closePath();break}case"moon":{e.arc(c+i*.1,d,r*.5,l(-120),l(120)),e.arc(c+i*.4,d,r*.45,l(120),l(-120),!0),e.closePath();break}case"noSmoking":{const u=Math.min(i,r)/2;e.arc(c,d,u,0,Math.PI*2),e.moveTo(c-u*.7,d+u*.7),e.lineTo(c+u*.7,d-u*.7);break}case"flowChartProcess":e.rect(t,s,i,r);break;case"flowChartDecision":e.moveTo(c,s),e.lineTo(t+i,d),e.lineTo(c,s+r),e.lineTo(t,d),e.closePath();break;case"flowChartTerminator":{const u=r/2;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.arc(t+i-u,d,u,-Math.PI/2,Math.PI/2),e.lineTo(t+u,s+r),e.arc(t+u,d,u,Math.PI/2,-Math.PI/2),e.closePath();break}case"flowChartDocument":{e.moveTo(t,s),e.lineTo(t+i,s),e.lineTo(t+i,s+r*.8),e.bezierCurveTo(t+i*.75,s+r*.8,t+i*.75,s+r,t+i*.5,s+r),e.bezierCurveTo(t+i*.25,s+r,t+i*.25,s+r*.8,t,s+r*.8),e.closePath();break}case"flowChartDatabase":case"cylinder":{const u=r*.1;e.moveTo(t,s+u),e.ellipse(c,s+u,i/2,u,0,Math.PI,0),e.lineTo(t+i,s+r-u),e.ellipse(c,s+r-u,i/2,u,0,0,Math.PI),e.closePath();break}case"cube":{const u=i*.15;e.moveTo(t+u,s),e.lineTo(t+i,s),e.lineTo(t+i,s+r-u),e.lineTo(t+i-u,s+r),e.lineTo(t,s+r),e.lineTo(t,s+u),e.closePath(),e.moveTo(t+u,s),e.lineTo(t+u,s+u),e.lineTo(t,s+u),e.moveTo(t+u,s+u),e.lineTo(t+i,s+u);break}case"callout1":case"borderCallout1":case"wedgeRectCallout":{e.rect(t,s,i,r*.8),e.moveTo(c-i*.1,s+r*.8),e.lineTo(c,s+r),e.lineTo(c+i*.1,s+r*.8),e.closePath();break}case"wedgeRoundRectCallout":{const u=r*.05;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.arcTo(t+i,s,t+i,s+u,u),e.lineTo(t+i,s+r*.75-u),e.arcTo(t+i,s+r*.75,t+i-u,s+r*.75,u),e.lineTo(c+i*.1,s+r*.75),e.lineTo(c,s+r),e.lineTo(c-i*.1,s+r*.75),e.lineTo(t+u,s+r*.75),e.arcTo(t,s+r*.75,t,s+r*.75-u,u),e.lineTo(t,s+u),e.arcTo(t,s,t+u,s,u),e.closePath();break}case"wedgeEllipseCallout":{e.ellipse(c,d-r*.05,i/2,r*.45,0,0,Math.PI*2),e.moveTo(c-i*.1,d+r*.4),e.lineTo(c,s+r),e.lineTo(c+i*.1,d+r*.4),e.closePath();break}case"cloudCallout":case"cloud":{e.beginPath();const u=[{cx:c-i*.22,cy:d-r*.12,r:i*.16},{cx:c-i*.07,cy:d-r*.22,r:i*.18},{cx:c+i*.1,cy:d-r*.22,r:i*.17},{cx:c+i*.25,cy:d-r*.12,r:i*.15},{cx:c+i*.35,cy:d+r*.05,r:i*.13},{cx:c-i*.3,cy:d+r*.05,r:i*.13}];for(const p of u)e.arc(p.cx,p.cy,p.r,0,Math.PI*2);e.rect(c-i*.35,d,i*.7,r*.25);break}case"smileyFace":{e.arc(c,d,Math.min(i,r)/2,0,Math.PI*2);break}case"donut":{const u=Math.min(i,r)/2,p=u*a(0,25e3);e.arc(c,d,u,0,Math.PI*2),e.arc(c,d,p,Math.PI*2,0,!0);break}case"bracketPair":{const u=i*.2;e.moveTo(t+u,s),e.arcTo(t,s,t,s+u,u),e.lineTo(t,s+r-u),e.arcTo(t,s+r,t+u,s+r,u),e.moveTo(t+i-u,s),e.arcTo(t+i,s,t+i,s+u,u),e.lineTo(t+i,s+r-u),e.arcTo(t+i,s+r,t+i-u,s+r,u);break}case"bracePair":{const u=r*.15;e.moveTo(c-i*.35,s),e.bezierCurveTo(c-i*.45,s,c-i*.45,s,c-i*.45,s+u),e.lineTo(c-i*.45,d-u),e.bezierCurveTo(c-i*.45,d,c-i*.5,d,c-i*.5,d),e.bezierCurveTo(c-i*.5,d,c-i*.45,d,c-i*.45,d+u),e.lineTo(c-i*.45,s+r-u),e.bezierCurveTo(c-i*.45,s+r,c-i*.35,s+r,c-i*.35,s+r);break}case"irregularSeal1":case"irregularSeal2":{$e(e,c,d,i/2,r/2,12,a(0,42533),0);break}case"accentCallout1":case"accentCallout2":case"calloutWedgeRect":e.rect(t,s,i,r);break;case"flowChartAlternateProcess":{const u=r*.15;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.arcTo(t+i,s,t+i,s+u,u),e.lineTo(t+i,s+r-u),e.arcTo(t+i,s+r,t+i-u,s+r,u),e.lineTo(t+u,s+r),e.arcTo(t,s+r,t,s+r-u,u),e.lineTo(t,s+u),e.arcTo(t,s,t+u,s,u),e.closePath();break}case"flowChartConnector":e.arc(c,d,Math.min(i,r)/2,0,Math.PI*2);break;case"flowChartInputOutput":{const u=i*.2;e.moveTo(t+u,s),e.lineTo(t+i,s),e.lineTo(t+i-u,s+r),e.lineTo(t,s+r),e.closePath();break}case"flowChartPredefinedProcess":{e.rect(t,s,i,r),e.moveTo(t+i*.1,s),e.lineTo(t+i*.1,s+r),e.moveTo(t+i*.9,s),e.lineTo(t+i*.9,s+r);break}case"flowChartManualInput":{e.moveTo(t,s+r*.2),e.lineTo(t+i,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break}case"flowChartPreparation":{const u=i*.2;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.lineTo(t+i,d),e.lineTo(t+i-u,s+r),e.lineTo(t+u,s+r),e.lineTo(t,d),e.closePath();break}case"ribbon":case"ribbon2":{const u=r*.3;e.moveTo(t,s+u/2),e.lineTo(t+i*.1,s),e.lineTo(t+i*.1,s+r-u),e.lineTo(t,s+r),e.lineTo(t+i*.5,s+r-u),e.lineTo(t+i,s+r),e.lineTo(t+i-i*.1,s+r-u),e.lineTo(t+i-i*.1,s),e.lineTo(t+i,s+u/2),e.lineTo(t+i*.5,s+u),e.closePath();break}case"ellipseRibbon":case"ellipseRibbon2":{e.ellipse(c,d,i/2,r/2,0,0,Math.PI*2);break}case"teardrop":{const u=Math.min(i,r)*.45;e.arc(c,d+u,u,-Math.PI,0),e.bezierCurveTo(c+u,d+u-u*.55,c+u*.1,d-r*.4,c,s),e.bezierCurveTo(c-u*.1,d-r*.4,c-u,d+u-u*.55,c-u,d+u),e.closePath();break}default:return e.rect(t,s,i,r),!1}return!0}function tt(e,n,t,s,i,r,o=0){for(let l=0;l<r;l++){const a=o+l/r*Math.PI*2,c=n+s*Math.cos(a),d=t+i*Math.sin(a);l===0?e.moveTo(c,d):e.lineTo(c,d)}e.closePath()}function $e(e,n,t,s,i,r,o=.5,l=-Math.PI/2){for(let a=0;a<r*2;a++){const c=l+a/(r*2)*Math.PI*2,d=a%2===1,h=d?s*o:s,u=d?i*o:i,p=n+h*Math.cos(c),g=t+u*Math.sin(c);a===0?e.moveTo(p,g):e.lineTo(p,g)}e.closePath()}function oo(e,n,t,s,i){e.beginPath();const r=n+s/2,o=t+i*.25;e.moveTo(r,t+i*.9),e.bezierCurveTo(n-s*.1,t+i*.6,n-s*.1,o-i*.05,r-s*.25,o-i*.1),e.bezierCurveTo(r-s*.5+s*.05,t+i*.05,r-s*.03,t+i*.05,r,o-i*.15),e.bezierCurveTo(r+s*.03,t+i*.05,r+s*.5-s*.05,t+i*.05,r+s*.25,o-i*.1),e.bezierCurveTo(n+s*1.1,o-i*.05,n+s*1.1,t+i*.6,r,t+i*.9),e.closePath()}const Vn=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0","#FF7F00","#9E480E"];function ao(e){const n=e?.textContent?.trim();if(n==null||n==="")return null;const t=parseFloat(n);return isNaN(t)?n:t}function gt(e){if(!e)return[];const n=C(m(e,"ptCount"),"val",0),t=new Array(n).fill(null);for(const s of ue(e,"pt")){const i=C(s,"idx",0);t[i]=ao(m(s,"v"))}return t}function Tt(e){const n=m(e,"tx");if(!n)return null;const t=m(n,"v");if(t)return t.textContent.trim();const s=m(n,"strCache");if(s){const i=m(s,"pt"),r=i?m(i,"v"):null;return r?r.textContent.trim():null}return null}function Zt(e){const n=m(e,"cat")||m(e,"xVal");return n?gt(m(n,"strCache")||m(n,"numCache")):[]}function jt(e){const n=m(e,"val")||m(e,"yVal");return n?gt(m(n,"numCache")):[]}function Qe(e,n,t){const s=m(e,"spPr");if(s){const r=m(s,"solidFill");if(r){const o=ge(r),l=ve(o,t);if(l)return pe(l)}}const i=`accent${n%6+1}`;return t[i]?`#${t[i]}`:Vn[n%Vn.length]}function Fs(e,n){const t={};for(const s of ue(e,"dPt")){const i=C(m(s,"idx"),"val",-1);if(i<0)continue;const r=m(s,"spPr");if(!r)continue;const o=m(r,"solidFill");if(!o)continue;const l=ge(o),a=ve(l,n);a&&(t[i]=pe(a))}return t}function Jt(e,n,t,s,i={}){const{padL:r=.12,padR:o=.06,padT:l=.08,padB:a=.1,legendH:c=.1,hasLegend:d=!0,hasTitle:h=!1}=i,u=h?s*.08:0,p=d?s*c:0;return{x:e+t*r,y:n+s*l+u,w:t*(1-r-o),h:s*(1-l-a)-p-u,legendY:n+s*(1-c*.7)}}function wt(e,n,t,s,i,r=3){s<0&&(n+=s,s=-s),i<0&&(t+=i,i=-i),r=Math.min(r,Math.abs(s)/2,Math.abs(i)/2),e.beginPath(),e.moveTo(n+r,t),e.arcTo(n+s,t,n+s,t+i,r),e.arcTo(n+s,t+i,n,t+i,r),e.arcTo(n,t+i,n,t,r),e.arcTo(n,t,n+s,t,r),e.closePath()}function Ee(e,n,t,s,i,r="#999",o=.7){e.save(),e.strokeStyle=r,e.lineWidth=o,e.setLineDash([]),e.beginPath(),e.moveTo(n,t),e.lineTo(s,i),e.stroke(),e.restore()}function Ze(e,n,t,s,i){e.save(),e.strokeStyle="rgba(0,0,0,0.10)",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(n,t),e.lineTo(s,i),e.stroke(),e.setLineDash([]),e.restore()}function Cs(e,n=5){const t=e/n,s=Math.pow(10,Math.floor(Math.log10(t))),i=t/s;let r;return i<1.5?r=1:i<3.5?r=2:i<7.5?r=5:r=10,r*s}function kt(e,n=!0){const t=e.filter(o=>typeof o=="number"&&isFinite(o));if(!t.length)return{min:0,max:100,step:20};let s=n?Math.min(0,...t):Math.min(...t),i=Math.max(...t);s===i&&(s-=1,i+=1);const r=Cs(i-s);return i=Math.ceil(i/r)*r,s=Math.floor(s/r)*r,{min:s,max:i,step:r}}function Je(e){return typeof e!="number"?String(e??""):Math.abs(e)>=1e9?(e/1e9).toFixed(1).replace(/\.0$/,"")+"B":Math.abs(e)>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":Math.abs(e)>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+"K":Number.isInteger(e)?String(e):e.toFixed(1)}function Ft(e,n,t,s,i,r,o){if(!r.length)return;const l=Math.max(8,Math.min(14,s*.025))*o,a=s/Math.max(r.length,1);e.save(),e.font=`${l}px sans-serif`,e.textBaseline="middle";for(let c=0;c<r.length;c++){if(!r[c].name)continue;const d=n+a*c+l*.5;e.fillStyle=r[c].color,wt(e,d,i-l/2,l*1.2,l),e.fill(),e.fillStyle="#444",e.fillText(r[c].name,d+l*1.5,i)}e.restore()}function lo(e,n,t,s,i,r,o,l){const a=m(n,"barChart")||m(n,"bar3DChart"),c=!a||O(a,"barDir","col")!=="bar",d=O(a,"grouping","clustered"),h=d==="stacked"||d==="percentStacked",u=d==="percentStacked",p=ue(a,"ser"),g=p.map((k,T)=>({name:Tt(k),values:jt(k),color:Qe(k,T,o),dptColors:Fs(k,o)}));if(!g.length)return;const b=Zt(p[0])||[],_=Math.max(b.length,g[0]?.values.length||0,1),y=Jt(t,s,i,r,{hasLegend:g.length>1});let w;h?(w=Array.from({length:_},(k,T)=>g.reduce((N,M)=>N+(M.values[T]||0),0)),u&&(w=w.map(()=>100))):w=g.flatMap(k=>k.values);const x=kt(w),P=Math.max(7,Math.min(11,y.w*.018))*l;e.font=`${P}px sans-serif`,e.textBaseline="middle";const v=Math.round((x.max-x.min)/x.step);if(c){e.save(),e.textAlign="right",e.fillStyle="#666";for(let S=0;S<=v;S++){const $=x.min+S*x.step,R=($-x.min)/(x.max-x.min),W=y.y+y.h-R*y.h;Ze(e,y.x,W,y.x+y.w,W),e.fillText(u?$+"%":Je($),y.x-4*l,W)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";const k=y.w/_;for(let S=0;S<_;S++){const $=y.x+k*S+k/2,R=String(b[S]??S+1);e.fillText(R,$,y.y+y.h+P*1.5)}e.restore(),Ee(e,y.x,y.y,y.x,y.y+y.h),Ee(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h);const T=y.w/_,N=T*.15,M=T-N*2,F=h?M:M/g.length;for(let S=0;S<_;S++){const $=y.x+T*S+N;let R=0;for(let W=0;W<g.length;W++){const Q=g[W];let D=Q.values[S]??0;if(u){const re=g.reduce((de,oe)=>de+(oe.values[S]||0),0);D=re?D/re*100:0}const U=Q.dptColors[S]||Q.color,K=Math.abs(D)/(x.max-x.min)*y.h,J=h?$:$+W*F,q=h?(R-x.min)/(x.max-x.min):Math.max(0,-x.min)/(x.max-x.min),I=y.y+y.h-q*y.h,Z=D>=0?I-K:I;e.save(),e.fillStyle=U,wt(e,J,Z,h?M:F-1*l,K,2*l),e.fill();const ee=e.createLinearGradient(J,Z,J,Z+K*.3);ee.addColorStop(0,"rgba(255,255,255,0.18)"),ee.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=ee,e.fill(),e.restore(),h&&(R+=Math.abs(D))}}}else{e.save(),e.textAlign="right",e.fillStyle="#666";const k=y.h/_;for(let S=0;S<_;S++){const $=y.y+k*S+k/2,R=String(b[S]??S+1);e.fillText(R,y.x-4*l,$)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";for(let S=0;S<=v;S++){const $=x.min+S*x.step,R=($-x.min)/(x.max-x.min),W=y.x+R*y.w;Ze(e,W,y.y,W,y.y+y.h),e.fillText(u?$+"%":Je($),W,y.y+y.h+P*1.5)}e.restore(),Ee(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h),Ee(e,y.x,y.y,y.x,y.y+y.h);const T=k*.15,N=k-T*2,M=h?N:N/g.length,F=y.x+-x.min/(x.max-x.min)*y.w;for(let S=0;S<_;S++){const $=y.y+k*S+T;let R=0;for(let W=0;W<g.length;W++){const Q=g[W];let D=Q.values[S]??0;if(u){const Z=g.reduce((ee,re)=>ee+(re.values[S]||0),0);D=Z?D/Z*100:0}const U=Q.dptColors[S]||Q.color,K=Math.abs(D)/(x.max-x.min)*y.w,J=h?$:$+W*M,q=h?F+R/(x.max-x.min)*y.w:F,I=D>=0?q:q-K;e.save(),e.fillStyle=U,wt(e,I,J,K,h?N:M-1*l,2*l),e.fill(),e.restore(),h&&(R+=Math.abs(D))}}}g.length>1&&Ft(e,t,s,i,y.legendY,g,l)}function co(e,n,t,s,i,r,o,l){const a=m(n,"lineChart")||m(n,"line3DChart"),c=ue(a,"ser"),d=c.map((y,w)=>({name:Tt(y),values:jt(y),color:Qe(y,w,o),marker:O(m(y,"marker"),"symbol","none")!=="none",smooth:O(m(y,"smooth"),"val","0")==="1"}));if(!d.length)return;const h=Zt(c[0])||[],u=Math.max(h.length,d[0]?.values.length||0,1),p=Jt(t,s,i,r,{hasLegend:!0}),g=kt(d.flatMap(y=>y.values)),b=Math.max(7,Math.min(11,p.w*.018))*l,_=Math.round((g.max-g.min)/g.step);e.save(),e.textAlign="right",e.fillStyle="#666",e.font=`${b}px sans-serif`;for(let y=0;y<=_;y++){const w=g.min+y*g.step,x=(w-g.min)/(g.max-g.min),P=p.y+p.h-x*p.h;Ze(e,p.x,P,p.x+p.w,P),e.fillText(Je(w),p.x-4*l,P)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666",e.font=`${b}px sans-serif`;for(let y=0;y<u;y++){const w=p.x+y/(u-1||1)*p.w;Ze(e,w,p.y,w,p.y+p.h);const x=String(h[y]??y+1);e.fillText(x,w,p.y+p.h+b*1.5)}e.restore(),Ee(e,p.x,p.y,p.x,p.y+p.h),Ee(e,p.x,p.y+p.h,p.x+p.w,p.y+p.h);for(const y of d){const w=y.values.map((P,v)=>{const k=u>1?v/(u-1):.5,T=(P-g.min)/(g.max-g.min);return{x:p.x+k*p.w,y:p.y+p.h-T*p.h,v:P}}).filter(P=>typeof P.v=="number");if(w.length<2)continue;e.save(),e.beginPath(),e.moveTo(w[0].x,p.y+p.h);for(const P of w)e.lineTo(P.x,P.y);if(e.lineTo(w[w.length-1].x,p.y+p.h),e.closePath(),e.fillStyle=y.color+"22",e.fill(),e.restore(),e.save(),e.strokeStyle=y.color,e.lineWidth=2*l,e.lineJoin="round",e.lineCap="round",e.beginPath(),y.smooth&&w.length>2){e.moveTo(w[0].x,w[0].y);for(let P=1;P<w.length-1;P++){const v=(w[P].x+w[P+1].x)/2,k=(w[P].y+w[P+1].y)/2;e.quadraticCurveTo(w[P].x,w[P].y,v,k)}e.lineTo(w[w.length-1].x,w[w.length-1].y)}else{e.moveTo(w[0].x,w[0].y);for(const P of w.slice(1))e.lineTo(P.x,P.y)}e.stroke(),e.restore();const x=3.5*l;for(const P of w)e.save(),e.fillStyle=y.color,e.strokeStyle="#fff",e.lineWidth=1.5*l,e.beginPath(),e.arc(P.x,P.y,x,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}Ft(e,t,s,i,p.legendY,d,l)}function uo(e,n,t,s,i,r,o,l){const a=m(n,"areaChart")||m(n,"area3DChart"),c=O(a,"grouping","standard"),d=c==="percentStacked",h=c==="stacked"||d,p=ue(a,"ser").map((v,k)=>({name:Tt(v),values:jt(v),color:Qe(v,k,o)})).reverse();if(!p.length)return;const g=Math.max(...p.map(v=>v.values.length),1),b=Jt(t,s,i,r,{hasLegend:!0});let _=0;if(d)_=100;else for(let v=0;v<g;v++){const k=p.reduce((T,N)=>T+(N.values[v]||0),0);_=Math.max(_,k)}const y={min:0,max:_||100,step:Cs(_||100)},w=Math.round((y.max-y.min)/y.step),x=Math.max(7,Math.min(11,b.w*.018))*l;e.save(),e.font=`${x}px sans-serif`,e.textAlign="right",e.fillStyle="#666";for(let v=0;v<=w;v++){const k=y.min+v*y.step,T=(k-y.min)/(y.max-y.min),N=b.y+b.h-T*b.h;Ze(e,b.x,N,b.x+b.w,N),e.fillText(d?k+"%":Je(k),b.x-4*l,N)}e.restore(),Ee(e,b.x,b.y,b.x,b.y+b.h),Ee(e,b.x,b.y+b.h,b.x+b.w,b.y+b.h);const P=new Array(g).fill(0);for(const v of p){e.save(),e.beginPath();const k=[];for(let T=0;T<g;T++){let N=v.values[T]??0;if(d){const W=p.reduce((Q,D)=>Q+(D.values[T]||0),0);N=W?N/W*100:0}const M=h?P[T]:0,F=M+Math.abs(N),S=(M-y.min)/(y.max-y.min),$=(F-y.min)/(y.max-y.min),R=b.x+T/(g-1||1)*b.w;k.push({x:R,y:b.y+b.h-$*b.h,baseY:b.y+b.h-S*b.h}),h&&(P[T]+=Math.abs(N))}e.moveTo(k[0].x,k[0].baseY);for(const T of k)e.lineTo(T.x,T.baseY);for(let T=k.length-1;T>=0;T--)e.lineTo(k[T].x,k[T].y);e.closePath(),e.fillStyle=v.color+"cc",e.fill(),e.beginPath(),e.moveTo(k[0].x,k[0].y);for(const T of k.slice(1))e.lineTo(T.x,T.y);e.strokeStyle=v.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}Ft(e,t,s,i,b.legendY,[...p].reverse(),l)}function Hn(e,n,t,s,i,r,o,l){const a=m(n,"pieChart")||m(n,"pie3DChart"),c=m(n,"doughnutChart"),d=a||c,h=!!c,u=ue(d,"ser");if(!u.length)return;const p=u[0],g=jt(p).map(S=>typeof S=="number"&&S>0?S:0),b=Zt(p),_=Fs(p,o),y=g.reduce((S,$)=>S+$,0);if(!y)return;const w=Math.min(i,r)*.38,x=t+i*.44,P=s+r*.5,v=h?w*.55:0;let k=-Math.PI/2;for(let S=0;S<g.length;S++){if(!g[S])continue;const $=g[S]/y*Math.PI*2,R=_[S]||Qe(p,S,o),W=k+$/2,Q=S===0?w*.04:0,D=Q*Math.cos(W),U=Q*Math.sin(W);e.save(),e.beginPath(),e.moveTo(x+D,P+U),e.arc(x+D,P+U,w,k,k+$),e.closePath(),e.fillStyle=R,e.fill(),e.shadowColor="rgba(0,0,0,0.12)",e.shadowBlur=4*l,e.strokeStyle="#fff",e.lineWidth=1.5*l,e.stroke(),e.restore(),v>0&&(e.save(),e.beginPath(),e.arc(x,P,v,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.restore());const K=g[S]/y;if(K>.05){const J=x+D+w*.65*Math.cos(W),q=P+U+w*.65*Math.sin(W),I=Math.max(8,Math.min(13,w*.15))*l;e.save(),e.fillStyle="#fff",e.font=`bold ${I}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(Math.round(K*100)+"%",J,q),e.restore()}k+=$}if(h){const S=Math.max(10,Math.min(16,w*.22))*l;e.save(),e.font=`bold ${S}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="middle",e.fillText(Je(y),x,P),e.restore()}const T=t+i*.78,N=Math.max(8,Math.min(12,i*.022))*l;e.font=`${N}px sans-serif`,e.textBaseline="middle";const M=N*1.8,F=P-g.length*M/2;for(let S=0;S<g.length;S++){const $=T,R=F+S*M,W=_[S]||Qe(p,S,o);e.fillStyle=W,wt(e,$,R-N*.5,N*1.2,N),e.fill(),e.fillStyle="#444";const Q=String(b[S]??`Item ${S+1}`);e.fillText(Q,$+N*1.5,R)}}function fo(e,n,t,s,i,r,o,l){const a=m(n,"scatterChart")||m(n,"bubbleChart"),d=ue(a,"ser").map((k,T)=>{const N=gt(m(m(k,"xVal"),"numCache")),M=gt(m(m(k,"yVal"),"numCache")),F=gt(m(m(k,"bubbleSize"),"numCache"));return{name:Tt(k),color:Qe(k,T,o),points:N.map((S,$)=>({x:S,y:M[$],r:F[$]})).filter(S=>typeof S.x=="number"&&typeof S.y=="number")}});if(!d.length)return;const h=Jt(t,s,i,r,{hasLegend:d.length>1}),u=d.flatMap(k=>k.points.map(T=>T.x)),p=d.flatMap(k=>k.points.map(T=>T.y)),g=kt(u,!1),b=kt(p),_=Math.max(7,Math.min(11,h.w*.018))*l,y=Math.round((g.max-g.min)/g.step),w=Math.round((b.max-b.min)/b.step);e.font=`${_}px sans-serif`,e.save(),e.textAlign="center",e.fillStyle="#666";for(let k=0;k<=y;k++){const T=g.min+k*g.step,N=(T-g.min)/(g.max-g.min),M=h.x+N*h.w;Ze(e,M,h.y,M,h.y+h.h),e.fillText(Je(T),M,h.y+h.h+_*1.5)}e.textAlign="right";for(let k=0;k<=w;k++){const T=b.min+k*b.step,N=(T-b.min)/(b.max-b.min),M=h.y+h.h-N*h.h;Ze(e,h.x,M,h.x+h.w,M),e.fillText(Je(T),h.x-4*l,M)}e.restore(),Ee(e,h.x,h.y,h.x,h.y+h.h),Ee(e,h.x,h.y+h.h,h.x+h.w,h.y+h.h);const x=d.flatMap(k=>k.points.map(T=>T.r??1)),P=Math.max(...x.filter(k=>typeof k=="number"),1),v=Math.min(h.w,h.h)*.06;for(const k of d)for(const T of k.points){const N=h.x+(T.x-g.min)/(g.max-g.min)*h.w,M=h.y+h.h-(T.y-b.min)/(b.max-b.min)*h.h,F=T.r!=null?T.r/P*v:4*l;e.save(),e.fillStyle=k.color+"aa",e.strokeStyle=k.color,e.lineWidth=1*l,e.beginPath(),e.arc(N,M,F,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}d.length>1&&Ft(e,t,s,i,h.legendY,d,l)}function ho(e,n,t,s,i,r,o,l){const a=m(n,"radarChart"),c=ue(a,"ser"),d=c.map((w,x)=>({name:Tt(w),values:jt(w),color:Qe(w,x,o)}));if(!d.length)return;const h=Zt(c[0])||[],u=h.length||d[0]?.values.length||0;if(u<3)return;const p=t+i*.5,g=s+r*.5,b=Math.min(i,r)*.34,_=kt(d.flatMap(w=>w.values)),y=4;for(let w=1;w<=y;w++){const x=b*w/y;e.save(),e.beginPath();for(let P=0;P<u;P++){const v=P/u*Math.PI*2-Math.PI/2,k=p+x*Math.cos(v),T=g+x*Math.sin(v);P===0?e.moveTo(k,T):e.lineTo(k,T)}e.closePath(),e.strokeStyle="rgba(0,0,0,0.12)",e.lineWidth=.5,e.stroke(),e.restore()}for(let w=0;w<u;w++){const x=w/u*Math.PI*2-Math.PI/2;Ee(e,p,g,p+b*Math.cos(x),g+b*Math.sin(x));const P=p+(b+16*l)*Math.cos(x),v=g+(b+16*l)*Math.sin(x);e.save(),e.font=`${Math.max(7,11*l)}px sans-serif`,e.fillStyle="#555",e.textAlign="center",e.textBaseline="middle",e.fillText(String(h[w]??w+1),P,v),e.restore()}for(const w of d){const x=w.values.map((P,v)=>{const k=v/u*Math.PI*2-Math.PI/2,T=(P-_.min)/(_.max-_.min);return{x:p+b*T*Math.cos(k),y:g+b*T*Math.sin(k)}});e.save(),e.beginPath(),e.moveTo(x[0].x,x[0].y);for(const P of x.slice(1))e.lineTo(P.x,P.y);e.closePath(),e.fillStyle=w.color+"44",e.fill(),e.strokeStyle=w.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}Ft(e,t,s,i,s+r-20*l,d,l)}function po(e,n,t,s,i,r){const o=m(m(n,"chart"),"title");if(!o)return!1;const l=m(o,"tx");if(!l)return!1;let a="";for(const d of ue(l,"t"))a+=d.textContent;if(!a.trim())return!1;const c=Math.max(10,Math.min(16,i*.03))*r;return e.save(),e.font=`bold ${c}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="top",e.fillText(a,t+i/2,s+6*r),e.restore(),!0}function go(e,n,t,s,i,r,o,l){if(!n)return;const a=n;e.save(),e.fillStyle="#fff",wt(e,t,s,i,r,4*l),e.fill(),e.strokeStyle="#ddd",e.lineWidth=.5,e.stroke(),e.restore();const d=po(e,a,t,s,i,l)?s+Math.min(r*.08,24*l):s,h=r-(d-s),u=m(a,"plotArea");if(!u)return;const p=m(u,"bar3DChart")||m(u,"barChart"),g=m(u,"line3DChart")||m(u,"lineChart"),b=m(u,"area3DChart")||m(u,"areaChart"),_=m(u,"pie3DChart")||m(u,"pieChart"),y=m(u,"doughnutChart"),w=m(u,"scatterChart")||m(u,"bubbleChart"),x=m(u,"radarChart");if(p)lo(e,u,t,d,i,h,o,l);else if(g)co(e,u,t,d,i,h,o,l);else if(b)uo(e,u,t,d,i,h,o,l);else if(y)Hn(e,u,t,d,i,h,o,l);else if(_)Hn(e,u,t,d,i,h,o,l);else if(w)fo(e,u,t,d,i,h,o,l);else if(x)ho(e,u,t,d,i,h,o,l);else{e.save(),e.fillStyle="#aaa",e.font=`${12*l}px sans-serif`,e.textAlign="center",e.textBaseline="middle";const P=u.firstElementChild;e.fillText(P?.localName??"Chart",t+i/2,s+r/2),e.restore()}}function Xt(e,n,t=0,s=1){return(e?parseInt(e.getAttribute(n)||t,10):t)*s}function Ms(e,n){if(!e)return null;const t=ge(e);if(!t)return null;const s=ve(t,n);return s?pe(s):null}function mo(e,n,t,s,i,r,o){const l=m(n,"bevelT"),a=m(n,"bevelB"),c=l||a;if(!c)return;const d=Math.max(2*o,Xt(c,"w",76200,o)),h=Math.max(2*o,Xt(c,"h",76200,o)),p=O(c,"prst","circle").toLowerCase().includes("in"),g=Math.min(d,i*.3),b=Math.min(h,r*.3),_=p?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.35)",y=p?"rgba(255,255,255,0.20)":"rgba(0,0,0,0.20)",w=e.createLinearGradient(t,s,t,s+b);w.addColorStop(0,_),w.addColorStop(1,"rgba(255,255,255,0)"),e.save(),e.fillStyle=w,e.fillRect(t,s,i,b);const x=e.createLinearGradient(t,s+r-b,t,s+r);x.addColorStop(0,"rgba(0,0,0,0)"),x.addColorStop(1,y),e.fillStyle=x,e.fillRect(t,s+r-b,i,b);const P=e.createLinearGradient(t,s,t+g,s);P.addColorStop(0,_),P.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=P,e.fillRect(t,s,g,r);const v=e.createLinearGradient(t+i-g,s,t+i,s);v.addColorStop(0,"rgba(0,0,0,0)"),v.addColorStop(1,y),e.fillStyle=v,e.fillRect(t+i-g,s,g,r),e.restore()}function bo(e,n,t,s,i,r,o,l){const a=Xt(n,"extrusionH",0,l);if(a<1*l)return;const c=m(n,"extrusionClr")||m(n,"contourClr"),d=Ms(c,t)||"rgba(0,0,0,0.3)",h=Math.min(a/914400*72*l,Math.min(r,o)*.15),u=h*.7,p=h*.7;e.save(),e.fillStyle=d,e.beginPath(),e.moveTo(s+r,i),e.lineTo(s+r+u,i+p),e.lineTo(s+r+u,i+o+p),e.lineTo(s+r,i+o),e.closePath(),e.fill(),e.beginPath(),e.moveTo(s,i+o),e.lineTo(s+u,i+o+p),e.lineTo(s+r+u,i+o+p),e.lineTo(s+r,i+o),e.closePath(),e.fill(),e.restore()}function yo(e,n,t,s,i,r,o,l){const a=Xt(n,"contourW",0,l);if(a<.5)return;const c=m(n,"contourClr"),d=Ms(c,t)||"#888888",h=Math.max(.5,a/914400*72*l);e.save(),e.strokeStyle=d,e.lineWidth=h,e.strokeRect(s,i,r,o),e.restore()}function vo(e,n,t,s,i,r){if(!n)return()=>{};const o=m(n,"camera");if(!o)return()=>{};const l=O(o,"prst","orthographicFront"),a=m(o,"rot");if(l.toLowerCase().includes("orthographic")&&!a)return()=>{};const d=a?C(a,"lat",0)/6e4:0,h=a?C(a,"lon",0)/6e4:0;a&&C(a,"rev",0)/6e4;const u=d*Math.PI/180,p=h*Math.PI/180,g=Math.sin(p)*.15,b=Math.sin(u)*.08;return e.save(),e.transform(1,b,g,1,t*-g,s*-b),()=>e.restore()}function wo(e,n,t,s,i,r){if(!n)return;const o=m(n,"lightRig");if(!o)return;const l=O(o,"dir","t"),a=O(o,"rig","balanced"),c={t:{gx:t+i/2,gy:s},b:{gx:t+i/2,gy:s+r},l:{gx:t,gy:s+r/2},r:{gx:t+i,gy:s+r/2},tl:{gx:t,gy:s},tr:{gx:t+i,gy:s},bl:{gx:t,gy:s+r},br:{gx:t+i,gy:s+r}},{gx:d,gy:h}=c[l]||c.t,u=a==="flat"?.08:a==="balanced"?.14:a==="sunrise"?.2:a==="harsh"?.28:.12,p=Math.sqrt(i*i+r*r),g=e.createRadialGradient(d,h,0,d,h,p);g.addColorStop(0,`rgba(255,255,255,${u})`),g.addColorStop(.5,"rgba(255,255,255,0)"),g.addColorStop(1,`rgba(0,0,0,${u*.5})`),e.save(),e.fillStyle=g,e.fillRect(t,s,i,r),e.restore()}function ko(e,n,t,s,i,r,o,l){if(!n)return{applyCamera:()=>()=>{},overlay:()=>{}};const a=m(n,"sp3d")||m(n,"scene3d")?.parentNode&&null,c=m(n,"scene3d");a&&bo(e,a,t,s,i,r,o,l);const d=vo(e,c,s,i);return{overlay(){a&&(mo(e,a,s,i,r,o,l),yo(e,a,t,s,i,r,o,l)),c&&wo(e,c,s,i,r,o)},cleanup:d}}function xo(e){return e?!!(m(e,"sp3d")||m(e,"scene3d")):!1}async function xt(e,n,t,s,i,r,o,l,a){if(!n)return!1;const c=n.localName;if(c==="noFill")return!1;if(c==="solidFill"){const d=ge(n),h=ve(d,l);return h?(e.fillStyle=pe(h),e.fill(),!0):!1}if(c==="gradFill"){const d=m(n,"gsLst");if(!d)return!1;const h=ue(d,"gs").map(y=>{const w=C(y,"pos",0)/1e5,x=ge(y),P=ve(x,l);return{pos:w,color:P}}).sort((y,w)=>y.pos-w.pos);if(h.length<2)return!1;const u=m(n,"lin"),p=m(n,"path"),g=t+i/2,b=s+r/2;let _;if(u||!u&&!p){const x=(C(u,"ang",0)/6e4-90)*Math.PI/180,P=Math.cos(x),v=Math.sin(x),k=Math.abs(i*P)+Math.abs(r*v),T=g-k/2*P,N=b-k/2*v,M=g+k/2*P,F=b+k/2*v;_=e.createLinearGradient(T,N,M,F)}else{const y=m(p,"fillToRect"),w=C(y,"l",5e4)/1e5,x=C(y,"t",5e4)/1e5,P=C(y,"r",5e4)/1e5,v=C(y,"b",5e4)/1e5,k=t+i*(w+(1-w-P)/2),T=s+r*(x+(1-x-v)/2),N=Math.sqrt(i*i+r*r)/2;_=e.createRadialGradient(k,T,0,g,b,N)}for(const y of h)y.color&&_.addColorStop(y.pos,pe(y.color));return e.fillStyle=_,e.fill(),!0}if(c==="blipFill"){const d=m(n,"blip"),h=d?d.getAttribute("r:embed")||d.getAttribute("embed"):null;if(h&&a&&a[h]){const u=a[h],p=m(n,"stretch"),g=p?m(p,"fillRect"):null;let b=t,_=s,y=i,w=r;if(g){const k=C(g,"l",0)/1e5,T=C(g,"t",0)/1e5,N=C(g,"r",0)/1e5,M=C(g,"b",0)/1e5;b=t+i*k,_=s+r*T,y=i-i*k-i*N,w=r-r*T-r*M}if(m(n,"tile")){const k=e.createPattern(u,"repeat");if(k)return e.fillStyle=k,e.fill(),!0}const P=m(n,"alphaModFix")||m(d,"alphaModFix"),v=P?C(P,"amt",1e5)/1e5:1;return e.save(),e.clip(),v<1&&(e.globalAlpha=v),e.drawImage(u,b,_,y,w),e.restore(),!0}return!1}if(c==="pattFill"){const d=m(n,"fgClr"),h=m(n,"bgClr"),u=d?ve(ge(d),l):{r:0,g:0,b:0,a:1},p=h?ve(ge(h),l):{r:255,g:255,b:255,a:1},g=pe(u),b=pe(p),_=O(n,"prst","dotGrid");let y=null,w=null;try{w=typeof OffscreenCanvas<"u"?new OffscreenCanvas(8,8):document.createElement("canvas");const v=8;w.width=v,w.height=v,y=w.getContext("2d")}catch{}const x=8;if(!y)return e.fillStyle=pe(u),e.fill(),!0;switch(y.fillStyle=b,y.fillRect(0,0,x,x),y.fillStyle=g,_){case"smGrid":case"dotGrid":case"dotDmnd":for(let v=0;v<x;v+=2)for(let k=0;k<x;k+=2)y.fillRect(v,k,1,1);break;case"lgGrid":case"cross":y.fillRect(0,0,x,1),y.fillRect(0,0,1,x);break;case"diagBd":case"fwdDiag":for(let v=0;v<x*2;v++)y.fillRect(v%x,Math.floor(v/x)*2,1,1);break;case"bkDiag":case"ltDnDiag":for(let v=0;v<x*2;v++)y.fillRect(x-1-v%x,Math.floor(v/x)*2,1,1);break;case"horzBrick":case"horz":y.fillRect(0,x/2,x,1);break;case"vert":case"vertBrick":y.fillRect(x/2,0,1,x);break;case"smCheck":case"lgCheck":for(let v=0;v<x;v++)for(let k=0;k<x;k++)(v+k)%2===0&&y.fillRect(k,v,1,1);break;default:for(let v=0;v<x;v+=4)y.fillRect(v,v,2,2)}const P=e.createPattern(w,"repeat");return P?(e.fillStyle=P,e.fill(),!0):(e.fillStyle=pe(u,(u.a??1)*.4),e.fill(),!0)}return!1}async function Le(e,n){const t=n.split("/"),s=t.pop(),i=[...t,"_rels",s+".rels"].join("/"),r=e[i];if(!r)return{};const o=new TextDecoder().decode(r),l=xe(o),a={};for(const c of Array.from(l.getElementsByTagName("Relationship"))){const d=c.getAttribute("Id"),h=c.getAttribute("Target"),u=c.getAttribute("Type")||"",p=c.getAttribute("TargetMode")||"Internal";let g=h;if(p!=="External")if(h.startsWith("/"))g=h.slice(1);else{const b=n.split("/");b.pop();const _=h.split("/");for(const y of _)y===".."?b.pop():y!=="."&&b.push(y);g=b.join("/")}a[d]={target:h,fullPath:g,type:u,external:p==="External"}}return a}async function Gt(e,n){const t={},s=new Set(["png","jpg","jpeg","gif","webp","bmp","tiff","tif","svg"]);for(const[i,r]of Object.entries(n)){if(r.external)continue;const o=r.fullPath.split(".").pop().toLowerCase();if(s.has(o))try{const l=e[r.fullPath];if(!l)continue;const c={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",svg:"image/svg+xml"}[o]||"image/png",d=new Blob([l],{type:c}),h=URL.createObjectURL(d),u=await new Promise((p,g)=>{const b=new Image;b.onload=()=>p(b),b.onerror=()=>p(null),b.src=h});t[i]=u}catch{}}return t}function Ns(e,n,t){if(!e)return n*1.2;const s=m(e,"spcPct"),i=m(e,"spcPts");return s?n*(C(s,"val",1e5)/1e5):i?C(i,"val",0)/100*12700*(t||1):n*1.2}function _o(e,n,t,s){if(!e||m(e,"buNone"))return null;const i=m(e,"buChar"),r=m(e,"buAutoNum");if(!i&&!r)return null;let o=null;const l=m(e,"buClr");if(l){const g=ge(l);o=ve(g,t)}const a=m(e,"buSzPct"),c=m(e,"buSzPts");let d=1;a&&(d=C(a,"val",1e5)/1e5);const h=c?C(c,"val",0)/100:null;let u=null;const p=m(e,"buFont");if(p){const g=p.getAttribute("typeface");g&&(u=g)}return i?{type:"char",char:i.getAttribute("char")||"•",color:o,sizePct:d,sizePts:h,fontFamily:u}:r?{type:"autoNum",numType:r.getAttribute("type")||"arabicPeriod",startAt:C(r,"startAt",1),color:o,sizePct:d,sizePts:h,fontFamily:u}:null}function Po(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return Yn(n).toLowerCase()+".";case"romanUcPeriod":return Yn(n)+".";case"alphaLcParenR":return String.fromCharCode(96+n)+")";case"alphaUcParenR":return String.fromCharCode(64+n)+")";case"alphaLcPeriod":return String.fromCharCode(96+n)+".";case"alphaUcPeriod":return String.fromCharCode(64+n)+".";default:return n+"."}}function Yn(e){const n=[1e3,900,500,400,100,90,50,40,10,9,5,4,1],t=["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"];let s="";for(let i=0;i<n.length;i++)for(;e>=n[i];)s+=t[i],e-=n[i];return s}function So(e,n,t,s,i){if(!n)return;const r=e.font.match(/(d+(?:.d+)?)px/),o=r?parseFloat(r[1]):16,l=n.sizePts!=null?n.sizePts*(o/12):o*n.sizePct;e.save(),n.color&&(e.fillStyle=pe(n.color),e.strokeStyle=e.fillStyle);const a=n.fontFamily?'"'+n.fontFamily+'", sans-serif':e.font.split(/\d+px\s+/)[1]||"sans-serif";if(e.font=l+"px "+a,n.type==="char")e.fillText(n.char,t,s);else if(n.type==="autoNum"){const c=n.numType+":"+n.startAt;i[c]===void 0&&(i[c]=n.startAt);const d=Po(n.numType,i[c]);i[c]++,e.fillText(d,t,s)}e.restore()}async function Vt(e,n,t,s,i,r,o,l,a,c=1800){if(!n)return;const d=m(n,"bodyPr"),h=O(d,"anchor","t"),u=O(d,"wrap","square"),p=O(d,"vert","horz"),g=C(d,"lIns",91440)*o,b=C(d,"tIns",45720)*o,_=C(d,"rIns",91440)*o,y=C(d,"bIns",45720)*o,w=t+g,x=s+b,P=i-g-_,v=r-b-y,k=u!=="none",T=p==="vert"||p==="vert270"||p==="eaVert";T&&(e.save(),p==="vert270"?(e.translate(t+i,s),e.rotate(Math.PI/2)):(e.translate(t,s+r),e.rotate(-Math.PI/2)));const N=m(d,"normAutoFit")||m(n,"normAutoFit");m(d,"spAutoFit")||m(n,"spAutoFit");const M=N?N.getAttribute("fontScale"):null;let F=M?parseInt(M,10)/1e5:1;const S=m(n,"lstStyle"),$=S?m(S,"defRPr"):null;function R(q,I,Z,ee){const re=q?q.getAttribute(Z):null;if(re!==null&&re!=="")return re;const de=I?I.getAttribute(Z):null;if(de!==null&&de!=="")return de;const oe=$?$.getAttribute(Z):null;return oe!==null&&oe!==""?oe:ee}const W=ue(n,"p"),Q=[];let D=0;for(const q of W){const I=m(q,"pPr"),Z=O(I,"algn","l");C(I,"lvl",0);const ee=C(I,"marL",0)*o,re=C(I,"indent",0)*o,de=I?_o(I,ne,l):null,oe=m(I,"spcBef"),H=m(I,"spcAft"),me=m(I,"lnSpc"),ne=m(I,"defRPr");let se=c;if($){const L=$.getAttribute("sz");L&&(se=parseInt(L,10))}if(ne){const L=ne.getAttribute("sz");L&&(se=parseInt(L,10))}let fe=0,we=0;if(oe){const L=m(oe,"spcPct"),X=m(oe,"spcPts");L?fe=se*127*o*(C(L,"val",0)/1e5):X&&(fe=C(X,"val",0)*yt*o/100)}if(H){const L=m(H,"spcPct"),X=m(H,"spcPts");L?we=se*127*o*(C(L,"val",0)/1e5):X&&(we=C(X,"val",0)*yt*o/100)}const be=[];for(const L of q.children){const X=L.localName;(X==="r"||X==="br"||X==="fld")&&be.push(L)}if(be.length===0){const L=m(q,"endParaRPr"),V=C(L||ne,"sz",se)*127*o*F;Q.push({lines:[""],algn:Z,marL:ee,spaceBefore:fe,spaceAfter:we,szPx:V,lnSpc:me,runs:[],emptyPara:!0,bullet:de}),D+=fe+V*1.2+we;continue}let ye=[],le=[],z=0;for(const L of be){if(L.localName==="br"){ye.push({runs:le,maxSzPx:Math.max(z,se*127*o)}),le=[],z=0;continue}const X=m(L,"rPr"),V=m(L,"t");let ae=V?V.textContent:"";const ce=js(X,ne,o*F,a,se,$);e.font=ce.fontStr;const te=ce.szPx;te>z&&(z=te);const ke=ro(X,ne,l),Te=R(X,ne,"u","none")!=="none",Ne=R(X,ne,"strike","noStrike")!=="noStrike",Ae=parseInt(R(X,ne,"baseline","0"),10);if(k){const Mt=ae.split(" ");for(let cn=0;cn<Mt.length;cn++){const dn=Mt[cn];let Rn=re+ee;for(const Nt of le)e.font=Nt.fontInfo.fontStr,Rn+=e.measureText(Nt.text).width;e.font=ce.fontStr;const Js=e.measureText(dn).width,ei=le.length?e.measureText(" ").width:0;if(Rn+ei+Js>P&&le.length>0)ye.push({runs:le,maxSzPx:Math.max(z,te)}),le=[{text:dn,rPr:X,fontInfo:ce,color:ke,underline:Te,strikethrough:Ne,baseline:Ae}],z=te;else{if(le.length>0){const Nt={text:" ",rPr:X,fontInfo:ce,color:ke,underline:!1,strikethrough:!1,baseline:Ae};le.push(Nt)}le.push({text:dn,rPr:X,fontInfo:ce,color:ke,underline:Te,strikethrough:Ne,baseline:Ae})}}}else le.push({text:ae,rPr:X,fontInfo:ce,color:ke,underline:Te,strikethrough:Ne,baseline:Ae}),te>z&&(z=te)}le.length>0&&ye.push({runs:le,maxSzPx:Math.max(z,se*127*o)});const E=me?Ns(me,se*127*o*F,o):null;Q.push({lines:ye,algn:Z,marL:ee,indent:re,spaceBefore:fe,spaceAfter:we,lnSpcPx:E,emptyPara:!1,bullet:de});for(const L of ye)D+=fe+(E||L.maxSzPx*1.2)+we}if(N&&!M&&D>v&&v>0){let q=.3,I=1;for(let Z=0;Z<8;Z++){const ee=(q+I)/2;let re=0;for(const de of W){const oe=m(de,"pPr"),H=oe?m(oe,"defRPr"):null;let me=c;if($){const E=$.getAttribute("sz");E&&(me=parseInt(E,10))}if(H){const E=H.getAttribute("sz");E&&(me=parseInt(E,10))}const ne=Array.from(de.children).filter(E=>["r","br","fld"].includes(E.localName)),se=me*127*o*ee;if(ne.length===0){re+=se*1.2;continue}const fe=ne.reduce((E,L)=>{const X=m(L,"t");return E+(X?X.textContent.length:0)},0),we=P>0?P:i,be=fe>0?ne.reduce((E,L)=>{const X=m(L,"t");return E+(X?X.textContent:"")},"").slice(0,20):"W";e.font=`${se}px sans-serif`;const ye=be.length>0?e.measureText(be).width/be.length:se*.6,le=Math.max(1,Math.floor(we/ye)),z=Math.max(1,Math.ceil(fe/le));re+=z*se*1.2}re<=v?q=ee:I=ee}F=(q+I)/2}let U=x;h==="ctr"?U=x+(v-D)/2:h==="b"&&(U=x+v-D);let K=U;const J={};for(const q of Q){const{lines:I,algn:Z,marL:ee,indent:re,spaceBefore:de,spaceAfter:oe,lnSpcPx:H,emptyPara:me,bullet:ne}=q;if(K+=de,me){K+=I[0]?H||q.szPx*1.2:12*o,K+=oe;continue}for(const se of I){const{runs:fe,maxSzPx:we}=se,be=H||we*1.2,ye=K+we*.85;let le=0;for(const V of fe)e.font=V.fontInfo.fontStr,le+=e.measureText(V.text).width;let z=w+ee;Z==="ctr"?z=w+(P-le)/2:Z==="r"&&(z=w+P-le);const E=se===I[0];if(ne&&E){const V=w+ee+re;So(e,ne,V,ye,J)}let L=0;if(Z==="just"&&!(se===I[I.length-1])){let ae=0;for(const te of fe)e.font=te.fontInfo.fontStr,ae+=(te.text.match(/ /g)||[]).length;const ce=P-ee-le;ae>0&&ce>0&&(L=ce/ae)}const X=(V,ae,ce,te,ke,Te)=>{e.font=te.fontStr;const Ne=e.measureText(V).width;e.fillText(V,ae,ce);const Ae=Math.max(.5,te.szPx*.07);return ke&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Ae,e.beginPath(),e.moveTo(ae,ce+Ae*1.5),e.lineTo(ae+Ne,ce+Ae*1.5),e.stroke(),e.restore()),Te&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Ae,e.beginPath(),e.moveTo(ae,ce-te.szPx*.3),e.lineTo(ae+Ne,ce-te.szPx*.3),e.stroke(),e.restore()),Ne};for(const V of fe){const ae=V.color;e.fillStyle=ae?pe(ae):"#000000";let ce=ye,te=V.fontInfo;if(V.baseline!==0){const ke=te.szPx*.65,Te=`${te.italic?"italic ":""}${te.bold?"bold ":""}${ke}px "${te.family}", sans-serif`;te={...te,szPx:ke,fontStr:Te},V.baseline>0?ce=ye-V.fontInfo.szPx*.38:ce=ye+V.fontInfo.szPx*.12}if(L>0&&V.text.includes(" ")){e.font=te.fontStr;const ke=V.text.split(" ");for(let Te=0;Te<ke.length;Te++){const Ne=X(ke[Te],z,ce,te,V.underline,V.strikethrough);z+=Ne,Te<ke.length-1&&(e.font=te.fontStr,z+=e.measureText(" ").width+L)}}else{e.font=te.fontStr;const ke=e.measureText(V.text).width;X(V.text,z,ce,te,V.underline,V.strikethrough),z+=ke}}K+=be}K+=oe}T&&e.restore()}function As(e,n,t,s){const i=m(n,"effectLst");if(!i)return()=>{};const r=m(i,"outerShdw"),o=m(i,"innerShdw"),l=r||o;if(l){const c=C(l,"blurRad",38100)*s,d=C(l,"dist",38100)*s,u=C(l,"dir",27e5)/6e4*Math.PI/180,p=d*Math.cos(u),g=d*Math.sin(u),b=ge(l),_=ve(b,t),y=_?pe(_):"rgba(0,0,0,0.35)";e.shadowBlur=Math.min(c,40),e.shadowOffsetX=p,e.shadowOffsetY=g,e.shadowColor=y}const a=m(i,"glow");if(a){const c=C(a,"rad",0)*s,d=ge(a),h=ve(d,t);h&&(e.shadowBlur=Math.min(c,30),e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor=pe(h))}return()=>{e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor="transparent"}}async function en(e,n,t,s,i,r,o,l=null,a=null){const c=m(n,"spPr"),d=m(c,"xfrm");let h=0,u=0,p=0,g=0,b=0,_=!1,y=!1;if(d){const U=m(d,"off"),K=m(d,"ext");U&&(h=C(U,"x",0)*o,u=C(U,"y",0)*o),K&&(p=C(K,"cx",0)*o,g=C(K,"cy",0)*o),b=C(d,"rot",0)/6e4,_=O(d,"flipH","0")==="1",y=O(d,"flipV","0")==="1"}else{const U=Is(n,a);if(U)h=U.x*o,u=U.y*o,p=U.w*o,g=U.h*o;else return}if(p<=0||g<=0)return;if(l){const{grpOff:U,grpExt:K,chOff:J,chExt:q}=l,I=K.cx/q.cx,Z=K.cy/q.cy;h=U.x+(h/o-J.x)*I*o,u=U.y+(u/o-J.y)*Z*o,p=p*I,g=g*Z}const w=h+p/2,x=u+g/2;e.save(),(b!==0||_||y)&&(e.translate(w,x),b!==0&&e.rotate(b*Math.PI/180),_&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x));const P=m(c,"prstGeom"),v=m(c,"custGeom"),k=P?O(P,"prst","rect"):"rect",T={};if(P){const U=m(P,"avLst");if(U){let K=0;for(const J of ue(U,"gd")){const I=O(J,"fmla","").match(/val\s+(-?\d+)/);I&&(T[K]=parseInt(I[1])),K++}}}const N=()=>{const U=["noFill","solidFill","gradFill","blipFill","pattFill","grpFill"];for(const J of U){const q=m(c,J);if(q)return q}const K=m(n,"style");if(K){const J=m(K,"fillRef");if(J){if(C(J,"idx",1)===0)return xe("<noFill/>").documentElement;const I=ge(J);if(I)return xe('<solidFill xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'">'+I.outerHTML+"</solidFill>").documentElement}}return null},M=()=>{const U=m(c,"ln");if(U)return U;const K=m(n,"style");if(K){const J=m(K,"lnRef");if(J){if(C(J,"idx",1)===0)return null;const I=ge(J);if(I)return xe('<ln xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'"><solidFill>'+I.outerHTML+"</solidFill></ln>").documentElement}}return null};if(v){const U=m(v,"pathLst");if(U)for(const J of ue(U,"path")){const q=C(J,"w",1)||1,I=C(J,"h",1)||1,Z=p/q,ee=g/I;e.beginPath();for(const oe of J.children)switch(oe.localName){case"moveTo":{const H=m(oe,"pt");H&&e.moveTo(h+C(H,"x",0)*Z,u+C(H,"y",0)*ee);break}case"lnTo":{const H=m(oe,"pt");H&&e.lineTo(h+C(H,"x",0)*Z,u+C(H,"y",0)*ee);break}case"cubicBezTo":{const H=ue(oe,"pt");H.length>=3&&e.bezierCurveTo(h+C(H[0],"x",0)*Z,u+C(H[0],"y",0)*ee,h+C(H[1],"x",0)*Z,u+C(H[1],"y",0)*ee,h+C(H[2],"x",0)*Z,u+C(H[2],"y",0)*ee);break}case"quadBezTo":{const H=ue(oe,"pt");H.length>=2&&e.quadraticCurveTo(h+C(H[0],"x",0)*Z,u+C(H[0],"y",0)*ee,h+C(H[1],"x",0)*Z,u+C(H[1],"y",0)*ee);break}case"arcTo":{const H=C(oe,"wR",0)*Z,me=C(oe,"hR",0)*ee,ne=C(oe,"stAng",0)/6e4*Math.PI/180,se=C(oe,"swAng",0)/6e4*Math.PI/180,fe=e._lastX||h,we=e._lastY||u,be=fe-H*Math.cos(ne),ye=we-me*Math.sin(ne);H===me?e.arc(be,ye,H,ne,ne+se,se<0):e.ellipse(be,ye,H,me,0,ne,ne+se,se<0);break}case"close":e.closePath();break}const re=N();re&&await xt(e,re,h,u,p,g,o,i,s);const de=M();de&&at(e,de,i,o)}e.restore();const K=m(n,"txBody");if(K){e.save(),e.beginPath(),e.rect(h,u,p,g),e.clip();const J=yn(n);await Vt(e,K,h,u,p,g,o,i,r,J),e.restore()}return}e.beginPath(),Kt(e,k,h,u,p,g,T);const F=As(e,c,i,o),S=h,$=u,R=p,W=g,Q=xo(c)?ko(e,c,i,S,$,R,W,o):null;try{const U=N();let K=!1;U&&(K=await xt(e,U,h,u,p,g,o,i,s)),Q&&Q.overlay();const J=M();J?at(e,J,i,o):K||(k==="line"||k==="straightConnector1")&&(e.strokeStyle="#000",e.lineWidth=1,e.stroke())}finally{F(),Q?.cleanup&&Q.cleanup()}e.restore();const D=m(n,"txBody");if(D){e.save(),(b!==0||_||y)&&(e.translate(w,x),b!==0&&e.rotate(b*Math.PI/180),_&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x)),e.beginPath(),e.rect(h,u,p,g),e.clip();const U=yn(n);await Vt(e,D,h,u,p,g,o,i,r,U),e.restore()}}function yn(e,n){const t=m(e,"nvSpPr"),s=t?m(t,"nvPr"):null,i=s?m(s,"ph"):null;if(i){const r=O(i,"type","body");if(r==="title"||r==="ctrTitle")return 4400;if(r==="subTitle"||r==="body")return 2800}return 1800}function at(e,n,t,s){if(!n||m(n,"noFill"))return;const r=m(n,"solidFill"),o=m(n,"gradFill"),l=C(n,"w",12700),a=Math.max(.5,l*s);let c="#000000";if(r){const p=ge(r),g=ve(p,t);g&&(c=pe(g))}else o&&(c="#888888");const d=m(n,"prstDash"),h=d?O(d,"val","solid"):"solid",u=O(n,"cap","flat");switch(O(n,"cmpd","sng"),e.strokeStyle=c,e.lineWidth=a,e.lineCap=u==="rnd"?"round":u==="sq"?"square":"butt",e.lineJoin="round",h){case"dash":e.setLineDash([a*4,a*2]);break;case"dot":e.setLineDash([a,a*2]);break;case"dashDot":e.setLineDash([a*4,a*2,a,a*2]);break;case"lgDash":e.setLineDash([a*8,a*3]);break;case"lgDashDot":e.setLineDash([a*8,a*3,a,a*3]);break;default:e.setLineDash([])}e.stroke(),e.setLineDash([])}async function tn(e,n,t,s,i,r){const o=m(n,"spPr"),l=m(o,"xfrm");if(!l)return;const a=m(l,"off"),c=m(l,"ext");if(!a||!c)return;const d=C(a,"x",0)*r,h=C(a,"y",0)*r,u=C(c,"cx",0)*r,p=C(c,"cy",0)*r,g=C(l,"rot",0)/6e4,b=O(l,"flipH","0")==="1",_=O(l,"flipV","0")==="1";if(u<=0||p<=0)return;const y=m(n,"blipFill"),w=y?m(y,"blip"):null,x=w?w.getAttribute("r:embed")||w.getAttribute("embed"):null,P=d+u/2,v=h+p/2;if(e.save(),(g!==0||b||_)&&(e.translate(P,v),g!==0&&e.rotate(g*Math.PI/180),b&&e.scale(-1,1),_&&e.scale(1,-1),e.translate(-P,-v)),x&&s[x]){const k=s[x],T=m(o,"prstGeom"),N=T?O(T,"prst","rect"):"rect",M={};if(T){const $=m(T,"avLst");if($){let R=0;for(const W of ue($,"gd")){const Q=(O(W,"fmla","")||"").match(/val\s+(-?\d+)/);Q&&(M[R]=parseInt(Q[1])),R++}}}e.beginPath(),Kt(e,N,d,h,u,p,M),e.clip();const F=y?m(y,"srcRect"):null;if(F){const $=C(F,"l",0)/1e5,R=C(F,"t",0)/1e5,W=C(F,"r",0)/1e5,Q=C(F,"b",0)/1e5,D=k.naturalWidth*(1-$-W),U=k.naturalHeight*(1-R-Q);e.drawImage(k,k.naturalWidth*$,k.naturalHeight*R,D,U,d,h,u,p)}else e.drawImage(k,d,h,u,p);const S=m(o,"ln");S&&(e.beginPath(),Kt(e,N,d,h,u,p,M),at(e,S,i,r))}else e.fillStyle="#e0e0e0",e.fillRect(d,h,u,p),e.strokeStyle="#aaa",e.lineWidth=1,e.strokeRect(d,h,u,p),e.beginPath(),e.moveTo(d,h),e.lineTo(d+u,h+p),e.moveTo(d+u,h),e.lineTo(d,h+p),e.stroke();e.restore()}async function $s(e,n,t,s,i){const r=m(n,"xfrm");if(!r)return;const o=m(r,"off"),l=m(r,"ext");if(!o||!l)return;const a=C(o,"x",0)*i,c=C(o,"y",0)*i;C(l,"cx",0)*i,C(l,"cy",0)*i;const d=m(n,"graphic"),h=d?m(d,"graphicData"):null,u=h?m(h,"tbl"):null;if(!u)return;const p=m(u,"tblPr"),g=p?O(p,"bandRow","0")==="1":!1;p&&O(p,"bandCol","0");const b=p?O(p,"firstRow","0")==="1":!1,_=p?O(p,"lastRow","0")==="1":!1;p&&O(p,"firstCol","0"),p&&O(p,"lastCol","0");const y=m(u,"tblGrid"),w=ue(y,"gridCol").map(v=>C(v,"w",0)*i),x=ue(u,"tr");let P=c;for(let v=0;v<x.length;v++){const k=x[v],T=C(k,"h",457200)*i,N=ue(k,"tc");let M=a;const F=v===0,S=v===x.length-1,$=v%2===1;for(let R=0;R<N.length;R++){const W=N[R],Q=C(W,"gridSpan",1);O(W,"vMerge","0");let D=0;for(let I=0;I<Q;I++)D+=w[R+I]||0;const U=m(W,"tcPr"),K=U?["noFill","solidFill","gradFill","blipFill","pattFill"].map(I=>m(U,I)).find(Boolean):null;if(e.save(),e.beginPath(),e.rect(M,P,D,T),K)await xt(e,K,M,P,D,T,i,t,null);else{let I=null;b&&F?I=t.accent1?"#"+t.accent1.toLowerCase():"#4472C4":_&&S?I="#e0e0e0":g&&$&&(I="rgba(0,0,0,0.06)"),e.fillStyle=I||"transparent",I&&e.fill()}const J=[{el:m(U,"lnL"),x1:M,y1:P,x2:M,y2:P+T},{el:m(U,"lnR"),x1:M+D,y1:P,x2:M+D,y2:P+T},{el:m(U,"lnT"),x1:M,y1:P,x2:M+D,y2:P},{el:m(U,"lnB"),x1:M,y1:P+T,x2:M+D,y2:P+T}];for(const I of J)I.el?m(I.el,"noFill")||(e.beginPath(),e.moveTo(I.x1,I.y1),e.lineTo(I.x2,I.y2),at(e,I.el,t,i)):(e.beginPath(),e.strokeStyle="#cccccc",e.lineWidth=.5,e.moveTo(I.x1,I.y1),e.lineTo(I.x2,I.y2),e.stroke());e.restore();const q=m(W,"txBody");q&&(e.save(),e.beginPath(),e.rect(M,P,D,T),e.clip(),await Vt(e,q,M,P,D,T,i,t,s,1400),e.restore()),M+=D}P+=T}}async function nn(e,n,t,s,i,r,o){const l=m(n,"grpSpPr"),a=m(l,"xfrm");if(!a)return;const c=m(a,"off"),d=m(a,"ext"),h=m(a,"chOff"),u=m(a,"chExt");if(!c||!d||!h||!u)return;const p=C(a,"rot",0)/6e4,g=O(a,"flipH","0")==="1",b=O(a,"flipV","0")==="1",_={grpOff:{x:C(c,"x",0)*o,y:C(c,"y",0)*o},grpExt:{cx:C(d,"cx",0)*o,cy:C(d,"cy",0)*o},chOff:{x:C(h,"x",0),y:C(h,"y",0)},chExt:{cx:C(u,"cx",1),cy:C(u,"cy",1)}},y=_.grpOff.x+_.grpExt.cx/2,w=_.grpOff.y+_.grpExt.cy/2;e.save(),(p!==0||g||b)&&(e.translate(y,w),p!==0&&e.rotate(p*Math.PI/180),g&&e.scale(-1,1),b&&e.scale(1,-1),e.translate(-y,-w));for(const x of n.children){const P=x.localName;P==="sp"?await en(e,x,t,s,i,r,o,_):P==="pic"?await tn(e,x,t,s,i,o):P==="grpSp"?await nn(e,x,t,s,i,r,o):P==="graphicFrame"?await rn(e,x,i,r,o,files,t):P==="cxnSp"&&await sn(e,x,i,o)}e.restore()}function Qn(e,n,t,s,i,r,o,l,a){const c=m(n,t);if(!c)return;const d=c.getAttribute("type")||"none";if(d==="none")return;const h={sm:3,med:6,lg:9},u=Math.max(.5,C(n,"w",12700)*a),p=u*(h[c.getAttribute("w")||"med"]??6),g=u*(h[c.getAttribute("len")||"med"]??6),b=Math.atan2(o-i,r-s);switch(e.save(),e.fillStyle=e.strokeStyle,e.strokeStyle=e.strokeStyle,d){case"triangle":case"arrow":case"stealth":{const _=d==="arrow",y=d==="stealth"?g*.5:0;e.beginPath(),e.moveTo(s,i),e.lineTo(s+g*Math.cos(b)+p/2*Math.sin(b),i+g*Math.sin(b)-p/2*Math.cos(b)),_||e.lineTo(s+y*Math.cos(b),i+y*Math.sin(b)),e.lineTo(s+g*Math.cos(b)-p/2*Math.sin(b),i+g*Math.sin(b)+p/2*Math.cos(b)),e.closePath(),_?e.stroke():e.fill();break}case"diamond":{const _=g/2;e.beginPath(),e.moveTo(s,i),e.lineTo(s+_*Math.cos(b)+p/2*Math.sin(b),i+_*Math.sin(b)-p/2*Math.cos(b)),e.lineTo(s+g*Math.cos(b),i+g*Math.sin(b)),e.lineTo(s+_*Math.cos(b)-p/2*Math.sin(b),i+_*Math.sin(b)+p/2*Math.cos(b)),e.closePath(),e.fill();break}case"oval":{const _=g/2,y=p/2,w=s+_*Math.cos(b),x=i+_*Math.sin(b);e.beginPath(),e.save(),e.translate(w,x),e.rotate(b),e.scale(1,y/_),e.arc(0,0,_,0,Math.PI*2),e.restore(),e.fill();break}}e.restore()}async function sn(e,n,t,s){const i=m(n,"spPr"),r=m(i,"xfrm");if(!r)return;const o=m(r,"off"),l=m(r,"ext");if(!o||!l)return;const a=C(o,"x",0)*s,c=C(o,"y",0)*s,d=C(l,"cx",0)*s,h=C(l,"cy",0)*s,u=C(r,"rot",0)/6e4,p=O(r,"flipH","0")==="1",g=O(r,"flipV","0")==="1",b=a+d/2,_=c+h/2,y=m(i,"ln");e.save(),(u!==0||p||g)&&(e.translate(b,_),u!==0&&e.rotate(u*Math.PI/180),p&&e.scale(-1,1),g&&e.scale(1,-1),e.translate(-b,-_));const w=m(i,"prstGeom"),x=w?O(w,"prst","line"):"line",P=x==="line"||x==="straightConnector1";if(e.beginPath(),P){const v=p?a:a+d,k=g?c:c+h,T=p?a+d:a,N=g?c+h:c;e.moveTo(T,N),e.lineTo(v,k)}else Kt(e,x,a,c,d,h,{});if(y){if(at(e,y,t,s),P){const v=p?a+d:a,k=g?c+h:c,T=p?a:a+d,N=g?c:c+h;Qn(e,y,"headEnd",T,N,v,k,t,s),Qn(e,y,"tailEnd",v,k,T,N,t,s)}}else e.strokeStyle="#000",e.lineWidth=1,e.stroke();e.restore()}async function Es(e,n,t,s,i,r,o,l,a,c,d){const h=c*a,u=d*a,p=x=>{const P=m(x,"cSld");if(!P)return null;const v=m(P,"bg");if(!v)return null;const k=m(v,"bgPr"),T=m(v,"bgRef");return{bgPr:k,bgRef:T}},g=n?p(n):null,b=s?p(s):null,_=t?p(t):null,y=g||b||_;let w=!1;if(y){const{bgPr:x,bgRef:P}=y;if(x){const v=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const k of v){const T=m(x,k);if(T){e.beginPath(),e.rect(0,0,h,u);const N=y===_?Object.assign({},o):o;await xt(e,T,0,0,h,u,1,l,N)&&(w=!0);break}}}else if(P){C(P,"idx",0);const v=ge(P),k=ve(v,l);k&&(e.fillStyle=pe(k),e.fillRect(0,0,h,u),w=!0)}}w||(e.fillStyle="#ffffff",e.fillRect(0,0,h,u))}function Rs(e){const n={};for(const t of e){if(!t)continue;const s=m(t,"cSld"),i=s?m(s,"spTree"):null;if(i)for(const r of ue(i,"sp")){const o=m(r,"nvSpPr"),l=o?m(o,"nvPr"):null,a=l?m(l,"ph"):null;if(!a)continue;const c=O(a,"type","body"),d=O(a,"idx","0"),h=`${c}:${d}`;if(n[h])continue;const u=m(r,"spPr"),p=m(u,"xfrm");if(!p)continue;const g=m(p,"off"),b=m(p,"ext");!g||!b||(n[h]={x:C(g,"x",0),y:C(g,"y",0),w:C(b,"cx",0),h:C(b,"cy",0),txBody:m(r,"txBody")})}}return n}function Is(e,n){if(!n)return null;const t=m(e,"nvSpPr"),s=t?m(t,"nvPr"):null,i=s?m(s,"ph"):null;if(!i)return null;const r=O(i,"type","body"),o=O(i,"idx","0");return n[`${r}:${o}`]||n[`${r}:0`]||n[`body:${o}`]||null}async function rn(e,n,t,s,i,r,o){const l=m(n,"graphic"),a=l?m(l,"graphicData"):null,c=a?O(a,"uri",""):"";if(m(n,"tbl")||a&&m(a,"tbl"))return $s(e,n,t,s,i);const d=m(n,"xfrm");if(!d)return;const h=m(d,"off"),u=m(d,"ext");if(!h||!u)return;const p=C(h,"x",0)*i,g=C(h,"y",0)*i,b=C(u,"cx",0)*i,_=C(u,"cy",0)*i;if(b<=0||_<=0)return;const y=c.includes("chart"),w=c.includes("diagram");if(y&&r&&o){const P=a?m(a,"chart"):null,v=P?P.getAttribute("r:id")||P.getAttribute("id"):null,k=v?o[v]:null;if(k&&r[k.fullPath]){const T=new TextDecoder().decode(r[k.fullPath]),N=xe(T);go(e,N,p,g,b,_,t,i);return}}if(w&&r&&o){const P=a?m(a,"relIds"):null,v=P?P.getAttribute("r:dm")||P.getAttribute("dm"):null,k=v?o[v]:null;if(k&&r[k.fullPath]){const T=new TextDecoder().decode(r[k.fullPath]),N=xe(T),M=P?P.getAttribute("r:lo")||P.getAttribute("lo"):null,F=M?o[M]:null,S=F&&r[F.fullPath]?xe(new TextDecoder().decode(r[F.fullPath])):null,{renderSmartArt:$}=await Qt(async()=>{const{renderSmartArt:R}=await import("./smartart-CrK5frje.js");return{renderSmartArt:R}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]),import.meta.url);$(e,N,S,p,g,b,_,t,i);return}}const x=y?"📊 Chart":w?"🔷 Diagram":"⬛ Graphic";e.save(),e.fillStyle="#f4f4f8",e.strokeStyle="#ccccdd",e.lineWidth=1,e.fillRect(p,g,b,_),e.strokeRect(p,g,b,_),e.fillStyle="#999",e.font=`${Math.min(b*.07,16*i)}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(x,p+b/2,g+_/2),e.textAlign="start",e.textBaseline="alphabetic",e.restore()}async function zs(e,n,t,s,i,r,o,l,a){if(n)for(const c of n.children){const d=c.localName;try{d==="sp"?await en(e,c,t,s,i,r,o,null,l):d==="pic"?await tn(e,c,t,s,i,o):d==="grpSp"?await nn(e,c,t,s,i,r,o):d==="graphicFrame"?await rn(e,c,i,r,o,a,t):d==="cxnSp"&&await sn(e,c,i,o)}catch(h){console.warn("Error rendering shape:",d,h)}}}const To=Object.freeze(Object.defineProperty({__proto__:null,applyEffects:As,applyFill:xt,applyOutline:at,buildPlaceholderMap:Rs,computeLineHeight:Ns,getDefaultFontSize:yn,getRels:Le,loadImages:Gt,renderBackground:Es,renderConnector:sn,renderGraphicFrame:rn,renderGroupShape:nn,renderPicture:tn,renderShape:en,renderSpTree:zs,renderTable:$s,renderTextBody:Vt,resolvePlaceholderXfrm:Is},Symbol.toStringTag,{value:"Module"}));async function jo(e){const n=new CompressionStream("deflate-raw"),t=n.writable.getWriter(),s=n.readable.getReader();t.write(e),t.close();const i=[];let r=0;for(;;){const{value:a,done:c}=await s.read();if(c)break;i.push(a),r+=a.length}const o=new Uint8Array(r);let l=0;for(const a of i)o.set(a,l),l+=a.length;return o}const Fo=(()=>{const e=new Uint32Array(256);for(let n=0;n<256;n++){let t=n;for(let s=0;s<8;s++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t}return e})();function Co(e){let n=4294967295;for(let t=0;t<e.length;t++)n=Fo[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}class Mo{constructor(){this._chunks=[],this._size=0}append(n){this._chunks.push(n),this._size+=n.length}get size(){return this._size}concat(){const n=new Uint8Array(this._size);let t=0;for(const s of this._chunks)n.set(s,t),t+=s.length;return n}}function he(e){return new Uint8Array([e&255,e>>8&255])}function Re(e){return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}const Ds=new TextEncoder;function No(e){return Ds.encode(e)}const Zn=18977,Jn=0;class Ao{constructor(){this._entries=[]}async addText(n,t){return this.addBytes(n,Ds.encode(t))}async addBytes(n,t,s=!0){const i=No(n),r=Co(t),o=t.length;let l,a;if(s&&t.length>32){const c=await jo(t);c.length<t.length?(l=c,a=8):(l=t,a=0)}else l=t,a=0;this._entries.push({name:n,nameBytes:i,compData:l,uncompSize:o,crc:r,method:a,localOffset:0})}async finalize(){const n=new Mo;for(const i of this._entries)i.localOffset=n.size,n.append(new Uint8Array([80,75,3,4])),n.append(he(20)),n.append(he(2048)),n.append(he(i.method)),n.append(he(Jn)),n.append(he(Zn)),n.append(Re(i.crc)),n.append(Re(i.compData.length)),n.append(Re(i.uncompSize)),n.append(he(i.nameBytes.length)),n.append(he(0)),n.append(i.nameBytes),n.append(i.compData);const t=n.size;for(const i of this._entries)n.append(new Uint8Array([80,75,1,2])),n.append(he(798)),n.append(he(20)),n.append(he(2048)),n.append(he(i.method)),n.append(he(Jn)),n.append(he(Zn)),n.append(Re(i.crc)),n.append(Re(i.compData.length)),n.append(Re(i.uncompSize)),n.append(he(i.nameBytes.length)),n.append(he(0)),n.append(he(0)),n.append(he(0)),n.append(he(0)),n.append(Re(0)),n.append(Re(i.localOffset)),n.append(i.nameBytes);const s=n.size-t;return n.append(new Uint8Array([80,75,5,6])),n.append(he(0)),n.append(he(0)),n.append(he(this._entries.length)),n.append(he(this._entries.length)),n.append(Re(s)),n.append(Re(t)),n.append(he(0)),n.concat()}}async function $o(e){const n=new Ao;for(const[t,s]of Object.entries(e))typeof s=="string"?await n.addText(t,s):await n.addBytes(t,s);return n.finalize()}const Eo=new TextDecoder,Ls=new TextEncoder,_e={p:"http://schemas.openxmlformats.org/presentationml/2006/main",a:"http://schemas.openxmlformats.org/drawingml/2006/main",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",rel:"http://schemas.openxmlformats.org/package/2006/relationships",ct:"http://schemas.openxmlformats.org/package/2006/content-types"};function mt(e){return new DOMParser().parseFromString(e,"application/xml")}function Ro(e){const n=new XMLSerializer().serializeToString(e);return n.startsWith("<?xml")?n:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
|
|
35
|
+
`+n}function Me(e){return Ls.encode(Ro(e))}function ze(e,n){const t=e[n];return t?mt(Eo.decode(t)):null}function ie(e,n){if(!e)return null;const t=e.getElementsByTagName("*");for(let s=0;s<t.length;s++)if(t[s].localName===n)return t[s];return null}function De(e,n){if(!e)return[];const t=[],s=e.getElementsByTagName("*");for(let i=0;i<s.length;i++)s[i].localName===n&&t.push(s[i]);return t}function Io(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function Ye(e){const n=e.split("/"),t=n.pop();return[...n,"_rels",t+".rels"].join("/")}function He(e,n){const t=ze(e,Ye(n));if(!t)return{};const s={};for(const i of Array.from(t.getElementsByTagName("Relationship"))){const r=i.getAttribute("Id"),o=i.getAttribute("Target"),l=i.getAttribute("Type")||"";let a=o;if(!o.startsWith("/")&&!o.startsWith("http")){const c=n.split("/").slice(0,-1).join("/");a=c?c+"/"+o.replace(/^\.\.\//,""):o;const d=a.split("/"),h=[];for(const u of d)u===".."?h.pop():h.push(u);a=h.join("/")}s[r]={id:r,target:o,type:l,fullPath:a}}return s}function Et(e){const n=mt('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>'),t=n.documentElement;for(const s of Object.values(e)){const i=n.createElementNS(_e.rel,"Relationship");i.setAttribute("Id",s.id),i.setAttribute("Type",s.type),i.setAttribute("Target",s.target),s.targetMode&&i.setAttribute("TargetMode",s.targetMode),t.appendChild(i)}return n}function Rt(e){const n=Object.keys(e).map(t=>parseInt(t.replace("rId",""),10)).filter(t=>!isNaN(t));return"rId"+((n.length?Math.max(...n):0)+1)}function Wt(e,n){for(const t of e.children){const s=t.localName;if(s==="sp"||s==="pic"||s==="cxnSp"){const i=ie(t,"nvSpPr")||ie(t,"nvPicPr")||ie(t,"nvCxnSpPr"),r=i?ie(i,"cNvPr"):null;if(r&&(r.getAttribute("name")||"")===n)return t}else if(s==="grpSp"){const i=Wt(t,n);if(i)return i}}return null}function nt(e){const n=ie(e,"cSld");return n?ie(n,"spTree"):null}function It(e,n,t,s=!0){for(const i of De(e,"t")){const r=i.textContent;if(!r)continue;const o=s?r.split(n).join(t):r.replace(new RegExp(zo(n),"gi"),t);o!==r&&(i.textContent=o)}}function zo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const es={"image/jpeg":"jpeg","image/jpg":"jpeg","image/png":"png","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"},Do={jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml"};function ts(e,n,t){const s="[Content_Types].xml",i=ze(e,s);if(!i)return;const r=i.documentElement;for(const l of De(i,"Override"))if(l.getAttribute("PartName")==="/"+t)return;const o=i.createElementNS(_e.ct,"Override");o.setAttribute("PartName","/"+t),o.setAttribute("ContentType",Do[n]||"application/octet-stream"),r.appendChild(o),e[s]=Me(i)}class Ht{constructor(n){this._files=n,this._presPath="ppt/presentation.xml",this._presDoc=ze(n,this._presPath),this._presRels=He(n,this._presPath),this._slidePaths=this._buildSlidePaths()}static fromRenderer(n){const t={};for(const[s,i]of Object.entries(n._files))t[s]=i instanceof Uint8Array?i.slice():i;return new Ht(t)}static async fromBytes(n){const t=await Ss(n);return new Ht(t)}_buildSlidePaths(){if(!this._presDoc)return[];const n=ie(this._presDoc,"sldIdLst");if(!n)return[];const t=[];for(const s of n.children){if(s.localName!=="sldId")continue;const i=s.getAttribute("r:id")||s.getAttribute("id"),r=this._presRels[i];r&&t.push(r.fullPath)}return t}_savePresDoc(){this._files[this._presPath]=Me(this._presDoc)}_savePresRels(){this._files[Ye(this._presPath)]=Me(Et(this._presRels))}getSlidePaths(){return[...this._slidePaths]}getSlideCount(){return this._slidePaths.length}_slideDoc(n){const t=this._slidePaths[n];if(!t)throw new RangeError(`Slide ${n} out of range`);return ze(this._files,t)}_saveSlideDoc(n,t){this._files[this._slidePaths[n]]=Me(t)}applyTemplate(n,t={}){const{open:s="{{",close:i="}}",slides:r}=t,o=r??this._slidePaths.map((l,a)=>a);for(const l of o){const a=this._slideDoc(l);for(const[c,d]of Object.entries(n)){const h=s+c+i;It(a,h,String(d))}this._saveSlideDoc(l,a)}for(const l of o)this._applyTemplateToNotes(l,n,s,i)}_applyTemplateToNotes(n,t,s,i){const r=He(this._files,this._slidePaths[n]),o=Object.values(r).find(a=>a.type?.includes("notesSlide"));if(!o)return;const l=ze(this._files,o.fullPath);if(l){for(const[a,c]of Object.entries(t))It(l,s+a+i,String(c));this._files[o.fullPath]=Me(l)}}replaceText(n,t,s={}){const{caseSensitive:i=!0,includeNotes:r=!1,slides:o}=s,l=o??this._slidePaths.map((a,c)=>c);for(const a of l){const c=this._slideDoc(a);if(It(c,n,t,i),this._saveSlideDoc(a,c),r){const d=He(this._files,this._slidePaths[a]),h=Object.values(d).find(u=>u.type?.includes("notesSlide"));if(h){const u=ze(this._files,h.fullPath);u&&(It(u,n,t,i),this._files[h.fullPath]=Me(u))}}}}setShapeText(n,t,s,i={}){const{preserveFormatting:r=!0}=i,o=this._slideDoc(n),l=nt(o);if(!l)return this;const a=Wt(l,t);if(!a)throw new Error(`Shape "${t}" not found on slide ${n}`);const c=ie(a,"txBody");if(!c)return this;const d=ie(c,"r"),h=d?ie(d,"rPr"):null,u=ie(ie(c,"p"),"pPr");for(const b of De(c,"p"))b.parentNode.removeChild(b);const p=s.split(`
|
|
36
|
+
`),g=_e.a;for(const b of p){const _=o.createElementNS(g,"a:p");u&&r&&_.appendChild(u.cloneNode(!0));const y=o.createElementNS(g,"a:r");h&&r&&y.appendChild(h.cloneNode(!0));const w=o.createElementNS(g,"a:t");w.textContent=b,y.appendChild(w),_.appendChild(y),c.appendChild(_)}return this._saveSlideDoc(n,o),this}getShapeText(n,t){const s=this._slideDoc(n),i=nt(s);if(!i)return"";const r=Wt(i,t);return r?De(r,"t").map(o=>o.textContent).join(""):""}addTextBox(n,t,s={}){const{x:i=914400,y:r=914400,w:o=4572e3,h:l=914400,color:a="000000",fontSize:c=1800,bold:d=!1,align:h="l",fontFamily:u="Calibri"}=s,p=this._slideDoc(n),g=nt(p);if(!g)return this;const _=Math.max(0,...De(g,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,y=`TextBox ${_}`,w=_e.a,P=`<p:sp xmlns:p="${_e.p}" xmlns:a="${w}">
|
|
37
|
+
<p:nvSpPr>
|
|
38
|
+
<p:cNvPr id="${_}" name="${y}"/>
|
|
39
|
+
<p:cNvSpPr txBox="1"><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
40
|
+
<p:nvPr/>
|
|
41
|
+
</p:nvSpPr>
|
|
42
|
+
<p:spPr>
|
|
43
|
+
<a:xfrm><a:off x="${i}" y="${r}"/><a:ext cx="${o}" cy="${l}"/></a:xfrm>
|
|
44
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
45
|
+
<a:noFill/>
|
|
46
|
+
</p:spPr>
|
|
47
|
+
<p:txBody>
|
|
48
|
+
<a:bodyPr wrap="square" rtlCol="0"><a:spAutoFit/></a:bodyPr>
|
|
49
|
+
<a:lstStyle/>
|
|
50
|
+
<a:p>
|
|
51
|
+
<a:pPr algn="${h}"/>
|
|
52
|
+
<a:r>
|
|
53
|
+
<a:rPr lang="en-US" sz="${c}" b="${d?1:0}" dirty="0">
|
|
54
|
+
<a:solidFill><a:srgbClr val="${a}"/></a:solidFill>
|
|
55
|
+
<a:latin typeface="${u}"/>
|
|
56
|
+
</a:rPr>
|
|
57
|
+
<a:t>${t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</a:t>
|
|
58
|
+
</a:r>
|
|
59
|
+
</a:p>
|
|
60
|
+
</p:txBody>
|
|
61
|
+
</p:sp>`,v=mt(P);return g.appendChild(p.adoptNode(v.documentElement)),this._saveSlideDoc(n,p),this}async setShapeImage(n,t,s,i="image/jpeg"){const r=this._slideDoc(n),o=nt(r);if(!o)return this;const l=Wt(o,t);if(!l)throw new Error(`Shape "${t}" not found on slide ${n}`);const a=He(this._files,this._slidePaths[n]),c=ie(l,"blipFill"),d=c?ie(c,"blip"):null,h=d?d.getAttribute("r:embed")||d.getAttribute("embed"):null,u=h?a[h]:null,p=es[i]||"jpeg",g=Object.keys(this._files).filter(y=>y.startsWith("ppt/media/")).length+1,b=`ppt/media/image${g}.${p}`;this._files[b]=s;let _;return h&&u?(_=h,a[_]={id:_,type:u.type,target:`../media/image${g}.${p}`,fullPath:b}):(_=Rt(a),a[_]={id:_,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${g}.${p}`,fullPath:b}),d&&d.setAttribute("r:embed",_),this._files[Ye(this._slidePaths[n])]=Me(Et(a)),this._saveSlideDoc(n,r),ts(this._files,p,b),this}async addImage(n,t,s="image/jpeg",i={}){const{x:r=914400,y:o=914400,w:l=2743200,h:a=2057400}=i,c=es[s]||"jpeg",d=Object.keys(this._files).filter(k=>k.startsWith("ppt/media/")).length+1,h=`ppt/media/image${d}.${c}`;this._files[h]=t;const u=He(this._files,this._slidePaths[n]),p=Rt(u);u[p]={id:p,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${d}.${c}`,fullPath:h},this._files[Ye(this._slidePaths[n])]=Me(Et(u));const g=this._slideDoc(n),b=nt(g);if(!b)return this;const y=Math.max(0,...De(b,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,w=_e.a,P=`<p:pic xmlns:p="${_e.p}" xmlns:a="${w}" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
62
|
+
<p:nvPicPr>
|
|
63
|
+
<p:cNvPr id="${y}" name="Picture ${y}"/>
|
|
64
|
+
<p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>
|
|
65
|
+
<p:nvPr/>
|
|
66
|
+
</p:nvPicPr>
|
|
67
|
+
<p:blipFill>
|
|
68
|
+
<a:blip r:embed="${p}"/>
|
|
69
|
+
<a:stretch><a:fillRect/></a:stretch>
|
|
70
|
+
</p:blipFill>
|
|
71
|
+
<p:spPr>
|
|
72
|
+
<a:xfrm><a:off x="${r}" y="${o}"/><a:ext cx="${l}" cy="${a}"/></a:xfrm>
|
|
73
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
74
|
+
</p:spPr>
|
|
75
|
+
</p:pic>`,v=mt(P);return b.appendChild(g.adoptNode(v.documentElement)),this._saveSlideDoc(n,g),ts(this._files,c,h),this}setSlideBackground(n,t){const s=this._slideDoc(n),i=ie(s,"cSld");if(!i)return this;const r=ie(i,"bg");r&&i.removeChild(r);const o=_e.a,a=`<p:bg xmlns:p="${_e.p}" xmlns:a="${o}">
|
|
76
|
+
<p:bgPr><a:solidFill><a:srgbClr val="${t}"/></a:solidFill>
|
|
77
|
+
<a:effectLst/></p:bgPr></p:bg>`,c=s.adoptNode(mt(a).documentElement);return i.insertBefore(c,i.firstChild),this._saveSlideDoc(n,s),this}setThemeColor(n,t){const s=this._presRels;let i=Object.values(s).find(l=>l.type?.includes("theme"))?.fullPath;if(!i){const l=Object.values(s).find(a=>a.type?.includes("slideMaster"));if(l){const a=He(this._files,l.fullPath);i=Object.values(a).find(c=>c.type?.includes("theme"))?.fullPath}}if(!i)return this;const r=ze(this._files,i);if(!r)return this;ie(r,"fmtScheme");const o=ie(r,"clrScheme");if(!o)return this;for(const l of o.children)if(l.localName===n){const a=ie(l,"srgbClr");if(a)a.setAttribute("val",t);else{for(;l.firstChild;)l.removeChild(l.firstChild);const c=_e.a,d=r.createElementNS(c,"a:srgbClr");d.setAttribute("val",t),l.appendChild(d)}break}return this._files[i]=Me(r),this}duplicateSlide(n,t){const s=t??this._slidePaths.length,i=this._slidePaths[n];if(!i)throw new RangeError(`Slide ${n} out of range`);const r=Object.keys(this._files).map(b=>b.match(/ppt\/slides\/slide(\d+)\.xml/)).filter(Boolean).map(b=>parseInt(b[1],10)),o=(r.length?Math.max(...r):0)+1,l=`ppt/slides/slide${o}.xml`,a=Ye(l);this._files[l]=this._files[i].slice();const c=Ye(i);this._files[c]&&(this._files[a]=this._files[c].slice());const d=Rt(this._presRels),h=`slides/slide${o}.xml`;this._presRels[d]={id:d,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",target:h,fullPath:l},this._savePresRels();const u=ie(this._presDoc,"sldIdLst");if(u){const b=De(u,"sldId").map(P=>parseInt(P.getAttribute("id")||"0",10)),_=(b.length?Math.max(...b):255)+1,y=_e.p,w=this._presDoc.createElementNS(y,"p:sldId");w.setAttribute("id",String(_)),w.setAttributeNS(_e.r,"r:id",d);const x=Array.from(u.children);s>=x.length?u.appendChild(w):u.insertBefore(w,x[s])}this._savePresDoc(),this._slidePaths=this._buildSlidePaths();const p="[Content_Types].xml",g=ze(this._files,p);if(g){const b=g.documentElement,_=g.createElementNS(_e.ct,"Override");_.setAttribute("PartName","/"+l),_.setAttribute("ContentType","application/vnd.openxmlformats-officedocument.presentationml.slide+xml"),b.appendChild(_),this._files[p]=Me(g)}return this}removeSlide(n){if(this._slidePaths.length<=1)throw new Error("Cannot remove the last slide");const t=this._slidePaths[n];if(!t)throw new RangeError(`Slide ${n} out of range`);const s=ie(this._presDoc,"sldIdLst");if(s)for(const i of Array.from(s.children)){const r=i.getAttribute("r:id")||i.getAttribute("id"),o=this._presRels[r];if(o&&o.fullPath===t){s.removeChild(i),delete this._presRels[r];break}}return this._savePresDoc(),this._savePresRels(),this._slidePaths=this._buildSlidePaths(),this}reorderSlides(n){if(n.length!==this._slidePaths.length)throw new Error("newOrder must have the same length as the current slide count");const t=ie(this._presDoc,"sldIdLst");if(!t)return this;const s=Array.from(t.children).filter(i=>i.localName==="sldId");for(const i of s)t.removeChild(i);for(const i of n)s[i]&&t.appendChild(s[i]);return this._savePresDoc(),this._slidePaths=this._buildSlidePaths(),this}setSlideNotes(n,t){const s=this._slidePaths[n],i=He(this._files,s),r=Object.values(i).find(o=>o.type?.includes("notesSlide"));if(r){const o=ze(this._files,r.fullPath);if(o){for(const l of De(o,"sp")){const a=ie(ie(l,"nvSpPr"),"nvPr"),c=a?ie(a,"ph"):null;if(c&&Io(c,"type")!=="sldNum"){for(const h of De(l,"t"))h.textContent="";const d=ie(l,"t");d&&(d.textContent=t);break}}this._files[r.fullPath]=Me(o)}}else this._createNotesSlide(n,s,i,t);return this}_createNotesSlide(n,t,s,i){const r=Object.keys(this._files).filter(h=>h.startsWith("ppt/notesSlides/")).length+1,o=_e.p,l=_e.a,a=`ppt/notesSlides/notesSlide${r}.xml`,c=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
78
|
+
<p:notes xmlns:p="${o}" xmlns:a="${l}">
|
|
79
|
+
<p:cSld><p:spTree>
|
|
80
|
+
<p:sp>
|
|
81
|
+
<p:nvSpPr><p:cNvPr id="2" name="Notes Placeholder 1"/>
|
|
82
|
+
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
83
|
+
<p:nvPr><p:ph type="body" idx="1"/></p:nvPr>
|
|
84
|
+
</p:nvSpPr>
|
|
85
|
+
<p:spPr/>
|
|
86
|
+
<p:txBody><a:bodyPr/><a:lstStyle/>
|
|
87
|
+
<a:p><a:r><a:t>${i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</a:t></a:r></a:p>
|
|
88
|
+
</p:txBody>
|
|
89
|
+
</p:sp>
|
|
90
|
+
</p:spTree></p:cSld>
|
|
91
|
+
</p:notes>`;this._files[a]=Ls.encode(c);const d=Rt(s);s[d]={id:d,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",target:`../notesSlides/notesSlide${r}.xml`,fullPath:a},this._files[Ye(t)]=Me(Et(s))}async save(){return $o(this._files)}async download(n="edited.pptx"){const t=await this.save(),s=new Blob([t],{type:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}),i=URL.createObjectURL(s),r=document.createElement("a");r.href=i,r.download=n,r.click(),setTimeout(()=>URL.revokeObjectURL(i),1e4)}listShapes(n){const t=this._slideDoc(n),s=nt(t);if(!s)return[];const i=[];for(const r of s.children){const o=r.localName;if(!["sp","pic","cxnSp","graphicFrame"].includes(o))continue;const l=ie(r,"nvSpPr")||ie(r,"nvPicPr")||ie(r,"nvGraphicFramePr")||ie(r,"nvCxnSpPr"),a=l?ie(l,"cNvPr"):null;i.push({id:a?.getAttribute("id")||"",name:a?.getAttribute("name")||"",type:o})}return i}}const Bs=new TextEncoder;function Lo(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}class Bo{constructor(){this._parts=[],this._size=0}write(n){const t=typeof n=="string"?Bs.encode(n):n;return this._parts.push(t),this._size+=t.length,this._size}get size(){return this._size}concat(){const n=new Uint8Array(this._size);let t=0;for(const s of this._parts)n.set(s,t),t+=s.length;return n}}async function Oo(e,n=.92){if(typeof e.convertToBlob=="function"){const s=await(await e.convertToBlob({type:"image/jpeg",quality:n})).arrayBuffer();return new Uint8Array(s)}return new Promise((t,s)=>{e.toBlob(i=>{if(!i){s(new Error("canvas.toBlob failed"));return}i.arrayBuffer().then(r=>t(new Uint8Array(r))).catch(s)},"image/jpeg",n)})}async function Uo(e,n,t){const{cx:s,cy:i}=e.slideSize,r=Math.round(t*i/s),o=typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,r):Object.assign(document.createElement("canvas"),{width:t,height:r});return await e.renderSlide(n,o,t),o}function Go(e,n){const t=e/914400*72,s=n/914400*72;return{w:t,h:s}}class Wo{constructor(){this._buf=new Bo,this._xref=[],this._objNum=0}_nextObj(){return++this._objNum}_writeObj(n,t,s=null){const i=this._buf.size;if(this._xref[n]=i,this._buf.write(`${n} 0 obj
|
|
92
|
+
`),s){const r=s.length;this._buf.write(`${t.replace("__LEN__",r)}
|
|
93
|
+
`),this._buf.write(`stream\r
|
|
94
|
+
`),this._buf.write(s),this._buf.write(`\r
|
|
95
|
+
endstream
|
|
96
|
+
`)}else this._buf.write(`${t}
|
|
97
|
+
`);return this._buf.write(`endobj
|
|
98
|
+
|
|
99
|
+
`),n}_reserveObjs(n){const t=this._objNum+1;return this._objNum+=n,t}async build(n,t={}){const{widthPx:s=1920,quality:i=.92,slideList:r=null,onProgress:o=null}=t,l=r??Array.from({length:n.slideCount},(v,k)=>k),a=l.length,{cx:c,cy:d}=n.slideSize,{w:h,h:u}=Go(c,d);this._buf.write(`%PDF-1.4
|
|
100
|
+
`),this._buf.write(`%ÿþýü
|
|
101
|
+
|
|
102
|
+
`);const p=this._nextObj(),g=this._nextObj(),b=Array.from({length:a},()=>this._nextObj()),_=Array.from({length:a},()=>this._nextObj()),y=Array.from({length:a},()=>this._nextObj());this._writeObj(p,`<< /Type /Catalog /Pages ${g} 0 R >>`);const w=b.map(v=>`${v} 0 R`).join(" ");this._writeObj(g,`<< /Type /Pages /Kids [${w}] /Count ${a} >>`);for(let v=0;v<a;v++){const k=l[v];o?.(v,a);const T=await Uo(n,k,s),N=await Oo(T,i),M=T.width,F=T.height;this._writeObj(b[v],`<< /Type /Page /Parent ${g} 0 R /MediaBox [0 0 ${h.toFixed(3)} ${u.toFixed(3)}] /Resources << /XObject << /Im${v} ${_[v]} 0 R >> >> /Contents ${y[v]} 0 R >>`),this._writeObj(_[v],`<< /Type /XObject /Subtype /Image /Width ${M} /Height ${F} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length __LEN__ >>`,N);const S=`q ${h.toFixed(3)} 0 0 ${u.toFixed(3)} 0 0 cm /Im${v} Do Q`;this._writeObj(y[v],"<< /Length __LEN__ >>",Bs.encode(S))}o?.(a,a);const x=this._buf.size,P=this._objNum+1;this._buf.write(`xref
|
|
103
|
+
0 ${P}
|
|
104
|
+
`),this._buf.write(`0000000000 65535 f \r
|
|
105
|
+
`);for(let v=1;v<P;v++){const k=this._xref[v]??0;this._buf.write(String(k).padStart(10,"0")+` 00000 n \r
|
|
106
|
+
`)}return this._buf.write(`trailer
|
|
107
|
+
<< /Size ${P} /Root ${p} 0 R >>
|
|
108
|
+
`),this._buf.write(`startxref
|
|
109
|
+
${x}
|
|
110
|
+
%%EOF
|
|
111
|
+
`),this._buf.concat()}}async function An(e,n={}){const{width:t=null,dpi:s=150,quality:i=.92,slides:r=null,onProgress:o=null}=n,l=t??Lo(e,s);return new Wo().build(e,{widthPx:l,quality:i,slideList:r,onProgress:o})}async function qo(e,n="presentation.pdf",t={}){const s=await An(e,t),i=new Blob([s],{type:"application/pdf"}),r=URL.createObjectURL(i),o=document.createElement("a");o.href=r,o.download=n,o.click(),setTimeout(()=>URL.revokeObjectURL(r),1e4)}async function Ko(e,n,t={}){return An(n,{...t,slides:[e]})}const Xo=500;function $n(e){if(!e)return[];const n=m(e,"timing");if(!n)return[];const t=m(n,"tnLst");if(!t)return[];const s=[];function i(o,l,a){const c=m(o,"cTn");if(!c)return;const d=O(c,"nodeType","");d==="clickEffect"&&(l+=1),d==="withEffect"&&l===0&&(l=0);const h=C(c,"delay",0)+a,u=m(o,"childTnLst")||m(c,"childTnLst");if(u)for(const p of u.children){const g=p.localName;if(g==="par")i(p,l,h);else if(g==="seq"){const b=m(p,"cTn"),y=(b?O(b,"nodeType",""):"")==="clickEffect"?l+1:l,w=m(p,"childTnLst");if(w)for(const x of w.children)x.localName==="par"&&i(x,y,h)}else if(g==="set"||g==="animEffect"||g==="anim"||g==="animScale"||g==="animClr"){const b=ns(p,l,h);b&&s.push(b)}}}function r(o,l){const a=m(o,"childTnLst")||m(m(o,"cTn"),"childTnLst");if(!a)return;let c=l;for(const d of a.children)if(d.localName==="par"){const h=m(d,"cTn"),u=h?O(h,"nodeType",""):"";(u==="clickEffect"||u==="clickPar")&&c++,i(d,c,0)}}for(const o of t.children)o.localName==="par"?i(o,0,0):o.localName==="seq"&&r(o,0);for(const o of ue(t,"animEffect")){const l=ns(o,0,0);l&&s.push(l)}return s.sort((o,l)=>o.clickNum-l.clickNum||o.delay-l.delay)}function ns(e,n,t){const s=m(e,"cTn"),i=m(e,"tgt")||m(s,"tgt"),r=i?m(i,"spTgt"):null,o=r?O(r,"spid",null):null;if(!o)return null;const l=s?O(s,"dur",null):null,a=l==="indefinite"?2e3:l?parseInt(l,10):Xo,c=(s?C(s,"delay",0):0)+t,d=O(e,"filter",null),h=O(e,"type",null)||(d?"filter":"set"),u=O(e,"dir",null)||(d?d.split("(")[1]?.replace(")",""):null)||"";let p="emphasis";(h==="in"||e.localName==="set"&&O(m(e,"attrNameLst")||e,"attrName","")==="style.visibility"&&O(e,"to","")==="visible")&&(p="entrance"),(h==="out"||e.localName==="set"&&O(e,"to","")==="hidden")&&(p="exit");let g=d||e.localName;if(d){const b=d.toLowerCase();b.includes("fade")?g="fade":b.includes("fly")?g="fly":b.includes("appear")?g="appear":b.includes("zoom")?g="zoom":b.includes("wipe")?g="wipe":b.includes("wheel")?g="wheel":b.includes("blinds")?g="blinds":b.includes("box")?g="box":b.includes("dissolve")?g="dissolve":b.includes("split")?g="split":b.includes("stretch")?g="stretch":b.includes("diamond")?g="diamond":b.includes("plus")?g="plus":b.includes("wedge")?g="wedge":b.includes("random")?g="dissolve":b.includes("strips")?g="strips":b.includes("peek")?g="fly":b.includes("checkerboard")?g="dissolve":g="fade"}return{shapeId:o,type:p,effect:g,clickNum:n,delay:c,duration:a,dir:u,raw:e.localName}}function En(e){if(!e)return null;const n=m(e,"transition");if(!n)return null;const t=C(n,"dur",700),s=O(n,"spd","med"),i=s==="slow"?1200:s==="fast"?300:t,r=n.firstElementChild,o=r?.localName||"fade",l=r?O(r,"dir","l"):"l";return{type:o,duration:i,dir:l}}function Vo(e){return 1-Math.pow(1-e,2)}function Ho(e){return e*e}function Yo(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}function Os(e,n,t,s){const i=Math.max(0,Math.min(1,n)),r=e.type==="entrance",o=r?Vo(i):Ho(i),l={opacity:1,tx:0,ty:0,scaleX:1,scaleY:1,clipProgress:1,clipDir:"none",spin:0},a=e.effect,c=e.dir;if(r)switch(a){case"appear":l.opacity=i>=.01?1:0;break;case"fade":case"dissolve":l.opacity=o;break;case"fly":case"flyIn":{l.opacity=Math.min(1,o*1.5);const d=1-o;c.includes("l")?l.tx=-t*d:c.includes("r")?l.tx=t*d:c.includes("t")?l.ty=-s*d:l.ty=s*d;break}case"zoom":l.opacity=o,l.scaleX=.1+o*.9,l.scaleY=.1+o*.9;break;case"wipe":l.clipProgress=o,l.clipDir=c||"r";break;case"split":l.clipProgress=o,l.clipDir=c.includes("v")?"split-v":"split-h";break;case"blinds":l.clipProgress=o,l.clipDir=c.includes("v")?"blinds-v":"blinds-h";break;case"box":l.clipProgress=o,l.clipDir="box";break;case"wheel":l.clipProgress=o,l.clipDir="wheel";break;case"wedge":l.clipProgress=o,l.clipDir="wedge";break;case"strips":l.clipProgress=o,l.clipDir=c.includes("r")?"strips-r":"strips-l";break;case"stretch":l.opacity=o,c.includes("h")?(l.scaleX=o,l.scaleY=1):(l.scaleX=1,l.scaleY=o);break;case"plus":case"diamond":l.clipProgress=o,l.clipDir=a;break;default:l.opacity=o}else if(e.type==="exit"){const d={...e,type:"entrance"};return Os(d,1-i,t,s)}else switch(a){case"spin":l.spin=o*360;break;case"grow":case"shrink":{const d=a==="grow"?1.5:.5,h=i<.5?i*2:(1-i)*2;l.scaleX=1+(d-1)*h,l.scaleY=l.scaleX;break}case"flash":l.opacity=i<.5?i<.25?0:1:i<.75?0:1;break;default:l.opacity=.5+.5*Math.cos(i*Math.PI*4)}return l}function Us(e,n,t,s,i){const r=Yo(i),o=e.canvas.width,l=e.canvas.height;e.clearRect(0,0,o,l);const a=s?.type||"fade",c=s?.dir||"l";switch(a){case"cut":e.drawImage(r<.5?n:t,0,0,o,l);break;case"fade":case"fade_slow":default:e.drawImage(n,0,0,o,l),e.globalAlpha=r,e.drawImage(t,0,0,o,l),e.globalAlpha=1;break;case"push":{const d=c==="l"?-o*r:c==="r"?o*r:0,h=c==="u"?-l*r:c==="d"?l*r:0;e.drawImage(n,d,h,o,l),e.drawImage(t,d+(c==="l"?o:c==="r"?-o:0),h+(c==="u"?l:c==="d"?-l:0),o,l);break}case"cover":case"uncover":{const d=a==="uncover",h=c==="l"?-o*(1-r):c==="r"?o*(1-r):0,u=c==="u"?-l*(1-r):c==="d"?l*(1-r):0;d?(e.drawImage(t,0,0,o,l),e.drawImage(n,h,u,o,l)):(e.drawImage(n,0,0,o,l),e.drawImage(t,h,u,o,l));break}case"wipe":{e.drawImage(n,0,0,o,l),e.save(),e.beginPath(),c==="l"?e.rect(o*(1-r),0,o*r,l):c==="r"?e.rect(0,0,o*r,l):c==="u"?e.rect(0,l*(1-r),o,l*r):e.rect(0,0,o,l*r),e.clip(),e.drawImage(t,0,0,o,l),e.restore();break}case"zoom":case"newsflash":{e.drawImage(n,0,0,o,l),e.save(),e.globalAlpha=r;const d=a==="newsflash"?1+(1-r)*3:.05+r*.95;e.translate(o/2,l/2),e.scale(d,d),e.drawImage(t,-o/2,-l/2,o,l),e.restore(),e.globalAlpha=1;break}case"dissolve":case"wheel":case"blinds":{e.drawImage(n,0,0,o,l),e.globalAlpha=r,e.drawImage(t,0,0,o,l),e.globalAlpha=1;break}}}class Gs{constructor(n,t){this.renderer=n,this.canvas=t,this.ctx=t.getContext("2d"),this._slideIndex=0,this._steps=[],this._transition=null,this._clickNum=0,this._activeAnimations=[],this._shapeStates=new Map,this._baseCanvas=null,this._playing=!1,this._rafId=null,this.onSlideComplete=null,this.onClickReady=null,this.onTransitionStart=null,this.onTransitionEnd=null}async loadSlide(n){this._slideIndex=n,this._clickNum=0,this._shapeStates.clear(),this._stopAnimations();const t=this.renderer._files,s=this.renderer.slidePaths[n];if(!s||!t)return;const i=t[s]?new TextDecoder().decode(t[s]):null;if(!i)return;const{parseXml:r}=await Qt(async()=>{const{parseXml:a}=await Promise.resolve().then(()=>Wr);return{parseXml:a}},void 0,import.meta.url).catch(()=>({parseXml:a=>new DOMParser().parseFromString(a,"application/xml")})),o=r(i);this._steps=$n(o),this._transition=En(o);const l=new Set(this._steps.filter(a=>a.type==="entrance").map(a=>a.shapeId));this._initiallyHidden=l,this._baseCanvas=await this._renderBaseSlide(),this._drawBase(),await this._playClickGroup(0)}async nextClick(){this._clickNum++,await this._playClickGroup(this._clickNum)}async play(n=1500){this._playing=!0;const t=Math.max(...this._steps.map(s=>s.clickNum),0);for(;this._playing&&this._clickNum<=t;)await this._playClickGroup(this._clickNum),this._clickNum++,this._clickNum<=t&&await this._delay(n);this._playing=!1}pause(){this._playing=!1,this._stopAnimations()}async stop(){this._playing=!1,this._stopAnimations(),this._shapeStates.clear(),this._clickNum=0,this._baseCanvas&&this._drawBase()}async transitionTo(n){const t=document.createElement("canvas");t.width=this.canvas.width,t.height=this.canvas.height,t.getContext("2d").drawImage(this.canvas,0,0),await this.loadSlide(n);const s=this._baseCanvas,i=this._transition||{type:"fade",duration:700,dir:"l"};this.onTransitionStart?.({from:this._slideIndex-1,to:n,transition:i}),await this._animateTransition(t,s,i),this.onTransitionEnd?.({slideIndex:n})}async _renderBaseSlide(){const n=this.canvas.width,t=typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,Math.round(n/(this.renderer.slideSize.cx/this.renderer.slideSize.cy))):Object.assign(document.createElement("canvas"),{width:n,height:Math.round(n/(this.renderer.slideSize.cx/this.renderer.slideSize.cy))});return await this.renderer.renderSlide(this._slideIndex,t,n),t}_drawBase(){this._baseCanvas&&(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.drawImage(this._baseCanvas,0,0,this.canvas.width,this.canvas.height))}async _playClickGroup(n){const t=this._steps.filter(s=>s.clickNum===n);t.length&&(this.onClickReady?.({clickNum:n,stepCount:t.length}),Math.max(...t.map(s=>s.delay+s.duration),0),await new Promise(s=>{const i=performance.now(),r=new Set,o=l=>{const a=l-i;for(const c of t){if(r.has(c))continue;const d=a-c.delay;if(d<0)continue;const h=Math.min(1,d/c.duration),u=this.canvas.width,p=this.canvas.height,g=Os(c,h,u*.3,p*.3);this._shapeStates.set(c.shapeId,{...g,step:c}),h>=1&&r.add(c)}this._composite(),r.size<t.length?this._rafId=requestAnimationFrame(o):s()};this._rafId=requestAnimationFrame(o)}))}_composite(){this._drawBase();for(const[n,t]of this._shapeStates)t.opacity<.99}async _animateTransition(n,t,s){const i=s.duration;await new Promise(r=>{const o=performance.now(),l=a=>{const c=Math.min(1,(a-o)/i);Us(this.ctx,n,t,s,c),c<1?this._rafId=requestAnimationFrame(l):r()};this._rafId=requestAnimationFrame(l)})}_stopAnimations(){this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null)}_delay(n){return new Promise(t=>setTimeout(t,n))}}const Qo=Object.freeze(Object.defineProperty({__proto__:null,PptxPlayer:Gs,parseAnimations:$n,parseTransition:En,renderTransitionFrame:Us},Symbol.toStringTag,{value:"Module"}));let Zo=0;function on(e="el"){return`${e}${++Zo}`}function je(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function A(e){return`${+e.toFixed(3)}`}function vn(e){return e?pe(e):"none"}function Ws(e,n,t,s,i,r,o){if(!e)return{fill:"none",fillAttrs:""};const l=e.localName;if(l==="noFill")return{fill:"none",fillAttrs:""};if(l==="solidFill"){const a=ge(e),c=ve(a,t),d=vn(c),h=c?.a!=null?c.a/255:1;return{fill:d,fillAttrs:h<1?` fill-opacity="${A(h)}"`:""}}if(l==="gradFill"){const a=m(e,"gsLst"),c=a?ue(a,"gs").map(g=>{const b=C(g,"pos",0)/1e5,_=ge(g),y=ve(_,t);return{pos:b,color:vn(y),opacity:y?.a!=null?y.a/255:1}}):[],d=m(e,"lin"),h=m(e,"path"),u=on("grad");let p;if(h){const g=m(h,"fillToRect"),b=C(g,"l",5e4)/1e5,_=C(g,"t",5e4)/1e5,y=s+r*b,w=i+o*_,x=Math.sqrt(r*r+o*o)/2;p=`<radialGradient id="${u}" cx="${A(y)}" cy="${A(w)}" r="${A(x)}" gradientUnits="userSpaceOnUse">`;for(const P of c)p+=`<stop offset="${A(P.pos)}" stop-color="${je(P.color)}"${P.opacity<1?` stop-opacity="${A(P.opacity)}"`:""}/>`;p+="</radialGradient>"}else{const b=(C(d,"ang",0)/6e4-90)*(Math.PI/180),_=Math.cos(b),y=Math.sin(b),w=Math.sqrt(r*r+o*o)/2,x=s+r/2,P=i+o/2;p=`<linearGradient id="${u}" x1="${A(x-_*w)}" y1="${A(P-y*w)}" x2="${A(x+_*w)}" y2="${A(P+y*w)}" gradientUnits="userSpaceOnUse">`;for(const v of c)p+=`<stop offset="${A(v.pos)}" stop-color="${je(v.color)}"${v.opacity<1?` stop-opacity="${A(v.opacity)}"`:""}/>`;p+="</linearGradient>"}return n.push(p),{fill:`url(#${u})`,fillAttrs:""}}return l==="blipFill"?{fill:"none",fillAttrs:""}:{fill:"none",fillAttrs:""}}function qs(e,n,t){if(!e)return"";if(m(e,"noFill"))return' stroke="none"';const s=m(e,"solidFill"),i=s?ge(s):null,r=ve(i,n),o=vn(r)||"#000",l=Math.max(.5,C(e,"w",12700)/914400*96),a=m(e,"prstDash"),c=a?O(a,"val","solid"):"solid";let d="";c==="dash"?d=` stroke-dasharray="${A(l*4)},${A(l*2)}"`:c==="dot"?d=` stroke-dasharray="${A(l)},${A(l*2)}"`:c==="dashDot"?d=` stroke-dasharray="${A(l*4)},${A(l*2)},${A(l)},${A(l*2)}"`:c==="lgDash"&&(d=` stroke-dasharray="${A(l*8)},${A(l*3)}"`);const h=O(e,"cap","flat"),u=h==="rnd"?"round":h==="sq"?"square":"butt";return` stroke="${je(o)}" stroke-width="${A(l)}" stroke-linecap="${u}" stroke-linejoin="round"${d}`}function Ks(e,n){if(!e)return"";const t=m(e,"outerShdw");if(!t)return"";const s=C(t,"dist",38100)/914400*96,i=C(t,"dir",27e5)/6e4,r=C(t,"blurRad",38100)/914400*96,o=i*Math.PI/180,l=Math.cos(o)*s,a=Math.sin(o)*s,c=ge(t),d=ve(c,{}),h=d?pe(d):"rgba(0,0,0,0.5)",u=d?.a!=null?d.a/255:.5,p=on("shd");return n.push(`<filter id="${p}" x="-50%" y="-50%" width="200%" height="200%"><feDropShadow dx="${A(l)}" dy="${A(a)}" stdDeviation="${A(r/2)}" flood-color="${je(h)}" flood-opacity="${A(u)}"/></filter>`),` filter="url(#${p})"`}function Jo(e,n,t,s,i,r){const o=[],l={beginPath(){o.length=0},moveTo(a,c){o.push(`M${A(a)},${A(c)}`)},lineTo(a,c){o.push(`L${A(a)},${A(c)}`)},bezierCurveTo(a,c,d,h,u,p){o.push(`C${A(a)},${A(c)},${A(d)},${A(h)},${A(u)},${A(p)}`)},quadraticCurveTo(a,c,d,h){o.push(`Q${A(a)},${A(c)},${A(d)},${A(h)}`)},arc(a,c,d,h,u,p){const g=a+d*Math.cos(h),b=c+d*Math.sin(h),_=a+d*Math.cos(u),y=c+d*Math.sin(u);let w=u-h;p&&(w=-(Math.PI*2-Math.abs(w)));const x=Math.abs(w)>Math.PI?1:0,P=w>0?1:0;o.length===0&&o.push(`M${A(g)},${A(b)}`),o.push(`A${A(d)},${A(d)},0,${x},${P},${A(_)},${A(y)}`)},arcTo(a,c,d,h,u){o.push(`L${A(a)},${A(c)} L${A(d)},${A(h)}`)},closePath(){o.push("Z")},fill(){},stroke(){},save(){},restore(){},translate(){},rotate(){},scale(){},rect(a,c,d,h){o.push(`M${A(a)},${A(c)}L${A(a+d)},${A(c)}L${A(a+d)},${A(c+h)}L${A(a)},${A(c+h)}Z`)},setLineDash(){},measureText(){return{width:0}}};return o.join(" ")||`M${A(n)},${A(t)}L${A(n+s)},${A(t)}L${A(n+s)},${A(t+i)}L${A(n)},${A(t+i)}Z`}let ea=null;function an(e){if(!e)return"";const n=C(e,"rot",0)/6e4,t=O(e,"flipH","0")==="1",s=O(e,"flipV","0")==="1",i=m(e,"off"),r=m(e,"ext");if(!i||!r)return"";const o=C(i,"x",0)/914400*96,l=C(i,"y",0)/914400*96,a=C(r,"cx",0)/914400*96,c=C(r,"cy",0)/914400*96,d=o+a/2,h=l+c/2,u=[];return n&&u.push(`rotate(${A(n)},${A(d)},${A(h)})`),t&&u.push(`scale(-1,1) translate(${A(-o*2-a)},0)`),s&&u.push(`scale(1,-1) translate(0,${A(-l*2-c)})`),u.length?` transform="${u.join(" ")}"`:""}function Ct(e){if(!e)return null;const n=m(e,"off"),t=m(e,"ext");return!n||!t?null:{x:C(n,"x",0)/914400*96,y:C(n,"y",0)/914400*96,w:C(t,"cx",0)/914400*96,h:C(t,"cy",0)/914400*96}}function ta(e,n,t,s,i,r,o,l){if(!e)return"";const a=m(e,"bodyPr"),c=O(a,"vert","horz"),d=c==="vert"||c==="vert270"||c==="wordArtVert";O(a,"anchor","t");const h=C(a,"lIns",91440)/914400*96,u=C(a,"rIns",91440)/914400*96,p=C(a,"tIns",45720)/914400*96;C(a,"bIns",45720)/914400*96;const g=n+h,b=s-h-u,_=t+p,y=1800,w=m(e,"lstStyle"),x=w?m(w,"defRPr"):null,P=ue(e,"p");let v="",k=_;const T=on("clip");l.push(`<clipPath id="${T}"><rect x="${A(n)}" y="${A(t)}" width="${A(s)}" height="${A(i)}"/></clipPath>`);const N=d?` transform="rotate(-90,${A(n+s/2)},${A(t+i/2)})"`:"",M={};for(const F of P){const S=m(F,"pPr"),$=O(S,"algn","l"),R=C(S,"marL",0)/914400*96,W=C(S,"indent",0)/914400*96,Q=m(S,"defRPr");let D=y;if(x){const z=x.getAttribute("sz");z&&(D=parseInt(z,10))}if(Q){const z=Q.getAttribute("sz");z&&(D=parseInt(z,10))}const U=m(S,"spcBef"),K=m(S,"spcAft");m(S,"lnSpc");let J=0,q=0;if(U){const z=m(U,"spcPct"),E=m(U,"spcPts");z?J=D*yt/914400*96*(C(z,"val",0)/1e5):E&&(J=C(E,"val",0)/100/72*96)}if(K){const z=m(K,"spcPct"),E=m(K,"spcPts");z?q=D*yt/914400*96*(C(z,"val",0)/1e5):E&&(q=C(E,"val",0)/100/72*96)}const I=S?m(S,"buChar"):null,Z=S?m(S,"buAutoNum"):null,re=!(S?m(S,"buNone"):null)&&(I||Z);k+=J;const de=[];for(const z of F.children)(z.localName==="r"||z.localName==="br"||z.localName==="fld")&&de.push(z);if(!de.length){const z=m(F,"endParaRPr"),X=C(z||Q,"sz",D)/100/72*96*1.2;k+=X+q;continue}let oe="";for(const z of de){if(z.localName==="br"){oe+=`
|
|
112
|
+
`;continue}const E=m(z,"t")||m(z,"fldVal");E&&(oe+=E.textContent)}const H=[];for(const z of de){if(z.localName==="br"){H.push({br:!0});continue}const E=m(z,"rPr")||m(z,"r")?.firstElementChild,L=m(z,"t");if(!L)continue;const X=L.textContent;if(!X)continue;const V=js(z,Q,x,r,o,D),ae=V?.szPx||D/100/72*96,ce=V?.family||"sans-serif",te=V?.bold?"bold":"normal",ke=V?.italic?"italic":"normal",Te=V?.color?pe(V.color):"#000000",Ne=E?(E.getAttribute("u")||"none")!=="none":!1,Ae=E?(E.getAttribute("strike")||"noStrike")!=="noStrike":!1,Mt=E?parseInt(E.getAttribute("baseline")||"0",10):0;H.push({text:X,szPx:ae,family:ce,bold:te,italic:ke,color:Te,underline:Ne,strike:Ae,baseline:Mt})}if(!H.length){k+=q;continue}const me=H.filter(z=>!z.br&&z.szPx).map(z=>z.szPx),ne=me.length?Math.max(...me):D/100/72*96,se=ne*1.2,fe=k+ne*.85;let we="start",be=g+R;$==="ctr"?(we="middle",be=g+b/2):$==="r"&&(we="end",be=g+b);let ye="";if(re){const z=g+R+W;let E="";if(I)E=je(I.getAttribute("char")||"•");else if(Z){const X=Z.getAttribute("type")||"arabicPeriod",V=C(Z,"startAt",1),ae=X+":"+V;M[ae]||(M[ae]=V),E=je(na(X,M[ae]++))}const L=ne;ye=`<text x="${A(z)}" y="${A(fe)}" font-size="${A(L)}" font-family="sans-serif" fill="#000">${E}</text>`}let le="";for(const z of H){if(z.br){k+=se,le+=`<tspan x="${A(be)}" dy="${A(se)}">`;continue}const E=z.underline?"underline":z.strike?"line-through":"none";let L=fe;z.baseline>0?L=fe-z.szPx*.38:z.baseline<0&&(L=fe+z.szPx*.12);const X=z.baseline!==0?z.szPx*.65:z.szPx;le+=`<tspan font-family="${je(z.family)}, sans-serif" font-size="${A(X)}" font-weight="${z.bold}" font-style="${z.italic}" fill="${je(z.color)}"`+(E!=="none"?` text-decoration="${E}"`:"")+(z.baseline!==0?` dy="${A(L-fe)}"`:"")+`>${je(z.text)}</tspan>`}v+=ye,v+=`<text x="${A(be)}" y="${A(fe)}" text-anchor="${we}">${le}</text>`,k+=se+q}return`<g clip-path="url(#${T})"${N}>${v}</g>`}function na(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return ss(n).toLowerCase()+".";case"romanUcPeriod":return ss(n)+".";case"alphaLcParenR":return String.fromCharCode(96+n)+")";case"alphaUcParenR":return String.fromCharCode(64+n)+")";default:return n+"."}}function ss(e){const n=[1e3,900,500,400,100,90,50,40,10,9,5,4,1],t=["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"];let s="";for(let i=0;i<n.length;i++)for(;e>=n[i];)s+=t[i],e-=n[i];return s}async function qt(e,n,t,s,i,r){if(!e)return"";let o="";for(const l of e.children){const a=l.localName;a==="sp"?o+=await sa(l,s,i,r):a==="pic"?o+=await ia(l,n,t,s,r):a==="cxnSp"?o+=await ra(l,s):a==="grpSp"?o+=await oa(l,n,t,s,i,r):a==="graphicFrame"&&(o+=await aa(l))}return o}async function sa(e,n,t,s){const i=m(e,"spPr"),r=m(i,"xfrm"),o=Ct(r);if(!o)return"";const l=m(i,"prstGeom"),a=l?O(l,"prst","rect"):"rect",c=m(i,"custGeom"),d=["noFill","solidFill","gradFill","blipFill","pattFill"];let h=null;for(const k of d){const T=m(i,k);if(T){h=T;break}}if(!h){const k=m(e,"style"),T=k?m(k,"fillRef"):null;if(T&&C(T,"idx",1)!==0){const N=ge(T),M=ve(N,n);M&&(h=new DOMParser().parseFromString(`<solidFill xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><srgbClr val="${pe(M).replace("#","")}"/></solidFill>`,"application/xml").documentElement)}}const{fill:u,fillAttrs:p}=Ws(h,s,n,o.x,o.y,o.w,o.h);let g=m(i,"ln");if(!g){const k=m(e,"style"),T=k?m(k,"lnRef"):null;if(T&&C(T,"idx",1)!==0){const N=ge(T),M=ve(N,n);M&&(g=new DOMParser().parseFromString(`<ln xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><solidFill><srgbClr val="${pe(M).replace("#","")}"/></solidFill></ln>`,"application/xml").documentElement)}}const b=qs(g,n),_=m(i,"effectLst"),y=Ks(_,s),w=an(r);let x="";if(a==="rect"||!l&&!c)x=`<rect x="${A(o.x)}" y="${A(o.y)}" width="${A(o.w)}" height="${A(o.h)}" fill="${je(u)}"${p}${b}${y}${w}/>`;else{const k=Jo(a,o.x,o.y,o.w,o.h,{});x=`<path d="${je(k)}" fill="${je(u)}"${p}${b}${y}${w}/>`}const P=m(e,"txBody"),v=P?ta(P,o.x,o.y,o.w,o.h,n,t,s):"";return`<g>${x}${v}</g>`}async function ia(e,n,t,s,i){const r=m(e,"spPr"),o=m(r,"xfrm"),l=Ct(o);if(!l)return"";const a=m(e,"blipFill"),c=a?m(a,"blip"):null,d=c?c.getAttribute("r:embed")||c.getAttribute("embed"):null,h=d?n[d]:null,u=h?t[h.fullPath]:null,p=an(o),g=m(r,"effectLst"),b=Ks(g,i);if(!u)return`<rect x="${A(l.x)}" y="${A(l.y)}" width="${A(l.w)}" height="${A(l.h)}" fill="#e0e0e0"${p}/>`;const _=h.fullPath.split(".").pop().toLowerCase(),y=_==="png"?"image/png":_==="gif"?"image/gif":_==="svg"?"image/svg+xml":"image/jpeg",w=u instanceof Uint8Array?u:new Uint8Array(u),x=btoa(Array.from(w,v=>String.fromCharCode(v)).join("")),P=on("pic");return i.push(`<clipPath id="${P}"><rect x="${A(l.x)}" y="${A(l.y)}" width="${A(l.w)}" height="${A(l.h)}"/></clipPath>`),`<image x="${A(l.x)}" y="${A(l.y)}" width="${A(l.w)}" height="${A(l.h)}" href="data:${y};base64,${x}" clip-path="url(#${P})"${b}${p} preserveAspectRatio="xMidYMid slice"/>`}async function ra(e,n,t){const s=m(e,"spPr"),i=m(s,"xfrm"),r=Ct(i);if(!r)return"";const o=m(s,"ln"),l=qs(o,n),a=an(i);return`<line x1="${A(r.x)}" y1="${A(r.y)}" x2="${A(r.x+r.w)}" y2="${A(r.y+r.h)}" fill="none"${l}${a}/>`}async function oa(e,n,t,s,i,r){const o=m(e,"grpSpPr"),l=m(o,"xfrm");Ct(l);const a=l?an(l):"",c=await qt(e,n,t,s,i,r);return`<g${a}>${c}</g>`}async function aa(e,n,t){const s=m(e,"xfrm"),i=Ct(s);return i?`<rect x="${A(i.x)}" y="${A(i.y)}" width="${A(i.w)}" height="${A(i.h)}" fill="#f4f4f8" stroke="#ccc" stroke-width="1"/><text x="${A(i.x+i.w/2)}" y="${A(i.y+i.h/2)}" text-anchor="middle" font-size="14" fill="#999">Chart</text>`:""}async function la(e,n,t,s,i,r,o,l,a){const c=p=>{const g=m(p,"cSld"),b=g?m(g,"bg"):null;return b?{bgPr:m(b,"bgPr"),bgRef:m(b,"bgRef")}:null},d=c(e)||c(t)||c(n);if(!d)return`<rect width="${A(o)}" height="${A(l)}" fill="white"/>`;const{bgPr:h,bgRef:u}=d;if(h){const p=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const g of p){const b=m(h,g);if(b){if(g==="blipFill"){const w=m(b,"blip"),x=w?w.getAttribute("r:embed")||w.getAttribute("embed"):null,P=x&&i?i[x]:null,v=P?s[P.fullPath]:null;if(v){const T=P.fullPath.split(".").pop().toLowerCase()==="png"?"image/png":"image/jpeg",N=v instanceof Uint8Array?v:new Uint8Array(v),M=btoa(Array.from(N,F=>String.fromCharCode(F)).join(""));return`<image width="${A(o)}" height="${A(l)}" href="data:${T};base64,${M}" preserveAspectRatio="xMidYMid slice"/>`}}const{fill:_,fillAttrs:y}=Ws(b,a,r,0,0,o,l);return`<rect width="${A(o)}" height="${A(l)}" fill="${je(_)}"${y}/>`}}}if(u){const p=ge(u),g=ve(p,r);if(g)return`<rect width="${A(o)}" height="${A(l)}" fill="${je(pe(g))}"/>`}return`<rect width="${A(o)}" height="${A(l)}" fill="white"/>`}async function Xs(e,n){const{_files:t,slidePaths:s,slideSize:i,themeColors:r,themeData:o,masterDoc:l,masterRels:a}=n;if(e<0||e>=s.length)throw new Error("Slide index out of range");const c=s[e],d=t[c]?new TextDecoder().decode(t[c]):null;if(!d)throw new Error(`Cannot read slide ${e}`);const h=xe(d),u=await Le(t,c),p=Object.values(u).find(S=>S.type?.includes("slideLayout")),g=p&&t[p.fullPath]?xe(new TextDecoder().decode(t[p.fullPath])):null,b=p?await Le(t,p.fullPath):{},_=i.cx/914400*96,y=i.cy/914400*96,w=[],x=await la(h,l,g,t,a,r,_,y,w),P=m(m(l,"cSld"),"spTree"),v=g?m(m(g,"cSld"),"spTree"):null,k=m(m(h,"cSld"),"spTree"),T=P?await qt(P,a,t,r,o,w):"",N=v?await qt(v,b,t,r,o,w):"",M=k?await qt(k,u,t,r,o,w):"",F=w.length?`<defs>${w.join(`
|
|
113
|
+
`)}</defs>`:"";return['<?xml version="1.0" encoding="UTF-8"?>','<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"',` width="${A(_)}" height="${A(y)}" viewBox="0 0 ${A(_)} ${A(y)}">`,F,x,T,N,M,"</svg>"].join(`
|
|
114
|
+
`)}async function ca(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await Xs(t,e));return n}function is(e){const n=e.replace(/[{}\-]/g,"");if(n.length<32){const a=n.padEnd(32,"0");return da(a.slice(0,32))}const t=n.slice(0,8),s=n.slice(8,12),i=n.slice(12,16),r=n.slice(16,32),o=new Uint8Array(16);o[0]=parseInt(t.slice(6,8),16),o[1]=parseInt(t.slice(4,6),16),o[2]=parseInt(t.slice(2,4),16),o[3]=parseInt(t.slice(0,2),16),o[4]=parseInt(s.slice(2,4),16),o[5]=parseInt(s.slice(0,2),16),o[6]=parseInt(i.slice(2,4),16),o[7]=parseInt(i.slice(0,2),16);for(let a=0;a<8;a++)o[8+a]=parseInt(r.slice(a*2,a*2+2),16);const l=new Uint8Array(32);return l.set(o),l.set(o,16),l}function da(e){const n=new Uint8Array(e.length/2);for(let t=0;t<n.length;t++)n[t]=parseInt(e.slice(t*2,t*2+2),16);return n}function rs(e,n){const t=new Uint8Array(e);for(let s=0;s<Math.min(32,t.length);s++)t[s]^=n[s];return t}function hn(e){if(e.length<4)return!1;const n=e[0]<<24|e[1]<<16|e[2]<<8|e[3];return n===65536||n===1330926671||n===1953658213||n===2001684038||n===2001684018}const wn=new Set;async function ua(e,n){const t=[],s=e["ppt/presentation.xml"];if(!s)return t;const r=new DOMParser().parseFromString(new TextDecoder().decode(s),"application/xml"),o=r.querySelector("embeddedFontLst")||[...r.getElementsByTagName("*")].find(a=>a.localName==="embeddedFontLst");if(!o)return t;const l=[...o.children].filter(a=>a.localName==="embeddedFont");for(const a of l){const c=[...a.children].find(u=>u.localName==="font");if(!c)continue;const d=c.getAttribute("typeface")||c.getAttribute("t");if(!d)continue;const h=[{el:[...a.children].find(u=>u.localName==="regular"),weight:"400",style:"normal"},{el:[...a.children].find(u=>u.localName==="bold"),weight:"700",style:"normal"},{el:[...a.children].find(u=>u.localName==="italic"),weight:"400",style:"italic"},{el:[...a.children].find(u=>u.localName==="boldItalic"),weight:"700",style:"italic"}];for(const{el:u,weight:p,style:g}of h){if(!u)continue;const b=u.getAttribute("r:id")||u.getAttribute("id")||u.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id");if(!b)continue;const _=`${d}:${p}:${g}`;if(wn.has(_)){t.push({typeface:d,weight:p,style:g,status:"already-loaded"});continue}const y=n?n[b]:null;if(!y){t.push({typeface:d,weight:p,style:g,status:"rel-not-found",rId:b});continue}const w=e[y.fullPath];if(!w){t.push({typeface:d,weight:p,style:g,status:"file-not-found",path:y.fullPath});continue}let x=null;const P=is(b),v=rs(w,P);if(hn(v))x=v;else{const k=y.fullPath.split("/").pop().replace(".fntdata",""),T=is(k),N=rs(w,T);hn(N)?x=N:hn(w)&&(x=w)}if(!x){t.push({typeface:d,weight:p,style:g,status:"decode-failed",path:y.fullPath});continue}try{const k=new FontFace(d,x.buffer,{weight:p,style:g});await k.load(),document.fonts.add(k),wn.add(_),t.push({typeface:d,weight:p,style:g,status:"loaded",path:y.fullPath})}catch(k){t.push({typeface:d,weight:p,style:g,status:"load-failed",error:k.message})}}}return t}function fa(e){const n=e["ppt/presentation.xml"];return n?[...new DOMParser().parseFromString(new TextDecoder().decode(n),"application/xml").getElementsByTagName("*")].filter(i=>i.localName==="embeddedFont").map(i=>{const r=[...i.children].find(a=>a.localName==="font"),o=r&&(r.getAttribute("typeface")||r.getAttribute("t"))||"",l=["regular","bold","italic","boldItalic"].filter(a=>[...i.children].some(c=>c.localName===a));return{typeface:o,variants:l,loaded:l.some(a=>wn.has(`${o}:${a==="bold"||a==="boldItalic"?"700":"400"}:${a.includes("talic")?"italic":"normal"}`))}}).filter(i=>i.typeface):[]}function G(e,n){if(!e)return null;const t=e.getElementsByTagName("*");for(let s=0;s<t.length;s++)if(t[s].localName===n)return t[s];return null}function Xe(e,n){if(!e)return[];const t=[],s=e.getElementsByTagName("*");for(let i=0;i<s.length;i++)s[i].localName===n&&t.push(s[i]);return t}function Pe(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function kn(e,n,t=0){const s=Pe(e,n);return s!==null?parseInt(s,10):t}function ha(e,n){const t=G(e,"rPr"),s=G(e,"t");if(!s)return null;const i=s.textContent||"",r=t?parseInt(t.getAttribute("sz")||"0",10):n?parseInt(n.getAttribute("sz")||"0",10):0,o=r?r/100:12,l=t?t.getAttribute("b")==="1":!1,a=t?t.getAttribute("i")==="1":!1,c=t&&t.getAttribute("u")||"none";let d="#000000";if(t){const h=G(t,"solidFill")||G(t,"lumMod");if(h){const u=G(h,"srgbClr");u&&(d="#"+(u.getAttribute("val")||"000000"))}}return{text:i,bold:l,italic:a,underline:c!=="none",fontSize:o,color:d}}function pa(e){const n=G(e,"pPr"),t=Pe(n,"algn","l"),s=kn(n,"lvl",0),i=G(n,"defRPr");let r=null;if(n&&!G(n,"buNone")){const a=G(n,"buChar"),c=G(n,"buAutoNum");a?r=a.getAttribute("char")||"•":c&&(r="{auto}")}const o=[];for(const a of e.children)if(a.localName==="r"){const c=ha(a,i);c&&o.push(c)}else if(a.localName==="br")o.push({text:`
|
|
115
|
+
`,bold:!1,italic:!1,underline:!1,fontSize:12,color:"#000"});else if(a.localName==="fld"){const c=G(a,"t");c&&o.push({text:c.textContent,bold:!1,italic:!1,underline:!1,fontSize:12,color:"#555"})}const l=o.map(a=>a.text).join("");return{runs:o,text:l,align:t,level:s,bullet:r}}function xn(e){return e?Xe(e,"p").map(pa).filter(n=>n.text.trim()):[]}function os(e){const n=G(e,"nvSpPr"),t=n?G(n,"nvPr"):null,s=t?G(t,"ph"):null;if(s){const r=Pe(s,"type","body");if(r==="title"||r==="ctrTitle")return"title";if(r==="subTitle")return"subtitle";if(r==="body")return"body"}return G(e,"txBody")?"textBox":"other"}function as(e){const n=G(e,"nvSpPr"),t=n?G(n,"cNvPr"):null;return t?Pe(t,"id",""):""}function ls(e){const n=G(e,"nvSpPr"),t=n?G(n,"cNvPr"):null;return t?Pe(t,"name",""):""}function ga(e){const n=G(e,"tbl");if(!n)return null;const t=G(e,"nvGraphicFramePr"),s=t?G(t,"cNvPr"):null,i=s?Pe(s,"id",""):"",r=s?Pe(s,"name",""):"",o=[];let l=0;for(const c of Xe(n,"tr")){const d=[];let h=0;for(const u of Xe(c,"tc")){const p=kn(u,"gridSpan",1),g=kn(u,"rowSpan",1),b=xn(G(u,"txBody")),_=b.map(y=>y.text).join(`
|
|
116
|
+
`);d.push({row:l,col:h,rowSpan:g,colSpan:p,text:_,paragraphs:b}),h++}o.push(d),l++}const a=o.map(c=>c.map(d=>d.text).join(" ")).join(`
|
|
117
|
+
`);return{id:i,name:r,rows:o,text:a}}function ma(e,n){const t=G(e,"graphic"),s=t?G(t,"graphicData"):null,i=s?G(s,"chart"):null;if(!i)return null;const r=i.getAttribute("r:id")||i.getAttribute("id"),o=G(e,"nvGraphicFramePr"),l=o?G(o,"cNvPr"):null;return{id:l?Pe(l,"id",""):"",name:l?Pe(l,"name",""):"",rId:r}}function ba(e){if(!e)return{chartType:"unknown",seriesNames:[],categories:[]};const n=G(e,"plotArea");if(!n)return{chartType:"unknown",seriesNames:[],categories:[]};const t=["barChart","lineChart","pieChart","areaChart","scatterChart","doughnutChart","radarChart","bubbleChart","bar3DChart","line3DChart","pie3DChart","area3DChart"];let s="unknown",i=null;for(const a of t)if(i=G(n,a),i){s=a.replace("3DChart","Chart").replace("Chart","");break}const r=i?Xe(i,"ser"):[],o=r.map(a=>{const c=G(a,"tx");if(!c)return null;const d=G(c,"v");if(d)return d.textContent.trim();const h=G(c,"strCache"),u=h?G(h,"pt"):null,p=u?G(u,"v"):null;return p?p.textContent.trim():null}).filter(Boolean),l=r.length>0?(()=>{const a=G(r[0],"cat")||G(r[0],"xVal");if(!a)return[];const c=G(a,"strCache")||G(a,"numCache");return c?Xe(c,"pt").map(d=>G(d,"v")?.textContent||"").filter(Boolean):[]})():[];return{chartType:s,seriesNames:o,categories:l}}function ya(e){if(!e)return"";const n=G(e,"cSld"),t=n?G(n,"spTree"):null;if(!t)return"";const s=[];for(const i of Xe(t,"sp")){const r=G(i,"nvSpPr"),o=r?G(r,"nvPr"):null,l=o?G(o,"ph"):null;if(l&&Pe(l,"type")==="sldNum")continue;const a=G(i,"txBody");if(a){const c=Xe(a,"r").map(d=>G(d,"t")?.textContent||"").join("");c.trim()&&s.push(c.trim())}}return s.join(`
|
|
118
|
+
|
|
119
|
+
`)}async function ln(e,n){const{_files:t,slidePaths:s}=n;if(e<0||e>=s.length)throw new Error("Slide index out of range");const i=t[s[e]];if(!i)return va(e);const r=new DOMParser().parseFromString(new TextDecoder().decode(i),"application/xml"),{getRels:o}=await Qt(async()=>{const{getRels:v}=await Promise.resolve().then(()=>To);return{getRels:v}},void 0,import.meta.url),l=await o(t,s[e]),a=Object.values(l).find(v=>v.type?.includes("notesSlide"));let c="";if(a&&t[a.fullPath]){const v=new DOMParser().parseFromString(new TextDecoder().decode(t[a.fullPath]),"application/xml");c=ya(v)}const d=G(r,"cSld"),h=d?G(d,"spTree"):null;if(!h)return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:c,text:c};const u=[],p=[],g=[],b=[];for(const v of h.children){const k=v.localName;if(k==="sp"){const T=G(v,"txBody");if(!T)continue;const N=os(v),M=as(v),F=ls(v),S=xn(T),$=S.map(R=>R.text).join(`
|
|
120
|
+
`);$.trim()&&u.push({id:M,name:F,type:N,paragraphs:S,text:$})}else if(k==="pic"){const T=G(v,"nvPicPr"),N=T?G(T,"cNvPr"):null,M=N?Pe(N,"id",""):"",F=N?Pe(N,"name",""):"",S=N?Pe(N,"descr","")||Pe(N,"title",""):"",$=T?G(T,"nvPr"):null;$&&G($,"extLst"),g.push({id:M,name:F,altText:S,title:F})}else if(k==="graphicFrame"){const T=(()=>{const N=G(v,"graphic"),M=N?G(N,"graphicData"):null;return M?Pe(M,"uri",""):""})();if(T.includes("table")||G(v,"tbl")){const N=ga(v);N&&p.push(N)}else if(T.includes("chart")){const N=ma(v);if(N){const M=N.rId?l[N.rId]:null;let F={chartType:"chart",seriesNames:[],categories:[]};if(M&&t[M.fullPath]){const S=new DOMParser().parseFromString(new TextDecoder().decode(t[M.fullPath]),"application/xml");F=ba(S)}b.push({id:N.id,name:N.name,...F})}}}else if(k==="grpSp")for(const T of Xe(v,"sp")){const N=G(T,"txBody");if(!N)continue;const M=os(T),F=as(T),S=ls(T),$=xn(N),R=$.map(W=>W.text).join(`
|
|
121
|
+
`);R.trim()&&u.push({id:F,name:S,type:M,paragraphs:$,text:R})}}const _=u.find(v=>v.type==="title"),y=u.find(v=>v.type==="subtitle"),w=_?.text||"",x=y?.text||"",P=[w,x,...u.filter(v=>v.type!=="title"&&v.type!=="subtitle").map(v=>v.text),...p.map(v=>v.text),...b.map(v=>[v.name,...v.seriesNames,...v.categories].join(" ")),c].filter(Boolean).join(`
|
|
122
|
+
|
|
123
|
+
`);return{index:e,title:w,subtitle:x,textShapes:u,tables:p,images:g,charts:b,notes:c,text:P}}function va(e){return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:"",text:""}}async function wa(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await ln(t,e));return n}async function ka(e,n){return(await ln(e,n)).text}async function xa(e,n){const t=e.toLowerCase().trim();if(!t)return[];const s=[];for(let i=0;i<n.slideCount;i++){const r=await ln(i,n),o=r.text.toLowerCase();if(!o.includes(t))continue;const l=[];let a=0;for(;(a=o.indexOf(t,a))!==-1;){const c=Math.max(0,a-60),d=Math.min(r.text.length,a+t.length+60),h=r.text.slice(c,a),u=r.text.slice(a,a+t.length),p=r.text.slice(a+t.length,d);if(l.push({before:(c>0?"…":"")+h,match:u,after:p+(d<r.text.length?"…":"")}),a+=t.length,l.length>=3)break}s.push({slideIndex:i,title:r.title,score:l.length+(r.title.toLowerCase().includes(t)?10:0),excerpts:l})}return s.sort((i,r)=>r.score-i.score)}class _a{constructor(n,t,s={}){this.renderer=n,this.container=t,this.opts={fullscreen:!0,showNotes:!1,showThumbs:!1,showHud:!0,loop:!1,autoAdvance:0,...s},this._index=0,this._playing=!1,this._player=null,this._autoTimer=null,this._el=null,this._canvas=null,this._notesEl=null,this._hudEl=null,this._thumbsEl=null,this._thumbnails=[],this._touchStartX=0,this._touchStartY=0,this._onKey=this._onKey.bind(this),this._onResize=this._onResize.bind(this),this._onFsChange=this._onFsChange.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this)}async start(n=0){this._playing=!0,this._index=Math.max(0,Math.min(n,this.renderer.slideCount-1)),this._buildDOM(),this._attachEvents(),this.opts.fullscreen&&await this._requestFullscreen(),this.opts.showThumbs&&this._generateThumbnails(),await this._renderCurrent(),this._updateHud(),this.opts.autoAdvance>0&&this._startAutoAdvance()}stop(){this._playing=!1,this._stopAutoAdvance(),this._detachEvents(),document.fullscreenElement===this._el&&document.exitFullscreen().catch(()=>{}),this._el&&this._el.parentNode&&this._el.parentNode.removeChild(this._el),this._el=null,this._canvas=null,this._player=null,this.opts.onSlideChange?.(null)}async goto(n){if(!this._playing)return;const t=Math.max(0,Math.min(n,this.renderer.slideCount-1));if(t===this._index)return;const s=this._index;this._index=t,this._resetAutoAdvance(),await this._renderCurrent(s),this._updateHud(),this.opts.onSlideChange?.(this._index)}async next(){if(this._playing){if(this._player){const n=this.renderer.getAnimations?.(this._index)||[];n.length&&Math.max(...n.map(t=>t.clickNum),0),await this._player.nextClick?.()}this._index<this.renderer.slideCount-1?await this.goto(this._index+1):this.opts.loop&&await this.goto(0)}}async prev(){this._playing&&(this._index>0?await this.goto(this._index-1):this.opts.loop&&await this.goto(this.renderer.slideCount-1))}get currentIndex(){return this._index}get isPlaying(){return this._playing}_buildDOM(){const n=document.createElement("div");n.style.cssText=["position:fixed","inset:0","z-index:999999","background:#000","display:flex","flex-direction:column","align-items:center","justify-content:center","user-select:none","touch-action:none"].join(";"),n.setAttribute("tabindex","0"),this._el=n;const t=document.createElement("div");t.style.cssText="position:relative; flex:1; display:flex; align-items:center; justify-content:center; width:100%; overflow:hidden;";const s=document.createElement("canvas");if(s.style.cssText="display:block; box-shadow:0 4px 32px rgba(0,0,0,0.6);",this._canvas=s,t.appendChild(s),n.appendChild(t),this.opts.showHud){const r=document.createElement("div");r.style.cssText=["position:absolute","bottom:24px","left:50%","transform:translateX(-50%)","display:flex","align-items:center","gap:12px","background:rgba(0,0,0,0.55)","backdrop-filter:blur(8px)","border-radius:24px","padding:8px 20px","color:white","font:500 14px/1 system-ui,sans-serif","pointer-events:none"].join(";"),this._hudEl=r,n.appendChild(r)}if(this.opts.showNotes){const r=document.createElement("div");r.style.cssText=["width:100%","max-height:22vh","overflow-y:auto","background:rgba(0,0,0,0.7)","backdrop-filter:blur(8px)","color:#e0e0e0","font:14px/1.5 system-ui,sans-serif","padding:12px 24px","white-space:pre-wrap","flex-shrink:0"].join(";"),this._notesEl=r,n.appendChild(r)}if(this.opts.showThumbs){const r=document.createElement("div");r.style.cssText=["display:flex","gap:6px","padding:8px 16px","overflow-x:auto","background:rgba(0,0,0,0.7)","width:100%","flex-shrink:0"].join(";"),this._thumbsEl=r,n.appendChild(r);for(let o=0;o<this.renderer.slideCount;o++){const l=document.createElement("canvas");l.width=120,l.height=Math.round(120/(this.renderer.slideSize.cx/this.renderer.slideSize.cy)),l.style.cssText="flex-shrink:0; cursor:pointer; border:2px solid transparent; border-radius:3px; opacity:0.6; transition:opacity 0.2s,border-color 0.2s;",l.title=`Slide ${o+1}`;const a=o;l.addEventListener("click",()=>this.goto(a)),r.appendChild(l),this._thumbnails.push(l)}}t.addEventListener("click",()=>this.next()),this._buildNavArrows(t);const i=document.createElement("button");i.textContent="✕",i.style.cssText=["position:absolute","top:16px","right:20px","background:rgba(255,255,255,0.15)","border:none","color:white","font-size:18px","width:36px","height:36px","border-radius:50%","cursor:pointer","opacity:0.7","transition:opacity 0.2s"].join(";"),i.addEventListener("mouseover",()=>i.style.opacity="1"),i.addEventListener("mouseout",()=>i.style.opacity="0.7"),i.addEventListener("click",r=>{r.stopPropagation(),this.stop()}),n.appendChild(i),this.container.appendChild(n),n.focus(),this._resizeCanvas()}_buildNavArrows(n){const t=s=>{const i=document.createElement("button");i.textContent=s==="prev"?"❮":"❯",i.style.cssText=["position:absolute",s==="prev"?"left:16px":"right:16px","top:50%","transform:translateY(-50%)","background:rgba(255,255,255,0.18)","border:none","color:white","font-size:22px","width:48px","height:64px","border-radius:8px","cursor:pointer","opacity:0","transition:opacity 0.2s"].join(";"),i.addEventListener("mouseenter",()=>i.style.opacity="1"),i.addEventListener("mouseleave",()=>i.style.opacity="0"),i.addEventListener("click",r=>{r.stopPropagation(),s==="prev"?this.prev():this.next()}),n.addEventListener("mouseenter",()=>i.style.opacity="0.5"),n.addEventListener("mouseleave",()=>i.style.opacity="0"),n.appendChild(i)};t("prev"),t("next")}_resizeCanvas(){if(!this._canvas||!this._el)return;const{cx:n,cy:t}=this.renderer.slideSize,s=n/t,i=this._canvas.parentElement,r=i.clientWidth||window.innerWidth,o=i.clientHeight||window.innerHeight*.75;let l=r,a=l/s;a>o&&(a=o,l=a*s),this._canvas.width=Math.round(l*window.devicePixelRatio),this._canvas.height=Math.round(a*window.devicePixelRatio),this._canvas.style.width=Math.round(l)+"px",this._canvas.style.height=Math.round(a)+"px"}async _renderCurrent(n=null){if(this._canvas){if(this._resizeCanvas(),n!==null&&this.renderer.getTransition){const t=this.renderer.getTransition(this._index);if(t&&t.type!=="cut"&&typeof OffscreenCanvas<"u"){const{renderTransitionFrame:s}=await Qt(async()=>{const{renderTransitionFrame:c}=await Promise.resolve().then(()=>Qo);return{renderTransitionFrame:c}},void 0,import.meta.url),i=new OffscreenCanvas(this._canvas.width,this._canvas.height);i.getContext("2d").drawImage(this._canvas,0,0),await this.renderer.renderSlide(this._index,this._canvas,this._canvas.width/window.devicePixelRatio);const r=new OffscreenCanvas(this._canvas.width,this._canvas.height);r.getContext("2d").drawImage(this._canvas,0,0);const o=this._canvas.getContext("2d"),l=t.duration||700,a=performance.now();await new Promise(c=>{const d=h=>{const u=Math.min(1,(h-a)/l);s(o,i,r,t,u),u<1?requestAnimationFrame(d):c()};requestAnimationFrame(d)}),this._updateThumbnail(this._index),this._updateNotes();return}}await this.renderer.renderSlide(this._index,this._canvas,this._canvas.width/window.devicePixelRatio),this._updateThumbnail(this._index),this._updateNotes()}}_updateThumbnail(n){const t=this._thumbnails[n];!t||!this._canvas||(t.getContext("2d").drawImage(this._canvas,0,0,t.width,t.height),this._thumbnails.forEach((s,i)=>{s.style.borderColor=i===this._index?"#4af":"transparent",s.style.opacity=i===this._index?"1":"0.6"}))}_updateHud(){if(!this._hudEl)return;const n=this.renderer.slideCount;this._hudEl.innerHTML=`
|
|
124
|
+
<span style="opacity:0.7">Slide</span>
|
|
125
|
+
<strong>${this._index+1}</strong>
|
|
126
|
+
<span style="opacity:0.5">of ${n}</span>
|
|
127
|
+
`}async _updateNotes(){if(this._notesEl)try{const n=await this.renderer.getSlideNotes(this._index);this._notesEl.textContent=n||"(no notes)"}catch{this._notesEl.textContent=""}}async _generateThumbnails(){for(let n=0;n<this.renderer.slideCount&&this._playing;n++){const t=this._thumbnails[n];if(t){try{await this.renderer.renderSlide(n,t,t.width)}catch{}await new Promise(s=>setTimeout(s,50))}}}_attachEvents(){document.addEventListener("keydown",this._onKey),window.addEventListener("resize",this._onResize),document.addEventListener("fullscreenchange",this._onFsChange),this._el&&(this._el.addEventListener("touchstart",this._onTouchStart,{passive:!0}),this._el.addEventListener("touchend",this._onTouchEnd,{passive:!0}))}_detachEvents(){document.removeEventListener("keydown",this._onKey),window.removeEventListener("resize",this._onResize),document.removeEventListener("fullscreenchange",this._onFsChange)}_onKey(n){if(this._playing)switch(n.key){case"ArrowRight":case"ArrowDown":case" ":case"PageDown":n.preventDefault(),this.next();break;case"ArrowLeft":case"ArrowUp":case"PageUp":case"Backspace":n.preventDefault(),this.prev();break;case"Home":n.preventDefault(),this.goto(0);break;case"End":n.preventDefault(),this.goto(this.renderer.slideCount-1);break;case"Escape":case"q":case"Q":n.preventDefault(),this.stop();break;case"f":case"F":n.preventDefault(),this._toggleFullscreen();break}}_onResize(){this._resizeCanvas(),this._renderCurrent()}_onFsChange(){document.fullscreenElement||this.stop()}_onTouchStart(n){this._touchStartX=n.touches[0].clientX,this._touchStartY=n.touches[0].clientY}_onTouchEnd(n){const t=n.changedTouches[0].clientX-this._touchStartX,s=n.changedTouches[0].clientY-this._touchStartY;Math.abs(t)>40&&Math.abs(t)>Math.abs(s)?t<0?this.next():this.prev():Math.abs(t)<10&&Math.abs(s)<10&&this.next()}async _requestFullscreen(){try{const n=this._el;n.requestFullscreen?await n.requestFullscreen():n.webkitRequestFullscreen&&await n.webkitRequestFullscreen()}catch{}}async _toggleFullscreen(){document.fullscreenElement?await document.exitFullscreen().catch(()=>{}):await this._requestFullscreen()}_startAutoAdvance(){this._stopAutoAdvance(),this.opts.autoAdvance>0&&(this._autoTimer=setInterval(()=>this.next(),this.opts.autoAdvance))}_stopAutoAdvance(){this._autoTimer&&(clearInterval(this._autoTimer),this._autoTimer=null)}_resetAutoAdvance(){this.opts.autoAdvance>0&&this._startAutoAdvance()}}function Vs(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}async function Pa(e,n,t={}){typeof t=="number"&&(t={width:t});const{width:s=null,dpi:i=150}=t,r=s??Vs(n,i),o=await Ys(e,n,r),l=o.toDataURL("image/png");if(navigator.clipboard&&window.ClipboardItem)try{const c=await new Promise(d=>o.toBlob(d,"image/png"));return await navigator.clipboard.write([new ClipboardItem({"image/png":c})]),{success:!0,method:"clipboard-api",dataUrl:l}}catch(c){if(c.name!=="NotAllowedError")throw c}if(document.execCommand)try{const c=new Image;c.src=l,await new Promise(g=>{c.onload=g});const d=document.createElement("div");d.contentEditable="true",d.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;",d.appendChild(c),document.body.appendChild(d);const h=document.createRange();h.selectNodeContents(d);const u=window.getSelection();u.removeAllRanges(),u.addRange(h);const p=document.execCommand("copy");if(document.body.removeChild(d),u.removeAllRanges(),p)return{success:!0,method:"execCommand",dataUrl:l}}catch{}const a=window.open();return a&&(a.document.write(`<img src="${l}" style="max-width:100%">`),a.document.title=`Slide ${e+1}`),{success:!1,method:"opened-tab",dataUrl:l}}async function Hs(e,n,t={},s){typeof t=="number"&&(t={width:t});const{width:i=null,dpi:r=300,filename:o}=t,l=i??Vs(n,r),c=(await Ys(e,n,l)).toDataURL("image/png"),d=o||`slide-${e+1}.png`,h=document.createElement("a");h.href=c,h.download=d,h.click()}async function Sa(e,n={},t){typeof n=="number"&&(n={width:n});const{onProgress:s,...i}=n,r=s,o=e.slideCount;for(let l=0;l<o;l++)await Hs(l,e,i),r?.(l+1,o),await new Promise(a=>setTimeout(a,100))}async function Ys(e,n,t){const{cx:s,cy:i}=n.slideSize,r=s/i,o=Math.round(t/r),l=document.createElement("canvas");return l.width=t,l.height=o,await n.renderSlide(e,l,t),l}function Ta(e,n,t={}){const{thumbWidth:s=320,fullWidth:i=1280,gap:r="24px",background:o="#1a1a1a",slideBackground:l="#fff",shadow:a=!0,clickToShow:c=!1,maxWidth:d="900px",rootMargin:h=200,onSlideVisible:u,onSlideRendered:p}=t,{cx:g,cy:b}=e.slideSize,_=g/b,y=e.slideCount;n.style.cssText=`
|
|
128
|
+
background:${o};
|
|
129
|
+
padding:${r};
|
|
130
|
+
display:flex;
|
|
131
|
+
flex-direction:column;
|
|
132
|
+
align-items:center;
|
|
133
|
+
gap:${r};
|
|
134
|
+
overflow-y:auto;
|
|
135
|
+
position:relative;
|
|
136
|
+
`;const w=[],x=[],P=[];for(let M=0;M<y;M++){const F=document.createElement("div");F.style.cssText=`
|
|
137
|
+
width:100%;
|
|
138
|
+
max-width:${d};
|
|
139
|
+
position:relative;
|
|
140
|
+
background:${l};
|
|
141
|
+
border-radius:4px;
|
|
142
|
+
${a?"box-shadow:0 4px 24px rgba(0,0,0,0.5);":""}
|
|
143
|
+
overflow:hidden;
|
|
144
|
+
aspect-ratio:${g}/${b};
|
|
145
|
+
flex-shrink:0;
|
|
146
|
+
`,F.setAttribute("data-slide",M);const S=document.createElement("div");S.style.cssText=`
|
|
147
|
+
position:absolute;bottom:8px;right:10px;
|
|
148
|
+
background:rgba(0,0,0,0.45);color:#fff;
|
|
149
|
+
font:11px/1.4 system-ui,sans-serif;
|
|
150
|
+
padding:2px 7px;border-radius:10px;
|
|
151
|
+
pointer-events:none;z-index:1;
|
|
152
|
+
`,S.textContent=M+1,F.appendChild(S);const $=document.createElement("canvas");$.style.cssText="display:block;width:100%;height:100%;",$.width=s,$.height=Math.round(s/_),F.appendChild($);const R=ja(M,g,b,l);F.appendChild(R),c&&(F.style.cursor="pointer",F.addEventListener("click",()=>{new(require("./slideshow.js")).SlideShow(e,document.body).start(M)})),n.appendChild(F),w.push(F),x.push($),P.push("pending")}const v=[];let k=!1;async function T(){if(!(k||v.length===0)){for(k=!0;v.length>0;){const M=v.shift();if(P[M]==="full")continue;const F=x[M],$=w[M].querySelector("[data-placeholder]");try{F.width=i,F.height=Math.round(i/_),await e.renderSlide(M,F,i),P[M]="full",F.style.transition="opacity 0.3s",F.style.opacity="1",$&&($.style.display="none"),p?.(M)}catch(R){console.warn(`LazyDeck: failed to render slide ${M}`,R)}}k=!1}}const N=new IntersectionObserver(M=>{for(const F of M){if(!F.isIntersecting)continue;const S=parseInt(F.target.getAttribute("data-slide"),10);if(!(isNaN(S)||P[S]==="full")){u?.(S);for(const $ of[S,S-1,S+1,S+2].filter(R=>R>=0&&R<y))P[$]!=="full"&&!v.includes($)&&v.push($);T()}}},{root:n,rootMargin:`${h}px`,threshold:0});return w.forEach(M=>N.observe(M)),{destroy(){N.disconnect(),n.innerHTML=""},scrollTo(M,F="smooth"){const S=w[M];S&&S.scrollIntoView({behavior:F,block:"start"})},async renderAll(M){for(let F=0;F<y;F++)P[F]!=="full"&&v.push(F);await T()},getCanvas(M){return x[M]||null},get slideCount(){return y}}}function ja(e,n,t,s){const i=document.createElement("div");i.setAttribute("data-placeholder","1"),i.style.cssText=`
|
|
153
|
+
position:absolute;inset:0;
|
|
154
|
+
display:flex;align-items:center;justify-content:center;
|
|
155
|
+
background:${s};
|
|
156
|
+
flex-direction:column;gap:12px;
|
|
157
|
+
`;const r=`
|
|
158
|
+
<div style="width:55%;height:18px;background:#e0e0e0;border-radius:3px;animation:pulse 1.4s ease-in-out infinite;"></div>
|
|
159
|
+
<div style="width:72%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.1s;"></div>
|
|
160
|
+
<div style="width:62%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.2s;"></div>
|
|
161
|
+
<div style="width:45%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.3s;"></div>
|
|
162
|
+
`;if(!document.getElementById("_pptx_lazy_css")){const o=document.createElement("style");o.id="_pptx_lazy_css",o.textContent="@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}",document.head.appendChild(o)}return i.innerHTML=r,i}class Fa{constructor(){this._files={},this.slideSize={cx:9144e3,cy:5143500},this.slidePaths=[],this.slideCount=0,this.themeData=null,this.themeColors={},this.masterDoc=null,this.masterRels={},this.masterImages={},this._blobUrls=[],this.embeddedFonts=[]}async load(n,t=()=>{}){let s;if(n instanceof Uint8Array)s=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);else if(n instanceof ArrayBuffer)s=n;else if(typeof n.arrayBuffer=="function")s=await n.arrayBuffer();else throw new TypeError("PptxRenderer.load(): expected File, Blob, ArrayBuffer, or Uint8Array");t(.05,"Decompressing…"),this._files=await Ss(s),t(.1,"Parsing presentation…");const i=this._readText("ppt/presentation.xml");if(!i)throw new Error("Invalid PPTX: missing ppt/presentation.xml");const r=xe(i),o=m(r,"sldSz");o&&(this.slideSize={cx:C(o,"cx",9144e3),cy:C(o,"cy",5143500)});const l=await Le(this._files,"ppt/presentation.xml");if(this.embeddedFonts=Qr(r,l),this.embeddedFonts.length>0){const h=this.embeddedFonts.map(u=>u.family).join(", ");console.info("[pptx-browser] PPTX contains embedded fonts: "+h+". Use registerFont() to supply woff2/ttf versions.")}const a=m(r,"sldIdLst");if(a)for(const h of a.children){if(h.localName!=="sldId")continue;const u=h.getAttribute("r:id")||h.getAttribute("id"),p=l[u];p&&this.slidePaths.push(p.fullPath)}this.slideCount=this.slidePaths.length,t(.2,"Loading theme…");let c=Object.values(l).find(h=>h.type?.includes("theme"))?.fullPath;if(!c){const h=Object.values(l).find(u=>u.type?.includes("slideMaster"));if(h){const u=await Le(this._files,h.fullPath);c=Object.values(u).find(p=>p.type?.includes("theme"))?.fullPath}}if(c){const h=this._readText(c);h&&(this.themeData=qr(xe(h)))}this.themeData||(this.themeData={colors:{},majorFont:"Calibri Light",minorFont:"Calibri"}),this.themeColors={...this.themeData.colors},t(.3,"Loading master…");const d=Object.values(l).find(h=>h.type?.includes("slideMaster"));if(d){const h=this._readText(d.fullPath);if(h){this.masterDoc=xe(h),this.masterRels=await Le(this._files,d.fullPath),this.masterImages=await Gt(this._files,this.masterRels),this._trackBlobs(this.masterImages);const u=Kr(this.masterDoc);this.themeColors=Xr(this.themeData,u)}}t(1,"Ready")}async renderSlide(n,t,s=1280){if(n<0||n>=this.slidePaths.length)throw new RangeError(`Slide ${n} out of range (0–${this.slidePaths.length-1})`);const i=this.slidePaths[n],r=this._readText(i);if(!r)throw new Error(`Could not read slide: ${i}`);const o=xe(r),l=await Le(this._files,i),a=await Gt(this._files,l);this._trackBlobs(a);let c=null,d={},h={};const u=Object.values(l).find(v=>v.type?.includes("slideLayout"));if(u){const v=this._readText(u.fullPath);v&&(c=xe(v),d=await Le(this._files,u.fullPath),h=await Gt(this._files,d),this._trackBlobs(h))}const p={...this.masterImages,...h,...a},g=Rs([c,this.masterDoc]),b=to([o,c,this.masterDoc]);await eo(b,this.themeData);const _=s/this.slideSize.cx,y=Math.round(this.slideSize.cy*_);t.width=s,t.height=y;const w=t.getContext("2d");w.clearRect(0,0,s,y),await Es(w,o,this.masterDoc,c,l,this.masterRels,p,this.themeColors,_,this.slideSize.cx,this.slideSize.cy),await this._renderNonPlaceholders(w,this.masterDoc,this.masterRels,this.masterImages,_),await this._renderNonPlaceholders(w,c,d,h,_);const x=m(o,"cSld"),P=x?m(x,"spTree"):null;P&&await zs(w,P,l,p,this.themeColors,this.themeData,_,g,this._files)}async renderAllSlides(n=320){const t=[];for(let s=0;s<this.slideCount;s++){const i=document.createElement("canvas");await this.renderSlide(s,i,n),t.push(i)}return t}registerFont(n,t,s){return bn(n,t,s)}registerFonts(n){return Yr(n)}listRegisteredFonts(){return no()}_readText(n){const t=this._files[n];return t?new TextDecoder().decode(t):null}_trackBlobs(n){for(const t of Object.values(n))t?.src?.startsWith("blob:")&&this._blobUrls.push(t.src)}async _renderNonPlaceholders(n,t,s,i,r){if(!t)return;const o=m(t,"cSld"),l=o?m(o,"spTree"):null;if(l)for(const a of l.children){const c=a.localName;if(!["sp","pic","grpSp","graphicFrame","cxnSp"].includes(c))continue;const d=m(a,"nvSpPr"),h=d?m(d,"nvPr"):null;if(!(h&&m(h,"ph")))try{c==="sp"?await en(n,a,s,i,this.themeColors,this.themeData,r):c==="pic"?await tn(n,a,s,i,this.themeColors,r):c==="grpSp"?await nn(n,a,s,i,this.themeColors,this.themeData,r):c==="graphicFrame"?await rn(n,a,this.themeColors,this.themeData,r):c==="cxnSp"&&await sn(n,a,this.themeColors,r)}catch(u){console.warn(`[PptxRenderer] master/layout shape error (${c}):`,u)}}}getAnimations(n){const t=this.slidePaths[n];if(!t||!this._files)return[];const s=this._files[t];if(!s)return[];const i=xe(new TextDecoder().decode(s));return $n(i)}getTransition(n){const t=this.slidePaths[n];if(!t||!this._files)return null;const s=this._files[t];if(!s)return null;const i=xe(new TextDecoder().decode(s));return En(i)}createPlayer(n){return new Gs(this,n)}async toSvg(n){return Xs(n,this)}async allToSvg(){return ca(this)}async loadEmbeddedFonts(){const n=this._presRels||{};return ua(this._files,n)}listEmbeddedFonts(){return fa(this._files)}async extractSlide(n){return ln(n,this)}async extractAll(){return wa(this)}async extractText(n){return ka(n,this)}async searchSlides(n){return xa(n,this)}createShow(n,t={}){return new _a(this,n,t)}async copySlide(n,t={}){return Pa(n,this,t)}async downloadSlide(n,t={}){return Hs(n,this,t)}async downloadAllSlides(n={}){return Sa(this,n)}createDeck(n,t={}){return Ta(this,n,t)}edit(){return Ht.fromRenderer(this)}async toPdf(n={}){return An(this,n)}async downloadPdf(n="presentation.pdf",t={}){return qo(this,n,t)}async slideToPdf(n,t={}){return Ko(n,this,t)}async getSlideNotes(n){if(n<0||n>=this.slidePaths.length)return"";const t=await Le(this._files,this.slidePaths[n]),s=Object.values(t).find(l=>l.type?.includes("notesSlide"));if(!s)return"";const i=this._readText(s.fullPath);if(!i)return"";const r=xe(i),o=[];for(const l of ue(r,"sp")){const a=m(m(l,"nvSpPr"),"nvPr"),c=a?m(a,"ph"):null;if(!(c&&O(c,"type")==="sldNum"))for(const d of ue(l,"t"))o.push(d.textContent)}return o.join("").trim()}getInfo(){return{slideCount:this.slideCount,widthEmu:this.slideSize.cx,heightEmu:this.slideSize.cy,width:this.slideSize.cx/914400,height:this.slideSize.cy/914400,aspectRatio:this.slideSize.cx/this.slideSize.cy}}async toDataURL(n,t=1280,s="image/png",i=.92){const r=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas");if(await this.renderSlide(n,r,t),r instanceof OffscreenCanvas){const o=await r.convertToBlob({type:s,quality:i});return new Promise(l=>{const a=new FileReader;a.onload=()=>l(a.result),a.readAsDataURL(o)})}return r.toDataURL(s,i)}async toBlob(n,t=1280,s="image/png"){const i=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas");return await this.renderSlide(n,i,t),i instanceof OffscreenCanvas?i.convertToBlob({type:s}):new Promise(r=>i.toBlob(r,s))}destroy(){for(const n of this._blobUrls)try{URL.revokeObjectURL(n)}catch{}this._blobUrls=[],this._files={},this.masterDoc=null,this.masterImages={}}}const Ca=({asset:e,bytes:n,onOpenExternal:t,dense:s=!1})=>{const i=B.useRef(null),r=B.useRef(null),[o,l]=B.useState({phase:"loading",progress:0}),[a,c]=B.useState(0),[d,h]=B.useState(1),[u,p]=B.useState(0),[g,b]=B.useState(!1),[_,y]=B.useState([]),[w,x]=B.useState(!s),P=B.useRef(null),[v,k]=B.useState(!1);B.useEffect(()=>{x(!s)},[s]),B.useLayoutEffect(()=>{const F=P.current;if(!F)return;const S=()=>k(F.getBoundingClientRect().height<360);S();const $=new ResizeObserver(S);return $.observe(F),()=>$.disconnect()},[]),B.useEffect(()=>{let F=!1;const S=new Fa;return i.current=S,l({phase:"loading",progress:0}),c(0),h(1),S.load(n,$=>{F||l({phase:"loading",progress:$})}).then(async()=>{if(F)return;const $=S.slideCount,W=(await S.renderAllSlides(160)).map(Q=>Q.toDataURL("image/png"));F||l({phase:"ready",slideCount:$,thumbnails:W})}).catch($=>{F||l({phase:"error",detail:$ instanceof Error&&$.message?$.message:j("ui.library.preview.pptx_failed_detail")})}),()=>{F=!0,S.destroy(),i.current=null}},[n,u]);const T=B.useCallback(async()=>{const F=i.current,S=r.current;if(!(!F||!S||o.phase!=="ready"))try{await F.renderSlide(a,S,Math.round(960*d))}catch($){l({phase:"error",detail:$ instanceof Error&&$.message?$.message:j("ui.library.preview.pptx_failed_detail")})}},[a,o.phase,d]);B.useEffect(()=>{T()},[T]),B.useEffect(()=>{const F=i.current;if(!F||o.phase!=="ready")return;let S=!1;return F.extractSlide(a).then($=>{S||y($.textShapes.map(R=>R.text.trim()).filter(Boolean))}).catch(()=>{S||y([])}),()=>{S=!0}},[a,o.phase]);const N=o.phase==="ready"?o.slideCount:0,M=F=>{N!==0&&c(Math.min(Math.max(F,0),N-1))};return o.phase==="error"?f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx("p",{className:"text-body text-ink",children:j("ui.library.preview.pptx_failed")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:o.detail}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Y,{variant:"secondary",size:"sm",onClick:()=>p(F=>F+1),children:j("ui.library.preview.retry")}),f.jsxs(Y,{variant:"secondary",size:"sm",disabled:g,onClick:()=>{b(!0),ot(e).catch(F=>Se(F instanceof Error&&F.message?F.message:j("ui.library.menu.save_failed"))).finally(()=>b(!1))},children:[f.jsx(rt,{"aria-hidden":"true"}),j("ui.library.menu.download")]}),t&&f.jsxs(Y,{variant:"ghost",size:"sm",onClick:t,children:[f.jsx(gs,{"aria-hidden":"true"}),j("ui.library.preview.open_externally")]})]})]}):f.jsxs("div",{ref:P,className:"flex min-h-0 flex-1 flex-col gap-2 p-3","data-pptx-viewer":"",onKeyDown:F=>{F.key==="ArrowRight"||F.key==="PageDown"?(F.preventDefault(),M(a+1)):F.key==="ArrowLeft"||F.key==="PageUp"?(F.preventDefault(),M(a-1)):F.key==="Home"?(F.preventDefault(),M(0)):F.key==="End"&&(F.preventDefault(),M(N-1))},children:[f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[f.jsx("div",{"data-pptx-slide":"",className:"flex min-h-[120px] min-w-0 flex-1 flex-col items-center justify-center rounded-md bg-canvas p-2",children:o.phase==="loading"?f.jsxs("div",{className:"flex w-60 flex-col items-center gap-2",children:[f.jsx(Pt,{size:18,"aria-hidden":"true",className:"motion-safe:animate-spin text-ink-muted"}),f.jsx(Li,{value:Math.round(o.progress*100)}),f.jsx("span",{className:"text-meta text-ink-muted",children:j("ui.library.preview.pptx_preparing")})]}):f.jsx("canvas",{ref:r,className:"max-h-full max-w-full rounded-xs bg-surface","aria-label":j("ui.library.preview.slide_of",{index:String(a+1),count:String(N)})})}),o.phase==="ready"&&!v&&!s&&f.jsx("div",{className:"flex h-[72px] shrink-0 flex-row gap-1 overflow-x-auto overflow-y-hidden",children:o.thumbnails.map((F,S)=>f.jsx("button",{type:"button",onClick:()=>c(S),"aria-pressed":S===a,"aria-label":j("ui.library.preview.go_to_slide",{index:String(S+1)}),className:qe("h-16 w-24 shrink-0 rounded-xs border p-0.5",S===a?"border-accent":"border-hairline hover:border-control"),children:f.jsx("img",{src:F,alt:"",loading:"lazy",className:"h-full w-full rounded-xs object-contain"})},S))})]}),o.phase==="ready"&&f.jsxs("div",{className:"shrink-0 rounded-md bg-canvas px-2 py-1","data-pptx-transcript":"",children:[s?f.jsx(Y,{variant:"ghost",size:"sm","aria-expanded":w,onClick:()=>x(F=>!F),children:j("ui.library.preview.pptx_text")}):null,w&&f.jsx("div",{className:"max-h-24 overflow-y-auto text-meta text-ink-muted",children:_.length?_.map((F,S)=>f.jsx("p",{"data-pptx-transcript-line":"",className:"truncate",children:F},`${S}:${F}`)):f.jsx("p",{children:j("ui.library.preview.pptx_no_text")})})]}),f.jsxs("div",{className:"flex min-h-10 shrink-0 flex-wrap items-center justify-between gap-1 px-1 py-1",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.previous_slide"),disabled:a===0||o.phase!=="ready",onClick:()=>M(a-1),children:f.jsx(Tn,{"aria-hidden":"true"})}),f.jsx("span",{className:"text-meta tabular-nums text-ink-muted",children:j("ui.library.preview.slide_of",{index:String(N?a+1:0),count:String(N)})}),f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.next_slide"),disabled:a>=N-1||o.phase!=="ready",onClick:()=>M(a+1),children:f.jsx(Bi,{"aria-hidden":"true"})})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.zoom_out"),onClick:()=>h(F=>Math.max(.5,F-.25)),children:f.jsx(_i,{"aria-hidden":"true"})}),f.jsxs("span",{className:"w-10 text-center text-meta tabular-nums text-ink-muted",children:[Math.round(d*100),"%"]}),f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.zoom_in"),onClick:()=>h(F=>Math.min(2,F+.25)),children:f.jsx(Pi,{"aria-hidden":"true"})}),f.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>h(1),disabled:d===1,children:j("ui.library.preview.fit")})]})]})]})},ut=({label:e})=>f.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 py-10 text-body-sm text-ink-muted",children:[f.jsx(Pt,{size:16,"aria-hidden":"true",className:"motion-safe:animate-spin"}),e??j("ui.library.preview.loading")]}),ft=({detail:e,asset:n})=>{const[t,s]=B.useState(!1);return f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(dt,{kind:n.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:j("ui.library.preview.could_not_load")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:e}),f.jsxs(Y,{variant:"secondary",size:"sm",disabled:t,onClick:()=>{s(!0),ot(n).catch(i=>Se(i instanceof Error&&i.message?i.message:j("ui.library.menu.save_failed"))).finally(()=>s(!1))},children:[f.jsx(rt,{"aria-hidden":"true"}),j("ui.library.menu.download")]})]})},cs=({asset:e})=>f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(dt,{kind:e.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"max-w-90 text-body text-ink",children:j("ui.library.preview.unsupported",{kind:e.kind})}),f.jsxs("div",{className:"flex items-center gap-2",children:[e.ref.type==="path"&&e.ref.path?f.jsx(Y,{variant:"secondary",size:"sm",onClick:()=>{e.ref.path&&window.api.openFile(e.ref.path)},children:j("ui.library.preview.open_externally")}):null,f.jsxs(Y,{variant:"secondary",size:"sm",onClick:()=>void ot(e),children:[f.jsx(rt,{"aria-hidden":"true"}),j("ui.library.menu.download")]})]})]}),Ma=({asset:e})=>{const{bytes:n,mimeType:t,error:s,loading:i}=et(e.id,"content",!0),r=Mn(n,t||e.ref.content_type);if(i)return f.jsx(ut,{});if(s||!r)return f.jsx(ft,{detail:s||"The bytes were empty.",asset:e});switch(e.kind){case"image":return f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-canvas p-3",children:f.jsx("img",{src:r,alt:e.name||e.derived_name,className:"max-h-full max-w-full object-contain"})});case"audio":return f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6",children:[f.jsx(dt,{kind:"audio",size:32,className:"text-ink-dim"}),f.jsx("audio",{src:r,controls:!0,className:"w-full max-w-100",children:f.jsx("track",{kind:"captions"})})]});default:return f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-canvas p-3",children:f.jsx("video",{src:r,controls:!0,className:"max-h-full max-w-full rounded-sm",children:f.jsx("track",{kind:"captions"})})})}},Na=({asset:e})=>{const{bytes:n,mimeType:t,error:s,loading:i}=et(e.id,"content",!0),r=Mn(n,t||e.ref.content_type);return i?f.jsx(ut,{}):s||!r?f.jsx(ft,{detail:s||"The bytes were empty.",asset:e}):f.jsx("iframe",{title:e.name||e.derived_name,src:r,className:"size-full flex-1 border-0 bg-surface",sandbox:e.kind==="html"?"allow-scripts":void 0})},Aa=({asset:e,text:n})=>{const t=e.ref.type==="path"&&!!e.ref.path&&e.exists,s=e.ref.path,[i,r]=B.useState({state:"pending"});B.useEffect(()=>{if(!t||!s)return;let l=!1;return ni(s).then(a=>{l||r({state:"done",mtimeMs:a?.mtimeMs??null})}),()=>{l=!0}},[t,s]);const o=B.useMemo(()=>!t||!s||i.state!=="done"?null:Or(e,n,i.mtimeMs),[e,t,s,i,n]);return t&&i.state==="pending"?f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center",children:f.jsx(ut,{label:j("ui.library.preview.checking_file")})}):o?f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto bg-canvas",children:f.jsxs("div",{className:"mx-auto flex w-full max-w-[760px] flex-col gap-4 px-6 py-8",children:[f.jsx("p",{className:"text-meta text-ink-dim",children:j("ui.library.preview.breadcrumb",{name:o.title})}),f.jsx(si,{document:o})]})}):f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:f.jsxs("div",{className:"mx-auto max-w-[720px]",children:[f.jsx("p",{className:"mb-4 text-meta text-ink-muted",children:j("ui.library.preview.read_only_markdown")}),f.jsx("div",{className:"prose-lo max-w-none text-body text-ink",children:f.jsx(Si,{remarkPlugins:[Ti],children:n})})]})})},$a=({asset:e})=>{const{bytes:n,error:t,loading:s}=et(e.id,"content",!0);if(s)return f.jsx(ut,{});if(t||!n)return f.jsx(ft,{detail:t||"The bytes were empty.",asset:e});const i=new TextDecoder("utf-8",{fatal:!1}).decode(n);return e.kind==="markdown"?f.jsx(Aa,{asset:e,text:i}):f.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-4 font-mono text-mono-sm whitespace-pre-wrap break-words text-ink",children:i})},Ea=({asset:e})=>{const{bytes:n,error:t,loading:s}=et(e.id,"content",!0);return s?f.jsx(ut,{}):t||!n?f.jsx(ft,{detail:t||"The bytes were empty.",asset:e}):f.jsx(Ra,{asset:e,bytes:n})},ds=200,us=40,Ra=({asset:e,bytes:n})=>{const t=(()=>{try{const r=ii(n,{type:"array"}),o=r.SheetNames[0];if(!o)return null;const l=ri.sheet_to_json(r.Sheets[o],{header:1,raw:!1,defval:""});return{name:o,rows:l}}catch{return null}})();if(!t)return f.jsx(ft,{detail:j("ui.library.preview.sheet_unreadable"),asset:e});const s=t.rows.slice(0,ds),i=t.rows.length>ds;return f.jsxs("div",{className:"min-h-0 flex-1 overflow-auto p-2",children:[f.jsxs("table",{className:"w-full border-collapse text-meta",children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{className:"sticky top-0 bg-sunken px-2 py-1 text-left text-ink-muted",children:"#"}),(s[0]??[]).slice(0,us).map((r,o)=>f.jsx("th",{className:"sticky top-0 border-b border-hairline bg-sunken px-2 py-1 text-left font-medium text-ink-muted",children:String.fromCharCode(65+o%26)},o))]})}),f.jsx("tbody",{children:s.map((r,o)=>f.jsxs("tr",{className:"odd:bg-canvas",children:[f.jsx("td",{className:"px-2 py-1 text-right tabular-nums text-ink-dim",children:o+1}),r.slice(0,us).map((l,a)=>f.jsx("td",{className:"max-w-60 truncate border-b border-hairline px-2 py-1 font-mono text-ink",children:String(l??"")},a))]},o))})]}),i&&f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:j("ui.library.preview.sheet_truncated")}),f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:j("ui.library.preview.sheet_name",{name:t.name})})]})},Ia=({asset:e,dense:n=!1})=>e.kind==="pptx"?f.jsx(za,{asset:e,dense:n}):e.kind==="image"||e.kind==="audio"||e.kind==="video"?f.jsx(Ma,{asset:e}):e.kind==="pdf"||e.kind==="html"?f.jsx(Na,{asset:e}):e.kind==="markdown"||e.kind==="text"||e.kind==="code"?f.jsx($a,{asset:e}):e.kind==="spreadsheet"?f.jsx(Ea,{asset:e}):e.kind==="docx"?f.jsx(cs,{asset:e}):f.jsx(cs,{asset:e}),za=({asset:e,dense:n=!1})=>{const{bytes:t,error:s,loading:i}=et(e.id,"content",!0);return i?f.jsx(ut,{label:j("ui.library.preview.pptx_opening")}):s||!t?f.jsx(ft,{detail:s||"The bytes were empty.",asset:e}):f.jsx(Ca,{asset:e,bytes:t,dense:n})};function Da(e){const n=vr(!0),t=kr().create,s=wr(),[i,r]=B.useState(!1);return{commit:async l=>{r(!0);try{const a=new Map([...n.data??[],...e.tags].map(d=>[d.name.toLowerCase(),d.id])),c=[];for(const d of l){const h=d.trim().toLowerCase();if(!h)continue;let u=a.get(h);u||(u=(await t.mutateAsync({name:h})).id,a.set(h,u)),c.includes(u)||c.push(u)}await s.mutateAsync({id:e.id,tags:c})}catch(a){Se(a instanceof Error&&a.message?a.message:j("ui.library.preview.tags_not_saved"))}finally{r(!1)}},saving:i}}const fs=({asset:e,nowMs:n,onClose:t,onOpenConversation:s,onFilterSession:i,onAsk:r,onToggleFavorite:o,composerFocusSignal:l,focusRequest:a,standalone:c=!1,onExpand:d})=>{jn();const h=ks(),{commit:u,saving:p}=Da(e),g=B.useRef(null),b=B.useRef(null),_=B.useRef(null),[y,w]=B.useState(!1),[x,P]=B.useState(!1);B.useLayoutEffect(()=>{const M=g.current;if(!M)return;const F=()=>w(M.getBoundingClientRect().height<700);F();const S=new ResizeObserver(F);return S.observe(M),()=>S.disconnect()},[]);const v=B.useMemo(()=>e.tags.map(M=>M.name),[e.tags]);B.useEffect(()=>{a&&(a.field==="tags"?(_.current?.scrollIntoView({block:"center"}),_.current?.querySelector("input")?.focus()):(b.current?.scrollIntoView({block:"center"}),b.current?.querySelector("button")?.click()))},[a?.signal]);const k=async M=>{try{await h.mutateAsync({id:e.id,fields:M})}catch(F){throw Se(F instanceof Error&&F.message?F.message:j("ui.library.preview.not_saved")),F}},T=async M=>{try{await h.mutateAsync({id:e.id,fields:{[M]:!e[M]}})}catch(F){Se(F instanceof Error&&F.message?F.message:j("ui.library.preview.not_saved"))}},N=()=>{if(e.ref.type==="path"&&e.ref.path){window.api.openFile(e.ref.path);return}ot(e).catch(()=>Se(j("ui.library.menu.save_failed")))};return f.jsxs("div",{ref:g,className:"flex h-full min-h-0 flex-col bg-canvas","data-library-preview":e.id,"data-library-compact":y?"":void 0,"data-glass-region":"pane",children:[f.jsxs("header",{className:"flex shrink-0 flex-col gap-2 px-4 pt-3 pb-2",children:[c&&f.jsxs(Y,{variant:"ghost",size:"sm",className:"self-start",onClick:t,children:[f.jsx(Tn,{"aria-hidden":"true"}),j("ui.library.page.back")]}),f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(dt,{kind:e.kind,size:18,className:"mt-1.5 text-ink-dim"}),f.jsx("div",{ref:b,className:"min-w-0 flex-1",children:f.jsx(zn,{label:j("ui.library.preview.name"),value:St(e),onSave:M=>k({name:M}),isSaving:h.isPending})}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[f.jsx(Lt,{content:e.favorite?j("ui.library.menu.unfavorite"):j("ui.library.menu.favorite"),children:f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-pressed":e.favorite,"aria-label":e.favorite?j("ui.library.menu.unfavorite"):j("ui.library.menu.favorite"),onClick:()=>void T("favorite"),children:f.jsx(_t,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0})})}),f.jsx(Lt,{content:e.locked?j("ui.library.preview.unlock"):j("ui.library.preview.lock"),children:f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-pressed":e.locked,"aria-label":e.locked?j("ui.library.preview.unlock"):j("ui.library.preview.lock"),onClick:()=>void T("locked"),children:e.locked?f.jsx(oi,{"aria-hidden":"true",className:"text-accent"}):f.jsx(ai,{"aria-hidden":"true"})})}),d&&f.jsx(Lt,{content:j("ui.library.preview.expand"),children:f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.expand"),onClick:d,children:f.jsx(ji,{"aria-hidden":"true"})})}),f.jsx(Nn,{asset:e,onAsk:r,onEditMetadata:()=>{b.current?.querySelector("button")?.click()},onEditTags:()=>{_.current?.scrollIntoView({block:"center"}),_.current?.querySelector("input")?.focus()},onToggleFavorite:o,onOpenConversation:s,onFilterSession:i}),f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.close"),onClick:t,children:f.jsx(bt,{"aria-hidden":"true"})})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta text-ink-muted",children:[f.jsx(st,{variant:"neutral",children:e.kind}),f.jsx(st,{variant:"neutral",children:j(Cn(e.origin_group))}),f.jsx("span",{children:Fn(e.size_bytes)}),e.width&&e.height?f.jsxs("span",{children:[e.width,"×",e.height]}):null,e.organized?f.jsx("span",{children:j("ui.library.preview.organized_by",{by:e.organized.by??"librarian",at:hr(e.organized.at,n)})}):f.jsx("span",{children:j("ui.library.preview.unorganized")}),e.exists?null:f.jsx(st,{variant:"warning",children:j("ui.library.preview.missing_file")})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs(Y,{variant:"secondary",size:"sm",onClick:N,children:[f.jsx(gs,{"aria-hidden":"true"}),j("ui.library.preview.open")]}),e.ref.type==="path"&&e.ref.path?f.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(gn,{"aria-hidden":"true"}),j("ui.library.preview.reveal")]}):null,f.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>void ot(e).then(()=>mn(j("ui.library.menu.saved_a_copy"))).catch(()=>Se(j("ui.library.menu.save_failed"))),children:[f.jsx(rt,{"aria-hidden":"true"}),j("ui.library.preview.download")]}),e.occurrences[0]?f.jsx(Y,{variant:"link",size:"sm",onClick:()=>s(e.occurrences[0].session_id),children:j("ui.library.preview.from_conversation",{title:e.occurrences[0].session_title||e.occurrences[0].session_id})}):null]}),y&&f.jsxs(Y,{variant:"ghost",size:"sm",className:"self-start","aria-expanded":x,onClick:()=>P(M=>!M),children:[f.jsx(Oi,{"aria-hidden":"true",className:qe("transition-transform duration-fast",x&&"rotate-180")}),j("ui.library.preview.details")]}),(!y||x)&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex flex-col gap-1",children:f.jsx(zn,{label:j("ui.library.preview.description"),value:e.description,multiline:!0,rows:3,placeholder:j("ui.library.preview.add_description"),onSave:M=>k({description:M}),isSaving:h.isPending})}),f.jsxs("div",{ref:_,className:"flex items-start gap-2",children:[f.jsx("div",{className:"min-w-0 flex-1",children:f.jsx(Ki,{label:j("ui.library.preview.tags"),value:v,disabled:p,onChange:M=>void u(M),placeholder:j("ui.library.preview.add_tag")})}),p&&f.jsx(Pt,{size:14,"aria-hidden":"true",className:"mt-6 motion-safe:animate-spin text-ink-muted"})]})]})]}),f.jsx("div",{className:"flex min-h-0 flex-1 flex-col bg-sunken",children:f.jsx(Ia,{asset:e,dense:y})}),f.jsx("div",{className:"shrink-0",children:f.jsx(Br,{asset:e,focusSignal:l,compact:y})})]})},Qs="library-view",Zs="library-filters",La=1152,Ba=1200,Oa=900;function Ua(){try{return localStorage.getItem(Qs)==="list"?"list":"grid"}catch{return"grid"}}function Ga(){try{const e=sessionStorage.getItem(Zs);if(!e)return Bt;const n=JSON.parse(e);return{...Bt,...n,scope:n.scope==="all"?"all":"final",q:""}}catch{return Bt}}function Wa(e){try{sessionStorage.setItem(Zs,JSON.stringify({...e,q:""}))}catch{}}function qa(){const[e,n]=B.useState(null),[t,s]=B.useState(0);return B.useLayoutEffect(()=>{if(!e)return;s(e.getBoundingClientRect().width);const i=new ResizeObserver(r=>{const o=r[0];o&&s(o.contentRect.width)});return i.observe(e),()=>i.disconnect()},[e]),{ref:n,width:t}}function Ka(){const[e,n]=B.useState(()=>window.innerWidth);return B.useEffect(()=>{const t=()=>n(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e}const Xa=({enabled:e,nowMs:n})=>{const t=ws(e),s=Pr(),i=Sn(),r=t.data;if(!r)return null;const o=r.last_run_at??r.last_run?.at??null,l=r.unorganized??r.library?.unorganized??null;return f.jsxs("div",{className:"flex h-10 shrink-0 flex-wrap items-center gap-x-3 gap-y-1 overflow-hidden text-meta text-ink-muted","data-library-librarian":"",children:[f.jsx("span",{className:"font-medium text-ink",children:j("ui.library.librarian.title")}),f.jsx("span",{children:r.paused?j("ui.library.librarian.paused"):r.enabled?j("ui.library.librarian.enabled"):j("ui.library.librarian.disabled")}),f.jsx("span",{children:o?j("ui.library.librarian.last_organized",{at:Va(o,n)}):j("ui.library.librarian.never_run")}),l!==null&&l>0&&f.jsx("span",{children:j("ui.library.librarian.unorganized",{count:l})}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[f.jsxs(Y,{variant:"ghost",size:"sm",disabled:!r.enabled||s.isPending,onClick:()=>s.mutate("run",{onError:a=>Se(a instanceof Error?a.message:j("ui.library.librarian.control_failed"))}),children:[f.jsx(pn,{"aria-hidden":"true"}),j("ui.library.librarian.organize_now")]}),f.jsx(Y,{variant:"ghost",size:"sm",disabled:!r.session_id||s.isPending,onClick:()=>s.mutate("open",{onSuccess:a=>{a?.session_id&&pt(i,a.session_id)},onError:a=>Se(a instanceof Error?a.message:j("ui.library.librarian.control_failed"))}),children:j("ui.library.librarian.open")})]})]})};function Va(e,n){const t=Math.max(0,n-e*1e3),s=Math.floor(t/36e5);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}const Ha=({onBack:e})=>f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Dt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:j("ui.library.preview.unavailable")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:j("ui.library.preview.unavailable_detail")}),f.jsxs(Y,{variant:"secondary",size:"sm",onClick:e,children:[f.jsx(Tn,{"aria-hidden":"true"}),j("ui.library.page.back")]})]}),Ya=({nowMs:e})=>{jn();const n=Sn(),t=Fi(),s=Ci(),i=Mi(),r=Ni(i.data,"library",1),o=ws(r),l=e??Date.now(),{ref:a,width:c}=qa(),d=Ka(),h=new URLSearchParams(t.search).get("full")==="1",u=d>=Ba&&c>=Oa,[p,g]=B.useState(Ga),[b,_]=B.useState(""),y=li(b,200),[w,x]=B.useState(Ua),[P,v]=B.useState(!1),[k,T]=B.useState(0),[N,M]=B.useState(null),F=B.useRef(null),S=s.assetId??null,$=c>=La&&!!S&&!h;B.useEffect(()=>{g(E=>E.q===y?E:{...E,q:y})},[y]),B.useEffect(()=>Wa(p),[p]),B.useEffect(()=>{try{localStorage.setItem(Qs,w)}catch{}},[w]);const R=br(p,r),W=ks(),Q=yr(S,r),D=B.useMemo(()=>{const E=R.data?.pages??[],X=E.length>1&&E.at(-1)?.cursor_reset?[E.at(-1)]:E,V=new Set,ae=[];for(const ce of X)for(const te of ce?.rows??[])V.has(te.id)||(V.add(te.id),ae.push(te));return ae},[R.data]),U=R.data?.pages.at(-1),K=U?.total??0,J=D.find(E=>E.id===S)??null,q=Q.data??J,I=()=>void R.fetchNextPage(),Z=!!(S&&!q&&!Q.isLoading&&Q.isError),ee=!!S&&!$,re=B.useCallback(E=>{n(`/library/assets/${E}${t.search}`,{state:t.state})},[n,t.search,t.state]),de=B.useCallback(()=>{const E=new URLSearchParams(t.search);E.delete("full");const L=E.toString();n(`/library${L?`?${L}`:""}`)},[n,t.search]),oe=B.useCallback(()=>{if(!S)return;const E=new URLSearchParams(t.search);E.set("full","1"),n(`/library/assets/${S}?${E.toString()}`)},[n,S,t.search]),H=B.useCallback(E=>{re(E.id),T(L=>L+1)},[re]),me=B.useCallback(E=>{W.mutate({id:E.id,fields:{favorite:!E.favorite}})},[W]),ne=B.useCallback(E=>void pt(n,E),[n]),se=B.useCallback(E=>{g(L=>({...L,session:E})),n("/library")},[n]),fe={onSelect:re,onAsk:H,onEditMetadata:E=>{re(E.id),M({field:"metadata",signal:Date.now()})},onEditTags:E=>{re(E.id),M({field:"tags",signal:Date.now()})},onToggleFavorite:me,onOpenConversation:ne,onFilterSession:se};if(B.useEffect(()=>{const E=L=>{const X=L.target,V=X?.tagName==="INPUT"||X?.tagName==="TEXTAREA"||X?.isContentEditable;if(L.key==="f"&&(L.metaKey||L.ctrlKey)||L.key==="/"&&!V){L.preventDefault(),F.current?.focus();return}if(!(V||L.metaKey||L.ctrlKey||L.altKey)){if(L.key==="Escape"){S&&de();return}if(L.key.toLowerCase()==="g"){L.preventDefault(),x(ae=>ae==="grid"?"list":"grid");return}if(L.key.toLowerCase()==="j"||L.key.toLowerCase()==="k"){if(ee||D.length===0)return;L.preventDefault();const ae=S?D.findIndex(ke=>ke.id===S):-1,ce=L.key.toLowerCase()==="j"?1:-1,te=Math.min(Math.max(ae===-1?ce===1?0:D.length-1:ae+ce,0),D.length-1);re(D[te].id)}}};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[de,re,D,S,ee]),!r)return f.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[f.jsx(Ei,{title:j("ui.library.page.title"),icon:Dt}),i.isLoading?f.jsx("div",{className:"flex justify-center py-16",children:f.jsx(On,{label:j("ui.library.page.checking")})}):f.jsx(un,{variant:"warning",children:j("ui.library.page.unavailable")})]});const we=o.data?.library?.total??null,be=f.jsx(Rr,{filters:p,onChange:E=>{g({...E,q:E.q}),_(E.q)},counts:U?.counts,tags:U?.tags??[],total:K,scopeTotal:we}),ye=D.length===0&&!R.isLoading,le=dr(p),z=R.error instanceof Error&&R.error.message?R.error.message:j("ui.library.page.load_failed");return f.jsxs("div",{ref:a,"data-glass-region":"canvas","data-glass-split":"",className:"flex h-full min-h-0 overflow-hidden bg-canvas",children:[u&&!ee&&f.jsx("aside",{"data-library-rail":"","data-glass-region":"page-sidebar","aria-label":j("ui.library.page.filters"),className:"flex w-48 shrink-0 flex-col overflow-hidden border-r border-hairline bg-surface",children:be}),f.jsxs("div",{"data-glass-region":"canvas-content",className:"flex min-w-0 flex-1 flex-col",children:[f.jsxs("header",{"data-library-header":"",className:"flex shrink-0 flex-col gap-1 px-6 pt-4 pb-2 min-[800px]:min-h-[136px]",children:[f.jsxs("div",{className:"flex h-12 min-w-0 items-center gap-2",children:[f.jsx(Dt,{size:20,"aria-hidden":"true",className:"text-ink-muted"}),f.jsx("h1",{className:"text-title text-ink",children:j("ui.library.page.title")}),f.jsx("span",{className:"ml-2 text-meta tabular-nums text-ink-dim",children:j("ui.library.page.loaded_count",{loaded:String(D.length),total:String(K)})}),f.jsxs("div",{className:"ml-auto flex items-center rounded-sm border border-control",children:[f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-pressed":w==="grid","aria-label":j("ui.library.page.grid_view"),onClick:()=>x("grid"),children:f.jsx(Ai,{"aria-hidden":"true"})}),f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-pressed":w==="list","aria-label":j("ui.library.page.list_view"),onClick:()=>x("list"),children:f.jsx(ci,{"aria-hidden":"true"})})]})]}),f.jsxs("div",{className:"flex h-12 min-w-0 items-center gap-2",children:[f.jsxs("div",{className:"relative min-w-60 flex-1",children:[f.jsx($i,{size:14,"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-ink-dim"}),f.jsx(Ui,{ref:F,value:b,onChange:E=>_(E.target.value),onKeyDown:E=>{E.key==="Enter"&&E.preventDefault()},placeholder:j("ui.library.page.search"),"aria-label":j("ui.library.page.search"),"data-library-search":"",className:"pl-8"})]}),f.jsxs(ms,{children:[f.jsx(bs,{asChild:!0,children:f.jsxs(Y,{variant:"secondary",size:"sm",children:[f.jsx(Un,{"aria-hidden":"true"}),j("ui.library.page.sort")]})}),f.jsx(ys,{align:"end",className:"min-w-45",children:lr.map(E=>f.jsxs(Ce,{onSelect:()=>g(L=>({...L,sort:E.key,order:cr(E.key)})),children:[p.sort===E.key?f.jsx(Gi,{"aria-hidden":"true"}):f.jsx("span",{className:"size-4"}),f.jsx("span",{children:j(E.labelKey)})]},E.key))})]}),f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.page.reverse_order"),onClick:()=>g(E=>({...E,order:E.order==="asc"?"desc":"asc"})),children:p.order==="asc"?f.jsx(Zi,{"aria-hidden":"true"}):f.jsx(Un,{"aria-hidden":"true"})}),!u&&!ee&&f.jsxs(Y,{variant:"secondary",size:"sm",onClick:()=>v(!0),children:[f.jsx(di,{"aria-hidden":"true"}),j("ui.library.page.filters")]})]}),f.jsx("div",{"data-library-librarian-track":"",className:"min-h-10 shrink-0",children:f.jsx(Xa,{enabled:r,nowMs:l})}),U?.state==="building"&&f.jsx("div",{"data-library-building":"",className:"flex h-4 items-center gap-2 text-meta text-ink-muted","aria-live":"polite",children:f.jsx("span",{children:j("ui.library.page.building",{scanned:String(U.scan.sessions_scanned),total:String(U.scan.sessions_total)})})})]}),f.jsx("div",{className:"flex min-h-0 flex-1",children:f.jsxs("div",{className:"flex min-w-0 flex-1",children:[!ee&&f.jsx("section",{"data-library-results":"","aria-label":j("ui.library.page.results"),"aria-busy":R.isLoading||R.isFetching,className:"min-w-0 flex-1 overflow-y-auto px-4 py-4 [scrollbar-gutter:stable]",children:R.isLoading?f.jsx($r,{view:w}):R.isError&&D.length===0?f.jsxs("div",{className:"flex flex-col items-start gap-3 py-10",children:[f.jsx(un,{variant:"warning",children:z}),f.jsxs(Y,{variant:"secondary",size:"sm",onClick:()=>void R.refetch(),children:[f.jsx(pn,{"aria-hidden":"true"}),j("ui.library.page.retry")]})]}):ye?f.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-center",children:[f.jsx(Dt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:le?j("ui.library.page.no_matches"):j("ui.library.page.empty_title")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:le?j("ui.library.page.no_matches_detail"):j("ui.library.page.empty_detail")}),le&&f.jsx(Y,{variant:"secondary",size:"sm",onClick:()=>{g({...Bt,scope:p.scope}),_("")},children:j("ui.library.page.clear_all")})]}):f.jsxs(f.Fragment,{children:[R.isRefetchError&&f.jsx(un,{variant:"warning",role:"alert","data-library-partial-error":"",className:"mb-3 items-center gap-2 py-2",children:f.jsxs("div",{"data-library-partial-row":"",className:"flex w-full min-w-0 items-center gap-2",children:[f.jsx("span",{className:"min-w-0 flex-1",children:z}),f.jsxs(Y,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void R.refetch(),children:[f.jsx(pn,{"aria-hidden":"true"}),j("ui.library.page.retry")]})]})}),f.jsx(Ar,{assets:D,selectedId:S,view:w,hasMore:!!R.hasNextPage,loadingMore:R.isFetchingNextPage,onLoadMore:I,...fe}),R.isFetchNextPageError&&f.jsxs("div",{className:"flex items-center gap-2 py-3 text-meta text-ink-muted",children:[f.jsx("span",{children:j("ui.library.page.load_more_failed")}),f.jsx(Y,{variant:"ghost",size:"sm",onClick:I,children:j("ui.library.page.retry")})]})]})}),$&&q&&f.jsx("aside",{className:"flex w-[448px] shrink-0 border-l border-hairline","aria-label":j("ui.library.page.preview"),children:f.jsx(fs,{asset:q,nowMs:l,onClose:de,onOpenConversation:ne,onFilterSession:se,onAsk:()=>T(E=>E+1),onToggleFavorite:()=>me(q),composerFocusSignal:k,focusRequest:N,onExpand:oe})}),ee&&f.jsx("div",{className:"min-w-0 flex-1","aria-label":j("ui.library.page.preview"),children:Z?f.jsx(Ha,{onBack:de}):q?f.jsx(fs,{asset:q,nowMs:l,onClose:de,onOpenConversation:ne,onFilterSession:se,onAsk:()=>T(E=>E+1),onToggleFavorite:()=>me(q),composerFocusSignal:k,focusRequest:N,standalone:!0}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(On,{label:j("ui.library.preview.loading")})})}),!ee&&!q&&$&&f.jsx("div",{className:"hidden w-[448px] shrink-0 items-start justify-center border-l border-hairline p-8 lg:flex",children:f.jsx("p",{className:"max-w-60 text-center text-body-sm text-ink-dim",children:j("ui.library.page.select_asset")})})]})})]}),f.jsx(Wi,{open:P,onOpenChange:v,children:f.jsx(qi,{side:"left",className:"w-80 max-w-[calc(100vw-32px)] p-0",children:f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[f.jsx("span",{className:"text-heading text-ink",children:j("ui.library.page.filters")}),f.jsx(Y,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.page.close_filters"),onClick:()=>v(!1),children:f.jsx(bt,{"aria-hidden":"true"})})]}),f.jsx("div",{"data-library-filter-sheet":"",className:"min-h-0 flex-1 overflow-y-auto bg-surface",children:be})]})})})]})},rl=Object.freeze(Object.defineProperty({__proto__:null,LibraryPage:Ya},Symbol.toStringTag,{value:"Module"}));export{ue as a,O as b,m as g,rl as l};
|