pptx-vanilla-viewer 1.16.2 → 1.16.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
@@ -4,6 +4,8 @@ All notable changes to this project are documented here.
4
4
  This file is generated from [Conventional Commits](https://www.conventionalcommits.org)
5
5
  by [git-cliff](https://git-cliff.org); do not edit it by hand.
6
6
 
7
+ ## [1.16.2](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@1.16.2) - 2026-08-07
8
+
7
9
  ## [1.16.1](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@1.16.1) - 2026-08-07
8
10
 
9
11
  ## [1.16.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@1.16.0) - 2026-08-07
@@ -1 +1 @@
1
- 'use strict';var chunkUEOXGECB_cjs=require('./chunk-UEOXGECB.cjs');require('./chunk-4VDLQK6F.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkUEOXGECB_cjs.Ii(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkUEOXGECB_cjs.Ri(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-focus-row"),f=chunkUEOXGECB_cjs.Ii(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkUEOXGECB_cjs.Di(p,o.getSlides())){let b=chunkUEOXGECB_cjs.Ii(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=chunkUEOXGECB_cjs.Ii(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-focus-actions"),d=chunkUEOXGECB_cjs.Ei(p,o.getSlides());if(d){let r=chunkUEOXGECB_cjs.Ii(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkUEOXGECB_cjs.Ri(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkUEOXGECB_cjs.Fi(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=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-focus-pick"),b=chunkUEOXGECB_cjs.Ri(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkUEOXGECB_cjs.Ii(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkUEOXGECB_cjs.Ii(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=chunkUEOXGECB_cjs.Ii(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkUEOXGECB_cjs.Ri(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-history-head"),x=chunkUEOXGECB_cjs.Ii(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkUEOXGECB_cjs.Ii(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkUEOXGECB_cjs.Ri(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-history-body"),m=chunkUEOXGECB_cjs.Ii(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkUEOXGECB_cjs.Xi({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=chunkUEOXGECB_cjs.Ii(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkUEOXGECB_cjs.Ii(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkUEOXGECB_cjs.Ii(t,"li","pptxv-ai-history-row"),r=chunkUEOXGECB_cjs.Ii(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkUEOXGECB_cjs.Ii(t,"span","pptxv-ai-history-text"),k=chunkUEOXGECB_cjs.Ii(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkUEOXGECB_cjs.Ii(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkUEOXGECB_cjs.Ri(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkUEOXGECB_cjs.Ii(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(chunkUEOXGECB_cjs.Ri(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=chunkUEOXGECB_cjs.aj(t.toolName,t.input,h?"present":"past"),c=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-tool"),p=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-tool-head"),m=chunkUEOXGECB_cjs.Ri(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkUEOXGECB_cjs.Ii(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkUEOXGECB_cjs.Ii(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkUEOXGECB_cjs.Ri(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkUEOXGECB_cjs.Ri(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=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkUEOXGECB_cjs.$i(t.input);if(g){let f=chunkUEOXGECB_cjs.Ii(o,"details","pptxv-ai-tool-details"),C=chunkUEOXGECB_cjs.Ii(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkUEOXGECB_cjs._i(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=chunkUEOXGECB_cjs.Zi(a);if(x.length===0&&!h)continue;let c=chunkUEOXGECB_cjs.Ii(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkUEOXGECB_cjs.Ri(o,h?"comment":"sparkles"));let m=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkUEOXGECB_cjs.Ii(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=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-proposals-header"),x=chunkUEOXGECB_cjs.Ii(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkUEOXGECB_cjs.Ii(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=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkUEOXGECB_cjs.Ii(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkUEOXGECB_cjs.Ii(o,"li");g.textContent=chunkUEOXGECB_cjs.Ti(s),l.appendChild(g);}a.appendChild(l);}let c=chunkUEOXGECB_cjs.Ii(o,"div","pptxv-ai-proposal-actions"),p=chunkUEOXGECB_cjs.Ii(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkUEOXGECB_cjs.Ri(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkUEOXGECB_cjs.Ii(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkUEOXGECB_cjs.Ri(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=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-header"),h=chunkUEOXGECB_cjs.Ii(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkUEOXGECB_cjs.Ii(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkUEOXGECB_cjs.Ri(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkUEOXGECB_cjs.Ri(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=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkUEOXGECB_cjs.Ii(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkUEOXGECB_cjs.Ii(t,"form","pptxv-ai-composer"),d=chunkUEOXGECB_cjs.Ii(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkUEOXGECB_cjs.Ii(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkUEOXGECB_cjs.Ri(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkUEOXGECB_cjs.Yi)({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:chunkUEOXGECB_cjs.Wi(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=>chunkUEOXGECB_cjs.Zi(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=chunkUEOXGECB_cjs.bj(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 chunkJCTGZ6EJ_cjs=require('./chunk-JCTGZ6EJ.cjs');require('./chunk-4VDLQK6F.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkJCTGZ6EJ_cjs.Ii(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkJCTGZ6EJ_cjs.Ri(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-focus-row"),f=chunkJCTGZ6EJ_cjs.Ii(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkJCTGZ6EJ_cjs.Di(p,o.getSlides())){let b=chunkJCTGZ6EJ_cjs.Ii(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=chunkJCTGZ6EJ_cjs.Ii(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-focus-actions"),d=chunkJCTGZ6EJ_cjs.Ei(p,o.getSlides());if(d){let r=chunkJCTGZ6EJ_cjs.Ii(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkJCTGZ6EJ_cjs.Ri(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkJCTGZ6EJ_cjs.Fi(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=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-focus-pick"),b=chunkJCTGZ6EJ_cjs.Ri(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkJCTGZ6EJ_cjs.Ii(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkJCTGZ6EJ_cjs.Ii(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=chunkJCTGZ6EJ_cjs.Ii(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkJCTGZ6EJ_cjs.Ri(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-history-head"),x=chunkJCTGZ6EJ_cjs.Ii(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkJCTGZ6EJ_cjs.Ii(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkJCTGZ6EJ_cjs.Ri(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-history-body"),m=chunkJCTGZ6EJ_cjs.Ii(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkJCTGZ6EJ_cjs.Xi({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=chunkJCTGZ6EJ_cjs.Ii(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkJCTGZ6EJ_cjs.Ii(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkJCTGZ6EJ_cjs.Ii(t,"li","pptxv-ai-history-row"),r=chunkJCTGZ6EJ_cjs.Ii(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkJCTGZ6EJ_cjs.Ii(t,"span","pptxv-ai-history-text"),k=chunkJCTGZ6EJ_cjs.Ii(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkJCTGZ6EJ_cjs.Ii(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkJCTGZ6EJ_cjs.Ri(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkJCTGZ6EJ_cjs.Ii(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(chunkJCTGZ6EJ_cjs.Ri(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=chunkJCTGZ6EJ_cjs.aj(t.toolName,t.input,h?"present":"past"),c=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-tool"),p=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-tool-head"),m=chunkJCTGZ6EJ_cjs.Ri(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkJCTGZ6EJ_cjs.Ii(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkJCTGZ6EJ_cjs.Ii(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkJCTGZ6EJ_cjs.Ri(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkJCTGZ6EJ_cjs.Ri(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=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkJCTGZ6EJ_cjs.$i(t.input);if(g){let f=chunkJCTGZ6EJ_cjs.Ii(o,"details","pptxv-ai-tool-details"),C=chunkJCTGZ6EJ_cjs.Ii(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkJCTGZ6EJ_cjs._i(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=chunkJCTGZ6EJ_cjs.Zi(a);if(x.length===0&&!h)continue;let c=chunkJCTGZ6EJ_cjs.Ii(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkJCTGZ6EJ_cjs.Ri(o,h?"comment":"sparkles"));let m=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkJCTGZ6EJ_cjs.Ii(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=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-proposals-header"),x=chunkJCTGZ6EJ_cjs.Ii(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkJCTGZ6EJ_cjs.Ii(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=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkJCTGZ6EJ_cjs.Ii(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkJCTGZ6EJ_cjs.Ii(o,"li");g.textContent=chunkJCTGZ6EJ_cjs.Ti(s),l.appendChild(g);}a.appendChild(l);}let c=chunkJCTGZ6EJ_cjs.Ii(o,"div","pptxv-ai-proposal-actions"),p=chunkJCTGZ6EJ_cjs.Ii(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkJCTGZ6EJ_cjs.Ri(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkJCTGZ6EJ_cjs.Ii(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkJCTGZ6EJ_cjs.Ri(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=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-header"),h=chunkJCTGZ6EJ_cjs.Ii(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkJCTGZ6EJ_cjs.Ii(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkJCTGZ6EJ_cjs.Ri(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkJCTGZ6EJ_cjs.Ri(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=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkJCTGZ6EJ_cjs.Ii(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkJCTGZ6EJ_cjs.Ii(t,"form","pptxv-ai-composer"),d=chunkJCTGZ6EJ_cjs.Ii(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkJCTGZ6EJ_cjs.Ii(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkJCTGZ6EJ_cjs.Ri(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkJCTGZ6EJ_cjs.Yi)({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:chunkJCTGZ6EJ_cjs.Wi(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=>chunkJCTGZ6EJ_cjs.Zi(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=chunkJCTGZ6EJ_cjs.bj(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 {Ii,Ri,Yi,Wi,Xi,Zi,bj,Di,Ei,Fi,aj,$i,_i,Ti}from'./chunk-4WCHRHQT.js';import'./chunk-WOT6VMZA.js';function K(o){let{doc:t,t:n,controller:i}=o,a=Ii(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=Ii(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Ri(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=Ii(t,"div","pptxv-ai-focus-row"),f=Ii(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of Di(p,o.getSlides())){let b=Ii(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=Ii(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=Ii(t,"div","pptxv-ai-focus-actions"),d=Ei(p,o.getSlides());if(d){let r=Ii(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Ri(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(Fi(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=Ii(t,"div","pptxv-ai-focus-pick"),b=Ri(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=Ii(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=Ii(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=Ii(t,"button","pptxv-ai-chats");i.type="button",i.append(Ri(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=Ii(t,"div","pptxv-ai-history");a.hidden=true;let h=Ii(t,"div","pptxv-ai-history-head"),x=Ii(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=Ii(t,"button","pptxv-ai-history-new");c.type="button",c.append(Ri(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=Ii(t,"div","pptxv-ai-history-body"),m=Ii(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=Xi({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=Ii(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=Ii(t,"ul","pptxv-ai-history-list");for(let d of f){let y=Ii(t,"li","pptxv-ai-history-row"),r=Ii(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=Ii(t,"span","pptxv-ai-history-text"),k=Ii(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=Ii(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Ri(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=Ii(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(Ri(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=aj(t.toolName,t.input,h?"present":"past"),c=Ii(o,"div","pptxv-ai-tool"),p=Ii(o,"div","pptxv-ai-tool-head"),m=Ri(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=Ii(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=Ii(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Ri(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Ri(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=Ii(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=$i(t.input);if(g){let f=Ii(o,"details","pptxv-ai-tool-details"),C=Ii(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=Ii(o,"div","pptxv-ai-tool-raw");d.textContent=`${_i(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=Zi(a);if(x.length===0&&!h)continue;let c=Ii(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=Ii(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Ri(o,h?"comment":"sparkles"));let m=Ii(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=Ii(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=Ii(o,"div","pptxv-ai-proposals-header"),x=Ii(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=Ii(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=Ii(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=Ii(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=Ii(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=Ii(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=Ii(o,"li");g.textContent=Ti(s),l.appendChild(g);}a.appendChild(l);}let c=Ii(o,"div","pptxv-ai-proposal-actions"),p=Ii(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Ri(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=Ii(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Ri(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=Ii(t,"div","pptxv-ai-header"),h=Ii(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=Ii(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Ri(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Ri(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=Ii(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=Ii(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=Ii(t,"div","pptxv-ai-proposals");g.hidden=true;let f=Ii(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=Ii(t,"form","pptxv-ai-composer"),d=Ii(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=Ii(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Ri(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??Yi)({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:Wi(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=>Zi(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=bj(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 {Ii,Ri,Yi,Wi,Xi,Zi,bj,Di,Ei,Fi,aj,$i,_i,Ti}from'./chunk-PRTPGAAE.js';import'./chunk-WOT6VMZA.js';function K(o){let{doc:t,t:n,controller:i}=o,a=Ii(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=Ii(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Ri(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=Ii(t,"div","pptxv-ai-focus-row"),f=Ii(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of Di(p,o.getSlides())){let b=Ii(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=Ii(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=Ii(t,"div","pptxv-ai-focus-actions"),d=Ei(p,o.getSlides());if(d){let r=Ii(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Ri(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(Fi(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=Ii(t,"div","pptxv-ai-focus-pick"),b=Ri(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=Ii(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=Ii(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=Ii(t,"button","pptxv-ai-chats");i.type="button",i.append(Ri(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=Ii(t,"div","pptxv-ai-history");a.hidden=true;let h=Ii(t,"div","pptxv-ai-history-head"),x=Ii(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=Ii(t,"button","pptxv-ai-history-new");c.type="button",c.append(Ri(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=Ii(t,"div","pptxv-ai-history-body"),m=Ii(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=Xi({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=Ii(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=Ii(t,"ul","pptxv-ai-history-list");for(let d of f){let y=Ii(t,"li","pptxv-ai-history-row"),r=Ii(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=Ii(t,"span","pptxv-ai-history-text"),k=Ii(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=Ii(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Ri(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=Ii(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(Ri(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=aj(t.toolName,t.input,h?"present":"past"),c=Ii(o,"div","pptxv-ai-tool"),p=Ii(o,"div","pptxv-ai-tool-head"),m=Ri(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=Ii(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=Ii(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Ri(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Ri(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=Ii(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=$i(t.input);if(g){let f=Ii(o,"details","pptxv-ai-tool-details"),C=Ii(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=Ii(o,"div","pptxv-ai-tool-raw");d.textContent=`${_i(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=Zi(a);if(x.length===0&&!h)continue;let c=Ii(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=Ii(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Ri(o,h?"comment":"sparkles"));let m=Ii(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=Ii(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=Ii(o,"div","pptxv-ai-proposals-header"),x=Ii(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=Ii(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=Ii(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=Ii(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=Ii(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=Ii(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=Ii(o,"li");g.textContent=Ti(s),l.appendChild(g);}a.appendChild(l);}let c=Ii(o,"div","pptxv-ai-proposal-actions"),p=Ii(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Ri(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=Ii(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Ri(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=Ii(t,"div","pptxv-ai-header"),h=Ii(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=Ii(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Ri(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Ri(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=Ii(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=Ii(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=Ii(t,"div","pptxv-ai-proposals");g.hidden=true;let f=Ii(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=Ii(t,"form","pptxv-ai-composer"),d=Ii(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=Ii(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Ri(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??Yi)({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:Wi(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=>Zi(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=bj(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};