pptx-vanilla-viewer 2.1.2 → 2.1.3

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,21 @@ 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.1.2](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.1.2) - 2026-08-28
11
+
12
+ ### Bug Fixes
13
+
14
+ - **vanilla:** Center the title-bar search box instead of absolute-positioning it (by @ChristopherVR) ([ae0816d](https://github.com/ChristopherVR/pptx-viewer/commit/ae0816dfd656320488a68bdf227bf90d7a50c6b0))
15
+ - **ui:** Stop ribbon action buttons from stretching to fill the row height (by @ChristopherVR) ([d53ce5b](https://github.com/ChristopherVR/pptx-viewer/commit/d53ce5b4b00e5cfaab70d8a230f37d3f0c241a96))
16
+ - **core:** Reindex chart data-point overrides after removing a category (by @ChristopherVR) ([7bd64f8](https://github.com/ChristopherVR/pptx-viewer/commit/7bd64f821d66d1bc7b3f91f46a3e262eda1072ee))
17
+ - **shared:** Repair print, drop Package for Sharing, wire Options behavior (by @ChristopherVR) ([bcc2ac7](https://github.com/ChristopherVR/pptx-viewer/commit/bcc2ac7420b50f69d7217f3b9915f0b3e0698640))
18
+ - **vanilla:** Repair print, drop Package for Sharing, wire Options behavior (by @ChristopherVR) ([00b0697](https://github.com/ChristopherVR/pptx-viewer/commit/00b0697c2def0ba01fabada2e388cc0bdc361268))
19
+ - **vanilla:** Remove an em-dash from the Protected View banner text (by @ChristopherVR) ([ba2dc03](https://github.com/ChristopherVR/pptx-viewer/commit/ba2dc0381f857093cebf79e411d91aebf673f8aa))
20
+
21
+ ### Security
22
+
23
+ - **shared:** Drop duplicate Protected View banner strings (by @ChristopherVR) ([1c35863](https://github.com/ChristopherVR/pptx-viewer/commit/1c358639246cc7fe058e2afe6f95cf52893dfff7))
24
+
10
25
  ## [2.1.1](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.1.1) - 2026-08-28
11
26
 
12
27
  ### Bug Fixes
@@ -1 +1 @@
1
- 'use strict';var chunkVVRZW27J_cjs=require('./chunk-VVRZW27J.cjs');require('./chunk-4VDLQK6F.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkVVRZW27J_cjs.rl(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkVVRZW27J_cjs.Cl(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-focus-row"),f=chunkVVRZW27J_cjs.rl(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkVVRZW27J_cjs.ml(p,o.getSlides())){let b=chunkVVRZW27J_cjs.rl(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=chunkVVRZW27J_cjs.rl(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-focus-actions"),d=chunkVVRZW27J_cjs.nl(p,o.getSlides());if(d){let r=chunkVVRZW27J_cjs.rl(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkVVRZW27J_cjs.Cl(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkVVRZW27J_cjs.ol(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=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-focus-pick"),b=chunkVVRZW27J_cjs.Cl(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkVVRZW27J_cjs.rl(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkVVRZW27J_cjs.rl(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=chunkVVRZW27J_cjs.rl(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkVVRZW27J_cjs.Cl(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-history-head"),x=chunkVVRZW27J_cjs.rl(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkVVRZW27J_cjs.rl(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkVVRZW27J_cjs.Cl(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-history-body"),m=chunkVVRZW27J_cjs.rl(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkVVRZW27J_cjs.Il({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=chunkVVRZW27J_cjs.rl(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkVVRZW27J_cjs.rl(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkVVRZW27J_cjs.rl(t,"li","pptxv-ai-history-row"),r=chunkVVRZW27J_cjs.rl(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkVVRZW27J_cjs.rl(t,"span","pptxv-ai-history-text"),k=chunkVVRZW27J_cjs.rl(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkVVRZW27J_cjs.rl(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkVVRZW27J_cjs.Cl(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkVVRZW27J_cjs.rl(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(chunkVVRZW27J_cjs.Cl(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=chunkVVRZW27J_cjs.Nl(t.toolName,t.input,h?"present":"past"),c=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-tool"),p=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-tool-head"),m=chunkVVRZW27J_cjs.Cl(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkVVRZW27J_cjs.rl(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkVVRZW27J_cjs.rl(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkVVRZW27J_cjs.Cl(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkVVRZW27J_cjs.Cl(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=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkVVRZW27J_cjs.Ml(t.input);if(g){let f=chunkVVRZW27J_cjs.rl(o,"details","pptxv-ai-tool-details"),C=chunkVVRZW27J_cjs.rl(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkVVRZW27J_cjs.Ll(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=chunkVVRZW27J_cjs.Kl(a);if(x.length===0&&!h)continue;let c=chunkVVRZW27J_cjs.rl(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkVVRZW27J_cjs.Cl(o,h?"comment":"sparkles"));let m=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkVVRZW27J_cjs.rl(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=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-proposals-header"),x=chunkVVRZW27J_cjs.rl(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkVVRZW27J_cjs.rl(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=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkVVRZW27J_cjs.rl(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkVVRZW27J_cjs.rl(o,"li");g.textContent=chunkVVRZW27J_cjs.El(s),l.appendChild(g);}a.appendChild(l);}let c=chunkVVRZW27J_cjs.rl(o,"div","pptxv-ai-proposal-actions"),p=chunkVVRZW27J_cjs.rl(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkVVRZW27J_cjs.Cl(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkVVRZW27J_cjs.rl(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkVVRZW27J_cjs.Cl(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=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-header"),h=chunkVVRZW27J_cjs.rl(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkVVRZW27J_cjs.rl(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkVVRZW27J_cjs.Cl(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkVVRZW27J_cjs.Cl(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=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkVVRZW27J_cjs.rl(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkVVRZW27J_cjs.rl(t,"form","pptxv-ai-composer"),d=chunkVVRZW27J_cjs.rl(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkVVRZW27J_cjs.rl(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkVVRZW27J_cjs.Cl(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkVVRZW27J_cjs.Jl)({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:chunkVVRZW27J_cjs.Hl(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=>chunkVVRZW27J_cjs.Kl(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=chunkVVRZW27J_cjs.Ol(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 chunkCM2O2VZ7_cjs=require('./chunk-CM2O2VZ7.cjs');require('./chunk-4VDLQK6F.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkCM2O2VZ7_cjs.rl(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkCM2O2VZ7_cjs.Cl(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-focus-row"),f=chunkCM2O2VZ7_cjs.rl(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkCM2O2VZ7_cjs.ml(p,o.getSlides())){let b=chunkCM2O2VZ7_cjs.rl(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=chunkCM2O2VZ7_cjs.rl(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-focus-actions"),d=chunkCM2O2VZ7_cjs.nl(p,o.getSlides());if(d){let r=chunkCM2O2VZ7_cjs.rl(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkCM2O2VZ7_cjs.Cl(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkCM2O2VZ7_cjs.ol(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=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-focus-pick"),b=chunkCM2O2VZ7_cjs.Cl(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkCM2O2VZ7_cjs.rl(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkCM2O2VZ7_cjs.rl(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=chunkCM2O2VZ7_cjs.rl(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkCM2O2VZ7_cjs.Cl(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-history-head"),x=chunkCM2O2VZ7_cjs.rl(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkCM2O2VZ7_cjs.rl(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkCM2O2VZ7_cjs.Cl(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-history-body"),m=chunkCM2O2VZ7_cjs.rl(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkCM2O2VZ7_cjs.Il({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=chunkCM2O2VZ7_cjs.rl(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkCM2O2VZ7_cjs.rl(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkCM2O2VZ7_cjs.rl(t,"li","pptxv-ai-history-row"),r=chunkCM2O2VZ7_cjs.rl(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkCM2O2VZ7_cjs.rl(t,"span","pptxv-ai-history-text"),k=chunkCM2O2VZ7_cjs.rl(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkCM2O2VZ7_cjs.rl(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkCM2O2VZ7_cjs.Cl(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkCM2O2VZ7_cjs.rl(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(chunkCM2O2VZ7_cjs.Cl(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=chunkCM2O2VZ7_cjs.Nl(t.toolName,t.input,h?"present":"past"),c=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-tool"),p=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-tool-head"),m=chunkCM2O2VZ7_cjs.Cl(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkCM2O2VZ7_cjs.rl(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkCM2O2VZ7_cjs.rl(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkCM2O2VZ7_cjs.Cl(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkCM2O2VZ7_cjs.Cl(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=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkCM2O2VZ7_cjs.Ml(t.input);if(g){let f=chunkCM2O2VZ7_cjs.rl(o,"details","pptxv-ai-tool-details"),C=chunkCM2O2VZ7_cjs.rl(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkCM2O2VZ7_cjs.Ll(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=chunkCM2O2VZ7_cjs.Kl(a);if(x.length===0&&!h)continue;let c=chunkCM2O2VZ7_cjs.rl(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkCM2O2VZ7_cjs.Cl(o,h?"comment":"sparkles"));let m=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkCM2O2VZ7_cjs.rl(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=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-proposals-header"),x=chunkCM2O2VZ7_cjs.rl(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkCM2O2VZ7_cjs.rl(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=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkCM2O2VZ7_cjs.rl(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkCM2O2VZ7_cjs.rl(o,"li");g.textContent=chunkCM2O2VZ7_cjs.El(s),l.appendChild(g);}a.appendChild(l);}let c=chunkCM2O2VZ7_cjs.rl(o,"div","pptxv-ai-proposal-actions"),p=chunkCM2O2VZ7_cjs.rl(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkCM2O2VZ7_cjs.Cl(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkCM2O2VZ7_cjs.rl(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkCM2O2VZ7_cjs.Cl(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=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-header"),h=chunkCM2O2VZ7_cjs.rl(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkCM2O2VZ7_cjs.rl(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkCM2O2VZ7_cjs.Cl(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkCM2O2VZ7_cjs.Cl(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=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkCM2O2VZ7_cjs.rl(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkCM2O2VZ7_cjs.rl(t,"form","pptxv-ai-composer"),d=chunkCM2O2VZ7_cjs.rl(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkCM2O2VZ7_cjs.rl(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkCM2O2VZ7_cjs.Cl(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkCM2O2VZ7_cjs.Jl)({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:chunkCM2O2VZ7_cjs.Hl(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=>chunkCM2O2VZ7_cjs.Kl(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=chunkCM2O2VZ7_cjs.Ol(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 {rl,Cl,Jl,Hl,Il,Kl,Ol,ml,nl,ol,Nl,Ml,Ll,El}from'./chunk-H2OCDYY3.js';import'./chunk-WOT6VMZA.js';function K(o){let{doc:t,t:n,controller:i}=o,a=rl(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=rl(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Cl(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=rl(t,"div","pptxv-ai-focus-row"),f=rl(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of ml(p,o.getSlides())){let b=rl(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=rl(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=rl(t,"div","pptxv-ai-focus-actions"),d=nl(p,o.getSlides());if(d){let r=rl(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Cl(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(ol(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=rl(t,"div","pptxv-ai-focus-pick"),b=Cl(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=rl(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=rl(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=rl(t,"button","pptxv-ai-chats");i.type="button",i.append(Cl(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=rl(t,"div","pptxv-ai-history");a.hidden=true;let h=rl(t,"div","pptxv-ai-history-head"),x=rl(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=rl(t,"button","pptxv-ai-history-new");c.type="button",c.append(Cl(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=rl(t,"div","pptxv-ai-history-body"),m=rl(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=Il({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=rl(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=rl(t,"ul","pptxv-ai-history-list");for(let d of f){let y=rl(t,"li","pptxv-ai-history-row"),r=rl(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=rl(t,"span","pptxv-ai-history-text"),k=rl(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=rl(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Cl(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=rl(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(Cl(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=Nl(t.toolName,t.input,h?"present":"past"),c=rl(o,"div","pptxv-ai-tool"),p=rl(o,"div","pptxv-ai-tool-head"),m=Cl(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=rl(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=rl(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Cl(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Cl(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=rl(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=Ml(t.input);if(g){let f=rl(o,"details","pptxv-ai-tool-details"),C=rl(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=rl(o,"div","pptxv-ai-tool-raw");d.textContent=`${Ll(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=Kl(a);if(x.length===0&&!h)continue;let c=rl(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=rl(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Cl(o,h?"comment":"sparkles"));let m=rl(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=rl(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=rl(o,"div","pptxv-ai-proposals-header"),x=rl(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=rl(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=rl(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=rl(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=rl(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=rl(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=rl(o,"li");g.textContent=El(s),l.appendChild(g);}a.appendChild(l);}let c=rl(o,"div","pptxv-ai-proposal-actions"),p=rl(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Cl(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=rl(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Cl(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=rl(t,"div","pptxv-ai-header"),h=rl(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=rl(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Cl(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Cl(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=rl(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=rl(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=rl(t,"div","pptxv-ai-proposals");g.hidden=true;let f=rl(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=rl(t,"form","pptxv-ai-composer"),d=rl(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=rl(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Cl(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??Jl)({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:Hl(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=>Kl(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=Ol(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 {rl,Cl,Jl,Hl,Il,Kl,Ol,ml,nl,ol,Nl,Ml,Ll,El}from'./chunk-MYXVJRWK.js';import'./chunk-WOT6VMZA.js';function K(o){let{doc:t,t:n,controller:i}=o,a=rl(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=rl(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Cl(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=rl(t,"div","pptxv-ai-focus-row"),f=rl(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of ml(p,o.getSlides())){let b=rl(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=rl(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=rl(t,"div","pptxv-ai-focus-actions"),d=nl(p,o.getSlides());if(d){let r=rl(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Cl(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(ol(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=rl(t,"div","pptxv-ai-focus-pick"),b=Cl(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=rl(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=rl(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=rl(t,"button","pptxv-ai-chats");i.type="button",i.append(Cl(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=rl(t,"div","pptxv-ai-history");a.hidden=true;let h=rl(t,"div","pptxv-ai-history-head"),x=rl(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=rl(t,"button","pptxv-ai-history-new");c.type="button",c.append(Cl(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=rl(t,"div","pptxv-ai-history-body"),m=rl(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=Il({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=rl(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=rl(t,"ul","pptxv-ai-history-list");for(let d of f){let y=rl(t,"li","pptxv-ai-history-row"),r=rl(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=rl(t,"span","pptxv-ai-history-text"),k=rl(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=rl(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Cl(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=rl(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(Cl(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=Nl(t.toolName,t.input,h?"present":"past"),c=rl(o,"div","pptxv-ai-tool"),p=rl(o,"div","pptxv-ai-tool-head"),m=Cl(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=rl(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=rl(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Cl(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Cl(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=rl(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=Ml(t.input);if(g){let f=rl(o,"details","pptxv-ai-tool-details"),C=rl(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=rl(o,"div","pptxv-ai-tool-raw");d.textContent=`${Ll(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=Kl(a);if(x.length===0&&!h)continue;let c=rl(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=rl(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Cl(o,h?"comment":"sparkles"));let m=rl(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=rl(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=rl(o,"div","pptxv-ai-proposals-header"),x=rl(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=rl(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=rl(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=rl(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=rl(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=rl(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=rl(o,"li");g.textContent=El(s),l.appendChild(g);}a.appendChild(l);}let c=rl(o,"div","pptxv-ai-proposal-actions"),p=rl(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Cl(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=rl(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Cl(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=rl(t,"div","pptxv-ai-header"),h=rl(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=rl(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Cl(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Cl(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=rl(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=rl(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=rl(t,"div","pptxv-ai-proposals");g.hidden=true;let f=rl(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=rl(t,"form","pptxv-ai-composer"),d=rl(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=rl(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Cl(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??Jl)({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:Hl(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=>Kl(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=Ol(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};