aitu-app 0.6.88 → 0.6.89
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/README.md +3 -3
- package/assets/{CanvasAudioPlayer-Db2KQnHc.js → CanvasAudioPlayer-ICySX117.js} +1 -1
- package/assets/DeferredAIInputBar-BoVVJuJk.js +107 -0
- package/assets/{DrawnixDeferredFeatures-z5BMov4v.js → DrawnixDeferredFeatures-DhrnFT-E.js} +1 -1
- package/assets/{KnowledgeBaseContent-V2obmOki.js → KnowledgeBaseContent-BczozRAL.js} +5 -5
- package/assets/{MVCreator-DuWUGevw.js → MVCreator-Dgbu8Ws7.js} +5 -5
- package/assets/{ModelBenchmarkWorkbench-BaHScDtR.js → ModelBenchmarkWorkbench-BH1nzXJ2.js} +2 -2
- package/assets/MusicAnalyzer-B7IHMKNM.js +1 -0
- package/assets/{MusicAnalyzer-DHYUPR1A.js → MusicAnalyzer-D-EQhZUL.js} +2 -2
- package/assets/{PromptHistoryTool-DqRHtZ6d.js → PromptHistoryTool-DlIQM0jM.js} +2 -2
- package/assets/{ResizableDivider-FEh2h5YJ.js → ResizableDivider-jVDqzJt6.js} +1 -1
- package/assets/TaskQueuePanel-_SeVIrTA.js +1 -0
- package/assets/{VideoAnalyzer-BM1H_Y8I.js → VideoAnalyzer-3JKvMhkf.js} +2 -2
- package/assets/ai-chat-D6xzUFfb.js +646 -0
- package/assets/{ai-generation-preferences-service-Bo327KdP.js → ai-generation-preferences-service-Cl6IE7ok.js} +1 -1
- package/assets/{batch-image-generation-BZONanpb.js → batch-image-generation-CRxzbDNA.js} +4 -4
- package/assets/{diagram-engines-CK6TM3uM.js → diagram-engines-ESppzuWA.js} +2 -2
- package/assets/{editor-engines-21-asm56.js → editor-engines-C-52QLSV.js} +1 -1
- package/assets/{index-CaEECqbx.js → index-3Vtbjidf.js} +5 -5
- package/assets/{index-DpSu48-V.js → index-B-llfol0.js} +1 -1
- package/assets/{index-BngKfOsM.js → index-DogsgbeC.js} +2 -2
- package/assets/{index-DvQowfrB.js → index-d6MN3VEY.js} +1 -1
- package/assets/{index-WQfnr1NY.js → index-nF811Jqr.js} +1 -1
- package/assets/{markdown-to-drawnix-DhIYYrl4.js → markdown-to-drawnix-BMFZUW3c.js} +2 -2
- package/assets/{mermaid-to-drawnix--HeoG8Lw.js → mermaid-to-drawnix-BfitqUIf.js} +2 -2
- package/assets/{model-benchmark-launcher-IY7KzpJ7.js → model-benchmark-launcher-BoT7f3cA.js} +1 -1
- package/assets/{photo-wall-splitter-Duwlmu9s.js → photo-wall-splitter-uX6GXe4f.js} +1 -1
- package/assets/{retry-image-Bwz8G6J1.js → retry-image-BTTuq4j5.js} +2 -2
- package/assets/{settings-dialog-CsVCWJAo.js → settings-dialog-Yw9vemg4.js} +1 -1
- package/assets/{skill-dsl-parser-Bot3mGE9.js → skill-dsl-parser-DpA8awF4.js} +1 -1
- package/assets/{startup-app-Gm7ZTEkM.js → startup-app-DLAM8ZvV.js} +466 -458
- package/assets/{tool-windows-64_7RRM4.js → tool-windows-yv_XPMbT.js} +22 -22
- package/assets/{ttd-dialog-C0An5aLw.js → ttd-dialog-CyZaGDSX.js} +2 -2
- package/assets/{ttd-dialog-submit-shortcut-C4IWl6dd.js → ttd-dialog-submit-shortcut-DgTqOx5t.js} +1 -1
- package/assets/{useCharacters-BM93pe_B.js → useCharacters-y1hMuC52.js} +2 -2
- package/assets/useWorkflowSubmission-BaHaR3xS.js +44 -0
- package/assets/{video-recovery-service-DDq_VV2m.js → video-recovery-service-TOt0qrmg.js} +1 -1
- package/assets/{workflow-generation-utils-Wfy9TayV.js → workflow-generation-utils-CBbtS-R1.js} +2 -2
- package/assets/{workflow-submission-service-ChPjfGZS.js → workflow-submission-service-B8JbWpRf.js} +1 -1
- package/changelog.json +18 -0
- package/idle-prefetch-manifest.json +260 -260
- package/manifest.json +3 -3
- package/package.json +1 -1
- package/precache-manifest.json +6 -6
- package/sw.js +1 -1
- package/version.json +4 -3
- package/assets/DeferredAIInputBar-ZYiuDyMU.js +0 -8
- package/assets/MusicAnalyzer-DfKxpiT1.js +0 -1
- package/assets/TaskQueuePanel-rQ80KIaN.js +0 -1
- package/assets/ai-chat-Dmj_C0Ww.js +0 -644
- package/assets/useWorkflowSubmission-DTPRJOm3.js +0 -44
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Opentu CDN Assets v0.6.
|
|
1
|
+
# Opentu CDN Assets v0.6.89
|
|
2
2
|
|
|
3
3
|
> 静态资源包,不含 HTML 文件
|
|
4
4
|
|
|
5
|
-
- unpkg: https://unpkg.com/aitu-app@0.6.
|
|
6
|
-
- jsdelivr: https://cdn.jsdelivr.net/npm/aitu-app@0.6.
|
|
5
|
+
- unpkg: https://unpkg.com/aitu-app@0.6.89/
|
|
6
|
+
- jsdelivr: https://cdn.jsdelivr.net/npm/aitu-app@0.6.89/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./startup-app-D5aWsYi2.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as ke}from"./startup-runtime-DTmhLESk.js";import{r as n,j as t,d1 as he,y as N,iY as Ae,fM as Se,dJ as Te,dK as Ee,d5 as ue,d3 as J,eu as U,ek as Le,m as de,c7 as Ce,bT as Ne,dM as Me,eo as Re,ew as oe,ex as pe,Y as ie,ep as _e,A as De,av as $e,ey as ze,en as Oe,l as Ue,ez as Fe,eA as fe,eB as Ye,ev as le,iZ as qe,i_ as Ve,i$ as Be,X as He,eD as We,eE as Qe,eF as Xe,eG as Ke,eH as Ge}from"./startup-app-Gm7ZTEkM.js";import{u as Je,a as Ze,b as ye,d as Z,e as et}from"./tool-windows-64_7RRM4.js";import{b as tt}from"./ai-chat-Dmj_C0Ww.js";const me=5;function ve(e,i,s){const c=Math.max(0,window.innerWidth-i),f=Math.max(0,window.innerHeight-s);return{x:Math.max(0,Math.min(e.x,c)),y:Math.max(0,Math.min(e.y,f))}}function at(e){try{const i=localStorage.getItem(e);if(!i)return null;const s=JSON.parse(i);if(typeof s.x=="number"&&typeof s.y=="number")return s}catch{}return null}function nt(e,i){try{localStorage.setItem(e,JSON.stringify(i))}catch{}}function st(e){const{storageKey:i,enabled:s=!0}=e,[c,f]=n.useState(()=>s?at(i):null),[v,b]=n.useState(!1),w=n.useRef(!1),h=n.useRef(null),j=n.useRef(null),_=n.useCallback(y=>{if(!s||y.button!==0)return;const m=j.current;if(!m)return;const p=m.getBoundingClientRect();h.current={startPointerX:y.clientX,startPointerY:y.clientY,startElX:p.left,startElY:p.top,activated:!1,frameId:0}},[s]);n.useEffect(()=>{if(!s)return;const y=p=>{const u=h.current;if(!u)return;const g=p.clientX-u.startPointerX,M=p.clientY-u.startPointerY;if(!u.activated){if(Math.abs(g)<me&&Math.abs(M)<me)return;u.activated=!0,b(!0)}cancelAnimationFrame(u.frameId),u.frameId=requestAnimationFrame(()=>{const S=j.current;if(!S)return;const d=ve({x:u.startElX+g,y:u.startElY+M},S.offsetWidth,S.offsetHeight);f(d)})},m=()=>{const p=h.current;if(!p)return;cancelAnimationFrame(p.frameId);const u=p.activated;h.current=null,b(!1),u&&(w.current=!0,requestAnimationFrame(()=>{w.current=!1}),f(g=>(g&&nt(i,g),g)))};return window.addEventListener("pointermove",y),window.addEventListener("pointerup",m),()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",m)}},[s,i]),n.useEffect(()=>{if(!s||!c)return;const y=()=>{const m=j.current;m&&f(p=>p&&ve(p,m.offsetWidth,m.offsetHeight))};return window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[s,!!c]);const P=n.useCallback(()=>{f(null);try{localStorage.removeItem(i)}catch{}},[i]);return{position:c,isDragging:v,wasDraggedRef:w,elementRef:j,handlePointerDown:_,resetPosition:P}}const ot=({volume:e,onVolumeChange:i})=>{const s=n.useRef(null),c=n.useRef(null),f=n.useRef(!1),v=n.useRef(!1),b=n.useRef(!1),[w,h]=n.useState(!1),[j,_]=n.useState(!1),[P,y]=n.useState(!1),m=Math.round(e*100),p={"--canvas-audio-progress":`${e*100}%`},u=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},g=()=>{u(),h(!0)},M=()=>{u(),h(d=>!d)},S=()=>{u(),!(v.current||b.current)&&(c.current=window.setTimeout(()=>{h(!1)},180))};return n.useEffect(()=>{v.current=j},[j]),n.useEffect(()=>{b.current=P},[P]),n.useEffect(()=>()=>u(),[]),n.useEffect(()=>{if(!w)return;const d=x=>{var k;(k=s.current)!=null&&k.contains(x.target)||(u(),h(!1),y(!1),_(!1),f.current=!1)};return document.addEventListener("pointerdown",d,!0),()=>document.removeEventListener("pointerdown",d,!0)},[w]),n.useEffect(()=>{if(!P)return;const d=()=>{b.current=!1,y(!1),v.current||(u(),c.current=window.setTimeout(()=>{h(!1)},180))};return window.addEventListener("pointerup",d),()=>window.removeEventListener("pointerup",d)},[P]),t.jsx("div",{ref:s,className:he("canvas-audio-player__volume",{"canvas-audio-player__volume--expanded":w}),onPointerDown:d=>d.stopPropagation(),onMouseEnter:()=>{v.current=!0,_(!0),u()},onMouseLeave:()=>{v.current=!1,_(!1),S()},onBlur:d=>{var k;const x=d.relatedTarget;x&&((k=s.current)!=null&&k.contains(x))||S()},children:t.jsxs("div",{className:"canvas-audio-player__volume-shell",children:[t.jsx("div",{className:"canvas-audio-player__volume-slider-wrap",children:t.jsx("input",{type:"range",min:0,max:1,step:.01,value:e,onFocus:g,onPointerDown:d=>{d.stopPropagation(),b.current=!0,y(!0),g()},onChange:d=>i(Number(d.target.value)),className:"canvas-audio-player__slider canvas-audio-player__slider--volume",style:p,"aria-label":"Playback volume","aria-valuetext":`${m}%`})}),t.jsxs("span",{className:"canvas-audio-player__volume-value",children:[m,"%"]}),t.jsx(N,{content:"音量",children:t.jsx("button",{type:"button",className:"canvas-audio-player__volume-toggle",onPointerDown:d=>{d.stopPropagation(),f.current=!0},onClick:()=>{f.current=!1,M()},onFocus:()=>{f.current||g()},onBlur:()=>{f.current=!1},"aria-label":"Volume controls","aria-expanded":w,children:e<=.01?t.jsx(Ae,{size:16}):t.jsx(Se,{size:16})})})]})})},ge="asset:";function it(e){var i;return(i=e==null?void 0:e.elementId)!=null&&i.startsWith(ge)?e.elementId.slice(ge.length):null}function xe(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"--:--";const i=Math.floor(e),s=Math.floor(i/60),c=i%60;return`${s}:${String(c).padStart(2,"0")}`}function lt(e){var s;const i=((s=e.segments[e.segments.length-1])==null?void 0:s.endMs)||0;return xe(i/1e3)}const rt=({queue:e,activeQueueIndex:i,queueSource:s,activePlaylistId:c,playing:f=!1,activeReadingSourceId:v,onSelect:b,onPlayAllTracksItem:w})=>{const{assets:h}=Te(),{playlists:j,playlistItems:_,favoriteAssetIds:P,createPlaylist:y,addAssetToPlaylist:m,removeAssetFromPlaylist:p,toggleFavorite:u}=Ee(),{contextMenu:g,openAt:M,close:S}=tt(),[d,x]=n.useState(!1),[k,L]=n.useState(""),[F,T]=n.useState(null),{noteMetas:$,loadReadingSource:Q,buildReadingQueue:X}=Je(),[Y,q]=n.useState(s==="reading"?ue:J),V=Y===ue,R=s==="playlist"&&c?c:J,E=e.filter(a=>!U(a)),ee=Ze(E),K=a=>{const o=it(a);if(o)return o;if(!(a!=null&&a.audioUrl))return null;const r=h.find(I=>I.type===Me.AUDIO&&I.url===a.audioUrl);return(r==null?void 0:r.id)||null},B=n.useMemo(()=>new Set(R!==J?(_[R]||[]).map(a=>a.assetId?Le({kind:"asset",assetId:a.assetId}):null).filter(a=>!!a):[]),[_,R]),D=n.useCallback(async a=>{if(w){w(a);return}const o=await Q(a);o&&(await X(a),b(o))},[w,Q,X,b]),z=n.useMemo(()=>$.map(a=>({id:a.id,title:a.title||"未命名笔记",subtitle:new Date(a.updatedAt).toLocaleDateString("zh-CN"),canFavorite:!1,isActive:(v==null?void 0:v.includes(a.id))===!0,isPlaying:f&&(v==null?void 0:v.includes(a.id))===!0})),[$,v,f]);return s==="reading"?t.jsxs("div",{className:"canvas-audio-player__playlist",children:[t.jsx(ye,{className:"canvas-audio-player__playlist-tabs",selectedPlaylistId:Y,allCount:E.length,allTracksCount:$.length,playlists:j,playlistItems:_,onSelect:q,onCreate:()=>{L(""),x(!0)}}),V?z.length===0?t.jsxs("div",{className:"canvas-audio-player__playlist-empty",children:[t.jsx(de,{size:16}),t.jsx("span",{children:"知识库还没有笔记"})]}):t.jsx(Z,{className:"canvas-audio-player__playlist-list",items:z,onSelect:a=>void D(a.id),onTogglePlayback:a=>void D(a.id),showPlaybackIndicator:!0}):t.jsx(Z,{className:"canvas-audio-player__playlist-list audio-track-list--queue",items:e.map((a,o)=>{const r=a;return{id:r.readingSourceId,title:r.title||"朗读轨道",subtitle:lt(r),previewImageUrl:r.previewImageUrl,isActive:o===i,isPlaying:o===i,canFavorite:!1}}),onSelect:a=>{const o=e.find(r=>U(r)&&r.readingSourceId===a.id);o&&b(o)},onTogglePlayback:a=>{const o=e.find(r=>U(r)&&r.readingSourceId===a.id);o&&b(o)},showPlaybackIndicator:!0})]}):t.jsxs("div",{className:"canvas-audio-player__playlist",children:[t.jsx(ye,{className:"canvas-audio-player__playlist-tabs",selectedPlaylistId:Y,allCount:E.length,allTracksCount:$.length,playlists:j,playlistItems:_,onSelect:q,onCreate:()=>{L(""),x(!0)}}),V?z.length===0?t.jsxs("div",{className:"canvas-audio-player__playlist-empty",children:[t.jsx(de,{size:16}),t.jsx("span",{children:"知识库还没有笔记"})]}):t.jsx(Z,{className:"canvas-audio-player__playlist-list",items:z,onSelect:a=>void D(a.id),onTogglePlayback:a=>void D(a.id),showPlaybackIndicator:!0}):t.jsx(Z,{className:"canvas-audio-player__playlist-list audio-track-list--queue",items:E.map((a,o)=>{const r=K(a);return{id:`${a.audioUrl}-${o}`,title:a.title||"未命名音频",subtitle:xe(ee.get(a.audioUrl)??a.duration),previewImageUrl:a.previewImageUrl,isActive:o===i,isPlaying:o===i,isFavorite:r?P.has(r):!1,canFavorite:!!r}}),onSelect:a=>{const o=E.find((r,I)=>`${r.audioUrl}-${I}`===a.id);o&&b(o)},onContextMenu:(a,o)=>{const r=E.find((H,te)=>`${H.audioUrl}-${te}`===a.id),I=K(r);I&&(o.preventDefault(),o.stopPropagation(),M(o.clientX,o.clientY,{kind:"asset",assetId:I}))},onToggleFavorite:a=>{const o=E.find((I,H)=>`${I.audioUrl}-${H}`===a.id),r=K(o);r&&u(r)},onTogglePlayback:a=>{const o=E.find((r,I)=>`${r.audioUrl}-${I}`===a.id);o&&b(o)},showFavoriteButton:!0,showPlaybackIndicator:!0}),t.jsx(et,{contextMenu:g?{x:g.x,y:g.y,item:g.payload}:null,playlists:j,playlistItems:_,favoriteAssetIds:P,selectedPlaylistId:R===J?null:R,currentPlaylistItemKeys:B,onClose:S,onToggleFavorite:a=>void u(a),onAddToPlaylist:(a,o)=>{a.kind==="asset"&&m(a.assetId,o)},onRemoveFromPlaylist:(a,o)=>{a.kind==="asset"&&p(a.assetId,o)},onCreatePlaylistAndAdd:a=>{a.kind==="asset"&&(T(a.assetId),L(""),x(!0))}}),t.jsx(Ce,{visible:d,header:"新建播放列表",onClose:()=>x(!1),onConfirm:async()=>{const a=await y(k);F&&await m(F,a.id),x(!1),L(""),T(null)},onCancel:()=>{x(!1),T(null)},confirmBtn:"确定",cancelBtn:"取消",children:t.jsx(Ne,{value:k,onChange:a=>L(String(a)),placeholder:"请输入播放列表名称"})})]})},we={sequential:t.jsx(Ge,{size:14}),"list-loop":t.jsx(Ke,{size:14}),"single-loop":t.jsx(Xe,{size:14}),shuffle:t.jsx(Qe,{size:14})},ct=Object.keys(le).map(e=>({value:e,content:le[e],prefixIcon:we[e]}));function ut(e,i){return We(i).map(s=>{const c=_e(s),f=Math.abs(s-e)<.001;return{value:s,content:f?`✓ ${c}`:c}})}function be(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"--:--";const i=Math.floor(e),s=Math.floor(i/60),c=i%60;return`${s}:${String(c).padStart(2,"0")}`}const vt=()=>{const e=Re(),i=n.useRef(null),[s,c]=n.useState(!1),[f,v]=n.useState(()=>{const l=oe.getToolState(pe);return(l==null?void 0:l.status)==="open"}),[b,w]=n.useState(()=>{try{return localStorage.getItem(ie.AUDIO_PLAYER_LAYOUT)==="vertical"?"vertical":"horizontal"}catch{return"horizontal"}}),[h,j]=n.useState(()=>typeof window<"u"?window.innerWidth:1024);n.useEffect(()=>{const l=()=>j(window.innerWidth);return window.addEventListener("resize",l),window.addEventListener("orientationchange",l),()=>{window.removeEventListener("resize",l),window.removeEventListener("orientationchange",l)}},[]);const _=h<=768?"vertical":b,[P,y]=n.useState(null),m=h<=768,{position:p,isDragging:u,wasDraggedRef:g,elementRef:M,handlePointerDown:S}=st({storageKey:ie.AUDIO_PLAYER_POSITION,enabled:!m}),d=n.useMemo(()=>!e.duration||e.duration<=0?0:Math.max(0,Math.min(100,e.currentTime/e.duration*100)),[e.currentTime,e.duration]),x=Number.isFinite(e.currentTime)?e.currentTime:0,k=Number.isFinite(e.duration)?e.duration:0,L=be(x),F=be(k),T=e.activeQueueIndex>=0?e.queue[e.activeQueueIndex]:null,$=e.activeTitle||(U(T)?T.title:void 0),Q=e.activePreviewImageUrl||(U(T)?T.previewImageUrl:void 0),X=e.activeQueueIndex>0,Y=e.activeQueueIndex>=0&&e.activeQueueIndex<e.queue.length-1,q=e.queue.length>1&&e.activeQueueIndex>=0,V=q?`${e.activeQueueIndex+1}/${e.queue.length}`:null,R=e.queueSource==="playlist"?e.activePlaylistName||"播放列表":e.activePlaylistName||(e.queueSource==="reading"?"朗读轨道":"画布音频"),E=q?`${R} ${e.activeQueueIndex+1} / ${e.queue.length}`:R,ee=V?`${V} · ${L} / ${F}`:`${L} / ${F}`,B=e.queueSource==="reading"&&(!!e.activeReadingSourceId||T!==null&&U(T))||!!e.activeAudioUrl,D=e.mediaType==="audio",z=e.mediaType==="reading"?"reading":"audio",a=le[e.playbackMode],o=we[e.playbackMode],r=n.useMemo(()=>ut(e.effectivePlaybackRate,z),[e.effectivePlaybackRate,z]),I=_e(e.effectivePlaybackRate),H=`${e.mediaType==="reading"?"语音速度":"播放速度"} ${I}`,te={"--canvas-audio-progress":`${d}%`},Pe=n.useCallback(()=>{w(l=>{const A=l==="horizontal"?"vertical":"horizontal";try{localStorage.setItem(ie.AUDIO_PLAYER_LAYOUT,A)}catch{}return A})},[]),Ie=n.useCallback(async()=>{try{e.playing?e.pausePlayback():await e.resumePlayback()}catch{}},[e]);if(n.useEffect(()=>{if(!B){c(!1),y(null);return}let l=0;const A=()=>{const ce=document.querySelector(".ai-input-bar__container");if(!(ce instanceof HTMLElement)){y(null);return}const se=ce.getBoundingClientRect(),G={left:Math.round(se.left),width:Math.round(se.width),bottom:Math.max(0,Math.round(window.innerHeight-se.top))};y(W=>W&&W.left===G.left&&W.width===G.width&&W.bottom===G.bottom?W:G)},C=()=>{window.cancelAnimationFrame(l),l=window.requestAnimationFrame(A)},ae=document.querySelector(".ai-input-bar__container"),ne=document.querySelector(".ai-input-bar"),O=typeof ResizeObserver<"u"?new ResizeObserver(()=>C()):null;return O&&ae instanceof HTMLElement&&O.observe(ae),O&&ne instanceof HTMLElement&&ne!==ae&&O.observe(ne),C(),window.addEventListener("resize",C),window.addEventListener("orientationchange",C),()=>{window.cancelAnimationFrame(l),window.removeEventListener("resize",C),window.removeEventListener("orientationchange",C),O==null||O.disconnect()}},[B]),n.useEffect(()=>{if(!s)return;const l=A=>{var C;(C=i.current)!=null&&C.contains(A.target)||c(!1)};return document.addEventListener("pointerdown",l,!0),()=>document.removeEventListener("pointerdown",l,!0)},[s]),n.useEffect(()=>{M.current=i.current}),n.useEffect(()=>{const l=oe.observeToolStates().subscribe(()=>{const A=oe.getToolState(pe);v((A==null?void 0:A.status)==="open")});return()=>l.unsubscribe()},[]),!B||f)return null;const je=p&&!m?{left:p.x,top:p.y}:{},re={...P?{"--canvas-audio-mobile-left":`${P.left}px`,"--canvas-audio-mobile-width":`${P.width}px`,"--canvas-audio-mobile-offset":`${P.bottom}px`}:{},...je};return t.jsxs("div",{ref:i,className:he("canvas-audio-player",{"canvas-audio-player--playlist-open":s,"canvas-audio-player--positioned":!!p,"canvas-audio-player--dragging":u,"canvas-audio-player--vertical":_==="vertical"}),style:Object.keys(re).length>0?re:void 0,children:[t.jsxs("button",{type:"button",className:"canvas-audio-player__queue-trigger",onPointerDown:S,onClick:()=>{g.current||c(l=>!l)},"aria-expanded":s,"aria-label":"切换播放列表",children:[t.jsx("div",{className:"canvas-audio-player__cover",children:t.jsx(De,{src:Q,alt:$||"Audio cover",fallbackClassName:"canvas-audio-player__cover-fallback",iconSize:16})}),t.jsxs("div",{className:"canvas-audio-player__meta",children:[t.jsx("div",{className:"canvas-audio-player__title",children:$||"未命名音频"}),t.jsxs("div",{className:"canvas-audio-player__subtitle",children:[t.jsx("span",{className:"canvas-audio-player__subtitle-text canvas-audio-player__subtitle-text--desktop",children:E}),t.jsx("span",{className:"canvas-audio-player__subtitle-text canvas-audio-player__subtitle-text--mobile",children:ee})]})]}),t.jsx("span",{className:"canvas-audio-player__queue-indicator","aria-hidden":"true",children:t.jsx($e,{size:14})})]}),t.jsxs("div",{className:"canvas-audio-player__controls",children:[t.jsx(N,{content:"上一首",children:t.jsx("button",{type:"button",className:"canvas-audio-player__action canvas-audio-player__action--previous",onClick:()=>void e.playPrevious(),disabled:!X,children:t.jsx(ze,{size:14})})}),t.jsx(N,{content:e.playing?"暂停":"播放",children:t.jsx("button",{type:"button",className:"canvas-audio-player__action canvas-audio-player__action--primary",onClick:()=>void Ie(),children:e.playing?t.jsx(Oe,{size:14}):t.jsx(Ue,{size:14})})}),t.jsx(N,{content:"下一首",children:t.jsx("button",{type:"button",className:"canvas-audio-player__action canvas-audio-player__action--next",onClick:()=>void e.playNext(),disabled:!Y,children:t.jsx(Fe,{size:14})})})]}),t.jsxs("div",{className:"canvas-audio-player__progress",children:[t.jsx("span",{className:"canvas-audio-player__time",children:L}),t.jsx("input",{type:"range",min:0,max:k||0,step:.1,value:Math.min(x,k||x),onChange:l=>{D&&e.seekTo(Number(l.target.value))},className:"canvas-audio-player__slider canvas-audio-player__slider--progress",style:te,"aria-label":D?"Audio progress":"Reading progress",disabled:!D}),t.jsx("span",{className:"canvas-audio-player__time",children:F})]}),t.jsx(ot,{volume:e.volume,onVolumeChange:e.setVolume}),t.jsx(fe,{options:r,trigger:"click",placement:"bottom",minColumnWidth:112,onClick:l=>e.setPlaybackRate(Number(l.value)),children:t.jsx(N,{content:H,children:t.jsx("button",{type:"button",className:"canvas-audio-player__toggle canvas-audio-player__speed-toggle","aria-label":`切换播放速度,当前${I}`,children:t.jsx(Ye,{size:14})})})}),t.jsx(fe,{options:ct,trigger:"click",placement:"bottom",minColumnWidth:132,onClick:l=>e.setPlaybackMode(l.value),children:t.jsx(N,{content:a,children:t.jsx("button",{type:"button",className:"canvas-audio-player__toggle canvas-audio-player__mode-toggle","aria-label":`切换播放模式,当前${a}`,children:o})})}),t.jsx(N,{content:"打开播放器工具",children:t.jsx("button",{type:"button",className:"canvas-audio-player__toggle canvas-audio-player__player-switch canvas-audio-player__switch-toggle",onClick:()=>{ke(async()=>{const{openMusicPlayerTool:l}=await import("./startup-app-Gm7ZTEkM.js").then(A=>A.mi);return{openMusicPlayerTool:l}},__vite__mapDeps([0]),import.meta.url).then(({openMusicPlayerTool:l})=>{l()})},"aria-label":"打开播放器工具",children:t.jsx(qe,{size:14})})}),t.jsx(N,{content:_==="horizontal"?"切换为垂直布局":"切换为水平布局",children:t.jsx("button",{type:"button",className:"canvas-audio-player__toggle canvas-audio-player__layout-toggle",onClick:Pe,style:{display:h<=768?"none":""},children:_==="horizontal"?t.jsx(Ve,{size:14}):t.jsx(Be,{size:14})})}),t.jsx(N,{content:"关闭播放器",children:t.jsx("button",{type:"button",className:"canvas-audio-player__close",onClick:e.stopPlayback,children:t.jsx(He,{size:14})})}),s?t.jsx(rt,{queue:e.queue,activeQueueIndex:e.activeQueueIndex,queueSource:e.queueSource,activePlaylistId:e.activePlaylistId,playing:e.playing,activeReadingSourceId:e.activeReadingSourceId,onSelect:l=>{U(l)?e.toggleReadingPlayback(l):e.togglePlayback(l),c(!1)}}):null]})};export{vt as CanvasAudioPlayer};
|
|
2
|
+
import{_ as ke}from"./startup-runtime-DTmhLESk.js";import{r as n,j as t,d2 as he,y as C,iZ as Ae,fN as Se,dK as Te,dL as Le,d6 as ue,d4 as J,ev as U,el as Ee,m as de,c8 as Ne,bU as Ce,dN as Me,ep as Re,ex as oe,ey as pe,Y as ie,eq as _e,A as De,av as $e,ez as ze,eo as Oe,l as Ue,eA as Fe,eB as fe,eC as qe,ew as le,i_ as Ye,i$ as Ve,j0 as Be,X as He,eE as We,eF as Qe,eG as Xe,eH as Ke,eI as Ge}from"./startup-app-DLAM8ZvV.js";import{u as Je,a as Ze,b as ye,d as Z,e as et}from"./tool-windows-yv_XPMbT.js";import{b as tt}from"./ai-chat-D6xzUFfb.js";const me=5;function ve(e,i,s){const c=Math.max(0,window.innerWidth-i),f=Math.max(0,window.innerHeight-s);return{x:Math.max(0,Math.min(e.x,c)),y:Math.max(0,Math.min(e.y,f))}}function at(e){try{const i=localStorage.getItem(e);if(!i)return null;const s=JSON.parse(i);if(typeof s.x=="number"&&typeof s.y=="number")return s}catch{}return null}function nt(e,i){try{localStorage.setItem(e,JSON.stringify(i))}catch{}}function st(e){const{storageKey:i,enabled:s=!0}=e,[c,f]=n.useState(()=>s?at(i):null),[v,b]=n.useState(!1),w=n.useRef(!1),h=n.useRef(null),j=n.useRef(null),_=n.useCallback(y=>{if(!s||y.button!==0)return;const m=j.current;if(!m)return;const p=m.getBoundingClientRect();h.current={startPointerX:y.clientX,startPointerY:y.clientY,startElX:p.left,startElY:p.top,activated:!1,frameId:0}},[s]);n.useEffect(()=>{if(!s)return;const y=p=>{const u=h.current;if(!u)return;const g=p.clientX-u.startPointerX,M=p.clientY-u.startPointerY;if(!u.activated){if(Math.abs(g)<me&&Math.abs(M)<me)return;u.activated=!0,b(!0)}cancelAnimationFrame(u.frameId),u.frameId=requestAnimationFrame(()=>{const S=j.current;if(!S)return;const d=ve({x:u.startElX+g,y:u.startElY+M},S.offsetWidth,S.offsetHeight);f(d)})},m=()=>{const p=h.current;if(!p)return;cancelAnimationFrame(p.frameId);const u=p.activated;h.current=null,b(!1),u&&(w.current=!0,requestAnimationFrame(()=>{w.current=!1}),f(g=>(g&&nt(i,g),g)))};return window.addEventListener("pointermove",y),window.addEventListener("pointerup",m),()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",m)}},[s,i]),n.useEffect(()=>{if(!s||!c)return;const y=()=>{const m=j.current;m&&f(p=>p&&ve(p,m.offsetWidth,m.offsetHeight))};return window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[s,!!c]);const P=n.useCallback(()=>{f(null);try{localStorage.removeItem(i)}catch{}},[i]);return{position:c,isDragging:v,wasDraggedRef:w,elementRef:j,handlePointerDown:_,resetPosition:P}}const ot=({volume:e,onVolumeChange:i})=>{const s=n.useRef(null),c=n.useRef(null),f=n.useRef(!1),v=n.useRef(!1),b=n.useRef(!1),[w,h]=n.useState(!1),[j,_]=n.useState(!1),[P,y]=n.useState(!1),m=Math.round(e*100),p={"--canvas-audio-progress":`${e*100}%`},u=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},g=()=>{u(),h(!0)},M=()=>{u(),h(d=>!d)},S=()=>{u(),!(v.current||b.current)&&(c.current=window.setTimeout(()=>{h(!1)},180))};return n.useEffect(()=>{v.current=j},[j]),n.useEffect(()=>{b.current=P},[P]),n.useEffect(()=>()=>u(),[]),n.useEffect(()=>{if(!w)return;const d=x=>{var k;(k=s.current)!=null&&k.contains(x.target)||(u(),h(!1),y(!1),_(!1),f.current=!1)};return document.addEventListener("pointerdown",d,!0),()=>document.removeEventListener("pointerdown",d,!0)},[w]),n.useEffect(()=>{if(!P)return;const d=()=>{b.current=!1,y(!1),v.current||(u(),c.current=window.setTimeout(()=>{h(!1)},180))};return window.addEventListener("pointerup",d),()=>window.removeEventListener("pointerup",d)},[P]),t.jsx("div",{ref:s,className:he("canvas-audio-player__volume",{"canvas-audio-player__volume--expanded":w}),onPointerDown:d=>d.stopPropagation(),onMouseEnter:()=>{v.current=!0,_(!0),u()},onMouseLeave:()=>{v.current=!1,_(!1),S()},onBlur:d=>{var k;const x=d.relatedTarget;x&&((k=s.current)!=null&&k.contains(x))||S()},children:t.jsxs("div",{className:"canvas-audio-player__volume-shell",children:[t.jsx("div",{className:"canvas-audio-player__volume-slider-wrap",children:t.jsx("input",{type:"range",min:0,max:1,step:.01,value:e,onFocus:g,onPointerDown:d=>{d.stopPropagation(),b.current=!0,y(!0),g()},onChange:d=>i(Number(d.target.value)),className:"canvas-audio-player__slider canvas-audio-player__slider--volume",style:p,"aria-label":"Playback volume","aria-valuetext":`${m}%`})}),t.jsxs("span",{className:"canvas-audio-player__volume-value",children:[m,"%"]}),t.jsx(C,{content:"音量",children:t.jsx("button",{type:"button",className:"canvas-audio-player__volume-toggle",onPointerDown:d=>{d.stopPropagation(),f.current=!0},onClick:()=>{f.current=!1,M()},onFocus:()=>{f.current||g()},onBlur:()=>{f.current=!1},"aria-label":"Volume controls","aria-expanded":w,children:e<=.01?t.jsx(Ae,{size:16}):t.jsx(Se,{size:16})})})]})})},ge="asset:";function it(e){var i;return(i=e==null?void 0:e.elementId)!=null&&i.startsWith(ge)?e.elementId.slice(ge.length):null}function xe(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"--:--";const i=Math.floor(e),s=Math.floor(i/60),c=i%60;return`${s}:${String(c).padStart(2,"0")}`}function lt(e){var s;const i=((s=e.segments[e.segments.length-1])==null?void 0:s.endMs)||0;return xe(i/1e3)}const rt=({queue:e,activeQueueIndex:i,queueSource:s,activePlaylistId:c,playing:f=!1,activeReadingSourceId:v,onSelect:b,onPlayAllTracksItem:w})=>{const{assets:h}=Te(),{playlists:j,playlistItems:_,favoriteAssetIds:P,createPlaylist:y,addAssetToPlaylist:m,removeAssetFromPlaylist:p,toggleFavorite:u}=Le(),{contextMenu:g,openAt:M,close:S}=tt(),[d,x]=n.useState(!1),[k,E]=n.useState(""),[F,T]=n.useState(null),{noteMetas:$,loadReadingSource:Q,buildReadingQueue:X}=Je(),[q,Y]=n.useState(s==="reading"?ue:J),V=q===ue,R=s==="playlist"&&c?c:J,L=e.filter(a=>!U(a)),ee=Ze(L),K=a=>{const o=it(a);if(o)return o;if(!(a!=null&&a.audioUrl))return null;const r=h.find(I=>I.type===Me.AUDIO&&I.url===a.audioUrl);return(r==null?void 0:r.id)||null},B=n.useMemo(()=>new Set(R!==J?(_[R]||[]).map(a=>a.assetId?Ee({kind:"asset",assetId:a.assetId}):null).filter(a=>!!a):[]),[_,R]),D=n.useCallback(async a=>{if(w){w(a);return}const o=await Q(a);o&&(await X(a),b(o))},[w,Q,X,b]),z=n.useMemo(()=>$.map(a=>({id:a.id,title:a.title||"未命名笔记",subtitle:new Date(a.updatedAt).toLocaleDateString("zh-CN"),canFavorite:!1,isActive:(v==null?void 0:v.includes(a.id))===!0,isPlaying:f&&(v==null?void 0:v.includes(a.id))===!0})),[$,v,f]);return s==="reading"?t.jsxs("div",{className:"canvas-audio-player__playlist",children:[t.jsx(ye,{className:"canvas-audio-player__playlist-tabs",selectedPlaylistId:q,allCount:L.length,allTracksCount:$.length,playlists:j,playlistItems:_,onSelect:Y,onCreate:()=>{E(""),x(!0)}}),V?z.length===0?t.jsxs("div",{className:"canvas-audio-player__playlist-empty",children:[t.jsx(de,{size:16}),t.jsx("span",{children:"知识库还没有笔记"})]}):t.jsx(Z,{className:"canvas-audio-player__playlist-list",items:z,onSelect:a=>void D(a.id),onTogglePlayback:a=>void D(a.id),showPlaybackIndicator:!0}):t.jsx(Z,{className:"canvas-audio-player__playlist-list audio-track-list--queue",items:e.map((a,o)=>{const r=a;return{id:r.readingSourceId,title:r.title||"朗读轨道",subtitle:lt(r),previewImageUrl:r.previewImageUrl,isActive:o===i,isPlaying:o===i,canFavorite:!1}}),onSelect:a=>{const o=e.find(r=>U(r)&&r.readingSourceId===a.id);o&&b(o)},onTogglePlayback:a=>{const o=e.find(r=>U(r)&&r.readingSourceId===a.id);o&&b(o)},showPlaybackIndicator:!0})]}):t.jsxs("div",{className:"canvas-audio-player__playlist",children:[t.jsx(ye,{className:"canvas-audio-player__playlist-tabs",selectedPlaylistId:q,allCount:L.length,allTracksCount:$.length,playlists:j,playlistItems:_,onSelect:Y,onCreate:()=>{E(""),x(!0)}}),V?z.length===0?t.jsxs("div",{className:"canvas-audio-player__playlist-empty",children:[t.jsx(de,{size:16}),t.jsx("span",{children:"知识库还没有笔记"})]}):t.jsx(Z,{className:"canvas-audio-player__playlist-list",items:z,onSelect:a=>void D(a.id),onTogglePlayback:a=>void D(a.id),showPlaybackIndicator:!0}):t.jsx(Z,{className:"canvas-audio-player__playlist-list audio-track-list--queue",items:L.map((a,o)=>{const r=K(a);return{id:`${a.audioUrl}-${o}`,title:a.title||"未命名音频",subtitle:xe(ee.get(a.audioUrl)??a.duration),previewImageUrl:a.previewImageUrl,isActive:o===i,isPlaying:o===i,isFavorite:r?P.has(r):!1,canFavorite:!!r}}),onSelect:a=>{const o=L.find((r,I)=>`${r.audioUrl}-${I}`===a.id);o&&b(o)},onContextMenu:(a,o)=>{const r=L.find((H,te)=>`${H.audioUrl}-${te}`===a.id),I=K(r);I&&(o.preventDefault(),o.stopPropagation(),M(o.clientX,o.clientY,{kind:"asset",assetId:I}))},onToggleFavorite:a=>{const o=L.find((I,H)=>`${I.audioUrl}-${H}`===a.id),r=K(o);r&&u(r)},onTogglePlayback:a=>{const o=L.find((r,I)=>`${r.audioUrl}-${I}`===a.id);o&&b(o)},showFavoriteButton:!0,showPlaybackIndicator:!0}),t.jsx(et,{contextMenu:g?{x:g.x,y:g.y,item:g.payload}:null,playlists:j,playlistItems:_,favoriteAssetIds:P,selectedPlaylistId:R===J?null:R,currentPlaylistItemKeys:B,onClose:S,onToggleFavorite:a=>void u(a),onAddToPlaylist:(a,o)=>{a.kind==="asset"&&m(a.assetId,o)},onRemoveFromPlaylist:(a,o)=>{a.kind==="asset"&&p(a.assetId,o)},onCreatePlaylistAndAdd:a=>{a.kind==="asset"&&(T(a.assetId),E(""),x(!0))}}),t.jsx(Ne,{visible:d,header:"新建播放列表",onClose:()=>x(!1),onConfirm:async()=>{const a=await y(k);F&&await m(F,a.id),x(!1),E(""),T(null)},onCancel:()=>{x(!1),T(null)},confirmBtn:"确定",cancelBtn:"取消",children:t.jsx(Ce,{value:k,onChange:a=>E(String(a)),placeholder:"请输入播放列表名称"})})]})},we={sequential:t.jsx(Ge,{size:14}),"list-loop":t.jsx(Ke,{size:14}),"single-loop":t.jsx(Xe,{size:14}),shuffle:t.jsx(Qe,{size:14})},ct=Object.keys(le).map(e=>({value:e,content:le[e],prefixIcon:we[e]}));function ut(e,i){return We(i).map(s=>{const c=_e(s),f=Math.abs(s-e)<.001;return{value:s,content:f?`✓ ${c}`:c}})}function be(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"--:--";const i=Math.floor(e),s=Math.floor(i/60),c=i%60;return`${s}:${String(c).padStart(2,"0")}`}const vt=()=>{const e=Re(),i=n.useRef(null),[s,c]=n.useState(!1),[f,v]=n.useState(()=>{const l=oe.getToolState(pe);return(l==null?void 0:l.status)==="open"}),[b,w]=n.useState(()=>{try{return localStorage.getItem(ie.AUDIO_PLAYER_LAYOUT)==="vertical"?"vertical":"horizontal"}catch{return"horizontal"}}),[h,j]=n.useState(()=>typeof window<"u"?window.innerWidth:1024);n.useEffect(()=>{const l=()=>j(window.innerWidth);return window.addEventListener("resize",l),window.addEventListener("orientationchange",l),()=>{window.removeEventListener("resize",l),window.removeEventListener("orientationchange",l)}},[]);const _=h<=768?"vertical":b,[P,y]=n.useState(null),m=h<=768,{position:p,isDragging:u,wasDraggedRef:g,elementRef:M,handlePointerDown:S}=st({storageKey:ie.AUDIO_PLAYER_POSITION,enabled:!m}),d=n.useMemo(()=>!e.duration||e.duration<=0?0:Math.max(0,Math.min(100,e.currentTime/e.duration*100)),[e.currentTime,e.duration]),x=Number.isFinite(e.currentTime)?e.currentTime:0,k=Number.isFinite(e.duration)?e.duration:0,E=be(x),F=be(k),T=e.activeQueueIndex>=0?e.queue[e.activeQueueIndex]:null,$=e.activeTitle||(U(T)?T.title:void 0),Q=e.activePreviewImageUrl||(U(T)?T.previewImageUrl:void 0),X=e.activeQueueIndex>0,q=e.activeQueueIndex>=0&&e.activeQueueIndex<e.queue.length-1,Y=e.queue.length>1&&e.activeQueueIndex>=0,V=Y?`${e.activeQueueIndex+1}/${e.queue.length}`:null,R=e.queueSource==="playlist"?e.activePlaylistName||"播放列表":e.activePlaylistName||(e.queueSource==="reading"?"朗读轨道":"画布音频"),L=Y?`${R} ${e.activeQueueIndex+1} / ${e.queue.length}`:R,ee=V?`${V} · ${E} / ${F}`:`${E} / ${F}`,B=e.queueSource==="reading"&&(!!e.activeReadingSourceId||T!==null&&U(T))||!!e.activeAudioUrl,D=e.mediaType==="audio",z=e.mediaType==="reading"?"reading":"audio",a=le[e.playbackMode],o=we[e.playbackMode],r=n.useMemo(()=>ut(e.effectivePlaybackRate,z),[e.effectivePlaybackRate,z]),I=_e(e.effectivePlaybackRate),H=`${e.mediaType==="reading"?"语音速度":"播放速度"} ${I}`,te={"--canvas-audio-progress":`${d}%`},Pe=n.useCallback(()=>{w(l=>{const A=l==="horizontal"?"vertical":"horizontal";try{localStorage.setItem(ie.AUDIO_PLAYER_LAYOUT,A)}catch{}return A})},[]),Ie=n.useCallback(async()=>{try{e.playing?e.pausePlayback():await e.resumePlayback()}catch{}},[e]);if(n.useEffect(()=>{if(!B){c(!1),y(null);return}let l=0;const A=()=>{const ce=document.querySelector(".ai-input-bar__container");if(!(ce instanceof HTMLElement)){y(null);return}const se=ce.getBoundingClientRect(),G={left:Math.round(se.left),width:Math.round(se.width),bottom:Math.max(0,Math.round(window.innerHeight-se.top))};y(W=>W&&W.left===G.left&&W.width===G.width&&W.bottom===G.bottom?W:G)},N=()=>{window.cancelAnimationFrame(l),l=window.requestAnimationFrame(A)},ae=document.querySelector(".ai-input-bar__container"),ne=document.querySelector(".ai-input-bar"),O=typeof ResizeObserver<"u"?new ResizeObserver(()=>N()):null;return O&&ae instanceof HTMLElement&&O.observe(ae),O&&ne instanceof HTMLElement&&ne!==ae&&O.observe(ne),N(),window.addEventListener("resize",N),window.addEventListener("orientationchange",N),()=>{window.cancelAnimationFrame(l),window.removeEventListener("resize",N),window.removeEventListener("orientationchange",N),O==null||O.disconnect()}},[B]),n.useEffect(()=>{if(!s)return;const l=A=>{var N;(N=i.current)!=null&&N.contains(A.target)||c(!1)};return document.addEventListener("pointerdown",l,!0),()=>document.removeEventListener("pointerdown",l,!0)},[s]),n.useEffect(()=>{M.current=i.current}),n.useEffect(()=>{const l=oe.observeToolStates().subscribe(()=>{const A=oe.getToolState(pe);v((A==null?void 0:A.status)==="open")});return()=>l.unsubscribe()},[]),!B||f)return null;const je=p&&!m?{left:p.x,top:p.y}:{},re={...P?{"--canvas-audio-mobile-left":`${P.left}px`,"--canvas-audio-mobile-width":`${P.width}px`,"--canvas-audio-mobile-offset":`${P.bottom}px`}:{},...je};return t.jsxs("div",{ref:i,className:he("canvas-audio-player",{"canvas-audio-player--playlist-open":s,"canvas-audio-player--positioned":!!p,"canvas-audio-player--dragging":u,"canvas-audio-player--vertical":_==="vertical"}),style:Object.keys(re).length>0?re:void 0,children:[t.jsxs("button",{type:"button",className:"canvas-audio-player__queue-trigger",onPointerDown:S,onClick:()=>{g.current||c(l=>!l)},"aria-expanded":s,"aria-label":"切换播放列表",children:[t.jsx("div",{className:"canvas-audio-player__cover",children:t.jsx(De,{src:Q,alt:$||"Audio cover",fallbackClassName:"canvas-audio-player__cover-fallback",iconSize:16})}),t.jsxs("div",{className:"canvas-audio-player__meta",children:[t.jsx("div",{className:"canvas-audio-player__title",children:$||"未命名音频"}),t.jsxs("div",{className:"canvas-audio-player__subtitle",children:[t.jsx("span",{className:"canvas-audio-player__subtitle-text canvas-audio-player__subtitle-text--desktop",children:L}),t.jsx("span",{className:"canvas-audio-player__subtitle-text canvas-audio-player__subtitle-text--mobile",children:ee})]})]}),t.jsx("span",{className:"canvas-audio-player__queue-indicator","aria-hidden":"true",children:t.jsx($e,{size:14})})]}),t.jsxs("div",{className:"canvas-audio-player__controls",children:[t.jsx(C,{content:"上一首",children:t.jsx("button",{type:"button",className:"canvas-audio-player__action canvas-audio-player__action--previous",onClick:()=>void e.playPrevious(),disabled:!X,children:t.jsx(ze,{size:14})})}),t.jsx(C,{content:e.playing?"暂停":"播放",children:t.jsx("button",{type:"button",className:"canvas-audio-player__action canvas-audio-player__action--primary",onClick:()=>void Ie(),children:e.playing?t.jsx(Oe,{size:14}):t.jsx(Ue,{size:14})})}),t.jsx(C,{content:"下一首",children:t.jsx("button",{type:"button",className:"canvas-audio-player__action canvas-audio-player__action--next",onClick:()=>void e.playNext(),disabled:!q,children:t.jsx(Fe,{size:14})})})]}),t.jsxs("div",{className:"canvas-audio-player__progress",children:[t.jsx("span",{className:"canvas-audio-player__time",children:E}),t.jsx("input",{type:"range",min:0,max:k||0,step:.1,value:Math.min(x,k||x),onChange:l=>{D&&e.seekTo(Number(l.target.value))},className:"canvas-audio-player__slider canvas-audio-player__slider--progress",style:te,"aria-label":D?"Audio progress":"Reading progress",disabled:!D}),t.jsx("span",{className:"canvas-audio-player__time",children:F})]}),t.jsx(ot,{volume:e.volume,onVolumeChange:e.setVolume}),t.jsx(fe,{options:r,trigger:"click",placement:"bottom",minColumnWidth:112,onClick:l=>e.setPlaybackRate(Number(l.value)),children:t.jsx(C,{content:H,children:t.jsx("button",{type:"button",className:"canvas-audio-player__toggle canvas-audio-player__speed-toggle","aria-label":`切换播放速度,当前${I}`,children:t.jsx(qe,{size:14})})})}),t.jsx(fe,{options:ct,trigger:"click",placement:"bottom",minColumnWidth:132,onClick:l=>e.setPlaybackMode(l.value),children:t.jsx(C,{content:a,children:t.jsx("button",{type:"button",className:"canvas-audio-player__toggle canvas-audio-player__mode-toggle","aria-label":`切换播放模式,当前${a}`,children:o})})}),t.jsx(C,{content:"打开播放器工具",children:t.jsx("button",{type:"button",className:"canvas-audio-player__toggle canvas-audio-player__player-switch canvas-audio-player__switch-toggle",onClick:()=>{ke(async()=>{const{openMusicPlayerTool:l}=await import("./startup-app-DLAM8ZvV.js").then(A=>A.mj);return{openMusicPlayerTool:l}},__vite__mapDeps([0]),import.meta.url).then(({openMusicPlayerTool:l})=>{l()})},"aria-label":"打开播放器工具",children:t.jsx(Ye,{size:14})})}),t.jsx(C,{content:_==="horizontal"?"切换为垂直布局":"切换为水平布局",children:t.jsx("button",{type:"button",className:"canvas-audio-player__toggle canvas-audio-player__layout-toggle",onClick:Pe,style:{display:h<=768?"none":""},children:_==="horizontal"?t.jsx(Ve,{size:14}):t.jsx(Be,{size:14})})}),t.jsx(C,{content:"关闭播放器",children:t.jsx("button",{type:"button",className:"canvas-audio-player__close",onClick:e.stopPlayback,children:t.jsx(He,{size:14})})}),s?t.jsx(rt,{queue:e.queue,activeQueueIndex:e.activeQueueIndex,queueSource:e.queueSource,activePlaylistId:e.activePlaylistId,playing:e.playing,activeReadingSourceId:e.activeReadingSourceId,onSelect:l=>{U(l)?e.toggleReadingPlayback(l):e.togglePlayback(l),c(!1)}}):null]})};export{vt as CanvasAudioPlayer};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./startup-app-D5aWsYi2.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{aI as gs,dM as lr,r as s,hL as qt,a7 as Ae,hM as Zn,ex as tn,j as u,hN as dr,br as ws,dc as Pt,bb as ur,hO as fr,hP as hr,ae as pr,n as mr,dz as Wo,fn as gr,aT as wr,ao as Ve,hQ as Gn,a6 as Pn,bh as qn,b6 as At,bg as Et,bi as pt,hR as Jn,hS as eo,hT as et,Q as to,hU as Lo,av as no,$ as oo,at as An,cT as xs,b5 as ys,gB as xr,cS as yr,q as so,h as Ir,hV as br,X as _r,a2 as vr,bR as kr,gZ as Sr,f4 as ro,aN as Mr,m as Cr,hW as Tr,hX as Pr,bj as Cn,hY as Qn,v as Is,hZ as Ar,dK as Er,fo as dt,fD as $n,ab as mt,aJ as Ct,h_ as Bo,h$ as Fo,i0 as Dr,fy as je,fm as Un,bG as Rr,i1 as wn,M as Je,dN as Ho,dO as Nr,i2 as jr,i3 as zr,i4 as Or,i5 as Wr,i6 as Go,gH as bs,g as Vn,dA as $o,i7 as Lr,bH as _s,i8 as Uo,a as Vo,i9 as Ko,ia as Yo,d2 as xn,e0 as Br,cY as Fr,ib as Hr,ef as Gr,ic as $r,id as Ur}from"./startup-app-DLAM8ZvV.js";import{u as Vr,a as Kr,c as yn,b as Tt,W as Yr}from"./useWorkflowSubmission-BaHaR3xS.js";import{P as Xr,r as In,G as bn,q as Zr,o as Tn,L as ao,N as qr,O as Jr,y as _n,E as ut,Q as Qr,R as Xo,M as vn,S as ea,T as ta,X as na,Y as Zo,Z as qo,$ as Jo,a0 as oa}from"./ai-chat-D6xzUFfb.js";import{_ as Qo}from"./startup-runtime-DTmhLESk.js";import{c as sa,q as ra,A as es,M as aa}from"./tool-windows-yv_XPMbT.js";import{u as ia,r as ca,g as la,a as da,b as ua,l as fa,c as Kn,s as ha,d as pa,P as ma}from"./ai-generation-preferences-service-Cl6IE7ok.js";import{s as ts}from"./workflow-submission-service-B8JbWpRf.js";import"./skill-dsl-parser-DpA8awF4.js";const ga=({generationType:e,onSelectPrompt:n,language:t,extraActions:l,onBeforeOpenMyPrompts:r})=>{const{history:c,removeHistory:a,refreshHistory:m}=gs({deduplicateWithPresets:!1,modelTypeFilter:e==="image"||e==="video"?void 0:e}),{imageHistory:d,videoHistory:h}=ia(),{confirm:p,confirmDialog:S}=lr(),[I,v]=s.useState(!1),[,g]=s.useState(0),R=s.useRef(null),x=s.useRef(null),C=s.useRef(null),N=t==="zh"?"我的提示词":"My Prompts",E=e==="image"||e==="video"?ca({generationType:e,language:t,promptContents:la(e,t,e==="image"?d:h),imageHistory:d,videoHistory:h}):da({generationType:e,language:t,aiInputHistory:c,imageHistory:d,videoHistory:h});s.useEffect(()=>qt.subscribeChanges(()=>{m(),g(K=>K+1)}),[m]),s.useEffect(()=>()=>{x.current&&clearTimeout(x.current),C.current&&clearTimeout(C.current)},[]);const b=s.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null),x.current=setTimeout(()=>{m(),g(K=>K+1),I||Ae.trackPromptAction({action:"open_panel",surface:"ai_input_prompt_popover",promptType:e,itemCount:E.length}),v(!0)},150)},[e,I,E.length,m]),T=s.useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null),C.current=setTimeout(()=>{v(!1)},200)},[]),G=s.useCallback(K=>{n({content:K.content,modelType:K.modelType,scene:K.scene}),v(!1)},[n]),te=s.useCallback(async K=>{const k=E.find(ae=>ae.id===K);!k||!await p({title:t==="zh"?"确认删除提示词":"Delete Prompt",description:t==="zh"?"确定要删除这条提示词吗?此操作不可撤销。":"Are you sure you want to delete this prompt? This action cannot be undone.",confirmText:t==="zh"?"删除":"Delete",cancelText:t==="zh"?"取消":"Cancel",danger:!0})||(qt.deletePrompt(e,k.content),k.historyId&&e!=="image"&&e!=="video"?a(k.historyId):g(ae=>ae+1))},[p,e,t,E,a]),Z=s.useCallback(K=>{const k=E.find(P=>P.id===K);k&&(qt.isPinned(e,k.content)?qt.unpinPrompt(e,k.content):qt.pinPrompt(e,k.content),g(P=>P+1))},[e,E]),re=s.useCallback(()=>{const K=Zn.find(ae=>ae.id==="prompt-history");if(!K){Ae.trackPromptAction({action:"open_tool",surface:"ai_input_prompt_popover",promptType:e,status:"failed",metadata:{tool_id:"prompt-history",reason:"tool_not_found"}});return}r==null||r();const k=tn.getToolState("prompt-history");console.info("[PromptHistoryPopover] open my prompts",{generationType:e,beforeStatus:k==null?void 0:k.status,beforeInstanceId:k==null?void 0:k.instanceId,beforeIsLauncher:k==null?void 0:k.isLauncher,beforeIsPinned:k==null?void 0:k.isPinned}),Ae.trackPromptAction({action:"open_tool",surface:"ai_input_prompt_popover",promptType:e,status:"success",metadata:{tool_id:K.id}}),v(!1),tn.openTool(K,{componentProps:{initialCategory:e}});const P=tn.getToolState("prompt-history");console.info("[PromptHistoryPopover] requested my prompts open",{generationType:e,afterStatus:P==null?void 0:P.status,afterInstanceId:P==null?void 0:P.instanceId,afterIsLauncher:P==null?void 0:P.isLauncher,afterIsPinned:P==null?void 0:P.isPinned})},[e,r]);return u.jsxs("div",{ref:R,className:"prompt-history-popover",children:[u.jsxs("div",{className:"prompt-history-popover__actions",children:[u.jsx("button",{className:"prompt-history-popover__trigger",title:N,"data-track":"ai_input_click_history",onMouseEnter:b,onMouseLeave:T,children:u.jsx(dr,{size:18})}),l]}),I&&u.jsx("div",{className:"prompt-history-popover__panel-wrapper",onMouseEnter:b,onMouseLeave:T,children:u.jsx(Xr,{title:N,items:E,onSelect:G,onTogglePin:Z,onDelete:te,onTitleClick:re,language:t,showCount:!0,analyticsSurface:"ai_input_prompt_popover",analyticsPromptType:e})}),S]})};function wa(e){var n;return!!((n=e.params)!=null&&n.longVideoMeta)}function xa(e){var n;return((n=e.params)==null?void 0:n.longVideoMeta)||null}class Dt{constructor(){this.isInitialized=!1,this.batches=new Map,this.initTimestamp=0}static getInstance(){return Dt.instance||(Dt.instance=new Dt),Dt.instance}initialize(){this.isInitialized||(this.isInitialized=!0,this.initTimestamp=Date.now(),ws.observeTaskUpdates().subscribe(n=>{if(n.type==="taskUpdated"&&n.task.status===Pt.COMPLETED&&n.task.type===ur.VIDEO&&wa(n.task)){if((n.task.completedAt||0)<this.initTimestamp)return;this.handleSegmentCompleted(n.task).catch(l=>{console.error("[LongVideoChain] Error handling completed segment:",l)})}}))}async handleSegmentCompleted(n){var h;const t=xa(n);if(!t)return;const{segmentIndex:l,totalSegments:r,scripts:c,batchId:a}=t,m=(h=n.result)==null?void 0:h.url;let d=this.batches.get(a);if(d||(d={batchId:a,totalSegments:r,completedSegments:new Map,processedSegments:new Set,creatingNextFor:null,isMerging:!1,mergeCompleted:!1,scripts:c||[],characterReferenceUrls:t.characterReferenceUrls,characterDescription:t.characterDescription},this.batches.set(a,d)),!d.processedSegments.has(l)){if(d.processedSegments.add(l),m&&d.completedSegments.set(l,m),d.completedSegments.size===r){await this.mergeAndInsert(d);return}if(d.creatingNextFor!==l&&l<r){d.creatingNextFor=l;try{await this.createNextSegment(n,t,c,m,d.characterReferenceUrls,d.characterDescription)}finally{d.creatingNextFor=null}}}}async createNextSegment(n,t,l,r,c,a){const m=t.segmentIndex+1,d=l.find(S=>S.index===m);if(!d){console.error(`[LongVideoChain] Script not found for segment ${m}`);return}let h;if(r)try{h=(await fr(r)).dataUrl}catch(S){console.error("[LongVideoChain] Failed to extract last frame:",S)}const p={...t,segmentIndex:m,needsLastFrame:m<t.totalSegments,characterReferenceUrls:c??t.characterReferenceUrls,characterDescription:a??t.characterDescription};sa(d,p,h)}async mergeAndInsert(n){if(!(n.isMerging||n.mergeCompleted)){n.isMerging=!0;try{const t=[];for(let a=1;a<=n.totalSegments;a++){const m=n.completedSegments.get(a);m&&t.push(m)}if(t.length===0){console.error("[LongVideoChain] No video URLs to merge");return}const l=this.extractTransitions(n),c=await hr(t,(a,m,d)=>{const h=d||`${m} ${a.toFixed(1)}%`},{transitions:l,transitionDuration:.5});await this.insertMergedVideo(c.url),n.mergeCompleted=!0,this.cleanupBatch(n.batchId)}catch(t){console.error("[LongVideoChain] Merge failed:",t),this.cleanupBatch(n.batchId)}finally{n.isMerging=!1}}}async insertMergedVideo(n){try{await ra("video",n)}catch(t){console.error("[LongVideoChain] Failed to insert video to canvas:",t)}}extractTransitions(n){return!n.scripts||n.scripts.length===0?[]:n.scripts.sort((t,l)=>t.index-l.index).slice(0,-1).map(t=>t.transition_hint||"cut")}cleanupBatch(n){const t=this.batches.get(n);t&&(t.completedSegments.clear(),t.processedSegments.clear(),this.batches.delete(n))}getBatchStatus(n){const t=this.batches.get(n);return t?{completed:t.completedSegments.size,total:t.totalSegments,isMerging:t.isMerging,mergeCompleted:t.mergeCompleted}:null}}const ya=Dt.getInstance();function Ia(){ya.initialize()}function ns(){return`img-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function os(e){return new Promise((n,t)=>{const l=new Image,r=e.startsWith("http")&&!e.startsWith(location.origin);l.crossOrigin="anonymous",l.onload=()=>n(l),l.onerror=()=>{t(r?new Error("无法加载外部图片,可能是跨域 (CORS) 限制。请先下载图片到本地后再操作。"):new Error("图片加载失败,请检查图片是否有效"))},l.src=e})}function ba(e,n=.92){return e.toDataURL("image/jpeg",n)}class _a{async split(n,t){const{rows:l,cols:r}=t;if(l<1||r<1)throw new Error("Grid rows and cols must be at least 1");const c=await os(n),a=c.naturalWidth,m=c.naturalHeight,d=Math.floor(a/r),h=Math.floor(m/l),p=[];for(let S=0;S<l;S++)for(let I=0;I<r;I++){const v=S*r+I,g=I*d,R=S*h,x=document.createElement("canvas");x.width=d,x.height=h;const C=x.getContext("2d");if(!C)throw new Error("Failed to get canvas 2d context");C.drawImage(c,g,R,d,h,0,0,d,h);const N=ba(x);p.push({id:ns(),imageData:N,originalIndex:v,width:d,height:h})}return p}async splitToBlob(n,t){const{rows:l,cols:r}=t;if(l<1||r<1)throw new Error("Grid rows and cols must be at least 1");const c=await os(n),a=c.naturalWidth,m=c.naturalHeight,d=Math.floor(a/r),h=Math.floor(m/l),p=[];for(let S=0;S<l;S++)for(let I=0;I<r;I++){const v=S*r+I,g=I*d,R=S*h,x=document.createElement("canvas");x.width=d,x.height=h;const C=x.getContext("2d");if(!C)throw new Error("Failed to get canvas 2d context");C.drawImage(c,g,R,d,h,0,0,d,h);const N=await new Promise((b,T)=>{x.toBlob(G=>{G?b(G):T(new Error("Failed to create blob"))},"image/png",.92)}),E=URL.createObjectURL(N);p.push({id:ns(),imageData:E,originalIndex:v,width:d,height:h})}return p}revokeBlobUrls(n){for(const t of n)t.imageData.startsWith("blob:")&&URL.revokeObjectURL(t.imageData)}}const ss=new _a;function Pe(e,n){return Math.random()*(n-e)+e}function kn(e){const n=[...e];for(let t=n.length-1;t>0;t--){const l=Math.floor(Math.random()*(t+1));[n[t],n[l]]=[n[l],n[t]]}return n}class va{calculate(n,t,l,r){switch(t){case"scattered":return this.scatteredLayout(n,l,r);case"grid":return this.gridLayout(n,l);case"circular":return this.circularLayout(n,l,r);case"inspiration-board":return this.inspirationBoardLayout(n,l,r);default:return console.warn(`[LayoutEngine] Unknown layout style: ${t}, falling back to grid`),this.gridLayout(n,l)}}scatteredLayout(n,t,l){const{maxRotation:r=15,minScale:c=.85,maxScale:a=1.15,positionJitter:m=40}=l||{},{canvasWidth:d,canvasHeight:h,startX:p,startY:S,gap:I=20}=t,v=n.length,g=Math.ceil(Math.sqrt(v)),R=Math.ceil(v/g),x=Math.max(...n.map(Z=>Z.width)),C=Math.max(...n.map(Z=>Z.height)),N=d-I*2,E=h-I*2,b=N/g,T=E/R,G=Math.min((b-I)/x,(T-I)/C,1),te=kn(n.map((Z,re)=>re));return n.map((Z,re)=>{const K=Math.floor(re/g),k=re%g,P=p+I+k*b+b/2,ae=S+I+K*T+T/2,U=Pe(-m,m),B=Pe(-m,m),ie=Pe(-r,r),_e=Pe(c,a),Ee=G*_e,tt=Z.width*Ee,nn=Z.height*Ee;return{...Z,x:P+U-tt/2,y:ae+B-nn/2,rotation:ie,scale:Ee,zIndex:te[re]}})}gridLayout(n,t){const{canvasWidth:l,canvasHeight:r,startX:c,startY:a,gap:m=20}=t,d=n.length,h=Math.ceil(Math.sqrt(d)),p=Math.ceil(d/h),S=Math.max(...n.map(N=>N.width)),I=Math.max(...n.map(N=>N.height)),v=l-m*(h+1),g=r-m*(p+1),R=v/h,x=g/p,C=Math.min(R/S,x/I,1);return n.map((N,E)=>{const b=Math.floor(E/h),T=E%h,G=N.width*C,te=N.height*C,Z=c+m+T*(R+m),re=a+m+b*(x+m),K=Z+(R-G)/2,k=re+(x-te)/2;return{...N,x:K,y:k,rotation:0,scale:C,zIndex:E}})}circularLayout(n,t,l){const{centerIndex:r=-1,radius:c,startAngle:a=-90}=l||{},{canvasWidth:m,canvasHeight:d,startX:h,startY:p}=t,S=h+m/2,I=p+d/2,v=r>=0&&r<n.length?n.filter((k,P)=>P!==r):n,g=r>=0&&r<n.length?n[r]:null,R=Math.max(...n.map(k=>k.width)),x=Math.max(...n.map(k=>k.height)),C=Math.max(R,x),N=v.length,E=C*.8,b=N*C*1.2,T=Math.max(E,b/(2*Math.PI)),G=c||Math.min(T,Math.min(m,d)/2-C/2),te=Math.min(m,d),Z=Math.min(te*.25/C,1),re=[];if(g){const k=g.width*Z*1.2,P=g.height*Z*1.2;re.push({...g,x:S-k/2,y:I-P/2,rotation:0,scale:Z*1.2,zIndex:N})}const K=360/N;return v.forEach((k,P)=>{const U=(a+P*K)*Math.PI/180,B=k.width*Z,ie=k.height*Z,_e=S+G*Math.cos(U)-B/2,Ee=I+G*Math.sin(U)-ie/2;re.push({...k,x:_e,y:Ee,rotation:0,scale:Z,zIndex:P})}),re}inspirationBoardLayout(n,t,l){const{minWidthRatio:r=In.minWidthRatio,maxWidthRatio:c=In.maxWidthRatio,maxRotation:a=In.maxRotation,gap:m=In.gap}=l||{},{canvasWidth:d,canvasHeight:h,startX:p,startY:S}=t,I=n.length,v=this.assignSizeCategories(I),g=n.reduce((T,G)=>T+G.width,0)/I,R=n.reduce((T,G)=>T+G.height,0)/I,x=d||1200,C=h||600,N=Math.min(x*.25/g,C*.4/R,1),E=this.calculateInspirationBoardPositions(I,x,C,m),b=kn(n.map((T,G)=>G));return n.map((T,G)=>{const te=E[G],Z=v[G];let re;switch(Z){case"large":re=Pe(1.2,c);break;case"medium":re=Pe(.9,1.1);break;case"small":re=Pe(r,.85);break;default:re=1}const K=N*re,k=Pe(-a,a),P=Pe(-20,20),ae=Pe(-15,15),U=T.width*K,B=T.height*K;return{...T,x:p+te.x+P-U/2,y:S+te.y+ae-B/2,rotation:k,scale:K,zIndex:b[G]}})}assignSizeCategories(n){const t=[],l=Math.max(2,Math.floor(n*.25)),r=Math.max(2,Math.floor(n*.25)),c=n-l-r;for(let a=0;a<l;a++)t.push("large");for(let a=0;a<c;a++)t.push("medium");for(let a=0;a<r;a++)t.push("small");return kn(t)}calculateInspirationBoardPositions(n,t,l,r){const c=[],a=Math.ceil(n/4),m=Math.ceil(n/a),d=(t-r*2)/m,h=(l-r*2)/a;for(let p=0;p<n;p++){const S=Math.floor(p/m),I=p%m,v=r+I*d+d/2,g=r+S*h+h/2,R=Pe(-d*.3,d*.3),x=Pe(-h*.2,h*.2);c.push({x:v+R,y:g+x})}return kn(c)}calculateRequiredSize(n,t,l=.5){const r=n.length,c=Math.ceil(Math.sqrt(r)),a=Math.ceil(r/c),m=Math.max(...n.map(v=>v.width)),d=Math.max(...n.map(v=>v.height)),h=20,p=t==="scattered"?60:40,S=c*m*l+(c+1)*h+p*2,I=a*d*l+(a+1)*h+p*2;return{width:S,height:I}}}const rs=new va;class ka{constructor(){this.board=null}setBoard(n){this.board=n}getBoard(){return this.board}async generate(n){const{theme:t,gridConfig:l=bn.gridConfig,layoutStyle:r=bn.layoutStyle,imageSize:c=bn.imageSize,imageQuality:a=bn.imageQuality}=n;try{const m=this.buildPrompt(t,l),d=await pr.generateImage(m,{size:c,quality:a,response_format:"url"});if(!d.data||d.data.length===0)throw new Error("AI 生成图片失败:未返回图片数据");const h=d.data[0].url||d.data[0].b64_json,p=h&&mr(String(h));if(!p)throw new Error("AI 生成图片失败:未返回图片 URL");const S=await Wo.getImageForAI(p),I=S.type==="base64"?S.value:p,v=await ss.split(I,l),g=this.calculateLayoutParams(v),R=rs.calculate(v,r,g);return{success:!0,originalImageUrl:p,elements:R}}catch(m){return console.error("[GridImageService] Generation failed:",m),{success:!1,error:m.message||"宫格图生成失败"}}}async processExistingImage(n,t,l="scattered"){try{const r=await Wo.getImageForAI(n),c=r.type==="base64"?r.value:n,a=await ss.split(c,t),m=this.calculateLayoutParams(a),d=rs.calculate(a,l,m);return{success:!0,originalImageUrl:n,elements:d}}catch(r){return console.error("[GridImageService] Processing failed:",r),{success:!1,error:r.message||"宫格图处理失败"}}}async insertToBoard(n,t){if(!this.board)throw new Error("画板未初始化,请先调用 setBoard");let l=(t==null?void 0:t[0])??100,r=t==null?void 0:t[1];if(r===void 0){const a=gr(this.board);r=(a==null?void 0:a[1])??100,l=(a==null?void 0:a[0])??l}const c=[...n].sort((a,m)=>a.zIndex-m.zIndex);for(const a of c){const m=l+a.x,d=r+a.y,h={url:a.imageData,width:a.width*a.scale,height:a.height*a.scale};wr.insertImage(this.board,h,[m,d])}}async generateAndInsert(n,t){const l=await this.generate(n);return l.success&&l.elements&&await this.insertToBoard(l.elements,t),l}buildPrompt(n,t){const l=Zr.zh;return l(n,t.rows,t.cols)}calculateLayoutParams(n){const t=n.reduce((v,g)=>v+g.width,0),l=n.reduce((v,g)=>v+g.height,0),r=n.length,c=Math.ceil(Math.sqrt(r)),a=Math.ceil(r/c),m=t/r,d=l/r,h=30,p=50,S=c*m+(c+1)*h+p*2,I=a*d+(a+1)*h+p*2;return{canvasWidth:S,canvasHeight:I,startX:0,startY:0,gap:h}}}const as=new ka;function Sa(e){return{cleanText:e,selectedAudioModel:null,selectedImageModel:null,selectedVideoModel:null,selectedParams:[],selectedCount:null}}function Ma(){const e=Pn.get();return(e==null?void 0:e.imageModelName)||pt()}function Ca(){const e=Pn.get();return(e==null?void 0:e.videoModelName)||At()}function Ta(){const e=Pn.get();return(e==null?void 0:e.audioModelName)||Et()}function is(){const e=Pn.get();return(e==null?void 0:e.textModelName)||qn()}function Pa(e,n,t){if(n.length>0)return n.join(`
|
|
3
|
+
`);if(e){if(t===1)return"请仔细分析这张图片的内容、风格、构图、色调和艺术特点,推测生成这张图片可能使用的原始提示词,然后基于你推测的提示词重新生成一张全新的、风格相似但内容不完全相同的图片。不要直接复制原图。";if(t>1)return"请分析这些图片的主题、风格和视觉元素,找出它们之间的共同点或关联性,然后创造性地将它们融合成一张全新的、和谐统一的图片。融合时请保持各图片的精华元素,确保最终作品在构图、色调和风格上协调一致。"}return""}function Jt(e){return e.replace(":","x").toLowerCase()}function Aa(e,n,t){const l=n.texts.length>0||n.images.length>0||n.videos.length>0||n.graphics.length>0,r=n.texts,c=n.images.length+n.graphics.length,a=Sa(e),m=a.cleanText.trim().length>0;let d=(t==null?void 0:t.generationType)||"image",h,p=!1;if(t!=null&&t.modelId){const b=Ve(t.modelId);t.generationType||((b==null?void 0:b.type)==="video"?d="video":(b==null?void 0:b.type)==="audio"?d="audio":(b==null?void 0:b.type)==="text"?d="text":d="image"),h=t.modelId,p=!0}else a.selectedAudioModel?(d="audio",h=a.selectedAudioModel,p=!0):a.selectedVideoModel?(d="video",h=a.selectedVideoModel,p=!0):a.selectedImageModel?(d="image",h=a.selectedImageModel,p=!0):!l&&m&&!(t!=null&&t.generationType)?(d="agent",h=is()):d==="video"?h=Ca():d==="audio"?h=Ta():d==="text"||d==="agent"?h=is():h=Ma();let S;(t==null?void 0:t.generationType)==="image"||(t==null?void 0:t.generationType)==="video"||(t==null?void 0:t.generationType)==="audio"||(t==null?void 0:t.generationType)==="text"?S="direct_generation":(t==null?void 0:t.generationType)==="agent"?S="agent_flow":S=m?"agent_flow":"direct_generation";const I=a.cleanText.trim(),v=r.join(`
|
|
4
|
+
`).trim();let g;if(v&&I?g=`${v}
|
|
5
|
+
|
|
6
|
+
${I}`:I?g=I:v?g=v:l&&c>0?g=d==="text"?"":Pa(l,[],c):g="",h.startsWith("mj")&&(t!=null&&t.params)){const b=ua(t.params);b&&(g=[g,b].filter(Boolean).join(" "))}const R=(t==null?void 0:t.count)||a.selectedCount||1;let x,C,N;if(t!=null&&t.params){d!=="audio"&&d!=="text"&&d!=="agent"&&!h.startsWith("mj")&&t.params.size&&(x=Jt(t.params.size)),t.params.duration&&(C=t.params.duration);const b={};for(const[T,G]of Object.entries(t.params))T!=="size"&&T!=="duration"&&G&&(b[T]=G);Object.keys(b).length>0&&(N=b)}if(!x&&(t!=null&&t.size)&&t.size!=="auto"&&(x=Jt(t.size)),!x&&(t==null?void 0:t.size)!=="auto"){for(const b of a.selectedParams)if(b.id==="size"){x=Jt(b.value);break}}if(!C){for(const b of a.selectedParams)if(b.id==="duration"){C=b.value;break}}if(!x&&(t==null?void 0:t.size)!=="auto"&&d!=="text"&&d!=="agent"&&d!=="audio"){const b=Ve(h);if((b==null?void 0:b.type)==="image"&&b.imageDefaults)x="1x1";else if((b==null?void 0:b.type)==="video"&&b.videoDefaults){const T=Gn(h,(t==null?void 0:t.modelRef)||h,t==null?void 0:t.params);x=Jt(T.size||b.videoDefaults.size),C||(C=T.duration||b.videoDefaults.duration)}else if(d==="image")x="1x1";else if(d==="video"){const T=Gn(h,(t==null?void 0:t.modelRef)||h,t==null?void 0:t.params);x=Jt(T.size),C||(C=T.duration)}}!C&&d==="video"&&(C=Gn(h,(t==null?void 0:t.modelRef)||h,t==null?void 0:t.params).duration);const E=a.cleanText.trim();return{scenario:S,generationType:d,modelId:h,modelRef:(t==null?void 0:t.modelRef)||null,defaultModels:t==null?void 0:t.defaultModels,defaultModelRefs:t==null?void 0:t.defaultModelRefs,isModelExplicit:p,prompt:g,userInstruction:E,rawInput:e,count:R,size:x,duration:C,extraParams:N,parseResult:a,hasExtraContent:m,selection:n}}const Yn={id:et,name:"自动"},cs=Jn.map(e=>({id:e.id,name:e.name,isSystem:!0,mcpTool:e.mcpTool,outputType:e.outputType})),Ea=({value:e,onSelect:n,onSelectSkill:t,onAddSkill:l,disabled:r=!1})=>{const[c,a]=s.useState(!1),[m,d]=s.useState([]),[h,p]=s.useState([]),[S,I]=s.useState(""),[v,g]=s.useState(0),R=s.useRef(null),x=s.useRef(null),C=s.useCallback(async()=>{try{const P=(await Tn.getAllDirectories()).find(ie=>ie.name==="Skill");if(!P)return;const ae=await Tn.getNoteMetasByDirectory(P.id),U=new Set(Jn.map(ie=>ie.id)),B=ae.filter(ie=>!U.has(ie.id)).map(ie=>{var _e;return{id:ie.id,name:ie.title,outputType:((_e=ie.metadata)==null?void 0:_e.outputType)||void 0}});d(B)}catch{}},[]),N=s.useCallback(async()=>{try{const k=await eo.getAllExternalSkillsMeta(),P=new Set(Jn.map(U=>U.id)),ae=k.filter(U=>!P.has(U.id)).map(U=>({id:U.id,name:U.name,isExternal:!0,source:U.source,outputType:U.outputType}));p(ae)}catch{}},[]);s.useEffect(()=>{if(c){C(),N(),I("");const P=[Yn,...cs,...h,...m].findIndex(ae=>ae.id===e);g(P>=0?P:0),setTimeout(()=>{var ae;return(ae=x.current)==null?void 0:ae.focus()},50)}},[c,e]),s.useEffect(()=>{if(c&&R.current){const k=R.current.children[v];k&&k.scrollIntoView({block:"nearest"})}},[v,c]);const E=s.useCallback(k=>{k.preventDefault(),!r&&a(P=>!P)},[r]),b=s.useCallback(k=>{n(k.id),t==null||t(k),a(!1)},[n,t]),T=s.useCallback(k=>{k.stopPropagation(),a(!1),l()},[l]),G=[Yn,...cs,...h,...m],te=S.trim()?G.filter(k=>k.name.toLowerCase().includes(S.toLowerCase())||k.id.toLowerCase().includes(S.toLowerCase())):G,Z=G.length>15,re=s.useCallback(k=>k==="Escape"?(a(!1),!0):k==="ArrowDown"?(g(P=>P<te.length-1?P+1:0),!0):k==="ArrowUp"?(g(P=>P>0?P-1:te.length-1),!0):k==="Enter"||k===" "||k==="Tab"?(v<te.length&&b(te[v]),!0):!1,[v,te,b]),K=te.find(k=>k.id===e)||Yn;return u.jsx(ao,{isOpen:c,setIsOpen:a,disabled:r,openKeys:["Enter"," ","ArrowDown","ArrowUp"],onOpenKey:re,children:({containerRef:k,menuRef:P,portalPosition:ae,handleTriggerKeyDown:U})=>u.jsxs("div",{className:"skill-dropdown",ref:k,children:[u.jsxs("button",{className:`skill-dropdown__trigger ${c?"skill-dropdown__trigger--open":""}`,onMouseDown:E,onKeyDown:U,disabled:r,type:"button",title:`Skill: ${K.name}`,children:[u.jsx("span",{className:"skill-dropdown__icon-prefix",children:u.jsx(Lo,{size:14})}),u.jsx("span",{className:"skill-dropdown__label",children:K.name}),u.jsx(no,{size:14,className:`skill-dropdown__chevron ${c?"skill-dropdown__chevron--open":""}`})]}),c&&to.createPortal(u.jsxs("div",{ref:P,className:`skill-dropdown__menu ${An}`,style:{position:"fixed",zIndex:oo.DROPDOWN_PORTAL,left:ae.left,bottom:window.innerHeight-ae.top+8},onMouseDown:B=>B.stopPropagation(),onClick:B=>B.stopPropagation(),children:[u.jsxs("div",{className:"skill-dropdown__header",children:[u.jsx(Lo,{size:14}),u.jsx("span",{children:"Skill"})]}),Z&&u.jsx("div",{className:"skill-dropdown__search",children:u.jsx("input",{ref:x,type:"text",className:"skill-dropdown__search-input",placeholder:"搜索 Skill...",value:S,onChange:B=>{I(B.target.value),g(0)},onMouseDown:B=>B.stopPropagation(),onKeyDown:B=>B.stopPropagation()})}),u.jsx("div",{ref:R,className:"skill-dropdown__list",children:te.map((B,ie)=>{const _e=B.id===e,Ee=ie===v;return u.jsxs("div",{className:`skill-dropdown__item ${_e?"skill-dropdown__item--selected":""} ${Ee?"skill-dropdown__item--highlighted":""}`,onClick:()=>b(B),onMouseEnter:()=>g(ie),children:[u.jsx("span",{className:"skill-dropdown__item-label",children:B.name}),B.outputType==="image"&&u.jsx(xs,{size:12,className:"skill-dropdown__item-image-icon"}),B.outputType==="video"&&u.jsx(ys,{size:12,className:"skill-dropdown__item-image-icon"}),B.outputType==="ppt"&&u.jsx(xr,{size:12,className:"skill-dropdown__item-image-icon"}),B.outputType==="audio"&&u.jsx(yr,{size:12,className:"skill-dropdown__item-image-icon"}),B.isSystem&&u.jsx("span",{className:"skill-dropdown__item-badge",children:"系统"}),B.isExternal&&u.jsx("span",{className:"skill-dropdown__item-badge",children:"系统"}),_e&&u.jsx(so,{size:14,className:"skill-dropdown__item-check"})]},B.id)})}),u.jsx("div",{className:"skill-dropdown__divider"}),u.jsxs("div",{className:"skill-dropdown__add-btn",onClick:T,onMouseDown:B=>B.preventDefault(),children:[u.jsx(Ir,{size:14}),u.jsx("span",{children:"添加 Skill"})]})]}),document.body)]})})},ls=["image","video","audio"];function Da(e){if(e==="image"||e==="video"||e==="audio")return e}function ft(e){if(!e)return[];const n=Da(e.outputType);if(n)return[n];if(e.outputType==="text")return[];const t=new Set,l=qr(e.mcpTool);l&&t.add(l);const r=[e.id,e.name,e.description,e.content].filter(Boolean).join(`
|
|
7
|
+
`);if(r)for(const c of ls)Ra(c).some(m=>r.includes(m))&&t.add(c);return ls.filter(c=>t.has(c))}function Ra(e){switch(e){case"image":return["generate_image","generate_grid_image","generate_photo_wall","generate_inspiration_board"];case"video":return["generate_video","generate_long_video"];case"audio":return["generate_audio"]}}var Oe=(e=>(e.VIDEO="视频创作",e.IMAGE="图片生成",e.MINDMAP="思维导图",e.FLOWCHART="流程图",e.PPT="PPT大纲",e.GRID="宫格图",e.SVG="SVG矢量图",e))(Oe||{});const Qt=3,Na="data:image/svg+xml;utf8,"+encodeURIComponent(`
|
|
8
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 420">
|
|
9
|
+
<defs>
|
|
10
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
11
|
+
<stop offset="0" stop-color="#f8f4ff"/>
|
|
12
|
+
<stop offset="1" stop-color="#fff7ed"/>
|
|
13
|
+
</linearGradient>
|
|
14
|
+
<linearGradient id="accent" x1="0" y1="0" x2="1" y2="1">
|
|
15
|
+
<stop offset="0" stop-color="#a855f7"/>
|
|
16
|
+
<stop offset="1" stop-color="#f97316"/>
|
|
17
|
+
</linearGradient>
|
|
18
|
+
</defs>
|
|
19
|
+
<rect width="420" height="420" rx="34" fill="url(#bg)"/>
|
|
20
|
+
<rect x="38" y="46" width="344" height="316" rx="22" fill="#ffffff" opacity="0.95"/>
|
|
21
|
+
<g transform="translate(58 116)" stroke="#d8b4fe" stroke-width="3">
|
|
22
|
+
<rect width="86" height="72" rx="14" fill="#fff7ed"/>
|
|
23
|
+
<rect x="108" width="86" height="72" rx="14" fill="#f5f3ff"/>
|
|
24
|
+
<rect x="216" width="86" height="72" rx="14" fill="#fffbeb"/>
|
|
25
|
+
<rect y="92" width="86" height="72" rx="14" fill="#fef2f2"/>
|
|
26
|
+
<rect x="108" y="92" width="86" height="72" rx="14" fill="#eef2ff"/>
|
|
27
|
+
<rect x="216" y="92" width="86" height="72" rx="14" fill="#fff7ed"/>
|
|
28
|
+
<rect y="184" width="86" height="72" rx="14" fill="#f5f3ff"/>
|
|
29
|
+
<rect x="108" y="184" width="86" height="72" rx="14" fill="#fffbeb"/>
|
|
30
|
+
<rect x="216" y="184" width="86" height="72" rx="14" fill="#fef2f2"/>
|
|
31
|
+
</g>
|
|
32
|
+
<circle cx="101" cy="152" r="18" fill="#f97316"/>
|
|
33
|
+
<circle cx="209" cy="152" r="18" fill="#a855f7"/>
|
|
34
|
+
<circle cx="317" cy="152" r="18" fill="#f59e0b"/>
|
|
35
|
+
<circle cx="101" cy="244" r="18" fill="#ef4444"/>
|
|
36
|
+
<circle cx="209" cy="244" r="18" fill="#6366f1"/>
|
|
37
|
+
<circle cx="317" cy="244" r="18" fill="#fb923c"/>
|
|
38
|
+
<circle cx="101" cy="336" r="18" fill="#8b5cf6"/>
|
|
39
|
+
<circle cx="209" cy="336" r="18" fill="#eab308"/>
|
|
40
|
+
<circle cx="317" cy="336" r="18" fill="#f43f5e"/>
|
|
41
|
+
<path d="M356 78l8 10 12-20" fill="none" stroke="url(#accent)" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/>
|
|
42
|
+
</svg>`),ja="data:image/svg+xml;utf8,"+encodeURIComponent(`
|
|
43
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 420">
|
|
44
|
+
<defs>
|
|
45
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
46
|
+
<stop offset="0" stop-color="#eef5ff"/>
|
|
47
|
+
<stop offset="1" stop-color="#e7e2ff"/>
|
|
48
|
+
</linearGradient>
|
|
49
|
+
<linearGradient id="accent" x1="0" y1="0" x2="1" y2="1">
|
|
50
|
+
<stop offset="0" stop-color="#3b82f6"/>
|
|
51
|
+
<stop offset="1" stop-color="#8b5cf6"/>
|
|
52
|
+
</linearGradient>
|
|
53
|
+
</defs>
|
|
54
|
+
<rect width="420" height="420" rx="34" fill="url(#bg)"/>
|
|
55
|
+
<rect x="34" y="44" width="352" height="318" rx="22" fill="#ffffff" opacity="0.94"/>
|
|
56
|
+
<rect x="34" y="44" width="352" height="52" rx="22" fill="#e8edff"/>
|
|
57
|
+
<rect x="56" y="126" width="160" height="14" rx="7" fill="url(#accent)"/>
|
|
58
|
+
<rect x="56" y="164" width="274" height="12" rx="6" fill="#c7d2fe"/>
|
|
59
|
+
<rect x="56" y="192" width="220" height="12" rx="6" fill="#dbeafe"/>
|
|
60
|
+
<rect x="56" y="244" width="100" height="70" rx="12" fill="#eff6ff" stroke="#93c5fd"/>
|
|
61
|
+
<rect x="186" y="244" width="100" height="70" rx="12" fill="#f5f3ff" stroke="#a78bfa"/>
|
|
62
|
+
<rect x="316" y="244" width="52" height="70" rx="12" fill="#ecfeff" stroke="#67e8f9"/>
|
|
63
|
+
<circle cx="82" cy="279" r="14" fill="#3b82f6"/>
|
|
64
|
+
<circle cx="236" cy="279" r="14" fill="#8b5cf6"/>
|
|
65
|
+
<circle cx="342" cy="279" r="14" fill="#06b6d4"/>
|
|
66
|
+
<path d="M158 279h24M288 279h24" stroke="#94a3b8" stroke-width="8" stroke-linecap="round"/>
|
|
67
|
+
<rect x="56" y="334" width="312" height="10" rx="5" fill="#dbeafe"/>
|
|
68
|
+
</svg>`),za="data:image/svg+xml;utf8,"+encodeURIComponent(`
|
|
69
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 420">
|
|
70
|
+
<defs>
|
|
71
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
72
|
+
<stop offset="0" stop-color="#f0fdf4"/>
|
|
73
|
+
<stop offset="1" stop-color="#ecfeff"/>
|
|
74
|
+
</linearGradient>
|
|
75
|
+
<linearGradient id="lineA" x1="0" y1="0" x2="1" y2="1">
|
|
76
|
+
<stop offset="0" stop-color="#22c55e"/>
|
|
77
|
+
<stop offset="1" stop-color="#06b6d4"/>
|
|
78
|
+
</linearGradient>
|
|
79
|
+
</defs>
|
|
80
|
+
<rect width="420" height="420" rx="34" fill="url(#bg)"/>
|
|
81
|
+
<rect x="34" y="48" width="352" height="312" rx="22" fill="#ffffff" opacity="0.94"/>
|
|
82
|
+
<g fill="none" stroke="url(#lineA)" stroke-width="3" stroke-linecap="round">
|
|
83
|
+
<path d="M210 210C170 190 150 156 126 128"/>
|
|
84
|
+
<path d="M210 210C170 220 144 252 116 286"/>
|
|
85
|
+
<path d="M210 210C250 184 278 150 312 128"/>
|
|
86
|
+
<path d="M210 210C252 224 280 254 322 292"/>
|
|
87
|
+
<path d="M126 128C108 116 94 110 78 104"/>
|
|
88
|
+
<path d="M312 128C332 116 346 110 362 104"/>
|
|
89
|
+
<path d="M116 286C98 300 82 310 66 324"/>
|
|
90
|
+
<path d="M322 292C342 302 356 312 372 326"/>
|
|
91
|
+
</g>
|
|
92
|
+
<rect x="168" y="178" width="84" height="64" rx="18" fill="#ecfdf5" stroke="#22c55e" stroke-width="3"/>
|
|
93
|
+
<circle cx="210" cy="210" r="16" fill="#22c55e"/>
|
|
94
|
+
<rect x="76" y="98" width="98" height="36" rx="13" fill="#f0fdf4" stroke="#86efac"/>
|
|
95
|
+
<rect x="72" y="270" width="102" height="36" rx="13" fill="#eff6ff" stroke="#93c5fd"/>
|
|
96
|
+
<rect x="262" y="98" width="102" height="36" rx="13" fill="#ecfeff" stroke="#67e8f9"/>
|
|
97
|
+
<rect x="266" y="276" width="108" height="36" rx="13" fill="#f0fdfa" stroke="#5eead4"/>
|
|
98
|
+
<circle cx="96" cy="116" r="7" fill="#22c55e"/>
|
|
99
|
+
<circle cx="96" cy="288" r="7" fill="#3b82f6"/>
|
|
100
|
+
<circle cx="286" cy="116" r="7" fill="#06b6d4"/>
|
|
101
|
+
<circle cx="290" cy="294" r="7" fill="#14b8a6"/>
|
|
102
|
+
<rect x="116" y="112" width="42" height="7" rx="3.5" fill="#bbf7d0"/>
|
|
103
|
+
<rect x="116" y="284" width="44" height="7" rx="3.5" fill="#bfdbfe"/>
|
|
104
|
+
<rect x="306" y="112" width="42" height="7" rx="3.5" fill="#a5f3fc"/>
|
|
105
|
+
<rect x="310" y="290" width="46" height="7" rx="3.5" fill="#99f6e4"/>
|
|
106
|
+
</svg>`),ds=[{id:"grid-emoji",title:"智能拆分宫格图",description:"宫格图,风格统一",prompt:"生成16宫格猫咪表情包",category:Oe.GRID,imageUrl:Na,badgeColor:"badge--grid",skillId:"generate_grid_image"},{id:"ppt-outline",title:"生成PPT大纲",description:"用参考图片规划配图与页面提示词",prompt:"生成一份关于「AI 创作工作流」的 PPT 大纲;如果已上传参考图片,请将参考图片作为配图和视觉风格参考。",category:Oe.PPT,imageUrl:ja,badgeColor:"badge--ppt",skillId:"generate_ppt"},{id:"mindmap-project",title:"项目规划脑图",description:"快速生成结构化的思维导图,梳理项目计划",prompt:"创建一个关于「移动应用开发」的思维导图,包含需求分析、UI设计、前端开发、后端开发、测试上线等主要分支",category:Oe.MINDMAP,imageUrl:za,badgeColor:"badge--mindmap",skillId:"generate_mindmap"}],Oa={[Oe.VIDEO]:{bg:"#fce7f3",text:"#be185d"},[Oe.IMAGE]:{bg:"#dbeafe",text:"#1d4ed8"},[Oe.MINDMAP]:{bg:"#dcfce7",text:"#15803d"},[Oe.FLOWCHART]:{bg:"#fef3c7",text:"#b45309"},[Oe.PPT]:{bg:"#dbeafe",text:"#1d4ed8"},[Oe.GRID]:{bg:"#f3e8ff",text:"#7c3aed"},[Oe.SVG]:{bg:"#e0e7ff",text:"#4338ca"}},Wa=({template:e,onClick:n})=>{const t=Oa[e.category],l=r=>{r.preventDefault()};return u.jsxs("div",{className:"inspiration-card",onMouseDown:l,onClick:n,"data-track":`inspiration_click_${e.id}`,children:[u.jsxs("div",{className:"inspiration-card__image-wrapper",children:[u.jsx("img",{src:e.imageUrl,alt:e.title,className:"inspiration-card__image",loading:"lazy"}),u.jsx("span",{className:"inspiration-card__badge",style:{backgroundColor:t.bg,color:t.text},children:e.category}),u.jsx("div",{className:"inspiration-card__hover-overlay",children:u.jsx("div",{className:"inspiration-card__arrow",children:u.jsx(br,{size:16})})})]}),u.jsxs("div",{className:"inspiration-card__content",children:[u.jsx("h3",{className:"inspiration-card__title",children:e.title}),u.jsx("p",{className:"inspiration-card__description",children:e.description})]})]})},us="aitu_hide_inspiration_board",La=({isCanvasEmpty:e,onSelectPrompt:n,onOpenPromptTool:t,visible:l=!0,className:r=""})=>{const[c,a]=s.useState(0),[m,d]=s.useState(!1);s.useEffect(()=>{localStorage.getItem(us)==="true"&&d(!0)},[]);const h=Math.ceil(ds.length/Qt),p=h>1,S=ds.slice(c*Qt,(c+1)*Qt),I=s.useCallback(x=>{x.preventDefault(),x.stopPropagation(),a(C=>(C-1+h)%h)},[h]),v=s.useCallback(x=>{x.preventDefault(),x.stopPropagation(),a(C=>(C+1)%h)},[h]),g=s.useCallback(x=>{n({prompt:x.prompt,modelType:"agent",skillId:x.skillId})},[n]),R=s.useCallback(x=>{x.preventDefault(),x.stopPropagation(),d(!0),localStorage.setItem(us,"true")},[]);return!e||!l||m?null:u.jsxs("div",{className:`inspiration-board ${r}`,children:[u.jsxs("div",{className:"inspiration-board__header",children:[u.jsx("h3",{className:"inspiration-board__title",children:"灵感创意"}),u.jsxs("button",{className:"inspiration-board__hide-btn",onClick:R,onMouseDown:x=>x.preventDefault(),title:"不再提示","data-track":"inspiration_click_hide",children:[u.jsx(_r,{size:14}),u.jsx("span",{children:"不再提示"})]}),t&&u.jsxs("button",{className:"inspiration-board__prompt-btn",onClick:t,onMouseDown:x=>x.preventDefault(),title:"提示词工具","data-track":"inspiration_click_prompt_tool",children:[u.jsx(vr,{size:14}),u.jsx("span",{children:"提示词"})]}),p&&u.jsxs("div",{className:"inspiration-board__pagination",children:[u.jsxs("span",{className:"inspiration-board__page-indicator",children:[c+1," / ",h]}),u.jsxs("div",{className:"inspiration-board__nav-buttons",children:[u.jsx("button",{className:"inspiration-board__nav-btn",onMouseDown:x=>x.preventDefault(),onClick:I,"aria-label":"上一页","data-track":"inspiration_click_prev",children:u.jsx(kr,{size:16})}),u.jsx("button",{className:"inspiration-board__nav-btn",onMouseDown:x=>x.preventDefault(),onClick:v,"aria-label":"下一页","data-track":"inspiration_click_next",children:u.jsx(Sr,{size:16})})]})]})]}),u.jsxs("div",{className:"inspiration-board__grid",children:[S.map(x=>u.jsx(Wa,{template:x,onClick:()=>g(x)},x.id)),S.length<Qt&&Array.from({length:Qt-S.length}).map((x,C)=>u.jsx("div",{className:"inspiration-card inspiration-card--placeholder"},`placeholder-${C}`))]})]})},ht=[{value:"image",label:"图片",icon:u.jsx(xs,{size:14}),zh:"图片",en:"Image"},{value:"video",label:"视频",icon:u.jsx(ys,{size:14}),zh:"视频",en:"Video"},{value:"audio",label:"音频",icon:u.jsx(Cr,{size:14}),zh:"音频",en:"Audio"},{value:"text",label:"文本",icon:u.jsx(Tr,{size:14}),zh:"文本",en:"Text"},{value:"agent",label:"Agent",icon:u.jsx(Pr,{size:14}),zh:"Agent",en:"Agent"}],Ba=({value:e,onSelect:n,disabled:t=!1})=>{const[l,r]=s.useState(!1),{language:c}=ro(),[a,m]=s.useState(0),d=s.useRef(null);s.useEffect(()=>{if(l){const v=ht.findIndex(g=>g.value===e);m(v>=0?v:0)}},[l,e]),s.useEffect(()=>{if(l&&d.current){const v=d.current.children[a];v&&v.scrollIntoView({block:"nearest"})}},[a,l]);const h=s.useCallback(v=>{v.preventDefault(),!t&&r(g=>!g)},[t]),p=s.useCallback(v=>{n(v),r(!1)},[n]),S=s.useCallback(v=>v==="Escape"?(r(!1),!0):v==="ArrowDown"?(m(g=>g<ht.length-1?g+1:0),!0):v==="ArrowUp"?(m(g=>g>0?g-1:ht.length-1),!0):v==="Enter"||v===" "||v==="Tab"?(p(ht[a].value),!0):!1,[a,p]),I=ht.find(v=>v.value===e)||ht[0];return u.jsx(ao,{isOpen:l,setIsOpen:r,disabled:t,openKeys:["Enter"," ","ArrowDown","ArrowUp"],onOpenKey:S,children:({containerRef:v,menuRef:g,portalPosition:R,handleTriggerKeyDown:x})=>u.jsxs("div",{className:"generation-type-dropdown",ref:v,children:[u.jsxs("button",{className:`generation-type-dropdown__trigger ${l?"generation-type-dropdown__trigger--open":""}`,onMouseDown:h,onKeyDown:x,disabled:t,type:"button",title:`${c==="zh"?"生成类型":"Type"}: ${c==="zh"?I.zh:I.en} (↑↓ Tab)`,children:[u.jsx("span",{className:"generation-type-dropdown__icon-prefix",children:I.icon}),u.jsx("span",{className:"generation-type-dropdown__label",children:c==="zh"?I.zh:I.en}),u.jsx(no,{size:14,className:`generation-type-dropdown__chevron ${l?"generation-type-dropdown__chevron--open":""}`})]}),l&&to.createPortal(u.jsxs("div",{ref:g,className:`generation-type-dropdown__menu ${An}`,style:{position:"fixed",zIndex:oo.DROPDOWN_PORTAL,left:R.left,bottom:window.innerHeight-R.top+8},onMouseDown:C=>C.stopPropagation(),onClick:C=>C.stopPropagation(),children:[u.jsxs("div",{className:"generation-type-dropdown__header",children:[u.jsx(Mr,{size:14}),u.jsx("span",{children:c==="zh"?"生成类型 (↑↓ Tab)":"Generation type (↑↓ Tab)"})]}),u.jsx("div",{ref:d,className:"generation-type-dropdown__list",children:ht.map((C,N)=>{const E=C.value===e,b=N===a;return u.jsxs("div",{className:`generation-type-dropdown__item ${E?"generation-type-dropdown__item--selected":""} ${b?"generation-type-dropdown__item--highlighted":""}`,onClick:()=>p(C.value),onMouseEnter:()=>m(N),children:[u.jsx("span",{className:"generation-type-dropdown__item-icon",children:C.icon}),u.jsx("span",{className:"generation-type-dropdown__item-label",children:c==="zh"?C.zh:C.en}),E&&u.jsx(so,{size:14,className:"generation-type-dropdown__item-check"})]},C.value)})})]}),document.body)]})})},en=[1,2,3,4,5,10,20],Fa=({value:e,onSelect:n,disabled:t=!1,isOpen:l,onOpenChange:r})=>{const{value:c,setValue:a}=Jr({controlledValue:l,defaultValue:!1,onChange:r}),{language:m}=ro(),[d,h]=s.useState(0),p=s.useRef(null);s.useEffect(()=>{if(c){const g=en.indexOf(e);h(g>=0?g:0)}},[c,e]),s.useEffect(()=>{if(c&&p.current){const g=p.current.children[d];g&&g.scrollIntoView({block:"nearest"})}},[d,c]);const S=s.useCallback(g=>{g.preventDefault(),!t&&a(!c)},[t,c,a]),I=s.useCallback(g=>{n(g),a(!1)},[n]),v=s.useCallback(g=>g==="Escape"?(a(!1),!0):g==="ArrowDown"?(h(R=>R<en.length-1?R+1:0),!0):g==="ArrowUp"?(h(R=>R>0?R-1:en.length-1),!0):g==="Enter"||g===" "||g==="Tab"?(I(en[d]),!0):!1,[d,I]);return u.jsx(ao,{isOpen:c,setIsOpen:a,disabled:t,openKeys:["Enter"," ","ArrowDown","ArrowUp"],onOpenKey:v,children:({containerRef:g,menuRef:R,portalPosition:x,handleTriggerKeyDown:C})=>u.jsxs("div",{className:"count-dropdown",ref:g,children:[u.jsxs("button",{className:`count-dropdown__trigger ${c?"count-dropdown__trigger--open":""}`,onMouseDown:S,onKeyDown:C,disabled:t,type:"button",title:`${m==="zh"?"生成数量":"Count"}: ${e} (↑↓ Tab)`,children:[u.jsxs("span",{className:"count-dropdown__label",children:[e,m==="zh"?"个":""]}),u.jsx(no,{size:14,className:`count-dropdown__chevron ${c?"count-dropdown__chevron--open":""}`})]}),c&&to.createPortal(u.jsxs("div",{ref:R,className:`count-dropdown__menu ${An}`,style:{position:"fixed",zIndex:oo.DROPDOWN_PORTAL,left:x.left,bottom:window.innerHeight-x.top+8},onMouseDown:N=>N.stopPropagation(),onClick:N=>N.stopPropagation(),children:[u.jsx("div",{className:"count-dropdown__header",children:u.jsx("span",{children:m==="zh"?"生成数量 (↑↓ Tab)":"Count (↑↓ Tab)"})}),u.jsx("div",{ref:p,className:"count-dropdown__list",children:en.map((N,E)=>{const b=N===e,T=E===d;return u.jsxs("div",{className:`count-dropdown__item ${b?"count-dropdown__item--selected":""} ${T?"count-dropdown__item--highlighted":""}`,onClick:()=>I(N),onMouseEnter:()=>h(E),children:[u.jsxs("span",{className:"count-dropdown__item-label",children:[N,m==="zh"?"个":N>1?" items":" item"]}),b&&u.jsx(so,{size:14,className:"count-dropdown__item-check"})]},N)})})]}),document.body)]})})},vs=["right","bottom","left","top"],Sn=4;function Ha(e,n,t,l,r=32){const c=l<=2?l:l<=4?2:3,a=Math.floor(t/c),m=t%c;return[e[0]+m*(n.width+r),e[1]+a*(n.height+r)]}function ks(e,n){const{ignoreElementIds:t=[],ignoreTypes:l=["workzone"],extraOccupiedRects:r=[]}=n;return[...e.children.filter(Ga).filter(c=>!l.includes(c.type??"")&&!t.includes(c.id??"")).map(c=>({...Cn.getRectangleByPoints(c.points),id:c.id,type:c.type})),...r]}function Ga(e){return typeof e=="object"&&e!==null&&Array.isArray(e.points)&&e.points.length===2}function Ss(e,n,t){return e.x<n.x+n.width+t&&e.x+e.width+t>n.x&&e.y<n.y+n.height+t&&e.y+e.height+t>n.y}function $a(e,n,t,l){const r=[e];for(let c=1;c<=l;c+=1)r.push([e[0]+n*c,e[1]],[e[0],e[1]+t*c],[e[0]+n*c,e[1]+t*c],[e[0]-n*c,e[1]],[e[0]-n*c,e[1]+t*c],[e[0],e[1]-t*c],[e[0]+n*c,e[1]-t*c],[e[0]-n*c,e[1]-t*c]);return r}function Ua(e,n,t,l,r){const c=Math.max(r,32),a=Math.max(Math.round(Math.min(n.width,n.height)*.16),28),m=Math.max(Math.round(Math.min(n.width,n.height)*.12),18),d=n.width+a,h=n.height+a,p=[];for(let S=0;S<t;S+=1){const I=Math.floor(S/Sn),v=S%Sn,g=Math.min(Sn,t-I*Sn),R=v-(g-1)/2,x=e.x+e.width/2-n.width/2,C=e.y+e.height/2-n.height/2,N=Math.abs(R)*m;let E=x,b=C;switch(l){case"right":E=e.x+e.width+c+I*d+N,b=C+R*(n.height+a);break;case"left":E=e.x-c-n.width-I*d-N,b=C+R*(n.height+a);break;case"top":E=x+R*(n.width+a),b=e.y-c-n.height-I*h-N;break;case"bottom":default:E=x+R*(n.width+a),b=e.y+e.height+c+I*h+N;break}p.push([Math.round(E),Math.round(b)])}return p}function fs(e,n,t,l,r){return e.reduce((a,m)=>{const d={x:m[0],y:m[1],width:n.width,height:n.height};return a+t.filter(h=>Ss(d,h,l)).length},0)*1e3+vs.indexOf(r)*10}function Va(e,n,t,l,r){var h;const{gap:c=40,padding:a=16}=r,m=ks(e,r),d=vs.map(p=>({side:p,positions:Ua(n,t,l,p,c)}));return d.sort((p,S)=>fs(p.positions,t,m,a,p.side)-fs(S.positions,t,m,a,S.side)),((h=d[0])==null?void 0:h.positions)??[]}function Ka(e,n,t,l,r={}){const{frameRect:c,extraOccupiedRects:a=[],...m}=r,d={...m,extraOccupiedRects:a},h=c?Va(e,c,t,l,d):Array.from({length:l},(S,I)=>Ha(n,t,I,l,d.gap)),p=[...a];return h.map(S=>{const I=Ya(e,S,t,{...d,extraOccupiedRects:p});return p.push({x:I[0],y:I[1],width:t.width,height:t.height}),I})}function Ya(e,n,t,l={}){const{gap:r=40,padding:c=16,maxSearchRadius:a=6}=l,m=ks(e,l),d=t.width+r,h=t.height+r,p=$a(n,d,h,a);for(const S of p){const I={x:S[0],y:S[1],width:t.width,height:t.height};if(!m.some(g=>Ss(I,g,c)))return S}return[n[0],n[1]+h*(a+1)]}function gt(e){return typeof e=="string"&&e.trim()?e.trim():null}function Xa(e){return e==="image"||e==="video"||e==="audio"||e==="text"||e==="agent"}function Za(e){if(!e||typeof e!="object")return!1;const n=e;return typeof n.modelId=="string"&&n.modelId.trim().length>0&&(n.profileId===null||typeof n.profileId=="string")&&(n.providerIdHint===null||typeof n.providerIdHint=="string")&&(n.vendorHint===null||typeof n.vendorHint=="string")&&typeof n.updatedAt=="number"&&Number.isFinite(n.updatedAt)}function io(){try{const e=window.localStorage.getItem(Qn);if(!e)return{};const n=JSON.parse(e);if(!n||typeof n!="object")return{};const t={};return Object.entries(n).forEach(([l,r])=>{Xa(l)&&Za(r)&&(t[l]={modelId:r.modelId.trim(),profileId:gt(r.profileId),providerIdHint:gt(r.providerIdHint),vendorHint:gt(r.vendorHint),updatedAt:r.updatedAt})}),t}catch{return{}}}function Ms(e){try{if(!Object.values(e).some(Boolean)){window.localStorage.removeItem(Qn);return}window.localStorage.setItem(Qn,JSON.stringify(e))}catch{}}function qa(e){const n=io();return n[e]?n[e]||null:e==="agent"&&n.text||null}function hs(e,n){var r;const t=gt(n.modelId);if(!t){Cs(e);return}const l=io();l[e]={modelId:t,profileId:gt((r=n.modelRef)==null?void 0:r.profileId),providerIdHint:gt(n.providerIdHint),vendorHint:gt(n.vendorHint),updatedAt:Date.now()},Ms(l)}function Cs(e){const n=io();n[e]&&(delete n[e],Ms(n))}function Qe(e,n,t,l){var c;const r=e.metadata||{};return{id:e.id,name:e.name,generationType:e.generationType,prompt:r.prompt||((c=n==null?void 0:n.aiContext)==null?void 0:c.finalPrompt)||"",aiAnalysis:e.aiAnalysis,count:r.count,createdAt:e.createdAt,status:e.status,steps:e.steps.map(a=>({id:a.id,description:a.description,status:a.status,mcp:a.mcp,args:a.args,result:a.result,error:a.error,duration:a.duration,options:a.options})),retryContext:n,postProcessingStatus:t,insertedCount:l}}function Ja(e,n){return e==="generate_image"?"image":e==="generate_video"||e==="generate_long_video"?"video":e==="generate_audio"?"audio":e==="generate_text"?"text":n.scenarioType==="skill_flow"||n.generationType==="agent"?"agent":n.generationType==="image"||n.generationType==="video"||n.generationType==="audio"||n.generationType==="text"?n.generationType:"agent"}function Qa(e,n){const t=typeof n.args.prompt=="string"?n.args.prompt.trim():e.metadata.prompt.trim(),l=(e.metadata.rawInput||e.metadata.userInstruction||e.metadata.prompt||t).trim().slice(0,2e3),r=e.scenarioType==="skill_flow"?e.name.trim():void 0,c=Ja(n.mcp,e);return{initialPrompt:l,sentPrompt:t.slice(0,2e3),category:c,skillId:e.skillId,skillName:r,tags:[c,r].filter(Boolean)}}function Mn(e,n){return n.args.promptMeta||!["generate_image","generate_video","generate_long_video","generate_audio","generate_text"].includes(n.mcp)?n:{...n,args:{...n.args,promptMeta:Qa(e,n)}}}let ps=!1;ps||(na(),Ia(),eo.initialize().catch(e=>{console.warn("[AIInputBar] 外部 Skill 服务初始化失败(非致命):",e)}),ps=!0);function Ts(e){return e.selectionKey||(e.sourceProfileId?`${e.sourceProfileId}::${e.id}`:e.id)}function ze(e,n){return n!=null&&n.profileId?`${n.profileId}::${e}`:e}function We(e){return e?mt(e.sourceProfileId||null,e.id):null}function Xn(e){return e<=0?"0":e<=20?"1-20":e<=100?"21-100":e<=300?"101-300":e<=800?"301-800":"800+"}const ei=1,Ps=4,ti=6,ni=1.5;function ms(e,n){const t=window.getComputedStyle(e),l=Number.parseFloat(t.fontSize)||15,r=Number.parseFloat(t.lineHeight)||l*ni,c=Number.parseFloat(t.paddingTop)+Number.parseFloat(t.paddingBottom),a=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth);return Math.ceil(r*n+c+a)}function oi(e,n){if(!e)return;if(!n){e.style.height="",e.style.overflowY="";return}const t=ms(e,Ps),l=ms(e,ti);e.style.height="auto";const r=e.scrollHeight,c=Math.min(Math.max(r,t),l);e.style.height=`${c}px`,e.style.overflowY=r>l?"auto":"hidden"}function Ie(e,n,t){if(!n)return;const l=ze(n,t),r=(t==null?void 0:t.profileId)||null;return e.find(c=>Ts(c)===l)||e.find(c=>c.id===n&&(c.sourceProfileId||null)===r)||(r===null?e.find(c=>c.id===n&&!c.sourceProfileId):void 0)||e.find(c=>c.id===n)}function si(e,n){return e==="agent"&&n==="text"?"agent":n}function ri(e){if(!e)return!1;const n=e.toLowerCase();return n.includes("#video")?!0:[".mp4",".webm",".mov",".avi",".mkv",".m4v",".flv",".wmv"].some(l=>n.includes(l))}const As=Is.memo(({language:e,onSelectionChange:n,externalBoardRef:t,onCanvasEmptyChange:l,isDataReady:r,onFrameSelected:c})=>{const a=$r(),m=s.useRef(a);m.current=a,s.useEffect(()=>(Zo(a),qo(a),Jo(a),ts(a),as.setBoard(a),t&&(t.current=a),()=>{Zo(null),qo(null),Jo(null),ts(null),as.setBoard(null),t&&(t.current=null)}),[a,t]);const d=s.useRef(l);d.current=l,s.useEffect(()=>{if(!a||!d.current||!r)return;const I=setInterval(()=>{var g;const v=a.children||[];(g=d.current)==null||g.call(d,v.length===0)},500);return()=>{clearInterval(I)}},[a,r]);const h=s.useRef(n);h.current=n;const p=s.useRef(c);return p.current=c,s.useEffect(()=>{const S=async()=>{var R,x,C,N;const v=m.current;if(!v)return;const g=bs(v);if(g.length===1&&_s(g[0])){const E=g[0],b=Cn.getRectangleByPoints(E.points);(R=p.current)==null||R.call(p,{id:E.id,width:b.width,height:b.height})}else(x=p.current)==null||x.call(p,null);if(g.length===0){h.current([]);return}try{const E=await Ur(v),b=[];E.graphicsImage&&b.push({url:E.graphicsImage,name:e==="zh"?"图形元素":"Graphics",type:"graphics",width:(C=E.graphicsImageDimensions)==null?void 0:C.width,height:(N=E.graphicsImageDimensions)==null?void 0:N.height});for(const T of E.remainingImages){const G=T.url||"",te=ri(G);b.push({url:G,name:T.name||(te?`video-${Date.now()}`:`image-${Date.now()}`),type:te?"video":"image",width:T.width,height:T.height})}E.remainingText&&E.remainingText.trim()&&b.push({type:"text",text:E.remainingText.trim(),name:e==="zh"?"文字内容":"Text Content"}),h.current(b)}catch(E){console.error("Failed to process selected content:",E),h.current([])}};S();const I=()=>{setTimeout(S,50)};return document.addEventListener("mouseup",I),()=>{document.removeEventListener("mouseup",I)}},[e]),null});As.displayName="SelectionWatcher";const Es=Is.memo(({className:e,isDataReady:n,onEnableToolWindows:t,onEnableRuntime:l})=>{const{language:r}=ro(),c=_n("image"),a=_n("video"),m=_n("audio"),d=_n("text"),h=Ar(),p=Vr(),{addHistory:S}=gs(),{addAsset:I}=Er(),v=s.useRef(h.sendWorkflowMessage);v.current=h.sendWorkflowMessage;const g=s.useRef(h.updateWorkflowMessage);g.current=h.updateWorkflowMessage;const R=s.useRef(h.appendAgentLog);R.current=h.appendAgentLog;const x=s.useRef(h.updateThinkingContent);x.current=h.updateThinkingContent;const C=s.useRef(h.setSelectedContent);C.current=h.setSelectedContent;const N=s.useRef(h.registerRetryHandler);N.current=h.registerRetryHandler;const E=s.useRef(null),b=s.useRef([]),T=s.useRef(null),G=fa(),te=s.useCallback((o,i,f)=>{if(!o)return;const w=b.current,_=(f!=null&&f.workflowId&&(f!=null&&f.batchId)&&typeof f.batchIndex=="number"?dt.getAnchorByBatchSlot(o,{workflowId:f.workflowId,batchId:f.batchId,batchIndex:f.batchIndex}):null)||(f!=null&&f.workflowId?dt.getAnchorByWorkflowId(o,f.workflowId):null)||(w[0]?dt.getAnchorById(o,w[0]):null);if(!_)return;const A=_.taskIds.includes(i)?_.taskIds:[..._.taskIds,i];dt.updateAnchor(o,_.id,{taskIds:A,primaryTaskId:_.primaryTaskId||i})},[]),Z=s.useCallback((o,i,f)=>{const w=b.current;w.length===0||!o||w.forEach(_=>{dt.updateAnchor(o,_,$n(i,f))})},[]),re=s.useCallback(o=>{const i=b.current;i.length===0||!o||(i.forEach(f=>{dt.removeAnchor(o,f)}),b.current=[])},[]),K=s.useCallback((o,i)=>{const f=qa(o);if(!f)return;const w=Ie(i,f.modelId,mt(f.profileId,f.modelId));if(w)return w;Cs(o)},[]),k=s.useCallback((o,i)=>{const f=K(o,i);if(f)return f;const _=Ct(o==="video"?"video":o==="audio"?"audio":o==="text"||o==="agent"?"text":"image"),A=Ie(i,_.modelId,mt(_.profileId,_.modelId));if(A)return A;const F=o==="video"?At():o==="audio"?Et():o==="text"||o==="agent"?qn():pt();return Ie(i,F,null)||i[0]},[K]),P=G.generationType,U=k(P,P==="video"?a:P==="audio"?m:P==="text"||P==="agent"?d:c)||Ve(G.selectedModel)||Ve(P==="video"?At():P==="audio"?Et():P==="text"||P==="agent"?qn():pt()),B=k("image",c)||Ve(pt()),ie=k("video",a)||Ve(At()),_e=k("audio",m)||Ve(Et()),Ee=Ct("image"),tt=(B==null?void 0:B.id)||Ee.modelId||pt(),nn=We(B)||mt(Ee.profileId,Ee.modelId),co=ze((U==null?void 0:U.id)||tt,We(U)||nn),lo=P==="agent"?{}:Kn(P,(U==null?void 0:U.id)||tt,co,G.selectedParams),[me,nt]=s.useState(""),[Ds,Rs]=s.useState(!1),[En,Dn]=s.useState([]),[Rt,wt]=s.useState([]),[Le,ot]=s.useState(!1),we=s.useRef(null),[Nt,st]=s.useState(!1),[Ns,js]=s.useState(null),[y,Be]=s.useState(P),[xe,on]=s.useState(G.selectedSkillId||et),[O,uo]=s.useState((U==null?void 0:U.id)||tt),[L,fo]=s.useState(We(U)||nn),[Fe,ho]=s.useState((B==null?void 0:B.id)||pt()),[Ke,po]=s.useState(We(B)),[He,mo]=s.useState((ie==null?void 0:ie.id)||At()),[Ye,go]=s.useState(We(ie)),[Ge,wo]=s.useState((_e==null?void 0:_e.id)||Et()),[Xe,xo]=s.useState(We(_e)),[Rn,$e]=s.useState([]),sn=s.useMemo(()=>{if(y!=="image"||Ie(c,O,L))return c;const i=ut("image",O,L);return i?[i,...c]:c},[y,c,O,L]),rn=s.useMemo(()=>{if(y!=="video"||Ie(a,O,L))return a;const i=ut("video",O,L);return i?[i,...a]:a},[y,O,L,a]),an=s.useMemo(()=>{if(y!=="audio"||Ie(m,O,L))return m;const i=ut("audio",O,L);return i?[i,...m]:m},[m,y,O,L]),cn=s.useMemo(()=>{if(y!=="text"&&y!=="agent"||Ie(d,O,L))return d;const i=ut("text",O,L);return i?[i,...d]:d},[y,O,L,d]),jt=s.useMemo(()=>{if(Ie(c,Fe,Ke))return c;const i=ut("image",Fe,Ke);return i?[i,...c]:c},[c,Fe,Ke]),zt=s.useMemo(()=>{if(Ie(a,He,Ye))return a;const i=ut("video",He,Ye);return i?[i,...a]:a},[He,Ye,a]),Ot=s.useMemo(()=>{if(Ie(m,Ge,Xe))return m;const i=ut("audio",Ge,Xe);return i?[i,...m]:m},[m,Ge,Xe]),[Me,ln]=s.useState(()=>{if(P==="agent")return{};const o=(U==null?void 0:U.id)||tt,i=Bo(o).find(f=>f.id==="size");return{...lo,...o.startsWith("mj")||!i?{}:{size:lo.size||Fo(o)}}}),Wt=s.useRef(Me),yo=s.useRef(P==="agent"?"agent":`${P}:${co}`);s.useEffect(()=>{Wt.current=Me},[Me]);const[Lt,Io]=s.useState(G.selectedCount),[bo,Nn]=s.useState(!1),[_o,jn]=s.useState(!1),[vo,zn]=s.useState(!1),rt=s.useRef(null),zs=s.useCallback(o=>{Nn(o),o||(rt.current=null)},[]),Os=s.useCallback(o=>{jn(o),o||(rt.current=null)},[]),Ws=s.useCallback(o=>{zn(o),o||(rt.current=null)},[]),[ko,Bt]=s.useState(!1),ce=s.useMemo(()=>[...Rt,...En],[Rt,En]),at=s.useMemo(()=>({invalidFile:r==="zh"?"请上传图片文件":"Please upload image files",fileTooLarge:r==="zh"?"图片大小不能超过 25MB":"Image size cannot exceed 25MB",loadFailed:r==="zh"?"加载图片失败":"Failed to load image",compressionFailed:r==="zh"?"图片压缩失败":"Image compression failed",compressing:o=>r==="zh"?`正在压缩图片 (${o.toFixed(1)}MB)...`:`Compressing image (${o.toFixed(1)}MB)...`,compressed:(o,i)=>r==="zh"?`压缩完成: ${o.toFixed(1)}MB → ${i.toFixed(1)}MB`:`Compressed: ${o.toFixed(1)}MB → ${i.toFixed(1)}MB`}),[r]);s.useEffect(()=>{const o=y==="video"?rn:y==="audio"?an:y==="text"||y==="agent"?cn:sn,f=Ie(o,O,L)||k(y,o);if(f){const w=ze(O,L),_=Ts(f);w!==_&&(uo(f.id),fo(We(f)))}y!=="agent"&&on(et),(y==="agent"||y==="text"||y==="audio")&&Io(1)},[an,y,sn,k,O,L,cn,rn]),s.useEffect(()=>{const o=(i,f,w,_,A,F)=>{if(Ie(f,w,_))return;const z=k(i,f);z&&(A(z.id),F(We(z)))};o("image",jt,Fe,Ke,ho,po),o("video",zt,He,Ye,mo,go),o("audio",Ot,Ge,Xe,wo,xo)},[k,Ge,Xe,Fe,Ke,He,Ye,Ot,jt,zt]);const dn=s.useMemo(()=>y==="video"?rn:y==="audio"?an:y==="text"||y==="agent"?cn:sn,[an,y,sn,cn,rn]);s.useEffect(()=>{let o=!1;return(async()=>{var F;if(y!=="agent"||xe===et){$e([]);return}const f=wn(xe);if(f){$e(ft(f));return}const w=Go(xe);if(w){$e(ft(w));return}const _=await eo.getSkillById(xe);if(o)return;if(_){$e(ft(_));return}const A=await Tn.getNoteById(xe);o||$e(A?ft({id:A.id,name:A.title,content:A.content,outputType:(F=A.metadata)==null?void 0:F.outputType}):[])})().catch(()=>{o||$e([])}),()=>{o=!0}},[y,xe]);const Ft=s.useMemo(()=>{var f;if(y==="agent")return[];if(y==="video")return Dr(O,L||O,Me);const o=Bo(O);return y!=="audio"?o:(Me.sunoAction||((f=o.find(w=>w.id==="sunoAction"))==null?void 0:f.defaultValue)||"music")==="lyrics"?o.filter(w=>w.id==="sunoAction"||w.id==="mv"||w.id==="title"||w.id==="tags"):o},[y,O,L,Me]);s.useEffect(()=>{if(!Nt)return;const o=i=>{const f=i.target;fn.current&&!fn.current.contains(f)&&st(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[Nt]),s.useEffect(()=>()=>{we.current&&clearTimeout(we.current)},[]),s.useEffect(()=>{const o=i=>{var f;((f=i.detail)==null?void 0:f.type)!=="image"&&(we.current&&(clearTimeout(we.current),we.current=null),ot(!1))};return window.addEventListener("ai-generation-complete",o),()=>{window.removeEventListener("ai-generation-complete",o)}},[]),s.useEffect(()=>{const o=ws.observeTaskUpdates().subscribe(i=>{var z,Y;const f=i.task,w=p.getWorkflow();if(!w)return;const _=w.steps.find(H=>{const J=H.result;return(J==null?void 0:J.taskId)===f.id});if(!_)return;let A=_.status,F=_.result,q=_.error;switch(f.status){case Pt.PENDING:case Pt.PROCESSING:A="running";break;case Pt.COMPLETED:A="completed",F={...typeof F=="object"?F:{},taskId:f.id,result:f.result};break;case Pt.FAILED:A="failed",q=((z=f.error)==null?void 0:z.message)||"任务执行失败";break;case Pt.CANCELLED:A="skipped";break}if(A!==_.status){if(p.updateStep(_.id,A,F,q),A==="failed"){const J=(Y=_.options)==null?void 0:Y.batchId;J&&w.steps.forEach(ne=>{var ye;ne.id!==_.id&&((ye=ne.options)==null?void 0:ye.batchId)===J&&ne.status==="running"&&p.updateStep(ne.id,"skipped",void 0,"前置任务失败")})}const H=p.getWorkflow();if(H){const J=Qe(H,E.current||void 0);g.current(J);const ne=T.current,ye=De.current;ne&&ye&&je.updateWorkflow(ye,ne,J)}}});return()=>o.unsubscribe()},[p]);const So=s.useRef(void 0),un=s.useRef(void 0);s.useEffect(()=>{const o=Un.observeCompletionEvents().subscribe(i=>{const f=p.getWorkflow(),w=f==null?void 0:f.steps.find(F=>{const q=F.result;return(q==null?void 0:q.taskId)===i.taskId});let _,A;switch(i.type){case"postProcessingStarted":_="processing";break;case"postProcessingCompleted":_="completed",A=i.result.insertedCount;break;case"postProcessingFailed":_="failed";break}if(So.current=_,A!==void 0&&(un.current=(un.current||0)+A),f&&w){const F=p.getWorkflow();if(F){const q=Qe(F,E.current||void 0,_,un.current);g.current(q);const z=T.current,Y=De.current;z&&Y&&je.updateWorkflow(Y,z,q)}}if(i.type==="postProcessingCompleted"){const F=i.result.firstElementPosition;we.current&&(clearTimeout(we.current),we.current=null),ot(!1),setTimeout(async()=>{var Y;h.closeChatDrawer();const q=T.current,z=De.current;if(q&&z){const H=p.getWorkflow();if(H==null?void 0:H.steps.every(ne=>ne.status==="completed"||ne.status==="failed"||ne.status==="skipped")){const{workflowCompletionService:ne}=await Qo(async()=>{const{workflowCompletionService:ee}=await import("./startup-app-DLAM8ZvV.js").then(Se=>Se.mk);return{workflowCompletionService:ee}},__vite__mapDeps([0]),import.meta.url);(H==null?void 0:H.steps.every(ee=>{const Se=ee.result;return Se!=null&&Se.taskId?ne.isPostProcessingCompleted(Se.taskId):!0}))&&(je.removeWorkZone(z,q),T.current=null)}}if(F&&z){const H=(Y=z.host)==null?void 0:Y.getBoundingClientRect();if(H){const J=z.viewport.zoom,ne=F[0]-H.width/(2*J),ye=F[1]-H.height/(2*J);Rr.updateViewport(z,[ne,ye],J)}}},500),So.current=void 0,un.current=void 0}});return()=>o.unsubscribe()},[p,h]);const De=s.useRef(null),{submitWorkflow:Mo}=Kr({boardRef:De,workZoneIdRef:T}),Ce=s.useRef(null),fn=s.useRef(null),Co=s.useRef(null);Qr(Ce,{enableCopy:!0,stopPropagation:!0}),s.useEffect(()=>{const o=i=>{const f=i.detail;if(f!=null&&f.generationType&&Be(f.generationType),f!=null&&f.skillId){on(f.skillId);const w=wn(f.skillId);w&&$e(ft(w))}st(!0),requestAnimationFrame(()=>{var w;(w=Ce.current)==null||w.focus()})};return window.addEventListener(es,o),()=>{window.removeEventListener(es,o)}},[]);const Ls=s.useCallback(o=>{var i;if(nt(o.prompt),Be("agent"),o.skillId){on(o.skillId);const f=wn(o.skillId);f&&$e(ft(f))}(i=Ce.current)==null||i.focus(),Ae.track("inspiration_selected",{promptLength:o.prompt.length,modelType:o.modelType,skillId:o.skillId})},[]),Bs=s.useCallback(o=>{var i;nt(o.content),o.modelType&&(o.modelType==="image"?Be("image"):o.modelType==="video"?Be("video"):o.modelType==="audio"?Be("audio"):o.modelType==="text"?Be("text"):o.modelType==="agent"&&Be("agent")),(i=Ce.current)==null||i.focus()},[]),Fs=s.useCallback(()=>{const o=Zn.find(i=>i.id==="knowledge-base");o&&(window.__kbPendingNavigation={directoryName:"Skill",autoCreateNote:!0},tn.openTool(o),setTimeout(()=>{window.dispatchEvent(new CustomEvent("kb:navigate",{detail:{directoryName:"Skill",autoCreateNote:!0}}))},300))},[]),To=s.useCallback((o="ai_input_bar")=>{const i=Zn.find(f=>f.id==="banana-prompt");if(!i){console.warn("[AIInputBar] Banana prompt tool not found"),Ae.trackPromptAction({action:"open_tool",surface:o,promptType:y,prompt:me,source:o,status:"failed",metadata:{tool_id:"banana-prompt",reason:"tool_not_found"}});return}Ae.trackPromptAction({action:"open_tool",surface:o,promptType:y,prompt:me,source:o,status:"success",metadata:{tool_id:i.id,tool_type:"external_prompt_library"}}),tn.openTool(i)},[y,me]),Hs=s.useCallback(()=>{To("inspiration_board")},[To]),Gs=s.useCallback(async o=>{try{const i=new Image;i.onload=()=>{const f={type:"image",url:o.url,name:o.name||`素材-${Date.now()}`,width:i.naturalWidth||void 0,height:i.naturalHeight||void 0};wt(w=>[...w,f]),Bt(!1)},i.onerror=()=>{const f={type:"image",url:o.url,name:o.name||`素材-${Date.now()}`};wt(w=>[...w,f]),Bt(!1)},i.src=o.url}catch(i){console.error("Failed to select asset from library:",i),Bt(!1)}},[]),$s=s.useCallback(()=>{var o;(o=Co.current)==null||o.click()},[]),Po=s.useCallback(o=>new Promise((i,f)=>{const w=new FileReader;w.onload=()=>{const _=w.result,A=new Image;A.onload=()=>{i({url:_,width:A.naturalWidth,height:A.naturalHeight})},A.onerror=()=>{i({url:_,width:0,height:0})},A.src=_},w.onerror=f,w.readAsDataURL(o)}),[]),hn=s.useCallback(async o=>{const i=Array.from(o);if(i.length===0)return;const f=[];for(const[w,_]of i.entries()){if(!_.type.startsWith("image/")){Je.error(at.invalidFile);continue}if(_.size>25*1024*1024){Je.error(at.fileTooLarge);continue}try{let A=_;if(_.size>10*1024*1024){const{compressImageBlob:H,getCompressionStrategy:J}=await Qo(async()=>{const{compressImageBlob:ee,getCompressionStrategy:Se}=await import("./startup-app-DLAM8ZvV.js").then(Ue=>Ue.m3);return{compressImageBlob:ee,getCompressionStrategy:Se}},__vite__mapDeps([0]),import.meta.url),ne=J(_.size/(1024*1024)),ye=Je.loading({content:at.compressing(_.size/(1024*1024)),duration:0,placement:"top"});try{A=await H(_,ne.targetSizeMB),Je.close(ye),Je.success({content:at.compressed(_.size/(1024*1024),A.size/(1024*1024)),duration:2})}catch(ee){Je.close(ye),console.error("[AIInputBar] Failed to compress image:",ee),Je.error(at.compressionFailed);continue}}const F=A instanceof File?A:new File([A],_.name||`pasted-image-${Date.now()}.png`,{type:A.type||_.type||"image/png"});I(F,Ho.IMAGE,Nr.LOCAL,F.name).catch(H=>{console.warn("[AIInputBar] Failed to add asset to library:",H)});const{url:q,width:z,height:Y}=await Po(F);f.push({type:"image",url:q,name:F.name||`上传图片 ${w+1}`,width:z||void 0,height:Y||void 0})}catch(A){console.error("[AIInputBar] Failed to import local image:",A),Je.error(at.loadFailed)}}f.length>0&&wt(w=>[...w,...f])},[I,Po,at]),Us=s.useCallback(async o=>{const i=o.target.files;!i||i.length===0||(await hn(i),o.target.value="")},[hn]),Vs=s.useCallback(o=>{Dn(o)},[]),Ao=s.useRef(null),Ks=s.useCallback(o=>{if(Ao.current=o,!o)return;const i=jr(o.width,o.height,O);i&&ln(f=>({...f,size:i}))},[O]),Ys=s.useCallback(o=>{o<Rt.length&&wt(i=>i.filter((f,w)=>w!==o))},[Rt.length]);s.useEffect(()=>{C.current(ce.map(o=>({type:o.type,url:o.url,text:o.text,name:o.name})))},[ce]),s.useEffect(()=>{const o=i=>{var z,Y;const f=(z=i.clipboardData)==null?void 0:z.items;if(!f||f.length===0||!Array.from(f).some(H=>H.type.startsWith("image/")))return;const _=document.activeElement,A=fn.current;if(!(!!A&&(A.contains(_)||Nt&&(_===document.body||(_==null?void 0:_.tagName)==="BODY"))))return;const q=[];for(const H of Array.from(f)){if(!H.type.startsWith("image/"))continue;const J=H.getAsFile();J&&q.push(J)}q.length!==0&&(i.preventDefault(),hn(q),(Y=Ce.current)==null||Y.focus())};return document.addEventListener("paste",o),()=>{document.removeEventListener("paste",o)}},[hn,Nt]);const xt=s.useCallback(()=>{if(rt.current!==null){const o=rt.current;nt(i=>i.substring(0,o)+i.substring(o+1)),rt.current=null}},[]),pn=s.useCallback(o=>{const i=si(y,o.type);Ae.track("ai_input_change_model",{model:o.id,type:o.type,profileId:o.sourceProfileId||null}),xt(),Be(i),uo(o.id);const f=We(o);fo(f),hs(i,{modelId:o.id,modelRef:f,providerIdHint:o.sourceProfileId||(f==null?void 0:f.profileId),vendorHint:o.vendor}),ln(i==="agent"?{}:Kn(i,o.id,ze(o.id,f))),Nn(!1),setTimeout(()=>{var w;return(w=Ce.current)==null?void 0:w.focus()},0)},[xt,y]),Xs=s.useCallback(o=>{const i=Ie(dn,o,L)||Ie(dn,o,null)||Ve(o);i&&pn(i)},[pn,dn,L]),Zs=s.useCallback(o=>{pn(o)},[pn]),mn=s.useCallback((o,i)=>{const f=We(i);o==="image"?(ho(i.id),po(f)):o==="video"?(mo(i.id),go(f)):(wo(i.id),xo(f)),hs(o,{modelId:i.id,modelRef:f,providerIdHint:i.sourceProfileId||(f==null?void 0:f.profileId),vendorHint:i.vendor}),Ae.track("ai_input_change_agent_media_model",{model:i.id,type:o,profileId:i.sourceProfileId||null})},[]),On=s.useCallback((o,i,f)=>{const w=o==="image"?jt:o==="video"?zt:Ot,_=Ie(w,i,f||null)||Ie(w,i,null)||Ve(i);_&&mn(o,_)},[mn,Ot,jt,zt]),Wn=s.useCallback((o,i)=>{mn(o,i)},[mn]),qs=s.useCallback(o=>{$e(ft(o))},[]),Eo=s.useMemo(()=>({image:Fe,video:He,audio:Ge}),[Ge,Fe,He]),Do=s.useMemo(()=>({image:Ke,video:Ye,audio:Xe}),[Xe,Ke,Ye]);s.useEffect(()=>{const o=(z,Y)=>{const H=Object.keys(z),J=Object.keys(Y);return H.length!==J.length?!1:H.every(ne=>z[ne]===Y[ne])},i=y==="agent"?"agent":`${y}:${ze(O,L)}`,f=y==="agent"?{}:yo.current===i?Wt.current||{}:Kn(y,O,ze(O,L),Wt.current),w={},_=Ft.find(z=>z.id==="size"),A=f.size,F=!A||!(_!=null&&_.options)||_.options.some(z=>z.value===A);!O.startsWith("mj")&&_&&(w.size=A&&F?A:_.defaultValue||Fo(O)),Ft.forEach(z=>{if(z.id==="size")return;const Y=f[z.id],H=!Y||z.valueType!=="enum"||!z.options||z.options.some(J=>J.value===Y);Y&&H?w[z.id]=Y:z.defaultValue&&(w[z.id]=z.defaultValue)});const q=zr(O,w);o(Wt.current||{},q)||(ln(q),Wt.current=q),yo.current=i},[y,O,L,Ft]),s.useEffect(()=>{ha({generationType:y,selectedModel:O,selectedParams:Me,selectedCount:Lt,selectedSkillId:xe}),y!=="agent"&&pa(y,O,Me,ze(O,L))},[y,O,L,Me,Lt,xe]);const Js=s.useCallback((o,i,f)=>{xt(),ln(w=>{const _={...w};return i===void 0||i===""?delete _[o]:_[o]=i,_}),f!=null&&f.keepOpen||(jn(!1),setTimeout(()=>{var w;return(w=Ce.current)==null?void 0:w.focus()},0))},[xt]),Qs=s.useCallback(o=>{xt(),Io(o),zn(!1),setTimeout(()=>{var i;return(i=Ce.current)==null?void 0:i.focus()},0)},[xt]),Ln=s.useCallback(async o=>{var F,q,z,Y,H,J,ne,ye;const i=me.trim();if(!i&&ce.length===0||Le)return;l==null||l();const f=Date.now(),w=i.length,_={trigger:o,source:"ai_input_bar",generationType:y,generation_type:y,model:O,profileId:(L==null?void 0:L.profileId)||null,profile_id:(L==null?void 0:L.profileId)||null,hasAttachedContent:ce.length>0,has_attached_content:ce.length>0,attachedCount:ce.length,attached_count:ce.length,promptLength:w,prompt_length:w,promptLengthBucket:Xn(w),prompt_length_bucket:Xn(w)},A=(ee,Se={})=>{const Ue=Date.now()-f;Ae.track("ai_input_submit",{..._,status:ee,durationMs:Ue,duration_ms:Ue,...Se})};A("start"),ot(!0);try{if(!Or(y==="video"?"video":y==="audio"?"audio":y==="text"||y==="agent"?"text":"image",L||O)&&!await Wr()){A("cancelled",{reason:"missing_api_key",submitMode:"preflight",submit_mode:"preflight"}),ot(!1);return}const Ue=ce.filter(M=>M.type==="image"&&M.url),Ht=ce.filter(M=>M.type==="graphics"&&M.url),D=[...Ue,...Ht].map(M=>{if(M.width&&M.height)return{width:M.width,height:M.height}}).filter(M=>M!==void 0),Q={texts:ce.filter(M=>M.type==="text"&&M.text).map(M=>M.text),images:Ue.map(M=>M.url),videos:ce.filter(M=>M.type==="video"&&M.url).map(M=>M.url),graphics:Ht.map(M=>M.url),imageDimensions:D},W=Aa(me,Q,{modelId:O,modelRef:L,params:Me,generationType:y,count:Lt,defaultModels:y==="agent"?Eo:void 0,defaultModelRefs:y==="agent"?Do:void 0}),oe=[...Q.images,...Q.graphics];let j;if(y==="agent"&&xe!==et){const M=wn(xe);if(M)try{j=await yn(W,M,oe)}catch(X){console.warn("[AIInputBar] 系统 Skill 工作流转换失败,降级到通用工作流:",X),j=Tt(W,oe)}else{const X=Go(xe);if(X)try{j=await yn(W,{id:X.id,name:X.name,type:"external",content:X.content,outputType:X.outputType},oe)}catch(V){console.warn("[AIInputBar] 外部 Skill 工作流转换失败,降级到角色扮演:",V),j=await yn(W,{id:X.id,name:X.name,type:"external",content:X.content,outputType:X.outputType},oe).catch(()=>Tt(W,oe))}else try{const V=await Tn.getNoteById(xe);if(V){const le=((F=V.metadata)==null?void 0:F.outputType)||void 0;j=await yn(W,{id:V.id,name:V.title,type:"user",content:V.content,outputType:le},oe)}else j=Tt(W,oe)}catch{j=Tt(W,oe)}}j||(console.warn("[AIInputBar] Skill 工作流未能生成,降级到通用工作流"),j=Tt(W,oe))}else j=Tt(W,oe);const $=De.current;if($){const le=(q=$.host)==null?void 0:q.getBoundingClientRect(),he=((z=$.viewport)==null?void 0:z.zoom)||1,pe=((H=(Y=$.viewport)==null?void 0:Y.origination)==null?void 0:H[0])||0,Re=((ne=(J=$.viewport)==null?void 0:J.origination)==null?void 0:ne[1])||0,Vt=$.children.filter(ge=>ge.type!=="workzone"),gn=pe+((le==null?void 0:le.width)||0)/2/he,vt=Re+((le==null?void 0:le.height)||0)/2/he;let ve=gn-200,se=vt,kt=ve,qe=vt-240/2;if(Vt.length>0){const ge=bs($);let de=!1;if(ge.length>0)try{const ue=Vn($,ge,!1);ge.every(ke=>$o.isDrawElement(ke)&&$o.isImage(ke)||Lr(ke))&&ue.width>ue.height?(ve=ue.x+ue.width+50,se=ue.y):(ve=ue.x,se=ue.y+ue.height+50),kt=ve,qe=se,de=!0}catch(ue){console.warn("[AIInputBar] Failed to calculate position for selected elements:",ue)}if(!de){let ue=null,Yt=-1/0;for(const ke of Vt)try{const Mt=Vn($,[ke],!1),Xt=Mt.y+Mt.height;Xt>Yt&&(Yt=Xt,ue=ke)}catch(Mt){console.warn("[AIInputBar] Failed to get rectangle for element:",Mt)}if(ue){const ke=Vn($,[ue],!1);ve=ke.x,se=ke.y+ke.height+50,kt=ve,qe=se}}}const ct=Qe(j),St=Ao.current;let Kt,lt,jo;if(St){const ge=$.children.find(de=>de.id===St.id);if(ge&&_s(ge)){Kt=St.id,lt={width:St.width,height:St.height};const de=Cn.getRectangleByPoints(ge.points);jo=de,ve=de.x,se=de.y}}if(W.generationType==="image"){const ge=Math.max(W.count??1,1),de=ge>1,ue=de?void 0:Kt,Yt=de?void 0:lt,ke=[],Mt=`wf_batch_${j.id}`,Xt=ue?null:Ka($,[ve,se],Uo({workflowId:j.id,expectedInsertPosition:[ve,se],requestedSize:W.size,requestedCount:1,zoom:he,title:ct.name||"图片生成",...$n("submitted")}).size??{width:320,height:180},ge,{frameRect:de?jo:void 0});for(let Ne=0;Ne<ge;Ne+=1){let Zt=Uo({workflowId:j.id,expectedInsertPosition:[ve,se],targetFrameId:ue,targetFrameDimensions:Yt,frameAffinityId:de?Kt:void 0,frameAffinityDimensions:de?lt:void 0,requestedSize:W.size,requestedCount:de?1:ge,batchId:de?Mt:void 0,batchIndex:de?Ne+1:void 0,batchTotal:de?ge:void 0,zoom:he,title:ct.name||"图片生成",...$n("submitted")});if(!ue){const Oo=Xt?Xt[Ne]??Zt.position:Zt.position;Zt={...Zt,position:Oo,expectedInsertPosition:Oo}}const cr=dt.insertAnchor($,Zt);ke.push(cr)}b.current=ke.map(Ne=>Ne.id),T.current=null;const[zo]=ke;zo&&setTimeout(()=>{const Ne=Cn.getRectangleByPoints(zo.points);Vo($,[Ne.x+Ne.width/2,Ne.y+Ne.height/2],100)},100)}else{const ge=je.insertWorkZone($,{workflow:ct,position:[kt,qe],size:{width:360,height:240},expectedInsertPosition:[ve,se],targetFrameId:Kt,targetFrameDimensions:lt,zoom:he});T.current=ge.id,b.current=[],setTimeout(()=>{const de=kt+180,ue=qe+240/2;Vo($,[de,ue],100)},100)}}const yt=Ct("image"),It=Ct("video"),bt=Ct("audio"),_t={rawInput:me,userInstruction:W.userInstruction,model:{id:W.modelId,type:W.generationType,isExplicit:W.isModelExplicit},modelRef:W.modelRef,defaultModels:W.defaultModels||{audio:bt.modelId||Et(),image:yt.modelId||pt(),video:It.modelId||At()},defaultModelRefs:W.defaultModelRefs||{audio:mt(bt.profileId,bt.modelId),image:mt(yt.profileId,yt.modelId),video:mt(It.profileId,It.modelId)},params:{count:W.count,size:W.size,duration:W.duration},selection:Q,finalPrompt:W.prompt},Fn=Ct("text").modelId,Gt={aiContext:_t,referenceImages:oe,textModel:Fn};E.current=Gt;try{const M=Date.now(),{usedSW:X}=await Mo(W,oe,Gt,j);if(X){if(A("success",{submitMode:"service_worker",submit_mode:"service_worker",workflowId:j.id,workflow_id:j.id,stepCount:j.steps.length,step_count:j.steps.length}),y==="image"&&Z($,"accepted"),me.trim()){const V=me.trim(),le=ce.length>0;S(V,le,y),y==="image"?Ko(V):y==="video"&&Yo(V)}nt(""),Dn([]),wt([]),we.current&&clearTimeout(we.current),we.current=setTimeout(()=>{ot(!1),we.current=null},1e3);return}}catch(M){console.warn("[AIInputBar] SW execution failed, falling back to main thread:",M)}if(y==="image"&&Z($,"handoff"),me.trim()){const M=me.trim(),X=ce.length>0;S(M,X,y),y==="image"?Ko(M):y==="video"&&Yo(M)}nt(""),Dn([]),wt([]),we.current&&clearTimeout(we.current),we.current=setTimeout(()=>{ot(!1),we.current=null},1e3);const fe=[],Ze=[],$t=(M,X)=>({onChunk:V=>{x.current(V)},onAddSteps:V=>{p.updateStep(M.id,"completed",{analysis:"completed"},void 0,Date.now()-X);const le=V.map((pe,Re)=>Mn(j,{...pe,status:pe.status==="completed"?"completed":"pending",options:{mode:"queue",batchId:`agent_${Date.now()}`,batchIndex:Re+1,batchTotal:V.length,globalIndex:Re+1}}));p.addSteps(le),Ze.push(...le),V.forEach(pe=>{R.current({type:"tool_call",timestamp:Date.now(),toolName:pe.mcp,args:pe.args})});const he=Qe(p.getWorkflow(),E.current||void 0);g.current(he),T.current&&$&&je.updateWorkflow($,T.current,he)},onUpdateStep:(V,le,he,pe)=>{p.updateStep(V,le,he,pe),R.current({type:"tool_result",timestamp:Date.now(),toolName:V,success:le==="completed",data:he,error:pe});const Re=Qe(p.getWorkflow(),E.current||void 0);g.current(Re),T.current&&$&&je.updateWorkflow($,T.current,Re)}});let Te=!1;const Ut=()=>{const M=Qe(p.getWorkflow(),E.current||void 0);g.current(M),T.current&&$&&je.updateWorkflow($,T.current,M)},Hn=async M=>{var le,he,pe,Re,Vt,gn;const X=Date.now(),V=Ze.length;p.updateStep(M.id,"running"),Ut();try{const vt={...M.options,...$t(M,X)},ve=Mn(j,M),se=await Xo.executeTool({name:ve.mcp,arguments:ve.args},vt),kt=(he=(le=p.getWorkflow())==null?void 0:le.steps.find(qe=>qe.id===M.id))==null?void 0:he.status;if(se.success){if(se.taskId)fe.push(se.taskId),p.updateStep(M.id,"running",{taskId:se.taskId}),te($,se.taskId,{workflowId:j.id,batchId:(pe=M.options)==null?void 0:pe.batchId,batchIndex:(Re=M.options)==null?void 0:Re.batchIndex});else if(kt==="running"){const qe=se.type==="text"&&se.data&&typeof se.data=="object"&&"content"in se.data?{content:se.data.content}:se.data;p.updateStep(M.id,"completed",qe,void 0,Date.now()-X);const ct=M.mcp==="generate_text"?(Vt=se.data)==null?void 0:Vt.content:M.mcp==="ai_analyze"?(gn=se.data)==null?void 0:gn.response:void 0;if((M.mcp==="generate_text"||M.mcp==="ai_analyze")&&ct&&ct.trim()&&Ze.length===V){const lt={id:`${M.id}-insert-text`,mcp:"insert_to_canvas",args:{items:[{type:"text",content:ct}]},description:M.mcp==="generate_text"?"将生成文本插入画布":"将 AI 回复插入画布",status:"pending"};p.addSteps([lt]),Ze.push(lt)}}}else return p.updateStep(M.id,"failed",void 0,se.error||"执行失败",Date.now()-X),!1;return!0}catch(vt){return p.updateStep(M.id,"failed",void 0,String(vt)),!1}finally{Ut()}};for(const M of j.steps){if(Te){p.updateStep(M.id,"skipped"),Ut();continue}await Hn(M)||(Te=!0)}if(!Te&&Ze.length>0){const M=p.getWorkflow();for(const X of Ze){if(Te){p.updateStep(X.id,"skipped"),Ut();continue}const V=(ye=p.getWorkflow())==null?void 0:ye.steps.find(he=>he.id===X.id);if(!V){console.warn(`[AIInputBar] Step ${X.id} not found in workflow!`);continue}if(V.status==="completed")continue;await Hn(V)||(Te=!0)}}const be=p.getWorkflow(),ar=be==null?void 0:be.steps.every(M=>M.status==="completed"||M.status==="failed"||M.status==="skipped"),ir=fe.length>0;if(ar&&!ir){const M=T.current,X=b.current,V=De.current;(M||X.length>0)&&V&&(be!=null&&be.steps.every(he=>{const pe=he.result;return pe!=null&&pe.taskId?Un.isPostProcessingCompleted(pe.taskId):!0}))&&setTimeout(()=>{M&&(je.removeWorkZone(V,M),T.current=null),X.length>0&&(Z(V,"completed"),re(V))},1500)}A(Te?"failed":"success",{submitMode:"main_thread",submit_mode:"main_thread",workflowId:j.id,workflow_id:j.id,stepCount:(be==null?void 0:be.steps.length)||j.steps.length,step_count:(be==null?void 0:be.steps.length)||j.steps.length,createdTaskCount:fe.length,created_task_count:fe.length,failureReason:Te?"workflow_step_failed":void 0,failure_reason:Te?"workflow_step_failed":void 0})}catch(ee){console.error("Failed to create generation task:",ee),A("failed",{submitMode:"setup",submit_mode:"setup",error:ee instanceof Error?ee.message:String(ee)}),y==="image"&&Z(De.current,"failed",{error:ee instanceof Error?ee.message:"创建图片任务失败"}),p.abortWorkflow(),ot(!1)}},[me,ce,Le,O,L,p,Mo,S,Me,Eo,Do,y,Lt,te,Z,re,l]),Bn=s.useCallback(async(o,i,f)=>{var Ht;const w=o.retryContext;if(!w){console.error("[AIInputBar] No retry context available for workflow");return}f&&(T.current=f);const _={id:o.id,name:o.name,description:`重试: ${o.name}`,scenarioType:o.steps.some(D=>D.mcp==="ai_analyze")?"agent_flow":"direct_generation",generationType:o.generationType,steps:o.steps.map((D,Q)=>({id:D.id,mcp:D.mcp,args:D.args,description:D.description,status:Q<i?D.status:"pending",result:Q<i?D.result:void 0,error:Q<i?D.error:void 0,duration:Q<i?D.duration:void 0,options:D.options})),metadata:{prompt:o.prompt,userInstruction:w.aiContext.userInstruction,rawInput:w.aiContext.rawInput,modelId:w.aiContext.model.id,modelRef:w.aiContext.modelRef,defaultModels:w.aiContext.defaultModels,defaultModelRefs:w.aiContext.defaultModelRefs,isModelExplicit:w.aiContext.model.isExplicit,count:o.count,size:w.aiContext.params.size,duration:w.aiContext.params.duration,referenceImages:w.referenceImages,selection:w.aiContext.selection},createdAt:Date.now()};p.startWorkflow(_),R.current({type:"retry",timestamp:Date.now(),reason:`从步骤 ${i+1} 开始重试`,attempt:1});const A=De.current,F=()=>{const D=Qe(p.getWorkflow(),w);g.current(D),T.current&&A&&je.updateWorkflow(A,T.current,D)},q=Qe(_,w);g.current(q),T.current&&A&&je.updateWorkflow(A,T.current,q);const z=(D,Q)=>({onChunk:W=>{x.current(W)},onAddSteps:W=>{p.updateStep(D.id,"completed",{analysis:"completed"},void 0,Date.now()-Q);const oe=W.map((j,$)=>Mn(_,{...j,status:j.status==="completed"?"completed":"pending",options:{mode:"queue",batchId:`agent_${Date.now()}`,batchIndex:$+1,batchTotal:W.length,globalIndex:$+1}}));p.addSteps(oe),Y.push(...oe),W.forEach(j=>{R.current({type:"tool_call",timestamp:Date.now(),toolName:j.mcp,args:j.args})}),F()},onUpdateStep:(W,oe,j,$)=>{p.updateStep(W,oe,j,$),R.current({type:"tool_result",timestamp:Date.now(),toolName:W,success:oe==="completed",data:j,error:$}),F()}}),Y=[];let H=!1;const J=new Map;o.steps.forEach(D=>{var W;const Q=(W=D.result)==null?void 0:W.taskId;Q&&J.set(D.id,Q)});const ne=async D=>{var oe,j,$,yt,It,bt;const Q=Date.now(),W=Y.length;p.updateStep(D.id,"running"),F();try{const _t=J.get(D.id),Fn={...D.options,...z(D,Q),..._t?{retryTaskId:_t}:{}},Gt=Mn(_,D),fe=await Xo.executeTool({name:Gt.mcp,arguments:Gt.args},Fn),Ze=(j=(oe=p.getWorkflow())==null?void 0:oe.steps.find($t=>$t.id===D.id))==null?void 0:j.status;if(fe.success){if(fe.taskId)p.updateStep(D.id,"running",{taskId:fe.taskId}),te(A,fe.taskId,{workflowId:o.id,batchId:($=D.options)==null?void 0:$.batchId,batchIndex:(yt=D.options)==null?void 0:yt.batchIndex});else if(Ze==="running"){const $t=fe.type==="text"&&fe.data&&typeof fe.data=="object"&&"content"in fe.data?{content:fe.data.content}:fe.data;p.updateStep(D.id,"completed",$t,void 0,Date.now()-Q);const Te=D.mcp==="generate_text"?(It=fe.data)==null?void 0:It.content:D.mcp==="ai_analyze"?(bt=fe.data)==null?void 0:bt.response:void 0;if((D.mcp==="generate_text"||D.mcp==="ai_analyze")&&Te&&Te.trim()&&Y.length===W){const be={id:`${D.id}-insert-text`,mcp:"insert_to_canvas",args:{items:[{type:"text",content:Te}]},description:D.mcp==="generate_text"?"将生成文本插入画布":"将 AI 回复插入画布",status:"pending"};p.addSteps([be]),Y.push(be)}}}else return p.updateStep(D.id,"failed",void 0,fe.error||"执行失败",Date.now()-Q),!1;return!0}catch(_t){return p.updateStep(D.id,"failed",void 0,String(_t)),!1}finally{F()}},ye=_.steps.slice(i);for(const D of ye){if(H){p.updateStep(D.id,"skipped"),F();continue}await ne(D)||(H=!0)}if(!H&&Y.length>0)for(const D of Y){if(H){p.updateStep(D.id,"skipped"),F();continue}const Q=(Ht=p.getWorkflow())==null?void 0:Ht.steps.find(oe=>oe.id===D.id);if(!Q||Q.status==="completed")continue;await ne(Q)||(H=!0)}const ee=p.getWorkflow(),Se=ee==null?void 0:ee.steps.every(D=>D.status==="completed"||D.status==="failed"||D.status==="skipped"),Ue=ee==null?void 0:ee.steps.some(D=>{var Q;return(Q=D.result)==null?void 0:Q.taskId});if(Se&&!Ue){const D=T.current,Q=De.current;D&&Q&&(ee!=null&&ee.steps.every(oe=>{const j=oe.result;return j!=null&&j.taskId?Un.isPostProcessingCompleted(j.taskId):!0}))&&setTimeout(()=>{je.removeWorkZone(Q,D),T.current=null},1500)}},[p,te]);s.useEffect(()=>{N.current(Bn);const o=De.current;o&&(o.__executeWorkflowRetry=Bn)},[Bn]);const er=s.useCallback(o=>{var i;if(!o.nativeEvent.isComposing&&!(o.key==="Enter"&&(o.shiftKey||o.altKey))){if((bo||_o||vo)&&(o.key==="Enter"||o.key==="Tab")){o.preventDefault();return}if(o.key==="Enter"){o.preventDefault(),Ae.track("ai_input_submit_keyboard"),Ln("keyboard");return}if(o.key==="Escape"){st(!1),(i=Ce.current)==null||i.blur();return}}},[Ln]),tr=s.useCallback(()=>{Ae.track("ai_input_focus_textarea"),st(!0)},[]),nr=s.useCallback(()=>{Ae.track("ai_input_blur_textarea"),st(!1)},[]),or=s.useCallback(o=>{const i=o.target.value,f=o.target.selectionStart||i.length;if(nt(i),f>0){const w=i[f-1],_=f>1?i[f-2]:" ";w==="#"&&(_===" "||_===`
|
|
107
|
+
`||f===1)&&(rt.current=f-1,Nn(!0),jn(!1),zn(!1))}},[]),sr=s.useMemo(()=>JSON.stringify({generationType:y,model:O,profileId:(L==null?void 0:L.profileId)||null,hasAttachedContent:ce.length>0,attachedCount:ce.length,promptLengthBucket:Xn(me.trim().length)}),[ce.length,y,me,O,L==null?void 0:L.profileId]),Ro=me.trim().length>0||ce.length>0,No=Ns===!0,rr=En.some(o=>{var i;return o.type==="text"&&((i=o.text)==null?void 0:i.trim())}),it=Nt||ce.length>0||Ds;return s.useLayoutEffect(()=>{oi(Ce.current,it)},[it,me]),u.jsxs("div",{ref:fn,className:xn("ai-input-bar",An,e,{"ai-input-bar--with-inspiration":No}),"data-testid":"ai-input-bar",children:[u.jsx(As,{language:r,onSelectionChange:Vs,externalBoardRef:De,onCanvasEmptyChange:js,isDataReady:n,onFrameSelected:Ks}),u.jsx(La,{isCanvasEmpty:No,onSelectPrompt:Ls,onOpenPromptTool:Hs}),u.jsxs("div",{className:xn("ai-input-bar__container",{"ai-input-bar__container--expanded":it}),children:[u.jsxs("div",{className:"ai-input-bar__bottom-bar",children:[u.jsx("input",{ref:Co,type:"file",accept:"image/*",multiple:!0,onChange:Us,style:{display:"none"}}),u.jsx("button",{className:"ai-input-bar__upload-btn",onMouseDown:o=>{o.preventDefault(),o.stopPropagation()},onClick:$s,title:r==="zh"?"上传图片":"Upload images","data-track":"ai_input_click_upload",children:u.jsx(Br,{size:18})}),u.jsx("button",{className:"ai-input-bar__library-btn",onMouseDown:o=>{o.preventDefault(),o.stopPropagation()},onClick:()=>Bt(!0),title:r==="zh"?"从素材库选择":"Select from library","data-track":"ai_input_click_library",children:u.jsx(Fr,{size:18})}),u.jsx(Ba,{value:y,onSelect:Be,disabled:Le}),y==="agent"&&u.jsx(Ea,{value:xe,onSelect:on,onSelectSkill:qs,onAddSkill:Fs,disabled:Le}),u.jsx(vn,{selectedModel:O,selectedSelectionKey:ze(O,L),onSelect:Xs,onSelectModel:Zs,language:r,models:dn,header:r==="zh"?y==="agent"?"选择文本模型 (↑↓ Tab)":"选择模型 (↑↓ Tab)":y==="agent"?"Select text model (↑↓ Tab)":"Select model (↑↓ Tab)",isOpen:bo,onOpenChange:zs}),y==="agent"&&xe!==et&&Rn.includes("image")&&u.jsx(vn,{selectedModel:Fe,selectedSelectionKey:ze(Fe,Ke),onSelect:(o,i)=>On("image",o,i),onSelectModel:o=>Wn("image",o),language:r,models:jt,header:r==="zh"?"选择图片模型 (↑↓ Tab)":"Select image model (↑↓ Tab)"}),y==="agent"&&xe!==et&&Rn.includes("video")&&u.jsx(vn,{selectedModel:He,selectedSelectionKey:ze(He,Ye),onSelect:(o,i)=>On("video",o,i),onSelectModel:o=>Wn("video",o),language:r,models:zt,header:r==="zh"?"选择视频模型 (↑↓ Tab)":"Select video model (↑↓ Tab)"}),y==="agent"&&xe!==et&&Rn.includes("audio")&&u.jsx(vn,{selectedModel:Ge,selectedSelectionKey:ze(Ge,Xe),onSelect:(o,i)=>On("audio",o,i),onSelectModel:o=>Wn("audio",o),language:r,models:Ot,header:r==="zh"?"选择音频模型 (↑↓ Tab)":"Select audio model (↑↓ Tab)"}),y!=="agent"&&Ft.length>0&&u.jsx(ma,{selectedParams:Me,onParamChange:Js,compatibleParams:Ft,modelId:O,language:r,isOpen:_o,onOpenChange:Os},O),y!=="agent"&&y!=="text"&&y!=="audio"&&u.jsx(Fa,{value:Lt,onSelect:Qs,disabled:Le,isOpen:vo,onOpenChange:Ws}),u.jsx("div",{className:"ai-input-bar__bottom-spacer"}),u.jsx("button",{className:`ai-input-bar__send-btn ${Ro?"active":""} ${Le?"loading":""}`,onMouseDown:o=>{o.preventDefault(),o.stopPropagation()},onClick:()=>Ln("button"),disabled:!Ro||Le,"data-track":"ai_input_click_send","data-track-params":sr,"data-testid":"ai-send-btn",children:u.jsx(Hr,{size:18})})]}),u.jsxs("div",{className:xn("ai-input-bar__input-area",{"ai-input-bar__input-area--expanded":it}),children:[ce.length>0&&u.jsx("div",{className:"ai-input-bar__content-preview",children:u.jsx(ea,{items:ce,language:r,enableHoverPreview:!0,onRemove:Ys,removableStartIndex:Rt.length})}),u.jsxs("div",{className:"ai-input-bar__prompt-row",children:[u.jsx("div",{className:"ai-input-bar__rich-input",children:u.jsx("textarea",{ref:Ce,className:xn("ai-input-bar__input",{"ai-input-bar__input--focused":it}),value:me,onChange:or,onKeyDown:er,onFocus:tr,onBlur:nr,placeholder:y==="agent"?r==="zh"?"输入指令,让 Agent 为你工作...":"Type instructions for Agent...":y==="text"?r==="zh"?"输入你想生成的文本内容、文章、摘要或 Markdown":"Describe the text, article, summary, or markdown you want":y==="audio"?rr?r==="zh"?"已有文本,无需额外提示词,直接发送":"Text already selected. No extra prompt needed, just send":r==="zh"?"描述你想要生成的音乐、风格、歌词或情绪":"Describe the music, style, lyrics, or mood you want":r==="zh"?`描述你想要创建的${y==="image"?"图片":"视频"}`:`Describe the ${y==="image"?"image":"video"} you want to create`,rows:it?Ps:ei,disabled:Le,"data-testid":"ai-input-textarea"})}),u.jsx(ga,{generationType:y,onSelectPrompt:Bs,language:r,onBeforeOpenMyPrompts:t,extraActions:it?u.jsx(ta,{className:"prompt-history-popover__action-btn",originalPrompt:me,language:r,scenarioId:`ai-input.${y}`,disabled:Le,allowStructuredMode:!0,onOpenChange:Rs,onMouseDown:o=>{o.preventDefault(),o.stopPropagation(),st(!0)},onApply:o=>{nt(o),st(!0),requestAnimationFrame(()=>{var i;(i=Ce.current)==null||i.focus()})}}):null})]})]})]}),ko&&u.jsx(aa,{isOpen:ko,onClose:()=>Bt(!1),mode:Gr.SELECT,filterType:Ho.IMAGE,onSelect:Gs})]})});Es.displayName="AIInputBar";function mi({isDataReady:e,activationKey:n,onEnableToolWindows:t,onEnableRuntime:l}){const r=s.useRef(null);return s.useEffect(()=>{if(n<=0)return;const c=window.setTimeout(()=>{var m;const a=(m=r.current)==null?void 0:m.querySelector('[data-testid="ai-input-textarea"]');a==null||a.focus()},0);return()=>{window.clearTimeout(c)}},[n]),u.jsx(Yr,{children:u.jsx(oa,{children:u.jsx("div",{ref:r,children:u.jsx(Es,{isDataReady:e,onEnableToolWindows:t,onEnableRuntime:l})})})})}export{mi as DeferredAIInputBar,mi as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./startup-app-D5aWsYi2.css","./ai-chat-CQtdTiRy.css","./tool-windows-D6a2KkKR.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as a}from"./startup-runtime-DTmhLESk.js";import{am as M,j as t,r as n}from"./startup-app-
|
|
2
|
+
import{_ as a}from"./startup-runtime-DTmhLESk.js";import{am as M,j as t,r as n}from"./startup-app-DLAM8ZvV.js";const F=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.a1),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.ProjectDrawer}))),U=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.a2),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.ToolboxDrawer}))),W=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.a3),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.DeferredMediaLibraryModal}))),q=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.a4),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.BackupRestoreDialog}))),G=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.a5),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.VersionUpdatePrompt}))),H=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.a6),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.PerformancePanel}))),J=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.a7),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.DeferredSyncSettings}))),K=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.a8),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.CommandPalette}))),N=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.a9),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.CanvasSearch}))),Q=n.lazy(()=>a(()=>import("./tool-windows-yv_XPMbT.js").then(e=>e.aa),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.ToolWinBoxManager})));function Z({board:e,value:S,containerRef:o,versionUpdateEnabled:v,performancePanelEnabled:D,toolWindowManagerEnabled:f,projectDrawerOpen:u,toolboxDrawerOpen:p,mediaLibraryOpen:_,mediaLibraryConfig:l,backupRestoreOpen:h,cloudSyncOpen:m,onBoardSwitch:r,setProjectDrawerOpen:T,setToolboxDrawerOpen:O,setMediaLibraryOpen:k,setBackupRestoreOpen:V,setCloudSyncOpen:A,handleOpenMediaLibrary:I,handleBeforeSwitch:x,onCreateProjectForMemory:R}){const{appState:P,setAppState:d}=M(),j=P.openCommandPalette||!1,E=P.openCanvasSearch||!1;return t.jsxs(t.Fragment,{children:[_&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(W,{isOpen:_,onClose:()=>k(!1),mode:l==null?void 0:l.mode,filterType:l==null?void 0:l.filterType,onSelect:l==null?void 0:l.onSelect,selectButtonText:l==null?void 0:l.selectButtonText})}),h&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(q,{open:h,onOpenChange:V,container:o.current,onBeforeImport:async()=>{await x()},onSwitchBoard:async(s,i)=>{const{workspaceService:w}=await a(async()=>{const{workspaceService:z}=await import("./startup-app-DLAM8ZvV.js").then(B=>B.ml);return{workspaceService:z}},__vite__mapDeps([0]),import.meta.url),c=await w.switchBoard(s);c&&r&&(i&&(c.viewport=i),r(c))}})}),m&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(J,{visible:m,onClose:()=>A(!1)})}),v&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(G,{})}),f&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(Q,{})}),j&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(K,{open:j,onClose:()=>{d(s=>({...s,openCommandPalette:!1}))},board:e,container:o.current})}),E&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(N,{open:E,onClose:()=>{d(s=>({...s,openCanvasSearch:!1}))},board:e})}),D&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(H,{container:o.current,onCreateProject:R,elements:(e==null?void 0:e.children)||S})}),u&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(F,{isOpen:u,onOpenChange:T,onBeforeSwitch:x,onBoardSwitch:r,onOpenMediaLibrary:I})}),p&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(U,{isOpen:p,onOpenChange:O})})]})}export{Z as DrawnixDeferredFeatures,Z as default};
|