aitu-app 1.0.0 → 1.0.2
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-DyUPmMV6.js → CanvasAudioPlayer-HtUs8HDj.js} +2 -2
- package/assets/ComicCreator-DhxXCyJR.js +43 -0
- package/assets/{DeferredAIInputBar-Cq0t7wNK.js → DeferredAIInputBar-B2R2-2RU.js} +3 -3
- package/assets/{DrawnixDeferredFeatures-B9y0GPYR.js → DrawnixDeferredFeatures-DHTr0c-V.js} +2 -2
- package/assets/{KnowledgeBaseContent-C8zmce09.js → KnowledgeBaseContent-CAq5kXdt.js} +6 -6
- package/assets/{MVCreator-Bl8GH4mR.js → MVCreator-B9uaRsGE.js} +16 -16
- package/assets/{ModelBenchmarkWorkbench-BwfeZDt-.js → ModelBenchmarkWorkbench-CK33zizl.js} +1 -1
- package/assets/{MusicAnalyzer-CdMhl-kU.js → MusicAnalyzer-D2NTonEA.js} +1 -1
- package/assets/{PromptHistoryTool-CCxoST3H.js → PromptHistoryTool-q6vOxFr6.js} +1 -1
- package/assets/{ResizableDivider-D1jgqdmh.js → ResizableDivider-BvT-DCEo.js} +2 -2
- package/assets/{TaskQueuePanel-WF6aq1G7.js → TaskQueuePanel-PayswYlG.js} +1 -1
- package/assets/{VideoAnalyzer-BOqRFjZ9.js → VideoAnalyzer-DnowtohS.js} +1 -1
- package/assets/{VideoAnalyzer-BrEKSLeh.js → VideoAnalyzer-DoaGlK92.js} +2 -2
- package/assets/{ai-chat-DbjmzngX.css → ai-chat-BlxYfB4O.css} +1 -1
- package/assets/ai-chat-BnWVpTEI.js +2977 -0
- package/assets/{batch-image-generation-DyWeiTsw.js → batch-image-generation-CkmX4dem.js} +5 -5
- package/assets/{bootstrap-DadYvnge.js → bootstrap-CQRLkOtk.js} +7 -7
- package/assets/{clean-confirm-CpWpcTF5.js → clean-confirm-CIViVQ8s.js} +1 -1
- package/assets/{diagram-engines-C0Ljec4Z.js → diagram-engines-DpAsX7pc.js} +3 -3
- package/assets/{editor-engines-Dz5Mk5YB.js → editor-engines-9_72Ghfn.js} +1 -1
- package/assets/{external-skill-service-BQUJLLLc.js → external-skill-service-BN8ZCtPn.js} +1 -1
- package/assets/{frame-size-matcher-2sxA9X-P.js → frame-size-matcher-9rxQ-bAY.js} +1 -1
- package/assets/{index-CRuDVxTu.js → index-291TeU7i.js} +1 -1
- package/assets/{index-BNtKpMlh.js → index-BJ-vS89P.js} +1 -1
- package/assets/{index-Ct7MFvFo.js → index-BSZAS0wO.js} +1 -1
- package/assets/{index-BfdBtWT6.js → index-C7DAD_xK.js} +1 -1
- package/assets/{index-o8hm5yhT.js → index-CIgiIDgZ.js} +1 -1
- package/assets/{index-BwW4Qp-A.js → index-CpHWUe__.js} +1 -1
- package/assets/{index-D7UBK5T7.js → index-D1LQ9eQM.js} +1 -1
- package/assets/{index-D_Yn26AT.js → index-DRGxmFyd.js} +1 -1
- package/assets/{index-CBMgStgL.js → index-DmtcRYr8.js} +1 -1
- package/assets/{index.es-CYBRnsv6.js → index.es-Ch45-H39.js} +1 -1
- package/assets/{jspdf.es.min-I7TkFvGI.js → jspdf.es.min-bNprb1JY.js} +3 -3
- package/assets/{link-popup-fCfgZp17.js → link-popup-B6ReK6iq.js} +1 -1
- package/assets/{markdown-to-drawnix-3yksNvbU.js → markdown-to-drawnix-BqT-3zQO.js} +3 -3
- package/assets/{mermaid-to-drawnix-C7rF-30X.js → mermaid-to-drawnix-CSctnpU0.js} +3 -3
- package/assets/{model-benchmark-launcher-uYoranwQ.js → model-benchmark-launcher-DNMp2MLQ.js} +1 -1
- package/assets/{photo-wall-splitter-CfRBAwCy.js → photo-wall-splitter-DhBTEpdG.js} +1 -1
- package/assets/{popup-toolbar-tKtYPGvw.js → popup-toolbar-BChsudwW.js} +7 -7
- package/assets/{prompt-utils-C_mjEqkz.js → prompt-utils-BX0pRV-Z.js} +1 -1
- package/assets/quick-creation-toolbar-3-AYFpEF.js +2 -0
- package/assets/{settings-dialog-DfK6bcBd.js → settings-dialog-Ccemaout.js} +1 -1
- package/assets/{size-picker-DvMt8S3Z.js → size-picker-DTrdjyLh.js} +1 -1
- package/assets/{skill-dsl-parser-CTM4hEIp.js → skill-dsl-parser-ZR--uu5h.js} +1 -1
- package/assets/{startup-app-9gZEGv85.js → startup-app-CH3QzBb4.js} +2 -2
- package/assets/{task-sync-D7bw59_K.js → task-sync-C5XXOQ5m.js} +1 -1
- package/assets/{tool-windows-BnDZa9FH.js → tool-windows-Bf_pMml-.js} +6 -6
- package/assets/ttd-dialog-CohjwODB.js +6 -0
- package/assets/{ttd-dialog-submit-shortcut-UfHT9Z9k.js → ttd-dialog-submit-shortcut-BVB8O_wE.js} +1 -1
- package/assets/{useCharacters-6u0Wuwt4.js → useCharacters-CFlPvydq.js} +1 -1
- package/assets/{useWorkflowSubmission-DTWha6Vn.js → useWorkflowSubmission-CKkOEcAT.js} +3 -3
- package/assets/{video-merge-webcodecs-Cwy2df91.js → video-merge-webcodecs-BInWo9HA.js} +2 -2
- package/assets/{video-recovery-service-CgZ3pA_1.js → video-recovery-service-DITdD0pC.js} +1 -1
- package/assets/{workflow-generation-utils-BPT49S-Z.js → workflow-generation-utils-e0nRpAgJ.js} +3 -3
- package/assets/{workflow-submission-service-C-6Uf9FA.js → workflow-submission-service-BqiL_5Cj.js} +3 -3
- package/changelog.json +105 -6
- package/idle-prefetch-manifest.json +136 -288
- package/manifest.json +3 -3
- package/package.json +1 -1
- package/precache-manifest.json +6 -6
- package/sw.js +1 -1
- package/version.json +63 -3
- package/.DS_Store +0 -0
- package/assets/ComicCreator-DjOhYrZt.js +0 -43
- package/assets/ai-chat-B-XdoWBQ.js +0 -2976
- package/assets/quick-creation-toolbar-CrQ0g0kO.js +0 -2
- package/assets/ttd-dialog-DS6KiOOa.js +0 -6
- package/assets/useMediaViewer-BrBFopM-.js +0 -1
- package/user-manual/gifs//346/200/235/347/273/264/345/257/274/345/233/276/345/210/233/345/273/272/346/274/224/347/244/272.gif +0 -0
- package/user-manual/screenshots/ai-step-0.png +0 -0
- package/user-manual/screenshots/ai-step-1.png +0 -0
- package/user-manual/screenshots/ai-step-2.png +0 -0
- package/user-manual/screenshots/ai-step-3.png +0 -0
- package/user-manual/screenshots/app-menu.png +0 -0
- package/user-manual/screenshots/backup-restore.png +0 -0
- package/user-manual/screenshots/canvas-tools.png +0 -0
- package/user-manual/screenshots/debug-panel.png +0 -0
- package/user-manual/screenshots/drawing-step-0.png +0 -0
- package/user-manual/screenshots/drawing-step-1.png +0 -0
- package/user-manual/screenshots/drawing-step-2.png +0 -0
- package/user-manual/screenshots/edit-selected.png +0 -0
- package/user-manual/screenshots/element-selected.png +0 -0
- package/user-manual/screenshots/flowchart-step-1.png +0 -0
- package/user-manual/screenshots/flowchart-step-2.png +0 -0
- package/user-manual/screenshots/flowchart-step-3.png +0 -0
- package/user-manual/screenshots/image-preview-empty.png +0 -0
- package/user-manual/screenshots/insert-from-library.png +0 -0
- package/user-manual/screenshots/insert-tools.png +0 -0
- package/user-manual/screenshots/inspiration-step-1.png +0 -0
- package/user-manual/screenshots/inspiration-step-2.png +0 -0
- package/user-manual/screenshots/media-library.png +0 -0
- package/user-manual/screenshots/mindmap-step-1.png +0 -0
- package/user-manual/screenshots/mindmap-step-2.png +0 -0
- package/user-manual/screenshots/mindmap-toolbar-menu.png +0 -0
- package/user-manual/screenshots/project-drawer.png +0 -0
- package/user-manual/screenshots/settings-dialog.png +0 -0
- package/user-manual/screenshots/shape-step-1.png +0 -0
- package/user-manual/screenshots/shape-step-2.png +0 -0
- package/user-manual/screenshots/text-step-1.png +0 -0
- package/user-manual/screenshots/text-step-2.png +0 -0
- package/user-manual/screenshots/toolbox-drawer.png +0 -0
- package/user-manual/screenshots/toolbox-entry.png +0 -0
- package/user-manual/screenshots/video-entry.png +0 -0
- package/user-manual/screenshots/view-navigation.png +0 -0
- package/user-manual/screenshots/zoom-menu.png +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ai-chat-DbjmzngX.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as Z}from"./startup-runtime-BrfuwjQS.js";import{cm as $,dI as W,bd as J,P as c,mz as K,mA as ee,mB as te,mC as ae,dP as re,a8 as a,iq as oe,iS as ne,iP as ie,f6 as se,dX as le,iR as ce,iQ as de,iT as ue,eI as U,i5 as pe,i6 as me,dQ as y,dR as w,bl as f,i7 as he,dV as fe,gt as N,gs as R,cO as I,aY as Ie,ao as k,b9 as be,ba as ge,bb as Pe,n7 as xe,aS as Te}from"./ai-chat-B-XdoWBQ.js";import{g as ye,I as ke,S as ve,t as E,F as _e,A as we,v as Ee}from"./bootstrap-DadYvnge.js";import{c as P,k as Se,o as Me}from"./tool-windows-BnDZa9FH.js";import"./startup-app-9gZEGv85.js";const Ae=c.lazy(()=>Z(()=>import("./ai-chat-B-XdoWBQ.js").then(p=>p.sZ),__vite__mapDeps([0]),import.meta.url).then(p=>({default:p.MediaLibraryModal}))),je=4,Ne=({position:p,visible:b,onClose:s,onOpenMediaLibrary:S})=>{const o=ye(),{t:l}=$(),m=W(),B=J.getBoardContainer(o),[M,A]=c.useState({freehand:!1,arrow:!1,shape:!1}),[j,x]=c.useState(!1),{refs:v,floatingStyles:F}=K({placement:"bottom",middleware:[ee(12),te({padding:16}),ae({fallbackPlacements:["top","right","left"]})]});c.useEffect(()=>{if(p&&b){const[e,r]=p;v.setPositionReference({getBoundingClientRect(){return{width:1,height:1,x:e,y:r,top:r,left:e,right:e+1,bottom:r+1}}})}},[p,b,v]),c.useEffect(()=>{if(!b)return;const e=i=>{const n=i.target,d=n.closest(".quick-creation-toolbar"),h=n.closest(".quick-toolbar-popover")||n.closest("[data-radix-popper-content-wrapper]")||n.closest(".plait-popover")||n.closest(".shape-picker")||n.closest(".arrow-picker")||n.closest(".freehand-panel"),t=n.closest(".media-library-modal");!d&&!h&&!t&&s()},r=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(r),document.removeEventListener("mousedown",e)}},[b,s]);const u=()=>{A({freehand:!1,arrow:!1,shape:!1})},C=e=>{A({freehand:!1,arrow:!1,shape:!1,[e]:!0})},q=()=>{u(),E(o),y(o,null),f.updatePointerType(o,N.text),m(N.text),s()},V=()=>{u(),E(o),y(o,w.dnd),f.updatePointerType(o,R.mind),m(R.mind),s()},z=()=>{u(),Se(o),s()},L=async e=>{try{e.type===I.IMAGE?await be(o,e.url):e.type===I.VIDEO?await ge(o,e.url):e.type===I.AUDIO&&await Pe(o,e.url,{title:e.name,duration:e.duration,previewImageUrl:e.thumbnail,prompt:e.prompt,mv:e.modelName,clipId:e.clipId,providerTaskId:e.providerTaskId}),k.success(l("toolbar.assetInserted")||"素材已插入到画板"),x(!1),s()}catch(r){console.error("Failed to insert asset:",r),k.error(l("toolbar.assetInsertFailed")||"插入素材失败")}},G=e=>new Promise(r=>{const i=new Image;i.onload=()=>{const n=xe(i.naturalWidth,i.naturalHeight,Te.MEDIA_MAX_SIZE);r(n)},i.onerror=()=>r({width:400,height:400}),i.src=e}),H=async e=>{const r=new Map;let i=0;const n=Math.min(je,e.length),d=async()=>{const h=i;i+=1;const t=e[h];t&&(r.set(t.url,await G(t.url)),await d())};return await Promise.all(Array.from({length:n},()=>d())),r},O=async e=>{var d,h;if(e.length===0)return;const r=e.filter(t=>t.type===I.IMAGE),i=await H(r);Ie("[CanvasInsertion][Toolbar] batch assets begin",{source:"quick-creation-toolbar",strategy:"shared-batch-layout",assetsCount:e.length,assetTypes:e.map(t=>t.type),zoom:((d=o==null?void 0:o.viewport)==null?void 0:d.zoom)||1});const n=await Me({items:e.map(t=>t.type===I.IMAGE?{type:"image",content:t.url,dimensions:i.get(t.url)}:t.type===I.VIDEO?{type:"video",content:t.url}:{type:"audio",content:t.url,metadata:{title:t.name,duration:t.duration,previewImageUrl:t.thumbnail,prompt:t.prompt,mv:t.modelName,clipId:t.clipId,providerTaskId:t.providerTaskId}}),horizontalGap:30,verticalGap:40});if(n.success){const t=((h=n.data)==null?void 0:h.insertedCount)??e.length;k.success(`已成功插入 ${t} 个素材到画板`)}else k.error(n.error||"插入素材失败");x(!1),s()},Y=()=>{if(u(),S){S({mode:U.SELECT,onSelect:L,onSelectMultiple:O,selectButtonText:l("toolbar.insert")||"插入",batchSelectButtonText:"批量插入画布"}),s();return}x(!0)},[D,Q]=c.useState(re.feltTipPen),X=300,T=c.useRef(null),g=c.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]);c.useEffect(()=>()=>{g()},[g]);const _=(e,r,i,n)=>a.jsxs(pe,{open:M[r],sideOffset:12,onOpenChange:d=>{d||u()},placement:"bottom",children:[a.jsx(me,{asChild:!0,children:a.jsx("div",{onPointerEnter:()=>{g(),T.current=setTimeout(()=>{C(r)},X)},onPointerLeave:()=>{g()},children:a.jsx(P,{type:"icon",visible:!0,selected:M[r],icon:e,"aria-label":i,"data-track":`quick_toolbar_click_${r}`,onPointerDown:()=>{g(),C(r),E(o),r==="freehand"&&(y(o,w.dnd),f.updatePointerType(o,D),m(D))},onPointerUp:()=>{r==="freehand"&&y(o,w.drawing)}})})}),a.jsx(he,{container:B,style:{zIndex:fe.POPOVER},className:"quick-toolbar-popover",children:n})]});return b?a.jsxs(a.Fragment,{children:[a.jsx(ke,{padding:1,className:`quick-creation-toolbar ${oe}`,ref:v.setFloating,style:F,children:a.jsxs(ve.Row,{gap:1,children:[a.jsx(P,{type:"icon",visible:!0,icon:a.jsx(ne,{}),"aria-label":l("toolbar.text"),"data-track":"quick_toolbar_click_text",onPointerUp:q}),a.jsx(P,{type:"icon",visible:!0,icon:a.jsx(ie,{size:24}),"aria-label":l("toolbar.image"),"data-track":"quick_toolbar_click_image",onPointerUp:z}),a.jsx(P,{type:"icon",visible:!0,icon:a.jsx(se,{}),"aria-label":l("toolbar.mediaLibrary"),"data-track":"quick_toolbar_click_media_library",onPointerUp:Y}),_(a.jsx(le,{}),"freehand",l("toolbar.pen"),a.jsx(_e,{onPointerUp:e=>{u(),Q(e),f.updatePointerType(o,e),m(e),s()}})),_(a.jsx(ce,{}),"arrow",l("toolbar.arrow"),a.jsx(we,{onPointerUp:e=>{u(),f.updatePointerType(o,e),m(e),s()}})),_(a.jsx(de,{}),"shape",l("toolbar.shape"),a.jsx(Ee,{onPointerUp:e=>{u(),f.updatePointerType(o,e),m(e),s()}})),a.jsx(P,{type:"icon",visible:!0,icon:a.jsx(ue,{}),"aria-label":l("toolbar.mind"),"data-track":"quick_toolbar_click_mind",onPointerUp:V})]})}),j&&a.jsx(c.Suspense,{fallback:null,children:a.jsx(Ae,{isOpen:j,onClose:()=>{x(!1)},mode:U.SELECT,onSelect:L,onSelectMultiple:O,selectButtonText:l("toolbar.insert")||"插入",batchSelectButtonText:"批量插入画布"})})]}):null};export{Ne as QuickCreationToolbar};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ai-chat-DbjmzngX.css","./tool-windows-DW-CDfPc.css","./batch-image-generation-DuPmleAE.css","./bootstrap-5wOMkP8H.css","./ttd-dialog-submit-shortcut-DyioEoKX.css","./useCharacters-DRBoWvvj.css","./character-Bo9jcTNu.css","./ResizableDivider-ClzYJk-6.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as Et}from"./startup-runtime-BrfuwjQS.js";import{P as e,a8 as t,ab as it,gh as Ds,co as bt,dF as Ls,bP as $s,dV as is,n8 as He,m6 as Vs,nI as Os,e$ as Fs,dU as Us,nV as Gs,gr as Ks,nW as Dt,fq as ls,fx as Ws,eN as cs,e8 as qs,nk as Bs,f1 as Hs,bm as xt,Q as kt,el as ds,ep as Xs,T as We,ao as Ne,aD as Se,nb as Js,c$ as Qs,eU as Ys,c5 as Lt,nX as Zs,eP as ve,b9 as en,ba as tn,nY as sn,mU as nn,en as us,eo as Je,ew as Fe,et as $e,ey as vt,ex as Le,f3 as Te,nZ as $t,gA as Pt,cm as Mt,R as Ie,nq as on,n_ as lt,aE as Ve,n$ as an,f2 as ms,nL as fs,nN as ps,c6 as at,o0 as rn,dc as Tt,o1 as ln,o2 as It,nC as cn,kH as dn,o3 as yt,o4 as Vt,ns as hs,o5 as Ot,o6 as un,o7 as Ft,o8 as mn,o9 as Ut,oa as Gt,kh as wt,kd as Kt,ke as Wt,gc as qt,gd as Bt,gC as Ht,ak as fn,bk as pn,at as hn,nQ as Xt,ob as Jt}from"./ai-chat-B-XdoWBQ.js";import{ap as gn,aq as bn,ar as xn,p as gs}from"./tool-windows-BnDZa9FH.js";import{u as Nt,r as vn,g as bs,s as xs}from"./prompt-utils-C_mjEqkz.js";import{u as vs,C as In,V as yn,a as wn}from"./useCharacters-6u0Wuwt4.js";/* empty css */import{R as Is}from"./ResizableDivider-D1jgqdmh.js";import{a as Qt,g as Cn,c as Sn}from"./image-task-prefill-DtECrkJn.js";import{b as Yt}from"./mj-params-M-7csAp7.js";import{g as _n}from"./bootstrap-DadYvnge.js";import{m as kn}from"./frame-size-matcher-2sxA9X-P.js";import"./startup-app-9gZEGv85.js";const Zt=(n,s,o)=>{const l=o==="image"?{isGenerating:n,imageLoading:s}:{isGenerating:n,videoLoading:s};window.dispatchEvent(new CustomEvent("ai-generation-state-change",{detail:l}))},ys=(n,s,o)=>{e.useEffect(()=>{const l=r=>{(r.metaKey||r.ctrlKey)&&r.key==="Enter"&&(r.preventDefault(),!n&&s.trim()&&o())};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[n,s,o])},ws=n=>{const[s,o]=e.useState(!1),[l,r]=e.useState(!1),d=e.useCallback(k=>{o(k),Zt(k,l,n)},[l,n]),I=e.useCallback(k=>{r(k),Zt(s,k,n)},[s,n]);return{isGenerating:s,isLoading:l,updateIsGenerating:d,updateIsLoading:I}},Tn=(n,s,o)=>s==="image"?n==="zh"?"一只可爱的小猫坐在窗台上,阳光透过窗户洒在它的毛发上,背景是温馨的家居环境":"A cute kitten sitting on a windowsill, with sunlight streaming through the window onto its fur, with a cozy home environment in the background":o==="sora"?n==="zh"?"描述视频内容,输入 @ 可引用已创建的角色,如 @username 在海边漫步...":"Describe video content, type @ to reference created characters, e.g. @username walking on the beach...":n==="zh"?"生成一个美丽的日出场景,阳光从山峰后缓缓升起,云朵轻柔地飘动":"Generate a beautiful sunrise scene where the sun slowly rises from behind mountains with clouds gently floating",jn=[1,2,3,4,5,10,20,50,100],En="aitu_image_generation_quantity",Pn="aitu_video_generation_quantity",Ct=100,Cs=({language:n,type:s,isGenerating:o,hasGenerated:l,canGenerate:r,onGenerate:d,onReset:I,leftContent:k})=>{const E=s==="video"?Pn:En,[a,g]=e.useState(()=>{try{const i=localStorage.getItem(E);if(i){const w=parseInt(i,10);if(!isNaN(w)&&w>=1&&w<=Ct)return w}}catch{}return 1}),[N,$]=e.useState(!1),[f,S]=e.useState(()=>a.toString()),M=e.useRef(null);e.useEffect(()=>{S(a.toString());try{localStorage.setItem(E,a.toString())}catch{}},[a,E]),e.useEffect(()=>{const i=w=>{M.current&&!M.current.contains(w.target)&&($(!1),C())};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[f]);const C=()=>{let i=parseInt(f,10);(isNaN(i)||i<1)&&(i=1),i>Ct&&(i=Ct),S(i.toString()),g(i)},G=i=>{const w=i.target.value;(w===""||/^\d*$/.test(w))&&S(w)},Z=i=>{g(i),S(i.toString()),$(!1)},K=()=>{o||$(!N)},ee=()=>{d(a)};return t.jsxs("div",{className:"section-actions unified-action-bar",children:[k&&t.jsx("div",{className:"action-bar-left",children:k}),t.jsxs("div",{className:`unified-action-box ${o?"is-generating":""} ${r?"can-generate":""}`,children:[t.jsxs("div",{className:"quantity-section",ref:M,children:[t.jsx(it,{content:n==="zh"?"生成数量":"Quantity",theme:"light",children:t.jsxs("div",{className:`quantity-control ${N?"is-open":""} ${o?"is-disabled":""}`,children:[t.jsx("input",{type:"text",inputMode:"numeric",value:f,onChange:G,onBlur:C,"data-track":"ai_click_quantity_input",onClick:()=>!o&&$(!0),disabled:o,className:"quantity-input"}),t.jsx("button",{type:"button","data-track":"ai_click_quantity_toggle",onClick:i=>{i.stopPropagation(),K()},disabled:o,className:"quantity-toggle",children:t.jsx(Ds,{className:`quantity-icon ${N?"is-open":""}`})})]})}),N&&t.jsxs("div",{className:"quantity-dropdown",children:[t.jsx("div",{className:"quantity-dropdown-header",children:n==="zh"?"选择数量":"Select Quantity"}),jn.map(i=>t.jsxs("button",{type:"button","data-track":"ai_click_quantity_select",onClick:()=>Z(i),className:`quantity-option ${a===i?"is-selected":""}`,children:[t.jsxs("span",{children:[i," ",s==="video"?n==="zh"?"个":i>1?"videos":"video":n==="zh"?"张":i>1?"images":"image"]}),a===i&&t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})]},i))]})]}),t.jsx("div",{className:"action-divider"}),t.jsx("button",{"data-track":"ai_click_generate",onClick:ee,disabled:o||!r,className:`generate-button ${o?"loading":""}`,children:o?n==="zh"?"生成中...":"Generating...":l?n==="zh"?"重新生成":"Regenerate":s==="video"?n==="zh"?"生成视频":"Generate Video":n==="zh"?"生成":"Generate"})]}),t.jsx(it,{content:n==="zh"?"重置表单":"Reset form",theme:"light",children:t.jsx(bt,{"data-track":"ai_click_reset",onClick:I,disabled:o,variant:"text",shape:"circle",icon:t.jsx(Ls,{}),className:"action-button--reset-subtle"})})]})},Ss=({error:n})=>n?t.jsx("div",{className:"form-error",children:n}):null,_s=({visible:n,query:s,position:o,showBelow:l=!1,selectedIndex:r,onSelect:d,onClose:I})=>{const{completedCharacters:k,isLoading:E}=vs(),a=e.useRef(null),g=e.useMemo(()=>{if(!s)return k;const f=s.toLowerCase();return k.filter(S=>S.username.toLowerCase().includes(f))},[k,s]);e.useEffect(()=>{if(!n||!a.current)return;const f=a.current.querySelector(".character-mention-popup__item--selected");f&&f.scrollIntoView({block:"nearest"})},[n,r]),e.useEffect(()=>{if(!n)return;const f=S=>{a.current&&!a.current.contains(S.target)&&I()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[n,I]);const N=e.useCallback(f=>{$s.track("character_used_in_prompt",{characterId:f.id,username:f.username}),d(f)},[d]);if(!n)return null;const $={position:"fixed",top:o.top,left:o.left,transform:l?"none":"translateY(-100%)",zIndex:is.DROPDOWN_PORTAL,maxHeight:"200px",overflowY:"auto"};return E?t.jsx("div",{ref:a,className:"character-mention-popup",style:$,children:t.jsx("div",{className:"character-mention-popup__empty",children:"加载中..."})}):g.length===0?t.jsx("div",{ref:a,className:"character-mention-popup",style:$,children:t.jsx("div",{className:"character-mention-popup__empty",children:s?`未找到 "${s}" 相关角色`:"暂无可用角色"})}):t.jsx("div",{ref:a,className:"character-mention-popup",style:$,children:g.map((f,S)=>t.jsxs("div",{className:`character-mention-popup__item ${S===r?"character-mention-popup__item--selected":""}`,onClick:()=>N(f),"data-track":"character_click_mention",children:[t.jsx("div",{className:"character-mention-popup__item-avatar",children:t.jsx(In,{characterId:f.id,profilePictureUrl:f.profilePictureUrl,alt:f.username})}),t.jsxs("span",{className:"character-mention-popup__item-name",children:["@",f.username]})]},f.id))})},Mn={visible:!1,query:"",position:{top:0,left:0},showBelow:!1,startIndex:-1,selectedIndex:0};function ks({enabled:n=!0,onPromptChange:s,prompt:o}){const[l,r]=e.useState(Mn),d=e.useRef(null),{completedCharacters:I}=vs(),k=e.useCallback(f=>{if(!d.current)return{top:0,left:0,showBelow:!1};const S=d.current,M=S.getBoundingClientRect(),C=document.createElement("div"),G=window.getComputedStyle(S),Z=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","lineHeight","textTransform","wordSpacing","whiteSpace","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxSizing"];C.style.position="absolute",C.style.top="0",C.style.left="-9999px",C.style.visibility="hidden",C.style.whiteSpace="pre-wrap",C.style.overflowWrap="break-word",C.style.overflow="hidden",C.style.width=`${S.clientWidth}px`,Z.forEach(H=>{C.style[H]=G.getPropertyValue(H.replace(/([A-Z])/g,"-$1").toLowerCase())}),document.body.appendChild(C);let K=0,ee=0;try{const H=S.value.substring(0,f),Q=document.createTextNode(H),re=document.createElement("span");re.textContent="",C.appendChild(Q),C.appendChild(re);const ce=re.getBoundingClientRect(),F=C.getBoundingClientRect();K=ce.top-F.top,ee=ce.left-F.left}finally{document.body.removeChild(C)}const i=S.scrollTop,w=parseInt(G.lineHeight)||20;let _=M.top+K-i,y=M.left+ee;const R=240,P=window.innerWidth;y+R>P-16&&(y=P-R-16),y<16&&(y=16);const je=_<220+16;return je?_=_+w+4:_=_-48,{top:_,left:y,showBelow:je}},[]),E=e.useCallback((f,S)=>{if(!n)return;const M=f.substring(0,S),C=M.lastIndexOf("@");if(C===-1){r(ee=>({...ee,visible:!1}));return}const G=C>0?f[C-1]:" ";if(!/\s/.test(G)&&C!==0){r(ee=>({...ee,visible:!1}));return}const Z=M.substring(C+1);if(Z.includes(" ")){r(ee=>({...ee,visible:!1}));return}const K=k(S);r({visible:!0,query:Z,position:{top:K.top,left:K.left},showBelow:K.showBelow,startIndex:C,selectedIndex:0})},[n,k]),a=e.useCallback(f=>{var Z;if(l.startIndex===-1)return;const S=o.substring(0,l.startIndex),M=((Z=d.current)==null?void 0:Z.selectionStart)||o.length,C=o.substring(M),G=`${S}@${f.username} ${C}`;s(G),r(K=>({...K,visible:!1})),setTimeout(()=>{if(d.current){const K=S.length+f.username.length+2;d.current.focus(),d.current.setSelectionRange(K,K)}},0)},[l.startIndex,o,s]),g=e.useCallback(f=>{if(!l.visible)return;const S=l.query?I.filter(M=>M.username.toLowerCase().includes(l.query.toLowerCase())):I;switch(f.key){case"ArrowDown":f.preventDefault(),r(M=>({...M,selectedIndex:Math.min(M.selectedIndex+1,S.length-1)}));break;case"ArrowUp":f.preventDefault(),r(M=>({...M,selectedIndex:Math.max(M.selectedIndex-1,0)}));break;case"Enter":case"Tab":S.length>0&&(f.preventDefault(),a(S[l.selectedIndex]));break;case"Escape":f.preventDefault(),r(M=>({...M,visible:!1}));break}},[l,I,a]),N=e.useCallback((f,S)=>{s(f),E(f,S)},[s,E]),$=e.useCallback(()=>{r(f=>({...f,visible:!1}))},[]);return{mentionState:l,setMentionState:r,textareaRef:d,completedCharacters:I,handleTextChange:N,handleKeyDown:g,handleCharacterSelect:a,closeMentionPopup:$,calculateMentionPosition:k}}const Ts=({prompt:n,onPromptChange:s,presetPrompts:o,language:l,type:r,disabled:d=!1,onError:I,enableMention:k=!0,videoProvider:E})=>{const[a,g]=e.useState(!1),N=e.useRef(null),$=e.useRef(null),[f,S]=e.useState(null),[M,C]=e.useState(0),{imageHistory:G,videoHistory:Z}=Nt();e.useEffect(()=>{if(typeof He.subscribeChanges=="function")return He.subscribeChanges(()=>{C(F=>F+1)})},[]);const K=e.useMemo(()=>vn({generationType:r,language:l,promptContents:o,imageHistory:G,videoHistory:Z}),[G,l,r,o,M,Z]),ee=k&&r==="video"&&E==="sora",{mentionState:i,textareaRef:w,handleTextChange:_,handleKeyDown:y,handleCharacterSelect:R,closeMentionPopup:P}=ks({enabled:ee,onPromptChange:s,prompt:n}),ae=e.useCallback(()=>{if($.current&&a){const F=$.current.getBoundingClientRect(),T=8,W=320,j=400,ye=window.innerHeight-F.top+4,oe=Math.min(W,window.innerWidth-T*2),he=window.innerWidth-F.right,Re=window.innerWidth-oe-T,ge=Math.max(Math.min(he,Re),T),le=Math.min(j,F.top-T,window.innerHeight*.45);S({bottom:ye,right:ge,maxHeight:le})}},[a]);e.useEffect(()=>{if(a)return ae(),window.addEventListener("scroll",ae,!0),window.addEventListener("resize",ae),()=>{window.removeEventListener("scroll",ae,!0),window.removeEventListener("resize",ae)}},[a,ae]),e.useEffect(()=>{const F=T=>{const W=T.target;if(N.current&&!N.current.contains(W)){const j=document.querySelector(".preset-prompt-panel-portal");j!=null&&j.contains(W)||g(!1)}};if(a)return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[a]);const je=e.useCallback(F=>{const T=typeof F=="string"?F:F.content;s(T),I==null||I(null),g(!1)},[s,I]),H=e.useCallback(F=>{const T=K.find(W=>W.id===F);T&&(T.pinned?He.unpinPrompt(r,T.content):He.pinPrompt(r,T.content),C(W=>W+1))},[r,K]),Q=e.useCallback(F=>{const T=K.find(W=>W.id===F);T&&(He.deletePrompt(r,T.content),C(W=>W+1))},[r,K]),re=e.useCallback(F=>{const T=F.target.value,W=F.target.selectionStart||0;_(T,W),I==null||I(null)},[_,I]);e.useEffect(()=>{r!=="video"&&P()},[r,P]);const ce=()=>{if(!a||!f)return null;const F=l==="zh"?`${r==="image"?"图片":"视频"}描述预设`:`${r==="image"?"Image":"Video"} Description Presets`,T=t.jsx("div",{className:"preset-prompt-panel-portal",style:{position:"fixed",bottom:f.bottom,right:f.right,zIndex:is.DIALOG_POPOVER,"--panel-max-width":"calc(100vw - 16px)","--panel-max-height":`${f.maxHeight}px`},children:t.jsx(Fs,{title:F,items:K,onSelect:je,onTogglePin:H,onDelete:Q,language:l,disabled:d,showCount:!0})});return Us.createPortal(T,document.body)};return t.jsxs("div",{className:"form-field form-field--prompt",children:[t.jsxs("div",{className:"form-label-with-icon",children:[t.jsx("label",{className:"form-label",children:l==="zh"?`${r==="image"?"图片":"视频"}描述`:`${r==="image"?"Image":"Video"} Description`}),t.jsx("div",{className:"textarea-with-preset",children:t.jsxs("div",{className:"preset-tooltip-container",ref:N,children:[t.jsx("button",{ref:$,type:"button",className:"preset-icon-button",disabled:d,onClick:()=>g(!a),children:t.jsx(Vs,{size:16})}),ce()]})})]}),t.jsxs("div",{className:"prompt-textarea-wrapper",children:[t.jsx("textarea",{ref:w,className:"form-textarea",value:n,onChange:re,onKeyDown:y,placeholder:Tn(l,r,E),rows:4,disabled:d}),t.jsx(Os,{className:"prompt-optimize-button",originalPrompt:n,language:l,scenarioId:r==="image"?"tool.image":"tool.video",disabled:d,tooltipPlacement:"top",allowStructuredMode:!0,onApply:F=>{s(F),I==null||I(null)}})]}),ee&&t.jsx(_s,{visible:i.visible,query:i.query,position:i.position,showBelow:i.showBelow,selectedIndex:i.selectedIndex,onSelect:R,onClose:P})]})};function js(){return Gs("scene")}function es(n,s){return{id:js(),order:n,duration:s,prompt:""}}function Nn(n,s,o=1){if(n.length===0)return{valid:!1,error:"至少需要一个场景"};for(const r of n){if(r.duration<o)return{valid:!1,error:`场景 ${r.order} 时长不能少于 ${o} 秒`};if(r.duration>s)return{valid:!1,error:`场景 ${r.order} 时长不能超过 ${s} 秒`}}const l=n.find(r=>!r.prompt.trim());return l?{valid:!1,error:`场景 ${l.order} 需要填写提示词`}:{valid:!0}}function Rn(n){return n.sort((s,o)=>s.order-o.order).map((s,o)=>`Shot ${o+1}:
|
|
3
|
-
duration: ${s.duration}sec
|
|
4
|
-
Scene: ${s.prompt.trim()}`).join(`
|
|
5
|
-
|
|
6
|
-
`)}function An(n){const s=/Shot\s+(\d+):\s*\n\s*duration:\s*([\d.]+)\s*sec\s*\n\s*Scene:\s*([^\n]+(?:\n(?!Shot\s+\d+:)[^\n]*)*)/gi,o=[];let l;for(;(l=s.exec(n))!==null;){const r=parseInt(l[1],10),d=parseFloat(l[2]),I=l[3].trim();o.push({id:js(),order:r,duration:d,prompt:I})}return o.length===0?null:o.sort((r,d)=>r.order-d.order)}const zn=({value:n,onChange:s,placeholder:o,disabled:l=!1,autoFocus:r=!1,enableMention:d=!0})=>{const{mentionState:I,textareaRef:k,handleTextChange:E,handleKeyDown:a,handleCharacterSelect:g,closeMentionPopup:N}=ks({enabled:d,onPromptChange:s,prompt:n}),$=e.useCallback(f=>{const S=f.target.value,M=f.target.selectionStart||0;E(S,M)},[E]);return e.useEffect(()=>{r&&k.current&&k.current.focus()},[r,k]),t.jsxs("div",{className:"scene-prompt-input",children:[t.jsx("textarea",{ref:k,className:"scene-prompt-input__textarea",value:n,onChange:$,onKeyDown:a,placeholder:o,disabled:l,rows:3}),d&&t.jsx(_s,{visible:I.visible,query:I.query,position:I.position,showBelow:I.showBelow,selectedIndex:I.selectedIndex,onSelect:g,onClose:N})]})},Dn=({enabled:n,onEnabledChange:s,totalDuration:o,maxScenes:l,minSceneDuration:r,scenes:d,onScenesChange:I,disabled:k=!1})=>{const[E,a]=e.useState(null),g=e.useRef(null),N=d.map(i=>i.id).join("|");e.useEffect(()=>{if(!n||d.length===0)return;!(E?d.some(w=>w.id===E):!1)&&E!==d[0].id&&a(d[0].id)},[n,N,d,E]);const $=e.useCallback(()=>{if(d.length>=l)return;const i=d.reduce((R,P)=>R+P.duration,0),w=o-i;let _=Math.max(r,w/2);_=parseFloat(_.toFixed(1)),_<r&&(_=r);const y=es(d.length+1,_);I([...d,y]),a(y.id),setTimeout(()=>{var R;(R=g.current)==null||R.scrollIntoView({behavior:"smooth"})},100)},[d,l,o,r,I]),f=e.useCallback(i=>{var y;if(d.length<=1)return;const _=d.filter(R=>R.id!==i).map((R,P)=>({...R,order:P+1}));I(_),E===i&&a(((y=_[0])==null?void 0:y.id)||null)},[d,I,E]),S=e.useCallback(i=>{const w=d.filter(_=>_.id!==i).reduce((_,y)=>_+y.duration,0);return Math.max(r,o-w)},[d,o,r]),M=e.useCallback(i=>{const w=S(i),_=[],y=.1;for(let R=r;R<=w+.001;R+=y){const P=parseFloat(R.toFixed(1));P<=w&&_.push({label:`${P}`,value:P})}return _},[r,S]),C=e.useCallback((i,w)=>{const _=typeof w=="string"?parseFloat(w):w;if(isNaN(_))return;const y=S(i),R=d.map(P=>{if(P.id===i){const ae=Math.max(r,Math.min(_,y)),je=parseFloat(ae.toFixed(1));return je===P.duration?P:{...P,duration:je}}return P});R.every((P,ae)=>P===d[ae])||I(R)},[d,r,S,I]),G=e.useCallback((i,w)=>{const _=d.find(R=>R.id===i);if((_==null?void 0:_.prompt)===w)return;const y=d.map(R=>R.id===i?{...R,prompt:w}:R);I(y)},[d,I]),Z=e.useCallback(i=>{if(s(i),i&&d.length===0){const w=es(1,o);I([w]),a(w.id)}},[d,o,s,I]),K=e.useCallback(i=>{a(i)},[]),ee=d.length<l;return t.jsxs("div",{className:"storyboard-editor",children:[t.jsxs("div",{className:"storyboard-editor__header",children:[t.jsxs("div",{className:"storyboard-editor__toggle",children:[t.jsx(Ks,{value:n,onChange:Z,disabled:k,size:"small"}),t.jsxs("div",{className:"storyboard-editor__title",children:[t.jsx("span",{className:"storyboard-editor__title-text",children:"故事场景模式"}),t.jsx("span",{className:"storyboard-editor__title-desc",children:"定义多个场景及其时长"})]})]}),n&&t.jsx("span",{className:"storyboard-editor__new-badge",children:"NEW"})]}),n&&t.jsxs("div",{className:"storyboard-editor__content",children:[t.jsxs("div",{className:"storyboard-editor__section-header",children:[t.jsx("span",{className:"storyboard-editor__section-title",children:"场景列表"}),t.jsxs("span",{className:"storyboard-editor__section-hint",children:["共 ",d.length," 个场景,已用 ",d.reduce((i,w)=>i+w.duration,0).toFixed(1)," 秒 / 总时长 ",o," 秒"]})]}),t.jsxs("div",{className:"storyboard-editor__scenes",children:[d.map((i,w)=>{const _=E===i.id,y=w===d.length-1;return t.jsxs("div",{className:`storyboard-editor__scene-wrapper ${_?"is-selected":""}`,children:[t.jsx("div",{className:`storyboard-editor__timeline-line ${y?"is-last":""}`}),t.jsx("div",{className:`storyboard-editor__timeline-node ${_?"is-selected":""}`,children:_?w+1:""}),!_&&t.jsxs("div",{className:"storyboard-editor__scene storyboard-editor__scene--compact",onClick:()=>K(i.id),children:[t.jsx("span",{className:"storyboard-editor__scene-index",children:w+1}),t.jsx("div",{className:"storyboard-editor__scene-preview",children:t.jsx("p",{className:"storyboard-editor__scene-preview-text",children:i.prompt||"暂无场景描述..."})}),t.jsxs("div",{className:"storyboard-editor__scene-duration-badge",children:[t.jsx(Dt,{size:"12px"}),t.jsxs("span",{children:[i.duration,"s"]})]}),t.jsx(ls,{className:"storyboard-editor__scene-arrow",size:"14px"})]}),_&&t.jsxs("div",{className:"storyboard-editor__scene storyboard-editor__scene--expanded",children:[t.jsxs("div",{className:"storyboard-editor__scene-header",children:[t.jsx("div",{className:"storyboard-editor__scene-info",children:t.jsxs("span",{className:"storyboard-editor__scene-label",children:[t.jsx("span",{className:"storyboard-editor__active-indicator"}),"场景 ",w+1]})}),t.jsxs("div",{className:"storyboard-editor__scene-controls",children:[t.jsx(Dt,{className:"storyboard-editor__time-icon"}),t.jsx(Ws,{value:parseFloat(i.duration.toFixed(1)),onChange:R=>C(i.id,R),disabled:k,className:"storyboard-editor__duration-select",size:"small",options:M(i.id),filterable:!0,creatable:!0,popupProps:{overlayClassName:"storyboard-editor__duration-popup"}}),d.length>1&&t.jsx(bt,{theme:"default",variant:"text",size:"small",icon:t.jsx(cs,{}),onClick:R=>{R.stopPropagation(),f(i.id)},disabled:k,className:"storyboard-editor__scene-delete"})]})]}),t.jsx("div",{className:"storyboard-editor__scene-prompt",children:t.jsx(zn,{value:i.prompt,onChange:R=>G(i.id,R),placeholder:`描述场景 ${w+1} 的内容,输入 @ 可引用角色`,disabled:k,autoFocus:!0,enableMention:!0})})]})]},i.id)}),t.jsx("div",{ref:g})]}),ee&&t.jsx(bt,{theme:"default",variant:"dashed",size:"medium",icon:t.jsx(qs,{}),onClick:$,disabled:k,className:"storyboard-editor__add-btn",block:!0,children:"添加场景"})]})]})},Es="aitu-dialog-task-list-width-",Rt=240,At=800,Ln=()=>{const n=Math.round(660);return Math.max(Rt,Math.min(At,n))},Ps=n=>{try{const s=localStorage.getItem(Es+n);if(s){const o=parseInt(s,10);if(!isNaN(o)&&o>=Rt&&o<=At)return o}}catch{}return Ln()},ts=(n,s)=>{try{localStorage.setItem(Es+n,s.toString())}catch{}},Ms=({isRightPanelVisible:n,onToggleRightPanel:s,onWidthChange:o,rightPanelWidth:l,minWidth:r=Rt,maxWidth:d=At,onResizeStart:I,onResizeEnd:k,language:E="zh",disabled:a=!1,storageKey:g="image"})=>{const[N,$]=e.useState(!1),f=e.useRef(0),S=e.useRef(0);e.useEffect(()=>(N?(document.body.style.userSelect="none",document.body.style.cursor="col-resize"):(document.body.style.userSelect="",document.body.style.cursor=""),()=>{document.body.style.userSelect="",document.body.style.cursor=""}),[N]);const M=e.useCallback(G=>{if(a||!n)return;G.preventDefault(),G.stopPropagation(),$(!0),f.current=G.clientX,S.current=l,I==null||I();const Z=ee=>{const i=f.current-ee.clientX,w=Math.max(r,Math.min(d,S.current+i));o(w)},K=()=>{$(!1),k==null||k(),S.current+(f.current-document.body.getBoundingClientRect().left),ts(g,l),document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",K)};document.addEventListener("mousemove",Z),document.addEventListener("mouseup",K)},[a,n,l,r,d,o,I,k,g]);e.useEffect(()=>{!N&&n&&ts(g,l)},[l,N,n,g]);const C=n?E==="zh"?"隐藏任务列表":"Hide Task List":E==="zh"?"显示任务列表":"Show Task List";return t.jsxs("div",{className:`resizable-divider ${N?"is-dragging":""} ${n?"":"is-collapsed"} ${a?"is-disabled":""}`,onMouseDown:M,children:[t.jsx("div",{className:"resizable-divider__bar"}),t.jsx(it,{content:C,placement:"left",children:t.jsx("button",{type:"button",className:"resizable-divider__toggle",onClick:G=>{G.stopPropagation(),s()},"aria-label":C,children:n?t.jsx(ls,{size:"14px"}):t.jsx(Bs,{size:"14px"})})})]})},Ns=({storageKey:n,language:s})=>{const[o,l]=e.useState(()=>{try{return localStorage.getItem(n)!=="false"}catch{return!0}}),r=e.useCallback(d=>{l(d);try{localStorage.setItem(n,String(d))}catch{}},[n]);return t.jsx(it,{content:s==="zh"?"生成后自动插入画布":"Auto insert to canvas after generation",theme:"light",children:t.jsx(Hs,{checked:o,onChange:r,className:"auto-insert-checkbox"})})};function jt(n){try{return localStorage.getItem(n)!=="false"}catch{return!0}}function $n(n={}){const{taskType:s}=n,{tasks:o,isLoading:l}=gn(),{retryTask:r,deleteTask:d}=bn(),I=e.useMemo(()=>[...s?o.filter(g=>g.type===s):o].sort((g,N)=>N.createdAt-g.createdAt),[o,s]),k=e.useCallback(async()=>{},[]),E=e.useCallback(async()=>{if(xn(),!await xt.isAvailable())return;const g=await xt.getAllTasks();g.length>0&&kt.restoreTasks(g)},[]);return{tasks:I,isLoading:l,isLoadingMore:!1,hasMore:!1,totalCount:I.length,loadedCount:I.length,loadMore:k,refresh:E,retryTask:r,deleteTask:d}}let rt={prompt:"",imageCount:0,knowledgeContextCount:0};function Vn(n){rt={prompt:n.prompt,imageCount:n.imageCount,knowledgeContextCount:n.knowledgeContextCount}}function On(){rt={prompt:"",imageCount:0,knowledgeContextCount:0}}function Fn(){return rt.prompt.trim().length>0||rt.imageCount>0||rt.knowledgeContextCount>0}const Rs=({taskIds:n,taskType:s,onEditTask:o})=>{const{tasks:l,isLoading:r,isLoadingMore:d,hasMore:I,totalCount:k,loadedCount:E,loadMore:a,retryTask:g,deleteTask:N}=$n({taskType:s}),{board:$,openDialog:f}=ds(),{confirm:S,confirmDialog:M}=Xs(),[C,G]=e.useState(!1),[Z,K]=e.useState(null),[ee,i]=e.useState(!1),[w,_]=e.useState(0),[y,R]=e.useState("single"),[P,ae]=e.useState(""),[je,H]=e.useState(null),[Q,re]=e.useState(!1),ce=e.useMemo(()=>l.filter(u=>u.status===We.FAILED).length,[l]),F=e.useCallback(()=>{const u=l.filter(b=>b.status===We.FAILED);u.forEach(b=>N(b.id)),re(!1),Ne.success(`已清除 ${u.length} 个失败任务`)},[l,N]),T=(u,b)=>{var ue,v,_e,ke,De,be,we,Ce,ie,Ae,ze;if(!b.trim())return!0;const J=b.toLowerCase().split(/\s+/).filter(Boolean),z={[We.PENDING]:"处理中",[We.PROCESSING]:"处理中",[We.COMPLETED]:"已完成",[We.FAILED]:"失败",[We.CANCELLED]:"已取消"},V=[],ne=(ue=u.params)!=null&&ue.params&&typeof u.params.params=="object"?u.params.params:null;V.push(((v=u.params)==null?void 0:v.prompt)??""),V.push(((_e=u.params)==null?void 0:_e.model)??""),V.push(u.id??""),V.push(z[u.status]??String(u.status)),(ke=u.params)!=null&&ke.batchId&&V.push(String(u.params.batchId)),(De=u.params)!=null&&De.batchIndex&&V.push(String(u.params.batchIndex)),(be=u.params)!=null&&be.batchTotal&&V.push(String(u.params.batchTotal)),typeof(ne==null?void 0:ne.model_name)=="string"&&V.push(ne.model_name),typeof(ne==null?void 0:ne.mode)=="string"&&V.push(ne.mode),typeof(ne==null?void 0:ne.klingAction2)=="string"&&V.push(ne.klingAction2),(we=u.result)!=null&&we.format&&V.push(String(u.result.format)),(Ce=u.result)!=null&&Ce.width&&((ie=u.result)!=null&&ie.height)?V.push(`${u.result.width}x${u.result.height}`):(Ae=u.params)!=null&&Ae.width&&((ze=u.params)!=null&&ze.height)&&V.push(`${u.params.width}x${u.params.height}`);const de=V.join(" ").toLowerCase();return J.every(Y=>de.includes(Y))},W=e.useMemo(()=>{let u=l;return n&&n.length>0&&(u=u.filter(b=>n.includes(b.id))),P.trim()&&(u=u.filter(b=>T(b,P))),u.sort((b,J)=>J.createdAt-b.createdAt)},[l,n,P]),j=u=>{g(u)},ye=u=>{K(u),G(!0)},oe=()=>{Z&&N(Z),G(!1),K(null)},he=async u=>{const b=l.find(z=>z.id===u);if(!b)return;const J=sn(b);if(J.length!==0)try{const z=await nn(J);z.openedCount>0&&z.downloadedCount===0?Ne.success(z.openedCount>1?`已打开 ${z.openedCount} 个链接,请在新标签页下载`:"资源不支持直接下载,已打开链接"):Ne.success(b.type===Se.AUDIO?J.length>1?"多条音频已开始下载":"音频下载成功":J.length>1?"多图已开始下载":"下载成功")}catch(z){console.error("Download failed:",z),Ne.error("下载失败,请稍后重试")}},Re=async u=>{var J,z,V,ne;const b=l.find(de=>de.id===u);if(!((J=b==null?void 0:b.result)!=null&&J.url)&&!((V=(z=b==null?void 0:b.result)==null?void 0:z.urls)!=null&&V.length)||!$){console.warn("Cannot insert: task result or board not available"),Ne.warning("无法插入:白板未就绪");return}try{if(b.type===Se.IMAGE){const de=(ne=b.result.urls)!=null&&ne.length?b.result.urls:[b.result.url];for(const ue of de)await en($,ue);Ne.success(de.length>1?"多图已插入到白板":"图片已插入到白板")}else b.type===Se.VIDEO&&(await tn($,b.result.url),Ne.success("视频已插入到白板"))}catch(de){console.error("Failed to insert to board:",de),Ne.error(`插入失败: ${de instanceof Error?de.message:"未知错误"}`)}},ge=e.useCallback(async()=>Fn()?S({title:"覆盖当前输入?",description:"当前 AI 图片生成窗口已有提示词或参考图,继续会覆盖当前输入。",confirmText:"覆盖当前输入",cancelText:"取消",confirmTheme:"warning"}):!0,[S]),le=async u=>{const b=await xt.getTask(u)||kt.getTask(u)||l.find(J=>J.id===u);if(!b||b.type!==Se.IMAGE){Ne.warning("未找到可回填的图片任务");return}await ge()&&(o?o(b):f(ve.aiImageGeneration,Qt(b)),Ne.success("已回填历史提示词和参考图,请手动发送"))},fe=async u=>{var J,z;const b=await xt.getTask(u)||kt.getTask(u)||l.find(V=>V.id===u);if(!b){console.warn("Cannot edit: task not found");return}if(o){o(b);return}if(b.type===Se.IMAGE)f(ve.aiImageGeneration,Qt(b));else if(b.type===Se.VIDEO){const V={initialPrompt:b.params.prompt,initialDuration:typeof b.params.seconds=="string"?parseInt(b.params.seconds,10):b.params.seconds,initialModel:b.params.model,initialSize:b.params.size,initialImages:b.params.uploadedImages,initialResultUrl:(J=b.result)==null?void 0:J.url,initialResultUrls:(z=b.result)==null?void 0:z.urls};f(ve.aiVideoGeneration,V)}},m=u=>{const b=l.find(J=>J.id===u);b&&H(b)},O=e.useMemo(()=>{const u=new Set;return W.filter(b=>{var J,z,V,ne;return b.status!==We.COMPLETED||!((J=b.result)!=null&&J.url)&&!((V=(z=b.result)==null?void 0:z.urls)!=null&&V.length)||b.type!==Se.IMAGE&&b.type!==Se.VIDEO&&!(b.type===Se.AUDIO&&((ne=b.result)==null?void 0:ne.resultKind)!=="lyrics")||u.has(b.id)?!1:(u.add(b.id),!0)})},[W]),{previewMediaItems:te,taskIdToPreviewConfig:Ee}=e.useMemo(()=>{var J,z,V,ne,de,ue;const u=[],b=new Map;for(const v of O){const _e=u.length,ke=((J=v.result)==null?void 0:J.title)||v.params.title||((z=v.params.prompt)==null?void 0:z.substring(0,50))||"媒体预览";if(v.type===Se.AUDIO){const be=((ne=(V=v.result)==null?void 0:V.clips)==null?void 0:ne.filter(ie=>!!ie.audioUrl).map((ie,Ae)=>{var ze,Y,Ue;return{id:ie.clipId||ie.id||`${v.id}-${Ae}`,url:ie.audioUrl,type:"audio",title:ie.title||((ze=v.result)!=null&&ze.clips&&v.result.clips.length>1?`${ke} (${Ae+1}/${v.result.clips.length})`:ke),posterUrl:ie.imageLargeUrl||ie.imageUrl||((Y=v.result)==null?void 0:Y.previewImageUrl),duration:typeof ie.duration=="number"?ie.duration:(Ue=v.result)==null?void 0:Ue.duration,prompt:v.params.prompt,tags:typeof v.params.tags=="string"?v.params.tags:void 0,artist:v.params.model||v.params.mv||"Aitu",album:"Aitu Generated"}}))??[],we=(de=v.result.urls)!=null&&de.length?v.result.urls:v.result.url?[v.result.url]:[],Ce=be.length>0?be:we.map((ie,Ae)=>{var ze,Y;return{id:we.length>1?`${v.id}-${Ae}`:v.id,url:ie,type:"audio",title:we.length>1?`${ke} (${Ae+1}/${we.length})`:ke,posterUrl:(ze=v.result)==null?void 0:ze.previewImageUrl,duration:(Y=v.result)==null?void 0:Y.duration,prompt:v.params.prompt,tags:typeof v.params.tags=="string"?v.params.tags:void 0,artist:v.params.model||v.params.mv||"Aitu",album:"Aitu Generated"}});u.push(...Ce)}else{const be=(ue=v.result.urls)!=null&&ue.length?v.result.urls:[v.result.url],we=v.type===Se.VIDEO?"video":"image";for(let Ce=0;Ce<be.length;Ce++)u.push({id:be.length>1?`${v.id}-${Ce}`:v.id,url:we==="image"?Js(be[Ce]):be[Ce],type:we,title:be.length>1?`${ke} (${Ce+1}/${be.length})`:ke})}const De=u.length-_e;b.set(v.id,{mode:v.type===Se.AUDIO&&De>1?"compare":"single",index:v.type===Se.AUDIO&&De>1?Array.from({length:Math.min(De,4)},(be,we)=>_e+we):_e})}return{previewMediaItems:u,taskIdToPreviewConfig:b}},[O]),pe=e.useCallback(u=>{const b=Ee.get(u);b!==void 0&&(R(b.mode),_(b.index),i(!0))},[Ee]),D=e.useCallback(()=>{i(!1)},[]),U=P.trim()&&W.length===0&&l.length>0,X=k>0?k:l.length;return t.jsxs(t.Fragment,{children:[M,t.jsxs("div",{className:"dialog-task-list",children:[t.jsxs("div",{className:"dialog-task-list__header",children:[t.jsxs("div",{className:"dialog-task-list__header-main",children:[t.jsxs("h4",{children:["生成任务 (",X,")"]}),t.jsx("div",{className:"dialog-task-list__header-actions",children:ce>0&&t.jsx(it,{content:`清除全部失败任务 (${ce})`,theme:"light",children:t.jsx(bt,{size:"small",variant:"text",icon:t.jsx(cs,{}),onClick:()=>re(!0)})})})]}),t.jsx("div",{className:"dialog-task-list__search",children:t.jsx(Qs,{value:P,onChange:u=>ae(u),placeholder:"搜索任务(提示词/模型/...)",clearable:!0,prefixIcon:t.jsx(Ys,{}),size:"small"})})]}),t.jsx(yn,{tasks:W,onRetry:j,onDelete:ye,onDownload:he,onInsert:Re,onEdit:fe,onRegenerate:le,onPreviewOpen:pe,onExtractCharacter:m,hasMore:I,isLoadingMore:d,onLoadMore:a,totalCount:X,loadedCount:E,className:"dialog-task-list__content",emptyContent:t.jsx("div",{className:"dialog-task-list__empty",children:r?t.jsx("p",{children:"加载中..."}):U?t.jsx("p",{children:"未找到匹配的任务"}):t.jsx("p",{children:"暂无生成任务"})})})]}),t.jsx(Lt,{open:C,title:"确认删除",description:"确定要删除此任务吗?此操作无法撤销。",confirmText:"删除",cancelText:"取消",danger:!0,onOpenChange:G,onConfirm:oe}),t.jsx(Lt,{open:Q,title:"清除失败任务",description:`确定要清除全部 ${ce} 个失败任务吗?此操作无法撤销。`,confirmText:"清除",cancelText:"取消",danger:!0,onOpenChange:re,onConfirm:F}),t.jsx(Zs,{visible:ee,items:te,initialMode:y,initialIndex:w,onClose:D,showThumbnails:!0}),t.jsx(wn,{visible:!!je,task:je,onClose:()=>H(null),onCreateComplete:u=>{H(null)}})]})};function As(n){if(!n)return;if(n==="auto")return lt;const s=n.replace(/[xX]/g,":");return ln.some(o=>o.value===s)?s:void 0}function ht(n,s){return As(n.size)||s||lt}function ss(n,s,o){if(n.startsWith("mj")||!o)return s;const l=o===lt?"auto":Tt(o);return!l||!rn(n).some(r=>r.value===l)||s.size===l?s:{...s,size:l}}function ns(n){var o;const s=n.length===1?(o=n[0].maskImage)==null?void 0:o.trim():"";return s?{referenceImages:[n[0].url],generationMode:"image_edit",maskImage:s}:{}}function Un(n){return n.map(({maskImage:s,...o})=>o)}const Gn=({initialPrompt:n="",initialImages:s=[],initialKnowledgeContextRefs:o=[],selectedElementIds:l=[],initialWidth:r,initialHeight:d,initialResultUrl:I,initialAspectRatio:k,targetFrameId:E,targetFrameDimensions:a,pptSlideImage:g,pptSlidePrompt:N,pptReplaceElementId:$,selectedModel:f,selectedModelRef:S,onModelChange:M,onModelRefChange:C,externalBatchId:G,assetMetadata:Z,initialAutoInsertToCanvas:K,onDraftChange:ee}={})=>{var et,tt,mt;const i=us("image"),w=Je("image"),_=Fe(i,w.modelId,$e(w.profileId,w.modelId))||vt("image",w.modelId,$e(w.profileId,w.modelId)),[y,R]=e.useState((_==null?void 0:_.id)||((et=i[0])==null?void 0:et.id)||"gemini-2.5-flash-image-vip"),[P,ae]=e.useState(Le(_)||$e(w.profileId,w.modelId)),je=Te((_==null?void 0:_.id)||((tt=i[0])==null?void 0:tt.id)||"gemini-2.5-flash-image-vip",Le(_)||$e(w.profileId,w.modelId)),H=$t((_==null?void 0:_.id)||((mt=i[0])==null?void 0:mt.id)||"gemini-2.5-flash-image-vip",je),[Q,re]=e.useState(n),[ce,F]=e.useState(o),[T,W]=e.useState(H.extraParams),j=e.useMemo(()=>{if(Fe(i,y,P)||!y)return i;const L=vt("image",y,P);return L?[L,...i]:i},[y,P,i]),[ye,oe]=e.useState(r||1024),[he,Re]=e.useState(d||1024),[ge,le]=e.useState(k||ht(H.extraParams,H.aspectRatio)),[fe,m]=e.useState(null),[O,te]=e.useState(s),[Ee,pe]=e.useState(!0),[D,U]=e.useState(()=>Ps("image")),[X,u]=e.useState("config"),b=e.useRef(null),{viewportWidth:J}=Pt(),z=J<=768,{imageHistory:V}=Nt(),[ne,de]=e.useState(0),{isGenerating:ue}=ws("image"),{language:v}=Mt(),{createTask:_e}=gs(),ke=e.useRef(!1);e.useEffect(()=>He.subscribeChanges(()=>{de(x=>x+1)}),[]);const De=y.startsWith("mj"),be=Ie.useMemo(()=>on(y).length>0,[y]),[we,Ce]=e.useState(!1);e.useEffect(()=>{if(we)return;const x=$t(y,Te(y,P)),L=k?ss(y,x.extraParams,k):x.extraParams;W(L),le(ht(L,k||x.aspectRatio))},[y,P,k,we]);const ie=e.useCallback((x,L)=>{if(!L||L==="default"){x==="size"&&le(lt),W(B=>{const q={...B};return delete q[x],q});return}x==="size"&&le(As(L)||lt),W(B=>({...B,[x]:L}))},[]),Ae=e.useCallback(x=>{U(x)},[]),ze=e.useCallback(()=>{pe(x=>!x)},[]),Y=Ie.useRef("");e.useEffect(()=>{if(we)return;const x=JSON.stringify({prompt:n,images:s==null?void 0:s.map(L=>L.url),knowledgeContextRefs:o.map(L=>L.noteId),elementIds:l,width:r,height:d,result:I,aspectRatio:k,targetFrameId:E,pptSlideImage:g,pptSlidePrompt:N,pptReplaceElementId:$});Y.current!==x&&(Y.current=x,re(n),F(o),te(s||[]),r&&oe(r),d&&Re(d),k&&(le(k),W(L=>ss(y,L,k))))},[n,s,o,l,r,d,I,k,E,g,N,$,we,y]);const Ue=e.useRef("");e.useEffect(()=>(Vn({prompt:Q,imageCount:O.length,knowledgeContextCount:ce.length}),On),[ce.length,Q,O.length]),e.useEffect(()=>{if(!ee)return;const x={prompt:Q,images:O.map(q=>({url:q.url,name:q.name})),aspectRatio:ge},L=JSON.stringify(x);if(Ue.current===L)return;const B=window.setTimeout(()=>{Ue.current!==L&&(Ue.current=L,ee(x))},200);return()=>{window.clearTimeout(B)}},[ge,ee,Q,O]),e.useEffect(()=>{const x=L=>{var q;const B=L.imageModelName||((q=j[0])==null?void 0:q.id)||"gemini-2.5-flash-image-vip";if(B!==y){R(B);const Pe=Fe(j,B,P);ae(Le(Pe)||null)}};return Ve.addListener(x),()=>Ve.removeListener(x)},[y,P,j]),e.useEffect(()=>{if(j.length===0)return;if(!Fe(j,y,P)){const L=j[0];R(L.id);const B=Le(L);ae(q=>q&&B&&q.profileId===B.profileId&&q.modelId===B.modelId?q:B)}},[y,P,j]),e.useEffect(()=>{if(!f)return;const x=Te(y,P),L=Te(f,S);if(x!==L){R(f);const B=Fe(j,f,S),q=Le(B)||S||null;ae(Pe=>Pe&&q&&Pe.profileId===q.profileId&&Pe.modelId===q.modelId?Pe:q)}},[y,P,f,S,j]),e.useEffect(()=>{!be&&Object.keys(T).length>0&&W({})},[be,T]),e.useEffect(()=>{an({currentModel:y,currentSelectionKey:Te(y,P),extraParams:T,aspectRatio:ge})},[y,P,T,ge]),e.useEffect(()=>(m(null),()=>{m(null)}),[]);const Qe=()=>{const x=It(y,{});re(""),W(x),te([]),F([]),m(null),le(ht(x)),u("config"),Ce(!1),window.dispatchEvent(new CustomEvent("ai-image-clear"))},ct=Ie.useMemo(()=>bs("image",v,V),[V,v,ne]),dt=!!(g||N!=null&&N.trim()),Ge=x=>{dt||(xs("image",x),de(L=>L+1))},ut=x=>{const L=x.params.model||y,B={...x.params.params||{},...x.params.size!==void 0?{size:x.params.size}:{},...x.params.resolution!==void 0?{resolution:x.params.resolution}:{},...x.params.quality!==void 0?{quality:x.params.quality}:{}},q=Object.keys(B).length>0?It(L,B):It(L,{});if(Ce(!0),u("config"),re(x.params.prompt||""),W(q),oe(x.params.width||1024),Re(x.params.height||1024),te(Cn(x)),F(Sn(x)),x.params.model){R(x.params.model),ae(x.params.modelRef||null);const Pe=Ve.get();Ve.update({...Pe,imageModelName:x.params.model})}le(ht(q,x.params.aspectRatio)),m(null)},Ye=async()=>Promise.all(O.map(async x=>{if(x.file)return new Promise((L,B)=>{const q=new FileReader;q.onload=()=>{L({type:"url",url:q.result,name:x.name,maskImage:x.maskImage})},q.onerror=B,q.readAsDataURL(x.file)});if(x.url)return{type:"url",url:x.url,name:x.name,maskImage:x.maskImage};throw new Error("Invalid image data")})),Ze=async(x=1)=>{const L=x;if(!ke.current){ke.current=!0;try{if(!Q||!Q.trim()){m(v==="zh"?"请输入图像描述":"Please enter image description");return}if(!cn("image",P||y)&&!await dn()){m(v==="zh"?"需要 API Key 才能生成图片":"API Key is required to generate images");return}De&&m(null);try{const B=typeof ye=="string"?parseInt(ye)||1024:ye,q=typeof he=="string"?parseInt(he)||1024:he,Pe=await Ye(),Xe=Un(Pe);if(L>1){const h=[],A=`batch_${Date.now()}`,se=y||Je("image").modelId,me=se.startsWith("mj")?[Q.trim(),Yt(T)].filter(Boolean).join(" "):(Q||"").trim(),xe=!se.startsWith("mj")&&Object.keys(T).length>0?T:void 0,Ke=xe!=null&&xe.size?xe.size:Tt(ge),qe=ns(Pe);for(let Me=0;Me<L;Me++){const ot={prompt:me,knowledgeContextRefs:ce,width:B,height:q,aspectRatio:ge,size:Ke,model:se,modelRef:P||null,uploadedImages:Xe,batchId:A,batchIndex:Me+1,batchTotal:L,assetMetadata:Z,autoInsertToCanvas:K??jt(at.AI_IMAGE_AUTO_INSERT),targetFrameId:E,targetFrameDimensions:a,pptSlideImage:g,pptSlidePrompt:N,pptReplaceElementId:$,...qe,...xe?{params:xe}:{}},zt=_e(ot,Se.IMAGE);zt&&h.push(zt.id)}h.length>0?(Ne.success(v==="zh"?`已添加 ${h.length} 个任务到队列`:`Added ${h.length} tasks to queue`),Ge(me),m(null),u("tasks"),Ce(!1)):m(v==="zh"?"批量任务创建失败,请稍后重试":"Failed to create batch tasks, please try again later");return}const st=y||Je("image").modelId,nt=st.startsWith("mj")?[Q.trim(),Yt(T)].filter(Boolean).join(" "):(Q||"").trim(),Oe=!st.startsWith("mj")&&Object.keys(T).length>0?T:void 0,ft=Oe!=null&&Oe.size?Oe.size:Tt(ge),pt=ns(Pe),c={prompt:nt,knowledgeContextRefs:ce,width:B,height:q,aspectRatio:ge,size:ft,model:st,modelRef:P||null,uploadedImages:Xe,autoInsertToCanvas:K??jt(at.AI_IMAGE_AUTO_INSERT),batchId:G||`image_single_${Date.now()}`,batchIndex:1,batchTotal:1,assetMetadata:Z,targetFrameId:E,targetFrameDimensions:a,pptSlideImage:g,pptSlidePrompt:N,pptReplaceElementId:$,...pt,...Oe?{params:Oe}:{}};_e(c,Se.IMAGE)?(Ne.success(v==="zh"?"任务已添加到队列,将在后台生成":"Task added to queue, will be generated in background"),Ge(nt),m(null),u("tasks"),Ce(!1)):m(v==="zh"?"任务创建失败,请检查参数或稍后重试":"Failed to create task, please check parameters or try again later")}catch(B){console.error("Failed to create task:",B);let q=v==="zh"?"任务创建失败,请检查参数或稍后重试":"Failed to create task, please check parameters or try again later";B.message&&(B.message.includes("exceed 5000 characters")?q=v==="zh"?"提示词不能超过 5000 字符":"Prompt must not exceed 5000 characters":B.message.includes("Duplicate submission")?q=v==="zh"?"请勿重复提交,请等待 5 秒后再试":"Duplicate submission. Please wait 5 seconds.":B.message.includes("Invalid parameters")&&(q=v==="zh"?`参数错误: ${B.message.replace("Invalid parameters: ","")}`:B.message)),m(q)}}finally{ke.current=!1}}};return ys(ue,Q,()=>Ze(1)),t.jsxs("div",{className:"ai-image-generation-container",children:[z?t.jsxs("div",{className:"ai-generation-mobile-switcher",role:"tablist",children:[t.jsx("button",{type:"button",className:`ai-generation-mobile-switcher__tab ${X==="config"?"ai-generation-mobile-switcher__tab--active":""}`,onClick:()=>u("config"),children:"生成设置"}),t.jsx("button",{type:"button",className:`ai-generation-mobile-switcher__tab ${X==="tasks"?"ai-generation-mobile-switcher__tab--active":""}`,onClick:()=>u("tasks"),children:"生成任务"})]}):null,t.jsxs("div",{className:`main-content ${z?"main-content--mobile-panels":""}`,ref:b,children:[t.jsxs("div",{className:`ai-image-generation-section ${z&&X!=="config"?"ai-generation-mobile-panel--hidden":""}`,children:[t.jsxs("div",{className:"ai-image-generation-form",children:[f!==void 0&&M&&t.jsx("div",{className:"form-header-row",children:t.jsx("div",{className:"model-selector-wrapper",children:t.jsx(ms,{selectedModel:y,selectedSelectionKey:Te(y,P),onSelect:x=>{R(x),ae(null),M(x),C==null||C(null)},onSelectModel:x=>{R(x.id);const L=Le(x);ae(L),M(x.id),C==null||C(L)},language:v,models:j,placement:"down",variant:"form",disabled:ue})})}),be&&t.jsx("div",{className:"model-params-row",children:t.jsx(fs,{selectedParams:T,onParamChange:ie,modelId:y,language:v,disabled:ue,placement:"down"})}),t.jsx(Is,{images:O,onImagesChange:te,language:v,disabled:ue,multiple:!0,label:v==="zh"?"参考图片 (可选)":"Reference Images (Optional)",onError:m}),t.jsx(Ts,{prompt:Q,onPromptChange:re,presetPrompts:ct,language:v,type:"image",disabled:ue,onError:m}),t.jsx(ps,{value:ce,onChange:F,disabled:ue,language:v}),t.jsx(Ss,{error:fe})]}),t.jsx(Cs,{language:v,type:"image",isGenerating:ue,hasGenerated:!1,canGenerate:!!(Q&&Q.trim()),onGenerate:Ze,onReset:Qe,leftContent:t.jsx(Ns,{storageKey:at.AI_IMAGE_AUTO_INSERT,language:v})})]}),z?null:t.jsx(Ms,{isRightPanelVisible:Ee,onToggleRightPanel:ze,onWidthChange:Ae,rightPanelWidth:D,language:v,storageKey:"image"}),(z||Ee)&&t.jsx("div",{className:`task-sidebar ${z?"task-sidebar--mobile-panel":""} ${z&&X!=="tasks"?"ai-generation-mobile-panel--hidden":""}`,style:z?void 0:{width:D,flexShrink:0},children:t.jsx(Rs,{taskType:Se.IMAGE,onEditTask:ut})})]})]})};function os(n,s){const o=Object.keys(n),l=Object.keys(s);return o.length!==l.length?!1:o.every(r=>n[r]===s[r])}function as(n,s,o){return n.slice(0,s).map((l,r)=>({...l,slot:r,slotLabel:o[r]||`参考图${r+1}`}))}function Kn(n,s){return n.length===s.length&&n.every((o,l)=>{const r=s[l];return o.slot===r.slot&&o.slotLabel===r.slotLabel&&o.url===r.url&&o.name===r.name&&o.file===r.file})}function St(n,s){return((n==null?void 0:n.profileId)||null)===((s==null?void 0:s.profileId)||null)&&((n==null?void 0:n.modelId)||null)===((s==null?void 0:s.modelId)||null)}function zs(n,s){const o=$e(s==null?void 0:s.profileId,s==null?void 0:s.modelId);return(o==null?void 0:o.modelId)===(n||null)?o:null}function Be(n,s,o){if(!s)return null;const l=zs(s,o),r=Fe(n,s,l);return Le(r)||l}function Wn(n){return n.reduce((s,o)=>(o.defaultValue&&(s[o.id]=o.defaultValue),s),{})}function _t(n,s){return Wn(hs(n,s||n,{}))}function gt(n,s,o){return{...n,...s!=null?{duration:String(s)}:{},...o?{size:o}:{}}}function rs(n,s,o){const{duration:l,size:r,...d}=n;return{extraParams:d,duration:s,size:o}}const qn=({initialPrompt:n="",initialImage:s,initialImages:o,initialKnowledgeContextRefs:l=[],initialDuration:r,initialModel:d,initialSize:I,initialResultUrl:k,selectedModel:E,selectedModelRef:a,onModelChange:g,onModelRefChange:N,externalBatchId:$,initialAutoInsertToCanvas:f,onDraftChange:S}={})=>{var Oe,ft,pt;const M=us("video"),[C,G]=e.useState(n),[Z,K]=e.useState(l),[ee,i]=e.useState(null),[w,_]=e.useState(!0),[y,R]=e.useState(()=>Ps("video")),[P,ae]=e.useState("config"),je=e.useRef(null),{viewportWidth:H}=Pt(),Q=H<=768,re=Je("video"),ce=d||re.modelId,F=zs(ce,d&&d===E?a:re.modelId===ce?$e(re.profileId,re.modelId):null),T=Fe(M,ce,F)||vt("video",ce,F),W=Be(M,(T==null?void 0:T.id)||ce,Le(T)||F),[j,ye]=e.useState((T==null?void 0:T.id)||((Oe=M[0])==null?void 0:Oe.id)||yt("veo3")),[oe,he]=e.useState(W),Re=Te((T==null?void 0:T.id)||((ft=M[0])==null?void 0:ft.id)||yt("veo3"),W),ge=Vt((T==null?void 0:T.id)||((pt=M[0])==null?void 0:pt.id)||yt("veo3"),Re),le=Ie.useMemo(()=>{if(Fe(M,j,oe)||!j)return M;const p=vt("video",j,oe);return p?[p,...M]:M},[j,oe,M]),[fe,m]=e.useState(()=>gt(ge.extraParams,(r==null?void 0:r.toString())||ge.duration,I||ge.size)),O=Ie.useMemo(()=>hs(j,oe||j,fe),[j,oe,fe]),te=Ie.useMemo(()=>Ot(j,oe||j,fe),[j,oe,fe]),Ee=Ie.useMemo(()=>(te.imageUpload.labels||[]).join("|"),[te.imageUpload.labels]),pe=Ie.useMemo(()=>Ee?Ee.split("|"):[],[Ee]),D=Ie.useMemo(()=>({maxCount:te.imageUpload.maxCount,mode:te.imageUpload.mode,required:te.imageUpload.required,labels:pe,labelsSignature:Ee}),[te.imageUpload.maxCount,te.imageUpload.mode,te.imageUpload.required,pe,Ee]),U=Ie.useMemo(()=>{var h;const c=O.find(A=>A.id==="duration"),p=fe.duration;return p&&((h=c==null?void 0:c.options)!=null&&h.some(A=>A.value===p))?p:(c==null?void 0:c.defaultValue)||te.defaultDuration},[O,te.defaultDuration,fe.duration]),X=Ie.useMemo(()=>{var h;const c=O.find(A=>A.id==="size"),p=fe.size;return p&&((h=c==null?void 0:c.options)!=null&&h.some(A=>A.value===p))?p:(c==null?void 0:c.defaultValue)||te.defaultSize},[O,te.defaultSize,fe.size]),u=Ie.useMemo(()=>O.length>0,[O]),b=e.useCallback((c,p)=>{if(!p||p==="default"){m(h=>{const A={...h};return delete A[c],A});return}m(h=>({...h,[c]:p}))},[]);e.useEffect(()=>{const c=O.reduce((p,h)=>{const A=fe[h.id],se=!A||h.valueType!=="enum"||!h.options||h.options.some(me=>me.value===A);return A&&se?p[h.id]=A:h.defaultValue&&(p[h.id]=h.defaultValue),p},{});os(fe,c)||m(c)},[O,fe]);const[J,z]=e.useState(()=>o&&o.length>0?o:s?[{slot:0,slotLabel:"参考图",url:s.url||"",name:s.name,file:s.file}]:[]),[V,ne]=e.useState(()=>{const c=te.imageUpload.maxCount,p=te.imageUpload.labels||[];let h=[];return o&&o.length>0?h=o:s&&(h=[{slot:0,slotLabel:p[0]||"参考图",url:s.url||"",name:s.name,file:s.file}]),h.slice(0,c).map((A,se)=>({...A,slot:se,slotLabel:p[se]||`参考图${se+1}`}))}),[de,ue]=e.useState(!1),[v,_e]=e.useState([]),ke=Ie.useMemo(()=>un(j),[j]),De=Ft(j),{videoHistory:be}=Nt(),[we,Ce]=e.useState(0);e.useEffect(()=>He.subscribeChanges(()=>{Ce(c=>c+1)}),[]);const{isGenerating:ie}=ws("video"),Ae=e.useCallback(c=>{R(c)},[]),ze=e.useCallback(()=>{_(c=>!c)},[]),{language:Y}=Mt(),{createTask:Ue}=gs(),Qe=e.useRef(!1),ct=E!==void 0,dt=Ie.useRef(null),Ge=Ie.useRef(null);e.useEffect(()=>{if(ct)return;const c=p=>{const h=p.videoModelName||"veo3";if(h!==j){ye(h);const A=Be(le,h,oe);he(A)}};return Ve.addListener(c),()=>Ve.removeListener(c)},[j,oe,ct,E,a,le]),e.useEffect(()=>{if(le.length===0)return;const c=Fe(le,j,oe),p=Be(le,j,oe);if(!c){const h=le[0],A=Le(h);ye(h.id),he(se=>St(se,A)?se:A);return}he(h=>St(h,p)?h:p)},[j,oe,le]),e.useEffect(()=>{if(!E)return;const c=Te(E,a);if(dt.current===c||Ge.current&&Ge.current!==E)return;dt.current=c,ye(h=>h===E?h:E);const p=Be(le,E,a);he(h=>St(h,p)?h:p)},[E,a,le,d]);const[ut,Ye]=e.useState(!1),[Ze,et]=e.useState(!1);e.useEffect(()=>{if(Ze){et(!1);return}const c=Vt(j,Te(j,oe)),p=gt(c.extraParams,r!==void 0?r.toString():c.duration,I||c.size);m(h=>os(h,p)?h:p),Ft(j)||(ue(h=>h&&!1),_e(h=>h.length>0?[]:h))},[j,oe,Ze,r,I]),e.useEffect(()=>{const c=J.length>0?as(J,D.maxCount,D.labels):[];ne(p=>Kn(p,c)?p:c)},[J,D.labels,D.labelsSignature,D.maxCount]),e.useEffect(()=>{const c=rs(fe,U,X);mn({currentModel:j,currentSelectionKey:Te(j,oe),extraParams:c.extraParams,duration:c.duration,size:c.size})},[j,oe,U,X,fe]);const tt=Ie.useRef("");e.useEffect(()=>{if(ut)return;const c=JSON.stringify({prompt:n,image:s==null?void 0:s.url,images:o==null?void 0:o.map(A=>A.url),knowledgeContextRefs:l.map(A=>A.noteId),duration:r,model:d,size:I,result:k});if(tt.current===c)return;tt.current=c,d&&(Ge.current=d,ye(d),he(Be(M,d,a))),G(n),K(l);let p=[];o&&o.length>0?p=o:s&&(p=[{slot:0,slotLabel:"参考图",url:s.url||"",name:s.name,file:s.file}]),z(p);const h=as(p,D.maxCount,D.labels);ne(h),(r!==void 0||I)&&m(A=>gt(A,r,I)),i(null)},[n,s,o,l,r,I,k,D.labels,D.labelsSignature,D.maxCount,ut]),e.useEffect(()=>(i(null),()=>{i(null)}),[]);const mt=()=>{G(""),z([]),ne([]),i(null),ae("config"),Ye(!1),ue(!1),_e([]),m(_t(j,oe||j)),window.dispatchEvent(new CustomEvent("ai-video-clear"))},x=Ie.useCallback((c,p)=>c.map((h,A)=>{const se=h.slot??A;return{slot:se,slotLabel:p[se]||`参考图${se+1}`,url:h.url,name:h.name,file:h.file}}),[]),L=Ie.useCallback(c=>c.map(p=>({url:p.url,name:p.name,file:p.file,slot:p.slot})),[]),B=Ie.useCallback(c=>{const p=x(c,D.labels);ne(p),z(p)},[D.labels,x]),q=Ie.useMemo(()=>bs("video",Y,be),[be,Y,we]),Pe=c=>{xs("video",c),Ce(p=>p+1)},Xe=e.useRef("");e.useEffect(()=>{if(!S)return;const c=Number.parseFloat(U),p={prompt:C,images:V.map(se=>({url:se.url,name:se.name})),duration:Number.isFinite(c)?c:void 0,size:X||void 0},h=JSON.stringify(p);if(Xe.current===h)return;const A=window.setTimeout(()=>{Xe.current!==h&&(Xe.current=h,S(p))},200);return()=>{window.clearTimeout(A)}},[U,X,S,C,V]);const st=c=>{var h,A;if(Ye(!0),ae("config"),et(!0),c.params.model){ye(c.params.model),he(c.params.modelRef||null);const se=Ve.get();Ve.update({...se,videoModelName:c.params.model})}if((h=c.params.storyboard)!=null&&h.enabled&&((A=c.params.storyboard)!=null&&A.scenes))ue(!0),_e(c.params.storyboard.scenes),G("");else{const se=c.params.prompt||"",me=An(se);me&&me.length>0?(ue(!0),_e(me),G("")):(ue(!1),_e([]),G(se))}const p=c.params.params&&typeof c.params.params=="object"?Object.entries(c.params.params).reduce((se,[me,xe])=>(xe!=null&&String(xe).trim()&&(se[me]=String(xe)),se),{}):{};if(m(gt(p,c.params.duration??c.params.seconds,c.params.size)),c.params.uploadedImages&&c.params.uploadedImages.length>0){z(c.params.uploadedImages);const se=c.params.model||j,me=Ot(se,c.params.modelRef||se,p),xe=me.imageUpload.maxCount,Ke=me.imageUpload.labels||[],qe=c.params.uploadedImages.slice(0,xe).map((Me,ot)=>({...Me,slot:ot,slotLabel:Ke[ot]||`参考图${ot+1}`}));ne(qe)}else z([]),ne([]);i(null)},nt=async(c=1)=>{if(!Qe.current){Qe.current=!0;try{if(de){const p=Nn(v,parseFloat(U),ke.minSceneDuration);if(!p.valid){i(p.error||"场景配置无效");return}}else if(!C||!C.trim()){i(Y==="zh"?"请输入视频描述":"Please enter video description");return}if(D.required&&!V.some(p=>p.url||p.file)){i(Y==="zh"?"请上传模型所需的参考图片":"Please upload the required reference image");return}try{const p=[];for(const me of V)if(me.file){const xe=await new Promise((Ke,qe)=>{const Me=new FileReader;Me.onload=()=>Ke(Me.result),Me.onerror=qe,Me.readAsDataURL(me.file)});p.push({...me,url:xe,file:void 0})}else p.push({...me,file:void 0});const h=de?Rn(v):(C||"").trim(),A=[],se=$||`video_batch_${Date.now()}`;for(let me=0;me<c;me++){const xe=rs(fe,U,X),Ke=Object.keys(xe.extraParams).length>0?xe.extraParams:void 0,qe={prompt:h,knowledgeContextRefs:Z,model:j,modelRef:oe||null,seconds:xe.duration,size:xe.size,uploadedImages:p,...de&&{storyboard:{enabled:!0,scenes:v,totalDuration:parseFloat(U)}},batchId:se,batchIndex:me+1,batchTotal:c,autoInsertToCanvas:f??jt(at.AI_VIDEO_AUTO_INSERT),...Ke?{params:Ke}:{}},Me=Ue(qe,Se.VIDEO);Me&&A.push(Me.id)}A.length>0?(Ne.success(Y==="zh"?c>1?`${A.length} 个视频任务已添加到队列,将在后台生成`:"视频任务已添加到队列,将在后台生成":c>1?`${A.length} video tasks added to queue, will be generated in background`:"Video task added to queue, will be generated in background"),Pe(h),G(""),z([]),ne([]),ue(!1),_e([]),i(null),ae("tasks"),Ye(!1)):i(Y==="zh"?"任务创建失败,请检查参数或稍后重试":"Failed to create task, please check parameters or try again later")}catch(p){console.error("Failed to create task:",p);let h=Y==="zh"?"任务创建失败,请检查参数或稍后重试":"Failed to create task, please check parameters or try again later";p.message&&(p.message.includes("exceed 5000 characters")?h=Y==="zh"?"提示词不能超过 5000 字符":"Prompt must not exceed 5000 characters":p.message.includes("Duplicate submission")?h=Y==="zh"?"请勿重复提交,请等待 5 秒后再试":"Duplicate submission. Please wait 5 seconds.":p.message.includes("Invalid parameters")&&(h=Y==="zh"?`参数错误: ${p.message.replace("Invalid parameters: ","")}`:p.message)),i(h)}}finally{Qe.current=!1}}};return ys(ie,C,nt),t.jsxs("div",{className:"ai-video-generation-container",children:[Q?t.jsxs("div",{className:"ai-generation-mobile-switcher",role:"tablist",children:[t.jsx("button",{type:"button",className:`ai-generation-mobile-switcher__tab ${P==="config"?"ai-generation-mobile-switcher__tab--active":""}`,onClick:()=>ae("config"),children:"生成设置"}),t.jsx("button",{type:"button",className:`ai-generation-mobile-switcher__tab ${P==="tasks"?"ai-generation-mobile-switcher__tab--active":""}`,onClick:()=>ae("tasks"),children:"生成任务"})]}):null,t.jsxs("div",{className:`main-content ${Q?"main-content--mobile-panels":""}`,ref:je,children:[t.jsxs("div",{className:`ai-image-generation-section ${Q&&P!=="config"?"ai-generation-mobile-panel--hidden":""}`,children:[t.jsxs("div",{className:"ai-image-generation-form",children:[E!==void 0&&g&&t.jsx("div",{className:"form-header-row",children:t.jsx("div",{className:"model-selector-wrapper",children:t.jsx(ms,{selectedModel:j,selectedSelectionKey:Te(j,oe),onSelect:(c,p)=>{const h=c,A=Be(le,h,p||null);Ge.current=null,ye(h),he(A),m(_t(h,A||h)),g(c),N==null||N(A)},onSelectModel:c=>{const p=c.id;Ge.current=null,ye(p);const h=Be(le,p,Le(c));he(h),m(_t(p,h||p)),g(c.id),N==null||N(h)},language:Y,models:le,placement:"down",variant:"form",placeholder:Y==="zh"?"选择视频模型":"Select Video Model",disabled:ie})})}),u&&t.jsx("div",{className:"model-params-row",children:t.jsx(fs,{selectedParams:fe,onParamChange:b,compatibleParams:O,modelId:j,language:Y,disabled:ie,placement:"down"})}),D.maxCount>0&&t.jsx(Is,{images:L(V),onImagesChange:B,language:Y,disabled:ie,multiple:D.maxCount>1,maxCount:D.maxCount,slotLabels:D.mode==="frames"?D.labels:void 0,label:D.mode==="frames"?Y==="zh"?"首尾帧图片 (可选)":"Start/End Frames (Optional)":D.required?Y==="zh"?"参考图片":"Reference Images":Y==="zh"?"参考图片 (可选)":"Reference Images (Optional)"}),De&&t.jsx(Dn,{enabled:de,onEnabledChange:ue,totalDuration:parseFloat(U),maxScenes:ke.maxScenes,minSceneDuration:ke.minSceneDuration,scenes:v,onScenesChange:_e,disabled:ie}),!de&&t.jsx(Ts,{prompt:C,onPromptChange:G,presetPrompts:q,language:Y,type:"video",disabled:ie,onError:i,videoProvider:te.provider}),t.jsx(ps,{value:Z,onChange:K,disabled:ie,language:Y}),t.jsx(Ss,{error:ee})]}),t.jsx(Cs,{language:Y,type:"video",isGenerating:ie,hasGenerated:!1,canGenerate:de?v.length>0:!!(C&&C.trim()),onGenerate:nt,onReset:mt,leftContent:t.jsx(Ns,{storageKey:at.AI_VIDEO_AUTO_INSERT,language:Y})})]}),Q?null:t.jsx(Ms,{isRightPanelVisible:w,onToggleRightPanel:ze,onWidthChange:Ae,rightPanelWidth:y,language:Y,storageKey:"video"}),(Q||w)&&t.jsx("div",{className:`task-sidebar ${Q?"task-sidebar--mobile-panel":""} ${Q&&P!=="tasks"?"ai-generation-mobile-panel--hidden":""}`,style:Q?void 0:{width:y,flexShrink:0},children:t.jsx(Rs,{taskType:Se.VIDEO,onEditTask:st})})]})]})},Bn=e.lazy(()=>Et(()=>import("./batch-image-generation-DyWeiTsw.js"),__vite__mapDeps([0,1,2]),import.meta.url)),Hn=e.lazy(()=>Et(()=>import("./mermaid-to-drawnix-C7rF-30X.js"),__vite__mapDeps([0,1,3,4,5,6,7]),import.meta.url)),Xn=e.lazy(()=>Et(()=>import("./markdown-to-drawnix-3yksNvbU.js"),__vite__mapDeps([0,1,3,4,5,6,7]),import.meta.url)),Jn=({container:n})=>{const{appState:s,openDialog:o,closeDialog:l}=ds(),{language:r}=Mt(),d=_n(),{isMobile:I,isTablet:k}=Pt(),E=s.dialogInitialDataByType,a=(E==null?void 0:E[ve.aiImageGeneration])??null,g=(E==null?void 0:E[ve.aiVideoGeneration])??null,N=!I&&!k,$=e.useRef(!1),f=e.useRef(null),[S,M]=e.useState(""),[C,G]=e.useState(null),[Z,K]=e.useState(""),[ee,i]=e.useState(null),w=e.useRef(null),_=e.useRef(null),y=e.useCallback(()=>{const m=Je("image"),O=Je("video"),te=m.modelId||"gemini-3-pro-image-preview-vip",Ee=$e(m.profileId,te),pe=O.modelId||"veo3",D=$e(O.profileId,pe);M(U=>U===te?U:te),G(U=>Te(te,U)===Te(te,Ee)?U:Ee),K(U=>U===pe?U:pe),i(U=>Te(pe,U)===Te(pe,D)?U:D)},[]);e.useEffect(()=>{y()},[y]),e.useEffect(()=>{const m=()=>{y()};return Ve.addListener(m),Ut.addListener(m),()=>{Ve.removeListener(m),Ut.removeListener(m)}},[y]);const R=m=>{M(m)},P=m=>{K(m)},ae=m=>{G(m)},je=m=>{i(m)};e.useEffect(()=>{if(!S)return;const m=Te(S,C);w.current!==m&&(w.current=m,Gt("image",$e(C==null?void 0:C.profileId,S)))},[S,C]),e.useEffect(()=>{if(!Z)return;const m=Te(Z,ee);_.current!==m&&(_.current=m,Gt("video",$e(ee==null?void 0:ee.profileId,Z)))},[Z,ee]);const[H,Q]=e.useState({initialPrompt:"",initialImages:[],selectedElementIds:[]}),[re,ce]=e.useState({initialPrompt:"",initialImage:void 0}),[F,T]=e.useState(!1),[W,j]=e.useState(()=>{try{return localStorage.getItem(wt)==="batch"?"batch":"single"}catch{return"single"}});e.useEffect(()=>{!N&&W==="batch"&&j("single")},[N,W]);const ye=e.useCallback(m=>{j(m),m==="batch"&&(T(!0),setTimeout(()=>T(!1),50));try{localStorage.setItem(wt,m)}catch(O){console.warn("Failed to save image mode:",O)}},[]);e.useEffect(()=>{if(s.openDialogTypes.has(ve.aiImageGeneration)){if(H.initialImages&&H.initialImages.length>0||H.initialPrompt&&H.initialPrompt.trim()!==""){T(!1);return}try{localStorage.getItem(wt)==="batch"&&(T(!0),setTimeout(()=>T(!1),50))}catch{T(!1)}}},[s.openDialogTypes,H.initialImages,H.initialPrompt]);const oe=e.useRef(!1),he=e.useRef(a),Re=e.useRef(!1),ge=e.useRef(g);e.useEffect(()=>{if(!d)return;const m=s.openDialogTypes.has(ve.aiImageGeneration),O=m&&!oe.current,te=he.current!==a;if(oe.current=m,he.current=a,!m||!O&&!te||$.current)return;(async()=>{$.current=!0,f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{console.warn("Processing timeout, resetting processing state"),$.current=!1},1e4);try{if(a){Q({initialPrompt:a.initialPrompt||a.prompt||"",initialImages:a.initialImages||a.uploadedImages||[],initialKnowledgeContextRefs:a.initialKnowledgeContextRefs||a.knowledgeContextRefs||[],selectedElementIds:[],initialResultUrl:a.initialResultUrl||a.resultUrl,initialAspectRatio:a.initialAspectRatio,targetFrameId:a.targetFrameId,targetFrameDimensions:a.targetFrameDimensions,pptSlideImage:a.pptSlideImage,pptSlidePrompt:a.pptSlidePrompt,pptReplaceElementId:a.pptReplaceElementId}),a.initialModel&&M(a.initialModel),a.initialModelRef!==void 0&&G(a.initialModelRef);return}const pe=s.lastSelectedElementIds||[];let D,U,X;const u=fn(d);if(u.length===1&&pn(u[0])){const z=u[0],V=hn.getRectangleByPoints(z.points);D=kn(V.width,V.height),U=z.id,X={width:V.width,height:V.height}}const b=await Xt(d,pe),J=[];b.remainingImages.forEach(z=>{J.push({url:z.url,name:z.name||`selected-image-${Date.now()}.png`})}),b.graphicsImage&&J.push({url:b.graphicsImage,name:`graphics-combined-${Date.now()}.png`}),Q({initialPrompt:b.remainingText||"",initialImages:J,initialKnowledgeContextRefs:[],selectedElementIds:pe,initialAspectRatio:D,targetFrameId:U,targetFrameDimensions:X})}catch(pe){console.warn("Error processing selected content for AI:",pe);const D=Jt(d),U=D.images.map(X=>({url:X.url,name:X.name||`selected-image-${Date.now()}.png`}));Q({initialPrompt:D.text||"",initialImages:U,initialKnowledgeContextRefs:[],selectedElementIds:[]})}finally{$.current=!1,f.current&&(clearTimeout(f.current),f.current=null)}})()},[s.lastSelectedElementIds,s.openDialogTypes,d,a]),e.useEffect(()=>{if(!d)return;const m=s.openDialogTypes.has(ve.aiVideoGeneration),O=m&&!Re.current,te=ge.current!==g;if(Re.current=m,ge.current=g,!m||!O&&!te||$.current)return;(async()=>{$.current=!0,f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{console.warn("Video processing timeout, resetting processing state"),$.current=!1},1e4);try{if(g){ce({initialPrompt:g.initialPrompt||g.prompt||"",initialImage:g.initialImage||g.uploadedImage,initialImages:g.initialImages||g.uploadedImages,initialDuration:g.initialDuration||g.duration,initialModel:g.initialModel||g.model,initialSize:g.initialSize||g.size,initialResultUrl:g.initialResultUrl||g.resultUrl});const X=g.initialModel||g.model;X&&K(X),g.initialModelRef!==void 0&&i(g.initialModelRef);return}const pe=s.lastSelectedElementIds||[],D=await Xt(d,pe),U=[];D.remainingImages.length>0?D.remainingImages.forEach((X,u)=>{U.push({url:X.url,name:X.name||`selected-image-${u+1}-${Date.now()}.png`})}):D.graphicsImage&&U.push({url:D.graphicsImage,name:`graphics-combined-${Date.now()}.png`}),ce({initialPrompt:D.remainingText||"",initialImage:U.length>0?U[0]:void 0,initialImages:U.map((X,u)=>({slot:u,slotLabel:`参考图${u+1}`,url:X.url,name:X.name}))})}catch(pe){console.warn("Error processing selected content for AI video:",pe);const D=Jt(d),U=D.images.map((X,u)=>({url:X.url,name:X.name||`selected-image-${u+1}-${Date.now()}.png`}));ce({initialPrompt:D.text||"",initialImage:U.length>0?U[0]:void 0,initialImages:U.map((X,u)=>({slot:u,slotLabel:`参考图${u+1}`,url:X.url,name:X.name}))})}finally{$.current=!1,f.current&&(clearTimeout(f.current),f.current=null)}})()},[s.lastSelectedElementIds,s.openDialogTypes,d,g]),e.useEffect(()=>{s.openDialogTypes.size===0&&($.current=!1,oe.current=!1,he.current=null,Re.current=!1,ge.current=null,f.current&&(clearTimeout(f.current),f.current=null))},[s.openDialogTypes]);const le=e.useCallback(()=>{const m=localStorage.getItem(Kt);if(m)try{const O=JSON.parse(m);O.timestamp=Date.now(),localStorage.setItem(Kt,JSON.stringify(O))}catch(O){console.warn("Failed to update cache timestamp:",O)}l(ve.aiImageGeneration)},[l]),fe=e.useCallback(()=>{const m=localStorage.getItem(Wt);if(m)try{const O=JSON.parse(m);O.timestamp=Date.now(),localStorage.setItem(Wt,JSON.stringify(O))}catch(O){console.warn("Failed to update cache timestamp:",O)}l(ve.aiVideoGeneration)},[l]);return t.jsxs(t.Fragment,{children:[t.jsx(qt,{open:s.openDialogTypes.has(ve.mermaidToDrawnix),onOpenChange:m=>{m?o(ve.mermaidToDrawnix):l(ve.mermaidToDrawnix)},children:t.jsx(Bt,{className:"Dialog ttd-dialog",container:n,children:t.jsx(e.Suspense,{fallback:null,children:t.jsx(Hn,{})})})}),t.jsx(qt,{open:s.openDialogTypes.has(ve.markdownToDrawnix),onOpenChange:m=>{m?o(ve.markdownToDrawnix):l(ve.markdownToDrawnix)},children:t.jsx(Bt,{className:"Dialog ttd-dialog",container:n,children:t.jsx(e.Suspense,{fallback:null,children:t.jsx(Xn,{})})})}),t.jsx(Ht,{id:"ai-image-dialog",visible:s.openDialogTypes.has(ve.aiImageGeneration),title:W==="batch"?r==="zh"?"批量出图":"Batch Generation":r==="zh"?"AI 图片生成":"AI Image Generation",headerContent:N?t.jsxs("div",{className:"image-generation-mode-tabs",onMouseDown:m=>m.stopPropagation(),onTouchStart:m=>m.stopPropagation(),onPointerDown:m=>m.stopPropagation(),children:[t.jsx("button",{type:"button",className:`mode-tab ${W==="single"?"active":""}`,onClick:m=>{m.stopPropagation(),m.preventDefault(),ye("single")},children:r==="zh"?"AI 图片生成":"AI Image"}),t.jsx("button",{type:"button",className:`mode-tab ${W==="batch"?"active":""}`,onClick:m=>{m.stopPropagation(),m.preventDefault(),ye("batch")},children:r==="zh"?"批量出图":"Batch"})]}):void 0,onClose:le,width:"80%",height:"60%",minWidth:800,minHeight:500,x:"center",y:"center",modal:!1,minimizable:!1,className:"winbox-ai-generation winbox-ai-image-generation",container:n,autoMaximize:F||I,children:s.openDialogTypes.has(ve.aiImageGeneration)&&(W==="batch"?t.jsx(e.Suspense,{fallback:t.jsx("div",{className:"loading-fallback",children:r==="zh"?"加载中...":"Loading..."}),children:t.jsx(Bn,{onSwitchToSingle:()=>ye("single"),selectedModel:S,selectedModelRef:C,onModelChange:R,onModelRefChange:ae})}):t.jsx(Gn,{initialPrompt:H.initialPrompt,initialImages:H.initialImages,initialKnowledgeContextRefs:H.initialKnowledgeContextRefs||(a==null?void 0:a.initialKnowledgeContextRefs)||(a==null?void 0:a.knowledgeContextRefs)||[],selectedElementIds:H.selectedElementIds,initialWidth:(a==null?void 0:a.initialWidth)||(a==null?void 0:a.width),initialHeight:(a==null?void 0:a.initialHeight)||(a==null?void 0:a.height),initialResultUrl:H.initialResultUrl,initialAspectRatio:H.initialAspectRatio,targetFrameId:H.targetFrameId,targetFrameDimensions:H.targetFrameDimensions,pptSlideImage:H.pptSlideImage,pptSlidePrompt:H.pptSlidePrompt,pptReplaceElementId:H.pptReplaceElementId,selectedModel:S,selectedModelRef:C,onModelChange:R,onModelRefChange:ae,externalBatchId:a==null?void 0:a.batchId,assetMetadata:a==null?void 0:a.assetMetadata,initialAutoInsertToCanvas:a==null?void 0:a.autoInsertToCanvas,onDraftChange:a==null?void 0:a.onDraftChange},(a==null?void 0:a.prefillId)||(a==null?void 0:a.batchId)||"ai-image-dialog"))},(a==null?void 0:a.prefillId)||"ai-image-window"),t.jsx(Ht,{id:"ai-video-dialog",visible:s.openDialogTypes.has(ve.aiVideoGeneration),title:r==="zh"?"AI 视频生成":"AI Video Generation",onClose:fe,width:"70%",height:"60%",minWidth:800,minHeight:600,x:"center",y:"center",modal:!1,minimizable:!1,className:"winbox-ai-generation winbox-ai-video-generation",container:n,autoMaximize:I,children:s.openDialogTypes.has(ve.aiVideoGeneration)&&t.jsx(qn,{initialPrompt:re.initialPrompt,initialImage:re.initialImage,initialImages:re.initialImages,initialKnowledgeContextRefs:(g==null?void 0:g.initialKnowledgeContextRefs)||(g==null?void 0:g.knowledgeContextRefs)||[],initialDuration:re.initialDuration,initialModel:re.initialModel,initialSize:re.initialSize,initialResultUrl:re.initialResultUrl,selectedModel:Z,selectedModelRef:ee,onModelChange:P,onModelRefChange:je,externalBatchId:g==null?void 0:g.batchId,initialAutoInsertToCanvas:g==null?void 0:g.autoInsertToCanvas,onDraftChange:g==null?void 0:g.onDraftChange},(g==null?void 0:g.batchId)||"ai-video-dialog")})]})},co=e.memo(Jn,(n,s)=>n.container===s.container);export{co as TTDDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{P as e}from"./ai-chat-B-XdoWBQ.js";function M(i={}){const{showNavbar:s=!0,showToolbar:o=!0,showTitle:n=!0,videoAutoPlay:g=!0,videoLoop:p=!0,onClose:a,onIndexChange:r}=i,[u,w]=e.useState(!1),[l,x]=e.useState([]),[c,d]=e.useState(0),I=e.useCallback((t,v=0)=>{const m=Array.isArray(t)?t:[t];m.length!==0&&(x(m),d(Math.max(0,Math.min(v,m.length-1))),w(!0))},[]),h=e.useCallback(()=>{w(!1),x([]),d(0),a==null||a()},[a]),f=e.useCallback(t=>{d(t),r==null||r(t)},[r]),b=e.useMemo(()=>({visible:u,items:l,initialIndex:c,onClose:h,onIndexChange:f,showNavbar:s,showToolbar:o,showTitle:n,videoAutoPlay:g,videoLoop:p}),[u,l,c,h,f,s,o,n,g,p]);return{openViewer:I,closeViewer:h,isOpen:u,currentIndex:c,items:l,viewerProps:b}}function V(i,s="image"){return i.map((o,n)=>({url:o,type:s,alt:`${s==="image"?"Image":"Video"} ${n+1}`}))}export{V as a,M as u};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|