local-operator-ui 0.41.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/out/main/index.js +0 -24
  2. package/out/renderer/assets/{_basePickBy--UFblcLV.js → _basePickBy-BP7Q8i4W.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-Ct7pRnI4.js → _baseUniq-D36dAcoY.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-Col1VcjS.js → agent-details-page-D3ljlPdf.js} +2 -2
  5. package/out/renderer/assets/{agent-hub-page-CTPn6yGs.js → agent-hub-page-BMyIHnNM.js} +2 -2
  6. package/out/renderer/assets/{agents-page-CBWj1DTr.js → agents-page-mMqgQd2V.js} +3 -3
  7. package/out/renderer/assets/{arc-B-YNVaQW.js → arc-GVvow4so.js} +1 -1
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DCzmuMLj.js → architectureDiagram-IEHRJDOE-BjGwXAtH.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-f1GS2_U0.js → blockDiagram-JOT3LUYC-BTuigKlt.js} +1 -1
  10. package/out/renderer/assets/{book-open-Cb4F-cRs.js → book-open-C1uak1LZ.js} +1 -1
  11. package/out/renderer/assets/browser-page-B3mjDx8k.js +1 -0
  12. package/out/renderer/assets/{browser-webauthn-prompt-ghcPWp0R.js → browser-webauthn-prompt-CzYoJfO4.js} +1 -1
  13. package/out/renderer/assets/{building-2-C_YBTC7O.js → building-2-Bpz1qaDa.js} +1 -1
  14. package/out/renderer/assets/{c4Diagram-VJAJSXHY-BlePs8Im.js → c4Diagram-VJAJSXHY-DK7eaKE8.js} +1 -1
  15. package/out/renderer/assets/channel-B05rL6In.js +1 -0
  16. package/out/renderer/assets/{chunk-4BMEZGHF-Bse1IaHb.js → chunk-4BMEZGHF-DkQrsDhM.js} +1 -1
  17. package/out/renderer/assets/{chunk-A2AXSNBT-CncpJ5It.js → chunk-A2AXSNBT-guh0INPR.js} +1 -1
  18. package/out/renderer/assets/{chunk-AEK57VVT-37Z6jWz2.js → chunk-AEK57VVT-DvgIx6-r.js} +1 -1
  19. package/out/renderer/assets/{chunk-D6G4REZN-BR9ZpBMV.js → chunk-D6G4REZN-FNdvnFYo.js} +1 -1
  20. package/out/renderer/assets/{chunk-RZ5BOZE2-KrZ6g0pV.js → chunk-RZ5BOZE2-CgCQC9Mn.js} +1 -1
  21. package/out/renderer/assets/{chunk-XZIHB7SX-BUwRYMe9.js → chunk-XZIHB7SX-D1VRTTc4.js} +1 -1
  22. package/out/renderer/assets/classDiagram-GIVACNV2-DpB8-8cT.js +1 -0
  23. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DpB8-8cT.js +1 -0
  24. package/out/renderer/assets/clone-BHHjv3HP.js +1 -0
  25. package/out/renderer/assets/{console-mirror-DPVG6sWK.js → console-mirror-DRkz3vUY.js} +1 -1
  26. package/out/renderer/assets/{consoleCapture-Coky9UhD.js → consoleCapture-BJfSUatx.js} +1 -1
  27. package/out/renderer/assets/{conversation-input-sync-C2vqs6ad.js → conversation-input-sync-CJU5GIzR.js} +5 -5
  28. package/out/renderer/assets/{dagre-OKDRZEBW-CGv1CEcm.js → dagre-OKDRZEBW-DeeYQh6O.js} +1 -1
  29. package/out/renderer/assets/{diagram-SSKATNLV-u_zFGYu8.js → diagram-SSKATNLV-DD-xNxKH.js} +1 -1
  30. package/out/renderer/assets/{diagram-VNBRO52H-Bme6bFvQ.js → diagram-VNBRO52H-YAoPlXaR.js} +1 -1
  31. package/out/renderer/assets/{erDiagram-Q7BY3M3F-B-KkjVtc.js → erDiagram-Q7BY3M3F-OKzGXyMI.js} +1 -1
  32. package/out/renderer/assets/{error-boundary-DJSaJHcb.js → error-boundary-ZYkSCpZC.js} +2 -2
  33. package/out/renderer/assets/{flowDiagram-4HSFHLVR-CSZy2b_d.js → flowDiagram-4HSFHLVR-BG-3pPqS.js} +1 -1
  34. package/out/renderer/assets/{ganttDiagram-APWFNJXF-CpYOSVKU.js → ganttDiagram-APWFNJXF-CRyD5vsE.js} +1 -1
  35. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-WOOSBsBb.js → gitGraphDiagram-7IBYFJ6S-aly2C__q.js} +1 -1
  36. package/out/renderer/assets/{graph-Du8nFp-Q.js → graph-CCWwMmhg.js} +1 -1
  37. package/out/renderer/assets/hash-BN0ECl3H.js +6 -0
  38. package/out/renderer/assets/{heart-CVGkdUzT.js → heart-tKYqMVIH.js} +1 -1
  39. package/out/renderer/assets/index-BDzV3bGH.js +57 -0
  40. package/out/renderer/assets/{index-fw54FEnm.js → index-BaNzqqGN.js} +1 -1
  41. package/out/renderer/assets/{index-D8L83jtw.js → index-CRjnV9wx.js} +199 -199
  42. package/out/renderer/assets/{index-AGCqaeOI.js → index-DaCf2W9T.js} +1 -1
  43. package/out/renderer/assets/index-ZovyVTxQ.css +1 -0
  44. package/out/renderer/assets/{infoDiagram-PH2N3AL5-BprulvMk.js → infoDiagram-PH2N3AL5-BY536sF5.js} +1 -1
  45. package/out/renderer/assets/{installer-muZhWyyS.js → installer-Dw1P6j8q.js} +1 -1
  46. package/out/renderer/assets/{journeyDiagram-U35MCT3I-DfdLRQAF.js → journeyDiagram-U35MCT3I-DGvx__t6.js} +1 -1
  47. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-R6IsuYWB.js → kanban-definition-NDS4AKOZ-CG2Lgkpw.js} +1 -1
  48. package/out/renderer/assets/{layout-05Xak_7z.js → layout-vpRrwE7T.js} +1 -1
  49. package/out/renderer/assets/{legacy-agents-page-Dpl33Kla.js → legacy-agents-page-D6Yma1Gm.js} +6 -6
  50. package/out/renderer/assets/library-page-B0gC-rRh.js +157 -0
  51. package/out/renderer/assets/{mermaid.core-BzKfajYZ.js → mermaid.core-COeGB8I0.js} +5 -5
  52. package/out/renderer/assets/{mesh-page-D6ZzFOeG.js → mesh-page-PabU05tN.js} +1 -1
  53. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Dn_l0i7j.js → mindmap-definition-ALO5MXBD-B0hkjZLY.js} +1 -1
  54. package/out/renderer/assets/{mini-BgJE9L7J.js → mini-Df5C4rpd.js} +1 -1
  55. package/out/renderer/assets/{notebook-pen-CtAKsfVm.js → notebook-pen-C3CwzwGA.js} +1 -1
  56. package/out/renderer/assets/{org-access-BHt55LAw.js → org-access-BacMtLkn.js} +1 -1
  57. package/out/renderer/assets/{org-surface-gate-CqFJQYmV.js → org-surface-gate-tkB025lu.js} +1 -1
  58. package/out/renderer/assets/{page-header-BlIvE-Ti.js → page-header-6mrV9W-E.js} +1 -1
  59. package/out/renderer/assets/{path-utils-CYBk4q7C.js → path-utils-Ct0VTUZS.js} +2 -2
  60. package/out/renderer/assets/{pieDiagram-IB7DONF6-_W_OzAAk.js → pieDiagram-IB7DONF6-DfFtQXU5.js} +1 -1
  61. package/out/renderer/assets/{projects-page-DtZ_g9gZ.js → projects-page-CoHTKLZH.js} +1 -1
  62. package/out/renderer/assets/{publication-validation-D7f3xAgF.js → publication-validation-B0Mf3mmP.js} +1 -1
  63. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-FQ5Wvxqm.js → quadrantDiagram-7GDLP6J5-C4eDJWaK.js} +1 -1
  64. package/out/renderer/assets/{radar-MK3ICKWK-BRufXucA.js → radar-MK3ICKWK-BEv1HS9Q.js} +1 -1
  65. package/out/renderer/assets/{radient-auth-buttons-7i7blC-7.js → radient-auth-buttons-BX5vf982.js} +1 -1
  66. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CHO8Cq1H.js → requirementDiagram-KVF5MWMF-B7f3qUcB.js} +1 -1
  67. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-C4JDJOwX.js → sankeyDiagram-QLVOVGJD-xM7E-74l.js} +1 -1
  68. package/out/renderer/assets/{schedules-page-6tPgFgS_.js → schedules-page-5q7pvL1H.js} +1 -1
  69. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BFf3HnKw.js → sequenceDiagram-X6HHIX6F-upwR02kU.js} +1 -1
  70. package/out/renderer/assets/{settings-page-CXOFCx8w.js → settings-page-DcnGr-GP.js} +9 -9
  71. package/out/renderer/assets/{smartart-crAq3DvJ.js → smartart-CYnMNs5u.js} +1 -1
  72. package/out/renderer/assets/{stateDiagram-DGXRK772-BqFVSIKA.js → stateDiagram-DGXRK772-BqTri7Q-.js} +1 -1
  73. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D8Sl1QhX.js +1 -0
  74. package/out/renderer/assets/team-bridge-page-vnNJdCi3.js +16 -0
  75. package/out/renderer/assets/{timeline-definition-BDJGKUSR-Cp3uYUSs.js → timeline-definition-BDJGKUSR-Bi2is17s.js} +1 -1
  76. package/out/renderer/assets/{use-download-agent-mutation-C_W8yx0C.js → use-download-agent-mutation-PHtokPlg.js} +2 -2
  77. package/out/renderer/assets/{use-session-snapshot-vFZD5qIO.js → use-session-snapshot-B5sxthdQ.js} +1 -1
  78. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DFcICu1Q.js → xychartDiagram-VJFVF3MP-B0TrjzLJ.js} +1 -1
  79. package/out/renderer/console-capture.html +5 -5
  80. package/out/renderer/index.html +7 -7
  81. package/out/renderer/installer.html +4 -4
  82. package/out/renderer/mini.html +7 -7
  83. package/package.json +2 -2
  84. package/out/renderer/assets/browser-page-BfJd3-qS.js +0 -1
  85. package/out/renderer/assets/channel-BFAjMbH6.js +0 -1
  86. package/out/renderer/assets/classDiagram-GIVACNV2-CmW0Ezdi.js +0 -1
  87. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CmW0Ezdi.js +0 -1
  88. package/out/renderer/assets/clone-B_pc7cSP.js +0 -1
  89. package/out/renderer/assets/hash--PQTQMu2.js +0 -6
  90. package/out/renderer/assets/index-ALGblIL0.css +0 -1
  91. package/out/renderer/assets/index-BYeiLB51.js +0 -57
  92. package/out/renderer/assets/library-page-BNrffbLi.js +0 -157
  93. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-aaVC-oiG.js +0 -1
  94. package/out/renderer/assets/team-bridge-page-BgjJrT3v.js +0 -26
