pptx-vanilla-viewer 2.5.4 → 2.5.5
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 +6 -0
- package/dist/{ai-panel-VKG74YAP.cjs → ai-panel-ATH6XY6L.cjs} +1 -1
- package/dist/{ai-panel-255FXBYU.js → ai-panel-YY6YHKZ7.js} +1 -1
- package/dist/{chunk-V6O3UHFE.cjs → chunk-3YE6EQJE.cjs} +124 -124
- package/dist/{chunk-2N4X3VII.js → chunk-ABYL3YBM.js} +124 -124
- package/dist/index.cjs +14 -14
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ 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.5.4](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.5.4) - 2026-09-04
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **shared,vanilla:** Continue appended numbered paragraphs ([#211](https://github.com/ChristopherVR/pptx-viewer/issues/211)) (by @Sudhansh6) ([1c3a8c5](https://github.com/ChristopherVR/pptx-viewer/commit/1c3a8c5d9511b482b6903a6895ac68aa84b9d577))
|
|
15
|
+
|
|
10
16
|
## [2.5.3](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.5.3) - 2026-09-03
|
|
11
17
|
|
|
12
18
|
### Bug Fixes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunkV6O3UHFE_cjs=require('./chunk-V6O3UHFE.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkV6O3UHFE_cjs.Bm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkV6O3UHFE_cjs.Mm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-focus-row"),f=chunkV6O3UHFE_cjs.Bm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkV6O3UHFE_cjs.om(p,o.getSlides())){let b=chunkV6O3UHFE_cjs.Bm(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=chunkV6O3UHFE_cjs.Bm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-focus-actions"),d=chunkV6O3UHFE_cjs.pm(p,o.getSlides());if(d){let r=chunkV6O3UHFE_cjs.Bm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkV6O3UHFE_cjs.Mm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkV6O3UHFE_cjs.qm(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=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-focus-pick"),b=chunkV6O3UHFE_cjs.Mm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkV6O3UHFE_cjs.Bm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkV6O3UHFE_cjs.Bm(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=chunkV6O3UHFE_cjs.Bm(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkV6O3UHFE_cjs.Mm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-history-head"),x=chunkV6O3UHFE_cjs.Bm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkV6O3UHFE_cjs.Bm(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkV6O3UHFE_cjs.Mm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-history-body"),m=chunkV6O3UHFE_cjs.Bm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkV6O3UHFE_cjs.sm({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=chunkV6O3UHFE_cjs.Bm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkV6O3UHFE_cjs.Bm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkV6O3UHFE_cjs.Bm(t,"li","pptxv-ai-history-row"),r=chunkV6O3UHFE_cjs.Bm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkV6O3UHFE_cjs.Bm(t,"span","pptxv-ai-history-text"),k=chunkV6O3UHFE_cjs.Bm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkV6O3UHFE_cjs.Bm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkV6O3UHFE_cjs.Mm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkV6O3UHFE_cjs.Bm(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(chunkV6O3UHFE_cjs.Mm(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=chunkV6O3UHFE_cjs.xm(t.toolName,t.input,h?"present":"past"),c=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-tool"),p=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-tool-head"),m=chunkV6O3UHFE_cjs.Mm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkV6O3UHFE_cjs.Bm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkV6O3UHFE_cjs.Bm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkV6O3UHFE_cjs.Mm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkV6O3UHFE_cjs.Mm(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=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkV6O3UHFE_cjs.wm(t.input);if(g){let f=chunkV6O3UHFE_cjs.Bm(o,"details","pptxv-ai-tool-details"),C=chunkV6O3UHFE_cjs.Bm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkV6O3UHFE_cjs.vm(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=chunkV6O3UHFE_cjs.km(a);if(x.length===0&&!h)continue;let c=chunkV6O3UHFE_cjs.Bm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkV6O3UHFE_cjs.Mm(o,h?"comment":"sparkles"));let m=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkV6O3UHFE_cjs.Bm(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=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-proposals-header"),x=chunkV6O3UHFE_cjs.Bm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkV6O3UHFE_cjs.Bm(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=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkV6O3UHFE_cjs.Bm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkV6O3UHFE_cjs.Bm(o,"li");g.textContent=chunkV6O3UHFE_cjs.hm(s),l.appendChild(g);}a.appendChild(l);}let c=chunkV6O3UHFE_cjs.Bm(o,"div","pptxv-ai-proposal-actions"),p=chunkV6O3UHFE_cjs.Bm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkV6O3UHFE_cjs.Mm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkV6O3UHFE_cjs.Bm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkV6O3UHFE_cjs.Mm(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=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-header"),h=chunkV6O3UHFE_cjs.Bm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkV6O3UHFE_cjs.Bm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkV6O3UHFE_cjs.Mm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkV6O3UHFE_cjs.Mm(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=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkV6O3UHFE_cjs.Bm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkV6O3UHFE_cjs.Bm(t,"form","pptxv-ai-composer"),d=chunkV6O3UHFE_cjs.Bm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkV6O3UHFE_cjs.Bm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkV6O3UHFE_cjs.Mm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkV6O3UHFE_cjs.tm)({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:chunkV6O3UHFE_cjs.rm(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=>chunkV6O3UHFE_cjs.km(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=chunkV6O3UHFE_cjs.ym(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 chunk3YE6EQJE_cjs=require('./chunk-3YE6EQJE.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunk3YE6EQJE_cjs.Bm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunk3YE6EQJE_cjs.Mm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-focus-row"),f=chunk3YE6EQJE_cjs.Bm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunk3YE6EQJE_cjs.om(p,o.getSlides())){let b=chunk3YE6EQJE_cjs.Bm(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=chunk3YE6EQJE_cjs.Bm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-focus-actions"),d=chunk3YE6EQJE_cjs.pm(p,o.getSlides());if(d){let r=chunk3YE6EQJE_cjs.Bm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunk3YE6EQJE_cjs.Mm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunk3YE6EQJE_cjs.qm(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=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-focus-pick"),b=chunk3YE6EQJE_cjs.Mm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunk3YE6EQJE_cjs.Bm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunk3YE6EQJE_cjs.Bm(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=chunk3YE6EQJE_cjs.Bm(t,"button","pptxv-ai-chats");i.type="button",i.append(chunk3YE6EQJE_cjs.Mm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-history");a.hidden=true;let h=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-history-head"),x=chunk3YE6EQJE_cjs.Bm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunk3YE6EQJE_cjs.Bm(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunk3YE6EQJE_cjs.Mm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-history-body"),m=chunk3YE6EQJE_cjs.Bm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunk3YE6EQJE_cjs.sm({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=chunk3YE6EQJE_cjs.Bm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunk3YE6EQJE_cjs.Bm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunk3YE6EQJE_cjs.Bm(t,"li","pptxv-ai-history-row"),r=chunk3YE6EQJE_cjs.Bm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunk3YE6EQJE_cjs.Bm(t,"span","pptxv-ai-history-text"),k=chunk3YE6EQJE_cjs.Bm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunk3YE6EQJE_cjs.Bm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunk3YE6EQJE_cjs.Mm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunk3YE6EQJE_cjs.Bm(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(chunk3YE6EQJE_cjs.Mm(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=chunk3YE6EQJE_cjs.xm(t.toolName,t.input,h?"present":"past"),c=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-tool"),p=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-tool-head"),m=chunk3YE6EQJE_cjs.Mm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunk3YE6EQJE_cjs.Bm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunk3YE6EQJE_cjs.Bm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunk3YE6EQJE_cjs.Mm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunk3YE6EQJE_cjs.Mm(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=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunk3YE6EQJE_cjs.wm(t.input);if(g){let f=chunk3YE6EQJE_cjs.Bm(o,"details","pptxv-ai-tool-details"),C=chunk3YE6EQJE_cjs.Bm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunk3YE6EQJE_cjs.vm(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=chunk3YE6EQJE_cjs.km(a);if(x.length===0&&!h)continue;let c=chunk3YE6EQJE_cjs.Bm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunk3YE6EQJE_cjs.Mm(o,h?"comment":"sparkles"));let m=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunk3YE6EQJE_cjs.Bm(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=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-proposals-header"),x=chunk3YE6EQJE_cjs.Bm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunk3YE6EQJE_cjs.Bm(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=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunk3YE6EQJE_cjs.Bm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunk3YE6EQJE_cjs.Bm(o,"li");g.textContent=chunk3YE6EQJE_cjs.hm(s),l.appendChild(g);}a.appendChild(l);}let c=chunk3YE6EQJE_cjs.Bm(o,"div","pptxv-ai-proposal-actions"),p=chunk3YE6EQJE_cjs.Bm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunk3YE6EQJE_cjs.Mm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunk3YE6EQJE_cjs.Bm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunk3YE6EQJE_cjs.Mm(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=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-header"),h=chunk3YE6EQJE_cjs.Bm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunk3YE6EQJE_cjs.Bm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunk3YE6EQJE_cjs.Mm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunk3YE6EQJE_cjs.Mm(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=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunk3YE6EQJE_cjs.Bm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunk3YE6EQJE_cjs.Bm(t,"form","pptxv-ai-composer"),d=chunk3YE6EQJE_cjs.Bm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunk3YE6EQJE_cjs.Bm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunk3YE6EQJE_cjs.Mm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunk3YE6EQJE_cjs.tm)({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:chunk3YE6EQJE_cjs.rm(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=>chunk3YE6EQJE_cjs.km(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=chunk3YE6EQJE_cjs.ym(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 {Bm,Mm,tm,rm,sm,km,ym,om,pm,qm,xm,wm,vm,hm}from'./chunk-2N4X3VII.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=Bm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=Bm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Mm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=Bm(t,"div","pptxv-ai-focus-row"),f=Bm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of om(p,o.getSlides())){let b=Bm(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=Bm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=Bm(t,"div","pptxv-ai-focus-actions"),d=pm(p,o.getSlides());if(d){let r=Bm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Mm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(qm(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=Bm(t,"div","pptxv-ai-focus-pick"),b=Mm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=Bm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=Bm(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=Bm(t,"button","pptxv-ai-chats");i.type="button",i.append(Mm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=Bm(t,"div","pptxv-ai-history");a.hidden=true;let h=Bm(t,"div","pptxv-ai-history-head"),x=Bm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=Bm(t,"button","pptxv-ai-history-new");c.type="button",c.append(Mm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=Bm(t,"div","pptxv-ai-history-body"),m=Bm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=sm({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=Bm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=Bm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=Bm(t,"li","pptxv-ai-history-row"),r=Bm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=Bm(t,"span","pptxv-ai-history-text"),k=Bm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=Bm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Mm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=Bm(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(Mm(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=xm(t.toolName,t.input,h?"present":"past"),c=Bm(o,"div","pptxv-ai-tool"),p=Bm(o,"div","pptxv-ai-tool-head"),m=Mm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=Bm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=Bm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Mm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Mm(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=Bm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=wm(t.input);if(g){let f=Bm(o,"details","pptxv-ai-tool-details"),C=Bm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=Bm(o,"div","pptxv-ai-tool-raw");d.textContent=`${vm(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=km(a);if(x.length===0&&!h)continue;let c=Bm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=Bm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Mm(o,h?"comment":"sparkles"));let m=Bm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=Bm(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=Bm(o,"div","pptxv-ai-proposals-header"),x=Bm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=Bm(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=Bm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=Bm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=Bm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=Bm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=Bm(o,"li");g.textContent=hm(s),l.appendChild(g);}a.appendChild(l);}let c=Bm(o,"div","pptxv-ai-proposal-actions"),p=Bm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Mm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=Bm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Mm(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=Bm(t,"div","pptxv-ai-header"),h=Bm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=Bm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Mm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Mm(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=Bm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=Bm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=Bm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=Bm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=Bm(t,"form","pptxv-ai-composer"),d=Bm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=Bm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Mm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??tm)({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:rm(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=>km(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=ym(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 {Bm,Mm,tm,rm,sm,km,ym,om,pm,qm,xm,wm,vm,hm}from'./chunk-ABYL3YBM.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=Bm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=Bm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Mm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=Bm(t,"div","pptxv-ai-focus-row"),f=Bm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of om(p,o.getSlides())){let b=Bm(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=Bm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=Bm(t,"div","pptxv-ai-focus-actions"),d=pm(p,o.getSlides());if(d){let r=Bm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Mm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(qm(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=Bm(t,"div","pptxv-ai-focus-pick"),b=Mm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=Bm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=Bm(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=Bm(t,"button","pptxv-ai-chats");i.type="button",i.append(Mm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=Bm(t,"div","pptxv-ai-history");a.hidden=true;let h=Bm(t,"div","pptxv-ai-history-head"),x=Bm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=Bm(t,"button","pptxv-ai-history-new");c.type="button",c.append(Mm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=Bm(t,"div","pptxv-ai-history-body"),m=Bm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=sm({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=Bm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=Bm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=Bm(t,"li","pptxv-ai-history-row"),r=Bm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=Bm(t,"span","pptxv-ai-history-text"),k=Bm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=Bm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Mm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=Bm(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(Mm(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=xm(t.toolName,t.input,h?"present":"past"),c=Bm(o,"div","pptxv-ai-tool"),p=Bm(o,"div","pptxv-ai-tool-head"),m=Mm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=Bm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=Bm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Mm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Mm(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=Bm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=wm(t.input);if(g){let f=Bm(o,"details","pptxv-ai-tool-details"),C=Bm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=Bm(o,"div","pptxv-ai-tool-raw");d.textContent=`${vm(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=km(a);if(x.length===0&&!h)continue;let c=Bm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=Bm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Mm(o,h?"comment":"sparkles"));let m=Bm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=Bm(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=Bm(o,"div","pptxv-ai-proposals-header"),x=Bm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=Bm(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=Bm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=Bm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=Bm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=Bm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=Bm(o,"li");g.textContent=hm(s),l.appendChild(g);}a.appendChild(l);}let c=Bm(o,"div","pptxv-ai-proposal-actions"),p=Bm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Mm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=Bm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Mm(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=Bm(t,"div","pptxv-ai-header"),h=Bm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=Bm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Mm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Mm(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=Bm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=Bm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=Bm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=Bm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=Bm(t,"form","pptxv-ai-composer"),d=Bm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=Bm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Mm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??tm)({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:rm(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=>km(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=ym(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};
|