@betteroffice/pptx-react 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- import {a}from'./chunk-HQ2N3DQ7.js';import {ca,_,L,J,x,E,G,F,$,M,K,H,I,b as b$1,a as a$1,n,r,Z,R,c,S,aa,Y,W,ba,q,N,U,o,p,P,O}from'./chunk-X6B77B3U.js';import {b,y,A,x as x$1,m,w,s,r as r$1,l}from'./chunk-X2M23RXQ.js';import {a as a$2}from'./chunk-O2XFH626.js';import {memo,useRef,useEffect,useMemo,useCallback,useSyncExternalStore,lazy,useLayoutEffect,useState,Suspense}from'react';import {browserFrameImages,frameAssetIds,createPptxWorkerSession,PptxWorkerEditorFailedError,PRESENTATION_COMMAND_ADMISSION,PptxWorkerEditorDisposedError,PRESENTATION_COMMAND_MUTATIONS,PptxWorkerUnsupportedError,indexGeometry,transformedRect,presentationCollaborationPipes,indexHitGeometry,presentationSharedInputs,hitGeometry,DEFAULT_EDITOR_TEXT_STYLE,decodeCommandDisplayList,findLine,navigateGeometry,selectionGeometry}from'@betteroffice/pptx/worker';import {flushSync,createPortal}from'react-dom';import {sizeCanvasForSlide,paintSlide}from'@betteroffice/pptx';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {attachCollaborationPipe}from'@betteroffice/pptx/collaboration';function De(e,t,o){return e.require(),e.store.dispatch({kind:"invoke",payload:{...t,inputTime:performance.now(),undoGroup:"object"}},o)}async function Je(e,t){let o=e.store.getSnapshot().selection;if(o?.kind!=="object")return null;await e.store.fence(),e.require();let i=e.store.getSnapshot();if(i.selection?.kind!=="object"||i.selection.shapeId!==o.shapeId||i.selection.slideId!==o.slideId)return null;let a=[o.slideId,o.shapeId],p=i.editState.object,r;switch(t.kind){case "fill":r={method:"setShapeFill",args:[...a,t.color]};break;case "strokeColor":r={method:"setShapeStroke",args:[...a,t.color===null?{}:{color:t.color}]};break;case "strokeWidth":r={method:"setShapeStroke",args:[...a,t.points===null?{}:{widthPt:t.points}]};break;case "adjust":r={method:"setShapeAdjust",args:[...a,{...p?.adjustments,[t.name]:t.value}]};break;case "remove":r={method:"removeShape",args:[...a]};break;case "zOrder":{r={method:{front:"bringShapeToFront",forward:"bringShapeForward",backward:"sendShapeBackward",back:"sendShapeToBack"}[t.value],args:[...a]};break}}return De(e,r)}function pn(){let e=browserFrameImages(),t=new Map,o=new Map,i=new Map,a=false,p=0,r=()=>{a&&!i.size&&t.clear();},u=(g,f)=>{--f.references===0&&(o.delete(g),f.resolve.release());};return {pin(g,f=[]){if(a)throw new Error("Slide images are disposed");let d=i.get(g);for(let l of d?f:[...f,...g.frame.media]){let c=t.get(l.assetId);if(c?.bytes.buffer===l.bytes)continue;let S=new Uint8Array(l.bytes);!c||c.bytes.length!==S.length||!c.bytes.every((x,C)=>x===S[C])?t.set(l.assetId,{bytes:S,version:++p}):c.bytes=S;}if(!d){let l=new Map,c=new Map;for(let S of frameAssetIds(g.displayList)){let x=t.get(S);if(!x)continue;let C=JSON.stringify([S,x.version]),I=o.get(C);if(!I){let n=e.resolve({media:new Map([[C,x.bytes]])});I={resolve:n,source:Promise.resolve(n(C)),references:0},o.set(C,I);}I.references+=1,l.set(S,{key:C,asset:I}),c.set(S,x.version);}d={resolve:S=>l.get(S)?.asset.source??null,versions:c,ready:Promise.all([...l.values()].map(({asset:S})=>S.source)).then(()=>{}),retainAsset(S){let x=l.get(S);x&&(x.asset.references+=1);let C=false;return {resolve:I=>!C&&I===S?x?.asset.source??null:null,ready:(x?.asset.source??Promise.resolve(null)).then(()=>{}),release(){C||(C=true,x&&u(x.key,x.asset));}}},release(){for(let{key:S,asset:x}of l.values())u(S,x);l.clear();},references:0},i.set(g,d);}let b=d,k=()=>{b.references+=1;let l=false;return {resolve:b.resolve,ready:b.ready,version:c=>b.versions.get(c),retain:k,retainAsset:b.retainAsset,release(){l||(l=true,--b.references===0&&(i.delete(g),b.release(),r()));}}};return k()},dispose(){a||(a=true,e.dispose(),r());}}}var Gt=new WeakMap,Eo=new WeakMap;function fn(e){if(e.cancelled)throw new Error("Slide raster is released");e.references+=1;let t=false;return {raster:e.raster,ready:e.ready,retain:()=>fn(e),release(){t||(t=true,--e.references===0&&e.release());}}}function To(e,t){let o=Gt.get(e)?.get(t);return o&&!o.cancelled?fn(o):void 0}function Kt(e,t={}){let o=t.scale??1,i=t.dpr??e.ownerDocument.defaultView?.devicePixelRatio??1,a=t.images??pn(),p=false,r=0,u,g,f,d=new Set,b=Promise.resolve(false),k=S=>!p&&(t.current?.(S)??true),l=()=>{r+=1,f?.cancel(),f=void 0;},c={checkpoint(S=true){let x=r,C=f&&{...f,lease:f.lease.retain()},I=u?.retain(),n=b,h=g?.retain(),E;if(S&&u){E=e.ownerDocument.createElement("canvas"),E.width=e.width,E.height=e.height;try{let T=E.getContext("2d");if(!T)throw new Error("Slide canvas is unavailable");T.drawImage(e,0,0);}catch(T){throw I?.release(),C?.lease.release(),h?.release(),Ze(E),T}}let v=e.style.width,P=e.style.height,m=false,w=()=>{m||(m=true,d.delete(w),I?.release(),C?.lease.release(),h?.release(),E&&Ze(E));};return d.add(w),Object.assign(()=>{if(!m){if(!k()||r>x+1){w();return}l();try{u?.release(),u=I?.retain(),g?.release(),g=h?.retain(),b=n,E&&(e.width=E.width,e.height=E.height,e.style.width=v,e.style.height=P,e.getContext("2d")?.drawImage(E,0,0)),C&&c.paintFrame(C.frame,C.view,C.media);}finally{w();}}},{commit:w})},paintFrame(S,x,C=[]){if(!k(S)||o<=0||i<=0)return;l();let I=r,n=()=>k(S)&&r===I,h=e.getContext("2d");if(!h)throw new Error("Slide canvas is unavailable");let E=a.pin(S,C);g?.release(),g=E;let v=Gt.get(S);v||(v=new Map,Gt.set(S,v));let P=o*i,m=v.get(P);if(!m){let B=E.retain(),H=[B.ready];try{let D=Eo.get(a);D||(D=new Map,Eo.set(a,D)),m=ui(e.ownerDocument,S.displayList,i,o,B,D,H,()=>{v.delete(P),v.size||Gt.delete(S);}),v.set(P,m);}catch(D){throw g?.release(),g=void 0,B.release(),b=Promise.allSettled(H).then(()=>false),D}}let w=fn(m),T,q,O=false;b=new Promise((B,H)=>{T=B,q=H;});let z={lease:w,frame:S,view:x,media:C,cancel(){O||(O=true,w.release(),f===z&&(f=void 0,g?.release(),g=void 0),w.ready.then(()=>T(false),()=>T(false)));}};f=z,w.ready.then(async()=>{if(!n()||O){z.cancel();return}if(t.beforeCommit&&await t.beforeCommit(n),!n()||O){z.cancel();return}let B=t.compose?.(w.raster,S,x);try{if(!n()||O){z.cancel();return}sizeCanvasForSlide(e,S.displayList,i,o),h.save(),h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,e.width,e.height),h.drawImage(B?.canvas??w.raster.canvas,0,0),h.restore();let H=u;u=w,f=void 0,O=!0;try{t.onCommit?.(S,x);}finally{H?.release();}}finally{B?.release();}T(true);}).catch(B=>{if(O){n()?q(B):T(false);return}O=true,w.release(),f===z&&(f=void 0,g?.release(),g=void 0),n()?q(B):T(false);});},whenPainted:()=>b,cancel:l,freeze(){l();for(let S of d)S();g?.release(),g=void 0;},dispose(){if(!p){p=true,l();for(let S of d)S();u?.release(),u=void 0,g?.release(),g=void 0,t.images||a.dispose();}}};return c}function Ze(e){e.width=0,e.height=0;}function un(e,t,o){return new Proxy(e,{get(i,a){if(o&&a==="clearRect")return ()=>{};if(o&&a==="setTransform")return ()=>{t()&&o();};let p=Reflect.get(i,a,i);return typeof p=="function"?(...r)=>t()?p.apply(i,r):void 0:p},set:(i,a,p)=>!t()||Reflect.set(i,a,p,i)})}function ui(e,t,o,i,a,p,r,u){let g=o*i,f=e.createElement("canvas");sizeCanvasForSlide(f,t,o,i);let d=f.getContext("2d");if(!d)throw Ze(f),new Error("Slide canvas is unavailable");let b=[],k=new Map,l=new Set,c=false,S=false,x=false,C=()=>{x||(x=true,a.release());},I=()=>!c,n=()=>{if(!c){c=true,u(),l.clear(),Ze(f);for(let[m,w]of k)--m.references===0&&(m.cancelled=true,m.releaseMedia?.(),p.get(w)===m&&p.delete(w),Ze(m.canvas));k.clear(),C();}};function h(m,w,T){let q=pi(m,w,g,t);if(!q)return;let O=m.kind==="textBox"?{...m,paragraphs:[]}:m,z=JSON.stringify([O,w.map(H=>({x:H.x,y:H.y,w:H.w,h:H.h,transform:H.transform})),g,q,m.kind==="image"&&m.assetId?a.version(m.assetId):null]),B=p.get(z);if(!B){let H=e.createElement("canvas");H.width=Math.ceil(q.width*g),H.height=Math.ceil(q.height*g);let D=H.getContext("2d");if(!D)throw Ze(H),new Error("Slide canvas is unavailable");let W=m.kind==="image"&&m.assetId?a.retainAsset(m.assetId):void 0,_=false,J={canvas:H,references:0,cancelled:false,ready:Promise.resolve(),releaseMedia(){_||W?.release();}},y=un(D,()=>!J.cancelled,()=>{D.setTransform(g,0,0,g,-q.x*g,-q.y*g);for(let re of w)mn(D,re),D.beginPath(),D.rect(re.x,re.y,re.w,re.h),D.clip();}),ie=()=>{if(!J.cancelled)return _=true,paintSlide(y,{...t,background:void 0,primitives:[m]},o,i,{resolveImage:re=>(W??a).resolve(re)})};try{J.ready=W?W.ready.then(ie).finally(()=>W.release()):Promise.resolve(ie());}catch(re){W?.release(),J.ready=Promise.reject(re);}J.ready.catch(()=>{}),B=J,p.set(z,B);}k.has(B)||(k.set(B,z),B.references+=1),r.push(B.ready),b.push({tile:B,bounds:q,box:T,line:m.kind==="textBox"?m.lines[0]:void 0});}function E(m,w){for(let T of m)if(T.kind==="chart"||T.kind==="table")E(T.primitives,[...w,T]);else if(T.kind==="textBox")for(let q of T.lines)h({...T,lines:[q]},w,T);else h(T,w);}let v={canvas:f,factor:g,get ready(){return S&&I()},subscribe(m){return c||l.add(m),()=>{l.delete(m);}},plate(m,w){let T=e.createElement("canvas"),q=e.createElement("canvas");T.width=q.width=Math.ceil(w.width*g),T.height=q.height=Math.ceil(w.height*g);try{let O=T.getContext("2d"),z=q.getContext("2d");if(S&&I()&&O&&z){let B=un(O,I,()=>{O.setTransform(g,0,0,g,-w.x*g,-w.y*g);});paintSlide(B,{...t,primitives:[]},o,i).catch(()=>{});let H=!1;for(let D of b){if(D.box?.objectId===m.box.objectId&&D.line?.start===m.line.start&&D.line.end===m.line.end){H=!0;continue}(H?z:O).drawImage(D.tile.canvas,(D.bounds.x-w.x)*g,(D.bounds.y-w.y)*g);}}return {background:T,foreground:q}}catch(O){throw Ze(T),Ze(q),O}}};try{E(t.primitives,[]);}catch(m){throw n(),m}let P=Promise.allSettled(r).then(async m=>{for(let w of m)if(w.status==="rejected")throw w.reason;if(I()&&(await paintSlide(un(d,I),{...t,primitives:[]},o,i),!!I())){for(let w of b)d.drawImage(w.tile.canvas,w.bounds.x*g,w.bounds.y*g);S=true;for(let w of l)w();}}).finally(C);return {raster:v,ready:P,references:0,cancelled:false,release(){this.cancelled=true,n();}}}function mn(e,t){if(!t.transform)return;let o=t.x+t.w/2,i=t.y+t.h/2;e.translate(o,i),e.rotate((t.transform.rotationDeg??0)*Math.PI/180),e.scale(t.transform.flipH?-1:1,t.transform.flipV?-1:1),e.translate(-o,-i);}function pi(e,t,o,i){let a=e.kind==="textBox"?e.lines[0]:void 0,p=e.kind==="textBox"?e.textShadow:e.kind==="shape"||e.kind==="image"?e.shadow:void 0,r=e.kind==="shape"||e.kind==="image"?e.stroke:void 0,u=[r?.headEnd,r?.tailEnd],f=(r?.width??0)*((r?.join??"miter")==="miter"?5:.5)+Math.max(0,...u.map(C=>C&&C.kind!=="none"?Math.hypot(C.length,C.width/2):0))+Math.abs(p?.dx??0)+Math.abs(p?.dy??0)+(p?.blur??0)*3+2,d=a?{x:Math.min(e.x,a.x),y:a.y,w:Math.max(e.x+e.w,a.x+a.width)-Math.min(e.x,a.x),h:a.height}:e,b=[{x:d.x-f,y:d.y-f},{x:d.x+d.w+f,y:d.y-f},{x:d.x-f,y:d.y+d.h+f},{x:d.x+d.w+f,y:d.y+d.h+f}],k=[...t,e];for(let C=k.length-1;C>=0;C-=1){let I=k[C],n=I.x+I.w/2,h=I.y+I.h/2,E=(I.transform?.rotationDeg??0)*Math.PI/180,v=Math.cos(E),P=Math.sin(E);for(let m of b){let w=(m.x-n)*(I.transform?.flipH?-1:1),T=(m.y-h)*(I.transform?.flipV?-1:1);m.x=n+w*v-T*P,m.y=h+w*P+T*v;}}let l=Math.max(0,Math.floor(Math.min(...b.map(C=>C.x))*o)/o),c=Math.max(0,Math.floor(Math.min(...b.map(C=>C.y))*o)/o),S=Math.min(i.width,Math.ceil(Math.max(...b.map(C=>C.x))*o)/o),x=Math.min(i.height,Math.ceil(Math.max(...b.map(C=>C.y))*o)/o);return S>l&&x>c?{x:l,y:c,width:S-l,height:x-c}:null}var It=null;function Nt(e){let t=e.box.textShadow,o=2+(t?.blur??0)*3+Math.abs(t?.dx??0)+Math.abs(t?.dy??0);return {x:e.box.x-o,y:e.line.y-o,width:e.box.w+o*2,height:e.line.height+o*2}}function Wt(e,t,o){return typeof document>"u"||(It||(It=document.createElement("canvas").getContext("2d")),!It||typeof It.measureText!="function")?null:e.line.x+Ao(It,qo(e,t),o-e.line.start)}function Ro(e,t){let i=(t?.scale??1)*(t?.dpr??e.ownerDocument.defaultView?.devicePixelRatio??1),a=()=>!p&&(t?.current?.()??true),p=false,r=0,u,g,f,d,b,k=[],l=new Set;function c(n){!n||--n.references>0||(n.background.width=n.foreground.width=0,n.background.height=n.foreground.height=0);}function S(){let n=g;if(!n)return;let h=()=>{n.ready.then(()=>{!a()||g!==n||!d||(c(f),f=void 0,I(d));}).catch(()=>{});},E=n.raster.subscribe(h);return n.raster.ready||h(),E}function x(n){if(!a()||!n.confirmed)return null;r+=1,d=n,(u!==n.confirmed||!g)&&(b?.(),c(f),f=void 0,g?.release(),u=n.confirmed,g=To(u,i),k=[],b=S());let h=g?.raster;if(!h?.ready)return null;let E=n.activeLine;if(E&&(!f||f.active.box!==E.box||f.active.line!==E.line)){c(f);let v=fi(E),P=Math.ceil((v.x+v.width)*i)/i,m=Math.ceil((v.y+v.height)*i)/i;v.x=Math.floor(v.x*i)/i,v.y=Math.floor(v.y*i)/i,v.width=P-v.x,v.height=m-v.y,f={references:1,active:E,bounds:v,...h.plate(E,v)};}return e.getContext("2d")}function C(n,h){let E=g?.raster;n.save(),n.setTransform(1,0,0,1,0,0);for(let v of k){let P=Math.max(0,Math.floor(v.x*i)),m=Math.max(0,Math.floor(v.y*i)),w=Math.min(e.width,Math.ceil((v.x+v.width)*i))-P,T=Math.min(e.height,Math.ceil((v.y+v.height)*i))-m;!E||w<=0||T<=0||(n.clearRect(P,m,w,T),n.drawImage(E.canvas,P,m,w,T,P,m,w,T));}k=[],n.restore(),d=h;}function I(n){let h=x(n);if(h){if(C(h,n),h.save(),h.setTransform(i,0,0,i,0,0),n.echo&&f){let{bounds:E,active:v}=f;h.clearRect(E.x,E.y,E.width,E.height),h.drawImage(f.background,E.x,E.y,E.width,E.height),k.push(E),h.save();for(let q of v.transforms)mn(h,q),(q.kind==="chart"||q.kind==="table")&&(h.beginPath(),h.rect(q.x,q.y,q.w,q.h),h.clip());h.beginPath();let P=Nt(v);h.rect(P.x,P.y,P.width,P.height),h.clip();let m=qo(v,n.echo),w=q=>Ao(h,m,q-v.line.start),T=v.line.x;for(let q of m){Mo(h,q.style);let O=v.box.textShadow;h.shadowColor=O?.color??"transparent",h.shadowBlur=(O?.blur??0)*i,h.shadowOffsetX=(O?.dx??0)*i,h.shadowOffsetY=(O?.dy??0)*i,h.fillText(q.text,T,v.line.baseline-(q.style.baselineOffsetPx??0));let z=h.measureText(q.text).width;q.style.underline&&h.fillRect(T,v.line.baseline+q.style.fontSizePx*.08,z,Math.max(1,q.style.fontSizePx*.05)),T+=z;}if(h.shadowColor="transparent",h.shadowBlur=0,h.shadowOffsetX=0,h.shadowOffsetY=0,n.composition?.selection){let q=Math.min(n.composition.selection.anchor,n.composition.selection.focus),O=w(q),z=w(q+n.composition.text.length);h.fillStyle="#111827",h.fillRect(v.line.x+Math.min(O,z),v.line.baseline+2,Math.abs(z-O),1);}h.restore(),h.drawImage(f.foreground,E.x,E.y,E.width,E.height);}else if(n.selection&&n.selection.anchor!==n.selection.focus){h.fillStyle="#3b82f640";for(let E of n.selectionRects)E.width<=0||E.height<=0||(h.fillRect(E.x,E.y,E.width,E.height),k.push(E));}h.restore();}}return {checkpoint(){let n=r,h=g?.retain(),E={frame:u,plate:f,latest:d,damaged:[...k]};E.plate&&(E.plate.references+=1);let v=false,P=()=>{v||(v=true,l.delete(P),h?.release(),c(E.plate));};return l.add(P),Object.assign(()=>{if(!v)try{if(!a()||r>n+1)return;r+=1,b?.(),g?.release(),c(f),{frame:u,plate:f,latest:d,damaged:k}=E,f&&(f.references+=1),g=h?.retain(),b=S();}finally{P();}},{commit:P})},attach(n){e=n;},paintEcho:I,restoreLine(n){let h=x(n);h&&C(h,n);},dispose(){if(!p)try{if(a()&&d&&k.length){let n=e.getContext("2d");n&&C(n,d);}}finally{p=true;for(let n of l)n();b?.(),b=void 0,c(f),f=void 0,g?.release(),g=void 0,u=void 0,d=void 0,k=[];}}}}function fi(e){let t=Nt(e),o=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}];for(let p=e.transforms.length-1;p>=0;p-=1){let r=e.transforms[p],u=r.x+r.w/2,g=r.y+r.h/2,f=(r.transform?.rotationDeg??0)*Math.PI/180,d=Math.cos(f),b=Math.sin(f);for(let k of o){let l=(k.x-u)*(r.transform?.flipH?-1:1),c=(k.y-g)*(r.transform?.flipV?-1:1);k.x=u+l*d-c*b,k.y=g+l*b+c*d;}}let i=Math.min(...o.map(p=>p.x)),a=Math.min(...o.map(p=>p.y));return {x:i,y:a,width:Math.max(...o.map(p=>p.x))-i,height:Math.max(...o.map(p=>p.y))-a}}function Mo(e,t){e.font=`${t.italic?"italic ":""}${t.bold?"bold ":""}${t.fontSizePx}px ${JSON.stringify(t.fontFamily)}`,e.fillStyle=t.color,e.letterSpacing=`${t.letterSpacingPx??0}px`,e.textBaseline="alphabetic";}function qo(e,t){let o=e.text,i=t.insertionOffset,a=o.length-i,p=[],r=0;if(!e.line.runs[0])return p;let g=(f,d)=>{if(!f)return;let b=p[p.length-1];b?.style===d?b.text+=f:p.push({text:f,style:d});};for(let f of e.line.runs){let d=r+f.text.length;if(g(o.slice(r,Math.min(d,i)),f),r=d,r>=i)break}g(t.text.slice(i,t.text.length-a),t.insertionStyle),r=0;for(let f of e.line.runs){let d=r+f.text.length,b=Math.max(r,o.length-a);b<d&&g(o.slice(b,d),f),r=d;}return p}function Ao(e,t,o){let i=0,a=Math.max(0,o);for(let p of t){if(a<=0)break;Mo(e,p.style),i+=e.measureText(p.text.slice(0,a)).width,a-=p.text.length;}return i}var gn=16*1024,yi=256,Pn=new WeakMap;function Me(e,t,o){let i=Pn.get(e);i||(i=new Set,Pn.set(e,i)),o?i.add(t):i.delete(t);}function Pt(e){return !!Pn.get(e)?.size}var $e=new WeakMap,_t=class extends Error{constructor(o,i){super("Could not decode the covering presentation frame");a$2(this,"seq",o);a$2(this,"cause",i);a$2(this,"name","PptxFrameDecodeError");}},ct=class extends Error{constructor(o,i){super(`Presentation ${o} refused: ${i.reason}`);a$2(this,"operation",o);a$2(this,"outcome",i);a$2(this,"name","PptxCommandRefusedError");}};function Bo(e,t,{echoEnabled:o=false,onError:i}={}){let a=e.state,p={session:a.session,incarnation:a.incarnation,epoch:a.epoch},r=new Map((a.frame?.media??[]).map(s=>[s.assetId,s.bytes])),u=new Set,g=new Set,f=new Set,d=[],b=new Map,k=new Map,l=new Map,c,S=new Map,x=new Set,C=presentationSharedInputs.get(e),I=new WeakMap,n=a.throughSeq+1,h=a.throughSeq,E=a.throughSeq,v=a.throughSeq,P,m=a.throughSeq,w=a.throughSeq,T=false,q=false,O,z=false,B=false,H,D=a.frame?indexGeometry(decodeCommandDisplayList(a.frame)):{hits:[],lines:new Map},W=null,_=a.frame?.coversThroughSeq===a.throughSeq?{selection:a.selection,run:a.editState.toolbar.echoRun}:null,J=new Map,y={confirmed:a.frame?re(a.frame):null,selection:a.selection,focused:false,caret:null,selectionRects:[],composition:null,echo:null,activeLine:null,activeContextBytes:0,pending:[],waitingInputCount:0,appliedThroughSeq:a.throughSeq,presentedThroughSeq:a.frame?.coversThroughSeq??a.throughSeq,editState:a.editState,thumbnails:new Map,dirtyThumbnailIds:new Set};function ie(s){let R=[];for(let j of frameAssetIds(s.displayList)){let A=r.get(j);A&&!s.frame.media.some($=>$.assetId===j)&&R.push({assetId:j,bytes:A});}return R.length?{...s,frame:{...s.frame,media:[...s.frame.media,...R]}}:s}function re(s){return ie({frame:s,displayList:decodeCommandDisplayList(s)})}function M(){return d.length===0&&b.size===0&&m<=y.presentedThroughSeq}function X(s=false){if(!M()||s&&!T&&w>y.presentedThroughSeq){let j={source:"afterSeq",seq:C?P?.ticket?.seq??E:v};return C&&P&&I.set(j,P),j}let R=y.selection;return R?.kind==="object"?!R.storyId||!y.editState.toolbar.canEditText?null:{source:"confirmed",selection:{slideId:R.slideId,shapeId:R.shapeId,storyId:R.storyId,kind:"shape",anchor:0,focus:0,affinity:"downstream"}}:R?{source:"confirmed",selection:R}:null}function ne(s){for(let R of [...s])!q&&s.has(R)&&R();}function se(){if(y.editState.readOnly||!_?.selection||!_.run||!y.selection||y.selection.kind==="object"||!zo(_.selection,y.selection))return null;let s=findLine(D,y.selection),R=y.selection.focus,j=_.run==="after"?s?.line.runs.find(A=>A.start<=R&&R<A.end)??null:[...s?.line.runs??[]].reverse().find(A=>A.start<R&&R<=A.end)??null;return !j||!yn(j.text)||!/[a-z]/.test(j.text)||(j.letterSpacingPx??0)!==0||(j.baselineOffsetPx??0)!==0||s?.line.runs.some(A=>A.start<=R&&R<=A.end&&(A.fontId!==j.fontId||!yn(A.text)))?null:j}function xe(s){if(!o)return false;let R=se();if(!R||!yn(s))return false;if(!W){W=new Map;for(let A of D.lines.values())for(let{line:$}of A)for(let Q of $.runs){let Z=W.get(Q.fontId);Z||(Z=new Set,W.set(Q.fontId,Z));for(let le of Q.text)Z.add(le);}}let j=W.get(R.fontId);return [...s].every(A=>j?.has(A))}function Ce(){let s=findLine(D,y.selection),R=s?.line.runs.map(fe=>fe.text).join("")??"",j=s&&R.length*2<=gn?{...s,text:R}:null,A="",$=[];for(let fe of y.pending)if(!(jo(fe.intent)||fe.intent.kind==="setReadOnly")){if(!fe.echoed||fe.intent.kind!=="insertText")break;A+=fe.intent.payload.text,$.push(fe.seq);}let Q=se(),Z=B&&d.length===0&&y.pending.every(fe=>fe.echoed&&fe.intent.kind==="insertText")&&xe(y.composition?.text??"")?y.composition:null;Z&&(A+=Z.text);let le=y.selection?.focus??0,F=le-(s?.line.start??0),K=R.slice(0,F)+A+R.slice(F),N=s?transformedRect(s.transforms,{x:s.box.x,y:s.line.y,width:s.box.w,height:s.line.height}):null,de=j&&N&&Q&&xe(A)&&y.selection?.anchor===le&&F>=0&&F<=R.length&&K.length*2<=gn&&($.length>0||Z!==null)?{text:K,sequences:$,bounds:N,caretPosition:le+A.length,insertionOffset:F,insertionStyle:Q}:null,ve=selectionGeometry(D,y.selection);if(de&&j){let fe=Wt(j,de,de.caretPosition);fe!==null&&(ve.caret=transformedRect(j.transforms,{x:fe,y:j.line.y,width:1,height:j.line.height}));}y={...y,activeLine:j,echo:de,activeContextBytes:j?Math.max(R.length,de?.text.length??0)*2:0,...ve};}function oe(){Ce(),y.confirmed&&(t.restoreLine(y),t.paintEcho(y)),ne(u);}function Ae(s){return s.session===p.session&&s.incarnation===p.incarnation&&s.epoch===p.epoch}function L(s){if(q||O||!Ae(s)||s.throughSeq<y.appliedThroughSeq)return;if(s.throughSeq===y.appliedThroughSeq){s.frame&&te(s.frame);return}let R=JSON.stringify(y.editState)!==JSON.stringify(s.editState);if(y.pending.some(F=>lt(F.intent)&&s.outcomes.some(K=>K.seq===F.seq&&K.committed)))for(let F of d){let K="at"in F.intent.payload?F.intent.payload.at:void 0,N=F.after?.ticket?.seq??(K?.source==="afterSeq"?K.seq:void 0);F.after&&F.after.ticket?.seq===void 0||N!==void 0&&N>s.throughSeq||(K?.source==="afterSeq"&&(F.intent=Tt(F.intent,s.throughSeq)),F.after=void 0,F.basis={epoch:s.epoch,version:s.version},F.basisThroughSeq=s.throughSeq);}let j=y.pending.some(F=>F.seq===s.historyThroughSeq&&(F.intent.kind==="applyRemoteUpdate"||F.intent.kind==="collabPipe")),A=y.pending.flatMap(F=>{let K=s.outcomes.find(N=>N.seq===F.seq);return K?.reason&&!x.has(F.seq)&&(K.status==="refused"||K.status==="cancelled")?[new ct(F.intent.kind,K)]:[]});for(let F of s.outcomes)x.delete(F.seq);if(s.historyThroughSeq===s.throughSeq){T=false,w=s.throughSeq;let F=j&&y.composition&&s.selection&&s.selection.kind!=="object"&&s.selection.storyId===y.composition.selection?.storyId?{...y.composition,selection:s.selection}:null;F||(B=false),y={...y,selection:s.selection,composition:F},s.activeSlideId!==null&&s.activeSlideId!==void 0&&(!j||s.activeSlideId!==y.confirmed?.frame.slideId)&&(c={seq:s.throughSeq,slideId:s.activeSlideId});}for(let[F,K]of l){let N=s.outcomes.find(de=>de.seq===F);F<=s.throughSeq&&s.activeSlideId===K&&N?.status!=="refused"&&N?.status!=="cancelled"&&(!c||s.throughSeq>c.seq)&&(c={seq:s.throughSeq,slideId:K});}k.set(s.throughSeq,s.selection),J.set(s.throughSeq,{selection:s.selection,run:s.editState.toolbar.echoRun});let $=new Set(s.outcomes.filter(F=>F.status==="refused"||F.status==="cancelled").map(F=>F.seq));for(let F of y.pending)F.afterSeq!==void 0&&$.has(F.afterSeq)&&$.add(F.seq);let Q=new Set;for(let F of d){let K="at"in F.intent.payload?F.intent.payload.at:void 0;(C?F.after&&(Q.has(F.after)||F.after.ticket?.seq!==void 0&&$.has(F.after.ticket.seq)):K?.source==="afterSeq"&&$.has(K.seq))&&(Q.add(F),C||$.add(F.seq));}y.composition&&[...y.pending.filter(F=>$.has(F.seq)),...Q].some(F=>F.intent.kind==="compositionStart"&&F.intent.payload.compositionId===y.composition?.id)&&(B=false,y={...y,composition:null});for(let F=d.length-1;F>=0;F-=1){let K=d[F];if(!Q.has(K))continue;d.splice(F,1);let N={seq:C?h+F+1:K.seq,status:"cancelled",reason:"dependency-refused",committed:false};K.quiet||A.push(new ct(K.intent.kind,N)),K.resolve({...s,outcomes:[N]});}if(C)P&&Q.has(P)&&(P=[...d].reverse().find(F=>!lt(F.intent)));else {let F=new Map(d.map((K,N)=>[K.seq,h+N+1]));for(let K of d){K.seq=F.get(K.seq);let N="at"in K.intent.payload?K.intent.payload.at:void 0;N?.source==="afterSeq"&&F.has(N.seq)&&(K.intent=Tt(K.intent,F.get(N.seq)));}n=h+d.length+1,v=Math.max(E,[...d].reverse().find(K=>!lt(K.intent))?.seq??0);}y={...y,appliedThroughSeq:s.throughSeq,editState:s.editState,pending:y.pending.filter(F=>!$.has(F.seq)).map(F=>({...F,status:F.seq<=s.throughSeq?"applied":F.status,echoed:F.echoed&&!$.has(F.seq)})),waitingInputCount:d.length};let Z=new Set(y.dirtyThumbnailIds),le=new Map(y.thumbnails);for(let F of s.dirtySlideIds)Z.add(F),le.delete(F);if(s.slides){let F=new Set(s.slides.map(K=>K.id));for(let K of le.keys())F.has(K)||le.delete(K);for(let K of Z)F.has(K)||Z.delete(K);s.activeSlideId===null&&(D={hits:[],lines:new Map},y={...y,confirmed:null,selection:null,caret:null,selectionRects:[],echo:null,activeLine:null,activeContextBytes:0});}y.confirmed||(y={...y,selection:s.selection,presentedThroughSeq:s.throughSeq,pending:y.pending.filter(F=>F.seq>s.throughSeq)},k.clear(),J.clear()),y={...y,thumbnails:le,dirtyThumbnailIds:Z},A.length&&(y={...y,inputFailure:A[A.length-1]}),(s.slides||s.dirtySlideIds.some(F=>F!==y.confirmed?.frame.slideId))&&ne(g),$.size&&oe(),R&&ne(f),s.frame&&te(s.frame),Pe();for(let F of A)try{i?.(F);}catch{}}function te(s){if(q||O||s.incarnation!==p.incarnation||s.documentEpoch!==p.epoch||s.coversThroughSeq<y.presentedThroughSeq)return false;let R=e.state;if(Ae(R)&&R.throughSeq===s.coversThroughSeq){let{slides:N,size:de,...ve}=R;L({...ve,...R.historyThroughSeq===R.throughSeq?{slides:N,size:de}:{},frame:void 0});}let j=y.confirmed?.frame,A=c?.seq===s.coversThroughSeq&&c.slideId===s.slideId,$=s.slideId!==j?.slideId;if($&&!A||j&&!$&&(s.slideRevision<j.slideRevision||s.slideRevision===j.slideRevision&&s.coversThroughSeq<=y.presentedThroughSeq)||s.coversThroughSeq<y.presentedThroughSeq)return false;let Q=y.pending.filter(N=>N.seq<=s.coversThroughSeq);if(!A&&j&&!$&&s.version===j.version&&s.slideRevision===j.slideRevision&&Q.length>0&&Q.every(N=>N.intent.kind==="collabPipe"))return y.confirmed.frame={...s,displayList:j.displayList,media:j.media},_=J.get(s.coversThroughSeq)??_,y={...y,presentedThroughSeq:s.coversThroughSeq,pending:y.pending.filter(N=>N.seq>s.coversThroughSeq)},we(s.coversThroughSeq),Pe(),true;let Z=A?k.get(s.coversThroughSeq)??null:T||w>s.coversThroughSeq?y.selection:k.has(s.coversThroughSeq)?k.get(s.coversThroughSeq):y.selection,le;try{le=re(s);}catch(N){throw C?new _t(s.coversThroughSeq,N):N}let F=C?{view:y,geometry:D,echoContext:_,echoCharacters:W,compositionVisible:B}:void 0,K;try{F&&(K=t.checkpoint?.(o)),_=J.get(s.coversThroughSeq)??(C&&s.coversThroughSeq===y.presentedThroughSeq?_:null),D=indexGeometry(le.displayList),W=null,y.composition&&y.pending.some(de=>de.seq<=s.coversThroughSeq&&de.intent.kind==="compositionStart")&&(B=Z!==null&&Z.kind!=="object"&&Z.anchor===Z.focus,Z&&Z.kind!=="object"&&(y={...y,composition:{...y.composition,selection:Z}}));let N=y.thumbnails;$&&j&&!y.dirtyThumbnailIds.has(j.slideId)&&(N=new Map(N).set(j.slideId,y.confirmed)),y={...y,confirmed:le,selection:Z,thumbnails:N,composition:A?null:y.composition,presentedThroughSeq:s.coversThroughSeq,pending:y.pending.filter(de=>de.seq>s.coversThroughSeq)},Ce(),t.paintFrame(le,y),t.paintEcho(y);}catch(N){if(!F)throw N;return {view:y,geometry:D,echoContext:_,echoCharacters:W,compositionVisible:B}=F,K?.(),false}return K?.commit?.(),A&&(T=false,B=false),we(s.coversThroughSeq),ne(u),$&&ne(g),Pe(),true}function we(s){for(let R of l.keys())R<=s&&l.delete(R);for(let R of k.keys())R<s&&k.delete(R);for(let R of J.keys())R<=s&&J.delete(R);}function ke(){return y.pending.length>=yi||y.pending.some(s=>s.status==="pending"&&!s.echoed&&bn(s.intent))}function pe(s){if(!(q||O)){O=s,d.length=0,b.clear();for(let R of S.values())R(s);y={...y,waitingInputCount:0,editState:{...y.editState,readOnly:true,toolbar:{...y.editState.toolbar,canEditText:false}}},ne(f);}}function ze(s,R){if(C){let A=s.after?.ticket?.seq;A!==void 0&&(R=Tt(R,A)),s.after=void 0,jo(R)&&(w=s.seq);}let j="at"in R.payload?R.payload.at:void 0;R.kind==="activateSlide"&&l.set(s.seq,R.payload.slideId),R.kind==="setSelection"&&R.payload.selection&&R.payload.selection.slideId!==y.confirmed?.frame.slideId&&l.set(s.seq,R.payload.selection.slideId),s.quiet&&x.add(s.seq),Pi(R)&&(m=Math.max(m,s.seq),R.kind!=="collabPipe"&&(T=false)),y={...y,pending:[...y.pending,{seq:s.seq,basisThroughSeq:s.basisThroughSeq,afterSeq:j?.source==="afterSeq"?j.seq:void 0,intent:R,status:"pending",echoed:s.echoed}]},h=s.seq,lt(R)||(E=s.seq),R.kind!=="collabPipe"&&oe();}function pt(s){let R=s.intent;(R.kind==="undo"||R.kind==="redo"||R.kind==="activateSlide"||R.kind==="insertTextBox"||R.kind==="insertShape"||R.kind==="insertPicture"||R.kind==="applyEdits"||R.kind==="registerFont"||R.kind==="invoke")&&(s.basis={epoch:p.epoch,version:e.state.version},s.basisThroughSeq=e.state.throughSeq),R.kind==="insertText"&&s.chunks.length&&(R={...R,payload:{...R.payload,text:R.payload.text+s.chunks.join("")}});let j;if(C){let A=s.after?.ticket;A?.seq!==void 0&&(R=Tt(R,A.seq));let $;try{$=C.submit(R,s.basis,A);}catch(Q){pe(Q),s.reject(Q);return}if(s.ticket=$.ticket,j=$.operation,s.ticket.seq===void 0){b.set(s,R),j.then(Q=>{b.delete(s),tt(s,Q);},Q=>{pe(Q),s.reject(Q);});return}s.seq=s.ticket.seq;}ze(s,R);try{(j??e.dispatch(R,s.basis)).then(A=>{C?tt(s,A):(L(A),s.resolve(A));},A=>{pe(A),s.reject(A);});}catch(A){pe(A),s.reject(A);}}function tt(s,R){try{L(R),s.resolve(R);}catch(j){if(s.reject(j),j instanceof _t){try{i?.(j);}catch{}Pe();}else pe(j);}}function Pe(){if(!(z||q||O)){z=true;try{for(;d.length&&!ke();){let s=d.shift();y={...y,waitingInputCount:d.length},pt(s);}}finally{z=false;}}}let Le={getSnapshot:()=>y,subscribePresentation:s=>Ie(u,s),subscribeStructure:s=>Ie(g,s),subscribeEditState:s=>Ie(f,s),dispatch(s,{reportRefusal:R=true}={}){if(q)return Promise.reject(new PptxWorkerEditorDisposedError);if(O)return Promise.reject(O);y.inputFailure&&(y={...y,inputFailure:void 0});let j=M(),A=C?P?.ticket?.seq??E:v,$="at"in s.payload?s.payload.at:void 0,Q=C&&!j&&("at"in s.payload||s.kind==="setSelection"||s.kind==="compositionEnd")?P:$&&I.get($);!j&&("at"in s.payload||s.kind==="setSelection"||s.kind==="compositionEnd")&&(s=Tt(s,A)),j&&s.kind==="setSelection"&&(y={...y,selection:s.payload.selection});let Z=d[d.length-1];if(Z?.intent.kind==="insertText"&&!Z.echoed&&s.kind==="insertText"&&s.payload.at.source==="afterSeq"&&(C?Q===Z:s.payload.at.seq===Z.seq)&&s.payload.undoGroup===Z.intent.payload.undoGroup&&s.payload.style===Z.intent.payload.style&&s.payload.inputTime===Z.intent.payload.inputTime)return Z.chunks.push(s.payload.text),Z.echoed=false,Z.operation;let le=C?0:n++;!C&&!lt(s)&&(v=le),j&&s.kind==="setSelection"&&(w=le,T=false);let F=d.length===0&&!ke()&&s.kind==="insertText"&&s.payload.style===void 0&&xe(s.payload.text)&&y.selection!==null&&y.selection.anchor===y.selection.focus&&!!y.activeLine&&(s.payload.at.source==="afterSeq"?s.payload.at.seq===A&&[...y.pending,...d].some(he=>he.seq===A&&he.echoed&&he.intent.kind==="insertText"):j&&zo(s.payload.at.selection,y.selection))&&y.pending.every(he=>he.echoed&&he.intent.kind==="insertText")&&(y.echo?.text.length??y.activeLine.text.length)*2+s.payload.text.length*2<=gn,K,N,de=new Promise((he,nt)=>{K=he,N=nt;});S.set(de,N),de.then(()=>{S.delete(de);},()=>{S.delete(de);});let ve={seq:le,intent:s,after:Q,basisThroughSeq:y.presentedThroughSeq,basis:{epoch:p.epoch,version:y.confirmed?.frame.version??e.state.version},echoed:F,quiet:!R,chunks:[],operation:de,resolve:K,reject:N},fe;if(s.kind==="selectAtPoint"&&!s.payload.drag){let he=hitGeometry(D,s.payload);fe=he?.kind==="text"?{slideId:s.payload.frame.slideId,shapeId:he.shapeId,storyId:he.storyId,anchor:he.position,focus:he.position,affinity:he.affinity??"downstream"}:null;}else s.kind==="setSelection"?fe=s.payload.selection:(s.kind==="selectObject"||s.kind==="activateSlide")&&(fe=null);if(fe!==void 0){let he={inTableCell:!!navigateGeometry(D,fe,"nextCell",false)};H=he;let nt=()=>{H===he&&(H=void 0);};de.then(nt,nt);}return lt(s)||(P=ve),d.length||ke()?(d.push(ve),y={...y,waitingInputCount:d.length},s.kind!=="collabPipe"&&ne(u)):pt(ve),de},async fence(){if(q)throw new PptxWorkerEditorDisposedError;if(O)throw O;if(await Promise.all([...S.keys()]),q)throw new PptxWorkerEditorDisposedError;if(O)throw O},setSelection(s){if(!(q||O)){if(!M()){Le.dispatch({kind:"setSelection",payload:{selection:s,inputTime:performance.now(),undoGroup:"selection"}}).catch(()=>{});return}T=true,y={...y,selection:s},oe();}},setFocused(s){q||s===y.focused||(y={...y,focused:s},oe());},beginComposition(s,R){let j=X(true),A=y.selection;if(q||O||y.composition||!j||A?.kind==="object"&&j.source!=="afterSeq")return;let $=A?.kind==="object"?null:A;B=M()&&$!==null&&$.anchor===$.focus,y={...y,composition:{id:s,selection:$,text:""}},Le.dispatch({kind:"compositionStart",payload:{compositionId:s,at:j,inputTime:R,undoGroup:s}}).catch(()=>{});},updateComposition(s){q||O||!y.composition||(y={...y,composition:{...y.composition,text:s}},oe());},installMedia(s){if(q||O||!s.length)return;for(let Q of s)r.set(Q.assetId,Q.bytes);let R=y.confirmed&&ie(y.confirmed),j=new Map(y.thumbnails),A=false;for(let[Q,Z]of j){let le=ie(Z);le!==Z&&(j.set(Q,le),A=true);}if(R===y.confirmed&&!A)return;let $=R!==y.confirmed;y={...y,confirmed:R,thumbnails:A?j:y.thumbnails},$&&R&&(t.paintFrame(R,y),t.paintEcho(y),ne(u)),A&&ne(g);},installThumbnail(s){if(q||s.incarnation!==p.incarnation||s.documentEpoch!==p.epoch)return false;let R=y.thumbnails.get(s.slideId);if(R&&R.frame.slideRevision>=s.slideRevision)return false;let j=new Map(y.thumbnails);j.set(s.slideId,re(s));let A=new Set(y.dirtyThumbnailIds);return A.delete(s.slideId),y={...y,thumbnails:j,dirtyThumbnailIds:A},ne(g),true},dispose(){if(!q){q=true,ft(),mt(),Xe(),ht(),vt?.(),d.length=0,b.clear();for(let s of S.values())s(new PptxWorkerEditorDisposedError);u.clear(),g.clear(),f.clear(),k.clear(),J.clear(),S.clear(),l.clear(),r.clear(),$e.delete(Le);}}};function Ie(s,R){return q||s.add(R),()=>{s.delete(R);}}$e.set(Le,{install:te,known:M,reference:X,hit:(s,R)=>hitGeometry(D,s,void 0,R),navigate:(s,R)=>navigateGeometry(D,y.selection,s,R),inTableCell:()=>H?.inTableCell??!!navigateGeometry(D,y.selection,"nextCell",false),finishComposition(){let s=y.composition,R=X();return s?(y={...y,composition:null},B=false,oe(),R?{...s,at:R}:null):null}});let ft=e.subscribe(L),mt=e.subscribeFrame(te),Xe=e.subscribeMedia(s=>Le.installMedia(s)),ht=e.subscribeFailure(s=>pe(s)),vt=C?.subscribeSent(()=>{for(let[s,R]of b){let j=s.ticket?.seq;j!==void 0&&(b.delete(s),s.seq=j,ze(s,R));}});return Ce(),y.confirmed&&t.paintFrame(y.confirmed,y),Le}function Tt(e,t){let o={source:"afterSeq",seq:t};switch(e.kind){case "moveShape":return "delta"in e.payload?{...e,payload:{...e.payload,at:o}}:e;case "insertText":return {...e,payload:{...e.payload,at:o}};case "replaceText":return {...e,payload:{...e.payload,at:o}};case "formatText":return {...e,payload:{...e.payload,at:o}};case "setParagraphAlignment":return {...e,payload:{...e.payload,at:o}};case "deleteBackward":return {...e,payload:{...e.payload,at:o}};case "deleteForward":return {...e,payload:{...e.payload,at:o}};case "paragraphBreak":return {...e,payload:{...e.payload,at:o}};case "compositionStart":return {...e,payload:{...e.payload,at:o}};case "compositionCommit":return {...e,payload:{...e.payload,at:o}};case "compositionEnd":return {...e,payload:{...e.payload,at:o}};case "setSelection":return {...e,payload:{...e.payload,at:o}};case "moveSelection":return {...e,payload:{...e.payload,at:o}};case "selectAtPoint":return {...e,payload:{...e.payload,at:o}};default:return e}}function bn(e){return e.kind==="collabPipe"?e.payload.ops.some(t=>t.op==="event"&&t.event.type==="message"):["insertText","replaceText","deleteBackward","deleteForward","paragraphBreak","compositionCommit","formatText","setParagraphAlignment","undo","redo","moveShape","setShapeRect","insertTextBox","insertShape","insertPicture","applyEdits","registerFont","applyRemoteUpdate","invoke"].includes(e.kind)}function jo(e){return e.kind==="setSelection"&&e.payload.at?.source!=="afterSeq"}function lt(e){return e.kind==="collabPipe"?!bn(e):e.kind==="invoke"&&["setSlideNotes","addComment","replyToComment","setCommentStatus","setCommentPosition","removeComment","setCommentFlavor"].includes(e.payload.method)}function Pi(e){return e.kind==="activateSlide"||e.kind==="selectObject"||bn(e)&&!lt(e)||e.kind==="moveSelection"||e.kind==="selectAtPoint"||e.kind==="compositionStart"||e.kind==="setSelection"&&e.payload.at?.source==="afterSeq"}function zo(e,t){return e.slideId===t.slideId&&e.shapeId===t.shapeId&&e.storyId===t.storyId&&e.anchor===t.anchor&&e.focus===t.focus&&e.affinity===t.affinity&&e.kind===t.kind}function yn(e){return !/[^\u0020-\u007e\u00a0-\u00ff]/.test(e)}function Ho(e,t){return $e.get(e)?.install(t)??false}function Rt(e,t,o){return $e.get(e)?.hit(t,o)??null}function Mt(e){return $e.get(e)?.known()??false}function Ge(e,t=false){return $e.get(e)?.reference(t)??null}function Uo(e,t,o=false,i){let a=Sn(t,i);return !Mt(e)||!a?null:$e.get(e)?.navigate(a,o)??null}function Go(e){return $e.get(e)?.inTableCell()??false}function Sn(e,t){let i=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?t?.altKey:t?.ctrlKey;switch(e){case "ArrowLeft":return t?.metaKey?"lineStart":i?"wordLeft":"left";case "ArrowRight":return t?.metaKey?"lineEnd":i?"wordRight":"right";case "Home":return t?.metaKey||t?.ctrlKey?"storyStart":"lineStart";case "End":return t?.metaKey||t?.ctrlKey?"storyEnd":"lineEnd";case "ArrowUp":return "up";case "ArrowDown":return "down";case "Tab":return t?.altKey||t?.ctrlKey||t?.metaKey?null:t?.shiftKey?"previousCell":"nextCell";default:return null}}function Be(e,t,o){let i=$e.get(e)?.finishComposition();if(!i)return Promise.resolve(null);let a=t?e.dispatch({kind:"compositionCommit",payload:{compositionId:i.id,at:i.at,text:t,inputTime:o,undoGroup:i.id}}):null,p=e.dispatch({kind:"compositionEnd",payload:{compositionId:i.id,inputTime:o,undoGroup:i.id,...t?{}:{cancelled:true}}});return a?(p.catch(()=>{}),a):p}function Ko(e){if(!e.selection||!e.editState.toolbar.canEditText)return null;let{formatting:t,alignment:o}=e.editState.toolbar;return {kind:e.selection.kind==="shape"||e.selection.kind==="object"?"shape":e.selection.anchor===e.selection.focus?"caret":"range",bold:t?.bold??"mixed",italic:t?.italic??"mixed",underline:t?.underline==null?"mixed":t.underline!=="none",fontFamily:t?.fontFamily??null,fontSize:t?.fontSizePt??null,color:t?.color??null,alignment:o}}function Xt(e,t,o=performance.now()){let i=e.getSnapshot(),a=Ge(e,true);if(!a||i.editState.readOnly||i.composition)return null;let p={at:a,inputTime:o,undoGroup:"format"};if(typeof t!="string"&&t.type==="fontSizeStep")return e.dispatch({kind:"formatText",payload:{...p,patch:{},fontSizeStep:{direction:t.direction,sizes:[...t.sizes]}}});if(typeof t!="string"&&t.type==="align")return e.dispatch({kind:"setParagraphAlignment",payload:{...p,alignment:t.value}});let r=i.editState.toolbar.formatting,u;switch(t){case "bold":u={bold:r?.bold!==true};break;case "italic":u={italic:r?.italic!==true};break;case "underline":u={underline:r?.underline!=null&&r.underline!=="none"?"none":"sng"};break;default:switch(t.type){case "fontFamily":u={fontFamily:t.value};break;case "fontSize":u={fontSizePt:t.value};break;case "textColor":u={color:t.value};break;default:return null}}return e.dispatch({kind:"formatText",payload:{...p,patch:u,...typeof t=="string"?{toggle:t}:{}}})}function xn(e,t,o=performance.now()){return e.getSnapshot().editState.readOnly?null:(Be(e,"",o).catch(()=>{}),e.dispatch({kind:t,payload:{inputTime:o,undoGroup:"history"}}))}function No(e,t){if(e.defaultPrevented||e.target!==e.currentTarget||e.altKey||!(e.ctrlKey||e.metaKey))return;let o=e.key.toLowerCase(),i=o==="z"?e.shiftKey?"redo":"undo":o==="y"&&!e.shiftKey?"redo":null;i&&(e.preventDefault(),e.repeat||xn(t,i,e.timeStamp)?.catch(()=>{}));}function Yt(e,t){let o=e.client.state.slides.find(i=>i.id===e.client.state.activeSlideId);return De(e,{method:"insertSlide",args:[o?o.index+1:0,t===void 0?o?.layoutPartPath??void 0:t??void 0]})}function vn(e,t,o){return De(e,{method:"moveSlide",args:[t,o]})}function Wo(e,t){return De(e,{method:"deleteSlide",args:[t]})}var bi=new Set(["bold","italic","underline","fontFamily","fontSize","fontSizeStep","textColor","alignment","tool","insertImage","save","undo","redo","shapeFill","shapeStrokeColor","shapeStrokeWidth","shapeAdjustment","zOrder","insertSlide","zoom","proposalsPanel","proposalSelect","proposalDiff","proposalAccept","proposalReject","slideshow","exportPng"]);function Yo(e){let t=e.store.getSnapshot().selection;return t?JSON.stringify([t.slideId,t.shapeId,t.storyId,t.kind,t.anchor,t.focus]):null}function Jo(e,t){if(!e)return {ok:false,failure:m("unsupported-selection",t)};let o=e.outcomes.find(i=>i.status==="refused"||i.status==="cancelled");if(o){let i=o.reason==="read-only"?"read-only":o.reason==="bad-target"||o.reason==="stale-basis"?"target-changed":o.reason==="invalid-payload"||o.reason==="invalid-offset"?"invalid-arguments":"input-failed";return {ok:false,failure:m(i,t)}}return {ok:true,status:e.outcomes.some(i=>i.status==="applied")?"executed":"noop"}}function Zo(e,{tool:t,setTool:o,openPicture:i,save:a,focus:p,i18n:r,zoom:u,setZoom:g,review:f,proposals:d,setReview:b$1,exportPng:k}){let{t:l}=b(),c=useMemo(()=>x$1(),[e]),S=useMemo(()=>({environment:I=>{let n=e?.store.getSnapshot(),h=n?Ko(n):null,E=n?.pending[n.pending.length-1]?.intent;!h&&I&&e&&E?.kind==="selectAtPoint"&&Rt(e.store,E.payload)?.kind==="text"&&(h={kind:"caret",bold:"mixed",italic:"mixed",underline:"mixed",fontFamily:null,fontSize:null,color:null,alignment:null});let v=n?.confirmed?.frame.slideId,P=e?.client.state.slides.find(m=>m.id===v);return {status:e?.current?"ready":"unavailable",readOnly:n?.editState.readOnly??true,reviewing:f.diff,pendingInput:!!((n?.pending.length||n?.waitingInputCount)&&(!n?.editState.canUndo||n?.pending.some(m=>m.intent.kind==="undo"||m.intent.kind==="redo"))),canUndo:n?.editState.canUndo??false,canRedo:n?.editState.canRedo??false,slide:P?{id:P.id,layoutPartPath:P.layoutPartPath}:null,layouts:[...new Set(e?.client.state.slides.flatMap(m=>m.layoutPartPath?[m.layoutPartPath]:[]))].map((m,w)=>({value:m,label:l("toolbar.layoutOption",{number:w+1}),args:{layoutPartPath:m}})),text:h,shape:n?.editState.object??null,tool:t,zoom:u,fontFamilies:r$1,fontSizes:s,proposals:{open:f.open,pending:d.map(m=>({id:m.id,label:m.note??m.agentId,stale:m.staleTargets.length>0})),canvas:{available:d.filter(m=>m.changes.some(w=>w.slideId===v)).map(m=>({id:m.id,label:m.note??m.agentId,stale:m.staleTargets.length>0})),selectedId:f.selectedId,diff:f.diff}},hostDisabled:m=>!bi.has(m),translate:l}},ordered:I=>I!=="tool"&&I!=="insertImage",admit(I){try{return e?.require(),Promise.resolve(I())}catch{return Promise.reject(new w("input-failed"))}},capture(I){return e?.current?{generation:0,run:e,id:I,slideId:e.store.getSnapshot().confirmed?.frame.slideId??null,target:Yo(e)}:null},resume(I){let n=I;return !e?.current||n.run!==e?"document-replaced":n.slideId!==(e.store.getSnapshot().confirmed?.frame.slideId??null)||!["undo","redo","save","tool","insertImage"].includes(n.id)&&n.target!==Yo(e)?"target-changed":null},async perform(I,n,h){if(!e?.current)return {ok:false,failure:m("editor-unavailable",h)};let E=w=>Xt(e.store,w),v=null;switch(I){case "zoom":return g(n.scale),{ok:true,status:"executed"};case "proposalsPanel":return b$1({...f,open:n===null?!f.open:n.open}),{ok:true,status:"opened"};case "proposalSelect":return flushSync(()=>b$1({...f,selectedId:n.proposalId})),{ok:true,status:"executed"};case "proposalDiff":{let w=n.enabled,T=e.store.getSnapshot().composition;if(w&&T){let q=await Be(e.store,T.text,performance.now()),O=Jo(q,h);if(!O.ok)return O;await e.store.fence(),e.require();}return flushSync(()=>b$1({...f,diff:w})),{ok:true,status:"executed"}}case "slideshow":return await e.store.fence(),b$1({...f,presenting:true}),{ok:true,status:"opened"};case "exportPng":return await k(),{ok:true,status:"executed"};case "proposalAccept":v=De(e,{method:"acceptProposal",args:[n.proposalId,{force:n.force}]}),b$1({...f,diff:false});break;case "proposalReject":v=De(e,{method:"rejectProposal",args:[n.proposalId]}),b$1({...f,diff:false});break;case "insertSlide":v=Yt(e,n.layoutPartPath);break;case "shapeFill":v=Je(e,{kind:"fill",color:n.color});break;case "shapeStrokeColor":v=Je(e,{kind:"strokeColor",color:n.color});break;case "shapeStrokeWidth":v=Je(e,{kind:"strokeWidth",points:n.points});break;case "shapeAdjustment":v=Je(e,{kind:"adjust",...n});break;case "zOrder":v=Je(e,{kind:"zOrder",value:n.value});break;case "tool":return o(n.value),{ok:true,status:"executed"};case "insertImage":return i(),{ok:true,status:"opened"};case "save":return await a(),{ok:true,status:"executed"};case "undo":case "redo":v=xn(e.store,I);break;case "bold":case "italic":case "underline":v=E(I);break;case "fontFamily":v=E({type:"fontFamily",value:n.family});break;case "fontSize":v=E({type:"fontSize",value:n.points});break;case "fontSizeStep":v=E({type:"fontSizeStep",direction:n.direction,sizes:h.fontSizes});break;case "textColor":v=E({type:"textColor",value:n.color});break;case "alignment":v=E({type:"align",value:n.value});break;default:return {ok:false,failure:m("unsupported-command",h)}}let P=await v;e.require();let m$1=Jo(P,h);return m$1.ok&&p(),m$1},chrome:()=>({i18n:r}),focusEditor:p}),[e,t,o,i,a,p,r,u,g,f,d,b$1,k,l]);return useLayoutEffect(()=>(c.attach(S),()=>c.detach(S)),[c,S]),useLayoutEffect(()=>{if(!e)return;let x=JSON.stringify(S.environment(false)),C=()=>{let n=JSON.stringify(S.environment(false));x!==n&&(x=n,c.refresh());},I=[e.store.subscribeEditState(C),e.store.subscribePresentation(C)];return ()=>{for(let n of I)n();}},[c,e,S]),c.store}function Jt(e){let t=Math.fround(Math.fround(e)*Math.fround(.00010498687664041995));for(let o=1;o<=9;o++){let i=Number(t.toPrecision(o));if(Math.fround(i)===t)return i}return t}var nr={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",tif:"image/tiff",tiff:"image/tiff",webp:"image/webp",svg:"image/svg+xml"},xi={async prepare(e,t){let o=e.type==="image/jpg"?"image/jpeg":e.type||nr[e.name.split(".").pop()?.toLowerCase()??""];if(e.size===0||e.size>8*1024*1024||!Object.values(nr).includes(o))throw new Error("Unsupported picture type or size");let i=await e.arrayBuffer(),a=o==="image/tiff"?await t.client.preparePicture?.(i):null;if(o==="image/tiff"&&!a)throw new Error("Picture conversion unavailable");let p=a?new Blob([a],{type:"image/png"}):e,r=URL.createObjectURL(p);try{let u=new Image,g=await new Promise((f,d)=>{u.onload=()=>f({width:u.naturalWidth,height:u.naturalHeight}),u.onerror=()=>d(new Error("Could not decode picture")),u.src=r;});if(!(g.width>0&&g.height>0))throw new Error("Invalid picture dimensions");return {bytes:i,contentType:o,...g}}finally{URL.revokeObjectURL(r);}}};function kn(e){let t=e?.store.getSnapshot().confirmed?.frame.slideId;return e?.inputEnabled&&t?{run:e,slideId:t}:null}function Cn(e){if(e.run.require(),!e.run.inputEnabled||e.run.store.getSnapshot().confirmed?.frame.slideId!==e.slideId||!e.run.client.state.slides.some(t=>t.id===e.slideId))throw new Error("Picture target changed")}async function or(e,t){Cn(e);let o=await xi.prepare(t,e.run);Cn(e);let i=e.run,a=i.client.state.size,p=i.store.getSnapshot().confirmed.displayList,r=Math.min(p.width*.5/o.width,p.height*.5/o.height,1),u=o.width*r*a.width/p.width,g=o.height*r*a.height/p.height,f={x:Math.round((a.width-u)/2),y:Math.round((a.height-g)/2),width:Math.max(1,Math.round(u)),height:Math.max(1,Math.round(g))},d=await i.store.dispatch({kind:"insertPicture",payload:{...o,slideId:e.slideId,name:t.name||"Picture",rect:f,inputTime:performance.now(),undoGroup:"picture"}});return i.require(),d}function rr(e,t,o){let{t:i}=b(),[a,p]=useState("select"),[r,u]=useState(null),[g,f]=useState(null),d=useRef(null),b$2=useRef(null),k=useCallback(()=>{let I=b$2.current;I&&Me(I.origin.run.store,"insertion",false),b$2.current=null,I?.element.releasePointerCapture?.(I.pointerId),u(null),d.current=null,f(null);},[]),l$1=useCallback(I=>{d.current=null,f(null),p(I);},[]);useEffect(()=>(l$1("select"),k),[e,k]),useEffect(()=>{window.addEventListener("blur",k);let I=()=>{b$2.current&&(!e?.inputEnabled||e.store.getSnapshot().confirmed?.frame.slideId!==b$2.current.origin.slideId)&&k();let E=d.current;if(!E)return;let v=e?.getVisualSnapshot()?.view.confirmed?.frame;(!e?.inputEnabled||e.store.getSnapshot().confirmed?.frame.slideId!==E.origin.slideId||v?.slideId!==E.origin.slideId||E.seq!==void 0&&v.coversThroughSeq>=E.seq)&&(d.current=null,f(null));},n=e?.store.subscribePresentation(I),h=e?.subscribeVisual(I);return ()=>{window.removeEventListener("blur",k),n?.(),h?.();}},[e,k]);let c=I=>{let n=e?.getVisualSnapshot()?.view.confirmed;return n&&t.current?b$1(t.current.getBoundingClientRect(),n.displayList,I.clientX,I.clientY):null},S=I=>{if(a==="select")return false;let n=kn(e),h=c(I);return !n||!h||I.button!==0||I.isPrimary===false||(k(),b$2.current={origin:n,start:h,end:h,pointerId:I.pointerId,element:I.currentTarget,tool:a},Me(n.run.store,"insertion",true),I.currentTarget.setPointerCapture?.(I.pointerId),I.preventDefault()),true},x=I=>{let n=b$2.current;if(!n||n.pointerId!==I.pointerId)return false;let h=c(I);return h&&(n.end=h,u({x:Math.min(n.start.x,h.x),y:Math.min(n.start.y,h.y),width:Math.abs(n.start.x-h.x),height:Math.abs(n.start.y-h.y)})),true},C=I=>{let n=b$2.current;if(!n||n.pointerId!==I.pointerId)return false;let h=c(I)??n.end;k();try{Cn(n.origin);}catch{return true}let E=n.origin.run.store.getSnapshot().confirmed.displayList,v=n.origin.run.client.state.size,P=Math.abs(h.x-n.start.x)>=6||Math.abs(h.y-n.start.y)>=6,m=n.tool==="textBox",w=P?Math.abs(h.x-n.start.x):E.width*(m?.36:.22),T=P?Math.abs(h.y-n.start.y):E.height*(m?.12:.18),q=Math.max(0,Math.min(P?Math.min(n.start.x,h.x):n.start.x-(m?0:w/2),E.width-w)),O=Math.max(0,Math.min(P?Math.min(n.start.y,h.y):n.start.y-(m?0:T/2),E.height-T)),z={x:Math.round(q*v.width/E.width),y:Math.round(O*v.height/E.height),width:Math.round(Math.max(12,w)*v.width/E.width),height:Math.round(Math.max(12,T)*v.height/E.height)},B={slideId:n.origin.slideId,inputTime:I.timeStamp,undoGroup:"insertion"},H=l(n.tool),D=m?{origin:n.origin,rect:{x:Jt(z.x),y:Jt(z.y),width:Jt(z.width),height:Jt(z.height)}}:null;d.current=D,f(D);let W=m?n.origin.run.store.dispatch({kind:"insertTextBox",payload:{...B,draft:{name:i("objects.defaultTextBoxName"),rect:z,text:"",style:DEFAULT_EDITOR_TEXT_STYLE}}}):H?n.origin.run.store.dispatch({kind:"insertShape",payload:{...B,draft:{name:H,rect:z,geometry:H,fill:"#d9eaf7"}}}):null;p("select"),W&&m&&o();let _=()=>{d.current===D&&(d.current=null,f(null));};return W?.then(J=>{if(!D||d.current!==D)return;if(J.outcomes.some(ie=>ie.seq===J.throughSeq&&ie.status==="refused")){_();return}D.seq=J.throughSeq;let y=n.origin.run.getVisualSnapshot()?.view.confirmed?.frame;(!n.origin.run.inputEnabled||y?.slideId!==D.origin.slideId||y.coversThroughSeq>=D.seq)&&_();},_),true};return {tool:a,preview:r,echo:g?.origin.run===e?g:null,setTool:l$1,cancel:k,onPointerDown:S,onPointerMove:x,onPointerUp:C,onPointerCancel:I=>{b$2.current?.pointerId===I.pointerId&&k();}}}function ir({input:e,origin:t,onError:o}){let{t:i}=b(),a=useRef(false);return jsx("input",{ref:e,type:"file",accept:"image/png,image/jpeg,image/gif,image/bmp,image/tiff,image/webp,image/svg+xml","aria-label":i("objects.insertPicture"),style:{display:"none"},onChange:p=>{let r=p.currentTarget.files?.[0],u=t.current;t.current=null,p.currentTarget.value="",!(!r||!u||a.current)&&(a.current=true,or(u,r).catch(g=>{u.run.current&&o(g instanceof Error?g:new Error(String(g)));}).finally(()=>{a.current=false;}));}})}function En(e,t,o,i=40){return e<=0||t<=0||o.width<=0||o.height<=0?0:Math.min(1,(e>i?e-i:e)/o.width,(t>i?t-i:t)/o.height)}var qt={reportRefusal:false};function Ii(e){throw new PptxWorkerUnsupportedError(e)}function At(e,t,o,i){e.require();let a=t.getBoundingClientRect();if(!a.width||!a.height||o<a.left||o>a.right||i<a.top||i>a.bottom)return null;let p=e.getVisualSnapshot()?.view.confirmed;if(!p)return null;let r={x:(o-a.left)*p.displayList.width/a.width,y:(i-a.top)*p.displayList.height/a.height},u=hitGeometry(indexGeometry(p.displayList),r);return u?{...u,slide:p.frame.slideIndex+1,slideId:p.frame.slideId}:null}function sr(e,t,o,i){function a(){if(e.require(),Pt(e.store))throw new w("gesture-active")}async function p(l){a(),await e.store.fence(),a();let c=await l();return e.require(),c}async function r(){e.require(),await e.ready,e.require();}let u=(l,...c)=>p(()=>e.client.access?.(l,...c)??Promise.reject(new PptxWorkerUnsupportedError(l))),g=async(l,c)=>{a();let S=e.store.dispatch({kind:"registerFont",payload:{font:{...l,bytes:l.bytes.slice().buffer},fallback:c,inputTime:performance.now(),undoGroup:"font"}},qt);await e.installFont(l);let x=await S;if(e.require(),x.fontId===void 0)throw new Error(x.outcomes[0]?.reason??"Font registration refused");return await e.client.flush(),await r(),x.fontId},f=async l=>{if(a(),!Number.isSafeInteger(l)||l<1||l>e.client.state.slides.length)return false;let c=e.client.state.slides[l-1].id,S=await e.store.dispatch({kind:"activateSlide",payload:{slideId:c}},qt);return await r(),!S.outcomes.some(x=>x.status==="refused"||x.status==="cancelled")&&e.store.getSnapshot().confirmed?.frame.slideId===c},d={get commands(){return e.require(),i??Ii("commands")},get hydrated(){return e.require(),e.hydrated},get failure(){return e.failure},save:()=>p(()=>e.client.save()),saveAsync:()=>d.save(),recoverySave:()=>e.recover(),whenHydrated:r,handleAsync:async()=>(await r(),k),flushPendingInput:()=>p(async()=>{await e.client.flush(),await r();}),version:()=>p(async()=>(await e.client.flush()).version),readContent:l=>p(async()=>(await e.client.read(l)).result),findText:l=>u("findText",l),exportStructured:l=>u("exportStructured",l),exportMarkdown:l=>u("exportMarkdown",l),validateEdits:l=>u("validateEdits",l),applyEdits:async l=>{if(a(),e.store.getSnapshot().editState.readOnly)return {ok:false,version:(await p(()=>e.client.flush())).version,failure:{code:"read-only",message:"The editor is read-only"}};let c=await e.store.dispatch({kind:"applyEdits",payload:{request:l,inputTime:performance.now(),undoGroup:"batch"}},qt);return e.require(),await r(),c.editResult??{ok:false,version:c.version,failure:{code:c.outcomes[0]?.reason==="read-only"?"read-only":"invalid-step",message:c.outcomes[0]?.reason??"Edit batch refused"}}},selectText:async l=>{if(a(),!Number.isSafeInteger(l.slide)||l.slide<1||l.slide>e.client.state.slides.length)return false;let c=e.client.state.slides[l.slide-1].id,S=await e.store.dispatch({kind:"setSelection",payload:{selection:{slideId:c,shapeId:l.shapeId,storyId:l.storyId,anchor:l.start,focus:l.end,affinity:"downstream"},inputTime:performance.now(),undoGroup:"selection"}},qt);return await r(),!S.outcomes.some(x=>x.status==="refused"||x.status==="cancelled")},goToSlide:f,goToSlideAsync:f,refresh:()=>p(async()=>{await e.client.flush(),await r();}),refreshProposals:async()=>{await u("listProposals");},clearSelection:async()=>{a(),await e.store.dispatch({kind:"setSelection",payload:{selection:null,inputTime:performance.now(),undoGroup:"selection"}}),await r();},focus(){e.require(),o();},getPositionAtPoint:(l,c)=>p(async()=>(await r(),At(e,t,l,c)))},b=Object.fromEntries(PRESENTATION_COMMAND_MUTATIONS.map(l=>[l,async(...c)=>{a();let S=await De(e,{method:l,args:c},qt);e.require();let x=S.outcomes.find(C=>C.status==="refused"||C.status==="cancelled");if(x)throw new w(x.reason==="invalid-payload"?"invalid-arguments":x.reason==="read-only"?"read-only":"target-changed");return await r(),S.mutationResult}])),k=Object.freeze({...b,encodeStateVector:()=>u("encodeStateVector"),encodeStateAsUpdate:l=>u("encodeStateAsUpdate",l),previewProposal:l=>u("previewProposal",l),layoutSlide:l=>u("layoutSlide",l),layoutProposalSlide:(l,c)=>u("layoutProposalSlide",l,c),layoutProposalDiffSlide:(l,c)=>u("layoutProposalDiffSlide",l,c),comments:()=>u("comments"),snapshot:()=>u("snapshot"),story:l=>u("story",l),findText:d.findText,searchText:(l,c)=>u("searchText",l,c),listProposals:()=>u("listProposals"),exportStructured:d.exportStructured,exportMarkdown:d.exportMarkdown,version:d.version,readContent:d.readContent,validateEdits:d.validateEdits,applyEdits:d.applyEdits,registerFont:l=>g(l,false),registerFallbackFont:l=>g(l,true)});return Object.defineProperties(d,{handle:{get(){throw new PptxWorkerUnsupportedError("handle",`handleAsync() or ${Z}={true} for synchronous access`)}}})}function ar(e,t,o,i,a,p){let r=()=>{let c=e.refusal();return c?O(c):t.current?Pt(t.store)?O("input-failed","An editor gesture is active"):null:O("document-replaced")};async function u(c,S=false){let x=r();if(x)return x;try{let C=!1;return await P([e.signal,e.lifetimeSignal],(async()=>{await t.store.fence();let n=r();if(n)return n;t.require(),C=!0;let h=await c();return S?h:r()??h})(),()=>C)??r()??O("aborted")}catch{return r()??O("input-failed")}}let g=()=>{let c=o();if(!c)throw new Error("Editor unavailable");return c},f={version:()=>u(async()=>({ok:true,version:(await t.client.flush()).version})),readContent:c=>u(async()=>(await t.client.read(c)).result),findText:c=>u(()=>t.client.access("findText",c)),validateEdits:c=>u(async()=>t.store.getSnapshot().editState.readOnly?O("read-only"):t.client.access("validateEdits",c))},d=N(i(),"separate")?{applyEdits:c=>u(async()=>{let S=r();return S||(N(i(),c.history)?t.store.getSnapshot().editState.readOnly?O("read-only"):(await p({kind:"applyEdits",payload:{request:c,inputTime:performance.now(),undoGroup:"plugin"}})).editResult??O("input-failed"):O("permission-denied"))},true)}:null,b={getDescriptor:c=>a.getDescriptor(c),getState:(c,S)=>a.getState(c,S),subscribe:a.subscribe,execute:(c,S)=>u(()=>a.execute(c,S),true)};async function k(c,S){return u(async()=>{if(t.client.state.version!==c.expectVersion)return {ok:false,failure:{code:"stale-version",message:"The presentation changed"}};let x=await S();return c.focus&&x&&g().focus(),x?{ok:true}:{ok:false,failure:{code:"missing-target",message:"The target is unavailable"}}})}return {read:f,edits:d,commands:b,navigation:{goToSlide:(c,S)=>k(S,()=>g().goToSlide(t.client.state.slides.findIndex(x=>x.id===c.slideId)+1)),selectText:(c,S)=>k(S,()=>g().selectText({...c,slide:t.client.state.slides.findIndex(x=>x.id===c.slideId)+1,start:c.anchor,end:c.focus})),selectShape:(c,S)=>k(S,async()=>{let x=t.client.state.slides.findIndex(n=>n.id===c.slideId);if(x<0||!await g().goToSlide(x+1)||r())return false;let C=t.store.getSnapshot().confirmed;return C?!(await t.store.dispatch({kind:"selectObject",payload:{frame:C.frame,shapeId:c.shapeId,inputTime:performance.now(),undoGroup:"plugin-selection"}})).outcomes.some(n=>n.status==="refused")&&t.store.getSnapshot().selection?.shapeId===c.shapeId:false})}}}function lr(e){let t=new Map;return {document:{version:()=>e.client.state.version,onUpdate(i){let a=e.client.state.throughSeq,p=e.client.subscribe(r=>{let u=r.outcomes.filter(d=>d.seq>a&&d.committed),g=u.map(d=>t.get(d.seq)),f=()=>i(new Uint8Array,"remote");if(u.length&&g.every(d=>d!==void 0))for(let d of new Set(g)){let b=f;f=()=>d.commit(b);}a=Math.max(a,r.throughSeq),f();for(let d of t.keys())d<=a&&t.delete(d);});return ()=>{p(),t.clear();}}},dispatch(i,a){let p,r=e.store.subscribePresentation(()=>{let u=e.store.getSnapshot().pending.find(g=>g.intent.payload===a.payload);u&&(p=u.seq,t.set(p,i));});return e.store.dispatch(a).finally(()=>{r(),p!==void 0&&t.delete(p);})}}}function mr(e,t,o,i,a,p){let{t:r}=b(),u=useRef({commands:t,t:r,reviewing:p});u.current={commands:t,t:r,reviewing:p};let g=useRef(null),[f,d]=useState(null),b$1=!!a.plugins?.length,k=useRef(null),l=useMemo(()=>R({commands:()=>y(u.current.commands),translate:m=>u.current.t(m),geometry:()=>g.current},(m,w,T)=>{let q=k.current;return ar(m,q.run,()=>i.current,w,T,O=>q.document.dispatch(m,O))}),[i]);useLayoutEffect(()=>{l.setReporter(a.onPluginError),l.setGrants(a.pluginGrants);}),useLayoutEffect(()=>{l.modeChanged(!!(a.readOnly||e?.failure));},[l,a.readOnly,e?.failure]),useLayoutEffect(()=>{l.setPlugins(a.plugins);},[l,a.plugins]),useLayoutEffect(()=>()=>l.close("unmounted"),[l]),useLayoutEffect(()=>{if(!e?.current||e.failure)return;let m={run:e,document:lr(e)};return k.current=m,l.open(m.document.document),()=>{l.close("document-replaced"),k.current===m&&(k.current=null);}},[l,e,e?.failure]),useLayoutEffect(()=>(l.syncCommands(),l.subscribe(()=>l.syncCommands())),[l]);let c$1=useCallback(m=>b$1&&e?e.subscribeVisual(m):()=>{},[e,b$1]),S$1=useCallback(()=>b$1?e?.getVisualSnapshot()??null:null,[e,b$1]),x=useSyncExternalStore(c$1,S$1,S$1),C=x?.view.confirmed,I=x?.fit,n=C?.frame.version,[h,E]=useState(null);useEffect(()=>{let m=true;return e?.current&&b$1&&n&&e.client.access("snapshot").then(w=>{m&&e.current&&e.client.state.version===n&&E({run:e,version:n,deck:w});}).catch(()=>{}),()=>{m=false;}},[e,n,b$1]);let v=useMemo(()=>{let m=o.current;if(!b$1||p||!e?.current||!C||!I||!m||!f||h?.run!==e||h.version!==C.frame.version||C.frame.version!==e.client.state.version)return null;let{frame:w,displayList:T}=C,q={id:`${w.incarnation}:${w.epoch}:${I.generation}`,version:w.version,slideId:w.slideId,slide:w.slideIndex+1,zoom:I.scale,width:T.width,height:T.height},O=()=>e.current&&!u.current.reviewing&&m.isConnected&&l.layoutId()===q.id&&e.getVisualSnapshot()?.view.confirmed===C&&e.getVisualSnapshot()?.fit===I&&e.store.getSnapshot().confirmed===C&&e.client.state.version===w.version,z=H=>O()?U(m,f,T,H):null,B=indexGeometry(T);return {layout:q,toOverlayRect:H=>{let D=H?.rect;return !D||![D.x,D.y,D.width,D.height].every(Number.isFinite)?null:H.space==="slide-px"?z(D):H.space!=="slide-emu"?null:z({x:D.x/S,y:D.y/S,width:D.width/S,height:D.height/S})},getShapeRect:H=>{let D=h.deck.slides.find(M=>M.id===w.slideId),W=D&&c(D.shapes,H);if(!W)return null;let _=new Set,J=M=>{_.add(M.id),M.children.forEach(J);};J(W);let y=B.hits.filter(M=>M.primitive.shapeId&&_.has(M.primitive.shapeId)).map(M=>transformedRect(M.transforms,{x:M.primitive.x,y:M.primitive.y,width:M.primitive.w,height:M.primitive.h}));if(!y.length)return null;let ie=Math.min(...y.map(M=>M.x)),re=Math.min(...y.map(M=>M.y));return z({x:ie,y:re,width:Math.max(...y.map(M=>M.x+M.width))-ie,height:Math.max(...y.map(M=>M.y+M.height))-re})},getPositionAtPoint:(H,D)=>{if(!O())return null;let W=At(e,m,H,D);return W?{...W,version:w.version,layoutId:q.id}:null}}},[l,b$1,p,e,C,I,o,f,h]);g.current=v,useLayoutEffect(()=>{l.layoutChanged(v?.layout??null),l.geometryChanged();},[l,v]),useLayoutEffect(()=>{if(!C)return;let{frame:m}=C,w=x?.view.selection,T={slideId:m.slideId,slide:m.slideIndex+1,target:w?w.kind==="object"?{kind:"shape",shapeId:w.shapeId}:{kind:"text",shapeId:w.shapeId,storyId:w.storyId,anchor:w.anchor,focus:w.focus}:{kind:"slide"}};l.selectionChanged(T);},[l,C,x?.view.selection]),useEffect(()=>{let m=o.current;if(!b$1||!m||!f)return;let w=0,T=()=>{w||(w=requestAnimationFrame(()=>{w=0,l.geometryChanged();}));},q=typeof ResizeObserver>"u"?null:new ResizeObserver(T);return q?.observe(m),q?.observe(f),window.addEventListener("resize",T),()=>{w&&cancelAnimationFrame(w),q?.disconnect(),window.removeEventListener("resize",T);}},[l,b$1,o,f]);let P=useSyncExternalStore(l.subscribe,l.activations,l.activations);return {host:l,activations:P,layerRef:d,managed:b$1}}var Zt=new WeakMap;function Rn(e,t){let o=e.store.getSnapshot().composition;o&&Be(e.store,o.text,performance.now()).catch(()=>{});let i={slideId:t};return Zt.set(e,i),e.store.dispatch({kind:"activateSlide",payload:{slideId:t}}).finally(()=>{Zt.get(e)===i&&Zt.delete(e);})}function hr(e,t){let o=t.store.getSnapshot();if(!t.current||e.target!==e.currentTarget||e.currentTarget.ownerDocument.activeElement!==e.currentTarget||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.nativeEvent.isComposing||o.focused||o.composition)return;let i=t.client.state.slides,a=Zt.get(t)?.slideId??o.confirmed?.frame.slideId,p=i.findIndex(u=>u.id===a);if(p<0)return;let r=e.key==="PageUp"?Math.max(0,p-1):e.key==="PageDown"?Math.min(i.length-1,p+1):e.key==="Home"?0:e.key==="End"?i.length-1:null;r!==null&&(e.preventDefault(),r!==p&&Rn(t,i[r].id).catch(()=>{}));}function gr(e){let t=useRef(e);return t.current===e||(t.current.length!==e.length||!t.current.every((o,i)=>{let a=e[i];return o.family===a.family&&(o.bold??false)===(a.bold??false)&&(o.italic??false)===(a.italic??false)&&(o.bytes===a.bytes||o.bytes.length===a.bytes.length&&o.bytes.every((p,r)=>p===a.bytes[r]))}))&&(t.current=e),t.current}async function Mn(e,t,o){typeof FontFace>"u"||await Promise.all(e.map(async i=>{let a=await new FontFace(i.family,i.bytes.slice().buffer,{style:i.italic?"italic":"normal",weight:i.bold?"700":"400"}).load();o()&&(document.fonts.add(a),t.push(a));}));}function yr(){let e=new Uint32Array(1);do globalThis.crypto.getRandomValues(e);while(e[0]===0);return e[0]}var Pr={open:createPptxWorkerSession},Vi={create:(...e)=>Bo(...e)},Ot={frame:Kt,echo:Ro};function ji(e){if(typeof window.requestIdleCallback=="function"){let o=window.requestIdleCallback(e);return ()=>window.cancelIdleCallback(o)}let t=window.setTimeout(e,0);return ()=>window.clearTimeout(t)}function br(e,t){let o=gr(e.fonts),i=e.collaboration,a=useRef(i?.initialUpdate),p=i?.initialUpdate;a.current!==p&&(!a.current||!p||a.current.length!==p.length||!a.current.every((C,I)=>C===p[I]))&&(a.current=p);let r=useMemo(()=>({}),[e.file,o,e.clientId,!!i,i?.roomId,i?.clientId,a.current]),u=useRef(r);u.current=r;let g=useRef(e);g.current=e;let[f,d]=useState(null),[b,k]=useState(null),l=useRef(null),[c,S]=useState(null),x=useRef(e.readOnly??false);return useLayoutEffect(()=>{x.current=e.readOnly??false,l.current?.(x.current);},[e.readOnly]),useLayoutEffect(()=>{if(d(null),k(null),S(null),!e.file||!t.current)return;let C=t.current,I=true,n,h=!!g.current.onChange,E=e.collaboration&&{...e.collaboration,clientId:e.collaboration.clientId??yr()},v,P,m,w,T,q=pn(),O,z,B,H,D,W=null,_,J=false,y,ie,re,M=U=>{if(re!==U){re=U;try{g.current.onDocumentChange?.({version:U});}catch(G){console.error("documentChange listener threw:",G);}}},X,ne=e.file instanceof Uint8Array?e.file.slice():new Uint8Array(e.file).slice(),se={bytes:ne,throughSeq:0,version:""},xe,Ce=[],oe=false,Ae=false,L,te,we=0,ke=0,pe=x.current,ze,pt=[],tt=new Set,Pe=new Map,Le=new Set,Ie=new Map,ft=[],mt=[],Xe=new Set,ht=new Set,vt,s=new Promise(U=>{vt=U;}),R=()=>{vt(),s=new Promise(U=>{vt=U;});},j=()=>I&&u.current===r,A=()=>j()&&!z,$=()=>{if(!j())throw new PptxWorkerEditorDisposedError;if(z)throw z},Q=()=>ke===we,Z=()=>A()&&Q()&&!!v&&(v.getSnapshot().confirmed===null||oe&&!!H?.scale&&W?.fit===H&&te?.confirmed===D),le=()=>A()&&Ae&&!!v?.getSnapshot().confirmed,F=()=>le()&&Q()&&!x.current&&!v?.getSnapshot().editState.readOnly,K=()=>{for(let U of ht)U();},N=U=>{if(!A())return;z=U instanceof PptxWorkerEditorFailedError?U:new PptxWorkerEditorFailedError(U);let G=ie;if(y!==void 0&&ze&&(!G||G.throughSeq>=y&&G.throughSeq<=ze.state.throughSeq&&G.version===ze.state.version)){if(y=void 0,ie=void 0,G)try{g.current.onChange?.(G.snapshot);}catch{}M(G?.version??ze.state.version);}_?.(),_=void 0,clearTimeout(X),X=void 0,m?.freeze(),m!==w&&m?.dispose(),T?.dispose(),T=void 0,O?.release(),O=void 0,q.dispose();for(let Y of ft.splice(0))document.fonts.delete(Y);if(v){let Y=te??v.getSnapshot();B={...Y,focused:false,caret:null,selectionRects:[],composition:null,echo:null,pending:[],waitingInputCount:0,editState:{...Y.editState,readOnly:true,toolbar:{...Y.editState.toolbar,canEditText:false}}},W&&(W={...W,view:B});}R(),K();for(let Y of Xe)try{Y();}catch{}S(z);try{g.current.onError?.(z);}catch{}n?.dispose().catch(()=>{});},de=Mn(o,ft,A);de.catch(N);async function ve(){for(;;){$();let U=s;if(Z())return;await U;}}async function fe(U,G){for(;A()&&H===U&&G()&&!Q();)await s;}function he(U,G=false){!A()||!oe||!W||H!==W.fit||U.confirmed!==W.view.confirmed||(G?T?.restoreLine(U):T?.paintEcho(U),te=U,W={...W,view:U},K());}function nt(U,G){if(!A())return;let Y=q.pin(U,[...Ie].map(([me,He])=>({assetId:me,bytes:He})));if(O?.release(),O=Y,D=U,oe=false,_?.(),_=void 0,R(),!H?.scale||!m)return;let ge=[...Ie].map(([me,He])=>({assetId:me,bytes:He}));Ie.clear();try{m.paintFrame(U,G,ge);}catch(me){throw ze&&!presentationSharedInputs.get(ze)&&N(me),me}m.whenPainted().catch(N);}function $n(){let U=ze;if(!(!A()||!U))for(let{sequence:G,readOnly:Y}of pt.splice(0)){let ge=(v??U).dispatch({kind:"setReadOnly",payload:{readOnly:Y,inputTime:performance.now(),undoGroup:"mode"}}).then(me=>{if(!(!A()||G!==we||me.editState.readOnly!==pe)){ke=G;for(let He of Xe)He();Ct(U);}}).catch(N).finally(()=>{tt.delete(ge),R();});v||tt.add(ge);}}function wt(U){if(!(!A()||pe===U)){pe=U,pt.push({sequence:++we,readOnly:U}),R();for(let G of Xe)G();$n();}}l.current=wt;function Ct(U){!A()||!v||v.getSnapshot().confirmed&&!oe||_||J||(_=ji(()=>{if(_=void 0,!A()||!v)return;let G=v.getSnapshot();G.confirmed&&(!oe||!L||te?.confirmed!==G.confirmed||G.presentedThroughSeq<U.state.throughSeq)||(J=true,ii(U).catch(N).finally(()=>{J=false,A()&&(Pe.size>0||y!==void 0)&&Ct(U);}));}));}async function _n(U){if(await v?.fence(),await ve(),!A())return;let G=await U.checkpoint?.();A()&&G&&G.throughSeq>=se.throughSeq&&(se={bytes:new Uint8Array(G.bytes).slice(),throughSeq:G.throughSeq,version:G.version},xe=G.recoveryUpdate?new Uint8Array(G.recoveryUpdate).slice():void 0,Ce=Ce.filter(Y=>Y.throughSeq>G.throughSeq));}function ri(U){X||(X=setTimeout(()=>{X=void 0,_n(U).catch(N);},1e3));}async function ii(U){if(!v||!A())return;await ve();let G=y;if(G!==void 0)if(g.current.onChange){if(await v.fence(),!A())return;await ve();let Te=ie;if(Te){if(ie=void 0,y!==void 0&&y<=Te.throughSeq&&(y=void 0),Te.throughSeq<=U.state.throughSeq&&Te.version===U.state.version){try{g.current.onChange?.(Te.snapshot);}catch{}M(Te.version);}}else {let ot=await U.read();if(!A())return;await ve();let kt;if(ot.result.ok&&(kt=U.access?await U.access("snapshot"):{widthEmu:U.state.size.width,heightEmu:U.state.size.height,slides:ot.result.slides},!A()))return;if(y!==void 0&&y<=Math.max(G,ot.throughSeq)&&(y=void 0),kt){try{g.current.onChange?.(kt);}catch{}M(U.state.version);}}}else if(g.current.onDocumentChange){if(await v.fence(),!A())return;await ve(),y=void 0,ie=void 0,M(U.state.version);}else y=void 0,ie=void 0;if(!A())return;await ve();let Y=v.getSnapshot().confirmed?.frame.slideId;Y&&Pe.delete(Y);let ge=Pe.entries().next().value;if(!ge)return;let[me,He]=ge,sn=v.getSnapshot().thumbnails.get(me),Fe=await U.thumbnail(me,sn?.frame.slideRevision).catch(Te=>{if(!U.state.slides.some(ot=>ot.id===me))return null;throw Te});if(Fe&&A()&&!(Fe.session!==U.state.session||Fe.incarnation!==U.state.incarnation||Fe.epoch!==U.state.epoch)){if(Fe.status==="refused"){Le.add(me),Pe.delete(me);return}if(Fe.status==="frame"){for(let Te of Fe.frame.media)Ie.set(Te.assetId,Te.bytes);v.installMedia(Fe.frame.media);}await ve(),Pe.get(me)===He&&(Fe.status==="frame"&&v.installThumbnail(Fe.frame),Pe.get(me)===He&&Pe.delete(me));}}try{n=Pr.open(e.file,{fonts:o,clientId:e.clientId,collaboration:E,readOnly:x.current,observeChanges:h,activeSlideIndex:Number.isInteger(e.initialSlide)?Math.max(0,e.initialSlide-1):0}),mt.push(n.subscribeFailure(N));let U=n;U.ready.then(G=>{if(!A())return;let Y=ge=>{if(A())for(let me of ge)Ie.set(me.assetId,me.bytes);};mt.push(G.subscribeMedia(Y)),ze=G,pt.length||(pe=G.state.editState.readOnly,wt(x.current)),$n();}).catch(N),Promise.all([U.ready,de]).then(async([G])=>{for(;A()&&tt.size;)await Promise.all([...tt]);if(!A())return;se.version=G.state.version,xe=G.state.recoveryUpdate?new Uint8Array(G.state.recoveryUpdate).slice():void 0,v=Vi.create(G,{checkpoint(V){let ee=m?.checkpoint(V),ue=T?.checkpoint(),be=O?.retain(),Oe={queuedFrame:D,paintedFrame:L,paintedView:te,firstPainted:oe,fit:H,visual:W,pendingMedia:new Map(Ie)},Re=!1,Ee=()=>{Re||(Re=!0,ee?.commit?.(),ue?.commit?.(),be?.release());};return Object.assign(()=>{if(!Re){if(A()&&H===Oe.fit){(({queuedFrame:D,paintedFrame:L,paintedView:te,firstPainted:oe,visual:W}=Oe)),O?.release(),O=be?.retain(),Ie.clear();for(let[rt,Vt]of Oe.pendingMedia)Ie.set(rt,Vt);}try{ee?.(),ue?.(),m?.whenPainted().catch(N),R(),Ct(G);}finally{Ee();}}},{commit:Ee})},paintFrame:nt,paintEcho:V=>he(V),restoreLine:V=>he(V,!0)},{onError:V=>g.current.onError?.(new PptxWorkerEditorFailedError(V))});let Y=v,ge=Y.getSnapshot.bind(Y),me=Y.subscribePresentation.bind(Y),He=Y.subscribeEditState.bind(Y),sn=Y.dispatch.bind(Y),Fe=Y.fence.bind(Y),Te=Y.setSelection.bind(Y),ot=Y.setFocused.bind(Y),kt=Y.beginComposition.bind(Y),si=Y.updateComposition.bind(Y),ai=Y.installThumbnail.bind(Y),Xn=(V,ee)=>{let ue=V(ee);return Xe.add(ee),()=>{ue(),Xe.delete(ee);}},Yn,Jn,Zn=Object.assign(Y,{getSnapshot:()=>{if(B)return B;let V=ge();return !x.current&&Q()?V:(Yn!==V&&(Yn=V,Jn={...V,editState:{...V.editState,readOnly:!0}}),Jn)},subscribePresentation:V=>Xn(me,V),subscribeEditState:V=>Xn(He,V),dispatch:(V,ee)=>{try{$();let ue=PRESENTATION_COMMAND_ADMISSION[V.kind];if(ue==="local-write"&&(x.current||!Q()||ge().editState.readOnly))throw new Error("The editor is read-only");if(ue!=="mode"&&V.kind!=="collabPipe"&&!le()&&!["undo","redo","applyEdits","registerFont","invoke","setChangeObserver"].includes(V.kind))throw new Error("Slide input is unavailable");return sn(V,ee)}catch(ue){return Promise.reject(ue)}},fence:async()=>{$(),await Fe(),$();},setSelection:V=>{$(),Te(V);},setFocused:V=>{A()&&ot(V);},beginComposition:(V,ee)=>{$(),F()&&kt(V,ee);},updateComposition:V=>{F()&&si(V);},installThumbnail:V=>A()&&ai(V)});G.state.frame&&Ho(Y,G.state.frame);for(let V of G.state.slides)V.id!==G.state.activeSlideId&&Pe.set(V.id,0);mt.push(G.subscribe(V=>{if(A()){if(V.throughSeq>se.throughSeq&&V.updates?.length&&Ce.push({throughSeq:V.throughSeq,version:V.version,updates:V.updates.map(ee=>new Uint8Array(ee.bytes).slice())}),V.slides){let ee=new Set(V.slides.map(ue=>ue.id));for(let ue of Le)ee.has(ue)&&Le.delete(ue);}for(let ee of V.dirtySlideIds)Le.has(ee)||Pe.set(ee,(Pe.get(ee)??0)+1);if(V.slides){let ee=new Set(V.slides.map(ue=>ue.id));for(let ue of Pe.keys())ee.has(ue)||Pe.delete(ue);V.activeSlideId===null&&(D=void 0,L=void 0,te=ge(),W=null,oe=!1,m?.freeze(),K(),R());}for(let ee of v.getSnapshot().dirtyThumbnailIds)!Le.has(ee)&&!Pe.has(ee)&&Pe.set(ee,0);V.outcomes.some(ee=>ee.committed)&&ri(G),(g.current.onChange||g.current.onDocumentChange)&&V.outcomes.some(ee=>ee.committed)&&(y=V.throughSeq,ie=V.change),Ct(G);}}));let Qn=V=>(ht.add(V),()=>{ht.delete(V);});P={fileGeneration:r,session:U,client:G,store:Zn,images:q,collaborationClientId:E?.clientId,visual:{subscribePresentation:Qn,getSnapshot:()=>B??te??ge()},getVisualSnapshot:()=>W,subscribeVisual:Qn,get ready(){return ve()},get current(){return A()},get selectionEnabled(){return le()},get inputEnabled(){return F()},get hydrated(){return Z()},get failure(){return z},require:$,setReadOnly:wt,setChangeObserver(V){!A()||h===V||(h=V,Zn.dispatch({kind:"setChangeObserver",payload:{enabled:V,inputTime:performance.now(),undoGroup:"observer"}}).catch(N));},async recover(){if(!j())throw new PptxWorkerEditorDisposedError;if(z||await _n(G),!j())throw new PptxWorkerEditorDisposedError;if(!Ce.length)return {...se,bytes:se.bytes.slice(),recovery:!0};if(!xe)throw new Error("Recovery baseline is unavailable");let V=Pr.open(ne,{fonts:o,initialUpdate:xe});try{let ee=await V.ready;for(let Oe of Ce)for(let Re of Oe.updates){if(!j())throw new PptxWorkerEditorDisposedError;if((await ee.dispatch({kind:"applyRemoteUpdate",payload:{bytes:Re.slice().buffer,inputTime:0,undoGroup:"recovery"}})).outcomes.some(rt=>rt.status==="refused"||rt.status==="cancelled"))throw new Error("Recovery update refused")}let ue=await ee.save();if(!j())throw new PptxWorkerEditorDisposedError;let be=Ce[Ce.length-1];return {bytes:ue,throughSeq:be.throughSeq,version:be.version,recovery:!0}}finally{await V.dispose();}},async installFont(V){$(),await Mn([V],ft,A),$();},fit(V){if(!A()||!ge().confirmed||H===V||(H=V,oe=!1,T?.dispose(),T=void 0,m?.freeze(),m!==w&&m?.dispose(),m=void 0,R(),!V.scale))return;let ee;m=Ot.frame(C,{...V,images:q,current:be=>A()&&H===V&&(!be||be===D),beforeCommit:be=>fe(V,be),compose(be,Oe){if(!A()||H!==V||ge().confirmed!==Oe)return;let Re=ge();if(!Re.echo&&Re.selection?.anchor===Re.selection?.focus)return;let Ee=C.ownerDocument.createElement("canvas");sizeCanvasForSlide(Ee,Oe.displayList,V.dpr,V.scale);let rt=Ee.getContext("2d");if(!rt)throw Ee.width=Ee.height=0,new Error("Slide canvas is unavailable");let Vt=!0,gt;try{rt.drawImage(be.canvas,0,0),gt=Ot.echo(Ee,{...V,current:()=>A()&&H===V&&(Vt||oe)}),gt.paintEcho(Re);}catch(li){throw gt?.dispose(),Ee.width=Ee.height=0,li}return ee=gt,{canvas:Ee,release(){Vt=!1,gt!==T&&gt?.dispose(),Ee.width=Ee.height=0;}}},onCommit(be){if(!A()||H!==V||be!==D||ge().confirmed!==be)return;let Oe=ge();T?.dispose();let Re=w;w=m,Re!==w&&Re?.dispose(),L=be.frame,te=Oe,oe=!0,W={view:Oe,fit:V},T=ee??Ot.echo(C,{...V,current:()=>A()&&oe&&H===V}),ee?(ee.attach(C),ee=void 0):T.paintEcho(Oe),flushSync(()=>{Ae||(Ae=!0,d(P)),K();}),R(),Ct(G);}});let ue=ge();try{ue.confirmed&&nt(ue.confirmed,ue);}catch(be){N(be);}}},wt(x.current),k(P),ge().confirmed===null&&(Ae=!0,d(P),R());}).catch(N);}catch(U){N(U);}return ()=>{I=false,l.current===wt&&(l.current=null),R(),_?.();for(let G of mt)G();v?.dispose(),T?.dispose(),m?.dispose(),w!==m&&w?.dispose();let U=C.getContext("2d");U?.setTransform(1,0,0,1,0,0),U?.clearRect(0,0,C.width,C.height),O?.release(),q.dispose(),Ie.clear();for(let G of ft)document.fonts.delete(G);clearTimeout(X),ht.clear(),Xe.clear(),z||n?.dispose().catch(()=>{});}},[r,t]),useLayoutEffect(()=>{let C=f?.fileGeneration===r?f:null;C?.current&&C.setChangeObserver(!!e.onChange);},[f,r,!!e.onChange]),{presentation:f?.fileGeneration===r?f:null,pending:b?.fileGeneration===r?b:null,failure:c}}var zi=memo(function({frame:t,run:o,fit:i,previewFit:a,current:p}){let r=useRef(null),u=useRef({previewFit:a,current:p});u.current={previewFit:a,current:p};let g=useRef(null);return useEffect(()=>{let f=()=>{let k=u.current.previewFit(t,o);return !!(k&&k.scale===i.scale&&k.dpr===i.dpr&&u.current.current(k,o))};if(!r.current)return;let d=Ot.frame(r.current,{...i,images:o.images,current:f}),b={confirmed:t,selection:null,focused:false,caret:null,selectionRects:[],composition:null,echo:null,activeLine:null,activeContextBytes:0,pending:[],waitingInputCount:0,appliedThroughSeq:t.frame.coversThroughSeq,presentedThroughSeq:t.frame.coversThroughSeq,editState:{readOnly:true,canUndo:false,canRedo:false,toolbar:{target:null,storedMarks:{},formatting:null,alignment:null,hyperlink:null,table:null,canEditText:false}},thumbnails:new Map,dirtyThumbnailIds:new Set};return d.paintFrame(t,b),d.whenPainted().catch(()=>{}),g.current=async k=>{!await d.whenPainted()&&k()&&f()&&(d.paintFrame(t,b),await d.whenPainted());},()=>{g.current=null,d.dispose();}},[t,o,i.scale,i.dpr]),useEffect(()=>{let f=true;return g.current?.(()=>f).catch(()=>{}),()=>{f=false;}},[t,o,i.scale,i.dpr,i.generation]),jsx("canvas",{ref:r,style:{width:128,display:"block"},"aria-hidden":"true"})}),Bi=memo(function({id:t,name:o,index:i,active:a,disabled:p,frame:r,run:u,previewFit:g,current:f,onNavigate:d}){let{t:b$1}=b(),k=useMemo(()=>r?g(r,u):null,[r,u,g]);return jsxs("button",{type:"button",disabled:p,"aria-current":a?"page":void 0,style:a?bt.activeSlide:bt.slide,draggable:!u.store.getSnapshot().editState.readOnly,onDragStart:l=>l.dataTransfer.setData("text/plain",t),onDragOver:l=>l.preventDefault(),onDrop:l=>{l.preventDefault();let c=l.dataTransfer.getData("text/plain");u.client.state.slides.some(S=>S.id===c)&&vn(u,c,i).catch(()=>{});},onKeyDown:l=>{if(!l.altKey||!["ArrowUp","ArrowDown"].includes(l.key))return;l.preventDefault();let c=i+(l.key==="ArrowUp"?-1:1);c>=0&&c<u.client.state.slides.length&&vn(u,t,c).catch(()=>{});},onClick:()=>{Rn(u,t).catch(()=>{}),d();},children:[jsx("span",{style:bt.number,children:i+1}),jsx("span",{style:bt.preview,children:r&&k?jsx(zi,{frame:r,run:u,fit:k,previewFit:g,current:f}):jsx("span",{style:bt.title,children:o??b$1("slides.fallbackTitle",{number:i+1})})})]})});function Hi({run:e,active:t,disabled:o}){let{t:i}=b(),a=useCallback(u=>e.store.subscribeEditState(u),[e]),p=useCallback(()=>e.store.getSnapshot().editState.readOnly,[e]);return useSyncExternalStore(a,p,p)?null:jsxs("div",{style:ca.row,children:[jsx("button",{type:"button",disabled:o,style:xr(o),onClick:()=>{Yt(e).catch(()=>{});},children:i("toolbar.addSlide")}),jsx("button",{type:"button",disabled:o||!t,style:xr(o||!t),onClick:()=>{t&&Wo(e,t).catch(()=>{});},children:i("toolbar.deleteSlide")})]})}var Cr=memo(function({run:t,previewFit:o,current:i,onNavigate:a}){let{store:p,client:r}=t,{t:u}=b(),g=useCallback(b=>{let k=p.subscribeStructure(b),l=p.subscribePresentation(b);return ()=>{k(),l();}},[p]),f=useMemo(()=>{let b;return ()=>{let k=p.getSnapshot(),l=k.confirmed?.frame.slideId,c=!t.current||!!t.failure,S=r.state.slides.map(x=>({id:x.id,name:x.name,frame:x.id===l?k.confirmed:k.thumbnails.get(x.id)}));return b&&b.active===l&&b.disabled===c&&b.slides.length===S.length&&S.every((x,C)=>x.id===b.slides[C].id&&x.name===b.slides[C].name&&x.frame===b.slides[C].frame)||(b={active:l,disabled:c,slides:S}),b}},[p,r,t]),d=useSyncExternalStore(g,f,f);return jsxs("div",{style:bt.strip,children:[jsx("aside",{style:{overflowY:"auto",flex:1},"aria-label":u("slides.panelLabel"),children:d.slides.map((b,k)=>jsx(Bi,{...b,index:k,active:b.id===d.active,disabled:d.disabled,run:t,previewFit:o,current:i,onNavigate:a},b.id))}),jsx(Hi,{run:t,active:d.active,disabled:d.disabled})]})});function xr(e){return e?{...ca.button,opacity:.5,cursor:"default"}:ca.button}var bt={strip:{width:184,display:"flex",flexDirection:"column",padding:"14px 10px",background:"#eef1f5",borderRight:"1px solid #d8dee9",boxSizing:"border-box"},slide:{display:"flex",alignItems:"flex-start",gap:6,width:"100%",marginBottom:12,padding:4,border:"2px solid transparent",borderRadius:5,background:"transparent",cursor:"pointer"},activeSlide:{display:"flex",alignItems:"flex-start",gap:6,width:"100%",marginBottom:12,padding:4,border:"2px solid #325ee6",borderRadius:5,background:"transparent",cursor:"pointer"},number:{width:18,flex:"0 0 auto",paddingTop:3,fontSize:11,color:"#647087",textAlign:"right"},preview:{display:"flex",alignItems:"center",justifyContent:"center",minWidth:0,background:"#ffffff",boxShadow:"0 1px 4px rgba(20, 31, 50, 0.16)"},title:{padding:8,fontSize:9,lineHeight:1.25,color:"#39445a",textAlign:"center"}};function Ir({run:e,onError:t}){let{t:o}=b(),i=useCallback(k=>e.store.subscribeEditState(k),[e]),a=useCallback(()=>e.store.getSnapshot().editState,[e]),p=useSyncExternalStore(i,a,a),r=p.notes?.slideId,u=p.notes?.text??"",[g,f]=useState({slideId:r,text:u}),d=useRef(new Map);useEffect(()=>{(!r||!d.current.has(r))&&f({slideId:r,text:u});},[u,r]);let b$1=g.slideId===r?g.text:(r&&d.current.get(r)?.text)??u;return r?jsxs("label",{style:ba.panel,children:[jsx("span",{style:ba.label,children:o("notes.panelLabel")}),jsx("textarea",{"data-testid":"pptx-notes-textarea","aria-label":o("notes.panelLabel"),placeholder:o("notes.placeholder"),style:ba.textarea,disabled:p.readOnly||!e.current||!!e.failure,value:b$1,onChange:k=>{let l=k.target.value,c=r;f({slideId:c,text:l});let S=d.current.get(c)??{count:0,text:l};S.count++,S.text=l,d.current.set(c,S),De(e,{method:"setSlideNotes",args:[c,l]}).then(x=>{if(x.outcomes.some(C=>C.status==="refused"))throw new Error(x.outcomes[0]?.reason??"Notes refused")}).catch(x=>{e.current&&!e.failure&&t(x instanceof Error?x:new Error(String(x)));}).finally(()=>{if(--S.count)return;d.current.delete(c);let x=e.store.getSnapshot().editState.notes;e.current&&x?.slideId===c&&f({slideId:c,text:x.text??""});});}})]}):null}function Tr({run:e,fileName:t}){let{t:o}=b(),[i,a]=useState(false);return jsx("button",{type:"button",disabled:i,style:aa,onClick:()=>{a(true),e.recover().then(p=>{let r=URL.createObjectURL(new Blob([new Uint8Array(p.bytes)],{type:"application/vnd.openxmlformats-officedocument.presentationml.presentation"})),u=document.createElement("a");u.href=r,u.download=t??"presentation-recovery.pptx",u.click(),URL.revokeObjectURL(r);}).catch(()=>{}).finally(()=>a(false));},children:o("worker.recovery")})}async function Rr(e,t){e.require(),await e.store.fence(),e.require();let o=e.store.getSnapshot(),i=o.selection;if(!i||i.kind==="object"||i.anchor===i.focus||o.composition||t&&o.editState.readOnly)return;let a=JSON.stringify(i),p=(await e.client.read({slideIds:[i.slideId]})).result;if(e.require(),!p.ok)throw new Error(p.failure.message);if(a!==JSON.stringify(e.store.getSnapshot().selection))throw new w("target-changed");let r=p.stories.find(u=>u.storyId===i.storyId&&u.shapeId===i.shapeId);if(!r)throw new w("target-changed");if(await navigator.clipboard.writeText(r.text.slice(Math.min(i.anchor,i.focus),Math.max(i.anchor,i.focus))),e.require(),!!t){if(await e.store.fence(),e.require(),e.store.getSnapshot().composition||!e.inputEnabled||!Mt(e.store)||p.version!==e.client.state.version||a!==JSON.stringify(e.store.getSnapshot().selection))throw new w("target-changed");await e.store.dispatch({kind:"replaceText",payload:{at:{source:"confirmed",selection:i},text:"",inputTime:performance.now(),undoGroup:"cut"}});}}function Lr({frameSource:e,subscribeRevision:t=Ji,revision:o=Zi,slideCount:i,startIndex:a,label:p,counterLabel:r,exitLabel:u,previousLabel:g,nextLabel:f,onExit:d,onError:b}){let k=useRef(null),l=useRef(null),c=useRef(null),S=useRef({onExit:d,onError:b});S.current={onExit:d,onError:b};let[x,C]=useState(a),I=Math.max(0,Math.min(x,i-1)),[n,h]=useState({width:0,height:0}),E=useSyncExternalStore(t,()=>o(I),()=>o(I)),v=P=>C(Math.max(0,Math.min(I+P,i-1)));return useEffect(()=>{C(P=>Math.max(0,Math.min(P,i-1))),i===0&&S.current.onExit();},[i]),useEffect(()=>{let P=l.current,m=k.current,w=document.activeElement,T=true;P.showModal(),P.focus(),m.requestFullscreen?.().then(()=>{T?(P.close(),P.showModal(),P.focus()):document.fullscreenElement===m&&document.exitFullscreen().catch(()=>{});}).catch(()=>{});let q=()=>{document.fullscreenElement||S.current.onExit();},O=()=>h({width:window.innerWidth,height:window.innerHeight});return O(),window.addEventListener("resize",O),document.addEventListener("fullscreenchange",q),()=>{T=false,window.removeEventListener("resize",O),document.removeEventListener("fullscreenchange",q),document.fullscreenElement===m&&document.exitFullscreen().catch(()=>{}),P.close(),w instanceof HTMLElement&&w.isConnected&&w.focus();}},[]),useEffect(()=>{let P=c.current;if(!P||i===0||n.width<=0||n.height<=0)return;let m=false;return (async()=>{let T=await e(I),q=T.frame;try{if(m)return;let O=document.createElement("canvas"),z=O.getContext("2d");if(!z)return;let B=Math.min(n.width/q.width,n.height/q.height),H=window.devicePixelRatio||1;if(sizeCanvasForSlide(O,q,H,B),await paintSlide(z,q,H,B,{resolveImage:T.resolveImage}),m)return;sizeCanvasForSlide(P,q,H,B),P.getContext("2d")?.drawImage(O,0,0);}finally{T.release();}})().catch(T=>{m||(S.current.onError(T),S.current.onExit());}),()=>{m=true;}},[e,I,i,n,E]),jsx("div",{ref:k,children:jsxs("dialog",{ref:l,"aria-label":p,tabIndex:-1,style:dt.presentationOverlay,onCancel:P=>{P.preventDefault(),d();},onClick:P=>{P.target===l.current&&v(1);},onKeyDown:P=>{if(!(P.altKey||P.ctrlKey||P.metaKey)){switch(P.key){case " ":if(P.target instanceof HTMLElement&&P.target.closest("button"))return;v(1);break;case "ArrowRight":case "ArrowDown":case "PageDown":v(1);break;case "ArrowLeft":case "ArrowUp":case "PageUp":v(-1);break;case "Home":C(0);break;case "End":C(Math.max(0,i-1));break;case "Escape":d();break;default:return}P.preventDefault(),P.stopPropagation();}},children:[jsx("canvas",{ref:c,style:dt.presentationCanvas}),jsx("button",{type:"button",onClick:d,"aria-label":u,title:u,style:dt.presentationExit,children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:jsx("path",{d:"M6 6 18 18M18 6 6 18"})})}),jsxs("div",{style:dt.presentationControls,children:[jsx("button",{type:"button",onClick:()=>v(-1),disabled:I===0,"aria-label":g,style:dt.presentationNavButton,children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4","aria-hidden":"true",children:jsx("path",{d:"m15 6-6 6 6 6"})})}),jsx("span",{style:dt.presentationCounter,"aria-live":"polite",children:r(I+1,i)}),jsx("button",{type:"button",onClick:()=>v(1),disabled:I>=i-1,"aria-label":f,style:dt.presentationNavButton,children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4","aria-hidden":"true",children:jsx("path",{d:"m9 6 6 6-6 6"})})})]})]})})}var Ji=()=>()=>{},Zi=()=>null,dt={presentationOverlay:{position:"fixed",margin:0,padding:0,border:0,width:"100vw",height:"100vh",maxWidth:"none",maxHeight:"none",inset:0,zIndex:2147483e3,display:"flex",alignItems:"center",justifyContent:"center",background:"#000000",cursor:"pointer"},presentationCanvas:{display:"block",pointerEvents:"none"},presentationExit:{position:"absolute",top:16,right:16,display:"inline-flex",alignItems:"center",justifyContent:"center",width:36,height:36,border:0,borderRadius:999,background:"rgba(255, 255, 255, 0.14)",color:"#ffffff",cursor:"pointer"},presentationControls:{position:"absolute",bottom:20,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:12,padding:"6px 14px",borderRadius:999,background:"rgba(255, 255, 255, 0.12)"},presentationNavButton:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,border:0,borderRadius:999,background:"rgba(255, 255, 255, 0.14)",color:"#ffffff",cursor:"pointer"},presentationCounter:{minWidth:64,color:"#ffffff",fontSize:12,fontWeight:600,textAlign:"center"}};async function en(e,t){e.require(),await e.store.fence(),e.require();let o=t??e.client.state.slides.findIndex(u=>u.id===e.client.state.activeSlideId),i=e.client.state.slides[o];if(!i)throw new Error("Slide is unavailable");let a=await e.client.thumbnail(i.id);if(e.require(),a.status!=="frame")throw new Error("Slide frame is unavailable");let p={frame:a.frame,displayList:decodeCommandDisplayList(a.frame)},r=e.images.pin(p,a.frame.media);return await r.ready,e.current||(r.release(),e.require()),{frame:p.displayList,resolveImage:r.resolve,release:r.release,confirmed:p,index:o}}async function Fr(e){let t=await en(e),o=document.createElement("canvas"),i=Kt(o,{images:e.images,scale:1,dpr:1,current:()=>e.current});try{if(i.paintFrame(t.confirmed,{...e.store.getSnapshot(),confirmed:t.confirmed,echo:null,caret:null,selection:null,selectionRects:[],composition:null}),!await i.whenPainted())throw new Error("Slide painting failed");return e.require(),{png:await new Promise((p,r)=>o.toBlob(u=>u?p(u):r(new Error("PNG encoding failed")),"image/png")),index:t.index}}finally{i.dispose(),t.release();}}var ss={...a.link,cursor:"default"},as=lazy(()=>import('./chunk-J3YQUJUG.js').then(e=>({default:e.ProposalChangeDetails})));function Dr(e){return JSON.stringify(e.changes,(t,o)=>o&&typeof o=="object"&&!Array.isArray(o)?Object.fromEntries(Object.entries(o).sort(([i],[a])=>i.localeCompare(a))):o)}function ls({run:e,id:t,onPreview:o,onError:i}){let a=useRef(null),p=useRef(i);p.current=i;let r=useSyncExternalStore(e.subscribeVisual,e.getVisualSnapshot,e.getVisualSnapshot);return useEffect(()=>{let u=false;o(null);let g=e.client.state.slides.findIndex(f=>f.id===e.client.state.activeSlideId);return (async()=>{let f=await en(e,g);try{let d=await e.client.access("layoutProposalDiffSlide",t,g);e.require();let b=r?.fit.scale??1,k=document.createElement("canvas"),l=k.getContext("2d");if(!l)throw new Error("Canvas is unavailable");sizeCanvasForSlide(k,d.frame,1,b),await paintSlide(l,d.frame,1,b,{resolveImage:f.resolveImage}),!u&&a.current&&e.current&&(sizeCanvasForSlide(a.current,d.frame,1,b),a.current.getContext("2d")?.drawImage(k,0,0),o(d.proposal));}finally{f.release();}})().catch(f=>{!u&&e.current&&p.current(f instanceof Error?f:new Error(String(f)));}),()=>{u=true;}},[e,t,r,o]),jsx("canvas",{ref:a,"data-testid":"pptx-proposal-diff",style:{position:"absolute",left:0,top:0}})}function jr({run:e,diffHost:t,state:o,proposals:i,commands:a$1,onError:p,exit:r}){let{t:u}=b(),[g,f]=useState(null),[d,b$1]=useState(null),k=useRef(false),[l,c]=useState(0),S=useRef(o.selectedId);S.current=o.diff?o.selectedId:null;let x=useCallback(P=>b$1(P),[e]),C=useCallback(P=>en(e,P),[e]),I=useCallback(P=>{let m=e.store.subscribeStructure(P),w=e.store.subscribePresentation(P);return ()=>{m(),w();}},[e]),n=useCallback(P=>{let m=e.client.state.slides[P]?.id;if(!m)return null;let w=e.store.getSnapshot(),T=m===w.confirmed?.frame.slideId?w.confirmed:w.thumbnails.get(m);return `${m}:${T?.frame.slideRevision??"stale"}`},[e]),h=async()=>{if(!d||S.current!==d.id||k.current)return;let P=d,m$1=y(a$1)?.defer("proposalAccept",{proposalId:P.id,force:true});if(m$1){k.current=true;try{await m$1.complete(async w=>{let T=await e.client.access("previewProposal",P.id);return e.require(),S.current!==P.id?{ok:!1,failure:m("target-changed",{translate:u})}:Dr(T.proposal)!==Dr(P)?(b$1(T.proposal),f(u("proposals.changedAgain")),{ok:!1,failure:m("target-changed",{translate:u})}):w()});}catch(w){if(e.current){b$1(null);let T=w instanceof Error?w:new Error(String(w));f(T.message),p(T);}}finally{k.current=false;}}},E=P=>{let m=e.client.state.slides.findIndex(w=>w.id===P.slideId);return m<0?u("proposals.targetMissing"):u("proposals.target",{slide:m+1,name:P.before?.name||u("notes.panelLabel")})},v=async P=>{f(null),b$1(null),c(m=>m+1);try{let m=e.store.getSnapshot().composition;if(m){let z=(await Be(e.store,m.text,performance.now()))?.outcomes.find(B=>B.status==="refused"||B.status==="cancelled");if(z)throw new ct("compositionCommit",z);await e.store.fence();}e.require();let w=P.changes[0]?.slideId;if(w&&w!==e.client.state.activeSlideId){let z=(await e.store.dispatch({kind:"activateSlide",payload:{slideId:w}})).outcomes.find(B=>B.status==="refused"||B.status==="cancelled");if(z)throw new ct("activateSlide",z);await e.ready;}let T=await a$1.execute("proposalSelect",{proposalId:P.id});if(!T.ok)throw new Error(T.failure.message);let q=await a$1.execute("proposalDiff",{enabled:!0});if(!q.ok)throw new Error(q.failure.message)}catch(m){if(e.current){let w=m instanceof Error?m:new Error(String(m));f(w.message),p(w);}}};return jsxs(Fragment,{children:[o.open&&jsxs("aside",{"data-testid":"pptx-proposals-panel","aria-label":u("proposals.title"),style:a.panel,children:[jsxs("header",{style:a.header,children:[jsxs("strong",{children:[u("proposals.title")," ",jsx("span",{style:a.count,children:i.length})]}),jsx("button",{type:"button","aria-label":u("proposals.close"),style:a.button,onClick:()=>{a$1.execute("proposalsPanel",{open:false});},children:"\xD7"})]}),g&&jsx("div",{role:"alert",style:a.warning,children:g}),i.length===0&&jsx("p",{style:a.muted,children:u("proposals.empty")}),i.map(P=>jsxs("section",{"data-testid":"pptx-proposal","data-proposal-id":P.id,style:a.card,children:[jsx("strong",{style:a.author,children:P.agentId}),P.note&&jsx("p",{style:a.note,children:P.note}),jsxs(Suspense,{fallback:null,children:[(o.diff&&o.selectedId===P.id&&d?.id===P.id?d:P).changes.map((m,w)=>jsxs("div",{style:a.change,children:[jsx("span",{style:ss,children:E(m)}),jsx(as,{change:m,t:u,testId:m.shapeId===null?"pptx-proposal-notes-diff":void 0})]},w)),P.staleTargets.length>0&&o.diff&&o.selectedId===P.id&&d?.id===P.id&&jsxs(Fragment,{children:[jsx("p",{style:a.warning,children:u("proposals.stalePreview")}),jsx("button",{type:"button","data-testid":"pptx-proposal-force",style:a.primary,onClick:()=>{h();},children:u("proposals.force")})]})]}),P.staleTargets.length>0&&jsx("p",{role:"alert","data-testid":"pptx-proposal-stale",style:a.warning,children:u("proposals.stale")}),jsx("div",{style:a.actions,children:jsx("button",{type:"button","data-testid":"pptx-proposal-preview",style:a.button,onClick:()=>{v(P);},children:u("proposals.preview")})}),jsxs("div",{style:a.actions,children:[jsx("button",{type:"button","data-testid":"pptx-proposal-accept",disabled:P.staleTargets.length>0,style:P.staleTargets.length>0?{...a.primary,opacity:.5,cursor:"default"}:a.primary,onClick:()=>{a$1.execute("proposalAccept",{proposalId:P.id});},children:u("proposals.accept")}),jsx("button",{type:"button","data-testid":"pptx-proposal-reject",style:a.button,onClick:()=>{a$1.execute("proposalReject",{proposalId:P.id});},children:u("proposals.reject")})]})]},P.id))]}),o.diff&&o.selectedId&&t.current&&createPortal(jsx(ls,{run:e,id:o.selectedId,onPreview:x,onError:p},l),t.current),o.presenting&&jsx(Lr,{frameSource:C,subscribeRevision:I,revision:n,slideCount:e.client.state.slides.length,startIndex:e.client.state.slides.findIndex(P=>P.id===e.client.state.activeSlideId),label:u("presentation.label"),counterLabel:(P,m)=>u("presentation.slideCounter",{current:P,total:m}),previousLabel:u("presentation.previousSlide"),nextLabel:u("presentation.nextSlide"),exitLabel:u("presentation.exit"),onExit:r,onError:P=>p(P instanceof Error?P:new Error(String(P)))})]})}function Hr({run:e,presence:t}){let{t:o}=b(),[i,a]=useState([]),p=useSyncExternalStore(e.subscribeVisual,e.getVisualSnapshot,e.getVisualSnapshot);useEffect(()=>(a(t.peers),t.onPresence(a)),[t,e]),useEffect(()=>{let d=()=>{let k=e.store.getSnapshot(),l=k.confirmed?.frame.slideId;t.setCursor(l?{slideId:l,...k.selection?.shapeId?{shapeId:k.selection.shapeId}:{}}:null);};d();let b=e.store.subscribePresentation(d);return ()=>{b(),t.setCursor(null);}},[t,e]);let r=p?.view.confirmed,u=r?indexHitGeometry(r.displayList):null,g=r&&u?Y(i,r.frame.slideId,new Set(u.hits.flatMap(d=>d.primitive.shapeId?[d.primitive.shapeId]:[]))):null,f=W(i);return jsxs(Fragment,{children:[jsxs("div",{role:"list","aria-label":o("presence.label"),style:{position:"absolute",right:8,top:8,zIndex:2},children:[f.visible.map(d=>jsx("span",{role:"listitem",style:{color:d.state.user.color},children:d.state.user.name},d.state.clientId)),f.overflow>0&&jsxs("span",{children:["+",f.overflow]})]}),g?.visible.map(d=>{let b=u.hits.find(c=>c.primitive.shapeId===d.shapeId);if(!b)return null;let k=transformedRect(b.transforms,{x:b.primitive.x,y:b.primitive.y,width:b.primitive.w,height:b.primitive.h}),l=p.fit.scale;return jsx("div",{"data-testid":"pptx-remote-shape","aria-hidden":"true",style:{position:"absolute",pointerEvents:"none",boxSizing:"border-box",border:`2px solid ${d.peer.state.user.color}`,left:k.x*l,top:k.y*l,width:k.width*l,height:k.height*l}},d.shapeId)})]})}var Hn=new WeakMap;function Ur(e){Hn.get(e)?.(),Hn.delete(e);}function Gr(e,t){let o=async(r,u)=>{e.require(),await e.store.fence(),e.require();let g=await e.client.access(r,...r==="encodeStateAsUpdate"?[u?.slice()]:[]);return e.require(),g},i=async r=>{e.require();let u=0;for(let b of r){if(!(b instanceof Uint8Array)||b.byteLength===0)throw new RangeError("Invalid collaboration update");u+=b.byteLength;}if(r.length===0||u>16777216)throw new RangeError("Invalid collaboration update");let g=r.map(b=>b.slice().buffer),f=await e.store.dispatch({kind:"applyRemoteUpdate",payload:{bytes:g.length===1?g[0]:g,inputTime:performance.now(),undoGroup:"remote"}});e.require();let d=f.outcomes.find(b=>b.status==="refused"||b.status==="cancelled");if(d)throw new Error(`Collaboration update refused: ${d.reason}`);await e.ready,e.require();},a={clientId:t,encodeStateVector:()=>o("encodeStateVector"),encodeStateAsUpdate:r=>o("encodeStateAsUpdate",r),applyUpdate:r=>i([r]),applyUpdateChunks:r=>i(r),onUpdate(r){return e.require(),e.client.subscribeUpdate(r)}},p=presentationCollaborationPipes.get(e.client);if(p){let r=false,u=p.channel(async f=>{e.require();let d=await e.store.dispatch({kind:"collabPipe",payload:{...f,inputTime:performance.now(),undoGroup:"remote"}});e.require();let b=d.outcomes.find(k=>k.status==="refused"||k.status==="cancelled");if(b)throw new Error(`Collaboration pipe refused: ${b.reason}`)}),g=new Map;attachCollaborationPipe(a,{open(f,d){r&&queueMicrotask(()=>d("Collaboration replica is retired"));let b=u.open(f,d),k={endpoint:b,seq:0};return g.set(d,k),{post(l,c){if(r)return Promise.reject(new Error("Collaboration replica is retired"));for(let S of l)k.seq=Math.max(k.seq,S.seq);return b.post(l,c)},close(){g.delete(d),b.close();}}}}),Hn.set(a,()=>{r=true;for(let[f,d]of g)d.endpoint.post([{op:"destroy",seq:d.seq+1}],[]).catch(()=>{}).then(()=>{g.delete(f)&&(d.endpoint.close(),f("Collaboration replica is retired"));});});}return a}var gs=530;function Wr(e,t){let[o,i]=useState(()=>typeof document>"u"||document.visibilityState==="visible"),[a,p]=useState(false);return useEffect(()=>{if(typeof document>"u")return;let r=()=>i(document.visibilityState==="visible");return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},[]),useEffect(()=>{let r=e&&o;if(p(r),!r)return;let u=window.setInterval(()=>p(g=>!g),gs);return ()=>window.clearInterval(u)},[e,o,t]),a}function Xr({store:e}){let t=useSyncExternalStore(e.subscribePresentation,e.getSnapshot,e.getSnapshot),o=t.focused&&t.caret!==null&&t.selection!==null&&t.selection.anchor===t.selection.focus,i=Wr(o,t.caret),a=useMemo(()=>t.activeLine??(t.confirmed?findLine(indexGeometry(t.confirmed.displayList),t.selection):null),[t.activeLine,t.confirmed,t.selection]);if(!t.confirmed)return null;let p=t.caret?.x??0,r=t.caret?.y??0,u=t.caret?.height??0,g="none";if(a&&t.selection){let b=t.selection.focus,k=a.line.caretStops[0],l=k&&a.line.caretStops.reduce((n,h)=>Math.abs(h.position-b)<Math.abs(n.position-b)?h:n,k),c=t.echo&&t.activeLine?Wt(t.activeLine,t.echo,t.echo.caretPosition)??l?.x??a.line.x:l?.x??a.line.x,S=(n,h)=>transformedRect(a.transforms,{x:c+n,y:a.line.y+h,width:0,height:0}),x=S(0,0),C=S(1,0),I=S(0,1);p=x.x,r=x.y,u=a.line.height,g=`matrix(${C.x-p}, ${C.y-r}, ${I.x-p}, ${I.y-r}, 0, 0)`;}let f=jsx("div",{"aria-hidden":"true","data-testid":"pptx-caret-clip",style:{position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"hidden",width:t.confirmed.displayList.width,height:t.confirmed.displayList.height,clipPath:t.echo&&a?$r(a.transforms,Nt(a)):void 0},children:jsx("div",{"data-testid":"pptx-caret","aria-hidden":"true",style:{position:"absolute",pointerEvents:"none",background:"#111827",left:p,top:r,width:1,height:u,transform:g,transformOrigin:"0 0",visibility:o&&i?"visible":"hidden"}})}),d=a?.transforms??[];for(let b=d.length-1;b>=0;b-=1){let k=d[b];k.kind!=="chart"&&k.kind!=="table"||(f=jsx("div",{"aria-hidden":"true",style:{position:"absolute",left:0,top:0,pointerEvents:"none",width:t.confirmed.displayList.width,height:t.confirmed.displayList.height,clipPath:t.echo?$r(d.slice(0,b+1),{x:k.x,y:k.y,width:k.w,height:k.h}):void 0},children:f},b));}return f}function $r(e,t){return `polygon(${[[t.x,t.y],[t.x+t.width,t.y],[t.x+t.width,t.y+t.height],[t.x,t.y+t.height]].map(([i,a])=>{let p=transformedRect(e,{x:i,y:a,width:0,height:0});return `${p.x}px ${p.y}px`}).join(", ")})`}var xs=0;function on(e,{canvas:t,presentation:o,focus:i}={}){let a=useRef(null),p=useRef(null);useEffect(()=>()=>{let l=a.current;e&&Me(e,"text",false),a.current=null,l&&l.element.releasePointerCapture?.(l.pointerId),p.current=null;},[e]);let r=useCallback(l=>{if(!e)return false;let c=Sn(l.key,l);if(!c)return false;let S=c==="nextCell"||c==="previousCell";if(!S&&e.getSnapshot().selection?.kind==="object"||S&&!Go(e))return false;let x=l.shiftKey&&!S;if(!(c==="wordLeft"||c==="wordRight"||c==="storyStart"||c==="storyEnd")&&Mt(e)){let n=Uo(e,l.key,x,l);return n?(l.preventDefault(),e.dispatch({kind:"setSelection",payload:{selection:n,inputTime:l.timeStamp,undoGroup:"selection"}}).catch(()=>{}),true):false}let I=Ge(e,true);return I?(l.preventDefault(),e.dispatch({kind:"moveSelection",payload:{at:I,motion:c,extend:x,inputTime:l.timeStamp,undoGroup:"selection"}}).catch(()=>{}),true):false},[e]),u=useCallback(function l(c,S,x=false){if(!e||!o?.selectionEnabled||!t?.current||e.getSnapshot().composition)return false;let C=o.getVisualSnapshot()?.view.confirmed,I=t.current.getBoundingClientRect();if(!C||!I.width||!I.height)return false;let n=(c.clientX-I.left)*C.displayList.width/I.width,h=(c.clientY-I.top)*C.displayList.height/I.height;if(!S&&(n<0||h<0||n>C.displayList.width||h>C.displayList.height))return false;let E=Ge(e,true),v=S;if(!S){let H=At(o,t.current,c.clientX,c.clientY);if(!H)return p.current=null,c.preventDefault(),e.dispatch({kind:"setSelection",payload:{selection:null,inputTime:c.timeStamp,undoGroup:"selection"}}).catch(()=>{}),c.currentTarget.focus(),true;if(H.kind!=="text")return false;let D=E?.source==="confirmed"?E.selection:null;v=c.shiftKey&&(E?.source==="afterSeq"||D?.slideId===C.frame.slideId&&D.shapeId===H.shapeId&&D.storyId===H.storyId&&D.kind!=="shape"&&D.kind!=="object");let W=JSON.stringify([C.frame.slideId,H.shapeId,H.storyId]),_=p.current,J=_?.target===W&&c.timeStamp-_.time<=600&&Math.hypot(c.clientX-_.x,c.clientY-_.y)<=6,y=c.shiftKey?1:c.detail>0?Math.min(c.detail,3):J?Math.min(_.count+1,3):1;p.current={target:W,count:y,time:c.timeStamp,x:c.clientX,y:c.clientY},a.current={pointerId:c.pointerId,group:`pointer-${++xs}`,granularity:y>=3?"paragraph":y===2?"word":"character",element:c.currentTarget,x:c.clientX,y:c.clientY,lastX:c.clientX,lastY:c.clientY,dragging:false},Me(e,"text",true),c.currentTarget.setPointerCapture?.(c.pointerId);}let P=a.current;if(!P||P.pointerId!==c.pointerId)return false;if(c.preventDefault(),S&&P.lastX===c.clientX&&P.lastY===c.clientY)return P.queued=void 0,true;if(S&&P.inFlight&&!x)return P.queued=c,true;P.queued=void 0,P.lastX=c.clientX,P.lastY=c.clientY;let{slideId:m,slideRevision:w,coversThroughSeq:T,documentEpoch:q,incarnation:O}=C.frame;S&&(P.inFlight=true);let z=e.dispatch({kind:"selectAtPoint",payload:{...E?{at:E}:{},frame:{slideId:m,slideRevision:w,coversThroughSeq:T,documentEpoch:q,incarnation:O},x:n,y:h,extend:v,granularity:P.granularity,drag:S,inputTime:c.timeStamp,undoGroup:P.group}}),B=()=>{if(!S||a.current!==P)return;P.inFlight=false;let H=P.queued;P.queued=void 0,H&&l(H,true);};return z.then(B,B),i?.(),true},[e,o,t,i]),g=useCallback(()=>{let l=a.current?.queued;l&&u(l,true,true);},[u]);useEffect(()=>{let l=t?.current?.closest('[role="application"]');if(!l)return;let c=["keydown","beforeinput","paste","compositionstart"];for(let S of c)l.addEventListener(S,g,true);return ()=>{for(let S of c)l.removeEventListener(S,g,true);}},[t,e,g]);let f=useCallback(l=>{l.button!==0||l.isPrimary===false||(g(),u(l,false));},[u,g]),d=useCallback(l=>{let c=a.current;!c||c.pointerId!==l.pointerId||!c.dragging&&Math.hypot(l.clientX-c.x,l.clientY-c.y)<=3||(c.dragging=true,p.current=null,u(l,true));},[u]),b=useCallback(l=>{let c=a.current;!c||c.pointerId!==l.pointerId||(c.dragging&&u(l,true,true),a.current=null,e&&Me(e,"text",false),c.element.releasePointerCapture?.(l.pointerId));},[u,e]),k=useCallback(l=>{let c=a.current;!c||c.pointerId!==l.pointerId||(a.current=null,e&&Me(e,"text",false),c.element.releasePointerCapture?.(l.pointerId),p.current=null);},[e]);return {move:r,onPointerDown:f,onPointerMove:d,onPointerUp:b,onPointerCancel:k,onLostPointerCapture:k}}var Zr=0;function Qr({store:e,visual:t=e,viewport:o,onShortcut:i,commands:a,inputRef:p}){let{t:r}=b(),u=r("editor.textInput"),g=r("editor.selectionAnnouncement"),f=useRef(null),d=p??f,b$1=useRef(a);b$1.current=a;let k=useRef(i);k.current=i;let l=useSyncExternalStore(t.subscribePresentation,t.getSnapshot,t.getSnapshot),{move:c}=on(e);useEffect(()=>{let n=d.current;if(!n)return;let h=null,E=null,v,P=false,m=false;function w(M){let X=e.dispatch(M);X!==v&&X.catch(()=>{}),v=X;}function T(M,X,ne=false){let se=Ge(e,true);if(e.getSnapshot().selection?.kind==="object"&&se?.source!=="afterSeq"||!se||!M)return;let xe={at:se,text:M,inputTime:X,undoGroup:ne?`paste-${++Zr}`:"typing"};w({kind:ne?"replaceText":"insertText",payload:xe});}function q(){e.getSnapshot().composition||(n.value="");}function O(M){let X=e.getSnapshot(),ne=Ge(e,true);if(X.editState.readOnly||X.selection?.kind==="object"&&ne?.source!=="afterSeq"){M.preventDefault();return}if(P||m&&!X.composition){M.preventDefault(),q();return}if(X.composition||M.isComposing||M.inputType==="insertCompositionText"){M.data!==null&&X.composition&&e.updateComposition(M.data);return}if(h!==null){let xe=h;if(h=null,(M.inputType==="insertText"||M.inputType==="insertFromComposition")&&M.data===xe){M.preventDefault(),q();return}}if(!ne)return;let se={at:ne,inputTime:M.timeStamp,undoGroup:"typing"};switch(M.inputType){case "insertText":case "insertReplacementText":case "insertFromComposition":M.preventDefault(),T(M.data??"",M.timeStamp);break;case "insertFromPaste":{M.preventDefault();let xe=M.dataTransfer?.getData("text/plain")??M.data??"";E!==xe&&T(xe,M.timeStamp,true),E=null;break}case "deleteContentBackward":M.preventDefault(),w({kind:"deleteBackward",payload:{...se,unit:"codePoint"}});break;case "deleteContentForward":M.preventDefault(),w({kind:"deleteForward",payload:{...se,unit:"codePoint"}});break;case "insertParagraph":case "insertLineBreak":M.preventDefault(),w({kind:"paragraphBreak",payload:se});break;default:return}q();}function z(M){if(M.defaultPrevented)return;let X=M.ctrlKey||M.metaKey,ne=M.key.toLowerCase();if(X&&!M.altKey&&(ne==="z"||ne==="y"&&!M.shiftKey)){if(M.preventDefault(),M.repeat||e.getSnapshot().editState.readOnly)return;P=!!e.getSnapshot().composition,h=null,E=null,n.value="",k.current?.(ne==="z"&&!M.shiftKey?"undo":"redo");return}if(!(M.isComposing||e.getSnapshot().composition||M.keyCode===229)){if(h=null,E=null,X&&!M.altKey&&!M.shiftKey&&["b","i","u","s"].includes(ne)){if(M.preventDefault(),M.repeat)return;ne==="s"?k.current?.("save"):b$1.current?b$1.current.execute(ne==="b"?"bold":ne==="i"?"italic":"underline",null):Xt(e,ne==="b"?"bold":ne==="i"?"italic":"underline",M.timeStamp)?.catch(()=>{});return}if(X){let se=ne==="c"?"copy":ne==="x"?"cut":null;if(se){if(M.preventDefault(),se!=="copy"&&e.getSnapshot().editState.readOnly)return;k.current?.(se);return}}["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab"].includes(M.key)&&c(M);}}function B(M){e.getSnapshot().editState.readOnly||(h=null,P=false,m=true,e.beginComposition(`composition-${++Zr}`,M.timeStamp));}function H(M){e.getSnapshot().editState.readOnly||e.updateComposition(M.data);}function D(M){if(m=false,P||!e.getSnapshot().composition){h=M.data,P=false,q();return}e.getSnapshot().editState.readOnly||!e.getSnapshot().composition||(h=M.data,Be(e,M.data,M.timeStamp).catch(()=>{}),q());}function W(M){if(!e.getSnapshot().editState.readOnly)if(e.getSnapshot().composition){let X=M.data;e.updateComposition(X??n.value);}else q();}function _(M){if(e.getSnapshot().composition||e.getSnapshot().editState.readOnly)return;M.preventDefault();let X=M.clipboardData?.getData("text/plain")??"";E=X,T(X,M.timeStamp,true),q();}function J(){e.setFocused(true);}function y(){e.setFocused(false);}n.addEventListener("beforeinput",O),n.addEventListener("keydown",z),n.addEventListener("compositionstart",B),n.addEventListener("compositionupdate",H),n.addEventListener("compositionend",D),n.addEventListener("input",W),n.addEventListener("paste",_);let ie=M=>{M.preventDefault(),k.current?.("copy");},re=M=>{M.preventDefault(),e.getSnapshot().editState.readOnly||k.current?.("cut");};return n.addEventListener("copy",ie),n.addEventListener("cut",re),n.addEventListener("focus",J),n.addEventListener("blur",y),()=>{let M=e.getSnapshot().composition;M&&!e.getSnapshot().editState.readOnly&&Be(e,M.text,performance.now()).catch(()=>{}),n.removeEventListener("beforeinput",O),n.removeEventListener("keydown",z),n.removeEventListener("compositionstart",B),n.removeEventListener("compositionupdate",H),n.removeEventListener("compositionend",D),n.removeEventListener("input",W),n.removeEventListener("paste",_),n.removeEventListener("copy",ie),n.removeEventListener("cut",re),n.removeEventListener("focus",J),n.removeEventListener("blur",y);}},[e,c,d]);let S=o?.scale??1,x=(o?.left??0)+(l.caret?.x??0)*S,C=(o?.top??0)+(l.caret?.y??0)*S,I=Math.max(1,(l.caret?.height??1)*S);return jsxs(Fragment,{children:[l.composition?.text&&!l.echo&&l.caret&&jsx("span",{"data-testid":"pptx-preedit","aria-hidden":"true",style:{position:"absolute",left:x,top:C,lineHeight:`${I}px`,fontSize:I*.8,whiteSpace:"pre",borderBottom:"1px solid currentColor",background:"#fff",pointerEvents:"none"},children:l.composition.text}),jsx("span",{role:"status","aria-live":"polite",style:{position:"absolute",width:1,height:1,overflow:"hidden",clipPath:"inset(50%)"},children:l.selection&&l.selection.anchor!==l.selection.focus?g:""}),jsx("textarea",{ref:d,"aria-label":u,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:false,tabIndex:0,readOnly:l.editState.readOnly,style:{position:"absolute",left:x,top:C,width:1,height:I,opacity:0,padding:0,border:0,resize:"none",overflow:"hidden",pointerEvents:"none"}}),l.inputFailure&&jsx("div",{role:"alert",children:l.inputFailure.message})]})}function ti({selection:e,preview:t,scale:o$1,readOnly:i}){let{t:a}=b(),p$1=useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot),r=e.bounds,u=p$1?.token===e.token?p$1.bounds:r;return jsxs(Fragment,{children:[jsx("div",{"data-testid":"pptx-shape-selection",style:{position:"absolute",pointerEvents:"none",left:r.x*o$1,top:r.y*o$1,width:r.width*o$1,height:r.height*o$1,border:"2px solid #2563eb",boxSizing:"border-box",transformOrigin:"0 0",transform:`translate(${(u.x-r.x)*o$1}px, ${(u.y-r.y)*o$1}px) scale(${r.width?u.width/r.width:1}, ${r.height?u.height/r.height:1})`}}),!i&&e.canResize&&a$1.map(g=>{let f=o(u,g);return jsx("span",{"data-testid":`pptx-resize-${g}`,"data-pptx-resize":g,role:"img","aria-label":a(`objects.resize.${g}`),style:{position:"absolute",pointerEvents:"auto",left:f.x*o$1-4,top:f.y*o$1-4,width:8,height:8,borderRadius:"50%",border:"1px solid #2563eb",background:"#fff",boxSizing:"border-box",cursor:p(g),touchAction:"none"}},g)})]})}var qs=0;function ni(e,t,o){if(!e.rect||!e.canMove||o&&!e.canResize)return null;let i={x:Math.round(t.x*e.units.x),y:Math.round(t.y*e.units.y)};return i.x===0&&i.y===0?{...e.rect}:o?q(e.rect,o,i,76200,e.aspectRatioLocked):{...e.rect,x:e.rect.x+i.x,y:e.rect.y+i.y}}function As(e,t,o){return o?{x:t.x/e.units.x,y:t.y/e.units.y,width:t.width/e.units.x,height:t.height/e.units.y}:{...e.bounds,x:e.bounds.x+(t.x-e.rect.x)/e.units.x,y:e.bounds.y+(t.y-e.rect.y)/e.units.y}}function oi(e,{canvas:t,presentation:o}){let i=useRef(null),a=useRef(new Set),p=useRef(null),r$1=useRef(null),u=useRef(new Set),g=useRef({getSnapshot:()=>r$1.current,subscribe:n=>(u.current.add(n),()=>{u.current.delete(n);})}),f=useCallback(n=>{if(r$1.current!==n){r$1.current=n;for(let h of u.current)h();}},[]),d=useCallback(()=>{let n=i.current;e&&Me(e,"shape",false),i.current=null,p.current=null;for(let h of a.current)h.cancelled=true;a.current.clear(),n&&n.element.releasePointerCapture?.(n.pointerId),f(null);},[e,f]);useEffect(()=>{if(f(null),!e)return;let n=()=>{let E=i.current,v=e.getSnapshot(),P=v.confirmed?.frame;E&&(v.editState.readOnly||!P||P.slideId!==E.frame.slideId||P.slideRevision!==E.frame.slideRevision||E.selected&&(v.selection?.kind!=="object"||v.selection.token!==E.selected.token))&&d();},h=[e.subscribePresentation(n),e.subscribeEditState(n)];return window.addEventListener("blur",d),()=>{window.removeEventListener("blur",d);for(let v of h)v();let E=i.current;Me(e,"shape",false),i.current=null;for(let v of a.current)v.cancelled=true;a.current.clear(),p.current=null,E?.element.releasePointerCapture?.(E.pointerId);}},[e,o,d,f]);let b=useCallback(n=>{let h=o?.getVisualSnapshot()?.view.confirmed;return t.current&&h?b$1(t.current.getBoundingClientRect(),h.displayList,n.clientX,n.clientY):null},[t,o]),k=useCallback(n=>{if(i.current!==n||n.cancelled||!n.dragging||!n.selected||e?.getSnapshot().editState.readOnly)return;let h=ni(n.selected,n.delta,n.handle);h&&f({token:n.selected.token,bounds:As(n.selected,h,!!n.handle)});},[e,f]),l=useCallback(n=>{if(!e||!o?.selectionEnabled||!t.current||n.button!==0||n.isPrimary===false||e.getSnapshot().composition)return false;let E=o.getVisualSnapshot()?.view.confirmed,v=b(n);if(!E||!v)return false;let P=n.target.dataset?.pptxResize;if(P&&!a$1.includes(P))return false;let m=e.getSnapshot().selection,w=t.current.getBoundingClientRect().width/E.displayList.width;if(P&&(m?.kind!=="object"||!m.canResize||e.getSnapshot().editState.readOnly))return true;let T=P?null:Rt(e,v,w);if(!P&&T?.kind!=="shape")return false;let q=P&&m?.kind==="object"?m.shapeId:T.shapeId,O=p.current,z=!P&&O?.slideId===E.frame.slideId&&O.shapeId===q&&n.timeStamp>=O.time&&n.timeStamp-O.time<=600&&Math.hypot(n.clientX-O.x,n.clientY-O.y)<=6;d();let{slideId:B,slideRevision:H,coversThroughSeq:D,documentEpoch:W,incarnation:_}=E.frame,J={slideId:B,slideRevision:H,coversThroughSeq:D,documentEpoch:W,incarnation:_},y=`shape-${++qs}`,ie=P&&m?.kind==="object"?Promise.resolve(m):e.dispatch({kind:"selectObject",payload:{frame:J,x:v.x,y:v.y,scale:w,inputTime:n.timeStamp,undoGroup:y}}).then(M=>M.outcomes.some(X=>X.status==="refused"||X.status==="cancelled")||M.selection?.kind!=="object"?null:M.selection,()=>null),re={pointerId:n.pointerId,element:n.currentTarget,frame:J,group:y,start:v,client:{x:n.clientX,y:n.clientY},delta:{x:0,y:0},shapeId:q,dragThreshold:z?8:4,handle:P,object:ie,selected:P&&m?.kind==="object"?m:null,dragging:false,cancelled:false};return i.current=re,Me(e,"shape",true),a.current.add(re),ie.then(M=>{re.selected=M,k(re);}),n.preventDefault(),n.currentTarget.focus(),n.currentTarget.setPointerCapture?.(n.pointerId),true},[e,o,t,d,b,k]),c=useCallback(n=>{if(n.buttons!==0||e&&Pt(e))return null;let h=o?.getVisualSnapshot()?.view.confirmed,E=b(n);if(!e||!o?.selectionEnabled||!t.current||!h||!E)return "default";let v=Rt(e,E,t.current.getBoundingClientRect().width/h.displayList.width);return v?.kind==="text"?"text":v?.kind==="shape"?"move":"default"},[e,o,t,b]),S=useCallback(n$1=>{let h=i.current;if(!h||h.pointerId!==n$1.pointerId)return false;let E=b(n$1);return E&&(h.dragging||(h.dragging=n(h.client.x,h.client.y,n$1.clientX,n$1.clientY,h.dragThreshold)),h.delta={x:E.x-h.start.x,y:E.y-h.start.y},k(h)),true},[b,k]),x=useCallback(n$1=>{let h=i.current;if(!e||!h||h.pointerId!==n$1.pointerId)return false;let E=b(n$1),v=r(h.start,h.delta,E),P=h.dragging||n(h.client.x,h.client.y,n$1.clientX,n$1.clientY,h.dragThreshold),m=n$1.timeStamp;if(i.current=null,Me(e,"shape",false),p.current=!h.handle&&!P?{slideId:h.frame.slideId,shapeId:h.shapeId,x:n$1.clientX,y:n$1.clientY,time:m}:null,h.element.releasePointerCapture?.(h.pointerId),f(null),!P||v.x===0&&v.y===0)return a.current.delete(h),true;if(a.current.delete(h),h.cancelled||!o?.current||e.getSnapshot().editState.readOnly)return true;let w=h.selected;if(!w){let O=Ge(e,true);return O?.source==="afterSeq"&&!h.handle&&e.dispatch({kind:"moveShape",payload:{at:O,frame:h.frame,shapeId:h.shapeId,delta:v,inputTime:m,undoGroup:h.group}}).catch(()=>{}),true}let T=ni(w,v,h.handle);if(!T||Object.keys(T).every(O=>T[O]===w.rect[O]))return true;let q={frame:h.frame,target:{slideId:w.slideId,shapeId:w.shapeId,token:w.token},inputTime:m,undoGroup:h.group};return e.dispatch(h.handle?{kind:"setShapeRect",payload:{...q,rect:T}}:{kind:"moveShape",payload:{...q,x:T.x,y:T.y}}).catch(()=>{}),true},[e,o,b,f]),C=useCallback(n=>i.current?.pointerId!==n.pointerId?false:(d(),true),[d]),I=useCallback(n=>{n.key!=="Escape"||!a.current.size||(n.preventDefault(),n.stopPropagation(),d());},[d]);return {preview:g.current,hoverCursor:c,onPointerDown:l,onPointerMove:S,onPointerUp:x,onPointerCancel:C,onKeyDown:I,onLostPointerCapture:C}}function Ds(e,t,o,i,a,p){let r=useRef(t);r.current=t;let u=useRef(0),g=useRef(null),[f,d]=useState(null),b=useCallback((c,S)=>{let x=e.current,C=r.current;if(!x||!C?.current)return;let I=C.store.getSnapshot().confirmed?.displayList;if(!I)return;c??(c=x.clientWidth),S??(S=x.clientHeight);let n=p==="fit"?En(c,S,I):p,h=x.ownerDocument.defaultView?.devicePixelRatio??1,E=g.current;if(E?.run===C&&E.width===c&&E.height===S&&E.token.scale===n&&E.token.dpr===h)return;let v={scale:n,dpr:h,generation:++u.current};g.current={run:C,token:v,width:c,height:S},C.fit(v),d(v);},[e,p]);useLayoutEffect(()=>{let c=e.current;if(!c)return;let S=typeof ResizeObserver>"u"?void 0:new ResizeObserver(C=>{let I=C.find(n=>n.target===c);I&&b(I.contentRect.width,I.contentRect.height);});S?.observe(c);let x=()=>b();return window.addEventListener("resize",x),()=>{S?.disconnect(),window.removeEventListener("resize",x);}},[e,b]),useLayoutEffect(()=>{b();},[t,o,i,a,b]);let k=useCallback((c,S)=>{let x=g.current?.run===S?g.current.token:S.getVisualSnapshot()?.fit;return x?{...x,scale:En(128,Number.MAX_VALUE,c.displayList,0)}:null},[f]),l=useCallback((c,S)=>{let x=g.current;return x!==null&&r.current===S&&x.run===S&&S.current&&!!x.token.scale&&x.token.generation===c.generation},[]);return {previewFit:k,current:l}}function Vs({run:e,commands:t,inputRef:o,preview:i,insertion:a,onError:p}){let r=useSyncExternalStore(e.subscribeVisual,e.getVisualSnapshot,e.getVisualSnapshot),u=useMemo(()=>r?.view.confirmed?indexGeometry(r.view.confirmed.displayList):null,[r?.view.confirmed]);if(!r?.view.confirmed)return null;let{view:g,fit:f}=r,d=g.confirmed,b=g.selection,k=b&&b.kind!=="object"&&b.slideId===d.frame.slideId?u.hits.filter(({primitive:x})=>x.shapeId===b.shapeId).map(({primitive:x,transforms:C})=>transformedRect(C,{x:x.x,y:x.y,width:x.w,height:x.h})):[],l=Math.min(...k.map(x=>x.x)),c=Math.min(...k.map(x=>x.y)),S=a??(k.length?{x:l,y:c,width:Math.max(...k.map(x=>x.x+x.width))-l,height:Math.max(...k.map(x=>x.y+x.height))-c}:null);return jsxs("div",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",touchAction:"none",overflow:"hidden",width:d.displayList.width*f.scale,height:d.displayList.height*f.scale},children:[jsx("div",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",width:d.displayList.width,height:d.displayList.height,transform:`scale(${f.scale})`,transformOrigin:"0 0"},children:jsx(Xr,{store:e.visual})}),!a&&g.selection?.kind==="object"&&jsx(ti,{selection:g.selection,preview:i,scale:f.scale,readOnly:g.editState.readOnly}),S&&jsx("span",{"data-testid":"pptx-text-edit-outline","aria-hidden":"true",style:{position:"absolute",zIndex:3,pointerEvents:"none",border:"2px dashed #6b7280",boxSizing:"border-box",boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.9)",left:S.x*f.scale,top:S.y*f.scale,width:Math.max(1,S.width*f.scale),height:Math.max(1,S.height*f.scale)}}),jsx(Qr,{inputRef:o,store:e.store,commands:t,visual:e.visual,viewport:{left:0,top:0,scale:f.scale},onShortcut:x=>{(x==="copy"||x==="cut")&&Rr(e,x==="cut").catch(C=>{e.failure||p(C instanceof Error?C:new Error(String(C)));}),(x==="save"||x==="undo"||x==="redo")&&t.execute(x,null);}})]})}function Sd(e){let{t}=b(),o=useRef(null),i=useRef(null),a=useRef(null),p=useRef(null),{presentation:r,pending:u,failure:g}=br(e,i),f=u??r,d=useCallback(L=>f?.store.subscribeStructure(L)??(()=>{}),[f]),b$1=useCallback(()=>f?.client.state.slides??null,[f]),k=useSyncExternalStore(d,b$1,b$1),l=!!(r&&r.store.getSnapshot().confirmed===null);useLayoutEffect(()=>{if(!l||!i.current)return;let L=i.current,te=L.getContext("2d");te?.setTransform(1,0,0,1,0,0),te?.clearRect(0,0,L.width,L.height);},[l]);let{toolbar:c,showToolbar:S}=e,[x$1,C]=useState(()=>_(e.initialZoom)),I$1=useRef(e.initialZoom);I$1.current=e.initialZoom,useLayoutEffect(()=>{I$1.current!==void 0&&C(_(I$1.current));},[e.file]);let n=S!==false&&c!==null,h=c!==void 0||!e.readOnly,{previewFit:E$1,current:v}=Ds(a,u??r,f,c,n,x$1),P=useRef(e);P.current=e;let m=useRef(null),w=useRef(null),T=useCallback(()=>{w.current?.focus();},[]),q=useCallback(()=>{a.current?.focus();},[]),O=on(r?.store??null,{canvas:i,presentation:r,focus:T}),z=rr(r,i,T),[B,H$1]=useState({open:false,selectedId:null,diff:false,presenting:false}),D=useCallback(L=>r?.store.subscribeEditState(L)??(()=>{}),[r]),W=useCallback(()=>r?.store.getSnapshot().editState??null,[r]),_$1=useSyncExternalStore(D,W,W),J$1=_$1?.proposals??js;useLayoutEffect(()=>{B.selectedId&&!J$1.some(L=>L.id===B.selectedId)&&H$1(L=>({...L,selectedId:null,diff:false}));},[J$1,B.selectedId]),useEffect(()=>{B.diff||T();},[B.diff,T]);let y$1=useCallback(async()=>{if(r)try{let{png:L,index:te}=await Fr(r);r.require();let we=URL.createObjectURL(L),ke=(P.current.fileName??"presentation.pptx").replace(/\.pptx$/i,""),pe=document.createElement("a");pe.href=we,pe.download=`${ke}-slide-${te+1}.png`,pe.click(),URL.revokeObjectURL(we);}catch(L){throw r.current&&!r.failure&&P.current.onError?.(L instanceof Error?L:new Error(String(L))),L}},[r]),ie=useRef(null),re=useRef(null),M$1=useCallback(()=>{re.current=kn(r),re.current&&ie.current?.click();},[r]),X=oi(r?.store??null,{canvas:i,presentation:r});useEffect(()=>{i.current&&(i.current.style.cursor=z.tool!=="select"?"crosshair":"default");},[z.tool,B.diff]);let ne=useCallback(async()=>{try{let L=m.current;if(!L||!r?.current)return;let te=P.current.onSaveRequest;if(te&&await te()!==!0)return;let we=await L.save();if(m.current!==L||(P.current.onSave?.(we),!(P.current.downloadOnSave??!P.current.onSave)))return;let ke=URL.createObjectURL(new Blob([new Uint8Array(we)],{type:"application/vnd.openxmlformats-officedocument.presentationml.presentation"})),pe=document.createElement("a");pe.href=ke,pe.download=P.current.fileName??"presentation.pptx",pe.click(),URL.revokeObjectURL(ke);}catch(L){throw r?.session.failure||P.current.onError?.(L instanceof Error?L:new Error(String(L))),L}},[r]),se=Zo(r,{tool:z.tool,setTool:z.setTool,openPicture:M$1,save:ne,focus:T,i18n:e.i18n,zoom:x$1,setZoom:C,review:B,proposals:J$1,setReview:H$1,exportPng:y$1}),[xe,Ce]=L(!!e.plugins?.length);J({commands:y(se),containerRef:o,editorInput:w,suspended:()=>B.presenting||!!r?.store.getSnapshot().composition}),useLayoutEffect(()=>{if(m.current=null,!r?.current||!i.current)return;let L=sr(r,i.current,T,se);m.current=L;let te=true,we;return (async()=>{for(;te&&r.current;)if(await r.ready,te&&r.current&&r.hydrated){we=P.current.onReady?.(L);return}})().catch(ke=>{if(!te||!r.current||r.failure)return;let pe=ke instanceof Error?ke:new Error(String(ke));console.error("[PptxEditor] onReady failed",pe);try{P.current.onError?.(pe);}catch{}}),()=>{te=false,m.current=null,typeof we=="function"&&we();}},[r,T,se]);let oe=mr(r,se,i,m,e,B.diff);useEffect(()=>{let L=e.collaboration;if(!r?.current||g||!L?.onReplica)return;let te=Gr(r,r.collaborationClientId??L.clientId);return L.onReplica(te),()=>{try{L.onReplica?.(null);}finally{Ur(te);}}},[r,g,e.collaboration?.onReplica]);let Ae=r?.getVisualSnapshot()?.fit.scale??1;return jsx(A.Provider,{value:se,children:jsxs("div",{ref:o,className:e.className,style:{...et.editor,...e.style},"data-testid":"pptx-worker-editor",children:[n&&(h||f)&&jsx("div",{style:et.toolbarShell,children:jsxs(x.Provider,{value:true,children:[h&&jsx("div",{style:et.toolbar,children:c??(f?jsx(E,{mode:"commands"}):null)}),c===void 0&&!e.readOnly&&_$1?.proposals&&jsx(G,{count:J$1.length}),c===void 0&&f&&jsx(F,{})]})}),!g&&(!e.file||!r||l)&&jsx("div",{role:"status","data-testid":"pptx-worker-status",style:{position:"absolute"},children:e.file?l?t("editor.noSlides"):e.loadingIndicator!==void 0?e.loadingIndicator:t("worker.preparing"):t("editor.openPrompt")}),g&&jsx($,{kind:r?"stopped":"open",details:g.message,children:r&&jsx(Tr,{run:r,fileName:e.fileName})}),jsxs("div",{ref:xe,style:et.workspace,children:[jsx(ir,{input:ie,origin:re,onError:L=>P.current.onError?.(L)}),f&&k&&k.length>0&&jsx(Cr,{run:f,previewFit:E$1,current:v,onNavigate:q}),oe.managed&&jsx(M,{host:oe.host,placement:"left",activations:oe.activations.filter(L=>L.plugin.panel?.placement==="left"),available:Ce}),jsx("div",{ref:a,role:"application","aria-label":t("editor.appLabel"),tabIndex:0,"aria-readonly":!!(e.readOnly||g),style:et.stage,onKeyDown:L=>{if(H(L.nativeEvent)||I(L.target)||(L.key==="Escape"&&z.cancel(),X.onKeyDown(L),L.defaultPrevented)||!r?.current||B.diff)return;let te=r.store.getSnapshot().selection;if((L.key==="Delete"||L.key==="Backspace")&&te?.kind==="object"){L.preventDefault(),r.inputEnabled&&Je(r,{kind:"remove"}).catch(()=>{});return}No(L,r.store),L.defaultPrevented||hr(L,r);},onPointerDown:L=>{!H(L.nativeEvent)&&!I(L.target)&&!B.diff&&!z.onPointerDown(L)&&!X.onPointerDown(L)&&O.onPointerDown(L);},onPointerMove:L=>{if(H(L.nativeEvent)||I(L.target)||B.diff)return;let te=z.tool==="select"?X.hoverCursor(L):null;te&&i.current&&(i.current.style.cursor=te),!z.onPointerMove(L)&&!X.onPointerMove(L)&&O.onPointerMove(L);},onPointerUp:L=>{!H(L.nativeEvent)&&!I(L.target)&&!B.diff&&!z.onPointerUp(L)&&!X.onPointerUp(L)&&O.onPointerUp(L);},onPointerCancel:L=>{H(L.nativeEvent)||I(L.target)||(z.onPointerCancel(L),X.onPointerCancel(L)||O.onPointerCancel(L));},onLostPointerCapture:L=>{H(L.nativeEvent)||I(L.target)||(z.onPointerCancel(L),X.onLostPointerCapture(L)||O.onLostPointerCapture(L));},children:jsxs("div",{ref:p,style:et.slideFrame,children:[jsx("canvas",{ref:i,style:r&&!l&&!g?et.slideCanvas:et.canvas,"data-testid":"pptx-slide-canvas"}),z.preview&&jsx("div",{"data-testid":"pptx-insertion-preview",style:{position:"absolute",pointerEvents:"none",left:z.preview.x*Ae,top:z.preview.y*Ae,width:z.preview.width*Ae,height:z.preview.height*Ae,border:"1px dashed #2563eb"}}),oe.managed&&jsx(K,{host:oe.host,activations:oe.activations,layerRef:oe.layerRef,claimPointerEvents:true}),r&&!g&&e.collaboration?.presence&&jsx(Hr,{run:r,presence:e.collaboration.presence}),r&&!B.diff&&jsx(Vs,{run:r,commands:se,inputRef:w,preview:X.preview,insertion:z.echo?.rect??null,onError:L=>P.current.onError?.(L)})]})}),oe.managed&&jsx(M,{host:oe.host,placement:"right",activations:oe.activations.filter(L=>L.plugin.panel?.placement==="right"),available:Ce}),r&&jsx(jr,{run:r,diffHost:p,state:B,proposals:J$1,commands:se,onError:L=>P.current.onError?.(L),exit:()=>{H$1({...B,presenting:false}),T();}})]}),oe.managed&&jsx(M,{host:oe.host,placement:"bottom",activations:oe.activations.filter(L=>L.plugin.panel?.placement==="bottom"),available:Ce}),r&&jsx(Ir,{run:r,onError:L=>P.current.onError?.(L)})]})})}var js=[],et={editor:{position:"relative",display:"flex",flexDirection:"column",height:"100%",minHeight:0,color:"#172033",fontFamily:"ui-sans-serif, system-ui, sans-serif"},toolbarShell:{display:"flex",alignItems:"center",flex:"0 0 auto"},toolbar:{flex:"1 1 auto",minWidth:0},workspace:{display:"flex",flex:1,minHeight:0},stage:{position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0,overflow:"auto",background:"#e2e8f0",touchAction:"none"},slideFrame:{position:"relative",flex:"0 0 auto",margin:"auto"},canvas:{display:"block",touchAction:"none"},slideCanvas:{display:"block",background:"#ffffff",boxShadow:"0 8px 32px rgba(27, 39, 61, 0.2)",touchAction:"none"}};export{Sd as PeerlessPptxSurface};
@@ -1 +0,0 @@
1
- import {H,Q,c,S,d,E,e,b,Z,R,C,y,_,U,D,X,I,J,q,p,f,h,g,z,i,m,k,j as j$1,aa,ca,Y,n,o,A,W,O,P,T,N,L,$,x,V as V$1,G,K,F,a,M,s,r,u,t}from'./chunk-X2M23RXQ.js';import {a as a$1}from'./chunk-O2XFH626.js';import {createContext,forwardRef,useRef,useId,useState,useCallback,useImperativeHandle,useEffect,useLayoutEffect,useContext,useSyncExternalStore,useReducer,useMemo,Component}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var be=createContext(null);function oa(){let e=useContext(be);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}var ke=createContext(null),fn=createContext(false);function hn({value:e,label:t,onChange:n,onClear:o,icon:r="textColor",none:i=false,clearLabel:u,disabled:a=false,description:p,testId:s}){let[x,c]=useState(false),m=Q(),h=X(a,p);return jsxs("span",{style:{display:"inline-flex",alignItems:"center",height:28},children:[jsxs("label",{title:W(t,null,h.reason),"aria-label":t,style:{display:"inline-grid",placeItems:"center",width:28,height:28,borderRadius:6,background:x&&!a?H.hover:"transparent",color:x&&!a?H.ink:H.inkMuted,cursor:a?"default":"pointer",opacity:a?I:1,boxSizing:"border-box",position:"relative",...J(m.focusRing)},onMouseEnter:()=>c(true),onMouseLeave:()=>c(false),children:[jsx(R,{name:r}),jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:7,right:7,bottom:5,height:3,borderRadius:1,boxShadow:`inset 0 0 0 1px ${H.line}`,background:i?"transparent":e,border:i?`1px solid ${H.inkMuted}`:0,boxSizing:"border-box"}}),i?jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:7,bottom:6,width:14,height:1,background:"#d93025",transform:"rotate(-18deg)"}}):null,h.node,jsx("input",{"data-testid":s,type:"color",...m.focusProps,value:e,...h.props,"aria-label":t,onClick:g=>{a&&g.preventDefault();},onKeyDown:g=>{a&&(g.key==="Enter"||g.key===" ")&&g.preventDefault();},onChange:g=>{a||n?.(g.target.value);},style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}})]}),o?jsx("button",{type:"button",disabled:a,"aria-label":u??t,title:u??t,onMouseDown:g=>g.preventDefault(),onClick:o,style:{appearance:"none",width:15,height:28,padding:0,border:0,borderRadius:6,background:"transparent",color:H.inkMuted,cursor:a?"default":"pointer",opacity:a?I:1,font:"500 14px ui-sans-serif, system-ui, sans-serif"},children:"\xD7"}):null]})}function Ue({value:e,options:t,label:n,onCommit:o,disabled:r=false,description:i,width:u=72,inputStyle:a,testId:p}){let s=X(r,i),[x,c]=useState(e),[m,h]=useState(false),[g,R$1]=useState(null),[w,L]=useState(null),H$1=Q(),[N,M]=useState({top:0,left:0,width:u}),D=useRef(null),A=useRef(null),$=useRef(null),v=useRef(false);useEffect(()=>{v.current=false,c(e);},[e]);let z=useCallback(()=>h(false),[]);useEffect(()=>{if(!m||!D.current)return;let l=D.current.getBoundingClientRect();M({top:l.bottom+4,left:l.left,width:Math.max(l.width,u)});},[m,u]),useEffect(()=>{if(!m)return;let l=b=>{let E=b.target;!D.current?.contains(E)&&!A.current?.contains(E)&&z();},f=b=>{b.key==="Escape"&&(v.current=false,c(e),z());};return document.addEventListener("mousedown",l),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",f);}},[m,z,e]);let C=useCallback(()=>{v.current&&(v.current=false,c(e),!r&&o&&x.trim()&&o(x.trim()));},[r,o,x,e]);return jsxs("div",{ref:D,style:{display:"inline-flex",alignItems:"center",width:u,height:28,border:`1px solid ${H.line}`,borderRadius:6,background:H.surface,opacity:r?I:1,boxSizing:"border-box",flex:"0 0 auto",...J(H$1.focusRing)},children:[jsx("input",{ref:$,"data-testid":p,role:"combobox","aria-label":n,"aria-autocomplete":"list","aria-expanded":m,...s.props,readOnly:r,title:s.reason?W(n,null,s.reason):void 0,value:x,onFocus:l=>{H$1.focusProps.onFocus(l),!r&&(h(true),l.currentTarget.select());},onChange:l=>{v.current=true,c(l.target.value);},onKeyDown:l=>{r||(l.key==="Enter"?(C(),z(),l.currentTarget.blur()):l.key==="Escape"?(v.current=false,c(e)):l.key==="ArrowDown"&&(h(true),l.preventDefault()));},onBlur:l=>{if(H$1.focusProps.onBlur(l),r){v.current=false,c(e);return}requestAnimationFrame(()=>{A.current?.contains(document.activeElement)||C();});},style:{appearance:"none",width:"calc(100% - 22px)",height:26,padding:"0 2px 0 7px",border:0,outline:0,background:"transparent",color:H.ink,font:"500 13px ui-sans-serif, system-ui, sans-serif",boxSizing:"border-box",...a}}),s.node,jsx("button",{type:"button",disabled:r,tabIndex:-1,"aria-label":n,title:n,onMouseDown:l=>l.preventDefault(),onClick:()=>{r||(h(l=>!l),$.current?.focus());},style:{appearance:"none",display:"grid",placeItems:"center",width:21,height:26,padding:0,border:0,background:"transparent",color:H.inkMuted,cursor:r?"default":"pointer"},children:jsx(R,{name:"chevronDown",size:18})}),m&&!r&&jsx("div",{ref:A,role:"listbox","aria-label":n,style:{position:"fixed",top:N.top,left:N.left,zIndex:1e4,width:N.width,maxHeight:260,overflowY:"auto",...O},children:t.map(l=>jsxs("button",{type:"button",role:"option","aria-selected":l.value===e,onMouseDown:f=>f.preventDefault(),onClick:()=>{v.current=false,c(l.label),o?.(l.value),z();},onMouseEnter:()=>R$1(l.value),onMouseLeave:()=>R$1(null),onFocus:()=>L(l.value),onBlur:()=>L(null),style:{...P({hovered:g===l.value,focusRing:w===l.value}),gap:6,minHeight:28,padding:"4px 8px 4px 4px"},children:[jsx("span",{style:{display:"inline-flex",width:18,flex:"0 0 auto"},children:l.value===e&&jsx(R,{name:"check",size:18})}),l.label]},l.value))})]})}var mt="pointer",Pn=false;function ft(){if(Pn||typeof document>"u")return;Pn=true;let e=()=>{mt="pointer";};document.addEventListener("pointerdown",e,true),document.addEventListener("mousedown",e,true),document.addEventListener("keydown",()=>{mt="keyboard";},true);}function No(e,t){ft(),!(mt!=="pointer"||t.ok&&t.status==="opened")&&requestAnimationFrame(()=>y(e)?.focusEditor());}function de(e,t,n){ft(),e.execute(t,n).then(o=>No(e,o));}ft();var _o={bold:"bold",italic:"italic",underline:"underline",textColor:"textColor",insertSlide:"newSlide",insertImage:"insertImage",shapeFill:"fillColor",shapeStrokeColor:"borderColor",shapeStrokeWidth:"borderWidth",zOrder:"bringToFront",save:"save",exportPng:"image",undo:"undo",redo:"redo"},Xe={l:{icon:"alignLeft",labelKey:"toolbar.align.left",testId:"left"},ctr:{icon:"alignCenter",labelKey:"toolbar.align.center",testId:"center"},r:{icon:"alignRight",labelKey:"toolbar.align.right",testId:"right"},just:{icon:"alignJustify",labelKey:"toolbar.align.justify",testId:"justify"}},gt={forward:{icon:"bringForward",labelKey:"toolbar.bringForward"},backward:{icon:"sendBackward",labelKey:"toolbar.sendBackward"},front:{icon:"bringToFront",labelKey:"toolbar.bringToFront"},back:{icon:"sendToBack",labelKey:"toolbar.sendToBack"}},Sn=["forward","backward","front","back"],Wo={bold:"pptx-bold",italic:"pptx-italic",underline:"pptx-underline",insertSlide:"pptx-new-slide",insertImage:"pptx-insert-image",save:"pptx-save",exportPng:"pptx-export-png",undo:"pptx-undo",redo:"pptx-redo"};function V(e){return e.enabled?void 0:e.disabledReason.message}function ce(e){return e&&typeof e=="object"?e:null}function ht(e,t){let n=ce(t)?.value;return e==="alignment"&&typeof n=="string"?Xe[n]?.icon:e==="zOrder"&&typeof n=="string"?gt[n]?.icon:e==="tool"&&typeof n=="string"?n==="select"?"select":n==="textBox"?"textBox":"shape":e==="fontSizeStep"?ce(t)?.direction==="increase"?"add":"remove":_o[e]}function Cn(e,t,n,o){let r=ce(t)?.value;if(e==="alignment"&&typeof r=="string"){let i=Xe[r];if(i)return n(i.labelKey)}if(e==="zOrder"&&typeof r=="string"){let i=gt[r];if(i)return n(i.labelKey)}if(e==="tool"&&typeof r=="string"){if(r==="select")return n("commands.selectTool");if(r==="textBox")return n("toolbar.textBoxTool");let i=k.find(u=>`shape:${u.geometry}`===r);if(i)return n(i.labelKey)}return e==="fontSizeStep"?n(ce(t)?.direction==="increase"?"toolbar.increaseFontSize":"toolbar.decreaseFontSize"):o}function $o(e,t){let n=ce(t)?.value;if(e==="alignment"&&typeof n=="string"){let o=Xe[n];return o?`pptx-align-${o.testId}`:void 0}if(e==="tool"&&n==="select")return "pptx-tool-select";if(e==="tool"&&n==="textBox")return "pptx-tool-text-box";if(e==="fontSizeStep")return ce(t)?.direction==="increase"?"pptx-font-size-increase":"pptx-font-size-decrease";if(!(e==="insertSlide"&&ce(t)?.layoutPartPath!==void 0))return Wo[e]}function wn(e,t){return e==="tool"&&ce(t)?.value==="select"?"Esc":j$1(e,t)}function En(e,t){return y(e)?.prepare(t)??{execute:n=>e.execute(t,n)}}function qe(e$1,t,n,o,r){let i=e$1.getState(n,o),u=ht(n,o);return {kind:"item",id:r,label:Cn(n,o,t,t(e$1.getDescriptor(n).labelKey)),icon:u?jsx(R,{name:u,size:16}):void 0,shortcut:wn(n,o)??void 0,checked:i.active,disabled:!i.enabled,description:V(i),onSelect:()=>{e$1.execute(n,o??e(n));}}}function Go(e,t,n){return (n.options??[]).map((o,r)=>({kind:"item",id:`${t}-${r}`,label:o.label,radio:true,checked:o.state.active===true,disabled:!o.state.enabled,description:o.state.enabled?void 0:o.state.disabledReason.message,onSelect:()=>{e.execute(t,o.args);}}))}function jo(e,t,n,o){let r=e.getState(n),i=V(r),u=Go(e,n,r);if(n==="insertSlide"&&u.unshift(qe(e,t,"insertSlide",{},"insertSlide-current"),{kind:"separator",id:"insertSlide-separator"}),n==="fontSize"&&o.prompt){let a=o.prompt;u.push({kind:"item",id:"fontSize-custom",label:t("commands.customFontSize"),disabled:!r.enabled,description:i,onSelect:()=>{let p=En(e,"fontSize");a({title:t("toolbar.fontSize"),label:t("commands.fontSizePoints"),initialValue:typeof r.value=="number"?String(r.value):"",valid:s=>/^\d+(\.\d+)?$/.test(s)&&e.getState("fontSize",{points:Number(s)}).enabled,submit:s=>{p.execute({points:Number(s)});}});}});}return {kind:"submenu",id:n,label:t(e.getDescriptor(n).labelKey),disabled:!r.enabled,description:i,entries:u}}var Tn={shapeFill:"toolbar.noFill",shapeStrokeColor:"toolbar.noBorder"};function Ve(e){return {color:e}}function Zo(e,t,n,o){let r=e.getState(n),i=!r.enabled,u=V(r),a=typeof r.value=="string"?r.value:null,p=t(e.getDescriptor(n).labelKey),s=[],x=Tn[n];if(x&&s.push({kind:"item",id:`${n}-clear`,label:t(x),radio:true,checked:r.value===null,disabled:i,description:u,onSelect:()=>{e.execute(n,Ve(null));}}),o.prompt){let c=o.prompt;s.push({kind:"item",id:`${n}-custom`,label:t("commands.customColor"),disabled:i,description:u,onSelect:()=>{let m=En(e,n);c({title:p,label:t("commands.hexColor"),placeholder:"#1A73E8",initialValue:a??"",valid:h=>/^#?[0-9a-f]{6}$/i.test(h),submit:h=>{m.execute(Ve(`#${h.replace(/^#/,"").toLowerCase()}`));}});}});}return {kind:"submenu",id:n,label:p,disabled:i,description:u,entries:s}}function Uo(e,t){let n=e.getState("zOrder");return {kind:"submenu",id:"zOrder",label:t(e.getDescriptor("zOrder").labelKey),disabled:!n.enabled,description:V(n),entries:Sn.map(o=>qe(e,t,"zOrder",{value:o},`zOrder-${o}`))}}var Rn=new Set(["fontFamily","fontSize","alignment","insertSlide","tool","shapeStrokeWidth","shapeAdjustment","zoom","proposalSelect"]);function Vo(e,t,n,o,r={}){{if(Rn.has(n))return jo(e,t,n,r);if(n==="textColor"||n==="shapeFill"||n==="shapeStrokeColor")return Zo(e,t,n,r);if(n==="zOrder")return Uo(e,t)}return qe(e,t,n,o,n)}function Xo(e,t,n){let o=C(),{t:r}=b(),i=useContext(T)?.prompt;U(e,()=>[Vo(o,r,t,n,{prompt:i})]);}function j(e$1){let{id:t,children:n,label:o,className:r,style:i}=e$1,u=e$1.args,a=d(t)?null:t,p=E(t,u??(a?e(a):null)),{t:s}=b();if(!a&&p.descriptor===null)return null;let x=a?ht(a,u):void 0,c=o??(a?Cn(a,u,s,p.label):p.label);return jsx(Z,{active:p.state.active,disabled:!p.state.enabled,description:V(p.state),title:c,shortcut:(a?wn(a,u):p.shortcut)??void 0,className:r,style:!x&&!n?{padding:"0 8px",...i}:i,testId:a?$o(a,u):void 0,onClick:()=>{p.execute();},children:n??(x?jsx(R,{name:x}):c)})}function xt({id:e,children:t,className:n,style:o}){let r=useRef(null);return Xo(r,e),jsx("span",{ref:r,className:n,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",...o},children:t})}function qo(){let e=C(),t=D("fontFamily"),{t:n}=b();return jsx(aa,{title:n("toolbar.fontFamily"),disabled:!t.enabled,description:V(t),menuWidth:210,testId:"pptx-font-family",style:{width:120,justifyContent:"space-between"},trigger:jsxs(Fragment,{children:[jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:t.value??n("toolbar.mixed")}),jsx(R,{name:"chevronDown",size:18})]}),children:o=>(t.options??[]).map(r=>jsx(ca,{label:r.label,radio:true,selected:t.value===r.args.family,onClick:()=>de(e,"fontFamily",r.args),close:o},r.args.family))})}function bt(e){return Number.parseFloat(e.replace("%","").trim())}function Yo(){let e=C(),t=D("fontSize"),{t:n$1}=b();return jsx(Ue,{value:typeof t.value=="number"?String(t.value):"",options:(t.options??[]).map(o=>({value:String(o.args.points),label:o.label})),label:n$1("toolbar.fontSize"),disabled:!t.enabled,description:V(t),onCommit:o$1=>{let r=bt(o$1);Number.isFinite(r)&&r>=n&&r<=o&&de(e,"fontSize",{points:r});},width:50,inputStyle:{textAlign:"center"},testId:"pptx-font-size"})}function Jo(){let e=C(),t=D("zoom"),{t:n}=b(),o=n("toolbar.fit"),r=t.value??"fit",i=r==="fit"?o:`${Math.round(r*100)}%`;return jsx(Ue,{value:i,options:(t.options??[]).map(u=>({value:u.label,label:u.label})),label:n("toolbar.zoomValue",{value:i}),disabled:!t.enabled,description:V(t),onCommit:u=>{if(u===o){de(e,"zoom",{scale:"fit"});return}let a=bt(u)/100;Number.isFinite(a)&&a>=p&&a<=q&&de(e,"zoom",{scale:a});},width:76,testId:"pptx-zoom"})}function Qo(){let e=C(),t=D("alignment"),{t:n}=b();return jsx(Fragment,{children:(t.options??[]).map(o=>jsx(er,{store:e,value:o.args.value,t:n},o.args.value))})}function er({store:e,value:t,t:n}){let o=D("alignment",{value:t}),r=Xe[t];return jsx(Y,{title:n(r.labelKey),active:o.active,disabled:!o.enabled,description:V(o),onClick:()=>{e.execute("alignment",{value:t});},testId:`pptx-align-${r.testId}`,children:jsx(R,{name:r.icon})})}function tr(){let e=C(),t=D("insertSlide"),n=E("insertSlide",{}),{t:o}=b(),r=t.options??[];return jsxs(Fragment,{children:[jsx(Y,{title:o("toolbar.newSlide"),disabled:!n.state.enabled,description:V(n.state),onClick:()=>{n.execute();},style:{borderRadius:"6px 0 0 6px"},testId:"pptx-new-slide",children:jsx(R,{name:"newSlide"})}),jsx(aa,{title:o("toolbar.newSlideWithLayout"),disabled:!t.enabled||r.length===0,description:V(t),menuWidth:230,testId:"pptx-new-slide-layout",style:{minWidth:20,width:20,padding:0,borderRadius:"0 6px 6px 0"},trigger:jsx(R,{name:"chevronDown",size:18}),children:i=>r.map((u,a)=>jsx(ca,{label:u.label,radio:true,selected:(u.args.layoutPartPath??null)===(t.value??null),onClick:()=>{e.execute("insertSlide",u.args);},close:i},u.args.layoutPartPath??`default-${a}`))})]})}function Pt(){let e=C(),t=D("tool"),n=D("tool",{value:"shape:rect"}),{t:o}=b(),r=useRef(null),i=useId();U(r,()=>[{kind:"submenu",id:i,label:o("toolbar.shapeTool"),disabled:!n.enabled,description:V(n),entries:k.map(a=>qe(e,o,"tool",{value:`shape:${a.geometry}`},`${i}-${a.geometry}`))}]);let u=t.value??"select";return jsx("span",{ref:r,style:{display:"inline-flex",flex:"0 0 auto"},children:jsx(aa,{title:o("toolbar.shapeTool"),active:u.startsWith("shape:"),disabled:!n.enabled,description:V(n),menuWidth:264,testId:"pptx-tool-shape",style:{minWidth:46,padding:"0 4px"},trigger:jsxs(Fragment,{children:[jsx(R,{name:"shape"}),jsx(R,{name:"chevronDown",size:18})]}),children:a=>jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 44px)",gap:4,padding:2},children:k.map(p=>{let s=`shape:${p.geometry}`;return jsx("button",{type:"button",role:"menuitemradio",tabIndex:-1,"aria-checked":u===s,"data-testid":`pptx-shape-${p.geometry}`,"aria-label":o(p.labelKey),title:o(p.labelKey),onClick:()=>{a(),de(e,"tool",{value:s});},style:{appearance:"none",display:"grid",placeItems:"center",width:44,height:38,padding:5,border:`1px solid ${H.line}`,borderRadius:6,background:u===s?H.selected:H.surface,color:H.ink,cursor:"pointer"},children:jsx(pr,{geometry:p.geometry})},p.geometry)})})})})}function nr(){let e=C(),t=D("shapeStrokeWidth"),{t:n}=b();return jsx(aa,{title:n("toolbar.borderWidth"),disabled:!t.enabled,description:V(t),menuWidth:170,testId:"pptx-shape-border-width",trigger:jsx(R,{name:"borderWidth"}),children:o=>(t.options??[]).map(r=>jsx(ca,{label:r.label,radio:true,selected:t.value===r.args.points,icon:r.args.points===null?void 0:jsx("span",{"aria-hidden":"true",style:{width:18,borderTop:`${Math.min(r.args.points,5)}px solid currentColor`}}),onClick:()=>{e.execute("shapeStrokeWidth",r.args);},close:o},String(r.args.points)))})}function or(){let e=C(),t=D("shapeAdjustment"),{t:n}=b(),o=t.value;if(!o)return null;let r=t.options??[],i=r.length>0?r[r.length-1].args.value:1,u=i<1;return jsx(Ue,{value:`${Math.round(o.value*100)}%`,options:r.map(a=>({value:String(Math.round(a.args.value*100)),label:a.label})),label:n(u?"toolbar.cornerRadius":"toolbar.shapeAdjustment"),disabled:!t.enabled,description:V(t),onCommit:a=>{let p=bt(a);Number.isFinite(p)&&de(e,"shapeAdjustment",{name:o.name,value:Math.max(0,Math.min(i*100,p))/100});},width:68,inputStyle:{textAlign:"center"},testId:u?"pptx-shape-corner-radius":"pptx-shape-adjustment"})}function rr({className:e}){let t=C(),n=D("proposalSelect"),{t:o}=b(),r=!n.enabled;return jsx("select",{className:e,"aria-label":o("proposals.canvasTitle"),"aria-disabled":r||void 0,title:V(n),value:n.value??"",onChange:i=>{r||t.execute("proposalSelect",{proposalId:i.target.value});},style:{maxWidth:220,font:"400 13px ui-sans-serif, system-ui, sans-serif"},children:(n.options??[]).map(i=>jsx("option",{value:i.args.proposalId,children:i.label},i.args.proposalId))})}function ir({id:e,className:t}){let n=null;switch(e){case "fontFamily":n=jsx(qo,{});break;case "fontSize":n=jsx(Yo,{});break;case "alignment":n=jsx(Qo,{});break;case "insertSlide":n=jsx(tr,{});break;case "tool":n=jsxs(Fragment,{children:[jsx(yn,{value:"select"}),jsx(yn,{value:"textBox"}),jsx(Pt,{})]});break;case "shapeStrokeWidth":n=jsx(nr,{});break;case "shapeAdjustment":n=jsx(or,{});break;case "zoom":n=jsx(Jo,{});break;case "proposalSelect":n=jsx(rr,{});break}return e==="tool"?jsx("span",{className:t,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto"},children:n}):jsx(xt,{id:e,className:t,children:n})}function yn({value:e}){return jsx(j,{id:"tool",args:{value:e}})}var ar={textColor:"pptx-text-color",shapeFill:"pptx-shape-fill",shapeStrokeColor:"pptx-shape-border-color"},lr={textColor:"#000000",shapeFill:"#d9eaf7",shapeStrokeColor:"#202124"};function sr({id:e}){let t=C(),n=D(e),{t:o}=b(),r=Tn[e],i=typeof n.value=="string"?n.value:null,u=!n.enabled;return jsx(xt,{id:e,children:jsx(hn,{value:i??lr[e],label:o(t.getDescriptor(e).labelKey),clearLabel:r?o(r):void 0,icon:ht(e,void 0),none:!!r&&!i,disabled:u,description:V(n),onChange:a=>de(t,e,Ve(a)),onClear:r?()=>{t.execute(e,Ve(null));}:void 0,testId:ar[e]})})}function ur(){let e=C(),t=D("zOrder"),{t:n}=b();return jsx(xt,{id:"zOrder",children:jsx(aa,{title:n("toolbar.arrange"),disabled:!t.enabled,description:V(t),menuWidth:190,testId:"pptx-shape-arrange",trigger:jsx(R,{name:"bringToFront"}),children:o=>Sn.map(r=>jsx(dr,{store:e,value:r,close:o,t:n},r))})})}function dr({store:e,value:t,close:n,t:o}){let r=D("zOrder",{value:t}),i=gt[t];return jsx(ca,{label:o(i.labelKey),icon:jsx(R,{name:i.icon,size:16}),disabled:!r.enabled,description:V(r),onClick:()=>{e.execute("zOrder",{value:t});},close:n})}function cr(){return jsxs(Fragment,{children:[jsx(j,{id:"fontSizeStep",args:{direction:"decrease"}}),jsx(j,{id:"fontSizeStep",args:{direction:"increase"}})]})}function ee(e){let{id:t,className:n}=e;if(d(t))return jsx(j,{id:t,className:n});let o=e.args;if(o===void 0){if(Rn.has(t))return jsx(ir,{id:t,className:n});switch(t){case "textColor":case "shapeFill":case "shapeStrokeColor":return jsx(sr,{id:t});case "zOrder":return jsx(ur,{});case "fontSizeStep":return jsx(cr,{});}}return jsx(j,{id:t,args:o,className:n})}function pr({geometry:e}){let t={rect:"M3 5h18v14H3Z",roundRect:"M7 5h10a4 4 0 0 1 4 4v6a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a4 4 0 0 1 4-4Z",ellipse:"M3 12a9 7 0 1 0 18 0 9 7 0 1 0-18 0",triangle:"m12 4 9 16H3Z",rtTriangle:"M4 4v16h16Z",diamond:"m12 3 9 9-9 9-9-9Z",parallelogram:"M7 5h14l-4 14H3Z",trapezoid:"M7 5h10l4 14H3Z",pentagon:"m12 3 9 7-4 11H7L3 10Z",hexagon:"m7 4 10 0 5 8-5 8H7l-5-8Z",octagon:"m7 3 10 0 4 4v10l-4 4H7l-4-4V7Z",star5:"m12 2.5 2.8 6 6.5.6-5 4.3 1.6 6.4-5.7-3.4-5.7 3.4 1.6-6.4-5-4.3 6.5-.6Z",rightArrow:"M3 8h11V4l7 8-7 8v-4H3Z",leftArrow:"m21 8H10V4l-7 8 7 8v-4h11Z",upArrow:"M8 21V10H4l8-7 8 7h-4v11Z",downArrow:"M8 3v11H4l8 7 8-7h-4V3Z",chevron:"M4 4h9l7 8-7 8H4l7-8Z"}[e];return jsx("svg",{width:"30",height:"24",viewBox:"0 0 24 24",fill:"rgba(60, 64, 67, 0.08)",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round","aria-hidden":"true",children:jsx("path",{d:t})})}var gr=Object.freeze([]);function In(){let e=C(),t=y(e),n=useCallback(()=>t?.pluginToolbar()??gr,[t]),o=useSyncExternalStore(e.subscribe,n,n),{t:r}=b();return o.length===0?null:jsx(_,{label:r("plugins.toolbarGroup"),children:o.map(i=>jsx(j,{id:i},i))})}var Pr={surface:H.surface,text:H.ink,mutedText:H.inkMuted,border:H.line,hover:H.hover,shadow:"rgba(0, 0, 0, 0.12)",focus:H.accent},Mn='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]',pe=8,yr=320;function vr(e,t,n){let o=t.offsetWidth,r=t.scrollHeight,i=window.innerWidth,u=window.innerHeight,a=n?e.right:e.right-o;n&&a+o>i-pe&&(a=e.left-o),a=Math.max(pe,Math.min(a,i-o-pe));let p=u-pe-(n?e.top:e.bottom+4),s=(n?e.bottom:e.top-4)-pe;if(r<=p||p>=s)return {top:n?e.top:e.bottom+4,left:a,maxHeight:Math.max(p,80)};let x=Math.max(s,80),c=n?e.bottom:e.top-4;return {top:Math.max(pe,c-Math.min(r,x)),left:a,maxHeight:x}}function Sr(){return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:jsx("path",{d:"M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z",fill:"currentColor"})})}function Cr(){return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:jsx("path",{d:"M10 6 8.6 7.4 13.2 12l-4.6 4.6L10 18l6-6z",fill:"currentColor"})})}function On({id:e,label:t,entries:n,anchor:o,beside:r,colors:i,initialFocus:u,onClose:a,onSelect:p,registerMenu:s}){let x=useRef(null),c=useId(),[m,h]=useState(null),g=useRef(false),[R,w]=useState(null),[L,H]=useState(null),[N,M]=useState(null),D=useRef(new Map),A=S({container:x,itemSelector:Mn,scope:'[role="menu"]',labelOf:C=>C.dataset.label??C.textContent??""});useLayoutEffect(()=>x.current?s(x.current):void 0,[s]),useLayoutEffect(()=>{let C=o(),l=x.current;if(!C||!l)return;let f=vr(C,l,r);h(b=>b&&b.top===f.top&&b.left===f.left&&b.maxHeight===f.maxHeight?b:f);},[o,r,n]),useLayoutEffect(()=>{!m||g.current||(g.current=true,u==="first"?A.focusFirst():u==="last"?A.focusLast():u==="menu"&&x.current?.focus({preventScroll:true}));},[u,m,A]);let $=(C,l)=>M({id:C,focus:l}),v=C=>{if(C.target instanceof Node&&!x.current?.contains(C.target))return;let l=C.target instanceof HTMLElement?C.target.closest(Mn):null,f=l&&l.closest('[role="menu"]')===x.current?l:null;if(C.key==="Escape"){C.preventDefault(),C.stopPropagation(),a(r?"parent":"escape");return}if(C.key==="Tab"){setTimeout(()=>a("tab"),0);return}if(r&&C.key==="ArrowLeft"){C.preventDefault(),C.stopPropagation(),a("parent");return}if(f?.dataset.submenu&&(C.key==="ArrowRight"||C.key==="Enter"||C.key===" ")){C.preventDefault(),C.stopPropagation(),f.getAttribute("aria-disabled")!=="true"&&$(f.dataset.submenu,"first");return}if(f&&(C.key==="Enter"||C.key===" ")){C.preventDefault(),C.stopPropagation();let b=Ln(n,f.dataset.entry??"");b&&!b.disabled&&p(b,"keyboard");return}A.onKeyDown(C)&&C.stopPropagation();},z=C=>C.map(l=>{if(l.kind==="separator")return jsx("div",{role:"separator",style:{height:1,margin:"4px 0",background:i.border}},l.id);if(l.kind==="group"){let W=`${c}-${l.id}-label`;return jsxs("div",{role:"group","aria-labelledby":l.label?W:void 0,children:[l.label&&jsx("div",{id:W,style:{padding:"6px 12px 2px",fontSize:11,fontWeight:500,color:i.mutedText,overflowWrap:"anywhere"},children:l.label}),z(l.entries)]},l.id)}let f=l.description?`${c}-${l.id}-description`:void 0,b=l.kind==="submenu",E=b?"menuitem":l.radio?"menuitemradio":l.checked!==void 0?"menuitemcheckbox":"menuitem",_=b?void 0:l.checked,q=b&&N?.id===l.id;return jsxs("div",{style:{position:"relative"},children:[jsxs("div",{role:E,tabIndex:-1,"data-entry":l.id,"data-label":l.label,"data-submenu":b?l.id:void 0,"aria-haspopup":b?"menu":void 0,"aria-expanded":b?q:void 0,"aria-checked":E==="menuitemcheckbox"||E==="menuitemradio"?_==="mixed"?"mixed":_===true:void 0,"aria-disabled":l.disabled?true:void 0,"aria-describedby":f,title:l.description,ref:W=>{b&&W&&D.current.set(l.id,W);},onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>{b&&!l.disabled?$(l.id,"none"):N&&M(null),H(l.id);},onMouseLeave:()=>H(null),onFocus:()=>w(l.id),onBlur:()=>w(W=>W===l.id?null:W),onClick:()=>{l.disabled||(b?$(l.id,"none"):p(l,"pointer"));},style:{display:"flex",alignItems:"center",gap:8,minHeight:32,margin:"0 4px",padding:"4px 12px 4px 8px",borderRadius:6,fontSize:13,cursor:l.disabled?"default":"pointer",color:l.disabled?i.mutedText:i.text,opacity:l.disabled?.6:1,background:!l.disabled&&(L===l.id||R===l.id)?i.hover:"transparent",...R===l.id?{outline:`2px solid ${i.focus}`,outlineOffset:-2}:{outline:"none"}},children:[jsx("span",{style:{width:16,flexShrink:0,display:"inline-flex",justifyContent:"center"},children:_===true?jsx(Sr,{}):_==="mixed"?"\u2013":null}),l.icon&&jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",flexShrink:0},children:l.icon}),jsx("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:l.label}),!b&&l.shortcut&&jsx("span",{"aria-hidden":"true",style:{marginLeft:16,flexShrink:0,whiteSpace:"nowrap",fontSize:12,color:i.mutedText},children:l.shortcut}),b&&jsx("span",{style:{display:"inline-flex",flexShrink:0},children:jsx(Cr,{})})]}),f&&jsx("span",{id:f,hidden:true,children:l.description}),b&&q&&jsx(On,{label:l.label,entries:l.entries,anchor:()=>D.current.get(l.id)?.getBoundingClientRect()??null,beside:true,colors:i,initialFocus:N?.focus??"none",onClose:W=>{M(null),W==="parent"?D.current.get(l.id)?.focus():a(W);},onSelect:p,registerMenu:s})]},l.id)});return jsx("div",{ref:x,id:e,role:"menu","aria-label":t,"aria-orientation":"vertical",tabIndex:-1,onKeyDown:v,style:{position:"fixed",top:m?.top??0,left:m?.left??0,maxHeight:m?.maxHeight,visibility:m?"visible":"hidden",overflowY:"auto",overflowX:"hidden",minWidth:Math.min(200,window.innerWidth-2*pe),maxWidth:Math.min(yr,window.innerWidth-2*pe),padding:"4px 0",background:i.surface,color:i.text,border:`1px solid ${i.border}`,borderRadius:8,boxShadow:`0 4px 16px ${i.shadow}`,zIndex:1e4,boxSizing:"border-box",outline:"none"},children:z(n)})}function Ln(e,t){for(let n of e){if(n.kind==="item"&&n.id===t)return n;if(n.kind==="group"){let o=Ln(n.entries,t);if(o)return o}}return null}var Dn=forwardRef(function({label:t,trigger:n,entries:o,colors:r,triggerClassName:i,triggerStyle:u,testId:a,onItemSelected:p},s){let x=useRef(null),c=useRef(new Set),m=useId(),[h,g]=useState(null),[R,w]=useState(false),L=Q(),H={...Pr,...r},N=useCallback(()=>g(null),[]);useImperativeHandle(s,()=>({focus:()=>x.current?.focus({preventScroll:true}),close:N}),[N]);let M=useCallback(A=>(c.current.add(A),()=>{c.current.delete(A);}),[]);useEffect(()=>{if(!h)return;let A=v=>{let z=v.target;if(!x.current?.contains(z)){for(let C of c.current)if(C.contains(z))return;N();}},$=()=>{let v=document.activeElement,z=[...c.current].some(C=>C.contains(v));N(),z&&x.current?.focus({preventScroll:true});};return document.addEventListener("mousedown",A,true),window.addEventListener("resize",$),()=>{document.removeEventListener("mousedown",A,true),window.removeEventListener("resize",$);}},[h,N]);let D=useCallback(()=>x.current?.getBoundingClientRect()??null,[]);return jsxs("span",{style:{display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:x,type:"button",className:i,style:typeof u=="function"?u({hovered:R,open:h!==null,focusRing:L.focusRing}):u,...L.focusProps,onMouseEnter:()=>w(true),onMouseLeave:()=>w(false),"data-testid":a,"aria-label":t,title:t,"aria-haspopup":"menu","aria-expanded":h!==null,"aria-controls":h?m:void 0,onMouseDown:A=>A.preventDefault(),onClick:()=>g(A=>A?null:"menu"),onKeyDown:A=>{A.key==="Enter"||A.key===" "||A.key==="ArrowDown"?(A.preventDefault(),g("first")):A.key==="ArrowUp"&&(A.preventDefault(),g("last"));},children:n}),h&&jsx(On,{id:m,label:t,entries:o,anchor:D,beside:false,colors:H,initialFocus:h,onClose:A=>{N(),A!=="tab"&&x.current?.focus({preventScroll:true});},onSelect:(A,$)=>{N(),$==="keyboard"&&x.current?.focus({preventScroll:true}),A.onSelect(),p?.($);},registerMenu:M})]})});var Tr={position:"absolute",visibility:"hidden",pointerEvents:"none",insetInlineStart:"0"},Fn={overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"},Rr=new WeakMap,Hn=new WeakMap,Nn=["a[href]","button",'input:not([type="hidden"])',"select","textarea","summary","[tabindex]",'[contenteditable]:not([contenteditable="false"])'].join(", ");function _n(e,t){if(t.length===0)return false;let n=Array.from(e.querySelectorAll(Nn));return e.matches(Nn)&&n.push(e),n.every(o=>t.some(r=>r.contains(o)))}function Bn(e){let t=getComputedStyle(e),n=(parseFloat(t.marginLeft)||0)+(parseFloat(t.marginRight)||0);return e.getBoundingClientRect().width+n}function kr(e){let t=getComputedStyle(e),n=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0);return e.getBoundingClientRect().width-n}function Ct(e,t,n,o){let r=n.get(e);if(o===!!r)return false;let i=Object.keys(t);if(o){let u={};for(let a of i)u[a]=e.style[a],e.style[a]=t[a]??"";n.set(e,u);}else {for(let u of i)e.style[u]=r?.[u]??"";n.delete(e);}return true}function Je(e,t){Ct(e,Tr,Rr,t)&&(t?e.setAttribute("aria-hidden","true"):e.removeAttribute("aria-hidden"),e.inert=t);}function Kn(e,t){let n=e.getBoundingClientRect(),o=t.getBoundingClientRect();o.left<n.left?e.scrollLeft-=n.left-o.left:o.right>n.right&&(e.scrollLeft+=Math.min(o.right-n.right,o.left-n.left));}function Ir(e,t){return e.length===t.length&&e.every((n,o)=>n===t[o])}function Wn(e){let t=useRef(e);t.current=e;let[n,o]=useState([]),r=useRef(n);r.current=n;let i=useRef(e.moreWidth??32),u=useCallback(()=>{let{items:a,more:p,canHide:s,onFocusHidden:x}=t.current,c=a.current,m=c?.parentElement;if(!c||!m)return;let h=c.scrollLeft,g=p.current;g&&(i.current=Bn(g));let R=Array.from(c.children).filter(v=>v instanceof HTMLElement);for(let v of R)Je(v,false);let w=parseFloat(getComputedStyle(c).columnGap)||0,L=kr(m),H=g?.style.position;g&&(g.style.position="absolute");let N=R.map(Bn);g&&(g.style.position=H??"");let M=N.reduce((v,z)=>v+z,0)+w*Math.max(0,R.length-1),D=[],A=false;if(M>L+.5){let v=L-i.current,z=R.map(f=>s(f)),C=R.reduce((f,b,E)=>z[E]?f:f+N[E]+w,0),l=false;R.forEach((f,b)=>{if(z[b]){if(!l&&C+N[b]<=v){C+=N[b]+w;return}l=true,D.push(f);}}),A=C-w>(D.length>0?v:L)+.5;}Ct(c,Fn,Hn,A);for(let v of R)Je(v,D.includes(v));for(let v of r.current)R.includes(v)||Je(v,false);c.scrollLeft=h;let $=document.activeElement;$&&D.some(v=>v.contains($))?x?.():A&&$&&c.contains($)&&Kn(c,$),Ir(D,r.current)||(r.current=D,o(D));},[]);return useLayoutEffect(()=>{u();}),useLayoutEffect(()=>{let a=t.current.items.current;if(!a)return;let p=new Set,s=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>u()),x=()=>{if(s)for(let h of [a,a.parentElement,...Array.from(a.children)])h&&!p.has(h)&&(p.add(h),s.observe(h));};x();let c=typeof MutationObserver>"u"?null:new MutationObserver(()=>{x(),u();});c?.observe(a,{childList:true});let m=h=>{h.target instanceof Element&&Kn(a,h.target);};return a.addEventListener("focusin",m),window.addEventListener("resize",u),document.fonts?.ready.then(u,()=>{}),()=>{s?.disconnect(),c?.disconnect(),a.removeEventListener("focusin",m),window.removeEventListener("resize",u),Ct(a,Fn,Hn,false);for(let h of Array.from(a.children))h instanceof HTMLElement&&Je(h,false);}},[u]),{hidden:n,remeasure:u}}var Or="input, button:not([disabled])",jn={height:30,padding:"0 12px"};function Un({prompt:e,onClose:t}){let{t:n}=b(),o=Q(),r=Q(),[i,u]=useState(e.initialValue??""),a=useRef(null),p=useRef(null),s=useId(),x=useId(),c=i.trim(),m=e.valid(c);return useLayoutEffect(()=>{p.current?.focus(),p.current?.select();},[]),jsx("div",{style:{position:"fixed",inset:0,zIndex:10001,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(32, 33, 36, 0.32)"},onMouseDown:g=>{g.target===g.currentTarget&&t();},children:jsxs("form",{ref:a,role:"dialog","aria-modal":"true","aria-labelledby":s,onKeyDown:g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),t();return}if(g.key!=="Tab")return;let R=Array.from(a.current?.querySelectorAll(Or)??[]);if(R.length===0)return;let w=R.indexOf(document.activeElement),L=g.shiftKey?w<=0?R.length-1:w-1:w===R.length-1?0:w+1;g.preventDefault(),R[L].focus();},onSubmit:g=>{g.preventDefault(),m&&(t(),e.submit(c));},style:{width:"min(320px, 100%)",boxSizing:"border-box",padding:16,borderRadius:8,background:H.surface,color:H.ink,boxShadow:"0 8px 24px rgba(0, 0, 0, 0.18)",font:"400 13px ui-sans-serif, system-ui, sans-serif"},children:[jsx("h2",{id:s,style:{margin:"0 0 12px",fontSize:15,fontWeight:600},children:e.title}),jsx("label",{htmlFor:x,style:{display:"block",marginBottom:4,fontSize:12},children:e.label}),jsx("input",{id:x,ref:p,value:i,placeholder:e.placeholder,"aria-invalid":c!==""&&!m,onChange:g=>u(g.target.value),style:{width:"100%",boxSizing:"border-box",padding:"6px 8px",border:`1px solid ${H.line}`,borderRadius:6,background:H.surface,color:H.ink,outlineColor:H.accent}}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[jsx("button",{type:"button",onClick:t,...o.focusProps,style:{...L({focusRing:o.focusRing}),...jn,border:`1px solid ${H.line}`,color:H.ink},children:n("commands.cancel")}),jsx("button",{type:"submit",disabled:!m,...r.focusProps,style:{...M({disabled:!m,focusRing:r.focusRing}),...jn},children:n("commands.apply")})]})]})})}function zr(e){return e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT"||e.tagName==="OPTION")}function Fr(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Tt({children:e,className:t,style:n,testId:o}){let{t:r}=b(),i=C(),u=useRef(null),a=useRef(null),p=useRef(null),s=useRef(new Set),[x,c]=useReducer(v=>v+1,0),[,m]=useReducer(v=>v+1,0),[h,g]=useState(false),[R$1,w]=useState(null),L$1=useRef(false),H=useMemo(()=>({register(v){return s.current.add(v),c(),()=>{s.current.delete(v),c();}},overflowing:()=>L$1.current,changed(){L$1.current&&m();},prompt:w,anchor:()=>a.current?.querySelector("button")??null}),[]),N$1=useCallback(v=>{let z=[];for(let C of s.current){let l=C.element();l&&v.contains(l)&&z.push({element:l,source:C});}return z.sort((C,l)=>Fr(C.element,l.element))},[]),{hidden:M,remeasure:D}=Wn({items:u,more:a,canHide:v=>v.getAttribute("role")==="separator"||_n(v,N$1(v).map(({element:z})=>z)),onFocusHidden:()=>g(true)});useLayoutEffect(()=>{D();},[x,D]),useLayoutEffect(()=>{!h||M.length===0||(g(false),p.current?.focus());},[h,M]),L$1.current=M.length>0,useEffect(()=>{if(M.length!==0)return i.subscribe(m)},[M.length,i]);let A=[];M.forEach((v,z)=>{let C=N$1(v).flatMap(({source:f})=>f.entries());if(C.length===0)return;let l=v.getAttribute("role")==="group"?v.getAttribute("aria-label"):null;A.push({kind:"group",id:`unit-${z}`,label:l??void 0,entries:C});});let $=A.flatMap((v,z)=>z===0?[v]:[{kind:"separator",id:`separator-${z}`},v]);return jsxs("div",{className:t,role:"toolbar","aria-label":r("toolbar.label"),"data-testid":o,onMouseDown:v=>{zr(v.target)||v.preventDefault();},style:{display:"flex",alignItems:"center",minWidth:0,...N,margin:"0 8px 4px",boxSizing:"border-box",...n},children:[jsx(T.Provider,{value:H,children:jsx("div",{ref:u,"data-toolbar-items":"",style:{position:"relative",display:"flex",alignItems:"center",flex:"1 1 auto",minWidth:0,overflow:"hidden"},children:e})}),M.length>0&&jsx("span",{ref:a,style:{display:"inline-flex",flex:"0 0 auto",marginLeft:4},children:jsx(Dn,{ref:p,label:r("toolbar.more"),trigger:jsx(R,{name:"more"}),entries:$,triggerStyle:L,testId:"pptx-toolbar-more",onItemSelected:v=>{v==="pointer"&&y(i)?.focusEditor();}})}),R$1&&jsx(Un,{prompt:R$1,onClose:()=>{w(null),p.current?.focus();}})]})}function pl({label:e,onSelect:t,disabled:n,description:o,checked:r,children:i}){let u=useRef(null),a=useId();return U(u,()=>[{kind:"item",id:a,label:e,checked:r,disabled:n,description:n?o:void 0,onSelect:t}]),jsx("span",{ref:u,style:{display:"inline-flex",alignItems:"center",flex:"0 0 auto"},children:i})}function Yn({children:e}){let{t}=b(),n=V$1(),o=useRef(null),r=useRef(null),i=G(),u=useCallback(w=>{r.current=w,i(w);},[i]),a=useId(),p=t("commands.moreControls"),[s,x]=useState(null),[c,m]=useState(null),[h,g]=useState({});U(o,()=>[{kind:"item",id:a,label:p,onSelect:()=>x({anchor:n?.anchor()??null,width:o.current?.getBoundingClientRect().width??0})}]);let R=useCallback(w=>{let L=s?.anchor;x(null),w&&L?.focus({preventScroll:true});},[s]);return useLayoutEffect(()=>{let w=r.current;if(!s||!w){m(null);return}let L=s.anchor?.getBoundingClientRect(),H=w.offsetWidth,N=Math.max(8,Math.min((L?.right??8)-H,window.innerWidth-H-8));m({top:(L?.bottom??8)+4,left:N}),g(K(s.anchor)),w.querySelector("button, input, select, textarea, a[href], [tabindex]")?.focus();},[s]),useEffect(()=>{if(!s)return;let w=H=>{r.current?.contains(H.target)||R(false);},L=()=>R(false);return document.addEventListener("mousedown",w),window.addEventListener("resize",L),()=>{document.removeEventListener("mousedown",w),window.removeEventListener("resize",L);}},[s,R]),jsxs(T.Provider,{value:null,children:[jsx("span",{ref:o,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",width:s?s.width:void 0},children:s?null:e}),s&&createPortal(jsx("div",{ref:u,role:"dialog","aria-label":p,tabIndex:-1,onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),R(true));},onBlur:w=>{let L=w.relatedTarget;L&&!r.current?.contains(L)&&R(false);},style:{position:"fixed",top:c?.top??0,left:c?.left??0,visibility:c?"visible":"hidden",zIndex:1e4,display:"flex",flexWrap:"wrap",alignItems:"center",gap:2,maxWidth:"calc(100vw - 16px)",...O,...h},children:e}),document.body)]})}var $r={bold:"onFormat",italic:"onFormat",underline:"onFormat",fontFamily:"onFormat",fontSize:"onFormat",fontSizeStep:"onFormat",textColor:"onFormat",alignment:"onFormat",shapeFill:"onShapeFormat",shapeStrokeColor:"onShapeFormat",shapeStrokeWidth:"onShapeFormat",shapeAdjustment:"onShapeFormat",zOrder:"onShapeFormat",insertSlide:"onInsertSlide",insertImage:"onInsertImage",tool:"onToolChange",save:"onSave",exportPng:"onExportPng",undo:"onUndo",redo:"onRedo",zoom:"onZoomChange"},Rt={ok:true,status:"requested"};function Gr(e,t){let n=e.currentFormatting??{},o=e.currentShapeFormatting??{};return {status:"ready",readOnly:false,reviewing:false,pendingInput:false,canUndo:e.canUndo??false,canRedo:e.canRedo??false,slide:{id:"",layoutPartPath:e.currentLayoutPartPath??null},layouts:(e.slideLayouts??[]).map((r,i)=>({args:{layoutPartPath:r.partPath},label:r.label??t("toolbar.layoutOption",{number:i+1})})),text:e.textSelectionActive?{kind:"range",bold:n.bold??false,italic:n.italic??false,underline:n.underline??false,fontFamily:n.fontFamily??null,fontSize:n.fontSize??null,color:n.textColor??null,alignment:n.align??null}:null,shape:e.shapeSelectionActive||e.shapeArrangeActive?{formattable:!!e.shapeSelectionActive,geometry:o.geometry??null,fill:o.fillColor??null,stroke:o.strokeColor??null,strokeWidth:o.strokeWidthPt??null,adjustments:o.adjustments??{},order:null}:null,tool:e.activeTool??"select",zoom:e.zoom??"fit",fontFamilies:e.fontFamilies??r,fontSizes:e.fontSizes??s,proposals:null,hostDisabled:r=>{let i=$r[r];return !!e.disabled||!i||!e[i]},translate:t}}function jr(e,t$1,n){let o=t$1;switch(e){case "bold":case "italic":case "underline":return e;case "fontFamily":return {type:"fontFamily",value:o.family};case "fontSize":return {type:"fontSize",value:o.points};case "fontSizeStep":{let r=n.text&&n.text!=="unsupported"?n.text.fontSize:null;return {type:"fontSize",value:u(r??t,n.fontSizes,o.direction==="increase"?1:-1)}}case "textColor":return {type:"textColor",value:o.color};case "alignment":return {type:"align",value:o.value};default:return null}}function Zr(e,t){let n=t;switch(e){case "shapeFill":return {type:"fillColor",value:n.color};case "shapeStrokeColor":return {type:"strokeColor",value:n.color};case "shapeStrokeWidth":return {type:"strokeWidth",value:n.points};case "shapeAdjustment":return {type:"adjust",name:n.name,value:n.value};case "zOrder":return {type:"zOrder",value:n.value};default:return null}}function Ur(e,t,n,o){let r=jr(t,n,o);if(r)return e.onFormat?.(r),Rt;let i=Zr(t,n);if(i)return e.onShapeFormat?.(i),Rt;let u=n;switch(t){case "insertSlide":e.onInsertSlide?.(u.layoutPartPath);break;case "insertImage":e.onInsertImage?.();break;case "tool":e.onToolChange?.(u.value);break;case "save":e.onSave?.();break;case "exportPng":e.onExportPng?.();break;case "undo":e.onUndo?.();break;case "redo":e.onRedo?.();break;case "zoom":e.onZoomChange?.(u.scale);break}return Rt}function eo(e){let{t}=b(),n=useRef({props:e,t});n.current={props:e,t};let[o]=useState(()=>{let r=x(),i={environment:()=>Gr(n.current.props,n.current.t),ordered:()=>false,admit:u=>Promise.resolve().then(u),perform:(u,a,p)=>Ur(n.current.props,u,a,p),capture:()=>({generation:0}),resume:()=>null,chrome:()=>({i18n:void 0}),focusEditor:()=>{}};return r.attach(i),r});return useLayoutEffect(()=>{o.refresh();}),o.store}function kt(e){return e==="mixed"?void 0:e}function Qn(e){let t={};for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}function Vr(e){let t=s=>e.getState(s),n=(s,x)=>{e.execute(s,x);},o=t("fontFamily"),r=t("fontSize"),i=t("textColor"),u=t("alignment"),a=t("shapeAdjustment").value,p=t("insertSlide");return {currentFormatting:Qn({bold:kt(t("bold").active),italic:kt(t("italic").active),underline:kt(t("underline").active),fontFamily:o.value??void 0,fontSize:r.value??void 0,textColor:i.value??void 0,align:u.value??void 0}),textSelectionActive:t("bold").enabled,onFormat:s=>{typeof s=="string"?n(s,null):s.type==="fontFamily"?n("fontFamily",{family:s.value}):s.type==="fontSize"?n("fontSize",{points:s.value}):s.type==="textColor"?n("textColor",{color:s.value}):n("alignment",{value:s.value});},currentShapeFormatting:Qn({fillColor:t("shapeFill").value,strokeColor:t("shapeStrokeColor").value,strokeWidthPt:t("shapeStrokeWidth").value,adjustments:a?{[a.name]:a.value}:void 0}),shapeSelectionActive:t("shapeFill").enabled,shapeArrangeActive:t("zOrder").enabled,onShapeFormat:s=>{s.type==="fillColor"?n("shapeFill",{color:s.value}):s.type==="strokeColor"?n("shapeStrokeColor",{color:s.value}):s.type==="strokeWidth"?n("shapeStrokeWidth",{points:s.value}):s.type==="adjust"?n("shapeAdjustment",{name:s.name,value:s.value}):n("zOrder",{value:s.value});},onInsertSlide:s=>n("insertSlide",s===void 0?{}:{layoutPartPath:s}),onInsertImage:()=>n("insertImage",null),slideLayouts:(p.options??[]).map(s=>({partPath:s.args.layoutPartPath??null,label:s.label})),currentLayoutPartPath:p.value??null,onSave:()=>n("save",null),onExportPng:()=>n("exportPng",null),onUndo:()=>n("undo",null),onRedo:()=>n("redo",null),canUndo:t("undo").enabled,canRedo:t("redo").enabled,zoom:t("zoom").value??"fit",onZoomChange:s=>n("zoom",{scale:s}),activeTool:t("tool").value??"select",onToolChange:s=>n("tool",{value:s}),fontFamilies:(o.options??[]).map(s=>s.args.family),fontSizes:(r.options??[]).map(s=>s.args.points),disabled:!t("save").enabled}}function to(e){let[t,n]=useReducer(o=>o+1,0);return useEffect(()=>e.subscribe(n),[e]),useMemo(()=>Vr(e),[e,t])}var Xr=["currentFormatting","textSelectionActive","onFormat","currentShapeFormatting","shapeSelectionActive","shapeArrangeActive","onShapeFormat","onInsertSlide","onInsertImage","slideLayouts","currentLayoutPartPath","onSave","onExportPng","onUndo","onRedo","canUndo","canRedo","zoom","onZoomChange","activeTool","onToolChange","fontFamilies","fontSizes","disabled"];function It(e,t){let n=Xr.filter(o=>e[o]!==void 0);if(n.length>0)throw new Error(`${t} in command mode reads state from the editor's commands; remove ${n.join(", ")} or use mode="legacy".`)}function oo(){let{t:e}=b();return jsxs(Fragment,{children:[jsxs(_,{label:e("toolbar.groups.history"),children:[jsx(j,{id:"undo"}),jsx(j,{id:"redo"})]}),jsx($,{}),jsxs(_,{label:e("toolbar.groups.file"),children:[jsx(j,{id:"save"}),jsx(j,{id:"exportPng"})]}),jsx(_,{label:e("toolbar.groups.slides"),children:jsx(ee,{id:"insertSlide"})}),jsx($,{}),jsx(_,{label:e("toolbar.groups.zoom"),children:jsx(ee,{id:"zoom"})}),jsx($,{}),jsxs(_,{label:e("toolbar.groups.tools"),children:[jsx(j,{id:"tool",args:{value:"select"}}),jsx(j,{id:"tool",args:{value:"textBox"}}),jsx(j,{id:"insertImage"}),jsx(Pt,{})]}),jsx($,{}),jsxs(_,{label:e("toolbar.groups.font"),children:[jsx(ee,{id:"fontFamily"}),jsx(j,{id:"fontSizeStep",args:{direction:"decrease"}}),jsx(ee,{id:"fontSize"}),jsx(j,{id:"fontSizeStep",args:{direction:"increase"}})]}),jsx($,{}),jsxs(_,{label:e("toolbar.groups.text"),children:[jsx(j,{id:"bold"}),jsx(j,{id:"italic"}),jsx(j,{id:"underline"}),jsx(ee,{id:"textColor"})]}),jsx($,{}),jsx(_,{label:e("toolbar.groups.alignment"),children:jsx(ee,{id:"alignment"})}),jsx($,{}),jsxs(_,{label:e("toolbar.groups.shape"),children:[jsx(ee,{id:"shapeFill"}),jsx(ee,{id:"shapeStrokeColor"}),jsx(ee,{id:"shapeStrokeWidth"}),jsx(ee,{id:"shapeAdjustment"}),jsx(ee,{id:"zOrder"})]}),jsx(In,{})]})}function qr(e){let t={};for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}function Yr(e){let t=useContext(be),n=t?{...t,...qr(e)}:e,o=eo(n);return jsx(A.Provider,{value:o,children:jsxs(Tt,{className:n.className,style:n.style,testId:"pptx-formatting-toolbar",children:[jsx(oo,{}),n.children?jsx(Yn,{children:n.children}):null]})})}function Jr(e){return It(e,"Toolbar"),jsx(Tt,{className:e.className,style:e.style,testId:"pptx-formatting-toolbar",children:e.children??jsx(oo,{})})}function Mt(e){let t=useContext(ke);return (e.mode??t??"legacy")==="commands"?jsx(Jr,{...e,mode:"commands"}):jsx(Yr,{...e})}var ro={display:"flex",flexDirection:"column",flex:"0 0 auto"};function oi({i18n:e,children:t}){let n=y(C()),o=F(),r=useRef(null);return useLayoutEffect(()=>{let i=r.current;if(!(!i||!n))return n.registerChrome(i)},[n]),jsx("div",{ref:r,style:{display:"contents"},children:jsx(a,{i18n:e??o?.i18n,children:t})})}function ri(e){It(e,"EditorToolbar");let{children:t,className:n,style:o,i18n:r}=e,i=to(C()),u=useContext(fn),a=jsx(ke.Provider,{value:"commands",children:jsx(be.Provider,{value:i,children:jsx("div",{className:n,"data-testid":"pptx-editor-toolbar",style:{...ro,...o},children:t??jsx(Mt,{mode:"commands"})})})});return u?a:jsx(oi,{i18n:r,children:a})}function ii({children:e,className:t,style:n,...o}){return jsx(ke.Provider,{value:"legacy",children:jsx(be.Provider,{value:o,children:jsx("div",{className:t,"data-testid":"pptx-editor-toolbar",style:{...ro,...n},children:e})})})}function ai(e){return e.mode==="commands"?jsx(ri,{...e}):jsx(ii,{...e})}var li=ai;li.Toolbar=Mt;function jl(){let e=C(),t=D("slideshow"),{t:n}=b(),o=X(!t.enabled,t.enabled?void 0:t.disabledReason?.message),r=Q();return jsxs(Fragment,{children:[jsxs("button",{type:"button",onClick:()=>{t.enabled&&e.execute("slideshow",null);},...o.props,title:o.reason,"data-testid":"pptx-present",...r.focusProps,style:{...si,opacity:t.enabled?1:I,...J(r.focusRing)},children:[jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M6 4.5v15l13-7.5Z"})}),n("toolbar.present")]}),o.node]})}var si={display:"inline-flex",alignItems:"center",gap:6,flex:"0 0 auto",margin:"0 12px 0 4px",padding:"0 12px",height:28,border:0,borderRadius:6,background:H.accent,color:H.accentInk,font:"500 13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"};function Jl({buttonRef:e,count:t}){let n=C(),o=D("proposalsPanel"),{t:r}=b(),i=X(!o.enabled,o.enabled?void 0:o.disabledReason?.message),u=Q();return jsxs(Fragment,{children:[jsxs("button",{ref:e,type:"button","data-testid":"pptx-proposals-button",...i.props,"aria-expanded":o.value??false,title:i.reason,...u.focusProps,style:{...di,...J(u.focusRing)},onClick:()=>{o.enabled&&n.execute("proposalsPanel",null);},children:[r("proposals.title")," ",jsx("span",{"data-testid":"pptx-proposals-count",children:t})]}),i.node]})}var di={display:"inline-flex",alignItems:"center",gap:6,flex:"0 0 auto",margin:"0 0 0 4px",padding:"0 10px",height:28,border:`1px solid ${H.line}`,borderRadius:6,background:H.surface,color:H.ink,font:"500 13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer",boxSizing:"border-box"};var At=new WeakMap;function Ot(e,t){At.has(e)||At.set(e,t);}function so(e){return At.get(e)??null}var Qe={"data-pptx-plugin-chrome":""};function ts(e){return e instanceof Element&&e.closest("[data-pptx-plugin-chrome]")!==null}var gi=Object.values(c).flatMap(e=>e.shortcuts.map(t=>({id:e.id,shortcut:t}))),hi=new Set(["save"]),xi=new Set(["undo","redo"]);function uo(e){let n=(e instanceof Element?e:null)?.closest("input, textarea, select, [contenteditable]");return !!n&&n.getAttribute("contenteditable")!=="false"}function as({commands:e,containerRef:t,editorInput:n,suspended:o}){let r=useRef(o);r.current=o,useEffect(()=>{let i$1=a=>{let p=so(a);if(p)return e.ownsStore(p);let s=a.target;return s instanceof Node&&(t.current?.contains(s)??false)||e.ownsChrome(s)},u=a=>{if(a.defaultPrevented||a.isComposing||a.keyCode===229||!i$1(a)||r.current())return;let p=gi.find(({shortcut:m})=>i(m.chord,a));if(!p){let m=e.pluginShortcuts().find(({chord:h})=>i(h,a));if(!m||uo(a.target)&&a.target!==n?.current)return;a.preventDefault(),a.repeat||e.store.execute(m.id,null);return}let{id:s,shortcut:x}=p;if(uo(a.target)&&!hi.has(s))return;let c=e.store.getState(s,x.args);!c.enabled&&c.disabledReason.code==="host-disabled"||(a.preventDefault(),!(a.repeat&&!xi.has(s))&&e.store.execute(s,x.args));};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u);}},[e,t,n]);}var Dt=class extends Component{constructor(){super(...arguments);a$1(this,"state",{failed:false});}static getDerivedStateFromError(){return {failed:true}}componentDidCatch(n){this.props.onError(n);}render(){return this.state.failed?null:this.props.children}};function et({host:e,activation:t,phase:n="render",claimPointerEvents:o=false,children:r}){let i=e.commandStore(t),u=o?a=>Ot(a.nativeEvent,i):void 0;return jsx(Dt,{onError:a=>e.fail(t.pluginId,n,a),children:jsx(A.Provider,{value:i,children:jsx("div",{style:{display:"contents"},onKeyDownCapture:a=>Ot(a.nativeEvent,i),onPointerDownCapture:u,onPointerMoveCapture:u,onPointerUpCapture:u,onPointerCancelCapture:u,onLostPointerCaptureCapture:u,children:r})})})}function hs({host:e,activations:t,layerRef:n,claimPointerEvents:o}){return jsx("div",{ref:n,...Qe,className:"pptx-plugin-overlays","data-testid":"plugin-overlays",style:{position:"absolute",inset:0,pointerEvents:"none",overflow:"visible"},children:t.map(r=>{let i=r.plugin.overlay,u=r.context.geometry;return i&&u?jsx(et,{host:e,activation:r,claimPointerEvents:o,children:jsx(i,{context:r.context,geometry:u})},r.key):null})})}var yi={left:280,right:280,bottom:200},Nt={left:160,right:160,bottom:120},vi=640,ae={surface:"#ffffff",border:"#e2e8f0",text:"#172033",muted:"#647087",selected:"#e8f0fe",primary:"#1a73e8"};function Si(e,t,n){let o=e==="bottom"?n.height:n.width,r=Math.max(Nt[e],Math.floor(o*.4));return Math.max(Nt[e],Math.min(t??yi[e],r))}function mo(e=true){let t=useRef(null),[n,o]=useState({width:0,height:0});return useEffect(()=>{let r=t.current;if(!e||!r)return;let i=()=>o(a=>a.width===r.clientWidth&&a.height===r.clientHeight?a:{width:r.clientWidth,height:r.clientHeight});if(i(),typeof ResizeObserver>"u")return;let u=new ResizeObserver(i);return u.observe(r),()=>u.disconnect()},[e]),[t,n]}var Cs=mo;function Ci({host:e,activation:t,id:n,labelledBy:o}){let[r,i]=mo(),u=t.plugin.panel.render;return jsx("div",{ref:r,id:n,role:"tabpanel","aria-labelledby":o,className:"pptx-plugin-dock__panel",style:{flex:1,minHeight:0,minWidth:0,overflow:"auto"},children:jsx(et,{host:e,activation:t,children:jsx(u,{context:t.context,width:i.width,height:i.height})})})}var wi=e=>({maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"4px 8px",border:0,borderRadius:4,background:e?ae.selected:"transparent",color:e?ae.primary:ae.muted,font:"12px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"}),co={flex:"0 0 auto",padding:"0 6px",border:0,borderRadius:4,background:"transparent",color:ae.muted,font:"13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"};function ws({host:e,placement:t,activations:n,available:o}){let{t:r}=b(),i=useId(),[u,a]=useState(null),[p,s]=useState({}),[x,c]=useState(false),m=useRef(null),h=useRef(null),g=t!=="bottom"&&o.width>0&&o.width<vi,R=g&&x&&n.length>0;if(useEffect(()=>{R&&h.current?.focus();},[R]),n.length===0)return null;let w=n.find(E=>E.pluginId===u)??n[0],L=w.plugin.panel,H=g?!R:p[w.pluginId]??L.defaultCollapsed??false,N=Si(t,L.preferredSize,o),M=E=>`${i}-tab-${E}`,D=`${i}-panel`,A=E=>m.current?.querySelector(`[data-plugin-tab="${E}"]`)?.focus(),$=E=>{g?c(!(R&&E===w.pluginId)):E===w.pluginId&&H&&s(_=>({..._,[E]:false})),a(E);},v=()=>{c(false),A(w.pluginId);},z=E=>{let _=n.findIndex(P=>P.pluginId===w.pluginId),q=n.length-1,W=E.key==="ArrowRight"||E.key==="ArrowDown"?_===q?0:_+1:E.key==="ArrowLeft"||E.key==="ArrowUp"?_===0?q:_-1:E.key==="Home"?0:E.key==="End"?q:null;if(W===null)return;E.preventDefault();let d=n[W].pluginId;a(d),A(d);},C=r(H?"plugins.expandPanel":"plugins.collapsePanel",{title:L.title}),l=t==="bottom",f=g||!l&&H,b$1=jsx(Ci,{host:e,activation:w,id:D,labelledBy:M(w.pluginId)},w.key);return jsxs("section",{...Qe,className:`pptx-plugin-dock pptx-plugin-dock--${t}`,"data-testid":`plugin-dock-${t}`,"aria-label":r("plugins.panelTabs"),style:{position:"relative",display:"flex",flexDirection:"column",flexShrink:0,minWidth:0,minHeight:0,background:ae.surface,color:ae.text,...l?{height:H?void 0:N,borderTop:`1px solid ${ae.border}`}:{width:H||g?void 0:N,maxWidth:H||g?96:void 0,[t==="left"?"borderRight":"borderLeft"]:`1px solid ${ae.border}`}},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:4,flexWrap:"wrap"},children:[jsx("div",{ref:m,role:"tablist","aria-label":r("plugins.panelTabs"),"aria-orientation":f?"vertical":"horizontal",onKeyDown:z,style:{display:"flex",flexDirection:f?"column":"row",gap:2,flex:1,minWidth:0,overflow:"hidden"},children:n.map(E=>{let _=E.pluginId===w.pluginId;return jsx("button",{type:"button",role:"tab",id:M(E.pluginId),"data-plugin-tab":E.pluginId,"aria-selected":_,"aria-controls":_&&!H?D:void 0,"aria-expanded":g?_&&R:void 0,tabIndex:_?0:-1,title:E.plugin.panel.title,onClick:()=>$(E.pluginId),style:wi(_),children:E.plugin.panel.title},E.pluginId)})}),!g&&jsx("button",{type:"button","aria-expanded":!H,"aria-label":C,title:C,onClick:()=>s(E=>({...E,[w.pluginId]:!H})),style:co,children:H?"+":"\u2212"})]}),!H&&!g&&b$1,R&&jsxs("div",{ref:h,tabIndex:-1,"data-testid":`plugin-drawer-${t}`,onKeyDown:E=>{E.key==="Escape"&&(E.stopPropagation(),v());},style:{position:"absolute",top:0,bottom:0,[t==="left"?"left":"right"]:"100%",width:Math.min(N,Math.max(Nt[t],o.width-64)),zIndex:60,display:"flex",flexDirection:"column",background:ae.surface,boxShadow:"0 4px 16px rgba(15, 23, 42, 0.18)",outline:"none"},children:[jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:4},children:jsx("button",{type:"button","aria-label":C,title:C,onClick:v,style:co,children:"\xD7"})}),b$1]})]})}var go=new WeakMap,Ei=/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9])?$/,Ti=new Set(["left","right","bottom"]),ho=e=>e!==null&&typeof e=="object"?Object.freeze({...e}):e;function Ri(e){return Array.isArray(e?.shortcuts)?Object.freeze({...e,shortcuts:Object.freeze([...e.shortcuts])}):ho(e)}function ks(e){let t={...e};t.panel!==void 0&&(t.panel=ho(t.panel)),Array.isArray(t.commands)&&(t.commands=Object.freeze(t.commands.map(Ri))),Array.isArray(t.toolbar)&&(t.toolbar=Object.freeze([...t.toolbar]));let n=Object.freeze(t),o=Object.freeze(n.revision===void 0?{id:n.id}:{id:n.id,revision:n.revision});return go.set(o,n),o}function xo(e){return e!==null&&typeof e=="object"?go.get(e)??null:null}function fo(e){return typeof e=="function"||e!==null&&typeof e=="object"}var ki=/^f([1-9]|1[0-2])$/i;function Ii(e){let t=f(e);if(t===null)return false;let n=t.split("+"),o=n[n.length-1];return n.includes("Mod")||n.includes("Alt")||ki.test(o)}function Bt(e){return e===void 0||typeof e=="function"}function bo(e){if(typeof e.createState!="function")return new TypeError("createState must be a function");if(!Bt(e.initialize)||!Bt(e.onEvent))return new TypeError("initialize and onEvent must be functions");if(e.overlay!==void 0&&!fo(e.overlay))return new TypeError("overlay must be a component");let t=e.panel;if(t!==void 0&&(typeof t?.title!="string"||!Ti.has(t.placement)||!fo(t.render)||t.preferredSize!==void 0&&!(Number.isFinite(t.preferredSize)&&t.preferredSize>0)))return new TypeError("panel needs a title, a left, right or bottom placement and a renderer");let n=e.commands??[];if(!Array.isArray(n))return new TypeError("commands must be an array");let o=new Set;for(let i of n){if(!Ei.test(i?.id??""))return new TypeError(`Invalid command id ${JSON.stringify(i?.id)}`);if(o.has(i.id))return new TypeError(`Duplicate command id "${i.id}"`);if(o.add(i.id),typeof i.label!="string"||typeof i.mutatesDocument!="boolean"||typeof i.execute!="function"||!Bt(i.getState))return new TypeError(`Command "${i.id}" needs a label, mutatesDocument and execute`);let u=i.shortcuts??[];if(!Array.isArray(u)||u.some(a=>!Ii(a)))return new TypeError(`Command "${i.id}" has an invalid shortcut`)}let r=e.toolbar??[];return !Array.isArray(r)||r.some(i=>!o.has(i))?new TypeError("toolbar may only list the plugin\u2019s own command ids"):null}function As(e){return e!==void 0&&Number.isFinite(e)&&e>0?Math.min(q,Math.max(p,e)):"fit"}var Mi={open:["editor.openError","editor.openErrorDescription"],stopped:["editor.stoppedError","editor.stoppedErrorDescription"],load:["editor.loadError","editor.loadErrorDescription"]},Ai={position:"absolute",inset:0,zIndex:3,justifyContent:"center",padding:24,background:"#ffffff"},Oi={position:"absolute",left:0,right:0,bottom:0,zIndex:3,padding:"10px 16px",borderTop:"1px solid #e0e0e0",background:"#fafafa"},yo={marginTop:4,padding:"6px 16px",border:"1px solid #dadce0",borderRadius:6,background:"#ffffff",color:"#202124",font:"inherit",cursor:"pointer"};function Ds({kind:e,details:t,onReload:n,children:o,className:r,style:i}){let{t:u}=b(),[a,p]=Mi[e];return jsxs("div",{"data-testid":"pptx-error","data-failure":e,role:"alert",className:r,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,boxSizing:"border-box",textAlign:"center",color:"#202124",font:"14px ui-sans-serif, system-ui, sans-serif",...e==="stopped"?Oi:Ai,...i},children:[jsx("strong",{style:{fontSize:e==="stopped"?14:16,fontWeight:600},children:u(a)}),jsx("span",{style:{maxWidth:420,color:"#5f6368"},children:u(p)}),n&&jsx("button",{type:"button",onClick:n,style:yo,children:u("editor.reloadPage")}),o,t&&jsxs("details",{style:{maxWidth:480,color:"#5f6368",fontSize:12},children:[jsx("summary",{style:{cursor:"pointer"},children:u("editor.showDetails")}),jsx("pre",{style:{margin:"8px 0 0",whiteSpace:"pre-wrap",wordBreak:"break-word",textAlign:"start"},children:t})]})]})}var zs=yo;var Ns=["nw","n","ne","e","se","s","sw","w"];var Li=Math.fround(Math.fround(Math.PI)/180);function Bs(e,t,n,o){if(!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)return null;let r=(n-e.left)*t.width/e.width,i=(o-e.top)*t.height/e.height;return Number.isFinite(r)&&Number.isFinite(i)?{x:r,y:i}:null}function ze(e,t){for(let n of e){if(n.id===t)return n;let o=ze(n.children,t);if(o)return o}return null}function Ks(e){let t=new Map,n=[...e];for(;n.length>0;){let o=n.pop();t.set(o.id,o),n.push(...o.children);}return t}function _s(e,t){for(let n of e.shapes)if(n.id===t||ze(n.children,t))return n;return null}function Ws(e,t){return !!(e&&e.id===t.slideId&&ze(e.shapes,t.shapeId))}function $s(e,t){return e?.pointerId===t}function ot(e){if(e.width>0&&e.height>0)return {x:e.x,y:e.y,width:e.width,height:e.height};let t=e.inherited;return !t||t.width<=0||t.height<=0?null:{x:t.x,y:t.y,width:t.width,height:t.height}}function Di(e){return ot(e)!==null}function zi(e){let n=((e.inherited?.rotationDeg??e.rotationDeg)%360+360)%360,o=e.inherited?.flipH??e.flipH,r=e.inherited?.flipV??e.flipV;return Di(e)&&n===0&&!o&&!r}function Gs(e,t,n){let o=Kt(t,n);if(o)return o;let r=ot(n);return !r||e.widthEmu<=0||e.heightEmu<=0?null:{x:r.x*t.width/e.widthEmu,y:r.y*t.height/e.heightEmu,width:r.width*t.width/e.widthEmu,height:r.height*t.height/e.heightEmu}}function Kt(e,t){let n=new Set;Eo(t,n);let o=e.primitives.filter(s=>s.shapeId&&n.has(s.shapeId));if(o.length===0)return null;let r=o.map(s=>{let x=(s.transform?.rotationDeg??0)*Math.PI/180,c=Math.abs(s.w*Math.cos(x))+Math.abs(s.h*Math.sin(x)),m=Math.abs(s.w*Math.sin(x))+Math.abs(s.h*Math.cos(x));return {x:s.x+(s.w-c)/2,y:s.y+(s.h-m)/2,width:c,height:m}}),i=Math.min(...r.map(s=>s.x)),u=Math.min(...r.map(s=>s.y)),a=Math.max(...r.map(s=>s.x+s.width)),p=Math.max(...r.map(s=>s.y+s.height));return {x:i,y:u,width:a-i,height:p-u}}function js(e,t,n,o){let r=e.primitives.find(c=>c.kind==="textBox"&&c.shapeId===t&&c.storyId===n);if(!r||r.lines.length===0)return null;let i=So(r,o),u=wo(r),a=0;for(let c=1;c<r.lines.length;c+=1){let m=r.lines[c],h=r.lines[a];nt(m,i,u)<nt(h,i,u)&&(a=c);}let p=r.lines[a],s=p.caretStops[0];return s?{position:p.caretStops.reduce((c,m)=>Math.abs(m.x-i.x)<Math.abs(c.x-i.x)?m:c,s).position,lineIndex:a}:{position:p.start,lineIndex:a}}function Fi(e,t){let n={x:Math.fround(t.x),y:Math.fround(t.y)};for(let o=e.primitives.length-1;o>=0;o-=1){let r=e.primitives[o];if(!r.shapeId)continue;let i=Co(r,n);if(i)return r.kind==="textBox"&&r.storyId&&Hi(r,i)?"text":"shape"}return null}function So(e,t){let n=e.transform;if(!n||!n.rotationDeg&&!n.flipH&&!n.flipV)return t;let o=Math.fround,r=o(o(e.x)+o(o(e.w)/2)),i=o(o(e.y)+o(o(e.h)/2)),u=o(o(n.rotationDeg??0)*Li),a=o(Math.cos(u)),p=o(Math.sin(u)),s=o(t.x-r),x=o(t.y-i),c=o(o(s*a)+o(x*p)),m=o(o(x*a)-o(s*p));return n.flipH&&(c=-c),n.flipV&&(m=-m),{x:o(r+c),y:o(i+m)}}function vo(e,t){return Math.fround(Math.fround(e)+Math.fround(t))}function Co(e,t){let n=So(e,t);return n.x>=Math.fround(e.x)&&n.x<=vo(e.x,e.w)&&n.y>=Math.fround(e.y)&&n.y<=vo(e.y,e.h)?n:null}function wo(e){return e.lines.some((t,n)=>n>0&&(t.columnOffset??0)!==(e.lines[n-1].columnOffset??0))}function nt(e,t,n){let o=Math.max(e.x-t.x,t.x-e.x-e.width,0),r=Ni(e.y,e.height,t.y);return n?o*o+r*r:r}function Hi(e,t){if(e.lines.length===0)return false;let n=wo(e);return e.lines.reduce((r,i)=>nt(i,t,n)<nt(r,t,n)?i:r).caretStops.length>0}function Zs(e,t,n,o){let r=ot(n);return r?{...r,x:r.x+Math.round(o.x*e.widthEmu/t.width),y:r.y+Math.round(o.y*e.heightEmu/t.height)}:null}function Us(e,t,n,o,r=4){return Math.hypot(n-e,o-t)>=r}function Eo(e,t){t.add(e.id);for(let n of e.children)Eo(n,t);}function Ni(e,t,n){return n<e?e-n:n>e+t?n-e-t:0}function Vs(e,t){let n=t.includes("w")?e.x:t.includes("e")?e.x+e.width:e.x+e.width/2,o=t.startsWith("n")?e.y:t.startsWith("s")?e.y+e.height:e.y+e.height/2;return {x:n,y:o}}function Xs(e){return e==="nw"||e==="se"?"nwse-resize":e==="ne"||e==="sw"?"nesw-resize":e==="n"||e==="s"?"ns-resize":"ew-resize"}function Bi(e,t,n,o,r=false){if(r&&t.length===2&&e.width>0&&e.height>0){let s=t.includes("w")?-n.x:n.x,x=t.startsWith("n")?-n.y:n.y,c=Math.max(1+(s*e.width+x*e.height)/(e.width**2+e.height**2),o/e.width,o/e.height),m=Math.round(e.width*c),h=Math.round(e.height*c);return {x:t.includes("w")?e.x+e.width-m:e.x,y:t.startsWith("n")?e.y+e.height-h:e.y,width:m,height:h}}let{x:i,y:u,width:a,height:p}=e;if(t.includes("w")){let s=Math.min(n.x,a-o);i+=s,a-=s;}else t.includes("e")&&(a=Math.max(o,a+n.x));if(t.startsWith("n")){let s=Math.min(n.y,p-o);u+=s,p-=s;}else t.startsWith("s")&&(p=Math.max(o,p+n.y));return {x:i,y:u,width:a,height:p}}function qs(e,t,n){return n?{x:n.x-e.x,y:n.y-e.y}:t}function Ki(e,t,n,o,r){if(!zi(n))return null;let i={x:Math.round(r.x*e.widthEmu/t.width),y:Math.round(r.y*e.heightEmu/t.height)},u=ot(n);if(!u)return null;let a=Bi(u,o,i,76200,n.aspectRatioLocked);return {x:a.x,y:a.y,width:a.width,height:a.height}}function Ys(e,t,n,o,r){let i=Ki(e,t,n,o,r);return !i||e.widthEmu<=0||e.heightEmu<=0?null:{x:i.x*t.width/e.widthEmu,y:i.y*t.height/e.heightEmu,width:i.width*t.width/e.widthEmu,height:i.height*t.height/e.heightEmu}}function Js(e,t,n=1){let o=Fi(e,t);if(o!=="text")return o;let r={x:Math.fround(t.x),y:Math.fround(t.y)};for(let i=e.primitives.length-1;i>=0;i-=1){let u=e.primitives[i];if(!u.shapeId)continue;let a=Co(u,r);if(a)return _i(u,a,n)?"shape":"text"}return o}function _i(e,t,n){let o=Number.isFinite(n)&&n>0?n:1,r=Math.min(6/o,e.w/3,e.h/3);return t.x-e.x<=r||e.x+e.w-t.x<=r||t.y-e.y<=r||e.y+e.h-t.y<=r}var Wi=Object.freeze({commands:Object.freeze([])});function To(e){if(!e||typeof e!="object")return Wi;let t=Array.isArray(e.commands)?[...new Set(e.commands.filter(n=>typeof n=="string"))].sort():[];return e.document!=="write"?Object.freeze({commands:Object.freeze(t)}):Object.freeze({commands:Object.freeze(t),document:"write",...e.editBatches===true?{editBatches:true}:{},...e.untrackedHistory===true?{untrackedHistory:true}:{}})}function Ro(e,t){let n=e.commands??[],o=t.commands??[];return e.document===t.document&&e.editBatches===t.editBatches&&e.untrackedHistory===t.untrackedHistory&&n.length===o.length&&n.every((r,i)=>r===o[i])}function ko(e,t){return e.commands?.includes(t)??false}function Io(e){return e.document==="write"}function _t(e,t){return e.document==="write"&&e.editBatches===true&&(t!=="none"||e.untrackedHistory===true)}var $i=/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9])?$/;function Gi(e){return typeof e=="string"&&$i.test(e)}function Mo(e){return e.revision===void 0?"":`${typeof e.revision}:${e.revision}`}var Ao=10;function Wt(e){return e.type==="load"?"document-change":e.type}function ji(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function $t(e){let t=new AbortController;if(e.aborted)return t.abort(),{controller:t,release:()=>{}};let n=()=>t.abort();return e.addEventListener("abort",n,{once:true}),{controller:t,release:()=>e.removeEventListener("abort",n)}}function Oo(e){let t=new Map,n=null,o=false,r={},i=new Map,u=new WeakSet,a=new Set,p=new Set,s=0,x=0,c=null,m=[],h=false,g=new Set,R=()=>!h&&[...t.values()].every(({activation:d})=>!d||d.status==="disposed"||d.status==="ready"&&!d.running&&!d.pumping&&!d.pending.length),w=()=>{if(!(!g.size||!R())){for(let d of g)d();g.clear();}},L=d=>{try{e.report(d);}catch(P){console.error("[plugins] onPluginError threw",P);}},H=d=>{let P=Object.hasOwn(r,d)?r[d]:void 0,k=i.get(d);if(k&&k.source===P)return k.grant;let y=To(P);return i.set(d,{source:P,grant:y}),y},N=d=>{let P=`${s}:${d.stateRevision}`;if(d.rendered?.key===P)return d.rendered.entry;let k=C(d,d.lifetime.signal),y={pluginId:d.registration.id,plugin:d.registration.plugin,generation:d.generation,activation:d.token,key:d.key,context:e.context(k,d.registration.plugin)};return d.rendered={key:P,entry:y},y},M=()=>{h=false;let d=[];for(let k of t.values()){let y=k.activation;y?.status==="ready"&&d.push(N(y));}d.length===m.length&&d.every((k,y)=>k===m[y])||(m=d);for(let k of [...p])k();w();},D=()=>{s+=1,!h&&(h=true,queueMicrotask(M));},A=(d,P)=>d.status==="disposed"?d.ended==="document-replaced"?"document-replaced":"plugin-unavailable":P.aborted?"aborted":null,$=(d,P,k)=>{let y=I=>L({pluginId:d.registration.id,generation:d.generation,phase:"cleanup",error:I});try{let I=P(k);ji(I)&&I.then(void 0,y);}catch(I){y(I);}},v=(d,P)=>{if(d.status!=="disposed"){d.status="disposed",d.ended=P,d.pending=[],d.registration.activation===d&&(d.registration.activation=null),d.lifetime.abort();for(let k of d.cleanups.splice(0).reverse())$(d,k,P);D();}},z=(d,P,k)=>{d.status!=="disposed"&&(d.registration.quarantined=true,L({pluginId:d.registration.id,generation:d.generation,phase:P,error:k}),v(d,"failed"));};function C(d,P){let k=e.snapshot(d.registration.id,d.generation);return {pluginId:d.registration.id,activation:d.token,snapshot:k,signal:P,lifetimeSignal:d.lifetime.signal,state:()=>d.state,setState(I,T){if(A(d,P)!==null)return false;let K=e.currentVersion();return K===null||(T??k.version)!==K?false:(d.state=typeof I=="function"?I(d.state):I,d.stateRevision+=1,D(),true)},onCleanup(I){if(typeof I!="function")throw new TypeError("A cleanup must be a function");d.status==="disposed"?$(d,I,d.ended??"unmounted"):d.cleanups.push(I);},run:I=>l(d,I),commit(I){let T=c;c=P;try{return I()}finally{c=T;}},refusal:()=>A(d,P)}}async function l(d,P){let{controller:k,release:y}=$t(d.lifetime.signal);if(!k.signal.aborted)try{await P(C(d,k.signal));}catch(I){k.signal.aborted||z(d,"action",I);}finally{y();}}async function f(d,P,k,y){let{controller:I,release:T}=$t(d.lifetime.signal);d.running={channel:k,controller:I};try{let K=C(d,I.signal);return await y(e.context(K,d.registration.plugin),K),d.status==="disposed"?"ended":I.signal.aborted?"aborted":"ok"}catch(K){return d.status==="disposed"?"ended":I.signal.aborted?"aborted":(z(d,P,K),"ended")}finally{T(),d.running?.controller===I&&(d.running=null);}}async function b(d){if(!d.pumping){d.pumping=true;try{for(;d.status==="ready";){let P=d.pending.shift();if(!P)break;if(!d.registration.plugin.onEvent)continue;if(await f(d,"event",Wt(P),y=>d.registration.plugin.onEvent?.(y,P))==="ended")break}}finally{d.pumping=false,w();}}}let E=(d,P)=>{if(d.status==="disposed"||P.generation!==d.generation)return;let k=Wt(P),y=d.pending.findIndex(T=>Wt(T)===k);if(y>=0){if(d.pending[y].type==="load")return;d.pending[y]=P;}else d.pending.push(P);let I=d.running;I?.channel===k&&I.controller.signal!==c&&I.controller.abort(),d.status==="ready"&&queueMicrotask(()=>{b(d);});};async function _(d,P,k){x+=1;let y={token:Object.freeze({}),key:`${d.id}#${x}`,registration:d,generation:P,lifetime:new AbortController,status:"initializing",ended:null,state:void 0,stateRevision:0,cleanups:[],pending:[],running:null,pumping:false,rendered:null};d.activation=y;try{y.state=d.plugin.createState();}catch(T){z(y,"initialize",T);return}if(d.plugin.initialize&&await f(y,"initialize","initialize",K=>y.registration.plugin.initialize?.(K))==="ended")return;let I="aborted";for(let T=0;I==="aborted"&&y.status!=="disposed";T+=1){if(T===Ao){z(y,"event",new Error(`Document changes superseded the load hook ${Ao} times`));return}y.pending=[],I=await f(y,"event","document-change",(K,Y)=>y.registration.plugin.onEvent?.(K,e.loadEvent(Y.snapshot,k)));}I!=="ok"||y.status==="disposed"||(y.status="ready",D(),b(y));}let q=(d,P)=>L({pluginId:d,generation:n,phase:"definition",error:P}),W=d=>{n=null,d==="unmounted"&&(o=false);for(let P of t.values())P.activation&&v(P.activation,d);D();};return {setPlugins(d){let P=new Map;for(let T of d){let K=Gi(T?.id)?e.validate?.(T):new TypeError(`Invalid plugin id ${JSON.stringify(T?.id)}`);if(K!=null){T&&typeof T=="object"&&!u.has(T)&&(u.add(T),q(typeof T.id=="string"?T.id:"",K));continue}let Y=P.get(T.id);Y?Y.push(T):P.set(T.id,[T]);}let k=new Set,y=new Map,I=[];for(let[T,K]of P){if(K.length>1){k.add(T),a.has(T)||q(T,new Error(`${K.length} plugins share the id "${T}"`));continue}let Y=K[0],oe=t.get(T);if(oe&&Mo(oe.plugin)===Mo(Y)){oe.plugin=Y,y.set(T,oe);continue}oe&&I.push([oe,"definition-replaced"]),y.set(T,{id:T,plugin:Y,quarantined:false,activation:null});}a=k;for(let[T,K]of t)y.has(T)||I.push([K,"removed"]);t=y;for(let[T,K]of I)T.activation&&v(T.activation,K);if(n!==null)for(let T of t.values())!T.activation&&!T.quarantined&&_(T,n,"attached");D();},setGrants(d){let P=new Map([...t.keys()].map(y=>[y,H(y)]));r=d??{},i.clear();let k=false;for(let y of t.values()){let I=H(y.id),T=P.get(y.id);if(Ro(T,I)){i.get(y.id).grant=T;continue}k=true;let K=y.activation;K&&E(K,e.grantsEvent(e.snapshot(y.id,K.generation),I));}k&&D();},grant:H,open(d){if(n===d)return;n!==null&&W("document-replaced"),n=d;let P=o?"replaced":"loaded";o=true;for(let k of t.values())k.quarantined=false,_(k,d,P);D();},close:W,generation:()=>n,notify(d){if(d.generation===n){for(let P of t.values())P.activation&&E(P.activation,d);D();}},notificationsIdle(){return R()?Promise.resolve():new Promise(d=>g.add(d))},touch:D,activations:()=>m,subscribe(d){return p.add(d),()=>{p.delete(d);}},guard(d,P,k,y){let I=t.get(d)?.activation;if(I?.status!=="ready")return y;try{return k(N(I).context)}catch(T){return queueMicrotask(()=>z(I,P,T)),y}},async invoke(d,P,k){let y=t.get(d)?.activation;if(y?.status!=="ready")return {ok:false,reason:"plugin-unavailable"};let{controller:I,release:T}=$t(y.lifetime.signal),K=C(y,I.signal);try{return {ok:!0,value:await k(e.context(K,y.registration.plugin))}}catch(Y){let oe=K.refusal();return oe?{ok:false,reason:oe}:(z(y,P,Y),{ok:false,reason:"failed"})}finally{T();}},fail(d,P,k){let y=t.get(d)?.activation;y&&z(y,P,k);}}}var Zi={"plugin-unavailable":"The plugin is no longer active","document-replaced":"The presentation was replaced",aborted:"This plugin context was superseded","permission-denied":"The host has not granted this operation","read-only":"The editor is read-only","input-failed":"Pending input could not be applied","unsupported-policy":"Plugins cannot run this operation yet","plugin-failed":"The plugin failed"},Ui={"stale-version":"The presentation changed after that version","missing-target":"The target is not in the presentation","ambiguous-target":"The target does not identify one object","layout-unavailable":"The slide cannot be shown",unsupported:"The editor cannot show this target now"};function Fe(e,t=Zi[e]){return {ok:false,failure:{code:e,message:t}}}function Ce(e){let t=e.refusal();return t?Fe(t):null}function Gt(e,t,n){return {deny(o){let r=e.refusal();if(r)return r;if(d(o))return o.startsWith(`plugin:${e.pluginId}/`)?null:"permission-denied";let i=t();return !ko(i,o)||c[o].mutatesDocument&&!Io(i)?"permission-denied":null},subscribe:n}}function Vi(e,t,n){return !n()&&e.some(o=>o.aborted)?Promise.resolve(null):new Promise((o,r)=>{let i=()=>{n()||(u(),o(null));},u=()=>{for(let a of e)a.removeEventListener("abort",i);};for(let a of e)a.addEventListener("abort",i,{once:true});t.then(a=>{u(),o(a);},a=>{u(),r(a);});})}function Lo(e,t,n,o){let r=async c=>{let m=Ce(e);if(m)return m;let h=t.handle();if(!h)return Fe("plugin-unavailable");let g=false,R=await Vi([e.signal,e.lifetimeSignal],t.admit(h,()=>{let w=Ce(e);return w?{refused:w}:(g=true,{value:c(h)})}),()=>g);return R?R.ok?"refused"in R.value?R.value.refused:R.value.value:Ce(e)??Fe(R.code):Ce(e)??Fe("aborted")},i={version:()=>r(c=>({ok:true,version:c.version()})),readContent:c=>r(m=>m.readContent(c)),findText:c=>r(m=>m.findText(c)),validateEdits:c=>r(m=>t.readOnlyRefusal(m)??m.validateEdits(c))},u=c=>Ce(e)??(_t(n(),c)?null:Fe("permission-denied")),a=_t(n(),"separate")?{async applyEdits(c){let m=u(c.history);return m||r(h=>t.applyEdits(h,c,()=>u(c.history),g=>e.commit(g)))}}:null,p={getDescriptor:c=>o.getDescriptor(c),getState:(c,m)=>o.getState(c,m),subscribe:c=>o.subscribe(c),execute:async(c,m)=>Ce(e)??o.execute(c,m)},s=async(c,m)=>{let h=await r(g=>g.version()===c?.expectVersion?m(g,c.focus===true):"stale-version");return h===null?{ok:true}:typeof h=="object"?h:{ok:false,failure:{code:h,message:Ui[h]}}};return {read:i,commands:p,edits:a,navigation:{goToSlide:(c,m)=>s(m,(h,g)=>t.navigator.goToSlide(h,c,g)),selectShape:(c,m)=>s(m,(h,g)=>t.navigator.selectShape(h,c,g)),selectText:(c,m)=>s(m,(h,g)=>t.navigator.selectText(h,c,g))}}}function jt(e,t){return e?.scoped(t)??z}var Xi=Object.freeze({enabled:true});function qi(e){let t=e;if(!t||typeof t.enabled!="boolean")throw new TypeError("A command getState must return a CommandState");if(!t.enabled&&(typeof t.disabledReason?.code!="string"||typeof t.disabledReason.message!="string"))throw new TypeError("A disabled command state needs a disabledReason");return e}function Yi(e){let t=e;return t&&typeof t.ok=="boolean"?e:{ok:true,status:"executed"}}function Ji(e,t){return e===t||!!e&&!!t&&e.id===t.id&&e.version===t.version}function rt(e){try{return e.version()}catch{return null}}function mu(e,t){let n=t??((l,f,b)=>{if(!("handle"in e))throw new TypeError("Plugin clients require document access");return Lo(l,e,f,b)}),o,r=null,i=null,u=false,a=0,p=null,s={version:"",readOnly:false,selection:null,layout:null},x=new WeakMap,c=new WeakMap,m$1=0,h$1=l=>{let f=c.get(l);return f===void 0&&(m$1+=1,f=m$1,c.set(l,f)),f},g$1=new WeakSet,R=new Set,w=l=>{if(!o){console.error(`[PptxEditor] plugin "${l.pluginId}" failed (${l.phase})`,l.error);return}try{o(l);}catch(f){console.error("[PptxEditor] onPluginError threw",f);}},L=()=>e.commands(),H=l=>{let f=()=>M.grant(l.pluginId);if(l.signal!==l.lifetimeSignal)return Gt(l,f,M.subscribe);let b=x.get(l.activation);return b||(b=Gt(l,f,M.subscribe),x.set(l.activation,b)),b},N=l=>{let f=l.pluginId,b=n(l,()=>M.grant(f),jt(L(),H(l))),E=e.geometry();return {pluginId:f,snapshot:l.snapshot,get state(){return l.state()},signal:l.signal,lifetimeSignal:l.lifetimeSignal,read:b.read,commands:b.commands,edits:b.edits,geometry:E&&l.snapshot.layout?.id===E.layout.id?E:null,navigation:b.navigation,setState:(_,q)=>l.setState(_,q),onCleanup:_=>l.onCleanup(_),run:_=>l.run(q=>_(N(q)))}},M=Oo({context:l=>N(l),snapshot:(l,f)=>({generation:f,version:s.version,readOnly:s.readOnly,grant:M.grant(l),selection:s.selection,layout:s.layout}),currentVersion:()=>r&&M.generation()!==null?rt(r):null,loadEvent:(l,f)=>({type:"load",generation:l.generation,version:l.version,reason:f}),grantsEvent:(l,f)=>({type:"grants-change",generation:l.generation,grant:f}),validate:bo,report:w}),D=l=>M.notify(l),A=()=>{let l=M.generation(),f=r?rt(r):null;!l||!f||f===s.version||(s.version=f,D({type:"document-change",generation:l,version:f}),s.layout&&s.layout.version!==f&&(s.layout=null,D({type:"layout-change",generation:l,layout:null})));},$=()=>{if(!u||!r){i?.(),i=null;return}if(!i){s.version=rt(r)??s.version;try{i=r.onUpdate(A);}catch(l){console.error("[PptxEditor] observing presentation changes for plugins failed",l);}}},v=()=>{i?.(),i=null,r=null;},z$1=(l,f)=>M.guard(l,"command-state",b=>qi(f.getState?f.getState(b):Xi),{enabled:false,disabledReason:m("plugin-unavailable",{translate:e.translate})}),C=async(l,f)=>{let b=await M.invoke(l,"command",_=>f.execute(_));if(b.ok)return Yi(b.value);let E=b.reason==="failed"?"command-failed":b.reason;return {ok:false,failure:m(E,{translate:e.translate})}};return {setPlugins(l){let f=[];for(let b of l??[]){let E=xo(b);if(E){f.push(E);continue}if(b!==null&&typeof b=="object"){if(g$1.has(b))continue;g$1.add(b);}w({pluginId:typeof b?.id=="string"?b.id:"",generation:M.generation(),phase:"definition",error:new TypeError("Plugins must be created with definePptxPlugin")});}u=f.length>0,$(),M.setPlugins(f);},setGrants:l=>M.setGrants(l),setReporter(l){o=l;},open(l){v(),r=l,s.version=rt(l)??"",s.layout=null,s.selection=null,$(),a+=1,M.open(`presentation-${a}`);},close(l){v(),s.layout=null,M.close(l);},generation:()=>M.generation(),version:()=>s.version,selectionChanged(l){if(JSON.stringify(l)===JSON.stringify(s.selection))return;s.selection=l;let f=M.generation();f&&D({type:"selection-change",generation:f,version:s.version,selection:l});},modeChanged(l){if(l===s.readOnly)return;s.readOnly=l;let f=M.generation();f&&D({type:"mode-change",generation:f,readOnly:l});},layoutChanged(l){let f=l&&l.version===s.version?l:null;if(Ji(f,s.layout))return;s.layout=f;let b=M.generation();b&&D({type:"layout-change",generation:b,layout:f});},layoutId:()=>M.generation()===null?null:s.layout?.id??null,geometryChanged:()=>M.touch(),activations:()=>M.activations(),subscribe:l=>M.subscribe(l),commandStore(l){let f=x.get(l.activation);return f?jt(L(),f):z},syncCommands(){let l=L();if(!l)return;let f$1=[],b=[],E=new Map,_=[];for(let W of M.activations()){let d=W.plugin;_.push(`${W.pluginId}:${h$1(d)}:${h$1(W.activation)}`);for(let P of d.commands??[]){let k=`plugin:${W.pluginId}/${P.id}`,y=[];for(let I of P.shortcuts??[]){let T=f(I),K=h.has(T)?"a built-in command":g.has(T)?"text editing":E.get(T);if(!K){E.set(T,k),y.push({chord:I,args:null});continue}let Y=`${W.pluginId}\0${T}`;R.has(Y)||(R.add(Y),w({pluginId:W.pluginId,generation:W.generation,phase:"definition",error:new Error(`Shortcut ${I} of ${k} is already used by ${K}; it was not bound`)}));}f$1.push({descriptor:Object.freeze({id:k,label:P.label,mutatesDocument:P.mutatesDocument,shortcuts:Object.freeze(y)}),state:()=>z$1(W.pluginId,P),execute:()=>C(W.pluginId,P)});}for(let P of d.toolbar??[])b.push(`plugin:${W.pluginId}/${P}`);}let q=_.join("|");if(q===p){l.refresh();return}p=q,l.setPluginCommands(f$1,b);},guard:(l,f,b,E)=>M.guard(l,f,b,E),fail:(l,f,b)=>M.fail(l,f,b)}}var it=9525,Do=new WeakMap,zo=0;function Qi(e){let t=Do.get(e);return t||(zo+=1,t=`slide-layout-${zo}`,Do.set(e,t)),t}function hu(e,t){if(!e||t===null||e.version!==t)return null;let n=e.snapshot.slides[e.slideIndex];return n?{id:Qi(e),version:t,slideId:n.id,slide:e.slideIndex+1,zoom:e.scale,width:e.frame.width,height:e.frame.height}:null}function ea(e){let t=e;return !!t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}function ta(e,t,n,o){let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();if(!(n.width>0&&n.height>0&&r.width>0&&r.height>0))return null;let u=r.width/n.width,a=r.height/n.height,p=r.left-i.left-t.clientLeft+t.scrollLeft,s=r.top-i.top-t.clientTop+t.scrollTop;return {x:p+o.x*u,y:s+o.y*a,width:o.width*u,height:o.height*a}}function xu(e,t,n,o,r,i){let u=a=>r()?ta(n,o,t.frame,a):null;return {layout:e,toOverlayRect(a){let p=a?.rect;return ea(p)?a.space==="slide-px"?u(p):a.space!=="slide-emu"?null:u({x:p.x/it,y:p.y/it,width:p.width/it,height:p.height/it}):null},getShapeRect(a){let p=t.snapshot.slides[t.slideIndex],s=p&&typeof a=="string"?ze(p.shapes,a):null,x=s?Kt(t.frame,s):null;return x?u(x):null},getPositionAtPoint(a,p){if(!r())return null;let s=i(t.frame,a,p);return s?{...s,version:e.version,layoutId:e.id}:null}}}function Pu(e,t=12){return {visible:e.slice(0,t),overflow:Math.max(0,e.length-t)}}function yu(e,t,n=4){let o=new Map;for(let r of e){let i=r.state.cursor?.slideId;if(!i||!t.has(i))continue;let u=o.get(i)??{visible:[],overflow:0};u.visible.length<n?u.visible.push(r):u.overflow+=1,o.set(i,u);}return o}function vu(e,t,n,o=24){let r=new Map,i=0;for(let u of e){let a=u.state.cursor;if(a?.slideId!==t||!a.shapeId||!n.has(a.shapeId))continue;let p=r.get(a.shapeId);p?(p.count+=1,u.cursorMovedAt>p.peer.cursorMovedAt&&(p.peer=u)):r.size<o?r.set(a.shapeId,{shapeId:a.shapeId,peer:u,count:1}):i+=1;}return {visible:[...r.values()],overflow:i}}var Cu="legacySyncApi";var Eu={panel:{flex:"0 0 auto",display:"flex",flexDirection:"column",gap:4,padding:"8px 14px 10px",background:"#ffffff",borderTop:"1px solid #e2e8f0"},label:{fontSize:11,fontWeight:650,color:"#647087",textTransform:"uppercase",letterSpacing:"0.02em"},textarea:{width:"100%",height:64,resize:"vertical",border:"1px solid #d8dee9",borderRadius:6,padding:"6px 8px",font:"13px ui-sans-serif, system-ui, sans-serif",color:"#172033",boxSizing:"border-box",outline:"none"}},Tu={row:{display:"flex",flexWrap:"wrap",gap:6,paddingTop:8},button:{flex:"1 1 auto",height:26,whiteSpace:"nowrap",padding:"0 8px",border:"1px solid #cbd5e1",borderRadius:5,background:"#ffffff",color:"#334155",font:"12px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"}};export{Ds as $,ee as A,In as B,pl as C,Mt as D,li as E,jl as F,Jl as G,so as H,ts as I,as as J,hs as K,Cs as L,ws as M,_t as N,Fe as O,Vi as P,ks as Q,mu as R,it as S,hu as T,ta as U,xu as V,Pu as W,yu as X,vu as Y,Cu as Z,As as _,Ns as a,zs as aa,Bs as b,Eu as ba,ze as c,Tu as ca,Ks as d,_s as e,Ws as f,$s as g,ot as h,Di as i,zi as j,Gs as k,js as l,Zs as m,Us as n,Vs as o,Xs as p,Bi as q,qs as r,Ki as s,Ys as t,Js as u,be as v,oa as w,fn as x,j as y,ir as z};