@betteroffice/pptx 0.2.0 → 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 +112 -263
- package/dist/chunk-2NCQ2IE7.js +3 -0
- package/dist/chunk-4FWJR3UX.js +1 -0
- package/dist/chunk-H3SEEI4U.js +1 -0
- package/dist/chunk-LIYNXEQC.js +1 -0
- package/dist/chunk-NNSP5326.js +1 -0
- package/dist/chunk-YMIVEAXD.js +0 -0
- package/dist/collaboration.d.ts +11 -0
- package/dist/collaboration.js +1 -0
- package/dist/editorSession-Cuqxkg-B.d.ts +1753 -0
- package/dist/generated/pptx_wasm_bg.wasm +0 -0
- package/dist/index.d.ts +9 -1552
- package/dist/index.js +1 -1
- package/dist/main-C6-cc0fR.d.ts +146 -0
- package/dist/pptxSessionWorker.d.ts +2 -0
- package/dist/pptxSessionWorker.mjs +9 -0
- package/dist/presence-C1o8TDwu.d.ts +95 -0
- package/dist/types-ui_ARP0o.d.ts +93 -0
- package/dist/worker.d.ts +621 -0
- package/dist/worker.js +1 -0
- package/package.json +17 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Mt=Object.defineProperty;var Ot=(t,e,r)=>e in t?Mt(t,e,{enumerable:true,configurable:true,writable:true,value:r}):t[e]=r;var y=(t,e,r)=>Ot(t,typeof e!="symbol"?e+"":e,r);function me(t,e,r=1){return {width:Math.ceil(t.width*r*e),height:Math.ceil(t.height*r*e)}}function be(t,e,r,n=1){let o=me(e,r,n);t.width=o.width,t.height=o.height,t.style.width=`${e.width*n}px`,t.style.height=`${e.height*n}px`;}async function ye(t,e,r=1,n=1,o={}){let i={remaining:o.maxShadowPixels??134217728};if(!Number.isSafeInteger(i.remaining)||i.remaining<0)throw new Error("invalid shadow pixel budget");t.save();try{t.setTransform(r*n,0,0,r*n,0,0),t.clearRect(0,0,e.width,e.height),e.background&&(t.fillStyle=oe(t,e.background,0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height));for(let l of e.primitives)await We(t,l,o,r*n,i);}finally{t.restore();}}async function We(t,e,r,n,o){t.save();try{switch(Lt(t,e),e.kind){case "shape":Xe(t,e,n,o);break;case "image":await qt(t,e,r.resolveImage,n,o);break;case "textBox":nr(t,e,r.textChanges);break;case "placeholder":ar(t,e);break;case "chart":case "table":await Ft(t,e,r,n,o);break}}finally{t.restore();}}async function Ft(t,e,r,n,o){t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip();for(let i of e.primitives)await We(t,i,r,n,o);}function Lt(t,e){let r=e.transform;if(!r)return;let n=e.x+e.w/2,o=e.y+e.h/2;t.translate(n,o),t.rotate((r.rotationDeg??0)*Math.PI/180),t.scale(r.flipH?-1:1,r.flipV?-1:1),t.translate(-n,-o);}function Xe(t,e,r,n){e.clip&&(_e(t,e.clip,e.x,e.y,e.w,e.h),t.clip()),e.shadow&&(e.fill||e.stroke||e.shadow.paths?.some(o=>o.stroke))&&Nt(t,e,r,n),_e(t,e.path,e.x,e.y,e.w,e.h),e.fill&&(t.fillStyle=oe(t,e.fill,e.x,e.y,e.w,e.h),t.fill(e.evenOdd?"evenodd":"nonzero")),e.stroke&&(ze(t,e.stroke,e.x,e.y,e.w,e.h),Vt(t,e));}function Nt(t,e,r,n){let o=e.shadow?.paths?.length?e.shadow.paths.map(i=>({...e,path:i.path,fill:i.fill?e.fill:void 0,stroke:i.stroke,shadow:void 0})):[{...e,shadow:void 0}];He(t,e.shadow,o.flatMap(i=>we(i.path,i)),o.reduce((i,l)=>Math.max(i,l.stroke?.width??0),0),r,n,i=>{for(let l of o)Xe(i,l,r,n);});}function He(t,e,r,n,o,i,l){let d=e.scaleX??1,s=e.scaleY??1,u=t.getTransform(),f={a:u.a*d,b:u.b*s,c:u.c*d,d:u.d*s,e:u.e*d,f:u.f*s};if(!r.length)return;let x=1/0,E=1/0,T=-1/0,N=-1/0;for(let[G,Le]of r){let Ne=f.a*G+f.c*Le+f.e,De=f.b*G+f.d*Le+f.f;x=Math.min(x,Ne),E=Math.min(E,De),T=Math.max(T,Ne),N=Math.max(N,De);}let C=Math.min(Math.max(e.blur??0,0)*o/2,128),m=C*3+1,V=n*o*Math.max(Math.abs(d),Math.abs(s))*2,j=(e.dx??0)*o,z=(e.dy??0)*o,c=Math.floor(Math.max(x-V,-m-j)),p=Math.floor(Math.max(E-V,-m-z)),w=Math.ceil(Math.min(T+V,t.canvas.width+m-j)),S=Math.ceil(Math.min(N+V,t.canvas.height+m-z));if(w<=c||S<=p)return;let O=(w-c)*(S-p);if(!Number.isSafeInteger(O)||O>i.remaining)throw new Error("shadows exceed the pixel budget on one slide");i.remaining-=O;let k=typeof OffscreenCanvas<"u"?new OffscreenCanvas(w-c,S-p):Object.assign(document.createElement("canvas"),{width:w-c,height:S-p}),D=k.getContext("2d");if(D){D.setTransform(f.a,f.b,f.c,f.d,f.e-c,f.f-p),l(D),t.save();try{if(t.setTransform(1,0,0,1,0,0),typeof t.filter=="string")D.setTransform(1,0,0,1,0,0),D.globalCompositeOperation="source-in",D.fillStyle=e.color,D.fillRect(0,0,k.width,k.height),t.filter=`blur(${C}px)`,t.drawImage(k,c+j,p+z);else {let G=t.canvas.width+1;t.shadowColor=e.color,t.shadowBlur=C*2,t.shadowOffsetX=c+j-G,t.shadowOffsetY=z,t.drawImage(k,G,p);}}finally{t.restore();}}}function we(t,e){let r=[];for(let n of t)n.type!=="close"&&(n.type==="quad"?r.push([e.x+n.cpx*e.w,e.y+n.cpy*e.h]):n.type==="cubic"&&(r.push([e.x+n.cp1x*e.w,e.y+n.cp1y*e.h]),r.push([e.x+n.cp2x*e.w,e.y+n.cp2y*e.h])),r.push([e.x+n.x*e.w,e.y+n.y*e.h]));return r.filter((n,o)=>o===0||n[0]!==r[o-1][0]||n[1]!==r[o-1][1])}function Dt(t){return t.path?we(t.path,t):[[t.x,t.y],[t.x+t.w,t.y],[t.x+t.w,t.y+t.h],[t.x,t.y+t.h]]}var Bt=new Set(["triangle","stealth","arrow","diamond","oval"]);function Vt(t,e){let r=e.stroke;if(!r||!r.headEnd&&!r.tailEnd)return;let n=we(e.path,e);if(n.length<2)return;let o=[[r.headEnd,n[1],n[0]],[r.tailEnd,n[n.length-2],n[n.length-1]]];t.save(),t.setLineDash([]);let i=r.paint?oe(t,r.paint,e.x,e.y,e.w,e.h):r.color;t.fillStyle=i,t.strokeStyle=i,t.lineWidth=r.width,t.lineJoin="miter";for(let[l,d,s]of o){if(!l||!Bt.has(l.kind))continue;let[u,f]=[s[0]-d[0],s[1]-d[1]],x=Math.hypot(u,f);x<1e-6||jt(t,l,s,u/x,f/x);}t.restore();}function jt(t,e,[r,n],o,i){let l=e.width/2,[d,s]=[-i*l,o*l],[u,f]=[r-o*e.length,n-i*e.length];switch(t.beginPath(),e.kind){case "triangle":t.moveTo(r,n),t.lineTo(u+d,f+s),t.lineTo(u-d,f-s),t.closePath(),t.fill();break;case "stealth":t.moveTo(r,n),t.lineTo(u+d,f+s),t.lineTo(r-o*e.length*.6,n-i*e.length*.6),t.lineTo(u-d,f-s),t.closePath(),t.fill();break;case "arrow":t.moveTo(u+d,f+s),t.lineTo(r,n),t.lineTo(u-d,f-s),t.stroke();break;case "diamond":{let[x,E]=[o*e.length/2,i*e.length/2];t.moveTo(r+x,n+E),t.lineTo(r+d,n+s),t.lineTo(r-x,n-E),t.lineTo(r-d,n-s),t.closePath(),t.fill();break}case "oval":t.ellipse(r,n,e.length/2,l,Math.atan2(i,o),0,Math.PI*2),t.fill();break}}function Wt(t,e,r){if(r.tile){Xt(t,e,r,r.tile);return}let n=r.crop,o=F(n?.left),i=F(n?.top),l=1-o-F(n?.right),d=1-i-F(n?.bottom),s=r.path!==void 0||l!==1||d!==1;if(l<=0||d<=0)return;s&&(t.save(),xe(t,r),t.clip());let u=qe(e),f=$e(e);u>0&&f>0?t.drawImage(e,o*u,i*f,l*u,d*f,r.x,r.y,r.w,r.h):t.drawImage(e,r.x,r.y,r.w,r.h),s&&t.restore();}function Xt(t,e,r,n){let o=qe(e),i=$e(e);if(o<=0||i<=0)return;let l=Math.round(F(r.crop?.left)*o),d=Math.round(F(r.crop?.top)*i),s=o-Math.round(F(r.crop?.right)*o),u=i-Math.round(F(r.crop?.bottom)*i);if(s<=l||u<=d)return;let f=l>0||d>0||s<o||u<i,x=t.createPattern(f?Ht(e,l,d,s-l,u-d):e,"repeat");x&&(t.save(),xe(t,r),t.clip(),x.setTransform(new DOMMatrix().translateSelf(r.x,r.y).scaleSelf(n.scaleX,n.scaleY)),t.fillStyle=x,t.fillRect(r.x,r.y,r.w,r.h),t.restore());}function Ht(t,e,r,n,o){try{let i=Ge(n,o),l=i?.getContext("2d");return !i||!l?t:(l.drawImage(t,e,r,n,o,0,0,n,o),i)}catch{return t}}function xe(t,e){e.path?_e(t,e.path,e.x,e.y,e.w,e.h):(t.beginPath(),t.rect(e.x,e.y,e.w,e.h));}function F(t){return t===void 0||!Number.isFinite(t)?0:Math.min(Math.max(t,0),1)}function qe(t){return "naturalWidth"in t&&typeof t.naturalWidth=="number"?t.naturalWidth:"width"in t&&typeof t.width=="number"?t.width:0}function $e(t){return "naturalHeight"in t&&typeof t.naturalHeight=="number"?t.naturalHeight:"height"in t&&typeof t.height=="number"?t.height:0}function _e(t,e,r,n,o,i){t.beginPath();for(let l of e)switch(l.type){case "move":t.moveTo(r+l.x*o,n+l.y*i);break;case "line":t.lineTo(r+l.x*o,n+l.y*i);break;case "quad":t.quadraticCurveTo(r+l.cpx*o,n+l.cpy*i,r+l.x*o,n+l.y*i);break;case "cubic":t.bezierCurveTo(r+l.cp1x*o,n+l.cp1y*i,r+l.cp2x*o,n+l.cp2y*i,r+l.x*o,n+l.y*i);break;case "close":t.closePath();break}}function ze(t,e,r,n,o,i){t.strokeStyle=e.paint?oe(t,e.paint,r,n,o,i):e.color,t.lineWidth=e.width,t.setLineDash(e.dashed?[Math.max(3,e.width*2),Math.max(2,e.width)]:[]),t.lineJoin=e.join??"miter",t.stroke();}function oe(t,e,r,n,o,i){if(e.kind==="solid")return e.color;let l=(e.angleDeg??0)*Math.PI/180,d=r+o/2,s=n+i/2,u=Math.hypot(o,i)/2,f=e.gradientType==="linear"?t.createLinearGradient(d-Math.cos(l)*u,s-Math.sin(l)*u,d+Math.cos(l)*u,s+Math.sin(l)*u):t.createRadialGradient(d,s,0,d,s,u);for(let x of e.stops)f.addColorStop(Math.max(0,Math.min(1,x.position)),x.color);return f}async function qt(t,e,r,n,o){let i;if(e.assetId&&r){let l=await $t(r,e.assetId);l&&(i=e.effects?.length?er(l,e.effects):l);}if(e.shadow&&(i||e.stroke||e.shadow.paths?.some(l=>l.stroke))){let l=e.shadow.paths?.length?e.shadow.paths.map(d=>({image:{...e,path:d.path,stroke:d.stroke},source:d.fill?i:void 0})):[{image:e,source:i}];He(t,e.shadow,l.flatMap(d=>Dt(d.image)),l.reduce((d,s)=>Math.max(d,s.image.stroke?.width??0),0),n,o,d=>{for(let s of l)Be(d,s.image,s.source);});}Be(t,e,i);}async function $t(t,e){try{return await t(e)}catch{return null}}function Be(t,e,r){r&&Wt(t,r,e),e.stroke&&(xe(t,e),ze(t,e.stroke,e.x,e.y,e.w,e.h));}var Ve=33554432,zt=67108864;function Gt(t){let e=t,r=e.naturalWidth??e.videoWidth??e.displayWidth??(typeof e.width=="number"?e.width:0),n=e.naturalHeight??e.videoHeight??e.displayHeight??(typeof e.height=="number"?e.height:0);return r>0&&n>0?{width:r,height:n}:null}function Yt(t){let e=t.width*t.height;if(e<=Ve)return t;let r=Math.sqrt(Ve/e);return {width:Math.max(1,Math.floor(t.width*r)),height:Math.max(1,Math.floor(t.height*r))}}var ge=new WeakMap,W=[],fe=0;function Kt(t){let e=t;return "videoWidth"in e||"displayWidth"in e||typeof e.getContext=="function"}function Zt(t,e){let r=ge.get(t),n=r?.get(e);if(!r||!n)return;let o=W.findIndex(i=>i.entries===r&&i.key===e);return o>=0&&W.push(...W.splice(o,1)),n}function Qt(t,e,r,n){let o=ge.get(t);for(o||(o=new Map,ge.set(t,o)),o.set(e,r),W.push({entries:o,key:e,pixels:n}),fe+=n;fe>zt&&W.length>1;){let i=W.shift();if(!i)break;i.entries.delete(i.key),fe-=i.pixels;}}function Ge(t,e){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(t,e);if(typeof document>"u")return null;let r=document.createElement("canvas");return r.width=t,r.height=e,r}function er(t,e){let r=Gt(t);if(!r)return t;let n=JSON.stringify(e),o=!Kt(t);if(o){let l=Zt(t,n);if(l)return l}let i=Yt(r);try{let l=Ge(i.width,i.height),d=l?.getContext("2d");if(!l||!d)return t;d.drawImage(t,0,0,i.width,i.height);let s=d.getImageData(0,0,i.width,i.height);rr(s.data,e),d.putImageData(s,0,0);let u=l;return o&&Qt(t,n,u,i.width*i.height),u}catch{return t}}function he(t,e){return .299*t[e]+.587*t[e+1]+.114*t[e+2]}function tr(t,e){let r=Math.min(Math.max(e,-1),1),n=r>=0?128/(128-127*r):(128+127*r)/128,o=128-128*n+255*Math.min(Math.max(t,-1),1)*(1+n)/2,i=new Uint8ClampedArray(256);for(let l=0;l<256;l+=1)i[l]=Math.round(n*l+o);return i}function ne(t){let e=t.startsWith("#")?t.slice(1):t,r=e.length===3||e.length===4?[...e].map(i=>i+i).join(""):e;if(r.length!==6&&r.length!==8)return null;let n=i=>Number.parseInt(r.slice(i,i+2),16),o=[n(0),n(2),n(4),r.length===8?n(6):255];return o.some(Number.isNaN)?null:o}function rr(t,e){for(let r of e)switch(r.kind){case "biLevel":{let n=Math.min(Math.max(r.threshold,0),1)*255;for(let o=0;o<t.length;o+=4){let i=he(t,o)<n?0:255;t[o]=i,t[o+1]=i,t[o+2]=i;}break}case "alpha":{let n=Math.min(Math.max(r.amount,0),1);for(let o=3;o<t.length;o+=4)t[o]=Math.round(t[o]*n);break}case "grayscale":{for(let n=0;n<t.length;n+=4){let o=Math.round(he(t,n));t[n]=o,t[n+1]=o,t[n+2]=o;}break}case "luminance":{let n=tr(r.brightness,r.contrast);for(let o=0;o<t.length;o+=4)t[o]=n[t[o]],t[o+1]=n[t[o+1]],t[o+2]=n[t[o+2]];break}case "duotone":{let n=ne(r.shadow),o=ne(r.highlight);if(!n||!o)break;for(let i=0;i<t.length;i+=4){let l=he(t,i)/255;for(let s=0;s<3;s+=1)t[i+s]=Math.round(n[s]*(1-l)+o[s]*l);let d=n[3]*(1-l)+o[3]*l;t[i+3]=Math.round(t[i+3]*d/255);}break}case "colorChange":{let n=ne(r.from),o=ne(r.to);if(!n||!o)break;for(let i=0;i<t.length;i+=4)t[i]!==n[0]||t[i+1]!==n[1]||t[i+2]!==n[2]||r.useAlpha!==false&&t[i+3]!==n[3]||(t[i]=o[0],t[i+1]=o[1],t[i+2]=o[2],r.useAlpha!==false&&(t[i+3]=o[3]));break}}}function nr(t,e,r=[]){e.overflow||(t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip()),t.textAlign="left",t.textBaseline="alphabetic";let n=r.filter(i=>i.storyId===e.storyId);je(t,e,n,false);let o=e.textShadow;o&&(t.save(),t.shadowColor=o.color,t.shadowBlur=Math.max(o.blur??0,0),t.shadowOffsetX=o.dx??0,t.shadowOffsetY=o.dy??0);for(let i of e.lines)for(let l of i.runs)or(t,l,i.baseline);o&&t.restore(),je(t,e,n,true);}function je(t,e,r,n){if(r.length!==0)for(let o of e.lines)for(let i of o.runs)for(let l of r){let d=Math.max(i.start,l.start),s=Math.min(i.end,l.end);if(d>=s)continue;let u=o.caretStops.filter(T=>T.position>=d&&T.position<=s),f=u.length>1?Math.max(i.x,Math.min(...u.map(T=>T.x))):i.x,x=u.length>1?Math.min(i.x+i.width,Math.max(...u.map(T=>T.x))):i.x+i.width;if(x<=f)continue;let E=l.kind==="insertion";if(n){t.fillStyle=E?"#166534":"#b91c1c";let N=o.baseline-(i.baselineOffsetPx??0)+i.fontSizePx*(E?.08:-0.3);t.fillRect(f,N,x-f,Math.max(1,i.fontSizePx*.05));}else t.fillStyle=E?"#dcfce7cc":"#fee2e2cc",t.fillRect(f,o.y,x-f,o.height);}}function or(t,e,r){let n=e.italic?"italic ":"",o=e.bold?"bold ":"";t.font=`${n}${o}${e.fontSizePx}px ${sr(e.fontFamily)}`,t.fillStyle=e.color;let i=e.letterSpacingPx??0;t.letterSpacing=i===0?"0px":`${i}px`;let l=r-(e.baselineOffsetPx??0);for(let d of ir(e))t.fillText(d.text,d.x,l);t.letterSpacing="0px",e.underline&&t.fillRect(e.x,l+e.fontSizePx*.08,e.width,Math.max(1,e.fontSizePx*.05));}function ir(t){if(t.glyphs.length===0)return [{text:t.text,x:t.x}];if(t.glyphs.length>1&&t.glyphs[1].x<t.glyphs[0].x){let i=t.text.split(" "),l=[],d=-1;for(let u of i)d+=u.length+1,l.push(d);let s=i.map(()=>1/0);for(let u of t.glyphs){let f=u.cluster-t.start,x=0,E=l.length-1;for(;x<E;){let T=x+E>>1;l[T]<f?x=T+1:E=T;}f>=0&&f<l[x]&&(s[x]=Math.min(s[x],u.x));}return i.flatMap((u,f)=>u.length>0&&s[f]<1/0?[{text:u,x:s[f]}]:[])}let e=[],r=0,n=t.x,o=t.x;for(let i of t.glyphs){let l=i.cluster-t.start;l>r&&l<t.text.length&&Math.abs(i.x-o)>1e-4&&(e.push({text:t.text.slice(r,l),x:n}),r=l,n=i.x),o=Math.fround(Math.fround(i.x)+Math.fround(i.advance));}return e.push({text:t.text.slice(r),x:n}),e}function sr(t){return t.includes(" ")?JSON.stringify(t):t}function ar(t,e){t.strokeStyle="#8a94a6",t.lineWidth=1,t.setLineDash([5,4]),t.strokeRect(e.x,e.y,e.w,e.h),e.label&&(t.setLineDash([]),t.fillStyle="#5d6675",t.font="12px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(e.label,e.x+e.w/2,e.y+e.h/2,Math.max(0,e.w-12)));}function Ye(t){return t.length>=4&&(t[0]===73&&t[1]===73&&t[2]===42&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===42)}var A=class t{static __wrap(e){let r=Object.create(t.prototype);return r.__wbg_ptr=e,Ke.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ke.unregister(this),e}free(){let e=this.__destroy_into_raw();a.__wbg_pptxdocument_free(e,0);}acceptProposalJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_acceptProposalJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}addCommentJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_addCommentJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}addPictureJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_addPictureJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}addShapeJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_addShapeJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}addTextBoxJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_addTextBoxJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}addTextBoxProfiledJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_addTextBoxProfiledJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}addUndoBoundary(){a.pptxdocument_addUndoBoundary(this.__wbg_ptr);}anchorCaretJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_anchorCaretJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}applyEditsJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_applyEditsJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}applyUpdateJson(e){let r,n;try{let l=R(e,a.__wbindgen_malloc),d=_,s=a.pptxdocument_applyUpdateJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}bringShapeForwardJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_bringShapeForwardJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}bringShapeToFrontJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_bringShapeToFrontJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}canRedo(){return a.pptxdocument_canRedo(this.__wbg_ptr)!==0}canUndo(){return a.pptxdocument_canUndo(this.__wbg_ptr)!==0}clearUpdateObservation(){a.pptxdocument_clearUpdateObservation(this.__wbg_ptr);}get clientId(){return a.pptxdocument_clientId(this.__wbg_ptr)}commentsJson(){let e,r;try{let i=a.pptxdocument_commentsJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,h(i[2]);return e=n,r=o,g(n,o)}finally{a.__wbindgen_free(e,r,1);}}deleteSlideJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_deleteSlideJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}deleteTextJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_deleteTextJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}deleteTextProfiledJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_deleteTextProfiledJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}documentVersion(){let e,r;try{let n=a.pptxdocument_documentVersion(this.__wbg_ptr);return e=n[0],r=n[1],g(n[0],n[1])}finally{a.__wbindgen_free(e,r,1);}}drainUpdateEvent(){let e=a.pptxdocument_drainUpdateEvent(this.__wbg_ptr);var r=L(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*1,1),r}encodeDiff(e){let r=R(e,a.__wbindgen_malloc),n=_,o=a.pptxdocument_encodeDiff(this.__wbg_ptr,r,n);if(o[3])throw h(o[2]);var i=L(o[0],o[1]).slice();return a.__wbindgen_free(o[0],o[1]*1,1),i}encodeStateAsUpdate(){let e=a.pptxdocument_encodeStateAsUpdate(this.__wbg_ptr);var r=L(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*1,1),r}encodeStateVector(){let e=a.pptxdocument_encodeStateVector(this.__wbg_ptr);var r=L(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*1,1),r}exportMarkdownJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_exportMarkdownJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}exportStructuredJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_exportStructuredJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}findTextJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_findTextJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}formatTextJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_formatTextJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}insertParagraphBreakJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_insertParagraphBreakJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}insertSlideJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_insertSlideJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}insertSlideProfiledJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_insertSlideProfiledJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}insertTextJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_insertTextJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}insertTextProfiledJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_insertTextProfiledJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}listProposalsJson(){let e,r;try{let i=a.pptxdocument_listProposalsJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,h(i[2]);return e=n,r=o,g(n,o)}finally{a.__wbindgen_free(e,r,1);}}mediaBytes(e){let r=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),n=_,o=a.pptxdocument_mediaBytes(this.__wbg_ptr,r,n);if(o[3])throw h(o[2]);var i=L(o[0],o[1]).slice();return a.__wbindgen_free(o[0],o[1]*1,1),i}moveShapeJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_moveShapeJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}moveShapeProfiledJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_moveShapeProfiledJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}moveSlideJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_moveSlideJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}static openCollaborative(e,r){let n=R(e,a.__wbindgen_malloc),o=_,i=a.pptxdocument_openCollaborative(n,o,r);if(i[2])throw h(i[1]);return t.__wrap(i[0])}static openCollaborativeFromUpdate(e,r,n){let o=R(e,a.__wbindgen_malloc),i=_;var l=pr(n)?0:R(n,a.__wbindgen_malloc),d=_;let s=a.pptxdocument_openCollaborativeFromUpdate(o,i,r,l,d);if(s[2])throw h(s[1]);return t.__wrap(s[0])}previewProposalJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_previewProposalJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}proposeJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_proposeJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}readContentJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_readContentJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}redoJson(){let e,r;try{let i=a.pptxdocument_redoJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,h(i[2]);return e=n,r=o,g(n,o)}finally{a.__wbindgen_free(e,r,1);}}rejectProposalJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_rejectProposalJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}removeCommentJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_removeCommentJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}removeShapeJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_removeShapeJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}replyToCommentJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_replyToCommentJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}resizeShapeJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_resizeShapeJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}resolveCaretAnchorJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_resolveCaretAnchorJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}saveBytes(){let e=a.pptxdocument_saveBytes(this.__wbg_ptr);if(e[3])throw h(e[2]);var r=L(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*1,1),r}searchTextJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_searchTextJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}sendShapeBackwardJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_sendShapeBackwardJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}sendShapeToBackJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_sendShapeToBackJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setCommentFlavorJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_setCommentFlavorJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setCommentPositionJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_setCommentPositionJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setCommentStatusJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_setCommentStatusJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setParagraphAlignmentJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_setParagraphAlignmentJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setShapeAdjustJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_setShapeAdjustJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setShapeFillJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_setShapeFillJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setShapeRectJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_setShapeRectJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setShapeStrokeJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_setShapeStrokeJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setSlideNotesJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_setSlideNotesJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}setUndoCaptureMode(e){let r=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),n=_,o=a.pptxdocument_setUndoCaptureMode(this.__wbg_ptr,r,n);if(o[1])throw h(o[0])}snapshotJson(){let e,r;try{let i=a.pptxdocument_snapshotJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,h(i[2]);return e=n,r=o,g(n,o)}finally{a.__wbindgen_free(e,r,1);}}startUpdateObservation(){let e=a.pptxdocument_startUpdateObservation(this.__wbg_ptr);if(e[1])throw h(e[0])}storyJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_storyJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}undoCaptureMode(){let e,r;try{let n=a.pptxdocument_undoCaptureMode(this.__wbg_ptr);return e=n[0],r=n[1],g(n[0],n[1])}finally{a.__wbindgen_free(e,r,1);}}undoJson(){let e,r;try{let i=a.pptxdocument_undoJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,h(i[2]);return e=n,r=o,g(n,o)}finally{a.__wbindgen_free(e,r,1);}}undoProfiledJson(){let e,r;try{let i=a.pptxdocument_undoProfiledJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,h(i[2]);return e=n,r=o,g(n,o)}finally{a.__wbindgen_free(e,r,1);}}validateEditsJson(e){let r,n;try{let l=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=a.pptxdocument_validateEditsJson(this.__wbg_ptr,l,d);var o=s[0],i=s[1];if(s[3])throw o=0,i=0,h(s[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}static version(){let e,r;try{let n=a.pptxdocument_version();return e=n[0],r=n[1],g(n[0],n[1])}finally{a.__wbindgen_free(e,r,1);}}};Symbol.dispose&&(A.prototype[Symbol.dispose]=A.prototype.free);var B=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ze.unregister(this),e}free(){let e=this.__destroy_into_raw();a.__wbg_pptxrenderer_free(e,0);}hitTestJson(e,r){let n,o;try{let d=a.pptxrenderer_hitTestJson(this.__wbg_ptr,e,r);var i=d[0],l=d[1];if(d[3])throw i=0,l=0,h(d[2]);return n=i,o=l,g(i,l)}finally{a.__wbindgen_free(n,o,1);}}layoutProposalDiffSlideJson(e,r,n){let o,i;try{ie(e,A);let s=b(r,a.__wbindgen_malloc,a.__wbindgen_realloc),u=_,f=a.pptxrenderer_layoutProposalDiffSlideJson(this.__wbg_ptr,e.__wbg_ptr,s,u,n);var l=f[0],d=f[1];if(f[3])throw l=0,d=0,h(f[2]);return o=l,i=d,g(l,d)}finally{a.__wbindgen_free(o,i,1);}}layoutProposalSlideJson(e,r,n){let o,i;try{ie(e,A);let s=b(r,a.__wbindgen_malloc,a.__wbindgen_realloc),u=_,f=a.pptxrenderer_layoutProposalSlideJson(this.__wbg_ptr,e.__wbg_ptr,s,u,n);var l=f[0],d=f[1];if(f[3])throw l=0,d=0,h(f[2]);return o=l,i=d,g(l,d)}finally{a.__wbindgen_free(o,i,1);}}layoutSlideJson(e,r){let n,o;try{ie(e,A);let d=a.pptxrenderer_layoutSlideJson(this.__wbg_ptr,e.__wbg_ptr,r);var i=d[0],l=d[1];if(d[3])throw i=0,l=0,h(d[2]);return n=i,o=l,g(i,l)}finally{a.__wbindgen_free(n,o,1);}}layoutSlideProfiledJson(e,r){let n,o;try{ie(e,A);let d=a.pptxrenderer_layoutSlideProfiledJson(this.__wbg_ptr,e.__wbg_ptr,r);var i=d[0],l=d[1];if(d[3])throw i=0,l=0,h(d[2]);return n=i,o=l,g(i,l)}finally{a.__wbindgen_free(n,o,1);}}constructor(){let e=a.pptxrenderer_new();return this.__wbg_ptr=e,Ze.register(this,this.__wbg_ptr,this),this}registerFallbackFont(e,r,n,o){let i=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),l=_,d=R(o,a.__wbindgen_malloc),s=_,u=a.pptxrenderer_registerFallbackFont(this.__wbg_ptr,i,l,r,n,d,s);if(u[2])throw h(u[1]);return u[0]>>>0}registerFont(e,r,n,o){let i=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),l=_,d=R(o,a.__wbindgen_malloc),s=_,u=a.pptxrenderer_registerFont(this.__wbg_ptr,i,l,r,n,d,s);if(u[2])throw h(u[1]);return u[0]>>>0}};Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);function Qe(t){let e=R(t,a.__wbindgen_malloc),r=_,n=a.decodeTiffPng(e,r);if(n[3])throw h(n[2]);var o=L(n[0],n[1]).slice();return a.__wbindgen_free(n[0],n[1]*1,1),o}function et(t,e){let r,n;try{let l=R(t,a.__wbindgen_malloc),d=_,s=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),u=_,f=a.exportPptxMarkdownJson(l,d,s,u);var o=f[0],i=f[1];if(f[3])throw o=0,i=0,h(f[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}function tt(t,e){let r,n;try{let l=R(t,a.__wbindgen_malloc),d=_,s=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),u=_,f=a.exportPptxStructuredJson(l,d,s,u);var o=f[0],i=f[1];if(f[3])throw o=0,i=0,h(f[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}function rt(t){let e,r;try{let i=R(t,a.__wbindgen_malloc),l=_,d=a.parsePptxJson(i,l);var n=d[0],o=d[1];if(d[3])throw n=0,o=0,h(d[2]);return e=n,r=o,g(n,o)}finally{a.__wbindgen_free(e,r,1);}}function nt(t,e){let r,n;try{let l=b(t,a.__wbindgen_malloc,a.__wbindgen_realloc),d=_,s=b(e,a.__wbindgen_malloc,a.__wbindgen_realloc),u=_,f=a.renderPptxMarkdownJson(l,d,s,u);var o=f[0],i=f[1];if(f[3])throw o=0,i=0,h(f[2]);return r=o,n=i,g(o,i)}finally{a.__wbindgen_free(r,n,1);}}function ot(){let t,e;try{let r=a.rendererVersion();return t=r[0],e=r[1],g(r[0],r[1])}finally{a.__wbindgen_free(t,e,1);}}function lr(){return {__proto__:null,"./pptx_wasm_bg.js":{__proto__:null,__wbg___wbindgen_throw_344f42d3211c4765:function(e,r){throw new Error(g(e,r))},__wbg_getRandomValues_3f44b700395062e5:function(){return cr(function(e,r){globalThis.crypto.getRandomValues(L(e,r));},arguments)},__wbg_now_546eb6b39d572d7e:function(){return performance.now()},__wbg_now_86c0d4ba3fa605b8:function(){return Date.now()},__wbg_now_f1489d8a2945407f:function(){return performance.now()},__wbg_random_039a7d5d06e0d333:function(){return Math.random()},__wbindgen_cast_0000000000000001:function(e,r){return g(e,r)},__wbindgen_init_externref_table:function(){let e=a.__wbindgen_externrefs,r=e.grow(4);e.set(0,void 0),e.set(r+0,void 0),e.set(r+1,null),e.set(r+2,true),e.set(r+3,false);}}}}var Ke=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>a.__wbg_pptxdocument_free(t,1)),Ze=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>a.__wbg_pptxrenderer_free(t,1));function dr(t){let e=a.__externref_table_alloc();return a.__wbindgen_externrefs.set(e,t),e}function ie(t,e){if(!(t instanceof e))throw new Error(`expected instance of ${e.name}`)}function L(t,e){return t=t>>>0,X().subarray(t/1,t/1+e)}function g(t,e){return fr(t>>>0,e)}var Y=null;function X(){return (Y===null||Y.byteLength===0)&&(Y=new Uint8Array(a.memory.buffer)),Y}function cr(t,e){try{return t.apply(this,e)}catch(r){let n=dr(r);a.__wbindgen_exn_store(n);}}function pr(t){return t==null}function R(t,e){let r=e(t.length*1,1)>>>0;return X().set(t,r/1),_=t.length,r}function b(t,e,r){if(r===void 0){let d=K.encode(t),s=e(d.length,1)>>>0;return X().subarray(s,s+d.length).set(d),_=d.length,s}let n=t.length,o=e(n,1)>>>0,i=X(),l=0;for(;l<n;l++){let d=t.charCodeAt(l);if(d>127)break;i[o+l]=d;}if(l!==n){l!==0&&(t=t.slice(l)),o=r(o,n,n=l+t.length*3,1)>>>0;let d=X().subarray(o+l,o+n),s=K.encodeInto(t,d);l+=s.written,o=r(o,n,l,1)>>>0;}return _=l,o}function h(t){let e=a.__wbindgen_externrefs.get(t);return a.__externref_table_dealloc(t),e}var se=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});se.decode();var ur=2146435072,Pe=0;function fr(t,e){return Pe+=e,Pe>=ur&&(se=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),se.decode(),Pe=e),se.decode(X().subarray(t,t+e))}var K=new TextEncoder;"encodeInto"in K||(K.encodeInto=function(t,e){let r=K.encode(t);return e.set(r),{read:t.length,written:r.length}});var _=0,a;function gr(t,e){return a=t.exports,Y=null,a.__wbindgen_start(),a}async function mr(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(o){if(t.ok&&r(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let n=await t.arrayBuffer();return await WebAssembly.instantiate(n,e)}else {let n=await WebAssembly.instantiate(t,e);return n instanceof WebAssembly.Instance?{instance:n,module:t}:n}function r(n){switch(n){case "basic":case "cors":case "default":return true}return false}}async function it(t){if(a!==void 0)return a;if(t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),t===void 0)throw new Error("pptx-wasm requires an explicit module or URL");let e=lr();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await mr(await t,e);return gr(r)}var Z=class extends Error{constructor(r){super(`Proposal targets changed: ${r.join(", ")}`);y(this,"targets");this.name="StaleProposalError",this.targets=r;}};var Q=class extends Error{constructor(r){super(r.message);y(this,"failure");this.name="PptxExportError",this.failure=r;}};var Se=false;function ve(){return typeof A.prototype.proposeJson=="function"&&typeof B.prototype.layoutProposalSlideJson=="function"}var ee;function le(t=new URL("./generated/pptx_wasm_bg.wasm",import.meta.url)){return Se?Promise.resolve():ee||(ee=it({module_or_path:t}).then(()=>{Se=true;},e=>{throw ee=void 0,H(e)}),ee)}function br(){return typeof WebAssembly=="object"}function yr(){return de(),ot()}function wr(t){return de(),Er(()=>rt(t))}function Ee(t){let e=at(t);if(!e.ok)throw new Q(e.failure);return e.content}async function xr(t,e={}){await le();let r=J(e);return Ee(()=>tt(t,r))}async function Pr(t,e={}){await le();let r=J(e);return Ee(()=>et(t,r))}async function Sr(t,e={}){await le();let r=J(e);return Ee(()=>nt(JSON.stringify(t),r))}function st(t){return de(),Ce(()=>Qe(t))}function vr(t,e={}){de();let r=e.clientId??Cr(),n=Ce(()=>e.initialUpdate===void 0?A.openCollaborative(t,r):A.openCollaborativeFromUpdate(e.initialUpdate.slice(),r,t.slice())),o=Ce(()=>new B);for(let c of e.fonts??[])ae(o,c);for(let c of e.fallbackFonts??[])ae(o,c,true);let i=new Map,l=[],d=0,s=false,u=false,f=0,x=false,E=()=>{if(s)throw new Error("presentation handle is disposed")},T=()=>{if(!(s||x||f!==0)){x=true;try{for(;!s&&l.length>0;){let c=l.shift();if(!c)break;for(let[p,w]of [...i]){if(s)return;if(i.get(p)===w)try{w(c.update.slice(),c.origin);}catch{}}}}finally{x=false,s&&(l.length=0);}}},N=()=>{if(!(!u||s))for(;;){let c=n.drainUpdateEvent();if(c.byteLength===0)return;let p=c[0];if(p!==0&&p!==1)throw new Error(`pptx wasm returned unknown update origin ${p}`);l.push({update:c.subarray(1),origin:p===0?"local":"remote"});}},C=(c,p=false)=>{E(),f+=1;try{let w,S,O=!1;try{w=c();}catch(k){S=k,O=!0;}if(p)try{N();}catch(k){O||(S=k,O=!0);}if(O)throw H(S);return w}finally{f-=1,f===0&&T();}},m=(c,p=false)=>C(()=>JSON.parse(c()),p),V=()=>{u||(C(()=>n.startUpdateObservation()),u=true);},j=()=>{!u||i.size>0||s||(l.length=0,C(()=>n.clearUpdateObservation()),u=false);};return {isProposalsAvailable:ve,propose(c,p,w){return m(()=>n.proposeJson(JSON.stringify({agentId:c,note:p,edits:w})))},listProposals(){return ve()?m(()=>n.listProposalsJson()):[]},previewProposal(c){return m(()=>n.previewProposalJson(JSON.stringify({id:c})))},layoutProposalDiffSlide(c,p){return m(()=>o.layoutProposalDiffSlideJson(n,c,p))},layoutProposalSlide(c,p){return m(()=>o.layoutProposalSlideJson(n,c,p))},acceptProposal(c,p){return m(()=>n.acceptProposalJson(JSON.stringify({id:c,force:p?.force??false})),true)},rejectProposal(c){return m(()=>n.rejectProposalJson(JSON.stringify({id:c})))},get clientId(){return C(()=>n.clientId)},snapshot(){return m(()=>n.snapshotJson())},story(c){return m(()=>n.storyJson(JSON.stringify({storyId:c})))},anchorCaret(c,p){return m(()=>n.anchorCaretJson(JSON.stringify({storyId:c,index:p})))},resolveCaretAnchor(c){return m(()=>n.resolveCaretAnchorJson(JSON.stringify({storyId:c.storyId,position:c.position})))},version(){return C(()=>n.documentVersion())},readContent(c={}){let p=J(c);return m(()=>n.readContentJson(p))},findText(c){let p=J(c);return m(()=>n.findTextJson(p))},exportStructured(c={}){let p=J(c);return m(()=>n.exportStructuredJson(p))},exportMarkdown(c={}){let p=J(c);return m(()=>n.exportMarkdownJson(p))},validateEdits(c){let p=J(c);return m(()=>n.validateEditsJson(p))},applyEdits(c){let p=J(c);return m(()=>n.applyEditsJson(p),true)},searchText(c,p={}){if(!c)return [];let w=p.limit??Number.POSITIVE_INFINITY;if(!Number.isSafeInteger(w)&&w!==Number.POSITIVE_INFINITY||w<0)throw new RangeError("search limit must be a non-negative safe integer");return m(()=>n.searchTextJson(JSON.stringify({query:c,caseSensitive:p.caseSensitive??false,limit:Number.isFinite(w)?Math.min(w,4294967295):void 0})))},registerFont(c){return C(()=>ae(o,c))},registerFallbackFont(c){return C(()=>ae(o,c,!0))},layoutSlide(c){return m(()=>o.layoutSlideJson(n,c))},layoutSlideProfiled(c){return m(()=>o.layoutSlideProfiledJson(n,c))},hitTest(c,p){return m(()=>o.hitTestJson(c,p))},mediaBytes(c){return C(()=>n.mediaBytes(c))},save(){return C(()=>n.saveBytes())},insertText(c,p,w,S={}){return m(()=>n.insertTextJson(JSON.stringify({storyId:c,index:p,text:w,style:S})),true)},insertTextProfiled(c,p,w,S={}){return m(()=>n.insertTextProfiledJson(JSON.stringify({storyId:c,index:p,text:w,style:S})),true)},deleteText(c,p,w){return m(()=>n.deleteTextJson(JSON.stringify({storyId:c,start:p,end:w})),true)},deleteTextProfiled(c,p,w){return m(()=>n.deleteTextProfiledJson(JSON.stringify({storyId:c,start:p,end:w})),true)},formatText(c,p,w,S){return m(()=>n.formatTextJson(JSON.stringify({storyId:c,start:p,end:w,patch:S})),true)},insertParagraphBreak(c,p){return m(()=>n.insertParagraphBreakJson(JSON.stringify({storyId:c,index:p})),true)},setParagraphAlignment(c,p,w,S){return m(()=>n.setParagraphAlignmentJson(JSON.stringify({storyId:c,start:p,end:w,alignment:S})),true)},insertSlide(c,p){return m(()=>n.insertSlideJson(JSON.stringify({index:c,layoutPartPath:p??null})),true)},insertSlideProfiled(c,p){return m(()=>n.insertSlideProfiledJson(JSON.stringify({index:c,layoutPartPath:p??null})),true)},deleteSlide(c){return m(()=>n.deleteSlideJson(JSON.stringify({slideId:c})),true)},moveSlide(c,p){return m(()=>n.moveSlideJson(JSON.stringify({slideId:c,toIndex:p})),true)},setSlideNotes(c,p){m(()=>n.setSlideNotesJson(JSON.stringify({slideId:c,text:p})),true);},addComment(c,p){return m(()=>n.addCommentJson(JSON.stringify({slideId:c,author:p.author,initials:p.initials??"",text:p.text,created:p.created,xEmu:p.xEmu??0,yEmu:p.yEmu??0})),true)},replyToComment(c,p){return m(()=>n.replyToCommentJson(JSON.stringify({commentId:c,author:p.author,initials:p.initials??"",text:p.text,created:p.created})),true)},setCommentPosition(c,p){if(!Number.isSafeInteger(p.xEmu)||!Number.isSafeInteger(p.yEmu))throw new Error("Comment coordinates must be safe integer EMU");return m(()=>n.setCommentPositionJson(JSON.stringify({commentId:c,...p})),true)},setCommentStatus(c,p){return m(()=>n.setCommentStatusJson(JSON.stringify({commentId:c,resolved:p})),true)},removeComment(c){return m(()=>n.removeCommentJson(JSON.stringify({commentId:c})),true)},setCommentFlavor(c){return m(()=>n.setCommentFlavorJson(JSON.stringify({flavor:c})),true)},comments(){return m(()=>n.commentsJson())},addTextBox(c,p){return m(()=>n.addTextBoxJson(JSON.stringify({slideId:c,draft:p})),true)},addTextBoxProfiled(c,p){return m(()=>n.addTextBoxProfiledJson(JSON.stringify({slideId:c,draft:p})),true)},addShape(c,p){return m(()=>n.addShapeJson(JSON.stringify({slideId:c,draft:p})),true)},addPicture(c,p){return m(()=>n.addPictureJson(JSON.stringify({slideId:c,...p})),true)},setShapeFill(c,p,w){return m(()=>n.setShapeFillJson(JSON.stringify({slideId:c,shapeId:p,color:w})),true)},setShapeStroke(c,p,w){return m(()=>n.setShapeStrokeJson(JSON.stringify({slideId:c,shapeId:p,stroke:w})),true)},setShapeAdjust(c,p,w){return m(()=>n.setShapeAdjustJson(JSON.stringify({slideId:c,shapeId:p,adjustments:w})),true)},removeShape(c,p){return m(()=>n.removeShapeJson(JSON.stringify({slideId:c,shapeId:p})),true)},bringShapeToFront(c,p){return m(()=>n.bringShapeToFrontJson(JSON.stringify({slideId:c,shapeId:p})),true)},sendShapeToBack(c,p){return m(()=>n.sendShapeToBackJson(JSON.stringify({slideId:c,shapeId:p})),true)},bringShapeForward(c,p){return m(()=>n.bringShapeForwardJson(JSON.stringify({slideId:c,shapeId:p})),true)},sendShapeBackward(c,p){return m(()=>n.sendShapeBackwardJson(JSON.stringify({slideId:c,shapeId:p})),true)},moveShape(c,p,w,S){return m(()=>n.moveShapeJson(JSON.stringify({slideId:c,shapeId:p,x:w,y:S})),true)},moveShapeProfiled(c,p,w,S){return m(()=>n.moveShapeProfiledJson(JSON.stringify({slideId:c,shapeId:p,x:w,y:S})),true)},resizeShape(c,p,w,S){return m(()=>n.resizeShapeJson(JSON.stringify({slideId:c,shapeId:p,width:w,height:S})),true)},setShapeRect(c,p,w){return m(()=>n.setShapeRectJson(JSON.stringify({slideId:c,shapeId:p,rect:w})),true)},canUndo(){return C(()=>n.canUndo())},canRedo(){return C(()=>n.canRedo())},undoCaptureMode(){return C(()=>n.undoCaptureMode())},setUndoCaptureMode(c){C(()=>n.setUndoCaptureMode(c));},addUndoBoundary(){C(()=>n.addUndoBoundary());},undo(){return m(()=>n.undoJson(),true)},undoProfiled(){return m(()=>n.undoProfiledJson(),true)},redo(){return m(()=>n.redoJson(),true)},encodeStateVector(){return C(()=>n.encodeStateVector())},encodeStateAsUpdate(c){return C(()=>c===void 0?n.encodeStateAsUpdate():n.encodeDiff(c))},encodeDiff(c){return C(()=>n.encodeDiff(c))},applyUpdate(c){return m(()=>n.applyUpdateJson(c),true)},onUpdate(c){if(E(),typeof c!="function")throw new TypeError("update listener must be a function");let p=d++;i.set(p,c);try{V();}catch(S){throw i.delete(p),S}let w=true;return ()=>{w&&(w=false,i.delete(p),j());}},dispose(){if(s)return;s=true,i.clear(),l.length=0;let c;if(u){try{n.clearUpdateObservation();}catch(p){c=p;}u=false;}try{o.free();}catch(p){c??(c=p);}try{n.free();}catch(p){c??(c=p);}if(c!==void 0)throw H(c)}}}function J(t){return JSON.stringify(t,(e,r)=>{if(typeof r=="number"&&!Number.isFinite(r))throw new RangeError("host requests must not contain NaN or infinite numbers");return r})}function ae(t,e,r=false){try{return (r?t.registerFallbackFont:t.registerFont).call(t,e.family,e.bold??!1,e.italic??!1,e.bytes)}catch(n){throw H(n)}}function de(){if(!Se)throw new Error("pptx wasm is not initialized; call initWasm() first")}function Cr(){let t=globalThis.crypto;if(!t||typeof t.getRandomValues!="function")throw new Error("crypto.getRandomValues is required to generate a collaboration client ID");let e=new Uint32Array(2),r;do t.getRandomValues(e),r=(e[0]&2097151)*4294967296+e[1];while(r===0);return r}function Ce(t){try{return t()}catch(e){throw H(e)}}function at(t){try{return JSON.parse(t())}catch(e){throw H(e)}}function Er(t){return at(t)}function H(t){if(t instanceof Error)return t;if(typeof t=="string")try{let e=JSON.parse(t);if(e.code==="staleProposal"&&Array.isArray(e.targets)&&e.targets.every(r=>typeof r=="string"))return new Z(e.targets)}catch{}return new Error(typeof t=="string"?t:String(t))}var Ir=33554432,dt="image/svg+xml",Ar=4194304;function ct(t){if(Ye(t)){if(t.byteLength>33554432)throw new Error("TIFF image exceeds the browser transfer budget");return new Blob([st(t).slice()],{type:"image/png"})}let e=Or(t)??Mr(t);return e?new Blob([e],{type:"image/bmp"}):Ur(t)??new Blob([t.slice()])}function pt(t){return t.type===dt}async function Rr(t,e){let r=ct(t);if(typeof createImageBitmap=="function"&&!pt(r))return createImageBitmap(r);let n=URL.createObjectURL(r);try{return await new Promise((o,i)=>{let l=new Image;l.onload=()=>o(l),l.onerror=()=>i(new Error(e)),l.src=n;})}finally{URL.revokeObjectURL(n);}}function Ur(t){if(t.byteLength>Ar)return;let e;try{e=new TextDecoder("utf-8",{fatal:!0}).decode(t).replace(/^\ufeff/,"");}catch{return}if(!(!/^\s*</.test(e)||!e.slice(0,1024).includes("<svg")))return new Blob([kr(e)],{type:dt})}function kr(t){let e=Jr(t);if(!e||/\s(?:width|height)\s*=/.test(t.slice(e.start,e.end)))return t;let r=t.slice(e.start,e.end).match(/\sviewBox\s*=\s*(["'])\s*[-+.\deE]+[\s,]+[-+.\deE]+[\s,]+([-+.\deE]+)[\s,]+([-+.\deE]+)\s*\1/),[n,o]=[Number(r?.[2]),Number(r?.[3])];if(!(n>0)||!(o>0))return t;let i=e.start+4;return `${t.slice(0,i)} width="${n}" height="${o}"${t.slice(i)}`}function Jr(t){let e=0;for(;e<t.length;){if(/\s/.test(t[e]))e+=1;else if(t.startsWith("<!--",e))e=te(t.indexOf("-->",e+4),3);else if(t.startsWith("<?",e))e=te(t.indexOf("?>",e+2),2);else if(t.startsWith("<!",e))e=te(lt(t,e+2),1);else break;if(e<0)return}if(!/^<svg[\s/>]/.test(t.slice(e,e+5)))return;let r=lt(t,e+4);return r<0?void 0:{start:e,end:r}}function te(t,e){return t<0?-1:t+e}function lt(t,e){let r="",n=false;for(let o=e;o<t.length;o+=1){let i=t[o];if(r)i===r&&(r="");else if(n&&t.startsWith("<!--",o)){if(o=te(t.indexOf("-->",o+4),2),o<0)return -1}else if(n&&t.startsWith("<?",o)){if(o=te(t.indexOf("?>",o+2),1),o<0)return -1}else if(i==='"'||i==="'")r=i;else if(i==="[")n=true;else if(i==="]")n=false;else if(i===">"&&!n)return o}return -1}function Mr(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(e.byteLength<108||e.getUint32(0,true)!==1||e.getUint32(40,true)!==1179469088)return;let r=e.getUint32(4,true);if(r<88||r%4||r>e.byteLength-8)return;let n=e.getInt32(16,true)-e.getInt32(8,true)+1,o=e.getInt32(20,true)-e.getInt32(12,true)+1,i=e.getUint32(r+4,true);if(e.getUint32(r,true)!==81||i<80||i>e.byteLength-r-8)return;let l=x=>e.getInt32(r+x,true),d=e.getUint32(r+48,true),s=e.getUint32(r+56,true),u=e.getUint32(r+60,true);if(l(24)!==e.getInt32(8,true)||l(28)!==e.getInt32(12,true)||l(72)!==n||l(76)!==o||l(32)!==0||l(36)!==0||l(40)!==n||l(44)!==o||e.getUint32(r+64,true)!==0||e.getUint32(r+68,true)!==13369376||d<80||d+e.getUint32(r+52,true)!==s||s+u!==i)return;let f=r+i;if(!(e.getUint32(f,true)!==14||e.getUint32(f+4,true)!==e.byteLength-f))return ut(t.subarray(r+d,f),n,o)}function Or(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(e.byteLength<18)return;let r=e.getUint32(0,true)===2596720087?22:0;if(e.byteLength<r+18||![1,2].includes(e.getUint16(r,true))||e.getUint16(r+2,true)!==9||e.getUint16(r+4,true)!==768||e.getUint32(r+6,true)*2!==e.byteLength-r)return;let n=0,o=0,i=0,l=0,d=false,s;for(let u=r+18;u+6<=e.byteLength;){let f=e.getUint32(u,true)*2,x=e.getUint16(u+4,true);if(f<6||f>e.byteLength-u)return;if(x===0)return f===6&&u+f===e.byteLength?s:void 0;if(s)return;if(x===259){if(f<8||e.getUint16(u+6,true)!==8)return;d=true;}else if(x===263){if(f<8||![1,2,3,4].includes(e.getUint16(u+6,true)))return}else if(x===523||x===524){if(f!==10)return;let E=e.getInt16(u+6,true),T=e.getInt16(u+8,true);if(x===523)n=T,o=E;else {if(!d)return;i=T,l=E;}}else if(x===2881){if(f<66||e.getUint32(u+6,true)!==13369376||e.getInt16(u+14,true)!==0||e.getInt16(u+16,true)!==0||e.getInt16(u+18,true)!==l||e.getInt16(u+20,true)!==i||e.getInt16(u+22,true)!==o||e.getInt16(u+24,true)!==n||!i||!l||(s=ut(t.subarray(u+26,u+f),e.getInt16(u+12,true),e.getInt16(u+10,true)),!s))return}else return;u+=f;}}function ut(t,e,r){if(t.length<40)return;let n=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n.getInt32(4,true),i=n.getInt32(8,true),l=n.getUint16(14,true);if(n.getUint32(0,true)!==40||o<1||!i||o*Math.abs(i)>Ir||e!==o||r!==Math.abs(i)||n.getUint16(12,true)!==1||![24,32].includes(l)||n.getUint32(16,true)!==0||n.getUint32(32,true)!==0)return;let d=Math.ceil(o*l/32)*4*Math.abs(i),s=n.getUint32(20,true);if(40+d!==t.length||s!==0&&s!==d)return;let u=new Uint8Array(14+t.length),f=new DataView(u.buffer);return f.setUint16(0,19778,true),f.setUint32(2,u.length,true),f.setUint32(10,54,true),u.set(t,14),u}async function Fr(t,e={}){let{scale:r=1,resolveImage:n}=e;if(!Number.isFinite(r)||r<=0)throw new Error("scale must be finite and positive");let o=Lr(t,r),i=o.getContext("2d");if(!i)throw new Error("2d canvas context unavailable");return await ye(i,t,1,r,{resolveImage:n}),Nr(o)}function Lr(t,e){if(typeof OffscreenCanvas=="function"){let{width:n,height:o}=me(t,1,e);return new OffscreenCanvas(n,o)}if(typeof document>"u")throw new Error("no canvas backend in this environment");let r=document.createElement("canvas");return be(r,t,1,e),r}function Nr(t){return "convertToBlob"in t?t.convertToBlob({type:"image/png"}):new Promise((e,r)=>{t.toBlob(n=>{n?e(n):r(new Error("canvas produced no png"));},"image/png");})}var ht=3e3;var ft=["#B3261E","#7B1FA2","#3949AB","#00796B","#2E7D32","#A84400","#C2185B","#00695C"],Dr=/^#[0-9a-fA-F]+$/;function Te(t){return ft[Math.abs(t)%ft.length]}function Ie(t,e){return typeof e=="string"&&(e.length===4||e.length===7)&&Dr.test(e)?e:Te(t)}function _t(t,e){if(e&&(typeof e.name!="string"||e.name.trim().length===0))throw new TypeError("Collaboration user name must be a non-empty string");if(e?.color!==void 0&&typeof e.color!="string")throw new TypeError("Collaboration user color must be a string");let r=e?.name.trim().slice(0,1024)||`Guest ${t.toString(36).toUpperCase()}`,n=Ie(t,e?.color);return {name:r,color:n}}function Ae(t,e){return t?.slideId===e?.slideId&&t?.shapeId===e?.shapeId}var ce=class{constructor(e,r={}){y(this,"localClientId",e);y(this,"states",new Map);y(this,"clocks",new Map);y(this,"maxTrackedIds");if(this.maxTrackedIds=r.maxTrackedIds??4096,!Number.isSafeInteger(this.maxTrackedIds)||this.maxTrackedIds<1)throw new RangeError("Presence tracked id limit must be a positive integer")}get peers(){return [...this.states.values()].sort((e,r)=>e.state.clientId-r.state.clientId).map(Br)}get trackedIdCount(){return this.clocks.size}get nextExpiryAt(){let e;for(let r of this.states.values()){let n=r.lastSeen+45e3;e=e===void 0?n:Math.min(e,n);}for(let r of this.clocks.values()){let n=r.updatedAt+3e5;e=e===void 0?n:Math.min(e,n);}return e}apply(e,r){let n=this.expire(r);for(let o of e){if(o.clientId===this.localClientId)continue;let i=this.clocks.get(o.clientId);if(i&&o.clock<=i.clock)continue;if(!i&&this.clocks.size>=this.maxTrackedIds&&(n=this.evictOldest()||n),this.clocks.delete(o.clientId),this.clocks.set(o.clientId,{clock:o.clock,updatedAt:r}),!o.state){n=this.states.delete(o.clientId)||n;continue}let l=this.states.get(o.clientId),d=l&&Ae(l.state.cursor,o.state.cursor)?l.cursorMovedAt:r;this.states.set(o.clientId,{state:gt(o.state),lastSeen:r,cursorMovedAt:d}),n=true;}return n}expire(e,r=45e3){let n=false;for(let[o,i]of this.states)e-i.lastSeen<r||(this.states.delete(o),n=true);for(let[o,i]of this.clocks)e-i.updatedAt<3e5||(this.clocks.delete(o),n=this.states.delete(o)||n);return n}clear(){let e=this.states.size>0;return this.states.clear(),this.clocks.clear(),e}evictOldest(){let e=this.clocks.keys().next();return e.done?false:(this.clocks.delete(e.value),this.states.delete(e.value))}};function gt(t){return {clientId:t.clientId,clock:t.clock,user:{...t.user},cursor:t.cursor?{...t.cursor}:null}}function Br(t){return {state:gt(t.state),lastSeen:t.lastSeen,cursorMovedAt:t.cursorMovedAt}}var M=16777216,$=4096,bt=0,yt=1,jr=2,wt=3,xt=0,Pt=1,St=2,Wr=0,Xr=Number.MAX_SAFE_INTEGER,P=class extends Error{constructor(e){super(e),this.name="ProtocolError";}},pe=class{constructor(e){y(this,"bytes",e);y(this,"offset",0);}get done(){return this.offset===this.bytes.byteLength}readVarUint(){let e=0,r=1,n=0;for(;;){if(this.offset>=this.bytes.byteLength)throw new P("Truncated varUint");let o=this.bytes[this.offset++],i=o&127;if(i>Math.floor((Xr-e)/r))throw new P("varUint exceeds Number.MAX_SAFE_INTEGER");if(e+=i*r,n+=1,(o&128)===0){if(n>1&&i===0)throw new P("Non-canonical varUint");return e}if(n>=8)throw new P("varUint exceeds Number.MAX_SAFE_INTEGER");r*=128;}}readVarUint8Array(){let e=this.readVarUint(),r=this.bytes.byteLength-this.offset;if(e>r)throw new P("Truncated varUint8Array");let n=this.bytes.slice(this.offset,this.offset+e);return this.offset+=e,n}readVarString(){let e=this.readVarUint8Array();try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(r){throw new P(`Invalid UTF-8 string${r instanceof Error?`: ${r.message}`:""}`)}}};function U(t){if(!Number.isSafeInteger(t)||t<0)throw new P("varUint value must be a non-negative safe integer");let e=[],r=t;for(;r>=128;)e.push(r%128|128),r=Math.floor(r/128);return e.push(r),Uint8Array.from(e)}function Hr(t){let e=new TextEncoder().encode(t);return re([U(e.byteLength),e],M)}function re(t,e){let r=0;for(let i of t)if(r+=i.byteLength,r>e)throw new P(`Frame exceeds ${e} bytes`);let n=new Uint8Array(r),o=0;for(let i of t)n.set(i,o),o+=i.byteLength;return n}function ke(t,e,r){return re([U(bt),U(t),U(e.byteLength),e],r)}function vt(t,e=M){return ke(xt,t,e)}function Ct(t,e=M){return ke(Pt,t,e)}function Et(t,e=M){return ke(St,t,e)}function Tt(t,e=M){if(t.length>$)throw new P(`Awareness update exceeds ${$} entries`);let r=[U(t.length)];for(let o of t){kt(o);let i=JSON.stringify(o.state);if(i===void 0)throw new P("Awareness state is not JSON serializable");r.push(U(o.clientId),U(o.clock),Hr(i));}let n=re(r,e);return re([U(yt),U(n.byteLength),n],e)}function It(t=M){return re([U(wt)],t)}function At(t,e=$){if(!(t instanceof Uint8Array))throw new P("Awareness update must be a Uint8Array");if(!Number.isSafeInteger(e)||e<1)throw new P("Awareness entry limit must be a positive integer");let r=new pe(t),n=r.readVarUint();if(n>e)throw new P(`Awareness update exceeds ${e} entries`);let o=[];for(let i=0;i<n;i+=1){let l=r.readVarUint(),d=r.readVarUint(),s;try{s=JSON.parse(r.readVarString());}catch(f){throw f instanceof P?f:new P(`Invalid awareness JSON${f instanceof Error?`: ${f.message}`:""}`)}let u={clientId:l,clock:d,state:Ut(s,l,d)};kt(u),o.push(u);}if(!r.done)throw new P("Awareness update has trailing bytes");return o}function Rt(t,e=M,r=$){if(!(t instanceof Uint8Array))throw new P("Frame must be a Uint8Array");if(t.byteLength===0)throw new P("Frame is empty");if(t.byteLength>e)throw new P(`Frame exceeds ${e} bytes`);if(!Number.isSafeInteger(r)||r<1)throw new P("Message limit must be a positive integer");let n=new pe(t),o=[];for(;!n.done;){if(o.length>=r)throw new P(`Frame exceeds ${r} messages`);let i=n.readVarUint();switch(i){case bt:{let l=n.readVarUint(),d=n.readVarUint8Array();if(l===xt)o.push({type:"sync-step-1",stateVector:d});else if(l===Pt)o.push({type:"sync-step-2",update:d});else if(l===St)o.push({type:"update",update:d});else throw new P(`Unknown sync message type ${l}`);break}case yt:o.push({type:"awareness",update:n.readVarUint8Array()});break;case jr:{let l=n.readVarUint();if(l!==Wr)throw new P(`Unknown auth message type ${l}`);o.push({type:"auth",reason:n.readVarString()});break}case wt:o.push({type:"query-awareness"});break;default:throw new P(`Unknown top-level message type ${i}`)}}return o}function Ut(t,e,r){if(t===null)return null;if(!Ue(t))throw new P("Awareness state must be an object or null");if(t.clientId!==e||t.clock!==r)throw new P("Awareness state identity does not match its entry");if(!Ue(t.user))throw new P("Awareness user must be an object");let n=Re(t.user.name,"Awareness user name"),o=Ie(e,t.user.color);return {clientId:e,clock:r,user:{name:n,color:o},cursor:qr(t.cursor)}}function qr(t){if(t==null)return null;if(!Ue(t))throw new P("Awareness cursor must be an object or null");let e=Re(t.slideId,"Awareness slideId"),r=t.shapeId===void 0?void 0:Re(t.shapeId,"Awareness shapeId");return r?{slideId:e,shapeId:r}:{slideId:e}}function kt(t){mt(t.clientId,"Awareness clientId"),mt(t.clock,"Awareness clock"),t.state!==null&&Ut(t.state,t.clientId,t.clock);}function mt(t,e){if(!Number.isSafeInteger(t)||t<0)throw new P(`${e} must be a non-negative safe integer`)}function Re(t,e){if(typeof t!="string"||t.length===0||t.length>1024)throw new P(`${e} must be between 1 and ${1024} characters`);return t}function Ue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var I=class extends Error{constructor(r,n,o){super(n);y(this,"code");y(this,"cause");this.name="CollaborationError",this.code=r,this.cause=o;}};var Gr=16*1024*1024,Je=new TextEncoder().encode("\0betteroffice-document-fingerprint-v1\0");function Me(t,e,r){if(!Number.isSafeInteger(e)||e<(r?0:1))throw new RangeError(`${t} must be ${r?"a non-negative":"a positive"} integer`);return e}function Yr(t){return t instanceof Error&&t.message?t.message:typeof t=="string"&&t?t:"Unknown error"}function v(t,e,r){return r instanceof I?r:new I(t,`${e}: ${Yr(r)}`,r)}function Oe(t,e){if(!(t instanceof Uint8Array))throw new TypeError(`${e} must return a Uint8Array`);return t.slice()}function Jt(t){let e=Je.byteLength+32,r=t.byteLength-e;if(r<0)return t;for(let n=0;n<Je.byteLength;n+=1)if(t[r+n]!==Je[n])return t;return t.subarray(0,r)}function Fe(t){typeof t=="object"&&t&&"unref"in t&&t.unref();}function Kr(t){if(!Number.isSafeInteger(t)||t<0)throw new RangeError("Replica clientId must be a non-negative safe integer");return t}function Zr(t){if(t===null)return null;if(!t||typeof t.slideId!="string"||t.slideId.length===0)throw new TypeError("Presence cursor slideId must be a non-empty string");if(t.shapeId!==void 0&&(typeof t.shapeId!="string"||t.shapeId.length===0))throw new TypeError("Presence cursor shapeId must be a non-empty string");return t.shapeId?{slideId:t.slideId,shapeId:t.shapeId}:{slideId:t.slideId}}function Qr(t){return t.slideId.length<=1024&&(t.shapeId===void 0||t.shapeId.length<=1024)}var ue=class{constructor(e,r,n={}){y(this,"replica");y(this,"transport");y(this,"maxFrameBytes");y(this,"maxMessagesPerFrame");y(this,"maxPendingBytes");y(this,"localClientId");y(this,"localUser");y(this,"remotePresence");y(this,"statusListeners",new Map);y(this,"errorListeners",new Map);y(this,"presenceListeners",new Map);y(this,"pendingFrames",[]);y(this,"unsubscribeReplica");y(this,"unsubscribeTransport",()=>{});y(this,"hasTransportSubscription",false);y(this,"connectionStatus","disconnected");y(this,"isSynced",false);y(this,"wantsConnection",false);y(this,"isOpen",false);y(this,"isDestroyed",false);y(this,"epoch",0);y(this,"connectAttempt",0);y(this,"nextListenerId",0);y(this,"queuedBytes",0);y(this,"isFlushing",false);y(this,"localClock",0);y(this,"reportedClockExhaustion",false);y(this,"localCursor",null);y(this,"lastAwarenessSentAt",0);y(this,"cursorTimer",null);y(this,"heartbeatTimer",null);y(this,"expiryTimer",null);this.replica=e,this.transport=r,this.localClientId=Kr(e.clientId),this.localUser=_t(this.localClientId,n.user),this.remotePresence=new ce(this.localClientId),this.maxFrameBytes=Me("maxFrameBytes",n.maxFrameBytes??M,false),this.maxMessagesPerFrame=Me("maxMessagesPerFrame",n.maxMessagesPerFrame??$,false),this.maxPendingBytes=Me("maxPendingBytes",n.maxPendingBytes??Gr,true);try{this.unsubscribeReplica=e.onUpdate((o,i)=>{i==="local"&&this.forwardLocalUpdate(o);});}catch(o){throw v("replica","Failed to observe replica updates",o)}}get status(){return this.connectionStatus}get synced(){return this.isSynced}get pendingBytes(){return this.queuedBytes}get peers(){return this.remotePresence.peers}setCursor(e){if(this.isDestroyed)return;let r=Zr(e),n=!r||Qr(r)?r:null;r&&!n&&this.report(new I("protocol",`Presence cursor identifiers exceed ${1024} characters; cursor dropped`)),!Ae(this.localCursor,n)&&(this.localCursor=n,this.isOpen&&this.wantsConnection&&this.scheduleCursorBroadcast());}connect(){if(this.isDestroyed||this.isOpen||this.connectionStatus==="connecting")return;this.wantsConnection=true;let e=this.hasTransportSubscription?this.epoch:++this.epoch,r=++this.connectAttempt;if(this.setStatus("connecting",false),!!this.isCurrent(e)){if(!this.hasTransportSubscription){let n;try{if(n=this.transport.onEvent(o=>this.handleTransportEvent(e,o)),typeof n!="function")throw new TypeError("Transport event subscription must return a function")}catch(o){this.failConnection(e,v("transport","Failed to subscribe to transport events",o));return}if(!this.isCurrent(e)){try{n();}catch(o){this.isDestroyed||this.report(v("transport","Failed to unsubscribe from stale transport events",o));}return}this.unsubscribeTransport=n,this.hasTransportSubscription=true;}try{let n=this.transport.connect();n&&n.catch(o=>{this.isCurrent(e)&&this.connectAttempt===r&&this.failConnection(e,v("transport","Transport connect failed",o));});}catch(n){this.failConnection(e,v("transport","Transport connect failed",n));}}}disconnect(){if(this.isDestroyed||!(this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus!=="disconnected"))return;if(this.isOpen&&this.wantsConnection){let o=this.epoch;if(this.broadcastLocalPresence(true),!this.isCurrent(o))return}this.stopPresenceTimers(),this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let r=this.takeTransportSubscription();this.clearPending(),this.clearRemotePresence();let n=this.cleanupTransport(r,true);this.setStatus("disconnected",false);for(let o of n)this.report(o);}destroy(){if(this.isDestroyed||(this.isOpen&&this.wantsConnection&&this.broadcastLocalPresence(true),this.isDestroyed))return;let e=this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus==="connecting"||this.connectionStatus==="connected";this.stopPresenceTimers(),this.isDestroyed=true,this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let r=this.takeTransportSubscription();this.clearPending(),this.clearRemotePresence();let n=this.cleanupTransport(r,e);this.setStatus("destroyed",false);for(let o of n)this.report(o);try{this.unsubscribeReplica();}catch(o){this.report(v("replica","Failed to unsubscribe from replica updates",o));}this.unsubscribeReplica=()=>{},this.statusListeners.clear(),this.errorListeners.clear(),this.presenceListeners.clear();}onStatus(e){if(this.isDestroyed)return ()=>{};if(typeof e!="function")throw new TypeError("status listener must be a function");let r=this.nextListenerId++;return this.statusListeners.set(r,e),()=>this.statusListeners.delete(r)}onError(e){if(this.isDestroyed)return ()=>{};if(typeof e!="function")throw new TypeError("error listener must be a function");let r=this.nextListenerId++;return this.errorListeners.set(r,e),()=>this.errorListeners.delete(r)}onPresence(e){if(this.isDestroyed)return ()=>{};if(typeof e!="function")throw new TypeError("presence listener must be a function");let r=this.nextListenerId++;this.presenceListeners.set(r,e);try{e(this.peers);}catch{}return ()=>this.presenceListeners.delete(r)}isCurrent(e){return !this.isDestroyed&&this.wantsConnection&&e===this.epoch}failConnection(e,r){if(!this.isCurrent(e))return;this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1,this.stopPresenceTimers();let n=this.takeTransportSubscription();this.clearPending(),this.clearRemotePresence();let o=this.cleanupTransport(n,true);this.setStatus("disconnected",false),this.report(r);for(let i of o)this.report(i);}takeTransportSubscription(){let e=this.unsubscribeTransport;return this.unsubscribeTransport=()=>{},this.hasTransportSubscription=false,e}cleanupTransport(e,r){let n=[];try{e();}catch(o){n.push(v("transport","Failed to unsubscribe from transport events",o));}if(!r)return n;try{let o=this.transport.disconnect();o&&o.catch(i=>{this.isDestroyed||this.report(v("transport","Transport disconnect failed",i));});}catch(o){n.push(v("transport","Transport disconnect failed",o));}return n}handleTransportEvent(e,r){if(this.isCurrent(e))switch(r.type){case "open":this.handleOpen(e);break;case "message":this.isOpen&&this.handleMessage(e,r.data);break;case "close":this.isOpen=false,this.connectAttempt+=1,this.stopPresenceTimers(),this.clearPending(),this.clearRemotePresence(),this.setStatus("disconnected",false);break;case "error":this.failConnection(e,v("transport","Transport error",r.error));break;case "drain":this.isOpen&&this.flushPending();break;default:this.failConnection(e,new I("transport","Unknown transport event"));}}handleOpen(e){if(this.isOpen||(this.isOpen=true,this.clearPending(),this.setStatus("connected",false),!this.isCurrent(e)||!this.isOpen))return;let r;try{r=Oe(this.replica.encodeStateVector(),"encodeStateVector");}catch(n){this.failConnection(e,v("replica","Failed to encode replica state vector",n));return}try{this.sendFrame(vt(r,this.maxFrameBytes));}catch(n){this.failConnection(e,v("protocol","Failed to encode SyncStep1",n));return}if(!(!this.isCurrent(e)||!this.isOpen)&&(this.startPresenceTimers(),this.broadcastLocalPresence(false),!(!this.isCurrent(e)||!this.isOpen)))try{this.sendFrame(It(this.maxFrameBytes));}catch(n){this.report(v("protocol","Failed to encode awareness query",n));}}handleMessage(e,r){let n;try{n=Rt(r.slice(),this.maxFrameBytes,this.maxMessagesPerFrame);}catch(o){this.failConnection(e,v("protocol","Invalid collaboration frame",o));return}for(let o of n){if(!this.isCurrent(e)||!this.isOpen)return;switch(o.type){case "sync-step-1":this.respondToSyncStep1(e,o.stateVector);break;case "sync-step-2":this.applyRemoteUpdate(e,o.update)&&this.isCurrent(e)&&this.setStatus("connected",true);break;case "update":this.applyRemoteUpdate(e,o.update);break;case "awareness":{try{let i=At(o.update,this.maxMessagesPerFrame);this.remotePresence.apply(i,Date.now())&&this.emitPresence(),this.schedulePresenceExpiry();}catch(i){this.report(v("protocol","Invalid awareness update",i));}break}case "auth":this.failConnection(e,new I("protocol",o.reason?`Authentication denied: ${o.reason}`:"Authentication denied"));return;case "query-awareness":this.broadcastLocalPresence(false);break}}}respondToSyncStep1(e,r){let n;try{n=Oe(this.replica.encodeStateAsUpdate(Jt(r).slice()),"encodeStateAsUpdate");}catch(o){this.failConnection(e,v("replica","Failed to encode replica update",o));return}try{this.sendFrame(Ct(n,this.maxFrameBytes));}catch(o){this.failConnection(e,v("protocol","Failed to encode SyncStep2",o));}}applyRemoteUpdate(e,r){try{return this.replica.applyUpdate(Jt(r).slice()),!0}catch(n){return this.failConnection(e,v("replica","Failed to apply remote update",n)),false}}forwardLocalUpdate(e){if(this.isDestroyed||!this.isOpen||!this.wantsConnection)return;let r=this.epoch,n;try{n=Oe(e,"Replica update");}catch(o){this.failConnection(r,v("replica","Invalid replica update",o));return}try{this.sendFrame(Et(n,this.maxFrameBytes));}catch(o){this.failConnection(r,v("protocol","Failed to encode update",o));}}scheduleCursorBroadcast(){if(this.cursorTimer)return;let e=Math.max(0,80-(Date.now()-this.lastAwarenessSentAt));if(e===0){this.broadcastLocalPresence(false);return}this.cursorTimer=setTimeout(()=>{this.cursorTimer=null,this.broadcastLocalPresence(false);},e),Fe(this.cursorTimer);}broadcastLocalPresence(e){if(!this.isOpen||this.isDestroyed||!this.wantsConnection)return;if(this.localClock>=Number.MAX_SAFE_INTEGER){this.reportedClockExhaustion||(this.reportedClockExhaustion=true,this.report(new I("protocol","Awareness clock exceeds Number.MAX_SAFE_INTEGER")));return}this.localClock+=1;let r=this.localClock,n=e?null:{clientId:this.localClientId,clock:r,user:{...this.localUser},cursor:this.localCursor?{...this.localCursor}:null};this.cursorTimer&&clearTimeout(this.cursorTimer),this.cursorTimer=null,this.lastAwarenessSentAt=Date.now();try{let o=Tt([{clientId:this.localClientId,clock:r,state:n}],this.maxFrameBytes);e?this.sendLeaveFrameBestEffort(o):this.sendFrame(o);}catch(o){this.report(v("protocol","Failed to encode awareness update",o));}}sendLeaveFrameBestEffort(e){try{this.transport.send(e.slice());}catch{}}startPresenceTimers(){this.stopPresenceTimers(),this.heartbeatTimer=setInterval(()=>{this.broadcastLocalPresence(false);},2e4),Fe(this.heartbeatTimer),this.schedulePresenceExpiry();}stopPresenceTimers(){this.cursorTimer&&clearTimeout(this.cursorTimer),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.expiryTimer&&clearTimeout(this.expiryTimer),this.cursorTimer=null,this.heartbeatTimer=null,this.expiryTimer=null;}schedulePresenceExpiry(){if(this.expiryTimer&&clearTimeout(this.expiryTimer),this.expiryTimer=null,!this.isOpen||this.isDestroyed)return;let e=this.remotePresence.nextExpiryAt;e!==void 0&&(this.expiryTimer=setTimeout(()=>{this.expiryTimer=null,this.remotePresence.expire(Date.now())&&this.emitPresence(),this.schedulePresenceExpiry();},Math.max(0,e-Date.now())),Fe(this.expiryTimer));}clearRemotePresence(){this.remotePresence.clear()&&this.emitPresence();}emitPresence(){let e=this.peers;for(let[r,n]of [...this.presenceListeners])if(this.presenceListeners.get(r)===n)try{n(e);}catch{}}sendFrame(e){if(!this.isOpen||this.isDestroyed||!this.wantsConnection)return;let r=this.epoch;if(this.pendingFrames.length>0){this.queueFrame(r,e);return}let n;try{n=this.transport.send(e.slice());}catch(o){this.failConnection(r,v("transport","Transport send failed",o));return}if(typeof n!="boolean"){this.failConnection(r,new I("transport","Transport send must return a boolean"));return}!n&&this.isCurrent(r)&&this.isOpen&&this.queueFrame(r,e);}queueFrame(e,r){if(r.byteLength>this.maxPendingBytes-this.queuedBytes){this.failConnection(e,new I("backpressure",`Pending collaboration data exceeds ${this.maxPendingBytes} bytes`));return}let n=r.slice();this.pendingFrames.push(n),this.queuedBytes+=n.byteLength;}flushPending(){if(!this.isFlushing){this.isFlushing=true;try{for(;this.isOpen&&!this.isDestroyed&&this.pendingFrames.length>0;){let e=this.epoch,r=this.pendingFrames[0],n;try{n=this.transport.send(r.slice());}catch(o){this.failConnection(e,v("transport","Transport send failed",o));return}if(typeof n!="boolean"){this.failConnection(e,new I("transport","Transport send must return a boolean"));return}if(!n||!this.isOpen||this.pendingFrames[0]!==r)return;this.pendingFrames.shift(),this.queuedBytes-=r.byteLength;}}finally{this.isFlushing=false;}}}clearPending(){this.pendingFrames.length=0,this.queuedBytes=0;}setStatus(e,r){if(this.connectionStatus===e&&this.isSynced===r)return;this.connectionStatus=e,this.isSynced=r;let n={status:e,synced:r};for(let[o,i]of [...this.statusListeners])if(this.statusListeners.get(o)===i)try{i(n);}catch{}}report(e){for(let[r,n]of [...this.errorListeners])if(this.errorListeners.get(r)===n)try{n(e);}catch{}}};export{I as CollaborationError,ue as CollaborationProvider,ht as PRESENCE_LABEL_DURATION_MS,Q as PptxExportError,Z as StaleProposalError,Rr as decodePresentationImage,Pr as exportPptxMarkdown,xr as exportPptxStructured,le as initWasm,wr as inspectPresentation,ve as isProposalsAvailable,br as isWasmAvailable,pt as needsElementDecode,vr as openPresentation,ye as paintSlide,Te as presenceColorForClientId,ct as presentationImageBlob,Sr as renderPptxMarkdown,be as sizeCanvasForSlide,Fr as slideToPng,yr as wasmVersion};
|
|
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};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire format between a main-thread collaboration facade and the provider its document worker runs.
|
|
3
|
+
* Main owns the host transport's lifecycle and forwards its bytes untouched; the worker runs the protocol and
|
|
4
|
+
* answers with frames to send, state and the transport calls its own failures need.
|
|
5
|
+
*/
|
|
6
|
+
type PipeErrorCode = 'backpressure' | 'protocol' | 'replica' | 'transport';
|
|
7
|
+
interface PipeError {
|
|
8
|
+
code: PipeErrorCode;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
interface PipeUser {
|
|
12
|
+
name: string;
|
|
13
|
+
color?: string;
|
|
14
|
+
}
|
|
15
|
+
interface PipeProviderOptions {
|
|
16
|
+
maxFrameBytes?: number;
|
|
17
|
+
maxMessagesPerFrame?: number;
|
|
18
|
+
syncChunkBytes?: number;
|
|
19
|
+
maxSyncBytes?: number;
|
|
20
|
+
user?: PipeUser;
|
|
21
|
+
}
|
|
22
|
+
/** The docx cursor; the default cursor type `C` of the pipe types. */
|
|
23
|
+
interface PipeCursor {
|
|
24
|
+
story: string;
|
|
25
|
+
anchor: Uint8Array;
|
|
26
|
+
head: Uint8Array;
|
|
27
|
+
}
|
|
28
|
+
type PipeTransportEvent = {
|
|
29
|
+
type: 'open';
|
|
30
|
+
} | {
|
|
31
|
+
type: 'message';
|
|
32
|
+
data: ArrayBuffer;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'close';
|
|
35
|
+
reason?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Main to worker, in order; `seq` increases. `connect`, `disconnect`, `destroy` and `fail` replay what main already
|
|
39
|
+
* did to the host transport, so the worker sends nothing and asks for no transport call while it runs them.
|
|
40
|
+
*/
|
|
41
|
+
type PipeOp<C = PipeCursor> = {
|
|
42
|
+
op: 'create';
|
|
43
|
+
seq: number;
|
|
44
|
+
options: PipeProviderOptions;
|
|
45
|
+
} | {
|
|
46
|
+
op: 'connect';
|
|
47
|
+
seq: number;
|
|
48
|
+
} | {
|
|
49
|
+
op: 'disconnect';
|
|
50
|
+
seq: number;
|
|
51
|
+
} | {
|
|
52
|
+
op: 'destroy';
|
|
53
|
+
seq: number;
|
|
54
|
+
} | {
|
|
55
|
+
op: 'fail';
|
|
56
|
+
seq: number;
|
|
57
|
+
error: PipeError;
|
|
58
|
+
} | {
|
|
59
|
+
op: 'cursor';
|
|
60
|
+
seq: number;
|
|
61
|
+
cursor: C | null;
|
|
62
|
+
broadcast: boolean;
|
|
63
|
+
} | {
|
|
64
|
+
op: 'event';
|
|
65
|
+
seq: number;
|
|
66
|
+
event: PipeTransportEvent;
|
|
67
|
+
};
|
|
68
|
+
/** The docx peer; the default peer type `P` of the pipe types. */
|
|
69
|
+
interface PipePeer {
|
|
70
|
+
clientId: number;
|
|
71
|
+
clock: number;
|
|
72
|
+
user: {
|
|
73
|
+
name: string;
|
|
74
|
+
color: string;
|
|
75
|
+
};
|
|
76
|
+
cursor: PipeCursor | null;
|
|
77
|
+
lastSeenAt: number;
|
|
78
|
+
cursorMovedAt: number;
|
|
79
|
+
inferredCursor: {
|
|
80
|
+
clientId: number;
|
|
81
|
+
story: string;
|
|
82
|
+
paraId: string;
|
|
83
|
+
endOffset: number;
|
|
84
|
+
} | null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Worker to main, in order. `through` is the last op the worker had run; main drops output older than its own
|
|
88
|
+
* latest lifecycle call.
|
|
89
|
+
*/
|
|
90
|
+
type PipeOutput<P = PipePeer> = {
|
|
91
|
+
do: 'unsubscribe';
|
|
92
|
+
through: number;
|
|
93
|
+
} | {
|
|
94
|
+
do: 'disconnect';
|
|
95
|
+
through: number;
|
|
96
|
+
} | {
|
|
97
|
+
do: 'send';
|
|
98
|
+
data: ArrayBuffer;
|
|
99
|
+
through: number;
|
|
100
|
+
}
|
|
101
|
+
/** The awareness leave main sends when the host disconnects first; null while there is none to send. */
|
|
102
|
+
| {
|
|
103
|
+
do: 'leave';
|
|
104
|
+
data: ArrayBuffer | null;
|
|
105
|
+
through: number;
|
|
106
|
+
} | {
|
|
107
|
+
do: 'status';
|
|
108
|
+
status: 'disconnected' | 'connecting' | 'connected' | 'destroyed';
|
|
109
|
+
synced: boolean;
|
|
110
|
+
through: number;
|
|
111
|
+
} | {
|
|
112
|
+
do: 'peers';
|
|
113
|
+
peers: P[];
|
|
114
|
+
timeOrigin: number;
|
|
115
|
+
through: number;
|
|
116
|
+
} | {
|
|
117
|
+
do: 'error';
|
|
118
|
+
error: PipeError;
|
|
119
|
+
through: number;
|
|
120
|
+
}
|
|
121
|
+
/** The worker has no provider under this id. */
|
|
122
|
+
| {
|
|
123
|
+
do: 'lost';
|
|
124
|
+
};
|
|
125
|
+
interface PipeOutputBatch<P = PipePeer> {
|
|
126
|
+
provider: number;
|
|
127
|
+
out: PipeOutput<P>[];
|
|
128
|
+
}
|
|
129
|
+
interface PipeCommandPayload<C = PipeCursor> {
|
|
130
|
+
provider: number;
|
|
131
|
+
ops: PipeOp<C>[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** One provider's line to the worker that runs it. */
|
|
135
|
+
interface CollaborationPipeEndpoint<C = PipeCursor> {
|
|
136
|
+
/** Runs `ops` in the worker, in order after earlier posts; settles once the worker has run them. */
|
|
137
|
+
post(ops: PipeOp<C>[], transfer: ArrayBuffer[]): Promise<unknown>;
|
|
138
|
+
close(): void;
|
|
139
|
+
}
|
|
140
|
+
/** What a worker replica offers a provider that can run in its worker. */
|
|
141
|
+
interface CollaborationPipeChannel<C = PipeCursor, P = PipePeer> {
|
|
142
|
+
/** `receive` takes the worker's output for this provider; `lost` reports the worker is gone for it. */
|
|
143
|
+
open(receive: (out: readonly PipeOutput<P>[]) => void, lost: (reason: string) => void): CollaborationPipeEndpoint<C>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export type { CollaborationPipeChannel as C, PipeCommandPayload as P, PipeOutputBatch as a };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {i,f,m,t,l as l$1,x as x$1,q as q$1,o,p,u,y,a as a$1,v,e}from'./chunk-2NCQ2IE7.js';import {P,b,T,X,K,s,N,J,H,z,A,G,B,m as m$1,Y,f as f$1,h,j,l,q,Q,a,o as o$1,p as p$1,I,k,n,M,L}from'./chunk-4FWJR3UX.js';import {c,e as e$1,d,f as f$3}from'./chunk-LIYNXEQC.js';import {x,i as i$1,f as f$2,w,a as a$2,y as y$1}from'./chunk-H3SEEI4U.js';async function gt(i){let h=await fetch(i);if(typeof WebAssembly.compileStreaming=="function")try{return await WebAssembly.compileStreaming(h.clone())}catch(f){if(!h.ok||!["basic","cors","default"].includes(h.type)||h.headers.get("Content-Type")==="application/wasm")throw f}return WebAssembly.compile(await h.arrayBuffer())}function yn(i,h,f,g=gt){let F,A=false;function L(){return F||(F=g(h),F.catch(()=>{})),F}return i.listen($=>{K($)&&$.kind==="wasm-compile"&&L();}),async $=>{if($!==void 0)return f($);let q=L(),_;try{_=await q;}catch(c){throw F===q&&(F=void 0),c}if(await f(_),!A){A=true;let c={protocol:1,kind:"wasm-module",url:h.href,module:_};try{i.post(c);}catch{}}}}var mn=["input","collab","interactive"],gn={input:0,collab:1,interactive:2,background:3},jn=8,Nn=24,Hn=1e3;function bn(i){let h={input:[],collab:[],interactive:[]},f=[],g=0,F=0,A=0,L=Number.NEGATIVE_INFINITY,$=Number.NEGATIVE_INFINITY,q=false,_=false,c=null,C=()=>i.now()-L<Hn?jn:Nn;function R(E=false){q||_||(_=true,(E?queueMicrotask:i.turn)(()=>{_=false,G();}));}function V(E){for(let S of mn)if(S!==E.lane)for(let r of h[S]){if(r.seq>E.seq)break;if(!(r.reorderable&&gn[E.lane]<gn[r.lane]))return true}return false}function x(){for(let E of mn){let S=h[E][0];if(S&&!V(S))return S}return null}function y(){let E=x();if(!E)return null;let S=[h[E.lane].shift()];if(E.lane==="collab")for(;h.collab[0]&&!V(h.collab[0]);)S.push(h.collab.shift());return S}function l(E){return E.idleAfterInputMs===void 0?Number.NEGATIVE_INFINITY:$+E.idleAfterInputMs}async function v(E){for(let S of E){S.mutates&&(F+=1),(S.mutates||S.reframes)&&(A+=1);try{await S.run();}catch(r){i.failed?.(r);}}}async function K(){let E=i.now(),S=f.findIndex(I=>l(I)<=E);if(S<0)return false;let[r]=f.splice(S,1);try{if(r.version!==F||r.generation!==A){if((r.onStale?.()??"cancel")==="cancel")return r.cancel?.(),!0;r.version=F,r.generation=A;}await r.run(C())==="yield"&&f.push(r);}catch(I){r.fail?r.fail(I):i.failed?.(I);}return true}function re(){if(c?.(),c=null,f.length===0)return;let E=Math.min(...f.map(l));c=i.timer(()=>{c=null,R();},Math.max(1,E-i.now()));}async function G(){if(q)return;q=true;let E=false;try{let r=y();r?(E=!0,await v(r)):f.length>0&&(E=await K());}catch(r){E=true,i.failed?.(r);}finally{q=false;}let S=E?x():null;S?R(!S.reorderable):E&&f.length>0?R():re();}function H(E,S){oe({kind:`${E.kind}:install`,version:E.version,generation:E.generation,onStale:()=>"cancel",cancel:()=>E.cancel?.(),fail:r=>E.cancel?.(r),run:async()=>(await E.install(S),"done")});}function oe(E){f.push(E),q||(c?.(),c=null),R();}return {submit(E){if(E.userInput&&(L=i.now()),E.holdsIdleTasks&&($=i.now()),E.key!==void 0){let S=h[E.lane];for(let r=S.length-1;r>=0;r-=1)if(S[r].replaceableBy===E.key)try{S.splice(r,1)[0].supersede?.();}catch(I){i.failed?.(I);}}h[E.lane].push({...E,seq:g++}),c?.(),c=null,R(true);},schedule:oe,dispatch(E){let S=E,r=()=>oe({kind:S.kind,version:S.version,generation:S.generation,onStale:()=>"cancel",cancel:()=>S.cancel?.(),fail:u=>S.cancel?.(u),run:async()=>(await S.install(S.compute(S.input)),"done")});if(!i.executor){r();return}let I=(S.transfer?.length??0)>0;i.executor.run({kind:S.kind,input:S.input,transfer:S.transfer}).then(u=>H(S,u),u=>I?S.cancel?.(u):r());},budget:C,get version(){return F},get generation(){return A},bump(E){E.version&&(F+=1),(E.version||E.generation)&&(A+=1);},pending(){return {foreground:h.input.length+h.collab.length+h.interactive.length,background:f.length}}}}var Bn=1e3;function bt(i){let h={name:i instanceof Error?i.name:"Error",message:i instanceof Error?i.message:String(i)};return i!==null&&typeof i=="object"&&"refusal"in i&&(h.refusal=i.refusal),h}function He(i){return i instanceof N||typeof WebAssembly<"u"&&i instanceof WebAssembly.RuntimeError}function _n(i){return i instanceof N?i:new N(He(i)?"trap":"crash",bt(i).message)}function Sn(i,h){let f,g=r=>{let I=_n(r);return I.code==="trap"?h.trapFailure?.(I)??I:I},F=false,A=()=>{},L=()=>{},$,q=0,_=new Set,c=new Set,C=()=>F||f!==void 0;function R(){A(),L();for(let r of _)clearTimeout(r);_.clear();for(let r of c)try{r.cancel();}catch{}c.clear();try{h.onDispose?.();}catch{}}function V(r){if(!C()){f=r;try{i.post({protocol:1,kind:"failure",code:r.code,message:r.message,...r.diagnostics===void 0?{}:{diagnostics:r.diagnostics}});}catch{}R();}}function x(r,I){if(!C())try{i.post(r,I);}catch(u){V(new N("message",`Session could not post a message: ${bt(u).message}`));}}function y(r,I){if(C())return ()=>{};let u=setTimeout(()=>{_.delete(u),C()||r();},I);return _.add(u),()=>{clearTimeout(u),_.delete(u);}}function l(r){let I={end(){c.delete(I);},cancel(){I.end(),r?.();}};return r&&c.add(I),I}function v(r,I){if(C())return I;let u=m=>{if(C())return I;if(!He(m))throw m;return V(g(m)),I};try{let m=r();return m instanceof Promise?m.catch(u):m}catch(m){return u(m)}}function K$1(r){let I=r.then(),u=m=>B=>{if(!C())try{return m(B)}catch(X){V(g(X));return}};return I.then=((m,B)=>Promise.prototype.then.call(I,m&&u(m),B&&u(B))),I}let re=h.executor,G$1=bn({now:Date.now,turn:r=>{y(r,0);},timer:y,executor:re&&{run(r){return K$1(re.run(r))}},failed:r=>V(g(r))}),H={schedule(r){if(C()){try{r.cancel?.();}catch{}return}let I=l(r.cancel&&(()=>r.cancel()));G$1.schedule({kind:r.kind,idleAfterInputMs:r.idleAfterInputMs,get version(){return r.version},set version(u){r.version=u;},get generation(){return r.generation},set generation(u){r.generation=u;},...r.onStale?{onStale:()=>v(()=>r.onStale(),"cancel")}:{},...r.cancel?{cancel(){return I.end(),v(()=>r.cancel(),void 0)}}:{},...r.fail?{fail(u){return I.end(),v(()=>r.fail(u),void 0)}}:{},async run(u){if(C())return "done";try{let m=await r.run(u);return m==="done"&&I.end(),C()?"done":m}catch(m){if(I.end(),C())return "done";if(He(m))return V(g(m)),"done";throw m}}});},dispatch(r){if(C()){try{r.cancel?.();}catch{}return}let I=l(r.cancel&&(()=>r.cancel()));G$1.dispatch({kind:r.kind,input:r.input,transfer:r.transfer,get version(){return r.version},set version(u){r.version=u;},get generation(){return r.generation},set generation(u){r.generation=u;},...r.cancel?{cancel(u){return I.end(),v(()=>r.cancel(u),void 0)}}:{},compute(u){return v(()=>r.compute(u),void 0)},async install(u){if(!C())try{await r.install(u);}catch(m){if(I.end(),C())return;if(He(m)){V(g(m));return}throw m}finally{I.end();}}});},bump:r=>G$1.bump(r),budget:()=>G$1.budget(),pending:()=>G$1.pending(),get version(){return G$1.version},get generation(){return G$1.generation}};function oe(r,I$1){I(I$1)?x({protocol:1,kind:"reply",id:r,ok:true,value:I$1.value},I$1.transfer):x({protocol:1,kind:"reply",id:r,ok:true,value:I$1});}function E(r,I){He(I)?V(g(I)):x({protocol:1,kind:"reply",id:r,ok:false,error:bt(I)});}async function S(r){if(!C()){$=r.id,q=Date.now();try{let I=h.handlers[r.method],u=await I(h.context,...r.args);G(u)?u.promise.then(m=>oe(r.id,m),m=>E(r.id,m)):oe(r.id,u);}catch(I){E(r.id,I);}finally{$===r.id&&($=void 0);}}}return A=i.listen(r=>{if(!C()){if(!K(r))V(new N("message","Session received a malformed client message"));else if(r.kind==="dispose")F=true,R(),i.close();else if(r.kind==="call"&&!f){let I=J(h.policies,r.method)?h.policies[r.method]:void 0;if(!J(h.handlers,r.method)||!I){x({protocol:1,kind:"reply",id:r.id,ok:false,error:{name:"Error",message:`Unknown session method: ${r.method}`}});return}let u;try{u=typeof I=="function"?I(...r.args):I;}catch(m){E(r.id,m);return}G$1.submit({...u,run:()=>S(r),supersede:()=>x({protocol:1,kind:"reply",id:r.id,ok:false,error:{name:M,message:"Superseded by a newer request"}})});}}}),L=i.onError(r=>V(g(r))),{scheduler:H,emit:(r,I,u)=>x({protocol:1,kind:"event",name:r,payload:I},u),progress(){let r=Date.now();$===void 0||r-q<Bn||(q=r,x({protocol:1,kind:"progress",id:$}));}}}var St=class{constructor(h){a$2(this,"emit",h);a$2(this,"listener",null);}connect(){}disconnect(){this.emit("disconnect");}send(h){return this.emit(h),true}onEvent(h){return this.listener=h,()=>{this.listener===h&&(this.listener=null,this.emit("unsubscribe"));}}deliver(h){this.listener?.(h);}};function vn(i){let h=new Map,f=[],g=false,F=false,A=null,L=(x,y)=>{if(F)return;let l=!g&&f.length===0,v=f[f.length-1];v?.provider===x?v.out.push(y):f.push({provider:x,out:[y]}),l&&i.onOutput?.();},$=()=>{let x=A;if(!x||x.updates.length===0)return;A={updates:[],arrivals:[],single:true};let y=i.merge(x.updates,x.single&&x.updates.length===1);if("failed"in y){for(let l of x.arrivals)l.fail(y.failed);return}x.arrivals.forEach((l,v)=>l.settle(v===x.arrivals.length-1?y.applied:null));},q=(x,y,l)=>{if(!A)throw new Error("Collaboration updates merge only within a pipe burst");return A.updates.push(...y),A.arrivals.push(i.arrive(x)),A.single&&(A.single=l),null},_=x=>({clientId:i.clientId,encodeStateVector:()=>($(),i.read.encodeStateVector()),encodeStateAsUpdate:y=>($(),i.read.encodeStateAsUpdate(y)),...i.read.encodeStateAsUpdateChunks&&{encodeStateAsUpdateChunks:(y,l)=>($(),i.read.encodeStateAsUpdateChunks(y,l))},applyUpdate:y=>q(x(),[y],true),applyUpdateChunks:y=>q(x(),y,false),onUpdate:i.onUpdate}),c=(x,y)=>{let l,v=new St(G=>{l.echo||L(x,typeof G=="string"?{do:G,through:l.through}:{do:"send",data:w(G),through:l.through});}),K=i.createProvider(_(()=>l.provider),v,y);l={id:x,provider:K,transport:v,through:0,echo:false,leaveClock:null,stop:[]};let re=false;return l.stop.push(K.onStatus(({status:G,synced:H})=>L(x,{do:"status",status:G,synced:H,through:l.through})),K.onError(G=>{l.echo||L(x,{do:"error",error:{code:G.code,message:G.message},through:l.through});}),K.onPeers(G=>{re&&L(x,{do:"peers",peers:[...G],timeOrigin:y$1(),through:l.through});})),re=true,h.set(x,l),l},C=(x,y)=>{x.echo=true;try{y();}finally{x.echo=false;}},R=x=>{let y=h.get(x.provider);for(let l of x.ops){if(l.op==="create"){y??(y=c(x.provider,l.options)),y.through=l.seq;continue}if(!y){L(x.provider,{do:"lost"});return}let v=y;switch(v.through=l.seq,l.op){case "connect":C(v,()=>v.provider.connect());break;case "disconnect":C(v,()=>v.provider.disconnect());break;case "fail":C(v,()=>v.transport.deliver({type:"error",error:i.transportError(l.error)}));break;case "destroy":C(v,()=>v.provider.destroy());for(let K of v.stop)K();h.delete(v.id),y=void 0;break;case "cursor":v.provider.setCursor(l.cursor,l.broadcast);break;case "event":{let{event:K}=l;v.transport.deliver(K.type==="message"?{type:"message",data:new Uint8Array(K.data)}:K);break}}}},V=()=>{for(let x of h.values()){let y=i.leave(x.provider),l=y?.clock??null;l!==x.leaveClock&&(x.leaveClock=l,L(x.id,{do:"leave",data:y?w(y.frame):null,through:x.through}));}};return {run(x){if(!F){g=true,A={updates:[],arrivals:[],single:true};try{R(x),$();}finally{A=null,g=false;}}},drain(){g=true;try{V();}finally{g=false;}if(f.length===0)return;let x=f;f=[];let y=[];for(let l of x)for(let v of l.out)(v.do==="send"||v.do==="leave"&&v.data)&&y.push(v.data);return {batches:x,transfer:y}},dispose(){if(!F){F=true;for(let x of h.values()){for(let y of x.stop)y();x.echo=true;try{x.provider.destroy();}catch{}}h.clear(),f=[];}}}}function Pn(i,h){return i.setCollaborative?.(),vn({clientId:i.clientId,read:{encodeStateVector:()=>i.encodeStateVector(),encodeStateAsUpdate:f=>i.encodeStateAsUpdate(f)},onUpdate:f=>i.onUpdate(f),merge(f){for(let g of f){let F=i.version();try{i.applyUpdate(g);}catch(A){if(!(A instanceof Error)||A instanceof WebAssembly.RuntimeError||i.version()!==F)throw A;return {failed:A}}}return {applied:null}},createProvider(f,g,F){let A=new f$3(f,g,F);return Object.assign(A,{onPeers:L=>A.onPresence(L)})},arrive:d,leave:e$1,transportError:f=>new c(f.code,f.message),onOutput:h})}function Ze(i,h){for(let f of i){if(f.id===h)return f;let g=Ze(f.children,h);if(g)return g}return null}function et(i,h){for(let f of i.shapes)if(f.id===h||Ze(f.children,h))return f;return null}function vt(i){if(i.width>0&&i.height>0)return {x:i.x,y:i.y,width:i.width,height:i.height};let h=i.inherited;return !h||h.width<=0||h.height<=0?null:{x:h.x,y:h.y,width:h.width,height:h.height}}function Pt(i){return vt(i)!==null}function kn(i){let f=((i.inherited?.rotationDeg??i.rotationDeg)%360+360)%360,g=i.inherited?.flipH??i.flipH,F=i.inherited?.flipV??i.flipV;return Pt(i)&&f===0&&!g&&!F}function xn(i,h,f,g,F){let A=F??JSON.parse(q(i,h.slideIndex));function L(_){for(let c of _)if(c.kind==="textBox"){let C=c.paragraphs.map(x=>x.runs.map(y=>y.text).join("")).join(`
|
|
2
|
+
`),R=[...q$1(C)],V=0;for(let x of c.lines){let y=[...x.caretStops].sort((K,re)=>K.position-re.position);for(;V<R.length&&R[V]<x.start;)V++;let l=[],v=0;for(let K=V;K<R.length&&R[K]<=x.end;K++){let re=R[K];for(;v<y.length&&y[v].position<re;)v++;let G=y[v],H=y[v-1];G?.position===re?l.push(G):H&&G&&l.push({position:re,x:H.x+(G.x-H.x)*(re-H.position)/(G.position-H.position)});}x.caretStops=l;}}else (c.kind==="table"||c.kind==="chart")&&L(c.primitives);}F||L(A.primitives),g?.(A);let $=new TextEncoder().encode(JSON.stringify(A)).buffer,q$2=[];for(let _ of Q(A)){if(f.has(_))continue;let c;try{c=i.mediaBytes(_);}catch{continue}if(a(c)&&c.byteLength<=33554432)try{c=z(c);}catch{}q$2.push({assetId:_,bytes:new Uint8Array(c).buffer});}return H({...h,displayList:$,media:q$2},[$,...q$2.map(({bytes:_})=>_)])}function wn(i,h){if(!h||!Array.isArray(h.args)||h.args.length>5)return null;let{method:f,args:g}=h,F=i.snapshot(),A=(c,C=1e6)=>typeof c=="string"&&c.length<=C&&!/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ud800-\udfff\ufffe\uffff]/u.test(c),L=c=>!!(c&&typeof c=="object"&&["xEmu","yEmu"].every(C=>Number.isSafeInteger(c[C]))),$=c=>!!(c&&typeof c=="object"&&A(c.author,1024)&&A(c.text)&&c.text.length>0&&A(c.created,128)&&Number.isFinite(Date.parse(c.created))&&(c.initials===void 0||A(c.initials,128)));if(f==="insertTableRow"||f==="deleteTableRow"||f==="insertTableColumn"||f==="deleteTableColumn"){let c=f==="insertTableRow"||f==="insertTableColumn";if(g.length<(c?4:3)||g.length>(c?5:3))return null;let[C,R,V]=g;if(!A(C,1024)||!A(R,1024)||!Number.isSafeInteger(V)||V<0)return null;let x=(y,l)=>{try{return i.checkTableEdit(f,C,R,V,y,l),!0}catch{return false}};if(f==="insertTableRow"||f==="insertTableColumn"){let y=g[3],l=g[4];return y!=="before"&&y!=="after"||l!==void 0&&(!Array.isArray(l)||l.length>1e3||l.some(v=>!A(v,16e3)))?null:x(y,l)?()=>i[f](C,R,V,y,l):null}return x()?()=>i[f](C,R,V):null}if(f==="setCommentFlavor")return ["legacy","modern"].includes(g[0])&&!F.comments?.length?()=>i.setCommentFlavor(g[0]):null;if(f==="replyToComment"||f==="setCommentStatus"||f==="setCommentPosition"||f==="removeComment"){let c=F.comments?.find(C=>C.id===g[0]);if(!c)return null;switch(f){case "replyToComment":return F.commentFlavor==="modern"&&!c.parentId&&$(g[1])?()=>i.replyToComment(c.id,g[1]):null;case "setCommentStatus":return F.commentFlavor==="modern"&&typeof g[1]=="boolean"?()=>i.setCommentStatus(c.id,g[1]):null;case "setCommentPosition":return !c.parentId&&L(g[1])?()=>i.setCommentPosition(c.id,g[1]):null;case "removeComment":return ()=>i.removeComment(c.id)}}if(f==="propose"){let[c,C,R]=g;if(!A(c,1024)||!c.trim()||C!==null&&!A(C)||!Array.isArray(R)||!R.length||R.length>256)return null;try{if(JSON.stringify(R).length>1e6)return null}catch{return null}if(i.listProposals().length>=64)return null;let V=new Map([["replaceText",["storyId","start","end","text","style"]],["formatText",["storyId","start","end","patch"]],["setParagraphAlignment",["storyId","start","end","alignment"]],["setShapeRect",["slideId","shapeId","rect"]],["setShapeFill",["slideId","shapeId","color"]],["setShapeStroke",["slideId","shapeId","stroke"]],["setShapeAdjust",["slideId","shapeId","adjustments"]],["setSlideNotes",["slideId","text"]]]),x=(H,oe)=>!!(H&&typeof H=="object"&&!Array.isArray(H)&&Object.keys(H).every(E=>oe.includes(E))),y=(H,oe=0)=>typeof H=="string"?A(H):typeof H=="number"?Number.isFinite(H):!H||typeof H!="object"||oe<16&&Object.entries(H).every(([E,S])=>A(E)&&y(S,oe+1)),l=(H,oe=false)=>{let E=["bold","italic","fontFamily","underline","color","fontSizePt","spacingPt","baselinePct"];return oe&&E.push("kernPt","caps"),x(H,E)?Object.entries(H).every(([S,r])=>{if(r==null)return true;switch(S){case "bold":case "italic":return typeof r=="boolean";case "fontFamily":return A(r);case "underline":return typeof r=="string"&&["none","words","sng","dbl","heavy","dotted","dottedHeavy","dash","dashHeavy","dashLong","dashLongHeavy","dotDash","dotDashHeavy","dotDotDash","dotDotDashHeavy","wavy","wavyHeavy","wavyDbl"].includes(r);case "color":return typeof r=="string"&&/^#?[0-9a-f]{6}$/i.test(r);case "fontSizePt":return typeof r=="number"&&Number.isFinite(r)&&r>=1&&r<=4e3;case "spacingPt":return typeof r=="number"&&Number.isFinite(r)&&Math.abs(r)<=4e3;case "baselinePct":return typeof r=="number"&&Number.isFinite(r)&&r*1e3>=-2147483648&&r*1e3<=2147483647;case "kernPt":return typeof r=="number"&&Number.isFinite(r)&&r>=0&&r<=4e3;case "caps":return typeof r=="string"&&["none","small","all"].includes(r);default:return false}}):false},v=i.readContent();if(!v.ok)return null;let K=[],re=[];for(let H of R){if(!H||typeof H!="object")return null;let oe=V.get(H.type);if(!oe||!x(H,["type",...oe]))return null;let E=H,S=Object.fromEntries(["type",...oe].map(r=>[r,E[r]]));if(!y(S)||S.type==="replaceText"&&S.style!=null&&!l(S.style,true)||S.type==="formatText"&&!l(S.patch)||S.type==="setShapeRect"&&!x(S.rect,["x","y","width","height"])||S.type==="setShapeStroke"&&!x(S.stroke,["color","widthPt"]))return null;if(re.push(S),"storyId"in S){let r=v.stories.find(u=>u.storyId===S.storyId);if(!r)return null;let I={kind:"range",slideId:r.slideId,shapeId:r.shapeId,storyId:r.storyId,start:S.start,end:S.end};if(S.type==="replaceText")K.push({op:"replaceText",target:I,text:S.text});else if(S.type==="formatText"){let u=Object.fromEntries(Object.entries(S.patch).filter(([,m])=>m!=null));S.patch=u,K.push({op:"formatText",target:I,patch:u});}else if(S.type==="setParagraphAlignment")K.push({op:"setParagraphAlignment",target:I,alignment:S.alignment});else return null}else {if(!["setShapeRect","setShapeFill","setShapeStroke","setShapeAdjust","setSlideNotes"].includes(S.type))return null;let{type:r,...I}=S,{slideId:u,...m}=I,B="shapeId"in m?m.shapeId:void 0;"shapeId"in m&&delete m.shapeId,K.push({op:r,target:B===void 0?{slideId:u}:{slideId:u,shapeId:B},...m});}}let G=i.version();try{if(!i.validateEdits({expectVersion:G,steps:K}).ok)return null}catch(H){if(H&&typeof H=="object"&&"name"in H&&H.name==="PptxEditDecodeError")return null;throw H}return ()=>i.propose(c,C,re)}if(f==="acceptProposal"||f==="rejectProposal"){let c=i.listProposals().find(C=>C.id===g[0]);return c?f==="rejectProposal"?()=>i.rejectProposal(c.id):g[1]?.force!==void 0&&typeof g[1].force!="boolean"||c.staleTargets.length&&!g[1]?.force?null:()=>i.acceptProposal(c.id,g[1]):null}if(f==="insertSlide"){let[c,C]=g;return !Number.isSafeInteger(c)||c<0||c>F.slides.length||C!==void 0&&(typeof C!="string"||!F.slides.some(R=>R.layoutPartPath===C))?null:()=>i.insertSlide(c,C)}let q=F.slides.find(c=>c.id===g[0]);if(!q)return null;if(f==="setSlideNotes")return A(g[1])?()=>i.setSlideNotes(q.id,g[1]):null;if(f==="addComment"){let c=g[1];return $(c)&&(c.xEmu===void 0&&c.yEmu===void 0||L(c))?()=>i.addComment(q.id,c):null}if(f==="deleteSlide")return ()=>i.deleteSlide(q.id);if(f==="moveSlide"){let c=g[1];return Number.isSafeInteger(c)&&c>=0&&c<F.slides.length?()=>i.moveSlide(q.id,c):null}let _=et(q,g[1]);if(!_||_.id!==g[1])return null;switch(f){case "setShapeFill":{let c=g[2];return _.kind==="shape"&&(c===null||/^#[0-9a-f]{6}$/i.test(c))?()=>i.setShapeFill(q.id,_.id,c):null}case "setShapeStroke":{let c=g[2];return _.kind==="shape"&&c&&(c.color===void 0||typeof c.color=="string"&&/^#[0-9a-f]{6}$/i.test(c.color))&&(c.widthPt===void 0||Number.isFinite(c.widthPt)&&c.widthPt>=0&&c.widthPt<=1584)?()=>i.setShapeStroke(q.id,_.id,c):null}case "setShapeAdjust":{let c=g[2];return _.kind==="shape"&&c&&typeof c=="object"&&!Array.isArray(c)&&Object.keys(c).length<=64&&Object.entries(c).every(([C,R])=>/^[a-zA-Z][a-zA-Z0-9]*$/.test(C)&&Number.isFinite(R)&&Math.abs(R)<=1e6)?()=>i.setShapeAdjust(q.id,_.id,c):null}case "removeShape":return ()=>i.removeShape(q.id,_.id);case "bringShapeToFront":return ()=>i.bringShapeToFront(q.id,_.id);case "sendShapeToBack":return ()=>i.sendShapeToBack(q.id,_.id);case "bringShapeForward":return ()=>i.bringShapeForward(q.id,_.id);case "sendShapeBackward":return ()=>i.sendShapeBackward(q.id,_.id);default:return null}}var It=1,Tt=4e3,Dn=new Set(["maxFrameBytes","maxMessagesPerFrame","user"]);function tt(i){return Math.round(i*100)/100}function Tn(i$2={}){let h,f$1,g=[],F,A$1,L,$="",q=new Map,_=false,c=false,C=0,R="",V=1,x$2=0,y$1=null,l=null,v$1=null,K=0,re=new Map,G,H$1=false,oe=false,E,S={},r=new Map,I,u$1,m$1,B=false,X=0,Y=new Map,ue=i(),he,ae=new Map,ce=new Map,fe=new Map,Pe=new Map,ye=new Map,Et=new Map,Ue=new Map,me=new Map,ie=new Map,_e=new Set,de=new Map,Ie=new Map;function be(){for(let e of Object.keys(S))delete S[e];}function rt(){m$1&&Q().addUndoBoundary(),m$1=void 0;}function ot(e){for(let a of e.slides)Et.set(a.id,a.notes??"");let t=new Map(e.sources.map(a=>[a.storyId,a.paragraphs]));for(let a of e.stories){let n=te(a),p=Ue.get(a.slideId)??new Set;p.add(n),Ue.set(a.slideId,p),ye.set(n,{text:a,snapshot:Q().story(a.storyId),echoRanges:[],source:new Map((t.get(a.storyId)??[]).map(P=>{let O=a.paragraphs.find(U=>U.paragraphId===P.paragraphId),T=a.text.slice(O.start,O.end),[d,s]=xt(P.text,T),k=P.fields.filter(U=>{let M=U.end<=d?0:U.start>=P.text.length-s?T.length-P.text.length:void 0;return M!==void 0&&O.fields.some(z=>z.start===O.start+U.start+M&&z.end===O.start+U.end+M&&z.fieldType===U.fieldType)});return [P.paragraphId,{text:P.text,fields:k,editable:P.editable&&O.editable&&!B}]}))});}}function De(e,t,a=false){let n=Q(),p=new Set(t.changedSlideIds);if(t.deckSizeChanged||t.slideOrderChanged){let O=L.slides.findIndex(k=>k.id===y$1),T=new Map(L.slides.map(k=>[k.id,k.index]));L=p$1(n),$=n.version(),q.clear();let d=new Set(L.slides.map(k=>k.id));for(let k of L.slides)q.set(k.id,k.index),(t.deckSizeChanged||T.get(k.id)!==k.index)&&p.add(k.id),ie.has(k.id)||ie.set(k.id,0);for(let k of T.keys())d.has(k)||p.add(k);for(let k of ie.keys())d.has(k)||(ie.delete(k),Ie.delete(k));(y$1===null||!d.has(y$1))&&(y$1=L.slides[Math.max(0,Math.min(O,L.slides.length-1))]?.id??null);let s=a?L.slides.find(k=>!T.has(k.id)):void 0;s&&(y$1=s.id);}let P=n.readCommandContent({slideIds:[...p].filter(O=>ie.has(O))});if(!P.ok)throw new Error(`Presentation history read refused: ${P.failure.message}`);for(let O of p){for(let T of Ue.get(O)??[])ye.delete(T);Ue.delete(O);}ot(P),Y.clear(),he=void 0,fe.clear(),Pe.clear(),me.clear();for(let[O,T]of de)p.has(T.tag.slideId)&&de.delete(O);return X=e,re.clear(),[...p]}function An(e,t){let a=JSON.stringify([e,t.id]),n=JSON.stringify([t.sourceId,t.kind,t.textStories.map(P=>P.id)]),p=re.get(a);return (!p||p.signature!==n)&&(p={signature:n,token:`${A$1.incarnation}:${++K}`},re.set(a,p)),p.token}function Ee(e,t){let a=Q().snapshot(),n=a.slides.find(j=>j.id===e),p=n&&Ze(n.shapes,t),P=Ve(e);if(!p||p.id!==t||!P)return null;let O=new Set;function T(j){O.add(j.id);for(let J of j.children)T(J);}T(p);let d=P.hits.filter(j=>j.primitive.shapeId&&O.has(j.primitive.shapeId)).map(j=>v(j.transforms,{x:j.primitive.x,y:j.primitive.y,width:j.primitive.w,height:j.primitive.h})),s=vt(p),k=P.size;if(!k)return null;let U={x:a.widthEmu/k.width,y:a.heightEmu/k.height};if(![U.x,U.y].every(j=>Number.isFinite(j)&&j>0))return null;let M=null;if(d.length){let j=Math.min(...d.map(ne=>ne.x)),J=Math.min(...d.map(ne=>ne.y));M={x:j,y:J,width:Math.max(...d.map(ne=>ne.x+ne.width))-j,height:Math.max(...d.map(ne=>ne.y+ne.height))-J};}else s&&(M={x:s.x/U.x,y:s.y/U.y,width:s.width/U.x,height:s.height/U.y});if(!M)return null;let z=p.textStories[0];return {kind:"object",slideId:e,shapeId:t,storyId:z?.id??"",anchor:0,focus:0,affinity:"downstream",token:An(e,p),bounds:M,rect:s,canMove:n.shapes.includes(p)&&Pt(p),canResize:n.shapes.includes(p)&&kn(p),aspectRatioLocked:p.aspectRatioLocked??false,units:U}}function it(e){let t=ye.get(te(e))?.text;return t?{slideId:e.slideId,shapeId:e.shapeId,storyId:e.storyId,kind:"shape",anchor:0,focus:t.text.length,affinity:"downstream"}:null}function At(e){return !!(e&&e.slideId===y$1&&e.incarnation===A$1.incarnation&&e.documentEpoch===V&&e.slideRevision===ie.get(e.slideId)&&e.coversThroughSeq<=C&&e.coversThroughSeq>=X&&de.has(ze(e)))}function Mt(e){if(!e||typeof e.slideId!="string"||typeof e.shapeId!="string"||typeof e.token!="string")return null;let t=Ee(e.slideId,e.shapeId);return t?.token===e.token&&v$1?.token===e.token&&v$1.slideId===e.slideId&&v$1.shapeId===e.shapeId?t:null}function Ae(e){return l&&te(l)===te(e)&&l.anchor===e.anchor&&l.focus===e.focus&&l.affinity===e.affinity&&l.kind===e.kind?S:{}}function Mn(){ue.retain([...Y.keys(),...[...de.values()].map(e=>e.version),...he?[he.version]:[],R]);for(let e of ce.keys())ae.has(e)||ce.delete(e);}function st(e){let t=ue.ack(e.value,he?.version);return t.outcomes=t.outcomes.map(a=>a.reason==="stale-basis"&&ce.has(a.seq)?{...a,reason:ce.get(a.seq)}:a),H(t,e.transfer)}function ze(e){return JSON.stringify([e.slideId,e.slideRevision,e.coversThroughSeq,e.documentEpoch,e.incarnation])}function Q(){if(E!==void 0)throw new m(E,"Presentation command session has failed");if(_)throw new Error("Presentation command session is disposed");if(!F||!A$1||!L)throw new Error("Presentation command session is not open");return F}function at(e){return e?.session===A$1?.session&&e?.incarnation===A$1?.incarnation}function Me(e){if(Q(),!at(e)||!Number.isSafeInteger(e.seq)||e.seq<0||e.seq>C)throw new Error("Presentation command fence differs")}function Re(e){let t=Q();return {selection:{...e},anchor:t.anchorCaret(e.storyId,e.anchor),focus:t.anchorCaret(e.storyId,e.focus)}}function Te(e){let t=Q(),a=t.resolveCaretAnchor(e.anchor),n=t.resolveCaretAnchor(e.focus);if(a===null||n===null)return null;let p={...e.selection,anchor:a,focus:n};return (a!==e.selection.anchor||n!==e.selection.focus)&&delete p.goalX,p}function Fe(e){if(!(!e||typeof e.slideId!="string"||typeof e.shapeId!="string"||typeof e.storyId!="string"))return ye.get(te(e))?.text}function Rn(e,t,a){let n=ye.get(te(e));for(let d of n.text.paragraphs){let s=n.source.get(d.paragraphId);s&&(s.fields=s.fields.filter((k,U)=>{let M=d.fields[U];return M.end<=t||M.start>=a}));}let p=Q().story(e.storyId),P="",O=p.paragraphs.map((d,s)=>{s>0&&(P+=`
|
|
3
|
+
`);let k=P.length,U=d.runs.map(ne=>ne.text).join("");P+=U;let M=n.source.get(d.id),z=[],j=M?.editable??true;if(M&&M.fields.length>0){let[ne,Oe]=xt(M.text,U);for(let o of M.fields){let b=o.end<=ne?0:o.start>=M.text.length-Oe?U.length-M.text.length:void 0;if(b===void 0){j=false,z.length=0;break}z.push({...o,start:k+o.start+b,end:k+o.end+b});}}let J=[];for(let ne=k;ne<P.length;ne+=1)P[ne]===`
|
|
4
|
+
`&&J.push(ne);return {paragraphId:d.id,start:k,end:P.length,lineBreaks:J,fields:z,editable:j}});if(P.length+1!==p.length)throw new Error("Story text projection differs");let T=P.length-n.text.text.length+a-t;t!==a?n.echoRanges=[]:n.echoRanges=n.echoRanges.map(d=>({start:d.start>=t?d.start+T:d.start,end:d.end>=t?d.end+T:d.end})),T>0&&(n.echoRanges.push({start:t,end:t+T}),n.echoRanges.sort((d,s)=>d.start-s.start),n.echoRanges=n.echoRanges.reduce((d,s)=>{let k=d[d.length-1];return k&&k.end>=s.start?k.end=Math.max(k.end,s.end):d.push({...s}),d},[])),n.snapshot=p,n.formatting=void 0,n.text={...n.text,text:P,paragraphs:O};}function Le(e){let t=ye.get(te(e)),a=t.formatting??(t.formatting=n(Q(),e)),n$1=Ae(e),p=r.get(te(e)),P=t.toolbar;if(P?.story===a&&P.selection.anchor===e.anchor&&P.selection.focus===e.focus&&P.selection.affinity===e.affinity&&P.selection.kind===e.kind&&Object.keys(P.marks).length===Object.keys(n$1).length&&Object.keys(n$1).every(o=>P.marks[o]===n$1[o]))return P.result;let O=e.kind==="shape"?0:Math.min(e.anchor,e.focus),T=e.kind==="shape"?a.length:Math.max(e.anchor,e.focus),d=0,s,k,U,M=[],z=[],j=new Set;for(let o of a.paragraphs){let b=d;for(let D of o.runs){if(p&&D.text.length===0)continue;let w=d+D.text.length,W={...D.style,bold:D.style.bold??a$1.bold,italic:D.style.italic??a$1.italic,underline:D.style.underline??"none",fontFamily:D.style.fontFamily??a$1.fontFamily,fontSizePt:tt(D.style.fontSizePt??a$1.fontSizePt),color:D.style.color??a$1.color};U??(U=W),(O>=d&&O<w||O===d&&w===d)&&(s??(s=W)),w<=O&&w>d&&(k=W),w>d&&O<w&&T>d&&M.push(W),w===d&&O<=d&&T>d&&z.push(W),d=w;}(O===T?O>=b&&O<=d:O<=d&&T>b)&&j.add(o.alignment??"l"),d+=1;}M.push(...z),p&&M.length===0&&M.push(p);let J={...a$1};if(O===T&&e.kind!=="shape")J={...J,...s??k??(p?U??p:a.paragraphs[0]?.runs[0]?.style),...n$1},J.fontSizePt!==null&&J.fontSizePt!==void 0&&(J.fontSizePt=tt(J.fontSizePt));else if(M.length>0){J={...M[0]};let o=new Set(M.flatMap(b=>Object.keys(b)));for(let b of o)M.some(D=>D[b]!==M[0][b])&&(J[b]=null);}let ne=j.size===1?[...j][0]:null,Oe={formatting:J,alignment:ne==="l"||ne==="ctr"||ne==="r"||ne==="just"?ne:null};return t.toolbar={story:a,selection:{...e},marks:{...n$1},result:Oe},Oe}function Fn(){let e$1=Q(),{formatting:t,alignment:a}=l?Le(l):{formatting:null,alignment:null},n=null;if(l&&l.kind!=="shape"){let T=ye.get(te(l)),d=e(T.snapshot,l.anchor,l.focus,S);!H$1&&d&&T.echoRanges.some(s=>s.start<=d.start&&s.end>=d.end)&&T.text.paragraphs.some(s=>s.paragraphId===d.paragraphId&&s.editable&&s.fields.length===0)&&(n=d.neighbour);}let p=v$1?e$1.snapshot().slides.find(T=>T.id===v$1.slideId):null,P=p&&p.shapes.find(T=>T.id===v$1.shapeId),O=T=>T&&/^[#]?[0-9a-f]{6}$/i.test(T)?`#${T.replace(/^#/,"")}`:null;return I={readOnly:H$1,...e$1.isProposalsAvailable()?{proposals:e$1.listProposals()}:{},notes:y$1?{slideId:y$1,text:Et.get(y$1)??""}:null,object:P&&p?{formattable:P.kind==="shape",geometry:P.geometry??null,fill:P.fill?.type==="none"?null:O(P.resolvedFillColor),stroke:O(P.resolvedOutlineColor),strokeWidth:P.resolvedOutlineColor?(P.outline?.width??12700)/12700:null,adjustments:P.adjustValues,order:{index:p.shapes.findIndex(T=>T.id===P.id),count:p.shapes.length}}:null,canUndo:e$1.canUndo(),canRedo:e$1.canRedo(),toolbar:{target:l?{slideId:l.slideId,shapeId:l.shapeId,storyId:l.storyId}:null,textContext:l?l.kind==="shape"?"shape":l.anchor===l.focus?"caret":"range":null,storedMarks:{...S},formatting:t,alignment:a,hyperlink:null,table:null,canEditText:l!==null&&!H$1,echoRun:n}},I}function We(){L=p$1(F),$=F.version(),q.clear();for(let[e,t]of L.slides.entries())q.set(t.id,e);return L}function je(){Q().version()!==$&&We();}function dt(e,t$1=true){let a=Q();je();let n=q.get(e);if(n===void 0)throw new RangeError("Slide is not in the command session");let p=ie.get(e),P=Ie.get(e),O=P?.revision===p&&P.slideIndex===n?P:void 0,T=O?.geometry,d=xn(a,{slideId:e,slideIndex:n,slideRevision:p,coversThroughSeq:C,documentEpoch:V,incarnation:A$1.incarnation,version:R,epoch:++x$2},_e,O?void 0:J=>{T=t(J),Ie.set(e,{slideIndex:n,revision:p,list:J,geometry:T});},O?.list);if(!T||!t$1)return d;let{slideId:s,slideRevision:k,coversThroughSeq:U,documentEpoch:M,incarnation:z}=d.value,j=ze(d.value);for(de.delete(j),de.set(j,{tag:{slideId:s,slideRevision:k,coversThroughSeq:U,documentEpoch:M,incarnation:z},geometry:T,version:R});de.size>257;)de.delete(de.keys().next().value);return d}function Ve(e){let t=[...de.values()].find(a=>a.tag.slideId===e&&a.tag.coversThroughSeq===C&&a.tag.slideRevision===ie.get(e))?.geometry;if(!t){if(je(),q.get(e)===void 0)return;dt(e),t=Ie.get(e)?.geometry;}return t}function Se(e=[],t=[],a=false,n,p,P){if(v$1){let k=Ee(v$1.slideId,v$1.shapeId);v$1=k?.token===v$1.token?k:null,l=v$1?it(v$1):null;}let O=Fn();je();let T=y$1===null||!q.has(y$1)?null:dt(y$1);Mn();let d=g.splice(0),s=H({...A$1,epoch:V,throughSeq:C,version:R,...d.length?{updates:d}:{},...oe&&e.some(k=>k.committed)?{change:{...A$1,throughSeq:C,version:R,snapshot:Q().snapshot()}}:{},selection:v$1??(l?{...l}:null),editState:O,outcomes:e,dirtySlideIds:t,activeSlideId:y$1,historyThroughSeq:X,...n?{creation:n}:{},...p?{editResult:p}:{},...P!==void 0?{fontId:P}:{},...a?{slides:L.slides,size:L.size}:{},frame:T?.value??null},[...T?.transfer??[],...d.map(k=>k.bytes)]);for(let{assetId:k}of s.value.frame?.media??[])_e.add(k);return s}function On(e){if(!e.basis||e.basis.epoch!==V||typeof e.basis.version!="string"||e.basis.version.length===0)return "stale-basis";let t=e.payload;if(!t||typeof t!="object"||Array.isArray(t)||e.kind!=="activateSlide"&&(!Number.isFinite(e.payload.inputTime)||typeof e.payload.undoGroup!="string"||e.payload.undoGroup.length===0))return "invalid-payload";let a=l$1[e.kind];if(!a||e.afterSeq!==void 0&&(!Number.isSafeInteger(e.afterSeq)||e.afterSeq<1||e.afterSeq>=e.seq))return "invalid-payload";if(e.kind==="selectAtPoint"){let{frame:o,x:b,y:D,extend:w,granularity:W,drag:Z}=e.payload;if(!o||typeof o!="object"||Array.isArray(o)||typeof o.slideId!="string"||o.slideId.length===0||typeof o.incarnation!="string"||o.incarnation.length===0||!Number.isSafeInteger(o.slideRevision)||o.slideRevision<0||!Number.isSafeInteger(o.coversThroughSeq)||o.coversThroughSeq<0||!Number.isSafeInteger(o.documentEpoch)||o.documentEpoch<1||!Number.isFinite(b)||!Number.isFinite(D)||typeof w!="boolean"||W!==void 0&&!["character","word","paragraph"].includes(W)||Z!==void 0&&typeof Z!="boolean")return "invalid-payload"}let n="at"in t?t.at:void 0;if("at"in t&&(!n||typeof n!="object"||Array.isArray(n)||n.source!=="confirmed"&&n.source!=="afterSeq"))return "invalid-payload";if(n?.source==="confirmed"){let o=n.selection;if(!o||typeof o!="object"||Array.isArray(o)||typeof o.slideId!="string"||typeof o.shapeId!="string"||typeof o.storyId!="string"||typeof o.anchor!="number"||typeof o.focus!="number"||o.affinity!=="upstream"&&o.affinity!=="downstream")return "invalid-payload";if(!Number.isSafeInteger(o.anchor)||!Number.isSafeInteger(o.focus)||o.anchor<0||o.focus<0)return "invalid-offset"}if(n?.source==="afterSeq"&&(!Number.isSafeInteger(n.seq)||n.seq<1)||(n?.source==="afterSeq"?e.afterSeq!==n.seq:e.afterSeq!==void 0))return "invalid-payload";if(e.afterSeq!==void 0){if(!ae.has(e.afterSeq))return "stale-basis";let o=ae.get(e.afterSeq);if(o.status==="refused"||o.status==="cancelled")return "dependency-refused"}if(H$1&&a==="local-write")return "read-only";let p$1=he&&e.basis.version===he.version?he.seq:Y.get(e.basis.version),P=n?.source==="afterSeq"&&(e.kind!=="setSelection"||e.payload.selection===null),O=p$1??(P?C:void 0);if(O===void 0)return "stale-basis";if(e.kind==="activateSlide"){We();let{slideId:o}=e.payload;return typeof o=="string"&&ie.has(o)&&q.has(o)?{kind:"activation",slideId:o}:"bad-target"}if(e.kind==="setChangeObserver")return typeof e.payload.enabled=="boolean"?{kind:"observer",enabled:e.payload.enabled}:"invalid-payload";if(e.kind==="invoke"){if(u$1)return "invalid-composition";if(e.basis.version!==R)return "stale-basis";let o=wn(Q(),e.payload);return o?{kind:"invoke",run:o,method:e.payload.method}:"invalid-payload"}if(e.kind==="collabPipe")return h&&x(e.payload,i$1,{validCursor:f$2,optionKeys:Dn})?{kind:"remote",pipe:e.payload}:"invalid-payload";if(e.kind==="applyRemoteUpdate"){let o=Array.isArray(e.payload.bytes)?e.payload.bytes:[e.payload.bytes],b=0;for(let D of o){if(!(D instanceof ArrayBuffer)||D.byteLength===0)return "invalid-payload";b+=D.byteLength;}return o.length>0&&b<=16*1024*1024?{kind:"remote",bytes:o}:"invalid-payload"}if(e.kind==="applyEdits"){if(u$1)return "invalid-composition";try{Q().validateEdits(e.payload.request);}catch{return "invalid-payload"}return {kind:"batch",request:e.payload.request}}if(e.kind==="registerFont"){let{font:o,fallback:b}=e.payload;return !o||!Be(o.family)||!o.family||!(o.bytes instanceof ArrayBuffer)||o.bytes.byteLength===0||o.bytes.byteLength>32*1024*1024||o.bold!==void 0&&typeof o.bold!="boolean"||o.italic!==void 0&&typeof o.italic!="boolean"||b!==void 0&&typeof b!="boolean"?"invalid-payload":{kind:"font",font:o,fallback:b??false}}if(e.kind==="insertTextBox"||e.kind==="insertShape"||e.kind==="insertPicture"){if(u$1)return "invalid-composition";let{slideId:o}=e.payload;if(typeof o!="string"||!q.has(o)||o!==y$1)return "bad-target";if(e.basis.version!==R||Q().version()!==R)return "stale-basis";let b=e.kind==="insertPicture"?e.payload:e.payload.draft;if(!b||!Be(b.name)||!b.rect||![b.rect.x,b.rect.y,b.rect.width,b.rect.height].every(Number.isSafeInteger)||b.rect.width<=0||b.rect.height<=0)return "invalid-payload";if(e.kind==="insertTextBox"){let N=e.payload.draft;return !Be(N.text)||!wt(N.style)?"invalid-payload":{kind:"insertion",slideId:o,draft:N}}if(e.kind==="insertShape"){let N=e.payload.draft;return !["rect","roundRect","ellipse","triangle","rtTriangle","diamond","parallelogram","trapezoid","pentagon","hexagon","octagon","star5","rightArrow","leftArrow","upArrow","downArrow","chevron"].includes(N.geometry)||N.fill!==void 0&&N.fill!==null&&!/^#[0-9a-f]{6}$/i.test(N.fill)?"invalid-payload":{kind:"insertion",slideId:o,draft:N}}let{bytes:D,contentType:w}=e.payload;if(!(D instanceof ArrayBuffer)||D.byteLength===0||D.byteLength>8*1024*1024||!["image/png","image/jpeg","image/gif","image/bmp","image/tiff","image/webp","image/svg+xml"].includes(w))return "invalid-payload";let W="",Z=new Uint8Array(D);for(let N=0;N<Z.length;N+=8192)W+=String.fromCharCode(...Z.subarray(N,N+8192));return {kind:"insertion",slideId:o,draft:{name:b.name,rect:b.rect,contentType:w,mediaBase64:btoa(W)}}}if(n?.source==="confirmed"){let o=n.selection,b=Fe(o);if(!b)return "bad-target";let D=b.text;for(let w of Pe.get(te(o))?.values()??[])if(w.seq>O){D=w.beforeText;break}if(!ge(D,o.anchor)||!ge(D,o.focus))return "invalid-offset"}if(p$1!==void 0&<(O,e.basis.version,e.afterSeq),e.kind==="undo"||e.kind==="redo")return {kind:"history",direction:e.kind};if(e.kind==="selectObject"){let{frame:o}=e.payload;if(!At(o)||e.basis.version!==R||Q().version()!==R)return "stale-basis";if(u$1)return "invalid-composition";if("shapeId"in e.payload){if(typeof e.payload.shapeId!="string")return "invalid-payload";let pe=Ee(o.slideId,e.payload.shapeId);return pe?{kind:"object",object:pe}:"bad-target"}let{x:b,y:D,scale:w}=e.payload;if(!Number.isFinite(b)||!Number.isFinite(D)||!Number.isFinite(w)||w<=0)return "invalid-payload";let W=de.get(ze(o)).geometry,Z=x$1(W,{x:b,y:D},void 0,w);if(Z?.kind!=="shape")return "bad-target";let N=Q().snapshot().slides.find(pe=>pe.id===o.slideId),ee=N&&et(N,Z.shapeId),se=ee?Ee(o.slideId,ee.id):null;return se?{kind:"object",object:se}:"bad-target"}if(e.kind==="moveShape"||e.kind==="setShapeRect"){let o=e.kind==="moveShape"&&"delta"in e.payload?e.payload:null;if(o&&(o.at.source!=="afterSeq"||o.at.seq!==C||!o.delta||!Number.isFinite(o.delta.x)||!Number.isFinite(o.delta.y)))return "invalid-payload";let b=o?v$1?.shapeId===o.shapeId?Mt(v$1):null:"target"in e.payload?Mt(e.payload.target):null;if(!b)return "bad-target";if(!At(e.payload.frame)||e.payload.frame.slideId!==b.slideId||e.basis.version!==R||Q().version()!==R)return "stale-basis";if(u$1)return "invalid-composition";let D=e.kind==="moveShape";if(!b.rect||!b.canMove||!D&&!b.canResize)return "unsupported";let w=e.kind==="moveShape"?o?{...b.rect,x:b.rect.x+Math.round(o.delta.x*b.units.x),y:b.rect.y+Math.round(o.delta.y*b.units.y)}:"x"in e.payload?{...b.rect,x:e.payload.x,y:e.payload.y}:null:e.payload.rect;return !w||![w.x,w.y,w.width,w.height].every(Number.isSafeInteger)||w.width<=0||w.height<=0||!D&&(w.width!==b.rect.width&&w.width<76200||w.height!==b.rect.height&&w.height<76200)?"invalid-payload":{kind:"transform",object:b,rect:{...w},move:D}}let T,d;if(e.kind==="selectAtPoint"){if(!n&&e.payload.extend)return "invalid-payload";let{frame:o,x:b,y:D}=e.payload;if(o.slideId!==y$1||o.incarnation!==A$1.incarnation||o.documentEpoch!==V||!ie.has(o.slideId)||o.slideRevision>ie.get(o.slideId)||o.coversThroughSeq>C||o.coversThroughSeq<X)return "stale-basis";let w=de.get(ze(o)),W=w?.geometry??Ve(o.slideId);if(!W)return "stale-basis";let Z=n?.source==="afterSeq"?me.get(n.seq):void 0,N=e.payload.drag?n?.source==="confirmed"?n.selection:Z?Te(Z):null:void 0,ee=x$1(W,{x:b,y:D},N);if(ee?.kind!=="text")return {kind:"noop"};d={slideId:o.slideId,shapeId:ee.shapeId,storyId:ee.storyId,anchor:ee.position,focus:ee.position,affinity:ee.affinity??"downstream"},T=w?o.coversThroughSeq:C;}if(e.kind==="setReadOnly")return typeof e.payload.readOnly=="boolean"?{kind:"mode",readOnly:e.payload.readOnly}:"invalid-payload";if(e.kind==="compositionEnd"){let{compositionId:o,cancelled:b}=e.payload;return typeof o!="string"||b!==void 0&&typeof b!="boolean"?"invalid-payload":u$1?.id===o?{kind:"compositionEnd"}:"invalid-composition"}let s;if(e.kind==="setSelection"){if(s=e.payload.selection,s===null)return {kind:"selection",selection:null}}else if(d&&!n)s=null;else {if(!("at"in t)||!t.at)return "invalid-payload";let o=t.at;if(o.source==="confirmed")s=o.selection;else if(o.source==="afterSeq"){if(o.seq!==e.afterSeq)return "invalid-payload";if(!me.has(o.seq))return "stale-basis";let b=me.get(o.seq);s=b?Te(b):null;}else return "invalid-payload"}let k=s;if(d&&(s=d),!s)return "bad-target";let U=Fe(s);if(!U)return "bad-target";if(!Number.isSafeInteger(s.anchor)||!Number.isSafeInteger(s.focus)||s.anchor<0||s.focus<0)return "invalid-offset";if(d||e.kind==="setSelection"||n?.source==="confirmed"){let o=T??O,b=Pe.get(te(s)),D=U.text;for(let w of b?.values()??[])if(w.seq>o){D=w.beforeText;break}if(!ge(D,s.anchor)||!ge(D,s.focus))return "invalid-offset";s={...s};for(let w of b?.values()??[]){if(w.seq<=o)continue;delete s.goalX;let W=Math.min(s.anchor,s.focus),Z=Math.max(s.anchor,s.focus);if(W!==Z&&w.deleted>0&&W<w.start+w.deleted&&Z>w.start)return "stale-basis";let N=ee=>ee<w.start?ee:w.deleted===0&&ee===w.start?ee+(W===Z||ee===W?w.inserted:0):ee>=w.start+w.deleted?ee-w.deleted+w.inserted:w.start+(W===Z?w.inserted:0);s.anchor=N(s.anchor),s.focus=N(s.focus);}}if(!ge(U.text,s.anchor)||!ge(U.text,s.focus))return "invalid-offset";if(s.kind!==void 0&&s.kind!=="shape"||(s.kind==="shape"&&(s={...s,anchor:0,focus:U.text.length}),s.affinity!=="upstream"&&s.affinity!=="downstream")||s.goalX!==void 0&&!Number.isFinite(s.goalX))return "invalid-payload";if(e.kind==="setSelection")return {kind:"selection",selection:{...s}};if(e.kind==="selectAtPoint"){let o$1=[...q$1(U.text)],b=s.focus;s.focus=o$1.reduce((w,W)=>Math.abs(W-b)<Math.abs(w-b)?W:w,0),s.anchor=s.focus;let D=e.payload.granularity??"character";if(D!=="character"){let w=o(U.text,s.focus,D);if(e.payload.drag){let N=G?.group===e.payload.undoGroup?Te(G.selection):null;if(!N||te(N)!==te(s))return "bad-target";s={...s,...p({start:Math.min(N.anchor,N.focus),end:Math.max(N.anchor,N.focus)},w)};}else s={...s,anchor:w.start,focus:w.end};let W=Ve(s.slideId),Z=W&&u(W,{...s,affinity:s.focus>s.anchor?"upstream":"downstream"});Z&&(s.affinity=s.focus===Z.line.end?"upstream":"downstream");}else if(e.payload.extend&&k&&k.kind!=="shape"&&te(k)===te(s)){let w=U.text;if(n?.source==="confirmed"){for(let Z of Pe.get(te(k))?.values()??[])if(Z.seq>O){w=Z.beforeText;break}}if(!Number.isSafeInteger(k.anchor)||!ge(w,k.anchor))return "invalid-offset";let W=n?.source==="confirmed"?qn(k,O):k;s.anchor=W.anchor;}return {kind:"selection",selection:s}}if(e.kind==="moveSelection"){if(!["left","right","wordLeft","wordRight","lineStart","lineEnd","storyStart","storyEnd","up","down","nextCell","previousCell"].includes(e.payload.motion)||typeof e.payload.extend!="boolean")return "invalid-payload";let o=Ve(s.slideId);if(!o)return "bad-target";let b=y(o,s,e.payload.motion,e.payload.extend,U.text);return b?{kind:"selection",selection:b}:"bad-target"}if(e.kind==="formatText"||e.kind==="setParagraphAlignment"){let o=Math.min(s.anchor,s.focus),b=Math.max(s.anchor,s.focus);if(U.paragraphs.some(N=>o<=N.end&&b>=N.start&&(!N.editable||N.fields.some(ee=>o>ee.start&&o<ee.end||b>ee.start&&b<ee.end))))return "unsupported";if(u$1)return "invalid-composition";if(e.kind==="setParagraphAlignment"){let N=e.payload.alignment;return N===null||["l","ctr","r","just"].includes(N)?{kind:"alignment",selection:{...s},alignment:N}:"invalid-payload"}let{patch:D,toggle:w,fontSizeStep:W}=e.payload;if(D===void 0||!wt(D)||w!==void 0&&!["bold","italic","underline"].includes(w))return "invalid-payload";let Z=Object.fromEntries(Object.entries(D).filter(([,N])=>N!==void 0));if(W!==void 0){if(!W||typeof W!="object"||Array.isArray(W)||w!==void 0||!["increase","decrease"].includes(W.direction)||!Array.isArray(W.sizes)||W.sizes.length>256||W.sizes.some((se,pe,ke)=>typeof se!="number"||!Number.isFinite(se)||se<It||se>Tt||pe>0&&se<=ke[pe-1]))return "invalid-payload";let N=Le(s).formatting.fontSizePt??a$1.fontSizePt,ee=W.sizes.map(tt);Z.fontSizePt=W.direction==="increase"?ee.find(se=>se>N)??Math.max(N,Math.min(Tt,N+1)):ee.reverse().find(se=>se<N)??Math.min(N,Math.max(It,N-1));}if(w){let N=Le(s).formatting;w==="underline"?Z.underline=N.underline!==null&&N.underline!=="none"?"none":"sng":Z[w]=N[w]!==true;}return {kind:"format",selection:{...s},patch:Z}}if(s.kind==="shape")return "unsupported";if(e.kind==="compositionStart"||e.kind==="compositionCommit"){if(typeof e.payload.compositionId!="string"||e.payload.compositionId.length===0)return "invalid-payload";if(e.kind==="compositionStart")return u$1?"invalid-composition":{kind:"compositionStart",id:e.payload.compositionId,selection:{...s}};if(u$1?.id!==e.payload.compositionId||u$1.committed)return "invalid-composition";let o=u$1.selection;if(s.storyId!==o.storyId||s.slideId!==o.slideId||s.shapeId!==o.shapeId)return "bad-target"}let M=Math.min(s.anchor,s.focus),z=Math.max(s.anchor,s.focus),j="",J;switch(e.kind){case "insertText":case "replaceText":case "compositionCommit":if(j=e.payload.text,J=e.payload.style,!wt(J))return "invalid-payload";break;case "paragraphBreak":j=`
|
|
5
|
+
`;break;case "deleteBackward":case "deleteForward":{let o=e.payload.count??1;if(e.payload.unit!=="codePoint"||!Number.isSafeInteger(o)||o<1)return "invalid-payload";if(M===z)for(let b=0;b<o;b+=1)if(e.kind==="deleteBackward"){if(M===0)break;M-=1,ge(U.text,M)||(M-=1);}else {if(z===U.text.length)break;z+=1,ge(U.text,z)||(z+=1);}break}default:return "invalid-payload"}if(!Be(j)||U.text.length-(z-M)+j.length>4294967294)return "invalid-payload";if(e.kind==="compositionCommit"&&j==="")return {kind:"text",selection:{...s},start:M,end:z,text:j};let ne=ye.get(te(s)),Oe=U.paragraphs.some(o=>M<=o.end&&o.end<z);for(let o of U.paragraphs){if(M<=o.end&&z>=o.start&&(!o.editable||Oe&&o.fields.length>0)||o.fields.some(se=>M>se.start&&M<se.end||z>se.start&&z<se.end)||j.includes(`
|
|
6
|
+
`)&&o.start<=M&&M<=o.end&&o.fields.some(se=>se.end<=M))return "unsupported";let b=ne.source.get(o.paragraphId);if(M>o.end||z<o.start||!b||b.fields.length===0)continue;if(!b.editable)return "unsupported";let D=U.text.slice(o.start,o.end),w=j.lastIndexOf(`
|
|
7
|
+
`),W=(w<0?D.slice(0,M-o.start)+j:j.slice(w+1))+D.slice(z-o.start),Z=w<0?o.start:M+w+1,[N,ee]=xt(b.text,W);for(let[se,pe]of b.fields.entries()){let ke=o.fields[se];if(!ke)return "unsupported";if(M<=ke.start&&ke.end<=z)continue;let ut=pe.end<=N?0:pe.start>=b.text.length-ee?W.length-b.text.length:void 0,qt=(ke.start>=z?j.length-(z-M):0)-Z;if(ut===void 0||pe.start+ut!==ke.start+qt||pe.end+ut!==ke.end+qt||b.text.slice(pe.start,pe.end).includes(`
|
|
8
|
+
`))return "unsupported"}}return J===void 0&&(e.kind==="insertText"||e.kind==="replaceText"||e.kind==="compositionCommit")&&(J={...a$1,...Object.fromEntries(Object.entries(Le(s).formatting).filter(([o,b])=>o!=="caps"&&b!==null&&b!==void 0)),...Ae(s)}),{kind:"text",selection:{...s},start:M,end:z,text:j,style:J}}function qn(e,t){let a=e.anchor;for(let n of Pe.get(te(e))?.values()??[])n.seq<=t||a<n.start||(a=a>=n.start+n.deleted?a-n.deleted+n.inserted:n.start+n.inserted);return {...e,anchor:a,focus:a}}function lt(e,t,a){he={seq:e,version:t};for(let[p,P]of Y){if(P>e)break;Y.delete(p);}for(let p of ae.keys()){if(p>e)break;p!==a&&ae.delete(p);}for(let p of me.keys()){if(p>e)break;p!==a&&me.delete(p);}let n=Math.min(e,...[...de.values()].map(p=>p.tag.coversThroughSeq));for(let[p,P]of fe){if(p>n)break;fe.delete(p);let O=Pe.get(P.story);O.delete(p),O.size===0&&Pe.delete(P.story);}}function Rt(){for(;Y.size>256;){let[e,t]=Y.entries().next().value;lt(t,e);}for(;fe.size>512;){let e=fe.values().next().value;for(let[t,a]of de)a.tag.coversThroughSeq<e.seq&&de.delete(t);lt(e.seq,e.version);}for(;ae.size>256;)ae.delete(ae.keys().next().value);for(;me.size>256;)me.delete(me.keys().next().value);}function Un(e,t){let a=Q();if(t.kind==="noop")return false;if(t.kind==="remote"){let d=l?Re(l):null,s=u$1?Re(u$1.selection):null,k=new Map(me);t.pipe||(G=void 0,rt());let U=a.version();if(t.pipe)h.run(t.pipe);else for(let M of t.bytes)a.applyUpdate(new Uint8Array(M));if(U===a.version())return false;t.pipe&&(G=void 0,rt()),t.receipt={applied:true,changedSlideIds:[...ie.keys()],deckSizeChanged:true,slideOrderChanged:true},De(e.seq,t.receipt);for(let[M,z]of k)me.set(M,z);if(l=d?Te(d):null,l&&(!Fe(l)||l.slideId!==y$1)&&(l=null),u$1&&s){let M=Te(s);M&&Fe(M)?u$1={...u$1,selection:M}:u$1=void 0;}return v$1=null,be(),true}if(e.kind!=="selectAtPoint"&&(G=void 0),t.kind==="history"){if(!(t.direction==="undo"?a.canUndo():a.canRedo()))return false;a.addUndoBoundary();let d=a.historyStep(t.direction);return d.applied?(t.receipt=d,m$1=void 0,u$1=void 0,l=null,v$1=null,be(),true):false}if(t.kind!=="text"&&rt(),t.kind==="activation")return be(),y$1=t.slideId,l=null,v$1=null,u$1=void 0,false;if(t.kind==="mode")return H$1=t.readOnly,false;if(t.kind==="observer")return oe=t.enabled,false;if(t.kind==="invoke"){let d=l?Re(l):null,s=v$1,k=a.version();return a.addUndoBoundary(),t.result=t.run(),a.addUndoBoundary(),k===a.version()?false:(t.receipt={applied:true,changedSlideIds:[...ie.keys()],deckSizeChanged:false,slideOrderChanged:["insertSlide","deleteSlide","moveSlide"].includes(t.method)},De(e.seq,t.receipt),t.method==="insertSlide"&&(y$1=t.result.slideId),l=d?Te(d):null,l&&(!Fe(l)||l.slideId!==y$1)&&(l=null),v$1=s&&s.slideId===y$1?Ee(s.slideId,s.shapeId):null,be(),true)}if(t.kind==="batch"){let d=l?Re(l):null;return t.result=a.applyEdits(t.request),!t.result.ok||!t.result.applied?false:(t.receipt={applied:true,changedSlideIds:t.result.changedSlides,deckSizeChanged:false,slideOrderChanged:false},De(e.seq,t.receipt),l=d?Te(d):null,v$1=null,be(),true)}if(t.kind==="font"){let d={...t.font,bytes:new Uint8Array(t.font.bytes)};t.fontId=t.fallback?a.registerFallbackFont(d):a.registerFont(d),Ie.clear();for(let s of ye.values())s.formatting=void 0,s.toolbar=void 0;return false}if(t.kind==="insertion"){a.addUndoBoundary(),t.receipt=e.kind==="insertTextBox"?a.addTextBox(t.slideId,t.draft):e.kind==="insertShape"?a.addShape(t.slideId,t.draft):a.addPicture(t.slideId,t.draft),a.addUndoBoundary(),We();let d=a.readCommandContent();if(!d.ok)throw new Error(d.failure.message);ot(d),Ie.delete(t.slideId),y$1=t.slideId;let s=Ee(t.slideId,t.receipt.shapeId);if(v$1=e.kind==="insertTextBox"?null:s,l=e.kind==="insertTextBox"&&s?.storyId?{slideId:s.slideId,shapeId:s.shapeId,storyId:s.storyId,anchor:0,focus:0,affinity:"downstream"}:s?it(s):null,e.kind==="insertTextBox"&&l){let k=t.draft.style;r.set(te(l),{...a$1,...Object.fromEntries(Object.entries(k).filter(([,U])=>U!=null)),fontSizePt:tt(k.fontSizePt??a$1.fontSizePt)});}return be(),true}if(t.kind==="compositionEnd")return u$1=void 0,false;if(t.kind==="selection")return v$1=null,(!t.selection||Ae(t.selection)!==S)&&be(),l=t.selection,e.kind==="selectAtPoint"&&!e.payload.drag&&l&&(G={group:e.payload.undoGroup,selection:Re(l)}),l&&(y$1=l.slideId),false;if(t.kind==="object"||t.kind==="transform"){let d=t.object;return be(),l=it(d),v$1=d,y$1=d.slideId,t.kind==="object"||d.rect&&Object.keys(t.rect).every(s=>t.rect[s]===d.rect[s])?false:(a.addUndoBoundary(),t.move?a.moveShape(d.slideId,d.shapeId,t.rect.x,t.rect.y):a.setShapeRect(d.slideId,d.shapeId,t.rect),a.addUndoBoundary(),true)}if(t.kind==="compositionStart")return v$1=null,Ae(t.selection)!==S&&be(),l=t.selection,y$1=l.slideId,u$1={id:t.id,selection:{...l},committed:false},false;if(t.kind==="format"||t.kind==="alignment"){let d=t.selection;(d.kind!=="shape"||!v$1||te(d)!==te(v$1))&&(v$1=null),Ae(d)!==S&&be(),l=d,y$1=d.slideId;let s=Math.min(d.anchor,d.focus),k=d.kind==="shape"?ye.get(te(d)).snapshot.length:Math.max(d.anchor,d.focus);return t.kind==="format"&&s===k&&d.kind!=="shape"?(Object.assign(S,t.patch),false):(a.addUndoBoundary(),t.kind==="format"?a.formatText(d.storyId,s,k,t.patch):a.setParagraphAlignment(d.storyId,s,k,t.alignment),a.addUndoBoundary(),true)}let{start:n,end:p,text:P,style:O}=t,T=t.selection;if(v$1=null,Ae(T)!==S&&be(),e.kind==="compositionCommit"&&P==="")return u$1.committed=true,false;if(n!==p||P.length>0){let d=ye.get(te(T)).text.paragraphs.some(j=>n<=j.end&&j.end<p),s=!d&&(e.kind==="insertText"||e.kind==="deleteBackward"||e.kind==="deleteForward"),k=e.payload.inputTime,U=e.payload.undoGroup;(!s||!m$1||m$1.target!==te(T)||m$1.group!==U||m$1.kind!==e.kind||k<m$1.time||k-m$1.time>=500||T.anchor!==m$1.position||T.focus!==m$1.position)&&a.addUndoBoundary(),p>n&&(d?o$1(a,T.storyId,n,p):a.deleteText(T.storyId,n,p));let M=n,z=P.split(`
|
|
9
|
+
`);for(let[j,J]of z.entries())j>0&&(a.insertParagraphBreak(T.storyId,M),M+=1),J.length>0&&(a.insertText(T.storyId,M,J,O),M+=J.length);s?m$1={target:te(T),group:U,time:k,kind:e.kind,position:n+P.length}:(a.addUndoBoundary(),m$1=void 0);}return l={...T,anchor:n+P.length,focus:n+P.length,affinity:"downstream"},delete l.goalX,y$1=T.slideId,e.kind==="compositionCommit"&&(u$1.committed=true),n!==p||P.length>0}let Ft={async openCommandEditor(e,t,a){if(_)throw new Error("Presentation command session is disposed");if(F||c)throw new Error("Presentation command session is already open");if(!a||typeof a.session!="string"||!a.session||typeof a.incarnation!="string"||!a.incarnation||a.readOnly!==void 0&&typeof a.readOnly!="boolean")throw new TypeError("Invalid presentation command open options");c=true;try{if(await(i$2.initWasm??s)(a.wasm),_)throw new Error("Presentation command session is disposed");F=A(new Uint8Array(t),{clientId:a.clientId,fonts:a.fonts?.map(d=>({...d,bytes:new Uint8Array(d.bytes)})),fallbackFonts:a.fallbackFonts?.map(d=>({...d,bytes:new Uint8Array(d.bytes)})),initialUpdate:a.initialUpdate}),f$1=F.onUpdate((d,s)=>{g.push({bytes:d.slice().buffer,origin:s});}),a.collaboration&&(h=Pn(F,i$2.onPipeOutput));let n=We(),p=a.activeSlideIndex??0;if(!Number.isSafeInteger(p))throw new RangeError("Active slide index is out of range");A$1={session:a.session,incarnation:a.incarnation},H$1=a.readOnly??!1,oe=a.observeChanges??!1,B=a.initialUpdate!==void 0,y$1=n.slides[Math.max(0,Math.min(p,n.slides.length-1))]?.id??null,F.setUndoCaptureMode("manual"),R=F.version(),ue.initialize(R),Y.set(R,0);let P=F.readCommandContent();if(!P.ok)throw new N("message",`Presentation command open refused: ${P.failure.message}`,P.failure.code);ot(P);for(let d of n.slides)ie.set(d.id,0);let O=Se(),T=F.encodeStateAsUpdate().slice().buffer;return H({...O.value,shared:ue.ack(O.value),slides:n.slides,size:n.size,activeSlideId:y$1,frame:O.value.frame??null,recoveryUpdate:T},[...O.transfer,T])}catch(n){throw Ot(),n}finally{c=false;}},command(e,t){if(Q(),t.kind!=="activateSlide"&&je(),!at(t)||!Number.isSafeInteger(t.seq)||t.seq<1)return Se();let a=ae.get(t.seq);if(a)return Se([{...a}]);if(t.seq<=C)return Se([{seq:t.seq,status:"refused",reason:"stale-basis",committed:false}]);if(t.seq!==C+1)return Se();let n=On(t);if(typeof n=="string"){t.kind==="compositionCommit"&&u$1&&u$1.id===t.payload?.compositionId&&(u$1=void 0);let T={seq:t.seq,status:n==="dependency-refused"?"cancelled":"refused",reason:n,committed:false};return C=t.seq,ae.set(t.seq,T),Rt(),Se([T])}let p={version:R,selection:l,objectSelection:v$1,activeSlideId:y$1,editState:I},P="selection"in n?n.selection?.slideId:"object"in n?n.object.slideId:void 0,O=P===void 0?void 0:ie.get(P);try{let T=n.kind==="text"?Fe(n.selection).text:"",d=Un(t,n),s=d&&n.kind==="history"?De(t.seq,n.receipt,!0):n.kind==="remote"||n.kind==="invoke"?n.receipt?.changedSlideIds:void 0;if(d&&n.kind==="text"&&Rn(n.selection,n.start,n.end),d&&(n.kind==="format"||n.kind==="alignment")){let z=ye.get(te(n.selection));z.snapshot=Q().story(n.selection.storyId),z.formatting=void 0,z.echoRanges=[];}C=t.seq,R=Q().version(),$=R,d&&ue.commit(R),!Y.has(R)&&R!==he?.version&&Y.set(R,C);let k={seq:t.seq,status:t.kind==="compositionCommit"&&t.payload.text===""?"cancelled":d||n.kind==="invoke"&&n.method==="propose"||n.kind==="format"||n.kind==="alignment"||n.kind==="font"||n.kind==="activation"||n.kind==="selection"||n.kind==="object"||t.kind==="setReadOnly"||t.kind==="compositionStart"||t.kind==="compositionEnd"?"applied":"noop",committed:d};if(ae.set(t.seq,k),d&&n.kind==="text"){let z=te(n.selection),j={seq:t.seq,story:z,start:n.start,deleted:n.end-n.start,inserted:n.text.length,version:R,beforeText:T};fe.set(t.seq,j);let J=Pe.get(z)??new Map;J.set(t.seq,j),Pe.set(z,J);}me.set(t.seq,l?Re(l):null),Rt();let U=n.kind==="font"?[...ie.keys()]:n.kind==="batch"&&n.result?.ok?n.result.changedSlides:s??(d&&y$1!==null?[y$1]:[]);for(let z of U){let j=ie.get(z);j!==void 0&&ie.set(z,j+1);}let M=Se([k],U,n.kind==="history"||n.kind==="remote"||n.kind==="invoke",n.kind==="insertion"?n.receipt:void 0,n.kind==="batch"?n.result:void 0,n.kind==="font"?n.fontId:void 0);return n.kind==="invoke"&&(M.value.mutationResult=n.result),M}catch(T){throw R!==p.version&&Y.delete(R),R=p.version,l=p.selection,v$1=p.objectSelection,y$1=p.activeSlideId,I=p.editState,P!==void 0&&O!==void 0&&ie.set(P,O),E=t.seq,C=t.seq,H$1=true,ae.set(t.seq,{seq:t.seq,status:"refused",reason:"unknown-outcome",committed:false}),new m(t.seq,`Command ${t.seq} has an unknown outcome: ${T instanceof Error?T.message:String(T)}`)}},edit(e,t){if(Q(),!f(t)){if(!Number.isSafeInteger(t?.seq)||t.seq<1)throw new TypeError("Invalid presentation edit envelope");return st(Se([{seq:t.seq,status:"refused",reason:"invalid-payload",committed:false}]))}if(t.session!==A$1.session||t.incarnation!==0){let n=st(Se());return n.value.outcomes=[{seq:t.seq,status:"refused",committed:false,reason:t.session!==A$1.session?"wrong-session":"stale-incarnation"}],n}let a=ue.envelope(t,A$1);return t.seq===C+1&&(t.basis.epoch!==V?ce.set(t.seq,"stale-epoch"):t.expectVersion===true&&t.basis.version!==ue.version&&(ce.set(t.seq,"stale-version"),a.basis.version="")),st(Ft.command(null,a))},checkpoint(){throw new Error("Presentation command checkpoints are unavailable")},thumbnailFrame(e,t){if(Q(),!at(t))throw new Error("Presentation command thumbnail identity differs");je();let a=ie.get(t.slideId),n={...A$1,epoch:V,slideId:t.slideId,slideRevision:a??0};if(a===void 0||!q.has(t.slideId))return {...n,status:"refused",reason:"bad-target"};if(t.knownRevision===a)return {...n,status:"unchanged"};let p=dt(t.slideId,false);for(let{assetId:P}of p.value.media)_e.add(P);return H({...n,status:"frame",frame:p.value},p.transfer)},flushCommandEditor(e,t){return Me(t),Se()},saveCommandEditor(e,t){Me(t);let a=new Uint8Array(Q().save()).buffer,n=g.splice(0);return H({...A$1,epoch:V,throughSeq:C,version:R,...n.length?{updates:n}:{},bytes:a},[a])},accessCommandEditor(e,t,a,n){if(Me(t),!Array.isArray(n))throw new TypeError("Invalid access arguments");let p=Q();switch(a){case "encodeStateVector":return p.encodeStateVector();case "encodeStateAsUpdate":return p.encodeStateAsUpdate(n[0]);case "snapshot":return p.snapshot();case "comments":return p.comments();case "story":return p.story(n[0]);case "findText":return p.findText(n[0]);case "validateEdits":return H$1?{ok:false,version:R,failure:{code:"read-only",message:"The editor is read-only"}}:p.validateEdits(n[0]);case "exportStructured":return p.exportStructured(n[0]);case "exportMarkdown":return p.exportMarkdown(n[0]);case "searchText":return p.searchText(n[0],n[1]);case "listProposals":return p.listProposals();case "previewProposal":return p.previewProposal(n[0]);case "layoutSlide":return p.layoutSlide(n[0]);case "layoutProposalSlide":return p.layoutProposalSlide(n[0],n[1]);case "layoutProposalDiffSlide":return p.layoutProposalDiffSlide(n[0],n[1]);default:throw new TypeError("Unsupported access method")}},checkpointCommandEditor(e,t){Me(t);let a=Q().save().slice().buffer,n=Q().encodeStateAsUpdate().slice().buffer;return H({...A$1,epoch:V,throughSeq:C,version:R,bytes:a,recoveryUpdate:n},[a,n])},prepareCommandPicture(e,t,a){if(Me(t),!(a instanceof ArrayBuffer)||a.byteLength===0||a.byteLength>8*1024*1024)throw new Error("Invalid picture bytes");let n=z(new Uint8Array(a)).slice().buffer;return H(n,[n])},readEditor(e,t,a){Me(t);let n=Q().readContent(a),p=Se();return H({...p.value,result:n},p.transfer)}};function Ot(){if(_)return;_=true;let e=F;h?.dispose(),h=void 0,f$1?.(),f$1=void 0,g.length=0,F=void 0,L=void 0,q.clear(),u$1=void 0,m$1=void 0,I=void 0,Y.clear(),ue.dispose(),ae.clear(),ce.clear(),he=void 0,fe.clear(),Pe.clear(),ye.clear(),r.clear(),Ue.clear(),re.clear(),me.clear(),ie.clear(),_e.clear(),de.clear(),Ie.clear(),e?.dispose();}return {handlers:Ft,policies:{openCommandEditor:{lane:"interactive"},command:e=>({lane:e.kind==="collabPipe"?"collab":"input",mutates:true,userInput:e.kind!=="collabPipe"}),edit:e=>({lane:e.kind==="collabPipe"?"collab":"input",mutates:true,userInput:e.kind!=="collabPipe"}),checkpoint:{lane:"interactive"},thumbnailFrame:{lane:"interactive"},flushCommandEditor:{lane:"interactive"},saveCommandEditor:{lane:"interactive"},readEditor:{lane:"interactive"},prepareCommandPicture:{lane:"interactive"},accessCommandEditor:{lane:"interactive"},checkpointCommandEditor:{lane:"interactive"}},drainPipe:()=>h?.drain(),dispose:Ot}}function te(i){return JSON.stringify([i.slideId,i.shapeId,i.storyId])}function xt(i,h){let f=0,g=Math.min(i.length,h.length);for(;f<g&&i[f]===h[f];)f+=1;(!ge(i,f)||!ge(h,f))&&(f-=1);let F=0;for(;F<g-f&&i[i.length-F-1]===h[h.length-F-1];)F+=1;return (!ge(i,i.length-F)||!ge(h,h.length-F))&&(F-=1),[f,F]}function ge(i,h){return Number.isSafeInteger(h)&&h>=0&&h<=i.length&&!(h>0&&h<i.length&&i.charCodeAt(h-1)>=55296&&i.charCodeAt(h-1)<=56319&&i.charCodeAt(h)>=56320&&i.charCodeAt(h)<=57343)}function Be(i){if(typeof i!="string")return false;for(let h of i){let f=h.codePointAt(0);if(!(f===9||f===10||f===13||f>=32&&f<=55295||f>=57344&&f<=65533||f>=65536))return false}return true}function wt(i){if(i===void 0)return true;if(!i||typeof i!="object"||Array.isArray(i))return false;let h=["none","words","sng","dbl","heavy","dotted","dottedHeavy","dash","dashHeavy","dashLong","dashLongHeavy","dotDash","dotDashHeavy","dotDotDash","dotDotDashHeavy","wavy","wavyHeavy","wavyDbl"];return Object.entries(i).every(([f,g])=>{if(!["bold","italic","fontFamily","underline","color","fontSizePt","spacingPt","baselinePct"].includes(f))return false;if(g===void 0)return true;switch(f){case "bold":case "italic":return typeof g=="boolean";case "fontFamily":return Be(g);case "underline":return typeof g=="string"&&h.includes(g);case "color":return typeof g=="string"&&/^#?[0-9a-f]{6}$/i.test(g);case "fontSizePt":return typeof g=="number"&&Number.isFinite(g)&&g>=It&&g<=Tt;case "spacingPt":return typeof g=="number"&&Number.isFinite(g)&&Math.abs(g)<=4e3;case "baselinePct":return typeof g=="number"&&Number.isFinite(g)&&g*1e3>=-2147483648&&g*1e3<=2147483647;default:return false}})}function nt(i){return i?.map(h=>({...h,bytes:new Uint8Array(h.bytes)}))}async function Ct(i){let h=i instanceof WebAssembly.Module?i:i===void 0?await gt(b()):await WebAssembly.compile(i);return await s(h),h}function Cn(i,h$1={}){let f,g=false,F=false,A$1=false,L$1=false,$=0,q$1=false,_=0,c=false,C=0,R,V=new TextEncoder,x=new Set;function y(){if(q$1)throw new Error("Presentation session is disposed");if(!f)throw new Error("Presentation session is not open");return f}function l$1(u=y(),m=u.version()){return R?.version!==m&&(R={version:m,value:g?k(u):p$1(u)}),R.value}function v(u=true){let m=y();if(!g||L$1||u&&!F)throw new B("stage","Presentation editor is not attached");return m}function K(u,m){let B$1=v();if($!==u||B$1.version()!==m)throw L$1=true,new B("position-mismatch","Presentation editor fence differs");return {sequence:$,version:B$1.version()}}function re(){let u=l$1();return {format:"pptx",stage:"ready",version:_,dirty:c,slides:u.slides,size:u.size}}function G(){q$1=true;let u=f;f=void 0,x.clear(),R=void 0,u?.dispose();}let H$1={async open(u,m,B={}){if(q$1)throw new Error("Presentation session is disposed");if(f||g)throw new Error("Presentation session is already open");if(await(h$1.initWasm??s)(B.wasm),q$1)throw new Error("Presentation session is disposed");let X=A(new Uint8Array(m),{clientId:B.clientId,fonts:nt(B.fonts),fallbackFonts:nt(B.fallbackFonts),initialUpdate:B.initialUpdate});try{let Y=l$1(X);return f=X,{format:"pptx",stage:"ready",version:_,dirty:c,slides:Y.slides,size:Y.size}}catch(Y){throw X.dispose(),Y}},version:()=>y().version(),readContent:(u,m)=>y().readContent(m),findText:(u,m)=>y().findText(m),validateEdits:(u,m)=>y().validateEdits(m),applyEdits(u,m){if(g)throw new B("stage","Editor mutations require ordered replay");let B$1=y().applyEdits(m);return B$1.ok&&B$1.applied&&(_+=1,c=true,I.emit("changed",{version:_,dirty:c})),B$1},frame(u,m){let B=y(),X=B.version(),Y=l$1(B,X).slides.length;if(!Number.isInteger(m)||m<0||m>=Y)throw new RangeError("Slide index is out of range");let ue=g?l(B,m):q(B,m),he=V.encode(ue).buffer,ae=[];for(let ce of Q(JSON.parse(ue))){if(x.has(ce))continue;let fe;try{fe=B.mediaBytes(ce);}catch{continue}if(a(fe)&&fe.byteLength<=33554432)try{fe=z(fe);}catch{}ae.push({assetId:ce,bytes:new Uint8Array(fe).buffer});}C+=1;for(let{assetId:ce}of ae)x.add(ce);return H({displayList:he,version:X,epoch:C,slideIndex:m,media:ae},[he,...ae.map(({bytes:ce})=>ce)])},slides:()=>l$1().slides,slideSize:()=>l$1().size,save(){if(g)throw new B("stage","Editor saves require a fence");let u=y().save(),m=u.buffer instanceof ArrayBuffer&&u.byteOffset===0&&u.byteLength===u.buffer.byteLength?u.buffer:new Uint8Array(u).buffer;return H(m,[m])},dispose(){y(),G();}},oe={async beginEditor(u,m,B){if(q$1)throw new Error("Presentation session is disposed");if(f||g)throw new Error("Presentation session is already open");g=true;let X=await(h$1.initEditorWasm??Ct)(B.wasm);if(q$1)throw new Error("Presentation session is disposed");let Y$1;try{if(Y$1=f$1(new Uint8Array(m),{clientId:B.clientId,fonts:nt(B.fonts),fallbackFonts:nt(B.fallbackFonts),initialUpdate:B.initialUpdate}),await h(Y$1),q$1)throw new Error("Presentation session is disposed");let ue=j(Y$1);return f=Y$1,{state:re(),hydration:ue,module:X,sequence:$,version:Y$1.version()}}catch(ue){throw f===Y$1&&(f=void 0),Y$1?.dispose(),L$1=true,Y(ue)}},attachPeer(u,m,B$1){let X=A$1;A$1=true,F=false;let Y=v(false);if(X||m!==Y.version()||B$1!==$)throw L$1=true,new B(X?"attachment":"position-mismatch","Presentation peer attachment differs or was already attempted");return F=true,{version:Y.version(),sequence:$}},replay(u,m){let B$1=v();try{if(m.expectedOutcome==null)throw new B("outcome","Editor replay requires an expected outcome");let X=m$1(B$1,m);if(!X.consumed)throw new B("refusal","Worker refused accepted input");return $=X.sequence,_=X.revision,c||(c=X.outcome.applied),{...X,projection:re()}}catch(X){throw L$1=true,Y(X)}},flush:(u,m,B)=>K(m,B),editorFrame(u,m){v(false);let B=l$1().slides.findIndex(Y=>Y.id===m),X=H$1.frame(null,B);return H({...X.value,slideId:m,sequence:$},X.transfer)},editorSave(u,m,B){K(m,B);let X=new Uint8Array(v().save()).buffer;return H(X,[X])}},E,S=Tn({initWasm:h$1.initWasm,onPipeOutput(){q$1||E!==void 0||(E=setTimeout(()=>{E=void 0;let u=S.drainPipe();u&&I.emit("collaborationPipe",u.batches,u.transfer);},0));}}),r={...i,post(u,m){let B=L(u)&&(u.kind==="reply"||u.kind==="event"&&u.name==="ack")?S.drainPipe():void 0;i.post(B?{...u,collabPipe:B.batches}:u,B?[...m??[],...B.transfer]:m);}},I=Sn(r,{handlers:{...H$1,...oe,...S.handlers},policies:{...X,...T,...S.policies},context:null,onDispose(){E!==void 0&&clearTimeout(E);try{G();}finally{S.dispose();}}});return I}var En=P(self),zn=Cn(En,{initWasm:yn(En,b(),s),initEditorWasm:Ct});Object.assign(globalThis,{__betterofficeEngineProgress:()=>zn.progress()});
|