@betteroffice/pptx-react 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ import {Y,a,H as H$1,_,b,$,f,i,ha,n,h,ea as ea$1,g,ga,fa,e,w,G,F,z,y,W,aa as aa$1,J as J$1,m,c as c$1,r,s,ba as ba$1,da as da$1,x,o,l,k,p as p$1,C,D,j,v,I,O,K,E,R,V,q,u}from'./chunk-HJN2B5PX.js';import {e as e$1,p,a as a$2}from'./chunk-3WH2K5EA.js';import {d,J,M,i as i$1,I as I$1,a as a$4,K as K$1,x as x$1,h as h$1,p as p$2,o as o$1,j as j$1,r as r$1,q as q$1}from'./chunk-LFHLWZA4.js';import {d as d$1,a as a$1,c}from'./chunk-52U7UPKN.js';import {a as a$3}from'./chunk-O2XFH626.js';import {sizeCanvasForSlide,paintSlide,StaleProposalError,initWasm,openPresentation,decodePresentationImage,PRESENCE_LABEL_DURATION_MS,metafileImageBytes,PptxPeerNotReadyError,presentationImageBlob,PptxWorkerEditorDisposedError}from'@betteroffice/pptx';import {presentationStoryFormatting}from'@betteroffice/pptx/worker';import {memo,useCallback,useSyncExternalStore,useRef,useEffect,useState,useMemo,useLayoutEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var De=class extends Error{constructor(s){super(s instanceof Error?s.message:String(s));a$3(this,"cause",s);}},ke=class extends Error{constructor(){super("The presentation was replaced before queued work ran");}};function Go(n){return n!==null&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}var Ve=()=>{};function qo(n=Ve){let r=Promise.resolve(),s=0,o=0,l=0,m=[],x=new Map,h=(c,p)=>{let g=l;s+=1,p==="keyboard"&&(o+=1),p&&m.push(c),s===1&&n();let b=v=>{g===l&&(v&&p&&x.set(c,v.value),m=m.filter(U=>U!==c),s-=1,p==="keyboard"&&(o-=1),s===0&&(x.clear(),n()));};c.then(()=>b(),v=>b({value:v}));},P=c=>{let p=l,g=r.then(()=>{if(p!==l)throw new ke;return c()});return r=g.then(Ve,Ve),g};return {busy:()=>s>0,keyboardQueued:()=>o>0,input(c,p="other"){if(s===0){let b;try{b=c();}catch(U){return Promise.reject(U)}if(!Go(b))return Promise.resolve();let v=Promise.resolve(b);return r=v.then(Ve,Ve),h(v,p),v}let g=P(c);return h(g,p),g},run(c){let p=[...m],g=()=>{for(let v of p)if(x.has(v))throw new De(x.get(v));return c()};if(s===0){let v;try{v=c();}catch(T){return Promise.reject(T)}if(!Go(v))return Promise.resolve(v);let U=Promise.resolve(v);return r=U.then(Ve,Ve),h(U,null),U}let b=P(g);return h(b,null),b},reset(){l+=1;let c=s>0;r=Promise.resolve(),s=0,o=0,m=[],x.clear(),c&&n();}}}function Vo(n){let r=n?.fill?.type==="none"?null:$o(n?.resolvedFillColor),s=$o(n?.resolvedOutlineColor);return {geometry:n?.geometry,fillColor:r,strokeColor:s,strokeWidthPt:s&&n?.outline?.width!==void 0?n.outline.width/12700:s?1:null,adjustments:n?.adjustValues??{}}}function $o(n){if(!n)return null;let r=n.replace(/^#/,"");return /^[0-9a-f]{6}$/i.test(r)?`#${r}`:null}function Yt(n,r,s,o){let l=ts(n,r,s,o),m=Ze(l,"underline"),x=l.map(P=>P.strike==="sngStrike"||P.strike==="dblStrike"),h=x.every(P=>P===x[0])?x[0]:void 0;return {bold:Ze(l,"bold"),italic:Ze(l,"italic"),underline:m===void 0?void 0:m!=="none",strikethrough:h,fontSize:Ze(l,"fontSizePt"),textColor:Ze(l,"color"),fontFamily:Ze(l,"fontFamily")}}function Zo(n,r){return Yt(n,0,n.length,r)}var Ni={left:"l",center:"ctr",right:"r",justify:"just"},Ui={l:"l",ctr:"ctr",r:"r",just:"just",justLow:"just",dist:"just",thaiDist:"just"};function Qo(n,r,s,o){let l=Xi(n),m=l[l.length-1]?.end??0,x=Math.min(Math.min(s,o),m),h=Math.max(s,o),P=l.map((p,g)=>({range:p,index:g})).filter(({range:p})=>x===h?x>=p.start&&x<=p.end:x<=p.end&&h>p.start).map(({index:p})=>_i(n,r,p));if(P.length===0)return;let c=P[0];return P.every(p=>p===c)?c:void 0}function _i(n,r,s){let o=n.paragraphs[s]?.alignment;if(o)return Ui[o]??"l";let l=r?.paragraphs[s]?.align;return l?Ni[l]??"l":"l"}function Xi(n){let r=0;return n.paragraphs.map(s=>{let o=r+s.runs.reduce((m,x)=>m+x.text.length,0),l={start:r,end:o};return r=o+1,l})}function Jo(n,r,s,o){let l=Yt(n,r,s,o),x=Ze(ts(n,r,s,o),"strike")??(l.strikethrough===void 0?o.strike:l.strikethrough?"sngStrike":void 0);return {bold:l.bold??o.bold,italic:l.italic??o.italic,underline:l.underline===void 0?o.underline:l.underline?"sng":"none",...x===void 0?{}:{strike:x==="noStrike"?void 0:x},fontSizePt:l.fontSize??o.fontSizePt,color:l.textColor??o.color,fontFamily:l.fontFamily??o.fontFamily}}function es(n){return Object.prototype.hasOwnProperty.call(n,"strike")&&n.strike===void 0?{...n,strike:"noStrike"}:n}function ts(n,r,s,o){let l=Yi(n,o);if(l.length===0)return [o];let m=Math.min(r,s),x=Math.max(r,s);if(m===x){let c=l.find(g=>m>=g.start&&m<g.end);return c?[c.style]:[[...l].reverse().find(g=>g.end<=m)?.style??l[0].style]}let h=l.filter(c=>c.end>m&&c.start<x).map(c=>c.style);return h.length>0?h:[[...l].reverse().find(c=>c.end<=m)?.style??l[0].style]}function Yi(n,r){let s=[],o=0;return n.paragraphs.forEach((l,m)=>{for(let x of l.runs){let h=o;o+=x.text.length,o>h&&s.push({start:h,end:o,style:Gi(x.style,r)});}m<n.paragraphs.length-1&&(o+=1);}),s}function Gi(n,r){return {bold:n.bold??r.bold,italic:n.italic??r.italic,underline:n.underline??r.underline,...(n.strike??r.strike)===void 0?{}:{strike:n.strike??r.strike},fontSizePt:n.fontSizePt??r.fontSizePt,color:n.color??r.color,fontFamily:n.fontFamily??r.fontFamily}}function Ze(n,r){let s=n[0]?.[r];return n.every(o=>o[r]===s)?s:void 0}var rs=new Set(["insertImage","save","exportPng","slideshow","zoom","proposalsPanel","proposalSelect","proposalDiff"]),Ji=new Set(["bold","italic","underline","strikethrough","fontFamily","fontSize","fontSizeStep","textColor","alignment"]),ea=new Set(["shapeFill","shapeStrokeColor","shapeStrokeWidth","shapeAdjustment","zOrder"]),ta=new Set(["insertSlide","tool"]),na=new Set(["cut","copy","paste","pasteAsPlainText","deleteObject","deleteSlide","duplicateSlide","tableInsert","tableDelete"]);function os(n){if(!n)return null;let r=n.replace(/^#/,"");return /^[0-9a-f]{6}$/i.test(r)?`#${r.toLowerCase()}`:null}function Gt(n){return n===void 0?"mixed":n}function ra(n,r){return `${r+1}. ${n.agentId}${n.note?` \xB7 ${n.note}`:""}`}function ss(n,r){return {id:n.id,label:ra(n,r),stale:n.staleTargets.length>0}}function we(n){return {ok:true,status:n?"executed":"noop"}}var qn={ok:true,status:"opened"};function It(n){let r=n.modelRef.current;return r?.snapshot.slides[r.slideIndex]??null}function $n(n){let r=It(n),s=n.shapeSelectionRef.current;return !r||!s||r.id!==s.slideId?null:f(r.shapes,s.shapeId)}function oa(n){let r=n.handleRef.current,s=n.selectionRef.current,o=s?null:$n(n)?.textStories[0]?.id??null,l=s?.storyId??o;if(!r||!l)return null;try{let m=It(n),x=s&&m?f(m.shapes,s.shapeId):$n(n),h;try{h=m&&x?presentationStoryFormatting(r,{slideId:m.id,shapeId:x.id,storyId:l}):r.story(l);}catch{h=r.story(l);}let P=n.modelRef.current?.frame?.primitives.find(v=>v.kind==="textBox"&&v.storyId===l),c=s?s.anchor:0,p=s?s.focus:h.length,g=Qo(h,P,c,p)??null;if(s&&s.anchor===s.focus){let v=n.textStyleRef.current;return {kind:"caret",bold:v.bold,italic:v.italic,underline:v.underline!=="none",strikethrough:v.strike==="sngStrike"||v.strike==="dblStrike",fontFamily:v.fontFamily,fontSize:v.fontSizePt,color:os(v.color),alignment:g}}let b=s?Yt(h,s.anchor,s.focus,n.baseStyle):Zo(h,n.baseStyle);return {kind:s?"range":"shape",bold:Gt(b.bold),italic:Gt(b.italic),underline:Gt(b.underline),strikethrough:Gt(b.strikethrough),fontFamily:b.fontFamily??null,fontSize:b.fontSize??null,color:os(b.textColor),alignment:g}}catch{return "unsupported"}}function sa(n){let r=It(n),s=$n(n);if(!r||!s)return null;let o=Vo(s),l=r.shapes.findIndex(m=>m.id===s.id);return {formattable:s.kind==="shape",geometry:s.geometry??null,fill:o.fillColor??null,stroke:o.strokeColor??null,strokeWidth:o.strokeWidthPt??null,adjustments:s.adjustValues??{},order:l>=0?{index:l,count:r.shapes.length}:null}}function is(n,r){if(Ji.has(r)){let s=n.selectionRef.current;return JSON.stringify(s?[s.shapeId,s.storyId,s.anchor,s.focus]:n.shapeSelectionRef.current)}return ea.has(r)?JSON.stringify(n.shapeSelectionRef.current):ta.has(r)?It(n)?.id??null:null}function as(n,r){let s=useRef(r);s.current=r;let o=useMemo(()=>{let x=c=>{let p=s.current,g=p.handleRef.current,b=p.status==="ready"&&g!==null,v=It(p),U=p.modelRef.current,T,k,X=[...new Set(U?.snapshot.slides.map(ee=>ee.layoutPartPath)??[])],Y=p.readOnlyRef.current,de=p.proposalsRef.current,z=Y?[]:de.filter(ee=>ee.changes.some(be=>be.slideId===v?.id)),Q=z.find(ee=>ee.id===p.reviewSelectedIdRef.current)??z[0]??null,he=!p.workerMode&&p.reviewEnabledRef.current;return {status:b?"ready":p.status==="ready"?"loading":p.status,readOnly:Y,reviewing:he&&Q!==null,pendingInput:!c&&p.coordinator.busy(),canUndo:b&&g.canUndo(),canRedo:b&&g.canRedo(),slide:v?{id:v.id,layoutPartPath:v.layoutPartPath}:null,layouts:X.map((ee,be)=>({args:{layoutPartPath:ee},label:p.t("toolbar.layoutOption",{number:be+1})})),get text(){return T===void 0&&(T=b?oa(p):null),T},get shape(){return k===void 0&&(k=b?sa(p):null),k},tool:p.activeToolRef.current,zoom:p.zoomRef.current,fontFamilies:o$1,fontSizes:p$2,proposals:p.proposalsAvailable?{open:p.proposalsOpenRef.current,pending:de.map(ss),canvas:{available:z.map(ss),selectedId:Q?.id??null,diff:he}}:null,hostDisabled:ee=>na.has(ee)||!!(p.workerMode&&(p.workerMode.preparing||["exportPng","slideshow","proposalSelect","proposalDiff"].includes(ee))),translate:p.workerMode?(ee,be)=>ee==="commands.reasons.hostDisabled"||ee==="commands.reasons.documentLoading"?p.t(p.workerMode.failed?"worker.failed":p.workerMode.preparing?"worker.preparing":"worker.disabled"):p.t(ee,be):p.t}},h=(c,p)=>({ok:false,failure:j$1(c,p)});return {environment:x,ordered:c=>!rs.has(c),admit(c){return s.current.coordinator.run(c).catch(p=>{throw p instanceof De?new I$1("input-failed"):p instanceof ke?new I$1("document-replaced"):p})},perform:(c,p,g)=>{let{actions:b}=s.current,v=p,U=g.text&&g.text!=="unsupported"?g.text:null,T=k=>{try{return we(k())}catch(X){return b.reportError(X),h("command-failed",g)}};switch(c){case "bold":return T(()=>b.format({bold:U?.bold!==true}));case "italic":return T(()=>b.format({italic:U?.italic!==true}));case "underline":return T(()=>b.format({underline:U?.underline===true?"none":"sng"}));case "strikethrough":return T(()=>b.format({strike:U?.strikethrough===true?"noStrike":"sngStrike"}));case "fontFamily":return T(()=>b.format({fontFamily:v.family}));case "fontSize":return T(()=>b.format({fontSizePt:v.points}));case "fontSizeStep":return T(()=>b.format({fontSizePt:r$1(U?.fontSize??q$1,g.fontSizes,v.direction==="increase"?1:-1)}));case "textColor":return T(()=>b.format({color:v.color}));case "alignment":return T(()=>b.align(v.value));case "insertSlide":return T(()=>b.insertSlide(v.layoutPartPath));case "insertImage":return b.openPicker(),qn;case "tool":return we(b.setTool(v.value));case "shapeFill":return T(()=>b.formatShape({type:"fillColor",value:v.color}));case "shapeStrokeColor":return T(()=>b.formatShape({type:"strokeColor",value:v.color}));case "shapeStrokeWidth":return T(()=>b.formatShape({type:"strokeWidth",value:v.points}));case "shapeAdjustment":return T(()=>b.formatShape({type:"adjust",name:v.name,value:v.value}));case "zOrder":return T(()=>b.formatShape({type:"zOrder",value:v.value}));case "save":return b.save().then(k=>{switch(k){case "saved":return we(true);case "requested":return {ok:true,status:"requested"};case "replaced":return h("document-replaced",g);case "gesture":return h("gesture-active",g);case "input-failed":return h("input-failed",g);default:return h("command-failed",g)}});case "exportPng":return b.exportPng().then(k=>{switch(k){case "exported":return we(true);case "replaced":return h("document-replaced",g);case "input-failed":return h("input-failed",g);default:return h("command-failed",g)}});case "slideshow":return b.present(),qn;case "undo":case "redo":return T(()=>b.history(c));case "zoom":return we(b.setZoom(v.scale));case "proposalsPanel":{let k=p===null?!g.proposals.open:!!v.open;return k===g.proposals.open?we(false):(b.setProposalsOpen(k),k?qn:we(true))}case "proposalSelect":return b.selectProposal(v.proposalId),we(true);case "proposalDiff":return !!v.enabled===g.proposals?.canvas.diff?we(false):(b.showProposalDiff(!!v.enabled),we(true));case "proposalAccept":try{return b.acceptProposal(v.proposalId,!!v.force)==="accepted"?we(!0):h("proposal-stale",g)}catch(k){return b.reportError(k),h("command-failed",g)}case "proposalReject":return T(()=>b.rejectProposal(v.proposalId));default:return h("unsupported-command",g)}},capture(c){let p=s.current;return p.handleRef.current?{id:c,generation:p.generationRef.current,target:p.coordinator.keyboardQueued()?null:is(p,c)}:null},resume(c){let p=s.current,{id:g,generation:b,target:v}=c;return p.handleRef.current?b!==p.generationRef.current?"document-replaced":v!==null&&v!==is(p,g)?"target-changed":g!=="tool"&&!rs.has(g)&&p.gestureActive()?"gesture-active":null:"editor-unavailable"},chrome:()=>({i18n:s.current.i18n}),focusEditor:()=>s.current.actions.focusEditor()}},[]);useLayoutEffect(()=>(n.attach(o),()=>n.detach(o)),[o,n]),useLayoutEffect(()=>{n.refresh();},r.stamp);let{handle:l,handleRef:m}=r;return useEffect(()=>{if(!l||m.current!==l)return;let x=false;return l.onUpdate(()=>{x||(x=true,queueMicrotask(()=>{x=false,n.refresh();}));})},[l,m,n]),useCallback((x,h)=>x$1(x,h,o.environment(true)),[o])}var cs=Object.freeze([]);function ps(n){let r=useRef(n);r.current=n;let s=useRef(null),[o]=useState(()=>O({...n.access,translate:z=>r.current.t(z),geometry:(z=null,Q)=>s.current?.(z,Q)??null})),l=(n.plugins?.length??0)>0,m=a$4(n.locale);useLayoutEffect(()=>{o.localeChanged(m);},[o,m]),useLayoutEffect(()=>{if(!l)return;let z=K(()=>r.current.focusRoot?.current?[r.current.focusRoot.current]:[],Q=>o.focusChanged(Q));return o.setFocusCheck(z.recheck),()=>{o.setFocusCheck(null),z();}},[o,l]),useLayoutEffect(()=>{o.setReporter(n.onPluginError);}),useLayoutEffect(()=>{o.modeChanged(n.readOnly);},[o,n.readOnly]),useLayoutEffect(()=>{o.setGrants(n.pluginGrants);}),useLayoutEffect(()=>{o.setPlugins(n.plugins);},[o,n.plugins]),useEffect(()=>()=>o.close("unmounted"),[o]),useEffect(()=>{if(!(!n.handle||n.access.handle()!==n.handle))return o.open(n.handle),()=>o.close("document-replaced")},[o,n.access,n.handle]),useEffect(()=>{o.syncCommands();let z=o.subscribe(()=>o.syncCommands()),Q=E(n.commands,()=>o.syncCommands());return ()=>{z(),Q();}},[o,n.commands]);let x=useSyncExternalStore(o.subscribe,o.activations,()=>cs);useEffect(()=>{l&&o.selectionChanged(n.selection,{focusLine:n.textSelection?.focusLine});},[o,l,n.selection,n.textSelection?.focusLine]);let h=useRef(null),[P,c]=useState(null),p=useCallback(z=>{h.current=z,z||o.layoutChanged(null),r.current.plugins?.length&&c(z);},[o]);useEffect(()=>{l&&c(h.current);},[l]);let[g,b]=useState(null),[v,U]=useState(0),T=P?.canvas??null;useEffect(()=>{if(!l||!T||!g)return;let z=0,Q=()=>{z||(z=requestAnimationFrame(()=>{z=0,U(be=>be+1);}));},he=typeof ResizeObserver>"u"?null:new ResizeObserver(Q);he?.observe(T),he?.observe(g),n.focusRoot?.current&&he?.observe(n.focusRoot.current),window.addEventListener("resize",Q);let ee=n.focusRoot?.current;return ee?.addEventListener("scroll",Q,{passive:true,capture:true}),()=>{z&&cancelAnimationFrame(z),he?.disconnect(),window.removeEventListener("resize",Q),ee?.removeEventListener("scroll",Q,true);}},[l,T,g,n.focusRoot]);let k=useSyncExternalStore(o.subscribe,o.version,o.version),X=useMemo(()=>l&&!n.reviewing?R(P,k):null,[l,n.reviewing,P,k]),Y=useMemo(()=>X&&P&&g?(z,Q)=>V(X,P,P.canvas,g,()=>!r.current.reviewing&&o.layoutId()===X.id&&h.current===P&&P.canvas.isConnected,(he,ee,be)=>r.current.pointAt(he,ee,be),n.focusRoot?.current??g,()=>z,Q):null,[o,X,P,g,v]);s.current=Y,useEffect(()=>{o.layoutChanged(X);},[o,X]),useEffect(()=>{o.geometryChanged();},[o,Y]);let de=useCallback(()=>{p(null),o.close("document-replaced");},[o,p]);return {host:o,managed:l,activations:l?x:cs,overlayLayerRef:b,beginLoad:de,presentFrame:p}}function Zn(n,r){return (n[r]?.columnOffset??0)-(n[0]?.columnOffset??0)}var fs=new Intl.Segmenter(void 0,{granularity:"word"});function Qn(n,r,s){return s==="word"?ia(n,r):aa(n,r)}function ia(n,r){let s=Jn(n,r),o=[...fs.segment(n)],l=o.find(m=>s>=m.index&&s<m.index+m.segment.length)??o[o.length-1];return l?{start:l.index,end:l.index+l.segment.length}:{start:s,end:s}}function aa(n,r){let s=Jn(n,r),o=n.lastIndexOf(`
2
+ `,Math.max(0,s-1))+1,l=n.indexOf(`
3
+ `,s);return {start:o,end:l===-1?n.length:l}}function ms(n,r){return r.start<n.start?{anchor:n.end,focus:r.start}:r.end>n.end?{anchor:n.start,focus:r.end}:{anchor:n.start,focus:n.end}}function Jn(n,r){return Number.isFinite(r)?Math.max(0,Math.min(n.length,Math.trunc(r))):0}function hs(n,r){return n.shapeId===r.shapeId&&n.position===r.position&&n.lineIndex===r.lineIndex}function er(n,r){let o=n[ft(n,r)]?.caretStops.find(l=>l.position===r.position)?.x;return o===void 0?void 0:o-Zn(n,ft(n,r))}function gs(n,r,s,o){if(n.length===0)return {position:r.position,lineIndex:0};let l=ft(n,r),m=l+(s==="up"?-1:1),x=n[m];if(!x)return {position:r.position,lineIndex:l};let h=o??er(n,r),P=h===void 0?void 0:h+Zn(n,m);return P===void 0?{position:x.start,lineIndex:m}:{position:x.caretStops.reduce((p,g)=>p===null||Math.abs(g.x-P)<Math.abs(p.x-P)?g:p,null)?.position??x.start,lineIndex:m}}function $t(n,r,s){let o=ft(n,r),l=n[o];return l?{position:s==="start"?l.start:l.end,lineIndex:o}:{position:r.position,lineIndex:o}}function xs(n,r,s){let o=Jn(n,r),l=[...fs.segment(n)].filter(x=>x.isWordLike).flatMap(x=>[x.index,x.index+x.segment.length]),m=s<0?l.filter(x=>x<o):l.filter(x=>x>o);return m.length===0?s<0?0:n.length:s<0?Math.max(...m):Math.min(...m)}function ft(n,r){let s=r.lineIndex;if(s!==void 0&&s>=0&&s<n.length&&r.position>=n[s].start&&r.position<=n[s].end)return s;let o=-1;for(let l=0;l<n.length;l+=1){let m=n[l];r.position>=m.start&&r.position<=m.end&&(o=l);}return o===-1?Math.max(0,n.length-1):o}function ys(n,r,s,o,l=()=>false,m=()=>true,x=()=>false){let h=()=>{if(!m()||n.state.stage==="disposed")throw new PptxWorkerEditorDisposedError},P=()=>{if(h(),n.failure)throw n.failure},c=()=>{P();let T=s();if(!n.hydrated||!T)throw new PptxPeerNotReadyError;return T},p=()=>{let T=c();if(l())throw new Error("Finish the pointer gesture before flushing input");return T},g=()=>{let T=c();return x()?{ok:false,version:T.version(),failure:{code:"read-only",message:"The editor is read-only"}}:null},b=async T=>{let k=c();return await r.flushPendingInput(),P(),T(k)},v=K$1(r.commands)?.guarded(P)??Object.fromEntries(Object.keys(r.commands).map(T=>[T,(...k)=>(P(),Reflect.apply(Reflect.get(r.commands,T),r.commands,k))]));return {get handle(){return h(),null},get commands(){return P(),v},get hydrated(){return h(),n.hydrated},get failure(){return h(),n.failure},save:()=>(h(),null),saveAsync:async()=>{p();let T=await n.saveAsync();return P(),T},whenHydrated:async()=>{P(),await n.whenHydrated(),P();},handleAsync:async()=>(P(),await n.whenHydrated(),c()),recoverySave:()=>n.recoverySave(),goToSlideAsync:async T=>(P(),o(T)),version:()=>b(T=>T.version()),readContent:T=>b(k=>k.readContent(T)),findText:T=>b(k=>k.findText(T)),validateEdits:async T=>g()??b(k=>g()??k.validateEdits(T)),applyEdits:async T=>{let k=g();if(k)return k;p();let X=await r.applyEdits(T);return await r.flushPendingInput(),P(),X},flushPendingInput:async()=>{c(),await r.flushPendingInput(),P();},getPositionAtPoint:(T,k)=>(P(),n.hydrated?r.getPositionAtPoint(T,k):null),selectText:T=>(P(),n.hydrated?r.selectText(T):false),goToSlide:T=>(P(),r.goToSlide(T)),clearSelection:()=>{P(),r.clearSelection();},focus:()=>{P(),r.focus();},refresh:()=>{P(),r.refresh();},refreshProposals:()=>{P(),r.refreshProposals();}}}var da={insertText:true,deleteText:true,formatText:true,setStoryParagraphs:true,insertParagraphBreak:true,setParagraphAlignment:true,insertSlide:true,duplicateSlide:true,deleteSlide:true,moveSlide:true,setSlideNotes:true,setSlideLayout:true,addTextBox:true,addShape:true,addPicture:true,removeShape:true,moveShape:true,resizeShape:true,setShapeRect:true,setShapeFill:true,setShapeStroke:true,setShapeAdjust:true,bringShapeToFront:true,sendShapeToBack:true,bringShapeForward:true,sendShapeBackward:true,addComment:true,replyToComment:true,setCommentStatus:true,setCommentPosition:true,removeComment:true,setCommentFlavor:true,propose:true,acceptProposal:true,rejectProposal:true,applyEdits:true,addUndoBoundary:true,undo:true,redo:true};function bs(n){let r=false,s,o=()=>{let h=n.session();if(!h)throw new PptxPeerNotReadyError;if(h.state.stage==="disposed")throw new PptxWorkerEditorDisposedError;if(h.failure)throw h.failure;if(!h.hydrated)throw new PptxPeerNotReadyError;return h},l=h=>{try{return o(),Promise.resolve(h())}catch(P){return Promise.reject(P)}},m=()=>{let h=o();if(n.readOnly?.())throw new I$1("read-only");return h},x=()=>m().apply({method:"addUndoBoundary",args:[]});return {busy:()=>false,keyboardQueued:()=>false,input:h=>l(h),run:l,reset(){r=false,s=void 0;},breakTyping(){s=void 0;},beginTyping(h,P=Date.now()){m(),(!s||s.target!==h||P-s.time>500)&&x(),s={target:h,time:P},r=true;},endTyping(){r=false;},flush(){return l(()=>{if(n.gestureActive())throw new Error("Finish the pointer gesture before flushing input");return o().flush()})},access(h){let P=o(),c=()=>{if(P.state.stage==="disposed"||n.session()!==P)throw new PptxWorkerEditorDisposedError;return o()},p=Object.create(null);for(let g of Reflect.ownKeys(h))Object.defineProperty(p,g,{enumerable:typeof g=="string",get:()=>(c(),typeof g!="string"||!Object.hasOwn(da,g)?Reflect.get(h,g):(...b)=>{let v=c();if(n.readOnly?.()){if(g==="applyEdits")return {ok:false,version:h.version(),failure:{code:"read-only",message:"The editor is read-only"}};throw new I$1("read-only")}!r&&g!=="addUndoBoundary"&&(s=void 0);let U=!r&&!["addUndoBoundary","undo","redo","applyEdits"].includes(g);U&&(s=void 0,x());try{return v.apply({method:g,args:b}).outcome.result}finally{U&&!v.failure&&x(),n.changed?.();}})});return Object.freeze(p)}}}function Ss(n){return n.length>=4&&(n[0]===73&&n[1]===73&&n[2]===42&&n[3]===0||n[0]===77&&n[1]===77&&n[2]===0&&n[3]===42)}function Is(n={}){let r=n.maxDecodedBytes??134217728;if(!Number.isSafeInteger(r)||r<0)throw new Error("invalid decoded image budget");let s=new Map,o=0,l=false,m=c=>{c.retained||c.references||c.closed||!c.source||(c.closed=true,"close"in c.source&&typeof c.source.close=="function"&&c.source.close(),c.source=null);},x=()=>{for(;s.size>25||o>r;){let c=s.entries().next().value;if(!c)break;s.delete(c[0]),o-=c[1].bytes,c[1].retained=false,m(c[1]);}},h=()=>{for(let c of s.values())c.retained=false,m(c);s.clear(),o=0;},P=(c,p,g=false,b)=>{let v=new Map,U=false;return Object.assign(k=>{if(l||U||b&&!b(k))return Promise.resolve(null);let X=v.get(k)??s.get(k);if(X)s.get(k)===X&&(s.delete(k),s.set(k,X));else {let Y=c(k);if(!Y)return Promise.resolve(null);let de={promise:Promise.resolve(null),source:null,references:0,retained:true,closed:false,bytes:0};de.promise=decodePresentationImage(Y,p).catch(z=>{if(g)return null;throw z}).then(z=>{if(de.source=z,z){let Q=z,he=(Q.naturalWidth??Q.width??0)*(Q.naturalHeight??Q.height??0)*4;de.bytes=Number.isSafeInteger(he)&&he>=0?he:r+1,de.retained&&(o+=de.bytes);}return x(),m(de),z}),X=de,s.set(k,X);}return v.has(k)||(v.set(k,X),X.references+=1),x(),X.promise},{release(){if(!U){U=true;for(let k of v.values())k.references-=1,m(k);v.clear();}}})};return {resolve:c=>P(p=>{let g=c.media.get(p);return g&&!Ss(g)?g:void 0},"Unable to decode slide image",true,p=>c.media.has(p)),resolver:(c,p)=>Object.assign(async g=>{let b=P(c,p);try{return await b(g)}finally{b.release();}},{acquire:()=>P(c,p)}),clear:h,dispose(){l=true,h();}}}function tr(n,r){let s=new Map;return new Proxy(n,{get(o,l){let m=Reflect.get(o,l,o);if(typeof m!="function")return m;let x=s.get(l);return x||(x=(...h)=>{if(!r())throw new Error("Paint superseded");return Reflect.apply(m,o,h)},s.set(l,x)),x},set(o,l,m){if(!r())throw new Error("Paint superseded");return Reflect.set(o,l,m,o)}})}var va=12;function Ds(n){let r;return ()=>r??(r=n().catch(s=>{throw r=void 0,s}))}var Es=Ds(()=>import('./chunk-3Y6BQIW3.js').then(n=>n.PresentationOverlay)),Ts=Ds(()=>import('./chunk-UNTN7FU5.js').then(n=>n.ProposalsPanel)),lr=class{constructor(){a$3(this,"frames",new Map);a$3(this,"listeners",new Map);}get(r){return this.frames.get(r)}get size(){return this.frames.size}subscribe(r,s){let o=this.listeners.get(r)??new Set;return this.listeners.set(r,o),o.add(s),()=>{o.delete(s),o.size===0&&this.listeners.delete(r);}}replace(r){let s=this.frames;this.frames=r;for(let[o,l]of s)r.get(o)!==l&&this.notify(o);for(let o of r.keys())s.has(o)||this.notify(o);}add(r){let s=[];for(let[o,l]of r)this.frames.get(o)!==l&&(this.frames.set(o,l),s.push(o));for(let o of s)this.notify(o);}notify(r){this.listeners.get(r)?.forEach(s=>s());}};function Vt(n){return n[Symbol.for("@betteroffice/pptx/slide-layout-cache")]}var Zt="application/vnd.openxmlformats-officedocument.presentationml.presentation";function ba(n,r){return `${(n??"presentation.pptx").replace(/\.pptx$/i,"")}-slide-${r+1}.png`}function wt(n,r,s){let o=new Blob([new Uint8Array(n)],{type:s}),l=URL.createObjectURL(o),m=document.createElement("a");m.href=l,m.download=r,document.body.appendChild(m),m.click(),m.remove(),URL.revokeObjectURL(l);}function Rs(n){return new Promise((r,s)=>{let o=new FileReader;o.onload=()=>r(o.result),o.onerror=()=>s(o.error??new Error("failed to read the file")),o.readAsDataURL(n);})}function Sa(n){return new Promise((r,s)=>{let o=new Image;o.onload=()=>r({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>s(new Error("failed to decode the image")),o.src=n;})}var ks=8*1024*1024,rr={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"},Ia=530,Qt=9,or={bold:false,italic:false,underline:"none",fontSizePt:24,color:"#111827",fontFamily:"Arial"};function nu({file:n$1,fonts:r$1,clientId:s$1,collaboration:o$1,collaborationIdentity:l$1,style:m$1,initialZoom:x$1,loadingIndicator:h$2,onDocumentChange:P,downloadOnSave:c$2,className:p$2,fileName:g$1,initialSlide:b$1,onReady:v$1,onChange:U,onError:T,onSave:k$1,onSaveRequest:X,readOnly:Y=false,toolbar:de,showToolbar:z$1=true,shortcuts:Q,onShortcutIssue:he,i18n:ee,plugins:be,pluginGrants:zs,onPluginError:js,backend:w$1,onWorkerReady:dr}){let{t:j$1,lang:Ks}=d(),tn=j$1("errors.decodeSlideImage"),nn=o$1?.clientId??s$1,rn=o$1?.initialUpdate,Ct=w$1?void 0:o$1?.onReplica,Me=w$1?void 0:o$1?.presence,C$1=useRef(null),D$1=useRef(null),Xe=useRef(0),[Qe]=useState(J),on=Qe.store,Be=useRef(null),ae=useRef(null),cr=useRef(()=>{}),[Ws,sn]=useState(0),pr=useRef(dr);pr.current=dr;let ve=useRef(Y),[G$1]=useState(()=>{if(w$1)return bs({session:()=>ae.current?.current?ae.current.owner:null,gestureActive:()=>!!(B.current||q$1.current),readOnly:()=>ve.current,changed:()=>cr.current()});let e=qo(()=>{e.busy()||(Be.current=null),Qe.refresh();});return e}),Je=useRef(null),an=useRef(null),ln=useRef(()=>null),Et=useCallback(async(e,t)=>{let i=a=>({ok:false,code:"document-replaced",error:new Error(a)});if(C$1.current!==e)return i("Presentation is no longer open");try{return {ok:!0,value:await G$1.run(()=>{if(C$1.current!==e)throw new ke;if(B.current||q$1.current)throw new en;return t()})}}catch(a){if(a instanceof ke)return i("Presentation changed while flushing input");if(a instanceof De)return {ok:false,code:"input-failed",error:a.cause};if(a instanceof en)return {ok:false,code:"input-failed",error:a};throw a}},[G$1]),He=useCallback(async(e,t)=>{let i=await Et(e,t);if(!i.ok)throw i.error;return i.value},[Et]),fr=useCallback(e=>w$1?G$1.flush():He(e,()=>{}),[He,w$1,G$1]),Ye=useCallback(e=>ve.current?{ok:false,version:e.version(),failure:{code:"read-only",message:"The editor is read-only"}}:null,[]),mr=useRef(b$1),hr=useRef(v$1),gr=useRef(U),xr=useRef(P);xr.current=P;let un=useRef(null),dn=useRef(x$1);dn.current=x$1;let yr=useRef(T),cn=useRef(null);a(cn);let xe=useRef(null),Tt=useRef(null),ht=useRef(null),Pr=useRef(null),[Ns,Us]=H$1((be?.length??0)>0),[_s,vr]=useState(false),Ae=useRef(null),q$1=useRef(null),[pn,ye]=useState(null),B=useRef(null),oe=useRef(null),fn=useRef(Is()),Rt=d$1(r$1),et=useMemo(()=>({}),[n$1,Rt,w$1,nn,l$1,rn]),br=a$1(et),mn=useRef(et);mn.current=et;let[E,hn]=useState(null),[Pe]=useState(()=>new lr),gn=useRef(Promise.resolve()),Xs=useCallback(()=>gn.current,[]),[V,J$2,ze]=_(null),[ge,ne,gt]=_(null),[xn,se]=useState(null),[Le,ce]=useState(null),[Ys,Sr,yn]=_(or),[Pn,vn,Ir]=_(b(x$1)),[tt,Ee,wr]=_("select"),[Cr,bn]=useState(null),[nt,Gs]=useState({width:0,height:0}),[kt,Mt]=useState(null),[Sn,xt]=useState(false),[qs,Er]=useState(0),[In,Tr]=useState(null),[wn,$s]=useState(null),[rt,Rr]=useState(null),At=useRef(null),[Ge,Cn]=useState([]),[En,Lt]=useState(false),[Tn,kr]=useState(null),[Ft,Mr]=useState(null);useEffect(()=>{let e=true;return Es().then(t=>{e&&kr(()=>t);},()=>{}),Ts().then(t=>{e&&Mr(()=>t);},()=>{}),()=>{e=false;}},[]);let[Ot,Rn,Vs]=_([]),[Dt,ot,Zs]=_(false),Ar=useRef(null),M$1=$(w$1?null:C$1.current,Y||w$1?[]:Ot,E?.snapshot,E?.slideIndex??0),[Qs,Lr]=useState(null),Js=useCallback(e=>C$1.current.layoutProposalDiffSlideById(M$1.selected.id,e),[M$1.selected,E?.snapshot]),je=useMemo(()=>w$1?Object.assign(e=>ae.current?.resolveImage(e)??Promise.resolve(null),{acquire:()=>{let e=ae.current,t=e?.frame(e.active);return e&&t?e.images.resolve(t):()=>null}}):Fa(C$1,fn,tn),[w$1,tn]);useEffect(()=>{M$1.reviewing&&(J$2(null),ne(null),B.current=null,q$1.current=null,ye(null),se(null),ce(null));},[M$1.reviewing]),useEffect(()=>{Y&&(Ee("select"),ot(false),B.current=null,q$1.current=null,oe.current=null,ye(null),se(null),ce(null));},[Y]),hr.current=v$1;let yt=useRef(null),Ke=useCallback(e=>{let t=yt.current;!t||t.handle!==e||e!==C$1.current||(yt.current=null,t.fire());},[]),kn=useRef(null),Bt=useCallback(()=>{let e=Tt.current;!e||e.getClientRects().length===0||Ke(kn.current);},[Ke]);ve.current=Y,mr.current=b$1,gr.current=U,yr.current=T,D$1.current=E;let st=useRef(M$1.reviewing);st.current=M$1.reviewing;let O=useCallback(e=>{let t=e instanceof Error?e:new Error(String(e));Mt(t.message),t!==ae.current?.owner.failure&&yr.current?.(t);},[]);useEffect(()=>{if(!Dt||Ft)return;let e=true;return Ts().then(t=>{e&&Mr(()=>t);},t=>{e&&(ot(false),O(t));}),()=>{e=false;}},[Dt,Ft,O,ot]);let K=useCallback((e,t=false,i$1=false,a)=>{let u=C$1.current;if(!u)return null;try{Ae.current=null;let d=Vt(u),f$1=i$1?d.snapshot():null,y=f$1?.snapshot??u.snapshot(),I=f$1?.keys??{...D$1.current?.layoutKeys},R=ka(e??D$1.current?.slideIndex??0,y.slides.length);w$1&&ae.current?.show(R+1);let S=new Map,A=y.slides[R]?.id;A&&!i$1&&(I[A]=d.key(R));let N=A&&d.activate(A,I[A]),Z=A&&D$1.current?.layoutKeys[A]===I[A]?Pe.get(A):void 0,le=A?!w$1&&N&&Z||u.layoutSlide(R):null;!w$1&&le&&A&&S.set(A,le);for(let ue=0;ue<y.slides.length;ue+=1){let Oe=y.slides[ue];if(ue===R)continue;let ut=Pe.get(Oe.id),Re=D$1.current?.layoutKeys[Oe.id];!i$1&&(!ut||Re!==I[Oe.id]||Oe.id===a)&&(I[Oe.id]=d.key(ue)),ut&&Re===I[Oe.id]&&S.set(Oe.id,ut);}let fe={snapshot:y,version:u.version(),slideIndex:R,frame:le,layoutKeys:I},Ie=y.slides[R];J$2(ue=>ue&&Ie&&f(Ie.shapes,ue.shapeId)?ue:null),ne(ue=>ue&&Ie?.id===ue.slideId&&f(Ie.shapes,ue.shapeId)?ue:null);let Ne=B.current;Ne&&(!Ie||Ie.id!==Ne.slideId||Ne.kind!=="textBox"&&Ne.kind!=="shapeInsert"&&!f(Ie.shapes,Ne.shapeId))&&(B.current=null,oe.current=null,se(null),ce(null));let Nt=q$1.current;if(Nt&&!i(Ie,Nt)&&(q$1.current=null,ye(null)),D$1.current=fe,w$1||Pe.replace(S),hn(fe),Rn(u.listProposals()),Mt(null),t){if(un.current!==fe.version){un.current=fe.version;try{xr.current?.({version:fe.version});}catch(ue){console.error("documentChange listener threw:",ue);}}gr.current?.(y);}return fe}catch(d){return O(d),null}},[w$1,O,Pe]),Fr=useCallback(()=>{let e=D$1.current!==null&&C$1.current?.version()!==D$1.current.version;K(void 0,e,true);},[K]);cr.current=()=>K(void 0,false);let Ht=useCallback((e,t,i,a=u=>u())=>{let u=i?.()??null;if(u)return u;let d=Ye(e);if(d)return d;let f=a(()=>e.applyEdits(t));return f.ok&&f.applied&&K(void 0,true,true),f},[Ye,K]),zt=useCallback(()=>{w$1&&G$1.breakTyping(),Be.current=null,Ae.current=null,q$1.current=null,B.current=null,oe.current=null,ye(null),J$2(null),ne(null),se(null),ce(null);},[w$1,G$1]),We=useCallback((e,t)=>{zt(),w$1&&ae.current?.show(e+1);let i=K(e);return i&&t&&xe.current?.focus(),i},[w$1,zt,K]),Mn=useCallback(e=>{if(w$1&&!C$1.current)return ae.current?.show(e)??false;let t=D$1.current;return !t||!Number.isInteger(e)||e<1||e>t.snapshot.slides.length?false:We(e-1,true)!==null},[w$1,We]),Or=useCallback(e=>{let t=C$1.current,i=D$1.current;if(!t||!i||!Number.isInteger(e.slide)||!Number.isInteger(e.start)||!Number.isInteger(e.end)||e.start<0||e.end<0)return false;let a=i.snapshot.slides[e.slide-1];if(!(a?f(a.shapes,e.shapeId):null)?.textStories.some(d=>d.id===e.storyId))return false;try{let d=t.story(e.storyId);return e.start>d.length||e.end>d.length||!We(e.slide-1,!1)?!1:(J$2({shapeId:e.shapeId,storyId:e.storyId,anchor:e.start,focus:e.end}),xe.current?.focus(),!0)}catch{return false}},[We]),An=useCallback((e,t,i)=>{let a=D$1.current?.snapshot.slides.findIndex(f=>f.id===e)??-1;if(a<0){!w$1&&i&&(M$1.select(i),M$1.selectSlide(e,i),M$1.setEnabled(true));return}let u=K(a),d=u?.snapshot.slides[u.slideIndex];J$2(null),ne(t&&d&&f(d.shapes,t)?{slideId:e,shapeId:t}:null),w$1||(i&&M$1.select(i),M$1.setEnabled(true));},[w$1,K,M$1.select,M$1.selectSlide,M$1.setEnabled]),it=useCallback(()=>{try{Rn(C$1.current?.listProposals()??[]);}catch(e){O(e);}},[O]),ei=useCallback((e,t)=>{let i=C$1.current;if(!i)throw new Error("Presentation is no longer open");try{return i.acceptProposal(e,{force:t}),K(void 0,!0,!0),"accepted"}catch(a){if(it(),a instanceof StaleProposalError)return "stale";throw a}},[K,it]),ti=useCallback(e=>{let t=C$1.current?.rejectProposal(e)??false;return it(),t},[it]),Dr={goToSlide(e,t,i){let a=sr(e,t?.slideId);return a?We(a.index,i)?null:"layout-unavailable":"missing-target"},selectShape(e,t,i){let a=sr(e,t?.slideId);return !a||!f(a.slide.shapes,t.shapeId)?"missing-target":st.current?"unsupported":We(a.index,false)?(ne({slideId:a.slide.id,shapeId:t.shapeId}),i&&xe.current?.focus(),null):"layout-unavailable"},selectText(e,t,i){let a=sr(e,t?.slideId),u=a?f(a.slide.shapes,t.shapeId):null;if(!a||!u?.textStories.some(I=>I.id===t.storyId))return "missing-target";let{anchor:d,focus:f$1}=t;if(!Number.isInteger(d)||!Number.isInteger(f$1)||d<0||f$1<0)return "missing-target";let y=e.story(t.storyId).length;return d>y||f$1>y?"missing-target":st.current?"unsupported":We(a.index,false)?(J$2({shapeId:u.id,storyId:t.storyId,anchor:d,focus:f$1}),i&&xe.current?.focus(),null):"layout-unavailable"}},qe=useRef({admit:Et,applyBatch:Ht,readOnlyRefusal:Ye,pluginNavigator:Dr});qe.current={admit:Et,applyBatch:Ht,readOnlyRefusal:Ye,pluginNavigator:Dr};let[ni]=useState(()=>({handle:()=>C$1.current,admit:(e,t)=>qe.current.admit(e,t),readOnlyRefusal:e=>qe.current.readOnlyRefusal(e),applyEdits:(e,t,i,a)=>qe.current.applyBatch(e,t,i,a),commands:()=>Qe,navigator:{goToSlide:(...e)=>qe.current.pluginNavigator.goToSlide(...e),selectShape:(...e)=>qe.current.pluginNavigator.selectShape(...e),selectText:(...e)=>qe.current.pluginNavigator.selectText(...e)}})),[ri,jt]=useState(null),oi=useMemo(()=>{let e=E?.snapshot.slides[E.slideIndex];if(!E||!e)return null;let t={slideId:e.id,slide:E.slideIndex+1};if(V){let{shapeId:i,storyId:a,anchor:u,focus:d}=V;return {...t,target:{kind:"text",shapeId:i,storyId:a,anchor:u,focus:d}}}return ge?.slideId===e.id?{...t,target:{kind:"shape",shapeId:ge.shapeId}}:{...t,target:{kind:"slide"}}},[E,V,ge]),Fe=ps({locale:Ks,focusRoot:xe,plugins:be,pluginGrants:zs,onPluginError:js,access:ni,commands:Qe,readOnly:Y,handle:ri,reviewing:M$1.reviewing,selection:oi,textSelection:V,pointAt:(e,t,i)=>(w$1?ae.current?.frame(ae.current.active)?.displayList===e:D$1.current?.frame===e)?ln.current(t,i):null,t:j$1}),Br=Fe.beginLoad,Ln=Fe.presentFrame;useEffect(()=>{let e=ae.current;if(!w$1||!e?.current)return;if(e.owner.failure){Mt(e.owner.failure.message),jt(null),C$1.current=null;return}if(e.access&&C$1.current)(D$1.current?.version!==e.owner.state.version||D$1.current?.slideIndex!==e.active)&&K(e.active);else {let i=e.snapshot(),a=e.frame(e.active)?.displayList??null;if(i&&(D$1.current?.version!==e.owner.state.version||D$1.current?.slideIndex!==e.active||D$1.current?.frame!==a)){let u={snapshot:i,frame:a,slideIndex:e.active,version:e.owner.state.version??"",layoutKeys:{}};D$1.current=u,hn(u);}}let t=new Map;e.owner.state.projection?.slides.forEach((i,a)=>{let u=e.frame(a);u&&t.set(i.id,u.displayList);}),Pe.replace(t);},[w$1,Ws,K,Pe]),useEffect(()=>{let e=false,t=null,i=[],a=()=>{};if(Br(),jt(null),w$1||C$1.current?.dispose(),C$1.current=null,Xe.current+=1,un.current=null,dn.current!==void 0&&vn(b(dn.current)),G$1.reset(),Be.current=null,Rr(null),D$1.current=null,hn(null),Pe.replace(new Map),J$2(null),ne(null),se(null),ce(null),ye(null),Ee("select"),Lt(false),Rn([]),ot(false),B.current=null,q$1.current=null,Ae.current=null,oe.current=null,Mt(null),Tr(null),Je.current=null,fn.current.clear(),!n$1)return;xt(true);let u=null;if(w$1)try{u=w$1(()=>{e||sn(d=>d+1);}),ae.current=u,sn(d=>d+1),u.request();}catch(d){xt(false),Tr(d instanceof Error?d:new Error(String(d))),O(d);return}return (u?u.open(G$1).then(()=>[void 0,[]]):Promise.all([initWasm(),c(Rt,()=>!e&&mn.current===et,br)])).then(([,d])=>{if(i=d,e||mn.current!==et){Ms(i);return}try{t=u?u.access:openPresentation(n$1,{clientId:nn,fonts:Rt,initialUpdate:rn}),!u&&o$1&&t.setCollaborative(),C$1.current=t,a=t.onUpdate((S,A)=>{A==="remote"&&K(void 0,!0,!0);});let f=mr.current,y=K(u?u.active:typeof f=="number"&&Number.isInteger(f)?f-1:0,!1,!0);xt(!1),u||Rr(t),u&&jt(t);let I=t,R={clearSelection:zt,commands:on,goToSlide:Mn,handle:I,refresh:Fr,refreshProposals:it,flushPendingInput:()=>fr(I),getPositionAtPoint:(S,A)=>C$1.current===I?ln.current(S,A):null,save:()=>{if(C$1.current!==I)throw new Error("Presentation is no longer open");if(G$1.busy()||B.current||q$1.current)throw new Error("Await flushPendingInput before saving pending input");return I.save()},selectText:Or,focus:()=>xe.current?.focus(),version:()=>He(I,()=>I.version()),readContent:S=>He(I,()=>I.readContent(S)),findText:S=>He(I,()=>I.findText(S)),validateEdits:S=>He(I,()=>Ye(I)??I.validateEdits(S)),applyEdits:async S=>{let A=Ye(I);return A||He(I,()=>Ht(I,S))}};if(u){let S=u,A=ys(S.owner,R,()=>S.access,async N=>S.show(N)?(We(N-1,!1),S.showAsync(N)):!1,()=>!!(B.current||q$1.current),()=>S.current,()=>ve.current);S.onFirstPaint=()=>pr.current?.(A),sn(N=>N+1);}else yt.current={handle:I,fire:()=>{if(!(e||C$1.current!==I)){try{hr.current?.(R);}catch(S){O(S);return}jt(I);}}},y||Ke(I);}catch(f){xt(false),O(f);}},d=>{e||(xt(false),u?.owner.failure||O(d));}),()=>{if(e=true,yt.current?.handle===t&&(yt.current=null),a(),u){let d=u;d.owner.state.sequence>0&&$s({save:()=>d.owner.recoverySave(),name:`previous-${g$1??"presentation.pptx"}`}),u.dispose();}else At.current?.handle!==t&&t?.dispose();ae.current===u&&(ae.current=null),C$1.current===t&&(C$1.current=null),fn.current.clear(),Ms(i);}},[w$1,He,Ht,Br,nn,l$1,rn,zt,on,G$1,n$1,fr,Mn,Rt,et,br,Fr,Ye,K,Ke,O,Or,Ee,J$2,ne,Pe]),useLayoutEffect(()=>{if(!Ct||!rt)return;let e={handle:rt};return At.current=e,Ct(rt),()=>{Ct(null),queueMicrotask(()=>{C$1.current!==rt&&rt.dispose(),At.current===e&&(At.current=null);});}},[Ct,rt]),useEffect(()=>bn(null),[tt]),useEffect(()=>{if(!Me){Cn([]);return}return Cn(Me.peers),Me.onPresence(Cn)},[Me]),useEffect(()=>{let e=Tt.current;if(!e)return;let t=()=>Gs({width:e.clientWidth,height:e.clientHeight});t();let i=new ResizeObserver(t);return i.observe(e),()=>i.disconnect()},[]);let si=useMemo(()=>!E?.frame||nt.width<=0||nt.height<=0?1:Math.min((nt.width-40)/E.frame.width,(nt.height-40)/E.frame.height,1),[E?.frame,nt]),W$1=Pn==="fit"?si:Pn;ha(Tt,ht,W$1,vn,n$1);let $$1=w$1?ae.current:null,Te=$$1?.frame($$1.active),Kt=$$1?.navigation,ii=$$1?.owner.state.sequence,ai=!w$1||$$1?.overlays;useEffect(()=>{let e=ht.current,t=E,i=w$1?Te?.displayList:t?.frame,a=C$1.current;if(!w$1&&t&&!i&&Ke(a),!e||!t||!i||w$1&&(!$$1||!Te||!$$1.currentPaint(Te,Kt)))return;let u=e.getContext("2d");if(!u){w$1||Ke(a);return}let d=window.devicePixelRatio||1;Ln(null),kn.current=null,sizeCanvasForSlide(e,i,d,W$1);let f=false,y=$$1&&Te?$$1.images.resolve(Te):null,I=()=>!f&&(!$$1||!!Te&&$$1.currentPaint(Te,Kt)),R=paintSlide(w$1?tr(u,I):Bs(u,I),i,d,W$1,{resolveImage:y??je}).then(()=>{if(!I())return;let{snapshot:S,slideIndex:A,version:N}=t;Ln({frame:i,snapshot:S,slideIndex:A,version:N,scale:W$1,canvas:e}),$$1&&Te&&$$1.didPaint(Te,Kt),w$1||(kn.current=a,Bt());},S=>{I()&&(O(S),w$1||Ke(a));});return gn.current=y?R.finally(()=>y.release()):R,()=>{f=true;}},[w$1,$$1,Te,Kt,ii,tn,E?.frame,E?.snapshot,E?.slideIndex,E?.version,Ln,Ke,Bt,O,je,W$1]),useEffect(()=>{w$1||Bt();},[w$1,nt,Bt]),useEffect(()=>{if(w$1)return;let e=C$1.current,t=E;if(!e||!t||Pe.size===t.snapshot.slides.length)return;let i=false,a,u=0,d=()=>{let f=D$1.current;if(i||C$1.current!==e||!f||f.layoutKeys!==t.layoutKeys||e.version()!==f.version)return;let y=performance.now(),I=new Map,R;try{try{for(;u<f.snapshot.slides.length;){let S=u++,A=f.snapshot.slides[S].id;if(!Pe.get(A)&&(I.set(A,e.layoutSlide(S)),performance.now()-y>=va))break}}finally{let S=f.snapshot.slides[f.slideIndex]?.id;S&&Vt(e).activate(S,f.layoutKeys[S]);}}catch(S){R={value:S};}if(Pe.add(I),R){O(R.value);return}u<f.snapshot.slides.length&&Pe.size<f.snapshot.slides.length&&(a=setTimeout(d,0));};return gn.current.then(()=>{i||(a=setTimeout(d,0));}),()=>{i=true,a!==void 0&&clearTimeout(a);}},[w$1,E?.layoutKeys,O,Pe]);let Se=useMemo(()=>{if(!E?.frame||!ge)return null;let e=E.snapshot.slides[E.slideIndex];return !e||e.id!==ge.slideId?null:f(e.shapes,ge.shapeId)},[E,ge]),$e=useMemo(()=>E?.frame&&Se?n(E.snapshot,E.frame,Se):null,[E,Se]),Pt=useMemo(()=>{if(!E?.frame||!V||$e)return null;let e=E.snapshot.slides[E.slideIndex],t=e?f(e.shapes,V.shapeId):null;return t?n(E.snapshot,E.frame,t):null},[E,$e,V]),pe=E?.snapshot.slides[E.slideIndex],at=pe?.id,Fn=useMemo(()=>{if(pe){if(ge?.slideId===pe.id)return ge.shapeId;if(V)return h(pe,V.shapeId)?.id}},[pe,V,ge]);useEffect(()=>{Me&&Me.setCursor(at?{slideId:at,...Fn?{shapeId:Fn}:{}}:null);},[Me,at,Fn]),useEffect(()=>()=>{Me?.setCursor(null);},[Me]);let vt=useMemo(()=>ea$1(Ge),[Ge]),On=useMemo(()=>{if(!E?.frame||!pe)return {visible:[],overflow:0};let e=g(pe.shapes),t=ga(Ge,pe.id,e),i=[],a=t.overflow;for(let u of t.visible){let d=e.get(u.shapeId);if(!d)continue;let f=n(E.snapshot,E.frame,d);f?i.push({peer:u.peer,peerCount:u.count,shapeId:u.shapeId,bounds:f}):a+=u.count;}return {visible:i,overflow:a}},[pe,E,Ge]),li=useMemo(()=>{let e=new Set(E?.snapshot.slides.map(t=>t.id));return fa(Ge,e)},[E,Ge]);useEffect(()=>{let e=C$1.current;if(!(!e||!V))try{let t=D$1.current,i=t?.snapshot.slides[t.slideIndex],a;try{a=i?presentationStoryFormatting(e,{slideId:i.id,shapeId:V.shapeId,storyId:V.storyId}):e.story(V.storyId);}catch{a=e.story(V.storyId);}Sr(Jo(a,V.anchor,V.focus,or));}catch(t){O(t);}},[E,O,V]);let ui=e=>{Mn(e+1);},di=(e,t,i)=>{let a=C$1.current,u=D$1.current;if(!a||!u?.frame||ve.current)return;let d=u.snapshot.slides.find(A=>A.id===e);if(!d)return;let f=Math.abs(i.x-t.x)>=6||Math.abs(i.y-t.y)>=6,y=f?Math.abs(i.x-t.x):u.frame.width*.36,I=f?Math.abs(i.y-t.y):u.frame.height*.12,R=Math.max(0,Math.min(f?Math.min(t.x,i.x):t.x,u.frame.width-y)),S=Math.max(0,Math.min(f?Math.min(t.y,i.y):t.y,u.frame.height-I));try{let A=a.addTextBox(d.id,{name:j$1("objects.defaultTextBoxName"),rect:{x:Math.round(R*u.snapshot.widthEmu/u.frame.width),y:Math.round(S*u.snapshot.heightEmu/u.frame.height),width:Math.round(Math.max(12,y)*u.snapshot.widthEmu/u.frame.width),height:Math.round(Math.max(12,I)*u.snapshot.heightEmu/u.frame.height)},text:"",style:yn.current}),N=K(void 0,!0,!1,d.id);Ee("select"),se(null),ce(null),B.current=null,oe.current=null;let Z=N?.snapshot.slides[N.slideIndex]?.shapes.find(fe=>fe.id===A.shapeId);Z&&ne(null);let le=Z?.textStories[0];le&&(J$2({shapeId:Z.id,storyId:le.id,anchor:0,focus:0,focusLine:0}),xe.current?.focus());}catch(A){throw O(A),A}},ci=(e,t,i,a)=>{let u=C$1.current,d=D$1.current;if(!u||!d?.frame||ve.current)return;let f=d.snapshot.slides.find(Z=>Z.id===e),y=h$1.find(Z=>Z.geometry===t);if(!f||!y)return;let I=Math.abs(a.x-i.x)>=6||Math.abs(a.y-i.y)>=6,R=I?Math.abs(a.x-i.x):d.frame.width*.22,S=I?Math.abs(a.y-i.y):d.frame.height*.18,A=Math.max(0,Math.min(I?Math.min(i.x,a.x):i.x-R/2,d.frame.width-R)),N=Math.max(0,Math.min(I?Math.min(i.y,a.y):i.y-S/2,d.frame.height-S));try{let Z=u.addShape(f.id,{name:j$1(y.labelKey),geometry:t,rect:{x:Math.round(A*d.snapshot.widthEmu/d.frame.width),y:Math.round(N*d.snapshot.heightEmu/d.frame.height),width:Math.round(Math.max(12,R)*d.snapshot.widthEmu/d.frame.width),height:Math.round(Math.max(12,S)*d.snapshot.heightEmu/d.frame.height)},fill:"#d9eaf7"}),le=K(void 0,!0,!1,f.id);Ee("select"),se(null),ce(null),B.current=null,oe.current=null,le?.snapshot.slides[le.slideIndex]?.id===f.id&&(J$2(null),ne({slideId:f.id,shapeId:Z.shapeId}),xe.current?.focus());}catch(Z){throw O(Z),Z}},pi=async(e,t)=>{let{handle:i}=t,a=()=>C$1.current===i&&Xe.current===t.generation&&zi("insertImage").enabled;try{if(e.size>ks)throw new Error(`image is ${e.size} bytes, exceeds the ${ks}-byte limit`);let u=e.name.split(".").pop()?.toLowerCase()??"",d=e.type==="image/jpg"?"image/jpeg":e.type||rr[u];if(!Object.values(rr).includes(d))throw new Error(`unsupported image type ${e.type||u}`);let f=await Rs(e),y=f.slice(f.indexOf(",")+1),I=`data:${d};base64,${y}`;if(d==="image/tiff"){let Re=Uint8Array.from(atob(y),Wi=>Wi.charCodeAt(0));I=await Rs(presentationImageBlob(Re));}let R=await Sa(I),S=D$1.current;if(!a()||!S?.frame){if(w$1)throw new Error("The presentation changed before the image was inserted");return}if(R.width<=0||R.height<=0)throw new Error("image dimensions must be positive");let A=S.snapshot.slides.findIndex(Re=>Re.id===t.slideId),N=S.snapshot.slides[A];if(!N){if(w$1)throw new Error("The image target slide no longer exists");return}let Z=S.frame.width*.5,le=S.frame.height*.5,fe=Math.min(Z/R.width,le/R.height,1),Ie=Math.max(1,R.width*fe),Ne=Math.max(1,R.height*fe),Nt=(S.frame.width-Ie)/2,ue=(S.frame.height-Ne)/2,Oe=i.addPicture(N.id,{name:e.name||j$1("objects.defaultPictureName"),rect:{x:Math.round(Nt*S.snapshot.widthEmu/S.frame.width),y:Math.round(ue*S.snapshot.heightEmu/S.frame.height),width:Math.round(Ie*S.snapshot.widthEmu/S.frame.width),height:Math.round(Ne*S.snapshot.heightEmu/S.frame.height)},contentType:d,mediaBase64:y}),ut=K(void 0,!0,!1,N.id);if(Ee("select"),se(null),ce(null),B.current=null,oe.current=null,ut&&A===ut.slideIndex){J$2(null),ne({slideId:N.id,shapeId:Oe.shapeId});let Re=document.activeElement;(!Re||Re===document.body||xe.current?.contains(Re))&&xe.current?.focus();}}catch(u){throw (w$1||a())&&O(u),u}},Hr=()=>{let e=C$1.current,t=D$1.current;return e?{handle:e,generation:Xe.current,slideId:t?.snapshot.slides[t.slideIndex]?.id??null}:null},fi=e=>{let t=an.current??Hr();if(an.current=null,!t||t.handle!==C$1.current||t.generation!==Xe.current){w$1&&O(new Error("The presentation changed before the image was inserted"));return}w$1&&Er(i=>i+1),G$1.input(()=>pi(e,t)).catch(()=>{}).finally(()=>{w$1&&Er(i=>i-1);});},mi=e$1=>{if(w$1){if(!ae.current?.hydrated){O(new PptxPeerNotReadyError);return}G$1.breakTyping();}if(!e$1.isPrimary||e$1.button!==0)return;Be.current=null;let t=C$1.current,i=D$1.current;if(!t||!i?.frame)return;let a=e(e$1.currentTarget.getBoundingClientRect(),i.frame,e$1.clientX,e$1.clientY);if(!a)return;Ae.current=null,q$1.current=null,ye(null);let u=i.snapshot.slides[i.slideIndex],d=i$1(tt);if(!Y&&(tt==="textBox"||d)&&u){J$2(null),ne(null),se(null),ce({start:a,end:a}),oe.current=null,B.current=d?{kind:"shapeInsert",pointerId:e$1.pointerId,slideId:u.id,geometry:d,start:a,last:a}:{kind:"textBox",pointerId:e$1.pointerId,slideId:u.id,start:a,last:a},e$1.currentTarget.setPointerCapture(e$1.pointerId),xe.current?.focus(),e$1.preventDefault();return}try{let f=u?Vt(t).hitTest(u.id,a.x,a.y):null,y=f?.kind==="text"&&x(i.frame,a,W$1)==="shape"?{kind:"shape",shapeId:f.shapeId}:f,I=u&&y?h(u,y.shapeId):null,R=oe.current,S=!!(u&&I&&R?.slideId===u.id&&R.shapeId===I.id&&e$1.timeStamp-R.timeStamp<=600&&Math.hypot(e$1.clientX-R.clientX,e$1.clientY-R.clientY)<=6),A=S&&R?Math.min(R.count+1,3):1,N=y?.kind==="text"?o(i.frame,y.shapeId,y.storyId,a):null;if(oe.current=null,u&&y?.kind==="text"&&I&&A>=2){let Z=t.story(y.storyId),le=A>=3?"paragraph":"word",fe=Qn(mt(Z),y.position,le);J$2({shapeId:y.shapeId,storyId:y.storyId,anchor:fe.start,focus:fe.end,focusLine:N?.lineIndex}),ne(null),se(null),B.current={kind:"text",pointerId:e$1.pointerId,slideId:u.id,shapeId:y.shapeId,storyId:y.storyId,anchor:fe.start,focus:fe.end,focusLine:N?.lineIndex,granularity:le,clickCount:A,clickShapeId:I.id,startClientX:e$1.clientX,startClientY:e$1.clientY,dragging:!1},e$1.currentTarget.setPointerCapture(e$1.pointerId);}else if(u&&V&&y?.kind==="text"&&y.shapeId===V.shapeId&&y.storyId===V.storyId){t.story(y.storyId);let Z=e$1.shiftKey?V.anchor:y.position;J$2({shapeId:y.shapeId,storyId:y.storyId,anchor:Z,focus:y.position,focusLine:N?.lineIndex}),ne(null),se(null),B.current={kind:"text",pointerId:e$1.pointerId,slideId:u.id,shapeId:y.shapeId,storyId:y.storyId,anchor:Z,focus:y.position,focusLine:N?.lineIndex,granularity:"character",clickCount:A,clickShapeId:I?.id??y.shapeId,startClientX:e$1.clientX,startClientY:e$1.clientY,dragging:!1},e$1.currentTarget.setPointerCapture(e$1.pointerId);}else u&&y?I?(J$2(null),ne({slideId:u.id,shapeId:I.id}),se(null),!Y&&l(I)?(B.current={kind:"shape",pointerId:e$1.pointerId,slideId:u.id,shapeId:I.id,startClientX:e$1.clientX,startClientY:e$1.clientY,start:a,last:a,dragThreshold:S?8:4,clickCount:A,dragging:!1},e$1.currentTarget.setPointerCapture(e$1.pointerId)):B.current=null):(J$2(null),ne(null),oe.current=null,B.current=null):(J$2(null),ne(null),se(null),oe.current=null,B.current=null);xe.current?.focus(),e$1.preventDefault();}catch(f){O(f);}},zr=e$1=>{let t=B.current,i=C$1.current,a=D$1.current;if(!t||t.pointerId!==e$1.pointerId||!i||!a?.frame)return false;let u=e(e$1.currentTarget.getBoundingClientRect(),a.frame,e$1.clientX,e$1.clientY);if(!u||a.snapshot.slides[a.slideIndex]?.id!==t.slideId)return false;if(t.kind==="text"){!t.dragging&&q(t.startClientX,t.startClientY,e$1.clientX,e$1.clientY)&&(t.dragging=true);let d=o(a.frame,t.shapeId,t.storyId,u);if(d){let f=t.granularity==="character"?{anchor:t.anchor,focus:d.position}:ms({start:t.anchor,end:t.focus},Qn(mt(i.story(t.storyId)),d.position,t.granularity));J$2({shapeId:t.shapeId,storyId:t.storyId,...f,focusLine:d.lineIndex});}}else t.kind==="shape"?(t.last=u,!t.dragging&&q(t.startClientX,t.startClientY,e$1.clientX,e$1.clientY,t.dragThreshold)&&(t.dragging=true),t.dragging&&se({shapeId:t.shapeId,delta:{x:u.x-t.start.x,y:u.y-t.start.y}})):(t.last=u,ce({start:t.start,end:u}));return true},hi=e$1=>{if(zr(e$1)){e$1.preventDefault();return}if(B.current||tt!=="select")return;let t=D$1.current;if(!t?.frame)return;let i=e(e$1.currentTarget.getBoundingClientRect(),t.frame,e$1.clientX,e$1.clientY);bn(i?x(t.frame,i,W$1):null);},gi=()=>{B.current||bn(null);},xi=e=>{zr(e);let t=B.current;if(!(!t||t.pointerId!==e.pointerId)){if(B.current=null,se(null),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t.kind==="textBox"){ce(null),G$1.input(()=>di(t.slideId,t.start,t.last)).catch(()=>{}),e.preventDefault();return}if(t.kind==="shapeInsert"){ce(null),G$1.input(()=>ci(t.slideId,t.geometry,t.start,t.last)).catch(()=>{}),e.preventDefault();return}if(t.kind==="text"){oe.current=t.dragging?null:{slideId:t.slideId,shapeId:t.clickShapeId,clientX:e.clientX,clientY:e.clientY,timeStamp:e.timeStamp,count:t.clickCount};return}if(t.kind==="shape"){if(!t.dragging){oe.current={slideId:t.slideId,shapeId:t.shapeId,clientX:e.clientX,clientY:e.clientY,timeStamp:e.timeStamp,count:t.clickCount};return}oe.current=null,e.preventDefault(),G$1.input(()=>yi(t)).catch(()=>{});}}},yi=e=>{let t=C$1.current,i=D$1.current,a=i?.snapshot.slides[i.slideIndex];if(!t||!i?.frame||a?.id!==e.slideId||ve.current)return;let u=f(a.shapes,e.shapeId);if(u)try{let d=k(u),f=p$1(i.snapshot,i.frame,u,{x:e.last.x-e.start.x,y:e.last.y-e.start.y});d&&f&&(f.x!==d.x||f.y!==d.y)&&(t.moveShape(a.id,u.id,f.x,f.y),K(void 0,!0)),ne({slideId:a.id,shapeId:u.id});}catch(d){throw O(d),d}},Pi=e=>{let t=C$1.current;if(!(!t||ve.current))try{t.removeShape(e.slideId,e.shapeId),ne(null),se(null),B.current=null,q$1.current=null,ye(null),K(void 0,!0);}catch(i){throw O(i),i}},jr=e=>{B.current?.pointerId===e.pointerId&&(B.current=null,se(null),ce(null),oe.current=null);},vi=e=>{if(ve.current)return ze.current;let t=e?{...e,focusLine:void 0}:null;return J$2(t),ne(null),oe.current=null,K(void 0,true),t},bi=e=>{if(w$1&&!ae.current?.hydrated){Ls(e)&&(e.preventDefault(),O(new PptxPeerNotReadyError));return}if(!C$1.current||C(e.nativeEvent)||D(e.target))return;if(e.key==="Escape"){M$1.setEnabled(false),Ee("select"),ce(null),B.current=null,q$1.current=null,ye(null),e.preventDefault();return}if((e.key==="Backspace"||e.key==="Delete")&&!ve.current&&!st.current&&ze.current===null&&gt.current){let d=gt.current;e.preventDefault(),G$1.input(()=>Pi(d)).catch(()=>{});return}let t={key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey},i=G$1.busy(),a=i?Be.current:null;if(!(!(a?a.selection!==null:ze.current!==null)||st.current||!Ls(t))){if(i){if(e.preventDefault(),!Be.current){let f=ze.current;Be.current={selection:f?Kr(f):null};}let d=Be.current;G$1.input(()=>Si(t,d),"keyboard").catch(()=>{});return}Wr(t,ze.current).handled&&e.preventDefault();}},Kr=e=>{let t=C$1.current;if(!t)return null;try{return {shapeId:e.shapeId,storyId:e.storyId,anchor:t.anchorCaret(e.storyId,e.anchor),focus:t.anchorCaret(e.storyId,e.focus)}}catch{return null}},Si=(e,t)=>{let i=t.selection;if(!i)return;let a=C$1.current;if(!a)throw new Error("Presentation is no longer open");let u;try{let f=a.resolveCaretAnchor(i.anchor),y=a.resolveCaretAnchor(i.focus);if(f===null||y===null)throw new Error("The text changed before the typed input was applied");u={shapeId:i.shapeId,storyId:i.storyId,anchor:f,focus:y};}catch(f){throw O(f),f}let d=Wr(e,u,true).selection;t.selection=d?Kr(d):null;},Wr=(e,t,i=false)=>{let a=C$1.current,u={handled:false,selection:t};if(!a||st.current)return u;let d=Math.min(t.anchor,t.focus),f=Math.max(t.anchor,t.focus),y=I=>({handled:true,selection:vi(I)});try{let I=wi(e,t);if(I!==null){w$1&&G$1.breakTyping();let R={...t,anchor:e.shiftKey?t.anchor:I.position,focus:I.position,focusLine:I.lineIndex};return J$2(R),{handled:!0,selection:R}}if(ve.current)return u;if(w$1&&G$1.beginTyping(t.storyId),e.key==="Backspace"){if(d!==f)return a.deleteText(t.storyId,d,f),y({...t,anchor:d,focus:d});let R=Aa(a.story(t.storyId),d);return R<d?(a.deleteText(t.storyId,R,d),y({...t,anchor:R,focus:R})):{handled:!0,selection:t}}if(e.key==="Delete"){if(d!==f)return a.deleteText(t.storyId,d,f),y({...t,anchor:d,focus:d});let R=La(a.story(t.storyId),f);return R>f?(a.deleteText(t.storyId,f,R),y({...t,anchor:f,focus:f})):{handled:!0,selection:t}}if(e.key==="Enter")return d!==f&&a.deleteText(t.storyId,d,f),a.insertParagraphBreak(t.storyId,d),y({...t,anchor:d+1,focus:d+1});if(Hs(e)){d!==f&&a.deleteText(t.storyId,d,f),a.insertText(t.storyId,d,e.key,es(yn.current));let R=d+e.key.length;return y({...t,anchor:R,focus:R})}return u}catch(I){if(O(I),i)throw I;return {handled:true,selection:t}}finally{w$1&&G$1.endTyping();}},Dn=()=>{let e=D$1.current,t=gt.current,i=e?.snapshot.slides[e.slideIndex];return i&&t&&i.id===t.slideId?f(i.shapes,t.shapeId):null},Ii=e=>{let t=C$1.current,i=ze.current,a=i?null:Dn()?.textStories[0]?.id??null;if(!t||!i&&!a)return false;if(Sr(u=>({...u,...e,...e.strike==="noStrike"?{strike:void 0}:{}})),i){if(i.anchor===i.focus)return true;t.formatText(i.storyId,Math.min(i.anchor,i.focus),Math.max(i.anchor,i.focus),e);}else Ma(t,t.story(a),e);return K(void 0,true),true},wi=(e,t)=>{let i=C$1.current;if(!i)return null;let a=i.story(t.storyId),u=Math.max(0,a.length-1),d=S=>Math.max(0,Math.min(u,S)),f=Oa(D$1.current?.frame,t),y={position:t.focus,lineIndex:t.focusLine},I=e.altKey||e.ctrlKey&&!e.metaKey,R=e.metaKey;if(e.key==="ArrowUp"||e.key==="ArrowDown"){let S={shapeId:t.shapeId,...y},A=Ae.current&&hs(Ae.current,S)?Ae.current.goalX:er(f,y),N=e.key==="ArrowUp"?"up":"down",Z=gs(f,y,N,A),le={...Z,position:d(Z.position)};return Ae.current=A===void 0?null:{shapeId:t.shapeId,goalX:A,position:le.position,lineIndex:le.lineIndex},le}if(Ae.current=null,e.key==="ArrowLeft"||e.key==="ArrowRight"){let S=e.key==="ArrowLeft"?-1:1;if(R){let N=$t(f,y,S<0?"start":"end");return {...N,position:d(N.position)}}let A=I?xs(mt(a),t.focus,S):t.focus+S;return {position:d(A),lineIndex:t.focusLine}}if(e.key==="Home"){if(R||e.ctrlKey)return {position:0,lineIndex:0};let S=$t(f,y,"start");return {...S,position:d(S.position)}}if(e.key==="End"){if(R||e.ctrlKey)return {position:u,lineIndex:Math.max(0,f.length-1)};let S=$t(f,y,"end");return {...S,position:d(S.position)}}return null},Ci=e=>{let t=C$1.current,i=ze.current,a=i?.storyId??Dn()?.textStories[0]?.id;return !t||!a?false:(i?t.setParagraphAlignment(a,Math.min(i.anchor,i.focus),Math.max(i.anchor,i.focus),e):t.setParagraphAlignment(a,0,t.story(a).length,e),K(void 0,true),true)},Ei=e=>{let t=C$1.current,i=gt.current,a=Dn();if(!t||!i||!a)return false;if(e.type==="fillColor")t.setShapeFill(i.slideId,i.shapeId,e.value);else if(e.type==="strokeColor")t.setShapeStroke(i.slideId,i.shapeId,e.value?{color:e.value}:{});else if(e.type==="strokeWidth")t.setShapeStroke(i.slideId,i.shapeId,e.value===null?{}:{widthPt:e.value});else if(e.type==="adjust")t.setShapeAdjust(i.slideId,i.shapeId,{...a.adjustValues,[e.name]:e.value});else {let u={front:t.bringShapeToFront,back:t.sendShapeToBack,forward:t.bringShapeForward,backward:t.sendShapeBackward}[e.value];u(i.slideId,i.shapeId);}return K(void 0,true),true},Ti=e=>{let t=C$1.current,i=D$1.current;if(!t||!i)return false;let a=i.slideIndex+1,u=e===void 0?i.snapshot.slides[i.slideIndex]?.layoutPartPath??void 0:e??void 0;return t.insertSlide(a,u),J$2(null),ne(null),se(null),ce(null),Ee("select"),B.current=null,oe.current=null,q$1.current=null,ye(null),K(a,true,true),true},Ri=e=>{let t=C$1.current;return t?(e==="undo"?t.undo():t.redo(),J$2(null),se(null),ce(null),Ee("select"),B.current=null,oe.current=null,q$1.current=null,ye(null),K(void 0,true,true),true):false},ki=e=>{w$1&&G$1.breakTyping();let t=wr.current!==e;return M$1.setEnabled(false),Ee(e),e!=="select"&&(J$2(null),ne(null)),ce(null),B.current=null,q$1.current=null,ye(null),t},Mi=()=>{if(w$1){let u=ae.current;return u?(async()=>{if(X&&await X()!==true)return "requested";if(B.current||q$1.current)return "gesture";let d=await u.owner.saveAsync();return u.require(),k$1&&k$1(d),(c$2??!k$1)&&wt(d,g$1??"presentation.pptx",Zt),"saved"})().catch(d=>(O(d),"failed")):Promise.resolve("replaced")}if(Je.current)return Je.current;let e=C$1.current;if(!e)return Promise.resolve("replaced");let t=Xe.current,i=()=>C$1.current===e&&Xe.current===t,a=Promise.resolve().then(async()=>X&&await X()!==true?"requested":i()?G$1.run(()=>{if(!i())return "replaced";if(B.current||q$1.current)return "gesture";let u=e.save();return k$1&&k$1(u),(c$2??!k$1)&&wt(u,g$1??"presentation.pptx",Zt),"saved"}):"replaced").catch(u=>u instanceof De?"input-failed":u instanceof ke||!i()?"replaced":(O(u),"failed")).finally(()=>{Je.current===a&&(Je.current=null);});return Je.current=a,a};ln.current=(e$1,t)=>{let i=C$1.current,a=D$1.current,u=ht.current;if(!i||!a?.frame||!u||M$1.reviewing)return null;let d=e(u.getBoundingClientRect(),a.frame,e$1,t);if(!d||d.x<0||d.y<0||d.x>=a.frame.width||d.y>=a.frame.height)return null;let f=a.snapshot.slides[a.slideIndex],y=f&&Vt(i).hitTest(f.id,d.x,d.y);return y&&f?{...y,slide:a.slideIndex+1,slideId:f.id}:null};let Nr=(e$1,t)=>{let i=ht.current,a=E?.frame;return !i||!a?null:e(i.getBoundingClientRect(),a,e$1,t)},Ai=e=>t=>{if(Y||!ge||!Se||!m(Se))return;let i=Nr(t.clientX,t.clientY);i&&(t.preventDefault(),t.stopPropagation(),q$1.current={pointerId:t.pointerId,handle:e,start:i,slideId:ge.slideId,shapeId:ge.shapeId,delta:{x:0,y:0}},ye({x:0,y:0}),t.currentTarget.setPointerCapture(t.pointerId));},Ur=e=>{let t=q$1.current;return j(t,e.pointerId)?u(t.start,t.delta,Nr(e.clientX,e.clientY)):null},Li=e=>{let t=q$1.current,i=Ur(e);!j(t,e.pointerId)||!i||(t.delta=i,ye(i));},_r=e=>{let t=q$1.current;return j(t,e.pointerId)?(q$1.current=null,ye(null),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t):null},Xr=e=>{_r(e);},Fi=e=>{let t=Ur(e),i=_r(e);!i||!t||t.x===0&&t.y===0||G$1.input(()=>Oi(i,t)).catch(()=>{});},Oi=(e,t)=>{let i=C$1.current,a=D$1.current,u=a?.snapshot.slides[a.slideIndex],d=u?f(u.shapes,e.shapeId):null;if(!(ve.current||!i||!a?.frame||u?.id!==e.slideId||!d))try{let f=v(a.snapshot,a.frame,d,e.handle,t),y=k(d);f&&y&&(f.x!==y.x||f.y!==y.y||f.width!==y.width||f.height!==y.height)&&(i.setShapeRect(e.slideId,e.shapeId,f),K(void 0,!0));}catch(f){throw O(f),f}},Wt=E?.snapshot.slides.length??0,bt=E?.slideIndex??0,Di=()=>{if(D$1.current?.snapshot.slides.length){if(Tn){Lt(true);return}Es().then(e=>{kr(()=>e),Lt(true);},O);}},Bi=async()=>{let e;try{e=await G$1.run(()=>{let a=D$1.current,u=C$1.current;if(!a?.frame||!u)throw new ke;return {slideIndex:a.slideIndex,handle:u}});}catch(a){return a instanceof De?"input-failed":"replaced"}let{slideIndex:t,handle:i}=e;try{let a=await i.renderPng({slide:t},{scale:window.devicePixelRatio||1});return C$1.current!==i?"replaced":(wt(a,ba(g$1,t),"image/png"),"exported")}catch(a){return C$1.current!==i?"replaced":(O(a),"failed")}},Yr=xn&&xn.shapeId===ge?.shapeId?xn.delta:null,Bn=q$1.current?.handle,Hi=E?.frame&&Se&&pn&&Bn?w(E.snapshot,E.frame,Se,Bn,pn):null,lt=$e?pn&&Bn?Hi??$e:{...$e,x:$e.x+(Yr?.x??0),y:$e.y+(Yr?.y??0)}:null,Gr=n$1?w$1&&!$$1?.hydrated?"loading":E&&C$1.current?"ready":Sn||!kt?"loading":"empty":"empty",Hn=!!((!w$1||$$1?.hydrated)&&C$1.current?.isProposalsAvailable()),zi=as(Qe,{handle:C$1.current,handleRef:C$1,modelRef:D$1,selectionRef:ze,shapeSelectionRef:gt,textStyleRef:yn,activeToolRef:wr,generationRef:Xe,coordinator:G$1,status:Gr,readOnlyRef:ve,zoomRef:Ir,proposalsRef:Vs,proposalsOpenRef:Zs,reviewEnabledRef:M$1.enabledRef,reviewSelectedIdRef:M$1.selectedIdRef,proposalsAvailable:Hn,gestureActive:()=>!!(B.current||q$1.current),baseStyle:or,i18n:ee,t:j$1,workerMode:w$1?{preparing:!$$1?.hydrated,failed:!!$$1?.owner.failure||!!In}:void 0,actions:{format:Ii,align:Ci,formatShape:Ei,insertSlide:Ti,history:Ri,setTool:ki,setZoom:e=>{let t=e!==Ir.current;return vn(e),t},openPicker:()=>{an.current=Hr(),Pr.current?.click();},save:Mi,exportPng:Bi,present:Di,setProposalsOpen:e=>{e&&it(),ot(e);},selectProposal:e=>{M$1.select(e),M$1.setEnabled(true);},showProposalDiff:e=>M$1.setEnabled(e),acceptProposal:ei,rejectProposal:ti,reportError:O,focusEditor:()=>xe.current?.focus()},stamp:[E,V,ge,Ys,tt,Pn,Y,Gr,M$1.enabled,M$1.selected,M$1.available,Ot,Dt,Hn,j$1,ee]}),qr=useRef(En);qr.current=En,G({commands:Qe,containerRef:cn,suspended:()=>qr.current,shortcuts:Q,onShortcutIssue:he,unsupported:F});let ji=!z$1||de===null?null:jsxs("div",{style:H.toolbarShell,children:[jsx(e$1.Provider,{value:true,children:de!==void 0?jsx("div",{style:H.toolbar,children:de}):Y?null:jsxs(Fragment,{children:[jsx(p,{mode:"commands",style:H.toolbar}),Hn&&jsx(z,{buttonRef:Ar,count:Ot.length})]})}),Ge.length>0?jsxs("div",{style:H.presenceStrip,role:"list","aria-label":j$1("presence.label"),children:[vt.visible.map(e=>{let t=e.state.cursor?.slideId===at;return jsx("span",{role:"listitem",style:As(e.state.user.color,t),title:e.state.user.name,"aria-label":e.state.user.name,children:Ha(e.state.user.name)},e.state.clientId)}),vt.overflow>0?jsxs("span",{role:"listitem",style:As("#64748b",true),title:j$1("presence.moreCollaborators",{count:vt.overflow}),"aria-label":j$1("presence.moreCollaborators",{count:vt.overflow}),children:["+",vt.overflow]}):null]}):null,de===void 0&&jsx(y,{})]}),zn=e=>Fe.managed?jsx(I,{host:Fe.host,placement:e,activations:Fe.activations.filter(t=>t.plugin.panel?.placement===e),available:Us}):null,Ki=jsxs("div",{dir:"ltr",ref:cn,className:p$2,style:{...H.root,...m$1},children:[ji,jsx("input",{ref:Pr,type:"file",accept:Object.values(rr).join(","),disabled:Y||M$1.reviewing||!!w$1&&!$$1?.hydrated,tabIndex:-1,"aria-hidden":"true","data-testid":"pptx-insert-image-input",style:H.hiddenFileInput,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value="",t&&fi(t);}}),w$1&&qs>0&&jsx("div",{role:"status",children:j$1("worker.image")}),w$1&&wn&&jsx("button",{type:"button",onClick:()=>{wn.save().then(({bytes:e})=>wt(e,wn.name,Zt)).catch(O);},children:j$1("worker.previousRecovery")}),w$1&&n$1&&!In&&!$$1?.hydrated&&jsxs("div",{role:"status","data-testid":"pptx-worker-status",children:[$$1?.owner.failure?j$1("worker.failed"):h$2!==void 0?h$2:j$1("worker.preparing"),$$1?.owner.failure&&jsx("button",{type:"button",onClick:()=>{$$1.owner.recoverySave().then(({bytes:e})=>wt(e,g$1??"presentation.pptx",Zt)).catch(O);},children:j$1("worker.recovery")})]}),jsxs("div",{ref:Ns,style:H.workspace,children:[jsx("aside",{style:H.slideStrip,"aria-label":j$1("slides.panelLabel"),children:M$1.reviewing&&M$1.selected&&C$1.current&&M$1.diff?jsx(W,{entries:C$1.current.proposalSlideStrip(M$1.selected.id),selectedSlideId:M$1.previewSlideId??at,load:Js,decodeImage:decodePresentationImage,resolveImage:je,onSelect:M$1.selectSlide}):E?.snapshot.slides.map((e,t)=>{let i=li.get(e.id);return jsxs("button",{type:"button","aria-current":t===bt?"page":void 0,style:za(t===bt),onClick:()=>ui(t),children:[jsx("span",{style:H.slideNumber,children:t+1}),jsxs("span",{style:H.slidePreview,children:[jsx(Ea,{store:Pe,slideId:e.id,title:Ba(e.shapes)||j$1("slides.fallbackTitle",{number:t+1}),resolveImage:je,afterPaint:Xs,worker:$$1}),e.id!==at&&i&&(i.visible.length>0||i.overflow>0)?jsxs("span",{style:H.thumbnailPresence,"aria-hidden":"true",children:[i.visible.map(a=>jsx("span",{style:{...H.thumbnailPresenceDot,backgroundColor:a.state.user.color}},a.state.clientId)),i.overflow>0?jsxs("span",{style:H.thumbnailPresenceOverflow,children:["+",i.overflow]}):null]}):null]})]},e.id)})}),zn("left"),jsxs("div",{style:H.center,children:[jsxs("div",{ref:xe,style:H.stage,tabIndex:0,role:"application","aria-label":j$1("editor.appLabel"),onKeyDown:bi,onFocus:()=>vr(true),onBlur:()=>vr(false),children:[!Y&&!w$1&&jsx(aa$1,{review:M$1,ready:Qs===M$1.diff}),jsx("div",{ref:Tt,style:H.canvasHost,children:E?.frame?jsxs("div",{style:{...H.canvasFrame,width:E.frame.width*W$1,height:E.frame.height*W$1},children:[jsx("canvas",{ref:ht,"data-testid":"pptx-slide-canvas","aria-hidden":M$1.reviewing,style:{...H.canvas,cursor:tt!=="select"?"crosshair":Cr==="text"?"text":Cr==="shape"?"move":"default"},onPointerDown:M$1.reviewing?void 0:mi,onPointerMove:hi,onPointerUp:xi,onPointerLeave:gi,onPointerCancel:jr,onLostPointerCapture:jr,"aria-label":Se?j$1("slides.canvasLabelWithSelection",{current:bt+1,total:Wt,name:Se.name}):j$1("slides.canvasLabel",{current:bt+1,total:Wt})}),Fe.managed&&jsx(J$1,{host:Fe.host,activations:Fe.activations,layerRef:Fe.overlayLayerRef}),!M$1.reviewing&&ai&&jsxs(Fragment,{children:[jsx(Ra,{frame:E.frame,selection:V,scale:W$1,focused:_s}),On.visible.map(({peer:e,peerCount:t,shapeId:i,bounds:a},u)=>jsx(wa,{peer:e,peerCount:t,bounds:a,scale:W$1,labelOffset:u},i)),On.overflow>0?jsx("span",{style:H.remoteShapeOverflow,"aria-hidden":"true",children:j$1("presence.moreSelections",{count:On.overflow})}):null,lt?jsxs(Fragment,{children:[jsx("span",{style:{...H.shapeSelection,left:lt.x*W$1,top:lt.y*W$1,width:Math.max(1,lt.width*W$1),height:Math.max(1,lt.height*W$1)},"aria-hidden":"true"}),!Y&&Se&&m(Se)?c$1.map(e=>{let t=r(lt,e);return jsx("span",{"data-testid":`pptx-resize-${e}`,onPointerDown:Ai(e),onPointerMove:Li,onPointerUp:Fi,onPointerCancel:Xr,onLostPointerCapture:Xr,style:{...H.resizeHandle,left:t.x*W$1-Qt/2,top:t.y*W$1-Qt/2,cursor:s(e)}},e)}):null]}):null,Pt?jsx("span",{style:{...H.textEditOutline,left:Pt.x*W$1,top:Pt.y*W$1,width:Math.max(1,Pt.width*W$1),height:Math.max(1,Pt.height*W$1)},"aria-hidden":"true"}):null,Le?jsx("span",{style:{...H.textBoxPreview,left:Math.min(Le.start.x,Le.end.x)*W$1,top:Math.min(Le.start.y,Le.end.y)*W$1,width:Math.max(1,Math.abs(Le.end.x-Le.start.x))*W$1,height:Math.max(1,Math.abs(Le.end.y-Le.start.y))*W$1},"aria-hidden":"true"}):null]}),M$1.diff&&jsx(ba$1,{diff:M$1.diff,current:E.snapshot,frame:E.frame,slideIndex:E.slideIndex,scale:W$1,resolveImage:je,decodeImage:decodePresentationImage,onPainted:Lr,onTarget:(e,t)=>{An(e,t,M$1.selected?.id),ot(true);}},`${M$1.diff.proposal.id}:${E.slideIndex}`)]}):M$1.diff&&E?jsx("div",{style:{...H.canvasFrame,width:M$1.diff.frame.width*W$1,height:M$1.diff.frame.height*W$1},children:jsx(ba$1,{diff:M$1.diff,current:E.snapshot,frame:M$1.diff.frame,slideIndex:0,scale:W$1,resolveImage:je,decodeImage:decodePresentationImage,onPainted:Lr,onTarget:(e,t)=>An(e,t,M$1.selected?.id)})}):jsx("div",{style:H.empty,children:Sn?h$2!==void 0?h$2:j$1("editor.opening"):j$1(n$1?"editor.noSlides":"editor.openPrompt")})}),kt?n$1&&!Sn&&(w$1?In:!E)?jsx(a$2,{kind:"open",details:kt}):jsx("div",{style:H.error,children:kt}):null]}),zn("bottom")]}),zn("right"),!Y&&Dt&&Ft&&E&&C$1.current&&jsx(Ft,{handle:C$1.current,proposals:Ot,snapshot:E.snapshot,visualDisabledReason:w$1?j$1("worker.disabled"):void 0,resolveImage:je,onNavigate:An,onClose:()=>Ar.current?.focus()})]}),pe&&M$1.diff?.proposal.changes.some(e=>e.slideId===pe.id&&!e.shapeId&&e.oldText!==e.newText)?jsx(da$1,{diff:M$1.diff,slideId:pe.id}):pe?jsx(Ca,{value:pe.notes??"",disabled:!E||M$1.reviewing||Y||!!w$1&&!$$1?.hydrated,label:j$1("notes.panelLabel"),placeholder:j$1("notes.placeholder"),onCommit:e=>{let t=C$1.current;if(!(!t||Y))try{t.setSlideNotes(pe.id,e),K(void 0,!0);}catch(i){O(i);}}},pe.id):null,En&&Tn&&Wt>0&&C$1.current?jsx(Tn,{handle:C$1.current,slideCount:Wt,startIndex:bt,resolveImage:je,counterLabel:(e,t)=>j$1("presentation.slideCounter",{current:e,total:t}),label:j$1("presentation.label"),exitLabel:j$1("presentation.exit"),previousLabel:j$1("presentation.previousSlide"),nextLabel:j$1("presentation.nextSlide"),onExit:()=>Lt(false),onError:O}):null]});return jsx(M.Provider,{value:on,children:Ki})}function wa({peer:n,peerCount:r,bounds:s,scale:o,labelOffset:l}){let[m,x]=useState(()=>Date.now()-n.cursorMovedAt<PRESENCE_LABEL_DURATION_MS);return useEffect(()=>{let h=PRESENCE_LABEL_DURATION_MS-(Date.now()-n.cursorMovedAt);if(h<=0){x(false);return}x(true);let P=setTimeout(()=>x(false),h);return ()=>clearTimeout(P)},[n.cursorMovedAt]),jsxs("span",{style:{...H.remoteShapeSelection,left:s.x*o,top:s.y*o,width:Math.max(1,s.width*o),height:Math.max(1,s.height*o),borderColor:n.state.user.color},"aria-hidden":"true",children:[jsx("span",{style:{...H.remoteShapeWash,backgroundColor:n.state.user.color}}),m?jsxs("span",{style:{...H.remoteShapeLabel,top:-4-l%3*20,backgroundColor:n.state.user.color},children:[n.state.user.name,r>1?` +${r-1}`:""]}):null]})}function Ca({value:n,disabled:r,label:s,placeholder:o,onCommit:l}){return jsxs("div",{style:H.notesPanel,children:[jsx("span",{style:H.notesLabel,children:s}),jsx("textarea",{"aria-label":s,style:H.notesTextarea,value:n,disabled:r,placeholder:o,"data-testid":"pptx-notes-textarea",onChange:m=>l(m.target.value)})]})}var Ea=memo(function({store:r,slideId:s,title:o,resolveImage:l,afterPaint:m,worker:x}){let h=useCallback(p=>r.subscribe(s,p),[r,s]),P=useCallback(()=>r.get(s),[r,s]),c=useSyncExternalStore(h,P,P);return c?jsx(Ta,{frame:c,resolveImage:l,afterPaint:m,worker:x}):jsx("span",{style:H.slideTitle,children:o})}),Ta=memo(function({frame:r,resolveImage:s,afterPaint:o,worker:l}){let m=useRef(null);return useEffect(()=>{let x=m.current;if(!x)return;let h=x.getContext("2d");if(!h)return;let P=128/r.width,c=window.devicePixelRatio||1;sizeCanvasForSlide(x,r,c,P);let p=false;return Promise.resolve().then(o).then(async()=>{if(p)return;let g=l?l.thumbnailImages(r):null;if(!(l&&!g))try{await paintSlide(l?tr(h,()=>!p&&l.isThumbnailCurrent(r)):Bs(h,()=>!p),r,c,P,{resolveImage:g??s});}finally{g?.release();}}).catch(()=>{}),()=>{p=true;}},[o,r,s,l]),jsx("canvas",{ref:m,style:H.thumbnailCanvas,"aria-hidden":"true"})});function Ra({frame:n,selection:r,scale:s,focused:o}){let l=useRef(null),[m,x]=useState(()=>typeof document>"u"||document.visibilityState==="visible"),[h,P]=useState(false);return useEffect(()=>{if(typeof document>"u")return;let c=()=>x(document.visibilityState==="visible");return document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c)},[]),useEffect(()=>{let c=o&&m&&r!==null&&r.anchor===r.focus;if(P(c),!c)return;let p=window.setInterval(()=>P(g=>!g),Ia);return ()=>window.clearInterval(p)},[o,m,r]),useEffect(()=>{let c=l.current;if(!c)return;let p=c.getContext("2d");if(!p)return;let g=window.devicePixelRatio||1;sizeCanvasForSlide(c,n,g,s),Da(p,n,r,g,s,h);},[h,n,s,r]),jsx("canvas",{ref:l,style:H.canvasOverlay,"aria-hidden":"true"})}var Jt=class extends Error{};function Bs(n,r){let s=new Map;return new Proxy(n,{get(o,l){let m=Reflect.get(o,l,o);if(typeof m!="function")return m;let x=s.get(l);return x||(x=(...h)=>{if(!r())throw new Jt;return Reflect.apply(m,o,h)},s.set(l,x)),x},set(o,l,m){if(!r())throw new Jt;return Reflect.set(o,l,m,o)}})}var en=class extends Error{constructor(){super("Finish the pointer gesture before flushing input");}};function sr(n,r){if(typeof r!="string")return null;let s=n.snapshot().slides,o=s.findIndex(l=>l.id===r);return o<0?null:{index:o,slide:s[o]}}function ka(n,r){return r===0?0:Math.max(0,Math.min(r-1,n))}function mt(n){return n.paragraphs.map(r=>r.runs.map(s=>s.text).join("")).join(`
4
+ `)}function Ma(n,r,s){n.formatText(r.id,0,r.length,s);}function Aa(n,r){let s=mt(n).slice(0,r),o=Array.from(s),l=o[o.length-1];return l?r-l.length:r}function La(n,r){let s=Array.from(mt(n).slice(r))[0];return s?r+s.length:r}function Ms(n){if(!(typeof document>"u"))for(let r of n)document.fonts.delete(r);}function Fa(n,r,s){return r.current.resolver(o=>{let l=n.current,m=l&&metafileImageBytes(l.mediaBytes(o),()=>l.metafileSvg(o));return m?.byteLength?m:void 0},s)}function Oa(n,r){return n?.primitives.find(o=>o.kind==="textBox"&&o.storyId===r.storyId&&o.shapeId===r.shapeId)?.lines??[]}function Da(n,r,s,o,l,m=true){if(!s)return;let x=r.primitives.find(c=>c.kind==="textBox"&&c.storyId===s.storyId&&c.shapeId===s.shapeId);if(!x)return;let h=Math.min(s.anchor,s.focus),P=Math.max(s.anchor,s.focus);if(n.save(),n.setTransform(o*l,0,0,o*l,0,0),h!==P){n.fillStyle="rgba(59, 130, 246, 0.26)";for(let c of x.lines){let p=Math.max(h,c.start),g=Math.min(P,c.end);if(p>=g)continue;let b=ir(c,p),v=ir(c,g);n.fillRect(Math.min(b,v),c.y,Math.max(1,Math.abs(v-b)),c.height);}}else if(m){let c=x.lines[ft(x.lines,{position:h,lineIndex:s.focusLine})];if(c){let p=ir(c,h);n.fillStyle="#1d4ed8",n.fillRect(p,c.y,1.5,c.height);}}n.restore();}function ir(n,r){let s=n.caretStops[0];return s?n.caretStops.reduce((o,l)=>Math.abs(l.position-r)<Math.abs(o.position-r)?l:o,s).x:n.x}function Ba(n){for(let r of n)for(let s of r.textStories){let o=mt(s).trim();if(o)return o.slice(0,40)}return ""}var H={root:{display:"flex",flexDirection:"column",width:"100%",height:"100%",minHeight:480,overflow:"hidden",color:"#172033",background:"#f3f5f8",fontFamily:"ui-sans-serif, system-ui, sans-serif"},toolbarShell:{display:"flex",alignItems:"center",flex:"0 0 auto",padding:"4px 0 5px",background:"#ffffff",borderBottom:"1px solid #e2e8f0"},toolbar:{flex:"1 1 auto",minWidth:0},presenceStrip:{display:"flex",alignItems:"center",gap:4,flex:"0 0 auto",maxWidth:"35%",padding:"0 10px 0 2px",overflowX:"auto"},workspace:{display:"flex",flex:1,minHeight:0},center:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},slideStrip:{width:184,padding:"14px 10px",overflowY:"auto",background:"#eef1f5",borderRight:"1px solid #d8dee9",boxSizing:"border-box"},slideNumber:{width:18,flex:"0 0 auto",paddingTop:3,fontSize:11,color:"#647087",textAlign:"right"},slidePreview:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:132,aspectRatio:"16 / 9",padding:8,overflow:"hidden",background:"#ffffff",boxSizing:"border-box",boxShadow:"0 1px 4px rgba(20, 31, 50, 0.16)"},slideTitle:{fontSize:9,lineHeight:1.25,color:"#39445a",textAlign:"center"},thumbnailCanvas:{display:"block",maxWidth:"100%",height:"auto"},thumbnailPresence:{position:"absolute",top:4,right:4,display:"flex",gap:3,padding:2,borderRadius:999,background:"rgba(255, 255, 255, 0.88)",boxShadow:"0 1px 3px rgba(15, 23, 42, 0.2)"},thumbnailPresenceDot:{width:7,height:7,borderRadius:999,boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.9)"},thumbnailPresenceOverflow:{color:"#475569",fontSize:8,fontWeight:700,lineHeight:"8px"},stage:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,outline:"none",overflow:"hidden"},canvasHost:{display:"flex",flex:1,minHeight:0,alignItems:"center",justifyContent:"center",width:"100%",overflow:"auto"},canvasFrame:{position:"relative",flex:"0 0 auto"},canvas:{display:"block",flex:"0 0 auto",background:"#fff",boxShadow:"0 8px 32px rgba(27, 39, 61, 0.2)",touchAction:"none"},canvasOverlay:{position:"absolute",inset:0,display:"block",pointerEvents:"none"},textEditOutline:{position:"absolute",zIndex:3,border:"2px dashed #6b7280",boxSizing:"border-box",boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.9)",pointerEvents:"none"},resizeHandle:{position:"absolute",zIndex:4,width:Qt,height:Qt,borderRadius:"50%",border:"1px solid #2563eb",background:"#ffffff",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.35)",boxSizing:"border-box",touchAction:"none"},shapeSelection:{position:"absolute",zIndex:3,border:"2px solid #2563eb",boxSizing:"border-box",boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.9)",pointerEvents:"none"},remoteShapeSelection:{position:"absolute",zIndex:2,border:"2px solid",borderRadius:2,boxSizing:"border-box",boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.88)",pointerEvents:"none"},remoteShapeWash:{position:"absolute",inset:0,opacity:.12},remoteShapeLabel:{position:"absolute",left:-2,maxWidth:180,overflow:"hidden",padding:"3px 6px",borderRadius:"4px 4px 4px 0",color:"#ffffff",fontSize:11,fontWeight:650,lineHeight:"14px",textOverflow:"ellipsis",whiteSpace:"nowrap",transform:"translateY(-100%)",boxShadow:"0 1px 3px rgba(15, 23, 42, 0.25)"},remoteShapeOverflow:{position:"absolute",top:8,right:8,zIndex:3,padding:"3px 6px",borderRadius:999,backgroundColor:"#475569",color:"#ffffff",fontSize:10,fontWeight:700,pointerEvents:"none"},textBoxPreview:{position:"absolute",border:"1.5px dashed #1a73e8",background:"rgba(26, 115, 232, 0.08)",boxSizing:"border-box",pointerEvents:"none"},notesPanel:Y.panel,notesLabel:Y.label,notesTextarea:Y.textarea,empty:{margin:"auto",color:"#6b7587",fontSize:14},error:{position:"absolute",left:16,right:16,bottom:14,padding:"9px 12px",color:"#8b1e2d",background:"#fff0f2",border:"1px solid #efb8c0",borderRadius:6,fontSize:12},hiddenFileInput:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0}};function Ha(n){let r=n.trim().split(/\s+/).filter(Boolean);return r.length===0?"?":r.slice(0,2).map(s=>s[0]).join("").toUpperCase()}function As(n,r){return {display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,flex:"0 0 auto",border:"2px solid #ffffff",borderRadius:999,backgroundColor:n,boxShadow:"0 0 0 1px rgba(15, 23, 42, 0.14)",color:"#ffffff",fontSize:10,fontWeight:700,letterSpacing:"-0.02em",opacity:r?1:.38}}function za(n){return {display:"flex",alignItems:"flex-start",gap:7,width:"100%",marginBottom:12,padding:4,border:n?"2px solid #325ee6":"2px solid transparent",borderRadius:5,background:"transparent",cursor:"pointer"}}var ja=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","Backspace","Delete","Enter"]);function Hs(n){return n.key.length>0&&!n.metaKey&&!n.ctrlKey&&!n.altKey&&Array.from(n.key).length===1}function Ls(n){return ja.has(n.key)||Hs(n)}export{Is as a,tr as b,nu as c};
@@ -0,0 +1 @@
1
+ import {c as c$1,b,a as a$1}from'./chunk-BNLMNYZQ.js';import {r,s}from'./chunk-3WH2K5EA.js';import {C,g,n,m,P,Q,d,Z,D,G,e,L as L$1,j,A,M,B,E,y,z,F,f}from'./chunk-LFHLWZA4.js';import {a,m as m$1,c,d as d$1}from'./chunk-PS7ULZVL.js';import {a as a$2}from'./chunk-O2XFH626.js';import {useEffect,useRef,useLayoutEffect,useState,useId,useCallback,useMemo,Component}from'react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {indexGeometry,selectionGeometry}from'@betteroffice/pptx/worker';import {sizeCanvasForSlide,paintSlide}from'@betteroffice/pptx';function Oo(e){useEffect(()=>{if(e.current)return g(e.current)},[e]);}function No(e){return e!==void 0&&Number.isFinite(e)&&e>0?Math.min(n,Math.max(m,e)):"fit"}function jo(){let e=P(),t=Q("slideshow"),{t:n}=d(),o=Z(!t.enabled,t.enabled?void 0:t.disabledReason?.message),r=m$1();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:{...ln,opacity:t.enabled?1:c,...d$1(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 ln={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:a.accent,color:a.accentInk,font:"500 13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"};function qo({buttonRef:e,count:t}){let n=P(),o=Q("proposalsPanel"),{t:r}=d(),s=Z(!o.enabled,o.enabled?void 0:o.disabledReason?.message),d$2=m$1();return jsxs(Fragment,{children:[jsxs("button",{ref:e,type:"button","data-testid":"pptx-proposals-button",...s.props,"aria-expanded":o.value??false,title:s.reason,...d$2.focusProps,style:{...un,...d$1(d$2.focusRing)},onClick:()=>{o.enabled&&n.execute("proposalsPanel",null);},children:[r("proposals.title")," ",jsx("span",{"data-testid":"pptx-proposals-count",children:t})]}),s.node]})}var un={display:"inline-flex",alignItems:"center",gap:6,flex:"0 0 auto",margin:"0 0 0 4px",padding:"0 10px",height:28,border:`1px solid ${a.line}`,borderRadius:6,background:a.surface,color:a.ink,font:"500 13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer",boxSizing:"border-box"};var bt=new WeakSet,we=new WeakMap;function Re(e){bt.add(e);}function Jo(e){return bt.has(e)}function pe(e){we.get(e)?.disarm();}function je(e,t){pe(e);let n=()=>{clearTimeout(o),e.removeEventListener("keyup",n),e.removeEventListener("blur",n),we.delete(e);},o=setTimeout(n,300);e.addEventListener("keyup",n),e.addEventListener("blur",n),we.set(e,{mode:t,disarm:n});}function Qo(e){let t=we.get(e);return t?.disarm(),t?.mode??null}var We=new WeakMap;function Ke(e,t){We.has(e)||We.set(e,t);}function St(e){return We.get(e)??null}var Ie={"data-pptx-plugin-chrome":""};function tr(e){return e instanceof Element&&e.closest("[data-pptx-plugin-chrome]")!==null}function $e(e,t){let n=C(e);if(!n||t)return n;let o=B(n);return C([(o.ctrl||o.mod)&&"Mod",o.alt&&"Alt",o.shift&&"Shift",o.key].filter(Boolean).join("+"))}function vt(e){return [...e].length===1||Object.hasOwn(y,e)||z.test(e)}function Ct(e){let t=B(e);return t.ctrl||t.mod||t.alt||z.test(t.key)}function pn(e,t){return e==="="?t.code==="Equal"||t.key==="="||t.key==="+":e==="space"?t.key===" "||t.code==="Space":e==="\\"?t.key==="\\"||t.code==="Backslash":t.key.toLowerCase()===e?true:/^[0-9]$/.test(e)?t.code===`Digit${e}`:/^[a-z]$/.test(e)?!/^[\x20-\x7e]$/.test(t.key)&&t.code===`Key${e.toUpperCase()}`:false}function wt(e,t,n=A()){let o=B(e),r=n?t.metaKey:t.ctrlKey,s=n?t.ctrlKey:t.metaKey,d=o.mod||!n&&o.ctrl,c=n&&o.ctrl;return d===r&&c===s&&o.shift===t.shiftKey&&o.alt===t.altKey&&pn(o.key,t)}var Ee=null;function ke(){if(Ee)return Ee;let e=new Map,t=new Map;for(let n of Object.values(E)){let o=n.shortcuts.map(({chord:r})=>D(r));if(o.length!==0){e.set(n.id,Object.freeze(o));for(let r of o)t.set(r,n.id);}}return Ee={chords:e,owners:t,issues:Object.freeze([])},Ee}function Te(e){return e.hostShortcuts()??ke()}function fe(e,t){return Te(e).owners.get(t)}function Rt(e,t){let n=ke().owners.get(t);return n!==void 0&&fe(e,t)!==n}function It(e,t){return e.hostShortcuts()?.chords.get(t)}function sr(e,t){let n=e.shortcutRevision();return e.store.subscribe(()=>{let o=e.shortcutRevision();o!==n&&(n=o,t());})}var fn=new Set(["arrowup","arrowdown","arrowleft","arrowright","home","end","pageup","pagedown","backspace","delete","enter","tab","escape"]);function ie(e){let t=B(e),n=t.mod||t.ctrl||t.alt;return fn.has(t.key)||(t.mod||t.ctrl)&&t.key==="a"||!n&&t.shift&&t.key==="f10"}var Me=new Set(["cut","copy","paste","pasteAsPlainText"]),Et=new Set(["Mod+A","Mod+C","Mod+V","Mod+X","Mod+Shift+V"].map(e=>C(e)));function gn(e,t){if(e===null||typeof e=="string"||Array.isArray(e))return typeof e=="string"?[e]:e;let n=e[t?"mac":"other"];return typeof n=="string"?[n]:n}function kt(e,t,n){let{mac:o,isBindable:r,isReserved:s}=n,d=[],c=new Map(e.map(u=>[u.id,u])),g=new Map,p=new Set;for(let[u,h]of Object.entries(t??{})){if(h===void 0)continue;if(!c.has(u)&&!r(u)){d.push({code:"unknown-id",id:u});continue}let w=gn(h,o);if(w===void 0)continue;if(w===null||w.length===0){p.add(u);continue}let m=[];for(let T of w){let C=typeof T=="string"?$e(T,o):null;!C||!vt(B(C).key)||!Ct(C)?d.push({code:"invalid-chord",id:u,chord:String(T)}):s?.(C,u)?d.push({code:"reserved-chord",id:u,chord:T}):m.includes(C)||m.push(C);}m.length>0&&g.set(u,m);}let v=new Map;for(let[u,h]of g)for(let w of h)v.set(w,[...v.get(w)??[],u]);for(let[u,h]of v)h.length<2||(h.forEach((w,m)=>{d.push({code:"duplicate-chord",id:w,chord:u,other:h[(m+1)%h.length]});let T=g.get(w).filter(C=>C!==u);T.length>0?g.set(w,T):g.delete(w);}),v.delete(u));let l=new Map,f=new Map;for(let[u,h]of g){l.set(u,Object.freeze(h));for(let w of h)f.set(w,u);}for(let{id:u,chords:h}of e){if(g.has(u))continue;if(p.has(u)){l.set(u,Object.freeze([]));continue}let w=[];for(let m of h){let T=$e(m,o),C=f.get(T);C===void 0?w.push(T):C!==u&&d.push({code:"displaced-default",id:C,chord:T,other:u});}l.set(u,Object.freeze(w));for(let m of w)f.set(m,u);}for(let u of p)l.has(u)||l.set(u,Object.freeze([]));return {chords:l,owners:f,issues:Object.freeze(d)}}function mn(){return Object.values(E).flatMap(e=>{let t=e.shortcuts;return t.length===0?[]:[{id:e.id,chords:t.map(({chord:n})=>n)}]})}var hn={cut:true,copy:true,paste:true,pasteAsPlainText:true,deleteObject:true,deleteSlide:true,duplicateSlide:true,bold:true,italic:true,underline:true,strikethrough:true,insertImage:true,save:true,exportPng:true,slideshow:true,undo:true,redo:true,proposalsPanel:true};function Pn(e){return G(e)||F(e)&&Object.hasOwn(hn,e)}function Tt(e,t={}){let{unsupported:n}=t,o=[],r=e&&n?Object.fromEntries(Object.entries(e).filter(([d,c])=>c===void 0||!n.has(d)?true:(o.push({code:"unknown-id",id:d}),false))):e,s=kt(mn(),r,{mac:t.mac??A(),isBindable:Pn,isReserved:d=>ie(d)});return o.length?{...s,issues:Object.freeze([...o,...s.issues])}:s}var bn=new Set(["save"]),Sn=new Set(["undo","redo"]),vn=new Map([["Mod+c","copy"],["Mod+x","cut"],["Mod+v","paste"],["Mod+Shift+v","pasteAsPlainText"]]);function Cn(e){if(!e.ctrlKey&&!e.metaKey)return null;switch(e.key.toLowerCase()){case "z":return e.shiftKey?{id:"redo",chord:"Mod+Shift+z"}:{id:"undo",chord:"Mod+z"};case "y":return {id:"redo",chord:"Mod+y"};case "b":return {id:"bold",chord:"Mod+b"};case "i":return {id:"italic",chord:"Mod+i"};case "u":return {id:"underline",chord:"Mod+u"};case "s":return {id:"save",chord:"Mod+s"};case "c":return {id:"copy",chord:"Mod+c"};case "x":return {id:"cut",chord:"Mod+x"};default:return null}}function De(e,t,n=A()){let o=null,r=t.key.toLowerCase();for(let s of e)if(wt(s,t,n)){if(s.slice(s.lastIndexOf("+")+1)===r)return s;o??(o=s);}return o}function wn(e,t,n={}){if(t===void 0)return e.setShortcuts(void 0),[];let o=Tt(t,{mac:n.mac??A(),unsupported:n.unsupported});return e.setShortcuts(o),o.issues}function Rn(e,t,n=A()){let{owners:o}=Te(e),r=De(o.keys(),t,n),s=r===null?void 0:o.get(r);return r===null||s===void 0||G(s)?null:{id:s,chord:r}}function In(e,t,n=A()){let{owners:o}=Te(e),r=ke().owners,s=De(new Set([...o.keys(),...r.keys()]),t,n);return s===null?null:{chord:s,owner:o.get(s),fallback:r.get(s)}}function En(e){let n=(e instanceof Element?e:null)?.closest("input, textarea, select, [contenteditable]");return !!n&&n.getAttribute("contenteditable")!=="false"}function kn(e){e.code!=="displaced-default"&&(typeof process<"u"&&process.env?.NODE_ENV==="production"||console.warn(`Shortcut ${e.chord??""} of ${e.id} was not applied: ${e.code}`));}function kr({commands:e,containerRef:t,editorInput:n,suspended:o,shortcuts:r,onShortcutIssue:s,unsupported:d}){let c=useRef(o);c.current=o;let g=useRef(r);g.current=r;let p=useRef(s);p.current=s;let v=r===void 0?void 0:JSON.stringify(r),l=useRef(new Set);useLayoutEffect(()=>{for(let f of wn(e,g.current,{unsupported:d})){let u=JSON.stringify(f);l.current.has(u)||(l.current.add(u),(p.current??kn)(f));}},[e,v,d]),useEffect(()=>{let f=m=>{let T=St(m);if(T)return e.ownsStore(T);let C=m.target;return C instanceof Node&&(t.current?.contains(C)??false)||e.ownsChrome(C)},u=m=>m!==null&&m===n?.current,h=m=>{if(!f(m))return;let T=m.target;if(u(T)&&pe(T),m.defaultPrevented||m.isComposing||m.keyCode===229||!m.ctrlKey&&!m.metaKey&&!m.altKey&&!/^F\d/.test(m.key))return;let C=In(e,m);if(!C){let b=Cn(m);if(b&&fe(e,b.chord)!==b.id){Re(m),u(T)&&Me.has(b.id)&&je(T,"ignore");return}let R=e.pluginShortcuts().map(({chord:D$1})=>D(D$1)??D$1).filter(D=>!ie(D));De(R,m)!==null&&Re(m);return}let{owner:A,fallback:M}=C;A!==M&&(Re(m),u(T)&&M!==void 0&&Me.has(M)&&je(T,"ignore"));},w=m=>{if(m.defaultPrevented||m.isComposing||m.keyCode===229||!f(m)||c.current())return;let T=m.target,C=En(T)&&!u(T),A=Rn(e,m);if(!A){let D$1=e.pluginShortcuts(),B=De(D$1.map(({chord:z})=>D(z)??z),m),N=D$1.find(({chord:z})=>(D(z)??z)===B);if(!N||C)return;m.preventDefault(),u(T)&&pe(T),m.repeat||e.store.execute(N.id,null);return}let{id:M,chord:b}=A;if(vn.get(b)===M||C&&!bn.has(M))return;let R=e.store.getState(M,null);!R.enabled&&(R.disabledReason.code==="host-disabled"||R.disabledReason.code==="unsupported-command")||(m.preventDefault(),u(T)&&pe(T),!(m.repeat&&!Sn.has(M))&&e.store.execute(M,null));};return document.addEventListener("keydown",h,true),document.addEventListener("keydown",w),()=>{document.removeEventListener("keydown",h,true),document.removeEventListener("keydown",w);}},[e,t,n]);}var Ue=class extends Component{constructor(){super(...arguments);a$2(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 Oe({host:e$1,activation:t,phase:n="render",claimPointerEvents:o=false,children:r}){let s=e$1.commandStore(t),d=o?c=>Ke(c.nativeEvent,s):void 0;return jsx(Ue,{onError:c=>e$1.fail(t.pluginId,n,c),children:jsx(M.Provider,{value:s,children:jsx("div",{"data-plugin-activation":e(t.activation),style:{display:"contents"},onKeyDownCapture:c=>Ke(c.nativeEvent,s),onPointerDownCapture:d,onPointerMoveCapture:d,onPointerUpCapture:d,onPointerCancelCapture:d,onLostPointerCaptureCapture:d,children:r})})})}var An={left:280,right:280,bottom:200},Ye={left:160,right:160,bottom:120},Dn=640,V={surface:"#ffffff",border:"#e2e8f0",text:"#172033",muted:"#647087",selected:"#e8f0fe",primary:"#1a73e8"};function On(e,t,n){let o=e==="bottom"?n.height:n.width,r=Math.max(Ye[e],Math.floor(o*.4));return Math.max(Ye[e],Math.min(t??An[e],r))}function Dt(e=true){let t=useRef(null),[n,o]=useState({width:0,height:0});return useEffect(()=>{let r=t.current;if(!e||!r)return;let s=()=>o(c=>c.width===r.clientWidth&&c.height===r.clientHeight?c:{width:r.clientWidth,height:r.clientHeight});if(s(),typeof ResizeObserver>"u")return;let d=new ResizeObserver(s);return d.observe(r),()=>d.disconnect()},[e]),[t,n]}var Fr=Dt;function Ln({host:e,activation:t,id:n,labelledBy:o}){let[r,s]=Dt(),d=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(Oe,{host:e,activation:t,children:jsx(d,{context:t.context,width:s.width,height:s.height})})})}var Hn=e=>({maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"4px 8px",border:0,borderRadius:4,background:e?V.selected:"transparent",color:e?V.primary:V.muted,font:"12px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"}),Mt={flex:"0 0 auto",padding:"0 6px",border:0,borderRadius:4,background:"transparent",color:V.muted,font:"13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"};function jr({host:e,placement:t,activations:n,available:o}){let{t:r}=d(),s=useId(),[d$1,c]=useState(null),[g,p]=useState({}),[v,l]=useState(false),f=useRef(null),u=useRef(null),h=t!=="bottom"&&o.width>0&&o.width<Dn,w=h&&v&&n.length>0;if(useEffect(()=>{w&&u.current?.focus();},[w]),n.length===0)return null;let m=n.find(a=>a.pluginId===d$1)??n[0],T=m.plugin.panel,C=h?!w:g[m.pluginId]??T.defaultCollapsed??false,A=On(t,T.preferredSize,o),M=a=>`${s}-tab-${a}`,b=`${s}-panel`,R=a=>f.current?.querySelector(`[data-plugin-tab="${a}"]`)?.focus(),D=a=>{h?l(!(w&&a===m.pluginId)):a===m.pluginId&&C&&p(P=>({...P,[a]:false})),c(a);},B=()=>{l(false),R(m.pluginId);},N=a=>{let P=n.findIndex(y=>y.pluginId===m.pluginId),k=n.length-1,G=a.key==="ArrowRight"||a.key==="ArrowDown"?P===k?0:P+1:a.key==="ArrowLeft"||a.key==="ArrowUp"?P===0?k:P-1:a.key==="Home"?0:a.key==="End"?k:null;if(G===null)return;a.preventDefault();let i=n[G].pluginId;c(i),R(i);},z=r(C?"plugins.expandPanel":"plugins.collapsePanel",{title:T.title}),K=t==="bottom",j=h||!K&&C,$=jsx(Ln,{host:e,activation:m,id:b,labelledBy:M(m.pluginId)},m.key);return jsxs("section",{...Ie,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:V.surface,color:V.text,...K?{height:C?void 0:A,borderTop:`1px solid ${V.border}`}:{width:C||h?void 0:A,maxWidth:C||h?96:void 0,[t==="left"?"borderRight":"borderLeft"]:`1px solid ${V.border}`}},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:4,flexWrap:"wrap"},children:[jsx("div",{ref:f,role:"tablist","aria-label":r("plugins.panelTabs"),"aria-orientation":j?"vertical":"horizontal",onKeyDown:N,style:{display:"flex",flexDirection:j?"column":"row",gap:2,flex:1,minWidth:0,overflow:"hidden"},children:n.map(a=>{let P=a.pluginId===m.pluginId;return jsx("button",{type:"button",role:"tab",id:M(a.pluginId),"data-plugin-tab":a.pluginId,"aria-selected":P,"aria-controls":P&&!C?b:void 0,"aria-expanded":h?P&&w:void 0,tabIndex:P?0:-1,title:a.plugin.panel.title,onClick:()=>D(a.pluginId),style:Hn(P),children:a.plugin.panel.title},a.pluginId)})}),!h&&jsx("button",{type:"button","aria-expanded":!C,"aria-label":z,title:z,onClick:()=>p(a=>({...a,[m.pluginId]:!C})),style:Mt,children:C?"+":"\u2212"})]}),!C&&!h&&$,w&&jsxs("div",{ref:u,tabIndex:-1,"data-testid":`plugin-drawer-${t}`,onKeyDown:a=>{a.key==="Escape"&&(a.stopPropagation(),B());},style:{position:"absolute",top:0,bottom:0,[t==="left"?"left":"right"]:"100%",width:Math.min(A,Math.max(Ye[t],o.width-64)),zIndex:60,display:"flex",flexDirection:"column",background:V.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":z,title:z,onClick:B,style:Mt,children:"\xD7"})}),$]})]})}function Ur({host:e,activations:t,layerRef:n,claimPointerEvents:o}){return jsx("div",{ref:n,...Ie,className:"pptx-plugin-overlays","data-plugin-overlays":"","data-testid":"plugin-overlays",style:{position:"absolute",inset:0,pointerEvents:"none",overflow:"visible"},children:t.map(r=>{let s=r.plugin.overlay,d=r.context.geometry;return s&&d?jsx(Oe,{host:e,activation:r,claimPointerEvents:o,children:jsx(s,{context:r.context,geometry:d})},r.key):null})})}var Ot=50,Gn=.005,Bn=300;function _n(e,t,n$1,o){let r=n$1===WheelEvent.DOM_DELTA_LINE?16:n$1===WheelEvent.DOM_DELTA_PAGE?o:1,s=Math.max(-Ot,Math.min(Ot,t*r));return Math.min(n,Math.max(m,e*Math.exp(-s*Gn)))}function Jr(e,t,n,o,r){let s=useRef(n),d=useRef(n),c=useRef(r),g=useRef(o),p=useRef(null),v=useRef(null),l=useRef(null),f=useRef(null);g.current=o,useLayoutEffect(()=>{Object.is(c.current,r)&&n===d.current||(c.current=r,d.current=n,s.current=n,p.current?.());},[r,n]),useEffect(()=>{let u=e.current;if(!u)return;let h=u.ownerDocument.defaultView,w=()=>{let b=f.current,R=t.current;if(!b||!R)return;let D=R.getBoundingClientRect();Math.abs(D.width-b.width)>=.5||Math.abs(D.height-b.height)>=.5||(T(),u.scrollLeft+=D.left+b.anchorX*D.width-b.clientX,u.scrollTop+=D.top+b.anchorY*D.height-b.clientY);},m=typeof ResizeObserver>"u"?null:new ResizeObserver(w),T=()=>{f.current=null,m?.disconnect();},C=()=>{let b=s.current;b!==null&&(d.current=b,g.current(b));},A=b=>{if(!b.ctrlKey||b.metaKey||b.altKey||!b.cancelable)return;let R=t.current,D=s.current;if(!R||D===null)return;b.preventDefault(),f.current&&b.timeStamp-f.current.timeStamp>Bn&&T();let B=_n(D,b.deltaY,b.deltaMode,u.clientHeight);if(B===D)return;let N=R.getBoundingClientRect(),z=f.current,K=z?.baseWidth??(D>0?N.width/D:N.width),j=z?.baseHeight??(D>0?N.height/D:N.height),$=z?.anchorX??(N.width>0?(b.clientX-N.left)/N.width:.5),a=z?.anchorY??(N.height>0?(b.clientY-N.top)/N.height:.5),P=K*B,k=j*B;if(f.current={width:P,height:k,baseWidth:K,baseHeight:j,anchorX:$,anchorY:a,clientX:b.clientX,clientY:b.clientY,timeStamp:b.timeStamp},m?.disconnect(),m?.observe(R),s.current=B,!h){C();return}v.current===null&&(v.current=h.requestAnimationFrame(()=>{v.current=null,C(),l.current!==null&&h.cancelAnimationFrame(l.current),l.current=h.requestAnimationFrame(()=>{l.current=null,w();});}));},M=()=>{T(),h&&v.current!==null&&(h.cancelAnimationFrame(v.current),v.current=null),h&&l.current!==null&&(h.cancelAnimationFrame(l.current),l.current=null);};return p.current=M,u.addEventListener("wheel",A,{passive:false}),()=>{u.removeEventListener("wheel",A),M(),p.current=null;}},[t,r,e]);}function Lt(e,t,n,o,r=false){if(r&&t.length===2&&e.width>0&&e.height>0){let p=t.includes("w")?-n.x:n.x,v=t.startsWith("n")?-n.y:n.y,l=Math.max(1+(p*e.width+v*e.height)/(e.width**2+e.height**2),o/e.width,o/e.height),f=Math.round(e.width*l),u=Math.round(e.height*l);return {x:t.includes("w")?e.x+e.width-f:e.x,y:t.startsWith("n")?e.y+e.height-u:e.y,width:f,height:u}}let{x:s,y:d,width:c,height:g}=e;if(t.includes("w")){let p=Math.min(n.x,c-o);s+=p,c-=p;}else t.includes("e")&&(c=Math.max(o,c+n.x));if(t.startsWith("n")){let p=Math.min(n.y,g-o);d+=p,g-=p;}else t.startsWith("s")&&(g=Math.max(o,g+n.y));return {x:s,y:d,width:c,height:g}}var ni=["nw","n","ne","e","se","s","sw","w"],Fn=6,jn=76200,Wn=Math.fround(Math.fround(Math.PI)/180);function oi(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,s=(o-e.top)*t.height/e.height;return Number.isFinite(r)&&Number.isFinite(s)?{x:r,y:s}:null}function ge(e,t){for(let n of e){if(n.id===t)return n;let o=ge(n.children,t);if(o)return o}return null}function ri(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 ii(e,t){for(let n of e.shapes)if(n.id===t||ge(n.children,t))return n;return null}function si(e,t){return !!(e&&e.id===t.slideId&&ge(e.shapes,t.shapeId))}function li(e,t){return e?.pointerId===t}function Ne(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 Kn(e){return Ne(e)!==null}function $n(e){let n=((e.inherited?.rotationDeg??e.rotationDeg)%360+360)%360,o=e.inherited?.flipH??e.flipH,r=e.inherited?.flipV??e.flipV;return Kn(e)&&n===0&&!o&&!r}function ze(e,t,n){let o=Je(t,n);if(o)return o;let r=Ne(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 Je(e,t){let n=new Set;Bt(t,n);let o=e.primitives.filter(p=>p.shapeId&&n.has(p.shapeId));if(o.length===0)return null;let r=o.map(p=>{let v=(p.transform?.rotationDeg??0)*Math.PI/180,l=Math.abs(p.w*Math.cos(v))+Math.abs(p.h*Math.sin(v)),f=Math.abs(p.w*Math.sin(v))+Math.abs(p.h*Math.cos(v));return {x:p.x+(p.w-l)/2,y:p.y+(p.h-f)/2,width:l,height:f}}),s=Math.min(...r.map(p=>p.x)),d=Math.min(...r.map(p=>p.y)),c=Math.max(...r.map(p=>p.x+p.width)),g=Math.max(...r.map(p=>p.y+p.height));return {x:s,y:d,width:c-s,height:g-d}}function ai(e,t,n,o){let r=e.primitives.find(l=>l.kind==="textBox"&&l.shapeId===t&&l.storyId===n);if(!r||r.lines.length===0)return null;let s=Nt(r,o),d=Gt(r),c=0;for(let l=1;l<r.lines.length;l+=1){let f=r.lines[l],u=r.lines[c];He(f,s,d)<He(u,s,d)&&(c=l);}let g=r.lines[c],p=g.caretStops[0];return p?{position:g.caretStops.reduce((l,f)=>Math.abs(f.x-s.x)<Math.abs(l.x-s.x)?f:l,p).position,lineIndex:c}:{position:g.start,lineIndex:c}}function Xn(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 s=zt(r,n);if(s)return r.kind==="textBox"&&r.storyId&&Un(r,s)?"text":"shape"}return null}function Nt(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)),s=o(o(e.y)+o(o(e.h)/2)),d=o(o(n.rotationDeg??0)*Wn),c=o(Math.cos(d)),g=o(Math.sin(d)),p=o(t.x-r),v=o(t.y-s),l=o(o(p*c)+o(v*g)),f=o(o(v*c)-o(p*g));return n.flipH&&(l=-l),n.flipV&&(f=-f),{x:o(r+l),y:o(s+f)}}function Ht(e,t){return Math.fround(Math.fround(e)+Math.fround(t))}function zt(e,t){let n=Nt(e,t);return n.x>=Math.fround(e.x)&&n.x<=Ht(e.x,e.w)&&n.y>=Math.fround(e.y)&&n.y<=Ht(e.y,e.h)?n:null}function Gt(e){return e.lines.some((t,n)=>n>0&&(t.columnOffset??0)!==(e.lines[n-1].columnOffset??0))}function He(e,t,n){let o=Math.max(e.x-t.x,t.x-e.x-e.width,0),r=Vn(e.y,e.height,t.y);return n?o*o+r*r:r}function Un(e,t){if(e.lines.length===0)return false;let n=Gt(e);return e.lines.reduce((r,s)=>He(s,t,n)<He(r,t,n)?s:r).caretStops.length>0}function ui(e,t,n,o){let r=Ne(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 di(e,t,n,o,r=4){return Math.hypot(n-e,o-t)>=r}function Bt(e,t){t.add(e.id);for(let n of e.children)Bt(n,t);}function Vn(e,t,n){return n<e?e-n:n>e+t?n-e-t:0}function ci(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 pi(e){return e==="nw"||e==="se"?"nwse-resize":e==="ne"||e==="sw"?"nesw-resize":e==="n"||e==="s"?"ns-resize":"ew-resize"}function qn(e,t,n,o,r=false){return Lt(e,t,n,o,r)}function fi(e,t,n){return n?{x:n.x-e.x,y:n.y-e.y}:t}function Yn(e,t,n,o,r){if(!$n(n))return null;let s={x:Math.round(r.x*e.widthEmu/t.width),y:Math.round(r.y*e.heightEmu/t.height)},d=Ne(n);if(!d)return null;let c=qn(d,o,s,jn,n.aspectRatioLocked);return {x:c.x,y:c.y,width:c.width,height:c.height}}function gi(e,t,n,o,r){let s=Yn(e,t,n,o,r);return !s||e.widthEmu<=0||e.heightEmu<=0?null:{x:s.x*t.width/e.widthEmu,y:s.y*t.height/e.heightEmu,width:s.width*t.width/e.widthEmu,height:s.height*t.height/e.heightEmu}}function mi(e,t,n=1){let o=Xn(e,t);if(o!=="text")return o;let r={x:Math.fround(t.x),y:Math.fround(t.y)};for(let s=e.primitives.length-1;s>=0;s-=1){let d=e.primitives[s];if(!d.shapeId)continue;let c=zt(d,r);if(c)return Zn(d,c,n)?"shape":"text"}return o}function Zn(e,t,n){let o=Number.isFinite(n)&&n>0?n:1,r=Math.min(Fn/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}function Pi(e,t){let n=e()[0]?.ownerDocument??globalThis.document,o=n.defaultView,r=null,s=true,d=typeof n.hasFocus=="function"?n.hasFocus():true,c=false,g=[],p=new MutationObserver(()=>u()),v=()=>{let M=e().filter(b=>b.isConnected);if(!(M.length===g.length&&M.every((b,R)=>b===g[R]))){p.disconnect(),g=M;for(let b of g)p.observe(b,{childList:true,subtree:true});}},l=M=>M instanceof Node&&M.isConnected&&!(M instanceof Element?M:M.parentElement)?.closest("[data-plugin-overlays]")&&e().some(b=>b.isConnected&&b.contains(M)),f=M=>{s&&(M?v():(p.disconnect(),g=[]),r!==M&&(r=M,t(M)));},u=()=>f(d&&l(n.activeElement)),h=()=>{c||(c=true,queueMicrotask(()=>{c=false,s&&u();}));},w=M=>f(d&&l(M.target)),m=M=>{l(M.relatedTarget)?f(d):h();},T=()=>{d=false,f(false);},C=()=>{d=true,h();};return n.addEventListener("focusin",w,true),n.addEventListener("focusout",m,true),o.addEventListener("blur",T),o.addEventListener("focus",C),u(),Object.assign(()=>{s=false,p.disconnect(),n.removeEventListener("focusin",w,true),n.removeEventListener("focusout",m,true),o.removeEventListener("blur",T),o.removeEventListener("focus",C);},{recheck:()=>{s&&u();}})}var Jn=Object.freeze({commands:Object.freeze([])});function _t(e){if(!e||typeof e!="object")return Jn;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 Ft(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,s)=>r===o[s])}function jt(e,t){return e.commands?.includes(t)??false}function Wt(e){return e.document==="write"}function Qe(e,t){return e.document==="write"&&e.editBatches===true&&(t!=="none"||e.untrackedHistory===true)}var Qn=/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9])?$/;function eo(e){return typeof e=="string"&&Qn.test(e)}function Kt(e){return e.revision===void 0?"":`${typeof e.revision}:${e.revision}`}var $t=10;function et(e){return e.type==="load"?"document-change":e.type}function to(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function tt(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 Xt(e){let t=new Map,n=null,o=false,r={},s=new Map,d=new WeakSet,c=new Set,g=new Set,p=0,v=0,l=null,f=[],u=false,h=new Set,w=()=>!u&&[...t.values()].every(({activation:i})=>!i||i.status==="disposed"||i.status==="ready"&&!i.running&&!i.pumping&&!i.pending.length),m=()=>{if(!(!h.size||!w())){for(let i of h)i();h.clear();}},T=i=>{try{e.report(i);}catch(y){console.error("[plugins] onPluginError threw",y);}},C=i=>{let y=Object.hasOwn(r,i)?r[i]:void 0,x=s.get(i);if(x&&x.source===y)return x.grant;let S=_t(y);return s.set(i,{source:y,grant:S}),S},A=i=>{let y=`${p}:${i.stateRevision}`;if(i.rendered?.key===y)return i.rendered.entry;let x=z(i,i.lifetime.signal),S={pluginId:i.registration.id,plugin:i.registration.plugin,generation:i.generation,activation:i.token,key:i.key,context:e.context(x,i.registration.plugin)};return i.rendered={key:y,entry:S},S},M=()=>{u=false;let i=[];for(let x of t.values()){let S=x.activation;S?.status==="ready"&&i.push(A(S));}i.length===f.length&&i.every((x,S)=>x===f[S])||(f=i);for(let x of [...g])x();m();},b=()=>{p+=1,!u&&(u=true,queueMicrotask(M));},R=(i,y)=>i.status==="disposed"?i.ended==="document-replaced"?"document-replaced":"plugin-unavailable":y.aborted?"aborted":null,D=(i,y,x)=>{let S=E=>T({pluginId:i.registration.id,generation:i.generation,phase:"cleanup",error:E});try{let E=y(x);to(E)&&E.then(void 0,S);}catch(E){S(E);}},B=(i,y)=>{if(i.status!=="disposed"){i.status="disposed",i.ended=y,i.pending=[],i.registration.activation===i&&(i.registration.activation=null),i.lifetime.abort();for(let x of i.cleanups.splice(0).reverse())D(i,x,y);b();}},N=(i,y,x)=>{i.status!=="disposed"&&(i.registration.quarantined=true,T({pluginId:i.registration.id,generation:i.generation,phase:y,error:x}),B(i,"failed"));};function z(i,y){let x=e.snapshot(i.registration.id,i.generation);return {pluginId:i.registration.id,activation:i.token,snapshot:x,signal:y,lifetimeSignal:i.lifetime.signal,state:()=>i.state,setState(E,I){if(R(i,y)!==null)return false;let O=e.currentVersion();return O===null||(I??x.version)!==O?false:(i.state=typeof E=="function"?E(i.state):E,i.stateRevision+=1,b(),true)},onCleanup(E){if(typeof E!="function")throw new TypeError("A cleanup must be a function");i.status==="disposed"?D(i,E,i.ended??"unmounted"):i.cleanups.push(E);},run:E=>K(i,E),commit(E){let I=l;l=y;try{return E()}finally{l=I;}},refusal:()=>R(i,y)}}async function K(i,y){let{controller:x,release:S}=tt(i.lifetime.signal);if(!x.signal.aborted)try{await y(z(i,x.signal));}catch(E){x.signal.aborted||N(i,"action",E);}finally{S();}}async function j(i,y,x,S){let{controller:E,release:I}=tt(i.lifetime.signal);i.running={channel:x,controller:E};try{let O=z(i,E.signal);return await S(e.context(O,i.registration.plugin),O),i.status==="disposed"?"ended":E.signal.aborted?"aborted":"ok"}catch(O){return i.status==="disposed"?"ended":E.signal.aborted?"aborted":(N(i,y,O),"ended")}finally{I(),i.running?.controller===E&&(i.running=null);}}async function $(i){if(!i.pumping){i.pumping=true;try{for(;i.status==="ready";){let y=i.pending.shift();if(!y)break;if(!i.registration.plugin.onEvent)continue;if(await j(i,"event",et(y),(S,E)=>{if(!e.eventCurrent||e.eventCurrent(y,E.snapshot))return i.registration.plugin.onEvent?.(S,y)})==="ended")break}}finally{i.pumping=false,m();}}}let a=(i,y)=>{if(i.status==="disposed"||y.generation!==i.generation)return;let x=et(y),S=i.pending.findIndex(I=>et(I)===x);if(S>=0){if(i.pending[S].type==="load")return;i.pending[S]=y;}else i.pending.push(y);let E=i.running;E?.channel===x&&E.controller.signal!==l&&E.controller.abort(),i.status==="ready"&&queueMicrotask(()=>{$(i);});};async function P(i,y,x){v+=1;let S={token:Object.freeze({}),key:`${i.id}#${v}`,registration:i,generation:y,lifetime:new AbortController,status:"initializing",ended:null,state:void 0,stateRevision:0,cleanups:[],pending:[],running:null,pumping:false,rendered:null};i.activation=S;try{S.state=i.plugin.createState();}catch(I){N(S,"initialize",I);return}if(i.plugin.initialize&&await j(S,"initialize","initialize",O=>S.registration.plugin.initialize?.(O))==="ended")return;let E="aborted";for(let I=0;E==="aborted"&&S.status!=="disposed";I+=1){if(I===$t){N(S,"event",new Error(`Document changes superseded the load hook ${$t} times`));return}S.pending=[],E=await j(S,"event","document-change",(O,F)=>S.registration.plugin.onEvent?.(O,e.loadEvent(F.snapshot,x)));}E!=="ok"||S.status==="disposed"||(S.status="ready",b(),$(S));}let k=(i,y)=>T({pluginId:i,generation:n,phase:"definition",error:y}),G=i=>{n=null,i==="unmounted"&&(o=false);for(let y of t.values())y.activation&&B(y.activation,i);b();};return {setPlugins(i){let y=new Map;for(let I of i){let O=eo(I?.id)?e.validate?.(I):new TypeError(`Invalid plugin id ${JSON.stringify(I?.id)}`);if(O!=null){I&&typeof I=="object"&&!d.has(I)&&(d.add(I),k(typeof I.id=="string"?I.id:"",O));continue}let F=y.get(I.id);F?F.push(I):y.set(I.id,[I]);}let x=new Set,S=new Map,E=[];for(let[I,O]of y){if(O.length>1){x.add(I),c.has(I)||k(I,new Error(`${O.length} plugins share the id "${I}"`));continue}let F=O[0],_=t.get(I);if(_&&Kt(_.plugin)===Kt(F)){_.plugin=F,S.set(I,_);continue}_&&E.push([_,"definition-replaced"]),S.set(I,{id:I,plugin:F,quarantined:false,activation:null});}c=x;for(let[I,O]of t)S.has(I)||E.push([O,"removed"]);t=S;for(let[I,O]of E)I.activation&&B(I.activation,O);if(n!==null)for(let I of t.values())!I.activation&&!I.quarantined&&P(I,n,"attached");b();},registered:()=>new Map([...t].map(([i,y])=>[i,y.plugin])),setGrants(i){let y=new Map([...t.keys()].map(S=>[S,C(S)]));r=i??{},s.clear();let x=false;for(let S of t.values()){let E=C(S.id),I=y.get(S.id);if(Ft(I,E)){s.get(S.id).grant=I;continue}x=true;let O=S.activation;O&&a(O,e.grantsEvent(e.snapshot(S.id,O.generation),E));}x&&b();},grant:C,open(i){if(n===i)return;n!==null&&G("document-replaced"),n=i;let y=o?"replaced":"loaded";o=true;for(let x of t.values())x.quarantined=false,P(x,i,y);b();},close:G,generation:()=>n,notify(i){if(i.generation===n){for(let y of t.values())y.activation&&a(y.activation,i);b();}},notificationsIdle(){return w()?Promise.resolve():new Promise(i=>h.add(i))},touch:b,activations:()=>f,activationState(i){let y=t.get(i),x=y?.activation;return !x||y.quarantined||n===null||x.generation!==n||x.status==="disposed"?"none":x.status==="ready"?"ready":"loading"},subscribe(i){return g.add(i),()=>{g.delete(i);}},guard(i,y,x,S){let E=t.get(i)?.activation;if(E?.status!=="ready")return S;try{return x(A(E).context)}catch(I){return queueMicrotask(()=>N(E,y,I)),S}},async invoke(i,y,x){let S=t.get(i)?.activation;if(S?.status!=="ready")return {ok:false,reason:"plugin-unavailable"};let{controller:E,release:I}=tt(S.lifetime.signal),O=z(S,E.signal);try{return {ok:!0,value:await x(e.context(O,S.registration.plugin))}}catch(F){let _=O.refusal();return _?{ok:false,reason:_}:(N(S,y,F),{ok:false,reason:"failed"})}finally{I();}},fail(i,y,x){let S=t.get(i)?.activation;S&&N(S,y,x);}}}var no={"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"},oo={"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 me(e,t=no[e]){return {ok:false,failure:{code:e,message:t}}}function de(e){let t=e.refusal();return t?me(t):null}function nt(e$1,t,n){return {gesture:()=>f(e(e$1.activation)),deny(o){let r=e$1.refusal();if(r)return r;if(G(o))return o.startsWith(`plugin:${e$1.pluginId}/`)?null:"permission-denied";let s=t();return !jt(s,o)||E[o].mutatesDocument&&!Wt(s)?"permission-denied":null},subscribe:n}}function ro(e,t,n){return !n()&&e.some(o=>o.aborted)?Promise.resolve(null):new Promise((o,r)=>{let s=()=>{n()||(d(),o(null));},d=()=>{for(let c of e)c.removeEventListener("abort",s);};for(let c of e)c.addEventListener("abort",s,{once:true});t.then(c=>{d(),o(c);},c=>{d(),r(c);});})}function Ut(e,t,n,o){let r=async l=>{let f=de(e);if(f)return f;let u=t.handle();if(!u)return me("plugin-unavailable");let h=false,w=await ro([e.signal,e.lifetimeSignal],t.admit(u,()=>{let m=de(e);return m?{refused:m}:(h=true,{value:l(u)})}),()=>h);return w?w.ok?"refused"in w.value?w.value.refused:w.value.value:de(e)??me(w.code):de(e)??me("aborted")},s={version:()=>r(l=>({ok:true,version:l.version()})),readContent:l=>r(f=>f.readContent(l)),findText:l=>r(f=>f.findText(l)),validateEdits:l=>r(f=>t.readOnlyRefusal(f)??f.validateEdits(l))},d=l=>de(e)??(Qe(n(),l)?null:me("permission-denied")),c=Qe(n(),"separate")?{async applyEdits(l){let f=d(l.history);return f||r(u=>t.applyEdits(u,l,()=>d(l.history),h=>e.commit(h)))}}:null,g={getDescriptor:l=>o.getDescriptor(l),getState:(l,f)=>o.getState(l,f),subscribe:l=>o.subscribe(l),execute:async(l,f)=>de(e)??o.execute(l,f)},p=async(l,f)=>{let u=await r(h=>h.version()===l?.expectVersion?f(h,l.focus===true):"stale-version");return u===null?{ok:true}:typeof u=="object"?u:{ok:false,failure:{code:u,message:oo[u]}}};return {read:s,commands:g,edits:c,navigation:{goToSlide:(l,f)=>p(f,(u,h)=>t.navigator.goToSlide(u,l,h)),selectShape:(l,f)=>p(f,(u,h)=>t.navigator.selectShape(u,l,h)),selectText:(l,f)=>p(f,(u,h)=>t.navigator.selectText(u,l,h))}}}function ot(e,t){return e?.scoped(t)??L$1}var io=Object.freeze({enabled:true});function so(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 lo(e){let t=e;return t&&typeof t.ok=="boolean"?e:{ok:true,status:"executed"}}function Vt(e,t){return e===t||!!e&&!!t&&e.id===t.id&&e.version===t.version}function qt(e,t){return e?.focusLine===t?.focusLine&&e?.affinity===t?.affinity}function Ge(e){try{return e.version()}catch{return null}}function Ni(e$1,t){let n=t??((a,P,k)=>{if(!("handle"in e$1))throw new TypeError("Plugin clients require document access");return Ut(a,e$1,P,k)}),o,r$1=null,s$1=null,d=null,c=false,g=0,p=null,v=null,l={version:"",readOnly:false,focused:false,locale:"en",selection:null,caretHint:void 0,layout:null},f=new WeakMap,u=new WeakMap,h=0,w=a=>{let P=u.get(a);return P===void 0&&(h+=1,P=h,u.set(a,P)),P},m=new WeakSet,T=new Set,C=a=>{if(!o){console.error(`[PptxEditor] plugin "${a.pluginId}" failed (${a.phase})`,a.error);return}try{o(a);}catch(P){console.error("[PptxEditor] onPluginError threw",P);}},A=()=>e$1.commands(),M=a=>{let P=()=>R.grant(a.pluginId);if(a.signal!==a.lifetimeSignal)return nt(a,P,R.subscribe);let k=f.get(a.activation);return k||(k=nt(a,P,R.subscribe),f.set(a.activation,k)),k},b=a=>{let P=a.pluginId,k=n(a,()=>R.grant(P),ot(A(),M(a))),G=l.caretHint,i=e$1.geometry(a.snapshot.selection,G),y=x=>!i||a.refusal()||x.kind==="selection"&&(JSON.stringify(a.snapshot.selection)!==JSON.stringify(l.selection)||!qt(G,l.caretHint))?{ok:false,failure:{code:"layout-unavailable",message:"The plugin context is no longer current."}}:i.getAnchorGeometry(x);return {pluginId:P,snapshot:a.snapshot,get state(){return a.state()},signal:a.signal,lifetimeSignal:a.lifetimeSignal,read:k.read,commands:k.commands,edits:k.edits,geometry:i&&a.snapshot.layout?.id===i.layout.id?{layout:i.layout,get viewport(){return i.viewport},getAnchorGeometry:y,readAnchorGeometries:x=>Promise.resolve(x.map(y)),toOverlayRect:i.toOverlayRect,getShapeRect:i.getShapeRect,getPositionAtPoint:i.getPositionAtPoint}:null,navigation:k.navigation,setState:(x,S)=>a.setState(x,S),onCleanup:x=>a.onCleanup(x),run:x=>a.run(S=>x(b(S)))}},R=Xt({context:a=>b(a),snapshot:(a,P)=>({generation:P,version:l.version,readOnly:l.readOnly,focused:l.focused,locale:l.locale,grant:R.grant(a),selection:l.selection,layout:l.layout}),currentVersion:()=>s$1&&R.generation()!==null?Ge(s$1):null,loadEvent:(a,P)=>({type:"load",generation:a.generation,version:a.version,reason:P}),grantsEvent:(a,P)=>({type:"grants-change",generation:a.generation,grant:P}),validate:s,report:C}),D$1=a=>R.notify(a),B=()=>{let a=R.generation(),P=l.layout?e$1.geometry():null,k=P&&Vt(P.layout,l.layout)?P.viewport??null:null;p===k||p&&k&&p.x===k.x&&p.y===k.y&&p.width===k.width&&p.height===k.height||(p=k?{...k}:null,a&&D$1({type:"viewport-change",generation:a,viewport:p}));},N=()=>{let a=R.generation(),P=s$1?Ge(s$1):null;!a||!P||P===l.version||(l.version=P,D$1({type:"document-change",generation:a,version:P}),l.layout&&l.layout.version!==P&&(l.layout=null,D$1({type:"layout-change",generation:a,layout:null}),B()));},z=()=>{if(!c||!s$1){d?.(),d=null;return}if(!d){l.version=Ge(s$1)??l.version;try{d=s$1.onUpdate(N);}catch(a){console.error("[PptxEditor] observing presentation changes for plugins failed",a);}}},K=()=>{d?.(),d=null,s$1=null;},j$1=(a,P)=>R.guard(a,"command-state",k=>so(P.getState?P.getState(k):io),{enabled:false,disabledReason:j("plugin-unavailable",{translate:e$1.translate})}),$=async(a,P)=>{let k=await R.invoke(a,"command",i=>P.execute(i));if(k.ok)return lo(k.value);let G=k.reason==="failed"?"command-failed":k.reason;return {ok:false,failure:j(G,{translate:e$1.translate})}};return {setPlugins(a){let P=[];for(let k of a??[]){let G=r(k);if(G){P.push(G);continue}if(k!==null&&typeof k=="object"){if(m.has(k))continue;m.add(k);}C({pluginId:typeof k?.id=="string"?k.id:"",generation:R.generation(),phase:"definition",error:new TypeError("Plugins must be created with definePptxPlugin")});}c=P.length>0,z(),R.setPlugins(P);},setGrants:a=>R.setGrants(a),setReporter(a){o=a;},open(a){K(),s$1=a,l.version=Ge(a)??"",l.layout=null,l.selection=null,l.caretHint=void 0,z(),p=null,g+=1,R.open(`presentation-${g}`),r$1?.();},close(a){K(),l.layout=null,R.close(a),r$1?.();},generation:()=>R.generation(),version:()=>l.version,selectionChanged(a,P){let k=JSON.stringify(a)!==JSON.stringify(l.selection);if(!k&&qt(P,l.caretHint))return;if(l.caretHint=P?{...P}:void 0,!k){R.touch();return}l.selection=a;let G=R.generation();G&&D$1({type:"selection-change",generation:G,version:l.version,selection:a});},focusChanged(a){if(a===l.focused)return;l.focused=a;let P=R.generation();P&&D$1({type:"focus-change",generation:P,focused:a});},setFocusCheck(a){r$1=a;},localeChanged(a){if(a===l.locale)return;l.locale=a;let P=R.generation();P&&D$1({type:"locale-change",generation:P,locale:a});},modeChanged(a){if(a===l.readOnly)return;l.readOnly=a;let P=R.generation();P&&D$1({type:"mode-change",generation:P,readOnly:a});},layoutChanged(a){let P=a&&a.version===l.version?a:null;if(Vt(P,l.layout))return;l.layout=P;let k=R.generation();k&&D$1({type:"layout-change",generation:k,layout:P}),B();},layoutId:()=>R.generation()===null?null:l.layout?.id??null,geometryChanged(){B(),R.touch();},activations:()=>R.activations(),subscribe:a=>R.subscribe(a),commandStore(a){let P=f.get(a.activation);return P?ot(A(),P):L$1},syncCommands(){let a=A();if(!a)return;let P=[],k=[],G$1=new Map,i=[];for(let x of R.activations()){let S=x.plugin;i.push(`${x.pluginId}:${w(S)}:${w(x.activation)}`);for(let E of S.commands??[]){let I=`plugin:${x.pluginId}/${E.id}`,O=[],F=It(a,I);for(let _ of F??[])G$1.set(_,I),O.push({chord:_,args:null});for(let _ of F?[]:E.shortcuts??[]){let te=D(_),he=fe(a,te),rn=ie(te)||Et.has(te)&&!Rt(a,te),st=he!==void 0&&G(he)?he:rn?"text editing":he!==void 0?"a built-in command":G$1.get(te);if(!st){G$1.set(te,I),O.push({chord:_,args:null});continue}let lt=`${x.pluginId}\0${te}`;T.has(lt)||(T.add(lt),C({pluginId:x.pluginId,generation:x.generation,phase:"definition",error:new Error(`Shortcut ${_} of ${I} is already used by ${st}; it was not bound`)}));}P.push({descriptor:Object.freeze({id:I,label:E.label,mutatesDocument:E.mutatesDocument,shortcuts:Object.freeze(O)}),activationId:e(x.activation),state:()=>j$1(x.pluginId,E),execute:()=>$(x.pluginId,E)});}for(let E of S.toolbar??[])k.push(`plugin:${x.pluginId}/${E}`);}i.push(`shortcuts:${a.shortcutRevision()}`);let y=i.join("|");if(y===v){a.refresh();return}v=y,a.setPluginCommands(P,k);},guard:(a,P,k,G)=>R.guard(a,P,k,G),fail:(a,P,k)=>R.fail(a,P,k)}}var Be=9525,Yt=new WeakMap,Zt=new WeakMap,Jt=0;function co(e){let t=Zt.get(e);return t||(t=indexGeometry(e),Zt.set(e,t)),t}function po(e){let t=Yt.get(e);return t||(Jt+=1,t=`slide-layout-${Jt}`,Yt.set(e,t)),t}function _i(e,t){if(!e||t===null||e.version!==t)return null;let n=e.snapshot.slides[e.slideIndex];return n?{id:po(e),version:t,slideId:n.id,slide:e.slideIndex+1,zoom:e.scale,width:e.frame.width,height:e.frame.height}:null}function fo(e){let t=e;return !!t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}function go(e,t,n,o){let r=e.getBoundingClientRect(),s=t.getBoundingClientRect();if(!(n.width>0&&n.height>0&&r.width>0&&r.height>0))return null;let d=r.width/n.width,c=r.height/n.height,g=r.left-s.left-t.clientLeft+t.scrollLeft,p=r.top-s.top-t.clientTop+t.scrollTop;return {x:g+o.x*d,y:p+o.y*c,width:o.width*d,height:o.height*c}}function mo(e,t){let n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:n.left+e.clientLeft-o.left-t.clientLeft+t.scrollLeft,y:n.top+e.clientTop-o.top-t.clientTop+t.scrollTop,width:e.clientWidth,height:e.clientHeight}}function ho(e,t,n,o,r,s,d={}){let c=(p,v)=>({ok:false,failure:{code:p,message:v}}),g=p=>{if(!n())return c("layout-unavailable","The slide layout is no longer presented.");if(p.kind==="range"&&p.version!==e.version)return c("stale-version","The range belongs to a different presentation version.");let v=p.kind==="selection"?s():{slideId:p.slideId,slide:e.slide,target:{...p,kind:"text"}};if(!v)return c("missing-target","There is no selection.");if(v.slideId!==e.slideId)return c("layout-unavailable","The target slide is not presented.");let l=o({x:0,y:0,width:e.width,height:e.height});if(!l)return c("layout-unavailable","The slide has no displayed bounds.");let f=(b,R)=>({ok:true,rects:b,anchor:R,pageRect:l,version:e.version,layoutId:e.id}),u=v.target;if(u.kind==="slide")return f([l],l);if(u.kind==="shape"){let b=r(u.shapeId);return b?f([b],b):c("missing-target","The shape is not displayed.")}let h=t.hits.find(({primitive:b})=>b.kind==="textBox"&&b.shapeId===u.shapeId&&b.storyId===u.storyId);if(!h||!Number.isInteger(u.anchor)||!Number.isInteger(u.focus)||Math.min(u.anchor,u.focus)<0||Math.max(u.anchor,u.focus)>(h.textLength??0))return c("missing-target","The text range does not exist.");let w=JSON.stringify([u.shapeId,u.storyId]),m=p.kind==="selection"&&u.anchor===u.focus&&d.focusLine!==void 0?t.lines.get(w)?.[d.focusLine]:void 0,T=m&&u.focus>=m.line.start&&u.focus<=m.line.end?{...t,lines:new Map([[w,[m]]])}:t,C=selectionGeometry(T,{slideId:v.slideId,shapeId:u.shapeId,storyId:u.storyId,anchor:u.anchor,focus:u.focus,affinity:p.kind==="selection"?d.affinity??"downstream":"downstream"}),A=[];if(u.anchor!==u.focus)for(let b of C.selectionRects){let R=o(b);if(!R)return c("layout-unavailable","The slide has no displayed bounds.");A.push(R);}let M=u.anchor===u.focus?C.caret&&o(C.caret):A[u.focus>u.anchor?A.length-1:0];return M?f(A,M):c("missing-target","The text range is not displayed.")};return {getAnchorGeometry:g,readAnchorGeometries:p=>Promise.resolve(p.map(g))}}function Fi(e,t,n,o,r,s,d=o,c=()=>null,g={}){let p=l=>r()?go(n,o,t.frame,l):null,v=l=>{let f=t.snapshot.slides[t.slideIndex],u=f&&typeof l=="string"?ge(f.shapes,l):null,h=u?Je(t.frame,u):null;return h?p(h):null};return {layout:e,...ho(e,co(t.frame),r,p,v,c,g),get viewport(){return mo(d,o)},toOverlayRect(l){let f=l?.rect;return fo(f)?l.space==="slide-px"?p(f):l.space!=="slide-emu"?null:p({x:f.x/Be,y:f.y/Be,width:f.width/Be,height:f.height/Be}):null},getShapeRect:v,getPositionAtPoint(l,f){if(!r())return null;let u=s(t.frame,l,f);return u?{...u,version:e.version,layoutId:e.id}:null}}}function bo({slideId:e,load:t,resolveImage:n,decodeImage:o}){let{t:r}=c$1(),s=r("errors.decodeSlideImage"),d=useRef(null);return useEffect(()=>{let c=false;return Promise.resolve().then(()=>t(e)).then(async g=>{try{if(c)return;let p=document.createElement("canvas"),v=p.getContext("2d");if(!v)return;let l=128/g.frame.width;sizeCanvasForSlide(p,g.frame,1,l);let f=b(g,g.resolveImage??n??(()=>null),s,o);try{await paintSlide(v,g.frame,1,l,{resolveImage:f.resolveImage,textChanges:g.textChanges.length?g.textChanges:void 0,shapeChanges:a$1(g)});}finally{f.release();}if(c||!d.current)return;sizeCanvasForSlide(d.current,g.frame,1,l),d.current.getContext("2d")?.drawImage(p,0,0);}finally{g.release?.();}}).catch(()=>{}),()=>{c=true;}},[e,t,n,s,o]),jsx("canvas",{ref:d,"aria-hidden":"true",style:{width:128,display:"block"}})}function So({entries:e,selectedSlideId:t,load:n,onSelect:o,resolveImage:r,decodeImage:s}){let{t:d}=c$1();return jsx("div",{"aria-label":d("proposals.slideStrip"),"data-testid":"pptx-proposal-slide-strip",children:e.map((c,g)=>jsxs("button",{type:"button","data-testid":`pptx-proposal-slide-${c.status}`,"data-slide-id":c.slideId,"aria-label":d("proposals.previewSlide",{number:g+1}),"aria-current":t===c.slideId?"page":void 0,onClick:()=>o(c.slideId),style:{display:"block",width:"100%",marginBottom:12,padding:4,cursor:"pointer",border:"2px solid #4338ca",borderStyle:c.status==="inserted"?"dashed":"solid",borderRadius:5,opacity:c.status==="deleted"?.4:1,background:t===c.slideId?"#e0e7ff":"#fff",color:"#4338ca"},children:[jsx("span",{children:g+1}),jsx(bo,{slideId:c.slideId,load:n,resolveImage:r,decodeImage:s}),c.status==="inserted"&&jsx("span",{"aria-label":d("proposals.insertedSlide"),children:"+"}),c.status==="deleted"&&jsx("span",{"aria-label":d("proposals.deletedSlide"),children:"-"}),c.status==="moved"&&jsx("span",{children:d("proposals.movedFrom",{number:(c.liveIndex??0)+1})})]},c.slideId))})}function Ui({id:e,read:t,...n}){let[o,r]=useState(null);return useEffect(()=>{let s=false;return t(e).then(d=>{s||r({id:e,entries:d});}).catch(()=>{}),()=>{s=true;}},[e,t]),jsx(So,{...n,entries:o?.id===e?o.entries:[]})}var Yi={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"}},Zi={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"}};function rt(e){let[t,n]=useState(e),o=useRef(t),r=useCallback(s=>{let d=typeof s=="function"?s(o.current):s;o.current=d,n(d);},[]);return [t,r,o]}function us(e,t,n,o){let[r,s,d]=rt(true),[c,g,p]=rt(null),[v,l]=useState(null),f=n?.slides[o]?.id,u=useMemo(()=>t.filter(C=>C.changes.some(A=>A.slideId===f)||(()=>{try{return e?.proposalSlideStrip(C.id).some(A=>A.status!=="unchanged")??!1}catch{return C.changes.some(A=>A.kind&&A.kind!=="content")}})()),[t,f,e,n]),h=u.find(C=>C.id===c)??u[0]??null,w=v?.proposalId===h?.id&&v?.liveSlideId===f&&v?.version===e?.version()?v?.slideId??null:null,m=useCallback((C,A=h?.id??null)=>{l({proposalId:A,slideId:C,liveSlideId:f,version:e?.version()});},[h?.id,f,e]),T=useMemo(()=>{if(!r||!e||!h)return {diff:null,error:null};try{return {diff:w||!f?e.layoutProposalDiffSlideById(h.id,w??e.proposalSlideStrip(h.id)[0].slideId):e.layoutProposalDiffSlide(h.id,o),error:null}}catch(C){return {diff:null,error:C instanceof Error?C.message:String(C)}}},[r,e,h,o,f,n,w]);return useEffect(()=>{s(true),g(null);},[e,s,g]),{...T,previewSlideId:w,selectSlide:m,available:u,selected:h,enabled:r,setEnabled:s,select:g,reviewing:r&&h!==null,enabledRef:d,selectedIdRef:p}}function ds({review:e,ready:t}){let{t:n}=c$1(),o=P(),r=e.selected?.id??"",s=Q("proposalAccept",{proposalId:r}),d=Q("proposalReject",{proposalId:r}),c=e.enabled&&!t,g=s.enabled?e.error?n("commands.reasons.previewFailed"):c?n("commands.reasons.previewPending"):void 0:s.disabledReason.message,p=s.enabled&&!e.error&&!c,v=Z(!p,g),l=Z(!d.enabled,d.enabled?void 0:d.disabledReason.message);if(!e.selected)return null;let f=e.selected.staleTargets.length>0;return jsxs("div",{style:L.toolbar,"data-testid":"pptx-canvas-review-toolbar",children:[jsxs("div",{style:L.row,children:[jsxs("label",{style:L.label,children:[n("proposals.canvasTitle"),jsx("select",{"aria-label":n("proposals.canvasTitle"),value:e.selected.id,onChange:u=>{o.execute("proposalSelect",{proposalId:u.target.value});},style:L.select,children:e.available.map((u,h)=>jsxs("option",{value:u.id,children:[h+1,". ",u.agentId,u.note?` \xB7 ${u.note}`:""]},u.id))})]}),jsx("button",{type:"button",style:L.button,"data-testid":"pptx-canvas-review-toggle","aria-pressed":e.enabled,onClick:()=>{o.execute("proposalDiff",{enabled:!e.enabled});},children:n(e.enabled?"proposals.editSlide":"proposals.showDiff")}),jsx("button",{type:"button",style:L.button,onClick:()=>{o.execute("proposalsPanel",{open:true});},children:n("proposals.details")}),jsx("button",{type:"button",style:{...L.primary,opacity:p?1:.45,cursor:p?"pointer":"default"},...v.props,title:v.reason,"data-testid":"pptx-canvas-proposal-accept",onClick:()=>{p&&o.execute("proposalAccept",{proposalId:r});},children:n("proposals.accept")}),v.node,jsx("button",{type:"button",style:L.button,...l.props,title:l.reason,"data-testid":"pptx-canvas-proposal-reject",onClick:()=>{d.enabled&&o.execute("proposalReject",{proposalId:r});},children:n("proposals.reject")}),l.node]}),e.enabled&&jsxs("div",{style:L.legend,children:[jsx("span",{style:L.removed,children:n("proposals.removed")}),jsx("span",{style:L.added,children:n("proposals.added")}),jsx("span",{children:n("proposals.reviewHint")})]}),f&&jsx("p",{role:"status",style:L.warning,children:n("proposals.canvasStale")}),e.error&&jsx("p",{role:"alert",style:L.warning,children:e.error})]})}function cs({diff:e,current:t,frame:n,scale:o,resolveImage:r,decodeImage:s,onTarget:d,onPainted:c}){let{t:g}=c$1(),p=g("errors.decodeSlideImage"),v=useRef(null),[l,f]=useState(null),[u,h]=useState(null);return useEffect(()=>{let w=false,m=v.current;if(!m)return;let T=document.createElement("canvas"),C=T.getContext("2d"),A=m.getContext("2d");if(!C||!A)return;let M=window.devicePixelRatio||1;sizeCanvasForSlide(T,e.frame,M,o),m.dataset.ready="false",f(null);let b$1=b(e,r,p,s);return paintSlide(C,e.frame,M,o,{resolveImage:b$1.resolveImage,textChanges:e.textChanges,shapeChanges:a$1(e)}).then(()=>{w||(sizeCanvasForSlide(m,e.frame,M,o),A.setTransform(1,0,0,1,0,0),A.drawImage(T,0,0),m.dataset.ready="true",h(e),c(e));}).catch(R=>{w||f(R instanceof Error?R.message:String(R));}).finally(b$1.release),()=>{w=true;}},[e,o,r,c,p,s]),jsxs("div",{style:L.overlay,"data-testid":"pptx-canvas-proposal-diff",children:[jsx("canvas",{ref:v,role:"img","aria-label":g("proposals.canvasTitle"),style:{...L.canvas,visibility:u===e?"visible":"hidden"}}),u!==e&&!l&&jsx("p",{role:"status",style:L.paintError,children:g("proposals.loadingDiff")}),jsx(To,{diff:e,current:t,frame:n,scale:o,onTarget:d}),l&&jsx("p",{role:"alert",style:L.paintError,children:l})]})}function To({diff:e,current:t,frame:n,scale:o,onTarget:r}){let{t:s}=c$1(),d=e.snapshot.slides[0]?.id,c=e.proposal.changes.filter(g=>g.slideId===d&&g.shapeId&&(g.before||g.after));return jsxs(Fragment,{children:[c.map(g=>{let p=g.before?ze(t,n,g.before):null,v=g.after?ze(e.snapshot,e.frame,g.after):g.before?ze(e.snapshot,e.frame,g.before):null,l=e.shapeChanges?.find(m=>m.shapeId===g.shapeId)?.kind,f=l==="deleted"||g.kind==="deleted",u=l==="inserted"||g.kind==="inserted";if(!v)return null;let h=!f&&p&&(p.x!==v.x||p.y!==v.y||p.width!==v.width||p.height!==v.height),w=m=>({left:m.x*o,top:m.y*o,width:Math.max(1,m.width*o),height:Math.max(1,m.height*o)});return jsxs("div",{children:[h&&jsx("span",{"data-testid":"pptx-proposal-old-bounds",style:{...L.outline,...w(p),borderColor:"#b91c1c",borderStyle:"dashed",pointerEvents:"none"},"aria-hidden":"true",children:jsx("span",{style:{...L.tag,color:"#b91c1c",background:"#fee2e2"},children:s("proposals.previousPosition")})}),jsxs("button",{type:"button","data-testid":"pptx-proposal-canvas-target","aria-label":`${e.proposal.agentId}: ${(g.after??g.before).name}`,"data-shape-change":l??g.kind??"changed",onClick:()=>r(g.slideId,g.shapeId),style:{...L.outline,...w(v),borderColor:"#4338ca",borderStyle:u||f?"dashed":"solid",cursor:"pointer"},children:[(u||f)&&jsx("span",{style:L.tag,children:s(f?"proposals.deletedShape":"proposals.insertedShape")}),l==="reordered"&&jsx("span",{style:L.tag,children:s("proposals.zOrderChanged")}),f&&jsx("svg",{"data-testid":"pptx-proposal-shape-strike",viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:jsx("line",{x1:"0",y1:"100",x2:"100",y2:"0",stroke:"#4338ca",strokeWidth:"2",vectorEffect:"non-scaling-stroke"})}),h&&jsx("span",{style:{...L.tag,left:"auto",right:-1,color:"#166534",background:"#dcfce7"},children:s("proposals.proposedPosition")})]})]},g.shapeId)}),jsx("div",{style:L.srOnly,children:c.map(g=>jsxs("p",{children:[(g.after??g.before).name,": ",jsx("del",{children:g.oldText})," ",jsx("ins",{children:g.newText})]},g.shapeId))})]})}function ps({diff:e,slideId:t}){let{t:n}=c$1(),o=e?.proposal.changes.find(r=>r.slideId===t&&!r.shapeId&&r.oldText!==r.newText);return o?jsxs("section",{"aria-label":n("notes.panelLabel"),style:L.notes,"data-testid":"pptx-proposal-notes-diff",children:[jsx("strong",{children:n("notes.panelLabel")}),jsx("del",{style:L.removed,children:o.oldText||n("proposals.blank")}),jsx("ins",{style:L.added,children:o.newText||n("proposals.blank")})]}):null}var L={toolbar:{flex:"0 0 auto",padding:"10px 14px",background:"#fff",borderBottom:"1px solid #dbe3ee",fontSize:12},row:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},label:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8,minWidth:0,fontWeight:600},select:{maxWidth:260,minWidth:80,padding:5,border:"1px solid #cbd5e1",borderRadius:4,font:"inherit"},legend:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,marginTop:8,color:"#64748b"},removed:{color:"#b91c1c",background:"#fee2e2",textDecoration:"line-through",padding:"2px 5px"},added:{color:"#166534",background:"#dcfce7",textDecoration:"underline",padding:"2px 5px"},button:{padding:"5px 9px",border:"1px solid #cbd5e1",borderRadius:5,background:"#fff",color:"#334155",cursor:"pointer",font:"inherit"},primary:{padding:"5px 9px",border:"1px solid #4338ca",borderRadius:5,background:"#4338ca",color:"#fff",cursor:"pointer",font:"inherit"},warning:{margin:"8px 0 0",color:"#92400e"},overlay:{position:"absolute",inset:0,overflow:"hidden",background:"#fff"},canvas:{position:"absolute",inset:0,display:"block",pointerEvents:"none"},outline:{position:"absolute",border:"1px solid",background:"transparent",padding:0},tag:{position:"absolute",left:-1,top:-18,fontSize:11,lineHeight:"16px",padding:"0 4px",whiteSpace:"nowrap"},srOnly:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},notes:{display:"grid",gap:6,padding:"10px 14px",maxHeight:160,overflow:"auto",background:"#fff",fontSize:12,whiteSpace:"pre-wrap"},paintError:{position:"absolute",top:8,left:8,right:8,padding:8,background:"#fff1f2",color:"#b91c1c"}};function ms(e,t=12){return {visible:e.slice(0,t),overflow:Math.max(0,e.length-t)}}function hs(e,t,n=4){let o=new Map;for(let r of e){let s=r.state.cursor?.slideId;if(!s||!t.has(s))continue;let d=o.get(s)??{visible:[],overflow:0};d.visible.length<n?d.visible.push(r):d.overflow+=1,o.set(s,d);}return o}function Ps(e,t,n,o=24){let r=new Map,s=0;for(let d of e){let c=d.state.cursor;if(c?.slideId!==t||!c.shapeId||!n.has(c.shapeId))continue;let g=r.get(c.shapeId);g?(g.count+=1,d.cursorMovedAt>g.peer.cursorMovedAt&&(g.peer=d)):r.size<o?r.set(c.shapeId,{shapeId:c.shapeId,peer:d,count:1}):s+=1;}return {visible:[...r.values()],overflow:s}}export{us as $,Jo as A,Qo as B,St as C,tr as D,sr as E,Me as F,kr as G,Fr as H,jr as I,Ur as J,Pi as K,Qe as L,me as M,ro as N,Ni as O,Be as P,co as Q,_i as R,go as S,mo as T,ho as U,Fi as V,So as W,Ui as X,Yi as Y,Zi as Z,rt as _,Oo as a,ds as aa,No as b,cs as ba,ni as c,To as ca,jn as d,ps as da,oi as e,ms as ea,ge as f,hs as fa,ri as g,Ps as ga,ii as h,Jr as ha,si as i,li as j,Ne as k,Kn as l,$n as m,ze as n,ai as o,ui as p,di as q,ci as r,pi as s,qn as t,fi as u,Yn as v,gi as w,mi as x,jo as y,qo as z};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-52U7UPKN.js';import'./chunk-O2XFH626.js';import {useMemo,useRef,useState,useCallback,useEffect}from'react';function A(e,n){return "face"in e||"face"in n?"face"in e&&"face"in n&&e.face.file===n.face.file&&e.face.family===n.face.family&&e.face.weight===n.face.weight&&e.face.style===n.face.style&&e.face.metricCompatWith===n.face.metricCompatWith&&e.baseUrl?.toString()===n.baseUrl?.toString():e.family===n.family&&(e.bold??false)===(n.bold??false)&&(e.italic??false)===(n.italic??false)&&(e.bytes===n.bytes||e.bytes.length===n.bytes.length&&e.bytes.every((s,r)=>s===n.bytes[r]))}function D(e){let n=useRef(e);return n.current===e||(n.current.length!==e.length||!n.current.every((s,r)=>A(s,e[r])))&&(n.current=e),n.current}function h({file:e,fonts:n,fallback:s,session:r,onReady:m,onError:v,children:k}){let a$1=D(n),t=useMemo(()=>({}),[e,a$1]),c=useMemo(()=>a$1.filter(o=>!("face"in o)),[a$1]),d=!!e&&c.length!==a$1.length,u=a(t),f=useRef(null),x=useRef(r);x.current=r;let[P,R]=useState(null),i=useCallback(()=>{f.current?.identity===t&&f.current.release();},[t]);useEffect(()=>{if(!e||!d)return;let o=true,p,l=()=>o,F=()=>{p?.release(),p=void 0;};return f.current={identity:t,release:F},(async()=>{try{let{loadBundledFonts:W}=await import('./chunk-ABH6B26J.js');if(!l())return;let{defaultFonts:g,initialSlide:w,experimentalSlicedFonts:j}=x.current,B=W(e,a$1,()=>{l()&&u();},{defaultFonts:g,slicedFonts:j,activeSlideIndex:Number.isInteger(w)?Math.max(0,w-1):0});p=B;let I=await B.fonts;l()&&R({identity:t,fonts:I});}catch{F(),l()&&(u(),R({identity:t,fonts:c}));}})(),()=>{o=false,F();}},[e,d,a$1,t,c,u]);let N=useCallback(o=>(i(),m?.(o)),[m,i]),C=useCallback(o=>{i(),v?.(o);},[v,i]),S=d?P?.identity===t?P.fonts:void 0:c;return S===void 0?s:k(S,N,C)}export{h as BundledFontsResolver};
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-3RN73K5U.js';import'./chunk-O2XFH626.js';var P=2,w=0,g=o=>o.trim().toLowerCase();function b(o,y){let s=new Map,m=++w;async function f(t,e,a$1){await new Promise(p=>setTimeout(p,0));let i=[...a$1.texts].join(`
2
+ `);a$1.texts.clear(),a$1.flush=void 0;let c=e.faces[e.faces.length-1],n=await o.readCoverageFont?.(t,i,c?.revision??null).catch(()=>null);if(!n)return t;if(!n.bytes)return c?.family??t;let r=`${t} s${m} r${n.revision}`,l=a(new Uint8Array(n.bytes)),v=await new FontFace(r,n.bytes,l?{weight:String(l.weight),style:l.italic?"italic":l.oblique?"oblique":"normal"}:{}).load();if(!y()||s.get(g(t))!==e)return t;let F=e.faces[e.faces.length-1];if(F&&F.revision>=n.revision)return F.family;for(document.fonts.add(v),e.faces.push({revision:n.revision,family:r,face:v});e.faces.length>P;)document.fonts.delete(e.faces.shift().face);return r}let d=t=>{let e=s.get(g(t));return e?.faces[e.faces.length-1]?.family};function u(){let t=new Map;return {prepare(e,a){let i=g(e);if(!o.state.slicedFamilies?.some(r=>g(r)===i)||!o.readCoverageFont||typeof document>"u"){let r=s.get(i);if(r)for(let{face:l}of r.faces)document.fonts.delete(l);return s.delete(i),Promise.resolve(e)}let c=s.get(i);c||s.set(i,c={faces:[]});let n=t.get(e);return n||t.set(e,n={texts:new Set}),n.texts.add(document.documentElement.dir==="rtl"?`${a}\u200F`:a),n.flush??(n.flush=f(e,c,n))},latest:d,covers:(e,a,i)=>!o.state.slicedPlainStyles?.includes(`${g(e)}|${a?1:0}|${i?1:0}`)}}return {...u(),thumbnails:u(),dispose(){for(let t of s.values())for(let{face:e}of t.faces)document.fonts?.delete(e);s.clear();}}}function x(o,y,s){let m=new Set,f,d=false;return ()=>f?(d=true,f):f=(async()=>{do{d=false;let u=(await o([...m])).filter(t=>!s(t.family));if(u.length)for(let t of await y(u))m.add(t.family);}while(d)})().finally(()=>{f=void 0;})}export{b as createPeerlessFontCoverage,x as createWholeFontInstaller};
@@ -0,0 +1 @@
1
+ function a(o,s,l){if(!s)return [];let t=[];for(let e of s.edits)if(!(!("slideId"in e)||(e.slideId.startsWith("@")?s.refs?.[e.slideId.slice(1)]:e.slideId)!==o.slideId)){if(e.type==="reorderShape"){if((e.shapeId.startsWith("@")?s.refs?.[e.shapeId.slice(1)]:e.shapeId)!==o.shapeId)continue;let r=e.to==="front"?"proposals.broughtToFront":e.to==="back"?"proposals.sentToBack":e.to==="forward"?"proposals.broughtForward":"proposals.sentBackward";t.push(l(r));}else if(e.type==="insertTableRow"||e.type==="deleteTableRow"||e.type==="insertTableColumn"||e.type==="deleteTableColumn"){if((e.shapeId.startsWith("@")?s.refs?.[e.shapeId.slice(1)]:e.shapeId)!==o.shapeId)continue;let r=e.type==="insertTableRow"?"proposals.rowInserted":e.type==="deleteTableRow"?"proposals.rowDeleted":e.type==="insertTableColumn"?"proposals.columnInserted":"proposals.columnDeleted";t.push(l(r));}else if(o.shapeId===null&&(e.type==="setSlideLayout"||e.type==="setSlideBackground")){let p=l(e.type==="setSlideLayout"?"proposals.layoutChanged":"proposals.backgroundChanged");t.includes(p)||t.push(p);}}return t}export{a};
@@ -0,0 +1 @@
1
+ import {m,f,n,e,j,i,k,l,b}from'./chunk-PS7ULZVL.js';import {a}from'./chunk-O2XFH626.js';import {createContext,forwardRef,useState,useRef,useCallback,useId,useImperativeHandle,useLayoutEffect,useEffect,useContext,useMemo,useSyncExternalStore}from'react';import {editorEn,deepMerge,createT}from'@betteroffice/pptx-i18n/editor';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';var Je=createContext(editorEn),Qe=createContext("en");function ho(e){if(typeof e!="string")return "en";try{return Intl.getCanonicalLocales(e)[0]??"en"}catch{return "en"}}function vo({i18n:e,children:o}){let t=ho(e?._lang),n=useMemo(()=>deepMerge(editorEn,e),[e]);return jsx(Qe.Provider,{value:t,children:jsx(Je.Provider,{value:n,children:o})})}function fo(){let e=useContext(Je),o=useContext(Qe);return {strings:e,lang:o}}function ye(){let{strings:e,lang:o}=fo();return {t:useMemo(()=>createT(e,o),[e,o]),lang:o}}var Ze=[{geometry:"rect",labelKey:"toolbar.shapes.rect"},{geometry:"roundRect",labelKey:"toolbar.shapes.roundRect"},{geometry:"ellipse",labelKey:"toolbar.shapes.ellipse"},{geometry:"triangle",labelKey:"toolbar.shapes.triangle"},{geometry:"rtTriangle",labelKey:"toolbar.shapes.rtTriangle"},{geometry:"diamond",labelKey:"toolbar.shapes.diamond"},{geometry:"parallelogram",labelKey:"toolbar.shapes.parallelogram"},{geometry:"trapezoid",labelKey:"toolbar.shapes.trapezoid"},{geometry:"pentagon",labelKey:"toolbar.shapes.pentagon"},{geometry:"hexagon",labelKey:"toolbar.shapes.hexagon"},{geometry:"octagon",labelKey:"toolbar.shapes.octagon"},{geometry:"star5",labelKey:"toolbar.shapes.star5"},{geometry:"rightArrow",labelKey:"toolbar.shapes.rightArrow"},{geometry:"leftArrow",labelKey:"toolbar.shapes.leftArrow"},{geometry:"upArrow",labelKey:"toolbar.shapes.upArrow"},{geometry:"downArrow",labelKey:"toolbar.shapes.downArrow"},{geometry:"chevron",labelKey:"toolbar.shapes.chevron"}];function Xe(e){if(!e.startsWith("shape:"))return null;let o=e.slice(6);return Ze.some(t=>t.geometry===o)?o:null}function Ye(e){if(!e)return null;if(e.adj!==void 0)return ["adj",e.adj];if(e.adj1!==void 0)return ["adj1",e.adj1];let o=Object.keys(e).sort()[0];return o?[o,e[o]]:null}function Se(e,o){return e==="roundRect"&&o==="adj"?.5:1}var xo={"clipboard-unavailable":"commands.reasons.clipboardUnavailable","table-required":"commands.reasons.tableRequired","last-slide":"commands.reasons.lastSlide","editor-unavailable":"commands.reasons.editorUnavailable","document-loading":"commands.reasons.documentLoading","no-document":"commands.reasons.noDocument","read-only":"commands.reasons.readOnly","nothing-to-undo":"commands.reasons.nothingToUndo","nothing-to-redo":"commands.reasons.nothingToRedo","text-selection-required":"commands.reasons.textSelectionRequired","shape-required":"commands.reasons.shapeRequired","slide-required":"commands.reasons.slideRequired","unsupported-selection":"commands.reasons.unsupportedSelection","invalid-layout":"commands.reasons.invalidLayout","invalid-adjustment":"commands.reasons.invalidAdjustment","z-order-boundary":"commands.reasons.zOrderBoundary","review-active":"commands.reasons.reviewActive","preview-pending":"commands.reasons.previewPending","preview-failed":"commands.reasons.previewFailed","proposal-stale":"commands.reasons.proposalStale","proposal-not-found":"commands.reasons.proposalNotFound","proposals-unavailable":"commands.reasons.proposalsUnavailable","host-disabled":"commands.reasons.hostDisabled","unsupported-command":"commands.reasons.unsupportedCommand","invalid-arguments":"commands.reasons.invalidArguments","permission-denied":"commands.reasons.permissionDenied","unsupported-policy":"commands.reasons.unsupportedPolicy","plugin-unavailable":"commands.reasons.pluginUnavailable",aborted:"commands.reasons.aborted","input-failed":"commands.reasons.inputFailed","document-replaced":"commands.reasons.documentReplaced","target-changed":"commands.reasons.targetChanged","gesture-active":"commands.reasons.gestureActive","command-failed":"commands.reasons.commandFailed"};function D(e,o,t=xo[e]){return {code:e,message:o?o.translate(t):e==="editor-unavailable"?"The editor is not ready.":e}}var tt=1,ot=400,go=.1,Po=5,Co=1584,bo=[.5,.75,.9,1,1.25,1.5,2],yo=[1,2,3,4,8],hn=["Arial","Calibri","Cambria","Georgia","Roboto","Times New Roman","Verdana"],vn=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],fn=24,nt=[{value:"l",labelKey:"toolbar.align.left"},{value:"ctr",labelKey:"toolbar.align.center"},{value:"r",labelKey:"toolbar.align.right"},{value:"just",labelKey:"toolbar.align.justify"}],Zo=new Set(["front","forward","backward","back"]);function S(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ce(e){return typeof e=="number"&&Number.isFinite(e)}function ne(e){return typeof e=="string"&&e.trim().length>0}function et(e){return typeof e=="string"&&/^#[0-9a-f]{6}$/i.test(e)}function So(e){return e==="select"||e==="textBox"||typeof e=="string"&&Xe(e)!==null}function xn(e,o,t){return t>0?o.find(n=>n>e)??Math.min(ot,e+1):[...o].reverse().find(n=>n<e)??Math.max(tt,e-1)}function To(e,o){if(o===void 0)return true;let t=o;switch(e){case "fontFamily":return S(t)&&ne(t.family);case "fontSize":return S(t)&&ce(t.points)&&t.points>=tt&&t.points<=ot;case "fontSizeStep":return S(t)&&(t.direction==="increase"||t.direction==="decrease");case "textColor":return S(t)&&et(t.color);case "alignment":return S(t)&&nt.some(n=>n.value===t.value);case "insertSlide":return S(t)&&(t.layoutPartPath===void 0||t.layoutPartPath===null||ne(t.layoutPartPath));case "tool":return S(t)&&So(t.value);case "shapeFill":case "shapeStrokeColor":return S(t)&&(t.color===null||et(t.color));case "shapeStrokeWidth":return S(t)&&(t.points===null||ce(t.points)&&t.points>0&&t.points<=Co);case "shapeAdjustment":return S(t)&&ne(t.name)&&ce(t.value);case "zOrder":return S(t)&&Zo.has(t.value);case "zoom":return S(t)&&(t.scale==="fit"||ce(t.scale)&&t.scale>=go&&t.scale<=Po);case "proposalsPanel":return t===null||S(t)&&typeof t.open=="boolean";case "proposalSelect":case "proposalReject":return S(t)&&ne(t.proposalId);case "proposalDiff":return S(t)&&typeof t.enabled=="boolean";case "proposalAccept":return S(t)&&ne(t.proposalId)&&(t.force===void 0||typeof t.force=="boolean");default:return t===null}}function G(e){switch(e.status){case "unavailable":return "editor-unavailable";case "loading":return "document-loading";case "empty":return "no-document";default:return null}}function T(e){return G(e)??(e.readOnly?"read-only":null)}function Te(e){return e.slide?null:"slide-required"}function we(e){return e.reviewing?"review-active":null}function Q(e){return T(e)??we(e)??(e.text==="unsupported"?"unsupported-selection":e.text?null:"text-selection-required")}function he(e){return T(e)?T(e):e.reviewing?"review-active":e.shape?e.shape.formattable?null:"unsupported-selection":"shape-required"}function wo(e){return e.text&&e.text!=="unsupported"?e.text:null}function Mo(e,o){let t=T(e)??we(e)??(e.shape?null:"shape-required");if(t||!e.shape?.order)return t;let{index:n,count:i}=e.shape.order,d=n>=i-1,l=n<=0;return o===void 0?d&&l?"z-order-boundary":null:(o==="front"||o==="forward"?d:l)?"z-order-boundary":null}function Eo(e,o){return e==="fit"?o.translate("toolbar.fit"):`${Math.round(e*100)}%`}function Ao(e,o){return e==="fit"||o==="fit"?e===o:Math.abs(e-o)<.001}function Io(e){return [{args:{value:"select"},label:e.translate("commands.selectTool")},{args:{value:"textBox"},label:e.translate("toolbar.textBoxTool")},...Ze.map(o=>({args:{value:`shape:${o.geometry}`},label:e.translate(o.labelKey)}))]}function qo(e,o,t){let n=T(o)??(o.proposals?null:"proposals-unavailable");if(n||!t)return {gate:n};let i=o.proposals.pending.find(d=>d.id===t.proposalId);return i?e==="proposalReject"?{gate:null}:{gate:i.stale&&!t.force?"proposal-stale":null}:{gate:"proposal-not-found"}}function Ro(e,o,t){let n=wo(t),i=t.translate,d=l=>l;switch(e){case "bold":case "italic":case "underline":case "strikethrough":return {gate:Q(t),active:n?.[e]??false};case "fontFamily":{let l=t.fontFamilies;return d({gate:Q(t),value:n?n.fontFamily:void 0,options:l.map(a=>({args:{family:a},label:a})),active:o?n?.fontFamily===o.family:void 0})}case "fontSize":{let l=o;return d({gate:Q(t),value:n?n.fontSize:void 0,options:t.fontSizes.map(a=>({args:{points:a},label:String(a)})),active:l?n?.fontSize===l.points:void 0})}case "fontSizeStep":return {gate:Q(t)};case "textColor":return d({gate:Q(t),value:n?n.color:void 0});case "alignment":{let l=o;return d({gate:Q(t),value:n?n.alignment:void 0,options:nt.map(a=>({args:{value:a.value},label:i(a.labelKey)})),active:l?n?.alignment===l.value:void 0})}case "insertSlide":{let l=o,a=l?.layoutPartPath,c=typeof a!="string"||t.layouts.some(h=>h.args.layoutPartPath===a);return d({gate:T(t)??(c?null:"invalid-layout"),value:t.slide?t.slide.layoutPartPath:void 0,options:t.layouts,active:l&&a!==void 0&&t.slide?(a??null)===t.slide.layoutPartPath:void 0})}case "insertImage":return {gate:T(t)??Te(t)??we(t)};case "tool":{let l=o?.value,a=l==="select"?G(t):T(t)??Te(t);return d({gate:a,value:t.tool,options:Io(t),active:l?t.tool===l:void 0})}case "shapeFill":return d({gate:he(t),value:t.shape?.formattable?t.shape.fill:void 0});case "shapeStrokeColor":return d({gate:he(t),value:t.shape?.formattable?t.shape.stroke:void 0});case "shapeStrokeWidth":{let l=o,a=t.shape?.formattable?t.shape.strokeWidth:void 0;return d({gate:he(t),value:a,options:[{args:{points:null},label:i("toolbar.noBorder")},...yo.map(c=>({args:{points:c},label:i("toolbar.borderWidthValue",{width:c})}))],active:l&&a!==void 0?a===l.points:void 0})}case "shapeAdjustment":{let l=t.shape?.formattable?t.shape:null,a=l?Ye(l.adjustments):null,c=o,h=he(t)??(a?null:"invalid-adjustment"),x=a?Se(l.geometry,a[0]):1,C=c&&l&&(!Object.prototype.hasOwnProperty.call(l.adjustments,c.name)||c.value<0||c.value>Se(l.geometry,c.name)),f=a?Array.from({length:Math.round(x*10)+1},(P,A)=>A/10):[];return d({gate:h??(C?"invalid-adjustment":null),value:l?a?{name:a[0],value:a[1]}:null:void 0,options:a?f.map(P=>({args:{name:a[0],value:P},label:`${Math.round(P*100)}%`})):[],active:c&&a?c.name===a[0]&&Math.abs(c.value-a[1])<5e-4:void 0})}case "zOrder":return {gate:Mo(t,o?.value),reasonKey:t.shape?void 0:"commands.reasons.objectRequired"};case "save":return {gate:G(t)};case "exportPng":case "slideshow":return {gate:G(t)??Te(t)};case "undo":return {gate:T(t)??(t.canUndo||t.pendingInput?null:"nothing-to-undo")};case "redo":return {gate:T(t)??(t.canRedo||t.pendingInput?null:"nothing-to-redo")};case "zoom":{let l=o,a=["fit",...bo];return d({gate:G(t),value:t.zoom,options:a.map(c=>({args:{scale:c},label:Eo(c,t)})),active:l?Ao(t.zoom,l.scale):void 0})}case "proposalsPanel":{let l=o,a=t.proposals?.open??false;return d({gate:T(t)??(t.proposals?null:"proposals-unavailable"),value:a,active:l?a===l.open:a})}case "proposalSelect":{let l=o,a=t.proposals?.canvas,c=T(t)??(a?null:"proposals-unavailable"),h=!l||!a||a.available.some(x=>x.id===l.proposalId);return d({gate:c??(a&&a.available.length===0?"proposal-not-found":null)??(h?null:"proposal-not-found"),value:a?.selectedId??null,options:(a?.available??[]).map(x=>({args:{proposalId:x.id},label:x.label})),active:l?a?.selectedId===l.proposalId:void 0})}case "proposalDiff":{let l=o,a=t.proposals?.canvas;return d({gate:T(t)??(a?null:"proposals-unavailable")??(a?.selectedId?null:"proposal-not-found"),value:a?.diff??false,active:l?(a?.diff??false)===l.enabled:a?.diff??false})}case "proposalAccept":case "proposalReject":return d(qo(e,t,o));default:return {gate:"unsupported-command"}}}function Ho(e){let o=e.active===void 0?{}:{active:e.active};return e.enabled?{...o,enabled:true}:{...o,enabled:false,disabledReason:e.disabledReason}}function rt(e,o){if(!o)return D("editor-unavailable",null);let t=e?T(o):G(o);return t?D(t,o):null}function Me(e,o,t){if(!t)return {enabled:false,disabledReason:D("editor-unavailable",null)};let n=t.gates?.(e,o,t)??(To(e,o)?Ro(e,o,t):{gate:G(t)??"invalid-arguments"}),i=t.hostDisabled?.(e)?"host-disabled":n.gate,d={};return n.active!==void 0&&(d.active=n.active),n.value!==void 0&&(d.value=n.value),n.options!==void 0&&o===void 0&&(d.options=n.options.map(l=>({...l,state:Ho(Me(e,l.args,t))}))),i?{...d,enabled:false,disabledReason:D(i,t,i===n.gate?n.reasonKey:void 0)}:{...d,enabled:true}}var at=new WeakMap,ko=0,I=null;function Pn(e){let o=at.get(e);return o||(o=`plugin-activation-${++ko}`,at.set(e,o)),o}function Cn(e){return I?.activationId===e&&I.event.eventPhase!==Event.NONE&&I.currentEvent()===I.event}function st(e,o=n=>n.isTrusted,t=()=>e.ownerDocument.defaultView?.event){let n=e.ownerDocument.defaultView,i=["click","keydown","pointerup"],d=null,l=h=>{if(I?.close(),!o(h))return;let x=h.composedPath().find(A=>A instanceof Element&&A.hasAttribute("data-plugin-activation")),C=x?.getAttribute("data-plugin-activation");if(!x||!e.contains(x)||!C)return;let f=setTimeout(()=>P(),0),P=()=>{clearTimeout(f),I?.event===h&&(I=null),d=null;};d=P,I={activationId:C,event:h,currentEvent:t,close:P};},a=h=>{I?.event===h&&I.close();},c=h=>{I?.event!==h&&I?.close();};for(let h of i)e.addEventListener(h,l,true),n?.addEventListener(h,c,true),n?.addEventListener(h,a);return ()=>{d?.();for(let h of i)e.removeEventListener(h,l,true),n?.removeEventListener(h,c,true),n?.removeEventListener(h,a);}}var Oo=new Set(["Ctrl","Mod","Shift","Alt"]),lt="Space Enter Tab Escape Backspace Delete Home End PageUp PageDown ArrowUp ArrowDown ArrowLeft ArrowRight".split(" "),Ko={escape:"Esc",delete:"Del",pageup:"Page Up",pagedown:"Page Down",arrowup:"\u2191",arrowdown:"\u2193",arrowleft:"\u2190",arrowright:"\u2192"},Lo=Object.fromEntries(lt.map(e=>[e.toLowerCase(),e])),Do=Object.fromEntries(lt.map(e=>[e.toLowerCase(),Ko[e.toLowerCase()]??e])),it=/^f([1-9]|1[0-2])$/;function re(){return typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform)}function ae(e){let o=e.split("+"),t=o.length>1&&o[o.length-1]===""?"+":o[o.length-1],n=new Set(o.slice(0,-1));return {ctrl:n.has("Ctrl"),mod:n.has("Mod"),shift:n.has("Shift"),alt:n.has("Alt"),key:t.toLowerCase()}}function mt(e){if(typeof e!="string"||e.length===0)return null;let o=e.split("+");if(!(o.length>1&&o[o.length-1]===""?o.slice(0,-2):o.slice(0,-1)).every(d=>Oo.has(d)))return null;let n=ae(e);if(n.key.length===0)return null;let i=n.key==="+"?"=":n.key;return [n.ctrl&&"Ctrl",n.mod&&"Mod",n.alt&&"Alt",n.shift&&"Shift",i].filter(Boolean).join("+")}function zo(e,o){let t=Do[e];return t?o?.[e]??t:e.length===1||it.test(e)?e.toUpperCase():e}function Ee(e,o=re(),t){let n=ae(e),i=zo(n.key,t);return o?`${n.ctrl?"\u2303":""}${n.alt?"\u2325":""}${n.shift?"\u21E7":""}${n.mod?"\u2318":""}${i}`:[(n.mod||n.ctrl)&&(t?.ctrl??"Ctrl"),n.alt&&(t?.alt??"Alt"),n.shift&&(t?.shift??"Shift"),i].filter(Boolean).join("+")}function dt(e,o=re()){let t=ae(e),n=Lo[t.key]??(t.key.length===1||it.test(t.key)?t.key.toUpperCase():t.key);return [(o?t.ctrl:t.ctrl||t.mod)&&"Control",o&&t.mod&&"Meta",t.alt&&"Alt",t.shift&&"Shift",n].filter(Boolean).join("+")}function Sn(e){let o=mt(e);return o&&!ae(o).ctrl?o:null}function v(e,o,t,n=[]){return Object.freeze({id:e,labelKey:o,mutatesDocument:t,shortcuts:Object.freeze(n)})}var H=e=>({chord:e,args:null}),X=Object.freeze({cut:v("cut","commands.cut",true,[H("Mod+X")]),copy:v("copy","commands.copy",false,[H("Mod+C")]),paste:v("paste","commands.paste",true,[H("Mod+V")]),pasteAsPlainText:v("pasteAsPlainText","commands.pastePlainText",true,[H("Mod+Shift+V")]),deleteObject:v("deleteObject","commands.delete",true),deleteSlide:v("deleteSlide","toolbar.deleteSlide",true),duplicateSlide:v("duplicateSlide","commands.duplicateSlide",true),tableInsert:v("tableInsert","commands.insert",true),tableDelete:v("tableDelete","commands.delete",true),bold:v("bold","toolbar.bold",true,[H("Mod+B")]),italic:v("italic","toolbar.italic",true,[H("Mod+I")]),underline:v("underline","toolbar.underline",true,[H("Mod+U")]),strikethrough:v("strikethrough","toolbar.strikethrough",true),fontFamily:v("fontFamily","toolbar.fontFamily",true),fontSize:v("fontSize","toolbar.fontSize",true),fontSizeStep:v("fontSizeStep","commands.fontSizeStep",true),textColor:v("textColor","toolbar.textColor",true),alignment:v("alignment","toolbar.groups.alignment",true),insertSlide:v("insertSlide","toolbar.newSlide",true),insertImage:v("insertImage","toolbar.insertImage",true),tool:v("tool","toolbar.groups.tools",false),shapeFill:v("shapeFill","toolbar.fillColor",true),shapeStrokeColor:v("shapeStrokeColor","toolbar.borderColor",true),shapeStrokeWidth:v("shapeStrokeWidth","toolbar.borderWidth",true),shapeAdjustment:v("shapeAdjustment","toolbar.shapeAdjustment",true),zOrder:v("zOrder","toolbar.arrange",true),save:v("save","toolbar.save",false,[H("Mod+S")]),exportPng:v("exportPng","toolbar.exportPng",false),slideshow:v("slideshow","toolbar.present",false),undo:v("undo","toolbar.undo",true,[H("Mod+Z")]),redo:v("redo","toolbar.redo",true,[H("Mod+Shift+Z"),H("Mod+Y")]),zoom:v("zoom","toolbar.groups.zoom",false),proposalsPanel:v("proposalsPanel","proposals.title",false),proposalSelect:v("proposalSelect","proposals.canvasTitle",false),proposalDiff:v("proposalDiff","proposals.showDiff",false),proposalAccept:v("proposalAccept","proposals.accept",true),proposalReject:v("proposalReject","proposals.reject",true)});Object.freeze(Object.keys(X));function ut(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(X,e)}var Fo=/^plugin:[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?\/[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;function z(e){return typeof e=="string"&&Fo.test(e)}function ve(e){return e==="insertSlide"?{}:null}var qe=class extends Error{constructor(t){super(t);a(this,"code",t);this.name="PptxCommandAdmissionError";}},Ae=512,fe=new WeakMap;function U(e,o){return {ok:false,failure:D(e,o)}}function pt(e,o){return o===void 0?e:`${e}\0${JSON.stringify(o)}`}function jo(e){switch(e){case "input-failed":case "target-changed":case "gesture-active":case "command-failed":return "editor-unavailable";case "document-replaced":case "aborted":return "plugin-unavailable";default:return e}}function Bo(e){return !z(e)&&X[e].mutatesDocument}function Ie(e){return ut(e)||z(e)}function No(){let e=null,o=new Map,t=Object.freeze([]),n=Object.freeze([]),i=new WeakMap,d=new WeakSet,l=new Set,a=new Map,c=new Set,h=new Set,x=null,C=0,f,P=0,A=new Map,j=r=>{if(!f)return X[r];let m=f,u=A.get(r);return u||(u=Object.freeze({...X[r],shortcuts:Object.freeze((m.chords.get(r)??[]).map(s=>({chord:s,args:null})))}),A.set(r,u)),u},Z=r=>{if(!e)return null;try{return e.environment(r)}catch(m){return console.error("[pptx commands] reading editor state failed",m),null}},B=(r,m)=>{let u=o.get(r);if(!u)return {enabled:false,disabledReason:D("unsupported-command",m)};let s=rt(u.descriptor.mutatesDocument,m);return s?{enabled:false,disabledReason:s}:u.state()},N=(r,m,u)=>z(r)?B(r,u):Me(r,m,u),Y=()=>{C+=1;for(let r of [...l])r();},ie=()=>{if(!(a.size<=Ae))for(let[r,m]of a){if(a.size<=Ae)break;m.holds===0&&m.read<C&&a.delete(r);}},q=(r,m)=>{let u=pt(r,m),s=a.get(u);if(!s){let p=Ie(r)?N(r,m,Z(false)):{enabled:false,disabledReason:D("unsupported-command",Z(false))};s={id:r,args:m,json:JSON.stringify(p),state:p,holds:0,read:C},a.set(u,s),ie();}return s.read=C,s},me=()=>{let r=null;try{r=e?.chrome()??null;}catch(u){console.error("[pptx commands] reading editor chrome failed",u);}if(!(r===x||r!==null&&x!==null&&r.i18n===x.i18n)){x=r;for(let u of [...h])u();}},R=()=>{if(me(),ie(),a.size===0)return;let r=Z(false),m=false;for(let u of a.values()){if(!Ie(u.id))continue;let s=N(u.id,u.args,r),p=JSON.stringify(s);p!==u.json&&(u.state=s,u.json=p,m=true);}m&&Y();},M=r=>{try{return e?.capture(r)??null}catch(m){return console.error("[pptx commands] capturing a command target failed",m),null}};async function F(r,m,u,s,p){let g=e;if(!g)return U("editor-unavailable",null);let b=p?.gesture()??false,y=z(r)?null:r,L=s!==void 0||y!==null&&g.ordered(y,m),O=s?s.origin:L&&y?M(y):void 0,te=()=>{if(O!==void 0){let oe=O?g.resume(O):"editor-unavailable";if(oe)return U(oe,Z(true))}let _=p?.deny(r)??null;if(_)return U(_,Z(true));let de=Z(true),ue=N(r,m,de);return ue.enabled?p&&Bo(r)&&!b?U("unsupported-policy",de):u(de):{ok:false,failure:ue.disabledReason}};try{return await(L?g.admit(te):te())}catch(_){return _ instanceof qe?U(_.code,Z(false)):(console.error(`[pptx commands] ${r} failed`,_),U("command-failed",Z(false)))}finally{R();}}let Ce=(r,m,u)=>z(r)?o.get(r).execute():e.perform(r,m,u),ee=(r,m,u)=>Ie(r)?F(r,m,s=>Ce(r,m,s),void 0,u):Promise.resolve(U("unsupported-command",Z(false))),E=r=>z(r)?o.get(r)?.descriptor??null:j(r),k=Object.freeze({getDescriptor:E,getState:(r,m)=>q(r,m).state,subscribe(r){return l.add(r),()=>{l.delete(r);}},execute:(r,m)=>ee(r,m)}),J=r=>{let m=new Map,s=Object.freeze({getDescriptor:E,getState:(p,g)=>{let b=q(p,g).state,y=r.deny(p),L=pt(p,g),O=m.get(L);if(O&&O.base===b&&O.denial===y)return O.state;let te=y?jo(y):null,{enabled:_,disabledReason:de,...ue}=b,oe=te?{...ue,enabled:false,disabledReason:D(te,Z(false))}:b;return m.size>=Ae&&m.delete(m.keys().next().value),m.set(L,{base:b,denial:y,state:oe}),oe},subscribe(p){let g=[k.subscribe(p),r.subscribe(p)];return ()=>{for(let b of g)b();}},execute:(p,g)=>ee(p,g,r)});return fe.set(s,{...K,store:s,defer(p,g){let b=M(p);return {complete:y=>{let L=e;return F(p,g,O=>y(()=>L.perform(p,g,O)),{origin:b},r)}}},prepare(p){let g=M(p);return {execute:b=>F(p,b,y=>e.perform(p,b,y),{origin:g},r)}}}),s},K={store:k,attach(r){e=r,R();},detach(r){e===r&&(e=null,R());},refresh:R,hold(r,m){let u=q(r,m);u.holds+=1;let s=true;return ()=>{s&&(s=false,u.holds-=1);}},defer(r,m){let u=M(r);return {complete:s=>{let p=e;return F(r,m,g=>s(()=>p.perform(r,m,g)),{origin:u})}}},prepare(r){let m=M(r);return {execute:u=>F(r,u,s=>e.perform(r,u,s),{origin:m})}},registerChrome(r){c.add(r);let m=st(r);return ()=>{m(),c.delete(r);}},ownsChrome(r){if(!(r instanceof Node))return false;for(let m of c)if(m.contains(r))return true;return false},chrome:()=>x,subscribeChrome(r){return h.add(r),()=>{h.delete(r);}},focusEditor(){e?.focusEditor();},setPluginCommands(r,m){o=new Map(r.map(u=>[u.descriptor.id,u])),t=Object.freeze(m.filter(u=>o.has(u))),n=Object.freeze(r.flatMap(u=>u.descriptor.shortcuts.map(({chord:s})=>({id:u.descriptor.id,chord:s})))),R(),Y();},pluginToolbar:()=>t,pluginActivation:r=>o.get(r)?.activationId,pluginShortcuts:()=>n,setShortcuts(r){f=r,P+=1,A.clear(),Y();},hostShortcuts:()=>f,shortcutRevision:()=>P,scoped(r){let m=i.get(r);return m||(m=J(r),i.set(r,m),d.add(m)),m},guarded(r){let m=Object.freeze(Object.fromEntries(Object.entries(k).map(([u,s])=>[u,(...p)=>(r(),Reflect.apply(s,k,p))])));return fe.set(m,{...K,store:m,prepare(u){r();let s=K.prepare(u);return {execute(p){return r(),s.execute(p)}}},defer(u,s){r();let p=K.defer(u,s);return {complete(g){return r(),p.complete(g)}}}}),d.add(m),m},ownsStore:r=>d.has(r)};return d.add(k),fe.set(k,K),K}function xe(e){return fe.get(e)??null}var ct=No().store;var ge=createContext(null);function On({commands:e,children:o}){return jsx(ge.Provider,{value:e??ct,children:o})}function Re(e,o,t=re()){let n=Object.fromEntries(["ctrl","alt","shift","delete","escape","pageup","pagedown"].map(i=>[i,o(`keys.${i}`)]));return {shortcut:Ee(e,t,n),ariaShortcut:dt(e,t)}}function ht(e,o,t,n,i){let d=JSON.stringify(n??ve(o)),a=e.getDescriptor(o).shortcuts.find(c=>JSON.stringify(c.args)===d)?.chord;return a?Re(a,t,i):{}}function Oe(){let e=useContext(ge);if(!e)throw new Error("usePptxCommands must be used inside PptxEditor chrome or a PptxCommandProvider");return e}function He(e){return e===void 0?void 0:JSON.parse(e)}function $o(e,o){let t=Oe(),n=o===void 0?void 0:JSON.stringify(o),i=useCallback(l=>{let a=xe(t)?.hold(e,He(n)),c=t.subscribe(l);return ()=>{c(),a?.();}},[t,e,n]),d=useCallback(()=>t.getState(e,He(n)),[t,e,n]);return useSyncExternalStore(i,d,d)}function Wn(e,o){let t=Oe(),n=$o(e,o),{t:i}=ye(),d=useCallback(()=>t.getDescriptor(e),[t,e]),l=useSyncExternalStore(t.subscribe,d,d),a=o===void 0?void 0:JSON.stringify(o),c=useCallback(h=>t.execute(e,h!==void 0?h:a!==void 0?JSON.parse(a):ve(e)),[t,e,a]);return useMemo(()=>{if(z(e)){let x=l,C=x?.shortcuts[0]?.chord,f=C?Re(C,i):null;return {id:e,descriptor:x,state:n,label:x?.label??e,shortcut:f?.shortcut??null,ariaShortcut:f?.ariaShortcut??null,execute:()=>c()}}let h=l;return {id:e,descriptor:h,state:n,label:i(h.labelKey),shortcut:null,ariaShortcut:null,...ht(t,e,i,He(a)),execute:c}},[t,e,l,n,i,a,c])}function $n(){let e=xe(Oe()),o=useCallback(n=>e?.subscribeChrome(n)??(()=>{}),[e]),t=useCallback(()=>e?.chrome()??null,[e]);return useSyncExternalStore(o,t,t)}function ft(){let e=useContext(ge),o=useRef(null);return useCallback(t=>{o.current?.(),o.current=null;let n=e?xe(e):null;t&&n&&(o.current=n.registerChrome(t));},[e])}function gt({path:e,size:o=b,style:t}){return jsx("svg",{width:o,height:o,viewBox:"0 -960 960 960",fill:"currentColor","aria-hidden":"true",focusable:"false",style:{display:"inline-flex",flexShrink:0,...t},children:jsx("path",{d:e})})}var Pt="M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z",Ct="M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z";var bt="M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z",yt="M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z",Zt="M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z",St="M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z",Tt="M220-280l210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z",wt="m247-904 57-56 343 343q23 23 23 57t-23 57L457-313q-23 23-57 23t-57-23L153-503q-23-23-23-57t23-57l190-191-96-96Zm153 153L209-560h382L400-751Zm303.5 447.5Q680-327 680-360q0-21 12.5-45t27.5-45q9-12 19-25t21-25q11 12 21 25t19 25q15 21 27.5 45t12.5 45q0 33-23.5 56.5T760-280q-33 0-56.5-23.5Z",Mt="M240-320h56l312-311-29-29-28-28-311 312v56Zm-80 80v-170l448-447q11-11 25.5-17t30.5-6q16 0 31 6t27 18l55 56q12 11 17.5 26t5.5 31q0 15-5.5 29.5T777-687L330-240H160Zm560-504-56-56 56 56ZM608-631l-29-29-28-28 57 57Z";var Et="M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z",At="M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z",It="M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z",qt="M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z";var Rt="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z",Ht="M480-360 280-560h400L480-360Z",kt="M200-440v-80h560v80H200Z",Ot="M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z",Kt="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z",Lt="M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z",Dt="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z",zt="M480-480ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h320v80H200v560h560v-320h80v320q0 33-23.5 56.5T760-120H200Zm40-160h480L570-480 450-320l-90-120-120 160Zm440-320v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z";var Ft="M440-280h80v-160h160v-80H520v-160h-80v160H280v80h160v160ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z",jt="m320-410 79-110h170L320-716v306ZM551-80 406-392 240-160v-720l560 440H516l144 309-109 51ZM399-520Z",Bt="M440-320v-240H320v-80h320v80H520v240h-80ZM40-40v-240h80v-400H40v-240h240v80h400v-80h240v240h-80v400h80v240H680v-80H280v80H40Zm240-160h400v-80h80v-400h-80v-80H280v80h-80v400h80v80ZM120-760h80v-80h-80v80Zm640 0h80v-80h-80v80Zm0 640h80v-80h-80v80Zm-640 0h80v-80h-80v80Zm80-640Zm560 0Zm0 560Zm-560 0Z",Nt="M600-360ZM320-242q10 1 19.5 1.5t20.5.5q11 0 20.5-.5T400-242v82h400v-400h-82q1-10 1.5-19.5t.5-20.5q0-11-.5-20.5T718-640h82q33 0 56.5 23.5T880-560v400q0 33-23.5 56.5T800-80H400q-33 0-56.5-23.5T320-160v-82ZM161.5-401.5Q80-483 80-600t81.5-198.5Q243-880 360-880t198.5 81.5Q640-717 640-600t-81.5 198.5Q477-320 360-320t-198.5-81.5Zm340-57Q560-517 560-600t-58.5-141.5Q443-800 360-800t-141.5 58.5Q160-683 160-600t58.5 141.5Q277-400 360-400t141.5-58.5ZM360-600Z",_t="M360-280q-33 0-56.5-23.5T280-360v-400q0-33 23.5-56.5T360-840h400q33 0 56.5 23.5T840-760v400q0 33-23.5 56.5T760-280H360Zm0-80h400v-400H360v400ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z",Gt="M200-120q-33 0-56.5-23.5T120-200v-480h80v480h480v80H200Zm160-240v80q-33 0-56.5-23.5T280-360h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T360-840v80Zm80 480v-80h80v80h-80Zm0-480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0 480v-80h80v80h-80Zm160-480v-80q33 0 56.5 23.5T840-760h-80Zm0 400h80q0 33-23.5 56.5T760-280v-80Zm0-80v-80h80v80h-80Zm0-160v-80h80v80h-80Z",Ut="M240-400v-480h480v480H240Zm80-80h320v-320H320v320Zm320 240v-80h80v80h-80Zm-400 0v-80h80v80h-80ZM640-80v-80h80v80h-80Zm-200 0v-80h80v80h-80Zm-200 0v-80h80v80h-80Zm240-560Z",Wt="M240-80v-480h480v480H240Zm80-80h320v-320H320v320Zm-80-480v-80h80v80h-80Zm400 0v-80h80v80h-80ZM240-800v-80h80v80h-80Zm200 0v-80h80v80h-80Zm200 0v-80h80v80h-80ZM480-320Z",$t="M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z";var Vo={save:Lt,image:Dt,insertImage:zt,undo:Pt,redo:Ct,newSlide:Ft,select:jt,textBox:Bt,shape:Nt,bringToFront:_t,sendToBack:Gt,bringForward:Ut,sendBackward:Wt,fillColor:wt,borderColor:Mt,borderWidth:$t,bold:bt,italic:yt,underline:Zt,strikethrough:St,textColor:Tt,alignLeft:Et,alignCenter:At,alignRight:It,alignJustify:qt,more:Rt,chevronDown:Ht,remove:kt,add:Ot,check:Kt};function Vt({name:e,size:o,style:t}){return jsx(gt,{path:Vo[e],size:o,style:t})}var Yt=createContext(null);function eo(e,o){for(let t of e){if(t.kind==="item"&&t.id===o)return t;if(t.kind==="group"||t.kind==="submenu"){let n=eo(t.entries,o);if(n)return n}}return null}function to(e,o,t){return e.map(n=>n.kind==="item"?{...n,...t?{activationId:t}:{},onSelect:()=>{let i=eo(o(),n.id);i&&!i.disabled&&i.onSelect();}}:n.kind==="group"||n.kind==="submenu"?{...n,entries:to(n.entries,o,t)}:n)}function Xo(e){return JSON.stringify(e,(o,t)=>o==="icon"||typeof t=="function"?void 0:t)}function Ke(e,o){let t=useContext(Yt),n=useRef(o);n.current=o;let i=useRef(null),d=o!==null;useLayoutEffect(()=>{if(!t||!d)return;let l=()=>n.current?.()??[];return i.current=null,t.register({element:()=>e.current,entries:()=>to(l(),l,e.current?.closest("[data-plugin-activation]")?.getAttribute("data-plugin-activation")??void 0)})},[t,e,d]),useLayoutEffect(()=>{if(!t||!d)return;if(!t.overflowing()){i.current=null;return}let a=`${e.current?.closest("[data-plugin-activation]")?.getAttribute("data-plugin-activation")??""}:${Xo(n.current?.()??[])}`;i.current!==a&&t.changed(),i.current=a;});}function oo(){return useContext(Yt)}function io(e,o,t){let n=o?`${e} (${o})`:e;return t?`${n}: ${t}`:n}function mo(e,o){let t=useId(),n=e&&o?o:void 0;return {reason:n,props:n?{disabled:false,"aria-disabled":true,"aria-describedby":t}:{disabled:e},node:n?jsx("span",{id:t,hidden:true,children:n}):null}}var on=forwardRef(function({active:o,disabled:t=false,description:n,title:i,shortcut:d,ariaShortcut:l,onClick:a,children:c,className:h,style:x,testId:C,ariaExpanded:f$1},P){let[A,j]=useState(false),Z=m(),B=mo(t,n);return jsxs(Fragment,{children:[jsx("button",{ref:P,type:"button",className:h,"data-testid":C,...B.props,"aria-label":i,"aria-pressed":o===void 0?void 0:o,"aria-expanded":f$1,"aria-keyshortcuts":l,title:io(i,d,B.reason),onMouseDown:N=>N.preventDefault(),onMouseEnter:()=>j(true),onMouseLeave:()=>j(false),onClick:t?void 0:a,...Z.focusProps,style:{...f({disabled:t,pressed:o===true,hovered:A,focusRing:Z.focusRing}),...x},children:c}),B.node]})});function cr(e){let o=useRef(null),t=useId(),{active:n,disabled:i=false,description:d,title:l,shortcut:a,ariaShortcut:c,onClick:h,overflowLabel:x}=e;return Ke(o,()=>[{kind:"item",id:t,label:x??l,shortcut:a,ariaShortcut:c,checked:n,disabled:i,description:i?d:void 0,onSelect:()=>h?.()}]),jsx(on,{ref:o,...e})}function hr({label:e,children:o,style:t}){return jsx("div",{role:"group","aria-label":e,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",...t},children:o})}function vr(){return jsx("div",{role:"separator","aria-orientation":"vertical",style:i})}var ao='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]',so='button, input, select, textarea, a[href], [tabindex]:not([tabindex="-1"])',$=8;function nn(e,o,t){let n=window.innerWidth,i=window.innerHeight,d=Math.max($,Math.min(e.left,n-Math.min(t,n-2*$)-$)),l=o.scrollHeight,a=i-$-(e.bottom+4),c=e.top-4-$;if(l<=a||a>=c)return {top:e.bottom+4,left:d,maxHeight:Math.max(a,80)};let h=Math.max(c,80);return {top:Math.max($,e.top-4-Math.min(l,h)),left:d,maxHeight:h}}var rn=forwardRef(function({title:o,trigger:t,children:n$1,disabled:i=false,description:d,active:l=false,menuWidth:a=220,style:c,testId:h,popup:x},C){let[f$1,P]=useState(null),[A,j$1]=useState(false),Z=m(),[B,N]=useState("menu"),[Y,ie]=useState({}),[q,me]=useState(null),R=useRef(null),M=useRef(null),F=ft(),Ce=useCallback(s=>{M.current=s,F(s);},[F]),ee=useId(),E=x??B,k=mo(i,d),J=n({container:M,itemSelector:ao,scope:'[role="menu"]',labelOf:s=>s.getAttribute("aria-label")??s.textContent??""}),K=()=>f$1?.anchor??R.current,r=useCallback(()=>P(null),[]),m$1=()=>{let s=K();P(null),s?.focus({preventScroll:true});};useImperativeHandle(C,()=>({openAt:s=>{i||P({focus:"first",anchor:s});}}),[i]),useLayoutEffect(()=>{let s=M.current;if(!f$1||!s){me(null);return}if(!x){let y=Array.from(s.querySelectorAll(so)).every(L=>L.matches(ao));N(y?"menu":"dialog");}let p=f$1.anchor??R.current,g=p?.getBoundingClientRect();g&&me(nn(g,s,a)),ie(e(p));},[f$1,x,a]),useLayoutEffect(()=>{let s=M.current;!f$1||!s||!q||s.contains(document.activeElement)||(E==="menu"?f$1.focus==="first"?J.focusFirst():f$1.focus==="last"?J.focusLast():s.focus({preventScroll:true}):(s.querySelector(so)??s).focus({preventScroll:true}));},[f$1,q,E,J]),useEffect(()=>{if(!f$1)return;let s=b=>{let y=b.target;!R.current?.contains(y)&&!M.current?.contains(y)&&r();},p=b=>{M.current?.contains(b.target)||r();},g=()=>r();return document.addEventListener("mousedown",s),window.addEventListener("scroll",p,true),window.addEventListener("resize",g),()=>{document.removeEventListener("mousedown",s),window.removeEventListener("scroll",p,true),window.removeEventListener("resize",g);}},[f$1,r]);let u=s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),m$1();return}if(s.key==="Tab"){E==="menu"&&setTimeout(r,0);return}E==="menu"&&J.onKeyDown(s)&&s.stopPropagation();};return jsxs("div",{style:{position:"relative",display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:R,type:"button","data-testid":h,...k.props,"aria-label":o,"aria-haspopup":E,"aria-expanded":f$1!==null,"aria-controls":f$1?ee:void 0,title:io(o,null,k.reason),onMouseDown:s=>s.preventDefault(),onMouseEnter:()=>j$1(true),onMouseLeave:()=>j$1(false),onClick:()=>{i||P(s=>s?null:{focus:"popup",anchor:null});},onKeyDown:s=>{i||(s.key==="ArrowDown"||s.key==="Enter"||s.key===" "?(s.preventDefault(),P({focus:"first",anchor:null})):s.key==="ArrowUp"&&(s.preventDefault(),P({focus:"last",anchor:null})));},...Z.focusProps,style:{...f({disabled:i,pressed:l,open:f$1!==null,hovered:A,focusRing:Z.focusRing}),...c},children:t}),k.node,f$1&&createPortal(jsx("div",{dir:"ltr",ref:Ce,id:ee,role:E,"aria-label":o,"aria-orientation":E==="menu"?"vertical":void 0,tabIndex:-1,onKeyDown:u,onBlur:s=>{if(E!=="dialog")return;let p=s.relatedTarget;p&&!M.current?.contains(p)&&!R.current?.contains(p)&&r();},onMouseDown:s=>{E==="menu"&&s.preventDefault();},style:{position:"fixed",top:q?.top??0,left:q?.left??0,visibility:q?"visible":"hidden",zIndex:1e4,width:Math.min(a,window.innerWidth-2*$),maxHeight:q?Math.min(440,q.maxHeight):440,overflowY:"auto",...j,...Y},children:n$1(()=>{let s=K();P(null),E==="menu"&&s?.focus({preventScroll:true});})}),document.body)]})});function fr(e){let o=useRef(null),t=useRef(null),n=oo(),i=useId(),{title:d,disabled:l=false,description:a}=e;return Ke(t,()=>[{kind:"item",id:i,label:d,disabled:l,description:l?a:void 0,onSelect:()=>o.current?.openAt(n?.anchor()??null)}]),jsx("span",{ref:t,style:{display:"inline-flex",flex:"0 0 auto"},children:jsx(rn,{ref:o,...e})})}function xr({label:e,icon:o,selected:t=false,radio:n=false,disabled:i=false,description:d,onClick:l,close:a}){let[c,h]=useState(false),x=m(),C=useId(),f=i?d:void 0;return jsxs(Fragment,{children:[jsxs("button",{type:"button",role:n?"menuitemradio":"menuitem",tabIndex:-1,"aria-disabled":i||void 0,"aria-checked":n?t:void 0,"aria-label":e,"aria-describedby":f?C:void 0,title:f,onMouseEnter:()=>h(true),onMouseLeave:()=>h(false),onClick:()=>{i||(l?.(),a?.());},...x.focusProps,style:k({disabled:i,hovered:c,focusRing:x.focusRing}),children:[jsx("span",{style:{display:"inline-grid",placeItems:"center",width:20,flex:"0 0 auto"},children:o}),jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:e}),t&&jsx(Vt,{name:"check",size:18})]}),f&&jsx("span",{id:C,hidden:true,children:f})]})}function gr(){return jsx("div",{role:"separator",style:l})}export{cr as $,re as A,ae as B,mt as C,Sn as D,X as E,ut as F,z as G,ve as H,qe as I,No as J,xe as K,ct as L,ge as M,On as N,ht as O,Oe as P,$o as Q,Wn as R,$n as S,ft as T,Vt as U,Yt as V,Ke as W,oo as X,io as Y,mo as Z,on as _,ho as a,hr as aa,vo as b,vr as ba,fo as c,rn as ca,ye as d,fr as da,Pn as e,xr as ea,Cn as f,gr as fa,st as g,Ze as h,Xe as i,D as j,tt as k,ot as l,go as m,Po as n,hn as o,vn as p,fn as q,xn as r,G as s,T as t,Te as u,we as v,Q as w,Me as x,Do as y,it as z};
@@ -0,0 +1 @@
1
+ export{a as DEFAULT_MENU_COLORS}from'./chunk-PSW72ZJN.js';import {n}from'./chunk-PS7ULZVL.js';import'./chunk-O2XFH626.js';import {useRef,useId,useState,useLayoutEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';var _='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]',s=8,Y=320;function j(n,g,c){let l=g.offsetWidth,b=g.scrollHeight,o=window.innerWidth,h=window.innerHeight;if(c==="point"){let a=n.left;a+l>o-s&&(a=n.left-l),a=Math.max(s,Math.min(a,o-l-s));let M=h-s-n.top,m=n.top-s;if(b<=M||M>=m)return {top:n.top,left:a,maxHeight:Math.max(M,80)};let E=Math.max(m,80);return {top:Math.max(s,n.top-Math.min(b,E)),left:a,maxHeight:E}}let f=c==="beside",p=f?n.right:n.right-l;f&&p+l>o-s&&(p=n.left-l),p=Math.max(s,Math.min(p,o-l-s));let x=h-s-(f?n.top:n.bottom+4),v=(f?n.bottom:n.top-4)-s;if(b<=x||x>=v)return {top:f?n.top:n.bottom+4,left:p,maxHeight:Math.max(x,80)};let w=Math.max(v,80),k=f?n.bottom:n.top-4;return {top:Math.max(s,k-Math.min(b,w)),left:p,maxHeight:w}}function q(){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 J(){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 Q({id:n$1,label:g,entries:c,anchor:l,mode:b,colors:o,initialFocus:h,onClose:f,onSelect:p,registerMenu:x,className:v,testId:w}){let k=b==="beside",a=useRef(null),M=useId(),[m,E]=useState(null),C=useRef(false),[N,F]=useState(null),[G,z]=useState(null),[R,S]=useState(null),L=useRef(new Map),y=n({container:a,itemSelector:_,scope:'[role="menu"]',labelOf:t=>t.dataset.label??t.textContent??""});useLayoutEffect(()=>a.current?x(a.current):void 0,[x]),useLayoutEffect(()=>{let t=l(),e=a.current;if(!t||!e)return;let d=j(t,e,b);E(i=>i&&i.top===d.top&&i.left===d.left&&i.maxHeight===d.maxHeight?i:d);},[l,b,c]),useLayoutEffect(()=>{!m||C.current||(C.current=true,h==="first"?y.focusFirst():h==="last"?y.focusLast():h==="menu"&&a.current?.focus({preventScroll:true}));},[h,m,y]);let O=(t,e)=>S({id:t,focus:e}),U=t=>{if(t.target instanceof Node&&!a.current?.contains(t.target))return;let e=t.target instanceof HTMLElement?t.target.closest(_):null,d=e&&e.closest('[role="menu"]')===a.current?e:null;if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),f(k?"parent":"escape");return}if(t.key==="Tab"){setTimeout(()=>f("tab"),0);return}if(k&&t.key==="ArrowLeft"){t.preventDefault(),t.stopPropagation(),f("parent");return}if(d?.dataset.submenu&&(t.key==="ArrowRight"||t.key==="Enter"||t.key===" ")){t.preventDefault(),t.stopPropagation(),d.getAttribute("aria-disabled")!=="true"&&O(d.dataset.submenu,"first");return}if(d&&(t.key==="Enter"||t.key===" ")){t.preventDefault(),t.stopPropagation();let i=B(c,d.dataset.entry??"");i&&!i.disabled&&p(i,"keyboard");return}y.onKeyDown(t)&&t.stopPropagation();},A=t=>t.map(e=>{if(e.kind==="separator")return jsx("div",{role:"separator",style:{height:1,margin:"4px 0",background:o.border}},e.id);if(e.kind==="group"){let u=`${M}-${e.id}-label`;return jsxs("div",{role:"group","aria-labelledby":e.label?u:void 0,children:[e.label&&jsx("div",{id:u,style:{padding:"6px 12px 2px",fontSize:11,fontWeight:500,color:o.mutedText,overflowWrap:"anywhere"},children:e.label}),A(e.entries)]},e.id)}let d=e.description?`${M}-${e.id}-description`:void 0,i=e.kind==="submenu",T=i?"menuitem":e.radio?"menuitemradio":e.checked!==void 0?"menuitemcheckbox":"menuitem",H=i?void 0:e.checked,$=i&&R?.id===e.id;return jsxs("div",{style:{position:"relative"},children:[jsxs("div",{role:T,tabIndex:-1,"data-entry":e.id,"aria-keyshortcuts":i?void 0:e.ariaShortcut,"data-label":e.label,"data-submenu":i?e.id:void 0,"aria-haspopup":i?"menu":void 0,"aria-expanded":i?$:void 0,"aria-checked":T==="menuitemcheckbox"||T==="menuitemradio"?H==="mixed"?"mixed":H===true:void 0,"data-plugin-activation":i?void 0:e.activationId,"aria-disabled":e.disabled?true:void 0,"aria-describedby":d,title:e.description,ref:u=>{i&&u&&L.current.set(e.id,u);},onMouseDown:u=>u.preventDefault(),onMouseEnter:()=>{i&&!e.disabled?O(e.id,"none"):R&&S(null),z(e.id);},onMouseLeave:()=>z(null),onFocus:()=>F(e.id),onBlur:()=>F(u=>u===e.id?null:u),onClick:()=>{e.disabled||(i?O(e.id,"none"):p(e,"pointer"));},style:{display:"flex",alignItems:"center",gap:8,minHeight:32,margin:"0 4px",padding:"4px 12px 4px 8px",borderRadius:6,fontSize:13,cursor:e.disabled?"default":"pointer",color:e.disabled?o.mutedText:o.text,opacity:e.disabled?.6:1,background:!e.disabled&&(G===e.id||N===e.id)?o.hover:"transparent",...N===e.id?{outline:`2px solid ${o.focus}`,outlineOffset:-2}:{outline:"none"}},children:[jsx("span",{style:{width:16,flexShrink:0,display:"inline-flex",justifyContent:"center"},children:H===true?jsx(q,{}):H==="mixed"?"\u2013":null}),e.icon&&jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",flexShrink:0},children:e.icon}),jsx("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:e.label}),!i&&e.shortcut&&jsx("span",{"aria-hidden":"true",style:{marginLeft:16,flexShrink:0,maxWidth:"45%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,color:o.mutedText},children:e.shortcut}),i&&jsx("span",{style:{display:"inline-flex",flexShrink:0},children:jsx(J,{})})]}),d&&jsx("span",{id:d,hidden:true,children:e.description}),i&&$&&jsx(Q,{label:e.label,entries:e.entries,anchor:()=>L.current.get(e.id)?.getBoundingClientRect()??null,mode:"beside",colors:o,initialFocus:R?.focus??"none",onClose:u=>{S(null),u==="parent"?L.current.get(e.id)?.focus():f(u);},onSelect:p,registerMenu:x})]},e.id)});return jsx("div",{ref:a,id:n$1,role:"menu","aria-label":g,"aria-orientation":"vertical",tabIndex:-1,className:v,"data-testid":w,onKeyDown:U,onContextMenu:t=>t.preventDefault(),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*s),maxWidth:Math.min(Y,window.innerWidth-2*s),padding:"4px 0",background:o.surface,color:o.text,border:`1px solid ${o.border}`,borderRadius:8,boxShadow:`0 4px 16px ${o.shadow}`,zIndex:1e4,boxSizing:"border-box",outline:"none"},children:A(c)})}function B(n,g){for(let c of n){if(c.kind==="item"&&c.id===g)return c;if(c.kind==="group"){let l=B(c.entries,g);if(l)return l}}return null}export{Q as MenuList,B as findItem};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-LEWN3FCH.js';import'./chunk-O2XFH626.js';import {jsxs,Fragment,jsx}from'react/jsx-runtime';function g({change:e,t:r,testId:o}){return e.oldText===e.newText?null:jsxs("div",{"data-testid":o,style:s.textDiff,children:[jsx("del",{style:s.deleted,children:e.oldText||r("proposals.blank")}),jsx("ins",{style:s.inserted,children:e.newText||r("proposals.blank")})]})}function w({change:e,proposal:r,t:o,lang:p,textOnly:i,testId:a$1}){return jsxs(Fragment,{children:[e.kind==="inserted"&&jsx("p",{children:o(e.shapeId?"proposals.insertedShape":"proposals.insertedSlide")}),e.kind==="deleted"&&jsx("p",{children:o(e.shapeId?"proposals.deletedShape":"proposals.deletedSlide")}),e.kind==="moved"&&jsx("p",{children:o("proposals.movedFrom",{number:(e.beforeIndex??0)+1})}),a(e,r,o).map((f,l)=>jsx("p",{children:f},l)),jsx(g,{change:e,t:o,testId:a$1}),!i&&e.before&&e.after&&jsx(b,{change:e,t:o,lang:p})]})}function b({change:e,t:r,lang:o}){let p=e.before,i=e.after,a=p.x!==i.x||p.y!==i.y||p.width!==i.width||p.height!==i.height,f=new Intl.NumberFormat(o??"en",{minimumFractionDigits:1,maximumFractionDigits:1}),l=n=>[n.x,n.y,n.width,n.height].map(y=>f.format(y/12700)).join(", ");return jsxs(Fragment,{children:[a&&jsxs("p",{style:s.detail,children:[r("proposals.geometry"),jsx("br",{}),r("proposals.geometryValues",{before:l(p),after:l(i)})]}),JSON.stringify({...p,x:0,y:0,width:0,height:0})!==JSON.stringify({...i,x:0,y:0,width:0,height:0})&&e.oldText===e.newText&&jsx("p",{style:s.detail,children:r("proposals.appearance")})]})}var s={textDiff:{display:"grid",gap:6,margin:"8px 0",whiteSpace:"pre-wrap",overflowWrap:"anywhere",maxHeight:200,overflowY:"auto"},deleted:{color:"#9f1239",background:"#fff1f2",padding:"4px 6px"},inserted:{color:"#166534",background:"#f0fdf4",padding:"4px 6px",textDecoration:"none"},detail:{color:"#64748b",lineHeight:1.5}};export{w as ProposalChangeDetails};
@@ -0,0 +1 @@
1
+ import {useRef,useCallback,useState}from'react';var L=500;function H(e){let o=useRef(e);o.current=e;let a=useRef({buffer:"",at:0}),n=useCallback(()=>{let{container:t,itemSelector:i,scope:c}=o.current,f=t.current;return f?Array.from(f.querySelectorAll(i)).filter(x=>!c||x.closest(c)===f):[]},[]),s=useCallback(t=>{let i=n();i.length!==0&&i[(t+i.length)%i.length].focus();},[n]),d=useCallback(t=>{let i=n();if(i.length===0)return false;let c=i.findIndex(g=>g===document.activeElement),f=(o.current.orientation??"vertical")==="vertical",x=f?"ArrowDown":"ArrowRight",C=f?"ArrowUp":"ArrowLeft",b=null;if(t.key===x)b=c+1;else if(t.key===C)b=c<0?i.length-1:c-1;else if(t.key==="Home")b=0;else if(t.key==="End")b=i.length-1;else if(t.key.length===1&&t.key!==" "&&!t.ctrlKey&&!t.metaKey&&!t.altKey){let g=Date.now(),l=a.current;l.buffer=g-l.at>L?t.key.toLowerCase():l.buffer+t.key.toLowerCase(),l.at=g;let m=o.current.labelOf??(u=>u.textContent??""),y=[...i.slice(c+1),...i.slice(0,c+1)],O=[...l.buffer].every(u=>u===l.buffer[0]),k=y.find(u=>m(u).trim().toLowerCase().startsWith(l.buffer))??(O?y.find(u=>m(u).trim().toLowerCase().startsWith(l.buffer[0])):void 0);return k?(t.preventDefault(),k.focus(),true):false}return b===null?false:(t.preventDefault(),s(b),true)},[s,n]);return {items:n,focusFirst:useCallback(()=>s(0),[s]),focusLast:useCallback(()=>s(-1),[s]),onKeyDown:d}}var F=["ink","ink-muted","rail","surface","hover","selected","line","accent","accent-ink"],r={ink:"var(--bo-toolbar-ink, #1f1f1f)",inkMuted:"var(--bo-toolbar-ink-muted, #444746)",rail:"var(--bo-toolbar-rail, #f1f1f1)",surface:"var(--bo-toolbar-surface, #ffffff)",hover:"var(--bo-toolbar-hover, rgba(31, 31, 31, 0.08))",selected:"var(--bo-toolbar-selected, rgba(31, 31, 31, 0.12))",line:"var(--bo-toolbar-line, rgba(31, 31, 31, 0.16))",accent:"var(--bo-toolbar-accent, #1f1f1f)",accentInk:"var(--bo-toolbar-accent-ink, #ffffff)"},v=28,K=18,R=6,T=.38,S='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',P="0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08)";function E(e,o=1){return e===void 0?{}:e?{outline:`2px solid ${r.accent}`,outlineOffset:o}:{outline:"none"}}function D(e){if(!e)return {};let o=getComputedStyle(e),a={};for(let n of F){let s=`--bo-toolbar-${n}`,d=o.getPropertyValue(s).trim();d&&(a[s]=d);}return a}function w({disabled:e=false,pressed:o=false,open:a=false,hovered:n=false,focusRing:s}){return {appearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:2,minWidth:v,height:v,padding:"0 4px",border:0,borderRadius:R,background:o?r.selected:(n||a)&&!e?r.hover:"transparent",color:o||n||a?r.ink:r.inkMuted,cursor:e?"default":"pointer",opacity:e?T:1,font:`500 13px ${S}`,lineHeight:1,whiteSpace:"nowrap",boxSizing:"border-box",...E(s)}}function $({disabled:e=false,focusRing:o}){return {...w({disabled:e,focusRing:o}),background:r.accent,color:r.accentInk}}var z={display:"flex",alignItems:"center",gap:0,minHeight:36,padding:"4px 8px",borderRadius:18,background:r.rail,color:r.ink,font:`400 13px ${S}`,boxSizing:"border-box"},N={width:1,height:20,margin:"0 6px",background:r.line,flex:"0 0 auto"},U={padding:4,border:`1px solid ${r.line}`,borderRadius:8,background:r.surface,color:r.ink,boxShadow:P,boxSizing:"border-box",outline:"none"};function W({disabled:e=false,hovered:o=false,focusRing:a}){return {appearance:"none",display:"flex",alignItems:"center",gap:10,width:"100%",minHeight:32,padding:"4px 10px",border:0,borderRadius:R,background:(o||a)&&!e?r.hover:"transparent",color:r.ink,cursor:e?"default":"pointer",opacity:e?T:1,font:`400 13px ${S}`,textAlign:"left",boxSizing:"border-box",...E(a,-2)}}var j={height:1,margin:"4px 2px",background:r.line};function I(e){try{return e.matches(":focus-visible")}catch{return true}}function Y(e={}){let[o,a]=useState(false);return {focusRing:o,focusProps:{onFocus:n=>{a(I(n.currentTarget)),e.onFocus?.(n);},onBlur:n=>{a(false),e.onBlur?.(n);}}}}export{r as a,K as b,T as c,E as d,D as e,w as f,$ as g,z as h,N as i,U as j,W as k,j as l,Y as m,H as n};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-PS7ULZVL.js';var r={surface:a.surface,text:a.ink,mutedText:a.inkMuted,border:a.line,hover:a.hover,shadow:"rgba(0, 0, 0, 0.12)",focus:a.accent};export{r as a};
@@ -0,0 +1 @@
1
+ export{a as readFontTraits}from'./chunk-3RN73K5U.js';import'./chunk-O2XFH626.js';