@betteroffice/pptx-react 0.1.1 → 0.5.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/README.md +115 -102
- package/dist/chunk-3Y6BQIW3.js +1 -0
- package/dist/chunk-66PPYFHW.js +4 -0
- package/dist/chunk-HGG45CCF.js +1 -0
- package/dist/chunk-HQ2N3DQ7.js +1 -0
- package/dist/chunk-J3YQUJUG.js +1 -0
- package/dist/chunk-M267LYSF.js +1 -0
- package/dist/chunk-O2XFH626.js +1 -0
- package/dist/chunk-V62S3LXB.js +1 -0
- package/dist/chunk-X2M23RXQ.js +1 -0
- package/dist/chunk-X6B77B3U.js +1 -0
- package/dist/index.d.ts +1137 -46
- package/dist/index.js +1 -4
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
# @betteroffice/pptx-react
|
|
2
2
|
|
|
3
|
-
React
|
|
4
|
-
|
|
5
|
-
slide canvas, slide strip, formatting toolbar, and keyboard editing surface.
|
|
6
|
-
Parsing, layout, and text shaping run in the core's Rust/WebAssembly engine;
|
|
7
|
-
slides are painted onto canvas.
|
|
3
|
+
React presentation editor with a slide canvas, slide strip, formatting toolbar, and keyboard editing.
|
|
4
|
+
The engine runs in a Web Worker by default, with promise-returning reads and exports.
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
## Install
|
|
10
7
|
|
|
11
8
|
```bash
|
|
12
|
-
bun add @betteroffice/pptx-react
|
|
9
|
+
bun add @betteroffice/pptx-react react react-dom
|
|
13
10
|
```
|
|
14
11
|
|
|
15
|
-
`react` and `react-dom
|
|
12
|
+
Peer dependencies: `react` and `react-dom`, version 18 or 19; the PPTX core is a package dependency.
|
|
16
13
|
|
|
17
|
-
##
|
|
14
|
+
## Usage
|
|
18
15
|
|
|
19
16
|
```tsx
|
|
20
17
|
import { PptxEditor } from '@betteroffice/pptx-react';
|
|
@@ -31,107 +28,123 @@ export function Presentation({ file, fontBytes }: {
|
|
|
31
28
|
}
|
|
32
29
|
```
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
with
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
##
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
`
|
|
46
|
-
|
|
47
|
-
`
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
31
|
+
`fonts` is required. Each entry is a family name and the bytes of a TTF or OTF file, for example
|
|
32
|
+
fetched from your server or loaded with `loadBundledFontBytes` from
|
|
33
|
+
[`@betteroffice/fonts`](https://www.npmjs.com/package/@betteroffice/fonts).
|
|
34
|
+
|
|
35
|
+
## Key options
|
|
36
|
+
|
|
37
|
+
The exported `PptxAsyncEditorProps` type describes the default editor props. All props below are
|
|
38
|
+
optional except `fonts`.
|
|
39
|
+
|
|
40
|
+
| prop | type | description |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `file` | `Uint8Array \| ArrayBuffer` | Presentation bytes to open. |
|
|
43
|
+
| `fonts` | `ReadonlyArray<PptxFontFace>` | Font families and bytes for text layout. |
|
|
44
|
+
| `readOnly` | `boolean` | Block user edits while retaining navigation and selection. |
|
|
45
|
+
| `initialSlide` | `number` | Initial slide, numbered from 1 and clamped to the deck. |
|
|
46
|
+
| `fileName` | `string` | Download name; defaults to `presentation.pptx`. |
|
|
47
|
+
| `className` | `string` | Class for the editor container. |
|
|
48
|
+
| `style` | `CSSProperties` | Inline styles for the editor container. |
|
|
49
|
+
| `initialZoom` | `number` | Initial zoom scale from 0.1 to 5; omitted, the slide fits the stage. |
|
|
50
|
+
| `loadingIndicator` | `ReactNode` | Shown while the presentation opens. |
|
|
51
|
+
| `i18n` | `PptxAsyncEditorProps['i18n']` | UI translations from `@betteroffice/pptx-i18n`. |
|
|
52
|
+
| `onReady` | `(api: PptxAsyncEditorApi) => void \| (() => void)` | Receive the async API; optionally return cleanup. |
|
|
53
|
+
| `onChange` | `(snapshot: DeckSnapshot) => void` | Receive deck snapshots after changes. |
|
|
54
|
+
| `onDocumentChange` | `(change: PptxDocumentChange) => void` | Receive `{ version }` after a committed edit, alongside `onChange`. |
|
|
55
|
+
| `onError` | `(error: Error) => void` | Receive loading and editing errors. |
|
|
56
|
+
| `onSave` | `(bytes: Uint8Array) => void` | Receive saved bytes; omitted, saving downloads the file. |
|
|
57
|
+
| `downloadOnSave` | `boolean` | Whether saving also downloads a copy; defaults to `true` only without `onSave`. |
|
|
58
|
+
| `onSaveRequest` | `() => boolean \| void \| Promise<boolean \| void>` | Intercept toolbar and keyboard saves; return `true` to continue. |
|
|
59
|
+
| `toolbar` | `ReactNode` | Replace built-in controls; `null` removes them. |
|
|
60
|
+
| `showToolbar` | `boolean` | Show the toolbar region; defaults to `true`. |
|
|
61
|
+
| `collaboration` | `PptxAsyncCollaborationOptions` | Shared seed, replica callback, and presence options. |
|
|
62
|
+
| `plugins` | `readonly PptxPlugin[]` | Host-owned tools, panels, and overlays. |
|
|
63
|
+
| `pluginGrants` | `Readonly<Record<string, PptxPluginGrant>>` | Permissions keyed by plugin ID. |
|
|
64
|
+
| `onPluginError` | `(error: PptxPluginError) => void` | Receive isolated plugin failures. |
|
|
65
|
+
|
|
66
|
+
`PptxFontFace` and `DeckSnapshot` are exported by `@betteroffice/pptx`; editor and plugin types are
|
|
67
|
+
exported by `@betteroffice/pptx-react`. `ReactNode` is a React type.
|
|
68
|
+
|
|
69
|
+
Deprecated: `legacySyncApi` keeps the synchronous API on the in-thread engine and is removed in 0.6.0;
|
|
70
|
+
omit it to use the default async editor. Also omit the deprecated `experimentalWorkerOpen` prop.
|
|
71
|
+
|
|
72
|
+
## Editor API
|
|
73
|
+
|
|
74
|
+
`onReady` receives `PptxAsyncEditorApi`. Await `save()` to serialize the presentation (`saveAsync()` is a
|
|
75
|
+
deprecated alias), and await
|
|
76
|
+
`handleAsync()` for asynchronous document access, including `snapshot()`, `exportStructured()`, and
|
|
77
|
+
`exportMarkdown()`. Reads and exports through that access object return promises; the API also has
|
|
78
|
+
`exportStructured()` and `exportMarkdown()` directly. Work that cannot run against its input or
|
|
79
|
+
target rejects with `PptxCommandAdmissionError`.
|
|
80
|
+
|
|
81
|
+
`flushPendingInput()` waits for accepted input. `goToSlide(slide)` and `selectText(target)` return
|
|
82
|
+
promises; slide numbers are 1-based and text offsets use UTF-16. `getPositionAtPoint(clientX, clientY)`
|
|
83
|
+
asynchronously returns a hit on the current slide or `null` outside slide content.
|
|
84
|
+
|
|
85
|
+
Finish pointer gestures before workflows that flush input. Keep the API tied to the mounted
|
|
86
|
+
presentation; replacing or closing the document invalidates its access.
|
|
87
|
+
|
|
88
|
+
## Saving
|
|
89
|
+
|
|
90
|
+
The toolbar and Ctrl/Cmd+S invoke `onSaveRequest` before serialization. Its result is awaited:
|
|
91
|
+
`true` continues saving, while `false` or `void` handles or cancels the request. If saving continues,
|
|
92
|
+
`onSave` receives the bytes, and the editor downloads the file using `fileName` when `downloadOnSave`
|
|
93
|
+
is `true` (the default without `onSave`).
|
|
94
|
+
|
|
95
|
+
Calling `save()` directly returns bytes without invoking those save callbacks.
|
|
96
|
+
|
|
97
|
+
## Toolbar
|
|
98
|
+
|
|
99
|
+
The toolbar composition API is experimental. `api.commands` is shared by the built-in controls and
|
|
100
|
+
host toolbar parts. Replace controls with
|
|
101
|
+
`toolbar`, or hide the region with `showToolbar={false}`.
|
|
102
|
+
See [Compose the PPTX toolbar](https://docs.betteroffice.dev/docs/javascript#compose-the-pptx-toolbar)
|
|
103
|
+
for composition, external controls, command state, and overflow.
|
|
104
|
+
|
|
105
|
+
Deprecated: prop-based `EditorToolbar` and `Toolbar` usage is replaced by command-mode controls;
|
|
106
|
+
use `EditorToolbar` with `mode="commands"`.
|
|
107
|
+
|
|
108
|
+
## Plugins
|
|
109
|
+
|
|
110
|
+
`definePptxPlugin` defines tools installed through `plugins`, with permissions supplied by
|
|
111
|
+
`pluginGrants`. This plugin API is experimental and may change in minor releases.
|
|
112
|
+
See [Host PPTX editor plugins](https://docs.betteroffice.dev/docs/javascript#host-pptx-editor-plugins)
|
|
113
|
+
for panels, overlays, lifecycle, permissions, and error handling.
|
|
114
|
+
|
|
115
|
+
## Version-checked edit batches
|
|
116
|
+
|
|
117
|
+
`readContent`, `findText`, `validateEdits`, and `applyEdits` on the editor API return promises and run
|
|
118
|
+
after pending input. See [Edit PPTX in version-checked batches](https://docs.betteroffice.dev/docs/javascript#edit-pptx-in-version-checked-batches)
|
|
119
|
+
for requests, atomicity, and typed refusals.
|
|
62
120
|
|
|
63
121
|
## Review agent proposals
|
|
64
122
|
|
|
65
|
-
Use the
|
|
66
|
-
|
|
123
|
+
Use the access returned by `handleAsync()` to call `propose`, then await `refreshProposals()`.
|
|
124
|
+
Pending proposals appear on the canvas with text differences, shape bounds, and speaker-note diffs.
|
|
125
|
+
The review controls preview, accept, or reject a group; acceptance creates one undo step.
|
|
67
126
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
type: 'setSlideNotes',
|
|
71
|
-
slideId: api.handle.snapshot().slides[0].id,
|
|
72
|
-
text: 'Explain the customer outcome before the implementation details.',
|
|
73
|
-
}]);
|
|
74
|
-
api.refreshProposals();
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Pending edits appear directly on the slide canvas: deleted text is red and
|
|
78
|
-
struck through, inserted text is green and underlined, and moved/resized shapes
|
|
79
|
-
show their previous and proposed bounds. Speaker notes have their own inline
|
|
80
|
-
text diff. The canvas toolbar selects a proposal when several affect the slide
|
|
81
|
-
and provides acceptance, rejection, and access to review details. Acceptance is
|
|
82
|
-
available after the current diff has painted successfully.
|
|
83
|
-
|
|
84
|
-
The canvas is in review mode while showing a diff. **Edit slide** (or Escape)
|
|
85
|
-
returns to normal editing; **Show changes** restores the diff. This keeps
|
|
86
|
-
temporary review offsets separate from editable text. Saving, PNG export, and
|
|
87
|
-
presentation mode use the actual document. Changes from other users refresh the
|
|
88
|
-
review, and stale targets require the explicit review described below.
|
|
89
|
-
|
|
90
|
-
The **Agent proposals** button shows the pending count. Each group shows its
|
|
91
|
-
author, rationale, targets, and text changes. **Preview** opens current and
|
|
92
|
-
proposed slide renderings, with a target selector for groups spanning multiple
|
|
93
|
-
shapes or slides. Notes changes also appear as text because notes are outside
|
|
94
|
-
the slide canvas.
|
|
95
|
-
|
|
96
|
-
Accepting a group updates the editor, calls `onChange`, and creates one Undo
|
|
97
|
-
step. Rejecting it leaves the deck untouched. If a target changed, preview its
|
|
98
|
-
current state before choosing **Apply updated proposal**. A further target
|
|
99
|
-
change detected at that click refreshes the preview for another review.
|
|
100
|
-
|
|
101
|
-
Pending proposals are session-local and disappear when the deck closes. Only
|
|
102
|
-
accepted edits are saved and synchronized. Existing host-driven edits may keep
|
|
103
|
-
using `api.refresh()`, which also refreshes the proposal list.
|
|
127
|
+
Escape or **Edit slide** exits review mode. Saving, PNG export, and presentation mode use committed
|
|
128
|
+
content. Pending proposals stay in the session; accepted edits are saved and synchronized.
|
|
104
129
|
|
|
105
130
|
## Collaboration
|
|
106
131
|
|
|
107
|
-
Pass
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
Pass `collaboration` to co-edit a deck; `onReplica` receives an async replica or `null` on cleanup.
|
|
133
|
+
Set `roomId` when switching rooms and seed peers from the same update. Omit `clientId` to generate
|
|
134
|
+
one for each opened session.
|
|
135
|
+
See the [collaboration guide](https://docs.betteroffice.dev/docs/collaboration) for transport setup.
|
|
110
136
|
|
|
111
|
-
|
|
112
|
-
import { CollaborationProvider } from '@betteroffice/pptx';
|
|
113
|
-
|
|
114
|
-
<PptxEditor
|
|
115
|
-
file={file}
|
|
116
|
-
fonts={fonts}
|
|
117
|
-
collaboration={{
|
|
118
|
-
clientId,
|
|
119
|
-
initialUpdate: sharedSeed,
|
|
120
|
-
onReplica: (replica) => {
|
|
121
|
-
if (!replica) return;
|
|
122
|
-
const provider = new CollaborationProvider(replica, transport, {
|
|
123
|
-
user: { name: "Ada" }, // shown on this peer's presence chip
|
|
124
|
-
});
|
|
125
|
-
provider.connect();
|
|
126
|
-
},
|
|
127
|
-
}}
|
|
128
|
-
/>;
|
|
129
|
-
```
|
|
137
|
+
## Browser integration
|
|
130
138
|
|
|
131
|
-
|
|
139
|
+
Mount the editor in the browser with a container of explicit height. Frameworks that render on the
|
|
140
|
+
server should load the editor client-side with server rendering disabled. See [hosting](https://docs.betteroffice.dev/docs/migrating-to-0-5#hosting) for
|
|
141
|
+
worker, chunk and CSP needs.
|
|
132
142
|
|
|
133
|
-
|
|
134
|
-
`next/dynamic` and `ssr: false`.
|
|
143
|
+
## Documentation
|
|
135
144
|
|
|
136
|
-
[JavaScript guide](https://docs.betteroffice.dev/docs/javascript)
|
|
137
|
-
[
|
|
145
|
+
- [JavaScript guide](https://docs.betteroffice.dev/docs/javascript)
|
|
146
|
+
- [Collaboration guide](https://docs.betteroffice.dev/docs/collaboration)
|
|
147
|
+
- [Package guide](https://docs.betteroffice.dev/docs/packages)
|
|
148
|
+
- [PPTX core: @betteroffice/pptx](https://www.npmjs.com/package/@betteroffice/pptx)
|
|
149
|
+
- [UI translations: @betteroffice/pptx-i18n](https://www.npmjs.com/package/@betteroffice/pptx-i18n)
|
|
150
|
+
- [Repository](https://github.com/openooxml/betteroffice)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-O2XFH626.js';import {sizeCanvasForSlide,paintSlide}from'@betteroffice/pptx';import {useRef,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';function K({handle:x,slideCount:n,startIndex:H,resolveImage:y,label:P,counterLabel:S,exitLabel:k,previousLabel:D,nextLabel:W,onExit:d,onError:E}){let C=useRef(null),m=useRef(null),M=useRef(null),u=useRef({onExit:d,onError:E});u.current={onExit:d,onError:E};let[z,h]=useState(H),a=Math.max(0,Math.min(z,n-1)),[f,B]=useState({width:0,height:0}),s=e=>h(Math.max(0,Math.min(a+e,n-1)));return useEffect(()=>{h(e=>Math.max(0,Math.min(e,n-1))),n===0&&u.current.onExit();},[n]),useEffect(()=>{let e=m.current,o=C.current,p=document.activeElement,r=true;e.showModal(),e.focus(),o.requestFullscreen?.().then(()=>{r?(e.close(),e.showModal(),e.focus()):document.fullscreenElement===o&&document.exitFullscreen().catch(()=>{});}).catch(()=>{});let c=()=>{document.fullscreenElement||u.current.onExit();},l=()=>B({width:window.innerWidth,height:window.innerHeight});return l(),window.addEventListener("resize",l),document.addEventListener("fullscreenchange",c),()=>{r=false,window.removeEventListener("resize",l),document.removeEventListener("fullscreenchange",c),document.fullscreenElement===o&&document.exitFullscreen().catch(()=>{}),e.close(),p instanceof HTMLElement&&p.isConnected&&p.focus();}},[]),useEffect(()=>{let e=M.current;if(!e||n===0||f.width<=0||f.height<=0)return;let o=false;return (async()=>{let r=x.layoutSlide(a),c=document.createElement("canvas"),l=c.getContext("2d");if(!l)return;let b=Math.min(f.width/r.width,f.height/r.height),v=window.devicePixelRatio||1;sizeCanvasForSlide(c,r,v,b),await paintSlide(l,r,v,b,{resolveImage:y}),!o&&(sizeCanvasForSlide(e,r,v,b),e.getContext("2d")?.drawImage(c,0,0));})().catch(r=>{o||(u.current.onError(r),u.current.onExit());}),()=>{o=true;}},[x,a,n,y,f]),jsx("div",{ref:C,children:jsxs("dialog",{ref:m,"aria-label":P,tabIndex:-1,style:i.presentationOverlay,onCancel:e=>{e.preventDefault(),d();},onClick:e=>{e.target===m.current&&s(1);},onKeyDown:e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){switch(e.key){case " ":if(e.target instanceof HTMLElement&&e.target.closest("button"))return;s(1);break;case "ArrowRight":case "ArrowDown":case "PageDown":s(1);break;case "ArrowLeft":case "ArrowUp":case "PageUp":s(-1);break;case "Home":h(0);break;case "End":h(Math.max(0,n-1));break;case "Escape":d();break;default:return}e.preventDefault(),e.stopPropagation();}},children:[jsx("canvas",{ref:M,style:i.presentationCanvas}),jsx("button",{type:"button",onClick:d,"aria-label":k,title:k,style:i.presentationExit,children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:jsx("path",{d:"M6 6 18 18M18 6 6 18"})})}),jsxs("div",{style:i.presentationControls,children:[jsx("button",{type:"button",onClick:()=>s(-1),disabled:a===0,"aria-label":D,style:i.presentationNavButton,children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4","aria-hidden":"true",children:jsx("path",{d:"m15 6-6 6 6 6"})})}),jsx("span",{style:i.presentationCounter,"aria-live":"polite",children:S(a+1,n)}),jsx("button",{type:"button",onClick:()=>s(1),disabled:a>=n-1,"aria-label":W,style:i.presentationNavButton,children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4","aria-hidden":"true",children:jsx("path",{d:"m9 6 6 6-6 6"})})})]})]})})}var i={presentationOverlay:{position:"fixed",margin:0,padding:0,border:0,width:"100vw",height:"100vh",maxWidth:"none",maxHeight:"none",inset:0,zIndex:2147483e3,display:"flex",alignItems:"center",justifyContent:"center",background:"#000000",cursor:"pointer"},presentationCanvas:{display:"block",pointerEvents:"none"},presentationExit:{position:"absolute",top:16,right:16,display:"inline-flex",alignItems:"center",justifyContent:"center",width:36,height:36,border:0,borderRadius:999,background:"rgba(255, 255, 255, 0.14)",color:"#ffffff",cursor:"pointer"},presentationControls:{position:"absolute",bottom:20,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:12,padding:"6px 14px",borderRadius:999,background:"rgba(255, 255, 255, 0.12)"},presentationNavButton:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,border:0,borderRadius:999,background:"rgba(255, 255, 255, 0.14)",color:"#ffffff",cursor:"pointer"},presentationCounter:{minWidth:64,color:"#ffffff",fontSize:12,fontWeight:600,textAlign:"center"}};export{K as PresentationOverlay};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {ba as ba$1,Z,L,_,c,f,k,e,W,d,Y,X as X$1,b as b$1,t,J,x as x$1,E,G,F,K,j,a as a$2,o,p,$,u,l as l$1,i,h,m,H,I,g,s,M,R,T,V,n,r as r$1}from'./chunk-X6B77B3U.js';import {a as a$1,b,x,A,l,s as s$1,r,w,y,v,C,D,X as X$2,k as k$1,m as m$1,u as u$1,t as t$1}from'./chunk-X2M23RXQ.js';import {a}from'./chunk-O2XFH626.js';import {sizeCanvasForSlide,paintSlide,StaleProposalError,initWasm,openPresentation,PRESENCE_LABEL_DURATION_MS,PptxPeerNotReadyError,presentationImageBlob,openPresentationSession,PptxWorkerEditorDisposedError,decodePresentationImage,createPptxWorkerEditorSession,slideToPng}from'@betteroffice/pptx';import {memo,useCallback,useSyncExternalStore,useRef,useEffect,useMemo,useState,useLayoutEffect,Component,lazy,Suspense}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function De(e){let[t,r]=useState(e),i=useRef(t),s=useCallback(u=>{let h=typeof u=="function"?u(i.current):u;i.current=h,r(h);},[]);return [t,s,i]}function ti(e,t,r,i){let[s,u,h]=De(true),[m,x,p]=De(null),d=r?.slides[i]?.id,g=useMemo(()=>t.filter(F=>F.changes.some(P=>P.slideId===d)),[t,d]),v=g.find(F=>F.id===m)??g[0]??null,I=useMemo(()=>{if(!s||!e||!v)return {diff:null,error:null};try{return {diff:e.layoutProposalDiffSlide(v.id,i),error:null}}catch(F){return {diff:null,error:F instanceof Error?F.message:String(F)}}},[s,e,v,i,r]);return useEffect(()=>{u(true),x(null);},[e,u,x]),{...I,available:g,selected:v,enabled:s,setEnabled:u,select:x,reviewing:s&&v!==null,enabledRef:h,selectedIdRef:p}}function ni({review:e,ready:t}){let{t:r}=b(),i=C(),s=e.selected?.id??"",u=D("proposalAccept",{proposalId:s}),h=D("proposalReject",{proposalId:s}),m=e.enabled&&!t,x=u.enabled?e.error?r("commands.reasons.previewFailed"):m?r("commands.reasons.previewPending"):void 0:u.disabledReason.message,p=u.enabled&&!e.error&&!m,d=X$2(!p,x),g=X$2(!h.enabled,h.enabled?void 0:h.disabledReason.message);if(!e.selected)return null;let v=e.selected.staleTargets.length>0;return jsxs("div",{style:re.toolbar,"data-testid":"pptx-canvas-review-toolbar",children:[jsxs("div",{style:re.row,children:[jsxs("label",{style:re.label,children:[r("proposals.canvasTitle"),jsx("select",{"aria-label":r("proposals.canvasTitle"),value:e.selected.id,onChange:I=>{i.execute("proposalSelect",{proposalId:I.target.value});},style:re.select,children:e.available.map((I,F)=>jsxs("option",{value:I.id,children:[F+1,". ",I.agentId,I.note?` \xB7 ${I.note}`:""]},I.id))})]}),jsx("button",{type:"button",style:re.button,"data-testid":"pptx-canvas-review-toggle","aria-pressed":e.enabled,onClick:()=>{i.execute("proposalDiff",{enabled:!e.enabled});},children:r(e.enabled?"proposals.editSlide":"proposals.showDiff")}),jsx("button",{type:"button",style:re.button,onClick:()=>{i.execute("proposalsPanel",{open:true});},children:r("proposals.details")}),jsx("button",{type:"button",style:{...re.primary,opacity:p?1:.45,cursor:p?"pointer":"default"},...d.props,title:d.reason,"data-testid":"pptx-canvas-proposal-accept",onClick:()=>{p&&i.execute("proposalAccept",{proposalId:s});},children:r("proposals.accept")}),d.node,jsx("button",{type:"button",style:re.button,...g.props,title:g.reason,"data-testid":"pptx-canvas-proposal-reject",onClick:()=>{h.enabled&&i.execute("proposalReject",{proposalId:s});},children:r("proposals.reject")}),g.node]}),e.enabled&&jsxs("div",{style:re.legend,children:[jsx("span",{style:re.removed,children:r("proposals.removed")}),jsx("span",{style:re.added,children:r("proposals.added")}),jsx("span",{children:r("proposals.reviewHint")})]}),v&&jsx("p",{role:"status",style:re.warning,children:r("proposals.canvasStale")}),e.error&&jsx("p",{role:"alert",style:re.warning,children:e.error})]})}function ri({diff:e,current:t,frame:r,slideIndex:i,scale:s,resolveImage:u,onTarget:h,onPainted:m}){let{t:x}=b(),p=useRef(null),[d,g]=useState(null),[v,I]=useState(null),F=t.slides[i]?.id,P=e.proposal.changes.filter(S=>S.slideId===F&&S.shapeId&&S.before&&S.after);return useEffect(()=>{let S=false,O=p.current;if(!O)return;let M=document.createElement("canvas"),z=M.getContext("2d"),B=O.getContext("2d");if(!z||!B)return;let G=window.devicePixelRatio||1;return sizeCanvasForSlide(M,e.frame,G,s),O.dataset.ready="false",g(null),paintSlide(z,e.frame,G,s,{resolveImage:u,textChanges:e.textChanges}).then(()=>{S||(sizeCanvasForSlide(O,e.frame,G,s),B.setTransform(1,0,0,1,0,0),B.drawImage(M,0,0),O.dataset.ready="true",I(e),m(e));}).catch(J=>{S||g(J instanceof Error?J.message:String(J));}),()=>{S=true;}},[e,s,u,m]),jsxs("div",{style:re.overlay,"data-testid":"pptx-canvas-proposal-diff",children:[jsx("canvas",{ref:p,role:"img","aria-label":x("proposals.canvasTitle"),style:{...re.canvas,visibility:v===e?"visible":"hidden"}}),v!==e&&!d&&jsx("p",{role:"status",style:re.paintError,children:x("proposals.loadingDiff")}),P.map(S=>{let O=k(t,r,S.before),M=k(e.snapshot,e.frame,S.after);if(!M)return null;let z=O&&(O.x!==M.x||O.y!==M.y||O.width!==M.width||O.height!==M.height),B=G=>({left:G.x*s,top:G.y*s,width:Math.max(1,G.width*s),height:Math.max(1,G.height*s)});return jsxs("div",{children:[z&&jsx("span",{"data-testid":"pptx-proposal-old-bounds",style:{...re.outline,...B(O),borderColor:"#b91c1c",borderStyle:"dashed",pointerEvents:"none"},"aria-hidden":"true",children:jsx("span",{style:{...re.tag,color:"#b91c1c",background:"#fee2e2"},children:x("proposals.previousPosition")})}),jsx("button",{type:"button","data-testid":"pptx-proposal-canvas-target","aria-label":`${e.proposal.agentId}: ${S.after.name}`,onClick:()=>h(S.slideId,S.shapeId),style:{...re.outline,...B(M),borderColor:"#16a34a",cursor:"pointer"},children:z&&jsx("span",{style:{...re.tag,left:"auto",right:-1,color:"#166534",background:"#dcfce7"},children:x("proposals.proposedPosition")})})]},S.shapeId)}),jsx("div",{style:re.srOnly,children:P.map(S=>jsxs("p",{children:[S.after.name,": ",jsx("del",{children:S.oldText})," ",jsx("ins",{children:S.newText})]},S.shapeId))}),d&&jsx("p",{role:"alert",style:re.paintError,children:d})]})}function oi({diff:e,slideId:t}){let{t:r}=b(),i=e?.proposal.changes.find(s=>s.slideId===t&&!s.shapeId&&s.oldText!==s.newText);return i?jsxs("section",{"aria-label":r("notes.panelLabel"),style:re.notes,"data-testid":"pptx-proposal-notes-diff",children:[jsx("strong",{children:r("notes.panelLabel")}),jsx("del",{style:re.removed,children:i.oldText||r("proposals.blank")}),jsx("ins",{style:re.added,children:i.newText||r("proposals.blank")})]}):null}var re={toolbar:{flex:"0 0 auto",padding:"10px 14px",background:"#fff",borderBottom:"1px solid #dbe3ee",fontSize:12},row:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},label:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8,minWidth:0,fontWeight:600},select:{maxWidth:260,minWidth:80,padding:5,border:"1px solid #cbd5e1",borderRadius:4,font:"inherit"},legend:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,marginTop:8,color:"#64748b"},removed:{color:"#b91c1c",background:"#fee2e2",textDecoration:"line-through",padding:"2px 5px"},added:{color:"#166534",background:"#dcfce7",textDecoration:"underline",padding:"2px 5px"},button:{padding:"5px 9px",border:"1px solid #cbd5e1",borderRadius:5,background:"#fff",color:"#334155",cursor:"pointer",font:"inherit"},primary:{padding:"5px 9px",border:"1px solid #4338ca",borderRadius:5,background:"#4338ca",color:"#fff",cursor:"pointer",font:"inherit"},warning:{margin:"8px 0 0",color:"#92400e"},overlay:{position:"absolute",inset:0,overflow:"hidden",background:"#fff"},canvas:{position:"absolute",inset:0,display:"block",pointerEvents:"none"},outline:{position:"absolute",border:"1px solid",background:"transparent",padding:0},tag:{position:"absolute",left:-1,top:-18,fontSize:11,lineHeight:"16px",padding:"0 4px",whiteSpace:"nowrap"},srOnly:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},notes:{display:"grid",gap:6,padding:"10px 14px",maxHeight:160,overflow:"auto",background:"#fff",fontSize:12,whiteSpace:"pre-wrap"},paintError:{position:"absolute",top:8,left:8,right:8,padding:8,background:"#fff1f2",color:"#b91c1c"}};var Ve=class extends Error{constructor(r){super(r instanceof Error?r.message:String(r));a(this,"cause",r);}},je=class extends Error{constructor(){super("The presentation was replaced before queued work ran");}};function ii(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}var lt=()=>{};function si(e=lt){let t=Promise.resolve(),r=0,i=0,s=0,u=[],h=new Map,m=(p,d)=>{let g=s;r+=1,d==="keyboard"&&(i+=1),d&&u.push(p),r===1&&e();let v=I=>{g===s&&(I&&d&&h.set(p,I.value),u=u.filter(F=>F!==p),r-=1,d==="keyboard"&&(i-=1),r===0&&(h.clear(),e()));};p.then(()=>v(),I=>v({value:I}));},x=p=>{let d=s,g=t.then(()=>{if(d!==s)throw new je;return p()});return t=g.then(lt,lt),g};return {busy:()=>r>0,keyboardQueued:()=>i>0,input(p,d="other"){if(r===0){let v;try{v=p();}catch(F){return Promise.reject(F)}if(!ii(v))return Promise.resolve();let I=Promise.resolve(v);return t=I.then(lt,lt),m(I,d),I}let g=x(p);return m(g,d),g},run(p){let d=[...u],g=()=>{for(let I of d)if(h.has(I))throw new Ve(h.get(I));return p()};if(r===0){let I;try{I=p();}catch(P){return Promise.reject(P)}if(!ii(I))return Promise.resolve(I);let F=Promise.resolve(I);return t=F.then(lt,lt),m(F,null),F}let v=x(g);return m(v,null),v},reset(){s+=1;let p=r>0;t=Promise.resolve(),r=0,i=0,u=[],h.clear(),p&&e();}}}function li(e){let t=e?.fill?.type==="none"?null:ai(e?.resolvedFillColor),r=ai(e?.resolvedOutlineColor);return {geometry:e?.geometry,fillColor:t,strokeColor:r,strokeWidthPt:r&&e?.outline?.width!==void 0?e.outline.width/12700:r?1:null,adjustments:e?.adjustValues??{}}}function ai(e){if(!e)return null;let t=e.replace(/^#/,"");return /^[0-9a-f]{6}$/i.test(t)?`#${t}`:null}function ln(e,t,r,i){let s=ba(e,t,r,i),u=St(s,"underline");return {bold:St(s,"bold"),italic:St(s,"italic"),underline:u===void 0?void 0:u!=="none",fontSize:St(s,"fontSizePt"),textColor:St(s,"color"),fontFamily:St(s,"fontFamily")}}function di(e,t){return ln(e,0,e.length,t)}var ga={left:"l",center:"ctr",right:"r",justify:"just"},ya={l:"l",ctr:"ctr",r:"r",just:"just",justLow:"just",dist:"just",thaiDist:"just"};function ci(e,t,r,i){let s=Pa(e),u=s[s.length-1]?.end??0,h=Math.min(Math.min(r,i),u),m=Math.max(r,i),x=s.map((d,g)=>({range:d,index:g})).filter(({range:d})=>h===m?h>=d.start&&h<=d.end:h<=d.end&&m>d.start).map(({index:d})=>xa(e,t,d));if(x.length===0)return;let p=x[0];return x.every(d=>d===p)?p:void 0}function xa(e,t,r){let i=e.paragraphs[r]?.alignment;if(i)return ya[i]??"l";let s=t?.paragraphs[r]?.align;return s?ga[s]??"l":"l"}function Pa(e){let t=0;return e.paragraphs.map(r=>{let i=t+r.runs.reduce((u,h)=>u+h.text.length,0),s={start:t,end:i};return t=i+1,s})}function ui(e,t,r,i){let s=ln(e,t,r,i);return {bold:s.bold??i.bold,italic:s.italic??i.italic,underline:s.underline===void 0?i.underline:s.underline?"sng":"none",fontSizePt:s.fontSize??i.fontSizePt,color:s.textColor??i.color,fontFamily:s.fontFamily??i.fontFamily}}function ba(e,t,r,i){let s=va(e,i);if(s.length===0)return [i];let u=Math.min(t,r),h=Math.max(t,r);if(u===h){let p=s.find(g=>u>=g.start&&u<g.end);return p?[p.style]:[[...s].reverse().find(g=>g.end<=u)?.style??s[0].style]}let m=s.filter(p=>p.end>u&&p.start<h).map(p=>p.style);return m.length>0?m:[[...s].reverse().find(p=>p.end<=u)?.style??s[0].style]}function va(e,t){let r=[],i=0;return e.paragraphs.forEach((s,u)=>{for(let h of s.runs){let m=i;i+=h.text.length,i>m&&r.push({start:m,end:i,style:Sa(h.style,t)});}u<e.paragraphs.length-1&&(i+=1);}),r}function Sa(e,t){return {bold:e.bold??t.bold,italic:e.italic??t.italic,underline:e.underline??t.underline,fontSizePt:e.fontSizePt??t.fontSizePt,color:e.color??t.color,fontFamily:e.fontFamily??t.fontFamily}}function St(e,t){let r=e[0]?.[t];return e.every(i=>i[t]===r)?r:void 0}var fi=new Set(["insertImage","save","exportPng","slideshow","zoom","proposalsPanel","proposalSelect","proposalDiff"]),ka=new Set(["bold","italic","underline","fontFamily","fontSize","fontSizeStep","textColor","alignment"]),Ta=new Set(["shapeFill","shapeStrokeColor","shapeStrokeWidth","shapeAdjustment","zOrder"]),Ra=new Set(["insertSlide","tool"]);function mi(e){if(!e)return null;let t=e.replace(/^#/,"");return /^[0-9a-f]{6}$/i.test(t)?`#${t.toLowerCase()}`:null}function dr(e){return e===void 0?"mixed":e}function Aa(e,t){return `${t+1}. ${e.agentId}${e.note?` \xB7 ${e.note}`:""}`}function hi(e,t){return {id:e.id,label:Aa(e,t),stale:e.staleTargets.length>0}}function Be(e){return {ok:true,status:e?"executed":"noop"}}var cr={ok:true,status:"opened"};function dn(e){let t=e.modelRef.current;return t?.snapshot.slides[t.slideIndex]??null}function yi(e){let t=dn(e),r=e.shapeSelectionRef.current;return !t||!r||t.id!==r.slideId?null:c(t.shapes,r.shapeId)}function Fa(e){let t=e.handleRef.current,r=e.selectionRef.current,i=r?null:yi(e)?.textStories[0]?.id??null,s=r?.storyId??i;if(!t||!s)return null;try{let u=t.story(s),h=e.modelRef.current?.frame?.primitives.find(g=>g.kind==="textBox"&&g.storyId===s),m=r?r.anchor:0,x=r?r.focus:u.length,p=ci(u,h,m,x)??null;if(r&&r.anchor===r.focus){let g=e.textStyleRef.current;return {kind:"caret",bold:g.bold,italic:g.italic,underline:g.underline!=="none",fontFamily:g.fontFamily,fontSize:g.fontSizePt,color:mi(g.color),alignment:p}}let d=r?ln(u,r.anchor,r.focus,e.baseStyle):di(u,e.baseStyle);return {kind:r?"range":"shape",bold:dr(d.bold),italic:dr(d.italic),underline:dr(d.underline),fontFamily:d.fontFamily??null,fontSize:d.fontSize??null,color:mi(d.textColor),alignment:p}}catch{return "unsupported"}}function La(e){let t=dn(e),r=yi(e);if(!t||!r)return null;let i=li(r),s=t.shapes.findIndex(u=>u.id===r.id);return {formattable:r.kind==="shape",geometry:r.geometry??null,fill:i.fillColor??null,stroke:i.strokeColor??null,strokeWidth:i.strokeWidthPt??null,adjustments:r.adjustValues??{},order:s>=0?{index:s,count:t.shapes.length}:null}}function gi(e,t){if(ka.has(t)){let r=e.selectionRef.current;return JSON.stringify(r?[r.shapeId,r.storyId,r.anchor,r.focus]:e.shapeSelectionRef.current)}return Ta.has(t)?JSON.stringify(e.shapeSelectionRef.current):Ra.has(t)?dn(e)?.id??null:null}function xi(e,t){let r$1=useRef(t);r$1.current=t;let i=useMemo(()=>{let h=p=>{let d=r$1.current,g=d.handleRef.current,v=d.status==="ready"&&g!==null,I=dn(d),F=d.modelRef.current,P,S,O=[...new Set(F?.snapshot.slides.map($=>$.layoutPartPath)??[])],M=d.readOnlyRef.current,z=d.proposalsRef.current,B=M?[]:z.filter($=>$.changes.some(Ae=>Ae.slideId===I?.id)),G=B.find($=>$.id===d.reviewSelectedIdRef.current)??B[0]??null,J=!d.workerMode&&d.reviewEnabledRef.current;return {status:v?"ready":d.status==="ready"?"loading":d.status,readOnly:M,reviewing:J&&G!==null,pendingInput:!p&&d.coordinator.busy(),canUndo:v&&g.canUndo(),canRedo:v&&g.canRedo(),slide:I?{id:I.id,layoutPartPath:I.layoutPartPath}:null,layouts:O.map(($,Ae)=>({args:{layoutPartPath:$},label:d.t("toolbar.layoutOption",{number:Ae+1})})),get text(){return P===void 0&&(P=v?Fa(d):null),P},get shape(){return S===void 0&&(S=v?La(d):null),S},tool:d.activeToolRef.current,zoom:d.zoomRef.current,fontFamilies:r,fontSizes:s$1,proposals:d.proposalsAvailable?{open:d.proposalsOpenRef.current,pending:z.map(hi),canvas:{available:B.map(hi),selectedId:G?.id??null,diff:J}}:null,hostDisabled:d.workerMode?$=>d.workerMode.preparing||["exportPng","slideshow","proposalSelect","proposalDiff"].includes($):void 0,translate:d.workerMode?($,Ae)=>$==="commands.reasons.hostDisabled"||$==="commands.reasons.documentLoading"?d.t(d.workerMode.failed?"worker.failed":d.workerMode.preparing?"worker.preparing":"worker.disabled"):d.t($,Ae):d.t}},m=(p,d)=>({ok:false,failure:m$1(p,d)});return {environment:h,ordered:p=>!fi.has(p),admit(p){return r$1.current.coordinator.run(p).catch(d=>{throw d instanceof Ve?new w("input-failed"):d instanceof je?new w("document-replaced"):d})},perform:(p,d,g)=>{let{actions:v}=r$1.current,I=d,F=g.text&&g.text!=="unsupported"?g.text:null,P=S=>{try{return Be(S())}catch(O){return v.reportError(O),m("command-failed",g)}};switch(p){case "bold":return P(()=>v.format({bold:F?.bold!==true}));case "italic":return P(()=>v.format({italic:F?.italic!==true}));case "underline":return P(()=>v.format({underline:F?.underline===true?"none":"sng"}));case "fontFamily":return P(()=>v.format({fontFamily:I.family}));case "fontSize":return P(()=>v.format({fontSizePt:I.points}));case "fontSizeStep":return P(()=>v.format({fontSizePt:u$1(F?.fontSize??t$1,g.fontSizes,I.direction==="increase"?1:-1)}));case "textColor":return P(()=>v.format({color:I.color}));case "alignment":return P(()=>v.align(I.value));case "insertSlide":return P(()=>v.insertSlide(I.layoutPartPath));case "insertImage":return v.openPicker(),cr;case "tool":return Be(v.setTool(I.value));case "shapeFill":return P(()=>v.formatShape({type:"fillColor",value:I.color}));case "shapeStrokeColor":return P(()=>v.formatShape({type:"strokeColor",value:I.color}));case "shapeStrokeWidth":return P(()=>v.formatShape({type:"strokeWidth",value:I.points}));case "shapeAdjustment":return P(()=>v.formatShape({type:"adjust",name:I.name,value:I.value}));case "zOrder":return P(()=>v.formatShape({type:"zOrder",value:I.value}));case "save":return v.save().then(S=>{switch(S){case "saved":return Be(true);case "requested":return {ok:true,status:"requested"};case "replaced":return m("document-replaced",g);case "gesture":return m("gesture-active",g);case "input-failed":return m("input-failed",g);default:return m("command-failed",g)}});case "exportPng":return v.exportPng().then(S=>{switch(S){case "exported":return Be(true);case "replaced":return m("document-replaced",g);case "input-failed":return m("input-failed",g);default:return m("command-failed",g)}});case "slideshow":return v.present(),cr;case "undo":case "redo":return P(()=>v.history(p));case "zoom":return Be(v.setZoom(I.scale));case "proposalsPanel":{let S=d===null?!g.proposals.open:!!I.open;return S===g.proposals.open?Be(false):(v.setProposalsOpen(S),S?cr:Be(true))}case "proposalSelect":return v.selectProposal(I.proposalId),Be(true);case "proposalDiff":return !!I.enabled===g.proposals?.canvas.diff?Be(false):(v.showProposalDiff(!!I.enabled),Be(true));case "proposalAccept":try{return v.acceptProposal(I.proposalId,!!I.force)==="accepted"?Be(!0):m("proposal-stale",g)}catch(S){return v.reportError(S),m("command-failed",g)}case "proposalReject":return P(()=>v.rejectProposal(I.proposalId));default:return m("unsupported-command",g)}},capture(p){let d=r$1.current;return d.handleRef.current?{id:p,generation:d.generationRef.current,target:d.coordinator.keyboardQueued()?null:gi(d,p)}:null},resume(p){let d=r$1.current,{id:g,generation:v,target:I}=p;return d.handleRef.current?v!==d.generationRef.current?"document-replaced":I!==null&&I!==gi(d,g)?"target-changed":g!=="tool"&&!fi.has(g)&&d.gestureActive()?"gesture-active":null:"editor-unavailable"},chrome:()=>({i18n:r$1.current.i18n}),focusEditor:()=>r$1.current.actions.focusEditor()}},[]);useLayoutEffect(()=>(e.attach(i),()=>e.detach(i)),[i,e]),useLayoutEffect(()=>{e.refresh();},t.stamp);let{handle:s,handleRef:u}=t;return useEffect(()=>{if(!s||u.current!==s)return;let h=false;return s.onUpdate(()=>{h||(h=true,queueMicrotask(()=>{h=false,e.refresh();}));})},[s,u,e]),useCallback((h,m)=>v(h,m,i.environment(true)),[i])}var Si=Object.freeze([]);function wi(e){let t=useRef(e);t.current=e;let r=useRef(null),[i]=useState(()=>R({...e.access,translate:z=>t.current.t(z),geometry:()=>r.current})),s=(e.plugins?.length??0)>0;useLayoutEffect(()=>{i.setReporter(e.onPluginError);}),useLayoutEffect(()=>{i.modeChanged(e.readOnly);},[i,e.readOnly]),useLayoutEffect(()=>{i.setGrants(e.pluginGrants);}),useLayoutEffect(()=>{i.setPlugins(e.plugins);},[i,e.plugins]),useEffect(()=>()=>i.close("unmounted"),[i]),useEffect(()=>{if(!(!e.handle||e.access.handle()!==e.handle))return i.open(e.handle),()=>i.close("document-replaced")},[i,e.access,e.handle]),useEffect(()=>(i.syncCommands(),i.subscribe(()=>i.syncCommands())),[i]);let u=useSyncExternalStore(i.subscribe,i.activations,()=>Si);useEffect(()=>{s&&i.selectionChanged(e.selection);},[i,s,e.selection]);let h=useRef(null),[m,x]=useState(null),p=useCallback(z=>{h.current=z,z||i.layoutChanged(null),t.current.plugins?.length&&x(z);},[i]);useEffect(()=>{s&&x(h.current);},[s]);let[d,g]=useState(null),[v,I]=useState(0),F=m?.canvas??null;useEffect(()=>{if(!s||!F||!d)return;let z=0,B=()=>{z||(z=requestAnimationFrame(()=>{z=0,I(J=>J+1);}));},G=typeof ResizeObserver>"u"?null:new ResizeObserver(B);return G?.observe(F),G?.observe(d),window.addEventListener("resize",B),()=>{z&&cancelAnimationFrame(z),G?.disconnect(),window.removeEventListener("resize",B);}},[s,F,d]);let P=useSyncExternalStore(i.subscribe,i.version,i.version),S=useMemo(()=>s&&!e.reviewing?T(m,P):null,[s,e.reviewing,m,P]),O=useMemo(()=>S&&m&&d?V(S,m,m.canvas,d,()=>i.layoutId()===S.id&&h.current===m&&m.canvas.isConnected,(z,B,G)=>t.current.pointAt(z,B,G)):null,[i,S,m,d,v]);r.current=O,useEffect(()=>{i.layoutChanged(S);},[i,S]),useEffect(()=>{i.geometryChanged();},[i,O]);let M=useCallback(()=>{p(null),i.close("document-replaced");},[i,p]);return {host:i,managed:s,activations:s?u:Si,overlayLayerRef:g,beginLoad:M,presentFrame:p}}function pr(e,t){return (e[t]?.columnOffset??0)-(e[0]?.columnOffset??0)}var Ii=new Intl.Segmenter(void 0,{granularity:"word"});function fr(e,t,r){return r==="word"?Ma(e,t):Oa(e,t)}function Ma(e,t){let r=mr(e,t),i=[...Ii.segment(e)],s=i.find(u=>r>=u.index&&r<u.index+u.segment.length)??i[i.length-1];return s?{start:s.index,end:s.index+s.segment.length}:{start:r,end:r}}function Oa(e,t){let r=mr(e,t),i=e.lastIndexOf(`
|
|
2
|
+
`,Math.max(0,r-1))+1,s=e.indexOf(`
|
|
3
|
+
`,r);return {start:i,end:s===-1?e.length:s}}function Ei(e,t){return t.start<e.start?{anchor:e.end,focus:t.start}:t.end>e.end?{anchor:e.start,focus:t.end}:{anchor:e.start,focus:e.end}}function mr(e,t){return Number.isFinite(t)?Math.max(0,Math.min(e.length,Math.trunc(t))):0}function Ci(e,t){return e.shapeId===t.shapeId&&e.position===t.position&&e.lineIndex===t.lineIndex}function hr(e,t){let i=e[wt(e,t)]?.caretStops.find(s=>s.position===t.position)?.x;return i===void 0?void 0:i-pr(e,wt(e,t))}function ki(e,t,r,i){if(e.length===0)return {position:t.position,lineIndex:0};let s=wt(e,t),u=s+(r==="up"?-1:1),h=e[u];if(!h)return {position:t.position,lineIndex:s};let m=i??hr(e,t),x=m===void 0?void 0:m+pr(e,u);return x===void 0?{position:h.start,lineIndex:u}:{position:h.caretStops.reduce((d,g)=>d===null||Math.abs(g.x-x)<Math.abs(d.x-x)?g:d,null)?.position??h.start,lineIndex:u}}function pn(e,t,r){let i=wt(e,t),s=e[i];return s?{position:r==="start"?s.start:s.end,lineIndex:i}:{position:t.position,lineIndex:i}}function Ti(e,t,r){let i=mr(e,t),s=[...Ii.segment(e)].filter(h=>h.isWordLike).flatMap(h=>[h.index,h.index+h.segment.length]),u=r<0?s.filter(h=>h<i):s.filter(h=>h>i);return u.length===0?r<0?0:e.length:r<0?Math.max(...u):Math.min(...u)}function wt(e,t){let r=t.lineIndex;if(r!==void 0&&r>=0&&r<e.length&&t.position>=e[r].start&&t.position<=e[r].end)return r;let i=-1;for(let s=0;s<e.length;s+=1){let u=e[s];t.position>=u.start&&t.position<=u.end&&(i=s);}return i===-1?Math.max(0,e.length-1):i}function Ri(e){return e.length>=4&&(e[0]===73&&e[1]===73&&e[2]===42&&e[3]===0||e[0]===77&&e[1]===77&&e[2]===0&&e[3]===42)}function fn(e){let t=useRef(e);return t.current===e||(t.current.length!==e.length||!t.current.every((r,i)=>{let s=e[i];return r.family===s.family&&(r.bold??false)===(s.bold??false)&&(r.italic??false)===(s.italic??false)&&(r.bytes===s.bytes||r.bytes.length===s.bytes.length&&r.bytes.every((u,h)=>u===s.bytes[h]))}))&&(t.current=e),t.current}async function mn(e,t,r){typeof FontFace>"u"||await Promise.all(e.map(async i=>{let s=await new FontFace(i.family,i.bytes.slice().buffer,{style:i.italic?"italic":"normal",weight:i.bold?"700":"400"}).load();r()&&(document.fonts.add(s),t.push(s));}));}function dt(e={}){let t=e.maxDecodedBytes??134217728;if(!Number.isSafeInteger(t)||t<0)throw new Error("invalid decoded image budget");let r=new Map,i=0,s=false,u=p=>{p.retained||p.references||p.closed||!p.source||(p.closed=true,"close"in p.source&&typeof p.source.close=="function"&&p.source.close(),p.source=null);},h=()=>{for(;r.size>25||i>t;){let p=r.entries().next().value;if(!p)break;r.delete(p[0]),i-=p[1].bytes,p[1].retained=false,u(p[1]);}},m=()=>{for(let p of r.values())p.retained=false,u(p);r.clear(),i=0;},x=(p,d,g=false,v)=>{let I=new Map,F=false;return Object.assign(S=>{if(s||F||v&&!v(S))return Promise.resolve(null);let O=I.get(S)??r.get(S);if(O)r.get(S)===O&&(r.delete(S),r.set(S,O));else {let M=p(S);if(!M)return Promise.resolve(null);let z={promise:Promise.resolve(null),source:null,references:0,retained:true,closed:false,bytes:0};z.promise=decodePresentationImage(M,d).catch(B=>{if(g)return null;throw B}).then(B=>{if(z.source=B,B){let G=B,J=(G.naturalWidth??G.width??0)*(G.naturalHeight??G.height??0)*4;z.bytes=Number.isSafeInteger(J)&&J>=0?J:t+1,z.retained&&(i+=z.bytes);}return h(),u(z),B}),O=z,r.set(S,O);}return I.has(S)||(I.set(S,O),O.references+=1),h(),O.promise},{release(){if(!F){F=true;for(let S of I.values())S.references-=1,u(S);I.clear();}}})};return {resolve:p=>x(d=>{let g=p.media.get(d);return g&&!Ri(g)?g:void 0},"Unable to decode slide image",true,d=>p.media.has(d)),resolver:(p,d)=>Object.assign(async g=>{let v=x(p,d);try{return await v(g)}finally{v.release();}},{acquire:()=>x(p,d)}),clear:m,dispose(){s=true,m();}}}function It(e,t){let r=new Map;return new Proxy(e,{get(i,s){let u=Reflect.get(i,s,i);if(typeof u!="function")return u;let h=r.get(s);return h||(h=(...m)=>{if(!t())throw new Error("Paint superseded");return Reflect.apply(u,i,m)},r.set(s,h)),h},set(i,s,u){if(!t())throw new Error("Paint superseded");return Reflect.set(i,s,u,i)}})}var Ha={open:openPresentationSession};function yr(e,t,r){return !!e&&e===r&&e.slideIndex===t}var gr=class{constructor(t,r,i,s,u,h=()=>true){a(this,"session",t);a(this,"changed",i);a(this,"report",s);a(this,"onReady",u);a(this,"isCurrent",h);a(this,"alive",true);a(this,"failed",false);a(this,"active");a(this,"navigation",0);a(this,"images",dt());a(this,"visible",new Set);a(this,"cache",new Map);a(this,"pending",new Set);a(this,"waiters",new Set);a(this,"running",false);a(this,"painted");a(this,"ready",false);this.active=Math.max(0,Math.min(t.state.slides.length-1,Number.isInteger(r)?r-1:0));}get current(){return this.alive&&!this.failed&&this.isCurrent()}require(){if(!this.current)throw new Error("Presentation is no longer open");return this.session}frame(t){let r=this.session.state.slides[t]?.id;for(let[i,s]of this.cache)if(i===JSON.stringify([r,s.version]))return s}start(){this.session.state.slides.length&&this.pending.add(this.active),this.drain();}show(t){if(!this.current||!Number.isInteger(t)||t<1||t>this.session.state.slides.length)return false;if(this.active!==t-1){this.finish(false),this.active=t-1,this.navigation+=1,this.painted=void 0;let r=this.frame(this.active);if(r){let i=JSON.stringify([this.session.state.slides[this.active].id,r.version]);this.cache.delete(i),this.cache.set(i,r);}else this.pending.add(this.active);this.trim(),this.changed();}return this.drain(),true}async showAsync(t){return this.show(t)?this.painted&&this.painted===this.frame(this.active)?true:new Promise(r=>this.waiters.add(r)):false}visibility(t,r){this.current&&(r?(!this.visible.has(t)&&!this.frame(t)&&this.pending.add(t),this.visible.add(t)):(this.visible.delete(t),this.trim(),t!==this.active&&this.pending.delete(t)),this.changed(),this.drain());}didPaint(t){!this.current||!yr(t,this.active,this.frame(this.active))||(this.painted=t,this.finish(true),this.ready||(this.ready=true,this.onReady()),this.changed(),this.drain());}isPainted(t){return this.painted===t}fail(t){this.current&&(this.failed=true,this.pending.clear(),this.finish(false),this.report(t),this.changed());}dispose(){this.alive=false,this.finish(false),this.cache.clear(),this.pending.clear(),this.visible.clear(),this.painted=void 0,this.images.dispose(),this.session.dispose().catch(()=>{});}finish(t){for(let r of this.waiters)r(t);this.waiters.clear();}trim(){for(;this.cache.size>25;){let t=[...this.cache].find(([,r])=>r.slideIndex!==this.active&&!this.visible.has(r.slideIndex));if(!t)break;this.cache.delete(t[0]);}}async drain(){if(!(this.running||!this.current)){this.running=true;try{for(;this.current;){let t=this.pending.has(this.active)?this.active:this.painted===this.frame(this.active)?this.pending.values().next().value:void 0;if(t===void 0)break;if(this.pending.delete(t),!(t!==this.active&&!this.visible.has(t))&&!this.frame(t))try{let r=await this.session.call.frame(t);if(!this.current)break;if(r.slideIndex!==t)throw new Error("Unexpected slide frame");let i=this.session.state.slides[t].id;this.cache.set(JSON.stringify([i,r.version]),r),this.trim(),this.changed();}catch(r){if(!this.current)break;r instanceof Error&&r.name==="SessionSuperseded"?(t===this.active||this.visible.has(t))&&this.pending.add(t):this.fail(r);}}}finally{this.running=false;}}}};function Li(e,t,r){let i=fn(e.fonts),s=useRef({props:e,focus:r,fonts:i});s.current={props:e,focus:r,fonts:i};let u=useRef(0),[h,m]=useState(null),[,x]=useState(0),[p,d]=useState(null),[g,v]=useState(false),[I,F]=useState(null),P=useCallback(O=>{let M=O instanceof Error?O:new Error(String(O));d(M.message),s.current.props.onError?.(M);},[]);useEffect(()=>{let O=++u.current,M=false,z=false,B,G=()=>{},J=[],$=()=>!M&&O===u.current&&s.current.props.file===e.file&&s.current.fonts===i&&s.current.props.clientId===e.clientId,Ae=()=>{$()&&x(C=>C+1);};return m(null),F(null),d(null),v(!!e.file),e.file&&(async()=>{try{let C=mn(i,J,()=>$()&&!z&&(B?.current??!0));C.catch(()=>{});let Me=await Ha.open(e.file,{fonts:i,clientId:e.clientId});if(!$()){Me.dispose().catch(()=>{});return}B=new gr(Me,s.current.props.initialSlide,Ae,j=>{$()&&P(j);},()=>{$()&&s.current.props.onReady?.(Pe);},$);let w=B,H=()=>w.require(),N=async j=>{if(!w.current)return null;try{let E=await j(H());return w.current?E:null}catch(E){if(!w.current)return null;throw E}},ie=()=>N(async j=>({ok:!1,version:await j.call.version(),failure:{code:"read-only",message:"The editor is read-only"}})),Pe={handle:null,commands:t,save:()=>null,getPositionAtPoint:()=>null,selectText:()=>!1,clearSelection:()=>{},refreshProposals:()=>{},refresh:()=>{},flushPendingInput:async()=>{H();},focus:()=>{w.current&&s.current.focus();},goToSlide:j=>{let E=w.show(j);return E&&s.current.focus(),E},goToSlideAsync:async j=>{let E=await w.showAsync(j);return w.current&&E},saveAsync:()=>N(j=>j.save()),version:()=>N(j=>j.call.version()),readContent:j=>N(E=>E.call.readContent(j)),findText:j=>N(E=>E.call.findText(j)),validateEdits:ie,applyEdits:ie};if(G=Me.onFailure(j=>w.fail(j)),Me.failure&&w.fail(Me.failure),await C,!$())return;m(w),v(!1),w.start();}catch(C){if(z=true,!$())return;if(B?.fail(C),!B){for(let Me of J.splice(0))document.fonts.delete(Me);P(C);}v(false);}})(),()=>{M=true,u.current+=1,G(),B?.dispose();for(let C of J)document.fonts.delete(C);}},[e.file,e.clientId,i,t,P]);let S=h?.current?h.session.state.slides[h.active]:void 0;return useEffect(()=>{if(F(null),!h?.current||!S)return;let O=false;return h.session.call.readContent({slideIds:[S.id]}).then(M=>{if(!(O||!h.current)){if(!M.ok)throw new Error(M.failure.message);F({id:S.id,text:M.slides[0]?.notes??""});}}).catch(M=>{!O&&h.current&&P(M);}),()=>{O=true;}},[h,S?.id,P]),{run:h,error:p,loading:g,reportError:P,notes:I?.id===S?.id?I?.text??"":""}}function Bi(e){let{t}=b(),r$1=useRef(null),i=useRef(null),s=useRef(null),u=useRef(null),h=useRef(null),[m]=useState(x),[x$2,p]=useState("fit"),[d,g]=useState({width:0,height:0}),[v,I]=useState(Oi),F=useCallback(()=>i.current?.focus(),[]),{run:P,loading:S,error:O,notes:M,reportError:z}=Li(e,m.store,F),B=P?.current?P.frame(P.active):void 0,G=P?.navigation,J$1=useRef({run:P,props:e,zoom:x$2,loading:S,t,reportError:z});J$1.current={run:P,props:e,zoom:x$2,loading:S,t,reportError:z};let $=useRef(null),Ae=useMemo(()=>({environment:()=>{let{run:w,zoom:H,loading:N,t:ie}=J$1.current,Pe=w?.session.state.slides[w.active];return {status:w?.current?"ready":N?"loading":"empty",readOnly:true,reviewing:false,pendingInput:false,canUndo:false,canRedo:false,slide:Pe??null,layouts:[],text:null,shape:null,tool:"select",zoom:H,fontFamilies:r,fontSizes:s$1,proposals:null,hostDisabled:j=>j==="slideshow"||j==="exportPng"||j==="tool",translate:ie}},ordered:()=>false,admit:async w=>w(),perform:(w,H)=>{let{run:N,props:ie,zoom:Pe}=J$1.current;if(!N?.current)return {ok:false,failure:{code:"document-replaced",message:"Presentation is no longer open"}};if(w==="zoom"){let E=H.scale;return p(E),{ok:true,status:E===Pe?"noop":"executed"}}if(w!=="save")return {ok:false,failure:{code:"read-only",message:"The editor is read-only"}};if($.current?.run===N)return $.current.promise;let j=Promise.resolve().then(async()=>{if(ie.onSaveRequest&&await ie.onSaveRequest()!==true)return {ok:true,status:"requested"};if(!N.current)throw new Error("Presentation is no longer open");let E=await N.session.save();if(!N.current)throw new Error("Presentation is no longer open");return ie.onSave?ie.onSave(E):qa(E,ie.fileName??"presentation.pptx"),{ok:true,status:"executed"}}).catch(E=>(N.current&&J$1.current.reportError(E),{ok:false,failure:{code:N.current?"command-failed":"document-replaced",message:String(E)}})).finally(()=>{$.current?.promise===j&&($.current=null);});return $.current={run:N,promise:j},j},capture:()=>J$1.current.run?.current?{generation:0,viewer:J$1.current.run}:null,resume:w=>"viewer"in w&&w.viewer===J$1.current.run&&J$1.current.run?.current?null:"document-replaced",chrome:()=>({i18n:J$1.current.props.i18n}),focusEditor:F}),[F]);useLayoutEffect(()=>(m.attach(Ae),()=>m.detach(Ae)),[m,Ae]),useLayoutEffect(()=>m.refresh()),J({commands:m,containerRef:r$1,suspended:()=>false}),useEffect(()=>{if(typeof window.matchMedia!="function")return;let w,H=()=>{let N=Oi();I(N),w?.removeEventListener("change",H),w=window.matchMedia(`(resolution: ${N}dppx)`),w.addEventListener("change",H);};return H(),()=>w?.removeEventListener("change",H)},[]),useEffect(()=>{let w=u.current;if(!w)return;let H=()=>g({width:w.clientWidth,height:w.clientHeight});H();let N=new ResizeObserver(H);return N.observe(w),()=>N.disconnect()},[]);let C=x$2==="fit"?!B||d.width<=0||d.height<=0?1:Math.min(Math.max(1,d.width-40)/Math.max(1,B.displayList.width),Math.max(1,d.height-40)/Math.max(1,B.displayList.height),1):x$2;useEffect(()=>{let w=h.current;if(!w||!B||!P?.current)return;let H=w.getContext("2d");if(!H)return;let N=false,ie=()=>!N&&P.current&&P.frame(P.active)===B;return sizeCanvasForSlide(w,B.displayList,v,C),w.width<1&&(w.width=1),w.height<1&&(w.height=1),Promise.resolve().then(async()=>{if(!ie())return;let Pe=P.images.resolve(B);try{await paintSlide(It(H,ie),B.displayList,v,C,{resolveImage:Pe});}finally{Pe.release();}}).then(()=>{ie()&&P.didPaint(B);}).catch(Pe=>{ie()&&P.fail(Pe);}),()=>{N=true;}},[P,B,C,v,G]),useEffect(()=>{let w=s.current;if(!w||!P?.current||typeof IntersectionObserver>"u")return;let H=new IntersectionObserver(N=>{for(let ie of N)P.visibility(Number(ie.target.dataset.slideIndex),ie.isIntersecting);},{root:w});for(let N of w.querySelectorAll("[data-slide-index]"))H.observe(N);return ()=>H.disconnect()},[P]);let Me=w=>{if(w.altKey||w.ctrlKey||w.metaKey||w.shiftKey||w.target.closest("input, textarea, select, [contenteditable]"))return;let H=["ArrowLeft","ArrowUp","PageUp"].includes(w.key),N=["ArrowRight","ArrowDown","PageDown"].includes(w.key);!H&&!N||(w.preventDefault(),P?.show(P.active+1+(H?-1:1))&&F());};return jsx(A.Provider,{value:m.store,children:jsxs("div",{ref:r$1,className:e.className,style:we.root,children:[e.showToolbar!==false&&e.toolbar!=null?jsx("div",{style:we.toolbarShell,children:jsx(x$1.Provider,{value:true,children:jsx("div",{style:{flex:"1 1 auto",minWidth:0},children:e.toolbar})})}):null,jsxs("div",{style:we.workspace,children:[jsx("aside",{ref:s,style:we.slideStrip,"aria-label":t("slides.panelLabel"),children:P?.session.state.slides.map((w,H)=>{let N=P.frame(H),ie=P.visible.has(H),Pe=w.name||t("slides.fallbackTitle",{number:H+1});return jsxs("button",{type:"button","data-slide-index":H,"aria-current":H===P.active?"page":void 0,style:{...we.slideButton,border:H===P.active?"2px solid #325ee6":"2px solid transparent"},onClick:()=>{P.show(H+1)&&F();},children:[jsx("span",{style:we.slideNumber,children:H+1}),jsx("span",{style:we.slidePreview,children:ie&&N&&B&&P.isPainted(B)?jsx(Ka,{run:P,frame:N,dpr:v}):jsx("span",{style:we.slideTitle,children:Pe})})]},w.id)})}),jsxs("div",{ref:i,tabIndex:0,style:we.stage,onKeyDown:Me,children:[jsx("div",{ref:u,style:we.canvasHost,children:B?jsx("canvas",{ref:h,style:we.canvas}):jsx("div",{style:we.empty,children:S?t("editor.opening"):e.file?t("editor.noSlides"):t("editor.openPrompt")})}),O?jsx("div",{style:we.error,children:O}):null]})]}),P?.session.state.slides[P.active]?jsxs("div",{style:we.notesPanel,children:[jsx("span",{style:we.notesLabel,children:t("notes.panelLabel")}),jsx("textarea",{"data-testid":"pptx-notes-textarea",style:we.notesTextarea,value:M,disabled:true,"aria-label":t("notes.panelLabel"),placeholder:t("notes.placeholder")})]}):null]})})}function Ka({run:e,frame:t,dpr:r}){let i=useRef(null);return useEffect(()=>{let s=i.current,u=s?.getContext("2d");if(!s||!u||!e.current)return;let h=false,m=()=>!h&&e.current&&e.visible.has(t.slideIndex),x=128/t.displayList.width;return sizeCanvasForSlide(s,t.displayList,r,x),s.width<1&&(s.width=1),s.height<1&&(s.height=1),Promise.resolve().then(async()=>{if(!m())return;let p=e.images.resolve(t);try{await paintSlide(It(u,m),t.displayList,r,x,{resolveImage:p});}finally{p.release();}}).catch(()=>{}),()=>{h=true;}},[e,t,r]),jsx("canvas",{ref:i,style:{display:"block",maxWidth:"100%",height:"auto"},"aria-hidden":"true"})}function Oi(){let e=typeof window>"u"?1:window.devicePixelRatio;return Number.isFinite(e)&&e>0?e:1}function qa(e,t){let r=new Blob([new Uint8Array(e)],{type:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(i);}var we={root:{display:"flex",flexDirection:"column",width:"100%",height:"100%",minHeight:480,overflow:"hidden",color:"#172033",background:"#f3f5f8",fontFamily:"ui-sans-serif, system-ui, sans-serif"},toolbarShell:{display:"flex",alignItems:"center",flex:"0 0 auto",padding:"4px 0 5px",background:"#ffffff",borderBottom:"1px solid #e2e8f0"},workspace:{display:"flex",flex:1,minHeight:0},slideStrip:{width:184,padding:"14px 10px",overflowY:"auto",background:"#eef1f5",borderRight:"1px solid #d8dee9",boxSizing:"border-box"},slideButton:{display:"flex",alignItems:"flex-start",gap:7,width:"100%",marginBottom:12,padding:4,borderRadius:5,background:"transparent",cursor:"pointer"},slideNumber:{width:18,flex:"0 0 auto",paddingTop:3,fontSize:11,color:"#647087",textAlign:"right"},slidePreview:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:132,aspectRatio:"16 / 9",padding:8,overflow:"hidden",background:"#ffffff",boxSizing:"border-box",boxShadow:"0 1px 4px rgba(20, 31, 50, 0.16)"},slideTitle:{fontSize:9,lineHeight:1.25,color:"#39445a",textAlign:"center"},stage:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,outline:"none",overflow:"hidden"},canvasHost:{display:"flex",flex:1,minHeight:0,alignItems:"center",justifyContent:"center",width:"100%",overflow:"auto"},canvas:{display:"block",flex:"0 0 auto",background:"#fff",boxShadow:"0 8px 32px rgba(27, 39, 61, 0.2)",touchAction:"none"},notesPanel:{flex:"0 0 auto",display:"flex",flexDirection:"column",gap:4,padding:"8px 14px 10px",background:"#ffffff",borderTop:"1px solid #e2e8f0"},notesLabel:{fontSize:11,fontWeight:650,color:"#647087",textTransform:"uppercase",letterSpacing:"0.02em"},notesTextarea:{width:"100%",height:64,resize:"vertical",border:"1px solid #d8dee9",borderRadius:6,padding:"6px 8px",font:"13px ui-sans-serif, system-ui, sans-serif",color:"#172033",boxSizing:"border-box",outline:"none"},empty:{margin:"auto",color:"#6b7587",fontSize:14},error:{position:"absolute",left:16,right:16,bottom:14,padding:"9px 12px",color:"#8b1e2d",background:"#fff0f2",border:"1px solid #efb8c0",borderRadius:6,fontSize:12}};var Xa={open:createPptxWorkerEditorSession},xr=class{constructor(t,r,i=()=>true){a(this,"changed",r);a(this,"isCurrent",i);a(this,"owner");a(this,"images",dt());a(this,"access",null);a(this,"active",0);a(this,"navigation",0);a(this,"alive",true);a(this,"onFirstPaint");a(this,"ready",false);a(this,"cache",new Map);a(this,"lists",new WeakMap);a(this,"waiters",new Set);a(this,"painted");a(this,"requesting",false);a(this,"requested",false);a(this,"off");a(this,"fonts",[]);a(this,"fontsReady");a(this,"resolveImage",async t=>{let r=this.frame(this.active);if(!r)return null;let i=this.images.resolve(r);try{return await i(t)}finally{i.release();}});this.active=Number.isInteger(t.initialSlide)?Math.max(0,t.initialSlide-1):0,this.owner=Xa.open(t.file,{fonts:t.fonts,clientId:t.clientId,collaboration:t.collaboration,onError:s=>{this.current&&t.onError?.(s);}}),this.off=this.owner.subscribe(()=>{this.current&&(this.owner.failure&&this.finish(this.owner.failure),r(),this.request());}),this.fontsReady=mn(t.fonts,this.fonts,()=>this.current),this.fontsReady.catch(()=>{});}get current(){return this.alive&&this.isCurrent()}get hydrated(){return this.current&&this.owner.hydrated&&this.access!==null}get overlays(){let t=this.frame(this.active);return this.hydrated&&!!t&&this.painted===t&&this.matches(t)}require(){if(!this.current)throw new PptxWorkerEditorDisposedError;if(this.owner.failure)throw this.owner.failure}async open(t){let r=await this.owner.handleAsync();return await this.fontsReady,this.require(),this.access=t.access(r),this.changed(),this.request(),this.access}snapshot(){if(this.hydrated)return this.access.snapshot();let t=this.owner.state.projection;return t?{widthEmu:t.size.width,heightEmu:t.size.height,slides:t.slides.map(r=>({...r,shapes:[],sourcePartPath:null}))}:null}frame(t){let r=this.owner.state.projection?.slides[t]?.id;return r?this.cache.get(r):void 0}matches(t){let r=this.owner.state;return this.current&&!r.failure&&t.sequence===r.sequence&&t.version===r.version&&r.projection?.slides[t.slideIndex]?.id===t.slideId&&this.cache.get(t.slideId)===t}currentPaint(t,r){return this.matches(t)&&r===this.navigation&&yr(t,this.active,this.frame(this.active))}thumbnailImages(t){let r=this.lists.get(t);return !r||!this.matches(r)?null:this.images.resolve(r)}isThumbnailCurrent(t){let r=this.lists.get(t);return !!r&&this.matches(r)}show(t){this.require();let r=this.access&&this.owner.hydrated?this.access.snapshot().slides.length:this.owner.state.projection?.slides.length??0;return !Number.isInteger(t)||t<1||t>r?false:(this.active!==t-1&&(this.finish(),this.active=t-1,this.navigation+=1,this.painted=void 0,this.changed()),this.request(),true)}async showAsync(t){return this.show(t)?this.overlays?true:new Promise((r,i)=>this.waiters.add({slide:t,resolve:r,reject:i})):false}didPaint(t,r){if(this.currentPaint(t,r)){this.painted=t;for(let i of this.waiters)i.resolve(i.slide===this.active+1);this.waiters.clear(),this.hydrated&&!this.ready&&this.onFirstPaint&&(this.ready=true,this.onFirstPaint()),this.changed();}}finish(t){for(let r of this.waiters)t?r.reject(t):r.resolve(false);this.waiters.clear();}async request(){if(this.requesting){this.requested=true;return}if(!this.current||this.owner.failure||!this.owner.state.projection||this.owner.state.sequence!==this.owner.state.acknowledgedSequence)return;this.requesting=true;let t=this.navigation,r=this.owner.state.sequence;try{let i=this.owner.state.projection.slides;this.active=Math.min(this.active,Math.max(0,i.length-1));let s=[this.active,...i.map((u,h)=>h).filter(u=>u!==this.active)];for(let u of s){let h=i[u];if(!h||!this.current||t!==this.navigation||r!==this.owner.state.sequence)break;let m=this.cache.get(h.id);if(m&&this.matches(m))continue;let x=await this.owner.frame(h.id);if(!this.current||this.owner.failure||t!==this.navigation||r!==this.owner.state.sequence)break;x.slideId!==h.id||x.slideIndex!==u||x.sequence!==r||x.version!==this.owner.state.version||!Number.isInteger(x.epoch)||x.epoch<=(m?.epoch??0)||(this.cache.set(h.id,x),this.lists.set(x.displayList,x),this.changed());}}catch(i){this.current&&!this.owner.failure&&this.finish(i);}finally{this.requesting=false;let i=this.requested;this.requested=false,this.current&&(i||t!==this.navigation||r!==this.owner.state.sequence)&&this.request();}}dispose(){this.alive=false,this.finish(new PptxWorkerEditorDisposedError),this.off(),this.cache.clear(),this.painted=void 0,this.images.dispose();for(let t of this.fonts)document.fonts.delete(t);this.owner.dispose().catch(()=>{});}};function Ni(e){let t=fn(e.fonts),r=useRef(e),i=useRef(t);return r.current=e,i.current=t,useCallback(s=>{let u=r.current;return new xr({...u,fonts:t,onError:h=>r.current.onError?.(h)},s,()=>r.current.file===u.file&&i.current===t&&r.current.clientId===u.clientId&&r.current.collaboration===u.collaboration)},[e.file,e.clientId,e.collaboration,t])}function ji(e){let t=Ni(e),{onReady:r,...i}=e;return jsx(Pr,{...i,backend:t,onWorkerReady:r})}function Ki(e,t,r,i,s=()=>false,u=()=>true,h=()=>false){let m=()=>{if(!u()||e.state.stage==="disposed")throw new PptxWorkerEditorDisposedError},x=()=>{if(m(),e.failure)throw e.failure},p=()=>{x();let P=r();if(!e.hydrated||!P)throw new PptxPeerNotReadyError;return P},d=()=>{let P=p();if(s())throw new Error("Finish the pointer gesture before flushing input");return P},g=()=>{let P=p();return h()?{ok:false,version:P.version(),failure:{code:"read-only",message:"The editor is read-only"}}:null},v=async P=>{let S=p();return await t.flushPendingInput(),x(),P(S)},I=y(t.commands)?.guarded(x)??Object.fromEntries(Object.keys(t.commands).map(P=>[P,(...S)=>(x(),Reflect.apply(Reflect.get(t.commands,P),t.commands,S))]));return {get handle(){return m(),null},get commands(){return x(),I},get hydrated(){return m(),e.hydrated},get failure(){return m(),e.failure},save:()=>(m(),null),saveAsync:async()=>{d();let P=await e.saveAsync();return x(),P},whenHydrated:async()=>{x(),await e.whenHydrated(),x();},handleAsync:async()=>(x(),await e.whenHydrated(),p()),recoverySave:()=>e.recoverySave(),goToSlideAsync:async P=>(x(),i(P)),version:()=>v(P=>P.version()),readContent:P=>v(S=>S.readContent(P)),findText:P=>v(S=>S.findText(P)),validateEdits:async P=>g()??v(S=>g()??S.validateEdits(P)),applyEdits:async P=>{let S=g();if(S)return S;d();let O=await t.applyEdits(P);return await t.flushPendingInput(),x(),O},flushPendingInput:async()=>{p(),await t.flushPendingInput(),x();},getPositionAtPoint:(P,S)=>(x(),e.hydrated?t.getPositionAtPoint(P,S):null),selectText:P=>(x(),e.hydrated?t.selectText(P):false),goToSlide:P=>(x(),t.goToSlide(P)),clearSelection:()=>{x(),t.clearSelection();},focus:()=>{x(),t.focus();},refresh:()=>{x(),t.refresh();},refreshProposals:()=>{x(),t.refreshProposals();}}}var $a={insertText:true,deleteText:true,formatText:true,setStoryParagraphs:true,insertParagraphBreak:true,setParagraphAlignment:true,insertSlide:true,duplicateSlide:true,deleteSlide:true,moveSlide:true,setSlideNotes:true,setSlideLayout:true,addTextBox:true,addShape:true,addPicture:true,removeShape:true,moveShape:true,resizeShape:true,setShapeRect:true,setShapeFill:true,setShapeStroke:true,setShapeAdjust:true,bringShapeToFront:true,sendShapeToBack:true,bringShapeForward:true,sendShapeBackward:true,addComment:true,replyToComment:true,setCommentStatus:true,setCommentPosition:true,removeComment:true,setCommentFlavor:true,propose:true,acceptProposal:true,rejectProposal:true,applyEdits:true,addUndoBoundary:true,undo:true,redo:true};function _i(e){let t=false,r,i=()=>{let m=e.session();if(!m)throw new PptxPeerNotReadyError;if(m.state.stage==="disposed")throw new PptxWorkerEditorDisposedError;if(m.failure)throw m.failure;if(!m.hydrated)throw new PptxPeerNotReadyError;return m},s=m=>{try{return i(),Promise.resolve(m())}catch(x){return Promise.reject(x)}},u=()=>{let m=i();if(e.readOnly?.())throw new w("read-only");return m},h=()=>u().apply({method:"addUndoBoundary",args:[]});return {busy:()=>false,keyboardQueued:()=>false,input:m=>s(m),run:s,reset(){t=false,r=void 0;},breakTyping(){r=void 0;},beginTyping(m,x=Date.now()){u(),(!r||r.target!==m||x-r.time>500)&&h(),r={target:m,time:x},t=true;},endTyping(){t=false;},flush(){return s(()=>{if(e.gestureActive())throw new Error("Finish the pointer gesture before flushing input");return i().flush()})},access(m){let x=i(),p=()=>{if(x.state.stage==="disposed"||e.session()!==x)throw new PptxWorkerEditorDisposedError;return i()},d=Object.create(null);for(let g of Reflect.ownKeys(m))Object.defineProperty(d,g,{enumerable:typeof g=="string",get:()=>(p(),typeof g!="string"||!Object.hasOwn($a,g)?Reflect.get(m,g):(...v)=>{let I=p();if(e.readOnly?.()){if(g==="applyEdits")return {ok:false,version:m.version(),failure:{code:"read-only",message:"The editor is read-only"}};throw new w("read-only")}!t&&g!=="addUndoBoundary"&&(r=void 0);let F=!t&&!["addUndoBoundary","undo","redo","applyEdits"].includes(g);F&&(r=void 0,h());try{return I.apply({method:g,args:v}).outcome.result}finally{F&&!I.failure&&h(),e.changed?.();}})});return Object.freeze(d)}}}var Ja={deprecated:`[PptxEditor] \`experimentalWorkerOpen={false}\` selects the deprecated in-thread engine. Omit it and \`${Z}\` to use the worker-owned async editor.`,collaboration:"[PptxEditor] the legacy hybrid runtime does not support `collaboration`; using the deprecated in-thread engine.","no-worker":"[PptxEditor] `Worker` is not available in this environment; using the deprecated in-thread engine.","no-offscreen-canvas":"[PptxEditor] `OffscreenCanvas` is not available in this environment; using the deprecated in-thread engine.","legacy-sync-api":`[PptxEditor] \`${Z}\` keeps the deprecated synchronous API on the in-thread engine, removed in 0.6.0. Omit it to use the async editor.`},br=Symbol.for("@betteroffice/pptx-react/engine-warnings"),vr=globalThis,Xi=vr[br]??(vr[br]=new Set);function gn(e){let t=Ja[e];Xi.has(t)||(Xi.add(t),console.warn(t));}var Sr=new WeakMap;function tl(e,t,r){let i=Sr.get(e),s=i?{Component:i}:{loading:true},[u,h]=useState(()=>({load:e,identity:t,chunk:s})),m=useRef(null);return useEffect(()=>{if(i)return;let x=true;if(!m.current||m.current.load!==e||m.current.identity!==t){let d;try{d=e();}catch(g){d=Promise.reject(g);}m.current={load:e,identity:t,promise:d};}let p=m.current;return p.promise.then(d=>{!x||m.current!==p||(Sr.set(e,d.PeerlessPptxSurface),h({load:e,identity:t,chunk:{Component:d.PeerlessPptxSurface}}));}).catch(d=>{!x||m.current!==p||(Sr.delete(e),h({load:e,identity:t,chunk:{error:new r(d)}}));}),()=>{x=false;}},[e,t,r]),i?{Component:i}:u.load===e&&u.identity===t?u.chunk:{loading:true}}function Yi({load:e,identity:t,ErrorType:r,fallback:i,editorProps:s}){let u=tl(e,t,r);if("error"in u)throw u.error;return "Component"in u?jsx(u.Component,{...s}):i}var fl=12;function ss(e){let t;return ()=>t??(t=e().catch(r=>{throw t=void 0,r}))}var $i=ss(()=>import('./chunk-3Y6BQIW3.js').then(e=>e.PresentationOverlay)),Ji=ss(()=>import('./chunk-V62S3LXB.js').then(e=>e.ProposalsPanel)),ml={load:()=>import('./chunk-M267LYSF.js')},hl=()=>globalThis.location?.reload(),zt=class extends Error{constructor(r){super("Failed to load the editor code. Reload the page to retry.");a(this,"cause",r);a(this,"code","chunk-load-failed");this.name="PptxWorkerEditorChunkLoadError";}};function gl({error:e,className:t,style:r}){let i=e instanceof zt;return jsx("div",{className:t,style:{position:"relative",width:"100%",height:"100%",...r},children:jsx($,{kind:i?"load":"open",details:e.message,onReload:i?hl:void 0})})}var Tr=class extends Component{constructor(){super(...arguments);a(this,"state",{error:null});a(this,"reported",null);}static getDerivedStateFromError(r){return {error:r instanceof Error?r:new Error(String(r))}}componentDidCatch(){let r=this.state.error;if(!(!r||this.reported===r)){this.reported=r;try{this.props.onError?.(r);}catch{}}}render(){return this.state.error?jsx(gl,{error:this.state.error,className:this.props.className,style:this.props.style}):this.props.children}},Rr=class{constructor(){a(this,"frames",new Map);a(this,"listeners",new Map);}get(t){return this.frames.get(t)}get size(){return this.frames.size}subscribe(t,r){let i=this.listeners.get(t)??new Set;return this.listeners.set(t,i),i.add(r),()=>{i.delete(r),i.size===0&&this.listeners.delete(t);}}replace(t){let r=this.frames;this.frames=t;for(let[i,s]of r)t.get(i)!==s&&this.notify(i);for(let i of t.keys())r.has(i)||this.notify(i);}add(t){let r=[];for(let[i,s]of t)this.frames.get(i)!==s&&(this.frames.set(i,s),r.push(i));for(let i of r)this.notify(i);}notify(t){this.listeners.get(t)?.forEach(r=>r());}};function yn(e){return e[Symbol.for("@betteroffice/pptx/slide-layout-cache")]}var xn="application/vnd.openxmlformats-officedocument.presentationml.presentation";function yl(e,t){return `${(e??"presentation.pptx").replace(/\.pptx$/i,"")}-slide-${t+1}.png`}function Bt(e,t,r){let i=new Blob([new Uint8Array(e)],{type:r}),s=URL.createObjectURL(i),u=document.createElement("a");u.href=s,u.download=t,document.body.appendChild(u),u.click(),u.remove(),URL.revokeObjectURL(s);}function Zi(e){return new Promise((t,r)=>{let i=new FileReader;i.onload=()=>t(i.result),i.onerror=()=>r(i.error??new Error("failed to read the file")),i.readAsDataURL(e);})}function xl(e){return new Promise((t,r)=>{let i=new Image;i.onload=()=>t({width:i.naturalWidth,height:i.naturalHeight}),i.onerror=()=>r(new Error("failed to decode the image")),i.src=e;})}var Qi=8*1024*1024,wr={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",tif:"image/tiff",tiff:"image/tiff",webp:"image/webp",svg:"image/svg+xml"},Pl=530,Pn=9,Ir={bold:false,italic:false,underline:"none",fontSizePt:24,color:"#111827",fontFamily:"Arial"};function qc({i18n:e,...t}){let r=t[Z]===true;return jsx(a$1,{i18n:e,children:r?jsx(Il,{...t,i18n:e}):jsx(bl,{...t,i18n:e})})}function bl(e){let t=useMemo(()=>e.file instanceof ArrayBuffer?new Uint8Array(e.file):e.file,[e.file]);return jsx(Sl,{...e,file:t})}function vl({fallback:e,editorProps:t}){let[r]=useState(()=>lazy(()=>import('./chunk-HGG45CCF.js').then(i=>({default:i.PptxAsyncInThreadSession}),i=>{throw new zt(i)})));return jsx(Suspense,{fallback:e,children:jsx(r,{...t})})}function Sl(e){let{t}=b(),r=e.experimentalWorkerOpen===false,i=useMemo(()=>({}),[e.file,r]),s=()=>({identity:i,reason:r?"deprecated":typeof Worker!="function"?"no-worker":typeof OffscreenCanvas!="function"?"no-offscreen-canvas":void 0}),[u,h]=useState(s),m=u.identity===i?u:s();u!==m&&h(m),useEffect(()=>{m.reason&&gn(m.reason);},[m.reason]);let x=jsx("div",{className:e.className,style:e.style,role:"status",children:e.file&&e.loadingIndicator!==void 0?e.loadingIndicator:t("worker.preparing")});return jsx(Tr,{onError:e.onError,className:e.className,style:e.style,children:m.reason?jsx(vl,{fallback:x,editorProps:e}):jsx(Yi,{load:ml.load,identity:i,ErrorType:zt,fallback:x,editorProps:e})})}function wl(e,t,r){if(e===false)return "deprecated";if(e!==true)return "in-thread";if(t!=null)return "collaboration";if(!r)return "no-worker"}function Il(e){useEffect(()=>{gn("legacy-sync-api");},[]);let t=ls(e.fonts),r=e.experimentalWorkerOpen,i=useMemo(()=>({}),[e.file,t,e.clientId,e.collaboration,r]),s=useMemo(()=>({}),[e.file,e.collaboration,r]),u=()=>({identity:s,reason:wl(r,e.collaboration,typeof Worker=="function")}),[h,m]=useState(u),x=h.identity===s?h:u();h!==x&&m(x);let p=!e.readOnly||(e.plugins?.length??0)>0||e.onChange!==void 0,d=()=>({identity:i,editable:p}),[g,v]=useState(d),I=g.identity===i?g:d(),F=I.editable||p;(g!==I||g.editable!==F)&&v({...I,editable:F}),useEffect(()=>{x.reason&&x.reason!=="in-thread"&&gn(x.reason);},[x.reason]);let P=ji;return x.reason?jsx(Pr,{...e}):F?jsx(P,{...e}):jsx(Bi,{...e})}function Pr({file:e$1,fonts:t$1,clientId:r,collaboration:i$1,collaborationIdentity:s$1,style:u$1,initialZoom:h$1,loadingIndicator:m$1,onDocumentChange:x$2,downloadOnSave:p$1,className:d$1,fileName:g$1,initialSlide:v,onReady:I$1,onChange:F$1,onError:P,onSave:S,onSaveRequest:O,readOnly:M$1=false,toolbar:z,showToolbar:B=true,i18n:G$1,plugins:J$1,pluginGrants:$$1,onPluginError:Ae,backend:C,onWorkerReady:Me}){let{t:w}=b(),H$1=w("errors.decodeSlideImage"),N=i$1?.clientId??r,ie=i$1?.initialUpdate,Pe=C?void 0:i$1?.onReplica,j$1=C?void 0:i$1?.presence,E$1=useRef(null),U=useRef(null),nt=useRef(0),[ct]=useState(x),Sn=ct.store,Ge=useRef(null),ge=useRef(null),Fr=useRef(()=>{}),[cs,wn]=useState(0),Lr=useRef(Me);Lr.current=Me;let Fe=useRef(M$1),[Q]=useState(()=>{if(C)return _i({session:()=>ge.current?.current?ge.current.owner:null,gestureActive:()=>!!(_$1.current||ee.current),readOnly:()=>Fe.current,changed:()=>Fr.current()});let n=si(()=>{n.busy()||(Ge.current=null),ct.refresh();});return n}),ut=useRef(null),In=useRef(null),En=useRef(()=>null),Ht=useCallback(async(n,o)=>{let a=l=>({ok:false,code:"document-replaced",error:new Error(l)});if(E$1.current!==n)return a("Presentation is no longer open");try{return {ok:!0,value:await Q.run(()=>{if(E$1.current!==n)throw new je;if(_$1.current||ee.current)throw new vn;return o()})}}catch(l){if(l instanceof je)return a("Presentation changed while flushing input");if(l instanceof Ve)return {ok:false,code:"input-failed",error:l.cause};if(l instanceof vn)return {ok:false,code:"input-failed",error:l};throw l}},[Q]),$e=useCallback(async(n,o)=>{let a=await Ht(n,o);if(!a.ok)throw a.error;return a.value},[Ht]),Mr=useCallback(n=>C?Q.flush():$e(n,()=>{}),[$e,C,Q]),rt=useCallback(n=>Fe.current?{ok:false,version:n.version(),failure:{code:"read-only",message:"The editor is read-only"}}:null,[]),Or=useRef(v),Wr=useRef(I$1),Dr=useRef(F$1),Br=useRef(x$2);Br.current=x$2;let Cn=useRef(null),kn=useRef(h$1);kn.current=h$1;let zr=useRef(P),Hr=useRef(null),Le=useRef(null),Nr=useRef(null),Nt=useRef(null),jr=useRef(null),[us,ps]=L((J$1?.length??0)>0),[fs,Kr]=useState(false),Ke=useRef(null),ee=useRef(null),[Tn,ke]=useState(null),_$1=useRef(null),fe=useRef(null),Rn=useRef(dt()),An=ls(t$1),[T,Fn]=useState(null),[Te]=useState(()=>new Rr),Ln=useRef(Promise.resolve()),ms=useCallback(()=>Ln.current,[]),[ue,se,Je]=De(null),[Ee,de,Ct]=De(null),[Mn,me]=useState(null),[qe,be]=useState(null),[hs,qr,On]=De(Ir),[Wn,Ur,_r]=De(_(h$1)),[pt,ze,Xr]=De("select"),[Yr,Dn]=useState(null),[kt,gs]=useState({width:0,height:0}),[jt,Kt]=useState(null),[Bn,Tt]=useState(false),[ys,Vr]=useState(0),[zn,Gr]=useState(null),[Hn,xs]=useState(null),[ft,$r]=useState(null),qt=useRef(null),[ot,Nn]=useState([]),[jn,Ut]=useState(false),[Kn,Jr]=useState(null),[_t,Zr]=useState(null);useEffect(()=>{let n=true;return $i().then(o=>{n&&Jr(()=>o);},()=>{}),Ji().then(o=>{n&&Zr(()=>o);},()=>{}),()=>{n=false;}},[]);let[Xt,qn,Ps]=De([]),[Yt,mt,bs]=De(false),Qr=useRef(null),Y$1=ti(C?null:E$1.current,M$1||C?[]:Xt,T?.snapshot,T?.slideIndex??0),[vs,Ss]=useState(null),ht=useMemo(()=>C?Object.assign(n=>ge.current?.resolveImage(n)??Promise.resolve(null),{acquire:()=>{let n=ge.current,o=n?.frame(n.active);return n&&o?n.images.resolve(o):()=>null}}):ts(E$1,Rn,H$1),[C,H$1]);useEffect(()=>{Y$1.reviewing&&(se(null),de(null),_$1.current=null,ee.current=null,ke(null),me(null),be(null));},[Y$1.reviewing]),useEffect(()=>{M$1&&(ze("select"),mt(false),_$1.current=null,ee.current=null,fe.current=null,ke(null),me(null),be(null));},[M$1]),Wr.current=I$1,Fe.current=M$1,Or.current=v,Dr.current=F$1,zr.current=P,U.current=T;let gt=useRef(Y$1.reviewing);gt.current=Y$1.reviewing;let K$1=useCallback(n=>{let o=n instanceof Error?n:new Error(String(n));Kt(o.message),o!==ge.current?.owner.failure&&zr.current?.(o);},[]);useEffect(()=>{if(!Yt||_t)return;let n=true;return Ji().then(o=>{n&&Zr(()=>o);},o=>{n&&(mt(false),K$1(o));}),()=>{n=false;}},[Yt,_t,K$1,mt]);let Z=useCallback((n,o=false,a=false,l)=>{let c$1=E$1.current;if(!c$1)return null;try{Ke.current=null;let f$1=yn(c$1),y=a?f$1.snapshot():null,b=y?.snapshot??c$1.snapshot(),L=y?.keys??{...U.current?.layoutKeys},k=Al(n??U.current?.slideIndex??0,b.slides.length);C&&ge.current?.show(k+1);let R=new Map,D=b.slides[k]?.id;D&&!a&&(L[D]=f$1.key(k));let ce=D&&f$1.activate(D,L[D]),oe=D&&U.current?.layoutKeys[D]===L[D]?Te.get(D):void 0,ye=D?!C&&ce&&oe||c$1.layoutSlide(k):null;!C&&ye&&D&&R.set(D,ye);for(let xe=0;xe<b.slides.length;xe+=1){let _e=b.slides[xe];if(xe===k)continue;let Pt=Te.get(_e.id),Ne=U.current?.layoutKeys[_e.id];!a&&(!Pt||Ne!==L[_e.id]||_e.id===l)&&(L[_e.id]=f$1.key(xe)),Pt&&Ne===L[_e.id]&&R.set(_e.id,Pt);}let Se={snapshot:b,version:c$1.version(),slideIndex:k,frame:ye,layoutKeys:L},We=b.slides[k];se(xe=>xe&&We&&c(We.shapes,xe.shapeId)?xe:null),de(xe=>xe&&We?.id===xe.slideId&&c(We.shapes,xe.shapeId)?xe:null);let Qe=_$1.current;Qe&&(!We||We.id!==Qe.slideId||Qe.kind!=="textBox"&&Qe.kind!=="shapeInsert"&&!c(We.shapes,Qe.shapeId))&&(_$1.current=null,fe.current=null,me(null),be(null));let Zt=ee.current;if(Zt&&!f(We,Zt)&&(ee.current=null,ke(null)),U.current=Se,C||Te.replace(R),Fn(Se),qn(c$1.listProposals()),Kt(null),o){if(Cn.current!==Se.version){Cn.current=Se.version;try{Br.current?.({version:Se.version});}catch(xe){console.error("documentChange listener threw:",xe);}}Dr.current?.(b);}return Se}catch(f){return K$1(f),null}},[C,K$1,Te]),eo=useCallback(()=>{let n=U.current!==null&&E$1.current?.version()!==U.current.version;Z(void 0,n,true);},[Z]);Fr.current=()=>Z(void 0,false);let Vt=useCallback((n,o,a,l=c=>c())=>{let c=a?.()??null;if(c)return c;let f=rt(n);if(f)return f;let y=l(()=>n.applyEdits(o));return y.ok&&y.applied&&Z(void 0,true,true),y},[rt,Z]),Gt=useCallback(()=>{C&&Q.breakTyping(),Ge.current=null,Ke.current=null,ee.current=null,_$1.current=null,fe.current=null,ke(null),se(null),de(null),me(null),be(null);},[C,Q]),Ze=useCallback((n,o)=>{Gt(),C&&ge.current?.show(n+1);let a=Z(n);return a&&o&&Le.current?.focus(),a},[C,Gt,Z]),Un=useCallback(n=>{if(C&&!E$1.current)return ge.current?.show(n)??false;let o=U.current;return !o||!Number.isInteger(n)||n<1||n>o.snapshot.slides.length?false:Ze(n-1,true)!==null},[C,Ze]),to=useCallback(n=>{let o=E$1.current,a=U.current;if(!o||!a||!Number.isInteger(n.slide)||!Number.isInteger(n.start)||!Number.isInteger(n.end)||n.start<0||n.end<n.start)return false;let l=a.snapshot.slides[n.slide-1];if(!(l?c(l.shapes,n.shapeId):null)?.textStories.some(f=>f.id===n.storyId))return false;try{let f=o.story(n.storyId);return n.end>f.length||!Ze(n.slide-1,!1)?!1:(se({shapeId:n.shapeId,storyId:n.storyId,anchor:n.start,focus:n.end}),Le.current?.focus(),!0)}catch{return false}},[Ze]),no=useCallback((n,o,a)=>{let l=U.current?.snapshot.slides.findIndex(y=>y.id===n)??-1;if(l<0)return;let c$1=Z(l),f=c$1?.snapshot.slides[c$1.slideIndex];se(null),de(o&&f&&c(f.shapes,o)?{slideId:n,shapeId:o}:null),C||(a&&Y$1.select(a),Y$1.setEnabled(true));},[C,Z,Y$1.select,Y$1.setEnabled]),yt=useCallback(()=>{try{qn(E$1.current?.listProposals()??[]);}catch(n){K$1(n);}},[K$1]),ws=useCallback((n,o)=>{let a=E$1.current;if(!a)throw new Error("Presentation is no longer open");try{return a.acceptProposal(n,{force:o}),Z(void 0,!0,!0),"accepted"}catch(l){if(yt(),l instanceof StaleProposalError)return "stale";throw l}},[Z,yt]),Is=useCallback(n=>{let o=E$1.current?.rejectProposal(n)??false;return yt(),o},[yt]),ro={goToSlide(n,o,a){let l=Er(n,o?.slideId);return l?Ze(l.index,a)?null:"layout-unavailable":"missing-target"},selectShape(n,o,a){let l=Er(n,o?.slideId);return !l||!c(l.slide.shapes,o.shapeId)?"missing-target":gt.current?"unsupported":Ze(l.index,false)?(de({slideId:l.slide.id,shapeId:o.shapeId}),a&&Le.current?.focus(),null):"layout-unavailable"},selectText(n,o,a){let l=Er(n,o?.slideId),c$1=l?c(l.slide.shapes,o.shapeId):null;if(!l||!c$1?.textStories.some(L=>L.id===o.storyId))return "missing-target";let{anchor:f,focus:y}=o;if(!Number.isInteger(f)||!Number.isInteger(y)||f<0||y<0)return "missing-target";let b=n.story(o.storyId).length;return f>b||y>b?"missing-target":gt.current?"unsupported":Ze(l.index,false)?(se({shapeId:c$1.id,storyId:o.storyId,anchor:f,focus:y}),a&&Le.current?.focus(),null):"layout-unavailable"}},it=useRef({admit:Ht,applyBatch:Vt,readOnlyRefusal:rt,pluginNavigator:ro});it.current={admit:Ht,applyBatch:Vt,readOnlyRefusal:rt,pluginNavigator:ro};let[Es]=useState(()=>({handle:()=>E$1.current,admit:(n,o)=>it.current.admit(n,o),readOnlyRefusal:n=>it.current.readOnlyRefusal(n),applyEdits:(n,o,a,l)=>it.current.applyBatch(n,o,a,l),commands:()=>ct,navigator:{goToSlide:(...n)=>it.current.pluginNavigator.goToSlide(...n),selectShape:(...n)=>it.current.pluginNavigator.selectShape(...n),selectText:(...n)=>it.current.pluginNavigator.selectText(...n)}})),[Cs,_n]=useState(null),ks=useMemo(()=>{let n=T?.snapshot.slides[T.slideIndex];if(!T||!n)return null;let o={slideId:n.id,slide:T.slideIndex+1};if(ue){let{shapeId:a,storyId:l,anchor:c,focus:f}=ue;return {...o,target:{kind:"text",shapeId:a,storyId:l,anchor:c,focus:f}}}return Ee?.slideId===n.id?{...o,target:{kind:"shape",shapeId:Ee.shapeId}}:{...o,target:{kind:"slide"}}},[T,ue,Ee]),Ue=wi({plugins:J$1,pluginGrants:$$1,onPluginError:Ae,access:Es,commands:ct,readOnly:M$1,handle:Cs,reviewing:Y$1.reviewing,selection:ks,pointAt:(n,o,a)=>(C?ge.current?.frame(ge.current.active)?.displayList===n:U.current?.frame===n)?En.current(o,a):null,t:w}),oo=Ue.beginLoad,Xn=Ue.presentFrame;useEffect(()=>{let n=ge.current;if(!C||!n?.current)return;if(n.owner.failure){Kt(n.owner.failure.message),_n(null),E$1.current=null;return}if(n.access&&E$1.current)(U.current?.version!==n.owner.state.version||U.current?.slideIndex!==n.active)&&Z(n.active);else {let a=n.snapshot(),l=n.frame(n.active)?.displayList??null;if(a&&(U.current?.version!==n.owner.state.version||U.current?.slideIndex!==n.active||U.current?.frame!==l)){let c={snapshot:a,frame:l,slideIndex:n.active,version:n.owner.state.version??"",layoutKeys:{}};U.current=c,Fn(c);}}let o=new Map;n.owner.state.projection?.slides.forEach((a,l)=>{let c=n.frame(l);c&&o.set(a.id,c.displayList);}),Te.replace(o);},[C,cs,Z,Te]),useEffect(()=>{let n=false,o=null,a=[],l=()=>{};if(oo(),_n(null),C||E$1.current?.dispose(),E$1.current=null,nt.current+=1,Cn.current=null,kn.current!==void 0&&Ur(_(kn.current)),Q.reset(),Ge.current=null,$r(null),U.current=null,Fn(null),Te.replace(new Map),se(null),de(null),me(null),be(null),ke(null),ze("select"),Ut(false),qn([]),mt(false),_$1.current=null,ee.current=null,Ke.current=null,fe.current=null,Kt(null),Gr(null),ut.current=null,Rn.current.clear(),!e$1)return;Tt(true);let c=null;if(C)try{c=C(()=>{n||wn(f=>f+1);}),ge.current=c,wn(f=>f+1),c.request();}catch(f){Tt(false),Gr(f instanceof Error?f:new Error(String(f))),K$1(f);return}return (c?c.open(Q).then(()=>[void 0,[]]):Promise.all([initWasm(),Bl(An)])).then(([,f])=>{if(a=f,n){es(a);return}try{o=c?c.access:openPresentation(e$1,{clientId:N,fonts:An,initialUpdate:ie}),!c&&i$1&&o.setCollaborative(),E$1.current=o,l=o.onUpdate((k,R)=>{R==="remote"&&Z(void 0,!0,!0);});let y=Or.current;Z(c?c.active:typeof y=="number"&&Number.isInteger(y)?y-1:0,!1,!0),Tt(!1),c||$r(o),_n(o);let b=o,L={clearSelection:Gt,commands:Sn,goToSlide:Un,handle:b,refresh:eo,refreshProposals:yt,flushPendingInput:()=>Mr(b),getPositionAtPoint:(k,R)=>E$1.current===b?En.current(k,R):null,save:()=>{if(E$1.current!==b)throw new Error("Presentation is no longer open");if(Q.busy()||_$1.current||ee.current)throw new Error("Await flushPendingInput before saving pending input");return b.save()},selectText:to,focus:()=>Le.current?.focus(),version:()=>$e(b,()=>b.version()),readContent:k=>$e(b,()=>b.readContent(k)),findText:k=>$e(b,()=>b.findText(k)),validateEdits:k=>$e(b,()=>rt(b)??b.validateEdits(k)),applyEdits:async k=>{let R=rt(b);return R||$e(b,()=>Vt(b,k))}};if(c){let k=c,R=Ki(k.owner,L,()=>k.access,async D=>k.show(D)?(Ze(D-1,!1),k.showAsync(D)):!1,()=>!!(_$1.current||ee.current),()=>k.current,()=>Fe.current);k.onFirstPaint=()=>Lr.current?.(R),wn(D=>D+1);}else Wr.current?.(L);}catch(y){Tt(false),K$1(y);}},f=>{n||(Tt(false),c?.owner.failure||K$1(f));}),()=>{if(n=true,l(),c){let f=c;f.owner.state.sequence>0&&xs({save:()=>f.owner.recoverySave(),name:`previous-${g$1??"presentation.pptx"}`}),c.dispose();}else qt.current?.handle!==o&&o?.dispose();ge.current===c&&(ge.current=null),E$1.current===o&&(E$1.current=null),Rn.current.clear(),es(a);}},[C,$e,Vt,oo,N,s$1,ie,Gt,Sn,Q,e$1,Mr,Un,An,eo,rt,Z,K$1,to,ze,se,de,Te]),useLayoutEffect(()=>{if(!Pe||!ft)return;let n={handle:ft};return qt.current=n,Pe(ft),()=>{Pe(null),queueMicrotask(()=>{E$1.current!==ft&&ft.dispose(),qt.current===n&&(qt.current=null);});}},[Pe,ft]),useEffect(()=>Dn(null),[pt]),useEffect(()=>{if(!j$1){Nn([]);return}return Nn(j$1.peers),j$1.onPresence(Nn)},[j$1]),useEffect(()=>{let n=Nr.current;if(!n)return;let o=()=>gs({width:n.clientWidth,height:n.clientHeight});o();let a=new ResizeObserver(o);return a.observe(n),()=>a.disconnect()},[]);let Ts=useMemo(()=>!T?.frame||kt.width<=0||kt.height<=0?1:Math.min((kt.width-40)/T.frame.width,(kt.height-40)/T.frame.height,1),[T?.frame,kt]),te=Wn==="fit"?Ts:Wn,ne=C?ge.current:null,He=ne?.frame(ne.active),$t=ne?.navigation,Rs=ne?.owner.state.sequence,As=!C||ne?.overlays;useEffect(()=>{let n=Nt.current,o=T,a=C?He?.displayList:o?.frame;if(!n||!o||!a||C&&(!ne||!He||!ne.currentPaint(He,$t)))return;let l=n.getContext("2d");if(!l)return;let c=window.devicePixelRatio||1;Xn(null),sizeCanvasForSlide(n,a,c,te);let f=false,y=ne&&He?ne.images.resolve(He):null,b=()=>!f&&(!ne||!!He&&ne.currentPaint(He,$t)),L=paintSlide(C?It(l,b):as(l,b),a,c,te,{resolveImage:y??ht}).then(()=>{if(!b())return;let{snapshot:k,slideIndex:R,version:D}=o;Xn({frame:a,snapshot:k,slideIndex:R,version:D,scale:te,canvas:n}),ne&&He&&ne.didPaint(He,$t);},k=>{b()&&K$1(k);});return Ln.current=y?L.finally(()=>y.release()):L,()=>{f=true;}},[C,ne,He,$t,Rs,H$1,T?.frame,T?.snapshot,T?.slideIndex,T?.version,Xn,K$1,ht,te]),useEffect(()=>{if(C)return;let n=E$1.current,o=T;if(!n||!o||Te.size===o.snapshot.slides.length)return;let a=false,l,c=0,f=()=>{let y=U.current;if(a||E$1.current!==n||!y||y.layoutKeys!==o.layoutKeys||n.version()!==y.version)return;let b=performance.now(),L=new Map,k;try{try{for(;c<y.snapshot.slides.length;){let R=c++,D=y.snapshot.slides[R].id;if(!Te.get(D)&&(L.set(D,n.layoutSlide(R)),performance.now()-b>=fl))break}}finally{let R=y.snapshot.slides[y.slideIndex]?.id;R&&yn(n).activate(R,y.layoutKeys[R]);}}catch(R){k={value:R};}if(Te.add(L),k){K$1(k.value);return}c<y.snapshot.slides.length&&Te.size<y.snapshot.slides.length&&(l=setTimeout(f,0));};return Ln.current.then(()=>{a||(l=setTimeout(f,0));}),()=>{a=true,l!==void 0&&clearTimeout(l);}},[C,T?.layoutKeys,K$1,Te]);let Oe=useMemo(()=>{if(!T?.frame||!Ee)return null;let n=T.snapshot.slides[T.slideIndex];return !n||n.id!==Ee.slideId?null:c(n.shapes,Ee.shapeId)},[T,Ee]),st=useMemo(()=>T?.frame&&Oe?k(T.snapshot,T.frame,Oe):null,[T,Oe]),Rt=useMemo(()=>{if(!T?.frame||!ue||st)return null;let n=T.snapshot.slides[T.slideIndex],o=n?c(n.shapes,ue.shapeId):null;return o?k(T.snapshot,T.frame,o):null},[T,st,ue]),ve=T?.snapshot.slides[T.slideIndex],At=ve?.id,Yn=useMemo(()=>{if(ve){if(Ee?.slideId===ve.id)return Ee.shapeId;if(ue)return e(ve,ue.shapeId)?.id}},[ve,ue,Ee]);useEffect(()=>{j$1&&j$1.setCursor(At?{slideId:At,...Yn?{shapeId:Yn}:{}}:null);},[j$1,At,Yn]),useEffect(()=>()=>{j$1?.setCursor(null);},[j$1]);let Ft=useMemo(()=>W(ot),[ot]),Vn=useMemo(()=>{if(!T?.frame||!ve)return {visible:[],overflow:0};let n=d(ve.shapes),o=Y(ot,ve.id,n),a=[],l=o.overflow;for(let c of o.visible){let f=n.get(c.shapeId);if(!f)continue;let y=k(T.snapshot,T.frame,f);y?a.push({peer:c.peer,peerCount:c.count,shapeId:c.shapeId,bounds:y}):l+=c.count;}return {visible:a,overflow:l}},[ve,T,ot]),Fs=useMemo(()=>{let n=new Set(T?.snapshot.slides.map(o=>o.id));return X$1(ot,n)},[T,ot]);useEffect(()=>{let n=E$1.current;if(!(!n||!ue))try{let o=n.story(ue.storyId);qr(ui(o,ue.anchor,ue.focus,Ir));}catch(o){K$1(o);}},[T,K$1,ue]);let Ls=n=>{Un(n+1);},Ms=(n,o,a)=>{let l=E$1.current,c=U.current;if(!l||!c?.frame||Fe.current)return;let f=c.snapshot.slides.find(D=>D.id===n);if(!f)return;let y=Math.abs(a.x-o.x)>=6||Math.abs(a.y-o.y)>=6,b=y?Math.abs(a.x-o.x):c.frame.width*.36,L=y?Math.abs(a.y-o.y):c.frame.height*.12,k=Math.max(0,Math.min(y?Math.min(o.x,a.x):o.x,c.frame.width-b)),R=Math.max(0,Math.min(y?Math.min(o.y,a.y):o.y,c.frame.height-L));try{let D=l.addTextBox(f.id,{name:w("objects.defaultTextBoxName"),rect:{x:Math.round(k*c.snapshot.widthEmu/c.frame.width),y:Math.round(R*c.snapshot.heightEmu/c.frame.height),width:Math.round(Math.max(12,b)*c.snapshot.widthEmu/c.frame.width),height:Math.round(Math.max(12,L)*c.snapshot.heightEmu/c.frame.height)},text:"",style:On.current}),ce=Z(void 0,!0,!1,f.id);ze("select"),me(null),be(null),_$1.current=null,fe.current=null;let oe=ce?.snapshot.slides[ce.slideIndex]?.shapes.find(Se=>Se.id===D.shapeId);oe&&de(null);let ye=oe?.textStories[0];ye&&(se({shapeId:oe.id,storyId:ye.id,anchor:0,focus:0,focusLine:0}),Le.current?.focus());}catch(D){throw K$1(D),D}},Os=(n,o,a,l)=>{let c=E$1.current,f=U.current;if(!c||!f?.frame||Fe.current)return;let y=f.snapshot.slides.find(oe=>oe.id===n),b=k$1.find(oe=>oe.geometry===o);if(!y||!b)return;let L=Math.abs(l.x-a.x)>=6||Math.abs(l.y-a.y)>=6,k=L?Math.abs(l.x-a.x):f.frame.width*.22,R=L?Math.abs(l.y-a.y):f.frame.height*.18,D=Math.max(0,Math.min(L?Math.min(a.x,l.x):a.x-k/2,f.frame.width-k)),ce=Math.max(0,Math.min(L?Math.min(a.y,l.y):a.y-R/2,f.frame.height-R));try{let oe=c.addShape(y.id,{name:w(b.labelKey),geometry:o,rect:{x:Math.round(D*f.snapshot.widthEmu/f.frame.width),y:Math.round(ce*f.snapshot.heightEmu/f.frame.height),width:Math.round(Math.max(12,k)*f.snapshot.widthEmu/f.frame.width),height:Math.round(Math.max(12,R)*f.snapshot.heightEmu/f.frame.height)},fill:"#d9eaf7"}),ye=Z(void 0,!0,!1,y.id);ze("select"),me(null),be(null),_$1.current=null,fe.current=null,ye?.snapshot.slides[ye.slideIndex]?.id===y.id&&(se(null),de({slideId:y.id,shapeId:oe.shapeId}),Le.current?.focus());}catch(oe){throw K$1(oe),oe}},Ws=async(n,o)=>{let{handle:a}=o,l=()=>E$1.current===a&&nt.current===o.generation&&aa("insertImage").enabled;try{if(n.size>Qi)throw new Error(`image is ${n.size} bytes, exceeds the ${Qi}-byte limit`);let c=n.name.split(".").pop()?.toLowerCase()??"",f=n.type==="image/jpg"?"image/jpeg":n.type||wr[c];if(!Object.values(wr).includes(f))throw new Error(`unsupported image type ${n.type||c}`);let y=await Zi(n),b=y.slice(y.indexOf(",")+1),L=`data:${f};base64,${b}`;if(f==="image/tiff"){let Ne=Uint8Array.from(atob(b),ca=>ca.charCodeAt(0));L=await Zi(presentationImageBlob(Ne));}let k=await xl(L),R=U.current;if(!l()||!R?.frame){if(C)throw new Error("The presentation changed before the image was inserted");return}if(k.width<=0||k.height<=0)throw new Error("image dimensions must be positive");let D=R.snapshot.slides.findIndex(Ne=>Ne.id===o.slideId),ce=R.snapshot.slides[D];if(!ce){if(C)throw new Error("The image target slide no longer exists");return}let oe=R.frame.width*.5,ye=R.frame.height*.5,Se=Math.min(oe/k.width,ye/k.height,1),We=Math.max(1,k.width*Se),Qe=Math.max(1,k.height*Se),Zt=(R.frame.width-We)/2,xe=(R.frame.height-Qe)/2,_e=a.addPicture(ce.id,{name:n.name||w("objects.defaultPictureName"),rect:{x:Math.round(Zt*R.snapshot.widthEmu/R.frame.width),y:Math.round(xe*R.snapshot.heightEmu/R.frame.height),width:Math.round(We*R.snapshot.widthEmu/R.frame.width),height:Math.round(Qe*R.snapshot.heightEmu/R.frame.height)},contentType:f,mediaBase64:b}),Pt=Z(void 0,!0,!1,ce.id);if(ze("select"),me(null),be(null),_$1.current=null,fe.current=null,Pt&&D===Pt.slideIndex){se(null),de({slideId:ce.id,shapeId:_e.shapeId});let Ne=document.activeElement;(!Ne||Ne===document.body||Le.current?.contains(Ne))&&Le.current?.focus();}}catch(c){throw (C||l())&&K$1(c),c}},io=()=>{let n=E$1.current,o=U.current;return n?{handle:n,generation:nt.current,slideId:o?.snapshot.slides[o.slideIndex]?.id??null}:null},Ds=n=>{let o=In.current??io();if(In.current=null,!o||o.handle!==E$1.current||o.generation!==nt.current){C&&K$1(new Error("The presentation changed before the image was inserted"));return}C&&Vr(a=>a+1),Q.input(()=>Ws(n,o)).catch(()=>{}).finally(()=>{C&&Vr(a=>a-1);});},Bs=n=>{if(C){if(!ge.current?.hydrated){K$1(new PptxPeerNotReadyError);return}Q.breakTyping();}if(!n.isPrimary||n.button!==0)return;Ge.current=null;let o=E$1.current,a=U.current;if(!o||!a?.frame)return;let l$2=b$1(n.currentTarget.getBoundingClientRect(),a.frame,n.clientX,n.clientY);if(!l$2)return;Ke.current=null,ee.current=null,ke(null);let c=a.snapshot.slides[a.slideIndex],f=l(pt);if(!M$1&&(pt==="textBox"||f)&&c){se(null),de(null),me(null),be({start:l$2,end:l$2}),fe.current=null,_$1.current=f?{kind:"shapeInsert",pointerId:n.pointerId,slideId:c.id,geometry:f,start:l$2,last:l$2}:{kind:"textBox",pointerId:n.pointerId,slideId:c.id,start:l$2,last:l$2},n.currentTarget.setPointerCapture(n.pointerId),Le.current?.focus(),n.preventDefault();return}try{let y=c?yn(o).hitTest(c.id,l$2.x,l$2.y):null,b=y?.kind==="text"&&u(a.frame,l$2,te)==="shape"?{kind:"shape",shapeId:y.shapeId}:y,L=c&&b?e(c,b.shapeId):null,k=fe.current,R=!!(c&&L&&k?.slideId===c.id&&k.shapeId===L.id&&n.timeStamp-k.timeStamp<=600&&Math.hypot(n.clientX-k.clientX,n.clientY-k.clientY)<=6),D=R&&k?Math.min(k.count+1,3):1,ce=b?.kind==="text"?l$1(a.frame,b.shapeId,b.storyId,l$2):null;if(fe.current=null,c&&b?.kind==="text"&&L&&D>=2){let oe=o.story(b.storyId),ye=D>=3?"paragraph":"word",Se=fr(Et(oe),b.position,ye);se({shapeId:b.shapeId,storyId:b.storyId,anchor:Se.start,focus:Se.end,focusLine:ce?.lineIndex}),de(null),me(null),_$1.current={kind:"text",pointerId:n.pointerId,slideId:c.id,shapeId:b.shapeId,storyId:b.storyId,anchor:Se.start,focus:Se.end,focusLine:ce?.lineIndex,granularity:ye,clickCount:D,clickShapeId:L.id,startClientX:n.clientX,startClientY:n.clientY,dragging:!1},n.currentTarget.setPointerCapture(n.pointerId);}else if(c&&ue&&b?.kind==="text"&&b.shapeId===ue.shapeId&&b.storyId===ue.storyId){o.story(b.storyId);let oe=n.shiftKey?ue.anchor:b.position;se({shapeId:b.shapeId,storyId:b.storyId,anchor:oe,focus:b.position,focusLine:ce?.lineIndex}),de(null),me(null),_$1.current={kind:"text",pointerId:n.pointerId,slideId:c.id,shapeId:b.shapeId,storyId:b.storyId,anchor:oe,focus:b.position,focusLine:ce?.lineIndex,granularity:"character",clickCount:D,clickShapeId:L?.id??b.shapeId,startClientX:n.clientX,startClientY:n.clientY,dragging:!1},n.currentTarget.setPointerCapture(n.pointerId);}else c&&b?L?(se(null),de({slideId:c.id,shapeId:L.id}),me(null),!M$1&&i(L)?(_$1.current={kind:"shape",pointerId:n.pointerId,slideId:c.id,shapeId:L.id,startClientX:n.clientX,startClientY:n.clientY,start:l$2,last:l$2,dragThreshold:R?8:4,clickCount:D,dragging:!1},n.currentTarget.setPointerCapture(n.pointerId)):_$1.current=null):(se(null),de(null),fe.current=null,_$1.current=null):(se(null),de(null),me(null),fe.current=null,_$1.current=null);Le.current?.focus(),n.preventDefault();}catch(y){K$1(y);}},so=n$1=>{let o=_$1.current,a=E$1.current,l=U.current;if(!o||o.pointerId!==n$1.pointerId||!a||!l?.frame)return false;let c=b$1(n$1.currentTarget.getBoundingClientRect(),l.frame,n$1.clientX,n$1.clientY);if(!c||l.snapshot.slides[l.slideIndex]?.id!==o.slideId)return false;if(o.kind==="text"){!o.dragging&&n(o.startClientX,o.startClientY,n$1.clientX,n$1.clientY)&&(o.dragging=true);let f=l$1(l.frame,o.shapeId,o.storyId,c);if(f){let y=o.granularity==="character"?{anchor:o.anchor,focus:f.position}:Ei({start:o.anchor,end:o.focus},fr(Et(a.story(o.storyId)),f.position,o.granularity));se({shapeId:o.shapeId,storyId:o.storyId,...y,focusLine:f.lineIndex});}}else o.kind==="shape"?(o.last=c,!o.dragging&&n(o.startClientX,o.startClientY,n$1.clientX,n$1.clientY,o.dragThreshold)&&(o.dragging=true),o.dragging&&me({shapeId:o.shapeId,delta:{x:c.x-o.start.x,y:c.y-o.start.y}})):(o.last=c,be({start:o.start,end:c}));return true},zs=n=>{if(so(n)){n.preventDefault();return}if(_$1.current||pt!=="select")return;let o=U.current;if(!o?.frame)return;let a=b$1(n.currentTarget.getBoundingClientRect(),o.frame,n.clientX,n.clientY);Dn(a?u(o.frame,a,te):null);},Hs=()=>{_$1.current||Dn(null);},Ns=n=>{so(n);let o=_$1.current;if(!(!o||o.pointerId!==n.pointerId)){if(_$1.current=null,me(null),n.currentTarget.hasPointerCapture(n.pointerId)&&n.currentTarget.releasePointerCapture(n.pointerId),o.kind==="textBox"){be(null),Q.input(()=>Ms(o.slideId,o.start,o.last)).catch(()=>{}),n.preventDefault();return}if(o.kind==="shapeInsert"){be(null),Q.input(()=>Os(o.slideId,o.geometry,o.start,o.last)).catch(()=>{}),n.preventDefault();return}if(o.kind==="text"){fe.current=o.dragging?null:{slideId:o.slideId,shapeId:o.clickShapeId,clientX:n.clientX,clientY:n.clientY,timeStamp:n.timeStamp,count:o.clickCount};return}if(o.kind==="shape"){if(!o.dragging){fe.current={slideId:o.slideId,shapeId:o.shapeId,clientX:n.clientX,clientY:n.clientY,timeStamp:n.timeStamp,count:o.clickCount};return}fe.current=null,n.preventDefault(),Q.input(()=>js(o)).catch(()=>{});}}},js=n=>{let o=E$1.current,a=U.current,l=a?.snapshot.slides[a.slideIndex];if(!o||!a?.frame||l?.id!==n.slideId||Fe.current)return;let c$1=c(l.shapes,n.shapeId);if(c$1)try{let f=h(c$1),y=m(a.snapshot,a.frame,c$1,{x:n.last.x-n.start.x,y:n.last.y-n.start.y});f&&y&&(y.x!==f.x||y.y!==f.y)&&(o.moveShape(l.id,c$1.id,y.x,y.y),Z(void 0,!0)),de({slideId:l.id,shapeId:c$1.id});}catch(f){throw K$1(f),f}},Ks=n=>{let o=E$1.current;if(!(!o||Fe.current))try{o.removeShape(n.slideId,n.shapeId),de(null),me(null),_$1.current=null,ee.current=null,ke(null),Z(void 0,!0);}catch(a){throw K$1(a),a}},ao=n=>{_$1.current?.pointerId===n.pointerId&&(_$1.current=null,me(null),be(null),fe.current=null);},qs=n=>{if(Fe.current)return Je.current;let o=n?{...n,focusLine:void 0}:null;return se(o),de(null),fe.current=null,Z(void 0,true),o},Us=n=>{if(C&&!ge.current?.hydrated){rs(n)&&(n.preventDefault(),K$1(new PptxPeerNotReadyError));return}if(!E$1.current||H(n.nativeEvent)||I(n.target))return;if(n.key==="Escape"){Y$1.setEnabled(false),ze("select"),be(null),_$1.current=null,ee.current=null,ke(null),n.preventDefault();return}if((n.key==="Backspace"||n.key==="Delete")&&!Fe.current&&!gt.current&&Je.current===null&&Ct.current){let f=Ct.current;n.preventDefault(),Q.input(()=>Ks(f)).catch(()=>{});return}let o={key:n.key,shiftKey:n.shiftKey,metaKey:n.metaKey,ctrlKey:n.ctrlKey,altKey:n.altKey},a=Q.busy(),l=a?Ge.current:null;if(!(!(l?l.selection!==null:Je.current!==null)||gt.current||!rs(o))){if(a){if(n.preventDefault(),!Ge.current){let y=Je.current;Ge.current={selection:y?lo(y):null};}let f=Ge.current;Q.input(()=>_s(o,f),"keyboard").catch(()=>{});return}co(o,Je.current).handled&&n.preventDefault();}},lo=n=>{let o=E$1.current;if(!o)return null;try{return {shapeId:n.shapeId,storyId:n.storyId,anchor:o.anchorCaret(n.storyId,n.anchor),focus:o.anchorCaret(n.storyId,n.focus)}}catch{return null}},_s=(n,o)=>{let a=o.selection;if(!a)return;let l=E$1.current;if(!l)throw new Error("Presentation is no longer open");let c;try{let y=l.resolveCaretAnchor(a.anchor),b=l.resolveCaretAnchor(a.focus);if(y===null||b===null)throw new Error("The text changed before the typed input was applied");c={shapeId:a.shapeId,storyId:a.storyId,anchor:y,focus:b};}catch(y){throw K$1(y),y}let f=co(n,c,true).selection;o.selection=f?lo(f):null;},co=(n,o,a=false)=>{let l=E$1.current,c={handled:false,selection:o};if(!l||gt.current)return c;let f=Math.min(o.anchor,o.focus),y=Math.max(o.anchor,o.focus),b=L=>({handled:true,selection:qs(L)});try{let L=Ys(n,o);if(L!==null){C&&Q.breakTyping();let k={...o,anchor:n.shiftKey?o.anchor:L.position,focus:L.position,focusLine:L.lineIndex};return se(k),{handled:!0,selection:k}}if(Fe.current)return c;if(C&&Q.beginTyping(o.storyId),n.key==="Backspace"){if(f!==y)return l.deleteText(o.storyId,f,y),b({...o,anchor:f,focus:f});let k=Wl(l.story(o.storyId),f);return k<f?(l.deleteText(o.storyId,k,f),b({...o,anchor:k,focus:k})):{handled:!0,selection:o}}if(n.key==="Delete"){if(f!==y)return l.deleteText(o.storyId,f,y),b({...o,anchor:f,focus:f});let k=Dl(l.story(o.storyId),y);return k>y?(l.deleteText(o.storyId,y,k),b({...o,anchor:y,focus:y})):{handled:!0,selection:o}}if(n.key==="Enter")return f!==y&&l.deleteText(o.storyId,f,y),l.insertParagraphBreak(o.storyId,f),b({...o,anchor:f+1,focus:f+1});if(ds(n)){f!==y&&l.deleteText(o.storyId,f,y),l.insertText(o.storyId,f,n.key,On.current);let k=f+n.key.length;return b({...o,anchor:k,focus:k})}return c}catch(L){if(K$1(L),a)throw L;return {handled:true,selection:o}}finally{C&&Q.endTyping();}},Gn=()=>{let n=U.current,o=Ct.current,a=n?.snapshot.slides[n.slideIndex];return a&&o&&a.id===o.slideId?c(a.shapes,o.shapeId):null},Xs=n=>{let o=E$1.current,a=Je.current,l=a?null:Gn()?.textStories[0]?.id??null;if(!o||!a&&!l)return false;if(qr(c=>({...c,...n})),a){if(a.anchor===a.focus)return true;o.formatText(a.storyId,Math.min(a.anchor,a.focus),Math.max(a.anchor,a.focus),n);}else Ol(o,o.story(l),n);return Z(void 0,true),true},Ys=(n,o)=>{let a=E$1.current;if(!a)return null;let l=a.story(o.storyId),c=Math.max(0,l.length-1),f=R=>Math.max(0,Math.min(c,R)),y=zl(U.current?.frame,o),b={position:o.focus,lineIndex:o.focusLine},L=n.altKey||n.ctrlKey&&!n.metaKey,k=n.metaKey;if(n.key==="ArrowUp"||n.key==="ArrowDown"){let R={shapeId:o.shapeId,...b},D=Ke.current&&Ci(Ke.current,R)?Ke.current.goalX:hr(y,b),ce=n.key==="ArrowUp"?"up":"down",oe=ki(y,b,ce,D),ye={...oe,position:f(oe.position)};return Ke.current=D===void 0?null:{shapeId:o.shapeId,goalX:D,position:ye.position,lineIndex:ye.lineIndex},ye}if(Ke.current=null,n.key==="ArrowLeft"||n.key==="ArrowRight"){let R=n.key==="ArrowLeft"?-1:1;if(k){let ce=pn(y,b,R<0?"start":"end");return {...ce,position:f(ce.position)}}let D=L?Ti(Et(l),o.focus,R):o.focus+R;return {position:f(D),lineIndex:o.focusLine}}if(n.key==="Home"){if(k||n.ctrlKey)return {position:0,lineIndex:0};let R=pn(y,b,"start");return {...R,position:f(R.position)}}if(n.key==="End"){if(k||n.ctrlKey)return {position:c,lineIndex:Math.max(0,y.length-1)};let R=pn(y,b,"end");return {...R,position:f(R.position)}}return null},Vs=n=>{let o=E$1.current,a=Je.current,l=a?.storyId??Gn()?.textStories[0]?.id;return !o||!l?false:(a?o.setParagraphAlignment(l,Math.min(a.anchor,a.focus),Math.max(a.anchor,a.focus),n):o.setParagraphAlignment(l,0,o.story(l).length,n),Z(void 0,true),true)},Gs=n=>{let o=E$1.current,a=Ct.current,l=Gn();if(!o||!a||!l)return false;if(n.type==="fillColor")o.setShapeFill(a.slideId,a.shapeId,n.value);else if(n.type==="strokeColor")o.setShapeStroke(a.slideId,a.shapeId,n.value?{color:n.value}:{});else if(n.type==="strokeWidth")o.setShapeStroke(a.slideId,a.shapeId,n.value===null?{}:{widthPt:n.value});else if(n.type==="adjust")o.setShapeAdjust(a.slideId,a.shapeId,{...l.adjustValues,[n.name]:n.value});else {let c={front:o.bringShapeToFront,back:o.sendShapeToBack,forward:o.bringShapeForward,backward:o.sendShapeBackward}[n.value];c(a.slideId,a.shapeId);}return Z(void 0,true),true},$s=n=>{let o=E$1.current,a=U.current;if(!o||!a)return false;let l=a.slideIndex+1,c=n===void 0?a.snapshot.slides[a.slideIndex]?.layoutPartPath??void 0:n??void 0;return o.insertSlide(l,c),se(null),de(null),me(null),be(null),ze("select"),_$1.current=null,fe.current=null,ee.current=null,ke(null),Z(l,true,true),true},Js=n=>{let o=E$1.current;return o?(n==="undo"?o.undo():o.redo(),se(null),me(null),be(null),ze("select"),_$1.current=null,fe.current=null,ee.current=null,ke(null),Z(void 0,true,true),true):false},Zs=n=>{C&&Q.breakTyping();let o=Xr.current!==n;return Y$1.setEnabled(false),ze(n),n!=="select"&&(se(null),de(null)),be(null),_$1.current=null,ee.current=null,ke(null),o},Qs=()=>{if(C){let c=ge.current;return c?(async()=>{if(O&&await O()!==true)return "requested";if(_$1.current||ee.current)return "gesture";let f=await c.owner.saveAsync();return c.require(),S&&S(f),(p$1??!S)&&Bt(f,g$1??"presentation.pptx",xn),"saved"})().catch(f=>(K$1(f),"failed")):Promise.resolve("replaced")}if(ut.current)return ut.current;let n=E$1.current;if(!n)return Promise.resolve("replaced");let o=nt.current,a=()=>E$1.current===n&&nt.current===o,l=Promise.resolve().then(async()=>O&&await O()!==true?"requested":a()?Q.run(()=>{if(!a())return "replaced";if(_$1.current||ee.current)return "gesture";let c=n.save();return S&&S(c),(p$1??!S)&&Bt(c,g$1??"presentation.pptx",xn),"saved"}):"replaced").catch(c=>c instanceof Ve?"input-failed":c instanceof je||!a()?"replaced":(K$1(c),"failed")).finally(()=>{ut.current===l&&(ut.current=null);});return ut.current=l,l};En.current=(n,o)=>{let a=E$1.current,l=U.current,c=Nt.current;if(!a||!l?.frame||!c||Y$1.reviewing)return null;let f=b$1(c.getBoundingClientRect(),l.frame,n,o);if(!f||f.x<0||f.y<0||f.x>=l.frame.width||f.y>=l.frame.height)return null;let y=l.snapshot.slides[l.slideIndex],b=y&&yn(a).hitTest(y.id,f.x,f.y);return b&&y?{...b,slide:l.slideIndex+1,slideId:y.id}:null};let uo=(n,o)=>{let a=Nt.current,l=T?.frame;return !a||!l?null:b$1(a.getBoundingClientRect(),l,n,o)},ea=n=>o=>{if(M$1||!Ee||!Oe||!j(Oe))return;let a=uo(o.clientX,o.clientY);a&&(o.preventDefault(),o.stopPropagation(),ee.current={pointerId:o.pointerId,handle:n,start:a,slideId:Ee.slideId,shapeId:Ee.shapeId,delta:{x:0,y:0}},ke({x:0,y:0}),o.currentTarget.setPointerCapture(o.pointerId));},po=n=>{let o=ee.current;return g(o,n.pointerId)?r$1(o.start,o.delta,uo(n.clientX,n.clientY)):null},ta=n=>{let o=ee.current,a=po(n);!g(o,n.pointerId)||!a||(o.delta=a,ke(a));},fo=n=>{let o=ee.current;return g(o,n.pointerId)?(ee.current=null,ke(null),n.currentTarget.hasPointerCapture(n.pointerId)&&n.currentTarget.releasePointerCapture(n.pointerId),o):null},mo=n=>{fo(n);},na=n=>{let o=po(n),a=fo(n);!a||!o||o.x===0&&o.y===0||Q.input(()=>ra(a,o)).catch(()=>{});},ra=(n,o)=>{let a=E$1.current,l=U.current,c$1=l?.snapshot.slides[l.slideIndex],f=c$1?c(c$1.shapes,n.shapeId):null;if(!(Fe.current||!a||!l?.frame||c$1?.id!==n.slideId||!f))try{let y=s(l.snapshot,l.frame,f,n.handle,o),b=h(f);y&&b&&(y.x!==b.x||y.y!==b.y||y.width!==b.width||y.height!==b.height)&&(a.setShapeRect(n.slideId,n.shapeId,y),Z(void 0,!0));}catch(y){throw K$1(y),y}},Jt=T?.snapshot.slides.length??0,Lt=T?.slideIndex??0,oa=()=>{if(U.current?.snapshot.slides.length){if(Kn){Ut(true);return}$i().then(n=>{Jr(()=>n),Ut(true);},K$1);}},ia=async()=>{let n;try{n=await Q.run(()=>{let y=U.current,b=E$1.current;if(!y?.frame||!b)throw new je;return {frame:y.frame,slideIndex:y.slideIndex,handle:b}});}catch(y){return y instanceof Ve?"input-failed":"replaced"}let{frame:o,slideIndex:a,handle:l}=n,c={current:l},f={current:dt()};try{let y=await slideToPng(o,{scale:window.devicePixelRatio||1,resolveImage:ts(c,f,H$1)}),b=new Uint8Array(await y.arrayBuffer());return E$1.current!==l?"replaced":(Bt(b,yl(g$1,a),"image/png"),"exported")}catch(y){return E$1.current!==l?"replaced":(K$1(y),"failed")}finally{f.current.dispose();}},ho=Mn&&Mn.shapeId===Ee?.shapeId?Mn.delta:null,$n=ee.current?.handle,sa=T?.frame&&Oe&&Tn&&$n?t(T.snapshot,T.frame,Oe,$n,Tn):null,xt=st?Tn&&$n?sa??st:{...st,x:st.x+(ho?.x??0),y:st.y+(ho?.y??0)}:null,go=e$1?C&&!ne?.hydrated?"loading":T&&E$1.current?"ready":Bn||!jt?"loading":"empty":"empty",Jn=!!((!C||ne?.hydrated)&&E$1.current?.isProposalsAvailable()),aa=xi(ct,{handle:E$1.current,handleRef:E$1,modelRef:U,selectionRef:Je,shapeSelectionRef:Ct,textStyleRef:On,activeToolRef:Xr,generationRef:nt,coordinator:Q,status:go,readOnlyRef:Fe,zoomRef:_r,proposalsRef:Ps,proposalsOpenRef:bs,reviewEnabledRef:Y$1.enabledRef,reviewSelectedIdRef:Y$1.selectedIdRef,proposalsAvailable:Jn,gestureActive:()=>!!(_$1.current||ee.current),baseStyle:Ir,i18n:G$1,t:w,workerMode:C?{preparing:!ne?.hydrated,failed:!!ne?.owner.failure||!!zn}:void 0,actions:{format:Xs,align:Vs,formatShape:Gs,insertSlide:$s,history:Js,setTool:Zs,setZoom:n=>{let o=n!==_r.current;return Ur(n),o},openPicker:()=>{In.current=io(),jr.current?.click();},save:Qs,exportPng:ia,present:oa,setProposalsOpen:n=>{n&&yt(),mt(n);},selectProposal:n=>{Y$1.select(n),Y$1.setEnabled(true);},showProposalDiff:n=>Y$1.setEnabled(n),acceptProposal:ws,rejectProposal:Is,reportError:K$1,focusEditor:()=>Le.current?.focus()},stamp:[T,ue,Ee,hs,pt,Wn,M$1,go,Y$1.enabled,Y$1.selected,Y$1.available,Xt,Yt,Jn,w,G$1]}),yo=useRef(jn);yo.current=jn,J({commands:ct,containerRef:Hr,suspended:()=>yo.current});let la=!B||z===null?null:jsxs("div",{style:X.toolbarShell,children:[jsx(x$1.Provider,{value:true,children:z!==void 0?jsx("div",{style:X.toolbar,children:z}):M$1?null:jsxs(Fragment,{children:[jsx(E,{mode:"commands",style:X.toolbar}),Jn&&jsx(G,{buttonRef:Qr,count:Xt.length})]})}),ot.length>0?jsxs("div",{style:X.presenceStrip,role:"list","aria-label":w("presence.label"),children:[Ft.visible.map(n=>{let o=n.state.cursor?.slideId===At;return jsx("span",{role:"listitem",style:ns(n.state.user.color,o),title:n.state.user.name,"aria-label":n.state.user.name,children:jl(n.state.user.name)},n.state.clientId)}),Ft.overflow>0?jsxs("span",{role:"listitem",style:ns("#64748b",true),title:`${Ft.overflow} more collaborators`,"aria-label":`${Ft.overflow} more collaborators`,children:["+",Ft.overflow]}):null]}):null,z===void 0&&jsx(F,{})]}),Zn=n=>Ue.managed?jsx(M,{host:Ue.host,placement:n,activations:Ue.activations.filter(o=>o.plugin.panel?.placement===n),available:ps}):null,da=jsxs("div",{ref:Hr,className:d$1,style:{...X.root,...u$1},children:[la,jsx("input",{ref:jr,type:"file",accept:Object.values(wr).join(","),disabled:M$1||Y$1.reviewing||!!C&&!ne?.hydrated,tabIndex:-1,"aria-hidden":"true","data-testid":"pptx-insert-image-input",style:X.hiddenFileInput,onChange:n=>{let o=n.currentTarget.files?.[0];n.currentTarget.value="",o&&Ds(o);}}),C&&ys>0&&jsx("div",{role:"status",children:w("worker.image")}),C&&Hn&&jsx("button",{type:"button",onClick:()=>{Hn.save().then(({bytes:n})=>Bt(n,Hn.name,xn)).catch(K$1);},children:w("worker.previousRecovery")}),C&&e$1&&!zn&&!ne?.hydrated&&jsxs("div",{role:"status","data-testid":"pptx-worker-status",children:[ne?.owner.failure?w("worker.failed"):m$1!==void 0?m$1:w("worker.preparing"),ne?.owner.failure&&jsx("button",{type:"button",onClick:()=>{ne.owner.recoverySave().then(({bytes:n})=>Bt(n,g$1??"presentation.pptx",xn)).catch(K$1);},children:w("worker.recovery")})]}),jsxs("div",{ref:us,style:X.workspace,children:[jsx("aside",{style:X.slideStrip,"aria-label":w("slides.panelLabel"),children:T?.snapshot.slides.map((n,o)=>{let a=Fs.get(n.id);return jsxs("button",{type:"button","aria-current":o===Lt?"page":void 0,style:Kl(o===Lt),onClick:()=>Ls(o),children:[jsx("span",{style:X.slideNumber,children:o+1}),jsxs("span",{style:X.slidePreview,children:[jsx(kl,{store:Te,slideId:n.id,title:Nl(n.shapes)||w("slides.fallbackTitle",{number:o+1}),resolveImage:ht,afterPaint:ms,worker:ne}),n.id!==At&&a&&(a.visible.length>0||a.overflow>0)?jsxs("span",{style:X.thumbnailPresence,"aria-hidden":"true",children:[a.visible.map(l=>jsx("span",{style:{...X.thumbnailPresenceDot,backgroundColor:l.state.user.color}},l.state.clientId)),a.overflow>0?jsxs("span",{style:X.thumbnailPresenceOverflow,children:["+",a.overflow]}):null]}):null]})]},n.id)})}),Zn("left"),jsxs("div",{style:X.center,children:[jsxs("div",{ref:Le,style:X.stage,tabIndex:0,role:"application","aria-label":w("editor.appLabel"),onKeyDown:Us,onFocus:()=>Kr(true),onBlur:()=>Kr(false),children:[!M$1&&!C&&jsx(ni,{review:Y$1,ready:vs===Y$1.diff}),jsx("div",{ref:Nr,style:X.canvasHost,children:T?.frame?jsxs("div",{style:{...X.canvasFrame,width:T.frame.width*te,height:T.frame.height*te},children:[jsx("canvas",{ref:Nt,"data-testid":"pptx-slide-canvas","aria-hidden":Y$1.reviewing,style:{...X.canvas,cursor:pt!=="select"?"crosshair":Yr==="text"?"text":Yr==="shape"?"move":"default"},onPointerDown:Y$1.reviewing?void 0:Bs,onPointerMove:zs,onPointerUp:Ns,onPointerLeave:Hs,onPointerCancel:ao,onLostPointerCapture:ao,"aria-label":Oe?w("slides.canvasLabelWithSelection",{current:Lt+1,total:Jt,name:Oe.name}):w("slides.canvasLabel",{current:Lt+1,total:Jt})}),Ue.managed&&jsx(K,{host:Ue.host,activations:Ue.activations,layerRef:Ue.overlayLayerRef}),!Y$1.reviewing&&As&&jsxs(Fragment,{children:[jsx(Rl,{frame:T.frame,selection:ue,scale:te,focused:fs}),Vn.visible.map(({peer:n,peerCount:o,shapeId:a,bounds:l},c)=>jsx(El,{peer:n,peerCount:o,bounds:l,scale:te,labelOffset:c},a)),Vn.overflow>0?jsxs("span",{style:X.remoteShapeOverflow,"aria-hidden":"true",children:["+",Vn.overflow," selections"]}):null,xt?jsxs(Fragment,{children:[jsx("span",{style:{...X.shapeSelection,left:xt.x*te,top:xt.y*te,width:Math.max(1,xt.width*te),height:Math.max(1,xt.height*te)},"aria-hidden":"true"}),!M$1&&Oe&&j(Oe)?a$2.map(n=>{let o$1=o(xt,n);return jsx("span",{"data-testid":`pptx-resize-${n}`,onPointerDown:ea(n),onPointerMove:ta,onPointerUp:na,onPointerCancel:mo,onLostPointerCapture:mo,style:{...X.resizeHandle,left:o$1.x*te-Pn/2,top:o$1.y*te-Pn/2,cursor:p(n)}},n)}):null]}):null,Rt?jsx("span",{style:{...X.textEditOutline,left:Rt.x*te,top:Rt.y*te,width:Math.max(1,Rt.width*te),height:Math.max(1,Rt.height*te)},"aria-hidden":"true"}):null,qe?jsx("span",{style:{...X.textBoxPreview,left:Math.min(qe.start.x,qe.end.x)*te,top:Math.min(qe.start.y,qe.end.y)*te,width:Math.max(1,Math.abs(qe.end.x-qe.start.x))*te,height:Math.max(1,Math.abs(qe.end.y-qe.start.y))*te},"aria-hidden":"true"}):null]}),Y$1.diff&&jsx(ri,{diff:Y$1.diff,current:T.snapshot,frame:T.frame,slideIndex:T.slideIndex,scale:te,resolveImage:ht,onPainted:Ss,onTarget:(n,o)=>{no(n,o,Y$1.selected?.id),mt(true);}},`${Y$1.diff.proposal.id}:${T.slideIndex}`)]}):jsx("div",{style:X.empty,children:Bn?m$1!==void 0?m$1:w("editor.opening"):w(e$1?"editor.noSlides":"editor.openPrompt")})}),jt?e$1&&!Bn&&(C?zn:!T)?jsx($,{kind:"open",details:jt}):jsx("div",{style:X.error,children:jt}):null]}),Zn("bottom")]}),Zn("right"),!M$1&&Yt&&_t&&T&&E$1.current&&jsx(_t,{handle:E$1.current,proposals:Xt,snapshot:T.snapshot,visualDisabledReason:C?w("worker.disabled"):void 0,resolveImage:ht,onNavigate:no,onClose:()=>Qr.current?.focus()})]}),ve&&Y$1.diff?.proposal.changes.some(n=>n.slideId===ve.id&&!n.shapeId&&n.oldText!==n.newText)?jsx(oi,{diff:Y$1.diff,slideId:ve.id}):ve?jsx(Cl,{value:ve.notes??"",disabled:!T||Y$1.reviewing||M$1||!!C&&!ne?.hydrated,label:w("notes.panelLabel"),placeholder:w("notes.placeholder"),onCommit:n=>{let o=E$1.current;if(!(!o||M$1))try{o.setSlideNotes(ve.id,n),Z(void 0,!0);}catch(a){K$1(a);}}},ve.id):null,jn&&Kn&&Jt>0&&E$1.current?jsx(Kn,{handle:E$1.current,slideCount:Jt,startIndex:Lt,resolveImage:ht,counterLabel:(n,o)=>w("presentation.slideCounter",{current:n,total:o}),label:w("presentation.label"),exitLabel:w("presentation.exit"),previousLabel:w("presentation.previousSlide"),nextLabel:w("presentation.nextSlide"),onExit:()=>Ut(false),onError:K$1}):null]});return jsx(A.Provider,{value:Sn,children:da})}function El({peer:e,peerCount:t,bounds:r,scale:i,labelOffset:s}){let[u,h]=useState(()=>Date.now()-e.cursorMovedAt<PRESENCE_LABEL_DURATION_MS);return useEffect(()=>{let m=PRESENCE_LABEL_DURATION_MS-(Date.now()-e.cursorMovedAt);if(m<=0){h(false);return}h(true);let x=setTimeout(()=>h(false),m);return ()=>clearTimeout(x)},[e.cursorMovedAt]),jsxs("span",{style:{...X.remoteShapeSelection,left:r.x*i,top:r.y*i,width:Math.max(1,r.width*i),height:Math.max(1,r.height*i),borderColor:e.state.user.color},"aria-hidden":"true",children:[jsx("span",{style:{...X.remoteShapeWash,backgroundColor:e.state.user.color}}),u?jsxs("span",{style:{...X.remoteShapeLabel,top:-4-s%3*20,backgroundColor:e.state.user.color},children:[e.state.user.name,t>1?` +${t-1}`:""]}):null]})}function Cl({value:e,disabled:t,label:r,placeholder:i,onCommit:s}){return jsxs("div",{style:X.notesPanel,children:[jsx("span",{style:X.notesLabel,children:r}),jsx("textarea",{"aria-label":r,style:X.notesTextarea,value:e,disabled:t,placeholder:i,"data-testid":"pptx-notes-textarea",onChange:u=>s(u.target.value)})]})}var kl=memo(function({store:t,slideId:r,title:i,resolveImage:s,afterPaint:u,worker:h}){let m=useCallback(d=>t.subscribe(r,d),[t,r]),x=useCallback(()=>t.get(r),[t,r]),p=useSyncExternalStore(m,x,x);return p?jsx(Tl,{frame:p,resolveImage:s,afterPaint:u,worker:h}):jsx("span",{style:X.slideTitle,children:i})}),Tl=memo(function({frame:t,resolveImage:r,afterPaint:i,worker:s}){let u=useRef(null);return useEffect(()=>{let h=u.current;if(!h)return;let m=h.getContext("2d");if(!m)return;let x=128/t.width,p=window.devicePixelRatio||1;sizeCanvasForSlide(h,t,p,x);let d=false;return Promise.resolve().then(i).then(async()=>{if(d)return;let g=s?s.thumbnailImages(t):null;if(!(s&&!g))try{await paintSlide(s?It(m,()=>!d&&s.isThumbnailCurrent(t)):as(m,()=>!d),t,p,x,{resolveImage:g??r});}finally{g?.release();}}).catch(()=>{}),()=>{d=true;}},[i,t,r,s]),jsx("canvas",{ref:u,style:X.thumbnailCanvas,"aria-hidden":"true"})});function Rl({frame:e,selection:t,scale:r,focused:i}){let s=useRef(null),[u,h]=useState(()=>typeof document>"u"||document.visibilityState==="visible"),[m,x]=useState(false);return useEffect(()=>{if(typeof document>"u")return;let p=()=>h(document.visibilityState==="visible");return document.addEventListener("visibilitychange",p),()=>document.removeEventListener("visibilitychange",p)},[]),useEffect(()=>{let p=i&&u&&t!==null&&t.anchor===t.focus;if(x(p),!p)return;let d=window.setInterval(()=>x(g=>!g),Pl);return ()=>window.clearInterval(d)},[i,u,t]),useEffect(()=>{let p=s.current;if(!p)return;let d=p.getContext("2d");if(!d)return;let g=window.devicePixelRatio||1;sizeCanvasForSlide(p,e,g,r),Hl(d,e,t,g,r,m);},[m,e,r,t]),jsx("canvas",{ref:s,style:X.canvasOverlay,"aria-hidden":"true"})}var bn=class extends Error{};function as(e,t){let r=new Map;return new Proxy(e,{get(i,s){let u=Reflect.get(i,s,i);if(typeof u!="function")return u;let h=r.get(s);return h||(h=(...m)=>{if(!t())throw new bn;return Reflect.apply(u,i,m)},r.set(s,h)),h},set(i,s,u){if(!t())throw new bn;return Reflect.set(i,s,u,i)}})}var vn=class extends Error{constructor(){super("Finish the pointer gesture before flushing input");}};function Er(e,t){if(typeof t!="string")return null;let r=e.snapshot().slides,i=r.findIndex(s=>s.id===t);return i<0?null:{index:i,slide:r[i]}}function Al(e,t){return t===0?0:Math.max(0,Math.min(t-1,e))}function ls(e){let t=useRef(e);return Fl(t.current,e)||(t.current=e),t.current}function Fl(e,t){return e===t?true:e.length!==t.length?false:e.every((r,i)=>Ll(r,t[i]))}function Ll(e,t){return e.family===t.family&&(e.bold??false)===(t.bold??false)&&(e.italic??false)===(t.italic??false)&&Ml(e.bytes,t.bytes)}function Ml(e,t){return e===t?true:e.byteLength!==t.byteLength?false:e.every((r,i)=>r===t[i])}function Et(e){return e.paragraphs.map(t=>t.runs.map(r=>r.text).join("")).join(`
|
|
4
|
+
`)}function Ol(e,t,r){e.formatText(t.id,0,t.length,r);}function Wl(e,t){let r=Et(e).slice(0,t),i=Array.from(r),s=i[i.length-1];return s?t-s.length:t}function Dl(e,t){let r=Array.from(Et(e).slice(t))[0];return r?t+r.length:t}async function Bl(e){return typeof FontFace>"u"||typeof document>"u"?[]:await Promise.all(e.map(async r=>{let i=r.bytes.slice().buffer,u=await new FontFace(r.family,i,{style:r.italic?"italic":"normal",weight:r.bold?"700":"400"}).load();return document.fonts.add(u),u}))}function es(e){if(!(typeof document>"u"))for(let t of e)document.fonts.delete(t);}function ts(e,t,r){return t.current.resolver(i=>e.current?.mediaBytes(i),r)}function zl(e,t){return e?.primitives.find(i=>i.kind==="textBox"&&i.storyId===t.storyId&&i.shapeId===t.shapeId)?.lines??[]}function Hl(e,t,r,i,s,u=true){if(!r)return;let h=t.primitives.find(p=>p.kind==="textBox"&&p.storyId===r.storyId&&p.shapeId===r.shapeId);if(!h)return;let m=Math.min(r.anchor,r.focus),x=Math.max(r.anchor,r.focus);if(e.save(),e.setTransform(i*s,0,0,i*s,0,0),m!==x){e.fillStyle="rgba(59, 130, 246, 0.26)";for(let p of h.lines){let d=Math.max(m,p.start),g=Math.min(x,p.end);if(d>=g)continue;let v=Cr(p,d),I=Cr(p,g);e.fillRect(Math.min(v,I),p.y,Math.max(1,Math.abs(I-v)),p.height);}}else if(u){let p=h.lines[wt(h.lines,{position:m,lineIndex:r.focusLine})];if(p){let d=Cr(p,m);e.fillStyle="#1d4ed8",e.fillRect(d,p.y,1.5,p.height);}}e.restore();}function Cr(e,t){let r=e.caretStops[0];return r?e.caretStops.reduce((i,s)=>Math.abs(s.position-t)<Math.abs(i.position-t)?s:i,r).x:e.x}function Nl(e){for(let t of e)for(let r of t.textStories){let i=Et(r).trim();if(i)return i.slice(0,40)}return ""}var X={root:{display:"flex",flexDirection:"column",width:"100%",height:"100%",minHeight:480,overflow:"hidden",color:"#172033",background:"#f3f5f8",fontFamily:"ui-sans-serif, system-ui, sans-serif"},toolbarShell:{display:"flex",alignItems:"center",flex:"0 0 auto",padding:"4px 0 5px",background:"#ffffff",borderBottom:"1px solid #e2e8f0"},toolbar:{flex:"1 1 auto",minWidth:0},presenceStrip:{display:"flex",alignItems:"center",gap:4,flex:"0 0 auto",maxWidth:"35%",padding:"0 10px 0 2px",overflowX:"auto"},workspace:{display:"flex",flex:1,minHeight:0},center:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},slideStrip:{width:184,padding:"14px 10px",overflowY:"auto",background:"#eef1f5",borderRight:"1px solid #d8dee9",boxSizing:"border-box"},slideNumber:{width:18,flex:"0 0 auto",paddingTop:3,fontSize:11,color:"#647087",textAlign:"right"},slidePreview:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:132,aspectRatio:"16 / 9",padding:8,overflow:"hidden",background:"#ffffff",boxSizing:"border-box",boxShadow:"0 1px 4px rgba(20, 31, 50, 0.16)"},slideTitle:{fontSize:9,lineHeight:1.25,color:"#39445a",textAlign:"center"},thumbnailCanvas:{display:"block",maxWidth:"100%",height:"auto"},thumbnailPresence:{position:"absolute",top:4,right:4,display:"flex",gap:3,padding:2,borderRadius:999,background:"rgba(255, 255, 255, 0.88)",boxShadow:"0 1px 3px rgba(15, 23, 42, 0.2)"},thumbnailPresenceDot:{width:7,height:7,borderRadius:999,boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.9)"},thumbnailPresenceOverflow:{color:"#475569",fontSize:8,fontWeight:700,lineHeight:"8px"},stage:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,outline:"none",overflow:"hidden"},canvasHost:{display:"flex",flex:1,minHeight:0,alignItems:"center",justifyContent:"center",width:"100%",overflow:"auto"},canvasFrame:{position:"relative",flex:"0 0 auto"},canvas:{display:"block",flex:"0 0 auto",background:"#fff",boxShadow:"0 8px 32px rgba(27, 39, 61, 0.2)",touchAction:"none"},canvasOverlay:{position:"absolute",inset:0,display:"block",pointerEvents:"none"},textEditOutline:{position:"absolute",zIndex:3,border:"2px dashed #6b7280",boxSizing:"border-box",boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.9)",pointerEvents:"none"},resizeHandle:{position:"absolute",zIndex:4,width:Pn,height:Pn,borderRadius:"50%",border:"1px solid #2563eb",background:"#ffffff",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.35)",boxSizing:"border-box",touchAction:"none"},shapeSelection:{position:"absolute",zIndex:3,border:"2px solid #2563eb",boxSizing:"border-box",boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.9)",pointerEvents:"none"},remoteShapeSelection:{position:"absolute",zIndex:2,border:"2px solid",borderRadius:2,boxSizing:"border-box",boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.88)",pointerEvents:"none"},remoteShapeWash:{position:"absolute",inset:0,opacity:.12},remoteShapeLabel:{position:"absolute",left:-2,maxWidth:180,overflow:"hidden",padding:"3px 6px",borderRadius:"4px 4px 4px 0",color:"#ffffff",fontSize:11,fontWeight:650,lineHeight:"14px",textOverflow:"ellipsis",whiteSpace:"nowrap",transform:"translateY(-100%)",boxShadow:"0 1px 3px rgba(15, 23, 42, 0.25)"},remoteShapeOverflow:{position:"absolute",top:8,right:8,zIndex:3,padding:"3px 6px",borderRadius:999,backgroundColor:"#475569",color:"#ffffff",fontSize:10,fontWeight:700,pointerEvents:"none"},textBoxPreview:{position:"absolute",border:"1.5px dashed #1a73e8",background:"rgba(26, 115, 232, 0.08)",boxSizing:"border-box",pointerEvents:"none"},notesPanel:ba$1.panel,notesLabel:ba$1.label,notesTextarea:ba$1.textarea,empty:{margin:"auto",color:"#6b7587",fontSize:14},error:{position:"absolute",left:16,right:16,bottom:14,padding:"9px 12px",color:"#8b1e2d",background:"#fff0f2",border:"1px solid #efb8c0",borderRadius:6,fontSize:12},hiddenFileInput:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0}};function jl(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(r=>r[0]).join("").toUpperCase()}function ns(e,t){return {display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,flex:"0 0 auto",border:"2px solid #ffffff",borderRadius:999,backgroundColor:e,boxShadow:"0 0 0 1px rgba(15, 23, 42, 0.14)",color:"#ffffff",fontSize:10,fontWeight:700,letterSpacing:"-0.02em",opacity:t?1:.38}}function Kl(e){return {display:"flex",alignItems:"flex-start",gap:7,width:"100%",marginBottom:12,padding:4,border:e?"2px solid #325ee6":"2px solid transparent",borderRadius:5,background:"transparent",cursor:"pointer"}}var ql=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","Backspace","Delete","Enter"]);function ds(e){return e.key.length>0&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&Array.from(e.key).length===1}function rs(e){return ql.has(e.key)||ds(e)}export{zt as a,qc as b,Pr as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {c}from'./chunk-66PPYFHW.js';import'./chunk-X6B77B3U.js';import {w}from'./chunk-X2M23RXQ.js';import'./chunk-O2XFH626.js';import {useRef,useState,useCallback,useMemo,useEffect}from'react';import {PRESENTATION_COMMAND_MUTATIONS}from'@betteroffice/pptx/worker';import {jsx}from'react/jsx-runtime';function x(t){if(!t)return;let{onReplica:c,...n}=t;return {...n,onReplica:e=>c?.(e?{clientId:e.clientId,encodeStateVector:async()=>e.encodeStateVector(),encodeStateAsUpdate:async r=>e.encodeStateAsUpdate(r),applyUpdate:async r=>e.applyUpdate(r),onUpdate:r=>e.onUpdate(r)}:null)}}function A(t,c){let n=t.handle;async function e(o){return await t.flushPendingInput(),o()}async function r(o){return e(()=>{if(c())throw new w("read-only");let a=o();return t.refresh(),a})}let d=Object.fromEntries([...["snapshot","story","searchText","listProposals","comments","previewProposal","layoutSlide","layoutProposalSlide","layoutProposalDiffSlide","encodeStateVector","encodeStateAsUpdate","exportStructured","exportMarkdown"],...PRESENTATION_COMMAND_MUTATIONS].map(o=>[o,(...a)=>{let p=()=>Reflect.apply(n[o],n,a);return PRESENTATION_COMMAND_MUTATIONS.includes(o)?r(p):e(p)}])),l=(o,a)=>r(()=>a?n.registerFallbackFont(o):n.registerFont(o)),i=Object.freeze({...d,version:t.version,readContent:t.readContent,findText:t.findText,validateEdits:t.validateEdits,applyEdits:t.applyEdits,registerFont:o=>l(o,false),registerFallbackFont:o=>l(o,true)}),s=o=>e(()=>t.goToSlide(o));return {commands:t.commands,get hydrated(){return true},failure:void 0,whenHydrated:t.flushPendingInput,handleAsync:()=>e(()=>i),save:()=>e(t.save),saveAsync:()=>e(t.save),recoverySave:()=>e(()=>({bytes:t.save(),recovery:true,throughSeq:0,version:n.version()})),flushPendingInput:t.flushPendingInput,version:t.version,readContent:t.readContent,findText:t.findText,exportStructured:i.exportStructured,exportMarkdown:i.exportMarkdown,validateEdits:t.validateEdits,applyEdits:t.applyEdits,getPositionAtPoint:(o,a)=>e(()=>t.getPositionAtPoint(o,a)),clearSelection:()=>e(t.clearSelection),selectText:o=>e(()=>t.selectText(o)),goToSlide:s,goToSlideAsync:s,refresh:()=>e(t.refresh),refreshProposals:()=>e(t.refreshProposals),focus:t.focus}}function k(t){let c$1=useRef(t);c$1.current=t;let[n,e]=useState(null),r=useRef(t.readOnly);r.current=t.readOnly;let u=useCallback(s=>{e(A(s,()=>!!r.current));},[]),d=useMemo(()=>({}),[!!t.collaboration,t.collaboration?.roomId]),l=useMemo(()=>x(t.collaboration)?.onReplica,[t.collaboration?.onReplica]),i=t.collaboration?{...t.collaboration,onReplica:l}:void 0;return useEffect(()=>{if(!n)return;let s=c$1.current.onReady?.(n);return typeof s=="function"?s:void 0},[n]),jsx(c,{...t,collaboration:i,collaborationIdentity:d,onReady:u})}export{k as PptxAsyncInThreadSession};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r={panel:{width:340,maxWidth:"45%",flex:"0 0 auto",overflowY:"auto",background:"#fff",borderLeft:"1px solid #dbe3ee",padding:16,fontSize:13},header:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},count:{color:"#64748b",marginLeft:6},card:{border:"1px solid #dbe3ee",borderLeft:"3px solid #6366f1",borderRadius:8,padding:12,marginTop:16},author:{color:"#4338ca"},note:{margin:"6px 0 12px",lineHeight:1.5},change:{borderTop:"1px solid #eef2f7",padding:"10px 0"},actions:{display:"flex",flexWrap:"wrap",gap:8,marginTop:12},button:{border:"1px solid #cbd5e1",borderRadius:5,background:"#fff",color:"#334155",padding:"6px 10px",cursor:"pointer",font:"inherit"},primary:{border:"1px solid #4338ca",borderRadius:5,background:"#4338ca",color:"#fff",padding:"6px 10px",cursor:"pointer",font:"inherit"},link:{background:"none",border:0,padding:0,color:"#4338ca",textAlign:"left",cursor:"pointer",font:"inherit",fontWeight:600},warning:{padding:10,borderRadius:5,background:"#fffbeb",color:"#92400e",lineHeight:1.5},muted:{color:"#64748b",marginTop:24},dialog:{width:"min(1200px, 92vw)",maxHeight:"90vh",overflow:"auto",padding:24,border:"1px solid #cbd5e1",borderRadius:12,color:"#172033",background:"#f8fafc"},previews:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(360px, 100%), 1fr))",gap:16,margin:"20px 0"},figure:{margin:0,minWidth:0},caption:{fontWeight:600,marginBottom:8}};export{r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-O2XFH626.js';import {jsxs,Fragment,jsx}from'react/jsx-runtime';function x({change:e,t:o,testId:t}){return e.oldText===e.newText?null:jsxs("div",{"data-testid":t,style:p.textDiff,children:[jsx("del",{style:p.deleted,children:e.oldText||o("proposals.blank")}),jsx("ins",{style:p.inserted,children:e.newText||o("proposals.blank")})]})}function g({change:e,t:o,textOnly:t,testId:r}){return jsxs(Fragment,{children:[jsx(x,{change:e,t:o,testId:r}),!t&&e.before&&e.after&&jsx(y,{change:e,t:o})]})}function y({change:e,t:o}){let t=e.before,r=e.after,a=t.x!==r.x||t.y!==r.y||t.width!==r.width||t.height!==r.height,s=n=>[n.x,n.y,n.width,n.height].map(d=>(d/12700).toFixed(1)).join(", ");return jsxs(Fragment,{children:[a&&jsxs("p",{style:p.detail,children:[o("proposals.geometry"),jsx("br",{}),s(t)," \u2192 ",s(r)," pt"]}),JSON.stringify({...t,x:0,y:0,width:0,height:0})!==JSON.stringify({...r,x:0,y:0,width:0,height:0})&&e.oldText===e.newText&&jsx("p",{style:p.detail,children:o("proposals.appearance")})]})}var p={textDiff:{display:"grid",gap:6,margin:"8px 0",whiteSpace:"pre-wrap",overflowWrap:"anywhere",maxHeight:200,overflowY:"auto"},deleted:{color:"#9f1239",background:"#fff1f2",padding:"4px 6px"},inserted:{color:"#166534",background:"#f0fdf4",padding:"4px 6px",textDecoration:"none"},detail:{color:"#64748b",lineHeight:1.5}};export{g as ProposalChangeDetails};
|