@@ -0,0 +1,157 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./smartart-CYnMNs5u.js","./index-BDzV3bGH.js","./index-ZovyVTxQ.css","./console-mirror-DRkz3vUY.js","./path-utils-Ct0VTUZS.js","./console-mirror-DOrYoP_4.css","./page-header-6mrV9W-E.js","./error-boundary-ZYkSCpZC.js","./index-CRjnV9wx.js","./conversation-input-sync-CJU5GIzR.js","./conversation-input-sync-CAX4_ErH.css","./index-DHKnfVbX.css","./heart-tKYqMVIH.js","./hash-BN0ECl3H.js","./use-session-snapshot-B5sxthdQ.js"])))=>i.map(i=>d[i]);
2
+ import{t as T,r as E,j as f,c as ge}from"./index-BDzV3bGH.js";import{o as _s}from"./console-mirror-DRkz3vUY.js";import{a1 as wi,a2 as qn,a3 as xi,a4 as ki,a5 as _i,h as Nn,u as ft,a6 as Ge,d as Ae,a7 as Mn,r as en,a as An,c as yt,q as Si,Y as Pi,z as Ss,T as Ti,A as ji}from"./path-utils-Ct0VTUZS.js";import{P as Ci}from"./page-header-6mrV9W-E.js";import{c as jt,q as Ps,l as Dt,r as Ts,B as Z,s as js,w as $e,a9 as Fi,aa as Ni,ab as Mi,v as Wn,z as et,X as We,u as it,S as xt,x as Cs,ac as Ai,y as $i,A as bn,I as Ei,g as Ri,ad as zi,ae as Ii}from"./error-boundary-ZYkSCpZC.js";import{ci as Bt,cj as Kn,aO as $n,z as En,aL as Li,ck as Fs,cl as Di,cm as Bi,cn as Oi,co as Ui,cp as Gi,cq as qi,cc as Wi,cr as Ot,cs as Ki,ct as Vi,cu as wn}from"./index-CRjnV9wx.js";import{ap as qe,bx as Xi,az as Hi,by as xn,bz as Ns,bA as Yi,as as ct,aq as kn,T as Te,bB as Ms,bC as Et,bD as Qi,bE as Zi,bF as Ji,bG as Rn,bH as zn,bI as As,br as Vn,af as er,a7 as tr,a8 as nr,a9 as sr,ah as ir,bJ as rr,bK as or,bL as ar,bM as Xn,bd as tn,bN as $s,bk as In,bO as lr,bP as cr,bQ as Es,be as dr,bg as ur,bR as fr,bc as hr}from"./conversation-input-sync-CJU5GIzR.js";import{H as nn}from"./heart-tKYqMVIH.js";import{H as pr}from"./hash-BN0ECl3H.js";import{u as mr}from"./use-session-snapshot-B5sxthdQ.js";var gr=class extends wi{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:qn()})}getOptimisticResult(e){return e.behavior=qn(),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:ki(n,t.data),hasPreviousPage:xi(n,t.data),isFetchNextPageError:c,isFetchingNextPage:d,isFetchPreviousPageError:h,isFetchingPreviousPage:u,isRefetchError:l&&!c&&!h,isRefetching:r&&!d&&!u}}};function br(e,n){return _i(e,gr,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 yr=[["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"}]],Hn=jt("arrow-down-wide-narrow",yr);/**
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 vr=[["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"}]],wr=jt("arrow-up-narrow-wide",vr);/**
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 xr=[["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"}]],kr=jt("presentation",xr);/**
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 _r=[["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"}]],Sr=jt("sheet",_r);/**
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 Pr=[["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"}]],Tr=jt("tags",Pr),jr=["generated","created","mentioned"],_n=[{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"}],Cr=[{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"}],Ut={q:"",scope:"final",tagMode:"all",highlighted:!1,sort:"recent",order:"desc"};function Fr(e){return e==="name"||e==="kind"?"asc":"desc"}function Yn(e,n){return e.status===n}function Nr(e){return!!(e.q.trim()||e.category||e.originGroup||e.tag||e.session||e.highlighted||e.status)}function Mr(e){if(e==="unorganized")return!1}function De(e){return e.name.trim()||e.derived_name.trim()||e.id}function Rs(e){const n=e.derived_name.trim();return n?n===e.name.trim()?e.ref.display_path:n:e.ref.display_path}function Ar(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 Xt(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 $r(e,n){if(!e)return"";const t=n-e*1e3;if(t<6e4)return T("ui.library.time.just_now");const s=Math.floor(t/6e4);if(s<60)return T("ui.library.time.minutes_m_ago",{minutes:s});const i=Math.floor(s/60);if(i<24)return T("ui.library.time.hours_h_ago",{hours:i});const r=Math.floor(i/24);if(r<30)return T("ui.library.time.days_d_ago",{days:r});const o=Math.floor(r/30);return o<12?T("ui.library.time.months_mo_ago",{months:o}):T("ui.library.time.years_y_ago",{years:Math.floor(o/12)})}function Er(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 sn(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 Ne={all:["desktop","library"],list:e=>["desktop","library","list",e],detail:e=>["desktop","library","detail",e],tags:["desktop","library","tags"],librarian:["desktop","library","librarian"]},Rr=60;function zr(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=Mr(e.status);return t!==void 0?{organized:t}:{}})(),sort:e.sort,order:e.order,limit:Rr,...n?{cursor:n}:{}}}function Ir(e,n){return br({queryKey:Ne.list(e),enabled:n,initialPageParam:void 0,queryFn:({pageParam:t})=>Ae(zr(e,t)),getNextPageParam:t=>t.next_cursor??void 0,retry:en,refetchInterval:t=>t.state.data?.pages.at(-1)?.state==="building"?2e3:!1,staleTime:1e4})}function Lr(e,n){return Nn({queryKey:Ne.detail(e??""),enabled:n&&!!e,queryFn:()=>Ae({op:"library.get",id:e}),retry:en,staleTime:5e3})}function Dr(e){return Nn({queryKey:Ne.tags,enabled:e,queryFn:()=>Ae({op:"library.tags"}),retry:en,staleTime:2e4})}function zs(e){return Nn({queryKey:Ne.librarian,enabled:e,queryFn:()=>Ae({op:"library.librarian",action:"status"}).then(n=>"librarian"in n?n.librarian:n),retry:en,staleTime:3e4})}function Xe(e){return e.invalidateQueries({queryKey:Ne.all})}function Qn(e,n){return{...e,...n}}function Is(){const e=ft();return qe({mutationFn:n=>Ae({op:"library.update",id:n.id,fields:n.fields}),onMutate:async n=>{await e.cancelQueries({queryKey:Ne.all});const t=e.getQueryData(Ne.detail(n.id)),s=e.getQueriesData({queryKey:[...Ne.all,"list"]});t&&e.setQueryData(Ne.detail(n.id),Qn(t,n.fields));for(const[i,r]of s)r&&e.setQueryData(i,{...r,pages:r.pages.map(o=>({...o,rows:o.rows.map(l=>l.id===n.id?Qn(l,n.fields):l)}))});return{detail:t,lists:s}},onSuccess:n=>(e.setQueryData(Ne.detail(n.id),n),Xe(e)),onError:(n,t,s)=>{s?.detail&&e.setQueryData(Ne.detail(t.id),s.detail);for(const[i,r]of s?.lists??[])e.setQueryData(i,r);e.invalidateQueries({queryKey:Ne.detail(t.id)}),e.invalidateQueries({queryKey:Ne.all})},retry:Ge})}function Br(){const e=ft();return qe({mutationFn:n=>Ae({op:"library.tags.assign",id:n.id,tags:n.tags,...n.primary?{primary:n.primary}:{}}),onSuccess:n=>(e.setQueryData(Ne.detail(n.id),n),Xe(e)),onError:()=>Xe(e),retry:Ge})}function Or(){const e=ft(),n=()=>Xe(e),t=qe({mutationFn:o=>Ae({op:"library.tags.create",name:o.name,...o.category?{category:o.category}:{}}),onSuccess:n,retry:Ge}),s=qe({mutationFn:o=>Ae({op:"library.tags.update",id:o.id,...o.name!==void 0?{name:o.name}:{},...o.category!==void 0?{category:o.category}:{}}),onSuccess:n,retry:Ge}),i=qe({mutationFn:o=>Ae({op:"library.tags.delete",id:o.id}),onSuccess:n,retry:Ge}),r=qe({mutationFn:o=>Ae({op:"library.tags.merge",id:o.id,into:o.into}),onSuccess:n,retry:Ge});return{create:t,update:s,remove:i,merge:r}}function Ur(){const e=ft();return qe({mutationFn:n=>Ae({op:"library.chat.link",id:n.id,sessionId:n.sessionId}),onSuccess:()=>Xe(e),onError:()=>Xe(e),retry:Ge})}function Ls(){const e=ft();return qe({mutationFn:n=>Ae({op:"library.chat.clear",id:n.id}),onSuccess:()=>Xe(e),retry:Ge})}function Gr(){const e=ft();return qe({mutationFn:n=>Ae({op:"library.librarian",action:n}).then(t=>"librarian"in t?t.librarian:t),onSuccess:()=>Xe(e),retry:Ge})}function ht(e,n,t,s=!1){const[i,r]=E.useState({bytes:null,mimeType:"",error:null,loading:!1});return E.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}),Mn(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 Ds(e,n=!0){const[t,s]=E.useState(()=>e?Ht.get(e)??null:null);return E.useEffect(()=>{if(!e){s(null);return}if(s(Ht.get(e)??null),!n)return;let i=!0;return Wr(e).then(r=>{i&&s(r)}),()=>{i=!1}},[e,n]),t}const Ht=new Map,Zn=new Map;async function qr(e){try{const n=await Mn({op:"library.waveform",assetId:e},null);return n.kind==="json"?Xi(n.body):null}catch{return null}}function Wr(e){const n=Zn.get(e);if(n)return n;const t=qr(e).then(s=>(Ht.set(e,s),s)).catch(()=>(Ht.set(e,null),null));return Zn.set(e,t),t}function pt(e,n){const[t,s]=E.useState(null);return E.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 Kr=/[\\/]/;function Vr(e){const t=De(e).split(Kr).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 dt(e){const n=await Mn({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=Vr(e),i.rel="noopener",document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(s),3e4)}const Ln=({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),kn(p)}catch{Te(T("ui.library.menu.copy_failed"))}},c=async()=>{try{await dt(e),kn(T("ui.library.menu.saved_a_copy"))}catch{Te(T("ui.library.menu.save_failed"))}},d=!!(e.ref.type==="path"&&e.ref.path),h=e.occurrences;return f.jsxs(Ps,{children:[f.jsx(Dt,{content:T("ui.library.menu.asset_actions"),children:f.jsx(Ts,{asChild:!0,children:f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("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(Hi,{"aria-hidden":"true"})})})}),f.jsxs(js,{align:"end",className:"min-w-52",onClick:u=>u.stopPropagation(),children:[h.length===1?f.jsxs($e,{onSelect:()=>r(h[0].session_id),children:[f.jsx(Bt,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.open_source_conversation")})]}):h.length>1?f.jsxs(Fi,{children:[f.jsxs(Ni,{children:[f.jsx(Bt,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.open_source_conversation")})]}),f.jsx(Mi,{className:"min-w-60",children:h.map(u=>f.jsx($e,{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($e,{onSelect:n,children:[f.jsx(Bt,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.ask_about_asset")})]}),h.length>0&&f.jsxs($e,{onSelect:()=>o(h[0].session_id),children:[f.jsx(xn,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.show_from_conversation")})]}),f.jsx(Wn,{}),f.jsxs($e,{onSelect:i,children:[f.jsx(nn,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0}),f.jsx("span",{children:e.favorite?T("ui.library.menu.unfavorite"):T("ui.library.menu.favorite")})]}),f.jsxs($e,{onSelect:t,children:[f.jsx(Ns,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.edit_metadata")})]}),f.jsxs($e,{onSelect:s,children:[f.jsx(Tr,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.edit_tags")})]}),f.jsx(Wn,{}),e.ref.path?f.jsxs($e,{onSelect:()=>void a(e.ref.path,T("ui.library.menu.path_copied")),children:[f.jsx(Yi,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.copy_path")})]}):null,f.jsxs($e,{onSelect:()=>void a(e.id,T("ui.library.menu.asset_id_copied")),children:[f.jsx(pr,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.copy_asset_id")})]}),d?f.jsxs($e,{onSelect:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(xn,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.reveal_in_finder")})]}):f.jsxs($e,{onSelect:()=>void c(),children:[f.jsx(ct,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.download")})]}),e.ref.type==="artifact"&&f.jsxs($e,{onSelect:()=>void c(),children:[f.jsx(ct,{"aria-hidden":"true"}),f.jsx("span",{children:T("ui.library.menu.save_a_copy")})]})]})]})},Xr={image:Ji,audio:Zi,video:Qi,pdf:Et,pptx:kr,docx:Et,markdown:Et,html:Kn,spreadsheet:Sr,text:Et,code:Kn,other:Ms};function Hr(e){return Xr[e]??Ms}function Ye({kind:e,size:n=20,className:t}){const s=Hr(e);return f.jsx(s,{size:n,"aria-hidden":"true",className:t})}const Bs=({group:e})=>f.jsx(et,{variant:e==="generated"?"accent":"neutral",children:T(sn(e))}),Os=({asset:e,large:n=!1})=>{const[t,s]=zn("300px"),i=e.kind==="image"&&e.exists&&s,r=ht(e.id,"thumbnail",i),o=pt(r.bytes,r.mimeType);return f.jsx("div",{ref:t,className:ge("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(Ye,{kind:e.kind,size:n?28:22,className:"text-ink-dim"})})},Jn=()=>f.jsx("span",{className:"absolute top-1.5 left-1.5 flex size-5 items-center justify-center rounded-full bg-elevated",title:T("ui.library.card.highlighted"),children:f.jsx(En,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),Us=()=>f.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-elevated",title:T("ui.library.menu.favorite"),"data-library-favorite-mark":"",children:f.jsx(nn,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),Gs=({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(et,{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]})]})},Yr=({asset:e})=>{const[n,t]=zn("300px"),s=e.exists&&t,i=ht(e.id,"content",s),r=Ds(e.id,s),o=pt(i.bytes,i.mimeType||e.ref.content_type);return f.jsx("div",{ref:n,"data-library-audio-well":"",className:"relative flex aspect-[16/10] w-full shrink-0 items-center justify-center overflow-hidden bg-canvas px-2",children:o?f.jsx(As,{variant:"compact",ownerId:`sound:library:${e.id}`,src:o,label:De(e),peaks:r,durationHint:e.duration_s}):f.jsx(Ye,{kind:e.kind,size:28,className:"text-ink-dim"})})},Qr=({asset:e,selected:n,...t})=>{const s=e.kind==="audio",i=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:De(e)}),f.jsx("span",{className:"line-clamp-1 text-meta text-ink-dim",children:Rs(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:Xt(e.size_bytes)}),e.duration_s?f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:Er(e.duration_s)})]}):null]}),f.jsx(Gs,{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(Bt,{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(Bs,{group:e.origin_group}),f.jsxs("div",{className:"flex items-center gap-2",children:[e.session_count>1&&f.jsx("span",{className:"text-meta text-ink-dim",children:T("ui.library.card.conversations",{count:e.session_count})}),e.favorite&&f.jsx(Us,{})]})]})]}),r=f.jsxs("button",{type:"button",onClick:()=>t.onSelect(e.id),"aria-pressed":n,className:"flex w-full flex-1 flex-col text-left focus-visible:outline-offset-2",children:[s?null:f.jsxs("div",{className:"relative",children:[f.jsx(Os,{asset:e,large:!0}),e.highlighted&&f.jsx(Jn,{})]}),i]});return f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:ge("group relative flex flex-col overflow-hidden rounded-lg border border-hairline bg-surface",n&&$n),children:[s&&f.jsxs("div",{className:"relative",children:[f.jsx(Yr,{asset:e}),e.highlighted&&f.jsx(Jn,{})]}),r,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(Ln,{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"})})]})},Zr=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:ge("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(Os,{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(En,{size:12,"aria-hidden":"true",className:"shrink-0 fill-current text-accent"}),De(e)]}),f.jsx("span",{className:"truncate text-meta text-ink-dim",children:Rs(e)})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-meta text-ink-muted",children:[f.jsx(Gs,{asset:e}),f.jsx("span",{children:e.kind}),f.jsx("span",{children:Xt(e.size_bytes)}),f.jsx(Bs,{group:e.origin_group}),e.favorite&&f.jsx(Us,{})]})]}),f.jsx(Ln,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession})]}),Jr=({assets:e,selectedId:n,view:t,hasMore:s,loadingMore:i,onLoadMore:r,...o})=>{const l=E.useRef(null);return E.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(Qr,{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(Zr,{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(Rn,{size:14,"aria-hidden":"true",className:"motion-safe:animate-spin"}),T("ui.library.grid.loading_more")]}),!i&&s&&f.jsx(Z,{variant:"ghost",size:"sm",onClick:r,children:T("ui.library.grid.load_more")})]})]})},eo=({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))}),to=[{key:"highlighted",labelKey:"ui.library.status.highlighted"},{key:"unorganized",labelKey:"ui.library.status.unorganized"},{key:"favorite",labelKey:"ui.library.status.favorites"}],Ke=({label:e,count:n,active:t,onPress:s,icon:i,indent:r=!1})=>f.jsxs("button",{type:"button",onClick:s,"aria-pressed":t,className:ge("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})]}),bt=({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})]}),no=({filters:e,onChange:n,counts:t,tags:s,total:i,scopeTotal:r})=>{const o=Ar(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",{"data-lo-sidebar-edge-cues":!0,className:"flex h-full flex-col gap-5 overflow-y-auto px-2 py-4","data-library-filter-rail":"",children:[c&&f.jsxs(Z,{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(We,{"aria-hidden":"true"}),T("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:T("ui.library.filter.one_conversation")}),f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.filter.clear_conversation"),onClick:()=>a({session:void 0}),children:f.jsx(We,{"aria-hidden":"true"})})]}),f.jsxs(bt,{label:T("ui.library.filter.scope"),children:[f.jsx(Ke,{label:T("ui.library.filter.scope_final"),active:e.scope==="final",onPress:()=>a({scope:"final"})}),f.jsx(Ke,{label:T("ui.library.filter.scope_all"),count:r??void 0,active:e.scope==="all",onPress:()=>a({scope:"all"})})]}),f.jsxs(bt,{label:T("ui.library.filter.categories"),children:[f.jsx(Ke,{label:T("ui.library.category.all"),count:i,active:!e.category,onPress:()=>a({category:void 0})}),_n.map(d=>f.jsx(Ke,{label:T(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(Ye,{kind:d.iconKind,size:14,className:"text-ink-dim"})},d.key)),Object.keys(l).filter(d=>!_n.some(h=>h.key===d)).sort().map(d=>f.jsx(Ke,{label:d,count:l[d],active:e.category===d,onPress:()=>a({category:e.category===d?void 0:d}),icon:f.jsx(Vn,{size:14,"aria-hidden":"true"})},d))]}),f.jsx(bt,{label:T("ui.library.filter.status"),children:to.map(d=>f.jsx(Ke,{label:T(d.labelKey),active:Yn(e,d.key),onPress:()=>a({status:Yn(e,d.key)?void 0:d.key}),icon:d.key==="favorite"?f.jsx(nn,{size:14,"aria-hidden":"true"}):d.key==="highlighted"?f.jsx(En,{size:14,"aria-hidden":"true"}):void 0},d.key))}),f.jsx(bt,{label:T("ui.library.filter.source"),children:jr.filter(d=>e.originGroup===d||e.scope==="all"||(t?.origin_group?.[d]??0)>0).map(d=>f.jsx(Ke,{label:T(sn(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(bt,{label:T("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(Ke,{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(Vn,{size:13,"aria-hidden":"true"}),indent:!0},h.id))]},d.category))}),e.tag&&f.jsx(et,{variant:"neutral",children:T("ui.library.filter.tag_mode",{mode:e.tagMode.toUpperCase()})})]})},es=({value:e,onSave:n,label:t,placeholder:s="",multiline:i=!1,rows:r=3,textClassName:o,allowEmpty:l=!1,startSignal:a,field:c,className:d})=>{it();const[h,u]=E.useState(!1),[p,m]=E.useState(e),[g,S]=E.useState(!1),y=E.useRef("closed"),w=E.useRef(null),x=E.useRef(null),_=()=>{y.current==="closed"&&(m(e),y.current="edit",u(!0))},v=N=>{y.current="closed",N&&x.current?.focus(),u(!1)},k=async N=>{if(y.current!=="edit")return;const L=p.trim();if(!L&&!l||L===e){v(N);return}y.current="saving",S(!0);try{await n(L),y.current==="saving"&&v(N)}catch{y.current==="saving"&&(y.current="edit",w.current?.focus())}finally{S(!1)}};E.useEffect(()=>{if(!h)return;const N=setTimeout(()=>{const L=w.current;L&&(L.focus(),L.select(),L.scrollLeft=0,L instanceof HTMLTextAreaElement&&(L.scrollTop=0))},0);return()=>clearTimeout(N)},[h]),E.useEffect(()=>{y.current==="closed"&&m(e)},[e]);const j=E.useRef(a);E.useEffect(()=>{const N=j.current;j.current=a,!(a===N||!a)&&_()},[a]);const M=N=>{if(!(N.nativeEvent.isComposing||N.keyCode===229)){if(N.key==="Enter"){if(i&&N.shiftKey)return;N.preventDefault(),k(!0)}else if(N.key==="Escape"){if(N.preventDefault(),y.current==="saving")return;v(!0)}}},F=N=>{h&&N.preventDefault()},R=N=>{m(N.target.value)},$=e.trim()?f.jsx("span",{onDoubleClick:_,className:ge("block min-w-0 cursor-default select-none",i?"whitespace-pre-wrap break-words":"truncate",o),children:e}):f.jsx("button",{type:"button",onClick:_,className:ge("block min-w-0 cursor-pointer truncate text-start text-ink-dim","transition-colors duration-fast ease-out-quart hover:text-ink-muted",o),children:s});return f.jsxs("div",{"data-inline-edit":c,className:ge("group/inline flex min-w-0 items-center gap-1",!h&&"w-fit max-w-full",h&&"w-full",i&&h&&"items-start",d),children:[h?i?f.jsx("textarea",{"data-inline-edit-input":"",ref:N=>{w.current=N},value:p,rows:r,readOnly:g,"aria-label":t,"aria-busy":g||void 0,onChange:R,onKeyDown:M,onBlur:()=>void k(!1),spellCheck:!1,className:ge("min-w-0 flex-1 resize-none border-0 bg-transparent p-0 outline-none","text-ink",o)}):f.jsx("input",{"data-inline-edit-input":"",ref:N=>{w.current=N},value:p,readOnly:g,"aria-label":t,"aria-busy":g||void 0,onChange:R,onKeyDown:M,onBlur:()=>void k(!1),spellCheck:!1,className:ge("min-w-0 flex-1 border-0 bg-transparent p-0 outline-none","text-ink",o)}):f.jsx("div",{className:"min-w-0 flex-1",children:$}),f.jsx("button",{type:"button",ref:x,"data-inline-edit-control":"","aria-label":g?T("ui.common.forms.editable_field.saving"):h?T("ui.common.forms.autocomplete_field.cancel_editing",{label:t}):T("ui.common.forms.editable_field.edit_v2",{label:t}),title:g?T("ui.common.forms.editable_field.saving"):h?T("ui.common.forms.editable_field.cancel_escape"):T("ui.common.forms.editable_field.edit"),"aria-busy":g||void 0,"aria-disabled":g||void 0,onMouseDown:F,onClick:N=>{if(!(N.detail>1)&&y.current!=="saving"){if(h){v(!0);return}_()}},className:ge("inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-xs","text-ink-dim transition-opacity duration-base ease-out-quart","hover:text-ink-muted",!h&&"opacity-0 group-hover/inline:opacity-100 group-hover/inline:duration-fast",!h&&"group-focus-within/inline:opacity-100 group-focus-within/inline:duration-fast"),children:g?f.jsx(xt,{size:"xs"}):h?f.jsx(We,{className:"size-3","aria-hidden":"true"}):f.jsx(Ns,{className:"size-3","aria-hidden":"true"})})]})},so=({value:e,onChange:n,label:t,addLabel:s,saving:i=!1,startSignal:r})=>{it();const[o,l]=E.useState(!1),[a,c]=E.useState(""),d=E.useRef(null),h=E.useRef(null),u=()=>{i||o||l(!0)},p=()=>{c(""),l(!1)},m=x=>{const _=a.trim().toLowerCase();_&&!e.some(v=>v.toLowerCase()===_)&&n([...e,_]),c(""),x?d.current?.focus():l(!1)},g=E.useRef(!1);E.useEffect(()=>{if(i){g.current=!0;return}if(!o){g.current=!1;return}const x=g.current;g.current=!1;const _=setTimeout(()=>{if(x){const v=document.activeElement,k=h.current;if(!(!v||v===document.body||!!k?.contains(v)))return}d.current?.focus()},0);return()=>clearTimeout(_)},[o,i]);const S=E.useRef(r);E.useEffect(()=>{const x=S.current;S.current=r,!(r===x||!r)&&u()},[r]);const y=x=>{x.nativeEvent.isComposing||x.keyCode===229||(x.key==="Enter"?(x.preventDefault(),m(!0)):x.key==="Escape"&&(x.preventDefault(),p()))},w=i?f.jsx(xt,{size:"xs"}):o?f.jsx("input",{ref:d,value:a,"aria-label":t,onChange:x=>c(x.target.value),onKeyDown:y,onBlur:()=>a.trim()?m(!1):p(),spellCheck:!1,className:ge("w-28 min-w-0 border-0 bg-transparent p-0 outline-none","text-body-sm text-ink placeholder:text-ink-dim"),placeholder:s}):f.jsxs("button",{type:"button",onClick:u,className:ge("inline-flex items-center gap-1 rounded-xs text-ink-dim","text-body-sm transition-colors duration-fast ease-out-quart hover:text-ink-muted"),children:[f.jsx(Li,{className:"size-3","aria-hidden":"true"}),s]});return f.jsxs("div",{ref:h,"data-inline-tags":"",className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.map(x=>f.jsxs(et,{variant:"neutral",shape:"pill",className:"gap-1 pr-1 text-ink",children:[x,f.jsx("button",{type:"button","aria-label":T("ui.chat.tags.remove_named",{name:x}),disabled:i,onClick:()=>n(e.filter(_=>_!==x)),className:ge("inline-flex size-5 -m-1 items-center justify-center rounded-xs","text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:f.jsx(We,{className:"size-3","aria-hidden":"true"})})]},x)),w]})},io=2e3;function Dn(e){return e.ref.type==="path"&&!!e.ref.path&&e.exists===!0}function ro(e,n){const t=Dn(e)?e.ref.path:null,[s,i]=E.useState({mtimeMs:null,sizeBytes:null,revision:0,missing:!1}),r=E.useRef(null),o=E.useRef(!1);E.useEffect(()=>{r.current=null,i({mtimeMs:null,sizeBytes:null,revision:0,missing:!1})},[t]);const l=E.useCallback(async()=>{if(!(!t||!window.api?.probeFiles)&&!o.current){o.current=!0;try{const[a]=await window.api.probeFiles([t],void 0,{fresh:!0});if(!a)return;const c=a.exists===!1&&!a.error,d=a.mtimeMs??null,h=d!==null&&d!==r.current;r.current=d,i(u=>({mtimeMs:d,sizeBytes:a.sizeBytes??null,revision:h?u.revision+1:u.revision,missing:c}))}finally{o.current=!1}}},[t]);return E.useEffect(()=>{l()},[l,n]),E.useEffect(()=>{if(!t)return;const a=()=>void l(),c=()=>{document.visibilityState==="visible"&&l()};window.addEventListener("focus",a),document.addEventListener("visibilitychange",c);const d=window.setInterval(()=>{document.visibilityState==="visible"&&l()},io);return()=>{window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",c),window.clearInterval(d)}},[t,l]),s}const oo=[];function ao(e){const n=e.ref.display_path||e.ref.path||(e.ref.digest?`attachment digest ${e.ref.digest}`:e.id);return`${De(e)} (${n})`}function lo(e,n,t){if(e.kind!=="image"||!n||n.length===0)return null;let s="";const i=32768;for(let o=0;o<n.length;o+=i)s+=String.fromCharCode(...n.subarray(o,Math.min(o+i,n.length)));return`data:${e.ref.content_type||t};base64,${btoa(s)}`}const co=({asset:e,focusSignal:n,onSessionChange:t,showLinkedRow:s,onOpenChat:i,refreshSignal:r=0,streaming:o})=>{it();const l=E.useRef(null),a=An(),{frontend:c,refresh:d}=mr(),h=E.useRef(!1),[u,p]=E.useState(!1),[m,g]=E.useState({}),[S,y]=E.useState(null),w=e.chat?.session_id??m[e.id]??null,x=m[e.id]??null,_=S===e.id,v=Ur(),k=Ls(),j=ht(e.id,"content",e.kind==="image"),M=w??`library:${e.id}`;E.useEffect(()=>{w&&d(w)},[w,d,r]),E.useEffect(()=>{n!==0&&l.current?.focusInput()},[n]);const F=async()=>{const $=x??e.chat?.session_id;if($)try{await v.mutateAsync({id:e.id,sessionId:$}),g(N=>{const L={...N};return delete L[e.id],L}),y(null)}catch{Te(T("ui.library.composer.link_failed_short"))}},R=async($,N,L)=>{const H=$.trim();if(!H||h.current)return!1;h.current=!0,p(!0);const D=o??c?.streaming===!0;let U=w;try{const q=lo(e,j.bytes,j.mimeType),{images:Q,unreadable:J,overflow:I}=await tr(q?[...N,q]:N,$),V=nr(J);if(V)return Te(V),!1;const oe=sr(I);if(oe)return Te(oe),!1;if(!U){const Y=Si.getState();if(U=await Y.createSession(Y.cwd||"~"),!U)throw new Error(Y.error??T("ui.library.composer.could_not_start"))}const ee=U,ae={op:"sessions.message",sessionId:ee,requestId:crypto.randomUUID(),text:`${H}
28
+
29
+ ${ao(e)}`};if(Q.length>0&&(ae.images=Q),D&&(ae.mode="steer"),await Ae(ae),L?.(),g(Y=>({...Y,[e.id]:ee})),t(e.id,ee),!e.chat)try{await v.mutateAsync({id:e.id,sessionId:ee}),g(Y=>{const X={...Y};return delete X[e.id],X}),y(null)}catch(Y){y(e.id),Te(Y instanceof Error&&Y.message?T("ui.library.composer.link_failed",{message:Y.message}):T("ui.library.composer.link_failed_short"))}return!0}catch(q){return Te(q instanceof Error&&q.message?q.message:T("ui.library.composer.not_sent")),!1}finally{h.current=!1,p(!1)}},P=e.chat;return f.jsxs("div",{className:"flex flex-col gap-2 px-4 pb-3","data-library-composer":"","data-sending":u?"":void 0,children:[_&&x&&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:T("ui.library.composer.message_sent_link_failed")}),f.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>void F(),children:T("ui.library.composer.retry_link")}),f.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>i(x),children:T("ui.library.composer.open_chat")})]}),P&&s&&f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx(Fs,{size:13,"aria-hidden":"true"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:T("ui.library.composer.chat_about",{title:P.title||P.session_id})}),f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.composer.unlink"),onClick:()=>k.mutate({id:e.id}),children:f.jsx(We,{"aria-hidden":"true"})})]}),f.jsx("div",{className:"min-w-0","data-sending":u?"":void 0,children:f.jsx(er,{ref:l,conversationId:M,messages:oo,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:P||w?T("ui.library.composer.continue_placeholder"):T("ui.library.composer.ask_placeholder"),cwd:c?.cwd,cwdReadOnlyReason:T("ui.projects.project_quick_send.quick_send_follows_the_conversation_s_directory"),sessionStatus:c&&w?{frontend:c,costChannels:yt(a.data,"cost_channels")}:void 0,onSendMessage:R})})]})},uo=({sessionId:e,title:n,collapsed:t,onToggleCollapsed:s,onOpenChat:i,onUnlink:r,onTurnSettled:o,onStreamingChange:l})=>{it();const a=An(),c=Pi(e,!0,!0,e,{openFrame:yt(a.data,"open_frame"),journalOrder:yt(a.data,"journal_order"),peerJournalSource:yt(a.data,"peer_journal_source")}),d=E.useRef(null),u=(c.frontend??c.heldFrontend)?.streaming===!0,p=ir(c.frontend??c.heldFrontend),m=E.useRef(u);E.useEffect(()=>{m.current!==u&&(l(u),u||o()),m.current=u},[u,o,l]);const g=c.transcript.records.length===0&&c.awaitingHydration&&!c.missing;return f.jsxs("section",{"data-library-trajectory":"","data-collapsed":t?"":void 0,className:ge("flex min-h-0 flex-col bg-canvas",t?"shrink-0":"min-h-40 max-h-80 shrink-0 basis-[38%]"),children:[f.jsxs("header",{className:"flex shrink-0 items-center gap-2 px-4 py-1.5",children:[f.jsx(Fs,{size:13,"aria-hidden":"true",className:"text-ink-dim"}),f.jsxs("button",{type:"button","aria-expanded":!t,onClick:s,className:"flex min-w-0 flex-1 items-center gap-1 rounded-sm text-left text-meta text-ink-muted hover:text-ink focus-visible:outline-offset-1",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate",children:T("ui.library.composer.chat_about",{title:n})}),f.jsx(Cs,{"aria-hidden":"true",className:ge("size-3.5 shrink-0 transition-transform duration-fast",t&&"rotate-180")})]}),f.jsx(Z,{variant:"ghost",size:"sm",onClick:i,children:T("ui.library.composer.open_chat")}),f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.composer.unlink"),onClick:r,children:f.jsx(We,{"aria-hidden":"true"})})]}),!t&&p&&f.jsxs("div",{"data-library-trajectory-gate":"",className:"flex shrink-0 items-center gap-2 px-4 pb-1.5",children:[f.jsx("span",{className:"min-w-0 flex-1 text-meta text-ink",children:T("ui.mesh.mesh_approvals.waiting_for_you")}),f.jsx(Z,{variant:"secondary",size:"sm",onClick:i,children:T("ui.library.composer.open_chat")})]}),!t&&f.jsx("div",{"data-lo-sidebar-edge-cues":!0,className:"flex min-h-0 grow flex-col overflow-hidden",children:g?f.jsx("div",{className:"flex flex-1 items-center justify-center",children:f.jsx(xt,{label:T("ui.library.preview.loading")})}):f.jsx(rr,{frontend:c.frontend,transcript:c.transcript,gate:p,waiting:u,starting:!1,loadingOlder:c.loadingOlder,onLoadOlder:c.loadOlder,onLoadOlderOutcome:c.loadOlderDetailed,olderFailed:c.olderFailed,containerRef:d,isSmallView:!1,status:c.status,failure:c.failure,awaitingHydration:c.awaitingHydration,hydrationProven:c.hydrated,missing:c.missing,onReconnect:c.retry})})]})};function fo(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"}}const ho="h-[78px] w-[117px]",po=({asset:e,active:n,onSelect:t})=>{const[s,i]=zn("300px"),r=ht(e.id,"thumbnail",e.kind==="image"&&e.exists&&i),o=pt(r.bytes,r.mimeType),l=De(e);return f.jsx("li",{ref:s,className:ge("flex shrink-0 rounded-sm leading-none",n&&"ring-1 ring-ink"),children:f.jsx("button",{type:"button","aria-label":l,title:l,"aria-current":n?"true":void 0,onClick:t,"data-library-lightbox-tile":e.id,className:"block cursor-pointer overflow-hidden rounded-sm leading-none",children:f.jsx("div",{className:ge("flex items-center justify-center overflow-hidden bg-canvas",ho),children:o?f.jsx("img",{src:o,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover"}):f.jsx(Ye,{kind:e.kind,size:20,className:"text-ink-dim"})})})})},mo=({siblings:e,index:n,onSelect:t})=>f.jsx("ul",{role:"list","data-library-lightbox-strip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((s,i)=>f.jsx(po,{asset:s,active:i===n,onSelect:()=>t(i)},s.id))}),go=({open:e,siblings:n,index:t,onIndexChange:s,onClose:i,restoreFocusTo:r,resolved:o})=>{it();const l=or(t,n.length),a=n[l],c=o?.assetId===a.id,d=ht(a.id,"content",!c),h=pt(d.bytes,d.mimeType||a.ref.content_type),u=c?o?.url:h??void 0,p=De(a);return f.jsx(ar,{open:e,onOpenChange:m=>{m||i()},src:u,pending:!c&&(d.loading||u===void 0&&!d.error),label:p,mediaKind:a.kind==="video"?"video":"image",mediaLabel:"asset",restoreFocusTo:r,layerAttributes:{"data-library-lightbox":""},fallback:d.error||u!==void 0?f.jsx("p",{className:"max-w-90 text-center text-body-sm text-ink-muted",children:T("ui.library.preview.could_not_load")}):void 0,group:{index:l,count:n.length,onPrev:()=>s(Xn(l,n.length,-1)),onNext:()=>s(Xn(l,n.length,1)),filmstrip:n.length>1?f.jsx(mo,{siblings:n,index:l,onSelect:s}):void 0}})};async function qs(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 m=n.length-22;m>=l;m--)if(t.getUint32(m,!0)===s){o=m;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 m=Number(t.getBigUint64(d+8,!0));if(t.getUint32(m,!0)!==i)throw new Error("Invalid ZIP64 end record");a=Number(t.getBigUint64(m+48,!0)),c=Number(t.getBigUint64(m+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 m=0;m<c&&!(p+46>n.length||t.getUint32(p,!0)!==h);m++){const g=t.getUint16(p+10,!0);let S=t.getUint32(p+20,!0),y=t.getUint32(p+24,!0);const w=t.getUint16(p+28,!0),x=t.getUint16(p+30,!0),_=t.getUint16(p+32,!0);let v=t.getUint32(p+42,!0);const k=yo(n,p+46,w);if(S===4294967295||y===4294967295||v===4294967295){const P=p+46+w,$=P+x;let N=P;for(;N+4<=$;){const L=t.getUint16(N,!0),H=t.getUint16(N+2,!0);if(L===1){let D=N+4;y===4294967295&&D+8<=$&&(y=Number(t.getBigUint64(D,!0)),D+=8),S===4294967295&&D+8<=$&&(S=Number(t.getBigUint64(D,!0)),D+=8),v===4294967295&&D+8<=$&&(v=Number(t.getBigUint64(D,!0)));break}N+=4+H}}if(p+=46+w+x+_,k.endsWith("/")||g!==0&&g!==8||v+30>n.length)continue;const j=t.getUint16(v+26,!0),M=t.getUint16(v+28,!0),F=v+30+j+M;if(F+S>n.length)continue;const R=n.subarray(F,F+S);try{u[k]=g===0?R.slice():await bo(R)}catch(P){console.warn(`[zip.js] Failed to decompress "${k}":`,P.message)}}return u}async function bo(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 yo(e,n,t){return new TextDecoder().decode(e.subarray(n,n+t))}function Se(e){return new DOMParser().parseFromString(e,"application/xml")}function pe(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 b(e,n){return pe(e,n)[0]??null}function G(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=G(e,n);return s!==null?parseInt(s,10):t}function Le(e,n,t){return Math.max(n,Math.min(t,e))}const kt=12700,vo=Object.freeze(Object.defineProperty({__proto__:null,EMU_PER_PT:kt,attr:G,attrInt:C,clamp:Le,g1:b,gtn:pe,parseXml:Se},Symbol.toStringTag,{value:"Module"}));function wo(e){if(!e)return{colors:{},majorFont:"Calibri Light",minorFont:"Calibri"};const n=b(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=b(n,l);if(!a)continue;const c=b(a,"srgbClr"),d=b(a,"sysClr");c?t[l]=c.getAttribute("val")||"":d&&(t[l]=d.getAttribute("lastClr")||"")}}const s=b(e,"fontScheme");let i="Calibri Light",r="Calibri";if(s){const o=b(s,"majorFont"),l=b(s,"minorFont");if(o){const a=b(o,"latin");a&&(i=a.getAttribute("typeface")||i)}if(l){const a=b(l,"latin");a&&(r=a.getAttribute("typeface")||r)}}return{colors:t,majorFont:i,minorFont:r}}function xo(e){if(!e)return{};const n=b(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 ko(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 lt={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"}},Gt=new Set,_t=new Map,qt=new Set;let ts=null,yn=null;function _o(){return yn||(ts=typeof OffscreenCanvas<"u"?new OffscreenCanvas(300,10):Object.assign(document.createElement("canvas"),{width:300,height:10}),yn=ts.getContext("2d")),yn}const ns="mmmmmmmmmmlllllllllliiiiiiiiiixxxxxxxxxx",So=[20,40];function Ws(e){if(qt.has(e))return!0;if(typeof document<"u"&&document.fonts&&document.fonts.check(`16px "${e}"`))return qt.add(e),!0;try{const n=_o(),t=["monospace","serif"];for(const s of So)for(const i of t){n.font=`${s}px ${i}`;const r=n.measureText(ns).width;n.font=`${s}px "${e}", ${i}`;const o=n.measureText(ns).width;if(Math.abs(o-r)>.5)return qt.add(e),!0}}catch{}return!1}async function Sn(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=_t.get(e)??[];o.push(r),_t.set(e,o),Gt.add(e),qt.add(e);const l=e.toLowerCase().trim();return lt[l]?lt[l]._custom=!0:lt[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 Po(e){const n=[];for(const[t,s]of Object.entries(e))if(typeof s=="string")n.push(Sn(t,s));else if(Array.isArray(s))for(const i of s){const{url:r,...o}=i;n.push(Sn(t,r,o))}await Promise.all(n)}function To(e,n){if(!e)return[];const t=b(e,"embeddedFontLst");if(!t)return[];const s=[];for(const i of t.children){if(i.localName!=="embeddedFont")continue;const r=b(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=b(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 jo(e){if(!e)return"sans-serif";if(e==="+mj-lt"||e==="+mj")return"serif";if(e==="+mn-lt"||e==="+mn")return"sans-serif";if(_t.has(e))return e;const n=e.toLowerCase().trim(),t=lt[n];return t?t._custom||t.google===null?e:t.google&&Ws(t.google)?t.google:t.google||e:e}function Co(e){if(!e)return"sans-serif";const n=e.toLowerCase().trim();return lt[n]?.generic??"sans-serif"}async function Fo(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"||_t.has(o))continue;const l=o.toLowerCase().trim(),a=lt[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||Gt.has(c))continue;if(Ws(c)){Gt.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())Gt.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 No(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 Ks(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=b(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=jo(c),u=Co(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 Mo(){const e=[];for(const[n,t]of _t)for(const s of t)e.push({family:n,weight:s.weight,style:s.style,status:s.status});return e}function Rt(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 Qe(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 Ve(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 Ao={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 $o(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=Qe(t,s,i),h=Ve(d.h,Le(d.l*c,0,1),d.s);t=h.r,s=h.g,i=h.b;break}case"lumOff":{const c=a/1e5,d=Qe(t,s,i),h=Ve(d.h,Le(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=Qe(t,s,i),h=Ve(d.h,d.l,Le(d.s*c,0,1));t=h.r,s=h.g,i=h.b;break}case"satOff":{const c=a/1e5,d=Qe(t,s,i),h=Ve(d.h,d.l,Le(d.s+c,0,1));t=h.r,s=h.g,i=h.b;break}case"hueMod":{const c=a/1e5,d=Qe(t,s,i),h=Ve(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=Qe(t,s,i),h=Ve(((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=Le(r+a/1e5,0,1);break}case"alphaMod":{r=Le(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=Qe(t,s,i),d=Ve((c.h+.5)%1,c.l,c.s);t=d.r,s=d.g,i=d.b;break}}}return{r:Le(t,0,255),g:Le(s,0,255),b:Le(i,0,255),a:r}}function _e(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=Rt(r))}else if(t==="schemeClr"){const o=e.getAttribute("val")||"",l=n?.[o];l?s=Rt(l):s={r:0,g:0,b:0}}else if(t==="prstClr"){const r=(e.getAttribute("val")||"").toLowerCase(),o=Ao[r];o&&(s=Rt(o))}else if(t==="sysClr"){const r=e.getAttribute("lastClr");r?.length>=6?s=Rt(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=Ve(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?$o({...s,a:i},e):null}function we(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 xe(e){if(!e)return null;const n=["srgbClr","schemeClr","prstClr","sysClr","hslClr","scRgbClr"];for(const t of n){const s=b(e,t);if(s)return s}return null}function ss(e,n){if(!e)return null;const t=b(e,"solidFill");if(!t)return null;const s=xe(t),i=_e(s,n);return i?we(i):null}function Eo(e,n,t){const s=ss(e,t);return s||ss(n,t)}function Yt(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":ot(e,c,d,i/2,r/2,5,-Math.PI/2);break;case"hexagon":ot(e,c,d,i/2,r/2,6,0);break;case"heptagon":ot(e,c,d,i/2,r/2,7,-Math.PI/2);break;case"octagon":ot(e,c,d,i/2,r/2,8,Math.PI/8);break;case"decagon":ot(e,c,d,i/2,r/2,10,-Math.PI/2);break;case"dodecagon":ot(e,c,d,i/2,r/2,12,0);break;case"plus":case"cross":{const u=a(0,25e3),p=h*u,m=c-p/2,g=c+p/2,S=d-p/2,y=d+p/2;e.moveTo(m,s),e.lineTo(g,s),e.lineTo(g,S),e.lineTo(t+i,S),e.lineTo(t+i,y),e.lineTo(g,y),e.lineTo(g,s+r),e.lineTo(m,s+r),e.lineTo(m,y),e.lineTo(t,y),e.lineTo(t,S),e.lineTo(m,S),e.closePath();break}case"star4":Re(e,c,d,i/2,r/2,4,a(0,37500));break;case"star5":Re(e,c,d,i/2,r/2,5,a(0,19098),-Math.PI/2);break;case"star6":Re(e,c,d,i/2,r/2,6,a(0,28868),0);break;case"star7":Re(e,c,d,i/2,r/2,7,a(0,34601),-Math.PI/2);break;case"star8":Re(e,c,d,i/2,r/2,8,a(0,29289),Math.PI/8);break;case"star10":Re(e,c,d,i/2,r/2,10,a(0,30902),-Math.PI/2);break;case"star12":Re(e,c,d,i/2,r/2,12,a(0,37720),0);break;case"star16":Re(e,c,d,i/2,r/2,16,a(0,37500),0);break;case"star24":Re(e,c,d,i/2,r/2,24,a(0,37500),0);break;case"star32":Re(e,c,d,i/2,r/2,32,a(0,37500),0);break;case"rightArrow":{const u=a(0,5e4),p=a(1,5e4),m=(r-r*p)/2,g=t+i*(1-u);e.moveTo(t,s+m),e.lineTo(g,s+m),e.lineTo(g,s),e.lineTo(t+i,d),e.lineTo(g,s+r),e.lineTo(g,s+r-m),e.lineTo(t,s+r-m),e.closePath();break}case"leftArrow":{const u=a(0,5e4),p=a(1,5e4),m=(r-r*p)/2,g=t+i*u;e.moveTo(t+i,s+m),e.lineTo(g,s+m),e.lineTo(g,s),e.lineTo(t,d),e.lineTo(g,s+r),e.lineTo(g,s+r-m),e.lineTo(t+i,s+r-m),e.closePath();break}case"upArrow":{const u=a(0,5e4),p=a(1,5e4),m=(i-i*p)/2,g=s+r*u;e.moveTo(t+m,s+r),e.lineTo(t+m,g),e.lineTo(t,g),e.lineTo(c,s),e.lineTo(t+i,g),e.lineTo(t+i-m,g),e.lineTo(t+i-m,s+r),e.closePath();break}case"downArrow":{const u=a(0,5e4),p=a(1,5e4),m=(i-i*p)/2,g=s+r*(1-u);e.moveTo(t+m,s),e.lineTo(t+m,g),e.lineTo(t,g),e.lineTo(c,s+r),e.lineTo(t+i,g),e.lineTo(t+i-m,g),e.lineTo(t+i-m,s),e.closePath();break}case"leftRightArrow":{const u=a(0,25e3),p=a(1,5e4),m=(r-r*p)/2,g=t+i*u,S=t+i*(1-u);e.moveTo(t,d),e.lineTo(g,s),e.lineTo(g,s+m),e.lineTo(S,s+m),e.lineTo(S,s),e.lineTo(t+i,d),e.lineTo(S,s+r),e.lineTo(S,s+r-m),e.lineTo(g,s+r-m),e.lineTo(g,s+r),e.closePath();break}case"upDownArrow":{const u=a(0,25e3),p=a(1,5e4),m=(i-i*p)/2,g=s+r*u,S=s+r*(1-u);e.moveTo(c,s),e.lineTo(t+i,g),e.lineTo(t+i-m,g),e.lineTo(t+i-m,S),e.lineTo(t+i,S),e.lineTo(c,s+r),e.lineTo(t,S),e.lineTo(t+m,S),e.lineTo(t+m,g),e.lineTo(t,g),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,m=a(2,25e3)*Math.min(i,r)/2,g=Math.min(i,r)/2,S=g-m;e.moveTo(c+g*Math.cos(u),d+g*Math.sin(u)),e.arc(c,d,g,u,u+p),e.arc(c,d,Math.max(1,S),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":{Ro(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":{Re(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 ot(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 Re(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),m=t+u*Math.sin(c);a===0?e.moveTo(p,m):e.lineTo(p,m)}e.closePath()}function Ro(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 is=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0","#FF7F00","#9E480E"];function zo(e){const n=e?.textContent?.trim();if(n==null||n==="")return null;const t=parseFloat(n);return isNaN(t)?n:t}function vt(e){if(!e)return[];const n=C(b(e,"ptCount"),"val",0),t=new Array(n).fill(null);for(const s of pe(e,"pt")){const i=C(s,"idx",0);t[i]=zo(b(s,"v"))}return t}function Ct(e){const n=b(e,"tx");if(!n)return null;const t=b(n,"v");if(t)return t.textContent.trim();const s=b(n,"strCache");if(s){const i=b(s,"pt"),r=i?b(i,"v"):null;return r?r.textContent.trim():null}return null}function rn(e){const n=b(e,"cat")||b(e,"xVal");return n?vt(b(n,"strCache")||b(n,"numCache")):[]}function Ft(e){const n=b(e,"val")||b(e,"yVal");return n?vt(b(n,"numCache")):[]}function tt(e,n,t){const s=b(e,"spPr");if(s){const r=b(s,"solidFill");if(r){const o=xe(r),l=_e(o,t);if(l)return we(l)}}const i=`accent${n%6+1}`;return t[i]?`#${t[i]}`:is[n%is.length]}function Vs(e,n){const t={};for(const s of pe(e,"dPt")){const i=C(b(s,"idx"),"val",-1);if(i<0)continue;const r=b(s,"spPr");if(!r)continue;const o=b(r,"solidFill");if(!o)continue;const l=xe(o),a=_e(l,n);a&&(t[i]=we(a))}return t}function on(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 St(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 ze(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 nt(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 Xs(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 Pt(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=Xs(i-s);return i=Math.ceil(i/r)*r,s=Math.floor(s/r)*r,{min:s,max:i,step:r}}function st(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 Nt(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,St(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 Io(e,n,t,s,i,r,o,l){const a=b(n,"barChart")||b(n,"bar3DChart"),c=!a||G(a,"barDir","col")!=="bar",d=G(a,"grouping","clustered"),h=d==="stacked"||d==="percentStacked",u=d==="percentStacked",p=pe(a,"ser"),m=p.map((k,j)=>({name:Ct(k),values:Ft(k),color:tt(k,j,o),dptColors:Vs(k,o)}));if(!m.length)return;const g=rn(p[0])||[],S=Math.max(g.length,m[0]?.values.length||0,1),y=on(t,s,i,r,{hasLegend:m.length>1});let w;h?(w=Array.from({length:S},(k,j)=>m.reduce((M,F)=>M+(F.values[j]||0),0)),u&&(w=w.map(()=>100))):w=m.flatMap(k=>k.values);const x=Pt(w),_=Math.max(7,Math.min(11,y.w*.018))*l;e.font=`${_}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 P=0;P<=v;P++){const $=x.min+P*x.step,N=($-x.min)/(x.max-x.min),L=y.y+y.h-N*y.h;nt(e,y.x,L,y.x+y.w,L),e.fillText(u?$+"%":st($),y.x-4*l,L)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";const k=y.w/S;for(let P=0;P<S;P++){const $=y.x+k*P+k/2,N=String(g[P]??P+1);e.fillText(N,$,y.y+y.h+_*1.5)}e.restore(),ze(e,y.x,y.y,y.x,y.y+y.h),ze(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h);const j=y.w/S,M=j*.15,F=j-M*2,R=h?F:F/m.length;for(let P=0;P<S;P++){const $=y.x+j*P+M;let N=0;for(let L=0;L<m.length;L++){const H=m[L];let D=H.values[P]??0;if(u){const ee=m.reduce((ae,Y)=>ae+(Y.values[P]||0),0);D=ee?D/ee*100:0}const U=H.dptColors[P]||H.color,q=Math.abs(D)/(x.max-x.min)*y.h,Q=h?$:$+L*R,J=h?(N-x.min)/(x.max-x.min):Math.max(0,-x.min)/(x.max-x.min),I=y.y+y.h-J*y.h,V=D>=0?I-q:I;e.save(),e.fillStyle=U,St(e,Q,V,h?F:R-1*l,q,2*l),e.fill();const oe=e.createLinearGradient(Q,V,Q,V+q*.3);oe.addColorStop(0,"rgba(255,255,255,0.18)"),oe.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=oe,e.fill(),e.restore(),h&&(N+=Math.abs(D))}}}else{e.save(),e.textAlign="right",e.fillStyle="#666";const k=y.h/S;for(let P=0;P<S;P++){const $=y.y+k*P+k/2,N=String(g[P]??P+1);e.fillText(N,y.x-4*l,$)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";for(let P=0;P<=v;P++){const $=x.min+P*x.step,N=($-x.min)/(x.max-x.min),L=y.x+N*y.w;nt(e,L,y.y,L,y.y+y.h),e.fillText(u?$+"%":st($),L,y.y+y.h+_*1.5)}e.restore(),ze(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h),ze(e,y.x,y.y,y.x,y.y+y.h);const j=k*.15,M=k-j*2,F=h?M:M/m.length,R=y.x+-x.min/(x.max-x.min)*y.w;for(let P=0;P<S;P++){const $=y.y+k*P+j;let N=0;for(let L=0;L<m.length;L++){const H=m[L];let D=H.values[P]??0;if(u){const V=m.reduce((oe,ee)=>oe+(ee.values[P]||0),0);D=V?D/V*100:0}const U=H.dptColors[P]||H.color,q=Math.abs(D)/(x.max-x.min)*y.w,Q=h?$:$+L*F,J=h?R+N/(x.max-x.min)*y.w:R,I=D>=0?J:J-q;e.save(),e.fillStyle=U,St(e,I,Q,q,h?M:F-1*l,2*l),e.fill(),e.restore(),h&&(N+=Math.abs(D))}}}m.length>1&&Nt(e,t,s,i,y.legendY,m,l)}function Lo(e,n,t,s,i,r,o,l){const a=b(n,"lineChart")||b(n,"line3DChart"),c=pe(a,"ser"),d=c.map((y,w)=>({name:Ct(y),values:Ft(y),color:tt(y,w,o),marker:G(b(y,"marker"),"symbol","none")!=="none",smooth:G(b(y,"smooth"),"val","0")==="1"}));if(!d.length)return;const h=rn(c[0])||[],u=Math.max(h.length,d[0]?.values.length||0,1),p=on(t,s,i,r,{hasLegend:!0}),m=Pt(d.flatMap(y=>y.values)),g=Math.max(7,Math.min(11,p.w*.018))*l,S=Math.round((m.max-m.min)/m.step);e.save(),e.textAlign="right",e.fillStyle="#666",e.font=`${g}px sans-serif`;for(let y=0;y<=S;y++){const w=m.min+y*m.step,x=(w-m.min)/(m.max-m.min),_=p.y+p.h-x*p.h;nt(e,p.x,_,p.x+p.w,_),e.fillText(st(w),p.x-4*l,_)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666",e.font=`${g}px sans-serif`;for(let y=0;y<u;y++){const w=p.x+y/(u-1||1)*p.w;nt(e,w,p.y,w,p.y+p.h);const x=String(h[y]??y+1);e.fillText(x,w,p.y+p.h+g*1.5)}e.restore(),ze(e,p.x,p.y,p.x,p.y+p.h),ze(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((_,v)=>{const k=u>1?v/(u-1):.5,j=(_-m.min)/(m.max-m.min);return{x:p.x+k*p.w,y:p.y+p.h-j*p.h,v:_}}).filter(_=>typeof _.v=="number");if(w.length<2)continue;e.save(),e.beginPath(),e.moveTo(w[0].x,p.y+p.h);for(const _ of w)e.lineTo(_.x,_.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 _=1;_<w.length-1;_++){const v=(w[_].x+w[_+1].x)/2,k=(w[_].y+w[_+1].y)/2;e.quadraticCurveTo(w[_].x,w[_].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 _ of w.slice(1))e.lineTo(_.x,_.y)}e.stroke(),e.restore();const x=3.5*l;for(const _ of w)e.save(),e.fillStyle=y.color,e.strokeStyle="#fff",e.lineWidth=1.5*l,e.beginPath(),e.arc(_.x,_.y,x,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}Nt(e,t,s,i,p.legendY,d,l)}function Do(e,n,t,s,i,r,o,l){const a=b(n,"areaChart")||b(n,"area3DChart"),c=G(a,"grouping","standard"),d=c==="percentStacked",h=c==="stacked"||d,p=pe(a,"ser").map((v,k)=>({name:Ct(v),values:Ft(v),color:tt(v,k,o)})).reverse();if(!p.length)return;const m=Math.max(...p.map(v=>v.values.length),1),g=on(t,s,i,r,{hasLegend:!0});let S=0;if(d)S=100;else for(let v=0;v<m;v++){const k=p.reduce((j,M)=>j+(M.values[v]||0),0);S=Math.max(S,k)}const y={min:0,max:S||100,step:Xs(S||100)},w=Math.round((y.max-y.min)/y.step),x=Math.max(7,Math.min(11,g.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,j=(k-y.min)/(y.max-y.min),M=g.y+g.h-j*g.h;nt(e,g.x,M,g.x+g.w,M),e.fillText(d?k+"%":st(k),g.x-4*l,M)}e.restore(),ze(e,g.x,g.y,g.x,g.y+g.h),ze(e,g.x,g.y+g.h,g.x+g.w,g.y+g.h);const _=new Array(m).fill(0);for(const v of p){e.save(),e.beginPath();const k=[];for(let j=0;j<m;j++){let M=v.values[j]??0;if(d){const L=p.reduce((H,D)=>H+(D.values[j]||0),0);M=L?M/L*100:0}const F=h?_[j]:0,R=F+Math.abs(M),P=(F-y.min)/(y.max-y.min),$=(R-y.min)/(y.max-y.min),N=g.x+j/(m-1||1)*g.w;k.push({x:N,y:g.y+g.h-$*g.h,baseY:g.y+g.h-P*g.h}),h&&(_[j]+=Math.abs(M))}e.moveTo(k[0].x,k[0].baseY);for(const j of k)e.lineTo(j.x,j.baseY);for(let j=k.length-1;j>=0;j--)e.lineTo(k[j].x,k[j].y);e.closePath(),e.fillStyle=v.color+"cc",e.fill(),e.beginPath(),e.moveTo(k[0].x,k[0].y);for(const j of k.slice(1))e.lineTo(j.x,j.y);e.strokeStyle=v.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}Nt(e,t,s,i,g.legendY,[...p].reverse(),l)}function rs(e,n,t,s,i,r,o,l){const a=b(n,"pieChart")||b(n,"pie3DChart"),c=b(n,"doughnutChart"),d=a||c,h=!!c,u=pe(d,"ser");if(!u.length)return;const p=u[0],m=Ft(p).map(P=>typeof P=="number"&&P>0?P:0),g=rn(p),S=Vs(p,o),y=m.reduce((P,$)=>P+$,0);if(!y)return;const w=Math.min(i,r)*.38,x=t+i*.44,_=s+r*.5,v=h?w*.55:0;let k=-Math.PI/2;for(let P=0;P<m.length;P++){if(!m[P])continue;const $=m[P]/y*Math.PI*2,N=S[P]||tt(p,P,o),L=k+$/2,H=P===0?w*.04:0,D=H*Math.cos(L),U=H*Math.sin(L);e.save(),e.beginPath(),e.moveTo(x+D,_+U),e.arc(x+D,_+U,w,k,k+$),e.closePath(),e.fillStyle=N,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,_,v,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.restore());const q=m[P]/y;if(q>.05){const Q=x+D+w*.65*Math.cos(L),J=_+U+w*.65*Math.sin(L),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(q*100)+"%",Q,J),e.restore()}k+=$}if(h){const P=Math.max(10,Math.min(16,w*.22))*l;e.save(),e.font=`bold ${P}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="middle",e.fillText(st(y),x,_),e.restore()}const j=t+i*.78,M=Math.max(8,Math.min(12,i*.022))*l;e.font=`${M}px sans-serif`,e.textBaseline="middle";const F=M*1.8,R=_-m.length*F/2;for(let P=0;P<m.length;P++){const $=j,N=R+P*F,L=S[P]||tt(p,P,o);e.fillStyle=L,St(e,$,N-M*.5,M*1.2,M),e.fill(),e.fillStyle="#444";const H=String(g[P]??`Item ${P+1}`);e.fillText(H,$+M*1.5,N)}}function Bo(e,n,t,s,i,r,o,l){const a=b(n,"scatterChart")||b(n,"bubbleChart"),d=pe(a,"ser").map((k,j)=>{const M=vt(b(b(k,"xVal"),"numCache")),F=vt(b(b(k,"yVal"),"numCache")),R=vt(b(b(k,"bubbleSize"),"numCache"));return{name:Ct(k),color:tt(k,j,o),points:M.map((P,$)=>({x:P,y:F[$],r:R[$]})).filter(P=>typeof P.x=="number"&&typeof P.y=="number")}});if(!d.length)return;const h=on(t,s,i,r,{hasLegend:d.length>1}),u=d.flatMap(k=>k.points.map(j=>j.x)),p=d.flatMap(k=>k.points.map(j=>j.y)),m=Pt(u,!1),g=Pt(p),S=Math.max(7,Math.min(11,h.w*.018))*l,y=Math.round((m.max-m.min)/m.step),w=Math.round((g.max-g.min)/g.step);e.font=`${S}px sans-serif`,e.save(),e.textAlign="center",e.fillStyle="#666";for(let k=0;k<=y;k++){const j=m.min+k*m.step,M=(j-m.min)/(m.max-m.min),F=h.x+M*h.w;nt(e,F,h.y,F,h.y+h.h),e.fillText(st(j),F,h.y+h.h+S*1.5)}e.textAlign="right";for(let k=0;k<=w;k++){const j=g.min+k*g.step,M=(j-g.min)/(g.max-g.min),F=h.y+h.h-M*h.h;nt(e,h.x,F,h.x+h.w,F),e.fillText(st(j),h.x-4*l,F)}e.restore(),ze(e,h.x,h.y,h.x,h.y+h.h),ze(e,h.x,h.y+h.h,h.x+h.w,h.y+h.h);const x=d.flatMap(k=>k.points.map(j=>j.r??1)),_=Math.max(...x.filter(k=>typeof k=="number"),1),v=Math.min(h.w,h.h)*.06;for(const k of d)for(const j of k.points){const M=h.x+(j.x-m.min)/(m.max-m.min)*h.w,F=h.y+h.h-(j.y-g.min)/(g.max-g.min)*h.h,R=j.r!=null?j.r/_*v:4*l;e.save(),e.fillStyle=k.color+"aa",e.strokeStyle=k.color,e.lineWidth=1*l,e.beginPath(),e.arc(M,F,R,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}d.length>1&&Nt(e,t,s,i,h.legendY,d,l)}function Oo(e,n,t,s,i,r,o,l){const a=b(n,"radarChart"),c=pe(a,"ser"),d=c.map((w,x)=>({name:Ct(w),values:Ft(w),color:tt(w,x,o)}));if(!d.length)return;const h=rn(c[0])||[],u=h.length||d[0]?.values.length||0;if(u<3)return;const p=t+i*.5,m=s+r*.5,g=Math.min(i,r)*.34,S=Pt(d.flatMap(w=>w.values)),y=4;for(let w=1;w<=y;w++){const x=g*w/y;e.save(),e.beginPath();for(let _=0;_<u;_++){const v=_/u*Math.PI*2-Math.PI/2,k=p+x*Math.cos(v),j=m+x*Math.sin(v);_===0?e.moveTo(k,j):e.lineTo(k,j)}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;ze(e,p,m,p+g*Math.cos(x),m+g*Math.sin(x));const _=p+(g+16*l)*Math.cos(x),v=m+(g+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),_,v),e.restore()}for(const w of d){const x=w.values.map((_,v)=>{const k=v/u*Math.PI*2-Math.PI/2,j=(_-S.min)/(S.max-S.min);return{x:p+g*j*Math.cos(k),y:m+g*j*Math.sin(k)}});e.save(),e.beginPath(),e.moveTo(x[0].x,x[0].y);for(const _ of x.slice(1))e.lineTo(_.x,_.y);e.closePath(),e.fillStyle=w.color+"44",e.fill(),e.strokeStyle=w.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}Nt(e,t,s,i,s+r-20*l,d,l)}function Uo(e,n,t,s,i,r){const o=b(b(n,"chart"),"title");if(!o)return!1;const l=b(o,"tx");if(!l)return!1;let a="";for(const d of pe(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",St(e,t,s,i,r,4*l),e.fill(),e.strokeStyle="#ddd",e.lineWidth=.5,e.stroke(),e.restore();const d=Uo(e,a,t,s,i,l)?s+Math.min(r*.08,24*l):s,h=r-(d-s),u=b(a,"plotArea");if(!u)return;const p=b(u,"bar3DChart")||b(u,"barChart"),m=b(u,"line3DChart")||b(u,"lineChart"),g=b(u,"area3DChart")||b(u,"areaChart"),S=b(u,"pie3DChart")||b(u,"pieChart"),y=b(u,"doughnutChart"),w=b(u,"scatterChart")||b(u,"bubbleChart"),x=b(u,"radarChart");if(p)Io(e,u,t,d,i,h,o,l);else if(m)Lo(e,u,t,d,i,h,o,l);else if(g)Do(e,u,t,d,i,h,o,l);else if(y)rs(e,u,t,d,i,h,o,l);else if(S)rs(e,u,t,d,i,h,o,l);else if(w)Bo(e,u,t,d,i,h,o,l);else if(x)Oo(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 _=u.firstElementChild;e.fillText(_?.localName??"Chart",t+i/2,s+r/2),e.restore()}}function Qt(e,n,t=0,s=1){return(e?parseInt(e.getAttribute(n)||t,10):t)*s}function Hs(e,n){if(!e)return null;const t=xe(e);if(!t)return null;const s=_e(t,n);return s?we(s):null}function qo(e,n,t,s,i,r,o){const l=b(n,"bevelT"),a=b(n,"bevelB"),c=l||a;if(!c)return;const d=Math.max(2*o,Qt(c,"w",76200,o)),h=Math.max(2*o,Qt(c,"h",76200,o)),p=G(c,"prst","circle").toLowerCase().includes("in"),m=Math.min(d,i*.3),g=Math.min(h,r*.3),S=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+g);w.addColorStop(0,S),w.addColorStop(1,"rgba(255,255,255,0)"),e.save(),e.fillStyle=w,e.fillRect(t,s,i,g);const x=e.createLinearGradient(t,s+r-g,t,s+r);x.addColorStop(0,"rgba(0,0,0,0)"),x.addColorStop(1,y),e.fillStyle=x,e.fillRect(t,s+r-g,i,g);const _=e.createLinearGradient(t,s,t+m,s);_.addColorStop(0,S),_.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=_,e.fillRect(t,s,m,r);const v=e.createLinearGradient(t+i-m,s,t+i,s);v.addColorStop(0,"rgba(0,0,0,0)"),v.addColorStop(1,y),e.fillStyle=v,e.fillRect(t+i-m,s,m,r),e.restore()}function Wo(e,n,t,s,i,r,o,l){const a=Qt(n,"extrusionH",0,l);if(a<1*l)return;const c=b(n,"extrusionClr")||b(n,"contourClr"),d=Hs(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 Ko(e,n,t,s,i,r,o,l){const a=Qt(n,"contourW",0,l);if(a<.5)return;const c=b(n,"contourClr"),d=Hs(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=b(n,"camera");if(!o)return()=>{};const l=G(o,"prst","orthographicFront"),a=b(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,m=Math.sin(p)*.15,g=Math.sin(u)*.08;return e.save(),e.transform(1,g,m,1,t*-m,s*-g),()=>e.restore()}function Xo(e,n,t,s,i,r){if(!n)return;const o=b(n,"lightRig");if(!o)return;const l=G(o,"dir","t"),a=G(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),m=e.createRadialGradient(d,h,0,d,h,p);m.addColorStop(0,`rgba(255,255,255,${u})`),m.addColorStop(.5,"rgba(255,255,255,0)"),m.addColorStop(1,`rgba(0,0,0,${u*.5})`),e.save(),e.fillStyle=m,e.fillRect(t,s,i,r),e.restore()}function Ho(e,n,t,s,i,r,o,l){if(!n)return{applyCamera:()=>()=>{},overlay:()=>{}};const a=b(n,"sp3d")||b(n,"scene3d")?.parentNode&&null,c=b(n,"scene3d");a&&Wo(e,a,t,s,i,r,o,l);const d=Vo(e,c,s,i);return{overlay(){a&&(qo(e,a,s,i,r,o,l),Ko(e,a,t,s,i,r,o,l)),c&&Xo(e,c,s,i,r,o)},cleanup:d}}function Yo(e){return e?!!(b(e,"sp3d")||b(e,"scene3d")):!1}async function Tt(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=xe(n),h=_e(d,l);return h?(e.fillStyle=we(h),e.fill(),!0):!1}if(c==="gradFill"){const d=b(n,"gsLst");if(!d)return!1;const h=pe(d,"gs").map(y=>{const w=C(y,"pos",0)/1e5,x=xe(y),_=_e(x,l);return{pos:w,color:_}}).sort((y,w)=>y.pos-w.pos);if(h.length<2)return!1;const u=b(n,"lin"),p=b(n,"path"),m=t+i/2,g=s+r/2;let S;if(u||!u&&!p){const x=(C(u,"ang",0)/6e4-90)*Math.PI/180,_=Math.cos(x),v=Math.sin(x),k=Math.abs(i*_)+Math.abs(r*v),j=m-k/2*_,M=g-k/2*v,F=m+k/2*_,R=g+k/2*v;S=e.createLinearGradient(j,M,F,R)}else{const y=b(p,"fillToRect"),w=C(y,"l",5e4)/1e5,x=C(y,"t",5e4)/1e5,_=C(y,"r",5e4)/1e5,v=C(y,"b",5e4)/1e5,k=t+i*(w+(1-w-_)/2),j=s+r*(x+(1-x-v)/2),M=Math.sqrt(i*i+r*r)/2;S=e.createRadialGradient(k,j,0,m,g,M)}for(const y of h)y.color&&S.addColorStop(y.pos,we(y.color));return e.fillStyle=S,e.fill(),!0}if(c==="blipFill"){const d=b(n,"blip"),h=d?d.getAttribute("r:embed")||d.getAttribute("embed"):null;if(h&&a&&a[h]){const u=a[h],p=b(n,"stretch"),m=p?b(p,"fillRect"):null;let g=t,S=s,y=i,w=r;if(m){const k=C(m,"l",0)/1e5,j=C(m,"t",0)/1e5,M=C(m,"r",0)/1e5,F=C(m,"b",0)/1e5;g=t+i*k,S=s+r*j,y=i-i*k-i*M,w=r-r*j-r*F}if(b(n,"tile")){const k=e.createPattern(u,"repeat");if(k)return e.fillStyle=k,e.fill(),!0}const _=b(n,"alphaModFix")||b(d,"alphaModFix"),v=_?C(_,"amt",1e5)/1e5:1;return e.save(),e.clip(),v<1&&(e.globalAlpha=v),e.drawImage(u,g,S,y,w),e.restore(),!0}return!1}if(c==="pattFill"){const d=b(n,"fgClr"),h=b(n,"bgClr"),u=d?_e(xe(d),l):{r:0,g:0,b:0,a:1},p=h?_e(xe(h),l):{r:255,g:255,b:255,a:1},m=we(u),g=we(p),S=G(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=we(u),e.fill(),!0;switch(y.fillStyle=g,y.fillRect(0,0,x,x),y.fillStyle=m,S){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 _=e.createPattern(w,"repeat");return _?(e.fillStyle=_,e.fill(),!0):(e.fillStyle=we(u,(u.a??1)*.4),e.fill(),!0)}return!1}async function Ue(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=Se(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 m=h;if(p!=="External")if(h.startsWith("/"))m=h.slice(1);else{const g=n.split("/");g.pop();const S=h.split("/");for(const y of S)y===".."?g.pop():y!=="."&&g.push(y);m=g.join("/")}a[d]={target:h,fullPath:m,type:u,external:p==="External"}}return a}async function Wt(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,m)=>{const g=new Image;g.onload=()=>p(g),g.onerror=()=>p(null),g.src=h});t[i]=u}catch{}}return t}function Ys(e,n,t){if(!e)return n*1.2;const s=b(e,"spcPct"),i=b(e,"spcPts");return s?n*(C(s,"val",1e5)/1e5):i?C(i,"val",0)/100*12700*(t||1):n*1.2}function Qo(e,n,t,s){if(!e||b(e,"buNone"))return null;const i=b(e,"buChar"),r=b(e,"buAutoNum");if(!i&&!r)return null;let o=null;const l=b(e,"buClr");if(l){const m=xe(l);o=_e(m,t)}const a=b(e,"buSzPct"),c=b(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=b(e,"buFont");if(p){const m=p.getAttribute("typeface");m&&(u=m)}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 Zo(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return os(n).toLowerCase()+".";case"romanUcPeriod":return os(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 os(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 Jo(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=we(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=Zo(n.numType,i[c]);i[c]++,e.fillText(d,t,s)}e.restore()}async function Zt(e,n,t,s,i,r,o,l,a,c=1800){if(!n)return;const d=b(n,"bodyPr"),h=G(d,"anchor","t"),u=G(d,"wrap","square"),p=G(d,"vert","horz"),m=C(d,"lIns",91440)*o,g=C(d,"tIns",45720)*o,S=C(d,"rIns",91440)*o,y=C(d,"bIns",45720)*o,w=t+m,x=s+g,_=i-m-S,v=r-g-y,k=u!=="none",j=p==="vert"||p==="vert270"||p==="eaVert";j&&(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 M=b(d,"normAutoFit")||b(n,"normAutoFit");b(d,"spAutoFit")||b(n,"spAutoFit");const F=M?M.getAttribute("fontScale"):null;let R=F?parseInt(F,10)/1e5:1;const P=b(n,"lstStyle"),$=P?b(P,"defRPr"):null;function N(J,I,V,oe){const ee=J?J.getAttribute(V):null;if(ee!==null&&ee!=="")return ee;const ae=I?I.getAttribute(V):null;if(ae!==null&&ae!=="")return ae;const Y=$?$.getAttribute(V):null;return Y!==null&&Y!==""?Y:oe}const L=pe(n,"p"),H=[];let D=0;for(const J of L){const I=b(J,"pPr"),V=G(I,"algn","l");C(I,"lvl",0);const oe=C(I,"marL",0)*o,ee=C(I,"indent",0)*o,ae=I?Qo(I,ce,l):null,Y=b(I,"spcBef"),X=b(I,"spcAft"),ke=b(I,"lnSpc"),ce=b(I,"defRPr");let de=c;if($){const ne=$.getAttribute("sz");ne&&(de=parseInt(ne,10))}if(ce){const ne=ce.getAttribute("sz");ne&&(de=parseInt(ne,10))}let fe=0,W=0;if(Y){const ne=b(Y,"spcPct"),se=b(Y,"spcPts");ne?fe=de*127*o*(C(ne,"val",0)/1e5):se&&(fe=C(se,"val",0)*kt*o/100)}if(X){const ne=b(X,"spcPct"),se=b(X,"spcPts");ne?W=de*127*o*(C(ne,"val",0)/1e5):se&&(W=C(se,"val",0)*kt*o/100)}const le=[];for(const ne of J.children){const se=ne.localName;(se==="r"||se==="br"||se==="fld")&&le.push(ne)}if(le.length===0){const ne=b(J,"endParaRPr"),ie=C(ne||ce,"sz",de)*127*o*R;H.push({lines:[""],algn:V,marL:oe,spaceBefore:fe,spaceAfter:W,szPx:ie,lnSpc:ke,runs:[],emptyPara:!0,bullet:ae}),D+=fe+ie*1.2+W;continue}let me=[],he=[],B=0;for(const ne of le){if(ne.localName==="br"){me.push({runs:he,maxSzPx:Math.max(B,de*127*o)}),he=[],B=0;continue}const se=b(ne,"rPr"),ie=b(ne,"t");let z=ie?ie.textContent:"";const O=Ks(se,ce,o*R,a,de,$);e.font=O.fontStr;const re=O.szPx;re>B&&(B=re);const be=Eo(se,ce,l),ve=N(se,ce,"u","none")!=="none",je=N(se,ce,"strike","noStrike")!=="noStrike",Pe=parseInt(N(se,ce,"baseline","0"),10);if(k){const rt=z.split(" ");for(let mn=0;mn<rt.length;mn++){const gn=rt[mn];let Gn=ee+oe;for(const $t of he)e.font=$t.fontInfo.fontStr,Gn+=e.measureText($t.text).width;e.font=O.fontStr;const yi=e.measureText(gn).width,vi=he.length?e.measureText(" ").width:0;if(Gn+vi+yi>_&&he.length>0)me.push({runs:he,maxSzPx:Math.max(B,re)}),he=[{text:gn,rPr:se,fontInfo:O,color:be,underline:ve,strikethrough:je,baseline:Pe}],B=re;else{if(he.length>0){const $t={text:" ",rPr:se,fontInfo:O,color:be,underline:!1,strikethrough:!1,baseline:Pe};he.push($t)}he.push({text:gn,rPr:se,fontInfo:O,color:be,underline:ve,strikethrough:je,baseline:Pe})}}}else he.push({text:z,rPr:se,fontInfo:O,color:be,underline:ve,strikethrough:je,baseline:Pe}),re>B&&(B=re)}he.length>0&&me.push({runs:he,maxSzPx:Math.max(B,de*127*o)});const te=ke?Ys(ke,de*127*o*R,o):null;H.push({lines:me,algn:V,marL:oe,indent:ee,spaceBefore:fe,spaceAfter:W,lnSpcPx:te,emptyPara:!1,bullet:ae});for(const ne of me)D+=fe+(te||ne.maxSzPx*1.2)+W}if(M&&!F&&D>v&&v>0){let J=.3,I=1;for(let V=0;V<8;V++){const oe=(J+I)/2;let ee=0;for(const ae of L){const Y=b(ae,"pPr"),X=Y?b(Y,"defRPr"):null;let ke=c;if($){const te=$.getAttribute("sz");te&&(ke=parseInt(te,10))}if(X){const te=X.getAttribute("sz");te&&(ke=parseInt(te,10))}const ce=Array.from(ae.children).filter(te=>["r","br","fld"].includes(te.localName)),de=ke*127*o*oe;if(ce.length===0){ee+=de*1.2;continue}const fe=ce.reduce((te,ne)=>{const se=b(ne,"t");return te+(se?se.textContent.length:0)},0),W=_>0?_:i,le=fe>0?ce.reduce((te,ne)=>{const se=b(ne,"t");return te+(se?se.textContent:"")},"").slice(0,20):"W";e.font=`${de}px sans-serif`;const me=le.length>0?e.measureText(le).width/le.length:de*.6,he=Math.max(1,Math.floor(W/me)),B=Math.max(1,Math.ceil(fe/he));ee+=B*de*1.2}ee<=v?J=oe:I=oe}R=(J+I)/2}let U=x;h==="ctr"?U=x+(v-D)/2:h==="b"&&(U=x+v-D);let q=U;const Q={};for(const J of H){const{lines:I,algn:V,marL:oe,indent:ee,spaceBefore:ae,spaceAfter:Y,lnSpcPx:X,emptyPara:ke,bullet:ce}=J;if(q+=ae,ke){q+=I[0]?X||J.szPx*1.2:12*o,q+=Y;continue}for(const de of I){const{runs:fe,maxSzPx:W}=de,le=X||W*1.2,me=q+W*.85;let he=0;for(const ie of fe)e.font=ie.fontInfo.fontStr,he+=e.measureText(ie.text).width;let B=w+oe;V==="ctr"?B=w+(_-he)/2:V==="r"&&(B=w+_-he);const te=de===I[0];if(ce&&te){const ie=w+oe+ee;Jo(e,ce,ie,me,Q)}let ne=0;if(V==="just"&&!(de===I[I.length-1])){let z=0;for(const re of fe)e.font=re.fontInfo.fontStr,z+=(re.text.match(/ /g)||[]).length;const O=_-oe-he;z>0&&O>0&&(ne=O/z)}const se=(ie,z,O,re,be,ve)=>{e.font=re.fontStr;const je=e.measureText(ie).width;e.fillText(ie,z,O);const Pe=Math.max(.5,re.szPx*.07);return be&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Pe,e.beginPath(),e.moveTo(z,O+Pe*1.5),e.lineTo(z+je,O+Pe*1.5),e.stroke(),e.restore()),ve&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Pe,e.beginPath(),e.moveTo(z,O-re.szPx*.3),e.lineTo(z+je,O-re.szPx*.3),e.stroke(),e.restore()),je};for(const ie of fe){const z=ie.color;e.fillStyle=z?we(z):"#000000";let O=me,re=ie.fontInfo;if(ie.baseline!==0){const be=re.szPx*.65,ve=`${re.italic?"italic ":""}${re.bold?"bold ":""}${be}px "${re.family}", sans-serif`;re={...re,szPx:be,fontStr:ve},ie.baseline>0?O=me-ie.fontInfo.szPx*.38:O=me+ie.fontInfo.szPx*.12}if(ne>0&&ie.text.includes(" ")){e.font=re.fontStr;const be=ie.text.split(" ");for(let ve=0;ve<be.length;ve++){const je=se(be[ve],B,O,re,ie.underline,ie.strikethrough);B+=je,ve<be.length-1&&(e.font=re.fontStr,B+=e.measureText(" ").width+ne)}}else{e.font=re.fontStr;const be=e.measureText(ie.text).width;se(ie.text,B,O,re,ie.underline,ie.strikethrough),B+=be}}q+=le}q+=Y}j&&e.restore()}function Qs(e,n,t,s){const i=b(n,"effectLst");if(!i)return()=>{};const r=b(i,"outerShdw"),o=b(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),m=d*Math.sin(u),g=xe(l),S=_e(g,t),y=S?we(S):"rgba(0,0,0,0.35)";e.shadowBlur=Math.min(c,40),e.shadowOffsetX=p,e.shadowOffsetY=m,e.shadowColor=y}const a=b(i,"glow");if(a){const c=C(a,"rad",0)*s,d=xe(a),h=_e(d,t);h&&(e.shadowBlur=Math.min(c,30),e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor=we(h))}return()=>{e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor="transparent"}}async function an(e,n,t,s,i,r,o,l=null,a=null){const c=b(n,"spPr"),d=b(c,"xfrm");let h=0,u=0,p=0,m=0,g=0,S=!1,y=!1;if(d){const U=b(d,"off"),q=b(d,"ext");U&&(h=C(U,"x",0)*o,u=C(U,"y",0)*o),q&&(p=C(q,"cx",0)*o,m=C(q,"cy",0)*o),g=C(d,"rot",0)/6e4,S=G(d,"flipH","0")==="1",y=G(d,"flipV","0")==="1"}else{const U=ti(n,a);if(U)h=U.x*o,u=U.y*o,p=U.w*o,m=U.h*o;else return}if(p<=0||m<=0)return;if(l){const{grpOff:U,grpExt:q,chOff:Q,chExt:J}=l,I=q.cx/J.cx,V=q.cy/J.cy;h=U.x+(h/o-Q.x)*I*o,u=U.y+(u/o-Q.y)*V*o,p=p*I,m=m*V}const w=h+p/2,x=u+m/2;e.save(),(g!==0||S||y)&&(e.translate(w,x),g!==0&&e.rotate(g*Math.PI/180),S&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x));const _=b(c,"prstGeom"),v=b(c,"custGeom"),k=_?G(_,"prst","rect"):"rect",j={};if(_){const U=b(_,"avLst");if(U){let q=0;for(const Q of pe(U,"gd")){const I=G(Q,"fmla","").match(/val\s+(-?\d+)/);I&&(j[q]=parseInt(I[1])),q++}}}const M=()=>{const U=["noFill","solidFill","gradFill","blipFill","pattFill","grpFill"];for(const Q of U){const J=b(c,Q);if(J)return J}const q=b(n,"style");if(q){const Q=b(q,"fillRef");if(Q){if(C(Q,"idx",1)===0)return Se("<noFill/>").documentElement;const I=xe(Q);if(I)return Se('<solidFill xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'">'+I.outerHTML+"</solidFill>").documentElement}}return null},F=()=>{const U=b(c,"ln");if(U)return U;const q=b(n,"style");if(q){const Q=b(q,"lnRef");if(Q){if(C(Q,"idx",1)===0)return null;const I=xe(Q);if(I)return Se('<ln xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'"><solidFill>'+I.outerHTML+"</solidFill></ln>").documentElement}}return null};if(v){const U=b(v,"pathLst");if(U)for(const Q of pe(U,"path")){const J=C(Q,"w",1)||1,I=C(Q,"h",1)||1,V=p/J,oe=m/I;e.beginPath();for(const Y of Q.children)switch(Y.localName){case"moveTo":{const X=b(Y,"pt");X&&e.moveTo(h+C(X,"x",0)*V,u+C(X,"y",0)*oe);break}case"lnTo":{const X=b(Y,"pt");X&&e.lineTo(h+C(X,"x",0)*V,u+C(X,"y",0)*oe);break}case"cubicBezTo":{const X=pe(Y,"pt");X.length>=3&&e.bezierCurveTo(h+C(X[0],"x",0)*V,u+C(X[0],"y",0)*oe,h+C(X[1],"x",0)*V,u+C(X[1],"y",0)*oe,h+C(X[2],"x",0)*V,u+C(X[2],"y",0)*oe);break}case"quadBezTo":{const X=pe(Y,"pt");X.length>=2&&e.quadraticCurveTo(h+C(X[0],"x",0)*V,u+C(X[0],"y",0)*oe,h+C(X[1],"x",0)*V,u+C(X[1],"y",0)*oe);break}case"arcTo":{const X=C(Y,"wR",0)*V,ke=C(Y,"hR",0)*oe,ce=C(Y,"stAng",0)/6e4*Math.PI/180,de=C(Y,"swAng",0)/6e4*Math.PI/180,fe=e._lastX||h,W=e._lastY||u,le=fe-X*Math.cos(ce),me=W-ke*Math.sin(ce);X===ke?e.arc(le,me,X,ce,ce+de,de<0):e.ellipse(le,me,X,ke,0,ce,ce+de,de<0);break}case"close":e.closePath();break}const ee=M();ee&&await Tt(e,ee,h,u,p,m,o,i,s);const ae=F();ae&&ut(e,ae,i,o)}e.restore();const q=b(n,"txBody");if(q){e.save(),e.beginPath(),e.rect(h,u,p,m),e.clip();const Q=Pn(n);await Zt(e,q,h,u,p,m,o,i,r,Q),e.restore()}return}e.beginPath(),Yt(e,k,h,u,p,m,j);const R=Qs(e,c,i,o),P=h,$=u,N=p,L=m,H=Yo(c)?Ho(e,c,i,P,$,N,L,o):null;try{const U=M();let q=!1;U&&(q=await Tt(e,U,h,u,p,m,o,i,s)),H&&H.overlay();const Q=F();Q?ut(e,Q,i,o):q||(k==="line"||k==="straightConnector1")&&(e.strokeStyle="#000",e.lineWidth=1,e.stroke())}finally{R(),H?.cleanup&&H.cleanup()}e.restore();const D=b(n,"txBody");if(D){e.save(),(g!==0||S||y)&&(e.translate(w,x),g!==0&&e.rotate(g*Math.PI/180),S&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x)),e.beginPath(),e.rect(h,u,p,m),e.clip();const U=Pn(n);await Zt(e,D,h,u,p,m,o,i,r,U),e.restore()}}function Pn(e,n){const t=b(e,"nvSpPr"),s=t?b(t,"nvPr"):null,i=s?b(s,"ph"):null;if(i){const r=G(i,"type","body");if(r==="title"||r==="ctrTitle")return 4400;if(r==="subTitle"||r==="body")return 2800}return 1800}function ut(e,n,t,s){if(!n||b(n,"noFill"))return;const r=b(n,"solidFill"),o=b(n,"gradFill"),l=C(n,"w",12700),a=Math.max(.5,l*s);let c="#000000";if(r){const p=xe(r),m=_e(p,t);m&&(c=we(m))}else o&&(c="#888888");const d=b(n,"prstDash"),h=d?G(d,"val","solid"):"solid",u=G(n,"cap","flat");switch(G(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 ln(e,n,t,s,i,r){const o=b(n,"spPr"),l=b(o,"xfrm");if(!l)return;const a=b(l,"off"),c=b(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,m=C(l,"rot",0)/6e4,g=G(l,"flipH","0")==="1",S=G(l,"flipV","0")==="1";if(u<=0||p<=0)return;const y=b(n,"blipFill"),w=y?b(y,"blip"):null,x=w?w.getAttribute("r:embed")||w.getAttribute("embed"):null,_=d+u/2,v=h+p/2;if(e.save(),(m!==0||g||S)&&(e.translate(_,v),m!==0&&e.rotate(m*Math.PI/180),g&&e.scale(-1,1),S&&e.scale(1,-1),e.translate(-_,-v)),x&&s[x]){const k=s[x],j=b(o,"prstGeom"),M=j?G(j,"prst","rect"):"rect",F={};if(j){const $=b(j,"avLst");if($){let N=0;for(const L of pe($,"gd")){const H=(G(L,"fmla","")||"").match(/val\s+(-?\d+)/);H&&(F[N]=parseInt(H[1])),N++}}}e.beginPath(),Yt(e,M,d,h,u,p,F),e.clip();const R=y?b(y,"srcRect"):null;if(R){const $=C(R,"l",0)/1e5,N=C(R,"t",0)/1e5,L=C(R,"r",0)/1e5,H=C(R,"b",0)/1e5,D=k.naturalWidth*(1-$-L),U=k.naturalHeight*(1-N-H);e.drawImage(k,k.naturalWidth*$,k.naturalHeight*N,D,U,d,h,u,p)}else e.drawImage(k,d,h,u,p);const P=b(o,"ln");P&&(e.beginPath(),Yt(e,M,d,h,u,p,F),ut(e,P,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 Zs(e,n,t,s,i){const r=b(n,"xfrm");if(!r)return;const o=b(r,"off"),l=b(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=b(n,"graphic"),h=d?b(d,"graphicData"):null,u=h?b(h,"tbl"):null;if(!u)return;const p=b(u,"tblPr"),m=p?G(p,"bandRow","0")==="1":!1;p&&G(p,"bandCol","0");const g=p?G(p,"firstRow","0")==="1":!1,S=p?G(p,"lastRow","0")==="1":!1;p&&G(p,"firstCol","0"),p&&G(p,"lastCol","0");const y=b(u,"tblGrid"),w=pe(y,"gridCol").map(v=>C(v,"w",0)*i),x=pe(u,"tr");let _=c;for(let v=0;v<x.length;v++){const k=x[v],j=C(k,"h",457200)*i,M=pe(k,"tc");let F=a;const R=v===0,P=v===x.length-1,$=v%2===1;for(let N=0;N<M.length;N++){const L=M[N],H=C(L,"gridSpan",1);G(L,"vMerge","0");let D=0;for(let I=0;I<H;I++)D+=w[N+I]||0;const U=b(L,"tcPr"),q=U?["noFill","solidFill","gradFill","blipFill","pattFill"].map(I=>b(U,I)).find(Boolean):null;if(e.save(),e.beginPath(),e.rect(F,_,D,j),q)await Tt(e,q,F,_,D,j,i,t,null);else{let I=null;g&&R?I=t.accent1?"#"+t.accent1.toLowerCase():"#4472C4":S&&P?I="#e0e0e0":m&&$&&(I="rgba(0,0,0,0.06)"),e.fillStyle=I||"transparent",I&&e.fill()}const Q=[{el:b(U,"lnL"),x1:F,y1:_,x2:F,y2:_+j},{el:b(U,"lnR"),x1:F+D,y1:_,x2:F+D,y2:_+j},{el:b(U,"lnT"),x1:F,y1:_,x2:F+D,y2:_},{el:b(U,"lnB"),x1:F,y1:_+j,x2:F+D,y2:_+j}];for(const I of Q)I.el?b(I.el,"noFill")||(e.beginPath(),e.moveTo(I.x1,I.y1),e.lineTo(I.x2,I.y2),ut(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 J=b(L,"txBody");J&&(e.save(),e.beginPath(),e.rect(F,_,D,j),e.clip(),await Zt(e,J,F,_,D,j,i,t,s,1400),e.restore()),F+=D}_+=j}}async function cn(e,n,t,s,i,r,o){const l=b(n,"grpSpPr"),a=b(l,"xfrm");if(!a)return;const c=b(a,"off"),d=b(a,"ext"),h=b(a,"chOff"),u=b(a,"chExt");if(!c||!d||!h||!u)return;const p=C(a,"rot",0)/6e4,m=G(a,"flipH","0")==="1",g=G(a,"flipV","0")==="1",S={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=S.grpOff.x+S.grpExt.cx/2,w=S.grpOff.y+S.grpExt.cy/2;e.save(),(p!==0||m||g)&&(e.translate(y,w),p!==0&&e.rotate(p*Math.PI/180),m&&e.scale(-1,1),g&&e.scale(1,-1),e.translate(-y,-w));for(const x of n.children){const _=x.localName;_==="sp"?await an(e,x,t,s,i,r,o,S):_==="pic"?await ln(e,x,t,s,i,o):_==="grpSp"?await cn(e,x,t,s,i,r,o):_==="graphicFrame"?await un(e,x,i,r,o,files,t):_==="cxnSp"&&await dn(e,x,i,o)}e.restore()}function as(e,n,t,s,i,r,o,l,a){const c=b(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),m=u*(h[c.getAttribute("len")||"med"]??6),g=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 S=d==="arrow",y=d==="stealth"?m*.5:0;e.beginPath(),e.moveTo(s,i),e.lineTo(s+m*Math.cos(g)+p/2*Math.sin(g),i+m*Math.sin(g)-p/2*Math.cos(g)),S||e.lineTo(s+y*Math.cos(g),i+y*Math.sin(g)),e.lineTo(s+m*Math.cos(g)-p/2*Math.sin(g),i+m*Math.sin(g)+p/2*Math.cos(g)),e.closePath(),S?e.stroke():e.fill();break}case"diamond":{const S=m/2;e.beginPath(),e.moveTo(s,i),e.lineTo(s+S*Math.cos(g)+p/2*Math.sin(g),i+S*Math.sin(g)-p/2*Math.cos(g)),e.lineTo(s+m*Math.cos(g),i+m*Math.sin(g)),e.lineTo(s+S*Math.cos(g)-p/2*Math.sin(g),i+S*Math.sin(g)+p/2*Math.cos(g)),e.closePath(),e.fill();break}case"oval":{const S=m/2,y=p/2,w=s+S*Math.cos(g),x=i+S*Math.sin(g);e.beginPath(),e.save(),e.translate(w,x),e.rotate(g),e.scale(1,y/S),e.arc(0,0,S,0,Math.PI*2),e.restore(),e.fill();break}}e.restore()}async function dn(e,n,t,s){const i=b(n,"spPr"),r=b(i,"xfrm");if(!r)return;const o=b(r,"off"),l=b(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=G(r,"flipH","0")==="1",m=G(r,"flipV","0")==="1",g=a+d/2,S=c+h/2,y=b(i,"ln");e.save(),(u!==0||p||m)&&(e.translate(g,S),u!==0&&e.rotate(u*Math.PI/180),p&&e.scale(-1,1),m&&e.scale(1,-1),e.translate(-g,-S));const w=b(i,"prstGeom"),x=w?G(w,"prst","line"):"line",_=x==="line"||x==="straightConnector1";if(e.beginPath(),_){const v=p?a:a+d,k=m?c:c+h,j=p?a+d:a,M=m?c+h:c;e.moveTo(j,M),e.lineTo(v,k)}else Yt(e,x,a,c,d,h,{});if(y){if(ut(e,y,t,s),_){const v=p?a+d:a,k=m?c+h:c,j=p?a:a+d,M=m?c:c+h;as(e,y,"headEnd",j,M,v,k,t,s),as(e,y,"tailEnd",v,k,j,M,t,s)}}else e.strokeStyle="#000",e.lineWidth=1,e.stroke();e.restore()}async function Js(e,n,t,s,i,r,o,l,a,c,d){const h=c*a,u=d*a,p=x=>{const _=b(x,"cSld");if(!_)return null;const v=b(_,"bg");if(!v)return null;const k=b(v,"bgPr"),j=b(v,"bgRef");return{bgPr:k,bgRef:j}},m=n?p(n):null,g=s?p(s):null,S=t?p(t):null,y=m||g||S;let w=!1;if(y){const{bgPr:x,bgRef:_}=y;if(x){const v=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const k of v){const j=b(x,k);if(j){e.beginPath(),e.rect(0,0,h,u);const M=y===S?Object.assign({},o):o;await Tt(e,j,0,0,h,u,1,l,M)&&(w=!0);break}}}else if(_){C(_,"idx",0);const v=xe(_),k=_e(v,l);k&&(e.fillStyle=we(k),e.fillRect(0,0,h,u),w=!0)}}w||(e.fillStyle="#ffffff",e.fillRect(0,0,h,u))}function ei(e){const n={};for(const t of e){if(!t)continue;const s=b(t,"cSld"),i=s?b(s,"spTree"):null;if(i)for(const r of pe(i,"sp")){const o=b(r,"nvSpPr"),l=o?b(o,"nvPr"):null,a=l?b(l,"ph"):null;if(!a)continue;const c=G(a,"type","body"),d=G(a,"idx","0"),h=`${c}:${d}`;if(n[h])continue;const u=b(r,"spPr"),p=b(u,"xfrm");if(!p)continue;const m=b(p,"off"),g=b(p,"ext");!m||!g||(n[h]={x:C(m,"x",0),y:C(m,"y",0),w:C(g,"cx",0),h:C(g,"cy",0),txBody:b(r,"txBody")})}}return n}function ti(e,n){if(!n)return null;const t=b(e,"nvSpPr"),s=t?b(t,"nvPr"):null,i=s?b(s,"ph"):null;if(!i)return null;const r=G(i,"type","body"),o=G(i,"idx","0");return n[`${r}:${o}`]||n[`${r}:0`]||n[`body:${o}`]||null}async function un(e,n,t,s,i,r,o){const l=b(n,"graphic"),a=l?b(l,"graphicData"):null,c=a?G(a,"uri",""):"";if(b(n,"tbl")||a&&b(a,"tbl"))return Zs(e,n,t,s,i);const d=b(n,"xfrm");if(!d)return;const h=b(d,"off"),u=b(d,"ext");if(!h||!u)return;const p=C(h,"x",0)*i,m=C(h,"y",0)*i,g=C(u,"cx",0)*i,S=C(u,"cy",0)*i;if(g<=0||S<=0)return;const y=c.includes("chart"),w=c.includes("diagram");if(y&&r&&o){const _=a?b(a,"chart"):null,v=_?_.getAttribute("r:id")||_.getAttribute("id"):null,k=v?o[v]:null;if(k&&r[k.fullPath]){const j=new TextDecoder().decode(r[k.fullPath]),M=Se(j);Go(e,M,p,m,g,S,t,i);return}}if(w&&r&&o){const _=a?b(a,"relIds"):null,v=_?_.getAttribute("r:dm")||_.getAttribute("dm"):null,k=v?o[v]:null;if(k&&r[k.fullPath]){const j=new TextDecoder().decode(r[k.fullPath]),M=Se(j),F=_?_.getAttribute("r:lo")||_.getAttribute("lo"):null,R=F?o[F]:null,P=R&&r[R.fullPath]?Se(new TextDecoder().decode(r[R.fullPath])):null,{renderSmartArt:$}=await tn(async()=>{const{renderSmartArt:N}=await import("./smartart-CYnMNs5u.js");return{renderSmartArt:N}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url);$(e,M,P,p,m,g,S,t,i);return}}const x=y?"📊 Chart":w?"🔷 Diagram":"⬛ Graphic";e.save(),e.fillStyle="#f4f4f8",e.strokeStyle="#ccccdd",e.lineWidth=1,e.fillRect(p,m,g,S),e.strokeRect(p,m,g,S),e.fillStyle="#999",e.font=`${Math.min(g*.07,16*i)}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(x,p+g/2,m+S/2),e.textAlign="start",e.textBaseline="alphabetic",e.restore()}async function ni(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 an(e,c,t,s,i,r,o,null,l):d==="pic"?await ln(e,c,t,s,i,o):d==="grpSp"?await cn(e,c,t,s,i,r,o):d==="graphicFrame"?await un(e,c,i,r,o,a,t):d==="cxnSp"&&await dn(e,c,i,o)}catch(h){console.warn("Error rendering shape:",d,h)}}}const ea=Object.freeze(Object.defineProperty({__proto__:null,applyEffects:Qs,applyFill:Tt,applyOutline:ut,buildPlaceholderMap:ei,computeLineHeight:Ys,getDefaultFontSize:Pn,getRels:Ue,loadImages:Wt,renderBackground:Js,renderConnector:dn,renderGraphicFrame:un,renderGroupShape:cn,renderPicture:ln,renderShape:an,renderSpTree:ni,renderTable:Zs,renderTextBody:Zt,resolvePlaceholderXfrm:ti},Symbol.toStringTag,{value:"Module"}));async function ta(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 na=(()=>{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 sa(e){let n=4294967295;for(let t=0;t<e.length;t++)n=na[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}class ia{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 ye(e){return new Uint8Array([e&255,e>>8&255])}function Ie(e){return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}const si=new TextEncoder;function ra(e){return si.encode(e)}const ls=18977,cs=0;class oa{constructor(){this._entries=[]}async addText(n,t){return this.addBytes(n,si.encode(t))}async addBytes(n,t,s=!0){const i=ra(n),r=sa(t),o=t.length;let l,a;if(s&&t.length>32){const c=await ta(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 ia;for(const i of this._entries)i.localOffset=n.size,n.append(new Uint8Array([80,75,3,4])),n.append(ye(20)),n.append(ye(2048)),n.append(ye(i.method)),n.append(ye(cs)),n.append(ye(ls)),n.append(Ie(i.crc)),n.append(Ie(i.compData.length)),n.append(Ie(i.uncompSize)),n.append(ye(i.nameBytes.length)),n.append(ye(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(ye(798)),n.append(ye(20)),n.append(ye(2048)),n.append(ye(i.method)),n.append(ye(cs)),n.append(ye(ls)),n.append(Ie(i.crc)),n.append(Ie(i.compData.length)),n.append(Ie(i.uncompSize)),n.append(ye(i.nameBytes.length)),n.append(ye(0)),n.append(ye(0)),n.append(ye(0)),n.append(ye(0)),n.append(Ie(0)),n.append(Ie(i.localOffset)),n.append(i.nameBytes);const s=n.size-t;return n.append(new Uint8Array([80,75,5,6])),n.append(ye(0)),n.append(ye(0)),n.append(ye(this._entries.length)),n.append(ye(this._entries.length)),n.append(Ie(s)),n.append(Ie(t)),n.append(ye(0)),n.concat()}}async function aa(e){const n=new oa;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 la=new TextDecoder,ii=new TextEncoder,Ce={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 wt(e){return new DOMParser().parseFromString(e,"application/xml")}function ca(e){const n=new XMLSerializer().serializeToString(e);return n.startsWith("<?xml")?n:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
30
+ `+n}function Ee(e){return ii.encode(ca(e))}function Be(e,n){const t=e[n];return t?wt(la.decode(t)):null}function ue(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 Oe(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 da(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function Je(e){const n=e.split("/"),t=n.pop();return[...n,"_rels",t+".rels"].join("/")}function Ze(e,n){const t=Be(e,Je(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 zt(e){const n=wt('<?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(Ce.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 It(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 Kt(e,n){for(const t of e.children){const s=t.localName;if(s==="sp"||s==="pic"||s==="cxnSp"){const i=ue(t,"nvSpPr")||ue(t,"nvPicPr")||ue(t,"nvCxnSpPr"),r=i?ue(i,"cNvPr"):null;if(r&&(r.getAttribute("name")||"")===n)return t}else if(s==="grpSp"){const i=Kt(t,n);if(i)return i}}return null}function at(e){const n=ue(e,"cSld");return n?ue(n,"spTree"):null}function Lt(e,n,t,s=!0){for(const i of Oe(e,"t")){const r=i.textContent;if(!r)continue;const o=s?r.split(n).join(t):r.replace(new RegExp(ua(n),"gi"),t);o!==r&&(i.textContent=o)}}function ua(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const ds={"image/jpeg":"jpeg","image/jpg":"jpeg","image/png":"png","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"},fa={jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml"};function us(e,n,t){const s="[Content_Types].xml",i=Be(e,s);if(!i)return;const r=i.documentElement;for(const l of Oe(i,"Override"))if(l.getAttribute("PartName")==="/"+t)return;const o=i.createElementNS(Ce.ct,"Override");o.setAttribute("PartName","/"+t),o.setAttribute("ContentType",fa[n]||"application/octet-stream"),r.appendChild(o),e[s]=Ee(i)}class Jt{constructor(n){this._files=n,this._presPath="ppt/presentation.xml",this._presDoc=Be(n,this._presPath),this._presRels=Ze(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 Jt(t)}static async fromBytes(n){const t=await qs(n);return new Jt(t)}_buildSlidePaths(){if(!this._presDoc)return[];const n=ue(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]=Ee(this._presDoc)}_savePresRels(){this._files[Je(this._presPath)]=Ee(zt(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 Be(this._files,t)}_saveSlideDoc(n,t){this._files[this._slidePaths[n]]=Ee(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;Lt(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=Ze(this._files,this._slidePaths[n]),o=Object.values(r).find(a=>a.type?.includes("notesSlide"));if(!o)return;const l=Be(this._files,o.fullPath);if(l){for(const[a,c]of Object.entries(t))Lt(l,s+a+i,String(c));this._files[o.fullPath]=Ee(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(Lt(c,n,t,i),this._saveSlideDoc(a,c),r){const d=Ze(this._files,this._slidePaths[a]),h=Object.values(d).find(u=>u.type?.includes("notesSlide"));if(h){const u=Be(this._files,h.fullPath);u&&(Lt(u,n,t,i),this._files[h.fullPath]=Ee(u))}}}}setShapeText(n,t,s,i={}){const{preserveFormatting:r=!0}=i,o=this._slideDoc(n),l=at(o);if(!l)return this;const a=Kt(l,t);if(!a)throw new Error(`Shape "${t}" not found on slide ${n}`);const c=ue(a,"txBody");if(!c)return this;const d=ue(c,"r"),h=d?ue(d,"rPr"):null,u=ue(ue(c,"p"),"pPr");for(const g of Oe(c,"p"))g.parentNode.removeChild(g);const p=s.split(`
31
+ `),m=Ce.a;for(const g of p){const S=o.createElementNS(m,"a:p");u&&r&&S.appendChild(u.cloneNode(!0));const y=o.createElementNS(m,"a:r");h&&r&&y.appendChild(h.cloneNode(!0));const w=o.createElementNS(m,"a:t");w.textContent=g,y.appendChild(w),S.appendChild(y),c.appendChild(S)}return this._saveSlideDoc(n,o),this}getShapeText(n,t){const s=this._slideDoc(n),i=at(s);if(!i)return"";const r=Kt(i,t);return r?Oe(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),m=at(p);if(!m)return this;const S=Math.max(0,...Oe(m,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,y=`TextBox ${S}`,w=Ce.a,_=`<p:sp xmlns:p="${Ce.p}" xmlns:a="${w}">
32
+ <p:nvSpPr>
33
+ <p:cNvPr id="${S}" name="${y}"/>
34
+ <p:cNvSpPr txBox="1"><a:spLocks noGrp="1"/></p:cNvSpPr>
35
+ <p:nvPr/>
36
+ </p:nvSpPr>
37
+ <p:spPr>
38
+ <a:xfrm><a:off x="${i}" y="${r}"/><a:ext cx="${o}" cy="${l}"/></a:xfrm>
39
+ <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
40
+ <a:noFill/>
41
+ </p:spPr>
42
+ <p:txBody>
43
+ <a:bodyPr wrap="square" rtlCol="0"><a:spAutoFit/></a:bodyPr>
44
+ <a:lstStyle/>
45
+ <a:p>
46
+ <a:pPr algn="${h}"/>
47
+ <a:r>
48
+ <a:rPr lang="en-US" sz="${c}" b="${d?1:0}" dirty="0">
49
+ <a:solidFill><a:srgbClr val="${a}"/></a:solidFill>
50
+ <a:latin typeface="${u}"/>
51
+ </a:rPr>
52
+ <a:t>${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</a:t>
53
+ </a:r>
54
+ </a:p>
55
+ </p:txBody>
56
+ </p:sp>`,v=wt(_);return m.appendChild(p.adoptNode(v.documentElement)),this._saveSlideDoc(n,p),this}async setShapeImage(n,t,s,i="image/jpeg"){const r=this._slideDoc(n),o=at(r);if(!o)return this;const l=Kt(o,t);if(!l)throw new Error(`Shape "${t}" not found on slide ${n}`);const a=Ze(this._files,this._slidePaths[n]),c=ue(l,"blipFill"),d=c?ue(c,"blip"):null,h=d?d.getAttribute("r:embed")||d.getAttribute("embed"):null,u=h?a[h]:null,p=ds[i]||"jpeg",m=Object.keys(this._files).filter(y=>y.startsWith("ppt/media/")).length+1,g=`ppt/media/image${m}.${p}`;this._files[g]=s;let S;return h&&u?(S=h,a[S]={id:S,type:u.type,target:`../media/image${m}.${p}`,fullPath:g}):(S=It(a),a[S]={id:S,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${m}.${p}`,fullPath:g}),d&&d.setAttribute("r:embed",S),this._files[Je(this._slidePaths[n])]=Ee(zt(a)),this._saveSlideDoc(n,r),us(this._files,p,g),this}async addImage(n,t,s="image/jpeg",i={}){const{x:r=914400,y:o=914400,w:l=2743200,h:a=2057400}=i,c=ds[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=Ze(this._files,this._slidePaths[n]),p=It(u);u[p]={id:p,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${d}.${c}`,fullPath:h},this._files[Je(this._slidePaths[n])]=Ee(zt(u));const m=this._slideDoc(n),g=at(m);if(!g)return this;const y=Math.max(0,...Oe(g,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,w=Ce.a,_=`<p:pic xmlns:p="${Ce.p}" xmlns:a="${w}" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
57
+ <p:nvPicPr>
58
+ <p:cNvPr id="${y}" name="Picture ${y}"/>
59
+ <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>
60
+ <p:nvPr/>
61
+ </p:nvPicPr>
62
+ <p:blipFill>
63
+ <a:blip r:embed="${p}"/>
64
+ <a:stretch><a:fillRect/></a:stretch>
65
+ </p:blipFill>
66
+ <p:spPr>
67
+ <a:xfrm><a:off x="${r}" y="${o}"/><a:ext cx="${l}" cy="${a}"/></a:xfrm>
68
+ <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
69
+ </p:spPr>
70
+ </p:pic>`,v=wt(_);return g.appendChild(m.adoptNode(v.documentElement)),this._saveSlideDoc(n,m),us(this._files,c,h),this}setSlideBackground(n,t){const s=this._slideDoc(n),i=ue(s,"cSld");if(!i)return this;const r=ue(i,"bg");r&&i.removeChild(r);const o=Ce.a,a=`<p:bg xmlns:p="${Ce.p}" xmlns:a="${o}">
71
+ <p:bgPr><a:solidFill><a:srgbClr val="${t}"/></a:solidFill>
72
+ <a:effectLst/></p:bgPr></p:bg>`,c=s.adoptNode(wt(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=Ze(this._files,l.fullPath);i=Object.values(a).find(c=>c.type?.includes("theme"))?.fullPath}}if(!i)return this;const r=Be(this._files,i);if(!r)return this;ue(r,"fmtScheme");const o=ue(r,"clrScheme");if(!o)return this;for(const l of o.children)if(l.localName===n){const a=ue(l,"srgbClr");if(a)a.setAttribute("val",t);else{for(;l.firstChild;)l.removeChild(l.firstChild);const c=Ce.a,d=r.createElementNS(c,"a:srgbClr");d.setAttribute("val",t),l.appendChild(d)}break}return this._files[i]=Ee(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(g=>g.match(/ppt\/slides\/slide(\d+)\.xml/)).filter(Boolean).map(g=>parseInt(g[1],10)),o=(r.length?Math.max(...r):0)+1,l=`ppt/slides/slide${o}.xml`,a=Je(l);this._files[l]=this._files[i].slice();const c=Je(i);this._files[c]&&(this._files[a]=this._files[c].slice());const d=It(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=ue(this._presDoc,"sldIdLst");if(u){const g=Oe(u,"sldId").map(_=>parseInt(_.getAttribute("id")||"0",10)),S=(g.length?Math.max(...g):255)+1,y=Ce.p,w=this._presDoc.createElementNS(y,"p:sldId");w.setAttribute("id",String(S)),w.setAttributeNS(Ce.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",m=Be(this._files,p);if(m){const g=m.documentElement,S=m.createElementNS(Ce.ct,"Override");S.setAttribute("PartName","/"+l),S.setAttribute("ContentType","application/vnd.openxmlformats-officedocument.presentationml.slide+xml"),g.appendChild(S),this._files[p]=Ee(m)}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=ue(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=ue(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=Ze(this._files,s),r=Object.values(i).find(o=>o.type?.includes("notesSlide"));if(r){const o=Be(this._files,r.fullPath);if(o){for(const l of Oe(o,"sp")){const a=ue(ue(l,"nvSpPr"),"nvPr"),c=a?ue(a,"ph"):null;if(c&&da(c,"type")!=="sldNum"){for(const h of Oe(l,"t"))h.textContent="";const d=ue(l,"t");d&&(d.textContent=t);break}}this._files[r.fullPath]=Ee(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=Ce.p,l=Ce.a,a=`ppt/notesSlides/notesSlide${r}.xml`,c=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
73
+ <p:notes xmlns:p="${o}" xmlns:a="${l}">
74
+ <p:cSld><p:spTree>
75
+ <p:sp>
76
+ <p:nvSpPr><p:cNvPr id="2" name="Notes Placeholder 1"/>
77
+ <p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
78
+ <p:nvPr><p:ph type="body" idx="1"/></p:nvPr>
79
+ </p:nvSpPr>
80
+ <p:spPr/>
81
+ <p:txBody><a:bodyPr/><a:lstStyle/>
82
+ <a:p><a:r><a:t>${i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</a:t></a:r></a:p>
83
+ </p:txBody>
84
+ </p:sp>
85
+ </p:spTree></p:cSld>
86
+ </p:notes>`;this._files[a]=ii.encode(c);const d=It(s);s[d]={id:d,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",target:`../notesSlides/notesSlide${r}.xml`,fullPath:a},this._files[Je(t)]=Ee(zt(s))}async save(){return aa(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=at(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=ue(r,"nvSpPr")||ue(r,"nvPicPr")||ue(r,"nvGraphicFramePr")||ue(r,"nvCxnSpPr"),a=l?ue(l,"cNvPr"):null;i.push({id:a?.getAttribute("id")||"",name:a?.getAttribute("name")||"",type:o})}return i}}const ri=new TextEncoder;function ha(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}class pa{constructor(){this._parts=[],this._size=0}write(n){const t=typeof n=="string"?ri.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 ma(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 ga(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 ba(e,n){const t=e/914400*72,s=n/914400*72;return{w:t,h:s}}class ya{constructor(){this._buf=new pa,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
87
+ `),s){const r=s.length;this._buf.write(`${t.replace("__LEN__",r)}
88
+ `),this._buf.write(`stream\r
89
+ `),this._buf.write(s),this._buf.write(`\r
90
+ endstream
91
+ `)}else this._buf.write(`${t}
92
+ `);return this._buf.write(`endobj
93
+
94
+ `),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}=ba(c,d);this._buf.write(`%PDF-1.4
95
+ `),this._buf.write(`%ÿþýü
96
+
97
+ `);const p=this._nextObj(),m=this._nextObj(),g=Array.from({length:a},()=>this._nextObj()),S=Array.from({length:a},()=>this._nextObj()),y=Array.from({length:a},()=>this._nextObj());this._writeObj(p,`<< /Type /Catalog /Pages ${m} 0 R >>`);const w=g.map(v=>`${v} 0 R`).join(" ");this._writeObj(m,`<< /Type /Pages /Kids [${w}] /Count ${a} >>`);for(let v=0;v<a;v++){const k=l[v];o?.(v,a);const j=await ga(n,k,s),M=await ma(j,i),F=j.width,R=j.height;this._writeObj(g[v],`<< /Type /Page /Parent ${m} 0 R /MediaBox [0 0 ${h.toFixed(3)} ${u.toFixed(3)}] /Resources << /XObject << /Im${v} ${S[v]} 0 R >> >> /Contents ${y[v]} 0 R >>`),this._writeObj(S[v],`<< /Type /XObject /Subtype /Image /Width ${F} /Height ${R} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length __LEN__ >>`,M);const P=`q ${h.toFixed(3)} 0 0 ${u.toFixed(3)} 0 0 cm /Im${v} Do Q`;this._writeObj(y[v],"<< /Length __LEN__ >>",ri.encode(P))}o?.(a,a);const x=this._buf.size,_=this._objNum+1;this._buf.write(`xref
98
+ 0 ${_}
99
+ `),this._buf.write(`0000000000 65535 f \r
100
+ `);for(let v=1;v<_;v++){const k=this._xref[v]??0;this._buf.write(String(k).padStart(10,"0")+` 00000 n \r
101
+ `)}return this._buf.write(`trailer
102
+ << /Size ${_} /Root ${p} 0 R >>
103
+ `),this._buf.write(`startxref
104
+ ${x}
105
+ %%EOF
106
+ `),this._buf.concat()}}async function Bn(e,n={}){const{width:t=null,dpi:s=150,quality:i=.92,slides:r=null,onProgress:o=null}=n,l=t??ha(e,s);return new ya().build(e,{widthPx:l,quality:i,slideList:r,onProgress:o})}async function va(e,n="presentation.pdf",t={}){const s=await Bn(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 wa(e,n,t={}){return Bn(n,{...t,slides:[e]})}const xa=500;function On(e){if(!e)return[];const n=b(e,"timing");if(!n)return[];const t=b(n,"tnLst");if(!t)return[];const s=[];function i(o,l,a){const c=b(o,"cTn");if(!c)return;const d=G(c,"nodeType","");d==="clickEffect"&&(l+=1),d==="withEffect"&&l===0&&(l=0);const h=C(c,"delay",0)+a,u=b(o,"childTnLst")||b(c,"childTnLst");if(u)for(const p of u.children){const m=p.localName;if(m==="par")i(p,l,h);else if(m==="seq"){const g=b(p,"cTn"),y=(g?G(g,"nodeType",""):"")==="clickEffect"?l+1:l,w=b(p,"childTnLst");if(w)for(const x of w.children)x.localName==="par"&&i(x,y,h)}else if(m==="set"||m==="animEffect"||m==="anim"||m==="animScale"||m==="animClr"){const g=fs(p,l,h);g&&s.push(g)}}}function r(o,l){const a=b(o,"childTnLst")||b(b(o,"cTn"),"childTnLst");if(!a)return;let c=l;for(const d of a.children)if(d.localName==="par"){const h=b(d,"cTn"),u=h?G(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 pe(t,"animEffect")){const l=fs(o,0,0);l&&s.push(l)}return s.sort((o,l)=>o.clickNum-l.clickNum||o.delay-l.delay)}function fs(e,n,t){const s=b(e,"cTn"),i=b(e,"tgt")||b(s,"tgt"),r=i?b(i,"spTgt"):null,o=r?G(r,"spid",null):null;if(!o)return null;const l=s?G(s,"dur",null):null,a=l==="indefinite"?2e3:l?parseInt(l,10):xa,c=(s?C(s,"delay",0):0)+t,d=G(e,"filter",null),h=G(e,"type",null)||(d?"filter":"set"),u=G(e,"dir",null)||(d?d.split("(")[1]?.replace(")",""):null)||"";let p="emphasis";(h==="in"||e.localName==="set"&&G(b(e,"attrNameLst")||e,"attrName","")==="style.visibility"&&G(e,"to","")==="visible")&&(p="entrance"),(h==="out"||e.localName==="set"&&G(e,"to","")==="hidden")&&(p="exit");let m=d||e.localName;if(d){const g=d.toLowerCase();g.includes("fade")?m="fade":g.includes("fly")?m="fly":g.includes("appear")?m="appear":g.includes("zoom")?m="zoom":g.includes("wipe")?m="wipe":g.includes("wheel")?m="wheel":g.includes("blinds")?m="blinds":g.includes("box")?m="box":g.includes("dissolve")?m="dissolve":g.includes("split")?m="split":g.includes("stretch")?m="stretch":g.includes("diamond")?m="diamond":g.includes("plus")?m="plus":g.includes("wedge")?m="wedge":g.includes("random")?m="dissolve":g.includes("strips")?m="strips":g.includes("peek")?m="fly":g.includes("checkerboard")?m="dissolve":m="fade"}return{shapeId:o,type:p,effect:m,clickNum:n,delay:c,duration:a,dir:u,raw:e.localName}}function Un(e){if(!e)return null;const n=b(e,"transition");if(!n)return null;const t=C(n,"dur",700),s=G(n,"spd","med"),i=s==="slow"?1200:s==="fast"?300:t,r=n.firstElementChild,o=r?.localName||"fade",l=r?G(r,"dir","l"):"l";return{type:o,duration:i,dir:l}}function ka(e){return 1-Math.pow(1-e,2)}function _a(e){return e*e}function Sa(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}function oi(e,n,t,s){const i=Math.max(0,Math.min(1,n)),r=e.type==="entrance",o=r?ka(i):_a(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 oi(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 ai(e,n,t,s,i){const r=Sa(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 li{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 tn(async()=>{const{parseXml:a}=await Promise.resolve().then(()=>vo);return{parseXml:a}},void 0,import.meta.url).catch(()=>({parseXml:a=>new DOMParser().parseFromString(a,"application/xml")})),o=r(i);this._steps=On(o),this._transition=Un(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,m=oi(c,h,u*.3,p*.3);this._shapeStates.set(c.shapeId,{...m,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);ai(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 Pa=Object.freeze(Object.defineProperty({__proto__:null,PptxPlayer:li,parseAnimations:On,parseTransition:Un,renderTransitionFrame:ai},Symbol.toStringTag,{value:"Module"}));let Ta=0;function fn(e="el"){return`${e}${++Ta}`}function Me(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function A(e){return`${+e.toFixed(3)}`}function Tn(e){return e?we(e):"none"}function ci(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=xe(e),c=_e(a,t),d=Tn(c),h=c?.a!=null?c.a/255:1;return{fill:d,fillAttrs:h<1?` fill-opacity="${A(h)}"`:""}}if(l==="gradFill"){const a=b(e,"gsLst"),c=a?pe(a,"gs").map(m=>{const g=C(m,"pos",0)/1e5,S=xe(m),y=_e(S,t);return{pos:g,color:Tn(y),opacity:y?.a!=null?y.a/255:1}}):[],d=b(e,"lin"),h=b(e,"path"),u=fn("grad");let p;if(h){const m=b(h,"fillToRect"),g=C(m,"l",5e4)/1e5,S=C(m,"t",5e4)/1e5,y=s+r*g,w=i+o*S,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 _ of c)p+=`<stop offset="${A(_.pos)}" stop-color="${Me(_.color)}"${_.opacity<1?` stop-opacity="${A(_.opacity)}"`:""}/>`;p+="</radialGradient>"}else{const g=(C(d,"ang",0)/6e4-90)*(Math.PI/180),S=Math.cos(g),y=Math.sin(g),w=Math.sqrt(r*r+o*o)/2,x=s+r/2,_=i+o/2;p=`<linearGradient id="${u}" x1="${A(x-S*w)}" y1="${A(_-y*w)}" x2="${A(x+S*w)}" y2="${A(_+y*w)}" gradientUnits="userSpaceOnUse">`;for(const v of c)p+=`<stop offset="${A(v.pos)}" stop-color="${Me(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 di(e,n,t){if(!e)return"";if(b(e,"noFill"))return' stroke="none"';const s=b(e,"solidFill"),i=s?xe(s):null,r=_e(i,n),o=Tn(r)||"#000",l=Math.max(.5,C(e,"w",12700)/914400*96),a=b(e,"prstDash"),c=a?G(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=G(e,"cap","flat"),u=h==="rnd"?"round":h==="sq"?"square":"butt";return` stroke="${Me(o)}" stroke-width="${A(l)}" stroke-linecap="${u}" stroke-linejoin="round"${d}`}function ui(e,n){if(!e)return"";const t=b(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=xe(t),d=_e(c,{}),h=d?we(d):"rgba(0,0,0,0.5)",u=d?.a!=null?d.a/255:.5,p=fn("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="${Me(h)}" flood-opacity="${A(u)}"/></filter>`),` filter="url(#${p})"`}function ja(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 m=a+d*Math.cos(h),g=c+d*Math.sin(h),S=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,_=w>0?1:0;o.length===0&&o.push(`M${A(m)},${A(g)}`),o.push(`A${A(d)},${A(d)},0,${x},${_},${A(S)},${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 Ca=null;function hn(e){if(!e)return"";const n=C(e,"rot",0)/6e4,t=G(e,"flipH","0")==="1",s=G(e,"flipV","0")==="1",i=b(e,"off"),r=b(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 Mt(e){if(!e)return null;const n=b(e,"off"),t=b(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 Fa(e,n,t,s,i,r,o,l){if(!e)return"";const a=b(e,"bodyPr"),c=G(a,"vert","horz"),d=c==="vert"||c==="vert270"||c==="wordArtVert";G(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 m=n+h,g=s-h-u,S=t+p,y=1800,w=b(e,"lstStyle"),x=w?b(w,"defRPr"):null,_=pe(e,"p");let v="",k=S;const j=fn("clip");l.push(`<clipPath id="${j}"><rect x="${A(n)}" y="${A(t)}" width="${A(s)}" height="${A(i)}"/></clipPath>`);const M=d?` transform="rotate(-90,${A(n+s/2)},${A(t+i/2)})"`:"",F={};for(const R of _){const P=b(R,"pPr"),$=G(P,"algn","l"),N=C(P,"marL",0)/914400*96,L=C(P,"indent",0)/914400*96,H=b(P,"defRPr");let D=y;if(x){const B=x.getAttribute("sz");B&&(D=parseInt(B,10))}if(H){const B=H.getAttribute("sz");B&&(D=parseInt(B,10))}const U=b(P,"spcBef"),q=b(P,"spcAft");b(P,"lnSpc");let Q=0,J=0;if(U){const B=b(U,"spcPct"),te=b(U,"spcPts");B?Q=D*kt/914400*96*(C(B,"val",0)/1e5):te&&(Q=C(te,"val",0)/100/72*96)}if(q){const B=b(q,"spcPct"),te=b(q,"spcPts");B?J=D*kt/914400*96*(C(B,"val",0)/1e5):te&&(J=C(te,"val",0)/100/72*96)}const I=P?b(P,"buChar"):null,V=P?b(P,"buAutoNum"):null,ee=!(P?b(P,"buNone"):null)&&(I||V);k+=Q;const ae=[];for(const B of R.children)(B.localName==="r"||B.localName==="br"||B.localName==="fld")&&ae.push(B);if(!ae.length){const B=b(R,"endParaRPr"),se=C(B||H,"sz",D)/100/72*96*1.2;k+=se+J;continue}let Y="";for(const B of ae){if(B.localName==="br"){Y+=`
107
+ `;continue}const te=b(B,"t")||b(B,"fldVal");te&&(Y+=te.textContent)}const X=[];for(const B of ae){if(B.localName==="br"){X.push({br:!0});continue}const te=b(B,"rPr")||b(B,"r")?.firstElementChild,ne=b(B,"t");if(!ne)continue;const se=ne.textContent;if(!se)continue;const ie=Ks(B,H,x,r,o,D),z=ie?.szPx||D/100/72*96,O=ie?.family||"sans-serif",re=ie?.bold?"bold":"normal",be=ie?.italic?"italic":"normal",ve=ie?.color?we(ie.color):"#000000",je=te?(te.getAttribute("u")||"none")!=="none":!1,Pe=te?(te.getAttribute("strike")||"noStrike")!=="noStrike":!1,rt=te?parseInt(te.getAttribute("baseline")||"0",10):0;X.push({text:se,szPx:z,family:O,bold:re,italic:be,color:ve,underline:je,strike:Pe,baseline:rt})}if(!X.length){k+=J;continue}const ke=X.filter(B=>!B.br&&B.szPx).map(B=>B.szPx),ce=ke.length?Math.max(...ke):D/100/72*96,de=ce*1.2,fe=k+ce*.85;let W="start",le=m+N;$==="ctr"?(W="middle",le=m+g/2):$==="r"&&(W="end",le=m+g);let me="";if(ee){const B=m+N+L;let te="";if(I)te=Me(I.getAttribute("char")||"•");else if(V){const se=V.getAttribute("type")||"arabicPeriod",ie=C(V,"startAt",1),z=se+":"+ie;F[z]||(F[z]=ie),te=Me(Na(se,F[z]++))}const ne=ce;me=`<text x="${A(B)}" y="${A(fe)}" font-size="${A(ne)}" font-family="sans-serif" fill="#000">${te}</text>`}let he="";for(const B of X){if(B.br){k+=de,he+=`<tspan x="${A(le)}" dy="${A(de)}">`;continue}const te=B.underline?"underline":B.strike?"line-through":"none";let ne=fe;B.baseline>0?ne=fe-B.szPx*.38:B.baseline<0&&(ne=fe+B.szPx*.12);const se=B.baseline!==0?B.szPx*.65:B.szPx;he+=`<tspan font-family="${Me(B.family)}, sans-serif" font-size="${A(se)}" font-weight="${B.bold}" font-style="${B.italic}" fill="${Me(B.color)}"`+(te!=="none"?` text-decoration="${te}"`:"")+(B.baseline!==0?` dy="${A(ne-fe)}"`:"")+`>${Me(B.text)}</tspan>`}v+=me,v+=`<text x="${A(le)}" y="${A(fe)}" text-anchor="${W}">${he}</text>`,k+=de+J}return`<g clip-path="url(#${j})"${M}>${v}</g>`}function Na(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return hs(n).toLowerCase()+".";case"romanUcPeriod":return hs(n)+".";case"alphaLcParenR":return String.fromCharCode(96+n)+")";case"alphaUcParenR":return String.fromCharCode(64+n)+")";default:return n+"."}}function hs(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 Vt(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 Ma(l,s,i,r):a==="pic"?o+=await Aa(l,n,t,s,r):a==="cxnSp"?o+=await $a(l,s):a==="grpSp"?o+=await Ea(l,n,t,s,i,r):a==="graphicFrame"&&(o+=await Ra(l))}return o}async function Ma(e,n,t,s){const i=b(e,"spPr"),r=b(i,"xfrm"),o=Mt(r);if(!o)return"";const l=b(i,"prstGeom"),a=l?G(l,"prst","rect"):"rect",c=b(i,"custGeom"),d=["noFill","solidFill","gradFill","blipFill","pattFill"];let h=null;for(const k of d){const j=b(i,k);if(j){h=j;break}}if(!h){const k=b(e,"style"),j=k?b(k,"fillRef"):null;if(j&&C(j,"idx",1)!==0){const M=xe(j),F=_e(M,n);F&&(h=new DOMParser().parseFromString(`<solidFill xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><srgbClr val="${we(F).replace("#","")}"/></solidFill>`,"application/xml").documentElement)}}const{fill:u,fillAttrs:p}=ci(h,s,n,o.x,o.y,o.w,o.h);let m=b(i,"ln");if(!m){const k=b(e,"style"),j=k?b(k,"lnRef"):null;if(j&&C(j,"idx",1)!==0){const M=xe(j),F=_e(M,n);F&&(m=new DOMParser().parseFromString(`<ln xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><solidFill><srgbClr val="${we(F).replace("#","")}"/></solidFill></ln>`,"application/xml").documentElement)}}const g=di(m,n),S=b(i,"effectLst"),y=ui(S,s),w=hn(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="${Me(u)}"${p}${g}${y}${w}/>`;else{const k=ja(a,o.x,o.y,o.w,o.h,{});x=`<path d="${Me(k)}" fill="${Me(u)}"${p}${g}${y}${w}/>`}const _=b(e,"txBody"),v=_?Fa(_,o.x,o.y,o.w,o.h,n,t,s):"";return`<g>${x}${v}</g>`}async function Aa(e,n,t,s,i){const r=b(e,"spPr"),o=b(r,"xfrm"),l=Mt(o);if(!l)return"";const a=b(e,"blipFill"),c=a?b(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=hn(o),m=b(r,"effectLst"),g=ui(m,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 S=h.fullPath.split(".").pop().toLowerCase(),y=S==="png"?"image/png":S==="gif"?"image/gif":S==="svg"?"image/svg+xml":"image/jpeg",w=u instanceof Uint8Array?u:new Uint8Array(u),x=btoa(Array.from(w,v=>String.fromCharCode(v)).join("")),_=fn("pic");return i.push(`<clipPath id="${_}"><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(#${_})"${g}${p} preserveAspectRatio="xMidYMid slice"/>`}async function $a(e,n,t){const s=b(e,"spPr"),i=b(s,"xfrm"),r=Mt(i);if(!r)return"";const o=b(s,"ln"),l=di(o,n),a=hn(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 Ea(e,n,t,s,i,r){const o=b(e,"grpSpPr"),l=b(o,"xfrm");Mt(l);const a=l?hn(l):"",c=await Vt(e,n,t,s,i,r);return`<g${a}>${c}</g>`}async function Ra(e,n,t){const s=b(e,"xfrm"),i=Mt(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 za(e,n,t,s,i,r,o,l,a){const c=p=>{const m=b(p,"cSld"),g=m?b(m,"bg"):null;return g?{bgPr:b(g,"bgPr"),bgRef:b(g,"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 m of p){const g=b(h,m);if(g){if(m==="blipFill"){const w=b(g,"blip"),x=w?w.getAttribute("r:embed")||w.getAttribute("embed"):null,_=x&&i?i[x]:null,v=_?s[_.fullPath]:null;if(v){const j=_.fullPath.split(".").pop().toLowerCase()==="png"?"image/png":"image/jpeg",M=v instanceof Uint8Array?v:new Uint8Array(v),F=btoa(Array.from(M,R=>String.fromCharCode(R)).join(""));return`<image width="${A(o)}" height="${A(l)}" href="data:${j};base64,${F}" preserveAspectRatio="xMidYMid slice"/>`}}const{fill:S,fillAttrs:y}=ci(g,a,r,0,0,o,l);return`<rect width="${A(o)}" height="${A(l)}" fill="${Me(S)}"${y}/>`}}}if(u){const p=xe(u),m=_e(p,r);if(m)return`<rect width="${A(o)}" height="${A(l)}" fill="${Me(we(m))}"/>`}return`<rect width="${A(o)}" height="${A(l)}" fill="white"/>`}async function fi(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=Se(d),u=await Ue(t,c),p=Object.values(u).find(P=>P.type?.includes("slideLayout")),m=p&&t[p.fullPath]?Se(new TextDecoder().decode(t[p.fullPath])):null,g=p?await Ue(t,p.fullPath):{},S=i.cx/914400*96,y=i.cy/914400*96,w=[],x=await za(h,l,m,t,a,r,S,y,w),_=b(b(l,"cSld"),"spTree"),v=m?b(b(m,"cSld"),"spTree"):null,k=b(b(h,"cSld"),"spTree"),j=_?await Vt(_,a,t,r,o,w):"",M=v?await Vt(v,g,t,r,o,w):"",F=k?await Vt(k,u,t,r,o,w):"",R=w.length?`<defs>${w.join(`
108
+ `)}</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(S)}" height="${A(y)}" viewBox="0 0 ${A(S)} ${A(y)}">`,R,x,j,M,F,"</svg>"].join(`
109
+ `)}async function Ia(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await fi(t,e));return n}function ps(e){const n=e.replace(/[{}\-]/g,"");if(n.length<32){const a=n.padEnd(32,"0");return La(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 La(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 ms(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 vn(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 jn=new Set;async function Da(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:m}of h){if(!u)continue;const g=u.getAttribute("r:id")||u.getAttribute("id")||u.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id");if(!g)continue;const S=`${d}:${p}:${m}`;if(jn.has(S)){t.push({typeface:d,weight:p,style:m,status:"already-loaded"});continue}const y=n?n[g]:null;if(!y){t.push({typeface:d,weight:p,style:m,status:"rel-not-found",rId:g});continue}const w=e[y.fullPath];if(!w){t.push({typeface:d,weight:p,style:m,status:"file-not-found",path:y.fullPath});continue}let x=null;const _=ps(g),v=ms(w,_);if(vn(v))x=v;else{const k=y.fullPath.split("/").pop().replace(".fntdata",""),j=ps(k),M=ms(w,j);vn(M)?x=M:vn(w)&&(x=w)}if(!x){t.push({typeface:d,weight:p,style:m,status:"decode-failed",path:y.fullPath});continue}try{const k=new FontFace(d,x.buffer,{weight:p,style:m});await k.load(),document.fonts.add(k),jn.add(S),t.push({typeface:d,weight:p,style:m,status:"loaded",path:y.fullPath})}catch(k){t.push({typeface:d,weight:p,style:m,status:"load-failed",error:k.message})}}}return t}function Ba(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=>jn.has(`${o}:${a==="bold"||a==="boldItalic"?"700":"400"}:${a.includes("talic")?"italic":"normal"}`))}}).filter(i=>i.typeface):[]}function K(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 He(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 Fe(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function Cn(e,n,t=0){const s=Fe(e,n);return s!==null?parseInt(s,10):t}function Oa(e,n){const t=K(e,"rPr"),s=K(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=K(t,"solidFill")||K(t,"lumMod");if(h){const u=K(h,"srgbClr");u&&(d="#"+(u.getAttribute("val")||"000000"))}}return{text:i,bold:l,italic:a,underline:c!=="none",fontSize:o,color:d}}function Ua(e){const n=K(e,"pPr"),t=Fe(n,"algn","l"),s=Cn(n,"lvl",0),i=K(n,"defRPr");let r=null;if(n&&!K(n,"buNone")){const a=K(n,"buChar"),c=K(n,"buAutoNum");a?r=a.getAttribute("char")||"•":c&&(r="{auto}")}const o=[];for(const a of e.children)if(a.localName==="r"){const c=Oa(a,i);c&&o.push(c)}else if(a.localName==="br")o.push({text:`
110
+ `,bold:!1,italic:!1,underline:!1,fontSize:12,color:"#000"});else if(a.localName==="fld"){const c=K(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 Fn(e){return e?He(e,"p").map(Ua).filter(n=>n.text.trim()):[]}function gs(e){const n=K(e,"nvSpPr"),t=n?K(n,"nvPr"):null,s=t?K(t,"ph"):null;if(s){const r=Fe(s,"type","body");if(r==="title"||r==="ctrTitle")return"title";if(r==="subTitle")return"subtitle";if(r==="body")return"body"}return K(e,"txBody")?"textBox":"other"}function bs(e){const n=K(e,"nvSpPr"),t=n?K(n,"cNvPr"):null;return t?Fe(t,"id",""):""}function ys(e){const n=K(e,"nvSpPr"),t=n?K(n,"cNvPr"):null;return t?Fe(t,"name",""):""}function Ga(e){const n=K(e,"tbl");if(!n)return null;const t=K(e,"nvGraphicFramePr"),s=t?K(t,"cNvPr"):null,i=s?Fe(s,"id",""):"",r=s?Fe(s,"name",""):"",o=[];let l=0;for(const c of He(n,"tr")){const d=[];let h=0;for(const u of He(c,"tc")){const p=Cn(u,"gridSpan",1),m=Cn(u,"rowSpan",1),g=Fn(K(u,"txBody")),S=g.map(y=>y.text).join(`
111
+ `);d.push({row:l,col:h,rowSpan:m,colSpan:p,text:S,paragraphs:g}),h++}o.push(d),l++}const a=o.map(c=>c.map(d=>d.text).join(" ")).join(`
112
+ `);return{id:i,name:r,rows:o,text:a}}function qa(e,n){const t=K(e,"graphic"),s=t?K(t,"graphicData"):null,i=s?K(s,"chart"):null;if(!i)return null;const r=i.getAttribute("r:id")||i.getAttribute("id"),o=K(e,"nvGraphicFramePr"),l=o?K(o,"cNvPr"):null;return{id:l?Fe(l,"id",""):"",name:l?Fe(l,"name",""):"",rId:r}}function Wa(e){if(!e)return{chartType:"unknown",seriesNames:[],categories:[]};const n=K(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=K(n,a),i){s=a.replace("3DChart","Chart").replace("Chart","");break}const r=i?He(i,"ser"):[],o=r.map(a=>{const c=K(a,"tx");if(!c)return null;const d=K(c,"v");if(d)return d.textContent.trim();const h=K(c,"strCache"),u=h?K(h,"pt"):null,p=u?K(u,"v"):null;return p?p.textContent.trim():null}).filter(Boolean),l=r.length>0?(()=>{const a=K(r[0],"cat")||K(r[0],"xVal");if(!a)return[];const c=K(a,"strCache")||K(a,"numCache");return c?He(c,"pt").map(d=>K(d,"v")?.textContent||"").filter(Boolean):[]})():[];return{chartType:s,seriesNames:o,categories:l}}function Ka(e){if(!e)return"";const n=K(e,"cSld"),t=n?K(n,"spTree"):null;if(!t)return"";const s=[];for(const i of He(t,"sp")){const r=K(i,"nvSpPr"),o=r?K(r,"nvPr"):null,l=o?K(o,"ph"):null;if(l&&Fe(l,"type")==="sldNum")continue;const a=K(i,"txBody");if(a){const c=He(a,"r").map(d=>K(d,"t")?.textContent||"").join("");c.trim()&&s.push(c.trim())}}return s.join(`
113
+
114
+ `)}async function pn(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 tn(async()=>{const{getRels:v}=await Promise.resolve().then(()=>ea);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=Ka(v)}const d=K(r,"cSld"),h=d?K(d,"spTree"):null;if(!h)return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:c,text:c};const u=[],p=[],m=[],g=[];for(const v of h.children){const k=v.localName;if(k==="sp"){const j=K(v,"txBody");if(!j)continue;const M=gs(v),F=bs(v),R=ys(v),P=Fn(j),$=P.map(N=>N.text).join(`
115
+ `);$.trim()&&u.push({id:F,name:R,type:M,paragraphs:P,text:$})}else if(k==="pic"){const j=K(v,"nvPicPr"),M=j?K(j,"cNvPr"):null,F=M?Fe(M,"id",""):"",R=M?Fe(M,"name",""):"",P=M?Fe(M,"descr","")||Fe(M,"title",""):"",$=j?K(j,"nvPr"):null;$&&K($,"extLst"),m.push({id:F,name:R,altText:P,title:R})}else if(k==="graphicFrame"){const j=(()=>{const M=K(v,"graphic"),F=M?K(M,"graphicData"):null;return F?Fe(F,"uri",""):""})();if(j.includes("table")||K(v,"tbl")){const M=Ga(v);M&&p.push(M)}else if(j.includes("chart")){const M=qa(v);if(M){const F=M.rId?l[M.rId]:null;let R={chartType:"chart",seriesNames:[],categories:[]};if(F&&t[F.fullPath]){const P=new DOMParser().parseFromString(new TextDecoder().decode(t[F.fullPath]),"application/xml");R=Wa(P)}g.push({id:M.id,name:M.name,...R})}}}else if(k==="grpSp")for(const j of He(v,"sp")){const M=K(j,"txBody");if(!M)continue;const F=gs(j),R=bs(j),P=ys(j),$=Fn(M),N=$.map(L=>L.text).join(`
116
+ `);N.trim()&&u.push({id:R,name:P,type:F,paragraphs:$,text:N})}}const S=u.find(v=>v.type==="title"),y=u.find(v=>v.type==="subtitle"),w=S?.text||"",x=y?.text||"",_=[w,x,...u.filter(v=>v.type!=="title"&&v.type!=="subtitle").map(v=>v.text),...p.map(v=>v.text),...g.map(v=>[v.name,...v.seriesNames,...v.categories].join(" ")),c].filter(Boolean).join(`
117
+
118
+ `);return{index:e,title:w,subtitle:x,textShapes:u,tables:p,images:m,charts:g,notes:c,text:_}}function Va(e){return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:"",text:""}}async function Xa(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await pn(t,e));return n}async function Ha(e,n){return(await pn(e,n)).text}async function Ya(e,n){const t=e.toLowerCase().trim();if(!t)return[];const s=[];for(let i=0;i<n.slideCount;i++){const r=await pn(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 Qa{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 tn(async()=>{const{renderTransitionFrame:c}=await Promise.resolve().then(()=>Pa);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=`
119
+ <span style="opacity:0.7">Slide</span>
120
+ <strong>${this._index+1}</strong>
121
+ <span style="opacity:0.5">of ${n}</span>
122
+ `}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 hi(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}async function Za(e,n,t={}){typeof t=="number"&&(t={width:t});const{width:s=null,dpi:i=150}=t,r=s??hi(n,i),o=await mi(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(m=>{c.onload=m});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 pi(e,n,t={},s){typeof t=="number"&&(t={width:t});const{width:i=null,dpi:r=300,filename:o}=t,l=i??hi(n,r),c=(await mi(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 Ja(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 pi(l,e,i),r?.(l+1,o),await new Promise(a=>setTimeout(a,100))}async function mi(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 el(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:m,cy:g}=e.slideSize,S=m/g,y=e.slideCount;n.style.cssText=`
123
+ background:${o};
124
+ padding:${r};
125
+ display:flex;
126
+ flex-direction:column;
127
+ align-items:center;
128
+ gap:${r};
129
+ overflow-y:auto;
130
+ position:relative;
131
+ `;const w=[],x=[],_=[];for(let F=0;F<y;F++){const R=document.createElement("div");R.style.cssText=`
132
+ width:100%;
133
+ max-width:${d};
134
+ position:relative;
135
+ background:${l};
136
+ border-radius:4px;
137
+ ${a?"box-shadow:0 4px 24px rgba(0,0,0,0.5);":""}
138
+ overflow:hidden;
139
+ aspect-ratio:${m}/${g};
140
+ flex-shrink:0;
141
+ `,R.setAttribute("data-slide",F);const P=document.createElement("div");P.style.cssText=`
142
+ position:absolute;bottom:8px;right:10px;
143
+ background:rgba(0,0,0,0.45);color:#fff;
144
+ font:11px/1.4 system-ui,sans-serif;
145
+ padding:2px 7px;border-radius:10px;
146
+ pointer-events:none;z-index:1;
147
+ `,P.textContent=F+1,R.appendChild(P);const $=document.createElement("canvas");$.style.cssText="display:block;width:100%;height:100%;",$.width=s,$.height=Math.round(s/S),R.appendChild($);const N=tl(F,m,g,l);R.appendChild(N),c&&(R.style.cursor="pointer",R.addEventListener("click",()=>{new(require("./slideshow.js")).SlideShow(e,document.body).start(F)})),n.appendChild(R),w.push(R),x.push($),_.push("pending")}const v=[];let k=!1;async function j(){if(!(k||v.length===0)){for(k=!0;v.length>0;){const F=v.shift();if(_[F]==="full")continue;const R=x[F],$=w[F].querySelector("[data-placeholder]");try{R.width=i,R.height=Math.round(i/S),await e.renderSlide(F,R,i),_[F]="full",R.style.transition="opacity 0.3s",R.style.opacity="1",$&&($.style.display="none"),p?.(F)}catch(N){console.warn(`LazyDeck: failed to render slide ${F}`,N)}}k=!1}}const M=new IntersectionObserver(F=>{for(const R of F){if(!R.isIntersecting)continue;const P=parseInt(R.target.getAttribute("data-slide"),10);if(!(isNaN(P)||_[P]==="full")){u?.(P);for(const $ of[P,P-1,P+1,P+2].filter(N=>N>=0&&N<y))_[$]!=="full"&&!v.includes($)&&v.push($);j()}}},{root:n,rootMargin:`${h}px`,threshold:0});return w.forEach(F=>M.observe(F)),{destroy(){M.disconnect(),n.innerHTML=""},scrollTo(F,R="smooth"){const P=w[F];P&&P.scrollIntoView({behavior:R,block:"start"})},async renderAll(F){for(let R=0;R<y;R++)_[R]!=="full"&&v.push(R);await j()},getCanvas(F){return x[F]||null},get slideCount(){return y}}}function tl(e,n,t,s){const i=document.createElement("div");i.setAttribute("data-placeholder","1"),i.style.cssText=`
148
+ position:absolute;inset:0;
149
+ display:flex;align-items:center;justify-content:center;
150
+ background:${s};
151
+ flex-direction:column;gap:12px;
152
+ `;const r=`
153
+ <div style="width:55%;height:18px;background:#e0e0e0;border-radius:3px;animation:pulse 1.4s ease-in-out infinite;"></div>
154
+ <div style="width:72%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.1s;"></div>
155
+ <div style="width:62%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.2s;"></div>
156
+ <div style="width:45%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.3s;"></div>
157
+ `;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 nl{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 qs(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=Se(i),o=b(r,"sldSz");o&&(this.slideSize={cx:C(o,"cx",9144e3),cy:C(o,"cy",5143500)});const l=await Ue(this._files,"ppt/presentation.xml");if(this.embeddedFonts=To(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=b(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 Ue(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=wo(Se(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=Se(h),this.masterRels=await Ue(this._files,d.fullPath),this.masterImages=await Wt(this._files,this.masterRels),this._trackBlobs(this.masterImages);const u=xo(this.masterDoc);this.themeColors=ko(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=Se(r),l=await Ue(this._files,i),a=await Wt(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=Se(v),d=await Ue(this._files,u.fullPath),h=await Wt(this._files,d),this._trackBlobs(h))}const p={...this.masterImages,...h,...a},m=ei([c,this.masterDoc]),g=No([o,c,this.masterDoc]);await Fo(g,this.themeData);const S=s/this.slideSize.cx,y=Math.round(this.slideSize.cy*S);t.width=s,t.height=y;const w=t.getContext("2d");w.clearRect(0,0,s,y),await Js(w,o,this.masterDoc,c,l,this.masterRels,p,this.themeColors,S,this.slideSize.cx,this.slideSize.cy),await this._renderNonPlaceholders(w,this.masterDoc,this.masterRels,this.masterImages,S),await this._renderNonPlaceholders(w,c,d,h,S);const x=b(o,"cSld"),_=x?b(x,"spTree"):null;_&&await ni(w,_,l,p,this.themeColors,this.themeData,S,m,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 Sn(n,t,s)}registerFonts(n){return Po(n)}listRegisteredFonts(){return Mo()}_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=b(t,"cSld"),l=o?b(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=b(a,"nvSpPr"),h=d?b(d,"nvPr"):null;if(!(h&&b(h,"ph")))try{c==="sp"?await an(n,a,s,i,this.themeColors,this.themeData,r):c==="pic"?await ln(n,a,s,i,this.themeColors,r):c==="grpSp"?await cn(n,a,s,i,this.themeColors,this.themeData,r):c==="graphicFrame"?await un(n,a,this.themeColors,this.themeData,r):c==="cxnSp"&&await dn(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=Se(new TextDecoder().decode(s));return On(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=Se(new TextDecoder().decode(s));return Un(i)}createPlayer(n){return new li(this,n)}async toSvg(n){return fi(n,this)}async allToSvg(){return Ia(this)}async loadEmbeddedFonts(){const n=this._presRels||{};return Da(this._files,n)}listEmbeddedFonts(){return Ba(this._files)}async extractSlide(n){return pn(n,this)}async extractAll(){return Xa(this)}async extractText(n){return Ha(n,this)}async searchSlides(n){return Ya(n,this)}createShow(n,t={}){return new Qa(this,n,t)}async copySlide(n,t={}){return Za(n,this,t)}async downloadSlide(n,t={}){return pi(n,this,t)}async downloadAllSlides(n={}){return Ja(this,n)}createDeck(n,t={}){return el(this,n,t)}edit(){return Jt.fromRenderer(this)}async toPdf(n={}){return Bn(this,n)}async downloadPdf(n="presentation.pdf",t={}){return va(this,n,t)}async slideToPdf(n,t={}){return wa(n,this,t)}async getSlideNotes(n){if(n<0||n>=this.slidePaths.length)return"";const t=await Ue(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=Se(i),o=[];for(const l of pe(r,"sp")){const a=b(b(l,"nvSpPr"),"nvPr"),c=a?b(a,"ph"):null;if(!(c&&G(c,"type")==="sldNum"))for(const d of pe(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 sl=({asset:e,bytes:n,onOpenExternal:t,dense:s=!1,expanded:i=!1})=>{const r=E.useRef(null),o=E.useRef(null),[l,a]=E.useState({phase:"loading",progress:0}),[c,d]=E.useState(0),[h,u]=E.useState(1),[p,m]=E.useState(0),[g,S]=E.useState(!1),[y,w]=E.useState([]),[x,_]=E.useState(!s),v=E.useRef(null),[k,j]=E.useState(!1);E.useEffect(()=>{_(!s)},[s]),E.useLayoutEffect(()=>{const P=v.current;if(!P)return;const $=()=>j(P.getBoundingClientRect().height<360);$();const N=new ResizeObserver($);return N.observe(P),()=>N.disconnect()},[]),E.useEffect(()=>{let P=!1;const $=new nl;return r.current=$,a({phase:"loading",progress:0}),d(0),u(1),$.load(n,N=>{P||a({phase:"loading",progress:N})}).then(async()=>{if(P)return;const N=$.slideCount,H=(await $.renderAllSlides(160)).map(D=>D.toDataURL("image/png"));P||a({phase:"ready",slideCount:N,thumbnails:H})}).catch(N=>{P||a({phase:"error",detail:N instanceof Error&&N.message?N.message:T("ui.library.preview.pptx_failed_detail")})}),()=>{P=!0,$.destroy(),r.current=null}},[n,p]);const M=E.useCallback(async()=>{const P=r.current,$=o.current;if(!(!P||!$||l.phase!=="ready"))try{await P.renderSlide(c,$,Math.round(960*h))}catch(N){a({phase:"error",detail:N instanceof Error&&N.message?N.message:T("ui.library.preview.pptx_failed_detail")})}},[c,l.phase,h]);E.useEffect(()=>{M()},[M]),E.useEffect(()=>{const P=r.current;if(!P||l.phase!=="ready")return;let $=!1;return P.extractSlide(c).then(N=>{$||w(N.textShapes.map(L=>L.text.trim()).filter(Boolean))}).catch(()=>{$||w([])}),()=>{$=!0}},[c,l.phase]);const F=l.phase==="ready"?l.slideCount:0,R=P=>{F!==0&&d(Math.min(Math.max(P,0),F-1))};return l.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:T("ui.library.preview.pptx_failed")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:l.detail}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Z,{variant:"secondary",size:"sm",onClick:()=>m(P=>P+1),children:T("ui.library.preview.retry")}),f.jsxs(Z,{variant:"secondary",size:"sm",disabled:g,onClick:()=>{S(!0),dt(e).catch(P=>Te(P instanceof Error&&P.message?P.message:T("ui.library.menu.save_failed"))).finally(()=>S(!1))},children:[f.jsx(ct,{"aria-hidden":"true"}),T("ui.library.menu.download")]}),t&&f.jsxs(Z,{variant:"ghost",size:"sm",onClick:t,children:[f.jsx($s,{"aria-hidden":"true"}),T("ui.library.preview.open_externally")]})]})]}):f.jsxs("div",{ref:v,className:"flex min-h-0 flex-1 flex-col gap-2 p-3","data-pptx-viewer":"",onKeyDown:P=>{P.key==="ArrowRight"||P.key==="PageDown"?(P.preventDefault(),R(c+1)):P.key==="ArrowLeft"||P.key==="PageUp"?(P.preventDefault(),R(c-1)):P.key==="Home"?(P.preventDefault(),R(0)):P.key==="End"&&(P.preventDefault(),R(F-1))},children:[f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[f.jsx("div",{"data-pptx-slide":"",className:ge("flex min-h-[120px] min-w-0 flex-1 flex-col items-center rounded-md bg-canvas p-2",i?"justify-start overflow-y-auto":"justify-center"),children:l.phase==="loading"?f.jsxs("div",{className:"flex w-60 flex-col items-center gap-2",children:[f.jsx(Rn,{size:18,"aria-hidden":"true",className:"motion-safe:animate-spin text-ink-muted"}),f.jsx(Ai,{value:Math.round(l.progress*100)}),f.jsx("span",{className:"text-meta text-ink-muted",children:T("ui.library.preview.pptx_preparing")})]}):f.jsx("canvas",{ref:o,className:ge("rounded-xs bg-surface",i?"h-auto max-w-full w-full":"max-h-full max-w-full"),"aria-label":T("ui.library.preview.slide_of",{index:String(c+1),count:String(F)})})}),l.phase==="ready"&&!k&&!s&&f.jsx("div",{className:"flex h-[72px] shrink-0 flex-row gap-1 overflow-x-auto overflow-y-hidden",children:l.thumbnails.map((P,$)=>f.jsx("button",{type:"button",onClick:()=>d($),"aria-pressed":$===c,"aria-label":T("ui.library.preview.go_to_slide",{index:String($+1)}),className:ge("h-16 w-24 shrink-0 rounded-xs border p-0.5",$===c?"border-accent":"border-hairline hover:border-control"),children:f.jsx("img",{src:P,alt:"",loading:"lazy",className:"h-full w-full rounded-xs object-contain"})},$))})]}),l.phase==="ready"&&f.jsxs("div",{className:"shrink-0 rounded-md bg-canvas px-2 py-1","data-pptx-transcript":"",children:[s?f.jsx(Z,{variant:"ghost",size:"sm","aria-expanded":x,onClick:()=>_(P=>!P),children:T("ui.library.preview.pptx_text")}):null,x&&f.jsx("div",{className:"max-h-24 overflow-y-auto text-meta text-ink-muted",children:y.length?y.map((P,$)=>f.jsx("p",{"data-pptx-transcript-line":"",className:"truncate",children:P},`${$}:${P}`)):f.jsx("p",{children:T("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(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.preview.previous_slide"),disabled:c===0||l.phase!=="ready",onClick:()=>R(c-1),children:f.jsx(In,{"aria-hidden":"true"})}),f.jsx("span",{className:"text-meta tabular-nums text-ink-muted",children:T("ui.library.preview.slide_of",{index:String(F?c+1:0),count:String(F)})}),f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.preview.next_slide"),disabled:c>=F-1||l.phase!=="ready",onClick:()=>R(c+1),children:f.jsx($i,{"aria-hidden":"true"})})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.preview.zoom_out"),onClick:()=>u(P=>Math.max(.5,P-.25)),children:f.jsx(lr,{"aria-hidden":"true"})}),f.jsxs("span",{className:"w-10 text-center text-meta tabular-nums text-ink-muted",children:[Math.round(h*100),"%"]}),f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.preview.zoom_in"),onClick:()=>u(P=>Math.min(2,P+.25)),children:f.jsx(cr,{"aria-hidden":"true"})}),f.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>u(1),disabled:h===1,children:T("ui.library.preview.fit")})]})]})]})},mt=({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(Rn,{size:16,"aria-hidden":"true",className:"motion-safe:animate-spin"}),e??T("ui.library.preview.loading")]}),gt=({detail:e,asset:n})=>{const[t,s]=E.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(Ye,{kind:n.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:T("ui.library.preview.could_not_load")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:e}),f.jsxs(Z,{variant:"secondary",size:"sm",disabled:t,onClick:()=>{s(!0),dt(n).catch(i=>Te(i instanceof Error&&i.message?i.message:T("ui.library.menu.save_failed"))).finally(()=>s(!1))},children:[f.jsx(ct,{"aria-hidden":"true"}),T("ui.library.menu.download")]})]})},vs=({asset:e})=>f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Ye,{kind:e.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"max-w-90 text-body text-ink",children:T("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(Z,{variant:"secondary",size:"sm",onClick:()=>{e.ref.path&&window.api.openFile(e.ref.path)},children:T("ui.library.preview.open_externally")}):null,f.jsxs(Z,{variant:"secondary",size:"sm",onClick:()=>void dt(e),children:[f.jsx(ct,{"aria-hidden":"true"}),T("ui.library.menu.download")]})]})]}),il=72;function At(e,n){const t=Dn(e)?e.ref.path:null,[s,i]=E.useState(!1),r=ht(e.id,"content",!t||s),[o,l]=E.useState({bytes:null,mimeType:"",error:null,loading:!!t}),a=e.ref.content_type;return E.useEffect(()=>{if(!t)return;if(!window.api?.readFileBytes){i(!0),l({bytes:null,mimeType:"",error:T("ui.library.preview.could_not_load"),loading:!1});return}let c=!1;return i(!1),l(d=>({...d,loading:!0})),window.api.readFileBytes(t).then(d=>{c||(d.success||i(!0),l(d.success?{bytes:d.data,mimeType:a||"",error:null,loading:!1}:{bytes:null,mimeType:"",error:d.error,loading:!1}))}),()=>{c=!0}},[t,n,a]),t&&!s?o:r}const rl=({asset:e,mediaSiblings:n,revision:t,expanded:s})=>{const{bytes:i,mimeType:r,error:o,loading:l}=At(e,t),a=pt(i,r||e.ref.content_type),c=Ds(e.id,e.kind==="audio"),d=E.useRef(null),h=E.useRef(null),u=E.useRef(null),p=E.useRef(null),[m,g]=E.useState(null),[S,y]=E.useState(null),w=E.useMemo(()=>{const k=(n??[]).filter(j=>j.kind==="image"||j.kind==="video");return k.some(j=>j.id===e.id)?[...k]:[e]},[n,e]),x=Math.max(0,w.findIndex(k=>k.id===e.id)),_=De(e);if(E.useEffect(()=>{if(e.kind!=="video"||!a)return;const k=u.current,j=p.current;if(!k||!j)return;const M=()=>{const R=k.getBoundingClientRect(),P=j.getBoundingClientRect(),$=Math.max(0,P.height-il);if($<=0||P.width<=0){g(L=>L===null?L:null);return}const N={top:P.top-R.top,left:P.left-R.left,width:P.width,height:$};g(L=>L&&L.top===N.top&&L.left===N.left&&L.width===N.width&&L.height===N.height?L:N)};M(),j.addEventListener("loadedmetadata",M),j.addEventListener("loadeddata",M),j.addEventListener("canplay",M),window.addEventListener("resize",M);const F=typeof ResizeObserver>"u"?null:new ResizeObserver(M);return F?.observe(j),F?.observe(k),()=>{F?.disconnect(),j.removeEventListener("loadedmetadata",M),j.removeEventListener("loadeddata",M),j.removeEventListener("canplay",M),window.removeEventListener("resize",M)}},[e.kind,a]),l)return f.jsx(mt,{});if(o||!a)return f.jsx(gt,{detail:o||"The bytes were empty.",asset:e});const v=f.jsx(go,{open:S!==null,siblings:w,index:S??x,onIndexChange:y,onClose:()=>y(null),resolved:{assetId:e.id,url:a},restoreFocusTo:e.kind==="video"?h:d});switch(e.kind){case"image":return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",ref:d,"aria-label":_,title:_,onClick:()=>y(x),"data-library-media-trigger":"image",className:"flex h-full min-h-0 w-full min-w-0 flex-1 cursor-zoom-in items-center justify-center overflow-hidden bg-canvas p-3",children:f.jsx("img",{src:a,alt:e.name||e.derived_name,className:"block h-auto max-h-full w-auto max-w-full object-contain"})}),v]});case"audio":return f.jsxs("div",{className:"flex w-full max-w-100 flex-1 flex-col items-center justify-center gap-3 p-6",children:[f.jsx(Ye,{kind:"audio",size:32,className:"text-ink-dim"}),f.jsx(As,{variant:"full",ownerId:`sound:library:${e.id}`,src:a,label:De(e),peaks:c,durationHint:e.duration_s,className:s?void 0:"max-w-100"})]});default:return f.jsxs(f.Fragment,{children:[f.jsxs("div",{ref:u,className:"relative flex h-full min-h-0 w-full min-w-0 flex-1 items-center justify-center overflow-hidden bg-canvas p-3",children:[f.jsx("video",{ref:p,src:a,controls:!0,className:"max-h-full max-w-full rounded-sm",children:f.jsx("track",{kind:"captions"})}),m?f.jsx("button",{type:"button",tabIndex:-1,"aria-hidden":"true",onClick:()=>y(x),"data-library-media-trigger":"video-surface",className:"absolute z-[1] cursor-zoom-in bg-transparent",style:{top:m.top,left:m.left,width:m.width,height:m.height}}):null,f.jsx(Z,{variant:"ghost",size:"icon-sm",ref:h,"aria-label":_,title:_,onClick:()=>y(x),"data-library-media-trigger":"video",className:"absolute top-2 right-2 z-[2]",children:f.jsx(Es,{"aria-hidden":"true"})})]}),v]})}},ol=({asset:e,revision:n})=>{const{bytes:t,mimeType:s,error:i,loading:r}=At(e,n),o=pt(t,s||e.ref.content_type);return r?f.jsx(mt,{}):i||!o?f.jsx(gt,{detail:i||"The bytes were empty.",asset:e}):f.jsx("iframe",{title:e.name||e.derived_name,src:o,className:"size-full flex-1 border-0 bg-surface",sandbox:e.kind==="html"?"allow-scripts":void 0})},al=({asset:e,text:n,expanded:t,revision:s,mtimeMs:i})=>{const r=e.ref.type==="path"&&!!e.ref.path&&e.exists,o=e.ref.path,[l,a]=E.useState({state:"pending"});E.useEffect(()=>{if(!r||!o||i!==null)return;let h=!1;return Di(o).then(u=>{h||a({state:"done",mtimeMs:u?.mtimeMs??null})}),()=>{h=!0}},[r,o,s,i]);const c=i??(l.state==="done"?l.mtimeMs:null),d=E.useMemo(()=>!r||!o||i===null&&l.state!=="done"?null:fo(e,n,c),[e,r,o,l,n,i,c]);return r&&d===null?f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center",children:f.jsx(mt,{label:T("ui.library.preview.checking_file")})}):d?f.jsx("div",{"data-lo-pane-edge-cues":!0,className:"min-h-0 flex-1 overflow-y-auto bg-canvas",children:f.jsxs("div",{className:ge("mx-auto flex w-full flex-col gap-4 px-6 py-8",t?"max-w-none":"max-w-[760px]"),children:[f.jsx("p",{className:"text-meta text-ink-dim",children:T("ui.library.preview.breadcrumb",{name:d.title})}),f.jsx(Bi,{document:d,measure:t?"fill":"reading"})]})}):f.jsx("div",{"data-lo-pane-edge-cues":!0,className:"min-h-0 flex-1 overflow-y-auto p-5",children:f.jsxs("div",{className:ge("mx-auto",t?"max-w-[980px]":"max-w-[720px]"),children:[f.jsx("p",{className:"mb-4 text-meta text-ink-muted",children:T("ui.library.preview.read_only_markdown")}),f.jsx("div",{className:"prose-lo max-w-none text-body text-ink",children:f.jsx(dr,{remarkPlugins:[ur],children:n})})]})})},ll=({asset:e,expanded:n,revision:t,mtimeMs:s})=>{const{bytes:i,error:r,loading:o}=At(e,t);if(o)return f.jsx(mt,{});if(r||!i)return f.jsx(gt,{detail:r||"The bytes were empty.",asset:e});const l=new TextDecoder("utf-8",{fatal:!1}).decode(i);return e.kind==="markdown"?f.jsx(al,{asset:e,text:l,expanded:n,revision:t,mtimeMs:s}):f.jsx("pre",{"data-lo-pane-edge-cues":!0,className:ge("min-h-0 w-full flex-1 overflow-auto p-4 font-mono text-mono-sm text-ink",e.kind==="code"?"whitespace-pre":"whitespace-pre-wrap break-words"),children:l})},cl=({asset:e,revision:n})=>{const{bytes:t,error:s,loading:i}=At(e,n);return i?f.jsx(mt,{}):s||!t?f.jsx(gt,{detail:s||"The bytes were empty.",asset:e}):f.jsx(dl,{asset:e,bytes:t})},ws=200,xs=40,dl=({asset:e,bytes:n})=>{const t=(()=>{try{const r=Oi(n,{type:"array"}),o=r.SheetNames[0];if(!o)return null;const l=Ui.sheet_to_json(r.Sheets[o],{header:1,raw:!1,defval:""});return{name:o,rows:l}}catch{return null}})();if(!t)return f.jsx(gt,{detail:T("ui.library.preview.sheet_unreadable"),asset:e});const s=t.rows.slice(0,ws),i=t.rows.length>ws;return f.jsxs("div",{"data-lo-pane-edge-cues":!0,className:"min-h-0 flex-1 overflow-auto p-2",children:[f.jsxs("table",{className:"w-max min-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,xs).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,xs).map((l,a)=>f.jsx("td",{className:"whitespace-nowrap 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:T("ui.library.preview.sheet_truncated")}),f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:T("ui.library.preview.sheet_name",{name:t.name})})]})},ul=({asset:e,dense:n=!1,expanded:t=!1,revision:s=0,mtimeMs:i=null,mediaSiblings:r})=>e.kind==="pptx"?f.jsx(fl,{asset:e,dense:n,expanded:t,revision:s}):e.kind==="image"||e.kind==="audio"||e.kind==="video"?f.jsx(rl,{asset:e,mediaSiblings:r,revision:s,expanded:t}):e.kind==="pdf"||e.kind==="html"?f.jsx(ol,{asset:e,revision:s}):e.kind==="markdown"||e.kind==="text"||e.kind==="code"?f.jsx(ll,{asset:e,expanded:t,revision:s,mtimeMs:i}):e.kind==="spreadsheet"?f.jsx(cl,{asset:e,revision:s}):e.kind==="docx"?f.jsx(vs,{asset:e}):f.jsx(vs,{asset:e}),fl=({asset:e,dense:n=!1,expanded:t,revision:s})=>{const{bytes:i,error:r,loading:o}=At(e,s);return o?f.jsx(mt,{label:T("ui.library.preview.pptx_opening")}):r||!i?f.jsx(gt,{detail:r||"The bytes were empty.",asset:e}):f.jsx(sl,{asset:e,bytes:i,dense:n,expanded:t})};function hl(e){const n=Dr(!0),t=Or().create,s=Br(),[i,r]=E.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){Te(a instanceof Error&&a.message?a.message:T("ui.library.preview.tags_not_saved"))}finally{r(!1)}},saving:i}}const ks=({asset:e,nowMs:n,onClose:t,onOpenConversation:s,onFilterSession:i,onAsk:r,onToggleFavorite:o,composerFocusSignal:l,focusRequest:a,standalone:c=!1,onExpand:d,mediaSiblings:h})=>{it();const u=Is(),{commit:p,saving:m}=hl(e),g=E.useRef(null),S=E.useRef(null),y=E.useRef(null),[w,x]=E.useState(0),[_,v]=E.useState(0),[k,j]=E.useState(!1),[M,F]=E.useState(e.id);M!==e.id&&(F(e.id),x(0),v(0),j(!1));const[R,P]=E.useState(!1),[$,N]=E.useState(!1),[L,H]=E.useState({}),[D,U]=E.useState({}),[q,Q]=E.useState(0),[J,I]=E.useState({}),V=ro(e,q),oe=Ls(),ee=e.chat?.session_id??L[e.id]??null,ae=D[e.id]??R;E.useLayoutEffect(()=>{const W=g.current;if(!W)return;const le=()=>P(W.getBoundingClientRect().height<700);le();const me=new ResizeObserver(le);return me.observe(W),()=>me.disconnect()},[]);const Y=E.useMemo(()=>e.tags.map(W=>W.name),[e.tags]),X=!R||$,ke=()=>{j(!0),N(!0)};E.useEffect(()=>{if(!k||!X)return;const W=y.current;W&&(j(!1),W.scrollIntoView({block:"center"}),v(le=>le+1))},[k,X]),E.useEffect(()=>{a&&(a.field==="tags"?ke():(S.current?.scrollIntoView({block:"center"}),x(W=>W+1)))},[a?.signal]);const ce=async W=>{try{await u.mutateAsync({id:e.id,fields:W})}catch(le){throw Te(le instanceof Error&&le.message?le.message:T("ui.library.preview.not_saved")),le}},de=async()=>{try{await u.mutateAsync({id:e.id,fields:{locked:!e.locked}})}catch(W){Te(W instanceof Error&&W.message?W.message:T("ui.library.preview.not_saved"))}},fe=()=>{if(e.ref.type==="path"&&e.ref.path){window.api.openFile(e.ref.path);return}dt(e).catch(()=>Te(T("ui.library.menu.save_failed")))};return f.jsxs("div",{ref:g,className:"flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-surface","data-library-preview":e.id,"data-library-compact":R?"":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(Z,{variant:"ghost",size:"sm",className:"self-start",onClick:t,children:[f.jsx(In,{"aria-hidden":"true"}),T("ui.library.page.back")]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ye,{kind:e.kind,size:18,className:"text-ink-dim"}),f.jsx("div",{ref:S,className:"min-w-0 flex-1",children:f.jsx(es,{value:De(e),onSave:W=>ce({name:W}),label:T("ui.library.preview.name"),textClassName:"text-heading font-medium",field:"name",startSignal:w,className:"min-w-0"},`${e.id}:name`)}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[f.jsx(Dt,{content:e.favorite?T("ui.library.menu.unfavorite"):T("ui.library.menu.favorite"),children:f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-pressed":e.favorite,"aria-label":e.favorite?T("ui.library.menu.unfavorite"):T("ui.library.menu.favorite"),onClick:o,children:f.jsx(nn,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0})})}),f.jsx(Dt,{content:e.locked?T("ui.library.preview.unlock"):T("ui.library.preview.lock"),children:f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-pressed":e.locked,"aria-label":e.locked?T("ui.library.preview.unlock"):T("ui.library.preview.lock"),onClick:()=>void de(),children:e.locked?f.jsx(Gi,{"aria-hidden":"true",className:"text-accent"}):f.jsx(qi,{"aria-hidden":"true"})})}),d&&f.jsx(Dt,{content:T("ui.library.preview.expand"),children:f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.preview.expand"),onClick:d,children:f.jsx(Es,{"aria-hidden":"true"})})}),f.jsx(Ln,{asset:e,onAsk:r,onEditMetadata:()=>x(W=>W+1),onEditTags:ke,onToggleFavorite:o,onOpenConversation:s,onFilterSession:i}),f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.preview.close"),onClick:t,children:f.jsx(We,{"aria-hidden":"true"})})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta text-ink-muted",children:[f.jsx(et,{variant:"neutral",children:e.kind}),f.jsx(et,{variant:"neutral",children:T(sn(e.origin_group))}),Dn(e)&&V.mtimeMs!==null&&Math.floor(V.mtimeMs/1e3)!==Math.floor(e.modified_at)?f.jsx("span",{"data-library-file-live":"",children:Xt(V.sizeBytes??e.size_bytes)}):f.jsx("span",{children:Xt(e.size_bytes)}),e.width&&e.height?f.jsxs("span",{children:[e.width,"×",e.height]}):null,e.organized?f.jsx("span",{children:T("ui.library.preview.organized_by",{by:e.organized.by??"librarian",at:$r(e.organized.at,n)})}):f.jsx("span",{children:T("ui.library.preview.unorganized")}),e.exists?null:f.jsx(et,{variant:"warning",children:T("ui.library.preview.missing_file")})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs(Z,{variant:"secondary",size:"sm",onClick:fe,children:[f.jsx($s,{"aria-hidden":"true"}),T("ui.library.preview.open")]}),e.ref.type==="path"&&e.ref.path?f.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(xn,{"aria-hidden":"true"}),T("ui.library.preview.reveal")]}):null,f.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>void dt(e).then(()=>kn(T("ui.library.menu.saved_a_copy"))).catch(()=>Te(T("ui.library.menu.save_failed"))),children:[f.jsx(ct,{"aria-hidden":"true"}),T("ui.library.preview.download")]}),e.occurrences[0]?f.jsx(Z,{variant:"link",size:"sm",className:"h-auto max-w-full min-w-0 justify-start whitespace-normal text-left",title:`${T("ui.library.preview.from_conversation",{title:e.occurrences[0].session_title||e.occurrences[0].session_id})}`,onClick:()=>s(e.occurrences[0].session_id),children:f.jsx("span",{className:"line-clamp-2 break-words",children:T("ui.library.preview.from_conversation",{title:e.occurrences[0].session_title||e.occurrences[0].session_id})})}):null]}),R&&f.jsxs(Z,{variant:"ghost",size:"sm",className:"self-start","aria-expanded":$,onClick:()=>N(W=>!W),children:[f.jsx(Cs,{"aria-hidden":"true",className:ge("transition-transform duration-fast",$&&"rotate-180")}),T("ui.library.preview.details")]}),(!R||$)&&f.jsxs(f.Fragment,{children:[f.jsx(es,{value:e.description,onSave:W=>ce({description:W}),label:T("ui.library.preview.description"),placeholder:T("ui.library.preview.add_description"),multiline:!0,rows:3,allowEmpty:!0,textClassName:"text-body-sm",field:"description"},`${e.id}:description`),f.jsx("div",{ref:y,className:"min-w-0",children:f.jsx(so,{value:Y,onChange:W=>void p(W),label:T("ui.library.preview.tags"),addLabel:T("ui.library.preview.add_tag"),saving:m,startSignal:_},`${e.id}:tags`)})]})]}),f.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-sunken",children:f.jsx(ul,{asset:e,dense:R,expanded:c,revision:V.revision,mtimeMs:V.mtimeMs,mediaSiblings:h})}),ee&&f.jsx(uo,{sessionId:ee,title:e.chat?.title??ee,collapsed:ae,onToggleCollapsed:()=>U(W=>({...W,[e.id]:!ae})),onOpenChat:()=>s(ee),onUnlink:()=>{H(W=>{const le={...W};return delete le[e.id],le}),oe.mutate({id:e.id})},onTurnSettled:()=>Q(W=>W+1),onStreamingChange:W=>I(le=>({...le,[ee]:W}))}),f.jsx("div",{className:"shrink-0",children:f.jsx(co,{asset:e,focusSignal:l,showLinkedRow:!ee,onOpenChat:s,refreshSignal:q,streaming:ee?J[ee]:!1,onSessionChange:(W,le)=>H(me=>({...me,[W]:le}))})})]})},gi="library-view",bi="library-filters",pl=1152,ml=1200,gl=900;function bl(){try{return localStorage.getItem(gi)==="list"?"list":"grid"}catch{return"grid"}}function yl(){try{const e=sessionStorage.getItem(bi);if(!e)return Ut;const n=JSON.parse(e);return{...Ut,...n,scope:n.scope==="all"?"all":"final",q:""}}catch{return Ut}}function vl(e){try{sessionStorage.setItem(bi,JSON.stringify({...e,q:""}))}catch{}}function wl(){const[e,n]=E.useState(null),[t,s]=E.useState(0);return E.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 xl(){const[e,n]=E.useState(()=>window.innerWidth);return E.useEffect(()=>{const t=()=>n(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e}const kl=({enabled:e,nowMs:n})=>{const t=zs(e),s=Gr(),i=Ss(),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 min-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:T("ui.library.librarian.title")}),f.jsx("span",{children:r.paused?T("ui.library.librarian.paused"):r.enabled?T("ui.library.librarian.enabled"):T("ui.library.librarian.disabled")}),f.jsx("span",{children:o?T("ui.library.librarian.last_organized",{at:_l(o,n)}):T("ui.library.librarian.never_run")}),l!==null&&l>0&&f.jsx("span",{children:T("ui.library.librarian.unorganized",{count:l})}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[f.jsxs(Z,{variant:"ghost",size:"sm",disabled:!r.enabled||s.isPending,onClick:()=>s.mutate("run",{onError:a=>Te(a instanceof Error?a.message:T("ui.library.librarian.control_failed"))}),children:[f.jsx(wn,{"aria-hidden":"true"}),T("ui.library.librarian.organize_now")]}),f.jsx(Z,{variant:"ghost",size:"sm",disabled:!r.session_id||s.isPending,onClick:()=>s.mutate("open",{onSuccess:a=>{a?.session_id&&_s(i,a.session_id)},onError:a=>Te(a instanceof Error?a.message:T("ui.library.librarian.control_failed"))}),children:T("ui.library.librarian.open")})]})]})};function _l(e,n){const t=Math.max(0,n-e*1e3),s=Math.floor(t/36e5);return s<24?T("ui.library.time.hours_h_ago",{hours:s}):T("ui.library.time.days_d_ago",{days:Math.floor(s/24)})}const Sl=({onBack:e})=>f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Ot,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:T("ui.library.preview.unavailable")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:T("ui.library.preview.unavailable_detail")}),f.jsxs(Z,{variant:"secondary",size:"sm",onClick:e,children:[f.jsx(In,{"aria-hidden":"true"}),T("ui.library.page.back")]})]}),Pl=({nowMs:e})=>{it();const n=Ss(),t=Ti(),s=ji(),i=An(),r=yt(i.data,"library",1),o=zs(r),l=e??Date.now(),{ref:a,width:c}=wl(),d=xl(),h=new URLSearchParams(t.search).get("full")==="1",u=d>=ml&&c>=gl,[p,m]=E.useState(yl),[g,S]=E.useState(""),y=Wi(g,200),[w,x]=E.useState(bl),[_,v]=E.useState(!1),[k,j]=E.useState(0),[M,F]=E.useState(null),R=E.useRef(null),P=s.assetId??null,$=c>=pl&&!!P&&!h;E.useEffect(()=>{m(z=>z.q===y?z:{...z,q:y})},[y]),E.useEffect(()=>vl(p),[p]),E.useEffect(()=>{try{localStorage.setItem(gi,w)}catch{}},[w]);const N=Ir(p,r),L=Is(),H=Lr(P,r),D=E.useMemo(()=>{const z=N.data?.pages??[],re=z.length>1&&z.at(-1)?.cursor_reset?[z.at(-1)]:z,be=new Set,ve=[];for(const je of re)for(const Pe of je?.rows??[])be.has(Pe.id)||(be.add(Pe.id),ve.push(Pe));return ve},[N.data]),U=N.data?.pages.at(-1),q=U?.total??0,Q=E.useMemo(()=>D.filter(z=>z.kind==="image"||z.kind==="video"),[D]),J=D.find(z=>z.id===P)??null,I=H.data??J,V=()=>void N.fetchNextPage(),oe=!!(P&&!I&&!H.isLoading&&H.isError),ee=!!P&&!$,ae=E.useCallback(z=>{n(`/library/assets/${z}${t.search}`,{state:t.state})},[n,t.search,t.state]),Y=E.useCallback(()=>{const z=new URLSearchParams(t.search);z.delete("full");const O=z.toString();n(`/library${O?`?${O}`:""}`)},[n,t.search]),X=E.useCallback(()=>{if(!P)return;const z=new URLSearchParams(t.search);z.set("full","1"),n(`/library/assets/${P}?${z.toString()}`)},[n,P,t.search]),ke=E.useCallback(z=>{ae(z.id),j(O=>O+1)},[ae]),ce=E.useRef(new Set),de=E.useCallback(z=>{ce.current.has(z.id)||(ce.current.add(z.id),L.mutate({id:z.id,fields:{favorite:!z.favorite}},{onSettled:()=>{ce.current.delete(z.id)},onError:O=>{Te(O instanceof Error&&O.message?O.message:T("ui.library.preview.not_saved"))}}))},[L]),fe=E.useCallback(z=>void _s(n,z),[n]),W=E.useCallback(z=>{m(O=>({...O,session:z})),n("/library")},[n]),le={onSelect:ae,onAsk:ke,onEditMetadata:z=>{ae(z.id),F({field:"metadata",signal:Date.now()})},onEditTags:z=>{ae(z.id),F({field:"tags",signal:Date.now()})},onToggleFavorite:de,onOpenConversation:fe,onFilterSession:W};if(E.useEffect(()=>{const z=O=>{const re=O.target;if(re?.closest('[role="dialog"]'))return;const be=re?.tagName==="INPUT"||re?.tagName==="TEXTAREA"||re?.isContentEditable;if(O.key==="f"&&(O.metaKey||O.ctrlKey)||O.key==="/"&&!be){O.preventDefault(),R.current?.focus();return}if(!(be||O.metaKey||O.ctrlKey||O.altKey)){if(O.key==="Escape"){(P||I)&&Y();return}if(O.key.toLowerCase()==="g"){O.preventDefault(),x(ve=>ve==="grid"?"list":"grid");return}if(O.key.toLowerCase()==="j"||O.key.toLowerCase()==="k"){if(ee||D.length===0)return;O.preventDefault();const ve=P?D.findIndex(rt=>rt.id===P):-1,je=O.key.toLowerCase()==="j"?1:-1,Pe=Math.min(Math.max(ve===-1?je===1?0:D.length-1:ve+je,0),D.length-1);ae(D[Pe].id)}}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[Y,ae,D,I,P,ee]),!r)return f.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[f.jsx(Ci,{title:T("ui.library.page.title"),icon:Ot}),i.isLoading?f.jsx("div",{className:"flex justify-center py-16",children:f.jsx(xt,{label:T("ui.library.page.checking")})}):f.jsx(bn,{variant:"warning",children:T("ui.library.page.unavailable")})]});const me=o.data?.library?.total??null,he=f.jsx(no,{filters:p,onChange:z=>{m({...z,q:z.q}),S(z.q)},counts:U?.counts,tags:U?.tags??[],total:q,scopeTotal:me}),B=D.length===0&&!N.isLoading,te=Nr(p)||!!g.trim(),ne=(()=>{const z=[];if(g.trim()&&z.push({key:"search",label:`${T("ui.library.page.search")}: ${g.trim()}`,clear:()=>S("")}),p.category){const O=_n.find(re=>re.key===p.category);z.push({key:"category",label:O?T(O.labelKey):p.category,clear:()=>m(re=>({...re,category:void 0}))})}if(p.originGroup&&z.push({key:"origin",label:T(sn(p.originGroup)),clear:()=>m(O=>({...O,originGroup:void 0}))}),p.status){const O=p.status==="highlighted"?"ui.library.status.highlighted":p.status==="unorganized"?"ui.library.status.unorganized":"ui.library.status.favorites";z.push({key:"status",label:T(O),clear:()=>m(re=>({...re,status:void 0}))})}return p.highlighted&&p.status!=="highlighted"&&z.push({key:"highlighted",label:T("ui.library.status.highlighted"),clear:()=>m(O=>({...O,highlighted:!1}))}),p.tag&&z.push({key:"tag",label:`${T("ui.library.filter.tags")}: ${p.tag}`,clear:()=>m(O=>({...O,tag:void 0}))}),p.session&&z.push({key:"session",label:T("ui.library.filter.one_conversation"),clear:()=>m(O=>({...O,session:void 0}))}),(p.scope!=="final"||z.length>0)&&z.push({key:"scope",label:`${T("ui.library.filter.scope")}: ${p.scope==="all"?T("ui.library.filter.scope_all"):T("ui.library.filter.scope_final")}`,clear:()=>m(O=>({...O,scope:"final"}))}),z})(),se=()=>{m(z=>({...Ut,scope:z.scope,sort:z.sort,order:z.order})),S("")},ie=N.error instanceof Error&&N.error.message?N.error.message:T("ui.library.page.load_failed");return f.jsxs("div",{ref:a,"data-library-page":"","data-glass-region":"canvas","data-glass-split":"",className:"panel-flush flex min-h-0 flex-1 overflow-hidden bg-canvas",children:[u&&!ee&&f.jsx("aside",{"data-library-rail":"","data-glass-region":"page-sidebar","aria-label":T("ui.library.page.filters"),className:"panel-top-pad flex h-full w-48 shrink-0 flex-col overflow-hidden bg-surface",children:he}),!ee&&f.jsxs("div",{"data-glass-region":"canvas-content",className:"panel-top-pad 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(Ot,{size:20,"aria-hidden":"true",className:"text-ink-muted"}),f.jsx("h1",{className:"text-title text-ink",children:T("ui.library.page.title")}),f.jsx("span",{className:"ml-2 text-meta tabular-nums text-ink-dim",children:T("ui.library.page.loaded_count",{loaded:String(D.length),total:String(q)})}),f.jsxs("div",{className:"ml-auto flex items-center rounded-sm border border-control",children:[f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-pressed":w==="grid","aria-label":T("ui.library.page.grid_view"),onClick:()=>x("grid"),children:f.jsx(fr,{"aria-hidden":"true"})}),f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-pressed":w==="list","aria-label":T("ui.library.page.list_view"),onClick:()=>x("list"),children:f.jsx(Ki,{"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(hr,{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(Ei,{ref:R,value:g,onChange:z=>S(z.target.value),onKeyDown:z=>{z.key==="Enter"&&z.preventDefault()},placeholder:T("ui.library.page.search"),"aria-label":T("ui.library.page.search"),"data-library-search":"",className:"border-0 bg-elevated pl-8"})]}),f.jsxs(Ps,{children:[f.jsx(Ts,{asChild:!0,children:f.jsxs(Z,{variant:"ghost",size:"sm",className:"bg-elevated text-ink",children:[f.jsx(Hn,{"aria-hidden":"true"}),T("ui.library.page.sort")]})}),f.jsx(js,{align:"end",className:"min-w-45",children:Cr.map(z=>f.jsxs($e,{onSelect:()=>m(O=>({...O,sort:z.key,order:Fr(z.key)})),children:[p.sort===z.key?f.jsx(Ri,{"aria-hidden":"true"}):f.jsx("span",{className:"size-4"}),f.jsx("span",{children:T(z.labelKey)})]},z.key))})]}),f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.page.reverse_order"),onClick:()=>m(z=>({...z,order:z.order==="asc"?"desc":"asc"})),children:p.order==="asc"?f.jsx(wr,{"aria-hidden":"true"}):f.jsx(Hn,{"aria-hidden":"true"})}),!u&&!ee&&f.jsxs(Z,{variant:"ghost",size:"sm",className:"bg-elevated text-ink",onClick:()=>v(!0),children:[f.jsx(Vi,{"aria-hidden":"true"}),T("ui.library.page.filters")]})]}),ne.length>0&&f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[ne.map((z,O)=>f.jsxs("span",{className:"contents",children:[O>0&&f.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"+"}),f.jsxs("span",{className:"inline-flex h-7 max-w-full items-center gap-1 rounded-sm bg-elevated px-2 text-meta text-ink-muted",children:[f.jsx("span",{className:"min-w-0 truncate",children:z.label}),f.jsx("button",{type:"button","aria-label":`${T("ui.library.filter.clear_filters")} — ${z.label}`,onClick:z.clear,className:"inline-flex size-6 shrink-0 items-center justify-center rounded-xs text-ink-dim hover:bg-row-hover hover:text-ink",children:f.jsx(We,{size:12,"aria-hidden":"true"})})]})]},z.key)),f.jsx(Z,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-meta",onClick:se,children:T("ui.library.page.clear_all")})]}),f.jsx("div",{"data-library-librarian-track":"",className:"min-h-10 shrink-0",children:f.jsx(kl,{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:T("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.jsx("div",{className:"flex min-w-0 flex-1",children:!ee&&f.jsx("section",{"data-library-results":"","aria-label":T("ui.library.page.results"),"aria-busy":N.isLoading||N.isFetching,className:"min-w-0 flex-1 overflow-y-auto px-4 py-4 [scrollbar-gutter:stable]",children:N.isLoading?f.jsx(eo,{view:w}):N.isError&&D.length===0?f.jsxs("div",{className:"flex flex-col items-start gap-3 py-10",children:[f.jsx(bn,{variant:"warning",children:ie}),f.jsxs(Z,{variant:"secondary",size:"sm",onClick:()=>void N.refetch(),children:[f.jsx(wn,{"aria-hidden":"true"}),T("ui.library.page.retry")]})]}):B?f.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-center",children:[f.jsx(Ot,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:te?`${T("ui.library.page.no_matches")}: ${ne.map(z=>z.label).join(" + ")}`:T("ui.library.page.empty_title")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:te?T("ui.library.page.no_matches_detail"):T("ui.library.page.empty_detail")}),te&&f.jsx(Z,{variant:"secondary",size:"sm",onClick:se,children:T("ui.library.page.clear_all")})]}):f.jsxs(f.Fragment,{children:[N.isRefetchError&&f.jsx(bn,{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:ie}),f.jsxs(Z,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void N.refetch(),children:[f.jsx(wn,{"aria-hidden":"true"}),T("ui.library.page.retry")]})]})}),f.jsx(Jr,{assets:D,selectedId:P,view:w,hasMore:!!N.hasNextPage,loadingMore:N.isFetchingNextPage,onLoadMore:V,...le}),N.isFetchNextPageError&&f.jsxs("div",{className:"flex items-center gap-2 py-3 text-meta text-ink-muted",children:[f.jsx("span",{children:T("ui.library.page.load_more_failed")}),f.jsx(Z,{variant:"ghost",size:"sm",onClick:V,children:T("ui.library.page.retry")})]})]})})})})]}),$&&I&&f.jsx("aside",{className:"panel-top-pad flex h-full w-[448px] shrink-0 bg-surface","aria-label":T("ui.library.page.preview"),children:f.jsx(ks,{asset:I,nowMs:l,onClose:Y,onOpenConversation:fe,onFilterSession:W,onAsk:()=>j(z=>z+1),onToggleFavorite:()=>de(I),composerFocusSignal:k,focusRequest:M,onExpand:X,mediaSiblings:Q})}),ee&&f.jsx("div",{className:"panel-top-pad min-w-0 flex-1 bg-surface","aria-label":T("ui.library.page.preview"),children:oe?f.jsx(Sl,{onBack:Y}):I?f.jsx(ks,{asset:I,nowMs:l,onClose:Y,onOpenConversation:fe,onFilterSession:W,onAsk:()=>j(z=>z+1),onToggleFavorite:()=>de(I),composerFocusSignal:k,focusRequest:M,mediaSiblings:Q,standalone:!0}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(xt,{label:T("ui.library.preview.loading")})})}),!ee&&!I&&$&&f.jsx("div",{className:"panel-top-pad hidden h-full w-[448px] shrink-0 items-start justify-center bg-surface p-8 lg:flex",children:f.jsx("p",{className:"max-w-60 text-center text-body-sm text-ink-dim",children:T("ui.library.page.select_asset")})}),f.jsx(zi,{open:_,onOpenChange:v,children:f.jsx(Ii,{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:T("ui.library.page.filters")}),f.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":T("ui.library.page.close_filters"),onClick:()=>v(!1),children:f.jsx(We,{"aria-hidden":"true"})})]}),f.jsx("div",{"data-library-filter-sheet":"",className:"min-h-0 flex-1 overflow-y-auto bg-surface",children:he})]})})})]})},zl=Object.freeze(Object.defineProperty({__proto__:null,LibraryPage:Pl},Symbol.toStringTag,{value:"Module"}));export{pe as a,G as b,b as g,zl as l};