@betteroffice/pptx-react 0.2.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -350
- package/dist/chunk-3Y6BQIW3.js +1 -0
- package/dist/chunk-66PPYFHW.js +4 -0
- package/dist/chunk-HGG45CCF.js +1 -0
- package/dist/chunk-HQ2N3DQ7.js +1 -0
- package/dist/chunk-J3YQUJUG.js +1 -0
- package/dist/chunk-M267LYSF.js +1 -0
- package/dist/chunk-O2XFH626.js +1 -0
- package/dist/chunk-V62S3LXB.js +1 -0
- package/dist/chunk-X2M23RXQ.js +1 -0
- package/dist/chunk-X6B77B3U.js +1 -0
- package/dist/index.d.ts +167 -6
- package/dist/index.js +1 -4
- package/package.json +8 -5
package/dist/index.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import {StaleProposalError,initWasm,openPresentation,sizeCanvasForSlide,paintSlide,PRESENCE_LABEL_DURATION_MS,decodePresentationImage,presentationImageBlob,slideToPng}from'@betteroffice/pptx';import {createContext,forwardRef,useState,useRef,useCallback,useId,useImperativeHandle,useLayoutEffect,useEffect,useContext,useMemo,useSyncExternalStore,useReducer,Component}from'react';import {en as en$1,deepMerge,createT}from'@betteroffice/pptx-i18n';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';var au=Object.defineProperty;var su=(e,t,n)=>t in e?au(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var Yt=(e,t,n)=>su(e,typeof t!="symbol"?t+"":t,n);var da=createContext(en$1),ua=createContext("en");function Jt({i18n:e,children:t}){let n=typeof e?._lang=="string"?e._lang:"en",o=useMemo(()=>deepMerge(en$1,e),[e]);return jsx(ua.Provider,{value:n,children:jsx(da.Provider,{value:o,children:t})})}function Q(){let e=useContext(da),t=useContext(ua);return {t:useMemo(()=>createT(e,t),[e,t])}}function me(e,t,n,o=[]){return Object.freeze({id:e,labelKey:t,mutatesDocument:n,shortcuts:Object.freeze(o)})}var Qt=e=>({chord:e,args:null}),rt=Object.freeze({bold:me("bold","toolbar.bold",true,[Qt("Mod+B")]),italic:me("italic","toolbar.italic",true,[Qt("Mod+I")]),underline:me("underline","toolbar.underline",true,[Qt("Mod+U")]),fontFamily:me("fontFamily","toolbar.fontFamily",true),fontSize:me("fontSize","toolbar.fontSize",true),fontSizeStep:me("fontSizeStep","commands.fontSizeStep",true),textColor:me("textColor","toolbar.textColor",true),alignment:me("alignment","toolbar.groups.alignment",true),insertSlide:me("insertSlide","toolbar.newSlide",true),insertImage:me("insertImage","toolbar.insertImage",true),tool:me("tool","toolbar.groups.tools",false),shapeFill:me("shapeFill","toolbar.fillColor",true),shapeStrokeColor:me("shapeStrokeColor","toolbar.borderColor",true),shapeStrokeWidth:me("shapeStrokeWidth","toolbar.borderWidth",true),shapeAdjustment:me("shapeAdjustment","toolbar.shapeAdjustment",true),zOrder:me("zOrder","toolbar.arrange",true),save:me("save","toolbar.save",false,[Qt("Mod+S")]),exportPng:me("exportPng","toolbar.exportPng",false),slideshow:me("slideshow","toolbar.present",false),undo:me("undo","toolbar.undo",true,[Qt("Mod+Z")]),redo:me("redo","toolbar.redo",true,[Qt("Mod+Shift+Z")]),zoom:me("zoom","toolbar.groups.zoom",false),proposalsPanel:me("proposalsPanel","proposals.title",false),proposalSelect:me("proposalSelect","proposals.canvasTitle",false),proposalDiff:me("proposalDiff","proposals.showDiff",false),proposalAccept:me("proposalAccept","proposals.accept",true),proposalReject:me("proposalReject","proposals.reject",true)});Object.freeze(Object.keys(rt));function ca(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(rt,e)}var uu=/^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 Ge(e){return typeof e=="string"&&uu.test(e)}function en(e){return e==="insertSlide"?{}:null}function sr(e){let t=e.split("+"),n=t.length>1&&t[t.length-1]===""?"+":t[t.length-1],o=new Set(t.slice(0,-1));return {mod:o.has("Mod"),shift:o.has("Shift"),alt:o.has("Alt"),key:n.toLowerCase()}}var cu=new Set(["Mod","Shift","Alt"]);function tn(e){if(typeof e!="string"||e.length===0)return null;let t=e.split("+");if(!(t.length>1&&t[t.length-1]===""?t.slice(0,-2):t.slice(0,-1)).every(r=>cu.has(r)))return null;let o=sr(e);return o.key.length===0?null:[o.mod&&"Mod",o.alt&&"Alt",o.shift&&"Shift",o.key].filter(Boolean).join("+")}var pa=new Set(["Mod+A","Mod+C","Mod+V","Mod+X","Mod+Shift+V"].map(e=>tn(e))),ma=new Set(Object.values(rt).flatMap(e=>e.shortcuts.map(t=>tn(t.chord))));function fa(){return typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform)}function lr(e,t,n=fa()){let o=sr(e),r=n?t.metaKey:t.ctrlKey,s=n?t.ctrlKey:t.metaKey;return o.mod===r&&!s&&o.shift===t.shiftKey&&o.alt===t.altKey&&t.key.toLowerCase()===o.key}function dr(e,t=fa()){let n=sr(e),o=n.key.length===1?n.key.toUpperCase():n.key;return t?`${n.alt?"\u2325":""}${n.shift?"\u21E7":""}${n.mod?"\u2318":""}${o}`:[n.mod&&"Ctrl",n.alt&&"Alt",n.shift&&"Shift",o].filter(Boolean).join("+")}function Zn(e,t){let n=rt[e].shortcuts,o=JSON.stringify(t??en(e)),r=n.find(s=>JSON.stringify(s.args)===o);return r?dr(r.chord):null}var it=[{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 Xn(e){if(!e.startsWith("shape:"))return null;let t=e.slice(6);return it.some(n=>n.geometry===t)?t:null}function ga(e){if(!e)return null;if(e.adj!==void 0)return ["adj",e.adj];if(e.adj1!==void 0)return ["adj1",e.adj1];let t=Object.keys(e).sort()[0];return t?[t,e[t]]:null}function ur(e,t){return e==="roundRect"&&t==="adj"?.5:1}var pu={"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 Be(e,t,n=pu[e]){return {code:e,message:t?t.translate(n):e==="editor-unavailable"?"The editor is not ready.":e}}var Yn=1,Jn=400,pr=.25,mr=4,mu=1584,fu=[.5,.75,1,1.25,1.5,2],gu=[1,2,3,4,8],Qn=["Arial","Calibri","Cambria","Georgia","Roboto","Times New Roman","Verdana"],eo=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],to=24,xa=[{value:"l",labelKey:"toolbar.align.left"},{value:"ctr",labelKey:"toolbar.align.center"},{value:"r",labelKey:"toolbar.align.right"},{value:"just",labelKey:"toolbar.align.justify"}],hu=new Set(["front","forward","backward","back"]);function Ne(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function qn(e){return typeof e=="number"&&Number.isFinite(e)}function wn(e){return typeof e=="string"&&e.trim().length>0}function ha(e){return typeof e=="string"&&/^#[0-9a-f]{6}$/i.test(e)}function xu(e){return e==="select"||e==="textBox"||typeof e=="string"&&Xn(e)!==null}function no(e,t,n){return n>0?t.find(o=>o>e)??Math.min(Jn,e+1):[...t].reverse().find(o=>o<e)??Math.max(Yn,e-1)}function bu(e,t){if(t===void 0)return true;let n=t;switch(e){case "fontFamily":return Ne(n)&&wn(n.family);case "fontSize":return Ne(n)&&qn(n.points)&&n.points>=Yn&&n.points<=Jn;case "fontSizeStep":return Ne(n)&&(n.direction==="increase"||n.direction==="decrease");case "textColor":return Ne(n)&&ha(n.color);case "alignment":return Ne(n)&&xa.some(o=>o.value===n.value);case "insertSlide":return Ne(n)&&(n.layoutPartPath===void 0||n.layoutPartPath===null||wn(n.layoutPartPath));case "tool":return Ne(n)&&xu(n.value);case "shapeFill":case "shapeStrokeColor":return Ne(n)&&(n.color===null||ha(n.color));case "shapeStrokeWidth":return Ne(n)&&(n.points===null||qn(n.points)&&n.points>0&&n.points<=mu);case "shapeAdjustment":return Ne(n)&&wn(n.name)&&qn(n.value);case "zOrder":return Ne(n)&&hu.has(n.value);case "zoom":return Ne(n)&&(n.scale==="fit"||qn(n.scale)&&n.scale>=pr&&n.scale<=mr);case "proposalsPanel":return n===null||Ne(n)&&typeof n.open=="boolean";case "proposalSelect":case "proposalReject":return Ne(n)&&wn(n.proposalId);case "proposalDiff":return Ne(n)&&typeof n.enabled=="boolean";case "proposalAccept":return Ne(n)&&wn(n.proposalId)&&(n.force===void 0||typeof n.force=="boolean");default:return n===null}}function Dt(e){switch(e.status){case "unavailable":return "editor-unavailable";case "loading":return "document-loading";case "empty":return "no-document";default:return null}}function $e(e){return Dt(e)??(e.readOnly?"read-only":null)}function cr(e){return e.slide?null:"slide-required"}function fr(e){return e.reviewing?"review-active":null}function nn(e){return $e(e)??fr(e)??(e.text==="unsupported"?"unsupported-selection":e.text?null:"text-selection-required")}function Vn(e){return $e(e)?$e(e):e.reviewing?"review-active":e.shape?e.shape.formattable?null:"unsupported-selection":"shape-required"}function Pu(e){return e.text&&e.text!=="unsupported"?e.text:null}function yu(e,t){let n=$e(e)??fr(e)??(e.shape?null:"shape-required");if(n||!e.shape?.order)return n;let{index:o,count:r}=e.shape.order,s=o>=r-1,i=o<=0;return t===void 0?s&&i?"z-order-boundary":null:(t==="front"||t==="forward"?s:i)?"z-order-boundary":null}function vu(e,t){return e==="fit"?t.translate("toolbar.fit"):`${Math.round(e*100)}%`}function Su(e,t){return e==="fit"||t==="fit"?e===t:Math.abs(e-t)<.001}function Cu(e){return [{args:{value:"select"},label:e.translate("commands.selectTool")},{args:{value:"textBox"},label:e.translate("toolbar.textBoxTool")},...it.map(t=>({args:{value:`shape:${t.geometry}`},label:e.translate(t.labelKey)}))]}function wu(e,t,n){let o=$e(t)??(t.proposals?null:"proposals-unavailable");if(o||!n)return {gate:o};let r=t.proposals.pending.find(s=>s.id===n.proposalId);return r?e==="proposalReject"?{gate:null}:{gate:r.stale&&!n.force?"proposal-stale":null}:{gate:"proposal-not-found"}}function Iu(e,t,n){let o=Pu(n),r=n.translate,s=i=>i;switch(e){case "bold":case "italic":case "underline":return {gate:nn(n),active:o?.[e]};case "fontFamily":{let i=n.fontFamilies;return s({gate:nn(n),value:o?o.fontFamily:void 0,options:i.map(a=>({args:{family:a},label:a})),active:t?o?.fontFamily===t.family:void 0})}case "fontSize":{let i=t;return s({gate:nn(n),value:o?o.fontSize:void 0,options:n.fontSizes.map(a=>({args:{points:a},label:String(a)})),active:i?o?.fontSize===i.points:void 0})}case "fontSizeStep":return {gate:nn(n)};case "textColor":return s({gate:nn(n),value:o?o.color:void 0});case "alignment":{let i=t;return s({gate:nn(n),value:o?o.alignment:void 0,options:xa.map(a=>({args:{value:a.value},label:r(a.labelKey)})),active:i?o?.alignment===i.value:void 0})}case "insertSlide":{let i=t,a=i?.layoutPartPath,f=typeof a!="string"||n.layouts.some(u=>u.args.layoutPartPath===a);return s({gate:$e(n)??(f?null:"invalid-layout"),value:n.slide?n.slide.layoutPartPath:void 0,options:n.layouts,active:i&&a!==void 0&&n.slide?(a??null)===n.slide.layoutPartPath:void 0})}case "insertImage":return {gate:$e(n)??cr(n)??fr(n)};case "tool":{let i=t?.value,a=i==="select"?Dt(n):$e(n)??cr(n);return s({gate:a,value:n.tool,options:Cu(n),active:i?n.tool===i:void 0})}case "shapeFill":return s({gate:Vn(n),value:n.shape?.formattable?n.shape.fill:void 0});case "shapeStrokeColor":return s({gate:Vn(n),value:n.shape?.formattable?n.shape.stroke:void 0});case "shapeStrokeWidth":{let i=t,a=n.shape?.formattable?n.shape.strokeWidth:void 0;return s({gate:Vn(n),value:a,options:[{args:{points:null},label:r("toolbar.noBorder")},...gu.map(f=>({args:{points:f},label:r("toolbar.borderWidthValue",{width:f})}))],active:i&&a!==void 0?a===i.points:void 0})}case "shapeAdjustment":{let i=n.shape?.formattable?n.shape:null,a=i?ga(i.adjustments):null,f=t,u=Vn(n)??(a?null:"invalid-adjustment"),p=a?ur(i.geometry,a[0]):1,g=f&&i&&(!Object.prototype.hasOwnProperty.call(i.adjustments,f.name)||f.value<0||f.value>ur(i.geometry,f.name)),c=a?Array.from({length:Math.round(p*10)+1},(x,S)=>S/10):[];return s({gate:u??(g?"invalid-adjustment":null),value:i?a?{name:a[0],value:a[1]}:null:void 0,options:a?c.map(x=>({args:{name:a[0],value:x},label:`${Math.round(x*100)}%`})):[],active:f&&a?f.name===a[0]&&Math.abs(f.value-a[1])<5e-4:void 0})}case "zOrder":return {gate:yu(n,t?.value),reasonKey:n.shape?void 0:"commands.reasons.objectRequired"};case "save":return {gate:Dt(n)};case "exportPng":case "slideshow":return {gate:Dt(n)??cr(n)};case "undo":return {gate:$e(n)??(n.canUndo||n.pendingInput?null:"nothing-to-undo")};case "redo":return {gate:$e(n)??(n.canRedo||n.pendingInput?null:"nothing-to-redo")};case "zoom":{let i=t,a=["fit",...fu];return s({gate:Dt(n),value:n.zoom,options:a.map(f=>({args:{scale:f},label:vu(f,n)})),active:i?Su(n.zoom,i.scale):void 0})}case "proposalsPanel":{let i=t,a=n.proposals?.open??false;return s({gate:$e(n)??(n.proposals?null:"proposals-unavailable"),value:a,active:i?a===i.open:a})}case "proposalSelect":{let i=t,a=n.proposals?.canvas,f=$e(n)??(a?null:"proposals-unavailable"),u=!i||!a||a.available.some(p=>p.id===i.proposalId);return s({gate:f??(a&&a.available.length===0?"proposal-not-found":null)??(u?null:"proposal-not-found"),value:a?.selectedId??null,options:(a?.available??[]).map(p=>({args:{proposalId:p.id},label:p.label})),active:i?a?.selectedId===i.proposalId:void 0})}case "proposalDiff":{let i=t,a=n.proposals?.canvas;return s({gate:$e(n)??(a?null:"proposals-unavailable")??(a?.selectedId?null:"proposal-not-found"),value:a?.diff??false,active:i?(a?.diff??false)===i.enabled:a?.diff??false})}case "proposalAccept":case "proposalReject":return s(wu(e,n,t));default:return {gate:"unsupported-command"}}}function Eu(e){let t=e.active===void 0?{}:{active:e.active};return e.enabled?{...t,enabled:true}:{...t,enabled:false,disabledReason:e.disabledReason}}function ba(e,t){if(!t)return Be("editor-unavailable",null);let n=e?$e(t):Dt(t);return n?Be(n,t):null}function In(e,t,n){if(!n)return {enabled:false,disabledReason:Be("editor-unavailable",null)};let o=bu(e,t)?Iu(e,t,n):{gate:Dt(n)??"invalid-arguments"},r=n.hostDisabled?.(e)?"host-disabled":o.gate,s={};return o.active!==void 0&&(s.active=o.active),o.value!==void 0&&(s.value=o.value),o.options!==void 0&&t===void 0&&(s.options=o.options.map(i=>({...i,state:Eu(In(e,i.args,n))}))),r?{...s,enabled:false,disabledReason:Be(r,n,r===o.gate?o.reasonKey:void 0)}:{...s,enabled:true}}var on=class extends Error{constructor(n){super(n);Yt(this,"code",n);}},gr=512,xr=new WeakMap;function Ft(e,t){return {ok:false,failure:Be(e,t)}}function Pa(e,t){return t===void 0?e:`${e}\0${JSON.stringify(t)}`}function Tu(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 ya(e){return !Ge(e)&&rt[e].mutatesDocument}function hr(e){return ca(e)||Ge(e)}function En(){let e=null,t=new Map,n=Object.freeze([]),o=Object.freeze([]),r=new WeakMap,s=new WeakSet,i=new Set,a=new Map,f=new Set,u=new Set,p=null,g=0,c=C=>{if(!e)return null;try{return e.environment(C)}catch(F){return console.error("[pptx commands] reading editor state failed",F),null}},x=(C,F)=>{let H=t.get(C);if(!H)return {enabled:false,disabledReason:Be("unsupported-command",F)};let h=ba(H.descriptor.mutatesDocument,F);return h?{enabled:false,disabledReason:h}:H.state()},S=(C,F,H)=>Ge(C)?x(C,H):In(C,F,H),L=()=>{g+=1;for(let C of [...i])C();},A=()=>{if(!(a.size<=gr))for(let[C,F]of a){if(a.size<=gr)break;F.holds===0&&F.read<g&&a.delete(C);}},G=(C,F)=>{let H=Pa(C,F),h=a.get(H);if(!h){let y=hr(C)?S(C,F,c(false)):{enabled:false,disabledReason:Be("unsupported-command",c(false))};h={id:C,args:F,json:JSON.stringify(y),state:y,holds:0,read:g},a.set(H,h),A();}return h.read=g,h},D=()=>{let C=null;try{C=e?.chrome()??null;}catch(H){console.error("[pptx commands] reading editor chrome failed",H);}if(!(C===p||C!==null&&p!==null&&C.i18n===p.i18n)){p=C;for(let H of [...u])H();}},R=()=>{if(D(),A(),a.size===0)return;let C=c(false),F=false;for(let H of a.values()){if(!hr(H.id))continue;let h=S(H.id,H.args,C),y=JSON.stringify(h);y!==H.json&&(H.state=h,H.json=y,F=true);}F&&L();},_=C=>{try{return e?.capture(C)??null}catch(F){return console.error("[pptx commands] capturing a command target failed",F),null}};async function M(C,F,H,h,y){let K=e;if(!K)return Ft("editor-unavailable",null);let z=Ge(C)?null:C,W=h!==void 0||z!==null&&K.ordered(z,F),j=h?h.origin:W&&z?_(z):void 0,Y=()=>{if(j!==void 0){let Ut=j?K.resume(j):"editor-unavailable";if(Ut)return Ft(Ut,c(true))}let oe=y?.deny(C)??null;if(oe)return Ft(oe,c(true));let pe=c(true),$t=S(C,F,pe);return $t.enabled?y&&ya(C)?Ft("unsupported-policy",pe):H(pe):{ok:false,failure:$t.disabledReason}};try{return await(W?K.admit(Y):Y())}catch(oe){return oe instanceof on?Ft(oe.code,c(false)):(console.error(`[pptx commands] ${C} failed`,oe),Ft("command-failed",c(false)))}finally{R();}}let v=(C,F,H)=>Ge(C)?t.get(C).execute():e.perform(C,F,H),w=(C,F,H)=>hr(C)?M(C,F,h=>v(C,F,h),void 0,H):Promise.resolve(Ft("unsupported-command",c(false))),O=C=>Ge(C)?t.get(C)?.descriptor??null:rt[C],m=Object.freeze({getDescriptor:O,getState:(C,F)=>G(C,F).state,subscribe(C){return i.add(C),()=>{i.delete(C);}},execute:(C,F)=>w(C,F)}),E=C=>{let F=new Map,h=Object.freeze({getDescriptor:O,getState:(y,K)=>{let z=G(y,K).state,W=C.deny(y),j=!W&&z.enabled&&ya(y),Y=Pa(y,K),oe=F.get(Y);if(oe&&oe.base===z&&oe.denial===W&&oe.policy===j)return oe.state;let pe=W?Tu(W):j?"unsupported-policy":null,{enabled:$t,disabledReason:Ut,...Nn}=z,xn=pe?{...Nn,enabled:false,disabledReason:Be(pe,c(false))}:z;return F.size>=gr&&F.delete(F.keys().next().value),F.set(Y,{base:z,denial:W,policy:j,state:xn}),xn},subscribe(y){let K=[m.subscribe(y),C.subscribe(y)];return ()=>{for(let z of K)z();}},execute:(y,K)=>w(y,K,C)});return xr.set(h,{...B,store:h,defer(y,K){let z=_(y);return {complete:W=>{let j=e;return M(y,K,Y=>W(()=>j.perform(y,K,Y)),{origin:z},C)}}},prepare(y){let K=_(y);return {execute:z=>M(y,z,W=>e.perform(y,z,W),{origin:K},C)}}}),h},B={store:m,attach(C){e=C,R();},detach(C){e===C&&(e=null,R());},refresh:R,hold(C,F){let H=G(C,F);H.holds+=1;let h=true;return ()=>{h&&(h=false,H.holds-=1);}},defer(C,F){let H=_(C);return {complete:h=>{let y=e;return M(C,F,K=>h(()=>y.perform(C,F,K)),{origin:H})}}},prepare(C){let F=_(C);return {execute:H=>M(C,H,h=>e.perform(C,H,h),{origin:F})}},registerChrome(C){return f.add(C),()=>{f.delete(C);}},ownsChrome(C){if(!(C instanceof Node))return false;for(let F of f)if(F.contains(C))return true;return false},chrome:()=>p,subscribeChrome(C){return u.add(C),()=>{u.delete(C);}},focusEditor(){e?.focusEditor();},setPluginCommands(C,F){t=new Map(C.map(H=>[H.descriptor.id,H])),n=Object.freeze(F.filter(H=>t.has(H))),o=Object.freeze(C.flatMap(H=>H.descriptor.shortcuts.map(({chord:h})=>({id:H.descriptor.id,chord:h})))),R(),L();},pluginToolbar:()=>n,pluginShortcuts:()=>o,scoped(C){let F=r.get(C);return F||(F=E(C),r.set(C,F),s.add(F)),F},ownsStore:C=>s.has(C)};return s.add(m),xr.set(m,B),B}function je(e){return xr.get(e)??null}var rn=En().store;var dt=createContext(null);function ku({commands:e,children:t}){return jsx(dt.Provider,{value:e??rn,children:t})}function le(){let e=useContext(dt);if(!e)throw new Error("usePptxCommands must be used inside PptxEditor chrome or a PptxCommandProvider");return e}function br(e){return e===void 0?void 0:JSON.parse(e)}function he(e,t){let n=le(),o=t===void 0?void 0:JSON.stringify(t),r=useCallback(i=>{let a=je(n)?.hold(e,br(o)),f=n.subscribe(i);return ()=>{f(),a?.();}},[n,e,o]),s=useCallback(()=>n.getState(e,br(o)),[n,e,o]);return useSyncExternalStore(r,s,s)}function oo(e,t){let n=le(),o=he(e,t),{t:r}=Q(),s=n.getDescriptor(e),i=t===void 0?void 0:JSON.stringify(t),a=useCallback(f=>n.execute(e,f!==void 0?f:i!==void 0?JSON.parse(i):en(e)),[n,e,i]);return useMemo(()=>{if(Ge(e)){let u=s,p=u?.shortcuts[0]?.chord;return {id:e,descriptor:u,state:o,label:u?.label??e,shortcut:p?dr(p):null,execute:()=>a()}}let f=s;return {id:e,descriptor:f,state:o,label:r(f.labelKey),shortcut:Zn(e,br(i)),execute:a}},[e,s,o,r,i,a])}function Ca(){let e=je(le()),t=useCallback(o=>e?.subscribeChrome(o)??(()=>{}),[e]),n=useCallback(()=>e?.chrome()??null,[e]);return useSyncExternalStore(t,n,n)}function ro(){let e=useContext(dt),t=useRef(null);return useCallback(n=>{t.current?.(),t.current=null;let o=e?je(e):null;n&&o&&(t.current=o.registerChrome(n));},[e])}var Ou=500;function io(e){let t=useRef(e);t.current=e;let n=useRef({buffer:"",at:0}),o=useCallback(()=>{let{container:i,itemSelector:a,scope:f}=t.current,u=i.current;return u?Array.from(u.querySelectorAll(a)).filter(p=>!f||p.closest(f)===u):[]},[]),r=useCallback(i=>{let a=o();a.length!==0&&a[(i+a.length)%a.length].focus();},[o]),s=useCallback(i=>{let a=o();if(a.length===0)return false;let f=a.findIndex(x=>x===document.activeElement),u=(t.current.orientation??"vertical")==="vertical",p=u?"ArrowDown":"ArrowRight",g=u?"ArrowUp":"ArrowLeft",c=null;if(i.key===p)c=f+1;else if(i.key===g)c=f<0?a.length-1:f-1;else if(i.key==="Home")c=0;else if(i.key==="End")c=a.length-1;else if(i.key.length===1&&i.key!==" "&&!i.ctrlKey&&!i.metaKey&&!i.altKey){let x=Date.now(),S=n.current;S.buffer=x-S.at>Ou?i.key.toLowerCase():S.buffer+i.key.toLowerCase(),S.at=x;let L=t.current.labelOf??(R=>R.textContent??""),A=[...a.slice(f+1),...a.slice(0,f+1)],G=[...S.buffer].every(R=>R===S.buffer[0]),D=A.find(R=>L(R).trim().toLowerCase().startsWith(S.buffer))??(G?A.find(R=>L(R).trim().toLowerCase().startsWith(S.buffer[0])):void 0);return D?(i.preventDefault(),D.focus(),true):false}return c===null?false:(i.preventDefault(),r(c),true)},[r,o]);return {items:o,focusFirst:useCallback(()=>r(0),[r]),focusLast:useCallback(()=>r(-1),[r]),onKeyDown:s}}var zt=createContext(null);function Ra(e,t){for(let n of e){if(n.kind==="item"&&n.id===t)return n;if(n.kind==="group"||n.kind==="submenu"){let o=Ra(n.entries,t);if(o)return o}}return null}function ka(e,t){return e.map(n=>n.kind==="item"?{...n,onSelect:()=>{let o=Ra(t(),n.id);o&&!o.disabled&&o.onSelect();}}:n.kind==="group"||n.kind==="submenu"?{...n,entries:ka(n.entries,t)}:n)}function Fu(e){return JSON.stringify(e,(t,n)=>t==="icon"||typeof n=="function"?void 0:n)}function ft(e,t){let n=useContext(zt),o=useRef(t);o.current=t;let r=useRef(null),s=t!==null;useLayoutEffect(()=>{if(!n||!s)return;let i=()=>o.current?.()??[];return r.current=null,n.register({element:()=>e.current,entries:()=>ka(i(),i)})},[n,e,s]),useLayoutEffect(()=>{if(!n||!s)return;if(!n.overflowing()){r.current=null;return}let i=Fu(o.current?.()??[]);r.current!==i&&n.changed(),r.current=i;});}function ao(){return useContext(zt)}var q={text:"#3c4043",muted:"#5f6368",disabled:"#9aa0a6",hover:"#e2e7ef",active:"#d3e3fd",border:"#c7cacf",surface:"#ffffff",rail:"#edf2fa"},Nu={appearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:2,minWidth:28,height:28,padding:"0 5px",border:0,borderRadius:4,color:q.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",lineHeight:1,whiteSpace:"nowrap",boxSizing:"border-box"};function Kt(e,t,n,o){return {...Nu,background:t?q.active:n&&!e?q.hover:"transparent",color:e?q.disabled:q.text,cursor:e?"default":"pointer",opacity:e?.48:1,...o}}function ln(e,t,n){let o=t?`${e} (${t})`:e;return n?`${o}: ${n}`:o}function Ze(e,t){let n=useId(),o=e&&t?t:void 0;return {reason:o,props:o?{disabled:false,"aria-disabled":true,"aria-describedby":n}:{disabled:e},node:o?jsx("span",{id:n,hidden:true,children:o}):null}}var lo=forwardRef(function({active:t,disabled:n=false,description:o,title:r,shortcut:s,onClick:i,children:a,className:f,style:u,testId:p,ariaExpanded:g},c){let[x,S]=useState(false),L=Ze(n,o);return jsxs(Fragment,{children:[jsx("button",{ref:c,type:"button",className:f,"data-testid":p,...L.props,"aria-label":r,"aria-pressed":t===void 0?void 0:t,"aria-expanded":g,title:ln(r,s,L.reason),onMouseDown:A=>A.preventDefault(),onMouseEnter:()=>S(true),onMouseLeave:()=>S(false),onClick:n?void 0:i,style:Kt(n,t===true,x,u),children:a}),L.node]})});function Pr(e){let t=useRef(null),n=useId(),{active:o,disabled:r=false,description:s,title:i,shortcut:a,onClick:f,overflowLabel:u}=e;return ft(t,()=>[{kind:"item",id:n,label:u??i,shortcut:a,checked:o,disabled:r,description:r?s:void 0,onSelect:()=>f?.()}]),jsx(lo,{ref:t,...e})}function Je({label:e,children:t,style:n}){return jsx("div",{role:"group","aria-label":e,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",...n},children:t})}function vt(){return jsx("div",{role:"separator","aria-orientation":"vertical",style:{width:1,height:24,margin:"0 5px",background:q.border,flex:"0 0 auto"}})}var La='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]',Oa='button, input, select, textarea, a[href], [tabindex]:not([tabindex="-1"])',Ht=8;function Bu(e,t,n){let o=window.innerWidth,r=window.innerHeight,s=Math.max(Ht,Math.min(e.left,o-Math.min(n,o-2*Ht)-Ht)),i=t.scrollHeight,a=r-Ht-(e.bottom+4),f=e.top-4-Ht;if(i<=a||a>=f)return {top:e.bottom+4,left:s,maxHeight:Math.max(a,80)};let u=Math.max(f,80);return {top:Math.max(Ht,e.top-4-Math.min(i,u)),left:s,maxHeight:u}}var Nt=forwardRef(function({title:t,trigger:n,children:o,disabled:r=false,description:s,active:i=false,menuWidth:a=220,style:f,testId:u,popup:p},g){let[c,x]=useState(null),[S,L]=useState(false),[A,G]=useState("menu"),[D,R]=useState(null),_=useRef(null),M=useRef(null),v=ro(),w=useCallback(y=>{M.current=y,v(y);},[v]),O=useId(),m=p??A,E=Ze(r,s),B=io({container:M,itemSelector:La,scope:'[role="menu"]',labelOf:y=>y.getAttribute("aria-label")??y.textContent??""}),C=()=>c?.anchor??_.current,F=useCallback(()=>x(null),[]),H=()=>{let y=C();x(null),y?.focus({preventScroll:true});};useImperativeHandle(g,()=>({openAt:y=>{r||x({focus:"first",anchor:y});}}),[r]),useLayoutEffect(()=>{let y=M.current;if(!c||!y){R(null);return}if(!p){let W=Array.from(y.querySelectorAll(Oa)).every(j=>j.matches(La));G(W?"menu":"dialog");}let K=(c.anchor??_.current)?.getBoundingClientRect();K&&R(Bu(K,y,a));},[c,p,a]),useLayoutEffect(()=>{let y=M.current;!c||!y||!D||y.contains(document.activeElement)||(m==="menu"?c.focus==="first"?B.focusFirst():c.focus==="last"?B.focusLast():y.focus({preventScroll:true}):(y.querySelector(Oa)??y).focus({preventScroll:true}));},[c,D,m,B]),useEffect(()=>{if(!c)return;let y=W=>{let j=W.target;!_.current?.contains(j)&&!M.current?.contains(j)&&F();},K=W=>{M.current?.contains(W.target)||F();},z=()=>F();return document.addEventListener("mousedown",y),window.addEventListener("scroll",K,true),window.addEventListener("resize",z),()=>{document.removeEventListener("mousedown",y),window.removeEventListener("scroll",K,true),window.removeEventListener("resize",z);}},[c,F]);let h=y=>{if(y.key==="Escape"){y.preventDefault(),y.stopPropagation(),H();return}if(y.key==="Tab"){m==="menu"&&setTimeout(F,0);return}m==="menu"&&B.onKeyDown(y)&&y.stopPropagation();};return jsxs("div",{style:{position:"relative",display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:_,type:"button","data-testid":u,...E.props,"aria-label":t,"aria-haspopup":m,"aria-expanded":c!==null,"aria-controls":c?O:void 0,title:ln(t,null,E.reason),onMouseDown:y=>y.preventDefault(),onMouseEnter:()=>L(true),onMouseLeave:()=>L(false),onClick:()=>{r||x(y=>y?null:{focus:"popup",anchor:null});},onKeyDown:y=>{r||(y.key==="ArrowDown"||y.key==="Enter"||y.key===" "?(y.preventDefault(),x({focus:"first",anchor:null})):y.key==="ArrowUp"&&(y.preventDefault(),x({focus:"last",anchor:null})));},style:Kt(r,i||c!==null,S,f),children:n}),E.node,c&&createPortal(jsx("div",{ref:w,id:O,role:m,"aria-label":t,"aria-orientation":m==="menu"?"vertical":void 0,tabIndex:-1,onKeyDown:h,onBlur:y=>{if(m!=="dialog")return;let K=y.relatedTarget;K&&!M.current?.contains(K)&&!_.current?.contains(K)&&F();},onMouseDown:y=>{m==="menu"&&y.preventDefault();},style:{position:"fixed",top:D?.top??0,left:D?.left??0,visibility:D?"visible":"hidden",zIndex:1e4,width:Math.min(a,window.innerWidth-2*Ht),maxHeight:D?Math.min(440,D.maxHeight):440,overflowY:"auto",padding:6,border:`1px solid ${q.border}`,borderRadius:8,background:q.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box",outline:"none"},children:o(()=>{let y=C();x(null),m==="menu"&&y?.focus({preventScroll:true});})}),document.body)]})});function ju(e){let t=useRef(null),n=useRef(null),o=ao(),r=useId(),{title:s,disabled:i=false,description:a}=e;return ft(n,()=>[{kind:"item",id:r,label:s,disabled:i,description:i?a:void 0,onSelect:()=>t.current?.openAt(o?.anchor()??null)}]),jsx("span",{ref:n,style:{display:"inline-flex",flex:"0 0 auto"},children:jsx(Nt,{ref:t,...e})})}function dn({label:e,icon:t,selected:n=false,radio:o=false,disabled:r=false,description:s,onClick:i,close:a}){let[f,u]=useState(false),p=useId(),g=r?s:void 0;return jsxs(Fragment,{children:[jsxs("button",{type:"button",role:o?"menuitemradio":"menuitem",tabIndex:-1,"aria-disabled":r||void 0,"aria-checked":o?n:void 0,"aria-label":e,"aria-describedby":g?p:void 0,title:g,onMouseEnter:()=>u(true),onMouseLeave:()=>u(false),onClick:()=>{r||(i?.(),a?.());},style:{appearance:"none",display:"flex",alignItems:"center",gap:10,width:"100%",minHeight:32,padding:"5px 9px",border:0,borderRadius:4,background:f&&!r?q.hover:"transparent",color:r?q.disabled:q.text,cursor:r?"default":"pointer",opacity:r?.48:1,font:"400 13px ui-sans-serif, system-ui, sans-serif",textAlign:"left",boxSizing:"border-box"},children:[jsx("span",{style:{display:"inline-grid",placeItems:"center",width:20,flex:"0 0 auto"},children:t}),jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:e}),n&&jsx("span",{"aria-hidden":"true",children:"\u2713"})]}),g&&jsx("span",{id:p,hidden:true,children:g})]})}function _u(){return jsx("div",{role:"separator",style:{height:1,margin:"5px 2px",background:q.border}})}function yr({command:e,proposalId:t,label:n,style:o,testId:r}){let s=le(),i={proposalId:t},a=he(e,i),f=Ze(!a.enabled,a.enabled?void 0:a.disabledReason.message);return jsxs(Fragment,{children:[jsx("button",{type:"button","data-testid":r,...f.props,title:f.reason,style:{...o,opacity:a.enabled?1:.45},onClick:()=>{a.enabled&&s.execute(e,i);},children:n}),f.node]})}function Ka({handle:e,proposals:t,snapshot:n,resolveImage:o,onNavigate:r,onClose:s}){let{t:i}=Q(),a=le(),f=useId(),[u,p]=useState(null),g=useRef(u);g.current=u;let[c,x]=useState(null),[S,L]=useState(null),A=useRef(null),G=useRef(null);useEffect(()=>{if(u){if(!t.some(v=>v.id===u.id)){p(null);return}try{let v=e.previewProposal(u.id),w=v.proposal.changes[u.index],O=v.snapshot.slides.findIndex(B=>B.id===w?.slideId);if(O<0)throw new Error(i("proposals.targetMissing"));let m=e.layoutSlide(O),E=e.layoutProposalSlide(u.id,O);x({data:v,before:m,after:E}),L(null);}catch(v){x(null),L(v instanceof Error?v.message:String(v));}}},[e,t,n,u,i]),useEffect(()=>{let v=A.current;u&&v&&!v.open&&v.showModal(),!u&&v?.open&&v.close();},[u]);let D=v=>{let w=n.slides.findIndex(m=>m.id===v.slideId),O=v.before?.name||i("notes.panelLabel");return w<0?i("proposals.targetMissing"):i("proposals.target",{slide:w+1,name:O})},R=(v,w,O)=>{G.current=O;let m=v.changes[w];r(m.slideId,m.shapeId,v.id),x(null),L(null),p({id:v.id,index:w});},_=(v,w)=>{let O=()=>g.current?.id===v.id&&g.current.index===v.index;try{let m=e.previewProposal(v.id);if(JSON.stringify(m.proposal.changes)===JSON.stringify(w.proposal.changes))return !0;if(!O())return !1;let E=m.proposal.changes[v.index],B=m.snapshot.slides.findIndex(C=>C.id===E.slideId);x({data:m,before:e.layoutSlide(B),after:e.layoutProposalSlide(v.id,B)}),L(i("proposals.changedAgain"));}catch(m){if(!O())return false;x(null),L(m instanceof Error?m.message:String(m));}return false},M=v=>{if(!u||!c)return;let w=u,O=c.data;if(!_(w,O))return;je(a)?.defer("proposalAccept",{proposalId:w.id,force:v})?.complete(E=>_(w,O)?E():{ok:false,failure:Be("target-changed",{translate:i})});};return jsxs("aside",{"data-testid":"pptx-proposals-panel","aria-label":i("proposals.title"),style:ie.panel,children:[jsxs("header",{style:ie.header,children:[jsxs("strong",{children:[i("proposals.title")," ",jsx("span",{style:ie.count,children:t.length})]}),jsx("button",{type:"button",onClick:()=>{a.execute("proposalsPanel",{open:false}).then(()=>s());},"aria-label":i("proposals.close"),style:ie.button,children:"\xD7"})]}),t.length===0&&jsx("p",{style:ie.muted,children:i("proposals.empty")}),t.map(v=>jsxs("section",{"data-testid":"pptx-proposal","data-proposal-id":v.id,style:ie.card,children:[jsx("strong",{style:ie.author,children:v.agentId}),v.note&&jsx("p",{style:ie.note,children:v.note}),v.changes.map((w,O)=>jsxs("div",{style:ie.change,children:[jsx("button",{type:"button",onClick:()=>r(w.slideId,w.shapeId,v.id),style:ie.link,children:D(w)}),w.oldText!==w.newText?jsxs("div",{style:ie.textDiff,children:[jsx("del",{style:ie.deleted,children:w.oldText||i("proposals.blank")}),jsx("ins",{style:ie.inserted,children:w.newText||i("proposals.blank")})]}):null,w.before&&w.after&&jsx($u,{change:w}),jsx("button",{type:"button","data-testid":"pptx-proposal-preview",style:ie.button,onClick:m=>R(v,O,m.currentTarget),children:i("proposals.preview")})]},`${w.slideId}:${w.shapeId??"notes"}`)),v.staleTargets.length>0&&jsx("p",{role:"alert","data-testid":"pptx-proposal-stale",style:ie.warning,children:i("proposals.stale")}),jsxs("div",{style:ie.actions,children:[jsx(yr,{command:"proposalAccept",proposalId:v.id,label:i("proposals.accept"),style:ie.primary,testId:"pptx-proposal-accept"}),jsx(yr,{command:"proposalReject",proposalId:v.id,label:i("proposals.reject"),style:ie.button,testId:"pptx-proposal-reject"})]})]},v.id)),jsxs("dialog",{ref:A,"data-testid":"pptx-proposal-preview-dialog","aria-labelledby":f,style:ie.dialog,onCancel:()=>p(null),onClose:()=>{p(null),G.current?.focus();},children:[jsxs("header",{style:ie.header,children:[jsx("strong",{id:f,children:i("proposals.previewTitle")}),jsx("button",{type:"button",style:ie.button,onClick:()=>p(null),children:i("proposals.close")})]}),S&&jsx("p",{role:"alert",style:ie.warning,children:S}),c&&u&&jsxs(Fragment,{children:[jsxs("p",{children:[jsx("strong",{children:c.data.proposal.agentId}),c.data.proposal.note&&jsxs(Fragment,{children:[" \xB7 ",c.data.proposal.note]})]}),jsxs("label",{children:[i("proposals.targetLabel")," ",jsx("select",{"aria-label":i("proposals.targetLabel"),value:u.index,onChange:v=>{let w=Number(v.target.value),O=c.data.proposal.changes[w];r(O.slideId,O.shapeId,u.id),p({id:u.id,index:w});},children:c.data.proposal.changes.map((v,w)=>jsx("option",{value:w,children:D(v)},w))})]}),c.data.proposal.changes[u.index].oldText!==c.data.proposal.changes[u.index].newText&&jsxs("div",{style:ie.textDiff,children:[jsx("del",{style:ie.deleted,children:c.data.proposal.changes[u.index].oldText||i("proposals.blank")}),jsx("ins",{style:ie.inserted,children:c.data.proposal.changes[u.index].newText||i("proposals.blank")})]}),jsxs("div",{style:ie.previews,children:[jsx(Ha,{label:i("proposals.before"),frame:c.before,resolveImage:o}),jsx(Ha,{label:i("proposals.after"),frame:c.after,resolveImage:o})]}),c.data.proposal.staleTargets.length>0&&jsx("p",{role:"alert",style:ie.warning,children:i("proposals.stalePreview")}),jsxs("div",{style:ie.actions,children:[c.data.proposal.staleTargets.length>0?jsx("button",{type:"button","data-testid":"pptx-proposal-force",style:ie.primary,onClick:()=>M(true),children:i("proposals.force")}):jsx("button",{type:"button",style:ie.primary,onClick:()=>M(false),children:i("proposals.accept")}),jsx(yr,{command:"proposalReject",proposalId:u.id,label:i("proposals.reject"),style:ie.button})]})]})]})]})}function $u({change:e}){let{t}=Q(),n=e.before,o=e.after,r=n.x!==o.x||n.y!==o.y||n.width!==o.width||n.height!==o.height,s=i=>[i.x,i.y,i.width,i.height].map(a=>(a/12700).toFixed(1)).join(", ");return jsxs(Fragment,{children:[r&&jsxs("p",{style:ie.detail,children:[t("proposals.geometry"),jsx("br",{}),s(n)," \u2192 ",s(o)," pt"]}),JSON.stringify({...n,x:0,y:0,width:0,height:0})!==JSON.stringify({...o,x:0,y:0,width:0,height:0})&&e.oldText===e.newText&&jsx("p",{style:ie.detail,children:t("proposals.appearance")})]})}function Ha({label:e,frame:t,resolveImage:n}){let o=useRef(null),[r,s]=useState(null);return useEffect(()=>{let i=false,a=o.current;if(!a)return;let f=document.createElement("canvas"),u=f.getContext("2d"),p=a.getContext("2d");if(!u||!p)return;let g=Math.min(1,560/t.width),c=window.devicePixelRatio||1;return sizeCanvasForSlide(f,t,c,g),s(null),paintSlide(u,t,c,g,{resolveImage:n}).then(()=>{i||(sizeCanvasForSlide(a,t,c,g),p.setTransform(1,0,0,1,0,0),p.drawImage(f,0,0));}).catch(x=>{i||s(x instanceof Error?x.message:String(x));}),()=>{i=true;}},[t,n]),jsxs("figure",{style:ie.figure,children:[jsx("figcaption",{style:ie.caption,children:e}),jsx("canvas",{ref:o,role:"img","aria-label":e,style:{maxWidth:"100%",height:"auto",display:"block",background:"#fff"}}),r&&jsx("p",{role:"alert",children:r})]})}var ie={panel:{width:340,maxWidth:"45%",flex:"0 0 auto",overflowY:"auto",background:"#fff",borderLeft:"1px solid #dbe3ee",padding:16,fontSize:13},header:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},count:{color:"#64748b",marginLeft:6},card:{border:"1px solid #dbe3ee",borderLeft:"3px solid #6366f1",borderRadius:8,padding:12,marginTop:16},author:{color:"#4338ca"},note:{margin:"6px 0 12px",lineHeight:1.5},change:{borderTop:"1px solid #eef2f7",padding:"10px 0"},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"},actions:{display:"flex",flexWrap:"wrap",gap:8,marginTop:12},button:{border:"1px solid #cbd5e1",borderRadius:5,background:"#fff",color:"#334155",padding:"6px 10px",cursor:"pointer",font:"inherit"},primary:{border:"1px solid #4338ca",borderRadius:5,background:"#4338ca",color:"#fff",padding:"6px 10px",cursor:"pointer",font:"inherit"},link:{background:"none",border:0,padding:0,color:"#4338ca",textAlign:"left",cursor:"pointer",font:"inherit",fontWeight:600},warning:{padding:10,borderRadius:5,background:"#fffbeb",color:"#92400e",lineHeight:1.5},detail:{color:"#64748b",lineHeight:1.5},muted:{color:"#64748b",marginTop:24},dialog:{width:"min(1200px, 92vw)",maxHeight:"90vh",overflow:"auto",padding:24,border:"1px solid #cbd5e1",borderRadius:12,color:"#172033",background:"#f8fafc"},previews:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(360px, 100%), 1fr))",gap:16,margin:"20px 0"},figure:{margin:0,minWidth:0},caption:{fontWeight:600,marginBottom:8}};var Ba=["nw","n","ne","e","se","s","sw","w"];var Uu=Math.fround(Math.fround(Math.PI)/180);function un(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 Re(e,t){for(let n of e){if(n.id===t)return n;let o=Re(n.children,t);if(o)return o}return null}function ja(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 Sr(e,t){for(let n of e.shapes)if(n.id===t||Re(n.children,t))return n;return null}function _a(e,t){return !!(e&&e.id===t.slideId&&Re(e.shapes,t.shapeId))}function fo(e,t){return e?.pointerId===t}function Bt(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 Cr(e){return Bt(e)!==null}function go(e){let n=((e.inherited?.rotationDeg??e.rotationDeg)%360+360)%360,o=e.inherited?.flipH??e.flipH,r=e.inherited?.flipV??e.flipV;return Cr(e)&&n===0&&!o&&!r}function jt(e,t,n){let o=wr(t,n);if(o)return o;let r=Bt(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 wr(e,t){let n=new Set;Ua(t,n);let o=e.primitives.filter(u=>u.shapeId&&n.has(u.shapeId));if(o.length===0)return null;let r=o.map(u=>{let p=(u.transform?.rotationDeg??0)*Math.PI/180,g=Math.abs(u.w*Math.cos(p))+Math.abs(u.h*Math.sin(p)),c=Math.abs(u.w*Math.sin(p))+Math.abs(u.h*Math.cos(p));return {x:u.x+(u.w-g)/2,y:u.y+(u.h-c)/2,width:g,height:c}}),s=Math.min(...r.map(u=>u.x)),i=Math.min(...r.map(u=>u.y)),a=Math.max(...r.map(u=>u.x+u.width)),f=Math.max(...r.map(u=>u.y+u.height));return {x:s,y:i,width:a-s,height:f-i}}function Ir(e,t,n,o){let r=e.primitives.find(p=>p.kind==="textBox"&&p.shapeId===t&&p.storyId===n);if(!r||r.lines.length===0)return null;let s=Wa(r,o),i=0;for(let p=1;p<r.lines.length;p+=1){let g=r.lines[p],c=r.lines[i];mo(g.y,g.height,s.y)<mo(c.y,c.height,s.y)&&(i=p);}let a=r.lines[i],f=a.caretStops[0];return f?{position:a.caretStops.reduce((p,g)=>Math.abs(g.x-s.x)<Math.abs(p.x-s.x)?g:p,f).position,lineIndex:i}:{position:a.start,lineIndex:i}}function Zu(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=Ga(r,n);if(s)return r.kind==="textBox"&&r.storyId&&Xu(r,s.y)?"text":"shape"}return null}function Wa(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)),i=o(o(n.rotationDeg??0)*Uu),a=o(Math.cos(i)),f=o(Math.sin(i)),u=o(t.x-r),p=o(t.y-s),g=o(o(u*a)+o(p*f)),c=o(o(p*a)-o(u*f));return n.flipH&&(g=-g),n.flipV&&(c=-c),{x:o(r+g),y:o(s+c)}}function Na(e,t){return Math.fround(Math.fround(e)+Math.fround(t))}function Ga(e,t){let n=Wa(e,t);return n.x>=Math.fround(e.x)&&n.x<=Na(e.x,e.w)&&n.y>=Math.fround(e.y)&&n.y<=Na(e.y,e.h)?n:null}function Xu(e,t){return e.lines.length===0?false:e.lines.reduce((o,r)=>mo(r.y,r.height,t)<mo(o.y,o.height,t)?r:o).caretStops.length>0}function $a(e,t,n,o){let r=Bt(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 Er(e,t,n,o,r=4){return Math.hypot(n-e,o-t)>=r}function Ua(e,t){t.add(e.id);for(let n of e.children)Ua(n,t);}function mo(e,t,n){return n<e?e-n:n>e+t?n-e-t:0}function Za(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 Xa(e){return e==="nw"||e==="se"?"nwse-resize":e==="ne"||e==="sw"?"nesw-resize":e==="n"||e==="s"?"ns-resize":"ew-resize"}function qu(e,t,n,o){let{x:r,y:s,width:i,height:a}=e;if(t.includes("w")){let f=Math.min(n.x,i-o);r+=f,i-=f;}else t.includes("e")&&(i=Math.max(o,i+n.x));if(t.startsWith("n")){let f=Math.min(n.y,a-o);s+=f,a-=f;}else t.startsWith("s")&&(a=Math.max(o,a+n.y));return {x:r,y:s,width:i,height:a}}function qa(e,t,n){return n?{x:n.x-e.x,y:n.y-e.y}:t}function Tr(e,t,n,o,r){if(!go(n))return null;let s={x:Math.round(r.x*e.widthEmu/t.width),y:Math.round(r.y*e.heightEmu/t.height)},i=Bt(n);if(!i)return null;let a=qu(i,o,s,76200);return {x:a.x,y:a.y,width:a.width,height:a.height}}function Va(e,t,n,o,r){let s=Tr(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 Rr(e,t,n=1){let o=Zu(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 i=e.primitives[s];if(!i.shapeId)continue;let a=Ga(i,r);if(a)return Vu(i,a,n)?"shape":"text"}return o}function Vu(e,t,n){let o=Number.isFinite(n)&&n>0?n:1,r=Math.min(6/o,e.w/3,e.h/3);return t.x-e.x<=r||e.x+e.w-t.x<=r||t.y-e.y<=r||e.y+e.h-t.y<=r}function at(e){let[t,n]=useState(e),o=useRef(t),r=useCallback(s=>{let i=typeof s=="function"?s(o.current):s;o.current=i,n(i);},[]);return [t,r,o]}function ts(e,t,n,o){let[r,s,i]=at(true),[a,f,u]=at(null),p=n?.slides[o]?.id,g=useMemo(()=>t.filter(S=>S.changes.some(L=>L.slideId===p)),[t,p]),c=g.find(S=>S.id===a)??g[0]??null,x=useMemo(()=>{if(!r||!e||!c)return {diff:null,error:null};try{return {diff:e.layoutProposalDiffSlide(c.id,o),error:null}}catch(S){return {diff:null,error:S instanceof Error?S.message:String(S)}}},[r,e,c,o,n]);return useEffect(()=>{s(true),f(null);},[e,s,f]),{...x,available:g,selected:c,enabled:r,setEnabled:s,select:f,reviewing:r&&c!==null,enabledRef:i,selectedIdRef:u}}function ns({review:e,ready:t}){let{t:n}=Q(),o=le(),r=e.selected?.id??"",s=he("proposalAccept",{proposalId:r}),i=he("proposalReject",{proposalId:r}),a=e.enabled&&!t,f=s.enabled?e.error?n("commands.reasons.previewFailed"):a?n("commands.reasons.previewPending"):void 0:s.disabledReason.message,u=s.enabled&&!e.error&&!a,p=Ze(!u,f),g=Ze(!i.enabled,i.enabled?void 0:i.disabledReason.message);if(!e.selected)return null;let c=e.selected.staleTargets.length>0;return jsxs("div",{style:xe.toolbar,"data-testid":"pptx-canvas-review-toolbar",children:[jsxs("div",{style:xe.row,children:[jsxs("label",{style:xe.label,children:[n("proposals.canvasTitle"),jsx("select",{"aria-label":n("proposals.canvasTitle"),value:e.selected.id,onChange:x=>{o.execute("proposalSelect",{proposalId:x.target.value});},style:xe.select,children:e.available.map((x,S)=>jsxs("option",{value:x.id,children:[S+1,". ",x.agentId,x.note?` \xB7 ${x.note}`:""]},x.id))})]}),jsx("button",{type:"button",style:xe.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:xe.button,onClick:()=>{o.execute("proposalsPanel",{open:true});},children:n("proposals.details")}),jsx("button",{type:"button",style:{...xe.primary,opacity:u?1:.45,cursor:u?"pointer":"default"},...p.props,title:p.reason,"data-testid":"pptx-canvas-proposal-accept",onClick:()=>{u&&o.execute("proposalAccept",{proposalId:r});},children:n("proposals.accept")}),p.node,jsx("button",{type:"button",style:xe.button,...g.props,title:g.reason,"data-testid":"pptx-canvas-proposal-reject",onClick:()=>{i.enabled&&o.execute("proposalReject",{proposalId:r});},children:n("proposals.reject")}),g.node]}),e.enabled&&jsxs("div",{style:xe.legend,children:[jsx("span",{style:xe.removed,children:n("proposals.removed")}),jsx("span",{style:xe.added,children:n("proposals.added")}),jsx("span",{children:n("proposals.reviewHint")})]}),c&&jsx("p",{role:"status",style:xe.warning,children:n("proposals.canvasStale")}),e.error&&jsx("p",{role:"alert",style:xe.warning,children:e.error})]})}function os({diff:e,current:t,frame:n,slideIndex:o,scale:r,resolveImage:s,onTarget:i,onPainted:a}){let{t:f}=Q(),u=useRef(null),[p,g]=useState(null),[c,x]=useState(null),S=t.slides[o]?.id,L=e.proposal.changes.filter(A=>A.slideId===S&&A.shapeId&&A.before&&A.after);return useEffect(()=>{let A=false,G=u.current;if(!G)return;let D=document.createElement("canvas"),R=D.getContext("2d"),_=G.getContext("2d");if(!R||!_)return;let M=window.devicePixelRatio||1;return sizeCanvasForSlide(D,e.frame,M,r),G.dataset.ready="false",g(null),paintSlide(R,e.frame,M,r,{resolveImage:s,textChanges:e.textChanges}).then(()=>{A||(sizeCanvasForSlide(G,e.frame,M,r),_.setTransform(1,0,0,1,0,0),_.drawImage(D,0,0),G.dataset.ready="true",x(e),a(e));}).catch(v=>{A||g(v instanceof Error?v.message:String(v));}),()=>{A=true;}},[e,r,s,a]),jsxs("div",{style:xe.overlay,"data-testid":"pptx-canvas-proposal-diff",children:[jsx("canvas",{ref:u,role:"img","aria-label":f("proposals.canvasTitle"),style:{...xe.canvas,visibility:c===e?"visible":"hidden"}}),c!==e&&!p&&jsx("p",{role:"status",style:xe.paintError,children:f("proposals.loadingDiff")}),L.map(A=>{let G=jt(t,n,A.before),D=jt(e.snapshot,e.frame,A.after);if(!D)return null;let R=G&&(G.x!==D.x||G.y!==D.y||G.width!==D.width||G.height!==D.height),_=M=>({left:M.x*r,top:M.y*r,width:Math.max(1,M.width*r),height:Math.max(1,M.height*r)});return jsxs("div",{children:[R&&jsx("span",{"data-testid":"pptx-proposal-old-bounds",style:{...xe.outline,..._(G),borderColor:"#b91c1c",borderStyle:"dashed",pointerEvents:"none"},"aria-hidden":"true",children:jsx("span",{style:{...xe.tag,color:"#b91c1c",background:"#fee2e2"},children:f("proposals.previousPosition")})}),jsx("button",{type:"button","data-testid":"pptx-proposal-canvas-target","aria-label":`${e.proposal.agentId}: ${A.after.name}`,onClick:()=>i(A.slideId,A.shapeId),style:{...xe.outline,..._(D),borderColor:"#16a34a",cursor:"pointer"},children:R&&jsx("span",{style:{...xe.tag,left:"auto",right:-1,color:"#166534",background:"#dcfce7"},children:f("proposals.proposedPosition")})})]},A.shapeId)}),jsx("div",{style:xe.srOnly,children:L.map(A=>jsxs("p",{children:[A.after.name,": ",jsx("del",{children:A.oldText})," ",jsx("ins",{children:A.newText})]},A.shapeId))}),p&&jsx("p",{role:"alert",style:xe.paintError,children:p})]})}function rs({diff:e,slideId:t}){let{t:n}=Q(),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:xe.notes,"data-testid":"pptx-proposal-notes-diff",children:[jsx("strong",{children:n("notes.panelLabel")}),jsx("del",{style:xe.removed,children:o.oldText||n("proposals.blank")}),jsx("ins",{style:xe.added,children:o.newText||n("proposals.blank")})]}):null}var xe={toolbar:{flex:"0 0 auto",padding:"10px 14px",background:"#fff",borderBottom:"1px solid #dbe3ee",fontSize:12},row:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},label:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8,minWidth:0,fontWeight:600},select:{maxWidth:260,minWidth:80,padding:5,border:"1px solid #cbd5e1",borderRadius:4,font:"inherit"},legend:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,marginTop:8,color:"#64748b"},removed:{color:"#b91c1c",background:"#fee2e2",textDecoration:"line-through",padding:"2px 5px"},added:{color:"#166534",background:"#dcfce7",textDecoration:"underline",padding:"2px 5px"},button:{padding:"5px 9px",border:"1px solid #cbd5e1",borderRadius:5,background:"#fff",color:"#334155",cursor:"pointer",font:"inherit"},primary:{padding:"5px 9px",border:"1px solid #4338ca",borderRadius:5,background:"#4338ca",color:"#fff",cursor:"pointer",font:"inherit"},warning:{margin:"8px 0 0",color:"#92400e"},overlay:{position:"absolute",inset:0,overflow:"hidden",background:"#fff"},canvas:{position:"absolute",inset:0,display:"block",pointerEvents:"none"},outline:{position:"absolute",border:"1px solid",background:"transparent",padding:0},tag:{position:"absolute",left:-1,top:-18,fontSize:11,lineHeight:"16px",padding:"0 4px",whiteSpace:"nowrap"},srOnly:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},notes:{display:"grid",gap:6,padding:"10px 14px",maxHeight:160,overflow:"auto",background:"#fff",fontSize:12,whiteSpace:"pre-wrap"},paintError:{position:"absolute",top:8,left:8,right:8,padding:8,background:"#fff1f2",color:"#b91c1c"}};var _t=createContext(null);function oc(){let e=useContext(_t);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}var Mn=createContext(null),ho=createContext(false);var uc={bold:"onFormat",italic:"onFormat",underline:"onFormat",fontFamily:"onFormat",fontSize:"onFormat",fontSizeStep:"onFormat",textColor:"onFormat",alignment:"onFormat",shapeFill:"onShapeFormat",shapeStrokeColor:"onShapeFormat",shapeStrokeWidth:"onShapeFormat",shapeAdjustment:"onShapeFormat",zOrder:"onShapeFormat",insertSlide:"onInsertSlide",insertImage:"onInsertImage",tool:"onToolChange",save:"onSave",exportPng:"onExportPng",undo:"onUndo",redo:"onRedo",zoom:"onZoomChange"},Mr={ok:true,status:"requested"};function cc(e,t){let n=e.currentFormatting??{},o=e.currentShapeFormatting??{};return {status:"ready",readOnly:false,reviewing:false,pendingInput:false,canUndo:e.canUndo??false,canRedo:e.canRedo??false,slide:{id:"",layoutPartPath:e.currentLayoutPartPath??null},layouts:(e.slideLayouts??[]).map((r,s)=>({args:{layoutPartPath:r.partPath},label:r.label??t("toolbar.layoutOption",{number:s+1})})),text:e.textSelectionActive?{kind:"range",bold:n.bold??false,italic:n.italic??false,underline:n.underline??false,fontFamily:n.fontFamily??null,fontSize:n.fontSize??null,color:n.textColor??null,alignment:n.align??null}:null,shape:e.shapeSelectionActive||e.shapeArrangeActive?{formattable:!!e.shapeSelectionActive,geometry:o.geometry??null,fill:o.fillColor??null,stroke:o.strokeColor??null,strokeWidth:o.strokeWidthPt??null,adjustments:o.adjustments??{},order:null}:null,tool:e.activeTool??"select",zoom:e.zoom??"fit",fontFamilies:e.fontFamilies??Qn,fontSizes:e.fontSizes??eo,proposals:null,hostDisabled:r=>{let s=uc[r];return !!e.disabled||!s||!e[s]},translate:t}}function pc(e,t,n){let o=t;switch(e){case "bold":case "italic":case "underline":return e;case "fontFamily":return {type:"fontFamily",value:o.family};case "fontSize":return {type:"fontSize",value:o.points};case "fontSizeStep":{let r=n.text&&n.text!=="unsupported"?n.text.fontSize:null;return {type:"fontSize",value:no(r??to,n.fontSizes,o.direction==="increase"?1:-1)}}case "textColor":return {type:"textColor",value:o.color};case "alignment":return {type:"align",value:o.value};default:return null}}function mc(e,t){let n=t;switch(e){case "shapeFill":return {type:"fillColor",value:n.color};case "shapeStrokeColor":return {type:"strokeColor",value:n.color};case "shapeStrokeWidth":return {type:"strokeWidth",value:n.points};case "shapeAdjustment":return {type:"adjust",name:n.name,value:n.value};case "zOrder":return {type:"zOrder",value:n.value};default:return null}}function fc(e,t,n,o){let r=pc(t,n,o);if(r)return e.onFormat?.(r),Mr;let s=mc(t,n);if(s)return e.onShapeFormat?.(s),Mr;let i=n;switch(t){case "insertSlide":e.onInsertSlide?.(i.layoutPartPath);break;case "insertImage":e.onInsertImage?.();break;case "tool":e.onToolChange?.(i.value);break;case "save":e.onSave?.();break;case "exportPng":e.onExportPng?.();break;case "undo":e.onUndo?.();break;case "redo":e.onRedo?.();break;case "zoom":e.onZoomChange?.(i.scale);break}return Mr}function as(e){let{t}=Q(),n=useRef({props:e,t});n.current={props:e,t};let[o]=useState(()=>{let r=En(),s={environment:()=>cc(n.current.props,n.current.t),ordered:()=>false,admit:i=>Promise.resolve().then(i),perform:(i,a,f)=>fc(n.current.props,i,a,f),capture:()=>({generation:0}),resume:()=>null,chrome:()=>({i18n:void 0}),focusEditor:()=>{}};return r.attach(s),r});return useLayoutEffect(()=>{o.refresh();}),o.store}function Ar(e){return e==="mixed"?void 0:e}function is(e){let t={};for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}function gc(e){let t=u=>e.getState(u),n=(u,p)=>{e.execute(u,p);},o=t("fontFamily"),r=t("fontSize"),s=t("textColor"),i=t("alignment"),a=t("shapeAdjustment").value,f=t("insertSlide");return {currentFormatting:is({bold:Ar(t("bold").active),italic:Ar(t("italic").active),underline:Ar(t("underline").active),fontFamily:o.value??void 0,fontSize:r.value??void 0,textColor:s.value??void 0,align:i.value??void 0}),textSelectionActive:t("bold").enabled,onFormat:u=>{typeof u=="string"?n(u,null):u.type==="fontFamily"?n("fontFamily",{family:u.value}):u.type==="fontSize"?n("fontSize",{points:u.value}):u.type==="textColor"?n("textColor",{color:u.value}):n("alignment",{value:u.value});},currentShapeFormatting:is({fillColor:t("shapeFill").value,strokeColor:t("shapeStrokeColor").value,strokeWidthPt:t("shapeStrokeWidth").value,adjustments:a?{[a.name]:a.value}:void 0}),shapeSelectionActive:t("shapeFill").enabled,shapeArrangeActive:t("zOrder").enabled,onShapeFormat:u=>{u.type==="fillColor"?n("shapeFill",{color:u.value}):u.type==="strokeColor"?n("shapeStrokeColor",{color:u.value}):u.type==="strokeWidth"?n("shapeStrokeWidth",{points:u.value}):u.type==="adjust"?n("shapeAdjustment",{name:u.name,value:u.value}):n("zOrder",{value:u.value});},onInsertSlide:u=>n("insertSlide",u===void 0?{}:{layoutPartPath:u}),onInsertImage:()=>n("insertImage",null),slideLayouts:(f.options??[]).map(u=>({partPath:u.args.layoutPartPath??null,label:u.label})),currentLayoutPartPath:f.value??null,onSave:()=>n("save",null),onExportPng:()=>n("exportPng",null),onUndo:()=>n("undo",null),onRedo:()=>n("redo",null),canUndo:t("undo").enabled,canRedo:t("redo").enabled,zoom:t("zoom").value??"fit",onZoomChange:u=>n("zoom",{scale:u}),activeTool:t("tool").value??"select",onToolChange:u=>n("tool",{value:u}),fontFamilies:(o.options??[]).map(u=>u.args.family),fontSizes:(r.options??[]).map(u=>u.args.points),disabled:!t("save").enabled}}function ss(e){let[t,n]=useReducer(o=>o+1,0);return useEffect(()=>e.subscribe(n),[e]),useMemo(()=>gc(e),[e,t])}function De({name:e,size:t=20,style:n}){return jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"inline-flex",flexShrink:0,...n},children:[e==="save"&&jsx("path",{d:"M12 3v11m0 0 4-4m-4 4-4-4M5 19h14"}),e==="image"&&jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),jsx("circle",{cx:"8.5",cy:"9.5",r:"1.25"}),jsx("path",{d:"m6 17 4.5-4.5 3.25 3.25L16 13.5l2 2"})]}),e==="insertImage"&&jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"14",height:"12",rx:"2"}),jsx("circle",{cx:"7.5",cy:"9",r:"1"}),jsx("path",{d:"m5 15 3.5-3.5 2.5 2.5L13 12l1.5 1.5"}),jsx("path",{d:"M18 4v6m-3-3h6"})]}),e==="undo"&&jsx("path",{d:"m9 7-5 5 5 5M5 12h9a6 6 0 0 1 6 6"}),e==="redo"&&jsx("path",{d:"m15 7 5 5-5 5m4-5h-9a6 6 0 0 0-6 6"}),e==="newSlide"&&jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"15",height:"14",rx:"1.5"}),jsx("path",{d:"M7 9h7M7 13h5M20 9v6m-3-3h6"})]}),e==="select"&&jsx("path",{d:"m6 3 12 9-6 1.5L9 19Z"}),e==="textBox"&&jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1.5"}),jsx("path",{d:"M8 8h8m-4 0v8m-3 0h6"})]}),e==="shape"&&jsx("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"}),e==="bringToFront"&&jsxs(Fragment,{children:[jsx("rect",{x:"2",y:"8",width:"9",height:"9",rx:"1.3",opacity:"0.4"}),jsx("rect",{x:"6",y:"4",width:"9",height:"9",rx:"1.3",fill:"currentColor",fillOpacity:"0.15"}),jsx("path",{d:"M17 17 20 14 23 17"}),jsx("path",{d:"M17 12 20 9 23 12"})]}),e==="sendToBack"&&jsxs(Fragment,{children:[jsx("rect",{x:"6",y:"4",width:"9",height:"9",rx:"1.3",opacity:"0.4"}),jsx("rect",{x:"2",y:"8",width:"9",height:"9",rx:"1.3",fill:"currentColor",fillOpacity:"0.15"}),jsx("path",{d:"M17 9 20 12 23 9"}),jsx("path",{d:"M17 14 20 17 23 14"})]}),e==="bringForward"&&jsxs(Fragment,{children:[jsx("rect",{x:"2",y:"8",width:"9",height:"9",rx:"1.3",opacity:"0.4"}),jsx("rect",{x:"6",y:"4",width:"9",height:"9",rx:"1.3",fill:"currentColor",fillOpacity:"0.15"}),jsx("path",{d:"M17 15 20 12 23 15"})]}),e==="sendBackward"&&jsxs(Fragment,{children:[jsx("rect",{x:"6",y:"4",width:"9",height:"9",rx:"1.3",opacity:"0.4"}),jsx("rect",{x:"2",y:"8",width:"9",height:"9",rx:"1.3",fill:"currentColor",fillOpacity:"0.15"}),jsx("path",{d:"M17 11 20 14 23 11"})]}),e==="fillColor"&&jsxs(Fragment,{children:[jsx("path",{d:"m7 4 10 10-5 5-7-7Z"}),jsx("path",{d:"m5 12 7-7m6 12h2"})]}),e==="borderColor"&&jsx(Fragment,{children:jsx("path",{d:"M5 18h14M8 15l8-8 2 2-8 8H8Z"})}),e==="borderWidth"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 7h14",strokeWidth:"1"}),jsx("path",{d:"M5 12h14",strokeWidth:"2"}),jsx("path",{d:"M5 18h14",strokeWidth:"3"})]}),e==="bold"&&jsx("path",{d:"M7 4h6a4 4 0 0 1 0 8H7zm0 8h7a4 4 0 0 1 0 8H7z"}),e==="italic"&&jsx("path",{d:"M10 4h8M6 20h8M14 4 10 20"}),e==="underline"&&jsxs(Fragment,{children:[jsx("path",{d:"M7 4v7a5 5 0 0 0 10 0V4"}),jsx("path",{d:"M5 20h14"})]}),e==="textColor"&&jsxs(Fragment,{children:[jsx("path",{d:"m7 16 5-12 5 12M9 11h6"}),jsx("path",{d:"M5 20h14",strokeWidth:"3"})]}),e==="alignLeft"&&jsx("path",{d:"M4 6h16M4 10h10M4 14h16M4 18h10"}),e==="alignCenter"&&jsx("path",{d:"M4 6h16M7 10h10M4 14h16M7 18h10"}),e==="alignRight"&&jsx("path",{d:"M4 6h16M10 10h10M4 14h16M10 18h10"}),e==="alignJustify"&&jsx("path",{d:"M4 6h16M4 10h16M4 14h16M4 18h16"}),e==="more"&&jsxs(Fragment,{children:[jsx("circle",{cx:"5",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"19",cy:"12",r:"1",fill:"currentColor",stroke:"none"})]}),e==="chevronDown"&&jsx("path",{d:"m7 10 5 5 5-5"}),e==="remove"&&jsx("path",{d:"M5 12h14"}),e==="add"&&jsx("path",{d:"M12 5v14M5 12h14"})]})}function ds({value:e,label:t,onChange:n,onClear:o,icon:r="textColor",none:s=false,clearLabel:i,disabled:a=false,description:f,testId:u}){let[p,g]=useState(false),c=Ze(a,f);return jsxs("span",{style:{display:"inline-flex",alignItems:"center",height:28},children:[jsxs("label",{title:ln(t,null,c.reason),"aria-label":t,style:{display:"inline-grid",placeItems:"center",width:28,height:28,borderRadius:4,background:p&&!a?q.hover:"transparent",color:a?q.disabled:q.text,cursor:a?"default":"pointer",opacity:a?.48:1,boxSizing:"border-box",position:"relative"},onMouseEnter:()=>g(true),onMouseLeave:()=>g(false),children:[jsx(De,{name:r,size:20}),jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:5,right:5,bottom:2,height:3,borderRadius:2,background:s?"transparent":e,border:s?`1px solid ${q.disabled}`:0,boxSizing:"border-box"}}),s?jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:5,bottom:3,width:18,height:1,background:"#d93025",transform:"rotate(-18deg)"}}):null,c.node,jsx("input",{"data-testid":u,type:"color",value:e,...c.props,"aria-label":t,onClick:x=>{a&&x.preventDefault();},onKeyDown:x=>{a&&(x.key==="Enter"||x.key===" ")&&x.preventDefault();},onChange:x=>{a||n?.(x.target.value);},style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}})]}),o?jsx("button",{type:"button",disabled:a,"aria-label":i??t,title:i??t,onMouseDown:x=>x.preventDefault(),onClick:o,style:{appearance:"none",width:15,height:28,padding:0,border:0,borderRadius:3,background:"transparent",color:a?q.disabled:q.muted,cursor:a?"default":"pointer",opacity:a?.48:1,font:"500 14px ui-sans-serif, system-ui, sans-serif"},children:"\xD7"}):null]})}function xo({value:e,options:t,label:n,onCommit:o,disabled:r=false,description:s,width:i=72,inputStyle:a,testId:f}){let u=Ze(r,s),[p,g]=useState(e),[c,x]=useState(false),[S,L]=useState({top:0,left:0,width:i}),A=useRef(null),G=useRef(null),D=useRef(null);useEffect(()=>g(e),[e]);let R=useCallback(()=>x(false),[]);useEffect(()=>{if(!c||!A.current)return;let M=A.current.getBoundingClientRect();L({top:M.bottom+4,left:M.left,width:Math.max(M.width,i)});},[c,i]),useEffect(()=>{if(!c)return;let M=w=>{let O=w.target;!A.current?.contains(O)&&!G.current?.contains(O)&&R();},v=w=>{w.key==="Escape"&&(g(e),R());};return document.addEventListener("mousedown",M),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",v);}},[c,R,e]);let _=useCallback(()=>{!r&&o&&p.trim()&&o(p.trim()),g(e);},[r,o,p,e]);return jsxs("div",{ref:A,style:{display:"inline-flex",alignItems:"center",width:i,height:28,border:`1px solid ${q.border}`,borderRadius:4,background:r?"rgba(255,255,255,0.5)":q.surface,opacity:r?.48:1,boxSizing:"border-box",flex:"0 0 auto"},children:[jsx("input",{ref:D,"data-testid":f,role:"combobox","aria-label":n,"aria-autocomplete":"list","aria-expanded":c,...u.props,readOnly:r,title:u.reason?ln(n,null,u.reason):void 0,value:p,onFocus:M=>{r||(x(true),M.currentTarget.select());},onChange:M=>g(M.target.value),onKeyDown:M=>{r||(M.key==="Enter"?(_(),R(),M.currentTarget.blur()):M.key==="ArrowDown"&&(x(true),M.preventDefault()));},onBlur:()=>{r||requestAnimationFrame(()=>{G.current?.contains(document.activeElement)||_();});},style:{appearance:"none",width:"calc(100% - 22px)",height:26,padding:"0 2px 0 7px",border:0,outline:0,background:"transparent",color:q.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",boxSizing:"border-box",...a}}),u.node,jsx("button",{type:"button",disabled:r,tabIndex:-1,"aria-label":n,title:n,onMouseDown:M=>M.preventDefault(),onClick:()=>{r||(x(M=>!M),D.current?.focus());},style:{appearance:"none",display:"grid",placeItems:"center",width:21,height:26,padding:0,border:0,background:"transparent",color:q.muted,cursor:r?"default":"pointer"},children:jsx(De,{name:"chevronDown",size:14})}),c&&!r&&jsx("div",{ref:G,role:"listbox","aria-label":n,style:{position:"fixed",top:S.top,left:S.left,zIndex:1e4,width:S.width,maxHeight:260,overflowY:"auto",padding:4,border:`1px solid ${q.border}`,borderRadius:6,background:q.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box"},children:t.map(M=>jsx("button",{type:"button",role:"option","aria-selected":M.value===e,onMouseDown:v=>v.preventDefault(),onClick:()=>{g(M.label),o?.(M.value),R();},style:{appearance:"none",display:"block",width:"100%",minHeight:28,padding:"4px 7px",border:0,borderRadius:3,background:M.value===e?q.active:"transparent",color:q.text,cursor:"pointer",font:"400 13px ui-sans-serif, system-ui, sans-serif",textAlign:"left"},children:M.label},M.value))})]})}var Fr="pointer",cs=false;function zr(){if(cs||typeof document>"u")return;cs=true;let e=()=>{Fr="pointer";};document.addEventListener("pointerdown",e,true),document.addEventListener("mousedown",e,true),document.addEventListener("keydown",()=>{Fr="keyboard";},true);}function bc(e,t){zr(),!(Fr!=="pointer"||t.ok&&t.status==="opened")&&requestAnimationFrame(()=>je(e)?.focusEditor());}function St(e,t,n){zr(),e.execute(t,n).then(o=>bc(e,o));}zr();var vc={bold:"bold",italic:"italic",underline:"underline",textColor:"textColor",insertSlide:"newSlide",insertImage:"insertImage",shapeFill:"fillColor",shapeStrokeColor:"borderColor",shapeStrokeWidth:"borderWidth",zOrder:"bringToFront",save:"save",exportPng:"image",undo:"undo",redo:"redo"},Po={l:{icon:"alignLeft",labelKey:"toolbar.align.left",testId:"left"},ctr:{icon:"alignCenter",labelKey:"toolbar.align.center",testId:"center"},r:{icon:"alignRight",labelKey:"toolbar.align.right",testId:"right"},just:{icon:"alignJustify",labelKey:"toolbar.align.justify",testId:"justify"}},Hr={forward:{icon:"bringForward",labelKey:"toolbar.bringForward"},backward:{icon:"sendBackward",labelKey:"toolbar.sendBackward"},front:{icon:"bringToFront",labelKey:"toolbar.bringToFront"},back:{icon:"sendToBack",labelKey:"toolbar.sendToBack"}},fs=["forward","backward","front","back"],Sc={bold:"pptx-bold",italic:"pptx-italic",underline:"pptx-underline",insertSlide:"pptx-new-slide",insertImage:"pptx-insert-image",save:"pptx-save",exportPng:"pptx-export-png",undo:"pptx-undo",redo:"pptx-redo"};function Le(e){return e.enabled?void 0:e.disabledReason.message}function Ct(e){return e&&typeof e=="object"?e:null}function Kr(e,t){let n=Ct(t)?.value;return e==="alignment"&&typeof n=="string"?Po[n]?.icon:e==="zOrder"&&typeof n=="string"?Hr[n]?.icon:e==="tool"&&typeof n=="string"?n==="select"?"select":n==="textBox"?"textBox":"shape":e==="fontSizeStep"?Ct(t)?.direction==="increase"?"add":"remove":vc[e]}function gs(e,t,n,o){let r=Ct(t)?.value;if(e==="alignment"&&typeof r=="string"){let s=Po[r];if(s)return n(s.labelKey)}if(e==="zOrder"&&typeof r=="string"){let s=Hr[r];if(s)return n(s.labelKey)}if(e==="tool"&&typeof r=="string"){if(r==="select")return n("commands.selectTool");if(r==="textBox")return n("toolbar.textBoxTool");let s=it.find(i=>`shape:${i.geometry}`===r);if(s)return n(s.labelKey)}return e==="fontSizeStep"?n(Ct(t)?.direction==="increase"?"toolbar.increaseFontSize":"toolbar.decreaseFontSize"):o}function Cc(e,t){let n=Ct(t)?.value;if(e==="alignment"&&typeof n=="string"){let o=Po[n];return o?`pptx-align-${o.testId}`:void 0}if(e==="tool"&&n==="select")return "pptx-tool-select";if(e==="tool"&&n==="textBox")return "pptx-tool-text-box";if(e==="fontSizeStep")return Ct(t)?.direction==="increase"?"pptx-font-size-increase":"pptx-font-size-decrease";if(!(e==="insertSlide"&&Ct(t)?.layoutPartPath!==void 0))return Sc[e]}function hs(e,t){return e==="tool"&&Ct(t)?.value==="select"?"Esc":Zn(e,t)}function xs(e,t){return je(e)?.prepare(t)??{execute:n=>e.execute(t,n)}}function yo(e,t,n,o,r){let s=e.getState(n,o),i=Kr(n,o);return {kind:"item",id:r,label:gs(n,o,t,t(e.getDescriptor(n).labelKey)),icon:i?jsx(De,{name:i,size:16}):void 0,shortcut:hs(n,o)??void 0,checked:s.active,disabled:!s.enabled,description:Le(s),onSelect:()=>{e.execute(n,o??en(n));}}}function wc(e,t,n){return (n.options??[]).map((o,r)=>({kind:"item",id:`${t}-${r}`,label:o.label,radio:true,checked:o.state.active===true,disabled:!o.state.enabled,description:o.state.enabled?void 0:o.state.disabledReason.message,onSelect:()=>{e.execute(t,o.args);}}))}function Ic(e,t,n,o){let r=e.getState(n),s=Le(r),i=wc(e,n,r);if(n==="insertSlide"&&i.unshift(yo(e,t,"insertSlide",{},"insertSlide-current"),{kind:"separator",id:"insertSlide-separator"}),n==="fontSize"&&o.prompt){let a=o.prompt;i.push({kind:"item",id:"fontSize-custom",label:t("commands.customFontSize"),disabled:!r.enabled,description:s,onSelect:()=>{let f=xs(e,"fontSize");a({title:t("toolbar.fontSize"),label:t("commands.fontSizePoints"),initialValue:typeof r.value=="number"?String(r.value):"",valid:u=>/^\d+(\.\d+)?$/.test(u)&&e.getState("fontSize",{points:Number(u)}).enabled,submit:u=>{f.execute({points:Number(u)});}});}});}return {kind:"submenu",id:n,label:t(e.getDescriptor(n).labelKey),disabled:!r.enabled,description:s,entries:i}}var bs={shapeFill:"toolbar.noFill",shapeStrokeColor:"toolbar.noBorder"};function bo(e){return {color:e}}function Ec(e,t,n,o){let r=e.getState(n),s=!r.enabled,i=Le(r),a=typeof r.value=="string"?r.value:null,f=t(e.getDescriptor(n).labelKey),u=[],p=bs[n];if(p&&u.push({kind:"item",id:`${n}-clear`,label:t(p),radio:true,checked:r.value===null,disabled:s,description:i,onSelect:()=>{e.execute(n,bo(null));}}),o.prompt){let g=o.prompt;u.push({kind:"item",id:`${n}-custom`,label:t("commands.customColor"),disabled:s,description:i,onSelect:()=>{let c=xs(e,n);g({title:f,label:t("commands.hexColor"),placeholder:"#1A73E8",initialValue:a??"",valid:x=>/^#?[0-9a-f]{6}$/i.test(x),submit:x=>{c.execute(bo(`#${x.replace(/^#/,"").toLowerCase()}`));}});}});}return {kind:"submenu",id:n,label:f,disabled:s,description:i,entries:u}}function Tc(e,t){let n=e.getState("zOrder");return {kind:"submenu",id:"zOrder",label:t(e.getDescriptor("zOrder").labelKey),disabled:!n.enabled,description:Le(n),entries:fs.map(o=>yo(e,t,"zOrder",{value:o},`zOrder-${o}`))}}var Ps=new Set(["fontFamily","fontSize","alignment","insertSlide","tool","shapeStrokeWidth","shapeAdjustment","zoom","proposalSelect"]);function Rc(e,t,n,o,r={}){{if(Ps.has(n))return Ic(e,t,n,r);if(n==="textColor"||n==="shapeFill"||n==="shapeStrokeColor")return Ec(e,t,n,r);if(n==="zOrder")return Tc(e,t)}return yo(e,t,n,o,n)}function kc(e,t,n){let o=le(),{t:r}=Q(),s=useContext(zt)?.prompt;ft(e,()=>[Rc(o,r,t,n,{prompt:s})]);}function we(e){let{id:t,children:n,label:o,className:r,style:s}=e,i=e.args,a=Ge(t)?null:t,f=oo(t,i??(a?en(a):null)),{t:u}=Q();if(!a&&f.descriptor===null)return null;let p=a?Kr(a,i):void 0,g=o??(a?gs(a,i,u,f.label):f.label);return jsx(Pr,{active:f.state.active,disabled:!f.state.enabled,description:Le(f.state),title:g,shortcut:(a?hs(a,i):f.shortcut)??void 0,className:r,style:!p&&!n?{padding:"0 8px",...s}:s,testId:a?Cc(a,i):void 0,onClick:()=>{f.execute();},children:n??(p?jsx(De,{name:p}):g)})}function Nr({id:e,children:t,className:n,style:o}){let r=useRef(null);return kc(r,e),jsx("span",{ref:r,className:n,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",...o},children:t})}function Mc(){let e=le(),t=he("fontFamily"),{t:n}=Q();return jsx(Nt,{title:n("toolbar.fontFamily"),disabled:!t.enabled,description:Le(t),menuWidth:210,testId:"pptx-font-family",style:{width:120,justifyContent:"space-between"},trigger:jsxs(Fragment,{children:[jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:t.value??n("toolbar.mixed")}),jsx(De,{name:"chevronDown",size:13})]}),children:o=>(t.options??[]).map(r=>jsx(dn,{label:r.label,radio:true,selected:t.value===r.args.family,onClick:()=>St(e,"fontFamily",r.args),close:o},r.args.family))})}function Br(e){return Number.parseFloat(e.replace("%","").trim())}function Ac(){let e=le(),t=he("fontSize"),{t:n}=Q();return jsx(xo,{value:typeof t.value=="number"?String(t.value):"",options:(t.options??[]).map(o=>({value:String(o.args.points),label:o.label})),label:n("toolbar.fontSize"),disabled:!t.enabled,description:Le(t),onCommit:o=>{let r=Br(o);Number.isFinite(r)&&r>=Yn&&r<=Jn&&St(e,"fontSize",{points:r});},width:50,inputStyle:{textAlign:"center"},testId:"pptx-font-size"})}function Lc(){let e=le(),t=he("zoom"),{t:n}=Q(),o=n("toolbar.fit"),r=t.value??"fit",s=r==="fit"?o:`${Math.round(r*100)}%`;return jsx(xo,{value:s,options:(t.options??[]).map(i=>({value:i.label,label:i.label})),label:n("toolbar.zoomValue",{value:s}),disabled:!t.enabled,description:Le(t),onCommit:i=>{if(i===o){St(e,"zoom",{scale:"fit"});return}let a=Br(i)/100;Number.isFinite(a)&&a>=pr&&a<=mr&&St(e,"zoom",{scale:a});},width:76,testId:"pptx-zoom"})}function Oc(){let e=le(),t=he("alignment"),{t:n}=Q();return jsx(Fragment,{children:(t.options??[]).map(o=>jsx(Dc,{store:e,value:o.args.value,t:n},o.args.value))})}function Dc({store:e,value:t,t:n}){let o=he("alignment",{value:t}),r=Po[t];return jsx(lo,{title:n(r.labelKey),active:o.active,disabled:!o.enabled,description:Le(o),onClick:()=>{e.execute("alignment",{value:t});},testId:`pptx-align-${r.testId}`,children:jsx(De,{name:r.icon})})}function Fc(){let e=le(),t=he("insertSlide"),n=oo("insertSlide",{}),{t:o}=Q(),r=t.options??[];return jsxs(Fragment,{children:[jsx(lo,{title:o("toolbar.newSlide"),disabled:!n.state.enabled,description:Le(n.state),onClick:()=>{n.execute();},style:{borderRadius:"4px 0 0 4px"},testId:"pptx-new-slide",children:jsx(De,{name:"newSlide"})}),jsx(Nt,{title:o("toolbar.newSlideWithLayout"),disabled:!t.enabled||r.length===0,description:Le(t),menuWidth:230,testId:"pptx-new-slide-layout",style:{minWidth:20,width:20,padding:0,borderRadius:"0 4px 4px 0"},trigger:jsx(De,{name:"chevronDown",size:13}),children:s=>r.map((i,a)=>jsx(dn,{label:i.label,radio:true,selected:(i.args.layoutPartPath??null)===(t.value??null),onClick:()=>{e.execute("insertSlide",i.args);},close:s},i.args.layoutPartPath??`default-${a}`))})]})}function jr(){let e=le(),t=he("tool"),n=he("tool",{value:"shape:rect"}),{t:o}=Q(),r=useRef(null),s=useId();ft(r,()=>[{kind:"submenu",id:s,label:o("toolbar.shapeTool"),disabled:!n.enabled,description:Le(n),entries:it.map(a=>yo(e,o,"tool",{value:`shape:${a.geometry}`},`${s}-${a.geometry}`))}]);let i=t.value??"select";return jsx("span",{ref:r,style:{display:"inline-flex",flex:"0 0 auto"},children:jsx(Nt,{title:o("toolbar.shapeTool"),active:i.startsWith("shape:"),disabled:!n.enabled,description:Le(n),menuWidth:264,testId:"pptx-tool-shape",style:{minWidth:46,padding:"0 4px"},trigger:jsxs(Fragment,{children:[jsx(De,{name:"shape"}),jsx(De,{name:"chevronDown",size:11})]}),children:a=>jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 44px)",gap:4,padding:2},children:it.map(f=>{let u=`shape:${f.geometry}`;return jsx("button",{type:"button",role:"menuitemradio",tabIndex:-1,"aria-checked":i===u,"data-testid":`pptx-shape-${f.geometry}`,"aria-label":o(f.labelKey),title:o(f.labelKey),onClick:()=>{a(),St(e,"tool",{value:u});},style:{appearance:"none",display:"grid",placeItems:"center",width:44,height:38,padding:5,border:`1px solid ${q.border}`,borderRadius:4,background:i===u?q.active:q.surface,color:q.text,cursor:"pointer"},children:jsx($c,{geometry:f.geometry})},f.geometry)})})})})}function zc(){let e=le(),t=he("shapeStrokeWidth"),{t:n}=Q();return jsx(Nt,{title:n("toolbar.borderWidth"),disabled:!t.enabled,description:Le(t),menuWidth:170,testId:"pptx-shape-border-width",trigger:jsx(De,{name:"borderWidth"}),children:o=>(t.options??[]).map(r=>jsx(dn,{label:r.label,radio:true,selected:t.value===r.args.points,icon:r.args.points===null?void 0:jsx("span",{"aria-hidden":"true",style:{width:18,borderTop:`${Math.min(r.args.points,5)}px solid currentColor`}}),onClick:()=>{e.execute("shapeStrokeWidth",r.args);},close:o},String(r.args.points)))})}function Hc(){let e=le(),t=he("shapeAdjustment"),{t:n}=Q(),o=t.value;if(!o)return null;let r=t.options??[],s=r.length>0?r[r.length-1].args.value:1,i=s<1;return jsx(xo,{value:`${Math.round(o.value*100)}%`,options:r.map(a=>({value:String(Math.round(a.args.value*100)),label:a.label})),label:n(i?"toolbar.cornerRadius":"toolbar.shapeAdjustment"),disabled:!t.enabled,description:Le(t),onCommit:a=>{let f=Br(a);Number.isFinite(f)&&St(e,"shapeAdjustment",{name:o.name,value:Math.max(0,Math.min(s*100,f))/100});},width:68,inputStyle:{textAlign:"center"},testId:i?"pptx-shape-corner-radius":"pptx-shape-adjustment"})}function Kc({className:e}){let t=le(),n=he("proposalSelect"),{t:o}=Q(),r=!n.enabled;return jsx("select",{className:e,"aria-label":o("proposals.canvasTitle"),"aria-disabled":r||void 0,title:Le(n),value:n.value??"",onChange:s=>{r||t.execute("proposalSelect",{proposalId:s.target.value});},style:{maxWidth:220,font:"400 13px ui-sans-serif, system-ui, sans-serif"},children:(n.options??[]).map(s=>jsx("option",{value:s.args.proposalId,children:s.label},s.args.proposalId))})}function ys({id:e,className:t}){let n=null;switch(e){case "fontFamily":n=jsx(Mc,{});break;case "fontSize":n=jsx(Ac,{});break;case "alignment":n=jsx(Oc,{});break;case "insertSlide":n=jsx(Fc,{});break;case "tool":n=jsxs(Fragment,{children:[jsx(ps,{value:"select"}),jsx(ps,{value:"textBox"}),jsx(jr,{})]});break;case "shapeStrokeWidth":n=jsx(zc,{});break;case "shapeAdjustment":n=jsx(Hc,{});break;case "zoom":n=jsx(Lc,{});break;case "proposalSelect":n=jsx(Kc,{});break}return e==="tool"?jsx("span",{className:t,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto"},children:n}):jsx(Nr,{id:e,className:t,children:n})}function ps({value:e}){return jsx(we,{id:"tool",args:{value:e}})}var Nc={textColor:"pptx-text-color",shapeFill:"pptx-shape-fill",shapeStrokeColor:"pptx-shape-border-color"},Bc={textColor:"#000000",shapeFill:"#d9eaf7",shapeStrokeColor:"#202124"};function jc({id:e}){let t=le(),n=he(e),{t:o}=Q(),r=bs[e],s=typeof n.value=="string"?n.value:null,i=!n.enabled;return jsx(Nr,{id:e,children:jsx(ds,{value:s??Bc[e],label:o(t.getDescriptor(e).labelKey),clearLabel:r?o(r):void 0,icon:Kr(e,void 0),none:!!r&&!s,disabled:i,description:Le(n),onChange:a=>St(t,e,bo(a)),onClear:r?()=>{t.execute(e,bo(null));}:void 0,testId:Nc[e]})})}function _c(){let e=le(),t=he("zOrder"),{t:n}=Q();return jsx(Nr,{id:"zOrder",children:jsx(Nt,{title:n("toolbar.arrange"),disabled:!t.enabled,description:Le(t),menuWidth:190,testId:"pptx-shape-arrange",trigger:jsx(De,{name:"bringToFront"}),children:o=>fs.map(r=>jsx(Wc,{store:e,value:r,close:o,t:n},r))})})}function Wc({store:e,value:t,close:n,t:o}){let r=he("zOrder",{value:t}),s=Hr[t];return jsx(dn,{label:o(s.labelKey),icon:jsx(De,{name:s.icon,size:16}),disabled:!r.enabled,description:Le(r),onClick:()=>{e.execute("zOrder",{value:t});},close:n})}function Gc(){return jsxs(Fragment,{children:[jsx(we,{id:"fontSizeStep",args:{direction:"decrease"}}),jsx(we,{id:"fontSizeStep",args:{direction:"increase"}})]})}function Qe(e){let{id:t,className:n}=e;if(Ge(t))return jsx(we,{id:t,className:n});let o=e.args;if(o===void 0){if(Ps.has(t))return jsx(ys,{id:t,className:n});switch(t){case "textColor":case "shapeFill":case "shapeStrokeColor":return jsx(jc,{id:t});case "zOrder":return jsx(_c,{});case "fontSizeStep":return jsx(Gc,{});}}return jsx(we,{id:t,args:o,className:n})}function $c({geometry:e}){let t={rect:"M3 5h18v14H3Z",roundRect:"M7 5h10a4 4 0 0 1 4 4v6a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a4 4 0 0 1 4-4Z",ellipse:"M3 12a9 7 0 1 0 18 0 9 7 0 1 0-18 0",triangle:"m12 4 9 16H3Z",rtTriangle:"M4 4v16h16Z",diamond:"m12 3 9 9-9 9-9-9Z",parallelogram:"M7 5h14l-4 14H3Z",trapezoid:"M7 5h10l4 14H3Z",pentagon:"m12 3 9 7-4 11H7L3 10Z",hexagon:"m7 4 10 0 5 8-5 8H7l-5-8Z",octagon:"m7 3 10 0 4 4v10l-4 4H7l-4-4V7Z",star5:"m12 2.5 2.8 6 6.5.6-5 4.3 1.6 6.4-5.7-3.4-5.7 3.4 1.6-6.4-5-4.3 6.5-.6Z",rightArrow:"M3 8h11V4l7 8-7 8v-4H3Z",leftArrow:"m21 8H10V4l-7 8 7 8v-4h11Z",upArrow:"M8 21V10H4l8-7 8 7h-4v11Z",downArrow:"M8 3v11H4l8 7 8-7h-4V3Z",chevron:"M4 4h9l7 8-7 8H4l7-8Z"}[e];return jsx("svg",{width:"30",height:"24",viewBox:"0 0 24 24",fill:"rgba(60, 64, 67, 0.08)",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round","aria-hidden":"true",children:jsx("path",{d:t})})}var Xc=Object.freeze([]);function _r(){let e=le(),t=je(e),n=useCallback(()=>t?.pluginToolbar()??Xc,[t]),o=useSyncExternalStore(e.subscribe,n,n),{t:r}=Q();return o.length===0?null:jsx(Je,{label:r("plugins.toolbarGroup"),children:o.map(s=>jsx(we,{id:s},s))})}var Jc={surface:"#ffffff",text:"#202124",mutedText:"#5f6368",border:"#dadce0",hover:"#f1f3f4",shadow:"rgba(60, 64, 67, 0.24)"},Ss='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]',wt=8,Qc=320;function ep(e,t,n){let o=t.offsetWidth,r=t.scrollHeight,s=window.innerWidth,i=window.innerHeight,a=n?e.right:e.right-o;n&&a+o>s-wt&&(a=e.left-o),a=Math.max(wt,Math.min(a,s-o-wt));let f=i-wt-(n?e.top:e.bottom+4),u=(n?e.bottom:e.top-4)-wt;if(r<=f||f>=u)return {top:n?e.top:e.bottom+4,left:a,maxHeight:Math.max(f,80)};let p=Math.max(u,80),g=n?e.bottom:e.top-4;return {top:Math.max(wt,g-Math.min(r,p)),left:a,maxHeight:p}}function tp(){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 np(){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 ws({id:e,label:t,entries:n,anchor:o,beside:r,colors:s,initialFocus:i,onClose:a,onSelect:f,registerMenu:u}){let p=useRef(null),g=useId(),[c,x]=useState(null),S=useRef(false),[L,A]=useState(null),G=useRef(new Map),D=io({container:p,itemSelector:Ss,scope:'[role="menu"]',labelOf:v=>v.dataset.label??v.textContent??""});useLayoutEffect(()=>p.current?u(p.current):void 0,[u]),useLayoutEffect(()=>{let v=o(),w=p.current;if(!v||!w)return;let O=ep(v,w,r);x(m=>m&&m.top===O.top&&m.left===O.left&&m.maxHeight===O.maxHeight?m:O);},[o,r,n]),useLayoutEffect(()=>{!c||S.current||(S.current=true,i==="first"?D.focusFirst():i==="last"?D.focusLast():i==="menu"&&p.current?.focus({preventScroll:true}));},[i,c,D]);let R=(v,w)=>A({id:v,focus:w}),_=v=>{if(v.target instanceof Node&&!p.current?.contains(v.target))return;let w=v.target instanceof HTMLElement?v.target.closest(Ss):null,O=w&&w.closest('[role="menu"]')===p.current?w:null;if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),a(r?"parent":"escape");return}if(v.key==="Tab"){setTimeout(()=>a("tab"),0);return}if(r&&v.key==="ArrowLeft"){v.preventDefault(),v.stopPropagation(),a("parent");return}if(O?.dataset.submenu&&(v.key==="ArrowRight"||v.key==="Enter"||v.key===" ")){v.preventDefault(),v.stopPropagation(),O.getAttribute("aria-disabled")!=="true"&&R(O.dataset.submenu,"first");return}if(O&&(v.key==="Enter"||v.key===" ")){v.preventDefault(),v.stopPropagation();let m=Is(n,O.dataset.entry??"");m&&!m.disabled&&f(m,"keyboard");return}D.onKeyDown(v)&&v.stopPropagation();},M=v=>v.map(w=>{if(w.kind==="separator")return jsx("div",{role:"separator",style:{height:1,margin:"4px 0",background:s.border}},w.id);if(w.kind==="group"){let F=`${g}-${w.id}-label`;return jsxs("div",{role:"group","aria-labelledby":w.label?F:void 0,children:[w.label&&jsx("div",{id:F,style:{padding:"6px 12px 2px",fontSize:11,fontWeight:500,color:s.mutedText,overflowWrap:"anywhere"},children:w.label}),M(w.entries)]},w.id)}let O=w.description?`${g}-${w.id}-description`:void 0,m=w.kind==="submenu",E=m?"menuitem":w.radio?"menuitemradio":w.checked!==void 0?"menuitemcheckbox":"menuitem",B=m?void 0:w.checked,C=m&&L?.id===w.id;return jsxs("div",{style:{position:"relative"},children:[jsxs("div",{role:E,tabIndex:-1,"data-entry":w.id,"data-label":w.label,"data-submenu":m?w.id:void 0,"aria-haspopup":m?"menu":void 0,"aria-expanded":m?C:void 0,"aria-checked":E==="menuitemcheckbox"||E==="menuitemradio"?B==="mixed"?"mixed":B===true:void 0,"aria-disabled":w.disabled?true:void 0,"aria-describedby":O,title:w.description,ref:F=>{m&&F&&G.current.set(w.id,F);},onMouseDown:F=>F.preventDefault(),onMouseEnter:F=>{m&&!w.disabled?R(w.id,"none"):L&&A(null),F.currentTarget.style.background=w.disabled?"transparent":s.hover;},onMouseLeave:F=>{F.currentTarget.style.background="transparent";},onClick:()=>{w.disabled||(m?R(w.id,"none"):f(w,"pointer"));},style:{display:"flex",alignItems:"center",gap:8,minHeight:30,padding:"4px 12px 4px 8px",fontSize:13,cursor:w.disabled?"default":"pointer",color:w.disabled?s.mutedText:s.text,opacity:w.disabled?.6:1,outlineOffset:-2},children:[jsx("span",{style:{width:16,flexShrink:0,display:"inline-flex",justifyContent:"center"},children:B===true?jsx(tp,{}):B==="mixed"?"\u2013":null}),w.icon&&jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",flexShrink:0},children:w.icon}),jsx("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:w.label}),!m&&w.shortcut&&jsx("span",{"aria-hidden":"true",style:{marginLeft:16,flexShrink:0,whiteSpace:"nowrap",fontSize:12,color:s.mutedText},children:w.shortcut}),m&&jsx("span",{style:{display:"inline-flex",flexShrink:0},children:jsx(np,{})})]}),O&&jsx("span",{id:O,hidden:true,children:w.description}),m&&C&&jsx(ws,{label:w.label,entries:w.entries,anchor:()=>G.current.get(w.id)?.getBoundingClientRect()??null,beside:true,colors:s,initialFocus:L?.focus??"none",onClose:F=>{A(null),F==="parent"?G.current.get(w.id)?.focus():a(F);},onSelect:f,registerMenu:u})]},w.id)});return jsx("div",{ref:p,id:e,role:"menu","aria-label":t,"aria-orientation":"vertical",tabIndex:-1,onKeyDown:_,style:{position:"fixed",top:c?.top??0,left:c?.left??0,maxHeight:c?.maxHeight,visibility:c?"visible":"hidden",overflowY:"auto",overflowX:"hidden",minWidth:Math.min(200,window.innerWidth-2*wt),maxWidth:Math.min(Qc,window.innerWidth-2*wt),padding:"4px 0",background:s.surface,color:s.text,border:`1px solid ${s.border}`,borderRadius:8,boxShadow:`0 4px 16px ${s.shadow}`,zIndex:1e4,boxSizing:"border-box",outline:"none"},children:M(n)})}function Is(e,t){for(let n of e){if(n.kind==="item"&&n.id===t)return n;if(n.kind==="group"){let o=Is(n.entries,t);if(o)return o}}return null}var Es=forwardRef(function({label:t,trigger:n,entries:o,colors:r,triggerClassName:s,triggerStyle:i,testId:a,onItemSelected:f},u){let p=useRef(null),g=useRef(new Set),c=useId(),[x,S]=useState(null),L={...Jc,...r},A=useCallback(()=>S(null),[]);useImperativeHandle(u,()=>({focus:()=>p.current?.focus({preventScroll:true}),close:A}),[A]);let G=useCallback(R=>(g.current.add(R),()=>{g.current.delete(R);}),[]);useEffect(()=>{if(!x)return;let R=M=>{let v=M.target;if(!p.current?.contains(v)){for(let w of g.current)if(w.contains(v))return;A();}},_=()=>{let M=document.activeElement,v=[...g.current].some(w=>w.contains(M));A(),v&&p.current?.focus({preventScroll:true});};return document.addEventListener("mousedown",R,true),window.addEventListener("resize",_),()=>{document.removeEventListener("mousedown",R,true),window.removeEventListener("resize",_);}},[x,A]);let D=useCallback(()=>p.current?.getBoundingClientRect()??null,[]);return jsxs("span",{style:{display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:p,type:"button",className:s,style:i,"data-testid":a,"aria-label":t,title:t,"aria-haspopup":"menu","aria-expanded":x!==null,"aria-controls":x?c:void 0,onMouseDown:R=>R.preventDefault(),onClick:()=>S(R=>R?null:"menu"),onKeyDown:R=>{R.key==="Enter"||R.key===" "||R.key==="ArrowDown"?(R.preventDefault(),S("first")):R.key==="ArrowUp"&&(R.preventDefault(),S("last"));},children:n}),x&&jsx(ws,{id:c,label:t,entries:o,anchor:D,beside:false,colors:L,initialFocus:x,onClose:R=>{A(),R!=="tab"&&p.current?.focus({preventScroll:true});},onSelect:(R,_)=>{A(),_==="keyboard"&&p.current?.focus({preventScroll:true}),R.onSelect(),f?.(_);},registerMenu:G})]})});var ip={position:"absolute",visibility:"hidden",pointerEvents:"none",insetInlineStart:"0"},Rs={overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"},ap=new WeakMap,ks=new WeakMap,Ms=["a[href]","button",'input:not([type="hidden"])',"select","textarea","summary","[tabindex]",'[contenteditable]:not([contenteditable="false"])'].join(", ");function Os(e,t){if(t.length===0)return false;let n=Array.from(e.querySelectorAll(Ms));return e.matches(Ms)&&n.push(e),n.every(o=>t.some(r=>r.contains(o)))}function As(e){let t=getComputedStyle(e),n=(parseFloat(t.marginLeft)||0)+(parseFloat(t.marginRight)||0);return e.getBoundingClientRect().width+n}function sp(e){let t=getComputedStyle(e),n=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0);return e.getBoundingClientRect().width-n}function Xr(e,t,n,o){let r=n.get(e);if(o===!!r)return false;let s=Object.keys(t);if(o){let i={};for(let a of s)i[a]=e.style[a],e.style[a]=t[a]??"";n.set(e,i);}else {for(let i of s)e.style[i]=r?.[i]??"";n.delete(e);}return true}function Zr(e,t){Xr(e,ip,ap,t)&&(t?e.setAttribute("aria-hidden","true"):e.removeAttribute("aria-hidden"),e.inert=t);}function Ls(e,t){let n=e.getBoundingClientRect(),o=t.getBoundingClientRect();o.left<n.left?e.scrollLeft-=n.left-o.left:o.right>n.right&&(e.scrollLeft+=Math.min(o.right-n.right,o.left-n.left));}function lp(e,t){return e.length===t.length&&e.every((n,o)=>n===t[o])}function Ds(e){let t=useRef(e);t.current=e;let[n,o]=useState([]),r=useRef(n);r.current=n;let s=useRef(e.moreWidth??32),i=useCallback(()=>{let{items:a,more:f,canHide:u,onFocusHidden:p}=t.current,g=a.current,c=g?.parentElement;if(!g||!c)return;let x=f.current;x&&(s.current=As(x));let S=Array.from(g.children).filter(v=>v instanceof HTMLElement),L=parseFloat(getComputedStyle(g).columnGap)||0,A=sp(c),G=S.map(As),D=G.reduce((v,w)=>v+w,0)+L*Math.max(0,S.length-1),R=[],_=false;if(D>A+.5){let v=A-s.current,w=S.map(E=>u(E)),O=S.reduce((E,B,C)=>w[C]?E:E+G[C]+L,0),m=false;S.forEach((E,B)=>{if(w[B]){if(!m&&O+G[B]<=v){O+=G[B]+L;return}m=true,R.push(E);}}),_=O-L>(R.length>0?v:A)+.5;}Xr(g,Rs,ks,_);for(let v of S)Zr(v,R.includes(v));for(let v of r.current)S.includes(v)||Zr(v,false);let M=document.activeElement;M&&R.some(v=>v.contains(M))?p?.():_&&M&&g.contains(M)&&Ls(g,M),lp(R,r.current)||(r.current=R,o(R));},[]);return useLayoutEffect(()=>{i();}),useLayoutEffect(()=>{let a=t.current.items.current;if(!a)return;let f=new Set,u=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>i()),p=()=>{if(u)for(let x of [a,a.parentElement,...Array.from(a.children)])x&&!f.has(x)&&(f.add(x),u.observe(x));};p();let g=typeof MutationObserver>"u"?null:new MutationObserver(()=>{p(),i();});g?.observe(a,{childList:true});let c=x=>{x.target instanceof Element&&Ls(a,x.target);};return a.addEventListener("focusin",c),window.addEventListener("resize",i),document.fonts?.ready.then(i,()=>{}),()=>{u?.disconnect(),g?.disconnect(),a.removeEventListener("focusin",c),window.removeEventListener("resize",i),Xr(a,Rs,ks,false);for(let x of Array.from(a.children))x instanceof HTMLElement&&Zr(x,false);}},[i]),{hidden:n,remeasure:i}}var cp="input, button:not([disabled])";function Ks({prompt:e,onClose:t}){let{t:n}=Q(),[o,r]=useState(e.initialValue??""),s=useRef(null),i=useRef(null),a=useId(),f=useId(),u=o.trim(),p=e.valid(u);return useLayoutEffect(()=>{i.current?.focus(),i.current?.select();},[]),jsx("div",{style:{position:"fixed",inset:0,zIndex:10001,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(32, 33, 36, 0.32)"},onMouseDown:c=>{c.target===c.currentTarget&&t();},children:jsxs("form",{ref:s,role:"dialog","aria-modal":"true","aria-labelledby":a,onKeyDown:c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),t();return}if(c.key!=="Tab")return;let x=Array.from(s.current?.querySelectorAll(cp)??[]);if(x.length===0)return;let S=x.indexOf(document.activeElement),L=c.shiftKey?S<=0?x.length-1:S-1:S===x.length-1?0:S+1;c.preventDefault(),x[L].focus();},onSubmit:c=>{c.preventDefault(),p&&(t(),e.submit(u));},style:{width:"min(320px, 100%)",boxSizing:"border-box",padding:16,borderRadius:8,background:q.surface,color:q.text,boxShadow:"0 8px 24px rgba(60, 64, 67, 0.3)",font:"400 13px ui-sans-serif, system-ui, sans-serif"},children:[jsx("h2",{id:a,style:{margin:"0 0 12px",fontSize:15,fontWeight:600},children:e.title}),jsx("label",{htmlFor:f,style:{display:"block",marginBottom:4,fontSize:12},children:e.label}),jsx("input",{id:f,ref:i,value:o,placeholder:e.placeholder,"aria-invalid":u!==""&&!p,onChange:c=>r(c.target.value),style:{width:"100%",boxSizing:"border-box",padding:"6px 8px",border:`1px solid ${q.border}`,borderRadius:4,background:q.surface,color:q.text}}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[jsx("button",{type:"button",onClick:t,style:Kt(false,false,false),children:n("commands.cancel")}),jsx("button",{type:"submit",disabled:!p,style:Kt(!p,true,false),children:n("commands.apply")})]})]})})}var fp={surface:q.surface,text:q.text,mutedText:q.muted,border:q.border,hover:q.hover,shadow:"rgba(60, 64, 67, 0.24)"};function gp(e){return e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT"||e.tagName==="OPTION")}function hp(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Yr({children:e,className:t,style:n,testId:o}){let{t:r}=Q(),s=le(),i=useRef(null),a=useRef(null),f=useRef(null),u=useRef(new Set),[p,g]=useReducer(O=>O+1,0),[,c]=useReducer(O=>O+1,0),[x,S]=useState(false),[L,A]=useState(null),G=useRef(false),D=useMemo(()=>({register(O){return u.current.add(O),g(),()=>{u.current.delete(O),g();}},overflowing:()=>G.current,changed(){G.current&&c();},prompt:A,anchor:()=>a.current?.querySelector("button")??null}),[]),R=useCallback(O=>{let m=[];for(let E of u.current){let B=E.element();B&&O.contains(B)&&m.push({element:B,source:E});}return m.sort((E,B)=>hp(E.element,B.element))},[]),{hidden:_,remeasure:M}=Ds({items:i,more:a,canHide:O=>O.getAttribute("role")==="separator"||Os(O,R(O).map(({element:m})=>m)),onFocusHidden:()=>S(true)});useLayoutEffect(()=>{M();},[p,M]),useLayoutEffect(()=>{!x||_.length===0||(S(false),f.current?.focus());},[x,_]),G.current=_.length>0,useEffect(()=>{if(_.length!==0)return s.subscribe(c)},[_.length,s]);let v=[];_.forEach((O,m)=>{let E=R(O).flatMap(({source:C})=>C.entries());if(E.length===0)return;let B=O.getAttribute("role")==="group"?O.getAttribute("aria-label"):null;v.push({kind:"group",id:`unit-${m}`,label:B??void 0,entries:E});});let w=v.flatMap((O,m)=>m===0?[O]:[{kind:"separator",id:`separator-${m}`},O]);return jsxs("div",{className:t,role:"toolbar","aria-label":r("toolbar.label"),"data-testid":o,onMouseDown:O=>{gp(O.target)||O.preventDefault();},style:{display:"flex",alignItems:"center",minWidth:0,minHeight:36,margin:"0 8px 5px",padding:"4px 7px",borderRadius:18,background:q.rail,color:q.text,boxSizing:"border-box",...n},children:[jsx(zt.Provider,{value:D,children:jsx("div",{ref:i,"data-toolbar-items":"",style:{position:"relative",display:"flex",alignItems:"center",flex:"1 1 auto",minWidth:0,overflow:"hidden"},children:e})}),_.length>0&&jsx("span",{ref:a,style:{display:"inline-flex",flex:"0 0 auto",marginLeft:4},children:jsx(Es,{ref:f,label:r("toolbar.more"),trigger:jsx(De,{name:"more"}),entries:w,colors:fp,triggerStyle:Kt(false,false,false),testId:"pptx-toolbar-more",onItemSelected:O=>{O==="pointer"&&je(s)?.focusEditor();}})}),L&&jsx(Ks,{prompt:L,onClose:()=>{A(null),f.current?.focus();}})]})}function xp({label:e,onSelect:t,disabled:n,description:o,checked:r,children:s}){let i=useRef(null),a=useId();return ft(i,()=>[{kind:"item",id:a,label:e,checked:r,disabled:n,description:n?o:void 0,onSelect:t}]),jsx("span",{ref:i,style:{display:"inline-flex",alignItems:"center",flex:"0 0 auto"},children:s})}function _s({children:e}){let{t}=Q(),n=ao(),o=useRef(null),r=useRef(null),s=ro(),i=useCallback(S=>{r.current=S,s(S);},[s]),a=useId(),f=t("commands.moreControls"),[u,p]=useState(null),[g,c]=useState(null);ft(o,()=>[{kind:"item",id:a,label:f,onSelect:()=>p({anchor:n?.anchor()??null,width:o.current?.getBoundingClientRect().width??0})}]);let x=useCallback(S=>{let L=u?.anchor;p(null),S&&L?.focus({preventScroll:true});},[u]);return useLayoutEffect(()=>{let S=r.current;if(!u||!S){c(null);return}let L=u.anchor?.getBoundingClientRect(),A=S.offsetWidth,G=Math.max(8,Math.min((L?.right??8)-A,window.innerWidth-A-8));c({top:(L?.bottom??8)+4,left:G}),S.querySelector("button, input, select, textarea, a[href], [tabindex]")?.focus();},[u]),useEffect(()=>{if(!u)return;let S=A=>{r.current?.contains(A.target)||x(false);},L=()=>x(false);return document.addEventListener("mousedown",S),window.addEventListener("resize",L),()=>{document.removeEventListener("mousedown",S),window.removeEventListener("resize",L);}},[u,x]),jsxs(zt.Provider,{value:null,children:[jsx("span",{ref:o,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",width:u?u.width:void 0},children:u?null:e}),u&&createPortal(jsx("div",{ref:i,role:"dialog","aria-label":f,tabIndex:-1,onKeyDown:S=>{S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),x(true));},onBlur:S=>{let L=S.relatedTarget;L&&!r.current?.contains(L)&&x(false);},style:{position:"fixed",top:g?.top??0,left:g?.left??0,visibility:g?"visible":"hidden",zIndex:1e4,display:"flex",flexWrap:"wrap",alignItems:"center",gap:2,maxWidth:"calc(100vw - 16px)",padding:6,border:`1px solid ${q.border}`,borderRadius:8,background:q.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box",outline:"none"},children:e}),document.body)]})}var bp=["currentFormatting","textSelectionActive","onFormat","currentShapeFormatting","shapeSelectionActive","shapeArrangeActive","onShapeFormat","onInsertSlide","onInsertImage","slideLayouts","currentLayoutPartPath","onSave","onExportPng","onUndo","onRedo","canUndo","canRedo","zoom","onZoomChange","activeTool","onToolChange","fontFamilies","fontSizes","disabled"];function Jr(e,t){let n=bp.filter(o=>e[o]!==void 0);if(n.length>0)throw new Error(`${t} in command mode reads state from the editor's commands; remove ${n.join(", ")} or use mode="legacy".`)}function $s(){let{t:e}=Q();return jsxs(Fragment,{children:[jsxs(Je,{label:e("toolbar.groups.file"),children:[jsx(we,{id:"save"}),jsx(we,{id:"exportPng"})]}),jsx(Je,{label:e("toolbar.groups.slides"),children:jsx(Qe,{id:"insertSlide"})}),jsx(vt,{}),jsxs(Je,{label:e("toolbar.groups.history"),children:[jsx(we,{id:"undo"}),jsx(we,{id:"redo"})]}),jsx(Je,{label:e("toolbar.groups.zoom"),children:jsx(Qe,{id:"zoom"})}),jsx(vt,{}),jsxs(Je,{label:e("toolbar.groups.tools"),children:[jsx(we,{id:"tool",args:{value:"select"}}),jsx(we,{id:"tool",args:{value:"textBox"}}),jsx(we,{id:"insertImage"}),jsx(jr,{})]}),jsx(vt,{}),jsxs(Je,{label:e("toolbar.groups.font"),children:[jsx(Qe,{id:"fontFamily"}),jsx(we,{id:"fontSizeStep",args:{direction:"decrease"}}),jsx(Qe,{id:"fontSize"}),jsx(we,{id:"fontSizeStep",args:{direction:"increase"}})]}),jsx(vt,{}),jsxs(Je,{label:e("toolbar.groups.text"),children:[jsx(we,{id:"bold"}),jsx(we,{id:"italic"}),jsx(we,{id:"underline"}),jsx(Qe,{id:"textColor"})]}),jsx(vt,{}),jsx(Je,{label:e("toolbar.groups.alignment"),children:jsx(Qe,{id:"alignment"})}),jsx(vt,{}),jsxs(Je,{label:e("toolbar.groups.shape"),children:[jsx(Qe,{id:"shapeFill"}),jsx(Qe,{id:"shapeStrokeColor"}),jsx(Qe,{id:"shapeStrokeWidth"}),jsx(Qe,{id:"shapeAdjustment"}),jsx(Qe,{id:"zOrder"})]}),jsx(_r,{})]})}function Pp(e){let t={};for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}function yp(e){let t=useContext(_t),n=t?{...t,...Pp(e)}:e,o=as(n);return jsx(dt.Provider,{value:o,children:jsxs(Yr,{className:n.className,style:n.style,testId:"pptx-formatting-toolbar",children:[jsx($s,{}),n.children?jsx(_s,{children:n.children}):null]})})}function vp(e){return Jr(e,"Toolbar"),jsx(Yr,{className:e.className,style:e.style,testId:"pptx-formatting-toolbar",children:e.children??jsx($s,{})})}function Fn(e){let t=useContext(Mn);return (e.mode??t??"legacy")==="commands"?jsx(vp,{...e,mode:"commands"}):jsx(yp,{...e})}var Us={display:"flex",flexDirection:"column",flex:"0 0 auto"};function Ep({i18n:e,children:t}){let n=je(le()),o=Ca(),r=useRef(null);return useLayoutEffect(()=>{let s=r.current;if(!(!s||!n))return n.registerChrome(s)},[n]),jsx("div",{ref:r,style:{display:"contents"},children:jsx(Jt,{i18n:e??o?.i18n,children:t})})}function Tp(e){Jr(e,"EditorToolbar");let{children:t,className:n,style:o,i18n:r}=e,s=ss(le()),i=useContext(ho),a=jsx(Mn.Provider,{value:"commands",children:jsx(_t.Provider,{value:s,children:jsx("div",{className:n,"data-testid":"pptx-editor-toolbar",style:{...Us,...o},children:t??jsx(Fn,{mode:"commands"})})})});return i?a:jsx(Ep,{i18n:r,children:a})}function Rp({children:e,className:t,style:n,...o}){return jsx(Mn.Provider,{value:"legacy",children:jsx(_t.Provider,{value:o,children:jsx("div",{className:t,"data-testid":"pptx-editor-toolbar",style:{...Us,...n},children:e})})})}function kp(e){return e.mode==="commands"?jsx(Tp,{...e}):jsx(Rp,{...e})}var Co=kp;Co.Toolbar=Fn;function Vs({handle:e,slideCount:t,startIndex:n,resolveImage:o,label:r,counterLabel:s,exitLabel:i,previousLabel:a,nextLabel:f,onExit:u,onError:p}){let g=useRef(null),c=useRef(null),x=useRef(null),S=useRef({onExit:u,onError:p});S.current={onExit:u,onError:p};let[L,A]=useState(n),G=Math.max(0,Math.min(L,t-1)),[D,R]=useState({width:0,height:0}),_=M=>A(Math.max(0,Math.min(G+M,t-1)));return useEffect(()=>{A(M=>Math.max(0,Math.min(M,t-1))),t===0&&S.current.onExit();},[t]),useEffect(()=>{let M=c.current,v=g.current,w=document.activeElement,O=true;M.showModal(),M.focus(),v.requestFullscreen?.().then(()=>{O?(M.close(),M.showModal(),M.focus()):document.fullscreenElement===v&&document.exitFullscreen().catch(()=>{});}).catch(()=>{});let m=()=>{document.fullscreenElement||S.current.onExit();},E=()=>R({width:window.innerWidth,height:window.innerHeight});return E(),window.addEventListener("resize",E),document.addEventListener("fullscreenchange",m),()=>{O=false,window.removeEventListener("resize",E),document.removeEventListener("fullscreenchange",m),document.fullscreenElement===v&&document.exitFullscreen().catch(()=>{}),M.close(),w instanceof HTMLElement&&w.isConnected&&w.focus();}},[]),useEffect(()=>{let M=x.current;if(!M||t===0||D.width<=0||D.height<=0)return;let v=false;return (async()=>{let O=e.layoutSlide(G),m=document.createElement("canvas"),E=m.getContext("2d");if(!E)return;let B=Math.min(D.width/O.width,D.height/O.height),C=window.devicePixelRatio||1;sizeCanvasForSlide(m,O,C,B),await paintSlide(E,O,C,B,{resolveImage:o}),!v&&(sizeCanvasForSlide(M,O,C,B),M.getContext("2d")?.drawImage(m,0,0));})().catch(O=>{v||(S.current.onError(O),S.current.onExit());}),()=>{v=true;}},[e,G,t,o,D]),jsx("div",{ref:g,children:jsxs("dialog",{ref:c,"aria-label":r,tabIndex:-1,style:Wt.presentationOverlay,onCancel:M=>{M.preventDefault(),u();},onClick:M=>{M.target===c.current&&_(1);},onKeyDown:M=>{if(!(M.altKey||M.ctrlKey||M.metaKey)){switch(M.key){case " ":if(M.target instanceof HTMLElement&&M.target.closest("button"))return;_(1);break;case "ArrowRight":case "ArrowDown":case "PageDown":_(1);break;case "ArrowLeft":case "ArrowUp":case "PageUp":_(-1);break;case "Home":A(0);break;case "End":A(Math.max(0,t-1));break;case "Escape":u();break;default:return}M.preventDefault(),M.stopPropagation();}},children:[jsx("canvas",{ref:x,style:Wt.presentationCanvas}),jsx("button",{type:"button",onClick:u,"aria-label":i,title:i,style:Wt.presentationExit,children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:jsx("path",{d:"M6 6 18 18M18 6 6 18"})})}),jsxs("div",{style:Wt.presentationControls,children:[jsx("button",{type:"button",onClick:()=>_(-1),disabled:G===0,"aria-label":a,style:Wt.presentationNavButton,children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4","aria-hidden":"true",children:jsx("path",{d:"m15 6-6 6 6 6"})})}),jsx("span",{style:Wt.presentationCounter,"aria-live":"polite",children:s(G+1,t)}),jsx("button",{type:"button",onClick:()=>_(1),disabled:G>=t-1,"aria-label":f,style:Wt.presentationNavButton,children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4","aria-hidden":"true",children:jsx("path",{d:"m9 6 6 6-6 6"})})})]})]})})}var Wt={presentationOverlay:{position:"fixed",margin:0,padding:0,border:0,width:"100vw",height:"100vh",maxWidth:"none",maxHeight:"none",inset:0,zIndex:2147483e3,display:"flex",alignItems:"center",justifyContent:"center",background:"#000000",cursor:"pointer"},presentationCanvas:{display:"block",pointerEvents:"none"},presentationExit:{position:"absolute",top:16,right:16,display:"inline-flex",alignItems:"center",justifyContent:"center",width:36,height:36,border:0,borderRadius:999,background:"rgba(255, 255, 255, 0.14)",color:"#ffffff",cursor:"pointer"},presentationControls:{position:"absolute",bottom:20,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:12,padding:"6px 14px",borderRadius:999,background:"rgba(255, 255, 255, 0.12)"},presentationNavButton:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,border:0,borderRadius:999,background:"rgba(255, 255, 255, 0.14)",color:"#ffffff",cursor:"pointer"},presentationCounter:{minWidth:64,color:"#ffffff",fontSize:12,fontWeight:600,textAlign:"center"}};var xt=class extends Error{constructor(n){super(n instanceof Error?n.message:String(n));Yt(this,"cause",n);}},ut=class extends Error{constructor(){super("The presentation was replaced before queued work ran");}};function Ys(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}var Gt=()=>{};function Js(e=Gt){let t=Promise.resolve(),n=0,o=0,r=0,s=[],i=new Map,a=(u,p)=>{let g=r;n+=1,p==="keyboard"&&(o+=1),p&&s.push(u),n===1&&e();let c=x=>{g===r&&(x&&p&&i.set(u,x.value),s=s.filter(S=>S!==u),n-=1,p==="keyboard"&&(o-=1),n===0&&(i.clear(),e()));};u.then(()=>c(),x=>c({value:x}));},f=u=>{let p=r,g=t.then(()=>{if(p!==r)throw new ut;return u()});return t=g.then(Gt,Gt),g};return {busy:()=>n>0,keyboardQueued:()=>o>0,input(u,p="other"){if(n===0){let c;try{c=u();}catch(S){return Promise.reject(S)}if(!Ys(c))return Promise.resolve();let x=Promise.resolve(c);return t=x.then(Gt,Gt),a(x,p),x}let g=f(u);return a(g,p),g},run(u){let p=[...s],g=()=>{for(let x of p)if(i.has(x))throw new xt(i.get(x));return u()};if(n===0){let x;try{x=u();}catch(L){return Promise.reject(L)}if(!Ys(x))return Promise.resolve(x);let S=Promise.resolve(x);return t=S.then(Gt,Gt),a(S,null),S}let c=f(g);return a(c,null),c},reset(){r+=1;let u=n>0;t=Promise.resolve(),n=0,o=0,s=[],i.clear(),u&&e();}}}var ei=new WeakMap;function Qs(e,t){ei.has(e)||ei.set(e,t);}function Io(e){return ei.get(e)??null}var Eo={"data-pptx-plugin-chrome":""};function el(e){return e instanceof Element&&e.closest("[data-pptx-plugin-chrome]")!==null}var Op=Object.values(rt).flatMap(e=>e.shortcuts.map(t=>({id:e.id,shortcut:t}))),Dp=new Set(["save"]),Fp=new Set(["undo","redo"]);function tl(e){let n=(e instanceof Element?e:null)?.closest("input, textarea, select, [contenteditable]");return !!n&&n.getAttribute("contenteditable")!=="false"}function nl({commands:e,containerRef:t,suspended:n}){let o=useRef(n);o.current=n,useEffect(()=>{let r=i=>{let a=Io(i);if(a)return e.ownsStore(a);let f=i.target;return f instanceof Node&&(t.current?.contains(f)??false)||e.ownsChrome(f)},s=i=>{if(i.defaultPrevented||i.isComposing||i.keyCode===229||!r(i)||o.current())return;let a=Op.find(({shortcut:g})=>lr(g.chord,i));if(!a){let g=e.pluginShortcuts().find(({chord:c})=>lr(c,i));if(!g||tl(i.target))return;i.preventDefault(),i.repeat||e.store.execute(g.id,null);return}let{id:f,shortcut:u}=a;if(tl(i.target)&&!Dp.has(f))return;let p=e.store.getState(f,u.args);!p.enabled&&p.disabledReason.code==="host-disabled"||(i.preventDefault(),!(i.repeat&&!Fp.has(f))&&e.store.execute(f,u.args));};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s);}},[e,t]);}function rl(e){let t=e?.fill?.type==="none"?null:ol(e?.resolvedFillColor),n=ol(e?.resolvedOutlineColor);return {geometry:e?.geometry,fillColor:t,strokeColor:n,strokeWidthPt:n&&e?.outline?.width!==void 0?e.outline.width/12700:n?1:null,adjustments:e?.adjustValues??{}}}function ol(e){if(!e)return null;let t=e.replace(/^#/,"");return /^[0-9a-f]{6}$/i.test(t)?`#${t}`:null}function To(e,t,n,o){let r=Bp(e,t,n,o),s=mn(r,"underline");return {bold:mn(r,"bold"),italic:mn(r,"italic"),underline:s===void 0?void 0:s!=="none",fontSize:mn(r,"fontSizePt"),textColor:mn(r,"color"),fontFamily:mn(r,"fontFamily")}}function il(e,t){return To(e,0,e.length,t)}var zp={left:"l",center:"ctr",right:"r",justify:"just"},Hp={l:"l",ctr:"ctr",r:"r",just:"just",justLow:"just",dist:"just",thaiDist:"just"};function al(e,t,n,o){let r=Np(e),s=r[r.length-1]?.end??0,i=Math.min(Math.min(n,o),s),a=Math.max(n,o),f=r.map((p,g)=>({range:p,index:g})).filter(({range:p})=>i===a?i>=p.start&&i<=p.end:i<=p.end&&a>p.start).map(({index:p})=>Kp(e,t,p));if(f.length===0)return;let u=f[0];return f.every(p=>p===u)?u:void 0}function Kp(e,t,n){let o=e.paragraphs[n]?.alignment;if(o)return Hp[o]??"l";let r=t?.paragraphs[n]?.align;return r?zp[r]??"l":"l"}function Np(e){let t=0;return e.paragraphs.map(n=>{let o=t+n.runs.reduce((s,i)=>s+i.text.length,0),r={start:t,end:o};return t=o+1,r})}function sl(e,t,n,o){let r=To(e,t,n,o);return {bold:r.bold??o.bold,italic:r.italic??o.italic,underline:r.underline===void 0?o.underline:r.underline?"sng":"none",fontSizePt:r.fontSize??o.fontSizePt,color:r.textColor??o.color,fontFamily:r.fontFamily??o.fontFamily}}function Bp(e,t,n,o){let r=jp(e,o);if(r.length===0)return [o];let s=Math.min(t,n),i=Math.max(t,n);if(s===i){let u=r.find(g=>s>=g.start&&s<g.end);return u?[u.style]:[[...r].reverse().find(g=>g.end<=s)?.style??r[0].style]}let a=r.filter(u=>u.end>s&&u.start<i).map(u=>u.style);return a.length>0?a:[[...r].reverse().find(u=>u.end<=s)?.style??r[0].style]}function jp(e,t){let n=[],o=0;return e.paragraphs.forEach((r,s)=>{for(let i of r.runs){let a=o;o+=i.text.length,o>a&&n.push({start:a,end:o,style:_p(i.style,t)});}s<e.paragraphs.length-1&&(o+=1);}),n}function _p(e,t){return {bold:e.bold??t.bold,italic:e.italic??t.italic,underline:e.underline??t.underline,fontSizePt:e.fontSizePt??t.fontSizePt,color:e.color??t.color,fontFamily:e.fontFamily??t.fontFamily}}function mn(e,t){let n=e[0]?.[t];return e.every(o=>o[t]===n)?n:void 0}var dl=new Set(["insertImage","save","exportPng","slideshow","zoom","proposalsPanel","proposalSelect","proposalDiff"]),Zp=new Set(["bold","italic","underline","fontFamily","fontSize","fontSizeStep","textColor","alignment"]),Xp=new Set(["shapeFill","shapeStrokeColor","shapeStrokeWidth","shapeAdjustment","zOrder"]),qp=new Set(["insertSlide","tool"]);function ul(e){if(!e)return null;let t=e.replace(/^#/,"");return /^[0-9a-f]{6}$/i.test(t)?`#${t.toLowerCase()}`:null}function ti(e){return e===void 0?"mixed":e}function Vp(e,t){return `${t+1}. ${e.agentId}${e.note?` \xB7 ${e.note}`:""}`}function cl(e,t){return {id:e.id,label:Vp(e,t),stale:e.staleTargets.length>0}}function st(e){return {ok:true,status:e?"executed":"noop"}}var ni={ok:true,status:"opened"};function Ro(e){let t=e.modelRef.current;return t?.snapshot.slides[t.slideIndex]??null}function ml(e){let t=Ro(e),n=e.shapeSelectionRef.current;return !t||!n||t.id!==n.slideId?null:Re(t.shapes,n.shapeId)}function Yp(e){let t=e.handleRef.current,n=e.selectionRef.current,o=n?null:ml(e)?.textStories[0]?.id??null,r=n?.storyId??o;if(!t||!r)return null;try{let s=t.story(r),i=e.modelRef.current?.frame?.primitives.find(g=>g.kind==="textBox"&&g.storyId===r),a=n?n.anchor:0,f=n?n.focus:s.length,u=al(s,i,a,f)??null;if(n&&n.anchor===n.focus){let g=e.textStyleRef.current;return {kind:"caret",bold:g.bold,italic:g.italic,underline:g.underline!=="none",fontFamily:g.fontFamily,fontSize:g.fontSizePt,color:ul(g.color),alignment:u}}let p=n?To(s,n.anchor,n.focus,e.baseStyle):il(s,e.baseStyle);return {kind:n?"range":"shape",bold:ti(p.bold),italic:ti(p.italic),underline:ti(p.underline),fontFamily:p.fontFamily??null,fontSize:p.fontSize??null,color:ul(p.textColor),alignment:u}}catch{return "unsupported"}}function Jp(e){let t=Ro(e),n=ml(e);if(!t||!n)return null;let o=rl(n),r=t.shapes.findIndex(s=>s.id===n.id);return {formattable:n.kind==="shape",geometry:n.geometry??null,fill:o.fillColor??null,stroke:o.strokeColor??null,strokeWidth:o.strokeWidthPt??null,adjustments:n.adjustValues??{},order:r>=0?{index:r,count:t.shapes.length}:null}}function pl(e,t){if(Zp.has(t)){let n=e.selectionRef.current;return JSON.stringify(n?[n.shapeId,n.storyId,n.anchor,n.focus]:e.shapeSelectionRef.current)}return Xp.has(t)?JSON.stringify(e.shapeSelectionRef.current):qp.has(t)?Ro(e)?.id??null:null}function fl(e,t){let n=useRef(t);n.current=t;let o=useMemo(()=>{let i=u=>{let p=n.current,g=p.handleRef.current,c=p.status==="ready"&&g!==null,x=Ro(p),S=p.modelRef.current,L,A,G=[...new Set(S?.snapshot.slides.map(w=>w.layoutPartPath)??[])],D=p.readOnlyRef.current,R=p.proposalsRef.current,_=D?[]:R.filter(w=>w.changes.some(O=>O.slideId===x?.id)),M=_.find(w=>w.id===p.reviewSelectedIdRef.current)??_[0]??null,v=p.reviewEnabledRef.current;return {status:c?"ready":p.status==="ready"?"loading":p.status,readOnly:D,reviewing:v&&M!==null,pendingInput:!u&&p.coordinator.busy(),canUndo:c&&g.canUndo(),canRedo:c&&g.canRedo(),slide:x?{id:x.id,layoutPartPath:x.layoutPartPath}:null,layouts:G.map((w,O)=>({args:{layoutPartPath:w},label:p.t("toolbar.layoutOption",{number:O+1})})),get text(){return L===void 0&&(L=c?Yp(p):null),L},get shape(){return A===void 0&&(A=c?Jp(p):null),A},tool:p.activeToolRef.current,zoom:p.zoomRef.current,fontFamilies:Qn,fontSizes:eo,proposals:p.proposalsAvailable?{open:p.proposalsOpenRef.current,pending:R.map(cl),canvas:{available:_.map(cl),selectedId:M?.id??null,diff:v}}:null,translate:p.t}},a=(u,p)=>({ok:false,failure:Be(u,p)});return {environment:i,ordered:u=>!dl.has(u),admit(u){return n.current.coordinator.run(u).catch(p=>{throw p instanceof xt?new on("input-failed"):p instanceof ut?new on("document-replaced"):p})},perform:(u,p,g)=>{let{actions:c}=n.current,x=p,S=g.text&&g.text!=="unsupported"?g.text:null,L=A=>{try{return st(A())}catch(G){return c.reportError(G),a("command-failed",g)}};switch(u){case "bold":return L(()=>c.format({bold:S?.bold!==true}));case "italic":return L(()=>c.format({italic:S?.italic!==true}));case "underline":return L(()=>c.format({underline:S?.underline===true?"none":"sng"}));case "fontFamily":return L(()=>c.format({fontFamily:x.family}));case "fontSize":return L(()=>c.format({fontSizePt:x.points}));case "fontSizeStep":return L(()=>c.format({fontSizePt:no(S?.fontSize??to,g.fontSizes,x.direction==="increase"?1:-1)}));case "textColor":return L(()=>c.format({color:x.color}));case "alignment":return L(()=>c.align(x.value));case "insertSlide":return L(()=>c.insertSlide(x.layoutPartPath));case "insertImage":return c.openPicker(),ni;case "tool":return st(c.setTool(x.value));case "shapeFill":return L(()=>c.formatShape({type:"fillColor",value:x.color}));case "shapeStrokeColor":return L(()=>c.formatShape({type:"strokeColor",value:x.color}));case "shapeStrokeWidth":return L(()=>c.formatShape({type:"strokeWidth",value:x.points}));case "shapeAdjustment":return L(()=>c.formatShape({type:"adjust",name:x.name,value:x.value}));case "zOrder":return L(()=>c.formatShape({type:"zOrder",value:x.value}));case "save":return c.save().then(A=>{switch(A){case "saved":return st(true);case "requested":return {ok:true,status:"requested"};case "replaced":return a("document-replaced",g);case "gesture":return a("gesture-active",g);case "input-failed":return a("input-failed",g);default:return a("command-failed",g)}});case "exportPng":return c.exportPng().then(A=>{switch(A){case "exported":return st(true);case "replaced":return a("document-replaced",g);case "input-failed":return a("input-failed",g);default:return a("command-failed",g)}});case "slideshow":return c.present(),ni;case "undo":case "redo":return L(()=>c.history(u));case "zoom":return st(c.setZoom(x.scale));case "proposalsPanel":{let A=p===null?!g.proposals.open:!!x.open;return A===g.proposals.open?st(false):(c.setProposalsOpen(A),A?ni:st(true))}case "proposalSelect":return c.selectProposal(x.proposalId),st(true);case "proposalDiff":return !!x.enabled===g.proposals?.canvas.diff?st(false):(c.showProposalDiff(!!x.enabled),st(true));case "proposalAccept":try{return c.acceptProposal(x.proposalId,!!x.force)==="accepted"?st(!0):a("proposal-stale",g)}catch(A){return c.reportError(A),a("command-failed",g)}case "proposalReject":return L(()=>c.rejectProposal(x.proposalId));default:return a("unsupported-command",g)}},capture(u){let p=n.current;return p.handleRef.current?{id:u,generation:p.generationRef.current,target:p.coordinator.keyboardQueued()?null:pl(p,u)}:null},resume(u){let p=n.current,{id:g,generation:c,target:x}=u;return p.handleRef.current?c!==p.generationRef.current?"document-replaced":x!==null&&x!==pl(p,g)?"target-changed":g!=="tool"&&!dl.has(g)&&p.gestureActive()?"gesture-active":null:"editor-unavailable"},chrome:()=>({i18n:n.current.i18n}),focusEditor:()=>n.current.actions.focusEditor()}},[]);useLayoutEffect(()=>(e.attach(o),()=>e.detach(o)),[o,e]),useLayoutEffect(()=>{e.refresh();},t.stamp);let{handle:r,handleRef:s}=t;return useEffect(()=>{if(!r||s.current!==r)return;let i=false;return r.onUpdate(()=>{i||(i=true,queueMicrotask(()=>{i=false,e.refresh();}));})},[r,s,e]),useCallback((i,a)=>In(i,a,o.environment(true)),[o])}var ri=class extends Component{constructor(){super(...arguments);Yt(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 ko({host:e,activation:t,phase:n="render",children:o}){let r=e.commandStore(t);return jsx(ri,{onError:s=>e.fail(t.pluginId,n,s),children:jsx(dt.Provider,{value:r,children:jsx("div",{style:{display:"contents"},onKeyDownCapture:s=>Qs(s.nativeEvent,r),children:o})})})}function gl({host:e,activations:t,layerRef:n}){return jsx("div",{ref:n,...Eo,className:"pptx-plugin-overlays","data-testid":"plugin-overlays",style:{position:"absolute",inset:0,pointerEvents:"none",overflow:"visible"},children:t.map(o=>{let r=o.plugin.overlay,s=o.context.geometry;return r&&s?jsx(ko,{host:e,activation:o,children:jsx(r,{context:o.context,geometry:s})},o.key):null})})}var tm={left:280,right:280,bottom:200},li={left:160,right:160,bottom:120},nm=640,Pt={surface:"#ffffff",border:"#e2e8f0",text:"#172033",muted:"#647087",selected:"#e8f0fe",primary:"#1a73e8"};function om(e,t,n){let o=e==="bottom"?n.height:n.width,r=Math.max(li[e],Math.floor(o*.4));return Math.max(li[e],Math.min(t??tm[e],r))}function bl(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(a=>a.width===r.clientWidth&&a.height===r.clientHeight?a:{width:r.clientWidth,height:r.clientHeight});if(s(),typeof ResizeObserver>"u")return;let i=new ResizeObserver(s);return i.observe(r),()=>i.disconnect()},[e]),[t,n]}var Pl=bl;function rm({host:e,activation:t,id:n,labelledBy:o}){let[r,s]=bl(),i=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(ko,{host:e,activation:t,children:jsx(i,{context:t.context,width:s.width,height:s.height})})})}var im=e=>({maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"4px 8px",border:0,borderRadius:4,background:e?Pt.selected:"transparent",color:e?Pt.primary:Pt.muted,font:"12px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"}),hl={flex:"0 0 auto",padding:"0 6px",border:0,borderRadius:4,background:"transparent",color:Pt.muted,font:"13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"};function yl({host:e,placement:t,activations:n,available:o}){let{t:r}=Q(),s=useId(),[i,a]=useState(null),[f,u]=useState({}),[p,g]=useState(false),c=useRef(null),x=useRef(null),S=t!=="bottom"&&o.width>0&&o.width<nm,L=S&&p&&n.length>0;if(useEffect(()=>{L&&x.current?.focus();},[L]),n.length===0)return null;let A=n.find(H=>H.pluginId===i)??n[0],G=A.plugin.panel,D=S?!L:f[A.pluginId]??G.defaultCollapsed??false,R=om(t,G.preferredSize,o),_=H=>`${s}-tab-${H}`,M=`${s}-panel`,v=H=>c.current?.querySelector(`[data-plugin-tab="${H}"]`)?.focus(),w=H=>{S?g(!(L&&H===A.pluginId)):H===A.pluginId&&D&&u(h=>({...h,[H]:false})),a(H);},O=()=>{g(false),v(A.pluginId);},m=H=>{let h=n.findIndex(W=>W.pluginId===A.pluginId),y=n.length-1,K=H.key==="ArrowRight"||H.key==="ArrowDown"?h===y?0:h+1:H.key==="ArrowLeft"||H.key==="ArrowUp"?h===0?y:h-1:H.key==="Home"?0:H.key==="End"?y:null;if(K===null)return;H.preventDefault();let z=n[K].pluginId;a(z),v(z);},E=r(D?"plugins.expandPanel":"plugins.collapsePanel",{title:G.title}),B=t==="bottom",C=S||!B&&D,F=jsx(rm,{host:e,activation:A,id:M,labelledBy:_(A.pluginId)},A.key);return jsxs("section",{...Eo,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:Pt.surface,color:Pt.text,...B?{height:D?void 0:R,borderTop:`1px solid ${Pt.border}`}:{width:D||S?void 0:R,maxWidth:D||S?96:void 0,[t==="left"?"borderRight":"borderLeft"]:`1px solid ${Pt.border}`}},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:4,flexWrap:"wrap"},children:[jsx("div",{ref:c,role:"tablist","aria-label":r("plugins.panelTabs"),"aria-orientation":C?"vertical":"horizontal",onKeyDown:m,style:{display:"flex",flexDirection:C?"column":"row",gap:2,flex:1,minWidth:0,overflow:"hidden"},children:n.map(H=>{let h=H.pluginId===A.pluginId;return jsx("button",{type:"button",role:"tab",id:_(H.pluginId),"data-plugin-tab":H.pluginId,"aria-selected":h,"aria-controls":h&&!D?M:void 0,"aria-expanded":S?h&&L:void 0,tabIndex:h?0:-1,title:H.plugin.panel.title,onClick:()=>w(H.pluginId),style:im(h),children:H.plugin.panel.title},H.pluginId)})}),!S&&jsx("button",{type:"button","aria-expanded":!D,"aria-label":E,title:E,onClick:()=>u(H=>({...H,[A.pluginId]:!D})),style:hl,children:D?"+":"\u2212"})]}),!D&&!S&&F,L&&jsxs("div",{ref:x,tabIndex:-1,"data-testid":`plugin-drawer-${t}`,onKeyDown:H=>{H.key==="Escape"&&(H.stopPropagation(),O());},style:{position:"absolute",top:0,bottom:0,[t==="left"?"left":"right"]:"100%",width:Math.min(R,Math.max(li[t],o.width-64)),zIndex:60,display:"flex",flexDirection:"column",background:Pt.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":E,title:E,onClick:O,style:hl,children:"\xD7"})}),F]})]})}var am=Object.freeze({commands:Object.freeze([])});function vl(e){if(!e||typeof e!="object")return am;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 Sl(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 Cl(e,t){return e.commands?.includes(t)??false}function wl(e){return e.document==="write"}function di(e,t){return e.document==="write"&&e.editBatches===true&&(t!=="none"||e.untrackedHistory===true)}var sm=/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9])?$/;function lm(e){return typeof e=="string"&&sm.test(e)}function Il(e){return e.revision===void 0?"":`${typeof e.revision}:${e.revision}`}var El=10;function ui(e){return e.type==="load"?"document-change":e.type}function dm(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function ci(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 Tl(e){let t=new Map,n=null,o=false,r={},s=new Map,i=new WeakSet,a=new Set,f=new Set,u=0,p=0,g=null,c=[],x=false,S=h=>{try{e.report(h);}catch(y){console.error("[plugins] onPluginError threw",y);}},L=h=>{let y=Object.hasOwn(r,h)?r[h]:void 0,K=s.get(h);if(K&&K.source===y)return K.grant;let z=vl(y);return s.set(h,{source:y,grant:z}),z},A=h=>{let y=`${u}:${h.stateRevision}`;if(h.rendered?.key===y)return h.rendered.entry;let K=w(h,h.lifetime.signal),z={pluginId:h.registration.id,plugin:h.registration.plugin,generation:h.generation,activation:h.token,key:h.key,context:e.context(K,h.registration.plugin)};return h.rendered={key:y,entry:z},z},G=()=>{x=false;let h=[];for(let K of t.values()){let z=K.activation;z?.status==="ready"&&h.push(A(z));}h.length===c.length&&h.every((K,z)=>K===c[z])||(c=h);for(let K of [...f])K();},D=()=>{u+=1,!x&&(x=true,queueMicrotask(G));},R=(h,y)=>h.status==="disposed"?h.ended==="document-replaced"?"document-replaced":"plugin-unavailable":y.aborted?"aborted":null,_=(h,y,K)=>{let z=W=>S({pluginId:h.registration.id,generation:h.generation,phase:"cleanup",error:W});try{let W=y(K);dm(W)&&W.then(void 0,z);}catch(W){z(W);}},M=(h,y)=>{if(h.status!=="disposed"){h.status="disposed",h.ended=y,h.pending=[],h.registration.activation===h&&(h.registration.activation=null),h.lifetime.abort();for(let K of h.cleanups.splice(0).reverse())_(h,K,y);D();}},v=(h,y,K)=>{h.status!=="disposed"&&(h.registration.quarantined=true,S({pluginId:h.registration.id,generation:h.generation,phase:y,error:K}),M(h,"failed"));};function w(h,y){let K=e.snapshot(h.registration.id,h.generation);return {pluginId:h.registration.id,activation:h.token,snapshot:K,signal:y,lifetimeSignal:h.lifetime.signal,state:()=>h.state,setState(W,j){if(R(h,y)!==null)return false;let Y=e.currentVersion();return Y===null||(j??K.version)!==Y?false:(h.state=typeof W=="function"?W(h.state):W,h.stateRevision+=1,D(),true)},onCleanup(W){if(typeof W!="function")throw new TypeError("A cleanup must be a function");h.status==="disposed"?_(h,W,h.ended??"unmounted"):h.cleanups.push(W);},run:W=>O(h,W),commit(W){let j=g;g=y;try{return W()}finally{g=j;}},refusal:()=>R(h,y)}}async function O(h,y){let{controller:K,release:z}=ci(h.lifetime.signal);if(!K.signal.aborted)try{await y(w(h,K.signal));}catch(W){K.signal.aborted||v(h,"action",W);}finally{z();}}async function m(h,y,K,z){let{controller:W,release:j}=ci(h.lifetime.signal);h.running={channel:K,controller:W};try{let Y=w(h,W.signal);return await z(e.context(Y,h.registration.plugin),Y),h.status==="disposed"?"ended":W.signal.aborted?"aborted":"ok"}catch(Y){return h.status==="disposed"?"ended":W.signal.aborted?"aborted":(v(h,y,Y),"ended")}finally{j(),h.running?.controller===W&&(h.running=null);}}async function E(h){if(!h.pumping){h.pumping=true;try{for(;h.status==="ready";){let y=h.pending.shift();if(!y)break;if(!h.registration.plugin.onEvent)continue;if(await m(h,"event",ui(y),z=>h.registration.plugin.onEvent?.(z,y))==="ended")break}}finally{h.pumping=false;}}}let B=(h,y)=>{if(h.status==="disposed"||y.generation!==h.generation)return;let K=ui(y),z=h.pending.findIndex(j=>ui(j)===K);if(z>=0){if(h.pending[z].type==="load")return;h.pending[z]=y;}else h.pending.push(y);let W=h.running;W?.channel===K&&W.controller.signal!==g&&W.controller.abort(),h.status==="ready"&&queueMicrotask(()=>{E(h);});};async function C(h,y,K){p+=1;let z={token:Object.freeze({}),key:`${h.id}#${p}`,registration:h,generation:y,lifetime:new AbortController,status:"initializing",ended:null,state:void 0,stateRevision:0,cleanups:[],pending:[],running:null,pumping:false,rendered:null};h.activation=z;try{z.state=h.plugin.createState();}catch(j){v(z,"initialize",j);return}if(h.plugin.initialize&&await m(z,"initialize","initialize",Y=>z.registration.plugin.initialize?.(Y))==="ended")return;let W="aborted";for(let j=0;W==="aborted"&&z.status!=="disposed";j+=1){if(j===El){v(z,"event",new Error(`Document changes superseded the load hook ${El} times`));return}z.pending=[],W=await m(z,"event","document-change",(Y,oe)=>z.registration.plugin.onEvent?.(Y,e.loadEvent(oe.snapshot,K)));}W!=="ok"||z.status==="disposed"||(z.status="ready",D(),E(z));}let F=(h,y)=>S({pluginId:h,generation:n,phase:"definition",error:y}),H=h=>{n=null,h==="unmounted"&&(o=false);for(let y of t.values())y.activation&&M(y.activation,h);D();};return {setPlugins(h){let y=new Map;for(let j of h){let Y=lm(j?.id)?e.validate?.(j):new TypeError(`Invalid plugin id ${JSON.stringify(j?.id)}`);if(Y!=null){j&&typeof j=="object"&&!i.has(j)&&(i.add(j),F(typeof j.id=="string"?j.id:"",Y));continue}let oe=y.get(j.id);oe?oe.push(j):y.set(j.id,[j]);}let K=new Set,z=new Map,W=[];for(let[j,Y]of y){if(Y.length>1){K.add(j),a.has(j)||F(j,new Error(`${Y.length} plugins share the id "${j}"`));continue}let oe=Y[0],pe=t.get(j);if(pe&&Il(pe.plugin)===Il(oe)){pe.plugin=oe,z.set(j,pe);continue}pe&&W.push([pe,"definition-replaced"]),z.set(j,{id:j,plugin:oe,quarantined:false,activation:null});}a=K;for(let[j,Y]of t)z.has(j)||W.push([Y,"removed"]);t=z;for(let[j,Y]of W)j.activation&&M(j.activation,Y);if(n!==null)for(let j of t.values())!j.activation&&!j.quarantined&&C(j,n,"attached");D();},setGrants(h){let y=new Map([...t.keys()].map(z=>[z,L(z)]));r=h??{},s.clear();let K=false;for(let z of t.values()){let W=L(z.id),j=y.get(z.id);if(Sl(j,W)){s.get(z.id).grant=j;continue}K=true;let Y=z.activation;Y&&B(Y,e.grantsEvent(e.snapshot(z.id,Y.generation),W));}K&&D();},grant:L,open(h){if(n===h)return;n!==null&&H("document-replaced"),n=h;let y=o?"replaced":"loaded";o=true;for(let K of t.values())K.quarantined=false,C(K,h,y);D();},close:H,generation:()=>n,notify(h){if(h.generation===n){for(let y of t.values())y.activation&&B(y.activation,h);D();}},touch:D,activations:()=>c,subscribe(h){return f.add(h),()=>{f.delete(h);}},guard(h,y,K,z){let W=t.get(h)?.activation;if(W?.status!=="ready")return z;try{return K(A(W).context)}catch(j){return queueMicrotask(()=>v(W,y,j)),z}},async invoke(h,y,K){let z=t.get(h)?.activation;if(z?.status!=="ready")return {ok:false,reason:"plugin-unavailable"};let{controller:W,release:j}=ci(z.lifetime.signal),Y=w(z,W.signal);try{return {ok:!0,value:await K(e.context(Y,z.registration.plugin))}}catch(oe){let pe=Y.refusal();return pe?{ok:false,reason:pe}:(v(z,y,oe),{ok:false,reason:"failed"})}finally{j();}},fail(h,y,K){let z=t.get(h)?.activation;z&&v(z,y,K);}}}var um={"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"},cm={"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 zn(e,t=um[e]){return {ok:false,failure:{code:e,message:t}}}function fn(e){let t=e.refusal();return t?zn(t):null}function pi(e,t,n){return {deny(o){let r=e.refusal();if(r)return r;if(Ge(o))return o.startsWith(`plugin:${e.pluginId}/`)?null:"permission-denied";let s=t();return !Cl(s,o)||rt[o].mutatesDocument&&!wl(s)?"permission-denied":null},subscribe:n}}function pm(e,t,n){return !n()&&e.some(o=>o.aborted)?Promise.resolve(null):new Promise((o,r)=>{let s=()=>{n()||(i(),o(null));},i=()=>{for(let a of e)a.removeEventListener("abort",s);};for(let a of e)a.addEventListener("abort",s,{once:true});t.then(a=>{i(),o(a);},a=>{i(),r(a);});})}function Rl(e,t,n,o){let r=async g=>{let c=fn(e);if(c)return c;let x=t.handle();if(!x)return zn("plugin-unavailable");let S=false,L=await pm([e.signal,e.lifetimeSignal],t.admit(x,()=>{let A=fn(e);return A?{refused:A}:(S=true,{value:g(x)})}),()=>S);return L?L.ok?"refused"in L.value?L.value.refused:L.value.value:fn(e)??zn(L.code):fn(e)??zn("aborted")},s={version:()=>r(g=>({ok:true,version:g.version()})),readContent:g=>r(c=>c.readContent(g)),findText:g=>r(c=>c.findText(g)),validateEdits:g=>r(c=>t.readOnlyRefusal(c)??c.validateEdits(g))},i=g=>fn(e)??(di(n(),g)?null:zn("permission-denied")),a=di(n(),"separate")?{async applyEdits(g){let c=i(g.history);return c||r(x=>t.applyEdits(x,g,()=>i(g.history),S=>e.commit(S)))}}:null,f={getDescriptor:g=>o.getDescriptor(g),getState:(g,c)=>o.getState(g,c),subscribe:g=>o.subscribe(g),execute:async(g,c)=>fn(e)??o.execute(g,c)},u=async(g,c)=>{let x=await r(S=>S.version()===g?.expectVersion?c(S,g.focus===true):"stale-version");return x===null?{ok:true}:typeof x=="object"?x:{ok:false,failure:{code:x,message:cm[x]}}};return {read:s,commands:f,edits:a,navigation:{goToSlide:(g,c)=>u(c,(x,S)=>t.navigator.goToSlide(x,g,S)),selectShape:(g,c)=>u(c,(x,S)=>t.navigator.selectShape(x,g,S)),selectText:(g,c)=>u(c,(x,S)=>t.navigator.selectText(x,g,S))}}}function mi(e,t){return e?.scoped(t)??rn}var Ml=new WeakMap,mm=/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9])?$/,fm=new Set(["left","right","bottom"]),Al=e=>e!==null&&typeof e=="object"?Object.freeze({...e}):e;function gm(e){return Array.isArray(e?.shortcuts)?Object.freeze({...e,shortcuts:Object.freeze([...e.shortcuts])}):Al(e)}function hm(e){let t={...e};t.panel!==void 0&&(t.panel=Al(t.panel)),Array.isArray(t.commands)&&(t.commands=Object.freeze(t.commands.map(gm))),Array.isArray(t.toolbar)&&(t.toolbar=Object.freeze([...t.toolbar]));let n=Object.freeze(t),o=Object.freeze(n.revision===void 0?{id:n.id}:{id:n.id,revision:n.revision});return Ml.set(o,n),o}function Ll(e){return e!==null&&typeof e=="object"?Ml.get(e)??null:null}function kl(e){return typeof e=="function"||e!==null&&typeof e=="object"}var xm=/^f([1-9]|1[0-2])$/i;function bm(e){let t=tn(e);if(t===null)return false;let n=t.split("+"),o=n[n.length-1];return n.includes("Mod")||n.includes("Alt")||xm.test(o)}function fi(e){return e===void 0||typeof e=="function"}function Ol(e){if(typeof e.createState!="function")return new TypeError("createState must be a function");if(!fi(e.initialize)||!fi(e.onEvent))return new TypeError("initialize and onEvent must be functions");if(e.overlay!==void 0&&!kl(e.overlay))return new TypeError("overlay must be a component");let t=e.panel;if(t!==void 0&&(typeof t?.title!="string"||!fm.has(t.placement)||!kl(t.render)||t.preferredSize!==void 0&&!(Number.isFinite(t.preferredSize)&&t.preferredSize>0)))return new TypeError("panel needs a title, a left, right or bottom placement and a renderer");let n=e.commands??[];if(!Array.isArray(n))return new TypeError("commands must be an array");let o=new Set;for(let s of n){if(!mm.test(s?.id??""))return new TypeError(`Invalid command id ${JSON.stringify(s?.id)}`);if(o.has(s.id))return new TypeError(`Duplicate command id "${s.id}"`);if(o.add(s.id),typeof s.label!="string"||typeof s.mutatesDocument!="boolean"||typeof s.execute!="function"||!fi(s.getState))return new TypeError(`Command "${s.id}" needs a label, mutatesDocument and execute`);let i=s.shortcuts??[];if(!Array.isArray(i)||i.some(a=>!bm(a)))return new TypeError(`Command "${s.id}" has an invalid shortcut`)}let r=e.toolbar??[];return !Array.isArray(r)||r.some(s=>!o.has(s))?new TypeError("toolbar may only list the plugin\u2019s own command ids"):null}var Pm=Object.freeze({enabled:true});function ym(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 vm(e){let t=e;return t&&typeof t.ok=="boolean"?e:{ok:true,status:"executed"}}function Sm(e,t){return e===t||!!e&&!!t&&e.id===t.id&&e.version===t.version}function Ao(e){try{return e.version()}catch{return null}}function Dl(e){let t,n=null,o=null,r=false,s=0,i=null,a={version:"",readOnly:false,selection:null,layout:null},f=new WeakMap,u=new WeakMap,p=0,g=m=>{let E=u.get(m);return E===void 0&&(p+=1,E=p,u.set(m,E)),E},c=new WeakSet,x=new Set,S=m=>{if(!t){console.error(`[PptxEditor] plugin "${m.pluginId}" failed (${m.phase})`,m.error);return}try{t(m);}catch(E){console.error("[PptxEditor] onPluginError threw",E);}},L=()=>e.commands(),A=m=>{let E=()=>D.grant(m.pluginId);if(m.signal!==m.lifetimeSignal)return pi(m,E,D.subscribe);let B=f.get(m.activation);return B||(B=pi(m,E,D.subscribe),f.set(m.activation,B)),B},G=m=>{let E=m.pluginId,B=Rl(m,e,()=>D.grant(E),mi(L(),A(m))),C=e.geometry();return {pluginId:E,snapshot:m.snapshot,get state(){return m.state()},signal:m.signal,lifetimeSignal:m.lifetimeSignal,read:B.read,commands:B.commands,edits:B.edits,geometry:C&&m.snapshot.layout?.id===C.layout.id?C:null,navigation:B.navigation,setState:(F,H)=>m.setState(F,H),onCleanup:F=>m.onCleanup(F),run:F=>m.run(H=>F(G(H)))}},D=Tl({context:m=>G(m),snapshot:(m,E)=>({generation:E,version:a.version,readOnly:a.readOnly,grant:D.grant(m),selection:a.selection,layout:a.layout}),currentVersion:()=>n&&D.generation()!==null?Ao(n):null,loadEvent:(m,E)=>({type:"load",generation:m.generation,version:m.version,reason:E}),grantsEvent:(m,E)=>({type:"grants-change",generation:m.generation,grant:E}),validate:Ol,report:S}),R=m=>D.notify(m),_=()=>{let m=D.generation(),E=n?Ao(n):null;!m||!E||E===a.version||(a.version=E,R({type:"document-change",generation:m,version:E}),a.layout&&a.layout.version!==E&&(a.layout=null,R({type:"layout-change",generation:m,layout:null})));},M=()=>{if(!r||!n){o?.(),o=null;return}if(!o){a.version=Ao(n)??a.version;try{o=n.onUpdate(_);}catch(m){console.error("[PptxEditor] observing presentation changes for plugins failed",m);}}},v=()=>{o?.(),o=null,n=null;},w=(m,E)=>D.guard(m,"command-state",B=>ym(E.getState?E.getState(B):Pm),{enabled:false,disabledReason:Be("plugin-unavailable",{translate:e.translate})}),O=async(m,E)=>{let B=await D.invoke(m,"command",F=>E.execute(F));if(B.ok)return vm(B.value);let C=B.reason==="failed"?"command-failed":B.reason;return {ok:false,failure:Be(C,{translate:e.translate})}};return {setPlugins(m){let E=[];for(let B of m??[]){let C=Ll(B);if(C){E.push(C);continue}if(B!==null&&typeof B=="object"){if(c.has(B))continue;c.add(B);}S({pluginId:typeof B?.id=="string"?B.id:"",generation:D.generation(),phase:"definition",error:new TypeError("Plugins must be created with definePptxPlugin")});}r=E.length>0,M(),D.setPlugins(E);},setGrants:m=>D.setGrants(m),setReporter(m){t=m;},open(m){v(),n=m,a.version=Ao(m)??"",a.layout=null,a.selection=null,M(),s+=1,D.open(`presentation-${s}`);},close(m){v(),a.layout=null,D.close(m);},generation:()=>D.generation(),version:()=>a.version,selectionChanged(m){if(JSON.stringify(m)===JSON.stringify(a.selection))return;a.selection=m;let E=D.generation();E&&R({type:"selection-change",generation:E,version:a.version,selection:m});},modeChanged(m){if(m===a.readOnly)return;a.readOnly=m;let E=D.generation();E&&R({type:"mode-change",generation:E,readOnly:m});},layoutChanged(m){let E=m&&m.version===a.version?m:null;if(Sm(E,a.layout))return;a.layout=E;let B=D.generation();B&&R({type:"layout-change",generation:B,layout:E});},layoutId:()=>D.generation()===null?null:a.layout?.id??null,geometryChanged:()=>D.touch(),activations:()=>D.activations(),subscribe:m=>D.subscribe(m),commandStore(m){let E=f.get(m.activation);return E?mi(L(),E):rn},syncCommands(){let m=L();if(!m)return;let E=[],B=[],C=new Map,F=[];for(let h of D.activations()){let y=h.plugin;F.push(`${h.pluginId}:${g(y)}:${g(h.activation)}`);for(let K of y.commands??[]){let z=`plugin:${h.pluginId}/${K.id}`,W=[];for(let j of K.shortcuts??[]){let Y=tn(j),oe=ma.has(Y)?"a built-in command":pa.has(Y)?"text editing":C.get(Y);if(!oe){C.set(Y,z),W.push({chord:j,args:null});continue}let pe=`${h.pluginId}\0${Y}`;x.has(pe)||(x.add(pe),S({pluginId:h.pluginId,generation:h.generation,phase:"definition",error:new Error(`Shortcut ${j} of ${z} is already used by ${oe}; it was not bound`)}));}E.push({descriptor:Object.freeze({id:z,label:K.label,mutatesDocument:K.mutatesDocument,shortcuts:Object.freeze(W)}),state:()=>w(h.pluginId,K),execute:()=>O(h.pluginId,K)});}for(let K of y.toolbar??[])B.push(`plugin:${h.pluginId}/${K}`);}let H=F.join("|");if(H===i){m.refresh();return}i=H,m.setPluginCommands(E,B);},guard:(m,E,B,C)=>D.guard(m,E,B,C),fail:(m,E,B)=>D.fail(m,E,B)}}var Lo=9525,Fl=new WeakMap,zl=0;function Cm(e){let t=Fl.get(e);return t||(zl+=1,t=`slide-layout-${zl}`,Fl.set(e,t)),t}function Hl(e,t){if(!e||t===null||e.version!==t)return null;let n=e.snapshot.slides[e.slideIndex];return n?{id:Cm(e),version:t,slideId:n.id,slide:e.slideIndex+1,zoom:e.scale,width:e.frame.width,height:e.frame.height}:null}function wm(e){let t=e;return !!t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}function Im(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 i=r.width/n.width,a=r.height/n.height,f=r.left-s.left-t.clientLeft+t.scrollLeft,u=r.top-s.top-t.clientTop+t.scrollTop;return {x:f+o.x*i,y:u+o.y*a,width:o.width*i,height:o.height*a}}function Kl(e,t,n,o,r,s){let i=a=>r()?Im(n,o,t.frame,a):null;return {layout:e,toOverlayRect(a){let f=a?.rect;return wm(f)?a.space==="slide-px"?i(f):a.space!=="slide-emu"?null:i({x:f.x/Lo,y:f.y/Lo,width:f.width/Lo,height:f.height/Lo}):null},getShapeRect(a){let f=t.snapshot.slides[t.slideIndex],u=f&&typeof a=="string"?Re(f.shapes,a):null,p=u?wr(t.frame,u):null;return p?i(p):null},getPositionAtPoint(a,f){if(!r())return null;let u=s(t.frame,a,f);return u?{...u,version:e.version,layoutId:e.id}:null}}}var _l=Object.freeze([]);function Wl(e){let t=useRef(e);t.current=e;let n=useRef(null),[o]=useState(()=>Dl({...e.access,translate:R=>t.current.t(R),geometry:()=>n.current})),r=(e.plugins?.length??0)>0;useLayoutEffect(()=>{o.setReporter(e.onPluginError);}),useLayoutEffect(()=>{o.modeChanged(e.readOnly);},[o,e.readOnly]),useLayoutEffect(()=>{o.setGrants(e.pluginGrants);}),useLayoutEffect(()=>{o.setPlugins(e.plugins);},[o,e.plugins]),useEffect(()=>()=>o.close("unmounted"),[o]),useEffect(()=>{if(!(!e.handle||e.access.handle()!==e.handle))return o.open(e.handle),()=>o.close("document-replaced")},[o,e.access,e.handle]),useEffect(()=>(o.syncCommands(),o.subscribe(()=>o.syncCommands())),[o]);let s=useSyncExternalStore(o.subscribe,o.activations,()=>_l);useEffect(()=>{r&&o.selectionChanged(e.selection);},[o,r,e.selection]);let i=useRef(null),[a,f]=useState(null),u=useCallback(R=>{i.current=R,R||o.layoutChanged(null),t.current.plugins?.length&&f(R);},[o]);useEffect(()=>{r&&f(i.current);},[r]);let[p,g]=useState(null),[c,x]=useState(0),S=a?.canvas??null;useEffect(()=>{if(!r||!S||!p)return;let R=0,_=()=>{R||(R=requestAnimationFrame(()=>{R=0,x(v=>v+1);}));},M=typeof ResizeObserver>"u"?null:new ResizeObserver(_);return M?.observe(S),M?.observe(p),window.addEventListener("resize",_),()=>{R&&cancelAnimationFrame(R),M?.disconnect(),window.removeEventListener("resize",_);}},[r,S,p]);let L=useSyncExternalStore(o.subscribe,o.version,o.version),A=useMemo(()=>r&&!e.reviewing?Hl(a,L):null,[r,e.reviewing,a,L]),G=useMemo(()=>A&&a&&p?Kl(A,a,a.canvas,p,()=>o.layoutId()===A.id&&i.current===a&&a.canvas.isConnected,(R,_,M)=>t.current.pointAt(R,_,M)):null,[o,A,a,p,c]);n.current=G,useEffect(()=>{o.layoutChanged(A);},[o,A]),useEffect(()=>{o.geometryChanged();},[o,G]);let D=useCallback(()=>{u(null),o.close("document-replaced");},[o,u]);return {host:o,managed:r,activations:r?s:_l,overlayLayerRef:g,beginLoad:D,presentFrame:u}}function Gl(e,t=12){return {visible:e.slice(0,t),overflow:Math.max(0,e.length-t)}}function $l(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 i=o.get(s)??{visible:[],overflow:0};i.visible.length<n?i.visible.push(r):i.overflow+=1,o.set(s,i);}return o}function Ul(e,t,n,o=24){let r=new Map,s=0;for(let i of e){let a=i.state.cursor;if(a?.slideId!==t||!a.shapeId||!n.has(a.shapeId))continue;let f=r.get(a.shapeId);f?(f.count+=1,i.cursorMovedAt>f.peer.cursorMovedAt&&(f.peer=i)):r.size<o?r.set(a.shapeId,{shapeId:a.shapeId,peer:i,count:1}):s+=1;}return {visible:[...r.values()],overflow:s}}var Zl=new Intl.Segmenter(void 0,{granularity:"word"});function hi(e,t,n){return n==="word"?Em(e,t):Tm(e,t)}function Em(e,t){let n=xi(e,t),o=[...Zl.segment(e)],r=o.find(s=>n>=s.index&&n<s.index+s.segment.length)??o[o.length-1];return r?{start:r.index,end:r.index+r.segment.length}:{start:n,end:n}}function Tm(e,t){let n=xi(e,t),o=e.lastIndexOf(`
|
|
2
|
-
`,Math.max(0,n-1))+1,r=e.indexOf(`
|
|
3
|
-
`,n);return {start:o,end:r===-1?e.length:r}}function Xl(e,t){return t.start<e.start?{anchor:e.end,focus:t.start}:t.end>e.end?{anchor:e.start,focus:t.end}:{anchor:e.start,focus:e.end}}function xi(e,t){return Number.isFinite(t)?Math.max(0,Math.min(e.length,Math.trunc(t))):0}function ql(e,t){return e.shapeId===t.shapeId&&e.position===t.position&&e.lineIndex===t.lineIndex}function bi(e,t){return e[Hn(e,t)]?.caretStops.find(o=>o.position===t.position)?.x}function Vl(e,t,n,o){if(e.length===0)return {position:t.position,lineIndex:0};let r=Hn(e,t),s=r+(n==="up"?-1:1),i=e[s];if(!i)return {position:t.position,lineIndex:r};let a=o??bi(e,t);return a===void 0?{position:i.start,lineIndex:s}:{position:i.caretStops.reduce((u,p)=>u===null||Math.abs(p.x-a)<Math.abs(u.x-a)?p:u,null)?.position??i.start,lineIndex:s}}function Fo(e,t,n){let o=Hn(e,t),r=e[o];return r?{position:n==="start"?r.start:r.end,lineIndex:o}:{position:t.position,lineIndex:o}}function Yl(e,t,n){let o=xi(e,t),r=[...Zl.segment(e)].filter(i=>i.isWordLike).flatMap(i=>[i.index,i.index+i.segment.length]),s=n<0?r.filter(i=>i<o):r.filter(i=>i>o);return s.length===0?n<0?0:e.length:n<0?Math.max(...s):Math.min(...s)}function Hn(e,t){let n=t.lineIndex;if(n!==void 0&&n>=0&&n<e.length&&t.position>=e[n].start&&t.position<=e[n].end)return n;let o=-1;for(let r=0;r<e.length;r+=1){let s=e[r];t.position>=s.start&&t.position<=s.end&&(o=r);}return o===-1?Math.max(0,e.length-1):o}var Dm="application/vnd.openxmlformats-officedocument.presentationml.presentation";function Fm(e,t){return `${(e??"presentation.pptx").replace(/\.pptx$/i,"")}-slide-${t+1}.png`}function Ql(e,t,n){let o=new Blob([new Uint8Array(e)],{type:n}),r=URL.createObjectURL(o),s=document.createElement("a");s.href=r,s.download=t,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(r);}function ed(e){return new Promise((t,n)=>{let o=new FileReader;o.onload=()=>t(o.result),o.onerror=()=>n(o.error??new Error("failed to read the file")),o.readAsDataURL(e);})}function zm(e){return new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>n(new Error("failed to decode the image")),o.src=e;})}var td=8*1024*1024,Pi={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"},Hm=530,zo=9,yi={bold:false,italic:false,underline:"none",fontSizePt:24,color:"#111827",fontFamily:"Arial"};function Km({i18n:e,...t}){return jsx(Jt,{i18n:e,children:jsx(Nm,{...t,i18n:e})})}function Nm({file:e,fonts:t,clientId:n,collaboration:o,className:r,fileName:s,initialSlide:i,onReady:a,onChange:f,onError:u,onSave:p,onSaveRequest:g,readOnly:c=false,toolbar:x,showToolbar:S=true,i18n:L,plugins:A,pluginGrants:G,onPluginError:D}){let{t:R}=Q(),_=R("errors.decodeSlideImage"),M=o?.clientId??n,v=o?.initialUpdate,w=o?.onReplica,O=o?.presence,m=useRef(null),E=useRef(null),B=useRef(0),[C]=useState(En),F=C.store,H=useRef(null),[h]=useState(()=>{let l=Js(()=>{l.busy()||(H.current=null),C.refresh();});return l}),y=useRef(null),K=useRef(null),z=useRef(()=>null),W=useCallback(async(l,d)=>{let b=P=>({ok:false,code:"document-replaced",error:new Error(P)});if(m.current!==l)return b("Presentation is no longer open");try{return {ok:!0,value:await h.run(()=>{if(m.current!==l)throw new ut;if(de.current||Ce.current)throw new Ko;return d()})}}catch(P){if(P instanceof ut)return b("Presentation changed while flushing input");if(P instanceof xt)return {ok:false,code:"input-failed",error:P.cause};if(P instanceof Ko)return {ok:false,code:"input-failed",error:P};throw P}},[h]),j=useCallback(async(l,d)=>{let b=await W(l,d);if(!b.ok)throw b.error;return b.value},[W]),Y=useCallback(l=>j(l,()=>{}),[j]),oe=useRef(c),pe=useCallback(l=>oe.current?{ok:false,version:l.version(),failure:{code:"read-only",message:"The editor is read-only"}}:null,[]),$t=useRef(i),Ut=useRef(a),Nn=useRef(f),xn=useRef(u),wi=useRef(null),Ve=useRef(null),Ii=useRef(null),Bn=useRef(null),Ei=useRef(null),[sd,ld]=Pl((A?.length??0)>0),[dd,Ti]=useState(false),ct=useRef(null),Ce=useRef(null),[No,Ye]=useState(null),de=useRef(null),Me=useRef(null),Zt=useRef(new Map),Bo=Xm(t),[U,Ri]=useState(null),[Ie,Pe,Rt]=at(null),[We,Ee,jo]=at(null),[_o,Oe]=useState(null),[pt,ze]=useState(null),[ud,ki,Wo]=at(yi),[Go,cd,Mi]=at("fit"),[Xt,lt,Ai]=at("select"),[Li,$o]=useState(null),[bn,pd]=useState({width:0,height:0}),[Uo,Zo]=useState(null),[Oi,jn]=useState(false),[Xo,Di]=useState(null),[kt,qo]=useState([]),[Vo,Yo]=useState(false),[_n,Jo,md]=at([]),[Fi,Wn,fd]=at(false),zi=useRef(null),ae=ts(m.current,c?[]:_n,U?.snapshot,U?.slideIndex??0),[gd,hd]=useState(null),xd=useCallback(l=>gn(l,m,Zt,_),[_]);useEffect(()=>{ae.reviewing&&(Pe(null),Ee(null),de.current=null,Ce.current=null,Ye(null),Oe(null),ze(null));},[ae.reviewing]),useEffect(()=>{c&&(lt("select"),Wn(false),de.current=null,Ce.current=null,Me.current=null,Ye(null),Oe(null),ze(null));},[c]),Ut.current=a,oe.current=c,$t.current=i,Nn.current=f,xn.current=u,E.current=U;let Pn=useRef(ae.reviewing);Pn.current=ae.reviewing;let be=useCallback(l=>{let d=l instanceof Error?l:new Error(String(l));Zo(d.message),xn.current?.(d);},[]),fe=useCallback((l,d=false,b=false,P)=>{let k=m.current;if(!k)return null;try{ct.current=null;let I=k.snapshot(),T=Zm(l??E.current?.slideIndex??0,I.slides.length),N=new Map;for(let ne=0;ne<I.slides.length;ne+=1){let Ae=I.slides[ne],et=E.current?.thumbnails.get(Ae.id);ne!==T&&et&&!b&&Ae.id!==P?N.set(Ae.id,et):ne!==T&&N.set(Ae.id,k.layoutSlide(ne));}let X=I.slides.length>0?k.layoutSlide(T):null;X&&N.set(I.slides[T].id,X);let J={snapshot:I,version:k.version(),slideIndex:T,frame:X,thumbnails:N},V=I.slides[T];Pe(ne=>ne&&V&&Re(V.shapes,ne.shapeId)?ne:null),Ee(ne=>ne&&V?.id===ne.slideId&&Re(V.shapes,ne.shapeId)?ne:null);let ue=de.current;ue&&(!V||V.id!==ue.slideId||ue.kind!=="textBox"&&ue.kind!=="shapeInsert"&&!Re(V.shapes,ue.shapeId))&&(de.current=null,Me.current=null,Oe(null),ze(null));let Se=Ce.current;return Se&&!_a(V,Se)&&(Ce.current=null,Ye(null)),E.current=J,Ri(J),Jo(k.listProposals()),Zo(null),d&&Nn.current?.(I),J}catch(I){return be(I),null}},[be]),Hi=useCallback(()=>{fe(void 0,false,true);},[fe]),Gn=useCallback((l,d,b,P=k=>k())=>{let k=b?.()??null;if(k)return k;let I=pe(l);if(I)return I;let T=P(()=>l.applyEdits(d));return T.ok&&T.applied&&fe(void 0,true,true),T},[pe,fe]),$n=useCallback(()=>{H.current=null,ct.current=null,Ce.current=null,de.current=null,Me.current=null,Ye(null),Pe(null),Ee(null),Oe(null),ze(null);},[]),Mt=useCallback((l,d)=>{$n();let b=fe(l);return b&&d&&Ve.current?.focus(),b},[$n,fe]),Qo=useCallback(l=>{let d=E.current;return !d||!Number.isInteger(l)||l<1||l>d.snapshot.slides.length?false:Mt(l-1,true)!==null},[Mt]),Ki=useCallback(l=>{let d=m.current,b=E.current;if(!d||!b||!Number.isInteger(l.slide)||!Number.isInteger(l.start)||!Number.isInteger(l.end)||l.start<0||l.end<l.start)return false;let P=b.snapshot.slides[l.slide-1];if(!(P?Re(P.shapes,l.shapeId):null)?.textStories.some(I=>I.id===l.storyId))return false;try{let I=d.story(l.storyId);return l.end>I.length||!Mt(l.slide-1,!1)?!1:(Pe({shapeId:l.shapeId,storyId:l.storyId,anchor:l.start,focus:l.end}),Ve.current?.focus(),!0)}catch{return false}},[Mt]),Ni=useCallback((l,d,b)=>{let P=E.current?.snapshot.slides.findIndex(T=>T.id===l)??-1;if(P<0)return;let k=fe(P),I=k?.snapshot.slides[k.slideIndex];Pe(null),Ee(d&&I&&Re(I.shapes,d)?{slideId:l,shapeId:d}:null),b&&ae.select(b),ae.setEnabled(true);},[fe,ae.select,ae.setEnabled]),qt=useCallback(()=>{try{Jo(m.current?.listProposals()??[]);}catch(l){be(l);}},[be]),bd=useCallback((l,d)=>{let b=m.current;if(!b)throw new Error("Presentation is no longer open");try{return b.acceptProposal(l,{force:d}),fe(void 0,!0,!0),"accepted"}catch(P){if(qt(),P instanceof StaleProposalError)return "stale";throw P}},[fe,qt]),Pd=useCallback(l=>{let d=m.current?.rejectProposal(l)??false;return qt(),d},[qt]),Bi={goToSlide(l,d,b){let P=vi(l,d?.slideId);return P?Mt(P.index,b)?null:"layout-unavailable":"missing-target"},selectShape(l,d,b){let P=vi(l,d?.slideId);return !P||!Re(P.slide.shapes,d.shapeId)?"missing-target":Pn.current?"unsupported":Mt(P.index,false)?(Ee({slideId:P.slide.id,shapeId:d.shapeId}),b&&Ve.current?.focus(),null):"layout-unavailable"},selectText(l,d,b){let P=vi(l,d?.slideId),k=P?Re(P.slide.shapes,d.shapeId):null;if(!P||!k?.textStories.some(X=>X.id===d.storyId))return "missing-target";let{anchor:I,focus:T}=d;if(!Number.isInteger(I)||!Number.isInteger(T)||I<0||T<0)return "missing-target";let N=l.story(d.storyId).length;return I>N||T>N?"missing-target":Pn.current?"unsupported":Mt(P.index,false)?(Pe({shapeId:k.id,storyId:d.storyId,anchor:I,focus:T}),b&&Ve.current?.focus(),null):"layout-unavailable"}},At=useRef({admit:W,applyBatch:Gn,readOnlyRefusal:pe,pluginNavigator:Bi});At.current={admit:W,applyBatch:Gn,readOnlyRefusal:pe,pluginNavigator:Bi};let[yd]=useState(()=>({handle:()=>m.current,admit:(l,d)=>At.current.admit(l,d),readOnlyRefusal:l=>At.current.readOnlyRefusal(l),applyEdits:(l,d,b,P)=>At.current.applyBatch(l,d,b,P),commands:()=>C,navigator:{goToSlide:(...l)=>At.current.pluginNavigator.goToSlide(...l),selectShape:(...l)=>At.current.pluginNavigator.selectShape(...l),selectText:(...l)=>At.current.pluginNavigator.selectText(...l)}})),[vd,ji]=useState(null),Sd=useMemo(()=>{let l=U?.snapshot.slides[U.slideIndex];if(!U||!l)return null;let d={slideId:l.id,slide:U.slideIndex+1};if(Ie){let{shapeId:b,storyId:P,anchor:k,focus:I}=Ie;return {...d,target:{kind:"text",shapeId:b,storyId:P,anchor:k,focus:I}}}return We?.slideId===l.id?{...d,target:{kind:"shape",shapeId:We.shapeId}}:{...d,target:{kind:"slide"}}},[U,Ie,We]),mt=Wl({plugins:A,pluginGrants:G,onPluginError:D,access:yd,commands:C,readOnly:c,handle:vd,reviewing:ae.reviewing,selection:Sd,pointAt:(l,d,b)=>E.current?.frame===l?z.current(d,b):null,t:R}),_i=mt.beginLoad,er=mt.presentFrame;useEffect(()=>{let l=false,d=null,b=[],P=()=>{};if(_i(),ji(null),m.current?.dispose(),m.current=null,B.current+=1,h.reset(),H.current=null,Di(null),E.current=null,Ri(null),Pe(null),Ee(null),Oe(null),ze(null),Ye(null),lt("select"),Yo(false),Jo([]),Wn(false),de.current=null,Ce.current=null,ct.current=null,Me.current=null,Zo(null),y.current=null,Zt.current.clear(),!!e)return jn(true),Promise.all([initWasm(),tf(Bo)]).then(([,k])=>{if(b=k,l){nd(b);return}try{d=openPresentation(e,{clientId:M,fonts:Bo,initialUpdate:v}),m.current=d,P=d.onUpdate((N,X)=>{X==="remote"&&fe(void 0,!0,!0);});let I=$t.current;fe(typeof I=="number"&&Number.isInteger(I)?I-1:0),jn(!1),Di(d),ji(d);let T=d;Ut.current?.({clearSelection:$n,commands:F,goToSlide:Qo,handle:T,refresh:Hi,refreshProposals:qt,flushPendingInput:()=>Y(T),getPositionAtPoint:(N,X)=>m.current===T?z.current(N,X):null,save:()=>{if(m.current!==T)throw new Error("Presentation is no longer open");if(h.busy()||de.current||Ce.current)throw new Error("Await flushPendingInput before saving pending input");return T.save()},selectText:Ki,focus:()=>Ve.current?.focus(),version:()=>j(T,()=>T.version()),readContent:N=>j(T,()=>T.readContent(N)),findText:N=>j(T,()=>T.findText(N)),validateEdits:N=>j(T,()=>pe(T)??T.validateEdits(N)),applyEdits:async N=>{let X=pe(T);return X||j(T,()=>Gn(T,N))}});}catch(I){jn(false),be(I);}},k=>{l||(jn(false),be(k));}),()=>{l=true,P(),d?.dispose(),m.current===d&&(m.current=null),nd(b);}},[j,Gn,_i,M,v,$n,F,h,e,Y,Qo,Bo,Hi,pe,fe,be,Ki,lt,Pe,Ee]),useEffect(()=>{if(!(!w||!Xo))return w(Xo),()=>w(null)},[w,Xo]),useEffect(()=>$o(null),[Xt]),useEffect(()=>{if(!O){qo([]);return}return qo(O.peers),O.onPresence(qo)},[O]),useEffect(()=>{let l=Ii.current;if(!l)return;let d=()=>pd({width:l.clientWidth,height:l.clientHeight});d();let b=new ResizeObserver(d);return b.observe(l),()=>b.disconnect()},[]);let Cd=useMemo(()=>!U?.frame||bn.width<=0||bn.height<=0?1:Math.min((bn.width-40)/U.frame.width,(bn.height-40)/U.frame.height,1),[U?.frame,bn]),ge=Go==="fit"?Cd:Go;useEffect(()=>{let l=Bn.current,d=U,b=d?.frame;if(!l||!d||!b)return;let P=l.getContext("2d");if(!P)return;let k=window.devicePixelRatio||1;er(null),sizeCanvasForSlide(l,b,k,ge);let I=false;return paintSlide(Um(P,()=>!I),b,k,ge,{resolveImage:T=>gn(T,m,Zt,_)}).then(()=>{if(I)return;let{snapshot:T,slideIndex:N,version:X}=d;er({frame:b,snapshot:T,slideIndex:N,version:X,scale:ge,canvas:l});},T=>{I||be(T);}),()=>{I=true;}},[_,U?.frame,er,be,ge]);let ot=useMemo(()=>{if(!U?.frame||!We)return null;let l=U.snapshot.slides[U.slideIndex];return !l||l.id!==We.slideId?null:Re(l.shapes,We.shapeId)},[U,We]),Lt=useMemo(()=>U?.frame&&ot?jt(U.snapshot,U.frame,ot):null,[U,ot]),yn=useMemo(()=>{if(!U?.frame||!Ie||Lt)return null;let l=U.snapshot.slides[U.slideIndex],d=l?Re(l.shapes,Ie.shapeId):null;return d?jt(U.snapshot,U.frame,d):null},[U,Lt,Ie]),Ke=U?.snapshot.slides[U.slideIndex],vn=Ke?.id,tr=useMemo(()=>{if(Ke){if(We?.slideId===Ke.id)return We.shapeId;if(Ie)return Sr(Ke,Ie.shapeId)?.id}},[Ke,Ie,We]);useEffect(()=>{O&&O.setCursor(vn?{slideId:vn,...tr?{shapeId:tr}:{}}:null);},[O,vn,tr]),useEffect(()=>()=>{O?.setCursor(null);},[O]);let Sn=useMemo(()=>Gl(kt),[kt]),nr=useMemo(()=>{if(!U?.frame||!Ke)return {visible:[],overflow:0};let l=ja(Ke.shapes),d=Ul(kt,Ke.id,l),b=[],P=d.overflow;for(let k of d.visible){let I=l.get(k.shapeId);if(!I)continue;let T=jt(U.snapshot,U.frame,I);T?b.push({peer:k.peer,peerCount:k.count,shapeId:k.shapeId,bounds:T}):P+=k.count;}return {visible:b,overflow:P}},[Ke,U,kt]),wd=useMemo(()=>{let l=new Set(U?.snapshot.slides.map(d=>d.id));return $l(kt,l)},[U,kt]);useEffect(()=>{let l=m.current;if(!(!l||!Ie))try{let d=l.story(Ie.storyId);ki(sl(d,Ie.anchor,Ie.focus,yi));}catch(d){be(d);}},[U,be,Ie]);let Id=l=>{Qo(l+1);},Ed=(l,d,b)=>{let P=m.current,k=E.current;if(!P||!k?.frame||oe.current)return;let I=k.snapshot.slides.find(ue=>ue.id===l);if(!I)return;let T=Math.abs(b.x-d.x)>=6||Math.abs(b.y-d.y)>=6,N=T?Math.abs(b.x-d.x):k.frame.width*.36,X=T?Math.abs(b.y-d.y):k.frame.height*.12,J=Math.max(0,Math.min(T?Math.min(d.x,b.x):d.x,k.frame.width-N)),V=Math.max(0,Math.min(T?Math.min(d.y,b.y):d.y,k.frame.height-X));try{let ue=P.addTextBox(I.id,{name:R("objects.defaultTextBoxName"),rect:{x:Math.round(J*k.snapshot.widthEmu/k.frame.width),y:Math.round(V*k.snapshot.heightEmu/k.frame.height),width:Math.round(Math.max(12,N)*k.snapshot.widthEmu/k.frame.width),height:Math.round(Math.max(12,X)*k.snapshot.heightEmu/k.frame.height)},text:"",style:Wo.current}),Se=fe(void 0,!0,!1,I.id);lt("select"),Oe(null),ze(null),de.current=null,Me.current=null;let ne=Se?.snapshot.slides[Se.slideIndex]?.shapes.find(et=>et.id===ue.shapeId);ne&&Ee(null);let Ae=ne?.textStories[0];Ae&&(Pe({shapeId:ne.id,storyId:Ae.id,anchor:0,focus:0,focusLine:0}),Ve.current?.focus());}catch(ue){throw be(ue),ue}},Td=(l,d,b,P)=>{let k=m.current,I=E.current;if(!k||!I?.frame||oe.current)return;let T=I.snapshot.slides.find(ne=>ne.id===l),N=it.find(ne=>ne.geometry===d);if(!T||!N)return;let X=Math.abs(P.x-b.x)>=6||Math.abs(P.y-b.y)>=6,J=X?Math.abs(P.x-b.x):I.frame.width*.22,V=X?Math.abs(P.y-b.y):I.frame.height*.18,ue=Math.max(0,Math.min(X?Math.min(b.x,P.x):b.x-J/2,I.frame.width-J)),Se=Math.max(0,Math.min(X?Math.min(b.y,P.y):b.y-V/2,I.frame.height-V));try{let ne=k.addShape(T.id,{name:R(N.labelKey),geometry:d,rect:{x:Math.round(ue*I.snapshot.widthEmu/I.frame.width),y:Math.round(Se*I.snapshot.heightEmu/I.frame.height),width:Math.round(Math.max(12,J)*I.snapshot.widthEmu/I.frame.width),height:Math.round(Math.max(12,V)*I.snapshot.heightEmu/I.frame.height)},fill:"#d9eaf7"}),Ae=fe(void 0,!0,!1,T.id);lt("select"),Oe(null),ze(null),de.current=null,Me.current=null,Ae?.snapshot.slides[Ae.slideIndex]?.id===T.id&&(Pe(null),Ee({slideId:T.id,shapeId:ne.shapeId}),Ve.current?.focus());}catch(ne){throw be(ne),ne}},Rd=async(l,d)=>{let{handle:b}=d,P=()=>m.current===b&&B.current===d.generation&&Qd("insertImage").enabled;try{if(l.size>td)throw new Error(`image is ${l.size} bytes, exceeds the ${td}-byte limit`);let k=l.name.split(".").pop()?.toLowerCase()??"",I=l.type==="image/jpg"?"image/jpeg":l.type||Pi[k];if(!Object.values(Pi).includes(I))throw new Error(`unsupported image type ${l.type||k}`);let T=await ed(l),N=T.slice(T.indexOf(",")+1),X=`data:${I};base64,${N}`;if(I==="image/tiff"){let Ot=Uint8Array.from(atob(N),iu=>iu.charCodeAt(0));X=await ed(presentationImageBlob(Ot));}let J=await zm(X),V=E.current;if(!P()||!V?.frame)return;if(J.width<=0||J.height<=0)throw new Error("image dimensions must be positive");let ue=V.snapshot.slides.findIndex(Ot=>Ot.id===d.slideId),Se=V.snapshot.slides[ue];if(!Se)return;let ne=V.frame.width*.5,Ae=V.frame.height*.5,et=Math.min(ne/J.width,Ae/J.height,1),ta=Math.max(1,J.width*et),na=Math.max(1,J.height*et),nu=(V.frame.width-ta)/2,ou=(V.frame.height-na)/2,ru=b.addPicture(Se.id,{name:l.name||R("objects.defaultPictureName"),rect:{x:Math.round(nu*V.snapshot.widthEmu/V.frame.width),y:Math.round(ou*V.snapshot.heightEmu/V.frame.height),width:Math.round(ta*V.snapshot.widthEmu/V.frame.width),height:Math.round(na*V.snapshot.heightEmu/V.frame.height)},contentType:I,mediaBase64:N}),oa=fe(void 0,!0,!1,Se.id);if(lt("select"),Oe(null),ze(null),de.current=null,Me.current=null,oa&&ue===oa.slideIndex){Pe(null),Ee({slideId:Se.id,shapeId:ru.shapeId});let Ot=document.activeElement;(!Ot||Ot===document.body||Ve.current?.contains(Ot))&&Ve.current?.focus();}}catch(k){throw P()&&be(k),k}},Wi=()=>{let l=m.current,d=E.current;return l?{handle:l,generation:B.current,slideId:d?.snapshot.slides[d.slideIndex]?.id??null}:null},kd=l=>{let d=K.current??Wi();K.current=null,!(!d||d.handle!==m.current||d.generation!==B.current)&&h.input(()=>Rd(l,d)).catch(()=>{});},Md=l=>{if(!l.isPrimary||l.button!==0)return;H.current=null;let d=m.current,b=E.current;if(!d||!b?.frame)return;let P=un(l.currentTarget.getBoundingClientRect(),b.frame,l.clientX,l.clientY);if(!P)return;ct.current=null,Ce.current=null,Ye(null);let k=b.snapshot.slides[b.slideIndex],I=Xn(Xt);if(!c&&(Xt==="textBox"||I)&&k){Pe(null),Ee(null),Oe(null),ze({start:P,end:P}),Me.current=null,de.current=I?{kind:"shapeInsert",pointerId:l.pointerId,slideId:k.id,geometry:I,start:P,last:P}:{kind:"textBox",pointerId:l.pointerId,slideId:k.id,start:P,last:P},l.currentTarget.setPointerCapture(l.pointerId),Ve.current?.focus(),l.preventDefault();return}try{d.layoutSlide(b.slideIndex);let T=d.hitTest(P.x,P.y),N=T?.kind==="text"&&Rr(b.frame,P,ge)==="shape"?{kind:"shape",shapeId:T.shapeId}:T,X=k&&N?Sr(k,N.shapeId):null,J=Me.current,V=!!(k&&X&&J?.slideId===k.id&&J.shapeId===X.id&&l.timeStamp-J.timeStamp<=600&&Math.hypot(l.clientX-J.clientX,l.clientY-J.clientY)<=6),ue=V&&J?Math.min(J.count+1,3):1,Se=N?.kind==="text"?Ir(b.frame,N.shapeId,N.storyId,P):null;if(Me.current=null,k&&N?.kind==="text"&&X&&ue>=2){let ne=d.story(N.storyId),Ae=ue>=3?"paragraph":"word",et=hi(hn(ne),N.position,Ae);Pe({shapeId:N.shapeId,storyId:N.storyId,anchor:et.start,focus:et.end,focusLine:Se?.lineIndex}),Ee(null),Oe(null),de.current={kind:"text",pointerId:l.pointerId,slideId:k.id,shapeId:N.shapeId,storyId:N.storyId,anchor:et.start,focus:et.end,focusLine:Se?.lineIndex,granularity:Ae,clickCount:ue,clickShapeId:X.id,startClientX:l.clientX,startClientY:l.clientY,dragging:!1},l.currentTarget.setPointerCapture(l.pointerId);}else if(k&&Ie&&N?.kind==="text"&&N.shapeId===Ie.shapeId&&N.storyId===Ie.storyId){d.story(N.storyId);let ne=l.shiftKey?Ie.anchor:N.position;Pe({shapeId:N.shapeId,storyId:N.storyId,anchor:ne,focus:N.position,focusLine:Se?.lineIndex}),Ee(null),Oe(null),de.current={kind:"text",pointerId:l.pointerId,slideId:k.id,shapeId:N.shapeId,storyId:N.storyId,anchor:ne,focus:N.position,focusLine:Se?.lineIndex,granularity:"character",clickCount:ue,clickShapeId:X?.id??N.shapeId,startClientX:l.clientX,startClientY:l.clientY,dragging:!1},l.currentTarget.setPointerCapture(l.pointerId);}else k&&N?X?(Pe(null),Ee({slideId:k.id,shapeId:X.id}),Oe(null),!c&&Cr(X)?(de.current={kind:"shape",pointerId:l.pointerId,slideId:k.id,shapeId:X.id,startClientX:l.clientX,startClientY:l.clientY,start:P,last:P,dragThreshold:V?8:4,clickCount:ue,dragging:!1},l.currentTarget.setPointerCapture(l.pointerId)):de.current=null):(Pe(null),Ee(null),Me.current=null,de.current=null):(Pe(null),Ee(null),Oe(null),Me.current=null,de.current=null);Ve.current?.focus(),l.preventDefault();}catch(T){be(T);}},Gi=l=>{let d=de.current,b=m.current,P=E.current;if(!d||d.pointerId!==l.pointerId||!b||!P?.frame)return false;let k=un(l.currentTarget.getBoundingClientRect(),P.frame,l.clientX,l.clientY);if(!k||P.snapshot.slides[P.slideIndex]?.id!==d.slideId)return false;if(d.kind==="text"){!d.dragging&&Er(d.startClientX,d.startClientY,l.clientX,l.clientY)&&(d.dragging=true);let I=Ir(P.frame,d.shapeId,d.storyId,k);if(I){let T=d.granularity==="character"?{anchor:d.anchor,focus:I.position}:Xl({start:d.anchor,end:d.focus},hi(hn(b.story(d.storyId)),I.position,d.granularity));Pe({shapeId:d.shapeId,storyId:d.storyId,...T,focusLine:I.lineIndex});}}else d.kind==="shape"?(d.last=k,!d.dragging&&Er(d.startClientX,d.startClientY,l.clientX,l.clientY,d.dragThreshold)&&(d.dragging=true),d.dragging&&Oe({shapeId:d.shapeId,delta:{x:k.x-d.start.x,y:k.y-d.start.y}})):(d.last=k,ze({start:d.start,end:k}));return true},Ad=l=>{if(Gi(l)){l.preventDefault();return}if(de.current||Xt!=="select")return;let d=E.current;if(!d?.frame)return;let b=un(l.currentTarget.getBoundingClientRect(),d.frame,l.clientX,l.clientY);$o(b?Rr(d.frame,b,ge):null);},Ld=()=>{de.current||$o(null);},Od=l=>{Gi(l);let d=de.current;if(!(!d||d.pointerId!==l.pointerId)){if(de.current=null,Oe(null),l.currentTarget.hasPointerCapture(l.pointerId)&&l.currentTarget.releasePointerCapture(l.pointerId),d.kind==="textBox"){ze(null),h.input(()=>Ed(d.slideId,d.start,d.last)).catch(()=>{}),l.preventDefault();return}if(d.kind==="shapeInsert"){ze(null),h.input(()=>Td(d.slideId,d.geometry,d.start,d.last)).catch(()=>{}),l.preventDefault();return}if(d.kind==="text"){Me.current=d.dragging?null:{slideId:d.slideId,shapeId:d.clickShapeId,clientX:l.clientX,clientY:l.clientY,timeStamp:l.timeStamp,count:d.clickCount};return}if(d.kind==="shape"){if(!d.dragging){Me.current={slideId:d.slideId,shapeId:d.shapeId,clientX:l.clientX,clientY:l.clientY,timeStamp:l.timeStamp,count:d.clickCount};return}Me.current=null,l.preventDefault(),h.input(()=>Dd(d)).catch(()=>{});}}},Dd=l=>{let d=m.current,b=E.current,P=b?.snapshot.slides[b.slideIndex];if(!d||!b?.frame||P?.id!==l.slideId||oe.current)return;let k=Re(P.shapes,l.shapeId);if(k)try{let I=Bt(k),T=$a(b.snapshot,b.frame,k,{x:l.last.x-l.start.x,y:l.last.y-l.start.y});I&&T&&(T.x!==I.x||T.y!==I.y)&&(d.moveShape(P.id,k.id,T.x,T.y),fe(void 0,!0)),Ee({slideId:P.id,shapeId:k.id});}catch(I){throw be(I),I}},$i=l=>{de.current?.pointerId===l.pointerId&&(de.current=null,Oe(null),ze(null),Me.current=null);},Fd=l=>{if(oe.current)return Rt.current;let d=l?{...l,focusLine:void 0}:null;return Pe(d),Ee(null),Me.current=null,fe(void 0,true),d},zd=l=>{if(!m.current||Io(l.nativeEvent)||el(l.target))return;if(l.key==="Escape"){ae.setEnabled(false),lt("select"),ze(null),de.current=null,Ce.current=null,Ye(null),l.preventDefault();return}let d={key:l.key,shiftKey:l.shiftKey,metaKey:l.metaKey,ctrlKey:l.ctrlKey,altKey:l.altKey},b=h.busy(),P=b?H.current:null;if(!(!(P?P.selection!==null:Rt.current!==null)||Pn.current||!uf(d))){if(b){if(l.preventDefault(),!H.current){let T=Rt.current;H.current={selection:T?Ui(T):null};}let I=H.current;h.input(()=>Hd(d,I),"keyboard").catch(()=>{});return}Zi(d,Rt.current).handled&&l.preventDefault();}},Ui=l=>{let d=m.current;if(!d)return null;try{return {shapeId:l.shapeId,storyId:l.storyId,anchor:d.anchorCaret(l.storyId,l.anchor),focus:d.anchorCaret(l.storyId,l.focus)}}catch{return null}},Hd=(l,d)=>{let b=d.selection;if(!b)return;let P=m.current;if(!P)throw new Error("Presentation is no longer open");let k;try{let T=P.resolveCaretAnchor(b.anchor),N=P.resolveCaretAnchor(b.focus);if(T===null||N===null)throw new Error("The text changed before the typed input was applied");k={shapeId:b.shapeId,storyId:b.storyId,anchor:T,focus:N};}catch(T){throw be(T),T}let I=Zi(l,k,true).selection;d.selection=I?Ui(I):null;},Zi=(l,d,b=false)=>{let P=m.current,k={handled:false,selection:d};if(!P||Pn.current)return k;let I=Math.min(d.anchor,d.focus),T=Math.max(d.anchor,d.focus),N=X=>({handled:true,selection:Fd(X)});try{let X=Nd(l,d);if(X!==null){let J={...d,anchor:l.shiftKey?d.anchor:X.position,focus:X.position,focusLine:X.lineIndex};return Pe(J),{handled:!0,selection:J}}if(oe.current)return k;if(l.key==="Backspace"){if(I!==T)return P.deleteText(d.storyId,I,T),N({...d,anchor:I,focus:I});let J=Qm(P.story(d.storyId),I);return J<I?(P.deleteText(d.storyId,J,I),N({...d,anchor:J,focus:J})):{handled:!0,selection:d}}if(l.key==="Delete"){if(I!==T)return P.deleteText(d.storyId,I,T),N({...d,anchor:I,focus:I});let J=ef(P.story(d.storyId),T);return J>T?(P.deleteText(d.storyId,T,J),N({...d,anchor:T,focus:T})):{handled:!0,selection:d}}if(l.key==="Enter")return I!==T&&P.deleteText(d.storyId,I,T),P.insertParagraphBreak(d.storyId,I),N({...d,anchor:I+1,focus:I+1});if(ad(l)){I!==T&&P.deleteText(d.storyId,I,T),P.insertText(d.storyId,I,l.key,Wo.current);let J=I+l.key.length;return N({...d,anchor:J,focus:J})}return k}catch(X){if(be(X),b)throw X;return {handled:true,selection:d}}},or=()=>{let l=E.current,d=jo.current,b=l?.snapshot.slides[l.slideIndex];return b&&d&&b.id===d.slideId?Re(b.shapes,d.shapeId):null},Kd=l=>{let d=m.current,b=Rt.current,P=b?null:or()?.textStories[0]?.id??null;if(!d||!b&&!P)return false;if(ki(k=>({...k,...l})),b){if(b.anchor===b.focus)return true;d.formatText(b.storyId,Math.min(b.anchor,b.focus),Math.max(b.anchor,b.focus),l);}else Jm(d,d.story(P),l);return fe(void 0,true),true},Nd=(l,d)=>{let b=m.current;if(!b)return null;let P=b.story(d.storyId),k=Math.max(0,P.length-1),I=V=>Math.max(0,Math.min(k,V)),T=of(E.current?.frame,d),N={position:d.focus,lineIndex:d.focusLine},X=l.altKey||l.ctrlKey&&!l.metaKey,J=l.metaKey;if(l.key==="ArrowUp"||l.key==="ArrowDown"){let V={shapeId:d.shapeId,...N},ue=ct.current&&ql(ct.current,V)?ct.current.goalX:bi(T,N),Se=l.key==="ArrowUp"?"up":"down",ne=Vl(T,N,Se,ue),Ae={...ne,position:I(ne.position)};return ct.current=ue===void 0?null:{shapeId:d.shapeId,goalX:ue,position:Ae.position,lineIndex:Ae.lineIndex},Ae}if(ct.current=null,l.key==="ArrowLeft"||l.key==="ArrowRight"){let V=l.key==="ArrowLeft"?-1:1;if(J){let Se=Fo(T,N,V<0?"start":"end");return {...Se,position:I(Se.position)}}let ue=X?Yl(hn(P),d.focus,V):d.focus+V;return {position:I(ue),lineIndex:d.focusLine}}if(l.key==="Home"){if(J||l.ctrlKey)return {position:0,lineIndex:0};let V=Fo(T,N,"start");return {...V,position:I(V.position)}}if(l.key==="End"){if(J||l.ctrlKey)return {position:k,lineIndex:Math.max(0,T.length-1)};let V=Fo(T,N,"end");return {...V,position:I(V.position)}}return null},Bd=l=>{let d=m.current,b=Rt.current,P=b?.storyId??or()?.textStories[0]?.id;return !d||!P?false:(b?d.setParagraphAlignment(P,Math.min(b.anchor,b.focus),Math.max(b.anchor,b.focus),l):d.setParagraphAlignment(P,0,d.story(P).length,l),fe(void 0,true),true)},jd=l=>{let d=m.current,b=jo.current,P=or();if(!d||!b||!P)return false;if(l.type==="fillColor")d.setShapeFill(b.slideId,b.shapeId,l.value);else if(l.type==="strokeColor")d.setShapeStroke(b.slideId,b.shapeId,l.value?{color:l.value}:{});else if(l.type==="strokeWidth")d.setShapeStroke(b.slideId,b.shapeId,l.value===null?{}:{widthPt:l.value});else if(l.type==="adjust")d.setShapeAdjust(b.slideId,b.shapeId,{...P.adjustValues,[l.name]:l.value});else {let k={front:d.bringShapeToFront,back:d.sendShapeToBack,forward:d.bringShapeForward,backward:d.sendShapeBackward}[l.value];k(b.slideId,b.shapeId);}return fe(void 0,true),true},_d=l=>{let d=m.current,b=E.current;if(!d||!b)return false;let P=b.slideIndex+1,k=l===void 0?b.snapshot.slides[b.slideIndex]?.layoutPartPath??void 0:l??void 0;return d.insertSlide(P,k),Pe(null),Ee(null),Oe(null),ze(null),lt("select"),de.current=null,Me.current=null,Ce.current=null,Ye(null),fe(P,true,true),true},Wd=l=>{let d=m.current;return d?(l==="undo"?d.undo():d.redo(),Pe(null),Oe(null),ze(null),lt("select"),de.current=null,Me.current=null,Ce.current=null,Ye(null),fe(void 0,true),true):false},Gd=l=>{let d=Ai.current!==l;return ae.setEnabled(false),lt(l),l!=="select"&&(Pe(null),Ee(null)),ze(null),de.current=null,Ce.current=null,Ye(null),d},$d=()=>{if(y.current)return y.current;let l=m.current;if(!l)return Promise.resolve("replaced");let d=B.current,b=()=>m.current===l&&B.current===d,P=Promise.resolve().then(async()=>g&&await g()!==true?"requested":b()?h.run(()=>{if(!b())return "replaced";if(de.current||Ce.current)return "gesture";let k=l.save();return p?p(k):Ql(k,s??"presentation.pptx",Dm),"saved"}):"replaced").catch(k=>k instanceof xt?"input-failed":k instanceof ut||!b()?"replaced":(be(k),"failed")).finally(()=>{y.current===P&&(y.current=null);});return y.current=P,P};z.current=(l,d)=>{let b=m.current,P=E.current,k=Bn.current;if(!b||!P?.frame||!k||ae.reviewing)return null;let I=un(k.getBoundingClientRect(),P.frame,l,d);if(!I||I.x<0||I.y<0||I.x>=P.frame.width||I.y>=P.frame.height)return null;b.layoutSlide(P.slideIndex);let T=b.hitTest(I.x,I.y),N=P.snapshot.slides[P.slideIndex];return T&&N?{...T,slide:P.slideIndex+1,slideId:N.id}:null};let Xi=(l,d)=>{let b=Bn.current,P=U?.frame;return !b||!P?null:un(b.getBoundingClientRect(),P,l,d)},Ud=l=>d=>{if(c||!We||!ot||!go(ot))return;let b=Xi(d.clientX,d.clientY);b&&(d.preventDefault(),d.stopPropagation(),Ce.current={pointerId:d.pointerId,handle:l,start:b,slideId:We.slideId,shapeId:We.shapeId,delta:{x:0,y:0}},Ye({x:0,y:0}),d.currentTarget.setPointerCapture(d.pointerId));},qi=l=>{let d=Ce.current;return fo(d,l.pointerId)?qa(d.start,d.delta,Xi(l.clientX,l.clientY)):null},Zd=l=>{let d=Ce.current,b=qi(l);!fo(d,l.pointerId)||!b||(d.delta=b,Ye(b));},Vi=l=>{let d=Ce.current;return fo(d,l.pointerId)?(Ce.current=null,Ye(null),l.currentTarget.hasPointerCapture(l.pointerId)&&l.currentTarget.releasePointerCapture(l.pointerId),d):null},Yi=l=>{Vi(l);},Xd=l=>{let d=qi(l),b=Vi(l);!b||!d||d.x===0&&d.y===0||h.input(()=>qd(b,d)).catch(()=>{});},qd=(l,d)=>{let b=m.current,P=E.current,k=P?.snapshot.slides[P.slideIndex],I=k?Re(k.shapes,l.shapeId):null;if(!(oe.current||!b||!P?.frame||k?.id!==l.slideId||!I))try{let T=Tr(P.snapshot,P.frame,I,l.handle,d),N=Bt(I);T&&N&&(T.x!==N.x||T.y!==N.y||T.width!==N.width||T.height!==N.height)&&(b.setShapeRect(l.slideId,l.shapeId,T),fe(void 0,!0));}catch(T){throw be(T),T}},Un=U?.snapshot.slides.length??0,Cn=U?.slideIndex??0,Vd=()=>{E.current?.snapshot.slides.length&&Yo(true);},Yd=async()=>{let l;try{l=await h.run(()=>{let T=E.current,N=m.current;if(!T?.frame||!N)throw new ut;return {frame:T.frame,slideIndex:T.slideIndex,handle:N}});}catch(T){return T instanceof xt?"input-failed":"replaced"}let{frame:d,slideIndex:b,handle:P}=l,k={current:P},I={current:new Map};try{let T=await slideToPng(d,{scale:window.devicePixelRatio||1,resolveImage:X=>gn(X,k,I,_)}),N=new Uint8Array(await T.arrayBuffer());return m.current!==P?"replaced":(Ql(N,Fm(s,b),"image/png"),"exported")}catch(T){return m.current!==P?"replaced":(be(T),"failed")}},Ji=_o&&_o.shapeId===We?.shapeId?_o.delta:null,rr=Ce.current?.handle,Jd=U?.frame&&ot&&No&&rr?Va(U.snapshot,U.frame,ot,rr,No):null,Vt=Lt?No&&rr?Jd??Lt:{...Lt,x:Lt.x+(Ji?.x??0),y:Lt.y+(Ji?.y??0)}:null,Qi=e?U&&m.current?"ready":Oi||!Uo?"loading":"empty":"empty",ir=!!m.current?.isProposalsAvailable(),Qd=fl(C,{handle:m.current,handleRef:m,modelRef:E,selectionRef:Rt,shapeSelectionRef:jo,textStyleRef:Wo,activeToolRef:Ai,generationRef:B,coordinator:h,status:Qi,readOnlyRef:oe,zoomRef:Mi,proposalsRef:md,proposalsOpenRef:fd,reviewEnabledRef:ae.enabledRef,reviewSelectedIdRef:ae.selectedIdRef,proposalsAvailable:ir,gestureActive:()=>!!(de.current||Ce.current),baseStyle:yi,i18n:L,t:R,actions:{format:Kd,align:Bd,formatShape:jd,insertSlide:_d,history:Wd,setTool:Gd,setZoom:l=>{let d=l!==Mi.current;return cd(l),d},openPicker:()=>{K.current=Wi(),Ei.current?.click();},save:$d,exportPng:Yd,present:Vd,setProposalsOpen:l=>{l&&qt(),Wn(l);},selectProposal:l=>{ae.select(l),ae.setEnabled(true);},showProposalDiff:l=>ae.setEnabled(l),acceptProposal:bd,rejectProposal:Pd,reportError:be,focusEditor:()=>Ve.current?.focus()},stamp:[U,Ie,We,ud,Xt,Go,c,Qi,ae.enabled,ae.selected,ae.available,_n,Fi,ir,R,L]}),ea=useRef(Vo);ea.current=Vo,nl({commands:C,containerRef:wi,suspended:()=>ea.current});let eu=!S||x===null?null:jsxs("div",{style:re.toolbarShell,children:[jsx(ho.Provider,{value:true,children:x!==void 0?jsx("div",{style:re.toolbar,children:x}):c?null:jsxs(Fragment,{children:[jsx(Co,{mode:"commands",style:re.toolbar}),ir&&jsx(Bm,{buttonRef:zi,count:_n.length})]})}),kt.length>0?jsxs("div",{style:re.presenceStrip,role:"list","aria-label":"Collaborators",children:[Sn.visible.map(l=>{let d=l.state.cursor?.slideId===vn;return jsx("span",{role:"listitem",style:od(l.state.user.color,d),title:l.state.user.name,"aria-label":l.state.user.name,children:sf(l.state.user.name)},l.state.clientId)}),Sn.overflow>0?jsxs("span",{role:"listitem",style:od("#64748b",true),title:`${Sn.overflow} more collaborators`,"aria-label":`${Sn.overflow} more collaborators`,children:["+",Sn.overflow]}):null]}):null,x===void 0&&jsx(jm,{})]}),ar=l=>mt.managed?jsx(yl,{host:mt.host,placement:l,activations:mt.activations.filter(d=>d.plugin.panel?.placement===l),available:ld}):null,tu=jsxs("div",{ref:wi,className:r,style:re.root,children:[eu,jsx("input",{ref:Ei,type:"file",accept:Object.values(Pi).join(","),disabled:c||ae.reviewing,tabIndex:-1,"aria-hidden":"true","data-testid":"pptx-insert-image-input",style:re.hiddenFileInput,onChange:l=>{let d=l.currentTarget.files?.[0];l.currentTarget.value="",d&&kd(d);}}),jsxs("div",{ref:sd,style:re.workspace,children:[jsx("aside",{style:re.slideStrip,"aria-label":R("slides.panelLabel"),children:U?.snapshot.slides.map((l,d)=>{let b=wd.get(l.id);return jsxs("button",{type:"button","aria-current":d===Cn?"page":void 0,style:lf(d===Cn),onClick:()=>Id(d),children:[jsx("span",{style:re.slideNumber,children:d+1}),jsxs("span",{style:re.slidePreview,children:[U.thumbnails.get(l.id)?jsx(Gm,{frame:U.thumbnails.get(l.id),resolveImage:P=>gn(P,m,Zt,_)}):jsx("span",{style:re.slideTitle,children:af(l.shapes)||R("slides.fallbackTitle",{number:d+1})}),l.id!==vn&&b&&(b.visible.length>0||b.overflow>0)?jsxs("span",{style:re.thumbnailPresence,"aria-hidden":"true",children:[b.visible.map(P=>jsx("span",{style:{...re.thumbnailPresenceDot,backgroundColor:P.state.user.color}},P.state.clientId)),b.overflow>0?jsxs("span",{style:re.thumbnailPresenceOverflow,children:["+",b.overflow]}):null]}):null]})]},l.id)})}),ar("left"),jsxs("div",{style:re.center,children:[jsxs("div",{ref:Ve,style:re.stage,tabIndex:0,role:"application","aria-label":R("editor.appLabel"),onKeyDown:zd,onFocus:()=>Ti(true),onBlur:()=>Ti(false),children:[!c&&jsx(ns,{review:ae,ready:gd===ae.diff}),jsx("div",{ref:Ii,style:re.canvasHost,children:U?.frame?jsxs("div",{style:{...re.canvasFrame,width:U.frame.width*ge,height:U.frame.height*ge},children:[jsx("canvas",{ref:Bn,"data-testid":"pptx-slide-canvas","aria-hidden":ae.reviewing,style:{...re.canvas,cursor:Xt!=="select"?"crosshair":Li==="text"?"text":Li==="shape"?"move":"default"},onPointerDown:ae.reviewing?void 0:Md,onPointerMove:Ad,onPointerUp:Od,onPointerLeave:Ld,onPointerCancel:$i,onLostPointerCapture:$i,"aria-label":ot?R("slides.canvasLabelWithSelection",{current:Cn+1,total:Un,name:ot.name}):R("slides.canvasLabel",{current:Cn+1,total:Un})}),mt.managed&&jsx(gl,{host:mt.host,activations:mt.activations,layerRef:mt.overlayLayerRef}),!ae.reviewing&&jsxs(Fragment,{children:[jsx($m,{frame:U.frame,selection:Ie,scale:ge,focused:dd}),nr.visible.map(({peer:l,peerCount:d,shapeId:b,bounds:P},k)=>jsx(_m,{peer:l,peerCount:d,bounds:P,scale:ge,labelOffset:k},b)),nr.overflow>0?jsxs("span",{style:re.remoteShapeOverflow,"aria-hidden":"true",children:["+",nr.overflow," selections"]}):null,Vt?jsxs(Fragment,{children:[jsx("span",{style:{...re.shapeSelection,left:Vt.x*ge,top:Vt.y*ge,width:Math.max(1,Vt.width*ge),height:Math.max(1,Vt.height*ge)},"aria-hidden":"true"}),!c&&ot&&go(ot)?Ba.map(l=>{let d=Za(Vt,l);return jsx("span",{"data-testid":`pptx-resize-${l}`,onPointerDown:Ud(l),onPointerMove:Zd,onPointerUp:Xd,onPointerCancel:Yi,onLostPointerCapture:Yi,style:{...re.resizeHandle,left:d.x*ge-zo/2,top:d.y*ge-zo/2,cursor:Xa(l)}},l)}):null]}):null,yn?jsx("span",{style:{...re.textEditOutline,left:yn.x*ge,top:yn.y*ge,width:Math.max(1,yn.width*ge),height:Math.max(1,yn.height*ge)},"aria-hidden":"true"}):null,pt?jsx("span",{style:{...re.textBoxPreview,left:Math.min(pt.start.x,pt.end.x)*ge,top:Math.min(pt.start.y,pt.end.y)*ge,width:Math.max(1,Math.abs(pt.end.x-pt.start.x))*ge,height:Math.max(1,Math.abs(pt.end.y-pt.start.y))*ge},"aria-hidden":"true"}):null]}),ae.diff&&jsx(os,{diff:ae.diff,current:U.snapshot,frame:U.frame,slideIndex:U.slideIndex,scale:ge,resolveImage:xd,onPainted:hd,onTarget:(l,d)=>{Ni(l,d,ae.selected?.id),Wn(true);}},`${ae.diff.proposal.id}:${U.slideIndex}`)]}):jsx("div",{style:re.empty,children:R(Oi?"editor.opening":e?"editor.noSlides":"editor.openPrompt")})}),Uo?jsx("div",{style:re.error,children:Uo}):null]}),ar("bottom")]}),ar("right"),!c&&Fi&&U&&m.current&&jsx(Ka,{handle:m.current,proposals:_n,snapshot:U.snapshot,resolveImage:l=>gn(l,m,Zt,_),onNavigate:Ni,onClose:()=>zi.current?.focus()})]}),Ke&&ae.diff?.proposal.changes.some(l=>l.slideId===Ke.id&&!l.shapeId&&l.oldText!==l.newText)?jsx(rs,{diff:ae.diff,slideId:Ke.id}):Ke?jsx(Wm,{value:Ke.notes??"",disabled:!U||ae.reviewing||c,label:R("notes.panelLabel"),placeholder:R("notes.placeholder"),onCommit:l=>{let d=m.current;if(!(!d||c))try{d.setSlideNotes(Ke.id,l),fe(void 0,!0);}catch(b){be(b);}}},Ke.id):null,Vo&&Un>0&&m.current?jsx(Vs,{handle:m.current,slideCount:Un,startIndex:Cn,resolveImage:l=>gn(l,m,Zt,_),counterLabel:(l,d)=>R("presentation.slideCounter",{current:l,total:d}),label:R("presentation.label"),exitLabel:R("presentation.exit"),previousLabel:R("presentation.previousSlide"),nextLabel:R("presentation.nextSlide"),onExit:()=>Yo(false),onError:be}):null]});return jsx(dt.Provider,{value:F,children:tu})}function Bm({buttonRef:e,count:t}){let n=le(),o=he("proposalsPanel"),{t:r}=Q(),s=Ze(!o.enabled,id(o));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,style:re.presentButton,onClick:()=>{o.enabled&&n.execute("proposalsPanel",null);},children:[r("proposals.title")," ",jsx("span",{"data-testid":"pptx-proposals-count",children:t})]}),s.node]})}function jm(){let e=le(),t=he("slideshow"),{t:n}=Q(),o=Ze(!t.enabled,id(t));return jsxs(Fragment,{children:[jsxs("button",{type:"button",onClick:()=>{t.enabled&&e.execute("slideshow",null);},...o.props,title:o.reason,"data-testid":"pptx-present",style:{...re.presentButton,opacity:t.enabled?1:.6},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]})}function id(e){return e.enabled?void 0:e.disabledReason?.message}function _m({peer:e,peerCount:t,bounds:n,scale:o,labelOffset:r}){let[s,i]=useState(()=>Date.now()-e.cursorMovedAt<PRESENCE_LABEL_DURATION_MS);return useEffect(()=>{let a=PRESENCE_LABEL_DURATION_MS-(Date.now()-e.cursorMovedAt);if(a<=0){i(false);return}i(true);let f=setTimeout(()=>i(false),a);return ()=>clearTimeout(f)},[e.cursorMovedAt]),jsxs("span",{style:{...re.remoteShapeSelection,left:n.x*o,top:n.y*o,width:Math.max(1,n.width*o),height:Math.max(1,n.height*o),borderColor:e.state.user.color},"aria-hidden":"true",children:[jsx("span",{style:{...re.remoteShapeWash,backgroundColor:e.state.user.color}}),s?jsxs("span",{style:{...re.remoteShapeLabel,top:-4-r%3*20,backgroundColor:e.state.user.color},children:[e.state.user.name,t>1?` +${t-1}`:""]}):null]})}function Wm({value:e,disabled:t,label:n,placeholder:o,onCommit:r}){return jsxs("div",{style:re.notesPanel,children:[jsx("span",{style:re.notesLabel,children:n}),jsx("textarea",{"aria-label":n,style:re.notesTextarea,value:e,disabled:t,placeholder:o,"data-testid":"pptx-notes-textarea",onChange:s=>r(s.target.value)})]})}function Gm({frame:e,resolveImage:t}){let n=useRef(null);return useEffect(()=>{let o=n.current;if(!o)return;let r=o.getContext("2d");if(!r)return;let s=128/e.width,i=window.devicePixelRatio||1;sizeCanvasForSlide(o,e,i,s),paintSlide(r,e,i,s,{resolveImage:t}).catch(()=>{});},[e,t]),jsx("canvas",{ref:n,style:re.thumbnailCanvas,"aria-hidden":"true"})}function $m({frame:e,selection:t,scale:n,focused:o}){let r=useRef(null),[s,i]=useState(()=>typeof document>"u"||document.visibilityState==="visible"),[a,f]=useState(false);return useEffect(()=>{if(typeof document>"u")return;let u=()=>i(document.visibilityState==="visible");return document.addEventListener("visibilitychange",u),()=>document.removeEventListener("visibilitychange",u)},[]),useEffect(()=>{let u=o&&s&&t!==null&&t.anchor===t.focus;if(f(u),!u)return;let p=window.setInterval(()=>f(g=>!g),Hm);return ()=>window.clearInterval(p)},[o,s,t]),useEffect(()=>{let u=r.current;if(!u)return;let p=u.getContext("2d");if(!p)return;let g=window.devicePixelRatio||1;sizeCanvasForSlide(u,e,g,n),rf(p,e,t,g,n,a);},[a,e,n,t]),jsx("canvas",{ref:r,style:re.canvasOverlay,"aria-hidden":"true"})}var Ho=class extends Error{};function Um(e,t){let n=new Map;return new Proxy(e,{get(o,r){let s=Reflect.get(o,r,o);if(typeof s!="function")return s;let i=n.get(r);return i||(i=(...a)=>{if(!t())throw new Ho;return Reflect.apply(s,o,a)},n.set(r,i)),i},set(o,r,s){if(!t())throw new Ho;return Reflect.set(o,r,s,o)}})}var Ko=class extends Error{constructor(){super("Finish the pointer gesture before flushing input");}};function vi(e,t){if(typeof t!="string")return null;let n=e.snapshot().slides,o=n.findIndex(r=>r.id===t);return o<0?null:{index:o,slide:n[o]}}function Zm(e,t){return t===0?0:Math.max(0,Math.min(t-1,e))}function Xm(e){let t=useRef(e);return qm(t.current,e)||(t.current=e),t.current}function qm(e,t){return e===t?true:e.length!==t.length?false:e.every((n,o)=>Vm(n,t[o]))}function Vm(e,t){return e.family===t.family&&(e.bold??false)===(t.bold??false)&&(e.italic??false)===(t.italic??false)&&Ym(e.bytes,t.bytes)}function Ym(e,t){return e===t?true:e.byteLength!==t.byteLength?false:e.every((n,o)=>n===t[o])}function hn(e){return e.paragraphs.map(t=>t.runs.map(n=>n.text).join("")).join(`
|
|
4
|
-
`)}function Jm(e,t,n){e.formatText(t.id,0,t.length,n);}function Qm(e,t){let n=hn(e).slice(0,t),o=Array.from(n),r=o[o.length-1];return r?t-r.length:t}function ef(e,t){let n=Array.from(hn(e).slice(t))[0];return n?t+n.length:t}async function tf(e){return typeof FontFace>"u"||typeof document>"u"?[]:await Promise.all(e.map(async n=>{let o=n.bytes.slice().buffer,s=await new FontFace(n.family,o,{style:n.italic?"italic":"normal",weight:n.bold?"700":"400"}).load();return document.fonts.add(s),s}))}function nd(e){if(!(typeof document>"u"))for(let t of e)document.fonts.delete(t);}function gn(e,t,n,o){let r=n.current.get(e);if(r)return r;let s=nf(t.current?.mediaBytes(e),o);return n.current.set(e,s),s}function nf(e,t){return e?decodePresentationImage(e,t):Promise.resolve(null)}function of(e,t){return e?.primitives.find(o=>o.kind==="textBox"&&o.storyId===t.storyId&&o.shapeId===t.shapeId)?.lines??[]}function rf(e,t,n,o,r,s=true){if(!n)return;let i=t.primitives.find(u=>u.kind==="textBox"&&u.storyId===n.storyId&&u.shapeId===n.shapeId);if(!i)return;let a=Math.min(n.anchor,n.focus),f=Math.max(n.anchor,n.focus);if(e.save(),e.setTransform(o*r,0,0,o*r,0,0),a!==f){e.fillStyle="rgba(59, 130, 246, 0.26)";for(let u of i.lines){let p=Math.max(a,u.start),g=Math.min(f,u.end);if(p>=g)continue;let c=Si(u,p),x=Si(u,g);e.fillRect(Math.min(c,x),u.y,Math.max(1,Math.abs(x-c)),u.height);}}else if(s){let u=i.lines[Hn(i.lines,{position:a,lineIndex:n.focusLine})];if(u){let p=Si(u,a);e.fillStyle="#1d4ed8",e.fillRect(p,u.y,1.5,u.height);}}e.restore();}function Si(e,t){let n=e.caretStops[0];return n?e.caretStops.reduce((o,r)=>Math.abs(r.position-t)<Math.abs(o.position-t)?r:o,n).x:e.x}function af(e){for(let t of e)for(let n of t.textStories){let o=hn(n).trim();if(o)return o.slice(0,40)}return ""}var re={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:zo,height:zo,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:{flex:"0 0 auto",display:"flex",flexDirection:"column",gap:4,padding:"8px 14px 10px",background:"#ffffff",borderTop:"1px solid #e2e8f0"},notesLabel:{fontSize:11,fontWeight:650,color:"#647087",textTransform:"uppercase",letterSpacing:"0.02em"},notesTextarea:{width:"100%",height:64,resize:"vertical",border:"1px solid #d8dee9",borderRadius:6,padding:"6px 8px",font:"13px ui-sans-serif, system-ui, sans-serif",color:"#172033",boxSizing:"border-box",outline:"none"},empty:{margin:"auto",color:"#6b7587",fontSize:14},error:{position:"absolute",left:16,right:16,bottom:14,padding:"9px 12px",color:"#8b1e2d",background:"#fff0f2",border:"1px solid #efb8c0",borderRadius:6,fontSize:12},hiddenFileInput:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},presentButton:{display:"inline-flex",alignItems:"center",gap:6,flex:"0 0 auto",margin:"0 12px 0 4px",padding:"0 14px",height:30,border:0,borderRadius:15,background:"#1a73e8",color:"#ffffff",font:"600 13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"}};function sf(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0]).join("").toUpperCase()}function od(e,t){return {display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,flex:"0 0 auto",border:"2px solid #ffffff",borderRadius:999,backgroundColor:e,boxShadow:"0 0 0 1px rgba(15, 23, 42, 0.14)",color:"#ffffff",fontSize:10,fontWeight:700,letterSpacing:"-0.02em",opacity:t?1:.38}}function lf(e){return {display:"flex",alignItems:"flex-start",gap:7,width:"100%",marginBottom:12,padding:4,border:e?"2px solid #325ee6":"2px solid transparent",borderRadius:5,background:"transparent",cursor:"pointer"}}var df=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","Backspace","Delete","Enter"]);function ad(e){return e.key.length>0&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&Array.from(e.key).length===1}function uf(e){return df.has(e.key)||ad(e)}export{Co as EditorToolbar,_t as EditorToolbarContext,Jt as LocaleProvider,ku as PptxCommandProvider,Km as PptxEditor,_r as PptxPluginToolbar,Fn as PptxToolbar,it as SHAPE_PRESETS,Fn as Toolbar,Pr as ToolbarButton,Qe as ToolbarCommand,we as ToolbarCommandButton,ys as ToolbarCommandSelect,ju as ToolbarDropdown,Je as ToolbarGroup,dn as ToolbarMenuItem,_u as ToolbarMenuSeparator,xp as ToolbarOverflow,vt as ToolbarSeparator,hm as definePptxPlugin,oc as useEditorToolbar,oo as usePptxCommand,he as usePptxCommandState,le as usePptxCommands,Q as useTranslation};
|
|
1
|
+
export{b as PptxEditor,a as PptxWorkerEditorChunkLoadError}from'./chunk-66PPYFHW.js';export{E as EditorToolbar,v as EditorToolbarContext,B as PptxPluginToolbar,D as PptxToolbar,D as Toolbar,A as ToolbarCommand,y as ToolbarCommandButton,z as ToolbarCommandSelect,C as ToolbarOverflow,Q as definePptxPlugin,w as useEditorToolbar}from'./chunk-X6B77B3U.js';export{a as LocaleProvider,w as PptxCommandAdmissionError,B as PptxCommandProvider,k as SHAPE_PRESETS,Z as ToolbarButton,ba as ToolbarDropdown,_ as ToolbarGroup,ca as ToolbarMenuItem,da as ToolbarMenuSeparator,$ as ToolbarSeparator,E as usePptxCommand,D as usePptxCommandState,C as usePptxCommands,b as useTranslation}from'./chunk-X2M23RXQ.js';import'./chunk-O2XFH626.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betteroffice/pptx-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "PowerPoint-faithful React PPTX editor and viewer
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "PowerPoint-faithful React PPTX editor and viewer: full OOXML fidelity, real-time human + AI agent collaboration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pptx",
|
|
7
7
|
"powerpoint",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"typecheck": "tsc --noEmit -p ."
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@betteroffice/pptx": "0.
|
|
44
|
-
"@betteroffice/pptx-i18n": "0.
|
|
43
|
+
"@betteroffice/pptx": "0.5.0",
|
|
44
|
+
"@betteroffice/pptx-i18n": "0.5.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|
|
48
48
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@happy-dom/global-registrator": "^
|
|
51
|
+
"@happy-dom/global-registrator": "^21.0.4",
|
|
52
52
|
"@testing-library/react": "^16.0.0",
|
|
53
53
|
"@types/bun": "^1.4.2",
|
|
54
54
|
"@types/react": "^19.2.17",
|
|
@@ -65,6 +65,9 @@
|
|
|
65
65
|
"url": "https://github.com/openooxml/betteroffice.git",
|
|
66
66
|
"directory": "packages/pptx-react"
|
|
67
67
|
},
|
|
68
|
+
"bugs": {
|
|
69
|
+
"url": "https://github.com/openooxml/betteroffice/issues"
|
|
70
|
+
},
|
|
68
71
|
"publishConfig": {
|
|
69
72
|
"access": "public"
|
|
70
73
|
}
|