pptx-vanilla-viewer 2.17.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/styles.css CHANGED
@@ -35,6 +35,11 @@
35
35
  color: var(--pptx-foreground);
36
36
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
37
37
  font-size: 14px;
38
+ /* Text autosizing: the viewer scales the whole slide as one unit, so a
39
+ * mobile browser must not inflate the glyphs alone (it changes wrapping
40
+ * and clips text). Mirrors the React theme.css rule. */
41
+ -webkit-text-size-adjust: none;
42
+ text-size-adjust: none;
38
43
  }
39
44
  .pptxv *, .pptxv *::before, .pptxv *::after { box-sizing: border-box; }
40
45
  .pptxv:focus { outline: none; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptx-vanilla-viewer",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "description": "Zero-framework PowerPoint viewer and editor: render, edit, present, and export PPTX slides with plain DOM, no React/Vue/Angular required.",
5
5
  "keywords": [
6
6
  "javascript",
@@ -60,7 +60,7 @@
60
60
  "html2canvas-pro": "^2.4.2",
61
61
  "jspdf": "^4.2.1",
62
62
  "jszip": "^3.10.2",
63
- "lucide": "^1.43.0",
63
+ "lucide": "^1.44.0",
64
64
  "opentype.js": "^2.0.0",
65
65
  "pptx-viewer-mcp": "^2.5.1"
66
66
  },
@@ -71,7 +71,7 @@
71
71
  "tsdown": "^0.23.0",
72
72
  "tsup": "^8.5.1",
73
73
  "typescript": "^7.0.2",
74
- "vitest": "^4.1.11",
74
+ "vitest": "^5.0.0",
75
75
  "y-webrtc": "^10.3.0",
76
76
  "y-websocket": "^3.1.0",
77
77
  "yjs": "^13.6.32"
@@ -1 +0,0 @@
1
- import {lo,zo,do as _do,bo,co,Wn,io,_n,$n,ao,ho,go,fo,Tn}from'./chunk-MXXOTNOS.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=lo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=lo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(zo(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=lo(t,"div","pptxv-ai-focus-row"),f=lo(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of _n(p,o.getSlides())){let b=lo(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=lo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=lo(t,"div","pptxv-ai-focus-actions"),d=$n(p,o.getSlides());if(d){let r=lo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(zo(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(ao(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=lo(t,"div","pptxv-ai-focus-pick"),b=zo(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=lo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=lo(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=lo(t,"button","pptxv-ai-chats");i.type="button",i.append(zo(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=lo(t,"div","pptxv-ai-history");a.hidden=true;let h=lo(t,"div","pptxv-ai-history-head"),x=lo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=lo(t,"button","pptxv-ai-history-new");c.type="button",c.append(zo(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=lo(t,"div","pptxv-ai-history-body"),m=lo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=co({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=lo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=lo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=lo(t,"li","pptxv-ai-history-row"),r=lo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=lo(t,"span","pptxv-ai-history-text"),k=lo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=lo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(zo(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=lo(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(zo(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=ho(t.toolName,t.input,h?"present":"past"),c=lo(o,"div","pptxv-ai-tool"),p=lo(o,"div","pptxv-ai-tool-head"),m=zo(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=lo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=lo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(zo(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(zo(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=lo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=go(t.input);if(g){let f=lo(o,"details","pptxv-ai-tool-details"),C=lo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=lo(o,"div","pptxv-ai-tool-raw");d.textContent=`${fo(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=Wn(a);if(x.length===0&&!h)continue;let c=lo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=lo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(zo(o,h?"comment":"sparkles"));let m=lo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=lo(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=lo(o,"div","pptxv-ai-proposals-header"),x=lo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=lo(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=lo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=lo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=lo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=lo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=lo(o,"li");g.textContent=Tn(s),l.appendChild(g);}a.appendChild(l);}let c=lo(o,"div","pptxv-ai-proposal-actions"),p=lo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(zo(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=lo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(zo(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=lo(t,"div","pptxv-ai-header"),h=lo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=lo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(zo(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(zo(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=lo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=lo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=lo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=lo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=lo(t,"form","pptxv-ai-composer"),d=lo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=lo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(zo(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??_do)({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:bo(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=>Wn(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=io(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 +0,0 @@
1
- 'use strict';var chunkKHVPUMYT_cjs=require('./chunk-KHVPUMYT.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkKHVPUMYT_cjs.lo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkKHVPUMYT_cjs.zo(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-focus-row"),f=chunkKHVPUMYT_cjs.lo(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkKHVPUMYT_cjs._n(p,o.getSlides())){let b=chunkKHVPUMYT_cjs.lo(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=chunkKHVPUMYT_cjs.lo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-focus-actions"),d=chunkKHVPUMYT_cjs.$n(p,o.getSlides());if(d){let r=chunkKHVPUMYT_cjs.lo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkKHVPUMYT_cjs.zo(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkKHVPUMYT_cjs.ao(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=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-focus-pick"),b=chunkKHVPUMYT_cjs.zo(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkKHVPUMYT_cjs.lo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkKHVPUMYT_cjs.lo(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=chunkKHVPUMYT_cjs.lo(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkKHVPUMYT_cjs.zo(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-history-head"),x=chunkKHVPUMYT_cjs.lo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkKHVPUMYT_cjs.lo(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkKHVPUMYT_cjs.zo(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-history-body"),m=chunkKHVPUMYT_cjs.lo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkKHVPUMYT_cjs.co({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=chunkKHVPUMYT_cjs.lo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkKHVPUMYT_cjs.lo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkKHVPUMYT_cjs.lo(t,"li","pptxv-ai-history-row"),r=chunkKHVPUMYT_cjs.lo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkKHVPUMYT_cjs.lo(t,"span","pptxv-ai-history-text"),k=chunkKHVPUMYT_cjs.lo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkKHVPUMYT_cjs.lo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkKHVPUMYT_cjs.zo(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkKHVPUMYT_cjs.lo(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(chunkKHVPUMYT_cjs.zo(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=chunkKHVPUMYT_cjs.ho(t.toolName,t.input,h?"present":"past"),c=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-tool"),p=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-tool-head"),m=chunkKHVPUMYT_cjs.zo(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkKHVPUMYT_cjs.lo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkKHVPUMYT_cjs.lo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkKHVPUMYT_cjs.zo(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkKHVPUMYT_cjs.zo(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=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkKHVPUMYT_cjs.go(t.input);if(g){let f=chunkKHVPUMYT_cjs.lo(o,"details","pptxv-ai-tool-details"),C=chunkKHVPUMYT_cjs.lo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkKHVPUMYT_cjs.fo(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=chunkKHVPUMYT_cjs.Wn(a);if(x.length===0&&!h)continue;let c=chunkKHVPUMYT_cjs.lo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkKHVPUMYT_cjs.zo(o,h?"comment":"sparkles"));let m=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkKHVPUMYT_cjs.lo(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=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-proposals-header"),x=chunkKHVPUMYT_cjs.lo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkKHVPUMYT_cjs.lo(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=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkKHVPUMYT_cjs.lo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkKHVPUMYT_cjs.lo(o,"li");g.textContent=chunkKHVPUMYT_cjs.Tn(s),l.appendChild(g);}a.appendChild(l);}let c=chunkKHVPUMYT_cjs.lo(o,"div","pptxv-ai-proposal-actions"),p=chunkKHVPUMYT_cjs.lo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkKHVPUMYT_cjs.zo(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkKHVPUMYT_cjs.lo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkKHVPUMYT_cjs.zo(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=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-header"),h=chunkKHVPUMYT_cjs.lo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkKHVPUMYT_cjs.lo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkKHVPUMYT_cjs.zo(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkKHVPUMYT_cjs.zo(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=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkKHVPUMYT_cjs.lo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkKHVPUMYT_cjs.lo(t,"form","pptxv-ai-composer"),d=chunkKHVPUMYT_cjs.lo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkKHVPUMYT_cjs.lo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkKHVPUMYT_cjs.zo(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkKHVPUMYT_cjs.do)({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:chunkKHVPUMYT_cjs.bo(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=>chunkKHVPUMYT_cjs.Wn(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=chunkKHVPUMYT_cjs.io(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;