pptx-vanilla-viewer 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,39 @@ A release listed with no entries carried no Conventional Commit in this package'
7
7
  scope: scripts/release-plan.mjs re-releases a package whenever any of its files
8
8
  change, not only on conventional ones.
9
9
 
10
+ ## [2.4.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.4.0) - 2026-09-02
11
+
12
+ ### Features
13
+
14
+ - **shared:** Animate morph stacking, flips, and crop reveal like PowerPoint (by @nikko82) ([a9bba84](https://github.com/ChristopherVR/pptx-viewer/commit/a9bba842827274a9dc7cdb0b8934fe7509b560e6))
15
+ - **shared:** Minimum-cost media pairing and named text twins for morphs (by @nikko82) ([3abda95](https://github.com/ChristopherVR/pptx-viewer/commit/3abda95e72133e1fe886f2bc98d76a5c23a645c6))
16
+ - **shared:** Step an inert stacking-swap counterpart together with the mover (by @nikko82) ([e4f9438](https://github.com/ChristopherVR/pptx-viewer/commit/e4f9438771bcec15c78ebba5eb3b4e2c173152e0))
17
+ - **react,vue,angular,svelte,vanilla:** Replay the leaving slide's transition on backward steps (by @nikko82) ([e23838e](https://github.com/ChristopherVR/pptx-viewer/commit/e23838ebc6253c413fe87cd75e96244311349214))
18
+ - **shared:** I18n keys for the wave-4 parity UI (by @ChristopherVR) ([6cc9a86](https://github.com/ChristopherVR/pptx-viewer/commit/6cc9a8646c3f6174ec70928e00137412fea1778a))
19
+ - **core:** Master/layout CRUD, legacy comment threading, extended ppaction verbs (by @ChristopherVR) ([033b024](https://github.com/ChristopherVR/pptx-viewer/commit/033b024a70d041cf884aafb47dbc35e9d2ed10f6))
20
+ - **shared:** Master-view CRUD, recent colours, action options, handout-master print chrome (by @ChristopherVR) ([3cc928f](https://github.com/ChristopherVR/pptx-viewer/commit/3cc928fea1e07293ca24faabcf6058b0c43713b2))
21
+ - **vanilla:** Wave-4 parity UI (chart subtypes, read-only banner, compat toasts, rescale, sldRg, guides) (by @ChristopherVR) ([30df3a2](https://github.com/ChristopherVR/pptx-viewer/commit/30df3a2dce5782137c63e713913ac80aec5dd9d6))
22
+ - **shared:** Show entry slide, compat toast placement, master-view failure copy (by @ChristopherVR) ([79a42ba](https://github.com/ChristopherVR/pptx-viewer/commit/79a42ba93d0fd76d4fb509710c14eae22609c5de))
23
+ - **vanilla:** Wave-4 show entry, custom-show actions, master CRUD, mentions (by @ChristopherVR) ([9d5441d](https://github.com/ChristopherVR/pptx-viewer/commit/9d5441df75183caf5da70f689facad842d308651))
24
+ - **shared:** Resolve OLE action verbs against the clicked element (by @ChristopherVR) ([680c70c](https://github.com/ChristopherVR/pptx-viewer/commit/680c70c7d4cbb1f37d0c132b99544309e3563629))
25
+ - **vanilla:** Recent-colours row under every picker and OLE verb actions (by @ChristopherVR) ([a9cadea](https://github.com/ChristopherVR/pptx-viewer/commit/a9cadeac130631752846f503deba7246a450a87e))
26
+ - **shared:** Map F5 and Shift+F5 to the start-show actions (by @ChristopherVR) ([94852ed](https://github.com/ChristopherVR/pptx-viewer/commit/94852edbe44a6fb712e15dd8892ff4dcd1e9e7b0))
27
+ - **vanilla:** Start the slide show on F5 and Shift+F5 (by @ChristopherVR) ([6bdeb84](https://github.com/ChristopherVR/pptx-viewer/commit/6bdeb846a8f47ab9c7166ee104acc53d0b4dd782))
28
+
29
+ ### Bug Fixes
30
+
31
+ - **shared:** Play an un-authored morph at PowerPoint's 0.5s fallback (by @nikko82) ([0a70ef2](https://github.com/ChristopherVR/pptx-viewer/commit/0a70ef2db656e830ad429e9fd0a6efeb43ff7bde))
32
+ - **vanilla:** Keep the stage DOM on non-chart selection so double-click still opens table cells (by @ChristopherVR) ([427bbed](https://github.com/ChristopherVR/pptx-viewer/commit/427bbed1073de66a83536f8874726de2db39d0d0))
33
+ - **shared:** Close the open code-scanning findings at their root (by @ChristopherVR) ([455f853](https://github.com/ChristopherVR/pptx-viewer/commit/455f853f028ba1cb4142285558bbeef715d130d7))
34
+ - **vanilla:** Route ppaction://media through the shared media toggle (by @ChristopherVR) ([94b49a7](https://github.com/ChristopherVR/pptx-viewer/commit/94b49a755768b89c1c180fb1636a3574d625112c))
35
+ - **shared:** Write morph stacking-order journeys in the stage's z space (by @ChristopherVR) ([867b05b](https://github.com/ChristopherVR/pptx-viewer/commit/867b05b4e9bfea62361e7d1361ae4cb84787c191))
36
+ - **shared:** Take the nearest named text twin and drop its dead name veto (by @ChristopherVR) ([c6e8062](https://github.com/ChristopherVR/pptx-viewer/commit/c6e8062919e9b9ccc1d1b18c4504270fd8138f51))
37
+ - **shared:** Sample the morph crop track from the one easing definition (by @ChristopherVR) ([349e8bd](https://github.com/ChristopherVR/pptx-viewer/commit/349e8bd5eb1908077f3693e6ee4573cf88ad253c))
38
+
39
+ ### Testing
40
+
41
+ - **shared:** Cover the morph media assignment solver (by @ChristopherVR) ([cbf671f](https://github.com/ChristopherVR/pptx-viewer/commit/cbf671f7a7a2037006f19ddaabc502211069ded5))
42
+
10
43
  ## [2.3.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.3.0) - 2026-09-02
11
44
 
12
45
  ### Features
@@ -1 +1 @@
1
- 'use strict';var chunkOBWXMT2T_cjs=require('./chunk-OBWXMT2T.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkOBWXMT2T_cjs.Hm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-focus-row"),f=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkOBWXMT2T_cjs.jm(p,o.getSlides())){let b=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-focus-chip");(m||l)&&b.classList.add("is-strong"),b.title=r.title,b.textContent=r.label,g.appendChild(b);}if(l){let r=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-focus-actions"),d=chunkOBWXMT2T_cjs.km(p,o.getSlides());if(d){let r=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkOBWXMT2T_cjs.Hm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkOBWXMT2T_cjs.lm(d.slideIndex,d.elementIdA,d.elementIdB))),C.appendChild(r);}let y=h("crosshair",n("pptx.ai.pickElement"),()=>s?i.stopPicking():i.startPicking());if(y.setAttribute("aria-pressed",String(s)),y.classList.toggle("is-active",s),C.appendChild(y),m?C.appendChild(h("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):l?C.appendChild(h("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):C.appendChild(h("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),g.appendChild(C),a.appendChild(g),s){let r=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-focus-pick"),b=chunkOBWXMT2T_cjs.Hm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-focus-pick-done");T.type="button",T.textContent=n("pptx.ai.pickDone"),T.addEventListener("click",()=>i.stopPicking()),r.append(b,k,T),a.appendChild(r);}},c=i.subscribe(x);return x(),{el:a,destroy(){c(),a.remove();}}}function O(o){let{doc:t,t:n}=o,i=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkOBWXMT2T_cjs.Hm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-history-head"),x=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkOBWXMT2T_cjs.Hm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-history-body"),m=chunkOBWXMT2T_cjs.wm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkOBWXMT2T_cjs.nm({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:n("pptx.ai.untitledChat"),onChatsChanged:()=>s()});function s(){p.replaceChildren();let f=l.chats();if(f.length===0){let d=chunkOBWXMT2T_cjs.wm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkOBWXMT2T_cjs.wm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkOBWXMT2T_cjs.wm(t,"li","pptxv-ai-history-row"),r=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-history-text"),k=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkOBWXMT2T_cjs.Hm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-history-delete");P.type="button",P.title=n("pptx.ai.deleteChat"),P.setAttribute("aria-label",n("pptx.ai.deleteChat")),P.appendChild(chunkOBWXMT2T_cjs.Hm(t,"trash")),P.addEventListener("click",()=>{l.deleteChat(d.id);}),y.append(r,P),C.appendChild(y);}p.appendChild(C);}s(),i.addEventListener("click",()=>{a.hidden=!a.hidden;}),c.addEventListener("click",()=>{l.newChat(),a.hidden=true;});let g=f=>{a.hidden||!(f.target instanceof Node)||!a.contains(f.target)&&!i.contains(f.target)&&(a.hidden=true);};return t.addEventListener("mousedown",g),{button:i,el:a,notifyMessagesChanged:()=>l.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",g),l.dispose(),i.remove(),a.remove();}}}var _={view:"eye",text:"text-box",shape:"shapes",theme:"font-color",table:"table",slide:"layout",chart:"chart",move:"move-right",delete:"trash",search:"search",nav:"move-right",animation:"play",notes:"sticky-note",tool:"wrench"};function W(o,t,n){let i=t.state==="output-error",a=t.state==="output-available",h=!i&&!a,x=chunkOBWXMT2T_cjs.sm(t.toolName,t.input,h?"present":"past"),c=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-tool"),p=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-tool-head"),m=chunkOBWXMT2T_cjs.Hm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkOBWXMT2T_cjs.wm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkOBWXMT2T_cjs.wm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkOBWXMT2T_cjs.Hm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkOBWXMT2T_cjs.Hm(o,"check"),o.createTextNode(n("pptx.ai.toolDone")))):(s.classList.add("is-running"),s.textContent=n("pptx.ai.toolRunning")),p.append(m,l,s),c.appendChild(p),i&&t.errorText){let f=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkOBWXMT2T_cjs.rm(t.input);if(g){let f=chunkOBWXMT2T_cjs.wm(o,"details","pptxv-ai-tool-details"),C=chunkOBWXMT2T_cjs.wm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkOBWXMT2T_cjs.qm(t.toolName)}: ${g}`,f.append(C,d),c.appendChild(f);}return c}function q(o,t,n,i){t.replaceChildren();for(let a of n){if(a.role==="system")continue;let h=a.role==="user",x=chunkOBWXMT2T_cjs.fm(a);if(x.length===0&&!h)continue;let c=chunkOBWXMT2T_cjs.wm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkOBWXMT2T_cjs.Hm(o,h?"comment":"sparkles"));let m=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-msg-text");s.textContent=l.text,m.appendChild(s);}else m.appendChild(W(o,l,i));c.append(p,m),t.appendChild(c);}}function G(o,t,n,i,a){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let h=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposals-header"),x=chunkOBWXMT2T_cjs.wm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkOBWXMT2T_cjs.wm(o,"button","pptxv-ai-proposal-btn is-accept-all");c.type="button",c.textContent=i("pptx.ai.acceptAll"),c.addEventListener("click",()=>a.acceptAll()),h.appendChild(c);}t.appendChild(h);for(let c of n)t.appendChild(tt(o,c,i,a));}function tt(o,t,n,i){let a=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkOBWXMT2T_cjs.wm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkOBWXMT2T_cjs.wm(o,"li");g.textContent=chunkOBWXMT2T_cjs.cm(s),l.appendChild(g);}a.appendChild(l);}let c=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposal-actions"),p=chunkOBWXMT2T_cjs.wm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkOBWXMT2T_cjs.Hm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkOBWXMT2T_cjs.wm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkOBWXMT2T_cjs.Hm(o,"close"),o.createTextNode(n("pptx.ai.reject"))),m.addEventListener("click",()=>i.reject(t.id)),c.append(p,m),a.appendChild(c),a}async function wt(o){let{doc:t,host:n,t:i}=o;n.replaceChildren();let a=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-header"),h=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkOBWXMT2T_cjs.Hm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkOBWXMT2T_cjs.Hm(t,"sparkles"),h,x);let c,p=o.controller,m=p?K({doc:t,t:i,controller:p,getSlides:()=>o.bridge.getSlides(),onSendDirective:u=>{c?.sendMessage(u);}}):null,l=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkOBWXMT2T_cjs.wm(t,"form","pptxv-ai-composer"),d=chunkOBWXMT2T_cjs.wm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkOBWXMT2T_cjs.Hm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkOBWXMT2T_cjs.om)({bridge:o.bridge,config:o.config});}catch{return s.textContent=i("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,m?.destroy(),{destroy:()=>n.replaceChildren()}}let r=c,b=O({doc:t,t:i,deckId:chunkOBWXMT2T_cjs.mm(o.bridge),store:o.historyStore,getMessages:()=>r.getSnapshot().messages,setMessages:u=>r.setMessages(u)});a.insertBefore(b.button,x),n.appendChild(b.el);let k=r.subscribe(()=>b.notifyMessagesChanged()),T=new Set,P=u=>{if(!p)return;let A=u.messages.flatMap(Y=>chunkOBWXMT2T_cjs.fm(Y).filter(Z=>Z.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||T.has(A.toolCallId))return;T.add(A.toolCallId);let L=chunkOBWXMT2T_cjs.tm(A.toolName,A.input);L&&L.slideIndex!==void 0&&o.goToSlide?.(L.slideIndex),p.flashToolTarget(L);},M=u=>{q(t,l,u.messages,i),s.hidden=u.messages.length>0,u.messages.length===0&&l.appendChild(s),G(t,g,r.proposals.list(),i,{accept:A=>{p?.flashToolTarget(null),r.proposals.apply(A),M(r.getSnapshot());},reject:A=>{r.proposals.revert(A),M(r.getSnapshot());},acceptAll:()=>{p?.flashToolTarget(null),r.proposals.acceptAll(),M(r.getSnapshot());}});let w=u.status==="submitted"||u.status==="streaming";n.classList.toggle("is-busy",w),y.setAttribute("aria-label",i(w?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!u.error,f.textContent=u.error?i("pptx.ai.errorPrefix"):"",l.scrollTop=l.scrollHeight,P(u);},S=()=>{if(n.classList.contains("is-busy")){r.stop();return}let u=d.value.trim();u&&(d.value="",r.sendMessage(u));};C.addEventListener("submit",u=>{u.preventDefault(),S();}),d.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),S());});let I=p?.getPrefill().nonce??0,J=()=>{if(!p)return;let u=p.getPrefill();u.nonce!==I&&(I=u.nonce,d.value=u.text,d.focus());},Q=p?.subscribe(J),X=r.subscribe(M);return M(r.getSnapshot()),{changeAnimator:r.changeAnimator,destroy(){X(),k(),b.destroy(),Q?.(),m?.destroy(),n.replaceChildren();}}}exports.createAiPanel=wt;
1
+ 'use strict';var chunk2ENSC46Y_cjs=require('./chunk-2ENSC46Y.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunk2ENSC46Y_cjs.wm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunk2ENSC46Y_cjs.Hm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-focus-row"),f=chunk2ENSC46Y_cjs.wm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunk2ENSC46Y_cjs.jm(p,o.getSlides())){let b=chunk2ENSC46Y_cjs.wm(t,"span","pptxv-ai-focus-chip");(m||l)&&b.classList.add("is-strong"),b.title=r.title,b.textContent=r.label,g.appendChild(b);}if(l){let r=chunk2ENSC46Y_cjs.wm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-focus-actions"),d=chunk2ENSC46Y_cjs.km(p,o.getSlides());if(d){let r=chunk2ENSC46Y_cjs.wm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunk2ENSC46Y_cjs.Hm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunk2ENSC46Y_cjs.lm(d.slideIndex,d.elementIdA,d.elementIdB))),C.appendChild(r);}let y=h("crosshair",n("pptx.ai.pickElement"),()=>s?i.stopPicking():i.startPicking());if(y.setAttribute("aria-pressed",String(s)),y.classList.toggle("is-active",s),C.appendChild(y),m?C.appendChild(h("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):l?C.appendChild(h("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):C.appendChild(h("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),g.appendChild(C),a.appendChild(g),s){let r=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-focus-pick"),b=chunk2ENSC46Y_cjs.Hm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunk2ENSC46Y_cjs.wm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunk2ENSC46Y_cjs.wm(t,"button","pptxv-ai-focus-pick-done");T.type="button",T.textContent=n("pptx.ai.pickDone"),T.addEventListener("click",()=>i.stopPicking()),r.append(b,k,T),a.appendChild(r);}},c=i.subscribe(x);return x(),{el:a,destroy(){c(),a.remove();}}}function O(o){let{doc:t,t:n}=o,i=chunk2ENSC46Y_cjs.wm(t,"button","pptxv-ai-chats");i.type="button",i.append(chunk2ENSC46Y_cjs.Hm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-history");a.hidden=true;let h=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-history-head"),x=chunk2ENSC46Y_cjs.wm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunk2ENSC46Y_cjs.wm(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunk2ENSC46Y_cjs.Hm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-history-body"),m=chunk2ENSC46Y_cjs.wm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunk2ENSC46Y_cjs.nm({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:n("pptx.ai.untitledChat"),onChatsChanged:()=>s()});function s(){p.replaceChildren();let f=l.chats();if(f.length===0){let d=chunk2ENSC46Y_cjs.wm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunk2ENSC46Y_cjs.wm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunk2ENSC46Y_cjs.wm(t,"li","pptxv-ai-history-row"),r=chunk2ENSC46Y_cjs.wm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunk2ENSC46Y_cjs.wm(t,"span","pptxv-ai-history-text"),k=chunk2ENSC46Y_cjs.wm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunk2ENSC46Y_cjs.wm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunk2ENSC46Y_cjs.Hm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunk2ENSC46Y_cjs.wm(t,"button","pptxv-ai-history-delete");P.type="button",P.title=n("pptx.ai.deleteChat"),P.setAttribute("aria-label",n("pptx.ai.deleteChat")),P.appendChild(chunk2ENSC46Y_cjs.Hm(t,"trash")),P.addEventListener("click",()=>{l.deleteChat(d.id);}),y.append(r,P),C.appendChild(y);}p.appendChild(C);}s(),i.addEventListener("click",()=>{a.hidden=!a.hidden;}),c.addEventListener("click",()=>{l.newChat(),a.hidden=true;});let g=f=>{a.hidden||!(f.target instanceof Node)||!a.contains(f.target)&&!i.contains(f.target)&&(a.hidden=true);};return t.addEventListener("mousedown",g),{button:i,el:a,notifyMessagesChanged:()=>l.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",g),l.dispose(),i.remove(),a.remove();}}}var _={view:"eye",text:"text-box",shape:"shapes",theme:"font-color",table:"table",slide:"layout",chart:"chart",move:"move-right",delete:"trash",search:"search",nav:"move-right",animation:"play",notes:"sticky-note",tool:"wrench"};function W(o,t,n){let i=t.state==="output-error",a=t.state==="output-available",h=!i&&!a,x=chunk2ENSC46Y_cjs.sm(t.toolName,t.input,h?"present":"past"),c=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-tool"),p=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-tool-head"),m=chunk2ENSC46Y_cjs.Hm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunk2ENSC46Y_cjs.wm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunk2ENSC46Y_cjs.wm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunk2ENSC46Y_cjs.Hm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunk2ENSC46Y_cjs.Hm(o,"check"),o.createTextNode(n("pptx.ai.toolDone")))):(s.classList.add("is-running"),s.textContent=n("pptx.ai.toolRunning")),p.append(m,l,s),c.appendChild(p),i&&t.errorText){let f=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunk2ENSC46Y_cjs.rm(t.input);if(g){let f=chunk2ENSC46Y_cjs.wm(o,"details","pptxv-ai-tool-details"),C=chunk2ENSC46Y_cjs.wm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunk2ENSC46Y_cjs.qm(t.toolName)}: ${g}`,f.append(C,d),c.appendChild(f);}return c}function q(o,t,n,i){t.replaceChildren();for(let a of n){if(a.role==="system")continue;let h=a.role==="user",x=chunk2ENSC46Y_cjs.fm(a);if(x.length===0&&!h)continue;let c=chunk2ENSC46Y_cjs.wm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunk2ENSC46Y_cjs.Hm(o,h?"comment":"sparkles"));let m=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-msg-text");s.textContent=l.text,m.appendChild(s);}else m.appendChild(W(o,l,i));c.append(p,m),t.appendChild(c);}}function G(o,t,n,i,a){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let h=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-proposals-header"),x=chunk2ENSC46Y_cjs.wm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunk2ENSC46Y_cjs.wm(o,"button","pptxv-ai-proposal-btn is-accept-all");c.type="button",c.textContent=i("pptx.ai.acceptAll"),c.addEventListener("click",()=>a.acceptAll()),h.appendChild(c);}t.appendChild(h);for(let c of n)t.appendChild(tt(o,c,i,a));}function tt(o,t,n,i){let a=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunk2ENSC46Y_cjs.wm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunk2ENSC46Y_cjs.wm(o,"li");g.textContent=chunk2ENSC46Y_cjs.cm(s),l.appendChild(g);}a.appendChild(l);}let c=chunk2ENSC46Y_cjs.wm(o,"div","pptxv-ai-proposal-actions"),p=chunk2ENSC46Y_cjs.wm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunk2ENSC46Y_cjs.Hm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunk2ENSC46Y_cjs.wm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunk2ENSC46Y_cjs.Hm(o,"close"),o.createTextNode(n("pptx.ai.reject"))),m.addEventListener("click",()=>i.reject(t.id)),c.append(p,m),a.appendChild(c),a}async function wt(o){let{doc:t,host:n,t:i}=o;n.replaceChildren();let a=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-header"),h=chunk2ENSC46Y_cjs.wm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunk2ENSC46Y_cjs.wm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunk2ENSC46Y_cjs.Hm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunk2ENSC46Y_cjs.Hm(t,"sparkles"),h,x);let c,p=o.controller,m=p?K({doc:t,t:i,controller:p,getSlides:()=>o.bridge.getSlides(),onSendDirective:u=>{c?.sendMessage(u);}}):null,l=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunk2ENSC46Y_cjs.wm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunk2ENSC46Y_cjs.wm(t,"form","pptxv-ai-composer"),d=chunk2ENSC46Y_cjs.wm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunk2ENSC46Y_cjs.wm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunk2ENSC46Y_cjs.Hm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunk2ENSC46Y_cjs.om)({bridge:o.bridge,config:o.config});}catch{return s.textContent=i("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,m?.destroy(),{destroy:()=>n.replaceChildren()}}let r=c,b=O({doc:t,t:i,deckId:chunk2ENSC46Y_cjs.mm(o.bridge),store:o.historyStore,getMessages:()=>r.getSnapshot().messages,setMessages:u=>r.setMessages(u)});a.insertBefore(b.button,x),n.appendChild(b.el);let k=r.subscribe(()=>b.notifyMessagesChanged()),T=new Set,P=u=>{if(!p)return;let A=u.messages.flatMap(Y=>chunk2ENSC46Y_cjs.fm(Y).filter(Z=>Z.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||T.has(A.toolCallId))return;T.add(A.toolCallId);let L=chunk2ENSC46Y_cjs.tm(A.toolName,A.input);L&&L.slideIndex!==void 0&&o.goToSlide?.(L.slideIndex),p.flashToolTarget(L);},M=u=>{q(t,l,u.messages,i),s.hidden=u.messages.length>0,u.messages.length===0&&l.appendChild(s),G(t,g,r.proposals.list(),i,{accept:A=>{p?.flashToolTarget(null),r.proposals.apply(A),M(r.getSnapshot());},reject:A=>{r.proposals.revert(A),M(r.getSnapshot());},acceptAll:()=>{p?.flashToolTarget(null),r.proposals.acceptAll(),M(r.getSnapshot());}});let w=u.status==="submitted"||u.status==="streaming";n.classList.toggle("is-busy",w),y.setAttribute("aria-label",i(w?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!u.error,f.textContent=u.error?i("pptx.ai.errorPrefix"):"",l.scrollTop=l.scrollHeight,P(u);},S=()=>{if(n.classList.contains("is-busy")){r.stop();return}let u=d.value.trim();u&&(d.value="",r.sendMessage(u));};C.addEventListener("submit",u=>{u.preventDefault(),S();}),d.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),S());});let I=p?.getPrefill().nonce??0,J=()=>{if(!p)return;let u=p.getPrefill();u.nonce!==I&&(I=u.nonce,d.value=u.text,d.focus());},Q=p?.subscribe(J),X=r.subscribe(M);return M(r.getSnapshot()),{changeAnimator:r.changeAnimator,destroy(){X(),k(),b.destroy(),Q?.(),m?.destroy(),n.replaceChildren();}}}exports.createAiPanel=wt;
@@ -1 +1 @@
1
- import {wm,Hm,om,mm,nm,fm,tm,jm,km,lm,sm,rm,qm,cm}from'./chunk-SG47CFJD.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=wm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=wm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Hm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=wm(t,"div","pptxv-ai-focus-row"),f=wm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of jm(p,o.getSlides())){let b=wm(t,"span","pptxv-ai-focus-chip");(m||l)&&b.classList.add("is-strong"),b.title=r.title,b.textContent=r.label,g.appendChild(b);}if(l){let r=wm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=wm(t,"div","pptxv-ai-focus-actions"),d=km(p,o.getSlides());if(d){let r=wm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Hm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(lm(d.slideIndex,d.elementIdA,d.elementIdB))),C.appendChild(r);}let y=h("crosshair",n("pptx.ai.pickElement"),()=>s?i.stopPicking():i.startPicking());if(y.setAttribute("aria-pressed",String(s)),y.classList.toggle("is-active",s),C.appendChild(y),m?C.appendChild(h("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):l?C.appendChild(h("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):C.appendChild(h("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),g.appendChild(C),a.appendChild(g),s){let r=wm(t,"div","pptxv-ai-focus-pick"),b=Hm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=wm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=wm(t,"button","pptxv-ai-focus-pick-done");T.type="button",T.textContent=n("pptx.ai.pickDone"),T.addEventListener("click",()=>i.stopPicking()),r.append(b,k,T),a.appendChild(r);}},c=i.subscribe(x);return x(),{el:a,destroy(){c(),a.remove();}}}function O(o){let{doc:t,t:n}=o,i=wm(t,"button","pptxv-ai-chats");i.type="button",i.append(Hm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=wm(t,"div","pptxv-ai-history");a.hidden=true;let h=wm(t,"div","pptxv-ai-history-head"),x=wm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=wm(t,"button","pptxv-ai-history-new");c.type="button",c.append(Hm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=wm(t,"div","pptxv-ai-history-body"),m=wm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=nm({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:n("pptx.ai.untitledChat"),onChatsChanged:()=>s()});function s(){p.replaceChildren();let f=l.chats();if(f.length===0){let d=wm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=wm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=wm(t,"li","pptxv-ai-history-row"),r=wm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=wm(t,"span","pptxv-ai-history-text"),k=wm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=wm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Hm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=wm(t,"button","pptxv-ai-history-delete");P.type="button",P.title=n("pptx.ai.deleteChat"),P.setAttribute("aria-label",n("pptx.ai.deleteChat")),P.appendChild(Hm(t,"trash")),P.addEventListener("click",()=>{l.deleteChat(d.id);}),y.append(r,P),C.appendChild(y);}p.appendChild(C);}s(),i.addEventListener("click",()=>{a.hidden=!a.hidden;}),c.addEventListener("click",()=>{l.newChat(),a.hidden=true;});let g=f=>{a.hidden||!(f.target instanceof Node)||!a.contains(f.target)&&!i.contains(f.target)&&(a.hidden=true);};return t.addEventListener("mousedown",g),{button:i,el:a,notifyMessagesChanged:()=>l.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",g),l.dispose(),i.remove(),a.remove();}}}var _={view:"eye",text:"text-box",shape:"shapes",theme:"font-color",table:"table",slide:"layout",chart:"chart",move:"move-right",delete:"trash",search:"search",nav:"move-right",animation:"play",notes:"sticky-note",tool:"wrench"};function W(o,t,n){let i=t.state==="output-error",a=t.state==="output-available",h=!i&&!a,x=sm(t.toolName,t.input,h?"present":"past"),c=wm(o,"div","pptxv-ai-tool"),p=wm(o,"div","pptxv-ai-tool-head"),m=Hm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=wm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=wm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Hm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Hm(o,"check"),o.createTextNode(n("pptx.ai.toolDone")))):(s.classList.add("is-running"),s.textContent=n("pptx.ai.toolRunning")),p.append(m,l,s),c.appendChild(p),i&&t.errorText){let f=wm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=rm(t.input);if(g){let f=wm(o,"details","pptxv-ai-tool-details"),C=wm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=wm(o,"div","pptxv-ai-tool-raw");d.textContent=`${qm(t.toolName)}: ${g}`,f.append(C,d),c.appendChild(f);}return c}function q(o,t,n,i){t.replaceChildren();for(let a of n){if(a.role==="system")continue;let h=a.role==="user",x=fm(a);if(x.length===0&&!h)continue;let c=wm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=wm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Hm(o,h?"comment":"sparkles"));let m=wm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=wm(o,"div","pptxv-ai-msg-text");s.textContent=l.text,m.appendChild(s);}else m.appendChild(W(o,l,i));c.append(p,m),t.appendChild(c);}}function G(o,t,n,i,a){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let h=wm(o,"div","pptxv-ai-proposals-header"),x=wm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=wm(o,"button","pptxv-ai-proposal-btn is-accept-all");c.type="button",c.textContent=i("pptx.ai.acceptAll"),c.addEventListener("click",()=>a.acceptAll()),h.appendChild(c);}t.appendChild(h);for(let c of n)t.appendChild(tt(o,c,i,a));}function tt(o,t,n,i){let a=wm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=wm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=wm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=wm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=wm(o,"li");g.textContent=cm(s),l.appendChild(g);}a.appendChild(l);}let c=wm(o,"div","pptxv-ai-proposal-actions"),p=wm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Hm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=wm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Hm(o,"close"),o.createTextNode(n("pptx.ai.reject"))),m.addEventListener("click",()=>i.reject(t.id)),c.append(p,m),a.appendChild(c),a}async function wt(o){let{doc:t,host:n,t:i}=o;n.replaceChildren();let a=wm(t,"div","pptxv-ai-header"),h=wm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=wm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Hm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Hm(t,"sparkles"),h,x);let c,p=o.controller,m=p?K({doc:t,t:i,controller:p,getSlides:()=>o.bridge.getSlides(),onSendDirective:u=>{c?.sendMessage(u);}}):null,l=wm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=wm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=wm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=wm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=wm(t,"form","pptxv-ai-composer"),d=wm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=wm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Hm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??om)({bridge:o.bridge,config:o.config});}catch{return s.textContent=i("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,m?.destroy(),{destroy:()=>n.replaceChildren()}}let r=c,b=O({doc:t,t:i,deckId:mm(o.bridge),store:o.historyStore,getMessages:()=>r.getSnapshot().messages,setMessages:u=>r.setMessages(u)});a.insertBefore(b.button,x),n.appendChild(b.el);let k=r.subscribe(()=>b.notifyMessagesChanged()),T=new Set,P=u=>{if(!p)return;let A=u.messages.flatMap(Y=>fm(Y).filter(Z=>Z.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||T.has(A.toolCallId))return;T.add(A.toolCallId);let L=tm(A.toolName,A.input);L&&L.slideIndex!==void 0&&o.goToSlide?.(L.slideIndex),p.flashToolTarget(L);},M=u=>{q(t,l,u.messages,i),s.hidden=u.messages.length>0,u.messages.length===0&&l.appendChild(s),G(t,g,r.proposals.list(),i,{accept:A=>{p?.flashToolTarget(null),r.proposals.apply(A),M(r.getSnapshot());},reject:A=>{r.proposals.revert(A),M(r.getSnapshot());},acceptAll:()=>{p?.flashToolTarget(null),r.proposals.acceptAll(),M(r.getSnapshot());}});let w=u.status==="submitted"||u.status==="streaming";n.classList.toggle("is-busy",w),y.setAttribute("aria-label",i(w?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!u.error,f.textContent=u.error?i("pptx.ai.errorPrefix"):"",l.scrollTop=l.scrollHeight,P(u);},S=()=>{if(n.classList.contains("is-busy")){r.stop();return}let u=d.value.trim();u&&(d.value="",r.sendMessage(u));};C.addEventListener("submit",u=>{u.preventDefault(),S();}),d.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),S());});let I=p?.getPrefill().nonce??0,J=()=>{if(!p)return;let u=p.getPrefill();u.nonce!==I&&(I=u.nonce,d.value=u.text,d.focus());},Q=p?.subscribe(J),X=r.subscribe(M);return M(r.getSnapshot()),{changeAnimator:r.changeAnimator,destroy(){X(),k(),b.destroy(),Q?.(),m?.destroy(),n.replaceChildren();}}}export{wt as createAiPanel};
1
+ import {wm,Hm,om,mm,nm,fm,tm,jm,km,lm,sm,rm,qm,cm}from'./chunk-X7BSCIES.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=wm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=wm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Hm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=wm(t,"div","pptxv-ai-focus-row"),f=wm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of jm(p,o.getSlides())){let b=wm(t,"span","pptxv-ai-focus-chip");(m||l)&&b.classList.add("is-strong"),b.title=r.title,b.textContent=r.label,g.appendChild(b);}if(l){let r=wm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=wm(t,"div","pptxv-ai-focus-actions"),d=km(p,o.getSlides());if(d){let r=wm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Hm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(lm(d.slideIndex,d.elementIdA,d.elementIdB))),C.appendChild(r);}let y=h("crosshair",n("pptx.ai.pickElement"),()=>s?i.stopPicking():i.startPicking());if(y.setAttribute("aria-pressed",String(s)),y.classList.toggle("is-active",s),C.appendChild(y),m?C.appendChild(h("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):l?C.appendChild(h("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):C.appendChild(h("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),g.appendChild(C),a.appendChild(g),s){let r=wm(t,"div","pptxv-ai-focus-pick"),b=Hm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=wm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=wm(t,"button","pptxv-ai-focus-pick-done");T.type="button",T.textContent=n("pptx.ai.pickDone"),T.addEventListener("click",()=>i.stopPicking()),r.append(b,k,T),a.appendChild(r);}},c=i.subscribe(x);return x(),{el:a,destroy(){c(),a.remove();}}}function O(o){let{doc:t,t:n}=o,i=wm(t,"button","pptxv-ai-chats");i.type="button",i.append(Hm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=wm(t,"div","pptxv-ai-history");a.hidden=true;let h=wm(t,"div","pptxv-ai-history-head"),x=wm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=wm(t,"button","pptxv-ai-history-new");c.type="button",c.append(Hm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=wm(t,"div","pptxv-ai-history-body"),m=wm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=nm({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:n("pptx.ai.untitledChat"),onChatsChanged:()=>s()});function s(){p.replaceChildren();let f=l.chats();if(f.length===0){let d=wm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=wm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=wm(t,"li","pptxv-ai-history-row"),r=wm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=wm(t,"span","pptxv-ai-history-text"),k=wm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=wm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Hm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=wm(t,"button","pptxv-ai-history-delete");P.type="button",P.title=n("pptx.ai.deleteChat"),P.setAttribute("aria-label",n("pptx.ai.deleteChat")),P.appendChild(Hm(t,"trash")),P.addEventListener("click",()=>{l.deleteChat(d.id);}),y.append(r,P),C.appendChild(y);}p.appendChild(C);}s(),i.addEventListener("click",()=>{a.hidden=!a.hidden;}),c.addEventListener("click",()=>{l.newChat(),a.hidden=true;});let g=f=>{a.hidden||!(f.target instanceof Node)||!a.contains(f.target)&&!i.contains(f.target)&&(a.hidden=true);};return t.addEventListener("mousedown",g),{button:i,el:a,notifyMessagesChanged:()=>l.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",g),l.dispose(),i.remove(),a.remove();}}}var _={view:"eye",text:"text-box",shape:"shapes",theme:"font-color",table:"table",slide:"layout",chart:"chart",move:"move-right",delete:"trash",search:"search",nav:"move-right",animation:"play",notes:"sticky-note",tool:"wrench"};function W(o,t,n){let i=t.state==="output-error",a=t.state==="output-available",h=!i&&!a,x=sm(t.toolName,t.input,h?"present":"past"),c=wm(o,"div","pptxv-ai-tool"),p=wm(o,"div","pptxv-ai-tool-head"),m=Hm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=wm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=wm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Hm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Hm(o,"check"),o.createTextNode(n("pptx.ai.toolDone")))):(s.classList.add("is-running"),s.textContent=n("pptx.ai.toolRunning")),p.append(m,l,s),c.appendChild(p),i&&t.errorText){let f=wm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=rm(t.input);if(g){let f=wm(o,"details","pptxv-ai-tool-details"),C=wm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=wm(o,"div","pptxv-ai-tool-raw");d.textContent=`${qm(t.toolName)}: ${g}`,f.append(C,d),c.appendChild(f);}return c}function q(o,t,n,i){t.replaceChildren();for(let a of n){if(a.role==="system")continue;let h=a.role==="user",x=fm(a);if(x.length===0&&!h)continue;let c=wm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=wm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Hm(o,h?"comment":"sparkles"));let m=wm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=wm(o,"div","pptxv-ai-msg-text");s.textContent=l.text,m.appendChild(s);}else m.appendChild(W(o,l,i));c.append(p,m),t.appendChild(c);}}function G(o,t,n,i,a){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let h=wm(o,"div","pptxv-ai-proposals-header"),x=wm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=wm(o,"button","pptxv-ai-proposal-btn is-accept-all");c.type="button",c.textContent=i("pptx.ai.acceptAll"),c.addEventListener("click",()=>a.acceptAll()),h.appendChild(c);}t.appendChild(h);for(let c of n)t.appendChild(tt(o,c,i,a));}function tt(o,t,n,i){let a=wm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=wm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=wm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=wm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=wm(o,"li");g.textContent=cm(s),l.appendChild(g);}a.appendChild(l);}let c=wm(o,"div","pptxv-ai-proposal-actions"),p=wm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Hm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=wm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Hm(o,"close"),o.createTextNode(n("pptx.ai.reject"))),m.addEventListener("click",()=>i.reject(t.id)),c.append(p,m),a.appendChild(c),a}async function wt(o){let{doc:t,host:n,t:i}=o;n.replaceChildren();let a=wm(t,"div","pptxv-ai-header"),h=wm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=wm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Hm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Hm(t,"sparkles"),h,x);let c,p=o.controller,m=p?K({doc:t,t:i,controller:p,getSlides:()=>o.bridge.getSlides(),onSendDirective:u=>{c?.sendMessage(u);}}):null,l=wm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=wm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=wm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=wm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=wm(t,"form","pptxv-ai-composer"),d=wm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=wm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Hm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??om)({bridge:o.bridge,config:o.config});}catch{return s.textContent=i("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,m?.destroy(),{destroy:()=>n.replaceChildren()}}let r=c,b=O({doc:t,t:i,deckId:mm(o.bridge),store:o.historyStore,getMessages:()=>r.getSnapshot().messages,setMessages:u=>r.setMessages(u)});a.insertBefore(b.button,x),n.appendChild(b.el);let k=r.subscribe(()=>b.notifyMessagesChanged()),T=new Set,P=u=>{if(!p)return;let A=u.messages.flatMap(Y=>fm(Y).filter(Z=>Z.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||T.has(A.toolCallId))return;T.add(A.toolCallId);let L=tm(A.toolName,A.input);L&&L.slideIndex!==void 0&&o.goToSlide?.(L.slideIndex),p.flashToolTarget(L);},M=u=>{q(t,l,u.messages,i),s.hidden=u.messages.length>0,u.messages.length===0&&l.appendChild(s),G(t,g,r.proposals.list(),i,{accept:A=>{p?.flashToolTarget(null),r.proposals.apply(A),M(r.getSnapshot());},reject:A=>{r.proposals.revert(A),M(r.getSnapshot());},acceptAll:()=>{p?.flashToolTarget(null),r.proposals.acceptAll(),M(r.getSnapshot());}});let w=u.status==="submitted"||u.status==="streaming";n.classList.toggle("is-busy",w),y.setAttribute("aria-label",i(w?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!u.error,f.textContent=u.error?i("pptx.ai.errorPrefix"):"",l.scrollTop=l.scrollHeight,P(u);},S=()=>{if(n.classList.contains("is-busy")){r.stop();return}let u=d.value.trim();u&&(d.value="",r.sendMessage(u));};C.addEventListener("submit",u=>{u.preventDefault(),S();}),d.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),S());});let I=p?.getPrefill().nonce??0,J=()=>{if(!p)return;let u=p.getPrefill();u.nonce!==I&&(I=u.nonce,d.value=u.text,d.focus());},Q=p?.subscribe(J),X=r.subscribe(M);return M(r.getSnapshot()),{changeAnimator:r.changeAnimator,destroy(){X(),k(),b.destroy(),Q?.(),m?.destroy(),n.replaceChildren();}}}export{wt as createAiPanel};