local-operator-ui 0.36.8 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/main/index.js +2046 -19
- package/out/preload/index.js +34 -2
- package/out/renderer/assets/{_basePickBy-D11ygq2l.js → _basePickBy-Ccz_FVoP.js} +1 -1
- package/out/renderer/assets/{_baseUniq-_Pf0yG1r.js → _baseUniq-i6vGpLRc.js} +1 -1
- package/out/renderer/assets/{agent-details-page-LU973LFV.js → agent-details-page-Vg5HG_l0.js} +2 -2
- package/out/renderer/assets/{agent-hub-page-DegTVxlE.js → agent-hub-page-K4pCiyVg.js} +1 -1
- package/out/renderer/assets/{agents-page-B6Y-wB7u.js → agents-page-DO-dA64a.js} +3 -3
- package/out/renderer/assets/{arc-BedtwWh_.js → arc-B4AUWIOq.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DyIP0L4b.js → architectureDiagram-IEHRJDOE-B6S5IVGr.js} +1 -1
- package/out/renderer/assets/{arrow-up-BD8jieeb.js → arrow-up-BQ3q9CbG.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-w5b-ZzdW.js → blockDiagram-JOT3LUYC-LpW3K6pq.js} +1 -1
- package/out/renderer/assets/{book-open-DxzLWerU.js → book-open-1KhbTE6j.js} +1 -1
- package/out/renderer/assets/browser-page-C2PcMomi.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-CbE9FFZv.js → browser-webauthn-prompt-DW_0ckOh.js} +1 -1
- package/out/renderer/assets/{building-2-DtOQfBQY.js → building-2-B-r5qz8T.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-CnSFoHWb.js → c4Diagram-VJAJSXHY-CAqRIAIW.js} +1 -1
- package/out/renderer/assets/channel-C3p9uq-y.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-CY0scau5.js → chunk-4BMEZGHF-xA1Nsxex.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-B_cWmZiK.js → chunk-A2AXSNBT-CUDzamID.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-BRm1a_Ub.js → chunk-AEK57VVT-DlMRhXPR.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-CmZT-cQT.js → chunk-D6G4REZN-VcBIri9Q.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-Cwg1etHt.js → chunk-RZ5BOZE2-CCsj9xK4.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-a-OtMrnF.js → chunk-XZIHB7SX-CKTgVOcT.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-E64bGPOA.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-E64bGPOA.js +1 -0
- package/out/renderer/assets/clone-Cp6fbpqM.js +1 -0
- package/out/renderer/assets/{console-mirror-wrjuOlK5.js → console-mirror-rnDJat8Q.js} +1 -1
- package/out/renderer/assets/{consoleCapture-CGsX86Ez.js → consoleCapture-BDAHhWI6.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-qFePp_gf.js → conversation-input-sync-DkdrIqiD.js} +277 -277
- package/out/renderer/assets/{dagre-OKDRZEBW-ujAbOxN1.js → dagre-OKDRZEBW-BLJ3cLu1.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-BGt8bOqa.js → diagram-SSKATNLV-BH0p-5Dv.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DGmIp--B.js → diagram-VNBRO52H-B82m2-a7.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-Czgf2xtG.js → erDiagram-Q7BY3M3F-B49jRhsr.js} +1 -1
- package/out/renderer/assets/{error-boundary-CIO9VaTx.js → error-boundary-2fpGTHTH.js} +2 -2
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-BSuzI5ul.js → flowDiagram-4HSFHLVR-OEuTrGbc.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-DjjvFPP9.js → ganttDiagram-APWFNJXF-WrHus6zK.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-qgMylPGx.js → gitGraphDiagram-7IBYFJ6S-sdpNtvIC.js} +1 -1
- package/out/renderer/assets/{graph-C_PIARec.js → graph-CPx4Z3cH.js} +1 -1
- package/out/renderer/assets/{hash-BTR-wmLC.js → hash-MswM3CQT.js} +1 -1
- package/out/renderer/assets/index-Bt4e_nGt.js +57 -0
- package/out/renderer/assets/index-CXF8GwAZ.js +825 -0
- package/out/renderer/assets/index-Ct_f1nHS.css +1 -0
- package/out/renderer/assets/{index-B5ZsvNme.js → index-D0ZcaKHz.js} +1 -1
- package/out/renderer/assets/{index-B9Z9fABA.js → index-bD-9hTJ5.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-CXhZsMAw.js → infoDiagram-PH2N3AL5-CgbaZe5Z.js} +1 -1
- package/out/renderer/assets/{installer-DsBvKWJk.js → installer-GzNnUma-.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-BfRBfFPi.js → journeyDiagram-U35MCT3I-CIWLEQby.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BjBPm0Wp.js → kanban-definition-NDS4AKOZ-ORj0JKQO.js} +1 -1
- package/out/renderer/assets/{layout-CxH8v5Lh.js → layout-5wBU4YOj.js} +1 -1
- package/out/renderer/assets/legacy-agents-page-ou1Xp1az.js +33 -0
- package/out/renderer/assets/library-page-BloF_iPE.js +157 -0
- package/out/renderer/assets/{mermaid.core-Bx5BMQp8.js → mermaid.core-bCTq7TEV.js} +5 -5
- package/out/renderer/assets/{mesh-page-DXuH0pWs.js → mesh-page-IaVtAjU1.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Cnp-gOUf.js → mindmap-definition-ALO5MXBD-Ddhl_xII.js} +1 -1
- package/out/renderer/assets/{mini-Cxcx9-Gz.js → mini-CwNeJTk5.js} +1 -1
- package/out/renderer/assets/{notebook-pen-pmBcBtK5.js → notebook-pen-BY9EwH-7.js} +1 -1
- package/out/renderer/assets/{org-access-BBS-iiGY.js → org-access-c2-UvVYd.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-B9JbfoNw.js → org-surface-gate-B-MS3UYv.js} +1 -1
- package/out/renderer/assets/{page-header-D3rux4P9.js → page-header-CD8VERYn.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-BXGlHMJD.js → pieDiagram-IB7DONF6-STqRBD1R.js} +1 -1
- package/out/renderer/assets/projects-page-EY7aplWJ.js +45 -0
- package/out/renderer/assets/{publication-validation-Dent7Wyb.js → publication-validation-cVu_vGjF.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DTE1LofJ.js → quadrantDiagram-7GDLP6J5-D93w-jxI.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-C5aiTbpi.js → radar-MK3ICKWK-Dh3CwqLm.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-CD4FRlt9.js → radient-auth-buttons-BuUoxJkL.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-B-kbiFxO.js → requirementDiagram-KVF5MWMF-pKCmrqyl.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-8mSg8Gx1.js → sankeyDiagram-QLVOVGJD-Dv2syjv2.js} +1 -1
- package/out/renderer/assets/{schedules-page-M0NGG3zh.js → schedules-page-DJ7BtTi7.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-Ctz7PqiC.js → sequenceDiagram-X6HHIX6F-D14uGazi.js} +1 -1
- package/out/renderer/assets/{settings-page-Cy2SAtSh.js → settings-page-BPkUfxJX.js} +7 -7
- package/out/renderer/assets/smartart-uE0Bdv7c.js +1 -0
- package/out/renderer/assets/{stateDiagram-DGXRK772-x8oSqtIw.js → stateDiagram-DGXRK772-CTKP8UrZ.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-C1y1no_O.js +1 -0
- package/out/renderer/assets/team-bridge-page-ClnOkizZ.js +11 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-DZ5836tF.js → timeline-definition-BDJGKUSR-bs2AK5mP.js} +1 -1
- package/out/renderer/assets/ui-preferences-store-B5lixHt9.js +1 -0
- package/out/renderer/assets/{use-download-agent-mutation-Bgwi0JGB.js → use-download-agent-mutation-B3IkEPEZ.js} +3 -3
- package/out/renderer/assets/{use-session-snapshot-DQs7iPEs.js → use-session-snapshot-BKx6oLGB.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-CQNe5VvP.js → xychartDiagram-VJFVF3MP-B8vPLffn.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +3 -2
- package/out/renderer/assets/browser-page-Bm5bblrV.js +0 -1
- package/out/renderer/assets/channel-BJPW3C83.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BjlJ_E71.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BjlJ_E71.js +0 -1
- package/out/renderer/assets/clone-BuzQaJVT.js +0 -1
- package/out/renderer/assets/index-BSn66J9q.js +0 -57
- package/out/renderer/assets/index-BzHpKJoz.css +0 -1
- package/out/renderer/assets/index-U5qrTe4P.js +0 -824
- package/out/renderer/assets/legacy-agents-page-CiirOdbB.js +0 -33
- package/out/renderer/assets/library-page-CH3E7s4_.js +0 -157
- package/out/renderer/assets/projects-page-DjaYWghP.js +0 -40
- package/out/renderer/assets/smartart-DmOeXeJs.js +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CUVgaWvm.js +0 -1
- package/out/renderer/assets/tags-input-chips-BAP2XNbQ.js +0 -1
- package/out/renderer/assets/team-bridge-page-CYehSZqj.js +0 -11
- package/out/renderer/assets/ui-preferences-store-oc99NgQT.js +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./smartart-uE0Bdv7c.js","./index-Bt4e_nGt.js","./index-Ct_f1nHS.css","./index-CXF8GwAZ.js","./conversation-input-sync-DkdrIqiD.js","./ui-preferences-store-B5lixHt9.js","./error-boundary-2fpGTHTH.js","./conversation-input-sync-CAX4_ErH.css","./console-mirror-rnDJat8Q.js","./console-mirror-DOrYoP_4.css","./index-DHKnfVbX.css","./page-header-CD8VERYn.js","./hash-MswM3CQT.js","./arrow-up-BQ3q9CbG.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as P,r as R,j as f,c as ke}from"./index-Bt4e_nGt.js";import{b_ as Lt,a6 as Pt,b$ as Ln,bm as Cn,h as ri,c0 as bt,c1 as oi,c2 as ai,c3 as li,c4 as ci,c5 as di,c6 as ui,c7 as fi,bU as hi,c8 as Dt,c9 as pi,ca as gi,cb as yn}from"./index-CXF8GwAZ.js";import{c3 as mi,c4 as Dn,c5 as bi,c6 as yi,c7 as vi,$ as Fn,u as ft,aO as Oe,c8 as Ue,d as Me,c9 as ps,a0 as Zt,aI as wi,ca as vn,cb as gs,cc as xi,aT as ct,aP as wn,a2 as Fe,cd as ms,ce as $t,cf as ki,cg as _i,ch as Si,ci as Jt,cj as bs,bY as Bn,aR as Nn,ap as Pi,ck as Ti,cl as ji,cm as On,bP as en,cn as ys,bQ as Mn,co as Ci,cp as Fi,cq as vs,cr as Ni,cs as Mi,bJ as Ai,c1 as $i,aS as Ei,a as Ri,c as Ii,ct as zi,bO as Li}from"./conversation-input-sync-DkdrIqiD.js";import{P as Di}from"./page-header-CD8VERYn.js";import{c as Tt,h as ws,y as Bt,i as xs,B as H,j as ks,k as Ae,a9 as Bi,aa as Oi,ab as Ui,l as Un,q as et,X as Xe,u as ht,S as Xt,T as Gi,ac as Wi,J as qi,p as Ki,A as gn,I as Xi,g as Vi,ad as Hi,ae as Yi}from"./error-boundary-2fpGTHTH.js";import"./ui-preferences-store-B5lixHt9.js";import{H as Qi}from"./hash-MswM3CQT.js";import{A as Zi}from"./arrow-up-BQ3q9CbG.js";var Ji=class extends mi{constructor(e,n){super(e,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Dn()})}getOptimisticResult(e){return e.behavior=Dn(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,n){const{state:t}=e,s=super.createResult(e,n),{isFetching:i,isRefetching:r,isError:o,isRefetchError:l}=s,a=t.fetchMeta?.fetchMore?.direction,d=o&&a==="forward",c=i&&a==="forward",h=o&&a==="backward",u=i&&a==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:yi(n,t.data),hasPreviousPage:bi(n,t.data),isFetchNextPageError:d,isFetchingNextPage:c,isFetchPreviousPageError:h,isFetchingPreviousPage:u,isRefetchError:l&&!d&&!h,isRefetching:r&&!c&&!u}}};function er(e,n){return vi(e,Ji,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 tr=[["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"}]],Gn=Tt("arrow-down-wide-narrow",tr);/**
|
|
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 nr=[["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"}]],sr=Tt("arrow-up-narrow-wide",nr);/**
|
|
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 ir=[["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"}]],rr=Tt("presentation",ir);/**
|
|
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 or=[["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"}]],ar=Tt("sheet",or);/**
|
|
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 lr=[["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"}]],cr=Tt("tags",lr),dr=["generated","created","mentioned"],xn=[{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"}],ur=[{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"}],Ot={q:"",scope:"final",tagMode:"all",highlighted:!1,sort:"recent",order:"desc"};function fr(e){return e==="name"||e==="kind"?"asc":"desc"}function Wn(e,n){return e.status===n}function hr(e){return!!(e.q.trim()||e.category||e.originGroup||e.tag||e.session||e.highlighted||e.status)}function pr(e){if(e==="unorganized")return!1}function Ye(e){return e.name.trim()||e.derived_name.trim()||e.id}function _s(e){const n=e.derived_name.trim();return n?n===e.name.trim()?e.ref.display_path:n:e.ref.display_path}function gr(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 An(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 mr(e,n){if(!e)return"";const t=n-e*1e3;if(t<6e4)return P("ui.library.time.just_now");const s=Math.floor(t/6e4);if(s<60)return P("ui.library.time.minutes_m_ago",{minutes:s});const i=Math.floor(s/60);if(i<24)return P("ui.library.time.hours_h_ago",{hours:i});const r=Math.floor(i/24);if(r<30)return P("ui.library.time.days_d_ago",{days:r});const o=Math.floor(r/30);return o<12?P("ui.library.time.months_mo_ago",{months:o}):P("ui.library.time.years_y_ago",{years:Math.floor(o/12)})}function br(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 tn(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 Ge={all:["desktop","library"],list:e=>["desktop","library","list",e],detail:e=>["desktop","library","detail",e],tags:["desktop","library","tags"],librarian:["desktop","library","librarian"]},yr=60;function vr(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=pr(e.status);return t!==void 0?{organized:t}:{}})(),sort:e.sort,order:e.order,limit:yr,...n?{cursor:n}:{}}}function wr(e,n){return er({queryKey:Ge.list(e),enabled:n,initialPageParam:void 0,queryFn:({pageParam:t})=>Me(vr(e,t)),getNextPageParam:t=>t.next_cursor??void 0,retry:Zt,refetchInterval:t=>t.state.data?.pages.at(-1)?.state==="building"?2e3:!1,staleTime:1e4})}function xr(e,n){return Fn({queryKey:Ge.detail(e??""),enabled:n&&!!e,queryFn:()=>Me({op:"library.get",id:e}),retry:Zt,staleTime:5e3})}function kr(e){return Fn({queryKey:Ge.tags,enabled:e,queryFn:()=>Me({op:"library.tags"}),retry:Zt,staleTime:2e4})}function Ss(e){return Fn({queryKey:Ge.librarian,enabled:e,queryFn:()=>Me({op:"library.librarian",action:"status"}).then(n=>"librarian"in n?n.librarian:n),retry:Zt,staleTime:3e4})}function Ve(e){return e.invalidateQueries({queryKey:Ge.all})}function Ps(){const e=ft();return Oe({mutationFn:n=>Me({op:"library.update",id:n.id,fields:n.fields}),onSuccess:n=>(e.setQueryData(Ge.detail(n.id),n),Ve(e)),onError:(n,t)=>{e.invalidateQueries({queryKey:Ge.detail(t.id)}),e.invalidateQueries({queryKey:Ge.all})},retry:Ue})}function _r(){const e=ft();return Oe({mutationFn:n=>Me({op:"library.tags.assign",id:n.id,tags:n.tags,...n.primary?{primary:n.primary}:{}}),onSuccess:n=>(e.setQueryData(Ge.detail(n.id),n),Ve(e)),onError:()=>Ve(e),retry:Ue})}function Sr(){const e=ft(),n=()=>Ve(e),t=Oe({mutationFn:o=>Me({op:"library.tags.create",name:o.name,...o.category?{category:o.category}:{}}),onSuccess:n,retry:Ue}),s=Oe({mutationFn:o=>Me({op:"library.tags.update",id:o.id,...o.name!==void 0?{name:o.name}:{},...o.category!==void 0?{category:o.category}:{}}),onSuccess:n,retry:Ue}),i=Oe({mutationFn:o=>Me({op:"library.tags.delete",id:o.id}),onSuccess:n,retry:Ue}),r=Oe({mutationFn:o=>Me({op:"library.tags.merge",id:o.id,into:o.into}),onSuccess:n,retry:Ue});return{create:t,update:s,remove:i,merge:r}}function Pr(){const e=ft();return Oe({mutationFn:n=>Me({op:"library.chat.link",id:n.id,sessionId:n.sessionId}),onSuccess:()=>Ve(e),onError:()=>Ve(e),retry:Ue})}function Tr(){const e=ft();return Oe({mutationFn:n=>Me({op:"library.chat.clear",id:n.id}),onSuccess:()=>Ve(e),retry:Ue})}function jr(){const e=ft();return Oe({mutationFn:n=>Me({op:"library.librarian",action:n}).then(t=>"librarian"in t?t.librarian:t),onSuccess:()=>Ve(e),retry:Ue})}function We(e,n,t,s=!1){const[i,r]=R.useState({bytes:null,mimeType:"",error:null,loading:!1});return R.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}),ps(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 jt(e,n){const[t,s]=R.useState(null);return R.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 Cr=/[\\/]/;function Fr(e){const t=Ye(e).split(Cr).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 ps({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=Fr(e),i.rel="noopener",document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(s),3e4)}const $n=({asset:e,onAsk:n,onEditMetadata:t,onEditTags:s,onToggleFavorite:i,onOpenConversation:r,onFilterSession:o,triggerClassName:l})=>{const a=async(u,g)=>{try{await navigator.clipboard.writeText(u),wn(g)}catch{Fe(P("ui.library.menu.copy_failed"))}},d=async()=>{try{await dt(e),wn(P("ui.library.menu.saved_a_copy"))}catch{Fe(P("ui.library.menu.save_failed"))}},c=!!(e.ref.type==="path"&&e.ref.path),h=e.occurrences;return f.jsxs(ws,{children:[f.jsx(Bt,{content:P("ui.library.menu.asset_actions"),children:f.jsx(xs,{asChild:!0,children:f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("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(wi,{"aria-hidden":"true"})})})}),f.jsxs(ks,{align:"end",className:"min-w-52",onClick:u=>u.stopPropagation(),children:[h.length===1?f.jsxs(Ae,{onSelect:()=>r(h[0].session_id),children:[f.jsx(Lt,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.open_source_conversation")})]}):h.length>1?f.jsxs(Bi,{children:[f.jsxs(Oi,{children:[f.jsx(Lt,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.open_source_conversation")})]}),f.jsx(Ui,{className:"min-w-60",children:h.map(u=>f.jsx(Ae,{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(Ae,{onSelect:n,children:[f.jsx(Lt,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.ask_about_asset")})]}),h.length>0&&f.jsxs(Ae,{onSelect:()=>o(h[0].session_id),children:[f.jsx(vn,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.show_from_conversation")})]}),f.jsx(Un,{}),f.jsxs(Ae,{onSelect:i,children:[f.jsx(Pt,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0}),f.jsx("span",{children:e.favorite?P("ui.library.menu.unfavorite"):P("ui.library.menu.favorite")})]}),f.jsxs(Ae,{onSelect:t,children:[f.jsx(gs,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.edit_metadata")})]}),f.jsxs(Ae,{onSelect:s,children:[f.jsx(cr,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.edit_tags")})]}),f.jsx(Un,{}),e.ref.path?f.jsxs(Ae,{onSelect:()=>void a(e.ref.path,P("ui.library.menu.path_copied")),children:[f.jsx(xi,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.copy_path")})]}):null,f.jsxs(Ae,{onSelect:()=>void a(e.id,P("ui.library.menu.asset_id_copied")),children:[f.jsx(Qi,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.copy_asset_id")})]}),c?f.jsxs(Ae,{onSelect:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(vn,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.reveal_in_finder")})]}):f.jsxs(Ae,{onSelect:()=>void d(),children:[f.jsx(ct,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.download")})]}),e.ref.type==="artifact"&&f.jsxs(Ae,{onSelect:()=>void d(),children:[f.jsx(ct,{"aria-hidden":"true"}),f.jsx("span",{children:P("ui.library.menu.save_a_copy")})]})]})]})},Nr={image:Si,audio:_i,video:ki,pdf:$t,pptx:rr,docx:$t,markdown:$t,html:Ln,spreadsheet:ar,text:$t,code:Ln,other:ms};function Mr(e){return Nr[e]??ms}function it({kind:e,size:n=20,className:t}){const s=Mr(e);return f.jsx(s,{size:n,"aria-hidden":"true",className:t})}const Ts=({group:e})=>f.jsx(et,{variant:e==="generated"?"accent":"neutral",children:P(tn(e))}),js=({asset:e,large:n=!1})=>{const[t,s]=bs("300px"),i=e.kind==="image"&&e.exists&&s,r=We(e.id,"thumbnail",i),o=jt(r.bytes,r.mimeType);return f.jsx("div",{ref:t,className:ke("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(it,{kind:e.kind,size:n?28:22,className:"text-ink-dim"})})},Ar=()=>f.jsx("span",{className:"absolute top-1.5 left-1.5 flex size-5 items-center justify-center rounded-full bg-elevated",title:P("ui.library.card.highlighted"),children:f.jsx(Pt,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),Cs=({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]})]})},$r=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:ke("group relative flex flex-col overflow-hidden rounded-lg border border-hairline bg-surface",n&&Cn),children:[f.jsxs("button",{type:"button",onClick:()=>t.onSelect(e.id),"aria-pressed":n,className:"flex w-full flex-col text-left focus-visible:outline-offset-2",children:[f.jsxs("div",{className:"relative",children:[f.jsx(js,{asset:e,large:!0}),e.highlighted&&f.jsx(Ar,{}),f.jsx("div",{className:"absolute top-1.5 right-1.5"})]}),f.jsxs("div",{className:"flex w-full flex-col gap-1 p-3",children:[f.jsx("span",{className:"line-clamp-1 text-body-sm font-medium text-ink",children:Ye(e)}),f.jsx("span",{className:"line-clamp-1 text-meta text-ink-dim",children:_s(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:An(e.size_bytes)}),e.duration_s?f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:br(e.duration_s)})]}):null]}),f.jsx(Cs,{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(Lt,{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(Ts,{group:e.origin_group}),e.session_count>1&&f.jsx("span",{className:"text-meta text-ink-dim",children:P("ui.library.card.conversations",{count:e.session_count})})]})]})]}),f.jsx("div",{className:"invisible absolute top-1.5 right-1.5 group-focus-within:visible group-hover:visible [@media(pointer:coarse)]:visible",children:f.jsx($n,{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"})})]}),Er=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:ke("group relative flex items-center gap-3 rounded-md border border-hairline bg-surface px-3 py-2",n&&Cn),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(js,{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(Pt,{size:12,"aria-hidden":"true",className:"shrink-0 fill-current text-accent"}),Ye(e)]}),f.jsx("span",{className:"truncate text-meta text-ink-dim",children:_s(e)})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-meta text-ink-muted",children:[f.jsx(Cs,{asset:e}),f.jsx("span",{children:e.kind}),f.jsx("span",{children:An(e.size_bytes)}),f.jsx(Ts,{group:e.origin_group})]})]}),f.jsx($n,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession})]}),Rr=({assets:e,selectedId:n,view:t,hasMore:s,loadingMore:i,onLoadMore:r,...o})=>{const l=R.useRef(null);return R.useEffect(()=>{const a=l.current;if(!a||!s)return;const d=new IntersectionObserver(c=>{c.some(h=>h.isIntersecting)&&r()},{rootMargin:"600px 0px"});return d.observe(a),()=>d.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($r,{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(Er,{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(Jt,{size:14,"aria-hidden":"true",className:"motion-safe:animate-spin"}),P("ui.library.grid.loading_more")]}),!i&&s&&f.jsx(H,{variant:"ghost",size:"sm",onClick:r,children:P("ui.library.grid.load_more")})]})]})},Ir=({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))}),zr=[{key:"highlighted",labelKey:"ui.library.status.highlighted"},{key:"unorganized",labelKey:"ui.library.status.unorganized"},{key:"favorite",labelKey:"ui.library.status.favorites"}],qe=({label:e,count:n,active:t,onPress:s,icon:i,indent:r=!1})=>f.jsxs("button",{type:"button",onClick:s,"aria-pressed":t,className:ke("flex h-7 w-full items-center gap-2 rounded-md px-2 text-left text-body-sm",r&&"pl-6",t?Cn:"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})]}),mt=({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})]}),Lr=({filters:e,onChange:n,counts:t,tags:s,total:i,scopeTotal:r})=>{const o=gr(s),l=t?.category??{},a=c=>n({...e,...c}),d=!!(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:[d&&f.jsxs(H,{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(Xe,{"aria-hidden":"true"}),P("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:P("ui.library.filter.one_conversation")}),f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.filter.clear_conversation"),onClick:()=>a({session:void 0}),children:f.jsx(Xe,{"aria-hidden":"true"})})]}),f.jsxs(mt,{label:P("ui.library.filter.scope"),children:[f.jsx(qe,{label:P("ui.library.filter.scope_final"),active:e.scope==="final",onPress:()=>a({scope:"final"})}),f.jsx(qe,{label:P("ui.library.filter.scope_all"),count:r??void 0,active:e.scope==="all",onPress:()=>a({scope:"all"})})]}),f.jsxs(mt,{label:P("ui.library.filter.categories"),children:[f.jsx(qe,{label:P("ui.library.category.all"),count:i,active:!e.category,onPress:()=>a({category:void 0})}),xn.map(c=>f.jsx(qe,{label:P(c.labelKey),count:l[c.key]??0,active:e.category===c.key,onPress:()=>a({category:e.category===c.key?void 0:c.key}),icon:f.jsx(it,{kind:c.iconKind,size:14,className:"text-ink-dim"})},c.key)),Object.keys(l).filter(c=>!xn.some(h=>h.key===c)).sort().map(c=>f.jsx(qe,{label:c,count:l[c],active:e.category===c,onPress:()=>a({category:e.category===c?void 0:c}),icon:f.jsx(Bn,{size:14,"aria-hidden":"true"})},c))]}),f.jsx(mt,{label:P("ui.library.filter.status"),children:zr.map(c=>f.jsx(qe,{label:P(c.labelKey),active:Wn(e,c.key),onPress:()=>a({status:Wn(e,c.key)?void 0:c.key}),icon:c.key==="favorite"||c.key==="highlighted"?f.jsx(Pt,{size:14,"aria-hidden":"true"}):void 0},c.key))}),f.jsx(mt,{label:P("ui.library.filter.source"),children:dr.filter(c=>e.originGroup===c||e.scope==="all"||(t?.origin_group?.[c]??0)>0).map(c=>f.jsx(qe,{label:P(tn(c)),count:t?.origin_group?.[c]??0,active:e.originGroup===c,onPress:()=>a({originGroup:e.originGroup===c?void 0:c})},c))}),o.length>0&&f.jsx(mt,{label:P("ui.library.filter.tags"),children:o.map(c=>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:c.category}),c.tags.map(h=>f.jsx(qe,{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(Bn,{size:13,"aria-hidden":"true"}),indent:!0},h.id))]},c.category))}),e.tag&&f.jsx(et,{variant:"neutral",children:P("ui.library.filter.tag_mode",{mode:e.tagMode.toUpperCase()})})]})},qn=({value:e,onSave:n,label:t,placeholder:s="",multiline:i=!1,rows:r=3,textClassName:o,allowEmpty:l=!1,startSignal:a,field:d,className:c})=>{ht();const[h,u]=R.useState(!1),[g,p]=R.useState(e),[m,S]=R.useState(!1),y=R.useRef("closed"),x=R.useRef(null),w=R.useRef(null),k=()=>{y.current==="closed"&&(p(e),y.current="edit",u(!0))},v=I=>{y.current="closed",I&&w.current?.focus(),u(!1)},_=async I=>{if(y.current!=="edit")return;const L=g.trim();if(!L&&!l||L===e){v(I);return}y.current="saving",S(!0);try{await n(L),y.current==="saving"&&v(I)}catch{y.current==="saving"&&(y.current="edit",x.current?.focus())}finally{S(!1)}};R.useEffect(()=>{if(!h)return;const I=setTimeout(()=>{const L=x.current;L&&(L.focus(),L.select(),L.scrollLeft=0,L instanceof HTMLTextAreaElement&&(L.scrollTop=0))},0);return()=>clearTimeout(I)},[h]),R.useEffect(()=>{y.current==="closed"&&p(e)},[e]);const T=R.useRef(a);R.useEffect(()=>{const I=T.current;T.current=a,!(a===I||!a)&&k()},[a]);const N=I=>{if(!(I.nativeEvent.isComposing||I.keyCode===229)){if(I.key==="Enter"){if(i&&I.shiftKey)return;I.preventDefault(),_(!0)}else if(I.key==="Escape"){if(I.preventDefault(),y.current==="saving")return;v(!0)}}},M=I=>{h&&I.preventDefault()},C=I=>{p(I.target.value)},$=e.trim()?f.jsx("span",{onDoubleClick:k,className:ke("block min-w-0 cursor-default select-none",i?"whitespace-pre-wrap break-words":"truncate",o),children:e}):f.jsx("button",{type:"button",onClick:k,className:ke("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":d,className:ke("group/inline flex min-w-0 items-center gap-1",!h&&"w-fit max-w-full",h&&"w-full",i&&h&&"items-start",c),children:[h?i?f.jsx("textarea",{"data-inline-edit-input":"",ref:I=>{x.current=I},value:g,rows:r,readOnly:m,"aria-label":t,"aria-busy":m||void 0,onChange:C,onKeyDown:N,onBlur:()=>void _(!1),spellCheck:!1,className:ke("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:I=>{x.current=I},value:g,readOnly:m,"aria-label":t,"aria-busy":m||void 0,onChange:C,onKeyDown:N,onBlur:()=>void _(!1),spellCheck:!1,className:ke("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:w,"data-inline-edit-control":"","aria-label":m?P("ui.common.forms.editable_field.saving"):h?P("ui.common.forms.autocomplete_field.cancel_editing",{label:t}):P("ui.common.forms.editable_field.edit_v2",{label:t}),title:m?P("ui.common.forms.editable_field.saving"):h?P("ui.common.forms.editable_field.cancel_escape"):P("ui.common.forms.editable_field.edit"),"aria-busy":m||void 0,"aria-disabled":m||void 0,onMouseDown:M,onClick:I=>{if(!(I.detail>1)&&y.current!=="saving"){if(h){v(!0);return}k()}},className:ke("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:m?f.jsx(Xt,{size:"xs"}):h?f.jsx(Xe,{className:"size-3","aria-hidden":"true"}):f.jsx(gs,{className:"size-3","aria-hidden":"true"})})]})},Dr=({value:e,onChange:n,label:t,addLabel:s,saving:i=!1,startSignal:r})=>{ht();const[o,l]=R.useState(!1),[a,d]=R.useState(""),c=R.useRef(null),h=R.useRef(null),u=()=>{i||o||l(!0)},g=()=>{d(""),l(!1)},p=w=>{const k=a.trim().toLowerCase();k&&!e.some(v=>v.toLowerCase()===k)&&n([...e,k]),d(""),w?c.current?.focus():l(!1)},m=R.useRef(!1);R.useEffect(()=>{if(i){m.current=!0;return}if(!o){m.current=!1;return}const w=m.current;m.current=!1;const k=setTimeout(()=>{if(w){const v=document.activeElement,_=h.current;if(!(!v||v===document.body||!!_?.contains(v)))return}c.current?.focus()},0);return()=>clearTimeout(k)},[o,i]);const S=R.useRef(r);R.useEffect(()=>{const w=S.current;S.current=r,!(r===w||!r)&&u()},[r]);const y=w=>{w.nativeEvent.isComposing||w.keyCode===229||(w.key==="Enter"?(w.preventDefault(),p(!0)):w.key==="Escape"&&(w.preventDefault(),g()))},x=i?f.jsx(Xt,{size:"xs"}):o?f.jsx("input",{ref:c,value:a,"aria-label":t,onChange:w=>d(w.target.value),onKeyDown:y,onBlur:()=>a.trim()?p(!1):g(),spellCheck:!1,className:ke("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:ke("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(ri,{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(w=>f.jsxs(et,{variant:"neutral",shape:"pill",className:"gap-1 pr-1 text-ink",children:[w,f.jsx("button",{type:"button","aria-label":P("ui.chat.tags.remove_named",{name:w}),disabled:i,onClick:()=>n(e.filter(k=>k!==w)),className:ke("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(Xe,{className:"size-3","aria-hidden":"true"})})]},w)),x]})},Br=new Set(["image/png","image/jpeg","image/gif","image/webp"]),Or=1e6;function Ur(e){let n="";for(let s=0;s<e.length;s+=32768)n+=String.fromCharCode(...e.subarray(s,Math.min(s+32768,e.length)));return btoa(n)}function Gr(e){const n=e.ref.display_path||e.ref.path||(e.ref.digest?`attachment digest ${e.ref.digest}`:e.id);return`${Ye(e)} (${n})`}const Wr=({asset:e,focusSignal:n,compact:t=!1})=>{ht();const s=Nn(),i=R.useRef(null),r=()=>{const _=i.current;_&&(_.style.height="24px",_.style.height=`${Math.min(72,Math.max(24,_.scrollHeight))}px`)},[o,l]=R.useState(""),[a,d]=R.useState(!1),[c,h]=R.useState({}),[u,g]=R.useState(null),p=c[e.id]??null,m=u===e.id,S=Pr(),y=Tr(),x=We(e.id,"content",e.kind==="image");R.useEffect(()=>{l("")},[e.id]),R.useEffect(()=>{n!==0&&i.current?.focus()},[n]);const w=async()=>{const _=o.trim();if(!(!_||a)){d(!0);try{const T=Pi.getState();let N=e.chat?.session_id??p??null;if(!N&&(N=await T.createSession(T.cwd||"~"),!N))throw new Error(T.error??P("ui.library.composer.could_not_start"));const M={op:"sessions.message",sessionId:N,requestId:crypto.randomUUID(),text:`${_}
|
|
28
|
+
|
|
29
|
+
${Gr(e)}`},C=e.ref.content_type||x.mimeType;if(e.kind==="image"&&x.bytes&&Br.has(C)){const j=Ur(x.bytes);j.length<=Or&&(M.images=[{data_b64:j,mime_type:C}])}if(await Me(M),l(""),!e.chat&&!p)try{await S.mutateAsync({id:e.id,sessionId:N})}catch(j){h($=>({...$,[e.id]:N})),g(e.id),Fe(j instanceof Error&&j.message?P("ui.library.composer.link_failed",{message:j.message}):P("ui.library.composer.link_failed_short"));return}if(p)try{await S.mutateAsync({id:e.id,sessionId:N}),h(j=>{const $={...j};return delete $[e.id],$}),g(null)}catch{g(e.id),Fe(P("ui.library.composer.link_failed_short"));return}await bt(s,N)}catch(T){Fe(T instanceof Error&&T.message?T.message:P("ui.library.composer.not_sent"))}finally{d(!1)}}},k=e.chat,v=async()=>{const _=p??e.chat?.session_id;if(_)try{await S.mutateAsync({id:e.id,sessionId:_}),h(T=>{const N={...T};return delete N[e.id],N}),g(null)}catch{Fe(P("ui.library.composer.link_failed_short"))}};return f.jsxs("div",{className:ke("mx-auto flex w-[min(calc(100%-24px),720px)] flex-col justify-end gap-2 pb-4",t?"h-38":"h-44"),"data-library-composer":"",children:[m&&p&&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:P("ui.library.composer.message_sent_link_failed")}),f.jsx(H,{variant:"ghost",size:"sm",onClick:()=>void v(),children:P("ui.library.composer.retry_link")}),f.jsx(H,{variant:"ghost",size:"sm",onClick:()=>void bt(s,p),children:P("ui.library.composer.open_chat")})]}),k&&f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx(oi,{size:13,"aria-hidden":"true"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:P("ui.library.composer.chat_about",{title:k.title||k.session_id})}),f.jsx(H,{variant:"ghost",size:"sm",onClick:()=>void bt(s,k.session_id),children:P("ui.library.composer.open_chat")}),f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.composer.unlink"),onClick:()=>y.mutate({id:e.id}),children:f.jsx(Xe,{"aria-hidden":"true"})})]}),f.jsxs("div",{"data-glass-region":"composer",className:ke("flex items-end gap-2 rounded-lg bg-elevated p-2","focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-accent"),children:[f.jsx(Gi,{ref:i,rows:1,value:o,onChange:_=>{l(_.target.value),r()},onKeyDown:_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),w())},placeholder:k?P("ui.library.composer.continue_placeholder"):P("ui.library.composer.ask_placeholder"),"aria-label":P("ui.library.composer.label"),className:"h-6 min-h-6 max-h-18 resize-none overflow-y-auto border-0 bg-transparent px-0 py-0 text-body leading-6 shadow-none focus-visible:outline-none"}),f.jsx(H,{variant:"primary",size:"icon-sm",disabled:!o.trim()||a,"aria-label":P("ui.library.composer.send"),onClick:()=>void w(),children:a?f.jsx(Jt,{"aria-hidden":"true",className:"motion-safe:animate-spin"}):f.jsx(Zi,{"aria-hidden":"true"})})]})]})};function qr(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 Kr="h-[78px] w-[117px]",Xr=({asset:e,active:n,onSelect:t})=>{const[s,i]=bs("300px"),r=We(e.id,"thumbnail",e.kind==="image"&&e.exists&&i),o=jt(r.bytes,r.mimeType),l=Ye(e);return f.jsx("li",{ref:s,className:ke("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:ke("flex items-center justify-center overflow-hidden bg-canvas",Kr),children:o?f.jsx("img",{src:o,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover"}):f.jsx(it,{kind:e.kind,size:20,className:"text-ink-dim"})})})})},Vr=({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(Xr,{asset:s,active:i===n,onSelect:()=>t(i)},s.id))}),Hr=({open:e,siblings:n,index:t,onIndexChange:s,onClose:i,restoreFocusTo:r,resolved:o})=>{ht();const l=Ti(t,n.length),a=n[l],d=o?.assetId===a.id,c=We(a.id,"content",!d),h=jt(c.bytes,c.mimeType||a.ref.content_type),u=d?o?.url:h??void 0,g=Ye(a);return f.jsx(ji,{open:e,onOpenChange:p=>{p||i()},src:u,pending:!d&&(c.loading||u===void 0&&!c.error),label:g,mediaKind:a.kind==="video"?"video":"image",mediaLabel:"asset",restoreFocusTo:r,layerAttributes:{"data-library-lightbox":""},fallback:c.error||u!==void 0?f.jsx("p",{className:"max-w-90 text-center text-body-sm text-ink-muted",children:P("ui.library.preview.could_not_load")}):void 0,group:{index:l,count:n.length,onPrev:()=>s(On(l,n.length,-1)),onNext:()=>s(On(l,n.length,1)),filmstrip:n.length>1?f.jsx(Vr,{siblings:n,index:l,onSelect:s}):void 0}})};async function Fs(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 p=n.length-22;p>=l;p--)if(t.getUint32(p,!0)===s){o=p;break}if(o===-1)throw new Error("Not a valid ZIP file: EOCD not found");let a,d;const c=o-20;if(c>=0&&t.getUint32(c,!0)===r){const p=Number(t.getBigUint64(c+8,!0));if(t.getUint32(p,!0)!==i)throw new Error("Invalid ZIP64 end record");a=Number(t.getBigUint64(p+48,!0)),d=Number(t.getBigUint64(p+32,!0))}else a=t.getUint32(o+16,!0),d=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 g=a;for(let p=0;p<d&&!(g+46>n.length||t.getUint32(g,!0)!==h);p++){const m=t.getUint16(g+10,!0);let S=t.getUint32(g+20,!0),y=t.getUint32(g+24,!0);const x=t.getUint16(g+28,!0),w=t.getUint16(g+30,!0),k=t.getUint16(g+32,!0);let v=t.getUint32(g+42,!0);const _=Qr(n,g+46,x);if(S===4294967295||y===4294967295||v===4294967295){const j=g+46+x,$=j+w;let I=j;for(;I+4<=$;){const L=t.getUint16(I,!0),Y=t.getUint16(I+2,!0);if(L===1){let W=I+4;y===4294967295&&W+8<=$&&(y=Number(t.getBigUint64(W,!0)),W+=8),S===4294967295&&W+8<=$&&(S=Number(t.getBigUint64(W,!0)),W+=8),v===4294967295&&W+8<=$&&(v=Number(t.getBigUint64(W,!0)));break}I+=4+Y}}if(g+=46+x+w+k,_.endsWith("/")||m!==0&&m!==8||v+30>n.length)continue;const T=t.getUint16(v+26,!0),N=t.getUint16(v+28,!0),M=v+30+T+N;if(M+S>n.length)continue;const C=n.subarray(M,M+S);try{u[_]=m===0?C.slice():await Yr(C)}catch(j){console.warn(`[zip.js] Failed to decompress "${_}":`,j.message)}}return u}async function Yr(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:d}=await s.read();if(d)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 Qr(e,n,t){return new TextDecoder().decode(e.subarray(n,n+t))}function Se(e){return new DOMParser().parseFromString(e,"application/xml")}function de(e,n){if(!e)return[];const t=[],s=e.getElementsByTagName("*");for(let i=0;i<s.length;i++)s[i].localName===n&&t.push(s[i]);return t}function b(e,n){return de(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 F(e,n,t=0){const s=G(e,n);return s!==null?parseInt(s,10):t}function ze(e,n,t){return Math.max(n,Math.min(t,e))}const wt=12700,Zr=Object.freeze(Object.defineProperty({__proto__:null,EMU_PER_PT:wt,attr:G,attrInt:F,clamp:ze,g1:b,gtn:de,parseXml:Se},Symbol.toStringTag,{value:"Module"}));function Jr(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 d=b(a,"srgbClr"),c=b(a,"sysClr");d?t[l]=d.getAttribute("val")||"":c&&(t[l]=c.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 eo(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 to(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"}},Ut=new Set,xt=new Map,Gt=new Set;let Kn=null,mn=null;function no(){return mn||(Kn=typeof OffscreenCanvas<"u"?new OffscreenCanvas(300,10):Object.assign(document.createElement("canvas"),{width:300,height:10}),mn=Kn.getContext("2d")),mn}const Xn="mmmmmmmmmmlllllllllliiiiiiiiiixxxxxxxxxx",so=[20,40];function Ns(e){if(Gt.has(e))return!0;if(typeof document<"u"&&document.fonts&&document.fonts.check(`16px "${e}"`))return Gt.add(e),!0;try{const n=no(),t=["monospace","serif"];for(const s of so)for(const i of t){n.font=`${s}px ${i}`;const r=n.measureText(Xn).width;n.font=`${s}px "${e}", ${i}`;const o=n.measureText(Xn).width;if(Math.abs(o-r)>.5)return Gt.add(e),!0}}catch{}return!1}async function kn(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=xt.get(e)??[];o.push(r),xt.set(e,o),Ut.add(e),Gt.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 io(e){const n=[];for(const[t,s]of Object.entries(e))if(typeof s=="string")n.push(kn(t,s));else if(Array.isArray(s))for(const i of s){const{url:r,...o}=i;n.push(kn(t,r,o))}await Promise.all(n)}function ro(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 d of["regular","bold","italic","boldItalic"]){const c=b(i,d);if(!c)continue;const h=c.getAttribute("r:id")||c.getAttribute("id"),u=n?.[h];u&&(a.push(u.fullPath),l[d]=!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 oo(e){if(!e)return"sans-serif";if(e==="+mj-lt"||e==="+mj")return"serif";if(e==="+mn-lt"||e==="+mn")return"sans-serif";if(xt.has(e))return e;const n=e.toLowerCase().trim(),t=lt[n];return t?t._custom||t.google===null?e:t.google&&Ns(t.google)?t.google:t.google||e:e}function ao(e){if(!e)return"sans-serif";const n=e.toLowerCase().trim();return lt[n]?.generic??"sans-serif"}async function lo(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"||xt.has(o))continue;const l=o.toLowerCase().trim(),a=lt[l];let d=null,c=[400,700];if(a){if(a._custom||a.google===null)continue;d=a.google,c=a.weights.length?a.weights:[400,700]}else d=o;if(!d||Ut.has(d))continue;if(Ns(d)){Ut.add(d);continue}const h=s.get(d)??new Set;c.forEach(u=>h.add(u)),s.set(d,h)}if(s.size===0)return;for(const o of s.keys())Ut.add(o);const r=`https://fonts.googleapis.com/css2?${[...s.entries()].map(([o,l])=>{const a=[...l].sort((c,h)=>c-h),d=[...a.map(c=>`0,${c}`),...a.map(c=>`1,${c}`)].join(";");return`family=${encodeURIComponent(`${o}:ital,wght@${d}`)}`}).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 co(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 Ms(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"),x=n.getAttribute("i");y==="1"?l=!0:y==="0"&&(l=!1),x==="1"?a=!0:x==="0"&&(a=!1)}if(e){const y=e.getAttribute("b"),x=e.getAttribute("i");y==="1"?l=!0:y==="0"&&(l=!1),x==="1"?a=!0:x==="0"&&(a=!1)}let d=s?.minorFont??"Calibri";function c(y){if(!y)return;const x=b(y,"latin"),w=x?x.getAttribute("typeface"):y.getAttribute("typeface");if(w){if(w==="+mj-lt"||w==="+mj"){d=s?.majorFont??d;return}if(w==="+mn-lt"||w==="+mn"){d=s?.minorFont??d;return}d=w}}c(r),c(n),c(e);const h=oo(d),u=ao(d),g=o*127*t;return{fontStr:`${a?"italic ":""}${l?"bold":"normal"} ${g}px "${h}", ${u}`,sz:o,szPx:g,bold:l,italic:a,family:h,generic:u,rawFamily:d}}function uo(){const e=[];for(const[n,t]of xt)for(const s of t)e.push({family:n,weight:s.weight,style:s.style,status:s.status});return e}function Et(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 Ke(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 fo={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 ho(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 d=a/1e5,c=Qe(t,s,i),h=Ke(c.h,ze(c.l*d,0,1),c.s);t=h.r,s=h.g,i=h.b;break}case"lumOff":{const d=a/1e5,c=Qe(t,s,i),h=Ke(c.h,ze(c.l+d,0,1),c.s);t=h.r,s=h.g,i=h.b;break}case"tint":{const d=a/1e5;t=Math.round(t+(255-t)*(1-d)),s=Math.round(s+(255-s)*(1-d)),i=Math.round(i+(255-i)*(1-d));break}case"shade":{const d=a/1e5;t=Math.round(t*d),s=Math.round(s*d),i=Math.round(i*d);break}case"satMod":{const d=a/1e5,c=Qe(t,s,i),h=Ke(c.h,c.l,ze(c.s*d,0,1));t=h.r,s=h.g,i=h.b;break}case"satOff":{const d=a/1e5,c=Qe(t,s,i),h=Ke(c.h,c.l,ze(c.s+d,0,1));t=h.r,s=h.g,i=h.b;break}case"hueMod":{const d=a/1e5,c=Qe(t,s,i),h=Ke(c.h*d%1,c.l,c.s);t=h.r,s=h.g,i=h.b;break}case"hueOff":{const d=a/216e5,c=Qe(t,s,i),h=Ke(((c.h+d)%1+1)%1,c.l,c.s);t=h.r,s=h.g,i=h.b;break}case"alpha":{r=a/1e5;break}case"alphaOff":{r=ze(r+a/1e5,0,1);break}case"alphaMod":{r=ze(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 d=Qe(t,s,i),c=Ke((d.h+.5)%1,d.l,d.s);t=c.r,s=c.g,i=c.b;break}}}return{r:ze(t,0,255),g:ze(s,0,255),b:ze(i,0,255),a:r}}function we(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=Et(r))}else if(t==="schemeClr"){const o=e.getAttribute("val")||"",l=n?.[o];l?s=Et(l):s={r:0,g:0,b:0}}else if(t==="prstClr"){const r=(e.getAttribute("val")||"").toLowerCase(),o=fo[r];o&&(s=Et(o))}else if(t==="sysClr"){const r=e.getAttribute("lastClr");r?.length>=6?s=Et(r):s={r:0,g:0,b:0}}else if(t==="hslClr"){const r=F(e,"hue",0)/216e5,o=F(e,"sat",0)/1e5,l=F(e,"lum",0)/1e5;s=Ke(r,l,o)}else if(t==="scRgbClr"){const r=F(e,"r",0)/1e5,o=F(e,"g",0)/1e5,l=F(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?ho({...s,a:i},e):null}function me(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 be(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 Vn(e,n){if(!e)return null;const t=b(e,"solidFill");if(!t)return null;const s=be(t),i=we(s,n);return i?me(i):null}function po(e,n,t){const s=Vn(e,t);return s||Vn(n,t)}function Vt(e,n,t,s,i,r,o){const l=u=>u*Math.PI/180,a=(u,g=5e4)=>(o&&o[u]!==void 0?o[u]:g)/1e5,d=t+i/2,c=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(d,c,i/2,r/2,0,0,Math.PI*2);break;case"triangle":case"isoscelesTriangle":e.moveTo(d,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),g=i*u;e.moveTo(t+g,s),e.lineTo(t+i,s),e.lineTo(t+i-g,s+r),e.lineTo(t,s+r),e.closePath();break}case"trapezoid":{const u=a(0,25e3),g=i*u;e.moveTo(t+g,s),e.lineTo(t+i-g,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break}case"diamond":e.moveTo(d,s),e.lineTo(t+i,c),e.lineTo(d,s+r),e.lineTo(t,c),e.closePath();break;case"pentagon":ot(e,d,c,i/2,r/2,5,-Math.PI/2);break;case"hexagon":ot(e,d,c,i/2,r/2,6,0);break;case"heptagon":ot(e,d,c,i/2,r/2,7,-Math.PI/2);break;case"octagon":ot(e,d,c,i/2,r/2,8,Math.PI/8);break;case"decagon":ot(e,d,c,i/2,r/2,10,-Math.PI/2);break;case"dodecagon":ot(e,d,c,i/2,r/2,12,0);break;case"plus":case"cross":{const u=a(0,25e3),g=h*u,p=d-g/2,m=d+g/2,S=c-g/2,y=c+g/2;e.moveTo(p,s),e.lineTo(m,s),e.lineTo(m,S),e.lineTo(t+i,S),e.lineTo(t+i,y),e.lineTo(m,y),e.lineTo(m,s+r),e.lineTo(p,s+r),e.lineTo(p,y),e.lineTo(t,y),e.lineTo(t,S),e.lineTo(p,S),e.closePath();break}case"star4":Ee(e,d,c,i/2,r/2,4,a(0,37500));break;case"star5":Ee(e,d,c,i/2,r/2,5,a(0,19098),-Math.PI/2);break;case"star6":Ee(e,d,c,i/2,r/2,6,a(0,28868),0);break;case"star7":Ee(e,d,c,i/2,r/2,7,a(0,34601),-Math.PI/2);break;case"star8":Ee(e,d,c,i/2,r/2,8,a(0,29289),Math.PI/8);break;case"star10":Ee(e,d,c,i/2,r/2,10,a(0,30902),-Math.PI/2);break;case"star12":Ee(e,d,c,i/2,r/2,12,a(0,37720),0);break;case"star16":Ee(e,d,c,i/2,r/2,16,a(0,37500),0);break;case"star24":Ee(e,d,c,i/2,r/2,24,a(0,37500),0);break;case"star32":Ee(e,d,c,i/2,r/2,32,a(0,37500),0);break;case"rightArrow":{const u=a(0,5e4),g=a(1,5e4),p=(r-r*g)/2,m=t+i*(1-u);e.moveTo(t,s+p),e.lineTo(m,s+p),e.lineTo(m,s),e.lineTo(t+i,c),e.lineTo(m,s+r),e.lineTo(m,s+r-p),e.lineTo(t,s+r-p),e.closePath();break}case"leftArrow":{const u=a(0,5e4),g=a(1,5e4),p=(r-r*g)/2,m=t+i*u;e.moveTo(t+i,s+p),e.lineTo(m,s+p),e.lineTo(m,s),e.lineTo(t,c),e.lineTo(m,s+r),e.lineTo(m,s+r-p),e.lineTo(t+i,s+r-p),e.closePath();break}case"upArrow":{const u=a(0,5e4),g=a(1,5e4),p=(i-i*g)/2,m=s+r*u;e.moveTo(t+p,s+r),e.lineTo(t+p,m),e.lineTo(t,m),e.lineTo(d,s),e.lineTo(t+i,m),e.lineTo(t+i-p,m),e.lineTo(t+i-p,s+r),e.closePath();break}case"downArrow":{const u=a(0,5e4),g=a(1,5e4),p=(i-i*g)/2,m=s+r*(1-u);e.moveTo(t+p,s),e.lineTo(t+p,m),e.lineTo(t,m),e.lineTo(d,s+r),e.lineTo(t+i,m),e.lineTo(t+i-p,m),e.lineTo(t+i-p,s),e.closePath();break}case"leftRightArrow":{const u=a(0,25e3),g=a(1,5e4),p=(r-r*g)/2,m=t+i*u,S=t+i*(1-u);e.moveTo(t,c),e.lineTo(m,s),e.lineTo(m,s+p),e.lineTo(S,s+p),e.lineTo(S,s),e.lineTo(t+i,c),e.lineTo(S,s+r),e.lineTo(S,s+r-p),e.lineTo(m,s+r-p),e.lineTo(m,s+r),e.closePath();break}case"upDownArrow":{const u=a(0,25e3),g=a(1,5e4),p=(i-i*g)/2,m=s+r*u,S=s+r*(1-u);e.moveTo(d,s),e.lineTo(t+i,m),e.lineTo(t+i-p,m),e.lineTo(t+i-p,S),e.lineTo(t+i,S),e.lineTo(d,s+r),e.lineTo(t,S),e.lineTo(t+p,S),e.lineTo(t+p,m),e.lineTo(t,m),e.closePath();break}case"chevron":{const u=a(0,5e4),g=i*u;e.moveTo(t,s),e.lineTo(t+i-g,s),e.lineTo(t+i,c),e.lineTo(t+i-g,s+r),e.lineTo(t,s+r),e.lineTo(t+g,c),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,c),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,g=a(1,288e5/6e4)*Math.PI/180;e.moveTo(d,c),e.arc(d,c,Math.min(i,r)/2,u,u+g),e.closePath();break}case"blockArc":{const u=(a(0,0)*360-90)*Math.PI/180,g=a(1,25e3)*360*Math.PI/180,p=a(2,25e3)*Math.min(i,r)/2,m=Math.min(i,r)/2,S=m-p;e.moveTo(d+m*Math.cos(u),c+m*Math.sin(u)),e.arc(d,c,m,u,u+g),e.arc(d,c,Math.max(1,S),u+g,u,!0),e.closePath();break}case"line":case"straightConnector1":e.moveTo(t,c),e.lineTo(t+i,c);break;case"bentConnector3":case"bentConnector4":case"bentConnector5":case"elbowConnector":e.moveTo(t,s),e.lineTo(t,c),e.lineTo(t+i,c),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":{go(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(d+i*.1,c,r*.5,l(-120),l(120)),e.arc(d+i*.4,c,r*.45,l(120),l(-120),!0),e.closePath();break}case"noSmoking":{const u=Math.min(i,r)/2;e.arc(d,c,u,0,Math.PI*2),e.moveTo(d-u*.7,c+u*.7),e.lineTo(d+u*.7,c-u*.7);break}case"flowChartProcess":e.rect(t,s,i,r);break;case"flowChartDecision":e.moveTo(d,s),e.lineTo(t+i,c),e.lineTo(d,s+r),e.lineTo(t,c),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,c,u,-Math.PI/2,Math.PI/2),e.lineTo(t+u,s+r),e.arc(t+u,c,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(d,s+u,i/2,u,0,Math.PI,0),e.lineTo(t+i,s+r-u),e.ellipse(d,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(d-i*.1,s+r*.8),e.lineTo(d,s+r),e.lineTo(d+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(d+i*.1,s+r*.75),e.lineTo(d,s+r),e.lineTo(d-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(d,c-r*.05,i/2,r*.45,0,0,Math.PI*2),e.moveTo(d-i*.1,c+r*.4),e.lineTo(d,s+r),e.lineTo(d+i*.1,c+r*.4),e.closePath();break}case"cloudCallout":case"cloud":{e.beginPath();const u=[{cx:d-i*.22,cy:c-r*.12,r:i*.16},{cx:d-i*.07,cy:c-r*.22,r:i*.18},{cx:d+i*.1,cy:c-r*.22,r:i*.17},{cx:d+i*.25,cy:c-r*.12,r:i*.15},{cx:d+i*.35,cy:c+r*.05,r:i*.13},{cx:d-i*.3,cy:c+r*.05,r:i*.13}];for(const g of u)e.arc(g.cx,g.cy,g.r,0,Math.PI*2);e.rect(d-i*.35,c,i*.7,r*.25);break}case"smileyFace":{e.arc(d,c,Math.min(i,r)/2,0,Math.PI*2);break}case"donut":{const u=Math.min(i,r)/2,g=u*a(0,25e3);e.arc(d,c,u,0,Math.PI*2),e.arc(d,c,g,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(d-i*.35,s),e.bezierCurveTo(d-i*.45,s,d-i*.45,s,d-i*.45,s+u),e.lineTo(d-i*.45,c-u),e.bezierCurveTo(d-i*.45,c,d-i*.5,c,d-i*.5,c),e.bezierCurveTo(d-i*.5,c,d-i*.45,c,d-i*.45,c+u),e.lineTo(d-i*.45,s+r-u),e.bezierCurveTo(d-i*.45,s+r,d-i*.35,s+r,d-i*.35,s+r);break}case"irregularSeal1":case"irregularSeal2":{Ee(e,d,c,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(d,c,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,c),e.lineTo(t+i-u,s+r),e.lineTo(t+u,s+r),e.lineTo(t,c),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(d,c,i/2,r/2,0,0,Math.PI*2);break}case"teardrop":{const u=Math.min(i,r)*.45;e.arc(d,c+u,u,-Math.PI,0),e.bezierCurveTo(d+u,c+u-u*.55,d+u*.1,c-r*.4,d,s),e.bezierCurveTo(d-u*.1,c-r*.4,d-u,c+u-u*.55,d-u,c+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,d=n+s*Math.cos(a),c=t+i*Math.sin(a);l===0?e.moveTo(d,c):e.lineTo(d,c)}e.closePath()}function Ee(e,n,t,s,i,r,o=.5,l=-Math.PI/2){for(let a=0;a<r*2;a++){const d=l+a/(r*2)*Math.PI*2,c=a%2===1,h=c?s*o:s,u=c?i*o:i,g=n+h*Math.cos(d),p=t+u*Math.sin(d);a===0?e.moveTo(g,p):e.lineTo(g,p)}e.closePath()}function go(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 Hn=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0","#FF7F00","#9E480E"];function mo(e){const n=e?.textContent?.trim();if(n==null||n==="")return null;const t=parseFloat(n);return isNaN(t)?n:t}function yt(e){if(!e)return[];const n=F(b(e,"ptCount"),"val",0),t=new Array(n).fill(null);for(const s of de(e,"pt")){const i=F(s,"idx",0);t[i]=mo(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 nn(e){const n=b(e,"cat")||b(e,"xVal");return n?yt(b(n,"strCache")||b(n,"numCache")):[]}function Ft(e){const n=b(e,"val")||b(e,"yVal");return n?yt(b(n,"numCache")):[]}function tt(e,n,t){const s=b(e,"spPr");if(s){const r=b(s,"solidFill");if(r){const o=be(r),l=we(o,t);if(l)return me(l)}}const i=`accent${n%6+1}`;return t[i]?`#${t[i]}`:Hn[n%Hn.length]}function As(e,n){const t={};for(const s of de(e,"dPt")){const i=F(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=be(o),a=we(l,n);a&&(t[i]=me(a))}return t}function sn(e,n,t,s,i={}){const{padL:r=.12,padR:o=.06,padT:l=.08,padB:a=.1,legendH:d=.1,hasLegend:c=!0,hasTitle:h=!1}=i,u=h?s*.08:0,g=c?s*d:0;return{x:e+t*r,y:n+s*l+u,w:t*(1-r-o),h:s*(1-l-a)-g-u,legendY:n+s*(1-d*.7)}}function kt(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 Re(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 $s(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 _t(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=$s(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 d=0;d<r.length;d++){if(!r[d].name)continue;const c=n+a*d+l*.5;e.fillStyle=r[d].color,kt(e,c,i-l/2,l*1.2,l),e.fill(),e.fillStyle="#444",e.fillText(r[d].name,c+l*1.5,i)}e.restore()}function bo(e,n,t,s,i,r,o,l){const a=b(n,"barChart")||b(n,"bar3DChart"),d=!a||G(a,"barDir","col")!=="bar",c=G(a,"grouping","clustered"),h=c==="stacked"||c==="percentStacked",u=c==="percentStacked",g=de(a,"ser"),p=g.map((_,T)=>({name:Ct(_),values:Ft(_),color:tt(_,T,o),dptColors:As(_,o)}));if(!p.length)return;const m=nn(g[0])||[],S=Math.max(m.length,p[0]?.values.length||0,1),y=sn(t,s,i,r,{hasLegend:p.length>1});let x;h?(x=Array.from({length:S},(_,T)=>p.reduce((N,M)=>N+(M.values[T]||0),0)),u&&(x=x.map(()=>100))):x=p.flatMap(_=>_.values);const w=_t(x),k=Math.max(7,Math.min(11,y.w*.018))*l;e.font=`${k}px sans-serif`,e.textBaseline="middle";const v=Math.round((w.max-w.min)/w.step);if(d){e.save(),e.textAlign="right",e.fillStyle="#666";for(let j=0;j<=v;j++){const $=w.min+j*w.step,I=($-w.min)/(w.max-w.min),L=y.y+y.h-I*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 _=y.w/S;for(let j=0;j<S;j++){const $=y.x+_*j+_/2,I=String(m[j]??j+1);e.fillText(I,$,y.y+y.h+k*1.5)}e.restore(),Re(e,y.x,y.y,y.x,y.y+y.h),Re(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h);const T=y.w/S,N=T*.15,M=T-N*2,C=h?M:M/p.length;for(let j=0;j<S;j++){const $=y.x+T*j+N;let I=0;for(let L=0;L<p.length;L++){const Y=p[L];let W=Y.values[j]??0;if(u){const fe=p.reduce((ae,se)=>ae+(se.values[j]||0),0);W=fe?W/fe*100:0}const B=Y.dptColors[j]||Y.color,K=Math.abs(W)/(w.max-w.min)*y.h,Q=h?$:$+L*C,O=h?(I-w.min)/(w.max-w.min):Math.max(0,-w.min)/(w.max-w.min),z=y.y+y.h-O*y.h,X=W>=0?z-K:z;e.save(),e.fillStyle=B,kt(e,Q,X,h?M:C-1*l,K,2*l),e.fill();const ie=e.createLinearGradient(Q,X,Q,X+K*.3);ie.addColorStop(0,"rgba(255,255,255,0.18)"),ie.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=ie,e.fill(),e.restore(),h&&(I+=Math.abs(W))}}}else{e.save(),e.textAlign="right",e.fillStyle="#666";const _=y.h/S;for(let j=0;j<S;j++){const $=y.y+_*j+_/2,I=String(m[j]??j+1);e.fillText(I,y.x-4*l,$)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";for(let j=0;j<=v;j++){const $=w.min+j*w.step,I=($-w.min)/(w.max-w.min),L=y.x+I*y.w;nt(e,L,y.y,L,y.y+y.h),e.fillText(u?$+"%":st($),L,y.y+y.h+k*1.5)}e.restore(),Re(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h),Re(e,y.x,y.y,y.x,y.y+y.h);const T=_*.15,N=_-T*2,M=h?N:N/p.length,C=y.x+-w.min/(w.max-w.min)*y.w;for(let j=0;j<S;j++){const $=y.y+_*j+T;let I=0;for(let L=0;L<p.length;L++){const Y=p[L];let W=Y.values[j]??0;if(u){const X=p.reduce((ie,fe)=>ie+(fe.values[j]||0),0);W=X?W/X*100:0}const B=Y.dptColors[j]||Y.color,K=Math.abs(W)/(w.max-w.min)*y.w,Q=h?$:$+L*M,O=h?C+I/(w.max-w.min)*y.w:C,z=W>=0?O:O-K;e.save(),e.fillStyle=B,kt(e,z,Q,K,h?N:M-1*l,2*l),e.fill(),e.restore(),h&&(I+=Math.abs(W))}}}p.length>1&&Nt(e,t,s,i,y.legendY,p,l)}function yo(e,n,t,s,i,r,o,l){const a=b(n,"lineChart")||b(n,"line3DChart"),d=de(a,"ser"),c=d.map((y,x)=>({name:Ct(y),values:Ft(y),color:tt(y,x,o),marker:G(b(y,"marker"),"symbol","none")!=="none",smooth:G(b(y,"smooth"),"val","0")==="1"}));if(!c.length)return;const h=nn(d[0])||[],u=Math.max(h.length,c[0]?.values.length||0,1),g=sn(t,s,i,r,{hasLegend:!0}),p=_t(c.flatMap(y=>y.values)),m=Math.max(7,Math.min(11,g.w*.018))*l,S=Math.round((p.max-p.min)/p.step);e.save(),e.textAlign="right",e.fillStyle="#666",e.font=`${m}px sans-serif`;for(let y=0;y<=S;y++){const x=p.min+y*p.step,w=(x-p.min)/(p.max-p.min),k=g.y+g.h-w*g.h;nt(e,g.x,k,g.x+g.w,k),e.fillText(st(x),g.x-4*l,k)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666",e.font=`${m}px sans-serif`;for(let y=0;y<u;y++){const x=g.x+y/(u-1||1)*g.w;nt(e,x,g.y,x,g.y+g.h);const w=String(h[y]??y+1);e.fillText(w,x,g.y+g.h+m*1.5)}e.restore(),Re(e,g.x,g.y,g.x,g.y+g.h),Re(e,g.x,g.y+g.h,g.x+g.w,g.y+g.h);for(const y of c){const x=y.values.map((k,v)=>{const _=u>1?v/(u-1):.5,T=(k-p.min)/(p.max-p.min);return{x:g.x+_*g.w,y:g.y+g.h-T*g.h,v:k}}).filter(k=>typeof k.v=="number");if(x.length<2)continue;e.save(),e.beginPath(),e.moveTo(x[0].x,g.y+g.h);for(const k of x)e.lineTo(k.x,k.y);if(e.lineTo(x[x.length-1].x,g.y+g.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&&x.length>2){e.moveTo(x[0].x,x[0].y);for(let k=1;k<x.length-1;k++){const v=(x[k].x+x[k+1].x)/2,_=(x[k].y+x[k+1].y)/2;e.quadraticCurveTo(x[k].x,x[k].y,v,_)}e.lineTo(x[x.length-1].x,x[x.length-1].y)}else{e.moveTo(x[0].x,x[0].y);for(const k of x.slice(1))e.lineTo(k.x,k.y)}e.stroke(),e.restore();const w=3.5*l;for(const k of x)e.save(),e.fillStyle=y.color,e.strokeStyle="#fff",e.lineWidth=1.5*l,e.beginPath(),e.arc(k.x,k.y,w,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}Nt(e,t,s,i,g.legendY,c,l)}function vo(e,n,t,s,i,r,o,l){const a=b(n,"areaChart")||b(n,"area3DChart"),d=G(a,"grouping","standard"),c=d==="percentStacked",h=d==="stacked"||c,g=de(a,"ser").map((v,_)=>({name:Ct(v),values:Ft(v),color:tt(v,_,o)})).reverse();if(!g.length)return;const p=Math.max(...g.map(v=>v.values.length),1),m=sn(t,s,i,r,{hasLegend:!0});let S=0;if(c)S=100;else for(let v=0;v<p;v++){const _=g.reduce((T,N)=>T+(N.values[v]||0),0);S=Math.max(S,_)}const y={min:0,max:S||100,step:$s(S||100)},x=Math.round((y.max-y.min)/y.step),w=Math.max(7,Math.min(11,m.w*.018))*l;e.save(),e.font=`${w}px sans-serif`,e.textAlign="right",e.fillStyle="#666";for(let v=0;v<=x;v++){const _=y.min+v*y.step,T=(_-y.min)/(y.max-y.min),N=m.y+m.h-T*m.h;nt(e,m.x,N,m.x+m.w,N),e.fillText(c?_+"%":st(_),m.x-4*l,N)}e.restore(),Re(e,m.x,m.y,m.x,m.y+m.h),Re(e,m.x,m.y+m.h,m.x+m.w,m.y+m.h);const k=new Array(p).fill(0);for(const v of g){e.save(),e.beginPath();const _=[];for(let T=0;T<p;T++){let N=v.values[T]??0;if(c){const L=g.reduce((Y,W)=>Y+(W.values[T]||0),0);N=L?N/L*100:0}const M=h?k[T]:0,C=M+Math.abs(N),j=(M-y.min)/(y.max-y.min),$=(C-y.min)/(y.max-y.min),I=m.x+T/(p-1||1)*m.w;_.push({x:I,y:m.y+m.h-$*m.h,baseY:m.y+m.h-j*m.h}),h&&(k[T]+=Math.abs(N))}e.moveTo(_[0].x,_[0].baseY);for(const T of _)e.lineTo(T.x,T.baseY);for(let T=_.length-1;T>=0;T--)e.lineTo(_[T].x,_[T].y);e.closePath(),e.fillStyle=v.color+"cc",e.fill(),e.beginPath(),e.moveTo(_[0].x,_[0].y);for(const T of _.slice(1))e.lineTo(T.x,T.y);e.strokeStyle=v.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}Nt(e,t,s,i,m.legendY,[...g].reverse(),l)}function Yn(e,n,t,s,i,r,o,l){const a=b(n,"pieChart")||b(n,"pie3DChart"),d=b(n,"doughnutChart"),c=a||d,h=!!d,u=de(c,"ser");if(!u.length)return;const g=u[0],p=Ft(g).map(j=>typeof j=="number"&&j>0?j:0),m=nn(g),S=As(g,o),y=p.reduce((j,$)=>j+$,0);if(!y)return;const x=Math.min(i,r)*.38,w=t+i*.44,k=s+r*.5,v=h?x*.55:0;let _=-Math.PI/2;for(let j=0;j<p.length;j++){if(!p[j])continue;const $=p[j]/y*Math.PI*2,I=S[j]||tt(g,j,o),L=_+$/2,Y=j===0?x*.04:0,W=Y*Math.cos(L),B=Y*Math.sin(L);e.save(),e.beginPath(),e.moveTo(w+W,k+B),e.arc(w+W,k+B,x,_,_+$),e.closePath(),e.fillStyle=I,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(w,k,v,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.restore());const K=p[j]/y;if(K>.05){const Q=w+W+x*.65*Math.cos(L),O=k+B+x*.65*Math.sin(L),z=Math.max(8,Math.min(13,x*.15))*l;e.save(),e.fillStyle="#fff",e.font=`bold ${z}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(Math.round(K*100)+"%",Q,O),e.restore()}_+=$}if(h){const j=Math.max(10,Math.min(16,x*.22))*l;e.save(),e.font=`bold ${j}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="middle",e.fillText(st(y),w,k),e.restore()}const T=t+i*.78,N=Math.max(8,Math.min(12,i*.022))*l;e.font=`${N}px sans-serif`,e.textBaseline="middle";const M=N*1.8,C=k-p.length*M/2;for(let j=0;j<p.length;j++){const $=T,I=C+j*M,L=S[j]||tt(g,j,o);e.fillStyle=L,kt(e,$,I-N*.5,N*1.2,N),e.fill(),e.fillStyle="#444";const Y=String(m[j]??`Item ${j+1}`);e.fillText(Y,$+N*1.5,I)}}function wo(e,n,t,s,i,r,o,l){const a=b(n,"scatterChart")||b(n,"bubbleChart"),c=de(a,"ser").map((_,T)=>{const N=yt(b(b(_,"xVal"),"numCache")),M=yt(b(b(_,"yVal"),"numCache")),C=yt(b(b(_,"bubbleSize"),"numCache"));return{name:Ct(_),color:tt(_,T,o),points:N.map((j,$)=>({x:j,y:M[$],r:C[$]})).filter(j=>typeof j.x=="number"&&typeof j.y=="number")}});if(!c.length)return;const h=sn(t,s,i,r,{hasLegend:c.length>1}),u=c.flatMap(_=>_.points.map(T=>T.x)),g=c.flatMap(_=>_.points.map(T=>T.y)),p=_t(u,!1),m=_t(g),S=Math.max(7,Math.min(11,h.w*.018))*l,y=Math.round((p.max-p.min)/p.step),x=Math.round((m.max-m.min)/m.step);e.font=`${S}px sans-serif`,e.save(),e.textAlign="center",e.fillStyle="#666";for(let _=0;_<=y;_++){const T=p.min+_*p.step,N=(T-p.min)/(p.max-p.min),M=h.x+N*h.w;nt(e,M,h.y,M,h.y+h.h),e.fillText(st(T),M,h.y+h.h+S*1.5)}e.textAlign="right";for(let _=0;_<=x;_++){const T=m.min+_*m.step,N=(T-m.min)/(m.max-m.min),M=h.y+h.h-N*h.h;nt(e,h.x,M,h.x+h.w,M),e.fillText(st(T),h.x-4*l,M)}e.restore(),Re(e,h.x,h.y,h.x,h.y+h.h),Re(e,h.x,h.y+h.h,h.x+h.w,h.y+h.h);const w=c.flatMap(_=>_.points.map(T=>T.r??1)),k=Math.max(...w.filter(_=>typeof _=="number"),1),v=Math.min(h.w,h.h)*.06;for(const _ of c)for(const T of _.points){const N=h.x+(T.x-p.min)/(p.max-p.min)*h.w,M=h.y+h.h-(T.y-m.min)/(m.max-m.min)*h.h,C=T.r!=null?T.r/k*v:4*l;e.save(),e.fillStyle=_.color+"aa",e.strokeStyle=_.color,e.lineWidth=1*l,e.beginPath(),e.arc(N,M,C,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}c.length>1&&Nt(e,t,s,i,h.legendY,c,l)}function xo(e,n,t,s,i,r,o,l){const a=b(n,"radarChart"),d=de(a,"ser"),c=d.map((x,w)=>({name:Ct(x),values:Ft(x),color:tt(x,w,o)}));if(!c.length)return;const h=nn(d[0])||[],u=h.length||c[0]?.values.length||0;if(u<3)return;const g=t+i*.5,p=s+r*.5,m=Math.min(i,r)*.34,S=_t(c.flatMap(x=>x.values)),y=4;for(let x=1;x<=y;x++){const w=m*x/y;e.save(),e.beginPath();for(let k=0;k<u;k++){const v=k/u*Math.PI*2-Math.PI/2,_=g+w*Math.cos(v),T=p+w*Math.sin(v);k===0?e.moveTo(_,T):e.lineTo(_,T)}e.closePath(),e.strokeStyle="rgba(0,0,0,0.12)",e.lineWidth=.5,e.stroke(),e.restore()}for(let x=0;x<u;x++){const w=x/u*Math.PI*2-Math.PI/2;Re(e,g,p,g+m*Math.cos(w),p+m*Math.sin(w));const k=g+(m+16*l)*Math.cos(w),v=p+(m+16*l)*Math.sin(w);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[x]??x+1),k,v),e.restore()}for(const x of c){const w=x.values.map((k,v)=>{const _=v/u*Math.PI*2-Math.PI/2,T=(k-S.min)/(S.max-S.min);return{x:g+m*T*Math.cos(_),y:p+m*T*Math.sin(_)}});e.save(),e.beginPath(),e.moveTo(w[0].x,w[0].y);for(const k of w.slice(1))e.lineTo(k.x,k.y);e.closePath(),e.fillStyle=x.color+"44",e.fill(),e.strokeStyle=x.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}Nt(e,t,s,i,s+r-20*l,c,l)}function ko(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 c of de(l,"t"))a+=c.textContent;if(!a.trim())return!1;const d=Math.max(10,Math.min(16,i*.03))*r;return e.save(),e.font=`bold ${d}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 _o(e,n,t,s,i,r,o,l){if(!n)return;const a=n;e.save(),e.fillStyle="#fff",kt(e,t,s,i,r,4*l),e.fill(),e.strokeStyle="#ddd",e.lineWidth=.5,e.stroke(),e.restore();const c=ko(e,a,t,s,i,l)?s+Math.min(r*.08,24*l):s,h=r-(c-s),u=b(a,"plotArea");if(!u)return;const g=b(u,"bar3DChart")||b(u,"barChart"),p=b(u,"line3DChart")||b(u,"lineChart"),m=b(u,"area3DChart")||b(u,"areaChart"),S=b(u,"pie3DChart")||b(u,"pieChart"),y=b(u,"doughnutChart"),x=b(u,"scatterChart")||b(u,"bubbleChart"),w=b(u,"radarChart");if(g)bo(e,u,t,c,i,h,o,l);else if(p)yo(e,u,t,c,i,h,o,l);else if(m)vo(e,u,t,c,i,h,o,l);else if(y)Yn(e,u,t,c,i,h,o,l);else if(S)Yn(e,u,t,c,i,h,o,l);else if(x)wo(e,u,t,c,i,h,o,l);else if(w)xo(e,u,t,c,i,h,o,l);else{e.save(),e.fillStyle="#aaa",e.font=`${12*l}px sans-serif`,e.textAlign="center",e.textBaseline="middle";const k=u.firstElementChild;e.fillText(k?.localName??"Chart",t+i/2,s+r/2),e.restore()}}function Ht(e,n,t=0,s=1){return(e?parseInt(e.getAttribute(n)||t,10):t)*s}function Es(e,n){if(!e)return null;const t=be(e);if(!t)return null;const s=we(t,n);return s?me(s):null}function So(e,n,t,s,i,r,o){const l=b(n,"bevelT"),a=b(n,"bevelB"),d=l||a;if(!d)return;const c=Math.max(2*o,Ht(d,"w",76200,o)),h=Math.max(2*o,Ht(d,"h",76200,o)),g=G(d,"prst","circle").toLowerCase().includes("in"),p=Math.min(c,i*.3),m=Math.min(h,r*.3),S=g?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.35)",y=g?"rgba(255,255,255,0.20)":"rgba(0,0,0,0.20)",x=e.createLinearGradient(t,s,t,s+m);x.addColorStop(0,S),x.addColorStop(1,"rgba(255,255,255,0)"),e.save(),e.fillStyle=x,e.fillRect(t,s,i,m);const w=e.createLinearGradient(t,s+r-m,t,s+r);w.addColorStop(0,"rgba(0,0,0,0)"),w.addColorStop(1,y),e.fillStyle=w,e.fillRect(t,s+r-m,i,m);const k=e.createLinearGradient(t,s,t+p,s);k.addColorStop(0,S),k.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=k,e.fillRect(t,s,p,r);const v=e.createLinearGradient(t+i-p,s,t+i,s);v.addColorStop(0,"rgba(0,0,0,0)"),v.addColorStop(1,y),e.fillStyle=v,e.fillRect(t+i-p,s,p,r),e.restore()}function Po(e,n,t,s,i,r,o,l){const a=Ht(n,"extrusionH",0,l);if(a<1*l)return;const d=b(n,"extrusionClr")||b(n,"contourClr"),c=Es(d,t)||"rgba(0,0,0,0.3)",h=Math.min(a/914400*72*l,Math.min(r,o)*.15),u=h*.7,g=h*.7;e.save(),e.fillStyle=c,e.beginPath(),e.moveTo(s+r,i),e.lineTo(s+r+u,i+g),e.lineTo(s+r+u,i+o+g),e.lineTo(s+r,i+o),e.closePath(),e.fill(),e.beginPath(),e.moveTo(s,i+o),e.lineTo(s+u,i+o+g),e.lineTo(s+r+u,i+o+g),e.lineTo(s+r,i+o),e.closePath(),e.fill(),e.restore()}function To(e,n,t,s,i,r,o,l){const a=Ht(n,"contourW",0,l);if(a<.5)return;const d=b(n,"contourClr"),c=Es(d,t)||"#888888",h=Math.max(.5,a/914400*72*l);e.save(),e.strokeStyle=c,e.lineWidth=h,e.strokeRect(s,i,r,o),e.restore()}function jo(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 c=a?F(a,"lat",0)/6e4:0,h=a?F(a,"lon",0)/6e4:0;a&&F(a,"rev",0)/6e4;const u=c*Math.PI/180,g=h*Math.PI/180,p=Math.sin(g)*.15,m=Math.sin(u)*.08;return e.save(),e.transform(1,m,p,1,t*-p,s*-m),()=>e.restore()}function Co(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"),d={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:c,gy:h}=d[l]||d.t,u=a==="flat"?.08:a==="balanced"?.14:a==="sunrise"?.2:a==="harsh"?.28:.12,g=Math.sqrt(i*i+r*r),p=e.createRadialGradient(c,h,0,c,h,g);p.addColorStop(0,`rgba(255,255,255,${u})`),p.addColorStop(.5,"rgba(255,255,255,0)"),p.addColorStop(1,`rgba(0,0,0,${u*.5})`),e.save(),e.fillStyle=p,e.fillRect(t,s,i,r),e.restore()}function Fo(e,n,t,s,i,r,o,l){if(!n)return{applyCamera:()=>()=>{},overlay:()=>{}};const a=b(n,"sp3d")||b(n,"scene3d")?.parentNode&&null,d=b(n,"scene3d");a&&Po(e,a,t,s,i,r,o,l);const c=jo(e,d,s,i);return{overlay(){a&&(So(e,a,s,i,r,o,l),To(e,a,t,s,i,r,o,l)),d&&Co(e,d,s,i,r,o)},cleanup:c}}function No(e){return e?!!(b(e,"sp3d")||b(e,"scene3d")):!1}async function St(e,n,t,s,i,r,o,l,a){if(!n)return!1;const d=n.localName;if(d==="noFill")return!1;if(d==="solidFill"){const c=be(n),h=we(c,l);return h?(e.fillStyle=me(h),e.fill(),!0):!1}if(d==="gradFill"){const c=b(n,"gsLst");if(!c)return!1;const h=de(c,"gs").map(y=>{const x=F(y,"pos",0)/1e5,w=be(y),k=we(w,l);return{pos:x,color:k}}).sort((y,x)=>y.pos-x.pos);if(h.length<2)return!1;const u=b(n,"lin"),g=b(n,"path"),p=t+i/2,m=s+r/2;let S;if(u||!u&&!g){const w=(F(u,"ang",0)/6e4-90)*Math.PI/180,k=Math.cos(w),v=Math.sin(w),_=Math.abs(i*k)+Math.abs(r*v),T=p-_/2*k,N=m-_/2*v,M=p+_/2*k,C=m+_/2*v;S=e.createLinearGradient(T,N,M,C)}else{const y=b(g,"fillToRect"),x=F(y,"l",5e4)/1e5,w=F(y,"t",5e4)/1e5,k=F(y,"r",5e4)/1e5,v=F(y,"b",5e4)/1e5,_=t+i*(x+(1-x-k)/2),T=s+r*(w+(1-w-v)/2),N=Math.sqrt(i*i+r*r)/2;S=e.createRadialGradient(_,T,0,p,m,N)}for(const y of h)y.color&&S.addColorStop(y.pos,me(y.color));return e.fillStyle=S,e.fill(),!0}if(d==="blipFill"){const c=b(n,"blip"),h=c?c.getAttribute("r:embed")||c.getAttribute("embed"):null;if(h&&a&&a[h]){const u=a[h],g=b(n,"stretch"),p=g?b(g,"fillRect"):null;let m=t,S=s,y=i,x=r;if(p){const _=F(p,"l",0)/1e5,T=F(p,"t",0)/1e5,N=F(p,"r",0)/1e5,M=F(p,"b",0)/1e5;m=t+i*_,S=s+r*T,y=i-i*_-i*N,x=r-r*T-r*M}if(b(n,"tile")){const _=e.createPattern(u,"repeat");if(_)return e.fillStyle=_,e.fill(),!0}const k=b(n,"alphaModFix")||b(c,"alphaModFix"),v=k?F(k,"amt",1e5)/1e5:1;return e.save(),e.clip(),v<1&&(e.globalAlpha=v),e.drawImage(u,m,S,y,x),e.restore(),!0}return!1}if(d==="pattFill"){const c=b(n,"fgClr"),h=b(n,"bgClr"),u=c?we(be(c),l):{r:0,g:0,b:0,a:1},g=h?we(be(h),l):{r:255,g:255,b:255,a:1},p=me(u),m=me(g),S=G(n,"prst","dotGrid");let y=null,x=null;try{x=typeof OffscreenCanvas<"u"?new OffscreenCanvas(8,8):document.createElement("canvas");const v=8;x.width=v,x.height=v,y=x.getContext("2d")}catch{}const w=8;if(!y)return e.fillStyle=me(u),e.fill(),!0;switch(y.fillStyle=m,y.fillRect(0,0,w,w),y.fillStyle=p,S){case"smGrid":case"dotGrid":case"dotDmnd":for(let v=0;v<w;v+=2)for(let _=0;_<w;_+=2)y.fillRect(v,_,1,1);break;case"lgGrid":case"cross":y.fillRect(0,0,w,1),y.fillRect(0,0,1,w);break;case"diagBd":case"fwdDiag":for(let v=0;v<w*2;v++)y.fillRect(v%w,Math.floor(v/w)*2,1,1);break;case"bkDiag":case"ltDnDiag":for(let v=0;v<w*2;v++)y.fillRect(w-1-v%w,Math.floor(v/w)*2,1,1);break;case"horzBrick":case"horz":y.fillRect(0,w/2,w,1);break;case"vert":case"vertBrick":y.fillRect(w/2,0,1,w);break;case"smCheck":case"lgCheck":for(let v=0;v<w;v++)for(let _=0;_<w;_++)(v+_)%2===0&&y.fillRect(_,v,1,1);break;default:for(let v=0;v<w;v+=4)y.fillRect(v,v,2,2)}const k=e.createPattern(x,"repeat");return k?(e.fillStyle=k,e.fill(),!0):(e.fillStyle=me(u,(u.a??1)*.4),e.fill(),!0)}return!1}async function Be(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 d of Array.from(l.getElementsByTagName("Relationship"))){const c=d.getAttribute("Id"),h=d.getAttribute("Target"),u=d.getAttribute("Type")||"",g=d.getAttribute("TargetMode")||"Internal";let p=h;if(g!=="External")if(h.startsWith("/"))p=h.slice(1);else{const m=n.split("/");m.pop();const S=h.split("/");for(const y of S)y===".."?m.pop():y!=="."&&m.push(y);p=m.join("/")}a[c]={target:h,fullPath:p,type:u,external:g==="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 d={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",c=new Blob([l],{type:d}),h=URL.createObjectURL(c),u=await new Promise((g,p)=>{const m=new Image;m.onload=()=>g(m),m.onerror=()=>g(null),m.src=h});t[i]=u}catch{}}return t}function Rs(e,n,t){if(!e)return n*1.2;const s=b(e,"spcPct"),i=b(e,"spcPts");return s?n*(F(s,"val",1e5)/1e5):i?F(i,"val",0)/100*12700*(t||1):n*1.2}function Mo(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 p=be(l);o=we(p,t)}const a=b(e,"buSzPct"),d=b(e,"buSzPts");let c=1;a&&(c=F(a,"val",1e5)/1e5);const h=d?F(d,"val",0)/100:null;let u=null;const g=b(e,"buFont");if(g){const p=g.getAttribute("typeface");p&&(u=p)}return i?{type:"char",char:i.getAttribute("char")||"•",color:o,sizePct:c,sizePts:h,fontFamily:u}:r?{type:"autoNum",numType:r.getAttribute("type")||"arabicPeriod",startAt:F(r,"startAt",1),color:o,sizePct:c,sizePts:h,fontFamily:u}:null}function Ao(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return Qn(n).toLowerCase()+".";case"romanUcPeriod":return Qn(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 Qn(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 $o(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=me(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 d=n.numType+":"+n.startAt;i[d]===void 0&&(i[d]=n.startAt);const c=Ao(n.numType,i[d]);i[d]++,e.fillText(c,t,s)}e.restore()}async function Yt(e,n,t,s,i,r,o,l,a,d=1800){if(!n)return;const c=b(n,"bodyPr"),h=G(c,"anchor","t"),u=G(c,"wrap","square"),g=G(c,"vert","horz"),p=F(c,"lIns",91440)*o,m=F(c,"tIns",45720)*o,S=F(c,"rIns",91440)*o,y=F(c,"bIns",45720)*o,x=t+p,w=s+m,k=i-p-S,v=r-m-y,_=u!=="none",T=g==="vert"||g==="vert270"||g==="eaVert";T&&(e.save(),g==="vert270"?(e.translate(t+i,s),e.rotate(Math.PI/2)):(e.translate(t,s+r),e.rotate(-Math.PI/2)));const N=b(c,"normAutoFit")||b(n,"normAutoFit");b(c,"spAutoFit")||b(n,"spAutoFit");const M=N?N.getAttribute("fontScale"):null;let C=M?parseInt(M,10)/1e5:1;const j=b(n,"lstStyle"),$=j?b(j,"defRPr"):null;function I(O,z,X,ie){const fe=O?O.getAttribute(X):null;if(fe!==null&&fe!=="")return fe;const ae=z?z.getAttribute(X):null;if(ae!==null&&ae!=="")return ae;const se=$?$.getAttribute(X):null;return se!==null&&se!==""?se:ie}const L=de(n,"p"),Y=[];let W=0;for(const O of L){const z=b(O,"pPr"),X=G(z,"algn","l");F(z,"lvl",0);const ie=F(z,"marL",0)*o,fe=F(z,"indent",0)*o,ae=z?Mo(z,le,l):null,se=b(z,"spcBef"),V=b(z,"spcAft"),_e=b(z,"lnSpc"),le=b(z,"defRPr");let re=d;if($){const J=$.getAttribute("sz");J&&(re=parseInt(J,10))}if(le){const J=le.getAttribute("sz");J&&(re=parseInt(J,10))}let ue=0,ye=0;if(se){const J=b(se,"spcPct"),ee=b(se,"spcPts");J?ue=re*127*o*(F(J,"val",0)/1e5):ee&&(ue=F(ee,"val",0)*wt*o/100)}if(V){const J=b(V,"spcPct"),ee=b(V,"spcPts");J?ye=re*127*o*(F(J,"val",0)/1e5):ee&&(ye=F(ee,"val",0)*wt*o/100)}const xe=[];for(const J of O.children){const ee=J.localName;(ee==="r"||ee==="br"||ee==="fld")&&xe.push(J)}if(xe.length===0){const J=b(O,"endParaRPr"),te=F(J||le,"sz",re)*127*o*C;Y.push({lines:[""],algn:X,marL:ie,spaceBefore:ue,spaceAfter:ye,szPx:te,lnSpc:_e,runs:[],emptyPara:!0,bullet:ae}),W+=ue+te*1.2+ye;continue}let ve=[],ce=[],D=0;for(const J of xe){if(J.localName==="br"){ve.push({runs:ce,maxSzPx:Math.max(D,re*127*o)}),ce=[],D=0;continue}const ee=b(J,"rPr"),te=b(J,"t");let E=te?te.textContent:"";const U=Ms(ee,le,o*C,a,re,$);e.font=U.fontStr;const ne=U.szPx;ne>D&&(D=ne);const he=po(ee,le,l),ge=I(ee,le,"u","none")!=="none",Te=I(ee,le,"strike","noStrike")!=="noStrike",Pe=parseInt(I(ee,le,"baseline","0"),10);if(_){const rt=E.split(" ");for(let hn=0;hn<rt.length;hn++){const pn=rt[hn];let zn=fe+ie;for(const At of ce)e.font=At.fontInfo.fontStr,zn+=e.measureText(At.text).width;e.font=U.fontStr;const si=e.measureText(pn).width,ii=ce.length?e.measureText(" ").width:0;if(zn+ii+si>k&&ce.length>0)ve.push({runs:ce,maxSzPx:Math.max(D,ne)}),ce=[{text:pn,rPr:ee,fontInfo:U,color:he,underline:ge,strikethrough:Te,baseline:Pe}],D=ne;else{if(ce.length>0){const At={text:" ",rPr:ee,fontInfo:U,color:he,underline:!1,strikethrough:!1,baseline:Pe};ce.push(At)}ce.push({text:pn,rPr:ee,fontInfo:U,color:he,underline:ge,strikethrough:Te,baseline:Pe})}}}else ce.push({text:E,rPr:ee,fontInfo:U,color:he,underline:ge,strikethrough:Te,baseline:Pe}),ne>D&&(D=ne)}ce.length>0&&ve.push({runs:ce,maxSzPx:Math.max(D,re*127*o)});const Z=_e?Rs(_e,re*127*o*C,o):null;Y.push({lines:ve,algn:X,marL:ie,indent:fe,spaceBefore:ue,spaceAfter:ye,lnSpcPx:Z,emptyPara:!1,bullet:ae});for(const J of ve)W+=ue+(Z||J.maxSzPx*1.2)+ye}if(N&&!M&&W>v&&v>0){let O=.3,z=1;for(let X=0;X<8;X++){const ie=(O+z)/2;let fe=0;for(const ae of L){const se=b(ae,"pPr"),V=se?b(se,"defRPr"):null;let _e=d;if($){const Z=$.getAttribute("sz");Z&&(_e=parseInt(Z,10))}if(V){const Z=V.getAttribute("sz");Z&&(_e=parseInt(Z,10))}const le=Array.from(ae.children).filter(Z=>["r","br","fld"].includes(Z.localName)),re=_e*127*o*ie;if(le.length===0){fe+=re*1.2;continue}const ue=le.reduce((Z,J)=>{const ee=b(J,"t");return Z+(ee?ee.textContent.length:0)},0),ye=k>0?k:i,xe=ue>0?le.reduce((Z,J)=>{const ee=b(J,"t");return Z+(ee?ee.textContent:"")},"").slice(0,20):"W";e.font=`${re}px sans-serif`;const ve=xe.length>0?e.measureText(xe).width/xe.length:re*.6,ce=Math.max(1,Math.floor(ye/ve)),D=Math.max(1,Math.ceil(ue/ce));fe+=D*re*1.2}fe<=v?O=ie:z=ie}C=(O+z)/2}let B=w;h==="ctr"?B=w+(v-W)/2:h==="b"&&(B=w+v-W);let K=B;const Q={};for(const O of Y){const{lines:z,algn:X,marL:ie,indent:fe,spaceBefore:ae,spaceAfter:se,lnSpcPx:V,emptyPara:_e,bullet:le}=O;if(K+=ae,_e){K+=z[0]?V||O.szPx*1.2:12*o,K+=se;continue}for(const re of z){const{runs:ue,maxSzPx:ye}=re,xe=V||ye*1.2,ve=K+ye*.85;let ce=0;for(const te of ue)e.font=te.fontInfo.fontStr,ce+=e.measureText(te.text).width;let D=x+ie;X==="ctr"?D=x+(k-ce)/2:X==="r"&&(D=x+k-ce);const Z=re===z[0];if(le&&Z){const te=x+ie+fe;$o(e,le,te,ve,Q)}let J=0;if(X==="just"&&!(re===z[z.length-1])){let E=0;for(const ne of ue)e.font=ne.fontInfo.fontStr,E+=(ne.text.match(/ /g)||[]).length;const U=k-ie-ce;E>0&&U>0&&(J=U/E)}const ee=(te,E,U,ne,he,ge)=>{e.font=ne.fontStr;const Te=e.measureText(te).width;e.fillText(te,E,U);const Pe=Math.max(.5,ne.szPx*.07);return he&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Pe,e.beginPath(),e.moveTo(E,U+Pe*1.5),e.lineTo(E+Te,U+Pe*1.5),e.stroke(),e.restore()),ge&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Pe,e.beginPath(),e.moveTo(E,U-ne.szPx*.3),e.lineTo(E+Te,U-ne.szPx*.3),e.stroke(),e.restore()),Te};for(const te of ue){const E=te.color;e.fillStyle=E?me(E):"#000000";let U=ve,ne=te.fontInfo;if(te.baseline!==0){const he=ne.szPx*.65,ge=`${ne.italic?"italic ":""}${ne.bold?"bold ":""}${he}px "${ne.family}", sans-serif`;ne={...ne,szPx:he,fontStr:ge},te.baseline>0?U=ve-te.fontInfo.szPx*.38:U=ve+te.fontInfo.szPx*.12}if(J>0&&te.text.includes(" ")){e.font=ne.fontStr;const he=te.text.split(" ");for(let ge=0;ge<he.length;ge++){const Te=ee(he[ge],D,U,ne,te.underline,te.strikethrough);D+=Te,ge<he.length-1&&(e.font=ne.fontStr,D+=e.measureText(" ").width+J)}}else{e.font=ne.fontStr;const he=e.measureText(te.text).width;ee(te.text,D,U,ne,te.underline,te.strikethrough),D+=he}}K+=xe}K+=se}T&&e.restore()}function Is(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 d=F(l,"blurRad",38100)*s,c=F(l,"dist",38100)*s,u=F(l,"dir",27e5)/6e4*Math.PI/180,g=c*Math.cos(u),p=c*Math.sin(u),m=be(l),S=we(m,t),y=S?me(S):"rgba(0,0,0,0.35)";e.shadowBlur=Math.min(d,40),e.shadowOffsetX=g,e.shadowOffsetY=p,e.shadowColor=y}const a=b(i,"glow");if(a){const d=F(a,"rad",0)*s,c=be(a),h=we(c,t);h&&(e.shadowBlur=Math.min(d,30),e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor=me(h))}return()=>{e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor="transparent"}}async function rn(e,n,t,s,i,r,o,l=null,a=null){const d=b(n,"spPr"),c=b(d,"xfrm");let h=0,u=0,g=0,p=0,m=0,S=!1,y=!1;if(c){const B=b(c,"off"),K=b(c,"ext");B&&(h=F(B,"x",0)*o,u=F(B,"y",0)*o),K&&(g=F(K,"cx",0)*o,p=F(K,"cy",0)*o),m=F(c,"rot",0)/6e4,S=G(c,"flipH","0")==="1",y=G(c,"flipV","0")==="1"}else{const B=Bs(n,a);if(B)h=B.x*o,u=B.y*o,g=B.w*o,p=B.h*o;else return}if(g<=0||p<=0)return;if(l){const{grpOff:B,grpExt:K,chOff:Q,chExt:O}=l,z=K.cx/O.cx,X=K.cy/O.cy;h=B.x+(h/o-Q.x)*z*o,u=B.y+(u/o-Q.y)*X*o,g=g*z,p=p*X}const x=h+g/2,w=u+p/2;e.save(),(m!==0||S||y)&&(e.translate(x,w),m!==0&&e.rotate(m*Math.PI/180),S&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-x,-w));const k=b(d,"prstGeom"),v=b(d,"custGeom"),_=k?G(k,"prst","rect"):"rect",T={};if(k){const B=b(k,"avLst");if(B){let K=0;for(const Q of de(B,"gd")){const z=G(Q,"fmla","").match(/val\s+(-?\d+)/);z&&(T[K]=parseInt(z[1])),K++}}}const N=()=>{const B=["noFill","solidFill","gradFill","blipFill","pattFill","grpFill"];for(const Q of B){const O=b(d,Q);if(O)return O}const K=b(n,"style");if(K){const Q=b(K,"fillRef");if(Q){if(F(Q,"idx",1)===0)return Se("<noFill/>").documentElement;const z=be(Q);if(z)return Se('<solidFill xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'">'+z.outerHTML+"</solidFill>").documentElement}}return null},M=()=>{const B=b(d,"ln");if(B)return B;const K=b(n,"style");if(K){const Q=b(K,"lnRef");if(Q){if(F(Q,"idx",1)===0)return null;const z=be(Q);if(z)return Se('<ln xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'"><solidFill>'+z.outerHTML+"</solidFill></ln>").documentElement}}return null};if(v){const B=b(v,"pathLst");if(B)for(const Q of de(B,"path")){const O=F(Q,"w",1)||1,z=F(Q,"h",1)||1,X=g/O,ie=p/z;e.beginPath();for(const se of Q.children)switch(se.localName){case"moveTo":{const V=b(se,"pt");V&&e.moveTo(h+F(V,"x",0)*X,u+F(V,"y",0)*ie);break}case"lnTo":{const V=b(se,"pt");V&&e.lineTo(h+F(V,"x",0)*X,u+F(V,"y",0)*ie);break}case"cubicBezTo":{const V=de(se,"pt");V.length>=3&&e.bezierCurveTo(h+F(V[0],"x",0)*X,u+F(V[0],"y",0)*ie,h+F(V[1],"x",0)*X,u+F(V[1],"y",0)*ie,h+F(V[2],"x",0)*X,u+F(V[2],"y",0)*ie);break}case"quadBezTo":{const V=de(se,"pt");V.length>=2&&e.quadraticCurveTo(h+F(V[0],"x",0)*X,u+F(V[0],"y",0)*ie,h+F(V[1],"x",0)*X,u+F(V[1],"y",0)*ie);break}case"arcTo":{const V=F(se,"wR",0)*X,_e=F(se,"hR",0)*ie,le=F(se,"stAng",0)/6e4*Math.PI/180,re=F(se,"swAng",0)/6e4*Math.PI/180,ue=e._lastX||h,ye=e._lastY||u,xe=ue-V*Math.cos(le),ve=ye-_e*Math.sin(le);V===_e?e.arc(xe,ve,V,le,le+re,re<0):e.ellipse(xe,ve,V,_e,0,le,le+re,re<0);break}case"close":e.closePath();break}const fe=N();fe&&await St(e,fe,h,u,g,p,o,i,s);const ae=M();ae&&ut(e,ae,i,o)}e.restore();const K=b(n,"txBody");if(K){e.save(),e.beginPath(),e.rect(h,u,g,p),e.clip();const Q=_n(n);await Yt(e,K,h,u,g,p,o,i,r,Q),e.restore()}return}e.beginPath(),Vt(e,_,h,u,g,p,T);const C=Is(e,d,i,o),j=h,$=u,I=g,L=p,Y=No(d)?Fo(e,d,i,j,$,I,L,o):null;try{const B=N();let K=!1;B&&(K=await St(e,B,h,u,g,p,o,i,s)),Y&&Y.overlay();const Q=M();Q?ut(e,Q,i,o):K||(_==="line"||_==="straightConnector1")&&(e.strokeStyle="#000",e.lineWidth=1,e.stroke())}finally{C(),Y?.cleanup&&Y.cleanup()}e.restore();const W=b(n,"txBody");if(W){e.save(),(m!==0||S||y)&&(e.translate(x,w),m!==0&&e.rotate(m*Math.PI/180),S&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-x,-w)),e.beginPath(),e.rect(h,u,g,p),e.clip();const B=_n(n);await Yt(e,W,h,u,g,p,o,i,r,B),e.restore()}}function _n(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=F(n,"w",12700),a=Math.max(.5,l*s);let d="#000000";if(r){const g=be(r),p=we(g,t);p&&(d=me(p))}else o&&(d="#888888");const c=b(n,"prstDash"),h=c?G(c,"val","solid"):"solid",u=G(n,"cap","flat");switch(G(n,"cmpd","sng"),e.strokeStyle=d,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 on(e,n,t,s,i,r){const o=b(n,"spPr"),l=b(o,"xfrm");if(!l)return;const a=b(l,"off"),d=b(l,"ext");if(!a||!d)return;const c=F(a,"x",0)*r,h=F(a,"y",0)*r,u=F(d,"cx",0)*r,g=F(d,"cy",0)*r,p=F(l,"rot",0)/6e4,m=G(l,"flipH","0")==="1",S=G(l,"flipV","0")==="1";if(u<=0||g<=0)return;const y=b(n,"blipFill"),x=y?b(y,"blip"):null,w=x?x.getAttribute("r:embed")||x.getAttribute("embed"):null,k=c+u/2,v=h+g/2;if(e.save(),(p!==0||m||S)&&(e.translate(k,v),p!==0&&e.rotate(p*Math.PI/180),m&&e.scale(-1,1),S&&e.scale(1,-1),e.translate(-k,-v)),w&&s[w]){const _=s[w],T=b(o,"prstGeom"),N=T?G(T,"prst","rect"):"rect",M={};if(T){const $=b(T,"avLst");if($){let I=0;for(const L of de($,"gd")){const Y=(G(L,"fmla","")||"").match(/val\s+(-?\d+)/);Y&&(M[I]=parseInt(Y[1])),I++}}}e.beginPath(),Vt(e,N,c,h,u,g,M),e.clip();const C=y?b(y,"srcRect"):null;if(C){const $=F(C,"l",0)/1e5,I=F(C,"t",0)/1e5,L=F(C,"r",0)/1e5,Y=F(C,"b",0)/1e5,W=_.naturalWidth*(1-$-L),B=_.naturalHeight*(1-I-Y);e.drawImage(_,_.naturalWidth*$,_.naturalHeight*I,W,B,c,h,u,g)}else e.drawImage(_,c,h,u,g);const j=b(o,"ln");j&&(e.beginPath(),Vt(e,N,c,h,u,g,M),ut(e,j,i,r))}else e.fillStyle="#e0e0e0",e.fillRect(c,h,u,g),e.strokeStyle="#aaa",e.lineWidth=1,e.strokeRect(c,h,u,g),e.beginPath(),e.moveTo(c,h),e.lineTo(c+u,h+g),e.moveTo(c+u,h),e.lineTo(c,h+g),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=F(o,"x",0)*i,d=F(o,"y",0)*i;F(l,"cx",0)*i,F(l,"cy",0)*i;const c=b(n,"graphic"),h=c?b(c,"graphicData"):null,u=h?b(h,"tbl"):null;if(!u)return;const g=b(u,"tblPr"),p=g?G(g,"bandRow","0")==="1":!1;g&&G(g,"bandCol","0");const m=g?G(g,"firstRow","0")==="1":!1,S=g?G(g,"lastRow","0")==="1":!1;g&&G(g,"firstCol","0"),g&&G(g,"lastCol","0");const y=b(u,"tblGrid"),x=de(y,"gridCol").map(v=>F(v,"w",0)*i),w=de(u,"tr");let k=d;for(let v=0;v<w.length;v++){const _=w[v],T=F(_,"h",457200)*i,N=de(_,"tc");let M=a;const C=v===0,j=v===w.length-1,$=v%2===1;for(let I=0;I<N.length;I++){const L=N[I],Y=F(L,"gridSpan",1);G(L,"vMerge","0");let W=0;for(let z=0;z<Y;z++)W+=x[I+z]||0;const B=b(L,"tcPr"),K=B?["noFill","solidFill","gradFill","blipFill","pattFill"].map(z=>b(B,z)).find(Boolean):null;if(e.save(),e.beginPath(),e.rect(M,k,W,T),K)await St(e,K,M,k,W,T,i,t,null);else{let z=null;m&&C?z=t.accent1?"#"+t.accent1.toLowerCase():"#4472C4":S&&j?z="#e0e0e0":p&&$&&(z="rgba(0,0,0,0.06)"),e.fillStyle=z||"transparent",z&&e.fill()}const Q=[{el:b(B,"lnL"),x1:M,y1:k,x2:M,y2:k+T},{el:b(B,"lnR"),x1:M+W,y1:k,x2:M+W,y2:k+T},{el:b(B,"lnT"),x1:M,y1:k,x2:M+W,y2:k},{el:b(B,"lnB"),x1:M,y1:k+T,x2:M+W,y2:k+T}];for(const z of Q)z.el?b(z.el,"noFill")||(e.beginPath(),e.moveTo(z.x1,z.y1),e.lineTo(z.x2,z.y2),ut(e,z.el,t,i)):(e.beginPath(),e.strokeStyle="#cccccc",e.lineWidth=.5,e.moveTo(z.x1,z.y1),e.lineTo(z.x2,z.y2),e.stroke());e.restore();const O=b(L,"txBody");O&&(e.save(),e.beginPath(),e.rect(M,k,W,T),e.clip(),await Yt(e,O,M,k,W,T,i,t,s,1400),e.restore()),M+=W}k+=T}}async function an(e,n,t,s,i,r,o){const l=b(n,"grpSpPr"),a=b(l,"xfrm");if(!a)return;const d=b(a,"off"),c=b(a,"ext"),h=b(a,"chOff"),u=b(a,"chExt");if(!d||!c||!h||!u)return;const g=F(a,"rot",0)/6e4,p=G(a,"flipH","0")==="1",m=G(a,"flipV","0")==="1",S={grpOff:{x:F(d,"x",0)*o,y:F(d,"y",0)*o},grpExt:{cx:F(c,"cx",0)*o,cy:F(c,"cy",0)*o},chOff:{x:F(h,"x",0),y:F(h,"y",0)},chExt:{cx:F(u,"cx",1),cy:F(u,"cy",1)}},y=S.grpOff.x+S.grpExt.cx/2,x=S.grpOff.y+S.grpExt.cy/2;e.save(),(g!==0||p||m)&&(e.translate(y,x),g!==0&&e.rotate(g*Math.PI/180),p&&e.scale(-1,1),m&&e.scale(1,-1),e.translate(-y,-x));for(const w of n.children){const k=w.localName;k==="sp"?await rn(e,w,t,s,i,r,o,S):k==="pic"?await on(e,w,t,s,i,o):k==="grpSp"?await an(e,w,t,s,i,r,o):k==="graphicFrame"?await cn(e,w,i,r,o,files,t):k==="cxnSp"&&await ln(e,w,i,o)}e.restore()}function Zn(e,n,t,s,i,r,o,l,a){const d=b(n,t);if(!d)return;const c=d.getAttribute("type")||"none";if(c==="none")return;const h={sm:3,med:6,lg:9},u=Math.max(.5,F(n,"w",12700)*a),g=u*(h[d.getAttribute("w")||"med"]??6),p=u*(h[d.getAttribute("len")||"med"]??6),m=Math.atan2(o-i,r-s);switch(e.save(),e.fillStyle=e.strokeStyle,e.strokeStyle=e.strokeStyle,c){case"triangle":case"arrow":case"stealth":{const S=c==="arrow",y=c==="stealth"?p*.5:0;e.beginPath(),e.moveTo(s,i),e.lineTo(s+p*Math.cos(m)+g/2*Math.sin(m),i+p*Math.sin(m)-g/2*Math.cos(m)),S||e.lineTo(s+y*Math.cos(m),i+y*Math.sin(m)),e.lineTo(s+p*Math.cos(m)-g/2*Math.sin(m),i+p*Math.sin(m)+g/2*Math.cos(m)),e.closePath(),S?e.stroke():e.fill();break}case"diamond":{const S=p/2;e.beginPath(),e.moveTo(s,i),e.lineTo(s+S*Math.cos(m)+g/2*Math.sin(m),i+S*Math.sin(m)-g/2*Math.cos(m)),e.lineTo(s+p*Math.cos(m),i+p*Math.sin(m)),e.lineTo(s+S*Math.cos(m)-g/2*Math.sin(m),i+S*Math.sin(m)+g/2*Math.cos(m)),e.closePath(),e.fill();break}case"oval":{const S=p/2,y=g/2,x=s+S*Math.cos(m),w=i+S*Math.sin(m);e.beginPath(),e.save(),e.translate(x,w),e.rotate(m),e.scale(1,y/S),e.arc(0,0,S,0,Math.PI*2),e.restore(),e.fill();break}}e.restore()}async function ln(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=F(o,"x",0)*s,d=F(o,"y",0)*s,c=F(l,"cx",0)*s,h=F(l,"cy",0)*s,u=F(r,"rot",0)/6e4,g=G(r,"flipH","0")==="1",p=G(r,"flipV","0")==="1",m=a+c/2,S=d+h/2,y=b(i,"ln");e.save(),(u!==0||g||p)&&(e.translate(m,S),u!==0&&e.rotate(u*Math.PI/180),g&&e.scale(-1,1),p&&e.scale(1,-1),e.translate(-m,-S));const x=b(i,"prstGeom"),w=x?G(x,"prst","line"):"line",k=w==="line"||w==="straightConnector1";if(e.beginPath(),k){const v=g?a:a+c,_=p?d:d+h,T=g?a+c:a,N=p?d+h:d;e.moveTo(T,N),e.lineTo(v,_)}else Vt(e,w,a,d,c,h,{});if(y){if(ut(e,y,t,s),k){const v=g?a+c:a,_=p?d+h:d,T=g?a:a+c,N=p?d:d+h;Zn(e,y,"headEnd",T,N,v,_,t,s),Zn(e,y,"tailEnd",v,_,T,N,t,s)}}else e.strokeStyle="#000",e.lineWidth=1,e.stroke();e.restore()}async function Ls(e,n,t,s,i,r,o,l,a,d,c){const h=d*a,u=c*a,g=w=>{const k=b(w,"cSld");if(!k)return null;const v=b(k,"bg");if(!v)return null;const _=b(v,"bgPr"),T=b(v,"bgRef");return{bgPr:_,bgRef:T}},p=n?g(n):null,m=s?g(s):null,S=t?g(t):null,y=p||m||S;let x=!1;if(y){const{bgPr:w,bgRef:k}=y;if(w){const v=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const _ of v){const T=b(w,_);if(T){e.beginPath(),e.rect(0,0,h,u);const N=y===S?Object.assign({},o):o;await St(e,T,0,0,h,u,1,l,N)&&(x=!0);break}}}else if(k){F(k,"idx",0);const v=be(k),_=we(v,l);_&&(e.fillStyle=me(_),e.fillRect(0,0,h,u),x=!0)}}x||(e.fillStyle="#ffffff",e.fillRect(0,0,h,u))}function Ds(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 de(i,"sp")){const o=b(r,"nvSpPr"),l=o?b(o,"nvPr"):null,a=l?b(l,"ph"):null;if(!a)continue;const d=G(a,"type","body"),c=G(a,"idx","0"),h=`${d}:${c}`;if(n[h])continue;const u=b(r,"spPr"),g=b(u,"xfrm");if(!g)continue;const p=b(g,"off"),m=b(g,"ext");!p||!m||(n[h]={x:F(p,"x",0),y:F(p,"y",0),w:F(m,"cx",0),h:F(m,"cy",0),txBody:b(r,"txBody")})}}return n}function Bs(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 cn(e,n,t,s,i,r,o){const l=b(n,"graphic"),a=l?b(l,"graphicData"):null,d=a?G(a,"uri",""):"";if(b(n,"tbl")||a&&b(a,"tbl"))return zs(e,n,t,s,i);const c=b(n,"xfrm");if(!c)return;const h=b(c,"off"),u=b(c,"ext");if(!h||!u)return;const g=F(h,"x",0)*i,p=F(h,"y",0)*i,m=F(u,"cx",0)*i,S=F(u,"cy",0)*i;if(m<=0||S<=0)return;const y=d.includes("chart"),x=d.includes("diagram");if(y&&r&&o){const k=a?b(a,"chart"):null,v=k?k.getAttribute("r:id")||k.getAttribute("id"):null,_=v?o[v]:null;if(_&&r[_.fullPath]){const T=new TextDecoder().decode(r[_.fullPath]),N=Se(T);_o(e,N,g,p,m,S,t,i);return}}if(x&&r&&o){const k=a?b(a,"relIds"):null,v=k?k.getAttribute("r:dm")||k.getAttribute("dm"):null,_=v?o[v]:null;if(_&&r[_.fullPath]){const T=new TextDecoder().decode(r[_.fullPath]),N=Se(T),M=k?k.getAttribute("r:lo")||k.getAttribute("lo"):null,C=M?o[M]:null,j=C&&r[C.fullPath]?Se(new TextDecoder().decode(r[C.fullPath])):null,{renderSmartArt:$}=await en(async()=>{const{renderSmartArt:I}=await import("./smartart-uE0Bdv7c.js");return{renderSmartArt:I}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]),import.meta.url);$(e,N,j,g,p,m,S,t,i);return}}const w=y?"📊 Chart":x?"🔷 Diagram":"⬛ Graphic";e.save(),e.fillStyle="#f4f4f8",e.strokeStyle="#ccccdd",e.lineWidth=1,e.fillRect(g,p,m,S),e.strokeRect(g,p,m,S),e.fillStyle="#999",e.font=`${Math.min(m*.07,16*i)}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(w,g+m/2,p+S/2),e.textAlign="start",e.textBaseline="alphabetic",e.restore()}async function Os(e,n,t,s,i,r,o,l,a){if(n)for(const d of n.children){const c=d.localName;try{c==="sp"?await rn(e,d,t,s,i,r,o,null,l):c==="pic"?await on(e,d,t,s,i,o):c==="grpSp"?await an(e,d,t,s,i,r,o):c==="graphicFrame"?await cn(e,d,i,r,o,a,t):c==="cxnSp"&&await ln(e,d,i,o)}catch(h){console.warn("Error rendering shape:",c,h)}}}const Eo=Object.freeze(Object.defineProperty({__proto__:null,applyEffects:Is,applyFill:St,applyOutline:ut,buildPlaceholderMap:Ds,computeLineHeight:Rs,getDefaultFontSize:_n,getRels:Be,loadImages:Wt,renderBackground:Ls,renderConnector:ln,renderGraphicFrame:cn,renderGroupShape:an,renderPicture:on,renderShape:rn,renderSpTree:Os,renderTable:zs,renderTextBody:Yt,resolvePlaceholderXfrm:Bs},Symbol.toStringTag,{value:"Module"}));async function Ro(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:d}=await s.read();if(d)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 Io=(()=>{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 zo(e){let n=4294967295;for(let t=0;t<e.length;t++)n=Io[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}class Lo{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 pe(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 Us=new TextEncoder;function Do(e){return Us.encode(e)}const Jn=18977,es=0;class Bo{constructor(){this._entries=[]}async addText(n,t){return this.addBytes(n,Us.encode(t))}async addBytes(n,t,s=!0){const i=Do(n),r=zo(t),o=t.length;let l,a;if(s&&t.length>32){const d=await Ro(t);d.length<t.length?(l=d,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 Lo;for(const i of this._entries)i.localOffset=n.size,n.append(new Uint8Array([80,75,3,4])),n.append(pe(20)),n.append(pe(2048)),n.append(pe(i.method)),n.append(pe(es)),n.append(pe(Jn)),n.append(Ie(i.crc)),n.append(Ie(i.compData.length)),n.append(Ie(i.uncompSize)),n.append(pe(i.nameBytes.length)),n.append(pe(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(pe(798)),n.append(pe(20)),n.append(pe(2048)),n.append(pe(i.method)),n.append(pe(es)),n.append(pe(Jn)),n.append(Ie(i.crc)),n.append(Ie(i.compData.length)),n.append(Ie(i.uncompSize)),n.append(pe(i.nameBytes.length)),n.append(pe(0)),n.append(pe(0)),n.append(pe(0)),n.append(pe(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(pe(0)),n.append(pe(0)),n.append(pe(this._entries.length)),n.append(pe(this._entries.length)),n.append(Ie(s)),n.append(Ie(t)),n.append(pe(0)),n.concat()}}async function Oo(e){const n=new Bo;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 Uo=new TextDecoder,Gs=new TextEncoder,je={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 vt(e){return new DOMParser().parseFromString(e,"application/xml")}function Go(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 $e(e){return Gs.encode(Go(e))}function Le(e,n){const t=e[n];return t?vt(Uo.decode(t)):null}function oe(e,n){if(!e)return null;const t=e.getElementsByTagName("*");for(let s=0;s<t.length;s++)if(t[s].localName===n)return t[s];return null}function De(e,n){if(!e)return[];const t=[],s=e.getElementsByTagName("*");for(let i=0;i<s.length;i++)s[i].localName===n&&t.push(s[i]);return t}function Wo(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=Le(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 d=n.split("/").slice(0,-1).join("/");a=d?d+"/"+o.replace(/^\.\.\//,""):o;const c=a.split("/"),h=[];for(const u of c)u===".."?h.pop():h.push(u);a=h.join("/")}s[r]={id:r,target:o,type:l,fullPath:a}}return s}function Rt(e){const n=vt('<?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(je.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 qt(e,n){for(const t of e.children){const s=t.localName;if(s==="sp"||s==="pic"||s==="cxnSp"){const i=oe(t,"nvSpPr")||oe(t,"nvPicPr")||oe(t,"nvCxnSpPr"),r=i?oe(i,"cNvPr"):null;if(r&&(r.getAttribute("name")||"")===n)return t}else if(s==="grpSp"){const i=qt(t,n);if(i)return i}}return null}function at(e){const n=oe(e,"cSld");return n?oe(n,"spTree"):null}function zt(e,n,t,s=!0){for(const i of De(e,"t")){const r=i.textContent;if(!r)continue;const o=s?r.split(n).join(t):r.replace(new RegExp(qo(n),"gi"),t);o!==r&&(i.textContent=o)}}function qo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const ts={"image/jpeg":"jpeg","image/jpg":"jpeg","image/png":"png","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"},Ko={jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml"};function ns(e,n,t){const s="[Content_Types].xml",i=Le(e,s);if(!i)return;const r=i.documentElement;for(const l of De(i,"Override"))if(l.getAttribute("PartName")==="/"+t)return;const o=i.createElementNS(je.ct,"Override");o.setAttribute("PartName","/"+t),o.setAttribute("ContentType",Ko[n]||"application/octet-stream"),r.appendChild(o),e[s]=$e(i)}class Qt{constructor(n){this._files=n,this._presPath="ppt/presentation.xml",this._presDoc=Le(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 Qt(t)}static async fromBytes(n){const t=await Fs(n);return new Qt(t)}_buildSlidePaths(){if(!this._presDoc)return[];const n=oe(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]=$e(this._presDoc)}_savePresRels(){this._files[Je(this._presPath)]=$e(Rt(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 Le(this._files,t)}_saveSlideDoc(n,t){this._files[this._slidePaths[n]]=$e(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[d,c]of Object.entries(n)){const h=s+d+i;zt(a,h,String(c))}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=Le(this._files,o.fullPath);if(l){for(const[a,d]of Object.entries(t))zt(l,s+a+i,String(d));this._files[o.fullPath]=$e(l)}}replaceText(n,t,s={}){const{caseSensitive:i=!0,includeNotes:r=!1,slides:o}=s,l=o??this._slidePaths.map((a,d)=>d);for(const a of l){const d=this._slideDoc(a);if(zt(d,n,t,i),this._saveSlideDoc(a,d),r){const c=Ze(this._files,this._slidePaths[a]),h=Object.values(c).find(u=>u.type?.includes("notesSlide"));if(h){const u=Le(this._files,h.fullPath);u&&(zt(u,n,t,i),this._files[h.fullPath]=$e(u))}}}}setShapeText(n,t,s,i={}){const{preserveFormatting:r=!0}=i,o=this._slideDoc(n),l=at(o);if(!l)return this;const a=qt(l,t);if(!a)throw new Error(`Shape "${t}" not found on slide ${n}`);const d=oe(a,"txBody");if(!d)return this;const c=oe(d,"r"),h=c?oe(c,"rPr"):null,u=oe(oe(d,"p"),"pPr");for(const m of De(d,"p"))m.parentNode.removeChild(m);const g=s.split(`
|
|
31
|
+
`),p=je.a;for(const m of g){const S=o.createElementNS(p,"a:p");u&&r&&S.appendChild(u.cloneNode(!0));const y=o.createElementNS(p,"a:r");h&&r&&y.appendChild(h.cloneNode(!0));const x=o.createElementNS(p,"a:t");x.textContent=m,y.appendChild(x),S.appendChild(y),d.appendChild(S)}return this._saveSlideDoc(n,o),this}getShapeText(n,t){const s=this._slideDoc(n),i=at(s);if(!i)return"";const r=qt(i,t);return r?De(r,"t").map(o=>o.textContent).join(""):""}addTextBox(n,t,s={}){const{x:i=914400,y:r=914400,w:o=4572e3,h:l=914400,color:a="000000",fontSize:d=1800,bold:c=!1,align:h="l",fontFamily:u="Calibri"}=s,g=this._slideDoc(n),p=at(g);if(!p)return this;const S=Math.max(0,...De(p,"cNvPr").map(_=>parseInt(_.getAttribute("id")||"0",10)))+1,y=`TextBox ${S}`,x=je.a,k=`<p:sp xmlns:p="${je.p}" xmlns:a="${x}">
|
|
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="${d}" b="${c?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,"&").replace(/</g,"<").replace(/>/g,">")}</a:t>
|
|
53
|
+
</a:r>
|
|
54
|
+
</a:p>
|
|
55
|
+
</p:txBody>
|
|
56
|
+
</p:sp>`,v=vt(k);return p.appendChild(g.adoptNode(v.documentElement)),this._saveSlideDoc(n,g),this}async setShapeImage(n,t,s,i="image/jpeg"){const r=this._slideDoc(n),o=at(r);if(!o)return this;const l=qt(o,t);if(!l)throw new Error(`Shape "${t}" not found on slide ${n}`);const a=Ze(this._files,this._slidePaths[n]),d=oe(l,"blipFill"),c=d?oe(d,"blip"):null,h=c?c.getAttribute("r:embed")||c.getAttribute("embed"):null,u=h?a[h]:null,g=ts[i]||"jpeg",p=Object.keys(this._files).filter(y=>y.startsWith("ppt/media/")).length+1,m=`ppt/media/image${p}.${g}`;this._files[m]=s;let S;return h&&u?(S=h,a[S]={id:S,type:u.type,target:`../media/image${p}.${g}`,fullPath:m}):(S=It(a),a[S]={id:S,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${p}.${g}`,fullPath:m}),c&&c.setAttribute("r:embed",S),this._files[Je(this._slidePaths[n])]=$e(Rt(a)),this._saveSlideDoc(n,r),ns(this._files,g,m),this}async addImage(n,t,s="image/jpeg",i={}){const{x:r=914400,y:o=914400,w:l=2743200,h:a=2057400}=i,d=ts[s]||"jpeg",c=Object.keys(this._files).filter(_=>_.startsWith("ppt/media/")).length+1,h=`ppt/media/image${c}.${d}`;this._files[h]=t;const u=Ze(this._files,this._slidePaths[n]),g=It(u);u[g]={id:g,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${c}.${d}`,fullPath:h},this._files[Je(this._slidePaths[n])]=$e(Rt(u));const p=this._slideDoc(n),m=at(p);if(!m)return this;const y=Math.max(0,...De(m,"cNvPr").map(_=>parseInt(_.getAttribute("id")||"0",10)))+1,x=je.a,k=`<p:pic xmlns:p="${je.p}" xmlns:a="${x}" 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="${g}"/>
|
|
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=vt(k);return m.appendChild(p.adoptNode(v.documentElement)),this._saveSlideDoc(n,p),ns(this._files,d,h),this}setSlideBackground(n,t){const s=this._slideDoc(n),i=oe(s,"cSld");if(!i)return this;const r=oe(i,"bg");r&&i.removeChild(r);const o=je.a,a=`<p:bg xmlns:p="${je.p}" xmlns:a="${o}">
|
|
71
|
+
<p:bgPr><a:solidFill><a:srgbClr val="${t}"/></a:solidFill>
|
|
72
|
+
<a:effectLst/></p:bgPr></p:bg>`,d=s.adoptNode(vt(a).documentElement);return i.insertBefore(d,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(d=>d.type?.includes("theme"))?.fullPath}}if(!i)return this;const r=Le(this._files,i);if(!r)return this;oe(r,"fmtScheme");const o=oe(r,"clrScheme");if(!o)return this;for(const l of o.children)if(l.localName===n){const a=oe(l,"srgbClr");if(a)a.setAttribute("val",t);else{for(;l.firstChild;)l.removeChild(l.firstChild);const d=je.a,c=r.createElementNS(d,"a:srgbClr");c.setAttribute("val",t),l.appendChild(c)}break}return this._files[i]=$e(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(m=>m.match(/ppt\/slides\/slide(\d+)\.xml/)).filter(Boolean).map(m=>parseInt(m[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 d=Je(i);this._files[d]&&(this._files[a]=this._files[d].slice());const c=It(this._presRels),h=`slides/slide${o}.xml`;this._presRels[c]={id:c,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",target:h,fullPath:l},this._savePresRels();const u=oe(this._presDoc,"sldIdLst");if(u){const m=De(u,"sldId").map(k=>parseInt(k.getAttribute("id")||"0",10)),S=(m.length?Math.max(...m):255)+1,y=je.p,x=this._presDoc.createElementNS(y,"p:sldId");x.setAttribute("id",String(S)),x.setAttributeNS(je.r,"r:id",c);const w=Array.from(u.children);s>=w.length?u.appendChild(x):u.insertBefore(x,w[s])}this._savePresDoc(),this._slidePaths=this._buildSlidePaths();const g="[Content_Types].xml",p=Le(this._files,g);if(p){const m=p.documentElement,S=p.createElementNS(je.ct,"Override");S.setAttribute("PartName","/"+l),S.setAttribute("ContentType","application/vnd.openxmlformats-officedocument.presentationml.slide+xml"),m.appendChild(S),this._files[g]=$e(p)}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=oe(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=oe(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=Le(this._files,r.fullPath);if(o){for(const l of De(o,"sp")){const a=oe(oe(l,"nvSpPr"),"nvPr"),d=a?oe(a,"ph"):null;if(d&&Wo(d,"type")!=="sldNum"){for(const h of De(l,"t"))h.textContent="";const c=oe(l,"t");c&&(c.textContent=t);break}}this._files[r.fullPath]=$e(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=je.p,l=je.a,a=`ppt/notesSlides/notesSlide${r}.xml`,d=`<?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,"&").replace(/</g,"<").replace(/>/g,">")}</a:t></a:r></a:p>
|
|
83
|
+
</p:txBody>
|
|
84
|
+
</p:sp>
|
|
85
|
+
</p:spTree></p:cSld>
|
|
86
|
+
</p:notes>`;this._files[a]=Gs.encode(d);const c=It(s);s[c]={id:c,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",target:`../notesSlides/notesSlide${r}.xml`,fullPath:a},this._files[Je(t)]=$e(Rt(s))}async save(){return Oo(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=oe(r,"nvSpPr")||oe(r,"nvPicPr")||oe(r,"nvGraphicFramePr")||oe(r,"nvCxnSpPr"),a=l?oe(l,"cNvPr"):null;i.push({id:a?.getAttribute("id")||"",name:a?.getAttribute("name")||"",type:o})}return i}}const Ws=new TextEncoder;function Xo(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}class Vo{constructor(){this._parts=[],this._size=0}write(n){const t=typeof n=="string"?Ws.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 Ho(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 Yo(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 Qo(e,n){const t=e/914400*72,s=n/914400*72;return{w:t,h:s}}class Zo{constructor(){this._buf=new Vo,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,_)=>_),a=l.length,{cx:d,cy:c}=n.slideSize,{w:h,h:u}=Qo(d,c);this._buf.write(`%PDF-1.4
|
|
95
|
+
`),this._buf.write(`%ÿþýü
|
|
96
|
+
|
|
97
|
+
`);const g=this._nextObj(),p=this._nextObj(),m=Array.from({length:a},()=>this._nextObj()),S=Array.from({length:a},()=>this._nextObj()),y=Array.from({length:a},()=>this._nextObj());this._writeObj(g,`<< /Type /Catalog /Pages ${p} 0 R >>`);const x=m.map(v=>`${v} 0 R`).join(" ");this._writeObj(p,`<< /Type /Pages /Kids [${x}] /Count ${a} >>`);for(let v=0;v<a;v++){const _=l[v];o?.(v,a);const T=await Yo(n,_,s),N=await Ho(T,i),M=T.width,C=T.height;this._writeObj(m[v],`<< /Type /Page /Parent ${p} 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 ${M} /Height ${C} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length __LEN__ >>`,N);const j=`q ${h.toFixed(3)} 0 0 ${u.toFixed(3)} 0 0 cm /Im${v} Do Q`;this._writeObj(y[v],"<< /Length __LEN__ >>",Ws.encode(j))}o?.(a,a);const w=this._buf.size,k=this._objNum+1;this._buf.write(`xref
|
|
98
|
+
0 ${k}
|
|
99
|
+
`),this._buf.write(`0000000000 65535 f \r
|
|
100
|
+
`);for(let v=1;v<k;v++){const _=this._xref[v]??0;this._buf.write(String(_).padStart(10,"0")+` 00000 n \r
|
|
101
|
+
`)}return this._buf.write(`trailer
|
|
102
|
+
<< /Size ${k} /Root ${g} 0 R >>
|
|
103
|
+
`),this._buf.write(`startxref
|
|
104
|
+
${w}
|
|
105
|
+
%%EOF
|
|
106
|
+
`),this._buf.concat()}}async function En(e,n={}){const{width:t=null,dpi:s=150,quality:i=.92,slides:r=null,onProgress:o=null}=n,l=t??Xo(e,s);return new Zo().build(e,{widthPx:l,quality:i,slideList:r,onProgress:o})}async function Jo(e,n="presentation.pdf",t={}){const s=await En(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 ea(e,n,t={}){return En(n,{...t,slides:[e]})}const ta=500;function Rn(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 d=b(o,"cTn");if(!d)return;const c=G(d,"nodeType","");c==="clickEffect"&&(l+=1),c==="withEffect"&&l===0&&(l=0);const h=F(d,"delay",0)+a,u=b(o,"childTnLst")||b(d,"childTnLst");if(u)for(const g of u.children){const p=g.localName;if(p==="par")i(g,l,h);else if(p==="seq"){const m=b(g,"cTn"),y=(m?G(m,"nodeType",""):"")==="clickEffect"?l+1:l,x=b(g,"childTnLst");if(x)for(const w of x.children)w.localName==="par"&&i(w,y,h)}else if(p==="set"||p==="animEffect"||p==="anim"||p==="animScale"||p==="animClr"){const m=ss(g,l,h);m&&s.push(m)}}}function r(o,l){const a=b(o,"childTnLst")||b(b(o,"cTn"),"childTnLst");if(!a)return;let d=l;for(const c of a.children)if(c.localName==="par"){const h=b(c,"cTn"),u=h?G(h,"nodeType",""):"";(u==="clickEffect"||u==="clickPar")&&d++,i(c,d,0)}}for(const o of t.children)o.localName==="par"?i(o,0,0):o.localName==="seq"&&r(o,0);for(const o of de(t,"animEffect")){const l=ss(o,0,0);l&&s.push(l)}return s.sort((o,l)=>o.clickNum-l.clickNum||o.delay-l.delay)}function ss(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):ta,d=(s?F(s,"delay",0):0)+t,c=G(e,"filter",null),h=G(e,"type",null)||(c?"filter":"set"),u=G(e,"dir",null)||(c?c.split("(")[1]?.replace(")",""):null)||"";let g="emphasis";(h==="in"||e.localName==="set"&&G(b(e,"attrNameLst")||e,"attrName","")==="style.visibility"&&G(e,"to","")==="visible")&&(g="entrance"),(h==="out"||e.localName==="set"&&G(e,"to","")==="hidden")&&(g="exit");let p=c||e.localName;if(c){const m=c.toLowerCase();m.includes("fade")?p="fade":m.includes("fly")?p="fly":m.includes("appear")?p="appear":m.includes("zoom")?p="zoom":m.includes("wipe")?p="wipe":m.includes("wheel")?p="wheel":m.includes("blinds")?p="blinds":m.includes("box")?p="box":m.includes("dissolve")?p="dissolve":m.includes("split")?p="split":m.includes("stretch")?p="stretch":m.includes("diamond")?p="diamond":m.includes("plus")?p="plus":m.includes("wedge")?p="wedge":m.includes("random")?p="dissolve":m.includes("strips")?p="strips":m.includes("peek")?p="fly":m.includes("checkerboard")?p="dissolve":p="fade"}return{shapeId:o,type:g,effect:p,clickNum:n,delay:d,duration:a,dir:u,raw:e.localName}}function In(e){if(!e)return null;const n=b(e,"transition");if(!n)return null;const t=F(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 na(e){return 1-Math.pow(1-e,2)}function sa(e){return e*e}function ia(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}function qs(e,n,t,s){const i=Math.max(0,Math.min(1,n)),r=e.type==="entrance",o=r?na(i):sa(i),l={opacity:1,tx:0,ty:0,scaleX:1,scaleY:1,clipProgress:1,clipDir:"none",spin:0},a=e.effect,d=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 c=1-o;d.includes("l")?l.tx=-t*c:d.includes("r")?l.tx=t*c:d.includes("t")?l.ty=-s*c:l.ty=s*c;break}case"zoom":l.opacity=o,l.scaleX=.1+o*.9,l.scaleY=.1+o*.9;break;case"wipe":l.clipProgress=o,l.clipDir=d||"r";break;case"split":l.clipProgress=o,l.clipDir=d.includes("v")?"split-v":"split-h";break;case"blinds":l.clipProgress=o,l.clipDir=d.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=d.includes("r")?"strips-r":"strips-l";break;case"stretch":l.opacity=o,d.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 c={...e,type:"entrance"};return qs(c,1-i,t,s)}else switch(a){case"spin":l.spin=o*360;break;case"grow":case"shrink":{const c=a==="grow"?1.5:.5,h=i<.5?i*2:(1-i)*2;l.scaleX=1+(c-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 Ks(e,n,t,s,i){const r=ia(i),o=e.canvas.width,l=e.canvas.height;e.clearRect(0,0,o,l);const a=s?.type||"fade",d=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 c=d==="l"?-o*r:d==="r"?o*r:0,h=d==="u"?-l*r:d==="d"?l*r:0;e.drawImage(n,c,h,o,l),e.drawImage(t,c+(d==="l"?o:d==="r"?-o:0),h+(d==="u"?l:d==="d"?-l:0),o,l);break}case"cover":case"uncover":{const c=a==="uncover",h=d==="l"?-o*(1-r):d==="r"?o*(1-r):0,u=d==="u"?-l*(1-r):d==="d"?l*(1-r):0;c?(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(),d==="l"?e.rect(o*(1-r),0,o*r,l):d==="r"?e.rect(0,0,o*r,l):d==="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 c=a==="newsflash"?1+(1-r)*3:.05+r*.95;e.translate(o/2,l/2),e.scale(c,c),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 Xs{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 en(async()=>{const{parseXml:a}=await Promise.resolve().then(()=>Zr);return{parseXml:a}},void 0,import.meta.url).catch(()=>({parseXml:a=>new DOMParser().parseFromString(a,"application/xml")})),o=r(i);this._steps=Rn(o),this._transition=In(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 d of t){if(r.has(d))continue;const c=a-d.delay;if(c<0)continue;const h=Math.min(1,c/d.duration),u=this.canvas.width,g=this.canvas.height,p=qs(d,h,u*.3,g*.3);this._shapeStates.set(d.shapeId,{...p,step:d}),h>=1&&r.add(d)}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 d=Math.min(1,(a-o)/i);Ks(this.ctx,n,t,s,d),d<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 ra=Object.freeze(Object.defineProperty({__proto__:null,PptxPlayer:Xs,parseAnimations:Rn,parseTransition:In,renderTransitionFrame:Ks},Symbol.toStringTag,{value:"Module"}));let oa=0;function dn(e="el"){return`${e}${++oa}`}function Ne(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function A(e){return`${+e.toFixed(3)}`}function Sn(e){return e?me(e):"none"}function Vs(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=be(e),d=we(a,t),c=Sn(d),h=d?.a!=null?d.a/255:1;return{fill:c,fillAttrs:h<1?` fill-opacity="${A(h)}"`:""}}if(l==="gradFill"){const a=b(e,"gsLst"),d=a?de(a,"gs").map(p=>{const m=F(p,"pos",0)/1e5,S=be(p),y=we(S,t);return{pos:m,color:Sn(y),opacity:y?.a!=null?y.a/255:1}}):[],c=b(e,"lin"),h=b(e,"path"),u=dn("grad");let g;if(h){const p=b(h,"fillToRect"),m=F(p,"l",5e4)/1e5,S=F(p,"t",5e4)/1e5,y=s+r*m,x=i+o*S,w=Math.sqrt(r*r+o*o)/2;g=`<radialGradient id="${u}" cx="${A(y)}" cy="${A(x)}" r="${A(w)}" gradientUnits="userSpaceOnUse">`;for(const k of d)g+=`<stop offset="${A(k.pos)}" stop-color="${Ne(k.color)}"${k.opacity<1?` stop-opacity="${A(k.opacity)}"`:""}/>`;g+="</radialGradient>"}else{const m=(F(c,"ang",0)/6e4-90)*(Math.PI/180),S=Math.cos(m),y=Math.sin(m),x=Math.sqrt(r*r+o*o)/2,w=s+r/2,k=i+o/2;g=`<linearGradient id="${u}" x1="${A(w-S*x)}" y1="${A(k-y*x)}" x2="${A(w+S*x)}" y2="${A(k+y*x)}" gradientUnits="userSpaceOnUse">`;for(const v of d)g+=`<stop offset="${A(v.pos)}" stop-color="${Ne(v.color)}"${v.opacity<1?` stop-opacity="${A(v.opacity)}"`:""}/>`;g+="</linearGradient>"}return n.push(g),{fill:`url(#${u})`,fillAttrs:""}}return l==="blipFill"?{fill:"none",fillAttrs:""}:{fill:"none",fillAttrs:""}}function Hs(e,n,t){if(!e)return"";if(b(e,"noFill"))return' stroke="none"';const s=b(e,"solidFill"),i=s?be(s):null,r=we(i,n),o=Sn(r)||"#000",l=Math.max(.5,F(e,"w",12700)/914400*96),a=b(e,"prstDash"),d=a?G(a,"val","solid"):"solid";let c="";d==="dash"?c=` stroke-dasharray="${A(l*4)},${A(l*2)}"`:d==="dot"?c=` stroke-dasharray="${A(l)},${A(l*2)}"`:d==="dashDot"?c=` stroke-dasharray="${A(l*4)},${A(l*2)},${A(l)},${A(l*2)}"`:d==="lgDash"&&(c=` stroke-dasharray="${A(l*8)},${A(l*3)}"`);const h=G(e,"cap","flat"),u=h==="rnd"?"round":h==="sq"?"square":"butt";return` stroke="${Ne(o)}" stroke-width="${A(l)}" stroke-linecap="${u}" stroke-linejoin="round"${c}`}function Ys(e,n){if(!e)return"";const t=b(e,"outerShdw");if(!t)return"";const s=F(t,"dist",38100)/914400*96,i=F(t,"dir",27e5)/6e4,r=F(t,"blurRad",38100)/914400*96,o=i*Math.PI/180,l=Math.cos(o)*s,a=Math.sin(o)*s,d=be(t),c=we(d,{}),h=c?me(c):"rgba(0,0,0,0.5)",u=c?.a!=null?c.a/255:.5,g=dn("shd");return n.push(`<filter id="${g}" x="-50%" y="-50%" width="200%" height="200%"><feDropShadow dx="${A(l)}" dy="${A(a)}" stdDeviation="${A(r/2)}" flood-color="${Ne(h)}" flood-opacity="${A(u)}"/></filter>`),` filter="url(#${g})"`}function aa(e,n,t,s,i,r){const o=[],l={beginPath(){o.length=0},moveTo(a,d){o.push(`M${A(a)},${A(d)}`)},lineTo(a,d){o.push(`L${A(a)},${A(d)}`)},bezierCurveTo(a,d,c,h,u,g){o.push(`C${A(a)},${A(d)},${A(c)},${A(h)},${A(u)},${A(g)}`)},quadraticCurveTo(a,d,c,h){o.push(`Q${A(a)},${A(d)},${A(c)},${A(h)}`)},arc(a,d,c,h,u,g){const p=a+c*Math.cos(h),m=d+c*Math.sin(h),S=a+c*Math.cos(u),y=d+c*Math.sin(u);let x=u-h;g&&(x=-(Math.PI*2-Math.abs(x)));const w=Math.abs(x)>Math.PI?1:0,k=x>0?1:0;o.length===0&&o.push(`M${A(p)},${A(m)}`),o.push(`A${A(c)},${A(c)},0,${w},${k},${A(S)},${A(y)}`)},arcTo(a,d,c,h,u){o.push(`L${A(a)},${A(d)} L${A(c)},${A(h)}`)},closePath(){o.push("Z")},fill(){},stroke(){},save(){},restore(){},translate(){},rotate(){},scale(){},rect(a,d,c,h){o.push(`M${A(a)},${A(d)}L${A(a+c)},${A(d)}L${A(a+c)},${A(d+h)}L${A(a)},${A(d+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 la=null;function un(e){if(!e)return"";const n=F(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=F(i,"x",0)/914400*96,l=F(i,"y",0)/914400*96,a=F(r,"cx",0)/914400*96,d=F(r,"cy",0)/914400*96,c=o+a/2,h=l+d/2,u=[];return n&&u.push(`rotate(${A(n)},${A(c)},${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-d)})`),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:F(n,"x",0)/914400*96,y:F(n,"y",0)/914400*96,w:F(t,"cx",0)/914400*96,h:F(t,"cy",0)/914400*96}}function ca(e,n,t,s,i,r,o,l){if(!e)return"";const a=b(e,"bodyPr"),d=G(a,"vert","horz"),c=d==="vert"||d==="vert270"||d==="wordArtVert";G(a,"anchor","t");const h=F(a,"lIns",91440)/914400*96,u=F(a,"rIns",91440)/914400*96,g=F(a,"tIns",45720)/914400*96;F(a,"bIns",45720)/914400*96;const p=n+h,m=s-h-u,S=t+g,y=1800,x=b(e,"lstStyle"),w=x?b(x,"defRPr"):null,k=de(e,"p");let v="",_=S;const T=dn("clip");l.push(`<clipPath id="${T}"><rect x="${A(n)}" y="${A(t)}" width="${A(s)}" height="${A(i)}"/></clipPath>`);const N=c?` transform="rotate(-90,${A(n+s/2)},${A(t+i/2)})"`:"",M={};for(const C of k){const j=b(C,"pPr"),$=G(j,"algn","l"),I=F(j,"marL",0)/914400*96,L=F(j,"indent",0)/914400*96,Y=b(j,"defRPr");let W=y;if(w){const D=w.getAttribute("sz");D&&(W=parseInt(D,10))}if(Y){const D=Y.getAttribute("sz");D&&(W=parseInt(D,10))}const B=b(j,"spcBef"),K=b(j,"spcAft");b(j,"lnSpc");let Q=0,O=0;if(B){const D=b(B,"spcPct"),Z=b(B,"spcPts");D?Q=W*wt/914400*96*(F(D,"val",0)/1e5):Z&&(Q=F(Z,"val",0)/100/72*96)}if(K){const D=b(K,"spcPct"),Z=b(K,"spcPts");D?O=W*wt/914400*96*(F(D,"val",0)/1e5):Z&&(O=F(Z,"val",0)/100/72*96)}const z=j?b(j,"buChar"):null,X=j?b(j,"buAutoNum"):null,fe=!(j?b(j,"buNone"):null)&&(z||X);_+=Q;const ae=[];for(const D of C.children)(D.localName==="r"||D.localName==="br"||D.localName==="fld")&&ae.push(D);if(!ae.length){const D=b(C,"endParaRPr"),ee=F(D||Y,"sz",W)/100/72*96*1.2;_+=ee+O;continue}let se="";for(const D of ae){if(D.localName==="br"){se+=`
|
|
107
|
+
`;continue}const Z=b(D,"t")||b(D,"fldVal");Z&&(se+=Z.textContent)}const V=[];for(const D of ae){if(D.localName==="br"){V.push({br:!0});continue}const Z=b(D,"rPr")||b(D,"r")?.firstElementChild,J=b(D,"t");if(!J)continue;const ee=J.textContent;if(!ee)continue;const te=Ms(D,Y,w,r,o,W),E=te?.szPx||W/100/72*96,U=te?.family||"sans-serif",ne=te?.bold?"bold":"normal",he=te?.italic?"italic":"normal",ge=te?.color?me(te.color):"#000000",Te=Z?(Z.getAttribute("u")||"none")!=="none":!1,Pe=Z?(Z.getAttribute("strike")||"noStrike")!=="noStrike":!1,rt=Z?parseInt(Z.getAttribute("baseline")||"0",10):0;V.push({text:ee,szPx:E,family:U,bold:ne,italic:he,color:ge,underline:Te,strike:Pe,baseline:rt})}if(!V.length){_+=O;continue}const _e=V.filter(D=>!D.br&&D.szPx).map(D=>D.szPx),le=_e.length?Math.max(..._e):W/100/72*96,re=le*1.2,ue=_+le*.85;let ye="start",xe=p+I;$==="ctr"?(ye="middle",xe=p+m/2):$==="r"&&(ye="end",xe=p+m);let ve="";if(fe){const D=p+I+L;let Z="";if(z)Z=Ne(z.getAttribute("char")||"•");else if(X){const ee=X.getAttribute("type")||"arabicPeriod",te=F(X,"startAt",1),E=ee+":"+te;M[E]||(M[E]=te),Z=Ne(da(ee,M[E]++))}const J=le;ve=`<text x="${A(D)}" y="${A(ue)}" font-size="${A(J)}" font-family="sans-serif" fill="#000">${Z}</text>`}let ce="";for(const D of V){if(D.br){_+=re,ce+=`<tspan x="${A(xe)}" dy="${A(re)}">`;continue}const Z=D.underline?"underline":D.strike?"line-through":"none";let J=ue;D.baseline>0?J=ue-D.szPx*.38:D.baseline<0&&(J=ue+D.szPx*.12);const ee=D.baseline!==0?D.szPx*.65:D.szPx;ce+=`<tspan font-family="${Ne(D.family)}, sans-serif" font-size="${A(ee)}" font-weight="${D.bold}" font-style="${D.italic}" fill="${Ne(D.color)}"`+(Z!=="none"?` text-decoration="${Z}"`:"")+(D.baseline!==0?` dy="${A(J-ue)}"`:"")+`>${Ne(D.text)}</tspan>`}v+=ve,v+=`<text x="${A(xe)}" y="${A(ue)}" text-anchor="${ye}">${ce}</text>`,_+=re+O}return`<g clip-path="url(#${T})"${N}>${v}</g>`}function da(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return is(n).toLowerCase()+".";case"romanUcPeriod":return is(n)+".";case"alphaLcParenR":return String.fromCharCode(96+n)+")";case"alphaUcParenR":return String.fromCharCode(64+n)+")";default:return n+"."}}function is(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 Kt(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 ua(l,s,i,r):a==="pic"?o+=await fa(l,n,t,s,r):a==="cxnSp"?o+=await ha(l,s):a==="grpSp"?o+=await pa(l,n,t,s,i,r):a==="graphicFrame"&&(o+=await ga(l))}return o}async function ua(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",d=b(i,"custGeom"),c=["noFill","solidFill","gradFill","blipFill","pattFill"];let h=null;for(const _ of c){const T=b(i,_);if(T){h=T;break}}if(!h){const _=b(e,"style"),T=_?b(_,"fillRef"):null;if(T&&F(T,"idx",1)!==0){const N=be(T),M=we(N,n);M&&(h=new DOMParser().parseFromString(`<solidFill xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><srgbClr val="${me(M).replace("#","")}"/></solidFill>`,"application/xml").documentElement)}}const{fill:u,fillAttrs:g}=Vs(h,s,n,o.x,o.y,o.w,o.h);let p=b(i,"ln");if(!p){const _=b(e,"style"),T=_?b(_,"lnRef"):null;if(T&&F(T,"idx",1)!==0){const N=be(T),M=we(N,n);M&&(p=new DOMParser().parseFromString(`<ln xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><solidFill><srgbClr val="${me(M).replace("#","")}"/></solidFill></ln>`,"application/xml").documentElement)}}const m=Hs(p,n),S=b(i,"effectLst"),y=Ys(S,s),x=un(r);let w="";if(a==="rect"||!l&&!d)w=`<rect x="${A(o.x)}" y="${A(o.y)}" width="${A(o.w)}" height="${A(o.h)}" fill="${Ne(u)}"${g}${m}${y}${x}/>`;else{const _=aa(a,o.x,o.y,o.w,o.h,{});w=`<path d="${Ne(_)}" fill="${Ne(u)}"${g}${m}${y}${x}/>`}const k=b(e,"txBody"),v=k?ca(k,o.x,o.y,o.w,o.h,n,t,s):"";return`<g>${w}${v}</g>`}async function fa(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"),d=a?b(a,"blip"):null,c=d?d.getAttribute("r:embed")||d.getAttribute("embed"):null,h=c?n[c]:null,u=h?t[h.fullPath]:null,g=un(o),p=b(r,"effectLst"),m=Ys(p,i);if(!u)return`<rect x="${A(l.x)}" y="${A(l.y)}" width="${A(l.w)}" height="${A(l.h)}" fill="#e0e0e0"${g}/>`;const S=h.fullPath.split(".").pop().toLowerCase(),y=S==="png"?"image/png":S==="gif"?"image/gif":S==="svg"?"image/svg+xml":"image/jpeg",x=u instanceof Uint8Array?u:new Uint8Array(u),w=btoa(Array.from(x,v=>String.fromCharCode(v)).join("")),k=dn("pic");return i.push(`<clipPath id="${k}"><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,${w}" clip-path="url(#${k})"${m}${g} preserveAspectRatio="xMidYMid slice"/>`}async function ha(e,n,t){const s=b(e,"spPr"),i=b(s,"xfrm"),r=Mt(i);if(!r)return"";const o=b(s,"ln"),l=Hs(o,n),a=un(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 pa(e,n,t,s,i,r){const o=b(e,"grpSpPr"),l=b(o,"xfrm");Mt(l);const a=l?un(l):"",d=await Kt(e,n,t,s,i,r);return`<g${a}>${d}</g>`}async function ga(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 ma(e,n,t,s,i,r,o,l,a){const d=g=>{const p=b(g,"cSld"),m=p?b(p,"bg"):null;return m?{bgPr:b(m,"bgPr"),bgRef:b(m,"bgRef")}:null},c=d(e)||d(t)||d(n);if(!c)return`<rect width="${A(o)}" height="${A(l)}" fill="white"/>`;const{bgPr:h,bgRef:u}=c;if(h){const g=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const p of g){const m=b(h,p);if(m){if(p==="blipFill"){const x=b(m,"blip"),w=x?x.getAttribute("r:embed")||x.getAttribute("embed"):null,k=w&&i?i[w]:null,v=k?s[k.fullPath]:null;if(v){const T=k.fullPath.split(".").pop().toLowerCase()==="png"?"image/png":"image/jpeg",N=v instanceof Uint8Array?v:new Uint8Array(v),M=btoa(Array.from(N,C=>String.fromCharCode(C)).join(""));return`<image width="${A(o)}" height="${A(l)}" href="data:${T};base64,${M}" preserveAspectRatio="xMidYMid slice"/>`}}const{fill:S,fillAttrs:y}=Vs(m,a,r,0,0,o,l);return`<rect width="${A(o)}" height="${A(l)}" fill="${Ne(S)}"${y}/>`}}}if(u){const g=be(u),p=we(g,r);if(p)return`<rect width="${A(o)}" height="${A(l)}" fill="${Ne(me(p))}"/>`}return`<rect width="${A(o)}" height="${A(l)}" fill="white"/>`}async function Qs(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 d=s[e],c=t[d]?new TextDecoder().decode(t[d]):null;if(!c)throw new Error(`Cannot read slide ${e}`);const h=Se(c),u=await Be(t,d),g=Object.values(u).find(j=>j.type?.includes("slideLayout")),p=g&&t[g.fullPath]?Se(new TextDecoder().decode(t[g.fullPath])):null,m=g?await Be(t,g.fullPath):{},S=i.cx/914400*96,y=i.cy/914400*96,x=[],w=await ma(h,l,p,t,a,r,S,y,x),k=b(b(l,"cSld"),"spTree"),v=p?b(b(p,"cSld"),"spTree"):null,_=b(b(h,"cSld"),"spTree"),T=k?await Kt(k,a,t,r,o,x):"",N=v?await Kt(v,m,t,r,o,x):"",M=_?await Kt(_,u,t,r,o,x):"",C=x.length?`<defs>${x.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)}">`,C,w,T,N,M,"</svg>"].join(`
|
|
109
|
+
`)}async function ba(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await Qs(t,e));return n}function rs(e){const n=e.replace(/[{}\-]/g,"");if(n.length<32){const a=n.padEnd(32,"0");return ya(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 ya(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 os(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 bn(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 Pn=new Set;async function va(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 d=[...a.children].find(u=>u.localName==="font");if(!d)continue;const c=d.getAttribute("typeface")||d.getAttribute("t");if(!c)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:g,style:p}of h){if(!u)continue;const m=u.getAttribute("r:id")||u.getAttribute("id")||u.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id");if(!m)continue;const S=`${c}:${g}:${p}`;if(Pn.has(S)){t.push({typeface:c,weight:g,style:p,status:"already-loaded"});continue}const y=n?n[m]:null;if(!y){t.push({typeface:c,weight:g,style:p,status:"rel-not-found",rId:m});continue}const x=e[y.fullPath];if(!x){t.push({typeface:c,weight:g,style:p,status:"file-not-found",path:y.fullPath});continue}let w=null;const k=rs(m),v=os(x,k);if(bn(v))w=v;else{const _=y.fullPath.split("/").pop().replace(".fntdata",""),T=rs(_),N=os(x,T);bn(N)?w=N:bn(x)&&(w=x)}if(!w){t.push({typeface:c,weight:g,style:p,status:"decode-failed",path:y.fullPath});continue}try{const _=new FontFace(c,w.buffer,{weight:g,style:p});await _.load(),document.fonts.add(_),Pn.add(S),t.push({typeface:c,weight:g,style:p,status:"loaded",path:y.fullPath})}catch(_){t.push({typeface:c,weight:g,style:p,status:"load-failed",error:_.message})}}}return t}function wa(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(d=>d.localName===a));return{typeface:o,variants:l,loaded:l.some(a=>Pn.has(`${o}:${a==="bold"||a==="boldItalic"?"700":"400"}:${a.includes("talic")?"italic":"normal"}`))}}).filter(i=>i.typeface):[]}function q(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 Ce(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function Tn(e,n,t=0){const s=Ce(e,n);return s!==null?parseInt(s,10):t}function xa(e,n){const t=q(e,"rPr"),s=q(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,d=t&&t.getAttribute("u")||"none";let c="#000000";if(t){const h=q(t,"solidFill")||q(t,"lumMod");if(h){const u=q(h,"srgbClr");u&&(c="#"+(u.getAttribute("val")||"000000"))}}return{text:i,bold:l,italic:a,underline:d!=="none",fontSize:o,color:c}}function ka(e){const n=q(e,"pPr"),t=Ce(n,"algn","l"),s=Tn(n,"lvl",0),i=q(n,"defRPr");let r=null;if(n&&!q(n,"buNone")){const a=q(n,"buChar"),d=q(n,"buAutoNum");a?r=a.getAttribute("char")||"•":d&&(r="{auto}")}const o=[];for(const a of e.children)if(a.localName==="r"){const d=xa(a,i);d&&o.push(d)}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 d=q(a,"t");d&&o.push({text:d.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 jn(e){return e?He(e,"p").map(ka).filter(n=>n.text.trim()):[]}function as(e){const n=q(e,"nvSpPr"),t=n?q(n,"nvPr"):null,s=t?q(t,"ph"):null;if(s){const r=Ce(s,"type","body");if(r==="title"||r==="ctrTitle")return"title";if(r==="subTitle")return"subtitle";if(r==="body")return"body"}return q(e,"txBody")?"textBox":"other"}function ls(e){const n=q(e,"nvSpPr"),t=n?q(n,"cNvPr"):null;return t?Ce(t,"id",""):""}function cs(e){const n=q(e,"nvSpPr"),t=n?q(n,"cNvPr"):null;return t?Ce(t,"name",""):""}function _a(e){const n=q(e,"tbl");if(!n)return null;const t=q(e,"nvGraphicFramePr"),s=t?q(t,"cNvPr"):null,i=s?Ce(s,"id",""):"",r=s?Ce(s,"name",""):"",o=[];let l=0;for(const d of He(n,"tr")){const c=[];let h=0;for(const u of He(d,"tc")){const g=Tn(u,"gridSpan",1),p=Tn(u,"rowSpan",1),m=jn(q(u,"txBody")),S=m.map(y=>y.text).join(`
|
|
111
|
+
`);c.push({row:l,col:h,rowSpan:p,colSpan:g,text:S,paragraphs:m}),h++}o.push(c),l++}const a=o.map(d=>d.map(c=>c.text).join(" ")).join(`
|
|
112
|
+
`);return{id:i,name:r,rows:o,text:a}}function Sa(e,n){const t=q(e,"graphic"),s=t?q(t,"graphicData"):null,i=s?q(s,"chart"):null;if(!i)return null;const r=i.getAttribute("r:id")||i.getAttribute("id"),o=q(e,"nvGraphicFramePr"),l=o?q(o,"cNvPr"):null;return{id:l?Ce(l,"id",""):"",name:l?Ce(l,"name",""):"",rId:r}}function Pa(e){if(!e)return{chartType:"unknown",seriesNames:[],categories:[]};const n=q(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=q(n,a),i){s=a.replace("3DChart","Chart").replace("Chart","");break}const r=i?He(i,"ser"):[],o=r.map(a=>{const d=q(a,"tx");if(!d)return null;const c=q(d,"v");if(c)return c.textContent.trim();const h=q(d,"strCache"),u=h?q(h,"pt"):null,g=u?q(u,"v"):null;return g?g.textContent.trim():null}).filter(Boolean),l=r.length>0?(()=>{const a=q(r[0],"cat")||q(r[0],"xVal");if(!a)return[];const d=q(a,"strCache")||q(a,"numCache");return d?He(d,"pt").map(c=>q(c,"v")?.textContent||"").filter(Boolean):[]})():[];return{chartType:s,seriesNames:o,categories:l}}function Ta(e){if(!e)return"";const n=q(e,"cSld"),t=n?q(n,"spTree"):null;if(!t)return"";const s=[];for(const i of He(t,"sp")){const r=q(i,"nvSpPr"),o=r?q(r,"nvPr"):null,l=o?q(o,"ph"):null;if(l&&Ce(l,"type")==="sldNum")continue;const a=q(i,"txBody");if(a){const d=He(a,"r").map(c=>q(c,"t")?.textContent||"").join("");d.trim()&&s.push(d.trim())}}return s.join(`
|
|
113
|
+
|
|
114
|
+
`)}async function fn(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 ja(e);const r=new DOMParser().parseFromString(new TextDecoder().decode(i),"application/xml"),{getRels:o}=await en(async()=>{const{getRels:v}=await Promise.resolve().then(()=>Eo);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 d="";if(a&&t[a.fullPath]){const v=new DOMParser().parseFromString(new TextDecoder().decode(t[a.fullPath]),"application/xml");d=Ta(v)}const c=q(r,"cSld"),h=c?q(c,"spTree"):null;if(!h)return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:d,text:d};const u=[],g=[],p=[],m=[];for(const v of h.children){const _=v.localName;if(_==="sp"){const T=q(v,"txBody");if(!T)continue;const N=as(v),M=ls(v),C=cs(v),j=jn(T),$=j.map(I=>I.text).join(`
|
|
115
|
+
`);$.trim()&&u.push({id:M,name:C,type:N,paragraphs:j,text:$})}else if(_==="pic"){const T=q(v,"nvPicPr"),N=T?q(T,"cNvPr"):null,M=N?Ce(N,"id",""):"",C=N?Ce(N,"name",""):"",j=N?Ce(N,"descr","")||Ce(N,"title",""):"",$=T?q(T,"nvPr"):null;$&&q($,"extLst"),p.push({id:M,name:C,altText:j,title:C})}else if(_==="graphicFrame"){const T=(()=>{const N=q(v,"graphic"),M=N?q(N,"graphicData"):null;return M?Ce(M,"uri",""):""})();if(T.includes("table")||q(v,"tbl")){const N=_a(v);N&&g.push(N)}else if(T.includes("chart")){const N=Sa(v);if(N){const M=N.rId?l[N.rId]:null;let C={chartType:"chart",seriesNames:[],categories:[]};if(M&&t[M.fullPath]){const j=new DOMParser().parseFromString(new TextDecoder().decode(t[M.fullPath]),"application/xml");C=Pa(j)}m.push({id:N.id,name:N.name,...C})}}}else if(_==="grpSp")for(const T of He(v,"sp")){const N=q(T,"txBody");if(!N)continue;const M=as(T),C=ls(T),j=cs(T),$=jn(N),I=$.map(L=>L.text).join(`
|
|
116
|
+
`);I.trim()&&u.push({id:C,name:j,type:M,paragraphs:$,text:I})}}const S=u.find(v=>v.type==="title"),y=u.find(v=>v.type==="subtitle"),x=S?.text||"",w=y?.text||"",k=[x,w,...u.filter(v=>v.type!=="title"&&v.type!=="subtitle").map(v=>v.text),...g.map(v=>v.text),...m.map(v=>[v.name,...v.seriesNames,...v.categories].join(" ")),d].filter(Boolean).join(`
|
|
117
|
+
|
|
118
|
+
`);return{index:e,title:x,subtitle:w,textShapes:u,tables:g,images:p,charts:m,notes:d,text:k}}function ja(e){return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:"",text:""}}async function Ca(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await fn(t,e));return n}async function Fa(e,n){return(await fn(e,n)).text}async function Na(e,n){const t=e.toLowerCase().trim();if(!t)return[];const s=[];for(let i=0;i<n.slideCount;i++){const r=await fn(i,n),o=r.text.toLowerCase();if(!o.includes(t))continue;const l=[];let a=0;for(;(a=o.indexOf(t,a))!==-1;){const d=Math.max(0,a-60),c=Math.min(r.text.length,a+t.length+60),h=r.text.slice(d,a),u=r.text.slice(a,a+t.length),g=r.text.slice(a+t.length,c);if(l.push({before:(d>0?"…":"")+h,match:u,after:g+(c<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 Ma{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 en(async()=>{const{renderTransitionFrame:d}=await Promise.resolve().then(()=>ra);return{renderTransitionFrame:d}},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(d=>{const c=h=>{const u=Math.min(1,(h-a)/l);s(o,i,r,t,u),u<1?requestAnimationFrame(c):d()};requestAnimationFrame(c)}),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 Zs(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}async function Aa(e,n,t={}){typeof t=="number"&&(t={width:t});const{width:s=null,dpi:i=150}=t,r=s??Zs(n,i),o=await ei(e,n,r),l=o.toDataURL("image/png");if(navigator.clipboard&&window.ClipboardItem)try{const d=await new Promise(c=>o.toBlob(c,"image/png"));return await navigator.clipboard.write([new ClipboardItem({"image/png":d})]),{success:!0,method:"clipboard-api",dataUrl:l}}catch(d){if(d.name!=="NotAllowedError")throw d}if(document.execCommand)try{const d=new Image;d.src=l,await new Promise(p=>{d.onload=p});const c=document.createElement("div");c.contentEditable="true",c.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;",c.appendChild(d),document.body.appendChild(c);const h=document.createRange();h.selectNodeContents(c);const u=window.getSelection();u.removeAllRanges(),u.addRange(h);const g=document.execCommand("copy");if(document.body.removeChild(c),u.removeAllRanges(),g)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 Js(e,n,t={},s){typeof t=="number"&&(t={width:t});const{width:i=null,dpi:r=300,filename:o}=t,l=i??Zs(n,r),d=(await ei(e,n,l)).toDataURL("image/png"),c=o||`slide-${e+1}.png`,h=document.createElement("a");h.href=d,h.download=c,h.click()}async function $a(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 Js(l,e,i),r?.(l+1,o),await new Promise(a=>setTimeout(a,100))}async function ei(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 Ea(e,n,t={}){const{thumbWidth:s=320,fullWidth:i=1280,gap:r="24px",background:o="#1a1a1a",slideBackground:l="#fff",shadow:a=!0,clickToShow:d=!1,maxWidth:c="900px",rootMargin:h=200,onSlideVisible:u,onSlideRendered:g}=t,{cx:p,cy:m}=e.slideSize,S=p/m,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 x=[],w=[],k=[];for(let M=0;M<y;M++){const C=document.createElement("div");C.style.cssText=`
|
|
132
|
+
width:100%;
|
|
133
|
+
max-width:${c};
|
|
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:${p}/${m};
|
|
140
|
+
flex-shrink:0;
|
|
141
|
+
`,C.setAttribute("data-slide",M);const j=document.createElement("div");j.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
|
+
`,j.textContent=M+1,C.appendChild(j);const $=document.createElement("canvas");$.style.cssText="display:block;width:100%;height:100%;",$.width=s,$.height=Math.round(s/S),C.appendChild($);const I=Ra(M,p,m,l);C.appendChild(I),d&&(C.style.cursor="pointer",C.addEventListener("click",()=>{new(require("./slideshow.js")).SlideShow(e,document.body).start(M)})),n.appendChild(C),x.push(C),w.push($),k.push("pending")}const v=[];let _=!1;async function T(){if(!(_||v.length===0)){for(_=!0;v.length>0;){const M=v.shift();if(k[M]==="full")continue;const C=w[M],$=x[M].querySelector("[data-placeholder]");try{C.width=i,C.height=Math.round(i/S),await e.renderSlide(M,C,i),k[M]="full",C.style.transition="opacity 0.3s",C.style.opacity="1",$&&($.style.display="none"),g?.(M)}catch(I){console.warn(`LazyDeck: failed to render slide ${M}`,I)}}_=!1}}const N=new IntersectionObserver(M=>{for(const C of M){if(!C.isIntersecting)continue;const j=parseInt(C.target.getAttribute("data-slide"),10);if(!(isNaN(j)||k[j]==="full")){u?.(j);for(const $ of[j,j-1,j+1,j+2].filter(I=>I>=0&&I<y))k[$]!=="full"&&!v.includes($)&&v.push($);T()}}},{root:n,rootMargin:`${h}px`,threshold:0});return x.forEach(M=>N.observe(M)),{destroy(){N.disconnect(),n.innerHTML=""},scrollTo(M,C="smooth"){const j=x[M];j&&j.scrollIntoView({behavior:C,block:"start"})},async renderAll(M){for(let C=0;C<y;C++)k[C]!=="full"&&v.push(C);await T()},getCanvas(M){return w[M]||null},get slideCount(){return y}}}function Ra(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 Ia{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 Fs(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:F(o,"cx",9144e3),cy:F(o,"cy",5143500)});const l=await Be(this._files,"ppt/presentation.xml");if(this.embeddedFonts=ro(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"),g=l[u];g&&this.slidePaths.push(g.fullPath)}this.slideCount=this.slidePaths.length,t(.2,"Loading theme…");let d=Object.values(l).find(h=>h.type?.includes("theme"))?.fullPath;if(!d){const h=Object.values(l).find(u=>u.type?.includes("slideMaster"));if(h){const u=await Be(this._files,h.fullPath);d=Object.values(u).find(g=>g.type?.includes("theme"))?.fullPath}}if(d){const h=this._readText(d);h&&(this.themeData=Jr(Se(h)))}this.themeData||(this.themeData={colors:{},majorFont:"Calibri Light",minorFont:"Calibri"}),this.themeColors={...this.themeData.colors},t(.3,"Loading master…");const c=Object.values(l).find(h=>h.type?.includes("slideMaster"));if(c){const h=this._readText(c.fullPath);if(h){this.masterDoc=Se(h),this.masterRels=await Be(this._files,c.fullPath),this.masterImages=await Wt(this._files,this.masterRels),this._trackBlobs(this.masterImages);const u=eo(this.masterDoc);this.themeColors=to(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 Be(this._files,i),a=await Wt(this._files,l);this._trackBlobs(a);let d=null,c={},h={};const u=Object.values(l).find(v=>v.type?.includes("slideLayout"));if(u){const v=this._readText(u.fullPath);v&&(d=Se(v),c=await Be(this._files,u.fullPath),h=await Wt(this._files,c),this._trackBlobs(h))}const g={...this.masterImages,...h,...a},p=Ds([d,this.masterDoc]),m=co([o,d,this.masterDoc]);await lo(m,this.themeData);const S=s/this.slideSize.cx,y=Math.round(this.slideSize.cy*S);t.width=s,t.height=y;const x=t.getContext("2d");x.clearRect(0,0,s,y),await Ls(x,o,this.masterDoc,d,l,this.masterRels,g,this.themeColors,S,this.slideSize.cx,this.slideSize.cy),await this._renderNonPlaceholders(x,this.masterDoc,this.masterRels,this.masterImages,S),await this._renderNonPlaceholders(x,d,c,h,S);const w=b(o,"cSld"),k=w?b(w,"spTree"):null;k&&await Os(x,k,l,g,this.themeColors,this.themeData,S,p,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 kn(n,t,s)}registerFonts(n){return io(n)}listRegisteredFonts(){return uo()}_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 d=a.localName;if(!["sp","pic","grpSp","graphicFrame","cxnSp"].includes(d))continue;const c=b(a,"nvSpPr"),h=c?b(c,"nvPr"):null;if(!(h&&b(h,"ph")))try{d==="sp"?await rn(n,a,s,i,this.themeColors,this.themeData,r):d==="pic"?await on(n,a,s,i,this.themeColors,r):d==="grpSp"?await an(n,a,s,i,this.themeColors,this.themeData,r):d==="graphicFrame"?await cn(n,a,this.themeColors,this.themeData,r):d==="cxnSp"&&await ln(n,a,this.themeColors,r)}catch(u){console.warn(`[PptxRenderer] master/layout shape error (${d}):`,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 Rn(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 In(i)}createPlayer(n){return new Xs(this,n)}async toSvg(n){return Qs(n,this)}async allToSvg(){return ba(this)}async loadEmbeddedFonts(){const n=this._presRels||{};return va(this._files,n)}listEmbeddedFonts(){return wa(this._files)}async extractSlide(n){return fn(n,this)}async extractAll(){return Ca(this)}async extractText(n){return Fa(n,this)}async searchSlides(n){return Na(n,this)}createShow(n,t={}){return new Ma(this,n,t)}async copySlide(n,t={}){return Aa(n,this,t)}async downloadSlide(n,t={}){return Js(n,this,t)}async downloadAllSlides(n={}){return $a(this,n)}createDeck(n,t={}){return Ea(this,n,t)}edit(){return Qt.fromRenderer(this)}async toPdf(n={}){return En(this,n)}async downloadPdf(n="presentation.pdf",t={}){return Jo(this,n,t)}async slideToPdf(n,t={}){return ea(n,this,t)}async getSlideNotes(n){if(n<0||n>=this.slidePaths.length)return"";const t=await Be(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 de(r,"sp")){const a=b(b(l,"nvSpPr"),"nvPr"),d=a?b(a,"ph"):null;if(!(d&&G(d,"type")==="sldNum"))for(const c of de(l,"t"))o.push(c.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 za=({asset:e,bytes:n,onOpenExternal:t,dense:s=!1})=>{const i=R.useRef(null),r=R.useRef(null),[o,l]=R.useState({phase:"loading",progress:0}),[a,d]=R.useState(0),[c,h]=R.useState(1),[u,g]=R.useState(0),[p,m]=R.useState(!1),[S,y]=R.useState([]),[x,w]=R.useState(!s),k=R.useRef(null),[v,_]=R.useState(!1);R.useEffect(()=>{w(!s)},[s]),R.useLayoutEffect(()=>{const C=k.current;if(!C)return;const j=()=>_(C.getBoundingClientRect().height<360);j();const $=new ResizeObserver(j);return $.observe(C),()=>$.disconnect()},[]),R.useEffect(()=>{let C=!1;const j=new Ia;return i.current=j,l({phase:"loading",progress:0}),d(0),h(1),j.load(n,$=>{C||l({phase:"loading",progress:$})}).then(async()=>{if(C)return;const $=j.slideCount,L=(await j.renderAllSlides(160)).map(Y=>Y.toDataURL("image/png"));C||l({phase:"ready",slideCount:$,thumbnails:L})}).catch($=>{C||l({phase:"error",detail:$ instanceof Error&&$.message?$.message:P("ui.library.preview.pptx_failed_detail")})}),()=>{C=!0,j.destroy(),i.current=null}},[n,u]);const T=R.useCallback(async()=>{const C=i.current,j=r.current;if(!(!C||!j||o.phase!=="ready"))try{await C.renderSlide(a,j,Math.round(960*c))}catch($){l({phase:"error",detail:$ instanceof Error&&$.message?$.message:P("ui.library.preview.pptx_failed_detail")})}},[a,o.phase,c]);R.useEffect(()=>{T()},[T]),R.useEffect(()=>{const C=i.current;if(!C||o.phase!=="ready")return;let j=!1;return C.extractSlide(a).then($=>{j||y($.textShapes.map(I=>I.text.trim()).filter(Boolean))}).catch(()=>{j||y([])}),()=>{j=!0}},[a,o.phase]);const N=o.phase==="ready"?o.slideCount:0,M=C=>{N!==0&&d(Math.min(Math.max(C,0),N-1))};return o.phase==="error"?f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx("p",{className:"text-body text-ink",children:P("ui.library.preview.pptx_failed")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:o.detail}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(H,{variant:"secondary",size:"sm",onClick:()=>g(C=>C+1),children:P("ui.library.preview.retry")}),f.jsxs(H,{variant:"secondary",size:"sm",disabled:p,onClick:()=>{m(!0),dt(e).catch(C=>Fe(C instanceof Error&&C.message?C.message:P("ui.library.menu.save_failed"))).finally(()=>m(!1))},children:[f.jsx(ct,{"aria-hidden":"true"}),P("ui.library.menu.download")]}),t&&f.jsxs(H,{variant:"ghost",size:"sm",onClick:t,children:[f.jsx(ys,{"aria-hidden":"true"}),P("ui.library.preview.open_externally")]})]})]}):f.jsxs("div",{ref:k,className:"flex min-h-0 flex-1 flex-col gap-2 p-3","data-pptx-viewer":"",onKeyDown:C=>{C.key==="ArrowRight"||C.key==="PageDown"?(C.preventDefault(),M(a+1)):C.key==="ArrowLeft"||C.key==="PageUp"?(C.preventDefault(),M(a-1)):C.key==="Home"?(C.preventDefault(),M(0)):C.key==="End"&&(C.preventDefault(),M(N-1))},children:[f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[f.jsx("div",{"data-pptx-slide":"",className:"flex min-h-[120px] min-w-0 flex-1 flex-col items-center justify-center rounded-md bg-canvas p-2",children:o.phase==="loading"?f.jsxs("div",{className:"flex w-60 flex-col items-center gap-2",children:[f.jsx(Jt,{size:18,"aria-hidden":"true",className:"motion-safe:animate-spin text-ink-muted"}),f.jsx(Wi,{value:Math.round(o.progress*100)}),f.jsx("span",{className:"text-meta text-ink-muted",children:P("ui.library.preview.pptx_preparing")})]}):f.jsx("canvas",{ref:r,className:"max-h-full max-w-full rounded-xs bg-surface","aria-label":P("ui.library.preview.slide_of",{index:String(a+1),count:String(N)})})}),o.phase==="ready"&&!v&&!s&&f.jsx("div",{className:"flex h-[72px] shrink-0 flex-row gap-1 overflow-x-auto overflow-y-hidden",children:o.thumbnails.map((C,j)=>f.jsx("button",{type:"button",onClick:()=>d(j),"aria-pressed":j===a,"aria-label":P("ui.library.preview.go_to_slide",{index:String(j+1)}),className:ke("h-16 w-24 shrink-0 rounded-xs border p-0.5",j===a?"border-accent":"border-hairline hover:border-control"),children:f.jsx("img",{src:C,alt:"",loading:"lazy",className:"h-full w-full rounded-xs object-contain"})},j))})]}),o.phase==="ready"&&f.jsxs("div",{className:"shrink-0 rounded-md bg-canvas px-2 py-1","data-pptx-transcript":"",children:[s?f.jsx(H,{variant:"ghost",size:"sm","aria-expanded":x,onClick:()=>w(C=>!C),children:P("ui.library.preview.pptx_text")}):null,x&&f.jsx("div",{className:"max-h-24 overflow-y-auto text-meta text-ink-muted",children:S.length?S.map((C,j)=>f.jsx("p",{"data-pptx-transcript-line":"",className:"truncate",children:C},`${j}:${C}`)):f.jsx("p",{children:P("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(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.preview.previous_slide"),disabled:a===0||o.phase!=="ready",onClick:()=>M(a-1),children:f.jsx(Mn,{"aria-hidden":"true"})}),f.jsx("span",{className:"text-meta tabular-nums text-ink-muted",children:P("ui.library.preview.slide_of",{index:String(N?a+1:0),count:String(N)})}),f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.preview.next_slide"),disabled:a>=N-1||o.phase!=="ready",onClick:()=>M(a+1),children:f.jsx(qi,{"aria-hidden":"true"})})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.preview.zoom_out"),onClick:()=>h(C=>Math.max(.5,C-.25)),children:f.jsx(Ci,{"aria-hidden":"true"})}),f.jsxs("span",{className:"w-10 text-center text-meta tabular-nums text-ink-muted",children:[Math.round(c*100),"%"]}),f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.preview.zoom_in"),onClick:()=>h(C=>Math.min(2,C+.25)),children:f.jsx(Fi,{"aria-hidden":"true"})}),f.jsx(H,{variant:"ghost",size:"sm",onClick:()=>h(1),disabled:c===1,children:P("ui.library.preview.fit")})]})]})]})},pt=({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(Jt,{size:16,"aria-hidden":"true",className:"motion-safe:animate-spin"}),e??P("ui.library.preview.loading")]}),gt=({detail:e,asset:n})=>{const[t,s]=R.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(it,{kind:n.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:P("ui.library.preview.could_not_load")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:e}),f.jsxs(H,{variant:"secondary",size:"sm",disabled:t,onClick:()=>{s(!0),dt(n).catch(i=>Fe(i instanceof Error&&i.message?i.message:P("ui.library.menu.save_failed"))).finally(()=>s(!1))},children:[f.jsx(ct,{"aria-hidden":"true"}),P("ui.library.menu.download")]})]})},ds=({asset:e})=>f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(it,{kind:e.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"max-w-90 text-body text-ink",children:P("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(H,{variant:"secondary",size:"sm",onClick:()=>{e.ref.path&&window.api.openFile(e.ref.path)},children:P("ui.library.preview.open_externally")}):null,f.jsxs(H,{variant:"secondary",size:"sm",onClick:()=>void dt(e),children:[f.jsx(ct,{"aria-hidden":"true"}),P("ui.library.menu.download")]})]})]}),La=72,Da=({asset:e,mediaSiblings:n})=>{const{bytes:t,mimeType:s,error:i,loading:r}=We(e.id,"content",!0),o=jt(t,s||e.ref.content_type),l=R.useRef(null),a=R.useRef(null),d=R.useRef(null),c=R.useRef(null),[h,u]=R.useState(null),[g,p]=R.useState(null),m=R.useMemo(()=>{const w=(n??[]).filter(k=>k.kind==="image"||k.kind==="video");return w.some(k=>k.id===e.id)?[...w]:[e]},[n,e]),S=Math.max(0,m.findIndex(w=>w.id===e.id)),y=Ye(e);if(R.useEffect(()=>{if(e.kind!=="video"||!o)return;const w=d.current,k=c.current;if(!w||!k)return;const v=()=>{const T=w.getBoundingClientRect(),N=k.getBoundingClientRect(),M=Math.max(0,N.height-La);if(M<=0||N.width<=0){u(j=>j===null?j:null);return}const C={top:N.top-T.top,left:N.left-T.left,width:N.width,height:M};u(j=>j&&j.top===C.top&&j.left===C.left&&j.width===C.width&&j.height===C.height?j:C)};v(),k.addEventListener("loadedmetadata",v),k.addEventListener("loadeddata",v),k.addEventListener("canplay",v),window.addEventListener("resize",v);const _=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return _?.observe(k),_?.observe(w),()=>{_?.disconnect(),k.removeEventListener("loadedmetadata",v),k.removeEventListener("loadeddata",v),k.removeEventListener("canplay",v),window.removeEventListener("resize",v)}},[e.kind,o]),r)return f.jsx(pt,{});if(i||!o)return f.jsx(gt,{detail:i||"The bytes were empty.",asset:e});const x=f.jsx(Hr,{open:g!==null,siblings:m,index:g??S,onIndexChange:p,onClose:()=>p(null),resolved:{assetId:e.id,url:o},restoreFocusTo:e.kind==="video"?a:l});switch(e.kind){case"image":return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",ref:l,"aria-label":y,title:y,onClick:()=>p(S),"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:o,alt:e.name||e.derived_name,className:"block h-auto max-h-full w-auto max-w-full object-contain"})}),x]});case"audio":return f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6",children:[f.jsx(it,{kind:"audio",size:32,className:"text-ink-dim"}),f.jsx("audio",{src:o,controls:!0,className:"w-full max-w-100",children:f.jsx("track",{kind:"captions"})})]});default:return f.jsxs(f.Fragment,{children:[f.jsxs("div",{ref:d,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:c,src:o,controls:!0,className:"max-h-full max-w-full rounded-sm",children:f.jsx("track",{kind:"captions"})}),h?f.jsx("button",{type:"button",tabIndex:-1,"aria-hidden":"true",onClick:()=>p(S),"data-library-media-trigger":"video-surface",className:"absolute z-[1] cursor-zoom-in bg-transparent",style:{top:h.top,left:h.left,width:h.width,height:h.height}}):null,f.jsx(H,{variant:"ghost",size:"icon-sm",ref:a,"aria-label":y,title:y,onClick:()=>p(S),"data-library-media-trigger":"video",className:"absolute top-2 right-2 z-[2]",children:f.jsx(vs,{"aria-hidden":"true"})})]}),x]})}},Ba=({asset:e})=>{const{bytes:n,mimeType:t,error:s,loading:i}=We(e.id,"content",!0),r=jt(n,t||e.ref.content_type);return i?f.jsx(pt,{}):s||!r?f.jsx(gt,{detail:s||"The bytes were empty.",asset:e}):f.jsx("iframe",{title:e.name||e.derived_name,src:r,className:"size-full flex-1 border-0 bg-surface",sandbox:e.kind==="html"?"allow-scripts":void 0})},Oa=({asset:e,text:n})=>{const t=e.ref.type==="path"&&!!e.ref.path&&e.exists,s=e.ref.path,[i,r]=R.useState({state:"pending"});R.useEffect(()=>{if(!t||!s)return;let l=!1;return ai(s).then(a=>{l||r({state:"done",mtimeMs:a?.mtimeMs??null})}),()=>{l=!0}},[t,s]);const o=R.useMemo(()=>!t||!s||i.state!=="done"?null:qr(e,n,i.mtimeMs),[e,t,s,i,n]);return t&&i.state==="pending"?f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center",children:f.jsx(pt,{label:P("ui.library.preview.checking_file")})}):o?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:"mx-auto flex w-full max-w-[760px] flex-col gap-4 px-6 py-8",children:[f.jsx("p",{className:"text-meta text-ink-dim",children:P("ui.library.preview.breadcrumb",{name:o.title})}),f.jsx(li,{document:o})]})}):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:"mx-auto max-w-[720px]",children:[f.jsx("p",{className:"mb-4 text-meta text-ink-muted",children:P("ui.library.preview.read_only_markdown")}),f.jsx("div",{className:"prose-lo max-w-none text-body text-ink",children:f.jsx(Ni,{remarkPlugins:[Mi],children:n})})]})})},Ua=({asset:e})=>{const{bytes:n,error:t,loading:s}=We(e.id,"content",!0);if(s)return f.jsx(pt,{});if(t||!n)return f.jsx(gt,{detail:t||"The bytes were empty.",asset:e});const i=new TextDecoder("utf-8",{fatal:!1}).decode(n);return e.kind==="markdown"?f.jsx(Oa,{asset:e,text:i}):f.jsx("pre",{"data-lo-pane-edge-cues":!0,className:"min-h-0 flex-1 overflow-auto p-4 font-mono text-mono-sm whitespace-pre-wrap break-words text-ink",children:i})},Ga=({asset:e})=>{const{bytes:n,error:t,loading:s}=We(e.id,"content",!0);return s?f.jsx(pt,{}):t||!n?f.jsx(gt,{detail:t||"The bytes were empty.",asset:e}):f.jsx(Wa,{asset:e,bytes:n})},us=200,fs=40,Wa=({asset:e,bytes:n})=>{const t=(()=>{try{const r=ci(n,{type:"array"}),o=r.SheetNames[0];if(!o)return null;const l=di.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:P("ui.library.preview.sheet_unreadable"),asset:e});const s=t.rows.slice(0,us),i=t.rows.length>us;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-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,fs).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,fs).map((l,a)=>f.jsx("td",{className:"max-w-60 truncate border-b border-hairline px-2 py-1 font-mono text-ink",children:String(l??"")},a))]},o))})]}),i&&f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:P("ui.library.preview.sheet_truncated")}),f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:P("ui.library.preview.sheet_name",{name:t.name})})]})},qa=({asset:e,dense:n=!1,mediaSiblings:t})=>e.kind==="pptx"?f.jsx(Ka,{asset:e,dense:n}):e.kind==="image"||e.kind==="audio"||e.kind==="video"?f.jsx(Da,{asset:e,mediaSiblings:t}):e.kind==="pdf"||e.kind==="html"?f.jsx(Ba,{asset:e}):e.kind==="markdown"||e.kind==="text"||e.kind==="code"?f.jsx(Ua,{asset:e}):e.kind==="spreadsheet"?f.jsx(Ga,{asset:e}):e.kind==="docx"?f.jsx(ds,{asset:e}):f.jsx(ds,{asset:e}),Ka=({asset:e,dense:n=!1})=>{const{bytes:t,error:s,loading:i}=We(e.id,"content",!0);return i?f.jsx(pt,{label:P("ui.library.preview.pptx_opening")}):s||!t?f.jsx(gt,{detail:s||"The bytes were empty.",asset:e}):f.jsx(za,{asset:e,bytes:t,dense:n})};function Xa(e){const n=kr(!0),t=Sr().create,s=_r(),[i,r]=R.useState(!1);return{commit:async l=>{r(!0);try{const a=new Map([...n.data??[],...e.tags].map(c=>[c.name.toLowerCase(),c.id])),d=[];for(const c of l){const h=c.trim().toLowerCase();if(!h)continue;let u=a.get(h);u||(u=(await t.mutateAsync({name:h})).id,a.set(h,u)),d.includes(u)||d.push(u)}await s.mutateAsync({id:e.id,tags:d})}catch(a){Fe(a instanceof Error&&a.message?a.message:P("ui.library.preview.tags_not_saved"))}finally{r(!1)}},saving:i}}const hs=({asset:e,nowMs:n,onClose:t,onOpenConversation:s,onFilterSession:i,onAsk:r,onToggleFavorite:o,composerFocusSignal:l,focusRequest:a,standalone:d=!1,onExpand:c,mediaSiblings:h})=>{ht();const u=Ps(),{commit:g,saving:p}=Xa(e),m=R.useRef(null),S=R.useRef(null),y=R.useRef(null),[x,w]=R.useState(0),[k,v]=R.useState(0),[_,T]=R.useState(!1),[N,M]=R.useState(e.id);N!==e.id&&(M(e.id),w(0),v(0),T(!1));const[C,j]=R.useState(!1),[$,I]=R.useState(!1);R.useLayoutEffect(()=>{const O=m.current;if(!O)return;const z=()=>j(O.getBoundingClientRect().height<700);z();const X=new ResizeObserver(z);return X.observe(O),()=>X.disconnect()},[]);const L=R.useMemo(()=>e.tags.map(O=>O.name),[e.tags]),Y=!C||$,W=()=>{T(!0),I(!0)};R.useEffect(()=>{if(!_||!Y)return;const O=y.current;O&&(T(!1),O.scrollIntoView({block:"center"}),v(z=>z+1))},[_,Y]),R.useEffect(()=>{a&&(a.field==="tags"?W():(S.current?.scrollIntoView({block:"center"}),w(O=>O+1)))},[a?.signal]);const B=async O=>{try{await u.mutateAsync({id:e.id,fields:O})}catch(z){throw Fe(z instanceof Error&&z.message?z.message:P("ui.library.preview.not_saved")),z}},K=async O=>{try{await u.mutateAsync({id:e.id,fields:{[O]:!e[O]}})}catch(z){Fe(z instanceof Error&&z.message?z.message:P("ui.library.preview.not_saved"))}},Q=()=>{if(e.ref.type==="path"&&e.ref.path){window.api.openFile(e.ref.path);return}dt(e).catch(()=>Fe(P("ui.library.menu.save_failed")))};return f.jsxs("div",{ref:m,className:"flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-surface","data-library-preview":e.id,"data-library-compact":C?"":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:[d&&f.jsxs(H,{variant:"ghost",size:"sm",className:"self-start",onClick:t,children:[f.jsx(Mn,{"aria-hidden":"true"}),P("ui.library.page.back")]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(it,{kind:e.kind,size:18,className:"text-ink-dim"}),f.jsx("div",{ref:S,className:"min-w-0 flex-1",children:f.jsx(qn,{value:Ye(e),onSave:O=>B({name:O}),label:P("ui.library.preview.name"),textClassName:"text-heading font-medium",field:"name",startSignal:x,className:"min-w-0"},`${e.id}:name`)}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[f.jsx(Bt,{content:e.favorite?P("ui.library.menu.unfavorite"):P("ui.library.menu.favorite"),children:f.jsx(H,{variant:"ghost",size:"icon-sm","aria-pressed":e.favorite,"aria-label":e.favorite?P("ui.library.menu.unfavorite"):P("ui.library.menu.favorite"),onClick:()=>void K("favorite"),children:f.jsx(Pt,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0})})}),f.jsx(Bt,{content:e.locked?P("ui.library.preview.unlock"):P("ui.library.preview.lock"),children:f.jsx(H,{variant:"ghost",size:"icon-sm","aria-pressed":e.locked,"aria-label":e.locked?P("ui.library.preview.unlock"):P("ui.library.preview.lock"),onClick:()=>void K("locked"),children:e.locked?f.jsx(ui,{"aria-hidden":"true",className:"text-accent"}):f.jsx(fi,{"aria-hidden":"true"})})}),c&&f.jsx(Bt,{content:P("ui.library.preview.expand"),children:f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.preview.expand"),onClick:c,children:f.jsx(vs,{"aria-hidden":"true"})})}),f.jsx($n,{asset:e,onAsk:r,onEditMetadata:()=>w(O=>O+1),onEditTags:W,onToggleFavorite:o,onOpenConversation:s,onFilterSession:i}),f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.preview.close"),onClick:t,children:f.jsx(Xe,{"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:P(tn(e.origin_group))}),f.jsx("span",{children:An(e.size_bytes)}),e.width&&e.height?f.jsxs("span",{children:[e.width,"×",e.height]}):null,e.organized?f.jsx("span",{children:P("ui.library.preview.organized_by",{by:e.organized.by??"librarian",at:mr(e.organized.at,n)})}):f.jsx("span",{children:P("ui.library.preview.unorganized")}),e.exists?null:f.jsx(et,{variant:"warning",children:P("ui.library.preview.missing_file")})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs(H,{variant:"secondary",size:"sm",onClick:Q,children:[f.jsx(ys,{"aria-hidden":"true"}),P("ui.library.preview.open")]}),e.ref.type==="path"&&e.ref.path?f.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(vn,{"aria-hidden":"true"}),P("ui.library.preview.reveal")]}):null,f.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>void dt(e).then(()=>wn(P("ui.library.menu.saved_a_copy"))).catch(()=>Fe(P("ui.library.menu.save_failed"))),children:[f.jsx(ct,{"aria-hidden":"true"}),P("ui.library.preview.download")]}),e.occurrences[0]?f.jsx(H,{variant:"link",size:"sm",className:"h-auto max-w-full min-w-0 justify-start whitespace-normal text-left",title:`${P("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:P("ui.library.preview.from_conversation",{title:e.occurrences[0].session_title||e.occurrences[0].session_id})})}):null]}),C&&f.jsxs(H,{variant:"ghost",size:"sm",className:"self-start","aria-expanded":$,onClick:()=>I(O=>!O),children:[f.jsx(Ki,{"aria-hidden":"true",className:ke("transition-transform duration-fast",$&&"rotate-180")}),P("ui.library.preview.details")]}),(!C||$)&&f.jsxs(f.Fragment,{children:[f.jsx(qn,{value:e.description,onSave:O=>B({description:O}),label:P("ui.library.preview.description"),placeholder:P("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(Dr,{value:L,onChange:O=>void g(O),label:P("ui.library.preview.tags"),addLabel:P("ui.library.preview.add_tag"),saving:p,startSignal:k},`${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(qa,{asset:e,dense:C,mediaSiblings:h})}),f.jsx("div",{className:"shrink-0",children:f.jsx(Wr,{asset:e,focusSignal:l,compact:C})})]})},ti="library-view",ni="library-filters",Va=1152,Ha=1200,Ya=900;function Qa(){try{return localStorage.getItem(ti)==="list"?"list":"grid"}catch{return"grid"}}function Za(){try{const e=sessionStorage.getItem(ni);if(!e)return Ot;const n=JSON.parse(e);return{...Ot,...n,scope:n.scope==="all"?"all":"final",q:""}}catch{return Ot}}function Ja(e){try{sessionStorage.setItem(ni,JSON.stringify({...e,q:""}))}catch{}}function el(){const[e,n]=R.useState(null),[t,s]=R.useState(0);return R.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 tl(){const[e,n]=R.useState(()=>window.innerWidth);return R.useEffect(()=>{const t=()=>n(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e}const nl=({enabled:e,nowMs:n})=>{const t=Ss(e),s=jr(),i=Nn(),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:P("ui.library.librarian.title")}),f.jsx("span",{children:r.paused?P("ui.library.librarian.paused"):r.enabled?P("ui.library.librarian.enabled"):P("ui.library.librarian.disabled")}),f.jsx("span",{children:o?P("ui.library.librarian.last_organized",{at:sl(o,n)}):P("ui.library.librarian.never_run")}),l!==null&&l>0&&f.jsx("span",{children:P("ui.library.librarian.unorganized",{count:l})}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[f.jsxs(H,{variant:"ghost",size:"sm",disabled:!r.enabled||s.isPending,onClick:()=>s.mutate("run",{onError:a=>Fe(a instanceof Error?a.message:P("ui.library.librarian.control_failed"))}),children:[f.jsx(yn,{"aria-hidden":"true"}),P("ui.library.librarian.organize_now")]}),f.jsx(H,{variant:"ghost",size:"sm",disabled:!r.session_id||s.isPending,onClick:()=>s.mutate("open",{onSuccess:a=>{a?.session_id&&bt(i,a.session_id)},onError:a=>Fe(a instanceof Error?a.message:P("ui.library.librarian.control_failed"))}),children:P("ui.library.librarian.open")})]})]})};function sl(e,n){const t=Math.max(0,n-e*1e3),s=Math.floor(t/36e5);return s<24?P("ui.library.time.hours_h_ago",{hours:s}):P("ui.library.time.days_d_ago",{days:Math.floor(s/24)})}const il=({onBack:e})=>f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Dt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:P("ui.library.preview.unavailable")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:P("ui.library.preview.unavailable_detail")}),f.jsxs(H,{variant:"secondary",size:"sm",onClick:e,children:[f.jsx(Mn,{"aria-hidden":"true"}),P("ui.library.page.back")]})]}),rl=({nowMs:e})=>{ht();const n=Ai("surface"),t=Nn(),s=$i(),i=Ei(),r=Ri(),o=Ii(r.data,"library",1),l=Ss(o),a=e??Date.now(),{ref:d,width:c}=el(),h=tl(),u=new URLSearchParams(s.search).get("full")==="1",g=h>=Ha&&c>=Ya,[p,m]=R.useState(Za),[S,y]=R.useState(""),x=hi(S,200),[w,k]=R.useState(Qa),[v,_]=R.useState(!1),[T,N]=R.useState(0),[M,C]=R.useState(null),j=R.useRef(null),$=i.assetId??null,I=c>=Va&&!!$&&!u;R.useEffect(()=>{m(E=>E.q===x?E:{...E,q:x})},[x]),R.useEffect(()=>Ja(p),[p]),R.useEffect(()=>{try{localStorage.setItem(ti,w)}catch{}},[w]);const L=wr(p,o),Y=Ps(),W=xr($,o),B=R.useMemo(()=>{const E=L.data?.pages??[],ne=E.length>1&&E.at(-1)?.cursor_reset?[E.at(-1)]:E,he=new Set,ge=[];for(const Te of ne)for(const Pe of Te?.rows??[])he.has(Pe.id)||(he.add(Pe.id),ge.push(Pe));return ge},[L.data]),K=L.data?.pages.at(-1),Q=K?.total??0,O=R.useMemo(()=>B.filter(E=>E.kind==="image"||E.kind==="video"),[B]),z=B.find(E=>E.id===$)??null,X=W.data??z,ie=()=>void L.fetchNextPage(),fe=!!($&&!X&&!W.isLoading&&W.isError),ae=!!$&&!I,se=R.useCallback(E=>{t(`/library/assets/${E}${s.search}`,{state:s.state})},[t,s.search,s.state]),V=R.useCallback(()=>{const E=new URLSearchParams(s.search);E.delete("full");const U=E.toString();t(`/library${U?`?${U}`:""}`)},[t,s.search]),_e=R.useCallback(()=>{if(!$)return;const E=new URLSearchParams(s.search);E.set("full","1"),t(`/library/assets/${$}?${E.toString()}`)},[t,$,s.search]),le=R.useCallback(E=>{se(E.id),N(U=>U+1)},[se]),re=R.useCallback(E=>{Y.mutate({id:E.id,fields:{favorite:!E.favorite}})},[Y]),ue=R.useCallback(E=>void bt(t,E),[t]),ye=R.useCallback(E=>{m(U=>({...U,session:E})),t("/library")},[t]),xe={onSelect:se,onAsk:le,onEditMetadata:E=>{se(E.id),C({field:"metadata",signal:Date.now()})},onEditTags:E=>{se(E.id),C({field:"tags",signal:Date.now()})},onToggleFavorite:re,onOpenConversation:ue,onFilterSession:ye};if(R.useEffect(()=>{const E=U=>{const ne=U.target;if(ne?.closest('[role="dialog"]'))return;const he=ne?.tagName==="INPUT"||ne?.tagName==="TEXTAREA"||ne?.isContentEditable;if(U.key==="f"&&(U.metaKey||U.ctrlKey)||U.key==="/"&&!he){U.preventDefault(),j.current?.focus();return}if(!(he||U.metaKey||U.ctrlKey||U.altKey)){if(U.key==="Escape"){($||X)&&V();return}if(U.key.toLowerCase()==="g"){U.preventDefault(),k(ge=>ge==="grid"?"list":"grid");return}if(U.key.toLowerCase()==="j"||U.key.toLowerCase()==="k"){if(ae||B.length===0)return;U.preventDefault();const ge=$?B.findIndex(rt=>rt.id===$):-1,Te=U.key.toLowerCase()==="j"?1:-1,Pe=Math.min(Math.max(ge===-1?Te===1?0:B.length-1:ge+Te,0),B.length-1);se(B[Pe].id)}}};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[V,se,B,X,$,ae]),!o)return f.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[f.jsx(Di,{title:P("ui.library.page.title"),icon:Dt}),r.isLoading?f.jsx("div",{className:"flex justify-center py-16",children:f.jsx(Xt,{label:P("ui.library.page.checking")})}):f.jsx(gn,{variant:"warning",children:P("ui.library.page.unavailable")})]});const ve=l.data?.library?.total??null,ce=f.jsx(Lr,{filters:p,onChange:E=>{m({...E,q:E.q}),y(E.q)},counts:K?.counts,tags:K?.tags??[],total:Q,scopeTotal:ve}),D=B.length===0&&!L.isLoading,Z=hr(p)||!!S.trim(),J=(()=>{const E=[];if(S.trim()&&E.push({key:"search",label:`${P("ui.library.page.search")}: ${S.trim()}`,clear:()=>y("")}),p.category){const U=xn.find(ne=>ne.key===p.category);E.push({key:"category",label:U?P(U.labelKey):p.category,clear:()=>m(ne=>({...ne,category:void 0}))})}if(p.originGroup&&E.push({key:"origin",label:P(tn(p.originGroup)),clear:()=>m(U=>({...U,originGroup:void 0}))}),p.status){const U=p.status==="highlighted"?"ui.library.status.highlighted":p.status==="unorganized"?"ui.library.status.unorganized":"ui.library.status.favorites";E.push({key:"status",label:P(U),clear:()=>m(ne=>({...ne,status:void 0}))})}return p.highlighted&&p.status!=="highlighted"&&E.push({key:"highlighted",label:P("ui.library.status.highlighted"),clear:()=>m(U=>({...U,highlighted:!1}))}),p.tag&&E.push({key:"tag",label:`${P("ui.library.filter.tags")}: ${p.tag}`,clear:()=>m(U=>({...U,tag:void 0}))}),p.session&&E.push({key:"session",label:P("ui.library.filter.one_conversation"),clear:()=>m(U=>({...U,session:void 0}))}),(p.scope!=="final"||E.length>0)&&E.push({key:"scope",label:`${P("ui.library.filter.scope")}: ${p.scope==="all"?P("ui.library.filter.scope_all"):P("ui.library.filter.scope_final")}`,clear:()=>m(U=>({...U,scope:"final"}))}),E})(),ee=()=>{m(E=>({...Ot,scope:E.scope,sort:E.sort,order:E.order})),y("")},te=L.error instanceof Error&&L.error.message?L.error.message:P("ui.library.page.load_failed");return f.jsxs("div",{ref:d,"data-glass-region":"canvas","data-glass-split":"",className:"flex h-full min-h-0 overflow-hidden bg-canvas",children:[g&&!ae&&f.jsx("aside",{ref:n,"data-library-rail":"","data-glass-region":"page-sidebar","aria-label":P("ui.library.page.filters"),className:"flex h-full w-48 shrink-0 flex-col overflow-hidden bg-surface",children:ce}),!ae&&f.jsxs("div",{"data-glass-region":"canvas-content",className:"flex min-w-0 flex-1 flex-col",children:[f.jsxs("header",{"data-library-header":"",className:"flex shrink-0 flex-col gap-1 px-6 pt-4 pb-2 min-[800px]:min-h-[136px]",children:[f.jsxs("div",{className:"flex h-12 min-w-0 items-center gap-2",children:[f.jsx(Dt,{size:20,"aria-hidden":"true",className:"text-ink-muted"}),f.jsx("h1",{className:"text-title text-ink",children:P("ui.library.page.title")}),f.jsx("span",{className:"ml-2 text-meta tabular-nums text-ink-dim",children:P("ui.library.page.loaded_count",{loaded:String(B.length),total:String(Q)})}),f.jsxs("div",{className:"ml-auto flex items-center rounded-sm border border-control",children:[f.jsx(H,{variant:"ghost",size:"icon-sm","aria-pressed":w==="grid","aria-label":P("ui.library.page.grid_view"),onClick:()=>k("grid"),children:f.jsx(zi,{"aria-hidden":"true"})}),f.jsx(H,{variant:"ghost",size:"icon-sm","aria-pressed":w==="list","aria-label":P("ui.library.page.list_view"),onClick:()=>k("list"),children:f.jsx(pi,{"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(Li,{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(Xi,{ref:j,value:S,onChange:E=>y(E.target.value),onKeyDown:E=>{E.key==="Enter"&&E.preventDefault()},placeholder:P("ui.library.page.search"),"aria-label":P("ui.library.page.search"),"data-library-search":"",className:"border-0 bg-elevated pl-8"})]}),f.jsxs(ws,{children:[f.jsx(xs,{asChild:!0,children:f.jsxs(H,{variant:"ghost",size:"sm",className:"bg-elevated text-ink",children:[f.jsx(Gn,{"aria-hidden":"true"}),P("ui.library.page.sort")]})}),f.jsx(ks,{align:"end",className:"min-w-45",children:ur.map(E=>f.jsxs(Ae,{onSelect:()=>m(U=>({...U,sort:E.key,order:fr(E.key)})),children:[p.sort===E.key?f.jsx(Vi,{"aria-hidden":"true"}):f.jsx("span",{className:"size-4"}),f.jsx("span",{children:P(E.labelKey)})]},E.key))})]}),f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.page.reverse_order"),onClick:()=>m(E=>({...E,order:E.order==="asc"?"desc":"asc"})),children:p.order==="asc"?f.jsx(sr,{"aria-hidden":"true"}):f.jsx(Gn,{"aria-hidden":"true"})}),!g&&!ae&&f.jsxs(H,{variant:"ghost",size:"sm",className:"bg-elevated text-ink",onClick:()=>_(!0),children:[f.jsx(gi,{"aria-hidden":"true"}),P("ui.library.page.filters")]})]}),J.length>0&&f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[J.map((E,U)=>f.jsxs("span",{className:"contents",children:[U>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:E.label}),f.jsx("button",{type:"button","aria-label":`${P("ui.library.filter.clear_filters")} — ${E.label}`,onClick:E.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(Xe,{size:12,"aria-hidden":"true"})})]})]},E.key)),f.jsx(H,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-meta",onClick:ee,children:P("ui.library.page.clear_all")})]}),f.jsx("div",{"data-library-librarian-track":"",className:"min-h-10 shrink-0",children:f.jsx(nl,{enabled:o,nowMs:a})}),K?.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:P("ui.library.page.building",{scanned:String(K.scan.sessions_scanned),total:String(K.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:!ae&&f.jsx("section",{"data-library-results":"","aria-label":P("ui.library.page.results"),"aria-busy":L.isLoading||L.isFetching,className:"min-w-0 flex-1 overflow-y-auto px-4 py-4 [scrollbar-gutter:stable]",children:L.isLoading?f.jsx(Ir,{view:w}):L.isError&&B.length===0?f.jsxs("div",{className:"flex flex-col items-start gap-3 py-10",children:[f.jsx(gn,{variant:"warning",children:te}),f.jsxs(H,{variant:"secondary",size:"sm",onClick:()=>void L.refetch(),children:[f.jsx(yn,{"aria-hidden":"true"}),P("ui.library.page.retry")]})]}):D?f.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-center",children:[f.jsx(Dt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:Z?`${P("ui.library.page.no_matches")}: ${J.map(E=>E.label).join(" + ")}`:P("ui.library.page.empty_title")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:Z?P("ui.library.page.no_matches_detail"):P("ui.library.page.empty_detail")}),Z&&f.jsx(H,{variant:"secondary",size:"sm",onClick:ee,children:P("ui.library.page.clear_all")})]}):f.jsxs(f.Fragment,{children:[L.isRefetchError&&f.jsx(gn,{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:te}),f.jsxs(H,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void L.refetch(),children:[f.jsx(yn,{"aria-hidden":"true"}),P("ui.library.page.retry")]})]})}),f.jsx(Rr,{assets:B,selectedId:$,view:w,hasMore:!!L.hasNextPage,loadingMore:L.isFetchingNextPage,onLoadMore:ie,...xe}),L.isFetchNextPageError&&f.jsxs("div",{className:"flex items-center gap-2 py-3 text-meta text-ink-muted",children:[f.jsx("span",{children:P("ui.library.page.load_more_failed")}),f.jsx(H,{variant:"ghost",size:"sm",onClick:ie,children:P("ui.library.page.retry")})]})]})})})})]}),I&&X&&f.jsx("aside",{className:"flex h-full w-[448px] shrink-0 bg-surface","aria-label":P("ui.library.page.preview"),children:f.jsx(hs,{asset:X,nowMs:a,onClose:V,onOpenConversation:ue,onFilterSession:ye,onAsk:()=>N(E=>E+1),onToggleFavorite:()=>re(X),composerFocusSignal:T,focusRequest:M,onExpand:_e,mediaSiblings:O})}),ae&&f.jsx("div",{className:"min-w-0 flex-1","aria-label":P("ui.library.page.preview"),children:fe?f.jsx(il,{onBack:V}):X?f.jsx(hs,{asset:X,nowMs:a,onClose:V,onOpenConversation:ue,onFilterSession:ye,onAsk:()=>N(E=>E+1),onToggleFavorite:()=>re(X),composerFocusSignal:T,focusRequest:M,mediaSiblings:O,standalone:!0}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(Xt,{label:P("ui.library.preview.loading")})})}),!ae&&!X&&I&&f.jsx("div",{className:"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:P("ui.library.page.select_asset")})}),f.jsx(Hi,{open:v,onOpenChange:_,children:f.jsx(Yi,{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:P("ui.library.page.filters")}),f.jsx(H,{variant:"ghost",size:"icon-sm","aria-label":P("ui.library.page.close_filters"),onClick:()=>_(!1),children:f.jsx(Xe,{"aria-hidden":"true"})})]}),f.jsx("div",{"data-library-filter-sheet":"",className:"min-h-0 flex-1 overflow-y-auto bg-surface",children:ce})]})})})]})},pl=Object.freeze(Object.defineProperty({__proto__:null,LibraryPage:rl},Symbol.toStringTag,{value:"Module"}));export{de as a,G as b,b as g,pl as l};
|