@betteroffice/pptx 0.5.0 → 0.6.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.
Files changed (57) hide show
  1. package/LICENSES/MIT-ruzstd.txt +21 -0
  2. package/LICENSES/MIT-twox-hash.txt +21 -0
  3. package/LICENSES/MIT-wuff.txt +20 -0
  4. package/README.md +24 -5
  5. package/dist/chunk-2XA2UH2O.js +1 -0
  6. package/dist/chunk-4WP5ZWYV.js +1 -0
  7. package/dist/chunk-65A2TX24.js +1 -0
  8. package/dist/chunk-663FARNX.js +1 -0
  9. package/dist/chunk-AYLLA7XR.js +1 -0
  10. package/dist/chunk-AZDGFDN2.js +1 -0
  11. package/dist/chunk-CCVGR3MS.js +1 -0
  12. package/dist/chunk-COS6CTH7.js +2 -0
  13. package/dist/chunk-G54T5CXF.js +1 -0
  14. package/dist/chunk-GAM2OAAP.js +2 -0
  15. package/dist/chunk-GHET7GIK.js +1 -0
  16. package/dist/chunk-GR7EGQ2Z.js +1 -0
  17. package/dist/chunk-HZODDD5T.js +1 -0
  18. package/dist/chunk-J54GRQWZ.js +1 -0
  19. package/dist/chunk-JJV35WHH.js +2 -0
  20. package/dist/chunk-KGEED2XY.js +1 -0
  21. package/dist/chunk-O2XFH626.js +1 -0
  22. package/dist/chunk-OUNTNO7R.js +1 -0
  23. package/dist/chunk-QRAGGQDN.js +1 -0
  24. package/dist/chunk-QWRXUT7T.js +1 -0
  25. package/dist/chunk-RNJM2LKC.js +3 -0
  26. package/dist/chunk-S6HKAO2F.js +1 -0
  27. package/dist/chunk-S6UYP4BX.js +1 -0
  28. package/dist/chunk-T6VUFMNC.js +1 -0
  29. package/dist/chunk-TRT2B252.js +10 -0
  30. package/dist/collaboration.js +1 -1
  31. package/dist/{editorSession-Cuqxkg-B.d.ts → editorSession-qQaVvMVR.d.ts} +356 -18
  32. package/dist/generated/metafile_svg_wasm_bg.wasm +0 -0
  33. package/dist/generated/pptx_wasm_bg.wasm +0 -0
  34. package/dist/generated/pptx_wasm_lean_bg.wasm +0 -0
  35. package/dist/generated/preflight/pptx_preflight_bg.wasm +0 -0
  36. package/dist/index.d.ts +21 -18
  37. package/dist/index.js +1 -1
  38. package/dist/pptxSessionWorker.mjs +13 -9
  39. package/dist/pptxSessionWorker.node.mjs +1 -0
  40. package/dist/pptxWorkerStart.d.ts +5 -0
  41. package/dist/pptxWorkerStart.js +1 -0
  42. package/dist/sessionWorker.missing.d.ts +3 -0
  43. package/dist/sessionWorker.missing.js +1 -0
  44. package/dist/sessionWorker.node.d.ts +3 -0
  45. package/dist/sessionWorker.node.js +1 -0
  46. package/dist/transport-BcduBS8X.d.ts +16 -0
  47. package/dist/wasm-preflight.d.ts +26 -0
  48. package/dist/wasm-preflight.js +1 -0
  49. package/dist/worker.d.ts +122 -22
  50. package/dist/worker.js +1 -1
  51. package/package.json +18 -5
  52. package/dist/chunk-2NCQ2IE7.js +0 -3
  53. package/dist/chunk-4FWJR3UX.js +0 -1
  54. package/dist/chunk-H3SEEI4U.js +0 -1
  55. package/dist/chunk-LIYNXEQC.js +0 -1
  56. package/dist/chunk-NNSP5326.js +0 -1
  57. /package/dist/{pptxSessionWorker.d.ts → pptxSessionWorker.node.d.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,26 +1,29 @@
1
- import { C as CanvasImageResolver, S as SlideDisplayList } from './editorSession-Cuqxkg-B.js';
2
- export { B as BlipEffect, a as CaretStop, b as ColorTransform, c as ColorValue, d as CommentFlavor, e as CommentReceipt, f as CommentSnapshot, D as DeckSnapshot, E as EditProfile, g as EditSuccess, h as ExportCompletion, i as ExportDiagnostic, j as ExportSeverity, G as GeometryPathCommand, H as HistoryProfile, k as HistoryResult, l as HitTestResult, I as ImageCrop, m as ImageEffect, n as ImagePrimitive, o as InheritedGeometry, p as InspectPresentationOptions, L as LayoutProfile, M as MarkdownAnchor, O as OpenPresentationOptions, q as OperationFailure, r as OperationRefusal, P as Paint, s as PaintSlideOptions, t as ParagraphAlignment, u as ParagraphSnapshot, v as PictureDraft, w as PlaceholderPrimitive, x as PositionedGlyph, y as PositionedTextLine, z as PositionedTextRun, A as PptxAnchor, F as PptxAnchorScope, J as PptxCaretAnchor, K as PptxEditFailure, N as PptxEditFailureCode, Q as PptxEditHistory, R as PptxEditPreview, T as PptxEditReceipt, U as PptxEditRefusal, V as PptxEditRequest, W as PptxEditResult, X as PptxEditSource, Y as PptxEditStep, Z as PptxEditTarget, _ as PptxExportComment, $ as PptxExportDiagnostic, a0 as PptxExportDiagnosticCode, a1 as PptxExportError, a2 as PptxExportFailure, a3 as PptxExportFailureCode, a4 as PptxExportList, a5 as PptxExportMark, a6 as PptxExportNotes, a7 as PptxExportObject, a8 as PptxExportObjectKind, a9 as PptxExportOptions, aa as PptxExportParagraph, ab as PptxExportRefusal, ac as PptxExportResult, ad as PptxExportRun, ae as PptxExportShape, af as PptxExportShapeKind, ag as PptxExportSlide, ah as PptxExportStory, ai as PptxExportTable, aj as PptxExportTableCell, ak as PptxFindMatch, al as PptxFindRequest, am as PptxFindResult, an as PptxFindScope, ao as PptxFontFace, ap as PptxMarkdownContent, aq as PptxMarkdownOptions, ar as PptxParagraphText, as as PptxPeerNotReadyError, at as PptxReadRequest, au as PptxReadResult, av as PptxShapeTarget, aw as PptxSlideTarget, ax as PptxSourceProvenance, ay as PptxStoryTarget, az as PptxStoryText, aA as PptxStructuredContent, aB as PptxTextField, aC as PptxTextGuard, aD as PptxTextMatch, aE as PptxTextRange, aF as PptxTextSearchOptions, aG as PptxTextSpan, aH as PptxTextTarget, aI as PptxValidationResult, aJ as PptxWorkerEditorDisposedError, aK as PresentationHandle, aL as PresetShapeDraft, aM as PrimitiveTransform, aN as Profiled, aO as ProfiledLayout, aP as Proposal, aQ as ProposalAcceptance, aR as ProposalChange, aS as ProposalDiffSlide, aT as ProposalEdit, aU as ProposalPreview, aV as ProposalTextChange, aW as ShapeAdjustReceipt, aX as ShapeDraft, aY as ShapeFill, aZ as ShapeFillReceipt, a_ as ShapeGradient, a$ as ShapeKind, b0 as ShapeLineEnd, b1 as ShapeOutline, b2 as ShapePrimitive, b3 as ShapeReceipt, b4 as ShapeRect, b5 as ShapeSnapshot, b6 as ShapeStroke, b7 as ShapeStrokeReceipt, b8 as ShapeZOrderReceipt, b9 as SlideCanvasLike, ba as SlidePrimitive, bb as SlideReceipt, bc as SlideSnapshot, bd as StaleProposalError, be as StorySnapshot, bf as Stroke, bg as StrokeEnd, bh as TableReceipt, bi as TextBoxPrimitive, bj as TextParagraphDraft, bk as TextReceipt, bl as TextRunSnapshot, bm as TextStyle, bn as TextStylePatch, bo as TextStyleSnapshot, bp as TransformReceipt, bq as UndoCaptureMode, br as UpdateEvent, bs as ValidationSuccess, bt as WasmInitInput, bu as createPptxWorkerEditorSession, bv as exportPptxMarkdown, bw as exportPptxStructured, bx as initWasm, by as inspectPresentation, bz as isProposalsAvailable, bA as isWasmAvailable, bB as openPresentation, bC as openPresentationSession, bD as paintSlide, bE as renderPptxMarkdown, bF as sizeCanvasForSlide, bG as wasmVersion } from './editorSession-Cuqxkg-B.js';
1
+ import { P as PresentationImageDecodeOptions } from './editorSession-qQaVvMVR.js';
2
+ export { B as BlipEffect, C as CanvasImageResolver, a as CaretStop, b as ChartData, c as ChartDataSeries, d as ColorTransform, e as ColorValue, f as CommentFlavor, g as CommentReceipt, h as CommentSnapshot, D as DeckSnapshot, E as EditProfile, i as EditSuccess, j as ExportCompletion, k as ExportDiagnostic, l as ExportSeverity, G as GeometryPathCommand, H as HeaderFooterSettings, m as HistoryProfile, n as HistoryResult, o as HitTestResult, I as ImageCrop, p as ImageEffect, q as ImagePrimitive, r as InheritedGeometry, s as InspectPresentationOptions, L as LayoutProfile, M as MarkdownAnchor, O as OpenPresentationOptions, t as OperationFailure, u as OperationRefusal, v as Paint, w as PaintFontCoverage, x as PaintSlideOptions, y as ParagraphAlignment, z as ParagraphSnapshot, A as PictureDraft, F as PlaceholderPrimitive, J as PositionedGlyph, K as PositionedTextLine, N as PositionedTextRun, Q as PptxAnchor, R as PptxAnchorScope, S as PptxCaretAnchor, T as PptxEditFailure, U as PptxEditFailureCode, V as PptxEditHistory, W as PptxEditPreview, X as PptxEditReceipt, Y as PptxEditRefusal, Z as PptxEditRequest, _ as PptxEditResult, $ as PptxEditSource, a0 as PptxEditStep, a1 as PptxEditTarget, a2 as PptxExportComment, a3 as PptxExportDiagnostic, a4 as PptxExportDiagnosticCode, a5 as PptxExportError, a6 as PptxExportFailure, a7 as PptxExportFailureCode, a8 as PptxExportList, a9 as PptxExportMark, aa as PptxExportNotes, ab as PptxExportObject, ac as PptxExportObjectKind, ad as PptxExportOptions, ae as PptxExportParagraph, af as PptxExportRefusal, ag as PptxExportResult, ah as PptxExportRun, ai as PptxExportShape, aj as PptxExportShapeKind, ak as PptxExportSlide, al as PptxExportStory, am as PptxExportTable, an as PptxExportTableCell, ao as PptxFindMatch, ap as PptxFindRequest, aq as PptxFindResult, ar as PptxFindScope, as as PptxFontFace, at as PptxMarkdownContent, au as PptxMarkdownOptions, av as PptxParagraphText, aw as PptxPeerNotReadyError, ax as PptxPngOptions, ay as PptxPngTarget, az as PptxReadRequest, aA as PptxReadResult, aB as PptxShapeTarget, aC as PptxSlideTarget, aD as PptxSourceProvenance, aE as PptxStoryTarget, aF as PptxStoryText, aG as PptxStructuredContent, aH as PptxTextField, aI as PptxTextGuard, aJ as PptxTextMatch, aK as PptxTextRange, aL as PptxTextSearchOptions, aM as PptxTextSpan, aN as PptxTextTarget, aO as PptxValidationResult, aP as PptxWorkerEditorDisposedError, aQ as PresentationHandle, aR as PresetShapeDraft, aS as PrimitiveTransform, aT as Profiled, aU as ProfiledLayout, aV as Proposal, aW as ProposalAcceptance, aX as ProposalChange, aY as ProposalDiffSlide, aZ as ProposalEdit, a_ as ProposalPictureMediaTooLargeError, a$ as ProposalPreview, b0 as ProposalShapeChange, b1 as ProposalStripEntry, b2 as ProposalTextChange, b3 as SavePresentationOptions, b4 as ShapeAdjustReceipt, b5 as ShapeAltText, b6 as ShapeDraft, b7 as ShapeFill, b8 as ShapeFillReceipt, b9 as ShapeGradient, ba as ShapeKind, bb as ShapeLineEnd, bc as ShapeOutline, bd as ShapePrimitive, be as ShapeReceipt, bf as ShapeRect, bg as ShapeSnapshot, bh as ShapeStroke, bi as ShapeStrokeReceipt, bj as ShapeZOrderReceipt, bk as SlideCanvasLike, bl as SlideDateText, bm as SlideDisplayList, bn as SlideHeaderFooter, bo as SlideHeaderFooterText, bp as SlideLayoutSnapshot, bq as SlidePrimitive, br as SlideReceipt, bs as SlideSnapshot, bt as StaleProposalError, bu as StorySnapshot, bv as Stroke, bw as StrokeEnd, bx as TableGrid, by as TableGridCell, bz as TableReceipt, bA as TextBoxPrimitive, bB as TextLanguage, bC as TextLink, bD as TextLinkTarget, bE as TextParagraphDraft, bF as TextReceipt, bG as TextRunSnapshot, bH as TextStyle, bI as TextStylePatch, bJ as TextStyleSnapshot, bK as TransformReceipt, bL as UndoCaptureMode, bM as UpdateEvent, bN as ValidationSuccess, bO as WasmInitInput, bP as createPptxWorkerEditorSession, bQ as decodeFontFace, bR as exportPptxMarkdown, bS as exportPptxStructured, bT as initWasm, bU as inspectPresentation, bV as isProposalsAvailable, bW as isWasmAvailable, bX as metafileImageBytes, bY as needsElementDecode, bZ as openPresentation, b_ as openPresentationSession, b$ as paintSlide, c0 as renderPptxMarkdown, c1 as sizeCanvasForSlide, c2 as wasmVersion } from './editorSession-qQaVvMVR.js';
3
3
  export { C as CollaborationProvider, P as PRESENCE_LABEL_DURATION_MS, p as presenceColorForClientId } from './presence-C1o8TDwu.js';
4
4
  export { A as AsyncCollaborationReplica, b as CollaborationError, c as CollaborationErrorCode, d as CollaborationErrorListener, e as CollaborationProviderOptions, C as CollaborationReplica, f as CollaborationStatus, g as CollaborationStatusChange, h as CollaborationStatusListener, i as CollaborationTransport, j as CollaborationTransportEvent, k as CollaborationUpdateOrigin, l as CollaborationUser, m as PptxPresence, P as PptxPresenceCursor, n as PptxPresenceListener, a as PptxPresencePeer, o as PptxPresenceState, p as PptxPresenceUser } from './types-ui_ARP0o.js';
5
-
6
- interface PresentationImageDecodeOptions {
7
- maxDimension?: number;
8
- }
9
- declare function needsElementDecode(blob: Blob): boolean;
5
+ export { FontPreflight, FontPreflightFace, fontPreflight, preloadPreflightWasm } from './wasm-preflight.js';
10
6
 
11
7
  declare function presentationImageBlob(bytes: Uint8Array): Blob;
12
8
  declare function decodePresentationImage(bytes: Uint8Array, errorMessage: string, options?: PresentationImageDecodeOptions): Promise<CanvasImageSource>;
13
9
 
14
- interface SlideToPngOptions {
15
- /** Output scale, e.g. 2 for hidpi. */
16
- scale?: number;
17
- resolveImage?: CanvasImageResolver;
10
+ type PngExportCode = 'canvas-unavailable' | 'canvas-too-large' | 'font-unavailable' | 'picture-unavailable';
11
+ declare class PngExportError extends Error {
12
+ readonly code: PngExportCode;
13
+ constructor(code: PngExportCode, message: string);
18
14
  }
19
- /**
20
- * Rasterize one slide to a PNG blob through the same canvas painter the editor
21
- * draws with, so an export matches what is on screen. The server-side twin is
22
- * the `betteroffice-pptx-raster` crate.
23
- */
24
- declare function slideToPng(list: SlideDisplayList, options?: SlideToPngOptions): Promise<Blob>;
25
15
 
26
- export { CanvasImageResolver, type PresentationImageDecodeOptions, SlideDisplayList, type SlideToPngOptions, decodePresentationImage, needsElementDecode, presentationImageBlob, slideToPng };
16
+ /** An installed font pack that cannot be used, so its faces are substituted. */
17
+ interface FontPackDiagnostic {
18
+ /** The add-on package: `@betteroffice/fonts-latin`, `-intl` or `-cjk`. */
19
+ pack: 'latin' | 'intl' | 'cjk';
20
+ /** `version-mismatch`: another release is installed; `missing-file`: files are absent; `invalid-manifest`: its manifest cannot be read. */
21
+ reason: 'version-mismatch' | 'missing-file' | 'invalid-manifest';
22
+ /** A sentence naming the package and what is wrong. */
23
+ detail: string;
24
+ }
25
+
26
+ /** The installed font add-on packages that cannot be used, and why; their faces are substituted. */
27
+ declare function fontPackDiagnostics(): Promise<FontPackDiagnostic[]>;
28
+
29
+ export { type FontPackDiagnostic, type PngExportCode, PngExportError, PresentationImageDecodeOptions, decodePresentationImage, fontPackDiagnostics, presentationImageBlob };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {a,b,c,f}from'./chunk-NNSP5326.js';export{j as createPptxWorkerEditorSession,d as needsElementDecode,i as openPresentationSession}from'./chunk-NNSP5326.js';import'./chunk-YMIVEAXD.js';import {a as a$1,z}from'./chunk-4FWJR3UX.js';export{d as PptxExportError,C as PptxPeerNotReadyError,E as PptxWorkerEditorDisposedError,c as StaleProposalError,x as exportPptxMarkdown,w as exportPptxStructured,s as initWasm,v as inspectPresentation,r as isProposalsAvailable,t as isWasmAvailable,A as openPresentation,y as renderPptxMarkdown,u as wasmVersion}from'./chunk-4FWJR3UX.js';export{c as CollaborationError,f as CollaborationProvider}from'./chunk-LIYNXEQC.js';export{b as PRESENCE_LABEL_DURATION_MS,c as presenceColorForClientId}from'./chunk-H3SEEI4U.js';var Ee=134217728;function H(e,t,n=1){return {width:Math.ceil(e.width*n*t),height:Math.ceil(e.height*n*t)}}function X(e,t,n,o=1){let i=H(t,n,o);e.width=i.width,e.height=i.height,e.style.width=`${t.width*o}px`,e.style.height=`${t.height*o}px`;}async function _(e,t,n=1,o=1,i={}){let r={remaining:i.maxShadowPixels??Ee};if(!Number.isSafeInteger(r.remaining)||r.remaining<0)throw new Error("invalid shadow pixel budget");let a=i.resolveImage?.acquire?.()??i.resolveImage,s={...i,resolveImage:a};try{e.save(),e.setTransform(n*o,0,0,n*o,0,0),e.clearRect(0,0,t.width,t.height),t.background&&(e.fillStyle=O(e,t.background,0,0,t.width,t.height),e.fillRect(0,0,t.width,t.height));for(let l of t.primitives)await ee(e,l,s,n*o,r);}finally{try{e.restore();}finally{a?.release?.();}}}async function ee(e,t,n,o,i){e.save();try{switch(ke(e,t),t.kind){case "shape":te(e,t,o,i);break;case "image":await He(e,t,n.resolveImage,o,i);break;case "textBox":Ve(e,t,n.textChanges);break;case "placeholder":Qe(e,t);break;case "chart":case "table":await Te(e,t,n,o,i);break}}finally{e.restore();}}async function Te(e,t,n,o,i){e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip();for(let r of t.primitives)await ee(e,r,n,o,i);}function ke(e,t){let n=t.transform;if(!n)return;let o=t.x+t.w/2,i=t.y+t.h/2;e.translate(o,i),e.rotate((n.rotationDeg??0)*Math.PI/180),e.scale(n.flipH?-1:1,n.flipV?-1:1),e.translate(-o,-i);}function te(e,t,n,o){t.clip&&(W(e,t.clip,t.x,t.y,t.w,t.h),e.clip()),t.shadow&&(t.fill||t.stroke||t.shadow.paths?.some(i=>i.stroke))&&Re(e,t,n,o),W(e,t.path,t.x,t.y,t.w,t.h),t.fill&&(e.fillStyle=O(e,t.fill,t.x,t.y,t.w,t.h),e.fill(t.evenOdd?"evenodd":"nonzero")),t.stroke&&(ie(e,t.stroke,t.x,t.y,t.w,t.h),Le(e,t));}function Re(e,t,n,o){let i=t.shadow?.paths?.length?t.shadow.paths.map(r=>({...t,path:r.path,fill:r.fill?t.fill:void 0,stroke:r.stroke,shadow:void 0})):[{...t,shadow:void 0}];ne(e,t.shadow,i.flatMap(r=>N(r.path,r)),i.reduce((r,a)=>Math.max(r,a.stroke?.width??0),0),n,o,r=>{for(let a of i)te(r,a,n,o);});}function ne(e,t,n,o,i,r,a){let s=t.scaleX??1,l=t.scaleY??1,h=e.getTransform(),d={a:h.a*s,b:h.b*l,c:h.c*s,d:h.d*l,e:h.e*s,f:h.f*l};if(!n.length)return;let p=1/0,f=1/0,c=-1/0,m=-1/0;for(let[I,Y]of n){let j=d.a*I+d.c*Y+d.e,G=d.b*I+d.d*Y+d.f;p=Math.min(p,j),f=Math.min(f,G),c=Math.max(c,j),m=Math.max(m,G);}let b=Math.min(Math.max(t.blur??0,0)*i/2,128),P=b*3+1,u=o*i*Math.max(Math.abs(s),Math.abs(l))*2,M=(t.dx??0)*i,E=(t.dy??0)*i,x=Math.floor(Math.max(p-u,-P-M)),v=Math.floor(Math.max(f-u,-P-E)),T=Math.ceil(Math.min(c+u,e.canvas.width+P-M)),k=Math.ceil(Math.min(m+u,e.canvas.height+P-E));if(T<=x||k<=v)return;let L=(T-x)*(k-v);if(!Number.isSafeInteger(L)||L>r.remaining)return;r.remaining-=L;let w=typeof OffscreenCanvas<"u"?new OffscreenCanvas(T-x,k-v):Object.assign(document.createElement("canvas"),{width:T-x,height:k-v}),y=w.getContext("2d");if(y){y.setTransform(d.a,d.b,d.c,d.d,d.e-x,d.f-v),a(y),e.save();try{if(e.resetTransform(),typeof e.filter=="string")y.setTransform(1,0,0,1,0,0),y.globalCompositeOperation="source-in",y.fillStyle=t.color,y.fillRect(0,0,w.width,w.height),e.filter=`blur(${b}px)`,e.drawImage(w,x+M,v+E);else {let I=e.canvas.width+1;e.shadowColor=t.color,e.shadowBlur=b*2,e.shadowOffsetX=x+M-I,e.shadowOffsetY=E,e.drawImage(w,I,v);}}finally{e.restore();}}}function N(e,t){let n=[];for(let o of e)o.type!=="close"&&(o.type==="quad"?n.push([t.x+o.cpx*t.w,t.y+o.cpy*t.h]):o.type==="cubic"&&(n.push([t.x+o.cp1x*t.w,t.y+o.cp1y*t.h]),n.push([t.x+o.cp2x*t.w,t.y+o.cp2y*t.h])),n.push([t.x+o.x*t.w,t.y+o.y*t.h]));return n.filter((o,i)=>i===0||o[0]!==n[i-1][0]||o[1]!==n[i-1][1])}function De(e){return e.path?N(e.path,e):[[e.x,e.y],[e.x+e.w,e.y],[e.x+e.w,e.y+e.h],[e.x,e.y+e.h]]}var Oe=new Set(["triangle","stealth","arrow","diamond","oval"]);function Le(e,t){let n=t.stroke;if(!n||!n.headEnd&&!n.tailEnd)return;let o=N(t.path,t);if(o.length<2)return;let i=[[n.headEnd,o[1],o[0]],[n.tailEnd,o[o.length-2],o[o.length-1]]];e.save(),e.setLineDash([]);let r=n.paint?O(e,n.paint,t.x,t.y,t.w,t.h):n.color;e.fillStyle=r,e.strokeStyle=r,e.lineWidth=n.width,e.lineJoin="miter";for(let[a,s,l]of i){if(!a||!Oe.has(a.kind))continue;let[h,d]=[l[0]-s[0],l[1]-s[1]],p=Math.hypot(h,d);p<1e-6||Ae(e,a,l,h/p,d/p);}e.restore();}function Ae(e,t,[n,o],i,r){let a=t.width/2,[s,l]=[-r*a,i*a],[h,d]=[n-i*t.length,o-r*t.length];switch(e.beginPath(),t.kind){case "triangle":e.moveTo(n,o),e.lineTo(h+s,d+l),e.lineTo(h-s,d-l),e.closePath(),e.fill();break;case "stealth":e.moveTo(n,o),e.lineTo(h+s,d+l),e.lineTo(n-i*t.length*.6,o-r*t.length*.6),e.lineTo(h-s,d-l),e.closePath(),e.fill();break;case "arrow":e.moveTo(h+s,d+l),e.lineTo(n,o),e.lineTo(h-s,d-l),e.stroke();break;case "diamond":{let[p,f]=[i*t.length/2,r*t.length/2];e.moveTo(n+p,o+f),e.lineTo(n+s,o+l),e.lineTo(n-p,o-f),e.lineTo(n-s,o-l),e.closePath(),e.fill();break}case "oval":e.ellipse(n,o,t.length/2,a,Math.atan2(r,i),0,Math.PI*2),e.fill();break}}function Fe(e,t,n){if(n.tile){We(e,t,n,n.tile);return}let o=n.crop,i=g(o?.left),r=g(o?.top),a=1-i-g(o?.right),s=1-r-g(o?.bottom),l=n.path!==void 0||a!==1||s!==1;if(a<=0||s<=0)return;l&&(e.save(),U(e,n),e.clip());let h=oe(t),d=re(t),p=n.destination??n;h>0&&d>0?e.drawImage(t,i*h,r*d,a*h,s*d,p.x,p.y,p.w,p.h):e.drawImage(t,p.x,p.y,p.w,p.h),l&&e.restore();}function We(e,t,n,o){let i=oe(t),r=re(t);if(i<=0||r<=0)return;let a$1=a(t),s=i*a$1.x,l=r*a$1.y,h=Math.round(g(n.crop?.left)*s)/a$1.x,d=Math.round(g(n.crop?.top)*l)/a$1.y,p=(s-Math.round(g(n.crop?.right)*s))/a$1.x,f=(l-Math.round(g(n.crop?.bottom)*l))/a$1.y;if(p<=h||f<=d)return;let m=h>0||d>0||p<i||f<r?Be(t,h,d,p-h,f-d):t,b=e.createPattern(m,"repeat");if(!b)return;e.save(),U(e,n),e.clip();let P=a(m),u=n.destination??n;b.setTransform(new DOMMatrix().translateSelf(u.x,u.y).scaleSelf(o.scaleX*P.x,o.scaleY*P.y)),e.fillStyle=b,e.fillRect(u.x,u.y,u.w,u.h),e.restore();}function Be(e,t,n,o,i){try{let r=ae(Math.max(1,Math.ceil(o)),Math.max(1,Math.ceil(i))),a$1=r?.getContext("2d");if(!r||!a$1)return e;a$1.drawImage(e,t,n,o,i,0,0,r.width,r.height);let s=a(e);return b(r,{x:s.x*o/r.width,y:s.y*i/r.height}),r}catch{return e}}function U(e,t){t.path?W(e,t.path,t.x,t.y,t.w,t.h):(e.beginPath(),e.rect(t.x,t.y,t.w,t.h));}function g(e){return e===void 0||!Number.isFinite(e)?0:Math.min(Math.max(e,0),1)}function oe(e){return "naturalWidth"in e&&typeof e.naturalWidth=="number"?e.naturalWidth:"width"in e&&typeof e.width=="number"?e.width:0}function re(e){return "naturalHeight"in e&&typeof e.naturalHeight=="number"?e.naturalHeight:"height"in e&&typeof e.height=="number"?e.height:0}function W(e,t,n,o,i,r){e.beginPath();for(let a of t)switch(a.type){case "move":e.moveTo(n+a.x*i,o+a.y*r);break;case "line":e.lineTo(n+a.x*i,o+a.y*r);break;case "quad":e.quadraticCurveTo(n+a.cpx*i,o+a.cpy*r,n+a.x*i,o+a.y*r);break;case "cubic":e.bezierCurveTo(n+a.cp1x*i,o+a.cp1y*r,n+a.cp2x*i,o+a.cp2y*r,n+a.x*i,o+a.y*r);break;case "close":e.closePath();break}}function ie(e,t,n,o,i,r){e.strokeStyle=t.paint?O(e,t.paint,n,o,i,r):t.color,e.lineWidth=t.width,e.setLineDash(t.dashed?[Math.max(3,t.width*2),Math.max(2,t.width)]:[]),e.lineJoin=t.join??"miter",e.stroke();}function O(e,t,n,o,i,r){if(t.kind==="solid")return t.color;let a=(t.angleDeg??0)*Math.PI/180,s=n+i/2,l=o+r/2,h=Math.hypot(i,r)/2,d=t.gradientType==="linear"?e.createLinearGradient(s-Math.cos(a)*h,l-Math.sin(a)*h,s+Math.cos(a)*h,l+Math.sin(a)*h):e.createRadialGradient(s,l,0,s,l,h);for(let p of t.stops)d.addColorStop(Math.max(0,Math.min(1,p.position)),p.color);return d}async function He(e,t,n,o,i){let r;if(t.assetId&&n){let a=await Xe(n,t.assetId);a&&(r=t.effects?.length?qe(a,t.effects):a);}if(t.shadow&&(r||t.stroke||t.shadow.paths?.some(a=>a.stroke))){let a=t.shadow.paths?.length?t.shadow.paths.map(s=>({image:{...t,path:s.path,stroke:s.stroke},source:s.fill?r:void 0})):[{image:t,source:r}];ne(e,t.shadow,a.flatMap(s=>De(s.image)),a.reduce((s,l)=>Math.max(s,l.image.stroke?.width??0),0),o,i,s=>{for(let l of a)K(s,l.image,l.source);});}K(e,t,r);}async function Xe(e,t){try{return await e(t)}catch{return null}}function K(e,t,n){n&&Fe(e,n,t),t.stroke&&(U(e,t),ie(e,t.stroke,t.x,t.y,t.w,t.h));}var Z=33554432,_e=67108864;function Ne(e){let t=e,n=t.naturalWidth??t.videoWidth??t.displayWidth??(typeof t.width=="number"?t.width:0),o=t.naturalHeight??t.videoHeight??t.displayHeight??(typeof t.height=="number"?t.height:0);return n>0&&o>0?{width:n,height:o}:null}function Ue(e){let t=e.width*e.height;if(t<=Z)return e;let n=Math.sqrt(Z/t);return {width:Math.max(1,Math.floor(e.width*n)),height:Math.max(1,Math.floor(e.height*n))}}var B=new WeakMap,C=[],A=0;function Ye(e){let t=e;return "videoWidth"in t||"displayWidth"in t||typeof t.getContext=="function"}function je(e,t){let n=B.get(e),o=n?.get(t);if(!n||!o)return;let i=C.findIndex(r=>r.entries===n&&r.key===t);return i>=0&&C.push(...C.splice(i,1)),o}function Ge(e,t,n,o){let i=B.get(e);for(i||(i=new Map,B.set(e,i)),i.set(t,n),C.push({entries:i,key:t,pixels:o}),A+=o;A>_e&&C.length>1;){let r=C.shift();if(!r)break;r.entries.delete(r.key),A-=r.pixels;}}function ae(e,t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,t);if(typeof document>"u")return null;let n=document.createElement("canvas");return n.width=e,n.height=t,n}function qe(e,t){let n=Ne(e);if(!n)return e;let o=JSON.stringify(t),i=!Ye(e);if(i){let a=je(e,o);if(a)return a}let r=Ue(n);try{let a$1=ae(r.width,r.height),s=a$1?.getContext("2d");if(!a$1||!s)return e;s.drawImage(e,0,0,r.width,r.height);let l=s.getImageData(0,0,r.width,r.height);$e(l.data,t),s.putImageData(l,0,0);let h=a$1,d=a(e);return b(h,{x:d.x*n.width/r.width,y:d.y*n.height/r.height}),i&&Ge(e,o,h,r.width*r.height),h}catch{return e}}function F(e,t){return .299*e[t]+.587*e[t+1]+.114*e[t+2]}function ze(e,t){let n=Math.min(Math.max(t,-1),1),o=n>=0?128/(128-127*n):(128+127*n)/128,i=128-128*o+255*Math.min(Math.max(e,-1),1)*(1+o)/2,r=new Uint8ClampedArray(256);for(let a=0;a<256;a+=1)r[a]=Math.round(o*a+i);return r}function D(e){let t=e.startsWith("#")?e.slice(1):e,n=t.length===3||t.length===4?[...t].map(r=>r+r).join(""):t;if(n.length!==6&&n.length!==8)return null;let o=r=>Number.parseInt(n.slice(r,r+2),16),i=[o(0),o(2),o(4),n.length===8?o(6):255];return i.some(Number.isNaN)?null:i}function $e(e,t){for(let n of t)switch(n.kind){case "biLevel":{let o=Math.min(Math.max(n.threshold,0),1)*255;for(let i=0;i<e.length;i+=4){let r=F(e,i)<o?0:255;e[i]=r,e[i+1]=r,e[i+2]=r;}break}case "alpha":{let o=Math.min(Math.max(n.amount,0),1);for(let i=3;i<e.length;i+=4)e[i]=Math.round(e[i]*o);break}case "grayscale":{for(let o=0;o<e.length;o+=4){let i=Math.round(F(e,o));e[o]=i,e[o+1]=i,e[o+2]=i;}break}case "luminance":{let o=ze(n.brightness,n.contrast);for(let i=0;i<e.length;i+=4)e[i]=o[e[i]],e[i+1]=o[e[i+1]],e[i+2]=o[e[i+2]];break}case "duotone":{let o=D(n.shadow),i=D(n.highlight);if(!o||!i)break;for(let r=0;r<e.length;r+=4){let a=F(e,r)/255;for(let l=0;l<3;l+=1)e[r+l]=Math.round(o[l]*(1-a)+i[l]*a);let s=o[3]*(1-a)+i[3]*a;e[r+3]=Math.round(e[r+3]*s/255);}break}case "colorChange":{let o=D(n.from),i=D(n.to);if(!o||!i)break;for(let r=0;r<e.length;r+=4)e[r]!==o[0]||e[r+1]!==o[1]||e[r+2]!==o[2]||n.useAlpha!==false&&e[r+3]!==o[3]||(e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],n.useAlpha!==false&&(e[r+3]=i[3]));break}}}function Ve(e,t,n=[]){t.overflow||(e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip()),e.textAlign="left",e.textBaseline="alphabetic";let o=n.filter(r=>r.storyId===t.storyId);Q(e,t,o,false);let i=t.textShadow;i&&(e.save(),e.shadowColor=i.color,e.shadowBlur=Math.max(i.blur??0,0),e.shadowOffsetX=i.dx??0,e.shadowOffsetY=i.dy??0);for(let r of t.lines)for(let a of r.runs)Je(e,a,r.baseline);i&&e.restore(),Q(e,t,o,true);}function Q(e,t,n,o){if(n.length!==0)for(let i of t.lines)for(let r of i.runs)for(let a of n){let s=Math.max(r.start,a.start),l=Math.min(r.end,a.end);if(s>=l)continue;let h=i.caretStops.filter(c=>c.position>=s&&c.position<=l),d=h.length>1?Math.max(r.x,Math.min(...h.map(c=>c.x))):r.x,p=h.length>1?Math.min(r.x+r.width,Math.max(...h.map(c=>c.x))):r.x+r.width;if(p<=d)continue;let f=a.kind==="insertion";if(o){e.fillStyle=f?"#166534":"#b91c1c";let m=i.baseline-(r.baselineOffsetPx??0)+r.fontSizePx*(f?.08:-0.3);e.fillRect(d,m,p-d,Math.max(1,r.fontSizePx*.05));}else e.fillStyle=f?"#dcfce7cc":"#fee2e2cc",e.fillRect(d,i.y,p-d,i.height);}}function Je(e,t,n){let o=t.italic?"italic ":"",i=t.bold?"bold ":"";e.font=`${o}${i}${t.fontSizePx}px ${Ze(t.fontFamily)}`,e.fillStyle=t.color;let r=t.letterSpacingPx??0;e.letterSpacing=r===0?"0px":`${r}px`;let a=n-(t.baselineOffsetPx??0);for(let s of Ke(t))e.fillText(s.text,s.x,a);e.letterSpacing="0px",t.underline&&e.fillRect(t.x,a+t.fontSizePx*.08,t.width,Math.max(1,t.fontSizePx*.05));}function Ke(e){if(e.glyphs.length===0)return [{text:e.text,x:e.x}];if(e.glyphs.length>1&&e.glyphs[1].x<e.glyphs[0].x){let r=e.text.split(" "),a=[],s=-1;for(let h of r)s+=h.length+1,a.push(s);let l=r.map(()=>1/0);for(let h of e.glyphs){let d=h.cluster-e.start,p=0,f=a.length-1;for(;p<f;){let c=p+f>>1;a[c]<d?p=c+1:f=c;}d>=0&&d<a[p]&&(l[p]=Math.min(l[p],h.x));}return r.flatMap((h,d)=>h.length>0&&l[d]<1/0?[{text:h,x:l[d]}]:[])}let t=[],n=0,o=e.x,i=e.x;for(let r of e.glyphs){let a=r.cluster-e.start;a>n&&a<e.text.length&&Math.abs(r.x-i)>1e-4&&(t.push({text:e.text.slice(n,a),x:o}),n=a,o=r.x),i=Math.fround(Math.fround(r.x)+Math.fround(r.advance));}return t.push({text:e.text.slice(n),x:o}),t}function Ze(e){return e.includes(" ")?JSON.stringify(e):e}function Qe(e,t){e.strokeStyle="#8a94a6",e.lineWidth=1,e.setLineDash([5,4]),e.strokeRect(t.x,t.y,t.w,t.h),t.label&&(e.setLineDash([]),e.fillStyle="#5d6675",e.font="12px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(t.label,t.x+t.w/2,t.y+t.h/2,Math.max(0,t.w-12)));}function se(e){if(a$1(e)){if(e.byteLength>33554432)throw new Error("TIFF image exceeds the browser transfer budget");return new Blob([z(e).slice()],{type:"image/png"})}return c(e)}async function tt(e,t,n={}){let o=n.maxDimension;if(o!=null&&(!Number.isSafeInteger(o)||o<1))throw new Error("invalid image dimension limit");return f(se(e),t,n)}async function nt(e,t={}){let{scale:n=1,resolveImage:o}=t;if(!Number.isFinite(n)||n<=0)throw new Error("scale must be finite and positive");let i=ot(e,n),r=i.getContext("2d");if(!r)throw new Error("2d canvas context unavailable");return await _(r,e,1,n,{resolveImage:o}),rt(i)}function ot(e,t){if(typeof OffscreenCanvas=="function"){let{width:o,height:i}=H(e,1,t);return new OffscreenCanvas(o,i)}if(typeof document>"u")throw new Error("no canvas backend in this environment");let n=document.createElement("canvas");return X(n,e,1,t),n}function rt(e){return "convertToBlob"in e?e.convertToBlob({type:"image/png"}):new Promise((t,n)=>{e.toBlob(o=>{o?t(o):n(new Error("canvas produced no png"));},"image/png");})}export{tt as decodePresentationImage,_ as paintSlide,se as presentationImageBlob,X as sizeCanvasForSlide,nt as slideToPng};
1
+ export{c as fontPreflight,b as preloadPreflightWasm}from'./chunk-AYLLA7XR.js';export{f as createPptxWorkerEditorSession,e as openPresentationSession}from'./chunk-QRAGGQDN.js';import'./chunk-YMIVEAXD.js';export{b as PptxPeerNotReadyError,d as PptxWorkerEditorDisposedError}from'./chunk-KGEED2XY.js';import'./chunk-T6VUFMNC.js';import {a,ca,b,e,o}from'./chunk-COS6CTH7.js';export{G as PptxExportError,F as ProposalPictureMediaTooLargeError,E as StaleProposalError,H as decodeFontFace,aa as exportPptxMarkdown,$ as exportPptxStructured,X as initWasm,_ as inspectPresentation,W as isProposalsAvailable,Y as isWasmAvailable,f as metafileImageBytes,c as needsElementDecode,da as openPresentation,h as paintSlide,ba as renderPptxMarkdown,g as sizeCanvasForSlide,Z as wasmVersion}from'./chunk-COS6CTH7.js';export{a as PngExportError}from'./chunk-CCVGR3MS.js';import'./chunk-S6UYP4BX.js';export{c as CollaborationError,f as CollaborationProvider}from'./chunk-HZODDD5T.js';import'./chunk-GHET7GIK.js';export{a as PRESENCE_LABEL_DURATION_MS,b as presenceColorForClientId}from'./chunk-65A2TX24.js';import'./chunk-OUNTNO7R.js';import'./chunk-O2XFH626.js';function P(e){if(a(e)){if(e.byteLength>33554432)throw new Error("TIFF image exceeds the browser transfer budget");return new Blob([ca(e).slice()],{type:"image/png"})}return b(e)}async function G(e$1,l,o={}){let t=o.maxDimension;if(t!=null&&(!Number.isSafeInteger(t)||t<1))throw new Error("invalid image dimension limit");return e(P(e$1),l,o)}function W(){return o()}export{G as decodePresentationImage,W as fontPackDiagnostics,P as presentationImageBlob};