diff --git a/data/version.txt b/data/version.txt index 314c3d7..ab67981 100644 --- a/data/version.txt +++ b/data/version.txt @@ -1 +1 @@ -1.1.5 \ No newline at end of file +1.1.6 \ No newline at end of file diff --git a/data/web/index.html b/data/web/index.html index 09f0b85..439a531 100644 --- a/data/web/index.html +++ b/data/web/index.html @@ -15694,7 +15694,7 @@ Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>"The options parameter is deprecated and will * @author RubaXa * @author owenm * @license MIT - */function jkn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Gy(e){for(var t=1;t=0)&&(n[o]=e[o]);return n}function $Qs(e,t){if(e==null)return{};var n=_Qs(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var eBs="1.15.2";function C8(e){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(e)}var Z6=C8(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),uoe=C8(/Edge/i),Wkn=C8(/firefox/i),xJ=C8(/safari/i)&&!C8(/chrome/i)&&!C8(/android/i),A_n=C8(/iP(ad|od|hone)/i),f_n=C8(/chrome/i)&&C8(/android/i),g_n={capture:!1,passive:!1};function Sl(e,t,n){e.addEventListener(t,n,!Z6&&g_n)}function el(e,t,n){e.removeEventListener(t,n,!Z6&&g_n)}function mve(e,t){if(t){if(t[0]===">"&&(t=t.substring(1)),e)try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch{return!1}return!1}}function tBs(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function jb(e,t,n,r){if(e){n=n||document;do{if(t!=null&&(t[0]===">"?e.parentNode===n&&mve(e,t):mve(e,t))||r&&e===n)return e;if(e===n)break}while(e=tBs(e))}return null}var Hkn=/\s+/g;function nv(e,t,n){if(e&&t)if(e.classList)e.classList[n?"add":"remove"](t);else{var r=(" "+e.className+" ").replace(Hkn," ").replace(" "+t+" "," ");e.className=(r+(n?" "+t:"")).replace(Hkn," ")}}function No(e,t,n){var r=e&&e.style;if(r){if(n===void 0)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(e,""):e.currentStyle&&(n=e.currentStyle),t===void 0?n:n[t];!(t in r)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),r[t]=n+(typeof n=="string"?"":"px")}}function PW(e,t){var n="";if(typeof e=="string")n=e;else do{var r=No(e,"transform");r&&r!=="none"&&(n=r+" "+n)}while(!t&&(e=e.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(n)}function m_n(e,t,n){if(e){var r=e.getElementsByTagName(t),o=0,s=r.length;if(n)for(;o=s,!a)return r;if(r===Ly())break;r=W5(r,!1)}return!1}function xz(e,t,n,r){for(var o=0,s=0,a=e.children;s2&&arguments[2]!==void 0?arguments[2]:{},r=n.evt,o=$Qs(n,cBs);hoe.pluginEvent.bind(Uo)(e,t,Gy({dragEl:Ri,parentEl:Bu,ghostEl:gs,rootEl:Md,nextEl:mD,lastDownEl:OAe,cloneEl:lu,cloneHidden:XS,dragStarted:LG,putSortable:Xf,activeSortable:Uo.active,originalEvent:r,oldIndex:nj,oldDraggableIndex:SJ,newIndex:ov,newDraggableIndex:SS,hideGhostForTarget:C_n,unhideGhostForTarget:x_n,cloneNowHidden:function(){XS=!0},cloneNowShown:function(){XS=!1},dispatchSortableEvent:function(s){_m({sortable:t,name:s,originalEvent:r})}},o))};function _m(e){lBs(Gy({putSortable:Xf,cloneEl:lu,targetEl:Ri,rootEl:Md,oldIndex:nj,oldDraggableIndex:SJ,newIndex:ov,newDraggableIndex:SS},e))}var Ri,Bu,gs,Md,mD,OAe,lu,XS,nj,ov,SJ,SS,oue,Xf,iU=!1,kve=!1,vve=[],Y7,nb,KPe,JPe,Zkn,Ykn,LG,ON,TJ,EJ=!1,sue=!1,wAe,Wg,_Pe=[],mGe=!1,pve=[],mye=typeof document<"u",aue=A_n,Xkn=uoe||Z6?"cssFloat":"float",dBs=mye&&!f_n&&!A_n&&"draggable"in document.createElement("div"),O_n=function(){if(mye){if(Z6)return!1;var e=document.createElement("x");return e.style.cssText="pointer-events:auto",e.style.pointerEvents==="auto"}}(),w_n=function(e,t){var n=No(e),r=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),o=xz(e,0,t),s=xz(e,1,t),a=o&&No(o),l=s&&No(s),d=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Xh(o).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+Xh(s).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return s&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return o&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||d>=r&&n[Xkn]==="none"||s&&n[Xkn]==="none"&&d+u>r)?"vertical":"horizontal"},uBs=function(e,t,n){var r=n?e.left:e.top,o=n?e.right:e.bottom,s=n?e.width:e.height,a=n?t.left:t.top,l=n?t.right:t.bottom,d=n?t.width:t.height;return r===a||o===l||r+s/2===a+d/2},hBs=function(e,t){var n;return vve.some(function(r){var o=r[Wv].options.emptyInsertThreshold;if(!(!o||Qat(r))){var s=Xh(r),a=e>=s.left-o&&e<=s.right+o,l=t>=s.top-o&&t<=s.bottom+o;if(a&&l)return n=r}}),n},y_n=function(e){function t(o,s){return function(a,l,d,u){var h=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(o==null&&(s||h))return!0;if(o==null||o===!1)return!1;if(s&&o==="clone")return o;if(typeof o=="function")return t(o(a,l,d,u),s)(a,l,d,u);var f=(s?a:l).options.group.name;return o===!0||typeof o=="string"&&o===f||o.join&&o.indexOf(f)>-1}}var n={},r=e.group;(!r||bAe(r)!="object")&&(r={name:r}),n.name=r.name,n.checkPull=t(r.pull,!0),n.checkPut=t(r.put),n.revertClone=r.revertClone,e.group=n},C_n=function(){!O_n&&gs&&No(gs,"display","none")},x_n=function(){!O_n&&gs&&No(gs,"display","")};mye&&!f_n&&document.addEventListener("click",function(e){if(kve)return e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.stopImmediatePropagation&&e.stopImmediatePropagation(),kve=!1,!1},!0);var X7=function(e){if(Ri){e=e.touches?e.touches[0]:e;var t=hBs(e.clientX,e.clientY);if(t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[Wv]._onDragOver(n)}}},ABs=function(e){Ri&&Ri.parentNode[Wv]._isOutsideThisEl(e.target)};function Uo(e,t){if(!(e&&e.nodeType&&e.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));this.el=e,this.options=t=A6({},t),e[Wv]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return w_n(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(s,a){s.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:Uo.supportPointer!==!1&&"PointerEvent"in window&&!xJ,emptyInsertThreshold:5};hoe.initializePlugins(this,e,n);for(var r in n)!(r in t)&&(t[r]=n[r]);y_n(t);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=t.forceFallback?!1:dBs,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?Sl(e,"pointerdown",this._onTapStart):(Sl(e,"mousedown",this._onTapStart),Sl(e,"touchstart",this._onTapStart)),this.nativeDraggable&&(Sl(e,"dragover",this),Sl(e,"dragenter",this)),vve.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),A6(this,oBs())}Uo.prototype={constructor:Uo,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(ON=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,Ri):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,r=this.options,o=r.preventOnFilter,s=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,d=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,u=r.filter;if(OBs(n),!Ri&&!(/mousedown|pointerdown/.test(s)&&e.button!==0||r.disabled)&&!d.isContentEditable&&!(!this.nativeDraggable&&xJ&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=jb(l,r.draggable,n,!1),!(l&&l.animated)&&OAe!==l)){if(nj=kp(l),SJ=kp(l,r.draggable),typeof u=="function"){if(u.call(this,e,l,this)){_m({sortable:t,rootEl:d,name:"filter",targetEl:l,toEl:n,fromEl:n}),b0("filter",t,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=jb(d,h.trim(),n,!1),h)return _m({sortable:t,rootEl:h,name:"filter",targetEl:l,fromEl:n,toEl:n}),b0("filter",t,{evt:e}),!0}),u)){o&&e.cancelable&&e.preventDefault();return}r.handle&&!jb(d,r.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var r=this,o=r.el,s=r.options,a=o.ownerDocument,l;if(n&&!Ri&&n.parentNode===o){var d=Xh(n);if(Md=o,Ri=n,Bu=Ri.parentNode,mD=Ri.nextSibling,OAe=n,oue=s.group,Uo.dragged=Ri,Y7={target:Ri,clientX:(t||e).clientX,clientY:(t||e).clientY},Zkn=Y7.clientX-d.left,Ykn=Y7.clientY-d.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,Ri.style["will-change"]="all",l=function(){if(b0("delayEnded",r,{evt:e}),Uo.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!Wkn&&r.nativeDraggable&&(Ri.draggable=!0),r._triggerDragStart(e,t),_m({sortable:r,name:"choose",originalEvent:e}),nv(Ri,s.chosenClass,!0)},s.ignore.split(",").forEach(function(u){m_n(Ri,u.trim(),$Pe)}),Sl(a,"dragover",X7),Sl(a,"mousemove",X7),Sl(a,"touchmove",X7),Sl(a,"mouseup",r._onDrop),Sl(a,"touchend",r._onDrop),Sl(a,"touchcancel",r._onDrop),Wkn&&this.nativeDraggable&&(this.options.touchStartThreshold=4,Ri.draggable=!0),b0("delayStart",this,{evt:e}),s.delay&&(!s.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(uoe||Z6))){if(Uo.eventCanceled){this._onDrop();return}Sl(a,"mouseup",r._disableDelayedDrag),Sl(a,"touchend",r._disableDelayedDrag),Sl(a,"touchcancel",r._disableDelayedDrag),Sl(a,"mousemove",r._delayedDragTouchMoveHandler),Sl(a,"touchmove",r._delayedDragTouchMoveHandler),s.supportPointer&&Sl(a,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(l,s.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){Ri&&$Pe(Ri),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;el(e,"mouseup",this._disableDelayedDrag),el(e,"touchend",this._disableDelayedDrag),el(e,"touchcancel",this._disableDelayedDrag),el(e,"mousemove",this._delayedDragTouchMoveHandler),el(e,"touchmove",this._delayedDragTouchMoveHandler),el(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?Sl(document,"pointermove",this._onTouchMove):t?Sl(document,"touchmove",this._onTouchMove):Sl(document,"mousemove",this._onTouchMove):(Sl(Ri,"dragend",this),Sl(Md,"dragstart",this._onDragStart));try{document.selection?yAe(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(iU=!1,Md&&Ri){b0("dragStarted",this,{evt:t}),this.nativeDraggable&&Sl(document,"dragover",ABs);var n=this.options;!e&&nv(Ri,n.dragClass,!1),nv(Ri,n.ghostClass,!0),Uo.active=this,e&&this._appendGhost(),_m({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(nb){this._lastX=nb.clientX,this._lastY=nb.clientY,C_n();for(var e=document.elementFromPoint(nb.clientX,nb.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(nb.clientX,nb.clientY),e!==t);)t=e;if(Ri.parentNode[Wv]._isOutsideThisEl(e),t)do{if(t[Wv]){var n=void 0;if(n=t[Wv]._onDragOver({clientX:nb.clientX,clientY:nb.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);x_n()}},_onTouchMove:function(e){if(Y7){var t=this.options,n=t.fallbackTolerance,r=t.fallbackOffset,o=e.touches?e.touches[0]:e,s=gs&&PW(gs,!0),a=gs&&s&&s.a,l=gs&&s&&s.d,d=aue&&Wg&&zkn(Wg),u=(o.clientX-Y7.clientX+r.x)/(a||1)+(d?d[0]-_Pe[0]:0)/(a||1),h=(o.clientY-Y7.clientY+r.y)/(l||1)+(d?d[1]-_Pe[1]:0)/(l||1);if(!Uo.active&&!iU){if(n&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))=0&&(_m({rootEl:Bu,name:"add",toEl:Bu,fromEl:Md,originalEvent:e}),_m({sortable:this,name:"remove",toEl:Bu,originalEvent:e}),_m({rootEl:Bu,name:"sort",toEl:Bu,fromEl:Md,originalEvent:e}),_m({sortable:this,name:"sort",toEl:Bu,originalEvent:e})),Xf&&Xf.save()):ov!==nj&&ov>=0&&(_m({sortable:this,name:"update",toEl:Bu,originalEvent:e}),_m({sortable:this,name:"sort",toEl:Bu,originalEvent:e})),Uo.active&&((ov==null||ov===-1)&&(ov=nj,SS=SJ),_m({sortable:this,name:"end",toEl:Bu,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){b0("nulling",this),Md=Ri=Bu=gs=mD=lu=OAe=XS=Y7=nb=LG=ov=SS=nj=SJ=ON=TJ=Xf=oue=Uo.dragged=Uo.ghost=Uo.clone=Uo.active=null,pve.forEach(function(e){e.checked=!0}),pve.length=KPe=JPe=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":Ri&&(this._onDragOver(e),fBs(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,r=0,o=n.length,s=this.options;ro.right+s||e.clientY>r.bottom&&e.clientX>r.left:e.clientY>o.bottom+s||e.clientX>r.right&&e.clientY>r.top}function vBs(e,t,n,r,o,s,a,l){var d=r?e.clientY:e.clientX,u=r?n.height:n.width,h=r?n.top:n.left,f=r?n.bottom:n.right,g=!1;if(!a){if(l&&wAeh+u*s/2:df-wAe)return-TJ}else if(d>h+u*(1-o)/2&&df-u*s/2)?d>h+u/2?1:-1:0}function pBs(e){return kp(Ri){if(R&&(o==null?void 0:o.length)!==B.childNodes.length)return M.insertBefore(R,N.nextSibling),!0;const W=B.childNodes[I];R=B==null?void 0:B.replaceChild(N,W)})}}catch(R){P=R}finally{o=null}ei(()=>{if(Gkn(),P)throw P})}const O={onUpdate:p,onStart:A,onAdd:m,onRemove:v,onEnd:b};function w(T){const D=ge(s);return T||(T=zQs(D)?ZQs(D,r==null?void 0:r.$el):D),T&&!qQs(T)&&(T=T.$el),T||jQs("Root element not found"),T}function y(){var T;const D=(T=ge(l))!=null?T:{},{immediate:Q,clone:M}=D,B=u_n(D,["immediate","clone"]);return Ukn(B,(P,F)=>{GQs(P)&&(B[P]=(R,...N)=>{const I=LBs();return KQs(R,I),F(R,...N)})}),XQs(a===null?{}:O,B)}const C=T=>{T=w(T),d&&x.destroy(),d=new Uo(T,y())};At(()=>l,()=>{d&&Ukn(y(),(T,D)=>{d==null||d.option(T,D)})},{deep:!0});const x={option:(T,D)=>d==null?void 0:d.option(T,D),destroy:()=>{d==null||d.destroy(),d=null},save:()=>d==null?void 0:d.save(),toArray:()=>d==null?void 0:d.toArray(),closest:(...T)=>d==null?void 0:d.closest(...T)},L=()=>x==null?void 0:x.option("disabled",!0),S=()=>x==null?void 0:x.option("disabled",!1);return xBs(()=>{u&&C()}),CBs(x.destroy),tj({start:C,pause:L,resume:S},x)}const bGe=["update","start","add","remove","choose","unchoose","end","sort","filter","clone","move","change"],TBs=["clone","animation","ghostClass","group","sort","disabled","store","handle","draggable","swapThreshold","invertSwap","invertedSwapThreshold","removeCloneOnHide","direction","chosenClass","dragClass","ignore","filter","preventOnFilter","easing","setData","dropBubble","dragoverBubble","dataIdAttr","delay","delayOnTouchOnly","touchStartThreshold","forceFallback","fallbackClass","fallbackOnBody","fallbackTolerance","fallbackOffset","supportPointer","emptyInsertThreshold","scroll","forceAutoScrollFallback","scrollSensitivity","scrollSpeed","bubbleScroll","modelValue","tag","target","customUpdate",...bGe.map(e=>`on${e.replace(/^\S/,t=>t.toUpperCase())}`)],EBs=Xe({name:"VueDraggable",model:{prop:"modelValue",event:"update:modelValue"},props:TBs,emits:["update:modelValue",...bGe],setup(e,{slots:t,emit:n,expose:r,attrs:o}){const s=bGe.reduce((h,f)=>{const g=`on${f.replace(/^\S/,k=>k.toUpperCase())}`;return h[g]=(...k)=>n(f,...k),h},{}),a=G(()=>{const h=Si(e),{modelValue:f}=h,g=u_n(h,["modelValue"]),k=Object.entries(g).reduce((A,[m,v])=>{const p=ge(v);return p!==void 0&&(A[m]=p),A},{});return tj(tj({},s),HQs(tj(tj({},o),k)))}),l=G({get:()=>e.modelValue,set:h=>n("update:modelValue",h)}),d=de(),u=Po(SBs(e.target||d,l,a));return r(u),()=>{var h;return Bn(e.tag||"div",{ref:d},(h=t==null?void 0:t.default)==null?void 0:h.call(t,u))}}}),DBs={class:"previewContainer"},QBs={class:"mainContent"},BBs={class:"previewArea"},FBs={class:"videoWrapper"},PBs=["src","alt"],MBs={key:1,class:"placeholderImage"},RBs={class:"playerControls"},IBs={class:"controlButtons"},NBs={class:"progressArea"},UBs={class:"timeLabel"},jBs={class:"progressTrack"},WBs=["onClick"],HBs={class:"timeLabel"},VBs={class:"infoPanel"},zBs={class:"infoSection"},ZBs={class:"sectionTitle"},YBs={class:"sectionContent"},XBs={class:"infoSection"},qBs={class:"sectionTitle"},GBs={class:"sectionContent"},KBs={class:"infoSection"},JBs={class:"sectionTitle"},_Bs={class:"characterList"},$Bs={key:0,class:"noCharacter"},eFs={class:"infoSection"},tFs={class:"sectionTitle"},nFs={class:"shootingTips"},iFs={key:0,class:"tipItem"},rFs={class:"tipLabel"},oFs={class:"tipValue"},sFs={class:"shotListArea"},aFs={class:"shotListHeader"},lFs={class:"headerLeft"},cFs=["onClick"],dFs={class:"shotImageWrapper"},uFs=["src","alt"],hFs={key:1,class:"shotPlaceholder"},Jkn=50,AFs=Xe({__name:"preview",setup(e){const t=mt("episodesId"),n=de([]);mn(()=>{r()});async function r(){const{data:X}=await on.post("/production/getStoryboardData",{scriptId:t.value});n.value=X}const o=G(()=>n.value[a.value]||null),s=G(()=>{var X;return((X=o.value)==null?void 0:X.characters)||[]}),a=de(0),l=de(!1),d=de(),u=de(),h=de(!1),f=de(!1),g=de(0);let k=null;const A=n.value.map(X=>X.id),m=G(()=>{var X;return((X=o.value)==null?void 0:X.duration)??3}),v=G(()=>a.value===0),p=G(()=>a.value===n.value.length-1),b=G(()=>n.value.reduce((X,_)=>X+(_.duration??3),0)),O=G(()=>{const X=C(a.value)+g.value;return Math.min(X/b.value*100,100)}),w=G(()=>{var X,_;return[{label:$t("workbench.production.preview.sceneDescription"),value:(X=o.value)==null?void 0:X.description},{label:$t("workbench.production.preview.promptLabel"),value:(_=o.value)==null?void 0:_.prompt}]}),y=X=>{var _;return((_=n.value[X])==null?void 0:_.duration)??3},C=X=>{let _=0;for(let q=0;qy(X)/b.value*100,L=X=>C(X)/b.value*100,S=X=>{const _=Math.floor(X);return`${String(Math.floor(_/60)).padStart(2,"0")}:${String(_%60).padStart(2,"0")}`},T=()=>{k&&(clearInterval(k),k=null),f.value=!1},D=()=>{k||(f.value=!0,k=setInterval(()=>{g.value+=Jkn/1e3,g.value>=m.value&&(p.value?(g.value=m.value,T()):(g.value=0,a.value++,I()))},Jkn))},Q=()=>{if(f.value)return T();p.value&&g.value>=m.value&&(a.value=0,g.value=0),D()};Pa(T);const M=(X,_=!0)=>{_&&T(),a.value=X,g.value=0,I()},B=()=>{v.value||M(a.value-1)},P=()=>{p.value||M(a.value+1)},F=X=>M(X),R=X=>M(X),N=X=>{const _=u.value;if(!_)return;T();const q=le=>{const ce=_.getBoundingClientRect(),ie=Math.max(0,Math.min(1,(le.clientX-ce.left)/ce.width))*b.value;let Ae=0;for(let H=0;Hie){a.value=H,g.value=ie-Ae,I();return}Ae+=ee}a.value=n.value.length-1,g.value=y(n.value.length-1)};q(X);const re=()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",re)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",re)},I=()=>{ei(()=>{var _,q;const X=(_=d.value)==null?void 0:_.querySelectorAll(".shotItem");(q=X==null?void 0:X[a.value])==null||q.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})})},W=X=>{const _=Array.isArray(X)?X.length>0:X;n.value.forEach(q=>q.selected=_)};hf(document,"keydown",X=>{if(X.code==="Space"&&!X.repeat){X.preventDefault();const _=n.value[a.value];_&&(_.selected=!_.selected)}});const V=()=>{const X=_r.confirm({header:$t("workbench.production.preview.restoreSort"),body:$t("workbench.production.preview.restoreSortConfirm"),onConfirm:()=>{n.value.sort((_,q)=>A.indexOf(_.id)-A.indexOf(q.id)),X.destroy()},onClose:()=>X.destroy()})};At(()=>n.value.map(X=>X.selected),X=>{l.value=X.length>0&&X.every(Boolean)},{deep:!0});const z=()=>ei(()=>h.value=!1);async function Y(){const X=n.value.filter(re=>re.selected).map(re=>({id:re.id,filePath:re.filePath}));if(X.length===0){_r.alert({header:$t("workbench.production.preview.tip"),body:$t("workbench.production.preview.selectAtLeastOne")});return}const _=new $Un,q=X.map(async re=>{try{if(!re.filePath)return;const ce=await(await fetch(re.filePath)).blob();_.file(`分镜${re.id}.${K(re.filePath)}`,ce)}catch(le){console.error(`图片下载失败: ${re.filePath}`,le)}});await Promise.all(q),_.generateAsync({type:"blob"}).then(re=>{const le=document.createElement("a");le.href=URL.createObjectURL(re),le.download="分镜压缩包.zip",le.click(),setTimeout(()=>URL.revokeObjectURL(le.href),5e3)})}function K(X){const _=X.match(/\.(\w+)(?:\?|$)/);return _?_[1]:"jpg"}return(X,_)=>{var oe,te,J;const q=kn("i-pic"),re=kn("i-go-start"),le=vi,ce=kn("i-go-end"),me=Wu,ie=Gd,Ae=pO,H=kn("i-undo"),ee=kn("i-download");return Ce(),We("div",DBs,[he("div",QBs,[he("div",BBs,[he("div",FBs,[(oe=o.value)!=null&&oe.filePath?(Ce(),We("img",{key:0,src:o.value.filePath,alt:o.value.description,class:"previewImage"},null,8,PBs)):(Ce(),We("div",MBs,[c(q,{theme:"outline",size:"48",fill:"#999"}),he("span",null,De(X.$t("workbench.production.preview.noImage")),1)]))]),he("div",RBs,[he("div",IBs,[c(le,{theme:"default",variant:"text",size:"small",shape:"circle",onClick:B,disabled:v.value},{icon:ve(()=>[c(re,{theme:"outline",size:"18"})]),_:1},8,["disabled"]),c(le,{theme:"primary",variant:"text",size:"medium",shape:"circle",onClick:Q},{icon:ve(()=>[(Ce(),St(Ud(f.value?"i-pause":"i-play"),{theme:"outline",size:"22"}))]),_:1}),c(le,{theme:"default",variant:"text",size:"small",shape:"circle",onClick:P,disabled:p.value},{icon:ve(()=>[c(ce,{theme:"outline",size:"18"})]),_:1},8,["disabled"])]),he("div",NBs,[he("span",UBs,De(S(g.value)),1),he("div",{class:"progressBarWrapper",ref_key:"progressBarRef",ref:u,onMousedown:N},[he("div",jBs,[(Ce(!0),We(nn,null,bi(n.value,(se,ke)=>(Ce(),We("div",{key:"seg-"+se.id,class:uo(["progressSegment",{active:ke===a.value,completed:keF(ke),["stop"])},null,14,WBs))),128)),(Ce(!0),We(nn,null,bi(n.value.slice(0,-1),(se,ke)=>(Ce(),We("div",{key:"div-"+ke,class:"segmentDivider",style:eo({left:L(ke+1)+"%"})},null,4))),128)),he("div",{class:"progressFill",style:eo({width:O.value+"%"})},null,4),he("div",{class:"progressHandle",style:eo({left:O.value+"%"})},null,4)])],544),he("span",HBs,De(S(b.value)),1)])])]),he("div",VBs,[he("div",zBs,[he("div",ZBs,[_[5]||(_[5]=he("span",{class:"titleIndicator"},null,-1)),kt(" "+De(X.$t("workbench.production.preview.storyboardDesc")),1)]),he("div",YBs," 【"+De(X.$t("workbench.production.preview.serialNumber"))+" "+De(a.value+1)+"】"+De(((te=o.value)==null?void 0:te.description)||X.$t("workbench.production.preview.noDescription")),1)]),he("div",XBs,[he("div",qBs,[_[6]||(_[6]=he("span",{class:"titleIndicator"},null,-1)),kt(" "+De(X.$t("workbench.production.preview.duration")),1)]),he("div",GBs,De(((J=o.value)==null?void 0:J.duration)!=null?o.value.duration+" "+X.$t("workbench.production.preview.seconds"):"3 "+X.$t("workbench.production.preview.seconds")),1)]),he("div",KBs,[he("div",JBs,[_[7]||(_[7]=he("span",{class:"titleIndicator"},null,-1)),kt(" "+De(X.$t("workbench.production.preview.relatedAssets")),1)]),he("div",_Bs,[(Ce(!0),We(nn,null,bi(s.value,(se,ke)=>(Ce(),We("div",{key:ke,class:"characterItem"},[c(me,{src:se.avatar,fit:"cover",class:"characterAvatar",style:{width:"80px",height:"80px",borderRadius:"8px"}},null,8,["src"]),c(ie,null,{default:ve(()=>[kt(De(se.name)+"("+De(se.type=="role"?X.$t("workbench.production.preview.role"):se.type=="tool"?X.$t("workbench.production.preview.prop"):X.$t("workbench.production.preview.scene"))+") ",1)]),_:2},1024)]))),128)),s.value.length?Vt("",!0):(Ce(),We("div",$Bs,[c(ie,{theme:"default",variant:"light"},{default:ve(()=>[kt(De(X.$t("workbench.production.preview.noCharacters")),1)]),_:1})]))])]),he("div",eFs,[he("div",tFs,[_[8]||(_[8]=he("span",{class:"titleIndicator"},null,-1)),kt(" "+De(X.$t("workbench.production.preview.imagePrompt")),1)]),he("div",nFs,[(Ce(!0),We(nn,null,bi(w.value,se=>(Ce(),We(nn,{key:se.label},[se.value?(Ce(),We("div",iFs,[he("span",rFs,De(se.label)+":",1),he("span",oFs,De(se.value),1)])):Vt("",!0)],64))),128))])])])]),he("div",sFs,[he("div",aFs,[he("div",lFs,[c(Ae,{modelValue:l.value,"onUpdate:modelValue":_[0]||(_[0]=se=>l.value=se),onChange:W},{default:ve(()=>[kt(De(X.$t("workbench.production.preview.selectAll")),1)]),_:1},8,["modelValue"]),c(le,{theme:"default",variant:"text",size:"small",onClick:V},{icon:ve(()=>[c(H,{theme:"outline",size:"16"})]),default:ve(()=>[kt(" "+De(X.$t("workbench.production.preview.restoreSort")),1)]),_:1})]),c(le,{theme:"default",variant:"text",size:"small",class:"exportBtn",onClick:Y},{icon:ve(()=>[c(ee,{theme:"outline",size:"16"})]),default:ve(()=>[kt(" "+De(X.$t("workbench.production.preview.exportImage")),1)]),_:1})]),he("div",{class:"shotListWrapper",ref_key:"shotListWrapperRef",ref:d},[c(ge(EBs),{modelValue:n.value,"onUpdate:modelValue":_[3]||(_[3]=se=>n.value=se),animation:150,ghostClass:"shotGhost",dragClass:"shotDrag",scroll:d.value,scrollSensitivity:80,scrollSpeed:10,forceFallback:!0,target:".shotList",onStart:_[4]||(_[4]=se=>h.value=!0),onEnd:z},{default:ve(()=>[c(h4n,{type:"transition",tag:"div",name:h.value?void 0:"shot-flip",class:"shotList"},{default:ve(()=>[(Ce(!0),We(nn,null,bi(n.value,(se,ke)=>(Ce(),We("div",{key:se.id,class:uo(["shotItem",{active:a.value===ke}]),onClick:ye=>R(ke)},[c(Ae,{modelValue:se.selected,"onUpdate:modelValue":ye=>se.selected=ye,class:"shotCheckbox",onClick:_[1]||(_[1]=or(()=>{},["stop"])),onMousedown:_[2]||(_[2]=or(()=>{},["stop"]))},null,8,["modelValue","onUpdate:modelValue"]),he("div",dFs,[se.filePath?(Ce(),We("img",{key:0,src:se.filePath,alt:se.description,class:"shotImage"},null,8,uFs)):(Ce(),We("div",hFs,[c(q,{theme:"outline",size:"24",fill:"#999"})])),c(ie,{class:"shotNumber",size:"small",variant:"dark"},{default:ve(()=>[kt("#"+De(se.id),1)]),_:2},1024)])],10,cFs))),128))]),_:1},8,["name"])]),_:1},8,["modelValue","scroll"])],512)])])}}}),fFs=Fr(AFs,[["__scopeId","data-v-a51966a2"]]);function wN(e,t){return`${e??""}:${t??""}`}function gFs(e){if(!e)return"";if(e.startsWith("data:")||e.startsWith("blob:"))return e;try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return e}}function iMe(e){return e.map(t=>({...JSON.parse(JSON.stringify(t)),src:gFs(t.src)}))}const E_n=RO("imageListCache",()=>{const e=de({}),t=de({});async function n(m){if(!m.length)return{};const v=m.filter(b=>b.id==null?!1:(wN(b.id,b.sources),!0));if(v.length)try{const{data:b}=await on.post("/production/workbench/getFileUrl",{items:v.map(y=>({id:y.id,sources:y.sources}))}),O=b.data,w={};Array.isArray(O)?O.forEach(y=>{if(y.id!=null&&y.url){const C=wN(y.id,y.sources);w[C]=y.url}}):O&&typeof O=="object"&&!Array.isArray(O)&&Object.entries(O).forEach(([y,C])=>{w[y]=C}),t.value={...t.value,...w}}catch(b){console.warn("[imageListCache] resolveUrls 请求失败,降级使用路径",b)}const p={};return m.forEach(b=>{var w;const O=wN(b.id,b.sources);p[O]=t.value[O]||((w=b.id)==null?void 0:w.toString())||""}),p}function r(m,v,p){if(m!=null){const b=wN(m,v);if(t.value[b])return t.value[b]}return p||""}function o(m){return m.map(v=>({...v,src:r(v.id,v.sources,v.src)}))}function s(m,v,p){var O,w;const b=(w=(O=e.value[m])==null?void 0:O[v])==null?void 0:w[p];if(b)return o(b)}async function a(m,v,p){var w,y;const b=(y=(w=e.value[m])==null?void 0:w[v])==null?void 0:y[p];if(!b)return;const O=b.filter(C=>C.id!=null).map(C=>({id:C.id,sources:C.sources}));return await n(O),o(b)}function l(m,v,p){var b,O;return(O=(b=e.value[m])==null?void 0:b[v])==null?void 0:O[p]}function d(m,v,p,b){e.value[m]||(e.value[m]={}),e.value[m][v]||(e.value[m][v]={});let O=!1;b.forEach(w=>{if(!w.src||w.id==null)return;const y=wN(w.id,w.sources);t.value[y]||(t.value[y]=w.src,O=!0)}),O&&(t.value={...t.value}),e.value[m][v][p]=iMe(b)}function u(m,v,p){var b;(b=e.value[m])!=null&&b[v]&&delete e.value[m][v][p]}function h(m,v){e.value[m]&&delete e.value[m][v]}function f(m,v,p){p.forEach(b=>{var O,w;b.id!=null&&((w=(O=e.value[m])==null?void 0:O[v])!=null&&w[b.id]||(e.value[m]||(e.value[m]={}),e.value[m][v]||(e.value[m][v]={}),e.value[m][v][b.id]=iMe(b.medias)))})}function g(m,v,p){e.value[m]&&delete e.value[m][v],e.value[m]||(e.value[m]={}),e.value[m][v]={},p.forEach(b=>{b.id!=null&&(e.value[m][v][b.id]=iMe(b.medias))})}async function k(m,v){var w;const p=(w=e.value[m])==null?void 0:w[v];if(!p)return;const b=[],O=new Set;Object.values(p).forEach(y=>{y.forEach(C=>{if(C.id==null)return;const x=wN(C.id,C.sources);O.has(x)||(O.add(x),b.push({id:C.id,sources:C.sources}))})}),await n(b)}function A(){t.value={}}return{cacheData:e,urlMap:t,getCache:s,getCacheWithResolve:a,getRawCache:l,setCache:d,removeCache:u,clearScriptCache:h,initCacheFromTrackList:f,forceInitCacheFromTrackList:g,resolveUrls:n,resolveUrlSync:r,warmUpUrls:k,clearUrlMap:A}},{persist:{pick:["cacheData"]}}),mFs={class:"videoTrack"},kFs={class:"trackMenu f ac jb"},vFs={class:"left f ac"},pFs={key:0,class:"selectedCount"},bFs={class:"right f ac"},OFs={class:"itemBox"},wFs=["onClick"],yFs={key:1,class:"thumbGroup"},CFs=["src"],xFs={key:1,class:"thumb placeholder c"},LFs={key:2,class:"thumbGroup"},SFs={key:1,class:"thumb placeholder c"},TFs={key:3,class:"emptyTrack"},EFs=["onClick"],DFs=Xe({__name:"track",props:ha({modelParmas:{},imageList:{},clampDuration:{type:Function}},{activeTrackIndex:{default:0},activeTrackIndexModifiers:{},modelValue:{default:()=>[]},modelModifiers:{},genTextLoadingMap:{default:()=>{}},genTextLoadingMapModifiers:{}}),emits:ha(["getData","change","saveImageList"],["update:activeTrackIndex","update:modelValue","update:genTextLoadingMap"]),setup(e,{emit:t}){const{project:n}=Pr(Ad()),{removeCache:r}=E_n(),o=mt("episodesId"),s=e,a=Dc(e,"activeTrackIndex"),l=de([]),d=Dc(e,"modelValue"),u=Dc(e,"genTextLoadingMap"),h=t,f=de(!1),g=de({});function k(T){var Q;if(!T.selectVideoId)return null;const D=(Q=T.videoList)==null?void 0:Q.find(M=>M.id===T.selectVideoId);return(D==null?void 0:D.src)||null}function A(T){if(!T||g.value[T])return;const D=document.createElement("video");D.crossOrigin="anonymous",D.preload="auto",D.muted=!0,D.src=T,D.addEventListener("seeked",()=>{try{const Q=document.createElement("canvas");Q.width=D.videoWidth||160,Q.height=D.videoHeight||90;const M=Q.getContext("2d");M&&(M.drawImage(D,0,0,Q.width,Q.height),g.value[T]=Q.toDataURL("image/jpeg",.7))}catch{}D.src=""},{once:!0}),D.addEventListener("loadeddata",()=>{D.currentTime=0},{once:!0}),D.addEventListener("error",()=>{D.src=""},{once:!0}),D.load()}function m(T){if(a.value==T)return;const D=a.value;a.value=T,h("change",D)}async function v(T){var B;const D=d.value[T];if(!D)return;await on.post("/production/workbench/deleteTrack",{id:D.id}),l.value=l.value.filter(P=>P!==D.id);const Q=(B=n.value)==null?void 0:B.id,M=o.value;Q!=null&&M!=null&&D.id!=null&&r(Q,M,D.id),a.value>=d.value.length&&(a.value=d.value.length-1)}function p(T){const D=_r.confirm({header:$t("workbench.generate.del"),body:$t("workbench.generate.delConfirm"),confirmBtn:$t("settings.generate.delConfirmBtn"),cancelBtn:$t("settings.memory.msg.cancel"),onConfirm:async()=>{try{await v(T),window.$message.success($t("workbench.generate.delSuccess")),h("getData")}catch(Q){window.$message.error(Q.message??$t("workbench.cornerScape.cancelGeneration")+"失败")}finally{D.destroy()}}})}async function b(){var B,P;const{data:T}=await on.post("/modelSelect/getModelDetail",{modelId:s.modelParmas.model}),D=T.durationResolutionMap;if(!Array.isArray(D)||D.length===0||!((B=D[0].duration)!=null&&B.length))return;const Q=D[0].duration[0],{data:M}=await on.post("/production/workbench/addTrack",{projectId:(P=n.value)==null?void 0:P.id,scriptId:o.value??0,duration:Q});h("getData"),a.value=d.value.length-1}function O(T){var Q;return((Q=T.split(".").pop())==null?void 0:Q.split(/[#?]/)[0])||"mp4"}async function w(){const T=new $Un,Q=d.value.filter(F=>l.value.includes(F.id)).map(F=>{const R=F.videoList.find(I=>I.id===F.selectVideoId);if(!(R!=null&&R.src))return null;const N=`分镜${F.id}.${O(R.src)}`;return fetch(R.src).then(I=>I.blob()).then(I=>T.file(N,I)).catch(I=>console.error(`视频下载失败: ${R.src}`,I))}).filter(Boolean);await Promise.all(Q);const M=await T.generateAsync({type:"blob"}),B=URL.createObjectURL(M),P=document.createElement("a");P.href=B,P.download=`视频批量下载_${Date.now()}.zip`,document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(B),l.value=[],f.value=!1}function y(){d.value.filter(T=>l.value.includes(T.id)).forEach(async T=>{var M;const D=T.id;let Q=[];if(s.modelParmas.mode=="text"?Q=T==null?void 0:T.medias.map(({id:B,sources:P})=>({id:B,sources:P})):Q=C(T),!u.value[D]){u.value[D]=!0;try{const{data:B}=await on.post("/production/workbench/generateVideoPrompt",{projectId:(M=n.value)==null?void 0:M.id,trackId:D,info:Q,model:s.modelParmas.model}),P=d.value.find(F=>F.id===D);P&&(P.prompt=B),l.value=[],f.value=!1}catch(B){window.$message.error((B==null?void 0:B.message)??"提示词生成失败")}finally{u.value[D]=!1}}})}function C(T,D=!1){var M;const Q=(M=d.value[a.value])==null?void 0:M.id;if(T.id===Q){const B=s.imageList;return(D?B.filter(P=>!!P.src):B).map(({id:P,sources:F})=>({id:P,sources:F??"storyboard"}))}return T.medias.filter(B=>!D||!!B.src).map(({id:B,sources:P})=>({id:B,sources:P??"storyboard"}))}function x(){const T=_r.confirm({header:$t("workbench.generate.generateConfirm"),body:$t("workbench.generate.generateVideosInBatches"),onConfirm:async()=>{T.destroy(),d.value.filter(D=>l.value.includes(D.id)).forEach(async D=>{var M;const Q=D.id;try{const B=s.modelParmas.mode==="text"?[]:C(D,!0),P={projectId:(M=n.value)==null?void 0:M.id,scriptId:o.value,duration:s.clampDuration(D.duration||s.modelParmas.duration),uploadData:B,prompt:D.prompt,model:s.modelParmas.model,mode:s.modelParmas.mode,resolution:s.modelParmas.resolution,audio:!!s.modelParmas.audio,trackId:Q};if(!P.prompt)return window.$message.warning($t("workbench.generate.skipDataWithEmptyVideoPromptWords"));const{data:F}=await on.post("/production/workbench/generateVideo",P);D.videoList.push({id:F,state:"生成中",src:""}),window.$message.success($t("workbench.generate.generateStarted"))}catch(B){window.$message.error((B==null?void 0:B.message)??"视频发起生成请求失败")}finally{}})},onCancel:()=>T.destroy()})}function L(T){const D=d.value.map(Q=>Q.id).filter(Q=>Q!=null);l.value=T?D:[]}function S(T,D){if(T==null)return;D?l.value.includes(T)||l.value.push(T):l.value=l.value.filter(M=>M!==T);const Q=d.value.map(M=>M.id).filter(M=>M!=null);f.value=Q.length>0&&Q.every(M=>l.value.includes(M))}return At(()=>d.value.map(T=>({selectVideoId:T.selectVideoId,videoList:T.videoList})),()=>{d.value.forEach(T=>{const D=k(T);D&&A(D)})},{deep:!0,immediate:!0}),(T,D)=>{const Q=pO,M=vi,B=Gd,P=kn("i-video"),F=Wu,R=kn("i-volume-notice"),N=kn("i-close"),I=kn("i-plus"),W=yh;return Ce(),We("div",mFs,[c(W,{bordered:"",style:{height:"100%"}},{default:ve(()=>[he("div",kFs,[he("div",vFs,[c(Q,{modelValue:ge(f),"onUpdate:modelValue":D[0]||(D[0]=V=>Dn(f)?f.value=V:null),onChange:L},{default:ve(()=>[kt(De(T.$t("workbench.generate.selectAll")),1)]),_:1},8,["modelValue"]),ge(l).length?(Ce(),We("span",pFs,De(T.$t("workbench.generate.selected"))+" "+De(ge(l).length)+" 段",1)):Vt("",!0)]),he("div",bFs,[c(M,{size:"small",variant:"outline",onClick:w},{default:ve(()=>[kt(De(T.$t("workbench.generate.batchDownloadVideo")),1)]),_:1}),c(M,{size:"small",variant:"outline",onClick:y},{default:ve(()=>[kt(De(T.$t("workbench.generate.batchGenerateText")),1)]),_:1}),c(M,{size:"small",variant:"outline",onClick:x},{default:ve(()=>[kt(De(T.$t("workbench.generate.batchGenerateVideo")),1)]),_:1})])]),he("div",OFs,[(Ce(!0),We(nn,null,bi(d.value,(V,z)=>(Ce(),We("div",{class:uo(["item",{active:z===a.value}]),key:V.id,onClick:Y=>m(z)},[c(Q,{class:"trackCheck",checked:V.id!=null&&ge(l).includes(V.id),onClick:D[1]||(D[1]=or(()=>{},["stop"])),onChange:Y=>S(V.id,Y)},null,8,["checked","onChange"]),c(B,{class:"indexTag",size:"small"},{default:ve(()=>[kt("#"+De(z+1),1)]),_:2},1024),V.selectVideoId?(Ce(),St(B,{key:0,class:"selectTag",theme:"success",size:"small"},{default:ve(()=>[...D[2]||(D[2]=[kt("已选择",-1)])]),_:1})):Vt("",!0),V.selectVideoId&&k(V)?(Ce(),We("div",yFs,[ge(g)[k(V)]?(Ce(),We("img",{key:0,class:"thumb selectedVideoThumb",src:ge(g)[k(V)],draggable:"false"},null,8,CFs)):(Ce(),We("div",xFs,[c(P,{size:"24"})]))])):V.medias.some(Y=>Y.src)?(Ce(),We("div",LFs,[(Ce(!0),We(nn,null,bi(V.medias,(Y,K)=>(Ce(),We(nn,{key:K},[Y.src?(Ce(),We(nn,{key:0},[Y.fileType==="image"?(Ce(),St(F,{key:0,fit:"cover",src:Y.src,class:"thumb"},null,8,["src"])):(Ce(),We("div",SFs,[Y.fileType==="audio"?(Ce(),St(R,{key:0,size:"20"})):(Ce(),St(P,{key:1,size:"24"}))]))],64)):Vt("",!0)],64))),128))])):(Ce(),We("span",TFs,De(T.$t("workbench.generate.emptyTrack",{index:z+1})),1)),he("div",{class:"deleteBtn",onClick:or(Y=>p(z),["stop"])},[c(N,{size:"14"})],8,EFs)],10,wFs))),128)),he("div",{class:"item addItem c",onClick:b},[c(I,{size:"36"})])])]),_:1})])}}}),QFs=Fr(DFs,[["__scopeId","data-v-1137311f"]]),BFs={class:"imageUploadBox ac"},FFs={key:2,class:"imageToolsWrap"},PFs=["onClick"],MFs={class:"source"},RFs=["onClick"],IFs={key:0,style:{flex:"1"},class:"ac"},NFs=["src"],UFs={key:2,class:"imageToolsWrap"},jFs=["onClick"],WFs={class:"source"},HFs={class:"storyboardGrid"},VFs=["onClick"],zFs={key:0,class:"imageToolsWrap"},ZFs=["src"],YFs={key:2,class:"textBox ac jc"},XFs={style:{"font-size":"20px"}},qFs=Xe({__name:"imageSelect",props:ha({mode:{},storyboardList:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const t=e,n=Dc(e,"modelValue"),r=de(!1),o={fileType:"image",id:null,src:""};function s(b){return!b||!b.id}const a=G(()=>{const b=t.mode==="startFrameOptional",O=t.mode==="endFrameOptional";return[{label:b?"首帧(可选)":"首帧",value:"start"},{label:O?"尾帧(可选)":"尾帧",value:"end"}]});function l(){const b=[...n.value];for(;b.length<2;)b.push({...o});return b}function d(b,O){const w=l();w[b==="start"?0:1]=O,n.value=w}function u(b){if(!b)return null;try{const O=JSON.parse(b);if(Array.isArray(O))return O}catch{return b}return b}const h=G(()=>{const b=t.mode;return!(b=="singleImage"&&n.value.length>=1||b=="endFrameOptional"||b=="startEndRequired"||b=="startFrameOptional"||b=="text")});function f(b){var w;const O=((w=b==null?void 0:b.split(".").pop())==null?void 0:w.toLowerCase())??"";return["mp4","webm","mov","avi","mkv"].includes(O)?"video":["mp3","wav","ogg","aac","flac","m4a"].includes(O)?"audio":"image"}const g=G(()=>{const b=t.mode;if(!Array.isArray(b))return[];const O={audioReference:"audio",imageReference:"image",videoReference:"video"};return b.filter(w=>w in O).map(w=>O[w])});let k="";function A(b=""){if(!t.mode)return window.$message.error($t("workbench.generate.notSelectMode"));k=b;const O=Array.isArray(u(t.mode)),w=_r.confirm({header:$t("workbench.generate.selectSource"),confirmBtn:$t("workbench.generate.confirm"),cancelBtn:$t("workbench.generate.cancel"),onConfirm:async()=>{w.destroy();const y=await Fre({types:["role","tool","scene","clip"],clipMediaTypes:g.value,multiple:O});if(!y.length)return;const C=y.map(x=>({fileType:f(x.src),sources:"assets",src:x.src,id:x.id,prompt:x.prompt}));b==="start"||b==="end"?d(b,C[0]):t.mode==="singleImage"?n.value=[C[0]]:n.value=[...n.value,...C]},onCancel:()=>{w.destroy(),r.value=!0}})}function m(b){const O=l();O[b]={...o},n.value=O}function v(b){r.value=!1;const w={fileType:"image",sources:"storyboard",src:b.src,id:b.id,prompt:b.videoDesc??void 0,index:b.index};k==="start"||k==="end"?d(k,w):n.value=[...n.value,w]}function p(b){const O=[...n.value];O.splice(b,1),n.value=O}return(b,O)=>{const w=Wu,y=Ha,C=kn("i-close"),x=Gd,L=kn("i-plus"),S=qa;return Ce(),We("div",BFs,[e.mode=="singleImage"||Array.isArray(u(e.mode))?(Ce(!0),We(nn,{key:0},bi(e.mode=="singleImage"?n.value.slice(0,1):n.value,(T,D)=>(Ce(),We("div",{class:"uploadBtn c fc",key:D},[T.src?(Ce(),St(w,{key:0,src:T.src,fit:"contain",class:"uploadPreview"},{overlayContent:ve(()=>[...O[2]||(O[2]=[])]),_:1},8,["src"])):(Ce(),St(y,{key:1,theme:"primary",content:(T==null?void 0:T.prompt)||""},{default:ve(()=>[...O[3]||(O[3]=[he("span",{style:{"font-size":"20px"}},"文",-1)])]),_:1},8,["content"])),T.sources=="storyboard"&&T.index!=null?(Ce(),We("div",FFs,De(`P${T.index+1}`),1)):Vt("",!0),he("div",{class:"clearBtn",onClick:Q=>p(D)},[c(C,{size:"12"})],8,PFs),he("div",MFs,[c(x,{size:"small"},{default:ve(()=>[kt(De(T.sources=="storyboard"?b.$t("workbench.generate.storyboard"):b.$t("workbench.generate.assets")),1)]),_:2},1024)])]))),128)):e.mode=="endFrameOptional"||e.mode=="startFrameOptional"||e.mode=="startEndRequired"?(Ce(!0),We(nn,{key:1},bi(ge(a),(T,D)=>{var Q,M,B,P,F,R,N,I,W,V,z;return Ce(),We("div",{class:"uploadBtn c fc",key:T.value,onClick:Y=>A(T.value)},[s((Q=n.value)==null?void 0:Q[D])?(Ce(),We(nn,{key:1},[c(L,{size:"24"}),kt(" "+De(T.label),1)],64)):(Ce(),We("div",IFs,[(B=(M=n.value)==null?void 0:M[D])!=null&&B.src?(Ce(),We("img",{key:0,class:"uploadPreview",src:(P=n.value)==null?void 0:P[D].src},null,8,NFs)):(Ce(),St(y,{key:1,theme:"primary",content:((R=(F=n.value)==null?void 0:F[D])==null?void 0:R.prompt)||""},{default:ve(()=>[...O[4]||(O[4]=[he("span",{style:{"font-size":"20px"}},"文",-1)])]),_:1},8,["content"])),((I=(N=n.value)==null?void 0:N[D])==null?void 0:I.sources)=="storyboard"&&((V=(W=n.value)==null?void 0:W[D])==null?void 0:V.index)!=null?(Ce(),We("div",UFs,De(`P${((z=n.value[D])==null?void 0:z.index)+1}`),1)):Vt("",!0),he("div",{class:"clearBtn",onClick:or(Y=>m(D),["stop"])},[c(C,{size:"12"})],8,jFs),he("div",WFs,[c(x,{size:"small"},{default:ve(()=>{var Y,K;return[kt(De(((K=(Y=n.value)==null?void 0:Y[D])==null?void 0:K.sources)=="storyboard"?b.$t("workbench.generate.storyboard"):b.$t("workbench.generate.assets")),1)]}),_:2},1024)])]))],8,RFs)}),128)):Vt("",!0),ge(h)?(Ce(),We("div",{key:2,class:"uploadBtn c fc",onClick:O[0]||(O[0]=T=>A())},[c(L,{size:"24"}),kt(" "+De(b.$t("workbench.generate.addReference")),1)])):Vt("",!0),c(S,{visible:r.value,"onUpdate:visible":O[1]||(O[1]=T=>r.value=T),header:b.$t("workbench.generate.selectStoryboard"),footer:!1,width:"800px",placement:"center"},{default:ve(()=>[he("div",HFs,[(Ce(!0),We(nn,null,bi(e.storyboardList,T=>(Ce(),We("div",{class:"storyboardItem",key:T.id,onClick:D=>v(T)},[(T==null?void 0:T.index)!=null?(Ce(),We("div",zFs,De(`P${(T==null?void 0:T.index)+1}`),1)):Vt("",!0),T.src?(Ce(),We("img",{key:1,src:T.src},null,8,ZFs)):(Ce(),We("div",YFs,[c(y,{theme:"primary",content:(T==null?void 0:T.videoDesc)||""},{default:ve(()=>[he("span",XFs,De(`分镜 ${(T==null?void 0:T.index)+1||""}`),1)]),_:2},1032,["content"])]))],8,VFs))),128))])]),_:1},8,["visible","header"])])}}}),GFs=Fr(qFs,[["__scopeId","data-v-93201310"]]),KFs={class:"modeMenu"},JFs={class:"left f ac"},_Fs={class:"model"},$Fs={class:"status"},ePs={class:"resolutionDurationPicker"},tPs={key:0,class:"pickerSection"},nPs={class:"pickerLabel"},iPs={class:"pickerOptions"},rPs=["onClick"],oPs={key:1,class:"pickerSection"},sPs={class:"pickerLabel"},aPs={class:"pickerOptions"},lPs=["onClick"],cPs=Xe({__name:"modeMenu",props:ha({modeOptions:{},modeList:{},trackId:{}},{modelValue:{default:{mode:"",model:"",resolution:"480p",duration:8,audio:!1}},modelModifiers:{}}),emits:ha(["modeChange"],["update:modelValue"]),setup(e,{emit:t}){const n=e,r=Dc(e,"modelValue"),o=t;function s(l){o("modeChange",l)}function a(l){r.value.duration=l,n.trackId&&on.post("/production/workbench/updateVideoDuration",{id:n.trackId,duration:l})}return(l,d)=>{const u=W8,h=tC,f=_1,g=kn("i-volume-notice"),k=kn("i-volume-mute"),A=vi,m=Gd,v=bg;return Ce(),We("div",KFs,[he("div",JFs,[he("div",_Fs,[c(u,{modelValue:r.value.model,"onUpdate:modelValue":d[0]||(d[0]=p=>r.value.model=p),type:"video",size:"small"},null,8,["modelValue"])]),c(f,{size:"small",class:"mode",value:r.value.mode,onChange:s},{default:ve(()=>[(Ce(!0),We(nn,null,bi(e.modeList,(p,b)=>(Ce(),St(h,{key:b,value:p.value,label:p.label},null,8,["value","label"]))),128))]),_:1},8,["value"]),c(A,{size:"small",variant:"outline",theme:r.value.audio?"success":"danger",class:"audio",onClick:d[1]||(d[1]=p=>r.value.audio=!r.value.audio)},{icon:ve(()=>[r.value.audio?(Ce(),St(g,{key:0,size:"16"})):(Ce(),St(k,{key:1,size:"16"}))]),_:1},8,["theme"]),he("div",$Fs,[c(v,{trigger:"click",placement:"top","overlay-class-name":"resDurPickerPopup","overlay-inner-style":{padding:"16px",borderRadius:"8px"}},{content:ve(()=>[he("div",ePs,[Array.isArray(e.modeOptions.durationResolutionMap)&&e.modeOptions.durationResolutionMap.length>0&&e.modeOptions.durationResolutionMap[0].resolution&&e.modeOptions.durationResolutionMap[0].resolution.length>0?(Ce(),We("div",tPs,[he("div",nPs,De(l.$t("workbench.generate.resolution")),1),he("div",iPs,[(Ce(!0),We(nn,null,bi(e.modeOptions.durationResolutionMap[0].resolution,p=>(Ce(),We("div",{key:p,class:uo(["pickerOption",{active:r.value.resolution==p}]),onClick:b=>r.value.resolution=p},De(p),11,rPs))),128))])])):Vt("",!0),Array.isArray(e.modeOptions.durationResolutionMap)&&e.modeOptions.durationResolutionMap.length>0&&e.modeOptions.durationResolutionMap[0].duration&&e.modeOptions.durationResolutionMap[0].duration.length>0?(Ce(),We("div",oPs,[he("div",sPs,De(l.$t("workbench.generate.duration")),1),he("div",aPs,[(Ce(!0),We(nn,null,bi(e.modeOptions.durationResolutionMap[0].duration,p=>(Ce(),We("div",{key:p,class:uo(["pickerOption",{active:r.value.duration==p}]),onClick:b=>a(p)},De(p)+"s ",11,lPs))),128))])])):Vt("",!0)])]),default:ve(()=>[c(m,{class:"btn",variant:"outline"},{default:ve(()=>[kt(De(r.value.resolution)+"·"+De(r.value.duration)+"s",1)]),_:1})]),_:1})])])])}}}),dPs=Fr(cPs,[["__scopeId","data-v-3ff4eca5"]]),uPs={class:"history"},hPs={class:"titleBox f ac"},APs={class:"title"},fPs={class:"historyItemBox"},gPs=["onClick"],mPs=["src"],kPs=["src","onSeeked"],vPs={key:2,class:"loadingOverlay c fc"},pPs={class:"loadingText"},bPs=["onClick"],OPs=["onClick"],wPs=["onClick"],yPs=["onClick"],CPs={class:"videoPlayerBox"},xPs=["src"],LPs=Xe({__name:"video",props:ha({activeTrackIndex:{},generating:{type:Boolean}},{currentTrack:{default:()=>{}},currentTrackModifiers:{}}),emits:ha(["generate","refresh"],["update:currentTrack"]),setup(e,{emit:t}){const n=Dc(e,"currentTrack"),r=t,{project:o}=Pr(Ad()),s=mt("episodesId"),a=de(),l=de({}),d=de(!1),u=de();async function h(p){var b;if(!(p.state==="生成中"||p.state==="生成失败"))try{await on.post("/production/workbench/selectVideo",{projectId:(b=o.value)==null?void 0:b.id,scriptId:s.value??0,videoId:p.id,trackId:n==null?void 0:n.value.id}),window.$message.success($t("workbench.generate.selectVideoSuccess")),r("refresh")}catch{window.$message.error($t("workbench.generate.selectVideoFailed"))}}function f(p){const b=_r.confirm({header:$t("workbench.generate.del"),body:$t("workbench.generate.delVideo"),onConfirm:()=>{on.post("/production/workbench/delVideo",{id:p.id}).then(()=>{window.$message.success($t("workbench.generate.delSuccess")),r("refresh"),b.destroy(),n.value.videoList.filter(O=>O.id==p.id)})},onCancel:()=>b.destroy()})}async function g(p){const O=await(await fetch(p.src)).blob(),w=document.createElement("a");w.href=URL.createObjectURL(O),w.download="视频.mp4",document.body.appendChild(w),w.click(),document.body.removeChild(w),URL.revokeObjectURL(w.href)}function k(p){if(!p||l.value[p])return;const b=document.createElement("video");b.crossOrigin="anonymous",b.preload="auto",b.muted=!0,b.src=p,b.addEventListener("seeked",()=>{try{const O=document.createElement("canvas");O.width=b.videoWidth||160,O.height=b.videoHeight||90;const w=O.getContext("2d");w&&(w.drawImage(b,0,0,O.width,O.height),l.value[p]=O.toDataURL("image/jpeg",.7))}catch{}b.src=""},{once:!0}),b.addEventListener("loadeddata",()=>{b.currentTime=.5},{once:!0}),b.addEventListener("error",()=>{b.src=""},{once:!0}),b.load()}function A(p){p.src&&(u.value=p.src,d.value=!0)}function m(){u.value=void 0}function v(p){p.state==="生成中"||p.state}return(p,b)=>{const O=vi,w=kn("i-time"),y=qc,C=Gd,x=Ha,L=kn("i-check"),S=kn("i-delete"),T=kn("i-to-bottom"),D=kn("i-play"),Q=yh,M=qa;return Ce(),We(nn,null,[c(Q,{title:"#"+(e.activeTrackIndex+1)+p.$t("workbench.generate.videoMenu"),"header-bordered":"",style:{height:"100%"}},{actions:ve(()=>[c(O,{size:"small",loading:e.generating,onClick:b[0]||(b[0]=B=>r("generate"))},{default:ve(()=>[kt(De(p.$t("workbench.generate.generate")),1)]),_:1},8,["loading"])]),default:ve(()=>{var B,P;return[he("div",uPs,[he("div",hPs,[c(w),he("span",APs,De(p.$t("workbench.generate.history"))+"("+De((B=n.value)==null?void 0:B.videoList.length)+")",1)]),he("div",fPs,[(Ce(!0),We(nn,null,bi((P=n.value)==null?void 0:P.videoList,F=>(Ce(),We("div",{class:uo(["historyItem",{active:F.id===ge(a),generating:F.state==="生成中",failed:F.state==="生成失败"}]),key:F.id,onClick:R=>v(F)},[ge(l)[F.src]?(Ce(),We("img",{key:0,src:ge(l)[F.src],class:"videoCover"},null,8,mPs)):F.state!=="生成中"?(Ce(),We("video",{key:F.src,src:F.src,preload:"metadata",muted:"",onLoadedmetadata:b[1]||(b[1]=R=>{R.target.currentTime=.5}),onSeeked:R=>{const N=R.target;k(F.src),N.style.display="none"}},null,40,kPs)):Vt("",!0),F.state==="生成中"?(Ce(),We("div",vPs,[c(y,{size:"24px"}),he("span",pPs,De(p.$t("workbench.generate.generating")),1)])):Vt("",!0),F.state=="生成失败"?(Ce(),St(x,{key:3,placement:"top",content:(F==null?void 0:F.errorReason)??"",theme:"light"},{default:ve(()=>[c(C,{class:"stateTag",theme:"danger",size:"small"},{default:ve(()=>[kt(De(p.$t("workbench.generate.generateFailed")),1)]),_:1})]),_:1},8,["content"])):Vt("",!0),F.state!=="生成中"?(Ce(),We("div",{key:4,class:"selectBtn",onClick:or(R=>h(F),["stop"])},[c(L,{size:"16"})],8,bPs)):Vt("",!0),he("div",{class:"delBtn",onClick:or(R=>f(F),["stop"])},[c(S,{size:"16"})],8,OPs),F.state!=="生成中"&&F.state!=="生成失败"?(Ce(),We("div",{key:5,class:"download",onClick:or(R=>g(F),["stop"])},[c(T,{size:"16"})],8,wPs)):Vt("",!0),F.state!=="生成中"&&F.state!=="生成失败"?(Ce(),We("div",{key:6,class:"playBtn",onClick:or(R=>A(F),["stop"])},[c(D,{size:"16"})],8,yPs)):Vt("",!0)],10,gPs))),128))])])]}),_:1},8,["title"]),c(M,{visible:ge(d),"onUpdate:visible":b[2]||(b[2]=B=>Dn(d)?d.value=B:null),header:p.$t("workbench.generate.previewVideo"),footer:!1,width:"800px","destroy-on-close":"",onClose:m},{default:ve(()=>[he("div",CPs,[ge(u)?(Ce(),We("video",{key:0,src:ge(u),controls:"",autoplay:"",class:"videoPlayer"},null,8,xPs)):Vt("",!0)])]),_:1},8,["visible","header"])],64)}}}),SPs=Fr(LPs,[["__scopeId","data-v-74ac2df8"]]),TPs={class:"index fc"},EPs={class:"referenceImage"},DPs={class:"uploadBtn"},QPs={class:"modelSelect"},BPs={class:"generate ac"},FPs={key:0,class:"prompt"},PPs={class:"promptData fc"},MPs={class:"video"},RPs={class:"track"},IPs=Xe({__name:"index",setup(e){const{project:t}=Pr(Ad()),n=mt("episodesId"),r=de(0),o=E_n(),{getCache:s,setCache:a,removeCache:l,initCacheFromTrackList:d,warmUpUrls:u}=o,{urlMap:h}=Pr(o),f=de({name:"",modelName:"",durationResolutionMap:[],audio:!1,type:"video",mode:[]}),g=de([]),k=de({mode:"",model:"",resolution:"480p",duration:8,audio:!1}),A=de([]);function m(I){return I.src?I.sources==="assets"?0:1:2}const v=G({get(){var Y,K,X;h.value;const I=(Y=O.value)==null?void 0:Y.id,W=(K=t.value)==null?void 0:K.id,V=n.value;if(W!=null&&V!=null&&I!=null){const _=s(W,V,I);if(_!=null&&_.length)return _.sort((q,re)=>m(q)-m(re)),_}const z=(X=O.value)==null?void 0:X.medias;return z!=null&&z.length?(z.sort((_,q)=>m(_)-m(q)),z):[]},set(I){var W;if(O.value){O.value.medias=I;const V=(W=t.value)==null?void 0:W.id,z=n.value,Y=O.value.id;V!=null&&z!=null&&Y!=null&&a(V,z,Y,I)}}});function p(I){var W;if(I!=k.value.mode)if((v.value.length||(W=O.value)!=null&&W.prompt)&&k.value.mode){const V=_r.confirm({header:$t("workbench.generate.modeChange"),body:$t("workbench.generate.modeChangeConfirm"),confirmBtn:$t("settings.generate.modelChnageSure"),cancelBtn:$t("settings.memory.msg.cancel"),onConfirm:async()=>{v.value=[],O.value.prompt="",V.destroy(),k.value.mode=I}})}else I&&(k.value.mode=I)}const b=G(()=>{const I={singleImage:"单图",startEndRequired:"首尾帧",endFrameOptional:"尾帧可选",startFrameOptional:"首帧可选",text:"文本生视频",videoReference:"视频",imageReference:"图片",audioReference:"音频",textReference:"文本"};function W(V){const z=V.match(/^(videoReference|imageReference|audioReference|textReference):(\d+)$/);return z?`${I[z[1]]||z[1]} ×${z[2]}`:I[V]||V}return f.value.mode?f.value.mode.map(V=>Array.isArray(V)?{value:JSON.stringify(V),label:V.map(z=>W(z)).join(" + ")+"参考"}:{value:V,label:I[V]||V}):[]}),O=G({get(){return g.value[r.value]},set(I){g.value[r.value]=I}}),w=G(()=>{var W;const I=(W=g.value[r.value])==null?void 0:W.id;return I!=null?!!T.value[I]:!1});function y(I){var V,z;const W=(V=f.value)==null?void 0:V.durationResolutionMap;if(Array.isArray(W)&&W.length>0&&((z=W[0].duration)!=null&&z.length)){const Y=W[0].duration;return Math.max(Math.min(...Y),Math.min(I,Math.max(...Y)))}return I}At(()=>k.value.model,I=>{if(!I){f.value={name:"",modelName:"",durationResolutionMap:[],audio:!1,type:"video",mode:[]},k.value.mode="";return}on.post("/modelSelect/getModelDetail",{modelId:I}).then(({data:W})=>{var K,X;f.value=W,k.value.audio=W.audio===!0||W.audio==="true"||W.audio=="optional";const V=W.durationResolutionMap;Array.isArray(V)&&V.length>0&&((K=V[0].resolution)!=null&&K.length&&(k.value.resolution=V[0].resolution[0]),(X=V[0].duration)!=null&&X.length&&(k.value.duration=y(k.value.duration)));const z=C(k.value.mode);if(!(z!==null&&W.mode.some(_=>Array.isArray(_)&&Array.isArray(z)?JSON.stringify(_)===JSON.stringify(z):_==z))){const _=Array.isArray(W.mode[0])?JSON.stringify(W.mode[0]):W.mode[0];p(_)}})});function C(I){if(!I)return null;try{const W=JSON.parse(I);if(Array.isArray(W))return W}catch{return I}return I}const x=G(()=>{function I(W){var z;const V=((z=W==null?void 0:W.split(".").pop())==null?void 0:z.toLowerCase())??"";return["mp4","webm","mov","avi","mkv"].includes(V)?"video":["mp3","wav","ogg","aac","flac","m4a"].includes(V)?"audio":"image"}return v.value.filter(W=>W.src).map(W=>({type:I(W.src),src:W.src??""}))});async function L(){var z,Y,K,X;const{data:I}=await on.post("/production/workbench/getGenerateData",{projectId:(z=t.value)==null?void 0:z.id,scriptId:n.value??0});A.value=I.storyboardList;const W=(Y=t.value)==null?void 0:Y.id,V=n.value;W!=null&&V!=null&&(d(W,V,I.trackList),await u(W,V),I.trackList.forEach(_=>{if(_.id==null)return;const q=s(W,V,_.id);q!=null&&q.length&&(_.medias=q)}),g.value=[...I.trackList]),k.value.duration=y((X=(K=I.trackList)==null?void 0:K[r.value])==null?void 0:X.duration)}function S(){var W,V;const I=(W=g.value[r.value])==null?void 0:W.id;I!=null&&on.post("/production/workbench/updateVideoPrompt",{id:I,prompt:(V=O.value)==null?void 0:V.prompt})}const T=de({});async function D(){var z;if(O.value.id==null||T.value[O.value.id])return;let I=[];const W=O.value.id,V=O.value;k.value.mode=="text"?I=V==null?void 0:V.medias.map(({id:Y,sources:K})=>({id:Y,sources:K})):I=k.value.mode==="text"?[]:(()=>{const Y=["startEndRequired","endFrameOptional","startFrameOptional"],X=(Y.includes(k.value.mode)?v.value.slice(0,2):k.value.mode==="singleImage"?v.value.slice(0,1):v.value).filter(_=>_.id).map(({id:_,sources:q})=>({id:_,sources:q}));return Y.includes(k.value.mode)?X.slice(0,2):k.value.mode==="singleImage"?X.slice(0,1):X})(),T.value[W]=!0;try{const{data:Y}=await on.post("/production/workbench/generateVideoPrompt",{projectId:(z=t.value)==null?void 0:z.id,trackId:W,info:I,model:k.value.model});V.prompt=Y}catch(Y){window.$message.error((Y==null?void 0:Y.message)??"提示词生成失败")}finally{T.value[W]=!1}}function Q(I){var Y,K,X,_;if(I!=null){const q=g.value[I],re=(Y=t.value)==null?void 0:Y.id,le=n.value;re!=null&&le!=null&&(q==null?void 0:q.id)!=null&&a(re,le,q.id,q.medias)}const W=(K=t.value)==null?void 0:K.id,V=n.value,z=g.value[r.value];if(W!=null&&V!=null&&(z==null?void 0:z.id)!=null){const q=s(W,V,z.id);q&&(z.medias=q)}k.value.mode=="singleImage"&&v.value.length>1&&(v.value=v.value.slice(0,1)),k.value.duration=y((_=(X=g.value)==null?void 0:X[r.value])==null?void 0:_.duration)}At(()=>{var I;return(I=O.value)==null?void 0:I.medias},I=>{var Y,K;if(!I)return;const W=(Y=t.value)==null?void 0:Y.id,V=n.value,z=(K=O.value)==null?void 0:K.id;W!=null&&V!=null&&z!=null&&a(W,V,z,I)},{deep:!0}),mn(()=>{var I,W;k.value.model=((I=t.value)==null?void 0:I.videoModel)||"",k.value.mode=((W=t.value)==null?void 0:W.mode)||"",L(),R.value&&R.value.length&&P()});async function M(){const I=_r.confirm({header:$t("workbench.generate.generateConfirm"),body:$t("workbench.generate.generateConfirmBody"),onConfirm:async()=>{var W;I.destroy();try{const{data:V}=await on.post("/production/workbench/generateVideo",{projectId:(W=t.value)==null?void 0:W.id,scriptId:n.value,uploadData:k.value.mode==="text"?[]:(()=>{const z=["startEndRequired","endFrameOptional","startFrameOptional"],K=(z.includes(k.value.mode)?v.value.slice(0,2):k.value.mode==="singleImage"?v.value.slice(0,1):v.value).filter(X=>!!X.src&&X.id).map(({id:X,sources:_})=>({id:X,sources:_}));return z.includes(k.value.mode)?K.slice(0,2):k.value.mode==="singleImage"?K.slice(0,1):K})(),prompt:O.value.prompt,model:k.value.model,mode:k.value.mode,resolution:k.value.resolution,duration:k.value.duration,audio:k.value.audio,trackId:O.value.id});window.$message.success($t("workbench.generate.generateStarted")),O.value.videoList.push({id:V,state:"生成中",src:""})}catch(V){window.$message.error((V==null?void 0:V.message)??"视频发起生成请求失败")}finally{}},onCancel:()=>I.destroy()})}let B=null;function P(){B===null&&(B=setInterval(()=>N(),3e3))}function F(){B&&(clearInterval(B),B=null)}const R=G(()=>g.value.map(I=>I.videoList.filter(W=>W.state=="生成中").map(W=>W.id)).flatMap(I=>I));async function N(){var W;const{data:I}=await on.post("/production/workbench/checkVideoStateList",{projectId:(W=t.value)==null?void 0:W.id,scriptId:n.value??0,videoIds:R.value});I&&I.length&&I.forEach(V=>{for(const z of g.value){const Y=z.videoList.find(K=>K.id==V.id);if(Y){Y.state=V.state,Y.src=(V==null?void 0:V.src)??"",Y.errorReason=(V==null?void 0:V.errorReason)??"";break}}})}return At(()=>R.value,I=>{I&&I.length>0?P():F()}),Pa(()=>{F()}),(I,W)=>{var Y;const V=vi,z=yh;return Ce(),We("div",TPs,[he("div",EPs,[he("div",DPs,[c(GFs,{mode:ge(k).mode,modelValue:ge(v),"onUpdate:modelValue":W[0]||(W[0]=K=>Dn(v)?v.value=K:null),"storyboard-list":ge(A)},null,8,["mode","modelValue","storyboard-list"])])]),he("div",QPs,[c(dPs,{modelValue:ge(k),"onUpdate:modelValue":W[1]||(W[1]=K=>Dn(k)?k.value=K:null),modeOptions:ge(f),trackId:(Y=ge(O))==null?void 0:Y.id,modeList:ge(b),onModeChange:p},null,8,["modelValue","modeOptions","trackId","modeList"])]),he("div",BPs,[ge(O)?(Ce(),We("div",FPs,[c(z,{title:"#"+(ge(r)+1)+I.$t("workbench.generate.generateText"),"header-bordered":"",class:"videoPrompt"},{actions:ve(()=>[c(V,{size:"small",class:"genTextbtn",loading:ge(w),onClick:D},{default:ve(()=>[kt(De(I.$t("workbench.generate.generateText")),1)]),_:1},8,["loading"])]),default:ve(()=>[he("div",PPs,[he("div",{class:"promptInput",onFocusout:S},[c(PJn,{modelValue:ge(O).prompt,"onUpdate:modelValue":W[2]||(W[2]=K=>ge(O).prompt=K),references:ge(x),placeholder:I.$t("workbench.generate.promptPlaceholder")},null,8,["modelValue","references","placeholder"])],32)])]),_:1},8,["title"])])):Vt("",!0),he("div",MPs,[ge(O)?(Ce(),St(SPs,{key:0,"active-track-index":ge(r),"current-track":ge(O),"onUpdate:currentTrack":W[3]||(W[3]=K=>Dn(O)?O.value=K:null),onRefresh:L,onGenerate:M},null,8,["active-track-index","current-track"])):Vt("",!0)])]),he("div",RPs,[c(QFs,{activeTrackIndex:ge(r),"onUpdate:activeTrackIndex":W[4]||(W[4]=K=>Dn(r)?r.value=K:null),genTextLoadingMap:ge(T),"onUpdate:genTextLoadingMap":W[5]||(W[5]=K=>Dn(T)?T.value=K:null),modelValue:ge(g),"onUpdate:modelValue":W[6]||(W[6]=K=>Dn(g)?g.value=K:null),"image-list":ge(v),onChange:Q,modelParmas:ge(k),clampDuration:y,onGetData:L},null,8,["activeTrackIndex","genTextLoadingMap","modelValue","image-list","modelParmas"])])])}}}),NPs=Fr(IPs,[["__scopeId","data-v-52f5de32"]]);var UPs=Object.defineProperty,D_n=e=>{throw TypeError(e)},jPs=(e,t,n)=>t in e?UPs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ky=(e,t,n)=>jPs(e,typeof t!="symbol"?t+"":t,n),Pat=(e,t,n)=>t.has(e)||D_n("Cannot "+n),Jt=(e,t,n)=>(Pat(e,t,"read from private field"),n?n.call(e):t.get(e)),Oo=(e,t,n)=>t.has(e)?D_n("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),jr=(e,t,n,r)=>(Pat(e,t,"write to private field"),t.set(e,n),n),WPs=(e,t,n)=>(Pat(e,t,"access private method"),n);function Aoe(e=""){return`${e}${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function HPs(){return/Mac|iPod|iPhone|iPad/.test(navigator.platform)}function br(e){return Math.round(e*1e3)/1e3}const J1=RO("tracks",()=>{const e=de([]),t=de(new Set),n=de({clips:[],operation:null}),r=G(()=>e.value.find(_=>_.isMain)),o=G(()=>[...e.value].sort((_,q)=>{const re=me=>me.isMain?100:{effect:10,filter:20,sticker:30,subtitle:40,video:50,audio:200}[me.type]||0,le=re(_),ce=re(q);return le!==ce?le-ce:_.order-q.order})),s=G(()=>{let _=0;return e.value.forEach(q=>{q.clips.forEach(re=>{re.endTime>_&&(_=re.endTime)})}),_}),a=G(()=>{const _=[];return e.value.forEach(q=>{q.clips.forEach(re=>{t.value.has(re.id)&&_.push(re)})}),_});function l(_){if((_.type==="video"||_.type==="audio")&&"playbackRate"in _){const q=_,re=q.playbackRate||1;if(typeof q.trimStart=="number"&&typeof q.trimEnd=="number"){const le=q.trimEnd-q.trimStart,ce=br(le/re);return{...q,endTime:br(q.startTime+ce)}}}return _}function d(_){return _.map(q=>({...q,clips:q.clips?q.clips.map(l):[]}))}function u(_){e.value=d(_)}function h(_){_.clips&&_.clips.length>0&&(_.clips=_.clips.map(l)),e.value.push(_)}function f(_){const q=e.value.findIndex(re=>re.id===_);q!==-1&&e.value.splice(q,1)}function g(_,q){const re=e.value.find(le=>le.id===_);re&&Object.assign(re,q)}function k(_,q){const re=e.value.findIndex(ce=>ce.id===_);if(re===-1)return null;const le={id:`track-${Date.now()}`,type:q,name:`${q} ${m(q)+1}`,visible:!0,locked:!1,clips:[],order:re};return e.value.forEach(ce=>{ce.order>=re&&ce.order++}),e.value.splice(re,0,le),le}function A(_,q){const re=e.value.findIndex(ce=>ce.id===_);if(re===-1)return null;const le={id:`track-${Date.now()}`,type:q,name:`${q} ${m(q)+1}`,visible:!0,locked:!1,clips:[],order:re+1};return e.value.forEach(ce=>{ce.order>re&&ce.order++}),e.value.splice(re+1,0,le),le}function m(_){return e.value.filter(q=>q.type===_).length}function v(_,q){const re=e.value.find(le=>le.id===_);if(re){const le=l(q);re.clips.push(le)}}function p(_){e.value.forEach(q=>{const re=q.clips.findIndex(le=>le.id===_);if(re!==-1){const le=q.clips[re];if(le.type==="video"){q.clips.filter(me=>{if(me.type!=="transition")return!1;const ie=me,Ae=(ie.startTime+ie.endTime)/2,H=Math.abs(Ae-le.startTime){const ie=q.clips.findIndex(Ae=>Ae.id===me.id);ie!==-1&&(q.clips.splice(ie,1),t.value.delete(me.id))});const ce=q.clips.findIndex(me=>me.id===_);ce!==-1&&q.clips.splice(ce,1)}else q.clips.splice(re,1)}}),t.value.delete(_)}function b(_){_.forEach(q=>p(q))}function O(_,q){const re={..._};for(const le in q)if(Object.prototype.hasOwnProperty.call(q,le)){const ce=q[le],me=_[le];ce==null?re[le]=ce:typeof ce=="object"&&!Array.isArray(ce)&&typeof me=="object"&&me!==null&&!Array.isArray(me)?re[le]=O(me,ce):re[le]=ce}return re}function w(_,q){e.value.forEach(re=>{const le=re.clips.findIndex(ce=>ce.id===_);if(le!==-1){const ce=re.clips[le];re.clips[le]=O(ce,q)}})}function y(_,q){let re=null;for(const le of e.value){const ce=le.clips.findIndex(me=>me.id===_);if(ce!==-1){re=le.clips.splice(ce,1)[0],le.id;break}}if(re){const le=e.value.find(ce=>ce.id===q);le&&(re.trackId=q,le.clips.push(re))}}function C(_){for(const q of e.value){const re=q.clips.find(le=>le.id===_);if(re)return re}}function x(_,q=!1){q||t.value.clear(),t.value.add(_)}function L(_){t.value.has(_)?t.value.delete(_):t.value.add(_)}function S(_){t.value.delete(_)}function T(){t.value.clear()}function D(_,q,re,le){const ce=e.value.find(me=>me.id===_);return ce?ce.clips.some(me=>le&&me.id===le?!1:me.startTimeq):!1}function Q(){e.value=[],t.value.clear()}function M(){const _=[];e.value.forEach(q=>{q.isMain||q.clips.some(re=>re.type!=="transition")||_.push(q.id)}),_.forEach(q=>{f(q)})}function B(_){const q=_||Array.from(t.value);if(q.length===0)return!1;const re=[];return q.forEach(le=>{const ce=C(le);ce&&re.push(JSON.parse(JSON.stringify(ce)))}),re.length>0?(n.value={clips:re,operation:"copy"},!0):!1}function P(_){const q=_||Array.from(t.value);if(q.length===0)return!1;const re=[];return q.forEach(le=>{const ce=C(le);ce&&re.push(JSON.parse(JSON.stringify(ce)))}),re.length>0?(n.value={clips:re,operation:"cut"},!0):!1}function F(_,q,re,le=[]){const ce=e.value.find(H=>H.id===_);if(!ce)return q;const me=ce.clips.filter(H=>!le.includes(H.id)).sort((H,ee)=>H.startTime-ee.startTime);if(me.length===0)return q;let ie=q,Ae=q+re;for(const H of me)ieH.startTime&&(ie=H.endTime,Ae=ie+re);return Math.max(0,ie)}function R(_,q){if(n.value.clips.length===0)return null;const re=e.value.find(ee=>ee.id===_);if(!re)return null;const le=[],ce=()=>`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,me=Math.min(...n.value.clips.map(ee=>ee.startTime)),ie=Math.max(...n.value.clips.map(ee=>ee.endTime-me)),Ae=n.value.operation==="cut"?n.value.clips.map(ee=>ee.id):[],H=F(_,q,ie,Ae);return n.value.clips.forEach(ee=>{const oe=ee.endTime-ee.startTime,te=ee.startTime-me,J={...ee,id:ce(),trackId:_,startTime:H+te,endTime:H+te+oe,selected:!1};re.clips.push(J),le.push(J)}),n.value.operation==="cut"&&(n.value.clips.forEach(ee=>{p(ee.id)}),n.value={clips:[],operation:null}),le.length>0?le:null}function N(){return n.value.clips.length>0}function I(){return n.value}function W(){n.value={clips:[],operation:null}}function V(_,q){let re=null,le=null,ce=-1;for(const H of e.value){const ee=H.clips.findIndex(oe=>oe.id===_);if(ee!==-1){re=H.clips[ee],le=H,ce=ee;break}}if(!re||!le||ce===-1||q<=re.startTime||q>=re.endTime)return null;const me=()=>`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,ie={...JSON.parse(JSON.stringify(re)),endTime:q},Ae={...JSON.parse(JSON.stringify(re)),id:me(),startTime:q,selected:!1};if("trimStart"in re&&"trimEnd"in re&&"originalDuration"in re){const H=re,ee=H.endTime-H.startTime,oe=(H.trimEnd-H.trimStart)/ee,te=(q-H.startTime)*oe,J=H.trimStart+te;ie.trimEnd=J,Ae.trimStart=J}return le.clips.splice(ce,1,ie,Ae),t.value.has(_)&&(t.value.delete(_),t.value.add(ie.id)),{leftClip:ie,rightClip:Ae}}function z(_,q,re){const{allowShrink:le=!0,allowExpand:ce=!0,handleCollision:me=!0,keepStartTime:ie=!0}=re||{};if(q<.25||q>4)return{success:!1,message:"播放倍速必须在 0.25 到 4 之间"};let Ae=null,H=null;for(const Ge of e.value){const Ye=Ge.clips.find(_e=>_e.id===_);if(Ye){Ae=Ye,H=Ge;break}}if(!Ae||!H)return{success:!1,message:"未找到指定的 Clip"};if(Ae.type!=="video"&&Ae.type!=="audio")return{success:!1,message:"只有视频或音频类型的 Clip 可以调整倍速"};const ee=Ae,oe=ee.playbackRate||1;if(Math.abs(oe-q)<.001)return{success:!0};const te=ee.trimEnd-ee.trimStart,J=ee.endTime-ee.startTime,se=br(te/q),ke=se>J,ye=se{if(Ge.type!=="transition")return!1;const Ye=Ge,_e=(Ye.startTime+Ye.endTime)/2,vt=Math.abs(_e-ee.startTime)Ge.id!==_&&Ge.type!=="transition").sort((Ge,Ye)=>Ge.startTime-Ye.startTime),Re=Fe.filter(Ge=>QeGe.startTime);if(Re.length>0){if(!me)return{success:!1,message:"会与其他 Clip 产生碰撞"};const Ge=Re.filter(_e=>_e.startTime>=ee.startTime),Ye=xe-Math.min(...Ge.map(_e=>_e.startTime));if(Ye>0){const _e=Fe.filter(vt=>vt.startTime>=ee.endTime);for(const vt of _e){const Je=br(vt.startTime+Ye),tt=br(vt.endTime+Ye);w(vt.id,{startTime:Je,endTime:tt}),be.push({id:vt.id,startTime:Je,endTime:tt})}}}w(_,{playbackRate:q,startTime:Qe,endTime:xe});for(const Ge of Se){const Ye=Ge,_e=(Ye.startTime+Ye.endTime)/2,vt=H.clips.filter(Pt=>Pt.type!=="transition");({...ee});const Je=Math.abs(_e-ee.startTime)Ut.id!==_&&Math.abs(Ut.startTime-xe)<.01);if(yt=!!Pt,yt&&Pt){const Ut=(xe+Pt.startTime)/2,je=Ye.transitionDuration/2;w(Ge.id,{startTime:br(Ut-je),endTime:br(Ut+je)})}}else if(Je&&!ie){const Pt=vt.find(Ut=>Ut.id!==_&&Math.abs(Ut.endTime-Qe)<.01);if(yt=!!Pt,yt&&Pt){const Ut=(Pt.endTime+Qe)/2,je=Ye.transitionDuration/2;w(Ge.id,{startTime:br(Ut-je),endTime:br(Ut+je)})}}else Je&&ie&&(yt=!0);yt||(p(Ge.id),fe.push(Ge.id))}return{success:!0,removedTransitions:fe.length>0?fe:void 0,adjustedClips:be.length>0?be:void 0}}function Y(_,q){const re=C(_);if(!re||re.type!=="video"&&re.type!=="audio")return null;const le=re,ce=le.trimEnd-le.trimStart;return br(ce/q)}function K(_,q,re=!0){const le=C(_);if(!le||le.type!=="video"&&le.type!=="audio")return{willCollide:!1};const ce=le,me=ce.trimEnd-ce.trimStart,ie=br(me/q);let Ae,H;re?(Ae=ce.startTime,H=br(ce.startTime+ie)):(H=ce.endTime,Ae=br(Math.max(0,ce.endTime-ie)));let ee=null;for(const te of e.value)if(te.clips.some(J=>J.id===_)){ee=te;break}if(!ee)return{willCollide:!1,newDuration:ie};const oe=ee.clips.filter(te=>te.id!==_&&te.type!=="transition"&&Aete.startTime);return{willCollide:oe.length>0,collidingClipIds:oe.map(te=>te.id),newDuration:ie}}function X(_,q,re=1){const le=q-_;return br(le/re)}return{tracks:e,selectedClipIds:t,clipboard:n,mainTrack:r,sortedTracks:o,totalDuration:s,selectedClips:a,addTrack:h,addTrackAbove:k,addTrackBelow:A,removeTrack:f,updateTrack:g,getTrackCountByType:m,setTracks:u,normalizeTracks:d,normalizeClipDuration:l,addClip:v,removeClip:p,removeClips:b,updateClip:w,moveClipToTrack:y,getClip:C,selectClip:x,toggleClipSelection:L,deselectClip:S,clearSelection:T,hasOverlap:D,reset:Q,cleanupEmptyTracks:M,copyClips:B,cutClips:P,pasteClips:R,hasClipboardContent:N,getClipboardContent:I,clearClipboard:W,splitClip:V,setClipPlaybackRate:z,getClipDurationAtRate:Y,checkPlaybackRateCollision:K,calculateTrackDuration:X}}),Y6=RO("playback",()=>{const e=de(!1),t=de(0),n=de(1),r=de(0);let o=null,s=0;const a=G(()=>{const y=J1().totalDuration;return Math.max(y,r.value)}),l=G(()=>u(t.value)),d=G(()=>u(a.value));function u(y,C=30){const x=Math.floor(y*C),L=Math.floor(x/(C*3600)),S=Math.floor(x%(C*3600)/(C*60)),T=Math.floor(x%(C*60)/C),D=x%C;return`${String(L).padStart(2,"0")}:${String(S).padStart(2,"0")}:${String(T).padStart(2,"0")}:${String(D).padStart(2,"0")}`}function h(y){if(e.value){if(s>0){const C=(y-s)/1e3,x=t.value+C*n.value,L=a.value;if(x>=L){t.value=L,A();return}t.value=x}s=y,o=requestAnimationFrame(h)}}function f(){s=0,o=requestAnimationFrame(h)}function g(){o!==null&&(cancelAnimationFrame(o),o=null),s=0}function k(){e.value||(e.value=!0,f())}function A(){e.value&&(e.value=!1,g())}function m(){e.value?A():k()}function v(y){const C=a.value>0?a.value:1/0;t.value=Math.max(0,Math.min(y,C))}function p(y){n.value=y}function b(y){r.value=y}function O(y){const C=a.value;t.value=Math.max(0,Math.min(t.value+y,C))}function w(){A(),t.value=0,n.value=1,r.value=0}return{isPlaying:e,currentTime:t,playbackRate:n,duration:r,effectiveDuration:a,formattedCurrentTime:l,formattedDuration:d,formatTime:u,play:k,pause:A,togglePlay:m,seekTo:v,setPlaybackRate:p,setDuration:b,adjustTime:O,reset:w}}),WE=RO("history",()=>{const e=de([]),t=de(-1),n=de(50),r=G(()=>t.value>0),o=G(()=>t.valuen.value?e.value.shift():t.value++}function l(k){const A=J1(),m=JSON.parse(k.snapshot);A.tracks=m.tracks,A.selectedClipIds.clear(),m.selectedClipIds.forEach(v=>{A.selectedClipIds.add(v)})}function d(){if(!r.value)return;t.value--;const k=e.value[t.value];l(k)}function u(){if(!o.value)return;t.value++;const k=e.value[t.value];l(k)}function h(){e.value=[],t.value=-1,a("初始状态")}function f(){e.value=[],t.value=-1}function g(){f()}return{historyStack:e,currentIndex:t,maxHistorySize:n,canUndo:r,canRedo:o,createSnapshot:s,pushSnapshot:a,restoreSnapshot:l,undo:d,redo:u,initialize:h,clear:f,reset:g}}),Mat="video-track-scale-settings";function VPs(){try{const e=localStorage.getItem(Mat);if(e)return JSON.parse(e)}catch(e){console.warn("Failed to load scale settings from localStorage:",e)}return null}function zPs(e){try{localStorage.setItem(Mat,JSON.stringify(e))}catch(t){console.warn("Failed to save scale settings to localStorage:",t)}}const Q2=RO("scale",()=>{const e=VPs(),t=de((e==null?void 0:e.scale)??1),n=de(.1),r=de(10),o=de(100),s=de((e==null?void 0:e.snapEnabled)??!0),a=de(10);At([t,s],([y,C])=>{zPs({scale:y,snapEnabled:C})},{immediate:!1});const l=G(()=>o.value*t.value),d=G(()=>{const y=t.value;return y>=5?{majorInterval:1,minorInterval:1/30,majorHeight:20,minorHeight:8}:y>=2?{majorInterval:1,minorInterval:.1,majorHeight:20,minorHeight:10}:y>=1?{majorInterval:1,minorInterval:.2,majorHeight:20,minorHeight:10}:y>=.5?{majorInterval:2,minorInterval:.5,majorHeight:20,minorHeight:10}:y>=.2?{majorInterval:5,minorInterval:1,majorHeight:20,minorHeight:10}:{majorInterval:10,minorInterval:2,majorHeight:20,minorHeight:10}});function u(y){t.value=Math.max(n.value,Math.min(y,r.value))}function h(y=.1){u(t.value+y)}function f(y=.1){u(t.value-y)}function g(){s.value=!s.value}function k(y){s.value=y}function A(y){return y*l.value}function m(y){return y/l.value}function v(y,C){if(!s.value||C.length===0)return y;let x=y,L=a.value;for(const S of C){const T=Math.abs(y-S);T{const e=J1(),t=Q2(),n=WE(),r=de(!1),o=de([]),s=de(0),a=de(0),l=de(""),d=de(new Map),u=de(0),h=de(0),f=de({shift:!1}),g=de(!0),k=de({x:0,y:0}),A=de({enabled:!0,edgeThreshold:80,scrollSpeed:8,maxScrollSpeed:25}),m=de(null),v=de(null),p=de(null),b=de(null),O=de(0),w=de({trackId:"",startTime:0,endTime:0,needNewTrack:!1,visible:!1,clipType:""}),y=de("");let C=document;const x=G(()=>new Set(o.value.map(ce=>ce.id))),L=G(()=>!r.value||!w.value.visible?0:w.value.endTime);function S(ce){ce.enableCrossTrackDrag!==void 0&&(g.value=ce.enableCrossTrackDrag),ce.edgeScroll&&Object.assign(A.value,ce.edgeScroll)}function T(ce,me,ie){m.value=ce,v.value=me,b.value=ie||null}function D(ce){if(!v.value)return;const me=Math.max(0,v.value.scrollLeft+ce);v.value.scrollLeft=me,b.value&&b.value(me)}function Q(){if(!r.value||!A.value.enabled){P();return}const ce=m.value,me=v.value;if(!ce||!me)return;const ie=ce.getBoundingClientRect(),{edgeThreshold:Ae,scrollSpeed:H,maxScrollSpeed:ee}=A.value,oe=u.value-ie.left;let te=0;if(oe0){const J=Math.max(0,Ae-oe)/Ae;te=-Math.min(H+J*(ee-H),ee)}else if(oe>ie.width-Ae){const J=me.scrollWidth-me.clientWidth+500;if(me.scrollLeft40;let te=l.value;if(g.value&&oe){const ye=re(h.value);ye&&(te=ye)}y.value=te;let J=br(ee.startTime+Ae);t.snapEnabled&&!f.value.shift&&(J=q(J,H,te)),J=Math.max(0,J);const se=ee.endTime-ee.startTime,ke=J+se;N(te,J,ke,H.type)}function B(){p.value===null&&(p.value=requestAnimationFrame(Q))}function P(){p.value!==null&&(cancelAnimationFrame(p.value),p.value=null)}function F(ce,me,ie){var Ae;ce.type!=="transition"&&(C=ie||((Ae=me.target)==null?void 0:Ae.ownerDocument)||document,e.selectClip(ce.id),o.value=[ce],r.value=!0,s.value=me.clientX,a.value=me.clientY,u.value=me.clientX,h.value=me.clientY,l.value=ce.trackId,y.value=ce.trackId,d.value.clear(),d.value.set(ce.id,{startTime:ce.startTime,endTime:ce.endTime,trackId:ce.trackId}),k.value={x:0,y:0},O.value=0,w.value={trackId:ce.trackId,startTime:ce.startTime,endTime:ce.endTime,needNewTrack:!1,visible:!1,clipType:ce.type},C.addEventListener("mousemove",R),C.addEventListener("mouseup",V),B())}function R(ce){if(!r.value||o.value.length===0)return;f.value.shift=ce.shiftKey,u.value=ce.clientX,h.value=ce.clientY;const me=ce.clientX-s.value,ie=ce.clientY-a.value;k.value={x:me,y:ie};const Ae=(me+O.value)/t.actualPixelsPerSecond,H=o.value[0],ee=d.value.get(H.id);if(!ee)return;const oe=Math.abs(ie)>40;let te=l.value;if(g.value&&oe){const ye=re(h.value);ye&&(te=ye)}y.value=te;let J=br(ee.startTime+Ae);t.snapEnabled&&!f.value.shift&&(J=q(J,H,te)),J=Math.max(0,J);const se=ee.endTime-ee.startTime,ke=J+se;N(te,J,ke,H.type)}function N(ce,me,ie,Ae){const H=e.tracks.find(ye=>ye.id===ce),ee=l.value,oe=ce!==ee,te=ie-me;let J=me,se=ie,ke=!1;if(oe)if(!H)ke=!0;else{const ye=Ae;H.type===ye?W(ce,me,ie)&&(ke=!0):ke=!0}else{const ye=I(ce,me,te);J=ye.startTime,se=ye.endTime}w.value={trackId:ce,startTime:J,endTime:se,needNewTrack:ke,visible:!0,clipType:Ae}}function I(ce,me,ie){const Ae=e.tracks.find(J=>J.id===ce);if(!Ae)return{startTime:me,endTime:me+ie};const H=new Set(o.value.map(J=>J.id)),ee=Ae.clips.filter(J=>!H.has(J.id)&&J.type!=="transition").sort((J,se)=>J.startTime-se.startTime);let oe=me,te=me+ie;for(const J of ee)if(oeJ.startTime){const se=(oe+te)/2,ke=(J.startTime+J.endTime)/2;(seJ.startTime&&(oe=br(J.endTime)))):oe=br(J.endTime),te=oe+ie;break}return{startTime:oe,endTime:te}}function W(ce,me,ie){const Ae=e.tracks.find(ee=>ee.id===ce);if(!Ae)return!1;const H=new Set(o.value.map(ee=>ee.id));return Ae.clips.some(ee=>H.has(ee.id)||ee.type==="transition"?!1:ee.startTimeme)}function V(){if(!r.value||o.value.length===0){X();return}const ce=y.value!==l.value;if(!g.value&&ce){X();return}ce?K():z(),le(),e.cleanupEmptyTracks(),n.pushSnapshot("移动片段"),X()}function z(){const ce=w.value,me=o.value[0],ie=d.value.get(me.id);if(!ie)return;const Ae=ce.startTime-ie.startTime,H=new Map;o.value.forEach(ee=>{const oe=d.value.get(ee.id);if(oe){const te=oe.endTime-oe.startTime,J=br(Math.max(0,oe.startTime+Ae)),se=br(J+te);e.updateClip(ee.id,{startTime:J,endTime:se}),H.set(ee.id,{startTime:J,endTime:se})}}),Y(ce.trackId,H)}function Y(ce,me){const ie=e.tracks.find(ee=>ee.id===ce);if(!ie)return;const Ae=[...ie.clips].filter(ee=>ee.type!=="transition").map(ee=>{const oe=me.get(ee.id);return{id:ee.id,startTime:oe?oe.startTime:ee.startTime,endTime:oe?oe.endTime:ee.endTime}}).sort((ee,oe)=>ee.startTime-oe.startTime);if(Ae.length<2)return;const H=[];for(let ee=0;eete.startTime){const J=te.endTime-te.startTime,se=br(oe.endTime),ke=br(se+J);te.startTime=se,te.endTime=ke,H.push({id:te.id,startTime:se,endTime:ke})}}H.forEach(ee=>{e.updateClip(ee.id,{startTime:ee.startTime,endTime:ee.endTime})})}function K(){const ce=w.value,me=o.value[0],ie=d.value.get(me.id);if(!ie)return;const Ae=me.type;let H=null;if(ce.needNewTrack){const te=_(Ae);e.addTrack(te),H=te}else H=e.tracks.find(te=>te.id===ce.trackId)||null;if(!H)return;const ee=ce.startTime-ie.startTime,oe=new Map;o.value.forEach(te=>{const J=d.value.get(te.id);if(J){const se=J.endTime-J.startTime,ke=br(Math.max(0,J.startTime+ee)),ye=br(ke+se);te.trackId!==H.id&&e.moveClipToTrack(te.id,H.id),e.updateClip(te.id,{startTime:ke,endTime:ye}),oe.set(te.id,{startTime:ke,endTime:ye})}}),Y(H.id,oe)}function X(){P(),r.value=!1,o.value=[],d.value.clear(),k.value={x:0,y:0},O.value=0,w.value={trackId:"",startTime:0,endTime:0,needNewTrack:!1,visible:!1,clipType:""},y.value="",C.removeEventListener("mousemove",R),C.removeEventListener("mouseup",V)}function _(ce){const me=e.getTrackCountByType(ce),ie={video:"视频",audio:"音频",subtitle:"字幕",sticker:"贴纸",filter:"滤镜",effect:"特效"};return{id:Aoe("track-"),type:ce,name:`${ie[ce]||ce}${me+1}`,visible:!0,locked:!1,clips:[],order:e.tracks.length}}function q(ce,me,ie){if(f.value.shift||!t.snapEnabled)return ce;const Ae=e.tracks.find(J=>J.id===ie);if(!Ae)return ce;const H=[],ee=new Set(e.selectedClipIds);if(Ae.clips.forEach(J=>{J.id!==me.id&&!ee.has(J.id)&&J.type!=="transition"&&(H.push(J.startTime),H.push(J.endTime))}),H.length===0)return ce;const oe=t.timeToPixels(ce),te=t.snapToPosition(oe,H.map(J=>t.timeToPixels(J)));return br(t.pixelsToTime(te))}function re(ce){const me=document.querySelectorAll(".tracks__track");for(const ie of me){const Ae=ie.getBoundingClientRect();if(ce>=Ae.top&&ce<=Ae.bottom)return ie.dataset.trackId||null}return null}function le(){e.tracks.forEach(ce=>{const me=[];ce.clips.forEach(ie=>{if(ie.type!=="transition")return;const Ae=(ie.startTime+ie.endTime)/2,H=ce.clips.find(oe=>oe.type!=="transition"&&Math.abs(oe.endTime-Ae)<.1),ee=ce.clips.find(oe=>oe.type!=="transition"&&oe!==H&&Math.abs(oe.startTime-Ae)<.1);(!H||!ee||Math.abs(H.endTime-ee.startTime)>.1)&&me.push(ie.id)}),me.forEach(ie=>{e.removeClip(ie)})})}return{isDragging:r,draggedClips:o,draggedClipIds:x,dragOffset:k,previewPosition:w,previewEndTime:L,currentTargetTrackId:y,dragStartTrackId:l,edgeScrollConfig:A,setConfig:S,setScrollContainers:T,startDrag:F,handleDragMove:R,handleDragEnd:V,resetDragState:X,startEdgeScroll:B,stopEdgeScroll:P}});function ZPs(e={}){const t=J1(),n=Y6(),r=WE(),o=Q2(),s=e.callbacks||{},a=de(!1);function l(){var C;if(!((C=e.containerRef)!=null&&C.value))return!0;const x=document.activeElement;return x?e.containerRef.value.contains(x):!1}function d(){var C;return(C=e.containerRef)!=null&&C.value?a.value:!0}function u(C){return!C||!(C instanceof HTMLElement)?!1:!!(C instanceof HTMLInputElement||C instanceof HTMLTextAreaElement||C instanceof HTMLSelectElement||C.isContentEditable||C.getAttribute("contenteditable")==="true")}function h(C){var x,L;const S=HPs()?C.metaKey:C.ctrlKey;if(C.code==="Space"){if(u(C.target))return;C.preventDefault(),n.isPlaying?(n.pause(),(x=s.onPause)==null||x.call(s)):(n.play(),(L=s.onPlay)==null||L.call(s));return}if(d()&&!f(C)){if(S&&C.code==="KeyZ"&&!C.shiftKey){C.preventDefault(),r.undo();return}if(S&&C.code==="KeyY"||S&&C.shiftKey&&C.code==="KeyZ"){C.preventDefault(),r.redo();return}if(S&&C.code==="KeyC"){C.preventDefault(),g();return}if(S&&C.code==="KeyX"){C.preventDefault(),k();return}if(S&&C.code==="KeyV"){C.preventDefault(),A();return}if(C.code==="Delete"||C.code==="Backspace"){C.preventDefault(),m();return}if(S&&(C.code==="Equal"||C.code==="NumpadAdd")){C.preventDefault(),o.zoomIn(.1);return}if(S&&(C.code==="Minus"||C.code==="NumpadSubtract")){C.preventDefault(),o.zoomOut(.1);return}if(C.code==="ArrowRight"){C.preventDefault(),n.adjustTime(.1);return}if(C.code==="ArrowLeft"){C.preventDefault(),n.adjustTime(-.1);return}if(C.code==="Escape"){C.preventDefault(),t.clearSelection();return}}}function f(C){var x;const L=C.target;return L instanceof HTMLInputElement||L instanceof HTMLTextAreaElement||L.isContentEditable?((x=e.containerRef)!=null&&x.value&&e.containerRef.value.contains(L),!0):!1}function g(){var C;const x=Array.from(t.selectedClipIds);x.length!==0&&(t.copyClips(x),(C=s.onCopy)==null||C.call(s,x))}function k(){var C;const x=Array.from(t.selectedClipIds);x.length!==0&&(t.cutClips(x),(C=s.onCut)==null||C.call(s,x))}function A(){var C;if(!t.hasClipboardContent())return;const x=t.selectedClips;let L;if(x.length>0?L=x[0].trackId:t.mainTrack&&(L=t.mainTrack.id),!L)return;const S=n.currentTime,T=t.pasteClips(L,S);T&&(r.pushSnapshot("粘贴片段"),(C=s.onPaste)==null||C.call(s,T,L,S))}function m(){var C;const x=Array.from(t.selectedClipIds);x.length!==0&&(t.removeClips(x),r.pushSnapshot("删除片段"),(C=s.onDelete)==null||C.call(s,x))}function v(){a.value=!0}function p(){l()||(a.value=!1)}function b(){a.value=!0}function O(C){var x;const L=C.relatedTarget;(x=e.containerRef)!=null&&x.value&&L&&(e.containerRef.value.contains(L)||(a.value=!1))}function w(){var C;const x=(C=e.containerRef)==null?void 0:C.value;x&&(x.addEventListener("mouseenter",v),x.addEventListener("mouseleave",p),x.addEventListener("focusin",b),x.addEventListener("focusout",O))}function y(){var C;const x=(C=e.containerRef)==null?void 0:C.value;x&&(x.removeEventListener("mouseenter",v),x.removeEventListener("mouseleave",p),x.removeEventListener("focusin",b),x.removeEventListener("focusout",O))}return mn(()=>{document.addEventListener("keydown",h),w()}),Pa(()=>{document.removeEventListener("keydown",h),y()}),{handleKeyDown:h,isActive:a}}function YPs({scrollLeft:e,tracksWidth:t,setScrollLeft:n}){const r=Y6(),o=Q2();At(()=>r.currentTime,s=>{if(!r.isPlaying)return;const a=o.actualPixelsPerSecond,l=s*a,d=e.value+t.value*.9;if(l>d){const u=t.value*.8,h=e.value+u;n(h)}})}const Qg=(e,t)=>{const n=e.__vccOpts||e;for(const[r,o]of t)n[r]=o;return n},XPs={},qPs={width:"1em",height:"1em",viewBox:"0 0 24 24",preserveAspectRatio:"xMidYMid meet",fill:"none",role:"presentation",xmlns:"http://www.w3.org/2000/svg",class:"snap-icon"};function GPs(e,t){return Ce(),We("svg",qPs,[...t[0]||(t[0]=[he("g",null,[he("path",{d:"M11 22h2v-3h-2v3ZM6.106 4.416l1.415-1.414 2.121 2.122-1.414 1.414-2.122-2.122ZM16.48 3.002l1.414 1.414-2.122 2.122-1.414-1.414 2.122-2.122ZM11 2h2v3h-2V2Zm6.894 17.584-1.414 1.414-2.122-2.122 1.414-1.414 2.122 2.122ZM7.52 20.998l-1.414-1.414 2.122-2.122 1.414 1.415-2.121 2.12Z",fill:"currentColor"}),he("path",{d:"M4 16h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2Zm16-6h-7v4h7v-4ZM4 10h7v4H4v-4Z","clip-rule":"evenodd","fill-rule":"evenodd",fill:"currentColor"})],-1)])])}const KPs=Qg(XPs,[["render",GPs],["__scopeId","data-v-dca9589a"]]),JPs={class:"tools-bar"},_Ps={class:"tools-bar__section tools-bar__operations"},$Ps=["disabled","onClick"],eMs={class:"tools-bar__icon"},tMs={class:"tools-bar__label"},nMs=["disabled","title","onClick"],iMs={class:"tools-bar__icon"},rMs={class:"tools-bar__label"},oMs={class:"tools-bar__section tools-bar__playback"},sMs={class:"tools-bar__time"},aMs={class:"tools-bar__time-current"},lMs={class:"tools-bar__time-duration"},cMs=["value"],dMs={class:"tools-bar__section tools-bar__scale"},uMs={class:"tools-bar__scale-config"},hMs=["title"],AMs=["title","disabled","onClick"],fMs={class:"tools-bar__scale-control"},gMs=["disabled"],mMs={class:"tools-bar__scale-slider"},kMs=["min","max"],vMs={class:"tools-bar__scale-value"},pMs=["disabled"],bMs=Xe({__name:"index",props:{operationButtons:{default:()=>["reset","undo","redo","split","delete"]},scaleConfigButtons:{default:()=>["snap"]},locale:{default:()=>({})}},emits:["operation","playback:play","playback:pause"],setup(e,{emit:t}){const n=e,r=t,o=Y6(),s=Q2(),a=WE(),l=J1(),d=mt("config",{}),u=G(()=>o.isPlaying),h=G(()=>o.formattedCurrentTime),f=G(()=>o.formattedDuration),g=G(()=>s.snapEnabled),k=G(()=>s.minScale),A=G(()=>s.maxScale),m=de(o.playbackRate),v=G(()=>d.playbackRates||[.5,1,2,4]),p=de(s.scale),b=G(()=>{var z;return((z=n.locale)==null?void 0:z.snapOn)||"关闭自动吸附"}),O=G(()=>{var z;return((z=n.locale)==null?void 0:z.snapOff)||"开启自动吸附"});function w(z){return typeof z=="object"&&"type"in z&&z.type==="custom"}function y(z){return typeof z=="object"&&!("type"in z)&&"key"in z}function C(z){return typeof z=="object"&&!("type"in z)&&"key"in z}function x(z){return typeof z=="object"||typeof z=="function"}function L(z){const Y=z.disabled;return typeof Y=="function"?Y():Y??!1}function S(z){const Y=z.active;return typeof Y=="function"?Y():Y??!1}function T(z){z.onClick?z.onClick():z.key&&r("operation",z.key)}function D(z){z.onClick&&z.onClick()}function Q(z){return{reset:"↺",undo:"↶",redo:"↷",split:"✂",delete:"🗑"}[z]||""}function M(z){const Y=n.locale||{},K={reset:"重置",undo:"撤销",redo:"重做",split:"分割",delete:"删除"};return Y[z]||K[z]||z}function B(z){switch(z){case"undo":return!a.canUndo;case"redo":return!a.canRedo;case"split":return l.selectedClipIds.size===0;default:return!1}}function P(z){r("operation",z)}function F(){o.isPlaying?(o.pause(),r("playback:pause")):(o.play(),r("playback:play"))}function R(){o.setPlaybackRate(m.value)}function N(){s.toggleSnap()}function I(){s.zoomIn(.1),p.value=s.scale}function W(){s.zoomOut(.1),p.value=s.scale}function V(){s.setScale(p.value)}return(z,Y)=>(Ce(),We("div",JPs,[he("div",_Ps,[io(z.$slots,"operations-prepend",{},void 0,!0),(Ce(!0),We(nn,null,bi(e.operationButtons,(K,X)=>(Ce(),We(nn,{key:X},[typeof K=="string"?(Ce(),We("button",{key:0,class:uo(["tools-bar__btn",{"tools-bar__btn--disabled":B(K)}]),disabled:B(K),onClick:_=>P(K)},[he("span",eMs,De(Q(K)),1),he("span",tMs,De(M(K)),1)],10,$Ps)):w(K)?io(z.$slots,`custom-operation-${K.key}`,{key:1},void 0,!0):y(K)?(Ce(),We("button",{key:2,class:uo(["tools-bar__btn",[{"tools-bar__btn--disabled":L(K)},K.className]]),disabled:L(K),title:K.title,onClick:_=>T(K)},[he("span",iMs,[x(K.icon)?(Ce(),St(Ud(K.icon),{key:0})):(Ce(),We(nn,{key:1},[kt(De(K.icon||""),1)],64))]),he("span",rMs,De(K.label||""),1)],10,nMs)):Vt("",!0)],64))),128)),io(z.$slots,"operations-append",{},void 0,!0)]),he("div",oMs,[io(z.$slots,"playback-prepend",{},void 0,!0),he("button",{class:"tools-bar__btn tools-bar__btn--play",onClick:F},[he("span",{class:"tools-bar__icon",style:eo({marginLeft:u.value?"0":"2px"})},De(u.value?"⏸":"▶"),5)]),he("div",sMs,[he("span",aMs,De(h.value),1),Y[2]||(Y[2]=he("span",{class:"tools-bar__time-separator"},"/",-1)),he("span",lMs,De(f.value),1)]),gh(he("select",{"onUpdate:modelValue":Y[0]||(Y[0]=K=>m.value=K),class:"tools-bar__select",onChange:R},[(Ce(!0),We(nn,null,bi(v.value,K=>(Ce(),We("option",{key:K,value:K},De(K)+"x ",9,cMs))),128))],544),[[Psi,m.value]]),io(z.$slots,"playback-append",{},void 0,!0)]),he("div",dMs,[io(z.$slots,"scale-prepend",{},void 0,!0),he("div",uMs,[(Ce(!0),We(nn,null,bi(e.scaleConfigButtons,(K,X)=>(Ce(),We(nn,{key:X},[typeof K=="string"&&K==="snap"?(Ce(),We("button",{key:0,class:uo(["tools-bar__btn tools-bar__btn--toggle tools-bar__btn--snap",{"tools-bar__btn--active":g.value}]),title:g.value?b.value:O.value,onClick:N},[c(KPs,{class:"tools-bar__snap-icon"})],10,hMs)):w(K)?io(z.$slots,`custom-scale-config-${K.key}`,{key:1},void 0,!0):C(K)?(Ce(),We("button",{key:2,class:uo(["tools-bar__btn tools-bar__btn--toggle",[{"tools-bar__btn--active":S(K)},{"tools-bar__btn--disabled":L(K)},K.className]]),title:K.title,disabled:L(K),onClick:_=>D(K)},[x(K.icon)?(Ce(),St(Ud(K.icon),{key:0})):(Ce(),We(nn,{key:1},[kt(De(K.icon||""),1)],64))],10,AMs)):Vt("",!0)],64))),128))]),he("div",fMs,[he("button",{class:"tools-bar__btn tools-bar__btn--icon",disabled:p.value<=k.value,onClick:W}," − ",8,gMs),he("div",mMs,[gh(he("input",{type:"range",min:k.value,max:A.value,step:.1,"onUpdate:modelValue":Y[1]||(Y[1]=K=>p.value=K),onInput:V},null,40,kMs),[[f4n,p.value,void 0,{number:!0}]]),he("span",vMs,De(p.value.toFixed(1))+"x",1)]),he("button",{class:"tools-bar__btn tools-bar__btn--icon",disabled:p.value>=A.value,onClick:I}," + ",8,pMs)]),io(z.$slots,"scale-append",{},void 0,!0)])]))}}),OMs=Qg(bMs,[["__scopeId","data-v-c36de3a3"]]),wMs={key:0,class:"ruler__mark-label"},yMs=Xe({__name:"index",props:{width:{default:0},scrollLeft:{default:0},trackControlWidth:{default:200}},emits:["scroll","seek"],setup(e,{expose:t,emit:n}){const r=e,o=n,s=Y6(),a=Q2(),l=J1(),d=JZ(),u=de(),h=de(),f=de(!1),g=de(0);let k=null;t({isDraggingCursor:f});const A=G(()=>a.rulerConfig),m=G(()=>a.actualPixelsPerSecond),v=G(()=>{const D=Math.max(l.totalDuration,s.duration,d.previewEndTime,60);return Math.ceil(D*m.value)}),p=G(()=>{const D=[],Q=A.value,M=v.value/m.value,B=Q.minorInterval,P=Q.majorInterval,F=Math.ceil(M/B)+1;for(let R=0;RM)break;const I=Math.abs(Math.round(N/P)*P-N)<.001;D.push({time:N,position:N*m.value,isMajor:I,height:I?Q.majorHeight:Q.minorHeight})}return D}),b=G(()=>s.currentTime*m.value),O=G(()=>r.trackControlWidth+b.value-(r.scrollLeft||0)),w=G(()=>O.value>=r.trackControlWidth);function y(D){const Q=Math.floor(D/60),M=Math.floor(D%60);return`${String(Q).padStart(2,"0")}:${String(M).padStart(2,"0")}`}function C(D){var Q;if(f.value)return;const M=(Q=u.value)==null?void 0:Q.getBoundingClientRect();if(!M)return;const B=(D.clientX-M.left-r.trackControlWidth+(r.scrollLeft||0))/m.value,P=Math.max(0,B);s.seekTo(P),o("seek",P)}function x(){f.value=!0,s.pause(),document.body.style.userSelect="none";let D=null,Q=0,M=0;const B=()=>{f.value&&(M!==0&&h.value&&(h.value.scrollLeft+=M,o("scroll",h.value.scrollLeft),P()),D=requestAnimationFrame(B))},P=()=>{var N;const I=(N=u.value)==null?void 0:N.getBoundingClientRect();if(!I||!h.value)return;let W=(Q-I.left-r.trackControlWidth+h.value.scrollLeft)/m.value;W=Math.max(0,W),s.seekTo(W)},F=N=>{var I;Q=N.clientX;const W=(I=h.value)==null?void 0:I.getBoundingClientRect();if(W)if(N.clientXW.right-50){const V=1-(W.right-N.clientX)/50;M=15*Math.max(0,V)}else M=0;M===0&&P()},R=()=>{f.value=!1,document.body.style.userSelect="",D&&(cancelAnimationFrame(D),D=null),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",R),o("seek",s.currentTime)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",R),D=requestAnimationFrame(B)}function L(){h.value&&o("scroll",h.value.scrollLeft)}function S(){return u.value?u.value.closest(".video-track"):null}function T(){if(!u.value)return;const D=u.value.getBoundingClientRect(),Q=S(),M=Q?Q.getBoundingClientRect().bottom:window.innerHeight,B=D.top-5;g.value=Math.max(M-B,0)}return mn(()=>{ei(()=>{T(),k=new ResizeObserver(()=>{T()}),u.value&&k.observe(u.value);const D=S();D&&k.observe(D)}),window.addEventListener("resize",T)}),Pa(()=>{window.removeEventListener("resize",T),k&&(k.disconnect(),k=null)}),At(()=>r.scrollLeft,D=>{h.value&&h.value.scrollLeft!==D&&(h.value.scrollLeft=D)}),At(b,D=>{if(f.value||!h.value)return;const Q=h.value.clientWidth,M=h.value.scrollLeft;DM+Q&&(h.value.scrollLeft=D-Q+50)}),(D,Q)=>(Ce(),We("div",{class:"ruler",ref_key:"rulerRef",ref:u},[he("div",{class:"ruler__placeholder",style:eo({width:e.trackControlWidth+"px"})},null,4),he("div",{class:"ruler__wrapper",ref_key:"rulerWrapperRef",ref:h,onScroll:L},[he("div",{class:"ruler__content",style:eo({width:v.value+"px"}),onMousedown:C},[(Ce(!0),We(nn,null,bi(p.value,M=>(Ce(),We("div",{key:M.time,class:uo(["ruler__mark",{"ruler__mark--major":M.isMajor}]),style:eo({left:M.position+"px",height:M.height+"px"})},[M.isMajor?(Ce(),We("span",wMs,De(y(M.time)),1)):Vt("",!0)],6))),128))],36)],544),w.value?(Ce(),We("div",{key:0,class:uo(["ruler__cursor-handle",{"ruler__cursor-handle--dragging":f.value}]),style:eo({left:O.value+"px"}),onMousedown:or(x,["stop"])},[he("div",{class:"ruler__cursor-line",style:eo({height:`${g.value}px`}),onMousedown:or(x,["stop"])},null,36)],38)):Vt("",!0)],512))}}),CMs=Qg(yMs,[["__scopeId","data-v-f5735210"]]),xMs={class:"track-control"},LMs={class:"track-control__name"},SMs={key:2,class:"track-control__badge"},TMs={class:"track-control__actions"},EMs=["title"],DMs=["title"],QMs=["title"],BMs=Xe({__name:"TrackControl",props:{track:{},locale:{}},emits:["update","delete"],setup(e,{emit:t}){const n=e,r=t,o=de(!1),s=de(""),a=de();function l(){o.value=!0,s.value=n.track.name,ei(()=>{var k,A;(k=a.value)==null||k.focus(),(A=a.value)==null||A.select()})}function d(){s.value.trim()&&s.value!==n.track.name&&r("update",n.track.id,{name:s.value.trim()}),o.value=!1}function u(){o.value=!1,s.value=""}function h(){r("update",n.track.id,{visible:!n.track.visible})}function f(){r("update",n.track.id,{locked:!n.track.locked})}function g(){var k;const A=(((k=n.locale)==null?void 0:k.confirmDeleteTrack)||'确定要删除轨道"{name}"吗?').replace("{name}",n.track.name);confirm(A)&&r("delete",n.track.id)}return(k,A)=>{var m,v,p,b,O,w;return Ce(),We("div",xMs,[he("div",LMs,[o.value?gh((Ce(),We("input",{key:0,"onUpdate:modelValue":A[0]||(A[0]=y=>s.value=y),class:"track-control__name-input",onBlur:d,onKeyup:[zct(d,["enter"]),zct(u,["esc"])],ref_key:"nameInputRef",ref:a},null,544)),[[f4n,s.value]]):(Ce(),We("span",{key:1,class:"track-control__name-text",onDblclick:l},De(e.track.name),33)),e.track.isMain?(Ce(),We("span",SMs,De(((m=e.locale)==null?void 0:m.mainBadge)||"主"),1)):Vt("",!0)]),he("div",TMs,[he("button",{class:uo(["track-control__btn",{"track-control__btn--active":e.track.visible}]),onClick:h,title:e.track.visible?((v=e.locale)==null?void 0:v.hide)||"隐藏":((p=e.locale)==null?void 0:p.show)||"显示"},De(e.track.visible?"👁":"👁‍🗨"),11,EMs),he("button",{class:uo(["track-control__btn",{"track-control__btn--active":e.track.locked}]),onClick:f,title:e.track.locked?((b=e.locale)==null?void 0:b.unlock)||"解锁":((O=e.locale)==null?void 0:O.lock)||"锁定"},De(e.track.locked?"🔒":"🔓"),11,DMs),e.track.isMain?Vt("",!0):(Ce(),We("button",{key:0,class:"track-control__btn track-control__btn--danger",onClick:g,title:((w=e.locale)==null?void 0:w.delete)||"删除"}," 🗑 ",8,QMs))])])}}}),FMs=Qg(BMs,[["__scopeId","data-v-34ea43ab"]]);function PMs(){const e=J1(),t=Q2(),n=WE(),r=de(!1),o=de(null),s=de("left"),a=de(0),l=de(0),d=de(0),u=de(0),h=de(0);let f=document;const g=de([]),k=de([]);function A(R,N,I){var W;if(R.type==="transition"){y(R,N,I);return}if(f=((W=I.target)==null?void 0:W.ownerDocument)||document,r.value=!0,o.value=R,s.value=N,a.value=I.clientX,l.value=R.startTime,d.value=R.endTime,R.type==="video"||R.type==="audio"){const V=R;u.value=V.trimStart,h.value=V.trimEnd}m(R,N),f.addEventListener("mousemove",T),f.addEventListener("mouseup",P)}function m(R,N){g.value=[],k.value=[];const I=e.tracks.find(W=>W.id===R.trackId);if(I)if(N==="right"){const W=new Set([R.id]);v(I.clips,R.endTime,W)}else{const W=new Set([R.id]);p(I.clips,R.startTime,W)}}function v(R,N,I){const W=R.find(z=>{if(z.type!=="transition")return!1;const Y=z,K=(Y.startTime+Y.endTime)/2;return Math.abs(K-N)=N-Y.transitionDuration});if(!W)return;g.value.push({id:W.id,type:"transition",originalStartTime:W.startTime,originalEndTime:W.endTime,duration:W.transitionDuration});const V=R.find(z=>z.type!=="transition"&&!I.has(z.id)&&Math.abs(z.startTime-N){if(z.type!=="transition")return!1;const Y=z,K=(Y.startTime+Y.endTime)/2;return Math.abs(K-N)z.type!=="transition"&&!I.has(z.id)&&Math.abs(z.endTime-N)Y.id===R.trackId);if(!I)return;const W=(R.startTime+R.endTime)/2,V=I.clips.find(Y=>Y.type!=="transition"&&Math.abs(Y.endTime-W)<.5),z=I.clips.find(Y=>Y.type!=="transition"&&Y!==V&&Math.abs(Y.startTime-W)<.5);if(V&&z){const Y=br(W-N/2),K=br(W+N/2),X=br(W),_=br(N);e.updateClip(R.id,{startTime:Y,endTime:K,transitionDuration:_}),e.updateClip(V.id,{endTime:X}),e.updateClip(z.id,{startTime:X})}}const S=de({shift:!1});function T(R){if(!r.value||!o.value)return;S.value.shift=R.shiftKey;const N=R.clientX-a.value,I=t.pixelsToTime(N);s.value==="left"?D(I):M(I)}function D(R){if(!o.value)return;let N=br(l.value+R);const I=.1,W=d.value-I;if(N=Math.max(0,Math.min(N,W)),!(k.value.length>0&&k.value[0].type==="transition")){const z=e.tracks.find(Y=>Y.id===o.value.trackId);if(z){const Y=z.clips.filter(K=>K.type!=="transition"&&K.id!==o.value.id).find(K=>K.endTime<=l.value+.01&&K.endTime>N);Y&&(N=Math.max(N,Y.endTime))}}let V=0;if(o.value.type==="video"||o.value.type==="audio"){o.value;const z=N-l.value;V=br(u.value+z),V<0&&(N=br(l.value-u.value),V=0);const Y=h.value;V>Y-I&&(V=Y-I,N=br(l.value+(V-u.value)))}if(t.snapEnabled){const z=F(N);if(z!==N&&(o.value.type==="video"||o.value.type==="audio")){const Y=z-N;V=br(V+Y),V<0&&(V=0)}N=z}o.value.type==="video"||o.value.type==="audio"?e.updateClip(o.value.id,{startTime:N,trimStart:Math.max(0,V)}):e.updateClip(o.value.id,{startTime:N}),Q(N)}function Q(R){if(k.value.length===0)return;const N=d.value-R;let I=R;for(let W=0;W0&&g.value[0].type==="transition")){const z=e.tracks.find(Y=>Y.id===o.value.trackId);if(z){const Y=z.clips.filter(K=>K.type!=="transition"&&K.id!==o.value.id).find(K=>K.startTime>=d.value-.01&&K.startTimez.originalDuration&&(V=z.originalDuration,N=br(d.value+(V-h.value)));const K=u.value;VY.originalDuration&&(V=Y.originalDuration)}N=z}if(o.value.type==="video"||o.value.type==="audio"){const z=o.value;e.updateClip(o.value.id,{endTime:N,trimEnd:Math.min(V,z.originalDuration)})}else e.updateClip(o.value.id,{endTime:N});B(N)}function B(R){if(g.value.length===0)return;const N=R-l.value;let I=R,W=N;for(let V=0;VK.id===o.value.trackId);if(!N)return R;const I=new Set;g.value.forEach(K=>I.add(K.id)),k.value.forEach(K=>I.add(K.id));const W=[],V=new Set(e.selectedClipIds);if(N.clips.forEach(K=>{K.id!==o.value.id&&!V.has(K.id)&&!I.has(K.id)&&K.type!=="transition"&&(W.push(K.startTime),W.push(K.endTime))}),W.length===0)return R;const z=t.timeToPixels(R),Y=t.snapToPosition(z,W.map(K=>t.timeToPixels(K)));return br(t.pixelsToTime(Y))}return{isResizing:r,resizingClip:o,resizingEdge:s,startResize:A,handleResizeMove:T,handleResizeEnd:P}}function MMs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Q_n={};(function(e){var t=function(){var A=new Date,m=4,v=3,p=2,b=1,O=m,w={setLogLevel:function(y){y==this.debug?O=b:y==this.info?O=p:y==this.warn?O=v:(y==this.error,O=m)},debug:function(y,C){console.debug===void 0&&(console.debug=console.log),b>=O&&console.debug("["+t.getDurationString(new Date-A,1e3)+"]","["+y+"]",C)},log:function(y,C){this.debug(y.msg)},info:function(y,C){p>=O&&console.info("["+t.getDurationString(new Date-A,1e3)+"]","["+y+"]",C)},warn:function(y,C){v>=O&&console.warn("["+t.getDurationString(new Date-A,1e3)+"]","["+y+"]",C)},error:function(y,C){m>=O&&console.error("["+t.getDurationString(new Date-A,1e3)+"]","["+y+"]",C)}};return w}();t.getDurationString=function(A,m){var v;function p(x,L){for(var S=""+x,T=S.split(".");T[0].length0){for(var v="",p=0;p0&&(v+=","),v+="["+t.getDurationString(A.start(p))+","+t.getDurationString(A.end(p))+"]";return v}else return"(empty)"},e.Log=t;var n=function(A){if(A instanceof ArrayBuffer)this.buffer=A,this.dataview=new DataView(A);else throw"Needs an array buffer";this.position=0};n.prototype.getPosition=function(){return this.position},n.prototype.getEndPosition=function(){return this.buffer.byteLength},n.prototype.getLength=function(){return this.buffer.byteLength},n.prototype.seek=function(A){var m=Math.max(0,Math.min(this.buffer.byteLength,A));return this.position=isNaN(m)||!isFinite(m)?0:m,!0},n.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},n.prototype.readAnyInt=function(A,m){var v=0;if(this.position+A<=this.buffer.byteLength){switch(A){case 1:m?v=this.dataview.getInt8(this.position):v=this.dataview.getUint8(this.position);break;case 2:m?v=this.dataview.getInt16(this.position):v=this.dataview.getUint16(this.position);break;case 3:if(m)throw"No method for reading signed 24 bits values";v=this.dataview.getUint8(this.position)<<16,v|=this.dataview.getUint8(this.position+1)<<8,v|=this.dataview.getUint8(this.position+2);break;case 4:m?v=this.dataview.getInt32(this.position):v=this.dataview.getUint32(this.position);break;case 8:if(m)throw"No method for reading signed 64 bits values";v=this.dataview.getUint32(this.position)<<32,v|=this.dataview.getUint32(this.position+4);break;default:throw"readInt method not implemented for size: "+A}return this.position+=A,v}else throw"Not enough bytes in buffer"},n.prototype.readUint8=function(){return this.readAnyInt(1,!1)},n.prototype.readUint16=function(){return this.readAnyInt(2,!1)},n.prototype.readUint24=function(){return this.readAnyInt(3,!1)},n.prototype.readUint32=function(){return this.readAnyInt(4,!1)},n.prototype.readUint64=function(){return this.readAnyInt(8,!1)},n.prototype.readString=function(A){if(this.position+A<=this.buffer.byteLength){for(var m="",v=0;vthis._byteLength&&(this._byteLength=m);return}for(v<1&&(v=1);m>v;)v*=2;var p=new ArrayBuffer(v),b=new Uint8Array(this._buffer),O=new Uint8Array(p,0,b.length);O.set(b),this.buffer=p,this._byteLength=m}},r.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var A=new ArrayBuffer(this._byteLength),m=new Uint8Array(A),v=new Uint8Array(this._buffer,0,m.length);m.set(v),this.buffer=A}},r.BIG_ENDIAN=!1,r.LITTLE_ENDIAN=!0,r.prototype._byteLength=0,Object.defineProperty(r.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(r.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(A){this._buffer=A,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(r.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(A){this._byteOffset=A,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(r.prototype,"dataView",{get:function(){return this._dataView},set:function(A){this._byteOffset=A.byteOffset,this._buffer=A.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+A.byteLength}}),r.prototype.seek=function(A){var m=Math.max(0,Math.min(this.byteLength,A));this.position=isNaN(m)||!isFinite(m)?0:m},r.prototype.isEof=function(){return this.position>=this._byteLength},r.prototype.mapUint8Array=function(A){this._realloc(A*1);var m=new Uint8Array(this._buffer,this.byteOffset+this.position,A);return this.position+=A*1,m},r.prototype.readInt32Array=function(A,m){A=A??this.byteLength-this.position/4;var v=new Int32Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readInt16Array=function(A,m){A=A??this.byteLength-this.position/2;var v=new Int16Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readInt8Array=function(A){A=A??this.byteLength-this.position;var m=new Int8Array(A);return r.memcpy(m.buffer,0,this.buffer,this.byteOffset+this.position,A*m.BYTES_PER_ELEMENT),this.position+=m.byteLength,m},r.prototype.readUint32Array=function(A,m){A=A??this.byteLength-this.position/4;var v=new Uint32Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readUint16Array=function(A,m){A=A??this.byteLength-this.position/2;var v=new Uint16Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readUint8Array=function(A){A=A??this.byteLength-this.position;var m=new Uint8Array(A);return r.memcpy(m.buffer,0,this.buffer,this.byteOffset+this.position,A*m.BYTES_PER_ELEMENT),this.position+=m.byteLength,m},r.prototype.readFloat64Array=function(A,m){A=A??this.byteLength-this.position/8;var v=new Float64Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readFloat32Array=function(A,m){A=A??this.byteLength-this.position/4;var v=new Float32Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readInt32=function(A){var m=this._dataView.getInt32(this.position,A??this.endianness);return this.position+=4,m},r.prototype.readInt16=function(A){var m=this._dataView.getInt16(this.position,A??this.endianness);return this.position+=2,m},r.prototype.readInt8=function(){var A=this._dataView.getInt8(this.position);return this.position+=1,A},r.prototype.readUint32=function(A){var m=this._dataView.getUint32(this.position,A??this.endianness);return this.position+=4,m},r.prototype.readUint16=function(A){var m=this._dataView.getUint16(this.position,A??this.endianness);return this.position+=2,m},r.prototype.readUint8=function(){var A=this._dataView.getUint8(this.position);return this.position+=1,A},r.prototype.readFloat32=function(A){var m=this._dataView.getFloat32(this.position,A??this.endianness);return this.position+=4,m},r.prototype.readFloat64=function(A){var m=this._dataView.getFloat64(this.position,A??this.endianness);return this.position+=8,m},r.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,r.memcpy=function(A,m,v,p,b){var O=new Uint8Array(A,m,b),w=new Uint8Array(v,p,b);O.set(w)},r.arrayToNative=function(A,m){return m==this.endianness?A:this.flipArrayEndianness(A)},r.nativeToEndian=function(A,m){return this.endianness==m?A:this.flipArrayEndianness(A)},r.flipArrayEndianness=function(A){for(var m=new Uint8Array(A.buffer,A.byteOffset,A.byteLength),v=0;vb;p--,b++){var O=m[b];m[b]=m[p],m[p]=O}return A},r.prototype.failurePosition=0,String.fromCharCodeUint8=function(A){for(var m=[],v=0;v>16),this.writeUint8((A&65280)>>8),this.writeUint8(A&255)},r.prototype.adjustUint32=function(A,m){var v=this.position;this.seek(A),this.writeUint32(m),this.seek(v)},r.prototype.mapInt32Array=function(A,m){this._realloc(A*4);var v=new Int32Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*4,v},r.prototype.mapInt16Array=function(A,m){this._realloc(A*2);var v=new Int16Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*2,v},r.prototype.mapInt8Array=function(A){this._realloc(A*1);var m=new Int8Array(this._buffer,this.byteOffset+this.position,A);return this.position+=A*1,m},r.prototype.mapUint32Array=function(A,m){this._realloc(A*4);var v=new Uint32Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*4,v},r.prototype.mapUint16Array=function(A,m){this._realloc(A*2);var v=new Uint16Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*2,v},r.prototype.mapFloat64Array=function(A,m){this._realloc(A*8);var v=new Float64Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*8,v},r.prototype.mapFloat32Array=function(A,m){this._realloc(A*4);var v=new Float32Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*4,v};var s=function(A){this.buffers=[],this.bufferIndex=-1,A&&(this.insertBuffer(A),this.bufferIndex=0)};s.prototype=new r(new ArrayBuffer,0,r.BIG_ENDIAN),s.prototype.initialized=function(){var A;return this.bufferIndex>-1?!0:this.buffers.length>0?(A=this.buffers[0],A.fileStart===0?(this.buffer=A,this.bufferIndex=0,t.debug("MultiBufferStream","Stream ready for parsing"),!0):(t.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1)):(t.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1)},ArrayBuffer.concat=function(A,m){t.debug("ArrayBuffer","Trying to create a new buffer of size: "+(A.byteLength+m.byteLength));var v=new Uint8Array(A.byteLength+m.byteLength);return v.set(new Uint8Array(A),0),v.set(new Uint8Array(m),A.byteLength),v.buffer},s.prototype.reduceBuffer=function(A,m,v){var p;return p=new Uint8Array(v),p.set(new Uint8Array(A,m,v)),p.buffer.fileStart=A.fileStart+m,p.buffer.usedBytes=0,p.buffer},s.prototype.insertBuffer=function(A){for(var m=!0,v=0;vp.byteLength){this.buffers.splice(v,1),v--;continue}else t.warn("MultiBufferStream","Buffer (fileStart: "+A.fileStart+" - Length: "+A.byteLength+") already appended, ignoring");else A.fileStart+A.byteLength<=p.fileStart||(A=this.reduceBuffer(A,0,p.fileStart-A.fileStart)),t.debug("MultiBufferStream","Appending new buffer (fileStart: "+A.fileStart+" - Length: "+A.byteLength+")"),this.buffers.splice(v,0,A),v===0&&(this.buffer=A);m=!1;break}else if(A.fileStart0)A=this.reduceBuffer(A,b,O);else{m=!1;break}}}m&&(t.debug("MultiBufferStream","Appending new buffer (fileStart: "+A.fileStart+" - Length: "+A.byteLength+")"),this.buffers.push(A),v===0&&(this.buffer=A))},s.prototype.logBufferLevel=function(A){var m,v,p,b,O=[],w,y="";for(p=0,b=0,m=0;m0&&(y+=w.end-1+"]");var C=A?t.info:t.debug;this.buffers.length===0?C("MultiBufferStream","No more buffer in memory"):C("MultiBufferStream",""+this.buffers.length+" stored buffer(s) ("+p+"/"+b+" bytes), continuous ranges: "+y)},s.prototype.cleanBuffers=function(){var A,m;for(A=0;A"+this.buffer.byteLength+")"),!0}else return!1;else return!1},s.prototype.findPosition=function(A,m,v){var p,b=null,O=-1;for(A===!0?p=0:p=this.bufferIndex;p=m?(t.debug("MultiBufferStream","Found position in existing buffer #"+O),O):-1):-1},s.prototype.findEndContiguousBuf=function(A){var m,v,p,b=A!==void 0?A:this.bufferIndex;if(v=this.buffers[b],this.buffers.length>b+1)for(m=b+1;m>3;return L===31&&x.data.length>=2&&(L=32+((x.data[0]&7)<<3)+((x.data[1]&224)>>5)),L}else return null},w.DecoderConfigDescriptor=function(y){w.Descriptor.call(this,m,y)},w.DecoderConfigDescriptor.prototype=new w.Descriptor,w.DecoderConfigDescriptor.prototype.parse=function(y){this.oti=y.readUint8(),this.streamType=y.readUint8(),this.upStream=(this.streamType>>1&1)!==0,this.streamType=this.streamType>>>2,this.bufferSize=y.readUint24(),this.maxBitrate=y.readUint32(),this.avgBitrate=y.readUint32(),this.size-=13,this.parseRemainingDescriptors(y)},w.DecoderSpecificInfo=function(y){w.Descriptor.call(this,v,y)},w.DecoderSpecificInfo.prototype=new w.Descriptor,w.SLConfigDescriptor=function(y){w.Descriptor.call(this,p,y)},w.SLConfigDescriptor.prototype=new w.Descriptor,this};e.MPEG4DescriptorParser=a;var l={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"],["grpl"],["j2kH"],["etyp",["tyco"]]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){l.FullBox.prototype=new l.Box,l.ContainerBox.prototype=new l.Box,l.SampleEntry.prototype=new l.Box,l.TrackGroupTypeBox.prototype=new l.FullBox,l.BASIC_BOXES.forEach(function(A){l.createBoxCtor(A)}),l.FULL_BOXES.forEach(function(A){l.createFullBoxCtor(A)}),l.CONTAINER_BOXES.forEach(function(A){l.createContainerBoxCtor(A[0],null,A[1])})},Box:function(A,m,v){this.type=A,this.size=m,this.uuid=v},FullBox:function(A,m,v){l.Box.call(this,A,m,v),this.flags=0,this.version=0},ContainerBox:function(A,m,v){l.Box.call(this,A,m,v),this.boxes=[]},SampleEntry:function(A,m,v,p){l.ContainerBox.call(this,A,m),this.hdr_size=v,this.start=p},SampleGroupEntry:function(A){this.grouping_type=A},TrackGroupTypeBox:function(A,m){l.FullBox.call(this,A,m)},createBoxCtor:function(A,m){l.boxCodes.push(A),l[A+"Box"]=function(v){l.Box.call(this,A,v)},l[A+"Box"].prototype=new l.Box,m&&(l[A+"Box"].prototype.parse=m)},createFullBoxCtor:function(A,m){l[A+"Box"]=function(v){l.FullBox.call(this,A,v)},l[A+"Box"].prototype=new l.FullBox,l[A+"Box"].prototype.parse=function(v){this.parseFullHeader(v),m&&m.call(this,v)}},addSubBoxArrays:function(A){if(A){this.subBoxNames=A;for(var m=A.length,v=0;vv?(t.error("BoxParser","Box of type '"+x+"' has a size "+C+" greater than its container size "+v),{code:l.ERR_NOT_ENOUGH_DATA,type:x,size:C,hdr_size:O,start:b}):C!==0&&b+C>A.getEndPosition()?(A.seek(b),t.info("BoxParser","Not enough data in stream to parse the entire '"+x+"' box"),{code:l.ERR_NOT_ENOUGH_DATA,type:x,size:C,hdr_size:O,start:b}):m?{code:l.OK,type:x,size:C,hdr_size:O,start:b}:(l[x+"Box"]?p=new l[x+"Box"](C):x!=="uuid"?(t.warn("BoxParser","Unknown box type: '"+x+"'"),p=new l.Box(x,C),p.has_unparsed_data=!0):l.UUIDBoxes[y]?p=new l.UUIDBoxes[y](C):(t.warn("BoxParser","Unknown uuid type: '"+y+"'"),p=new l.Box(x,C),p.uuid=y,p.has_unparsed_data=!0),p.hdr_size=O,p.start=b,p.write===l.Box.prototype.write&&p.type!=="mdat"&&(t.info("BoxParser","'"+L+"' box writing not yet implemented, keeping unparsed data in memory for later write"),p.parseDataAndRewind(A)),p.parse(A),w=A.getPosition()-(p.start+p.size),w<0?(t.warn("BoxParser","Parsing of box '"+L+"' did not read the entire indicated box data size (missing "+-w+" bytes), seeking forward"),A.seek(p.start+p.size)):w>0&&(t.error("BoxParser","Parsing of box '"+L+"' read "+w+" more bytes than the indicated box data size, seeking backwards"),p.size!==0&&A.seek(p.start+p.size)),{code:l.OK,box:p,size:p.size})},l.Box.prototype.parse=function(A){this.type!="mdat"?this.data=A.readUint8Array(this.size-this.hdr_size):this.size===0?A.seek(A.getEndPosition()):A.seek(this.start+this.size)},l.Box.prototype.parseDataAndRewind=function(A){this.data=A.readUint8Array(this.size-this.hdr_size),A.position-=this.size-this.hdr_size},l.FullBox.prototype.parseDataAndRewind=function(A){this.parseFullHeader(A),this.data=A.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,A.position-=this.size-this.hdr_size},l.FullBox.prototype.parseFullHeader=function(A){this.version=A.readUint8(),this.flags=A.readUint24(),this.hdr_size+=4},l.FullBox.prototype.parse=function(A){this.parseFullHeader(A),this.data=A.readUint8Array(this.size-this.hdr_size)},l.ContainerBox.prototype.parse=function(A){for(var m,v;A.getPosition()>10&31,m[1]=this.language>>5&31,m[2]=this.language&31,this.languageString=String.fromCharCode(m[0]+96,m[1]+96,m[2]+96)},l.SAMPLE_ENTRY_TYPE_VISUAL="Visual",l.SAMPLE_ENTRY_TYPE_AUDIO="Audio",l.SAMPLE_ENTRY_TYPE_HINT="Hint",l.SAMPLE_ENTRY_TYPE_METADATA="Metadata",l.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle",l.SAMPLE_ENTRY_TYPE_SYSTEM="System",l.SAMPLE_ENTRY_TYPE_TEXT="Text",l.SampleEntry.prototype.parseHeader=function(A){A.readUint8Array(6),this.data_reference_index=A.readUint16(),this.hdr_size+=8},l.SampleEntry.prototype.parse=function(A){this.parseHeader(A),this.data=A.readUint8Array(this.size-this.hdr_size)},l.SampleEntry.prototype.parseDataAndRewind=function(A){this.parseHeader(A),this.data=A.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,A.position-=this.size-this.hdr_size},l.SampleEntry.prototype.parseFooter=function(A){l.ContainerBox.prototype.parse.call(this,A)},l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_HINT),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_METADATA),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_SUBTITLE),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_SYSTEM),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_TEXT),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,function(A){var m;this.parseHeader(A),A.readUint16(),A.readUint16(),A.readUint32Array(3),this.width=A.readUint16(),this.height=A.readUint16(),this.horizresolution=A.readUint32(),this.vertresolution=A.readUint32(),A.readUint32(),this.frame_count=A.readUint16(),m=Math.min(31,A.readUint8()),this.compressorname=A.readString(m),m<31&&A.readString(31-m),this.depth=A.readUint16(),A.readUint16(),this.parseFooter(A)}),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,function(A){this.parseHeader(A),A.readUint32Array(2),this.channel_count=A.readUint16(),this.samplesize=A.readUint16(),A.readUint16(),A.readUint16(),this.samplerate=A.readUint32()/65536,this.parseFooter(A)}),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avc1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avc2"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avc3"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avc4"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"av01"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"dav1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"hev1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"hvt1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"lhe1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"dvh1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"dvhe"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vvc1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vvi1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vvs1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vvcN"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vp08"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vp09"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avs3"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"j2ki"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"mjp2"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"mjpg"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"uncv"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"ac-4"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"Opus"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mha1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mha2"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mhm1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mhm2"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"fLaC"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"encv"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"enca"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_SYSTEM,"encs"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_TEXT,"enct"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_METADATA,"encm"),l.createBoxCtor("a1lx",function(A){var m=A.readUint8()&1,v=((m&1)+1)*16;this.layer_size=[];for(var p=0;p<3;p++)v==16?this.layer_size[p]=A.readUint16():this.layer_size[p]=A.readUint32()}),l.createBoxCtor("a1op",function(A){this.op_index=A.readUint8()}),l.createFullBoxCtor("auxC",function(A){this.aux_type=A.readCString();var m=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=A.readUint8Array(m)}),l.createBoxCtor("av1C",function(A){var m=A.readUint8();if(m>>7&!1){t.error("av1C marker problem");return}if(this.version=m&127,this.version!==1){t.error("av1C version "+this.version+" not supported");return}if(m=A.readUint8(),this.seq_profile=m>>5&7,this.seq_level_idx_0=m&31,m=A.readUint8(),this.seq_tier_0=m>>7&1,this.high_bitdepth=m>>6&1,this.twelve_bit=m>>5&1,this.monochrome=m>>4&1,this.chroma_subsampling_x=m>>3&1,this.chroma_subsampling_y=m>>2&1,this.chroma_sample_position=m&3,m=A.readUint8(),this.reserved_1=m>>5&7,this.reserved_1!==0){t.error("av1C reserved_1 parsing problem");return}if(this.initial_presentation_delay_present=m>>4&1,this.initial_presentation_delay_present===1)this.initial_presentation_delay_minus_one=m&15;else if(this.reserved_2=m&15,this.reserved_2!==0){t.error("av1C reserved_2 parsing problem");return}var v=this.size-this.hdr_size-4;this.configOBUs=A.readUint8Array(v)}),l.createBoxCtor("avcC",function(A){var m,v;for(this.configurationVersion=A.readUint8(),this.AVCProfileIndication=A.readUint8(),this.profile_compatibility=A.readUint8(),this.AVCLevelIndication=A.readUint8(),this.lengthSizeMinusOne=A.readUint8()&3,this.nb_SPS_nalus=A.readUint8()&31,v=this.size-this.hdr_size-6,this.SPS=[],m=0;m0&&(this.ext=A.readUint8Array(v))}),l.createBoxCtor("btrt",function(A){this.bufferSizeDB=A.readUint32(),this.maxBitrate=A.readUint32(),this.avgBitrate=A.readUint32()}),l.createFullBoxCtor("ccst",function(A){var m=A.readUint8();this.all_ref_pics_intra=(m&128)==128,this.intra_pred_used=(m&64)==64,this.max_ref_per_pic=(m&63)>>2,A.readUint24()}),l.createBoxCtor("cdef",function(A){var m;for(this.channel_count=A.readUint16(),this.channel_indexes=[],this.channel_types=[],this.channel_associations=[],m=0;m=32768&&this.component_type_urls.push(A.readCString())}}),l.createFullBoxCtor("co64",function(A){var m,v;if(m=A.readUint32(),this.chunk_offsets=[],this.version===0)for(v=0;v>7}else this.colour_type==="rICC"?this.ICC_profile=A.readUint8Array(this.size-4):this.colour_type==="prof"&&(this.ICC_profile=A.readUint8Array(this.size-4))}),l.createFullBoxCtor("cprt",function(A){this.parseLanguage(A),this.notice=A.readCString()}),l.createFullBoxCtor("cslg",function(A){this.version===0&&(this.compositionToDTSShift=A.readInt32(),this.leastDecodeToDisplayDelta=A.readInt32(),this.greatestDecodeToDisplayDelta=A.readInt32(),this.compositionStartTime=A.readInt32(),this.compositionEndTime=A.readInt32())}),l.createFullBoxCtor("ctts",function(A){var m,v;if(m=A.readUint32(),this.sample_counts=[],this.sample_offsets=[],this.version===0)for(v=0;v>6,this.bsid=m>>1&31,this.bsmod=(m&1)<<2|v>>6&3,this.acmod=v>>3&7,this.lfeon=v>>2&1,this.bit_rate_code=v&3|p>>5&7}),l.createBoxCtor("dec3",function(A){var m=A.readUint16();this.data_rate=m>>3,this.num_ind_sub=m&7,this.ind_subs=[];for(var v=0;v>6,p.bsid=b>>1&31,p.bsmod=(b&1)<<4|O>>4&15,p.acmod=O>>1&7,p.lfeon=O&1,p.num_dep_sub=w>>1&15,p.num_dep_sub>0&&(p.chan_loc=(w&1)<<8|A.readUint8())}}),l.createFullBoxCtor("dfLa",function(A){var m=127,v=128,p=[],b=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];do{var O=A.readUint8(),w=Math.min(O&m,b.length-1);if(w?A.readUint8Array(A.readUint24()):(A.readUint8Array(13),this.samplerate=A.readUint32()>>12,A.readUint8Array(20)),p.push(b[w]),O&v)break}while(!0);this.numMetadataBlocks=p.length+" ("+p.join(", ")+")"}),l.createBoxCtor("dimm",function(A){this.bytessent=A.readUint64()}),l.createBoxCtor("dmax",function(A){this.time=A.readUint32()}),l.createBoxCtor("dmed",function(A){this.bytessent=A.readUint64()}),l.createBoxCtor("dOps",function(A){if(this.Version=A.readUint8(),this.OutputChannelCount=A.readUint8(),this.PreSkip=A.readUint16(),this.InputSampleRate=A.readUint32(),this.OutputGain=A.readInt16(),this.ChannelMappingFamily=A.readUint8(),this.ChannelMappingFamily!==0){this.StreamCount=A.readUint8(),this.CoupledCount=A.readUint8(),this.ChannelMapping=[];for(var m=0;m=4;)this.compatible_brands[v]=A.readString(4),m-=4,v++}),l.createFullBoxCtor("hdlr",function(A){this.version===0&&(A.readUint32(),this.handler=A.readString(4),A.readUint32Array(3),this.name=A.readString(this.size-this.hdr_size-20),this.name[this.name.length-1]==="\0"&&(this.name=this.name.slice(0,-1)))}),l.createBoxCtor("hvcC",function(A){var m,v,p,b;this.configurationVersion=A.readUint8(),b=A.readUint8(),this.general_profile_space=b>>6,this.general_tier_flag=(b&32)>>5,this.general_profile_idc=b&31,this.general_profile_compatibility=A.readUint32(),this.general_constraint_indicator=A.readUint8Array(6),this.general_level_idc=A.readUint8(),this.min_spatial_segmentation_idc=A.readUint16()&4095,this.parallelismType=A.readUint8()&3,this.chroma_format_idc=A.readUint8()&3,this.bit_depth_luma_minus8=A.readUint8()&7,this.bit_depth_chroma_minus8=A.readUint8()&7,this.avgFrameRate=A.readUint16(),b=A.readUint8(),this.constantFrameRate=b>>6,this.numTemporalLayers=(b&13)>>3,this.temporalIdNested=(b&4)>>2,this.lengthSizeMinusOne=b&3,this.nalu_arrays=[];var O=A.readUint8();for(m=0;m>7,w.nalu_type=b&63;var y=A.readUint16();for(v=0;v>4&15,this.length_size=m&15,m=A.readUint8(),this.base_offset_size=m>>4&15,this.version===1||this.version===2?this.index_size=m&15:this.index_size=0,this.items=[];var v=0;if(this.version<2)v=A.readUint16();else if(this.version===2)v=A.readUint32();else throw"version of iloc box not supported";for(var p=0;p>7,this.axis=m&1}),l.createFullBoxCtor("infe",function(A){if((this.version===0||this.version===1)&&(this.item_ID=A.readUint16(),this.item_protection_index=A.readUint16(),this.item_name=A.readCString(),this.content_type=A.readCString(),this.content_encoding=A.readCString()),this.version===1){this.extension_type=A.readString(4),t.warn("BoxParser","Cannot parse extension type"),A.seek(this.start+this.size);return}this.version>=2&&(this.version===2?this.item_ID=A.readUint16():this.version===3&&(this.item_ID=A.readUint32()),this.item_protection_index=A.readUint16(),this.item_type=A.readString(4),this.item_name=A.readCString(),this.item_type==="mime"?(this.content_type=A.readCString(),this.content_encoding=A.readCString()):this.item_type==="uri "&&(this.item_uri_type=A.readCString()))}),l.createFullBoxCtor("ipma",function(A){var m,v;for(entry_count=A.readUint32(),this.associations=[],m=0;m>7===1,this.flags&1?w.property_index=(O&127)<<8|A.readUint8():w.property_index=O&127}}}),l.createFullBoxCtor("iref",function(A){var m,v;for(this.references=[];A.getPosition()>7,p.assignment_type=b&127,p.assignment_type){case 0:p.grouping_type=A.readString(4);break;case 1:p.grouping_type=A.readString(4),p.grouping_type_parameter=A.readUint32();break;case 2:break;case 3:break;case 4:p.sub_track_id=A.readUint32();break;default:t.warn("BoxParser","Unknown leva assignement type")}}}),l.createBoxCtor("lhvC",function(A){var m,v,p;this.configurationVersion=A.readUint8(),this.min_spatial_segmentation_idc=A.readUint16()&4095,this.parallelismType=A.readUint8()&3,p=A.readUint8(),this.numTemporalLayers=(p&13)>>3,this.temporalIdNested=(p&4)>>2,this.lengthSizeMinusOne=p&3,this.nalu_arrays=[];var b=A.readUint8();for(m=0;m>7,O.nalu_type=p&63;var w=A.readUint16();for(v=0;v>8,A.readUint16(),A.readUint32Array(2),this.matrix=A.readUint32Array(9),A.readUint32Array(6),this.next_track_id=A.readUint32()}),l.createBoxCtor("npck",function(A){this.packetssent=A.readUint32()}),l.createBoxCtor("nump",function(A){this.packetssent=A.readUint64()}),l.createFullBoxCtor("padb",function(A){var m=A.readUint32();this.padbits=[];for(var v=0;v0){var m=A.readUint32();this.kid=[];for(var v=0;v0&&(this.data=A.readUint8Array(p))}),l.createFullBoxCtor("clef",function(A){this.width=A.readUint32(),this.height=A.readUint32()}),l.createFullBoxCtor("enof",function(A){this.width=A.readUint32(),this.height=A.readUint32()}),l.createFullBoxCtor("prof",function(A){this.width=A.readUint32(),this.height=A.readUint32()}),l.createContainerBoxCtor("tapt",null,["clef","prof","enof"]),l.createBoxCtor("rtp ",function(A){this.descriptionformat=A.readString(4),this.sdptext=A.readString(this.size-this.hdr_size-4)}),l.createFullBoxCtor("saio",function(A){this.flags&1&&(this.aux_info_type=A.readUint32(),this.aux_info_type_parameter=A.readUint32());var m=A.readUint32();this.offset=[];for(var v=0;v>7,this.avgRateFlag=m>>6&1,this.durationFlag&&(this.duration=A.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=A.readUint8(),this.avgBitRate=A.readUint16(),this.avgFrameRate=A.readUint16()),this.dependency=[];for(var v=A.readUint8(),p=0;p>7,this.num_leading_samples=m&127}),l.createSampleGroupCtor("rash",function(A){if(this.operation_point_count=A.readUint16(),this.description_length!==2+(this.operation_point_count===1?2:this.operation_point_count*6)+9)t.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=A.readUint8Array(this.description_length-2);else{if(this.operation_point_count===1)this.target_rate_share=A.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(var m=0;m>4,this.skip_byte_block=m&15,this.isProtected=A.readUint8(),this.Per_Sample_IV_Size=A.readUint8(),this.KID=l.parseHex16(A),this.constant_IV_size=0,this.constant_IV=0,this.isProtected===1&&this.Per_Sample_IV_Size===0&&(this.constant_IV_size=A.readUint8(),this.constant_IV=A.readUint8Array(this.constant_IV_size))}),l.createSampleGroupCtor("stsa",function(A){t.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),l.createSampleGroupCtor("sync",function(A){var m=A.readUint8();this.NAL_unit_type=m&63}),l.createSampleGroupCtor("tele",function(A){var m=A.readUint8();this.level_independently_decodable=m>>7}),l.createSampleGroupCtor("tsas",function(A){t.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),l.createSampleGroupCtor("tscl",function(A){t.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),l.createSampleGroupCtor("vipr",function(A){t.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),l.createFullBoxCtor("sbgp",function(A){this.grouping_type=A.readString(4),this.version===1?this.grouping_type_parameter=A.readUint32():this.grouping_type_parameter=0,this.entries=[];for(var m=A.readUint32(),v=0;v>6,this.sample_depends_on[p]=m>>4&3,this.sample_is_depended_on[p]=m>>2&3,this.sample_has_redundancy[p]=m&3}),l.createFullBoxCtor("senc"),l.createFullBoxCtor("sgpd",function(A){this.grouping_type=A.readString(4),t.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),this.version===1?this.default_length=A.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=A.readUint32()),this.entries=[];for(var m=A.readUint32(),v=0;v>31&1,p.referenced_size=b&2147483647,p.subsegment_duration=A.readUint32(),b=A.readUint32(),p.starts_with_SAP=b>>31&1,p.SAP_type=b>>28&7,p.SAP_delta_time=b&268435455}}),l.SingleItemTypeReferenceBox=function(A,m,v,p){l.Box.call(this,A,m),this.hdr_size=v,this.start=p},l.SingleItemTypeReferenceBox.prototype=new l.Box,l.SingleItemTypeReferenceBox.prototype.parse=function(A){this.from_item_ID=A.readUint16();var m=A.readUint16();this.references=[];for(var v=0;v>4&15,this.sample_sizes[m+1]=p&15}else if(this.field_size===8)for(m=0;m0)for(v=0;v>4&15,this.default_skip_byte_block=m&15}this.default_isProtected=A.readUint8(),this.default_Per_Sample_IV_Size=A.readUint8(),this.default_KID=l.parseHex16(A),this.default_isProtected===1&&this.default_Per_Sample_IV_Size===0&&(this.default_constant_IV_size=A.readUint8(),this.default_constant_IV=A.readUint8Array(this.default_constant_IV_size))}),l.createFullBoxCtor("tfdt",function(A){this.version==1?this.baseMediaDecodeTime=A.readUint64():this.baseMediaDecodeTime=A.readUint32()}),l.createFullBoxCtor("tfhd",function(A){var m=0;this.track_id=A.readUint32(),this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=A.readUint64(),m+=8):this.base_data_offset=0,this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=A.readUint32(),m+=4):this.default_sample_description_index=0,this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=A.readUint32(),m+=4):this.default_sample_duration=0,this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=A.readUint32(),m+=4):this.default_sample_size=0,this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=A.readUint32(),m+=4):this.default_sample_flags=0}),l.createFullBoxCtor("tfra",function(A){this.track_ID=A.readUint32(),A.readUint24();var m=A.readUint8();this.length_size_of_traf_num=m>>4&3,this.length_size_of_trun_num=m>>2&3,this.length_size_of_sample_num=m&3,this.entries=[];for(var v=A.readUint32(),p=0;p>8,A.readUint16(),this.matrix=A.readInt32Array(9),this.width=A.readUint32(),this.height=A.readUint32()}),l.createBoxCtor("tmax",function(A){this.time=A.readUint32()}),l.createBoxCtor("tmin",function(A){this.time=A.readUint32()}),l.createBoxCtor("totl",function(A){this.bytessent=A.readUint32()}),l.createBoxCtor("tpay",function(A){this.bytessent=A.readUint32()}),l.createBoxCtor("tpyl",function(A){this.bytessent=A.readUint64()}),l.TrackGroupTypeBox.prototype.parse=function(A){this.parseFullHeader(A),this.track_group_id=A.readUint32()},l.createTrackGroupCtor("msrc"),l.TrackReferenceTypeBox=function(A,m,v,p){l.Box.call(this,A,m),this.hdr_size=v,this.start=p},l.TrackReferenceTypeBox.prototype=new l.Box,l.TrackReferenceTypeBox.prototype.parse=function(A){this.track_ids=A.readUint32Array((this.size-this.hdr_size)/4)},l.trefBox.prototype.parse=function(A){for(var m,v;A.getPosition()m&&this.flags&l.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=A.readInt32(),m+=4):this.data_offset=0,this.size-this.hdr_size>m&&this.flags&l.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=A.readUint32(),m+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>m)for(var v=0;v>7&1,this.block_pad_lsb=v>>6&1,this.block_little_endian=v>>5&1,this.block_reversed=v>>4&1,this.pad_unknown=v>>3&1,this.pixel_size=A.readUint32(),this.row_align_size=A.readUint32(),this.tile_align_size=A.readUint32(),this.num_tile_cols_minus_one=A.readUint32(),this.num_tile_rows_minus_one=A.readUint32()}}),l.createFullBoxCtor("url ",function(A){this.flags!==1&&(this.location=A.readCString())}),l.createFullBoxCtor("urn ",function(A){this.name=A.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=A.readCString())}),l.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66",!0,!1,function(A){this.LiveServerManifest=A.readString(this.size-this.hdr_size).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}),l.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,function(A){this.system_id=l.parseHex16(A);var m=A.readUint32();m>0&&(this.data=A.readUint8Array(m))}),l.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1),l.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,function(A){this.default_AlgorithmID=A.readUint24(),this.default_IV_size=A.readUint8(),this.default_KID=l.parseHex16(A)}),l.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,function(A){this.fragment_count=A.readUint8(),this.entries=[];for(var m=0;m>4,this.chromaSubsampling=m>>1&7,this.videoFullRangeFlag=m&1,this.colourPrimaries=A.readUint8(),this.transferCharacteristics=A.readUint8(),this.matrixCoefficients=A.readUint8(),this.codecIntializationDataSize=A.readUint16(),this.codecIntializationData=A.readUint8Array(this.codecIntializationDataSize)):(this.profile=A.readUint8(),this.level=A.readUint8(),m=A.readUint8(),this.bitDepth=m>>4&15,this.colorSpace=m&15,m=A.readUint8(),this.chromaSubsampling=m>>4&15,this.transferFunction=m>>1&7,this.videoFullRangeFlag=m&1,this.codecIntializationDataSize=A.readUint16(),this.codecIntializationData=A.readUint8Array(this.codecIntializationDataSize))}),l.createBoxCtor("vttC",function(A){this.text=A.readString(this.size-this.hdr_size)}),l.createFullBoxCtor("vvcC",function(A){var m,v,p={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(D){this.held_bits=D.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(D){this.held_bits=D.readUint16(),this.num_held_bits=16},extract_bits:function(D){var Q=this.held_bits>>this.num_held_bits-D&(1<1){for(p.stream_read_1_bytes(A),this.ptl_sublayer_present_mask=0,v=this.num_sublayers-2;v>=0;--v){var w=p.extract_bits(1);this.ptl_sublayer_present_mask|=w<1;++v)p.extract_bits(1);for(this.sublayer_level_idc=[],v=this.num_sublayers-2;v>=0;--v)this.ptl_sublayer_present_mask&1<"u"||m===null?m=2:m;v.length>=1;m+=l.decimalToHex(p,0),m+=".",this.hvcC.general_tier_flag===0?m+="L":m+="H",m+=this.hvcC.general_level_idc;var b=!1,O="";for(A=5;A>=0;A--)(this.hvcC.general_constraint_indicator[A]||b)&&(O="."+l.decimalToHex(this.hvcC.general_constraint_indicator[A],0)+O,b=!0);m+=O}return m},l.vvc1SampleEntry.prototype.getCodec=l.vvi1SampleEntry.prototype.getCodec=function(){var A,m=l.SampleEntry.prototype.getCodec.call(this);if(this.vvcC){m+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?m+=".H":m+=".L",m+=this.vvcC.general_level_idc;var v="";if(this.vvcC.general_constraint_info){var p=[],b=0;b|=this.vvcC.ptl_frame_only_constraint<<7,b|=this.vvcC.ptl_multilayer_enabled<<6;var O;for(A=0;A>2&63,p.push(b),b&&(O=A),b=this.vvcC.general_constraint_info[A]>>2&3;if(O===void 0)v=".CA";else{v=".C";var w="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",y=0,C=0;for(A=0;A<=O;++A)for(y=y<<8|p[A],C+=8;C>=5;){var x=y>>C-5&31;v+=w[x],C-=5,y&=(1<o&&(this.size+=8),this.type==="uuid"&&(this.size+=16),t.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+A.getPosition()+(m||"")),this.size>o?A.writeUint32(1):(this.sizePosition=A.getPosition(),A.writeUint32(this.size)),A.writeString(this.type,null,4),this.type==="uuid"&&A.writeUint8Array(this.uuid),this.size>o&&A.writeUint64(this.size)},l.FullBox.prototype.writeHeader=function(A){this.size+=4,l.Box.prototype.writeHeader.call(this,A," v="+this.version+" f="+this.flags),A.writeUint8(this.version),A.writeUint24(this.flags)},l.Box.prototype.write=function(A){this.type==="mdat"?this.data&&(this.size=this.data.length,this.writeHeader(A),A.writeUint8Array(this.data)):(this.size=this.data?this.data.length:0,this.writeHeader(A),this.data&&A.writeUint8Array(this.data))},l.ContainerBox.prototype.write=function(A){this.size=0,this.writeHeader(A);for(var m=0;m=2&&A.writeUint32(this.default_sample_description_index),A.writeUint32(this.entries.length),m=0;m0)for(m=0;m+1m?1:0,this.flags=0,this.size=4,this.version===1&&(this.size+=4),this.writeHeader(A),this.version===1?A.writeUint64(this.baseMediaDecodeTime):A.writeUint32(this.baseMediaDecodeTime)},l.tfhdBox.prototype.write=function(A){this.version=0,this.size=4,this.flags&l.TFHD_FLAG_BASE_DATA_OFFSET&&(this.size+=8),this.flags&l.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&l.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&l.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&l.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(A),A.writeUint32(this.track_id),this.flags&l.TFHD_FLAG_BASE_DATA_OFFSET&&A.writeUint64(this.base_data_offset),this.flags&l.TFHD_FLAG_SAMPLE_DESC&&A.writeUint32(this.default_sample_description_index),this.flags&l.TFHD_FLAG_SAMPLE_DUR&&A.writeUint32(this.default_sample_duration),this.flags&l.TFHD_FLAG_SAMPLE_SIZE&&A.writeUint32(this.default_sample_size),this.flags&l.TFHD_FLAG_SAMPLE_FLAGS&&A.writeUint32(this.default_sample_flags)},l.tkhdBox.prototype.write=function(A){this.version=0,this.size=4*18+2*4,this.writeHeader(A),A.writeUint32(this.creation_time),A.writeUint32(this.modification_time),A.writeUint32(this.track_id),A.writeUint32(0),A.writeUint32(this.duration),A.writeUint32(0),A.writeUint32(0),A.writeInt16(this.layer),A.writeInt16(this.alternate_group),A.writeInt16(this.volume<<8),A.writeUint16(0),A.writeInt32Array(this.matrix),A.writeUint32(this.width),A.writeUint32(this.height)},l.trexBox.prototype.write=function(A){this.version=0,this.flags=0,this.size=4*5,this.writeHeader(A),A.writeUint32(this.track_id),A.writeUint32(this.default_sample_description_index),A.writeUint32(this.default_sample_duration),A.writeUint32(this.default_sample_size),A.writeUint32(this.default_sample_flags)},l.trunBox.prototype.write=function(A){this.version=0,this.size=4,this.flags&l.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&l.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&l.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&l.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&l.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&l.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(A),A.writeUint32(this.sample_count),this.flags&l.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=A.getPosition(),A.writeInt32(this.data_offset)),this.flags&l.TRUN_FLAGS_FIRST_FLAG&&A.writeUint32(this.first_sample_flags);for(var m=0;m0&&A.writeUint8Array(this.codecIntializationData)},l.cttsBox.prototype.unpack=function(A){var m,v,p;for(p=0,m=0;m-1)){if(A[v]instanceof l.Box||m[v]instanceof l.Box||typeof A[v]>"u"||typeof m[v]>"u"||typeof A[v]=="function"||typeof m[v]=="function"||A.subBoxNames&&A.subBoxNames.indexOf(v.slice(0,4))>-1||m.subBoxNames&&m.subBoxNames.indexOf(v.slice(0,4))>-1||v==="data"||v==="start"||v==="size"||v==="creation_time"||v==="modification_time"||l.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(v)>-1)continue;if(A[v]!==m[v])return!1}return!0},l.boxEqual=function(A,m){if(!l.boxEqualFields(A,m))return!1;for(var v=0;v1)for(v=1;v-1&&this.fragmentedTracks.splice(m,1)},g.prototype.setExtractionOptions=function(A,m,v){var p=this.getTrackById(A);if(p){var b={};this.extractedTracks.push(b),b.id=A,b.user=m,b.trak=p,p.nextSample=0,b.nb_samples=1e3,b.samples=[],v&&v.nbSamples&&(b.nb_samples=v.nbSamples)}},g.prototype.unsetExtractionOptions=function(A){for(var m=-1,v=0;v-1&&this.extractedTracks.splice(m,1)},g.prototype.parse=function(){var A,m,v=!1;if(!(this.restoreParsePosition&&!this.restoreParsePosition()))for(;;)if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}else if(this.saveParsePosition&&this.saveParsePosition(),A=l.parseOneBox(this.stream,v),A.code===l.ERR_NOT_ENOUGH_DATA)if(this.processIncompleteBox){if(this.processIncompleteBox(A))continue;return}else return;else{var p;switch(m=A.box,p=m.type!=="uuid"?m.type:m.uuid,this.boxes.push(m),p){case"mdat":this.mdats.push(m);break;case"moof":this.moofs.push(m);break;case"moov":this.moovStartFound=!0,this.mdats.length===0&&(this.isProgressive=!0);default:this[p]!==void 0&&t.warn("ISOFile","Duplicate Box of type: "+p+", overriding previous occurrence"),this[p]=m;break}this.updateUsedBytes&&this.updateUsedBytes(m,A)}},g.prototype.checkBuffer=function(A){if(A==null)throw"Buffer must be defined and non empty";if(A.fileStart===void 0)throw"Buffer must have a fileStart property";return A.byteLength===0?(t.warn("ISOFile","Ignoring empty buffer (fileStart: "+A.fileStart+")"),this.stream.logBufferLevel(),!1):(t.info("ISOFile","Processing buffer (fileStart: "+A.fileStart+")"),A.usedBytes=0,this.stream.insertBuffer(A),this.stream.logBufferLevel(),this.stream.initialized()?!0:(t.warn("ISOFile","Not ready to start parsing"),!1))},g.prototype.appendBuffer=function(A,m){var v;if(this.checkBuffer(A))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(m),this.nextSeekPosition?(v=this.nextSeekPosition,this.nextSeekPosition=void 0):v=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(v=this.stream.getEndFilePositionAfter(v))):this.nextParsePosition?v=this.nextParsePosition:v=0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(t.info("ISOFile","Done processing buffer (fileStart: "+A.fileStart+") - next buffer to fetch should have a fileStart position of "+v),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),t.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),v},g.prototype.getInfo=function(){var A,m,v={},p,b,O,w,y=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(v.hasMoov=!0,v.duration=this.moov.mvhd.duration,v.timescale=this.moov.mvhd.timescale,v.isFragmented=this.moov.mvex!=null,v.isFragmented&&this.moov.mvex.mehd&&(v.fragment_duration=this.moov.mvex.mehd.fragment_duration),v.isProgressive=this.isProgressive,v.hasIOD=this.moov.iods!=null,v.brands=[],v.brands.push(this.ftyp.major_brand),v.brands=v.brands.concat(this.ftyp.compatible_brands),v.created=new Date(y+this.moov.mvhd.creation_time*1e3),v.modified=new Date(y+this.moov.mvhd.modification_time*1e3),v.tracks=[],v.audioTracks=[],v.videoTracks=[],v.subtitleTracks=[],v.metadataTracks=[],v.hintTracks=[],v.otherTracks=[],A=0;A0?v.mime+='video/mp4; codecs="':v.audioTracks&&v.audioTracks.length>0?v.mime+='audio/mp4; codecs="':v.mime+='application/mp4; codecs="',A=0;A=v.samples.length)&&(t.info("ISOFile","Sending fragmented data on track #"+p.id+" for samples ["+Math.max(0,v.nextSample-p.nb_samples)+","+(v.nextSample-1)+"]"),t.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(p.id,p.user,p.segmentStream.buffer,v.nextSample,A||v.nextSample>=v.samples.length),p.segmentStream=null,p!==this.fragmentedTracks[m]))break}}if(this.onSamples!==null)for(m=0;m=v.samples.length)&&(t.debug("ISOFile","Sending samples on track #"+O.id+" for sample "+v.nextSample),this.onSamples&&this.onSamples(O.id,O.user,O.samples),O.samples=[],O!==this.extractedTracks[m]))break}}}},g.prototype.getBox=function(A){var m=this.getBoxes(A,!0);return m.length?m[0]:null},g.prototype.getBoxes=function(A,m){var v=[];return g._sweep.call(this,A,v,m),v},g._sweep=function(A,m,v){this.type&&this.type==A&&m.push(this);for(var p in this.boxes){if(m.length&&v)return;g._sweep.call(this.boxes[p],A,m,v)}},g.prototype.getTrackSamplesInfo=function(A){var m=this.getTrackById(A);if(m)return m.samples},g.prototype.getTrackSample=function(A,m){var v=this.getTrackById(A),p=this.getSample(v,m);return p},g.prototype.releaseUsedSamples=function(A,m){var v=0,p=this.getTrackById(A);p.lastValidSample||(p.lastValidSample=0);for(var b=p.lastValidSample;bA*b.timescale){y=p-1;break}m&&b.is_sync&&(w=p)}for(m&&(y=w),A=v.samples[y].cts,v.nextSample=y;v.samples[y].alreadyRead===v.samples[y].size&&v.samples[y+1];)y++;return O=v.samples[y].offset+v.samples[y].alreadyRead,t.info("ISOFile","Seeking to "+(m?"RAP":"")+" sample #"+v.nextSample+" on track "+v.tkhd.track_id+", time "+t.getDurationString(A,C)+" and offset: "+O),{offset:O,time:A/C}},g.prototype.getTrackDuration=function(A){var m;return A.samples?(m=A.samples[A.samples.length-1],(m.cts+m.duration)/m.timescale):1/0},g.prototype.seek=function(A,m){var v=this.moov,p,b,O,w={offset:1/0,time:1/0};if(this.moov){for(O=0;Othis.getTrackDuration(p))&&(b=this.seekTrack(A,m,p),b.offset-1){w=y;break}switch(w){case"Visual":if(b.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),O.set("width",m.width).set("height",m.height).set("horizresolution",72<<16).set("vertresolution",72<<16).set("frame_count",1).set("compressorname",m.type+" Compressor").set("depth",24),m.avcDecoderConfigRecord){var L=new l.avcCBox;L.parse(new n(m.avcDecoderConfigRecord)),O.addBox(L)}else if(m.hevcDecoderConfigRecord){var S=new l.hvcCBox;S.parse(new n(m.hevcDecoderConfigRecord)),O.addBox(S)}else if(m.vpcDecoderConfigRecord){var T=new l.vpcCBox;T.parse(new n(m.vpcDecoderConfigRecord)),O.addBox(T)}break;case"Audio":b.add("smhd").set("balance",m.balance||0),O.set("channel_count",m.channel_count||2).set("samplesize",m.samplesize||16).set("samplerate",m.samplerate||65536);break;case"Hint":b.add("hmhd");break;case"Subtitle":switch(b.add("sthd"),m.type){case"stpp":O.set("namespace",m.namespace||"nonamespace").set("schema_location",m.schema_location||"").set("auxiliary_mime_types",m.auxiliary_mime_types||"");break}break;case"Metadata":b.add("nmhd");break;case"System":b.add("nmhd");break;default:b.add("nmhd");break}m.description&&O.addBox(m.description),m.description_boxes&&m.description_boxes.forEach(function(Q){O.addBox(Q)}),b.add("dinf").add("dref").addEntry(new l["url Box"]().set("flags",1));var D=b.add("stbl");return D.add("stsd").addEntry(O),D.add("stts").set("sample_counts",[]).set("sample_deltas",[]),D.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),D.add("stco").set("chunk_offsets",[]),D.add("stsz").set("sample_sizes",[]),this.moov.mvex.add("trex").set("track_id",m.id).set("default_sample_description_index",m.default_sample_description_index||1).set("default_sample_duration",m.default_sample_duration||0).set("default_sample_size",m.default_sample_size||0).set("default_sample_flags",m.default_sample_flags||0),this.buildTrakSampleLists(v),m.id}},l.Box.prototype.computeSize=function(A){var m=A||new r;m.endianness=r.BIG_ENDIAN,this.write(m)},g.prototype.addSample=function(A,m,v){var p=v||{},b={},O=this.getTrackById(A);if(O!==null){b.number=O.samples.length,b.track_id=O.tkhd.track_id,b.timescale=O.mdia.mdhd.timescale,b.description_index=p.sample_description_index?p.sample_description_index-1:0,b.description=O.mdia.minf.stbl.stsd.entries[b.description_index],b.data=m,b.size=m.byteLength,b.alreadyRead=b.size,b.duration=p.duration||1,b.cts=p.cts||0,b.dts=p.dts||0,b.is_sync=p.is_sync||!1,b.is_leading=p.is_leading||0,b.depends_on=p.depends_on||0,b.is_depended_on=p.is_depended_on||0,b.has_redundancy=p.has_redundancy||0,b.degradation_priority=p.degradation_priority||0,b.offset=0,b.subsamples=p.subsamples,O.samples.push(b),O.samples_size+=b.size,O.samples_duration+=b.duration,O.first_dts===void 0&&(O.first_dts=p.dts),this.processSamples();var w=this.createSingleSampleMoof(b);return this.addBox(w),w.computeSize(),w.trafs[0].truns[0].data_offset=w.size+8,this.add("mdat").data=new Uint8Array(m),b}},g.prototype.createSingleSampleMoof=function(A){var m=0;A.is_sync?m=1<<25:m=65536;var v=new l.moofBox;v.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++;var p=v.add("traf"),b=this.getTrackById(A.track_id);return p.add("tfhd").set("track_id",A.track_id).set("flags",l.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),p.add("tfdt").set("baseMediaDecodeTime",A.dts-(b.first_dts||0)),p.add("trun").set("flags",l.TRUN_FLAGS_DATA_OFFSET|l.TRUN_FLAGS_DURATION|l.TRUN_FLAGS_SIZE|l.TRUN_FLAGS_FLAGS|l.TRUN_FLAGS_CTS_OFFSET).set("data_offset",0).set("first_sample_flags",0).set("sample_count",1).set("sample_duration",[A.duration]).set("sample_size",[A.size]).set("sample_flags",[m]).set("sample_composition_time_offset",[A.cts-A.dts]),v},g.prototype.lastMoofIndex=0,g.prototype.samplesDataSize=0,g.prototype.resetTables=function(){var A,m,v,p,b,O,w,y;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,A=0;A=2&&(C=b[w].grouping_type+"/0",y=new x(b[w].grouping_type,0),y.is_fragment=!0,m.sample_groups_info[C]||(m.sample_groups_info[C]=y))}else for(w=0;w=2&&(C=p[w].grouping_type+"/0",y=new x(p[w].grouping_type,0),A.sample_groups_info[C]||(A.sample_groups_info[C]=y))},g.setSampleGroupProperties=function(A,m,v,p){var b,O;m.sample_groups=[];for(b in p)if(m.sample_groups[b]={},m.sample_groups[b].grouping_type=p[b].grouping_type,m.sample_groups[b].grouping_type_parameter=p[b].grouping_type_parameter,v>=p[b].last_sample_in_run&&(p[b].last_sample_in_run<0&&(p[b].last_sample_in_run=0),p[b].entry_index++,p[b].entry_index<=p[b].sbgp.entries.length-1&&(p[b].last_sample_in_run+=p[b].sbgp.entries[p[b].entry_index].sample_count)),p[b].entry_index<=p[b].sbgp.entries.length-1?m.sample_groups[b].group_description_index=p[b].sbgp.entries[p[b].entry_index].group_description_index:m.sample_groups[b].group_description_index=-1,m.sample_groups[b].group_description_index!==0){var w;p[b].fragment_description?w=p[b].fragment_description:w=p[b].description,m.sample_groups[b].group_description_index>0?(m.sample_groups[b].group_description_index>65535?O=(m.sample_groups[b].group_description_index>>16)-1:O=m.sample_groups[b].group_description_index-1,w&&O>=0&&(m.sample_groups[b].description=w.entries[O])):w&&w.version>=2&&w.default_group_description_index>0&&(m.sample_groups[b].description=w.entries[w.default_group_description_index-1])}},g.process_sdtp=function(A,m,v){m&&(A?(m.is_leading=A.is_leading[v],m.depends_on=A.sample_depends_on[v],m.is_depended_on=A.sample_is_depended_on[v],m.has_redundancy=A.sample_has_redundancy[v]):(m.is_leading=0,m.depends_on=0,m.is_depended_on=0,m.has_redundancy=0))},g.prototype.buildSampleLists=function(){var A,m;for(A=0;A"u")){for(m=0;mF&&(R++,F<0&&(F=0),F+=O.sample_counts[R]),m>0?(A.samples[m-1].duration=O.sample_deltas[R],A.samples_duration+=A.samples[m-1].duration,Y.dts=A.samples[m-1].dts+A.samples[m-1].duration):Y.dts=0,w?(m>=N&&(I++,N<0&&(N=0),N+=w.sample_counts[I]),Y.cts=A.samples[m].dts+w.sample_offsets[I]):Y.cts=Y.dts,y?(m==y.sample_numbers[W]-1?(Y.is_sync=!0,W++):(Y.is_sync=!1,Y.degradation_priority=0),x&&x.entries[V].sample_delta+z==m+1&&(Y.subsamples=x.entries[V].subsamples,z+=x.entries[V].sample_delta,V++)):Y.is_sync=!0,g.process_sdtp(A.mdia.minf.stbl.sdtp,Y,Y.number),T?Y.degradation_priority=T.priority[m]:Y.degradation_priority=0,x&&x.entries[V].sample_delta+z==m&&(Y.subsamples=x.entries[V].subsamples,z+=x.entries[V].sample_delta),(L.length>0||S.length>0)&&g.setSampleGroupProperties(A,Y,m,A.sample_groups_info)}m>0&&(A.samples[m-1].duration=Math.max(A.mdia.mdhd.duration-A.samples[m-1].dts,0),A.samples_duration+=A.samples[m-1].duration)}},g.prototype.updateSampleLists=function(){var A,m,v,p,b,O,w,y,C,x,L,S,T,D,Q;if(this.moov!==void 0){for(;this.lastMoofIndex0&&g.initSampleGroups(S,L,L.sbgps,S.mdia.minf.stbl.sgpds,L.sgpds),m=0;m0?D.dts=S.samples[S.samples.length-2].dts+S.samples[S.samples.length-2].duration:(L.tfdt?D.dts=L.tfdt.baseMediaDecodeTime:D.dts=0,S.first_traf_merged=!0),D.cts=D.dts,M.flags&l.TRUN_FLAGS_CTS_OFFSET&&(D.cts=D.dts+M.sample_composition_time_offset[v]),Q=w,M.flags&l.TRUN_FLAGS_FLAGS?Q=M.sample_flags[v]:v===0&&M.flags&l.TRUN_FLAGS_FIRST_FLAG&&(Q=M.first_sample_flags),D.is_sync=!(Q>>16&1),D.is_leading=Q>>26&3,D.depends_on=Q>>24&3,D.is_depended_on=Q>>22&3,D.has_redundancy=Q>>20&3,D.degradation_priority=Q&65535;var B=!!(L.tfhd.flags&l.TFHD_FLAG_BASE_DATA_OFFSET),P=!!(L.tfhd.flags&l.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),F=!!(M.flags&l.TRUN_FLAGS_DATA_OFFSET),R=0;B?R=L.tfhd.base_data_offset:P||m===0?R=x.start:R=y,m===0&&v===0?F?D.offset=R+M.data_offset:D.offset=R:D.offset=y,y=D.offset+D.size,(L.sbgps.length>0||L.sgpds.length>0||S.mdia.minf.stbl.sbgps.length>0||S.mdia.minf.stbl.sgpds.length>0)&&g.setSampleGroupProperties(S,D,D.number_in_traf,L.sample_groups_info)}}if(L.subs){S.has_fragment_subsamples=!0;var N=L.first_sample_index;for(m=0;m-1){v=this.stream.buffers[b];var O=v.byteLength-(p.offset+p.alreadyRead-v.fileStart);if(p.size-p.alreadyRead<=O)return t.debug("ISOFile","Getting sample #"+m+" data (alreadyRead: "+p.alreadyRead+" offset: "+(p.offset+p.alreadyRead-v.fileStart)+" read size: "+(p.size-p.alreadyRead)+" full size: "+p.size+")"),r.memcpy(p.data.buffer,p.alreadyRead,v,p.offset+p.alreadyRead-v.fileStart,p.size-p.alreadyRead),v.usedBytes+=p.size-p.alreadyRead,this.stream.logBufferLevel(),p.alreadyRead=p.size,p;if(O===0)return null;t.debug("ISOFile","Getting sample #"+m+" partial data (alreadyRead: "+p.alreadyRead+" offset: "+(p.offset+p.alreadyRead-v.fileStart)+" read size: "+O+" full size: "+p.size+")"),r.memcpy(p.data.buffer,p.alreadyRead,v,p.offset+p.alreadyRead-v.fileStart,O),p.alreadyRead+=O,v.usedBytes+=O,this.stream.logBufferLevel()}else return null}},g.prototype.releaseSample=function(A,m){var v=A.samples[m];return v.data?(this.samplesDataSize-=v.size,v.data=null,v.alreadyRead=0,v.size):0},g.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize},g.prototype.getCodecs=function(){var A,m="";for(A=0;A0&&(m+=","),m+=v.mdia.minf.stbl.stsd.entries[0].getCodec()}return m},g.prototype.getTrexById=function(A){var m;if(!this.moov||!this.moov.mvex)return null;for(m=0;m0&&(b.protection=O.ipro.protections[O.iinf.item_infos[v].protection_index-1]),O.iinf.item_infos[v].item_type?b.type=O.iinf.item_infos[v].item_type:b.type="mime",b.content_type=O.iinf.item_infos[v].content_type,b.content_encoding=O.iinf.item_infos[v].content_encoding;if(O.grpl)for(v=0;v0&&S.property_index-1-1){m=this.stream.buffers[O];var w=m.byteLength-(b.offset+b.alreadyRead-m.fileStart);if(b.length-b.alreadyRead<=w)t.debug("ISOFile","Getting item #"+A+" extent #"+p+" data (alreadyRead: "+b.alreadyRead+" offset: "+(b.offset+b.alreadyRead-m.fileStart)+" read size: "+(b.length-b.alreadyRead)+" full extent size: "+b.length+" full item size: "+v.size+")"),r.memcpy(v.data.buffer,v.alreadyRead,m,b.offset+b.alreadyRead-m.fileStart,b.length-b.alreadyRead),m.usedBytes+=b.length-b.alreadyRead,this.stream.logBufferLevel(),v.alreadyRead+=b.length-b.alreadyRead,b.alreadyRead=b.length;else return t.debug("ISOFile","Getting item #"+A+" extent #"+p+" partial data (alreadyRead: "+b.alreadyRead+" offset: "+(b.offset+b.alreadyRead-m.fileStart)+" read size: "+w+" full extent size: "+b.length+" full item size: "+v.size+")"),r.memcpy(v.data.buffer,v.alreadyRead,m,b.offset+b.alreadyRead-m.fileStart,w),b.alreadyRead+=w,v.alreadyRead+=w,m.usedBytes+=w,this.stream.logBufferLevel(),null}else return null}}return v.alreadyRead===v.size?v:null},g.prototype.releaseItem=function(A){var m=this.items[A];if(m.data){this.itemsDataSize-=m.size,m.data=null,m.alreadyRead=0;for(var v=0;v0?this.moov.traks[A].samples[0].duration:0),m.push(p)}return m},l.Box.prototype.printHeader=function(A){this.size+=8,this.size>o&&(this.size+=8),this.type==="uuid"&&(this.size+=16),A.log(A.indent+"size:"+this.size),A.log(A.indent+"type:"+this.type)},l.FullBox.prototype.printHeader=function(A){this.size+=4,l.Box.prototype.printHeader.call(this,A),A.log(A.indent+"version:"+this.version),A.log(A.indent+"flags:"+this.flags)},l.Box.prototype.print=function(A){this.printHeader(A)},l.ContainerBox.prototype.print=function(A){this.printHeader(A);for(var m=0;m>8)),A.log(A.indent+"matrix: "+this.matrix.join(", ")),A.log(A.indent+"next_track_id: "+this.next_track_id)},l.tkhdBox.prototype.print=function(A){l.FullBox.prototype.printHeader.call(this,A),A.log(A.indent+"creation_time: "+this.creation_time),A.log(A.indent+"modification_time: "+this.modification_time),A.log(A.indent+"track_id: "+this.track_id),A.log(A.indent+"duration: "+this.duration),A.log(A.indent+"volume: "+(this.volume>>8)),A.log(A.indent+"matrix: "+this.matrix.join(", ")),A.log(A.indent+"layer: "+this.layer),A.log(A.indent+"alternate_group: "+this.alternate_group),A.log(A.indent+"width: "+this.width),A.log(A.indent+"height: "+this.height)};var k={};k.createFile=function(A,m){var v=A!==void 0?A:!0,p=new g(m);return p.discardMdatData=!v,p},e.createFile=k.createFile})(Q_n);const OGe=MMs(Q_n),RMs=()=>{let e,t=16.6;self.onmessage=n=>{n.data.event==="start"&&(self.clearInterval(e),e=self.setInterval(()=>{self.postMessage({})},t)),n.data.event==="stop"&&self.clearInterval(e)}},IMs=()=>{const e=new Blob([`(${RMs.toString()})()`]),t=URL.createObjectURL(e);return new Worker(t)},rU=new Map;let wGe=1,ij=null;globalThis.Worker!=null&&(ij=IMs(),ij.onmessage=()=>{wGe+=1;for(const[e,t]of rU)if(wGe%e===0)for(const n of t)n()});const NMs=(e,t)=>{const n=Math.round(t/16.6),r=rU.get(n)??new Set;return r.add(e),rU.set(n,r),rU.size===1&&r.size===1&&(ij==null||ij.postMessage({event:"start"})),()=>{r.delete(e),r.size===0&&rU.delete(n),rU.size===0&&(wGe=0,ij==null||ij.postMessage({event:"stop"}))}};function UMs(e){return e instanceof Error?String(e):typeof e=="object"?JSON.stringify(e,(t,n)=>n instanceof Error?String(n):n):String(e)}function jMs(){const e=new Date;return`${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}.${e.getMilliseconds()}`}let B_n=1;const F_n=[],_kn=["debug","info","warn","error"].reduce((e,t,n)=>Object.assign(e,{[t]:(...r)=>{B_n<=n&&(console[t](...r),F_n.push({lvName:t,timeStr:jMs(),args:r}))}}),{}),foe=new Map,ld={setLogLevel:e=>{B_n=foe.get(e)??1},..._kn,create:e=>Object.fromEntries(Object.entries(_kn).map(([t,n])=>[t,(...r)=>n(e,...r)])),async dump(){return F_n.reduce((e,{lvName:t,timeStr:n,args:r})=>e+`[${t}][${n}] ${r.map(o=>UMs(o)).join(" ")} + */function jkn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Gy(e){for(var t=1;t=0)&&(n[o]=e[o]);return n}function $Qs(e,t){if(e==null)return{};var n=_Qs(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var eBs="1.15.2";function C8(e){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(e)}var Z6=C8(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),uoe=C8(/Edge/i),Wkn=C8(/firefox/i),xJ=C8(/safari/i)&&!C8(/chrome/i)&&!C8(/android/i),A_n=C8(/iP(ad|od|hone)/i),f_n=C8(/chrome/i)&&C8(/android/i),g_n={capture:!1,passive:!1};function Sl(e,t,n){e.addEventListener(t,n,!Z6&&g_n)}function el(e,t,n){e.removeEventListener(t,n,!Z6&&g_n)}function mve(e,t){if(t){if(t[0]===">"&&(t=t.substring(1)),e)try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch{return!1}return!1}}function tBs(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function jb(e,t,n,r){if(e){n=n||document;do{if(t!=null&&(t[0]===">"?e.parentNode===n&&mve(e,t):mve(e,t))||r&&e===n)return e;if(e===n)break}while(e=tBs(e))}return null}var Hkn=/\s+/g;function nv(e,t,n){if(e&&t)if(e.classList)e.classList[n?"add":"remove"](t);else{var r=(" "+e.className+" ").replace(Hkn," ").replace(" "+t+" "," ");e.className=(r+(n?" "+t:"")).replace(Hkn," ")}}function No(e,t,n){var r=e&&e.style;if(r){if(n===void 0)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(e,""):e.currentStyle&&(n=e.currentStyle),t===void 0?n:n[t];!(t in r)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),r[t]=n+(typeof n=="string"?"":"px")}}function PW(e,t){var n="";if(typeof e=="string")n=e;else do{var r=No(e,"transform");r&&r!=="none"&&(n=r+" "+n)}while(!t&&(e=e.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(n)}function m_n(e,t,n){if(e){var r=e.getElementsByTagName(t),o=0,s=r.length;if(n)for(;o=s,!a)return r;if(r===Ly())break;r=W5(r,!1)}return!1}function xz(e,t,n,r){for(var o=0,s=0,a=e.children;s2&&arguments[2]!==void 0?arguments[2]:{},r=n.evt,o=$Qs(n,cBs);hoe.pluginEvent.bind(Uo)(e,t,Gy({dragEl:Ri,parentEl:Bu,ghostEl:gs,rootEl:Md,nextEl:mD,lastDownEl:OAe,cloneEl:lu,cloneHidden:XS,dragStarted:LG,putSortable:Xf,activeSortable:Uo.active,originalEvent:r,oldIndex:nj,oldDraggableIndex:SJ,newIndex:ov,newDraggableIndex:SS,hideGhostForTarget:C_n,unhideGhostForTarget:x_n,cloneNowHidden:function(){XS=!0},cloneNowShown:function(){XS=!1},dispatchSortableEvent:function(s){_m({sortable:t,name:s,originalEvent:r})}},o))};function _m(e){lBs(Gy({putSortable:Xf,cloneEl:lu,targetEl:Ri,rootEl:Md,oldIndex:nj,oldDraggableIndex:SJ,newIndex:ov,newDraggableIndex:SS},e))}var Ri,Bu,gs,Md,mD,OAe,lu,XS,nj,ov,SJ,SS,oue,Xf,iU=!1,kve=!1,vve=[],Y7,nb,KPe,JPe,Zkn,Ykn,LG,ON,TJ,EJ=!1,sue=!1,wAe,Wg,_Pe=[],mGe=!1,pve=[],mye=typeof document<"u",aue=A_n,Xkn=uoe||Z6?"cssFloat":"float",dBs=mye&&!f_n&&!A_n&&"draggable"in document.createElement("div"),O_n=function(){if(mye){if(Z6)return!1;var e=document.createElement("x");return e.style.cssText="pointer-events:auto",e.style.pointerEvents==="auto"}}(),w_n=function(e,t){var n=No(e),r=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),o=xz(e,0,t),s=xz(e,1,t),a=o&&No(o),l=s&&No(s),d=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Xh(o).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+Xh(s).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return s&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return o&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||d>=r&&n[Xkn]==="none"||s&&n[Xkn]==="none"&&d+u>r)?"vertical":"horizontal"},uBs=function(e,t,n){var r=n?e.left:e.top,o=n?e.right:e.bottom,s=n?e.width:e.height,a=n?t.left:t.top,l=n?t.right:t.bottom,d=n?t.width:t.height;return r===a||o===l||r+s/2===a+d/2},hBs=function(e,t){var n;return vve.some(function(r){var o=r[Wv].options.emptyInsertThreshold;if(!(!o||Qat(r))){var s=Xh(r),a=e>=s.left-o&&e<=s.right+o,l=t>=s.top-o&&t<=s.bottom+o;if(a&&l)return n=r}}),n},y_n=function(e){function t(o,s){return function(a,l,d,u){var h=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(o==null&&(s||h))return!0;if(o==null||o===!1)return!1;if(s&&o==="clone")return o;if(typeof o=="function")return t(o(a,l,d,u),s)(a,l,d,u);var f=(s?a:l).options.group.name;return o===!0||typeof o=="string"&&o===f||o.join&&o.indexOf(f)>-1}}var n={},r=e.group;(!r||bAe(r)!="object")&&(r={name:r}),n.name=r.name,n.checkPull=t(r.pull,!0),n.checkPut=t(r.put),n.revertClone=r.revertClone,e.group=n},C_n=function(){!O_n&&gs&&No(gs,"display","none")},x_n=function(){!O_n&&gs&&No(gs,"display","")};mye&&!f_n&&document.addEventListener("click",function(e){if(kve)return e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.stopImmediatePropagation&&e.stopImmediatePropagation(),kve=!1,!1},!0);var X7=function(e){if(Ri){e=e.touches?e.touches[0]:e;var t=hBs(e.clientX,e.clientY);if(t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[Wv]._onDragOver(n)}}},ABs=function(e){Ri&&Ri.parentNode[Wv]._isOutsideThisEl(e.target)};function Uo(e,t){if(!(e&&e.nodeType&&e.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));this.el=e,this.options=t=A6({},t),e[Wv]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return w_n(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(s,a){s.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:Uo.supportPointer!==!1&&"PointerEvent"in window&&!xJ,emptyInsertThreshold:5};hoe.initializePlugins(this,e,n);for(var r in n)!(r in t)&&(t[r]=n[r]);y_n(t);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=t.forceFallback?!1:dBs,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?Sl(e,"pointerdown",this._onTapStart):(Sl(e,"mousedown",this._onTapStart),Sl(e,"touchstart",this._onTapStart)),this.nativeDraggable&&(Sl(e,"dragover",this),Sl(e,"dragenter",this)),vve.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),A6(this,oBs())}Uo.prototype={constructor:Uo,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(ON=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,Ri):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,r=this.options,o=r.preventOnFilter,s=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,d=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,u=r.filter;if(OBs(n),!Ri&&!(/mousedown|pointerdown/.test(s)&&e.button!==0||r.disabled)&&!d.isContentEditable&&!(!this.nativeDraggable&&xJ&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=jb(l,r.draggable,n,!1),!(l&&l.animated)&&OAe!==l)){if(nj=kp(l),SJ=kp(l,r.draggable),typeof u=="function"){if(u.call(this,e,l,this)){_m({sortable:t,rootEl:d,name:"filter",targetEl:l,toEl:n,fromEl:n}),b0("filter",t,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=jb(d,h.trim(),n,!1),h)return _m({sortable:t,rootEl:h,name:"filter",targetEl:l,fromEl:n,toEl:n}),b0("filter",t,{evt:e}),!0}),u)){o&&e.cancelable&&e.preventDefault();return}r.handle&&!jb(d,r.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var r=this,o=r.el,s=r.options,a=o.ownerDocument,l;if(n&&!Ri&&n.parentNode===o){var d=Xh(n);if(Md=o,Ri=n,Bu=Ri.parentNode,mD=Ri.nextSibling,OAe=n,oue=s.group,Uo.dragged=Ri,Y7={target:Ri,clientX:(t||e).clientX,clientY:(t||e).clientY},Zkn=Y7.clientX-d.left,Ykn=Y7.clientY-d.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,Ri.style["will-change"]="all",l=function(){if(b0("delayEnded",r,{evt:e}),Uo.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!Wkn&&r.nativeDraggable&&(Ri.draggable=!0),r._triggerDragStart(e,t),_m({sortable:r,name:"choose",originalEvent:e}),nv(Ri,s.chosenClass,!0)},s.ignore.split(",").forEach(function(u){m_n(Ri,u.trim(),$Pe)}),Sl(a,"dragover",X7),Sl(a,"mousemove",X7),Sl(a,"touchmove",X7),Sl(a,"mouseup",r._onDrop),Sl(a,"touchend",r._onDrop),Sl(a,"touchcancel",r._onDrop),Wkn&&this.nativeDraggable&&(this.options.touchStartThreshold=4,Ri.draggable=!0),b0("delayStart",this,{evt:e}),s.delay&&(!s.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(uoe||Z6))){if(Uo.eventCanceled){this._onDrop();return}Sl(a,"mouseup",r._disableDelayedDrag),Sl(a,"touchend",r._disableDelayedDrag),Sl(a,"touchcancel",r._disableDelayedDrag),Sl(a,"mousemove",r._delayedDragTouchMoveHandler),Sl(a,"touchmove",r._delayedDragTouchMoveHandler),s.supportPointer&&Sl(a,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(l,s.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){Ri&&$Pe(Ri),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;el(e,"mouseup",this._disableDelayedDrag),el(e,"touchend",this._disableDelayedDrag),el(e,"touchcancel",this._disableDelayedDrag),el(e,"mousemove",this._delayedDragTouchMoveHandler),el(e,"touchmove",this._delayedDragTouchMoveHandler),el(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?Sl(document,"pointermove",this._onTouchMove):t?Sl(document,"touchmove",this._onTouchMove):Sl(document,"mousemove",this._onTouchMove):(Sl(Ri,"dragend",this),Sl(Md,"dragstart",this._onDragStart));try{document.selection?yAe(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(iU=!1,Md&&Ri){b0("dragStarted",this,{evt:t}),this.nativeDraggable&&Sl(document,"dragover",ABs);var n=this.options;!e&&nv(Ri,n.dragClass,!1),nv(Ri,n.ghostClass,!0),Uo.active=this,e&&this._appendGhost(),_m({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(nb){this._lastX=nb.clientX,this._lastY=nb.clientY,C_n();for(var e=document.elementFromPoint(nb.clientX,nb.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(nb.clientX,nb.clientY),e!==t);)t=e;if(Ri.parentNode[Wv]._isOutsideThisEl(e),t)do{if(t[Wv]){var n=void 0;if(n=t[Wv]._onDragOver({clientX:nb.clientX,clientY:nb.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);x_n()}},_onTouchMove:function(e){if(Y7){var t=this.options,n=t.fallbackTolerance,r=t.fallbackOffset,o=e.touches?e.touches[0]:e,s=gs&&PW(gs,!0),a=gs&&s&&s.a,l=gs&&s&&s.d,d=aue&&Wg&&zkn(Wg),u=(o.clientX-Y7.clientX+r.x)/(a||1)+(d?d[0]-_Pe[0]:0)/(a||1),h=(o.clientY-Y7.clientY+r.y)/(l||1)+(d?d[1]-_Pe[1]:0)/(l||1);if(!Uo.active&&!iU){if(n&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))=0&&(_m({rootEl:Bu,name:"add",toEl:Bu,fromEl:Md,originalEvent:e}),_m({sortable:this,name:"remove",toEl:Bu,originalEvent:e}),_m({rootEl:Bu,name:"sort",toEl:Bu,fromEl:Md,originalEvent:e}),_m({sortable:this,name:"sort",toEl:Bu,originalEvent:e})),Xf&&Xf.save()):ov!==nj&&ov>=0&&(_m({sortable:this,name:"update",toEl:Bu,originalEvent:e}),_m({sortable:this,name:"sort",toEl:Bu,originalEvent:e})),Uo.active&&((ov==null||ov===-1)&&(ov=nj,SS=SJ),_m({sortable:this,name:"end",toEl:Bu,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){b0("nulling",this),Md=Ri=Bu=gs=mD=lu=OAe=XS=Y7=nb=LG=ov=SS=nj=SJ=ON=TJ=Xf=oue=Uo.dragged=Uo.ghost=Uo.clone=Uo.active=null,pve.forEach(function(e){e.checked=!0}),pve.length=KPe=JPe=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":Ri&&(this._onDragOver(e),fBs(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,r=0,o=n.length,s=this.options;ro.right+s||e.clientY>r.bottom&&e.clientX>r.left:e.clientY>o.bottom+s||e.clientX>r.right&&e.clientY>r.top}function vBs(e,t,n,r,o,s,a,l){var d=r?e.clientY:e.clientX,u=r?n.height:n.width,h=r?n.top:n.left,f=r?n.bottom:n.right,g=!1;if(!a){if(l&&wAeh+u*s/2:df-wAe)return-TJ}else if(d>h+u*(1-o)/2&&df-u*s/2)?d>h+u/2?1:-1:0}function pBs(e){return kp(Ri){if(R&&(o==null?void 0:o.length)!==B.childNodes.length)return M.insertBefore(R,N.nextSibling),!0;const W=B.childNodes[I];R=B==null?void 0:B.replaceChild(N,W)})}}catch(R){P=R}finally{o=null}ei(()=>{if(Gkn(),P)throw P})}const O={onUpdate:p,onStart:A,onAdd:m,onRemove:v,onEnd:b};function w(T){const D=ge(s);return T||(T=zQs(D)?ZQs(D,r==null?void 0:r.$el):D),T&&!qQs(T)&&(T=T.$el),T||jQs("Root element not found"),T}function y(){var T;const D=(T=ge(l))!=null?T:{},{immediate:Q,clone:M}=D,B=u_n(D,["immediate","clone"]);return Ukn(B,(P,F)=>{GQs(P)&&(B[P]=(R,...N)=>{const I=LBs();return KQs(R,I),F(R,...N)})}),XQs(a===null?{}:O,B)}const C=T=>{T=w(T),d&&x.destroy(),d=new Uo(T,y())};At(()=>l,()=>{d&&Ukn(y(),(T,D)=>{d==null||d.option(T,D)})},{deep:!0});const x={option:(T,D)=>d==null?void 0:d.option(T,D),destroy:()=>{d==null||d.destroy(),d=null},save:()=>d==null?void 0:d.save(),toArray:()=>d==null?void 0:d.toArray(),closest:(...T)=>d==null?void 0:d.closest(...T)},L=()=>x==null?void 0:x.option("disabled",!0),S=()=>x==null?void 0:x.option("disabled",!1);return xBs(()=>{u&&C()}),CBs(x.destroy),tj({start:C,pause:L,resume:S},x)}const bGe=["update","start","add","remove","choose","unchoose","end","sort","filter","clone","move","change"],TBs=["clone","animation","ghostClass","group","sort","disabled","store","handle","draggable","swapThreshold","invertSwap","invertedSwapThreshold","removeCloneOnHide","direction","chosenClass","dragClass","ignore","filter","preventOnFilter","easing","setData","dropBubble","dragoverBubble","dataIdAttr","delay","delayOnTouchOnly","touchStartThreshold","forceFallback","fallbackClass","fallbackOnBody","fallbackTolerance","fallbackOffset","supportPointer","emptyInsertThreshold","scroll","forceAutoScrollFallback","scrollSensitivity","scrollSpeed","bubbleScroll","modelValue","tag","target","customUpdate",...bGe.map(e=>`on${e.replace(/^\S/,t=>t.toUpperCase())}`)],EBs=Xe({name:"VueDraggable",model:{prop:"modelValue",event:"update:modelValue"},props:TBs,emits:["update:modelValue",...bGe],setup(e,{slots:t,emit:n,expose:r,attrs:o}){const s=bGe.reduce((h,f)=>{const g=`on${f.replace(/^\S/,k=>k.toUpperCase())}`;return h[g]=(...k)=>n(f,...k),h},{}),a=G(()=>{const h=Si(e),{modelValue:f}=h,g=u_n(h,["modelValue"]),k=Object.entries(g).reduce((A,[m,v])=>{const p=ge(v);return p!==void 0&&(A[m]=p),A},{});return tj(tj({},s),HQs(tj(tj({},o),k)))}),l=G({get:()=>e.modelValue,set:h=>n("update:modelValue",h)}),d=de(),u=Po(SBs(e.target||d,l,a));return r(u),()=>{var h;return Bn(e.tag||"div",{ref:d},(h=t==null?void 0:t.default)==null?void 0:h.call(t,u))}}}),DBs={class:"previewContainer"},QBs={class:"mainContent"},BBs={class:"previewArea"},FBs={class:"videoWrapper"},PBs=["src","alt"],MBs={key:1,class:"placeholderImage"},RBs={class:"playerControls"},IBs={class:"controlButtons"},NBs={class:"progressArea"},UBs={class:"timeLabel"},jBs={class:"progressTrack"},WBs=["onClick"],HBs={class:"timeLabel"},VBs={class:"infoPanel"},zBs={class:"infoSection"},ZBs={class:"sectionTitle"},YBs={class:"sectionContent"},XBs={class:"infoSection"},qBs={class:"sectionTitle"},GBs={class:"sectionContent"},KBs={class:"infoSection"},JBs={class:"sectionTitle"},_Bs={class:"characterList"},$Bs={key:0,class:"noCharacter"},eFs={class:"infoSection"},tFs={class:"sectionTitle"},nFs={class:"shootingTips"},iFs={key:0,class:"tipItem"},rFs={class:"tipLabel"},oFs={class:"tipValue"},sFs={class:"shotListArea"},aFs={class:"shotListHeader"},lFs={class:"headerLeft"},cFs=["onClick"],dFs={class:"shotImageWrapper"},uFs=["src","alt"],hFs={key:1,class:"shotPlaceholder"},Jkn=50,AFs=Xe({__name:"preview",setup(e){const t=mt("episodesId"),n=de([]);mn(()=>{r()});async function r(){const{data:X}=await on.post("/production/getStoryboardData",{scriptId:t.value});n.value=X}const o=G(()=>n.value[a.value]||null),s=G(()=>{var X;return((X=o.value)==null?void 0:X.characters)||[]}),a=de(0),l=de(!1),d=de(),u=de(),h=de(!1),f=de(!1),g=de(0);let k=null;const A=n.value.map(X=>X.id),m=G(()=>{var X;return((X=o.value)==null?void 0:X.duration)??3}),v=G(()=>a.value===0),p=G(()=>a.value===n.value.length-1),b=G(()=>n.value.reduce((X,_)=>X+(_.duration??3),0)),O=G(()=>{const X=C(a.value)+g.value;return Math.min(X/b.value*100,100)}),w=G(()=>{var X,_;return[{label:$t("workbench.production.preview.sceneDescription"),value:(X=o.value)==null?void 0:X.description},{label:$t("workbench.production.preview.promptLabel"),value:(_=o.value)==null?void 0:_.prompt}]}),y=X=>{var _;return((_=n.value[X])==null?void 0:_.duration)??3},C=X=>{let _=0;for(let q=0;qy(X)/b.value*100,L=X=>C(X)/b.value*100,S=X=>{const _=Math.floor(X);return`${String(Math.floor(_/60)).padStart(2,"0")}:${String(_%60).padStart(2,"0")}`},T=()=>{k&&(clearInterval(k),k=null),f.value=!1},D=()=>{k||(f.value=!0,k=setInterval(()=>{g.value+=Jkn/1e3,g.value>=m.value&&(p.value?(g.value=m.value,T()):(g.value=0,a.value++,I()))},Jkn))},Q=()=>{if(f.value)return T();p.value&&g.value>=m.value&&(a.value=0,g.value=0),D()};Pa(T);const M=(X,_=!0)=>{_&&T(),a.value=X,g.value=0,I()},B=()=>{v.value||M(a.value-1)},P=()=>{p.value||M(a.value+1)},F=X=>M(X),R=X=>M(X),N=X=>{const _=u.value;if(!_)return;T();const q=le=>{const ce=_.getBoundingClientRect(),ie=Math.max(0,Math.min(1,(le.clientX-ce.left)/ce.width))*b.value;let Ae=0;for(let H=0;Hie){a.value=H,g.value=ie-Ae,I();return}Ae+=ee}a.value=n.value.length-1,g.value=y(n.value.length-1)};q(X);const re=()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",re)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",re)},I=()=>{ei(()=>{var _,q;const X=(_=d.value)==null?void 0:_.querySelectorAll(".shotItem");(q=X==null?void 0:X[a.value])==null||q.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})})},W=X=>{const _=Array.isArray(X)?X.length>0:X;n.value.forEach(q=>q.selected=_)};hf(document,"keydown",X=>{if(X.code==="Space"&&!X.repeat){X.preventDefault();const _=n.value[a.value];_&&(_.selected=!_.selected)}});const V=()=>{const X=_r.confirm({header:$t("workbench.production.preview.restoreSort"),body:$t("workbench.production.preview.restoreSortConfirm"),onConfirm:()=>{n.value.sort((_,q)=>A.indexOf(_.id)-A.indexOf(q.id)),X.destroy()},onClose:()=>X.destroy()})};At(()=>n.value.map(X=>X.selected),X=>{l.value=X.length>0&&X.every(Boolean)},{deep:!0});const z=()=>ei(()=>h.value=!1);async function Y(){const X=n.value.filter(re=>re.selected).map(re=>({id:re.id,filePath:re.filePath}));if(X.length===0){_r.alert({header:$t("workbench.production.preview.tip"),body:$t("workbench.production.preview.selectAtLeastOne")});return}const _=new $Un,q=X.map(async re=>{try{if(!re.filePath)return;const ce=await(await fetch(re.filePath)).blob();_.file(`分镜${re.id}.${K(re.filePath)}`,ce)}catch(le){console.error(`图片下载失败: ${re.filePath}`,le)}});await Promise.all(q),_.generateAsync({type:"blob"}).then(re=>{const le=document.createElement("a");le.href=URL.createObjectURL(re),le.download="分镜压缩包.zip",le.click(),setTimeout(()=>URL.revokeObjectURL(le.href),5e3)})}function K(X){const _=X.match(/\.(\w+)(?:\?|$)/);return _?_[1]:"jpg"}return(X,_)=>{var oe,te,J;const q=kn("i-pic"),re=kn("i-go-start"),le=vi,ce=kn("i-go-end"),me=Wu,ie=Gd,Ae=pO,H=kn("i-undo"),ee=kn("i-download");return Ce(),We("div",DBs,[he("div",QBs,[he("div",BBs,[he("div",FBs,[(oe=o.value)!=null&&oe.filePath?(Ce(),We("img",{key:0,src:o.value.filePath,alt:o.value.description,class:"previewImage"},null,8,PBs)):(Ce(),We("div",MBs,[c(q,{theme:"outline",size:"48",fill:"#999"}),he("span",null,De(X.$t("workbench.production.preview.noImage")),1)]))]),he("div",RBs,[he("div",IBs,[c(le,{theme:"default",variant:"text",size:"small",shape:"circle",onClick:B,disabled:v.value},{icon:ve(()=>[c(re,{theme:"outline",size:"18"})]),_:1},8,["disabled"]),c(le,{theme:"primary",variant:"text",size:"medium",shape:"circle",onClick:Q},{icon:ve(()=>[(Ce(),St(Ud(f.value?"i-pause":"i-play"),{theme:"outline",size:"22"}))]),_:1}),c(le,{theme:"default",variant:"text",size:"small",shape:"circle",onClick:P,disabled:p.value},{icon:ve(()=>[c(ce,{theme:"outline",size:"18"})]),_:1},8,["disabled"])]),he("div",NBs,[he("span",UBs,De(S(g.value)),1),he("div",{class:"progressBarWrapper",ref_key:"progressBarRef",ref:u,onMousedown:N},[he("div",jBs,[(Ce(!0),We(nn,null,bi(n.value,(se,ke)=>(Ce(),We("div",{key:"seg-"+se.id,class:uo(["progressSegment",{active:ke===a.value,completed:keF(ke),["stop"])},null,14,WBs))),128)),(Ce(!0),We(nn,null,bi(n.value.slice(0,-1),(se,ke)=>(Ce(),We("div",{key:"div-"+ke,class:"segmentDivider",style:eo({left:L(ke+1)+"%"})},null,4))),128)),he("div",{class:"progressFill",style:eo({width:O.value+"%"})},null,4),he("div",{class:"progressHandle",style:eo({left:O.value+"%"})},null,4)])],544),he("span",HBs,De(S(b.value)),1)])])]),he("div",VBs,[he("div",zBs,[he("div",ZBs,[_[5]||(_[5]=he("span",{class:"titleIndicator"},null,-1)),kt(" "+De(X.$t("workbench.production.preview.storyboardDesc")),1)]),he("div",YBs," 【"+De(X.$t("workbench.production.preview.serialNumber"))+" "+De(a.value+1)+"】"+De(((te=o.value)==null?void 0:te.description)||X.$t("workbench.production.preview.noDescription")),1)]),he("div",XBs,[he("div",qBs,[_[6]||(_[6]=he("span",{class:"titleIndicator"},null,-1)),kt(" "+De(X.$t("workbench.production.preview.duration")),1)]),he("div",GBs,De(((J=o.value)==null?void 0:J.duration)!=null?o.value.duration+" "+X.$t("workbench.production.preview.seconds"):"3 "+X.$t("workbench.production.preview.seconds")),1)]),he("div",KBs,[he("div",JBs,[_[7]||(_[7]=he("span",{class:"titleIndicator"},null,-1)),kt(" "+De(X.$t("workbench.production.preview.relatedAssets")),1)]),he("div",_Bs,[(Ce(!0),We(nn,null,bi(s.value,(se,ke)=>(Ce(),We("div",{key:ke,class:"characterItem"},[c(me,{src:se.avatar,fit:"cover",class:"characterAvatar",style:{width:"80px",height:"80px",borderRadius:"8px"}},null,8,["src"]),c(ie,null,{default:ve(()=>[kt(De(se.name)+"("+De(se.type=="role"?X.$t("workbench.production.preview.role"):se.type=="tool"?X.$t("workbench.production.preview.prop"):X.$t("workbench.production.preview.scene"))+") ",1)]),_:2},1024)]))),128)),s.value.length?Vt("",!0):(Ce(),We("div",$Bs,[c(ie,{theme:"default",variant:"light"},{default:ve(()=>[kt(De(X.$t("workbench.production.preview.noCharacters")),1)]),_:1})]))])]),he("div",eFs,[he("div",tFs,[_[8]||(_[8]=he("span",{class:"titleIndicator"},null,-1)),kt(" "+De(X.$t("workbench.production.preview.imagePrompt")),1)]),he("div",nFs,[(Ce(!0),We(nn,null,bi(w.value,se=>(Ce(),We(nn,{key:se.label},[se.value?(Ce(),We("div",iFs,[he("span",rFs,De(se.label)+":",1),he("span",oFs,De(se.value),1)])):Vt("",!0)],64))),128))])])])]),he("div",sFs,[he("div",aFs,[he("div",lFs,[c(Ae,{modelValue:l.value,"onUpdate:modelValue":_[0]||(_[0]=se=>l.value=se),onChange:W},{default:ve(()=>[kt(De(X.$t("workbench.production.preview.selectAll")),1)]),_:1},8,["modelValue"]),c(le,{theme:"default",variant:"text",size:"small",onClick:V},{icon:ve(()=>[c(H,{theme:"outline",size:"16"})]),default:ve(()=>[kt(" "+De(X.$t("workbench.production.preview.restoreSort")),1)]),_:1})]),c(le,{theme:"default",variant:"text",size:"small",class:"exportBtn",onClick:Y},{icon:ve(()=>[c(ee,{theme:"outline",size:"16"})]),default:ve(()=>[kt(" "+De(X.$t("workbench.production.preview.exportImage")),1)]),_:1})]),he("div",{class:"shotListWrapper",ref_key:"shotListWrapperRef",ref:d},[c(ge(EBs),{modelValue:n.value,"onUpdate:modelValue":_[3]||(_[3]=se=>n.value=se),animation:150,ghostClass:"shotGhost",dragClass:"shotDrag",scroll:d.value,scrollSensitivity:80,scrollSpeed:10,forceFallback:!0,target:".shotList",onStart:_[4]||(_[4]=se=>h.value=!0),onEnd:z},{default:ve(()=>[c(h4n,{type:"transition",tag:"div",name:h.value?void 0:"shot-flip",class:"shotList"},{default:ve(()=>[(Ce(!0),We(nn,null,bi(n.value,(se,ke)=>(Ce(),We("div",{key:se.id,class:uo(["shotItem",{active:a.value===ke}]),onClick:ye=>R(ke)},[c(Ae,{modelValue:se.selected,"onUpdate:modelValue":ye=>se.selected=ye,class:"shotCheckbox",onClick:_[1]||(_[1]=or(()=>{},["stop"])),onMousedown:_[2]||(_[2]=or(()=>{},["stop"]))},null,8,["modelValue","onUpdate:modelValue"]),he("div",dFs,[se.filePath?(Ce(),We("img",{key:0,src:se.filePath,alt:se.description,class:"shotImage"},null,8,uFs)):(Ce(),We("div",hFs,[c(q,{theme:"outline",size:"24",fill:"#999"})])),c(ie,{class:"shotNumber",size:"small",variant:"dark"},{default:ve(()=>[kt("#"+De(se.id),1)]),_:2},1024)])],10,cFs))),128))]),_:1},8,["name"])]),_:1},8,["modelValue","scroll"])],512)])])}}}),fFs=Fr(AFs,[["__scopeId","data-v-a51966a2"]]);function wN(e,t){return`${e??""}:${t??""}`}function gFs(e){if(!e)return"";if(e.startsWith("data:")||e.startsWith("blob:"))return e;try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return e}}function iMe(e){return e.map(t=>({...JSON.parse(JSON.stringify(t)),src:gFs(t.src)}))}const E_n=RO("imageListCache",()=>{const e=de({}),t=de({});async function n(m){if(!m.length)return{};const v=m.filter(b=>b.id==null?!1:(wN(b.id,b.sources),!0));if(v.length)try{const{data:b}=await on.post("/production/workbench/getFileUrl",{items:v.map(y=>({id:y.id,sources:y.sources}))}),O=b.data,w={};Array.isArray(O)?O.forEach(y=>{if(y.id!=null&&y.url){const C=wN(y.id,y.sources);w[C]=y.url}}):O&&typeof O=="object"&&!Array.isArray(O)&&Object.entries(O).forEach(([y,C])=>{w[y]=C}),t.value={...t.value,...w}}catch(b){console.warn("[imageListCache] resolveUrls 请求失败,降级使用路径",b)}const p={};return m.forEach(b=>{var w;const O=wN(b.id,b.sources);p[O]=t.value[O]||((w=b.id)==null?void 0:w.toString())||""}),p}function r(m,v,p){if(m!=null){const b=wN(m,v);if(t.value[b])return t.value[b]}return p||""}function o(m){return m.map(v=>({...v,src:r(v.id,v.sources,v.src)}))}function s(m,v,p){var O,w;const b=(w=(O=e.value[m])==null?void 0:O[v])==null?void 0:w[p];if(b)return o(b)}async function a(m,v,p){var w,y;const b=(y=(w=e.value[m])==null?void 0:w[v])==null?void 0:y[p];if(!b)return;const O=b.filter(C=>C.id!=null).map(C=>({id:C.id,sources:C.sources}));return await n(O),o(b)}function l(m,v,p){var b,O;return(O=(b=e.value[m])==null?void 0:b[v])==null?void 0:O[p]}function d(m,v,p,b){e.value[m]||(e.value[m]={}),e.value[m][v]||(e.value[m][v]={});let O=!1;b.forEach(w=>{if(!w.src||w.id==null)return;const y=wN(w.id,w.sources);t.value[y]||(t.value[y]=w.src,O=!0)}),O&&(t.value={...t.value}),e.value[m][v][p]=iMe(b)}function u(m,v,p){var b;(b=e.value[m])!=null&&b[v]&&delete e.value[m][v][p]}function h(m,v){e.value[m]&&delete e.value[m][v]}function f(m,v,p){p.forEach(b=>{var O,w;b.id!=null&&((w=(O=e.value[m])==null?void 0:O[v])!=null&&w[b.id]||(e.value[m]||(e.value[m]={}),e.value[m][v]||(e.value[m][v]={}),e.value[m][v][b.id]=iMe(b.medias)))})}function g(m,v,p){e.value[m]&&delete e.value[m][v],e.value[m]||(e.value[m]={}),e.value[m][v]={},p.forEach(b=>{b.id!=null&&(e.value[m][v][b.id]=iMe(b.medias))})}async function k(m,v){var w;const p=(w=e.value[m])==null?void 0:w[v];if(!p)return;const b=[],O=new Set;Object.values(p).forEach(y=>{y.forEach(C=>{if(C.id==null)return;const x=wN(C.id,C.sources);O.has(x)||(O.add(x),b.push({id:C.id,sources:C.sources}))})}),await n(b)}function A(){t.value={}}return{cacheData:e,urlMap:t,getCache:s,getCacheWithResolve:a,getRawCache:l,setCache:d,removeCache:u,clearScriptCache:h,initCacheFromTrackList:f,forceInitCacheFromTrackList:g,resolveUrls:n,resolveUrlSync:r,warmUpUrls:k,clearUrlMap:A}},{persist:{pick:["cacheData"]}}),mFs={class:"videoTrack"},kFs={class:"trackMenu f ac jb"},vFs={class:"left f ac"},pFs={key:0,class:"selectedCount"},bFs={class:"right f ac"},OFs={class:"itemBox"},wFs=["onClick"],yFs={key:1,class:"thumbGroup"},CFs=["src"],xFs={key:1,class:"thumb placeholder c"},LFs={key:2,class:"thumbGroup"},SFs={key:1,class:"thumb placeholder c"},TFs={key:3,class:"emptyTrack"},EFs=["onClick"],DFs=Xe({__name:"track",props:ha({modelParmas:{},imageList:{},clampDuration:{type:Function}},{activeTrackIndex:{default:0},activeTrackIndexModifiers:{},modelValue:{default:()=>[]},modelModifiers:{},genTextLoadingMap:{default:()=>{}},genTextLoadingMapModifiers:{}}),emits:ha(["getData","change","saveImageList"],["update:activeTrackIndex","update:modelValue","update:genTextLoadingMap"]),setup(e,{emit:t}){const{project:n}=Pr(Ad()),{removeCache:r}=E_n(),o=mt("episodesId"),s=e,a=Dc(e,"activeTrackIndex"),l=de([]),d=Dc(e,"modelValue"),u=Dc(e,"genTextLoadingMap"),h=t,f=de(!1),g=de({});function k(T){var Q;if(!T.selectVideoId)return null;const D=(Q=T.videoList)==null?void 0:Q.find(M=>M.id===T.selectVideoId);return(D==null?void 0:D.src)||null}function A(T){if(!T||g.value[T])return;const D=document.createElement("video");D.crossOrigin="anonymous",D.preload="auto",D.muted=!0,D.src=T,D.addEventListener("seeked",()=>{try{const Q=document.createElement("canvas");Q.width=D.videoWidth||160,Q.height=D.videoHeight||90;const M=Q.getContext("2d");M&&(M.drawImage(D,0,0,Q.width,Q.height),g.value[T]=Q.toDataURL("image/jpeg",.7))}catch{}D.src=""},{once:!0}),D.addEventListener("loadeddata",()=>{D.currentTime=0},{once:!0}),D.addEventListener("error",()=>{D.src=""},{once:!0}),D.load()}function m(T){if(a.value==T)return;const D=a.value;a.value=T,h("change",D)}async function v(T){var B;const D=d.value[T];if(!D)return;await on.post("/production/workbench/deleteTrack",{id:D.id}),l.value=l.value.filter(P=>P!==D.id);const Q=(B=n.value)==null?void 0:B.id,M=o.value;Q!=null&&M!=null&&D.id!=null&&r(Q,M,D.id),a.value>=d.value.length&&(a.value=d.value.length-1)}function p(T){const D=_r.confirm({header:$t("workbench.generate.del"),body:$t("workbench.generate.delConfirm"),confirmBtn:$t("settings.generate.delConfirmBtn"),cancelBtn:$t("settings.memory.msg.cancel"),onConfirm:async()=>{try{await v(T),window.$message.success($t("workbench.generate.delSuccess")),h("getData")}catch(Q){window.$message.error(Q.message??$t("workbench.cornerScape.cancelGeneration")+"失败")}finally{D.destroy()}}})}async function b(){var B,P;const{data:T}=await on.post("/modelSelect/getModelDetail",{modelId:s.modelParmas.model}),D=T.durationResolutionMap;if(!Array.isArray(D)||D.length===0||!((B=D[0].duration)!=null&&B.length))return;const Q=D[0].duration[0],{data:M}=await on.post("/production/workbench/addTrack",{projectId:(P=n.value)==null?void 0:P.id,scriptId:o.value??0,duration:Q});h("getData"),a.value=d.value.length-1}function O(T){var Q;return((Q=T.split(".").pop())==null?void 0:Q.split(/[#?]/)[0])||"mp4"}async function w(){const T=new $Un,Q=d.value.filter(F=>l.value.includes(F.id)).map(F=>{const R=F.videoList.find(I=>I.id===F.selectVideoId);if(!(R!=null&&R.src))return null;const N=`分镜${F.id}.${O(R.src)}`;return fetch(R.src).then(I=>I.blob()).then(I=>T.file(N,I)).catch(I=>console.error(`视频下载失败: ${R.src}`,I))}).filter(Boolean);await Promise.all(Q);const M=await T.generateAsync({type:"blob"}),B=URL.createObjectURL(M),P=document.createElement("a");P.href=B,P.download=`视频批量下载_${Date.now()}.zip`,document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(B),l.value=[],f.value=!1}function y(){d.value.filter(T=>l.value.includes(T.id)).forEach(async T=>{var M;const D=T.id;let Q=[];if(s.modelParmas.mode=="text"?Q=T==null?void 0:T.medias.map(({id:B,sources:P})=>({id:B,sources:P})):Q=C(T),!u.value[D]){u.value[D]=!0;try{const{data:B}=await on.post("/production/workbench/generateVideoPrompt",{projectId:(M=n.value)==null?void 0:M.id,trackId:D,info:Q,model:s.modelParmas.model}),P=d.value.find(F=>F.id===D);P&&(P.prompt=B),l.value=[],f.value=!1}catch(B){window.$message.error((B==null?void 0:B.message)??"提示词生成失败")}finally{u.value[D]=!1}}})}function C(T,D=!1){var M;const Q=(M=d.value[a.value])==null?void 0:M.id;if(T.id===Q){const B=s.imageList;return(D?B.filter(P=>!!P.src):B).map(({id:P,sources:F})=>({id:P,sources:F??"storyboard"}))}return T.medias.filter(B=>!D||!!B.src).map(({id:B,sources:P})=>({id:B,sources:P??"storyboard"}))}function x(){const T=_r.confirm({header:$t("workbench.generate.generateConfirm"),body:$t("workbench.generate.generateVideosInBatches"),onConfirm:async()=>{T.destroy(),d.value.filter(D=>l.value.includes(D.id)).forEach(async D=>{var M;const Q=D.id;try{const B=s.modelParmas.mode==="text"?[]:C(D,!0),P={projectId:(M=n.value)==null?void 0:M.id,scriptId:o.value,duration:s.clampDuration(D.duration||s.modelParmas.duration),uploadData:B,prompt:D.prompt,model:s.modelParmas.model,mode:s.modelParmas.mode,resolution:s.modelParmas.resolution,audio:!!s.modelParmas.audio,trackId:Q};if(!P.prompt)return window.$message.warning($t("workbench.generate.skipDataWithEmptyVideoPromptWords"));const{data:F}=await on.post("/production/workbench/generateVideo",P);D.videoList.push({id:F,state:"生成中",src:""}),window.$message.success($t("workbench.generate.generateStarted"))}catch(B){window.$message.error((B==null?void 0:B.message)??"视频发起生成请求失败")}finally{}})},onCancel:()=>T.destroy()})}function L(T){const D=d.value.map(Q=>Q.id).filter(Q=>Q!=null);l.value=T?D:[]}function S(T,D){if(T==null)return;D?l.value.includes(T)||l.value.push(T):l.value=l.value.filter(M=>M!==T);const Q=d.value.map(M=>M.id).filter(M=>M!=null);f.value=Q.length>0&&Q.every(M=>l.value.includes(M))}return At(()=>d.value.map(T=>({selectVideoId:T.selectVideoId,videoList:T.videoList})),()=>{d.value.forEach(T=>{const D=k(T);D&&A(D)})},{deep:!0,immediate:!0}),(T,D)=>{const Q=pO,M=vi,B=Gd,P=kn("i-video"),F=Wu,R=kn("i-volume-notice"),N=kn("i-close"),I=kn("i-plus"),W=yh;return Ce(),We("div",mFs,[c(W,{bordered:"",style:{height:"100%"}},{default:ve(()=>[he("div",kFs,[he("div",vFs,[c(Q,{modelValue:ge(f),"onUpdate:modelValue":D[0]||(D[0]=V=>Dn(f)?f.value=V:null),onChange:L},{default:ve(()=>[kt(De(T.$t("workbench.generate.selectAll")),1)]),_:1},8,["modelValue"]),ge(l).length?(Ce(),We("span",pFs,De(T.$t("workbench.generate.selected"))+" "+De(ge(l).length)+" 段",1)):Vt("",!0)]),he("div",bFs,[c(M,{size:"small",variant:"outline",onClick:w},{default:ve(()=>[kt(De(T.$t("workbench.generate.batchDownloadVideo")),1)]),_:1}),c(M,{size:"small",variant:"outline",onClick:y},{default:ve(()=>[kt(De(T.$t("workbench.generate.batchGenerateText")),1)]),_:1}),c(M,{size:"small",variant:"outline",onClick:x},{default:ve(()=>[kt(De(T.$t("workbench.generate.batchGenerateVideo")),1)]),_:1})])]),he("div",OFs,[(Ce(!0),We(nn,null,bi(d.value,(V,z)=>(Ce(),We("div",{class:uo(["item",{active:z===a.value}]),key:V.id,onClick:Y=>m(z)},[c(Q,{class:"trackCheck",checked:V.id!=null&&ge(l).includes(V.id),onClick:D[1]||(D[1]=or(()=>{},["stop"])),onChange:Y=>S(V.id,Y)},null,8,["checked","onChange"]),c(B,{class:"indexTag",size:"small"},{default:ve(()=>[kt("#"+De(z+1),1)]),_:2},1024),V.selectVideoId?(Ce(),St(B,{key:0,class:"selectTag",theme:"success",size:"small"},{default:ve(()=>[...D[2]||(D[2]=[kt("已选择",-1)])]),_:1})):Vt("",!0),V.selectVideoId&&k(V)?(Ce(),We("div",yFs,[ge(g)[k(V)]?(Ce(),We("img",{key:0,class:"thumb selectedVideoThumb",src:ge(g)[k(V)],draggable:"false"},null,8,CFs)):(Ce(),We("div",xFs,[c(P,{size:"24"})]))])):V.medias.some(Y=>Y.src)?(Ce(),We("div",LFs,[(Ce(!0),We(nn,null,bi(V.medias,(Y,K)=>(Ce(),We(nn,{key:K},[Y.src?(Ce(),We(nn,{key:0},[Y.fileType==="image"?(Ce(),St(F,{key:0,fit:"cover",src:Y.src,class:"thumb"},null,8,["src"])):(Ce(),We("div",SFs,[Y.fileType==="audio"?(Ce(),St(R,{key:0,size:"20"})):(Ce(),St(P,{key:1,size:"24"}))]))],64)):Vt("",!0)],64))),128))])):(Ce(),We("span",TFs,De(T.$t("workbench.generate.emptyTrack",{index:z+1})),1)),he("div",{class:"deleteBtn",onClick:or(Y=>p(z),["stop"])},[c(N,{size:"14"})],8,EFs)],10,wFs))),128)),he("div",{class:"item addItem c",onClick:b},[c(I,{size:"36"})])])]),_:1})])}}}),QFs=Fr(DFs,[["__scopeId","data-v-1137311f"]]),BFs={class:"imageUploadBox ac"},FFs={key:2,class:"imageToolsWrap"},PFs=["onClick"],MFs={class:"source"},RFs=["onClick"],IFs={key:0,style:{flex:"1"},class:"ac"},NFs=["src"],UFs={key:2,class:"imageToolsWrap"},jFs=["onClick"],WFs={class:"source"},HFs={class:"storyboardGrid"},VFs=["onClick"],zFs={key:0,class:"imageToolsWrap"},ZFs=["src"],YFs={key:2,class:"textBox ac jc"},XFs={style:{"font-size":"20px"}},qFs=Xe({__name:"imageSelect",props:ha({mode:{},storyboardList:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const t=e,n=Dc(e,"modelValue"),r=de(!1),o={fileType:"image",id:null,src:""};function s(b){return!b||!b.id}const a=G(()=>{const b=t.mode==="startFrameOptional",O=t.mode==="endFrameOptional";return[{label:b?"首帧(可选)":"首帧",value:"start"},{label:O?"尾帧(可选)":"尾帧",value:"end"}]});function l(){const b=[...n.value];for(;b.length<2;)b.push({...o});return b}function d(b,O){const w=l();w[b==="start"?0:1]=O,n.value=w}function u(b){if(!b)return null;try{const O=JSON.parse(b);if(Array.isArray(O))return O}catch{return b}return b}const h=G(()=>{const b=t.mode;return!(b=="singleImage"&&n.value.length>=1||b=="endFrameOptional"||b=="startEndRequired"||b=="startFrameOptional"||b=="text")});function f(b){var w;const O=((w=b==null?void 0:b.split(".").pop())==null?void 0:w.toLowerCase())??"";return["mp4","webm","mov","avi","mkv"].includes(O)?"video":["mp3","wav","ogg","aac","flac","m4a"].includes(O)?"audio":"image"}const g=G(()=>{const b=t.mode;if(!Array.isArray(b))return[];const O={audioReference:"audio",imageReference:"image",videoReference:"video"};return b.filter(w=>w in O).map(w=>O[w])});let k="";function A(b=""){if(!t.mode)return window.$message.error($t("workbench.generate.notSelectMode"));k=b;const O=Array.isArray(u(t.mode)),w=_r.confirm({header:$t("workbench.generate.selectSource"),confirmBtn:$t("workbench.generate.confirm"),cancelBtn:$t("workbench.generate.cancel"),onConfirm:async()=>{w.destroy();const y=await Fre({types:["role","tool","scene","clip"],clipMediaTypes:g.value,multiple:O});if(!y.length)return;const C=y.map(x=>({fileType:f(x.src),sources:"assets",src:x.src,id:x.id,prompt:x.prompt}));b==="start"||b==="end"?d(b,C[0]):t.mode==="singleImage"?n.value=[C[0]]:n.value=[...n.value,...C]},onCancel:()=>{w.destroy(),r.value=!0}})}function m(b){const O=l();O[b]={...o},n.value=O}function v(b){r.value=!1;const w={fileType:"image",sources:"storyboard",src:b.src,id:b.id,prompt:b.videoDesc??void 0,index:b.index};k==="start"||k==="end"?d(k,w):n.value=[...n.value,w]}function p(b){const O=[...n.value];O.splice(b,1),n.value=O}return(b,O)=>{const w=Wu,y=Ha,C=kn("i-close"),x=Gd,L=kn("i-plus"),S=qa;return Ce(),We("div",BFs,[e.mode=="singleImage"||Array.isArray(u(e.mode))?(Ce(!0),We(nn,{key:0},bi(e.mode=="singleImage"?n.value.slice(0,1):n.value,(T,D)=>(Ce(),We("div",{class:"uploadBtn c fc",key:D},[T.src?(Ce(),St(w,{key:0,src:T.src,fit:"contain",class:"uploadPreview"},{overlayContent:ve(()=>[...O[2]||(O[2]=[])]),_:1},8,["src"])):(Ce(),St(y,{key:1,theme:"primary",content:(T==null?void 0:T.prompt)||""},{default:ve(()=>[...O[3]||(O[3]=[he("span",{style:{"font-size":"20px"}},"文",-1)])]),_:1},8,["content"])),T.sources=="storyboard"&&T.index!=null?(Ce(),We("div",FFs,De(`P${T.index+1}`),1)):Vt("",!0),he("div",{class:"clearBtn",onClick:Q=>p(D)},[c(C,{size:"12"})],8,PFs),he("div",MFs,[c(x,{size:"small"},{default:ve(()=>[kt(De(T.sources=="storyboard"?b.$t("workbench.generate.storyboard"):b.$t("workbench.generate.assets")),1)]),_:2},1024)])]))),128)):e.mode=="endFrameOptional"||e.mode=="startFrameOptional"||e.mode=="startEndRequired"?(Ce(!0),We(nn,{key:1},bi(ge(a),(T,D)=>{var Q,M,B,P,F,R,N,I,W,V,z;return Ce(),We("div",{class:"uploadBtn c fc",key:T.value,onClick:Y=>A(T.value)},[s((Q=n.value)==null?void 0:Q[D])?(Ce(),We(nn,{key:1},[c(L,{size:"24"}),kt(" "+De(T.label),1)],64)):(Ce(),We("div",IFs,[(B=(M=n.value)==null?void 0:M[D])!=null&&B.src?(Ce(),We("img",{key:0,class:"uploadPreview",src:(P=n.value)==null?void 0:P[D].src},null,8,NFs)):(Ce(),St(y,{key:1,theme:"primary",content:((R=(F=n.value)==null?void 0:F[D])==null?void 0:R.prompt)||""},{default:ve(()=>[...O[4]||(O[4]=[he("span",{style:{"font-size":"20px"}},"文",-1)])]),_:1},8,["content"])),((I=(N=n.value)==null?void 0:N[D])==null?void 0:I.sources)=="storyboard"&&((V=(W=n.value)==null?void 0:W[D])==null?void 0:V.index)!=null?(Ce(),We("div",UFs,De(`P${((z=n.value[D])==null?void 0:z.index)+1}`),1)):Vt("",!0),he("div",{class:"clearBtn",onClick:or(Y=>m(D),["stop"])},[c(C,{size:"12"})],8,jFs),he("div",WFs,[c(x,{size:"small"},{default:ve(()=>{var Y,K;return[kt(De(((K=(Y=n.value)==null?void 0:Y[D])==null?void 0:K.sources)=="storyboard"?b.$t("workbench.generate.storyboard"):b.$t("workbench.generate.assets")),1)]}),_:2},1024)])]))],8,RFs)}),128)):Vt("",!0),ge(h)?(Ce(),We("div",{key:2,class:"uploadBtn c fc",onClick:O[0]||(O[0]=T=>A())},[c(L,{size:"24"}),kt(" "+De(b.$t("workbench.generate.addReference")),1)])):Vt("",!0),c(S,{visible:r.value,"onUpdate:visible":O[1]||(O[1]=T=>r.value=T),header:b.$t("workbench.generate.selectStoryboard"),footer:!1,width:"800px",placement:"center"},{default:ve(()=>[he("div",HFs,[(Ce(!0),We(nn,null,bi(e.storyboardList,T=>(Ce(),We("div",{class:"storyboardItem",key:T.id,onClick:D=>v(T)},[(T==null?void 0:T.index)!=null?(Ce(),We("div",zFs,De(`P${(T==null?void 0:T.index)+1}`),1)):Vt("",!0),T.src?(Ce(),We("img",{key:1,src:T.src},null,8,ZFs)):(Ce(),We("div",YFs,[c(y,{theme:"primary",content:(T==null?void 0:T.videoDesc)||""},{default:ve(()=>[he("span",XFs,De(`分镜 ${(T==null?void 0:T.index)+1||""}`),1)]),_:2},1032,["content"])]))],8,VFs))),128))])]),_:1},8,["visible","header"])])}}}),GFs=Fr(qFs,[["__scopeId","data-v-93201310"]]),KFs={class:"modeMenu"},JFs={class:"left f ac"},_Fs={class:"model"},$Fs={class:"status"},ePs={class:"resolutionDurationPicker"},tPs={key:0,class:"pickerSection"},nPs={class:"pickerLabel"},iPs={class:"pickerOptions"},rPs=["onClick"],oPs={key:1,class:"pickerSection"},sPs={class:"pickerLabel"},aPs={class:"pickerOptions"},lPs=["onClick"],cPs=Xe({__name:"modeMenu",props:ha({modeOptions:{},modeList:{},trackId:{}},{modelValue:{default:{mode:"",model:"",resolution:"480p",duration:8,audio:!1}},modelModifiers:{}}),emits:ha(["modeChange"],["update:modelValue"]),setup(e,{emit:t}){const n=e,r=Dc(e,"modelValue"),o=t;function s(l){o("modeChange",l)}function a(l){r.value.duration=l,n.trackId&&on.post("/production/workbench/updateVideoDuration",{id:n.trackId,duration:l})}return(l,d)=>{const u=W8,h=tC,f=_1,g=kn("i-volume-notice"),k=kn("i-volume-mute"),A=vi,m=Gd,v=bg;return Ce(),We("div",KFs,[he("div",JFs,[he("div",_Fs,[c(u,{modelValue:r.value.model,"onUpdate:modelValue":d[0]||(d[0]=p=>r.value.model=p),type:"video",size:"small"},null,8,["modelValue"])]),c(f,{size:"small",class:"mode",value:r.value.mode,onChange:s},{default:ve(()=>[(Ce(!0),We(nn,null,bi(e.modeList,(p,b)=>(Ce(),St(h,{key:b,value:p.value,label:p.label},null,8,["value","label"]))),128))]),_:1},8,["value"]),c(A,{size:"small",variant:"outline",theme:r.value.audio?"success":"danger",class:"audio",onClick:d[1]||(d[1]=p=>r.value.audio=!r.value.audio)},{icon:ve(()=>[r.value.audio?(Ce(),St(g,{key:0,size:"16"})):(Ce(),St(k,{key:1,size:"16"}))]),_:1},8,["theme"]),he("div",$Fs,[c(v,{trigger:"click",placement:"top","overlay-class-name":"resDurPickerPopup","overlay-inner-style":{padding:"16px",borderRadius:"8px"}},{content:ve(()=>[he("div",ePs,[Array.isArray(e.modeOptions.durationResolutionMap)&&e.modeOptions.durationResolutionMap.length>0&&e.modeOptions.durationResolutionMap[0].resolution&&e.modeOptions.durationResolutionMap[0].resolution.length>0?(Ce(),We("div",tPs,[he("div",nPs,De(l.$t("workbench.generate.resolution")),1),he("div",iPs,[(Ce(!0),We(nn,null,bi(e.modeOptions.durationResolutionMap[0].resolution,p=>(Ce(),We("div",{key:p,class:uo(["pickerOption",{active:r.value.resolution==p}]),onClick:b=>r.value.resolution=p},De(p),11,rPs))),128))])])):Vt("",!0),Array.isArray(e.modeOptions.durationResolutionMap)&&e.modeOptions.durationResolutionMap.length>0&&e.modeOptions.durationResolutionMap[0].duration&&e.modeOptions.durationResolutionMap[0].duration.length>0?(Ce(),We("div",oPs,[he("div",sPs,De(l.$t("workbench.generate.duration")),1),he("div",aPs,[(Ce(!0),We(nn,null,bi(e.modeOptions.durationResolutionMap[0].duration,p=>(Ce(),We("div",{key:p,class:uo(["pickerOption",{active:r.value.duration==p}]),onClick:b=>a(p)},De(p)+"s ",11,lPs))),128))])])):Vt("",!0)])]),default:ve(()=>[c(m,{class:"btn",variant:"outline"},{default:ve(()=>[kt(De(r.value.resolution)+"·"+De(r.value.duration)+"s",1)]),_:1})]),_:1})])])])}}}),dPs=Fr(cPs,[["__scopeId","data-v-3ff4eca5"]]),uPs={class:"history"},hPs={class:"titleBox f ac"},APs={class:"title"},fPs={class:"historyItemBox"},gPs=["onClick"],mPs=["src"],kPs=["src","onSeeked"],vPs={key:2,class:"loadingOverlay c fc"},pPs={class:"loadingText"},bPs=["onClick"],OPs=["onClick"],wPs=["onClick"],yPs=["onClick"],CPs={class:"videoPlayerBox"},xPs=["src"],LPs=Xe({__name:"video",props:ha({activeTrackIndex:{},generating:{type:Boolean}},{currentTrack:{default:()=>{}},currentTrackModifiers:{}}),emits:ha(["generate","refresh"],["update:currentTrack"]),setup(e,{emit:t}){const n=Dc(e,"currentTrack"),r=t,{project:o}=Pr(Ad()),s=mt("episodesId"),a=de(),l=de({}),d=de(!1),u=de();async function h(p){var b;if(!(p.state==="生成中"||p.state==="生成失败"))try{await on.post("/production/workbench/selectVideo",{projectId:(b=o.value)==null?void 0:b.id,scriptId:s.value??0,videoId:p.id,trackId:n==null?void 0:n.value.id}),window.$message.success($t("workbench.generate.selectVideoSuccess")),r("refresh")}catch{window.$message.error($t("workbench.generate.selectVideoFailed"))}}function f(p){const b=_r.confirm({header:$t("workbench.generate.del"),body:$t("workbench.generate.delVideo"),onConfirm:()=>{on.post("/production/workbench/delVideo",{id:p.id}).then(()=>{window.$message.success($t("workbench.generate.delSuccess")),r("refresh"),b.destroy(),n.value.videoList.filter(O=>O.id==p.id)})},onCancel:()=>b.destroy()})}async function g(p){const O=await(await fetch(p.src)).blob(),w=document.createElement("a");w.href=URL.createObjectURL(O),w.download="视频.mp4",document.body.appendChild(w),w.click(),document.body.removeChild(w),URL.revokeObjectURL(w.href)}function k(p){if(!p||l.value[p])return;const b=document.createElement("video");b.crossOrigin="anonymous",b.preload="auto",b.muted=!0,b.src=p,b.addEventListener("seeked",()=>{try{const O=document.createElement("canvas");O.width=b.videoWidth||160,O.height=b.videoHeight||90;const w=O.getContext("2d");w&&(w.drawImage(b,0,0,O.width,O.height),l.value[p]=O.toDataURL("image/jpeg",.7))}catch{}b.src=""},{once:!0}),b.addEventListener("loadeddata",()=>{b.currentTime=.5},{once:!0}),b.addEventListener("error",()=>{b.src=""},{once:!0}),b.load()}function A(p){p.src&&(u.value=p.src,d.value=!0)}function m(){u.value=void 0}function v(p){p.state==="生成中"||p.state}return(p,b)=>{const O=vi,w=kn("i-time"),y=qc,C=Gd,x=Ha,L=kn("i-check"),S=kn("i-delete"),T=kn("i-to-bottom"),D=kn("i-play"),Q=yh,M=qa;return Ce(),We(nn,null,[c(Q,{title:"#"+(e.activeTrackIndex+1)+p.$t("workbench.generate.videoMenu"),"header-bordered":"",style:{height:"100%"}},{actions:ve(()=>[c(O,{size:"small",loading:e.generating,onClick:b[0]||(b[0]=B=>r("generate"))},{default:ve(()=>[kt(De(p.$t("workbench.generate.generate")),1)]),_:1},8,["loading"])]),default:ve(()=>{var B,P;return[he("div",uPs,[he("div",hPs,[c(w),he("span",APs,De(p.$t("workbench.generate.history"))+"("+De((B=n.value)==null?void 0:B.videoList.length)+")",1)]),he("div",fPs,[(Ce(!0),We(nn,null,bi((P=n.value)==null?void 0:P.videoList,F=>(Ce(),We("div",{class:uo(["historyItem",{active:F.id===ge(a),generating:F.state==="生成中",failed:F.state==="生成失败"}]),key:F.id,onClick:R=>v(F)},[ge(l)[F.src]?(Ce(),We("img",{key:0,src:ge(l)[F.src],class:"videoCover"},null,8,mPs)):F.state!=="生成中"?(Ce(),We("video",{key:F.src,src:F.src,preload:"metadata",muted:"",onLoadedmetadata:b[1]||(b[1]=R=>{R.target.currentTime=.5}),onSeeked:R=>{const N=R.target;k(F.src),N.style.display="none"}},null,40,kPs)):Vt("",!0),F.state==="生成中"?(Ce(),We("div",vPs,[c(y,{size:"24px"}),he("span",pPs,De(p.$t("workbench.generate.generating")),1)])):Vt("",!0),F.state=="生成失败"?(Ce(),St(x,{key:3,placement:"top",content:(F==null?void 0:F.errorReason)??"",theme:"light"},{default:ve(()=>[c(C,{class:"stateTag",theme:"danger",size:"small"},{default:ve(()=>[kt(De(p.$t("workbench.generate.generateFailed")),1)]),_:1})]),_:1},8,["content"])):Vt("",!0),F.state!=="生成中"?(Ce(),We("div",{key:4,class:"selectBtn",onClick:or(R=>h(F),["stop"])},[c(L,{size:"16"})],8,bPs)):Vt("",!0),he("div",{class:"delBtn",onClick:or(R=>f(F),["stop"])},[c(S,{size:"16"})],8,OPs),F.state!=="生成中"&&F.state!=="生成失败"?(Ce(),We("div",{key:5,class:"download",onClick:or(R=>g(F),["stop"])},[c(T,{size:"16"})],8,wPs)):Vt("",!0),F.state!=="生成中"&&F.state!=="生成失败"?(Ce(),We("div",{key:6,class:"playBtn",onClick:or(R=>A(F),["stop"])},[c(D,{size:"16"})],8,yPs)):Vt("",!0)],10,gPs))),128))])])]}),_:1},8,["title"]),c(M,{visible:ge(d),"onUpdate:visible":b[2]||(b[2]=B=>Dn(d)?d.value=B:null),header:p.$t("workbench.generate.previewVideo"),footer:!1,width:"800px","destroy-on-close":"",onClose:m},{default:ve(()=>[he("div",CPs,[ge(u)?(Ce(),We("video",{key:0,src:ge(u),controls:"",autoplay:"",class:"videoPlayer"},null,8,xPs)):Vt("",!0)])]),_:1},8,["visible","header"])],64)}}}),SPs=Fr(LPs,[["__scopeId","data-v-e8c2ef00"]]),TPs={class:"index fc"},EPs={class:"referenceImage"},DPs={class:"uploadBtn"},QPs={class:"modelSelect"},BPs={class:"generate ac"},FPs={key:0,class:"prompt"},PPs={class:"promptData fc"},MPs={class:"video"},RPs={class:"track"},IPs=Xe({__name:"index",setup(e){const{project:t}=Pr(Ad()),n=mt("episodesId"),r=de(0),o=E_n(),{getCache:s,setCache:a,removeCache:l,initCacheFromTrackList:d,warmUpUrls:u}=o,{urlMap:h}=Pr(o),f=de({name:"",modelName:"",durationResolutionMap:[],audio:!1,type:"video",mode:[]}),g=de([]),k=de({mode:"",model:"",resolution:"480p",duration:8,audio:!1}),A=de([]);function m(I){return I.src?I.sources==="assets"?0:1:2}const v=G({get(){var Y,K,X;h.value;const I=(Y=O.value)==null?void 0:Y.id,W=(K=t.value)==null?void 0:K.id,V=n.value;if(W!=null&&V!=null&&I!=null){const _=s(W,V,I);if(_!=null&&_.length)return _.sort((q,re)=>m(q)-m(re)),_}const z=(X=O.value)==null?void 0:X.medias;return z!=null&&z.length?(z.sort((_,q)=>m(_)-m(q)),z):[]},set(I){var W;if(O.value){O.value.medias=I;const V=(W=t.value)==null?void 0:W.id,z=n.value,Y=O.value.id;V!=null&&z!=null&&Y!=null&&a(V,z,Y,I)}}});function p(I){var W;if(I!=k.value.mode)if((v.value.length||(W=O.value)!=null&&W.prompt)&&k.value.mode){const V=_r.confirm({header:$t("workbench.generate.modeChange"),body:$t("workbench.generate.modeChangeConfirm"),confirmBtn:$t("settings.generate.modelChnageSure"),cancelBtn:$t("settings.memory.msg.cancel"),onConfirm:async()=>{v.value=[],O.value.prompt="",V.destroy(),k.value.mode=I}})}else I&&(k.value.mode=I)}const b=G(()=>{const I={singleImage:"单图",startEndRequired:"首尾帧",endFrameOptional:"尾帧可选",startFrameOptional:"首帧可选",text:"文本生视频",videoReference:"视频",imageReference:"图片",audioReference:"音频",textReference:"文本"};function W(V){const z=V.match(/^(videoReference|imageReference|audioReference|textReference):(\d+)$/);return z?`${I[z[1]]||z[1]} ×${z[2]}`:I[V]||V}return f.value.mode?f.value.mode.map(V=>Array.isArray(V)?{value:JSON.stringify(V),label:V.map(z=>W(z)).join(" + ")+"参考"}:{value:V,label:I[V]||V}):[]}),O=G({get(){return g.value[r.value]},set(I){g.value[r.value]=I}}),w=G(()=>{var W;const I=(W=g.value[r.value])==null?void 0:W.id;return I!=null?!!T.value[I]:!1});function y(I){var V,z;const W=(V=f.value)==null?void 0:V.durationResolutionMap;if(Array.isArray(W)&&W.length>0&&((z=W[0].duration)!=null&&z.length)){const Y=W[0].duration;return Math.max(Math.min(...Y),Math.min(I,Math.max(...Y)))}return I}At(()=>k.value.model,I=>{if(!I){f.value={name:"",modelName:"",durationResolutionMap:[],audio:!1,type:"video",mode:[]},k.value.mode="";return}on.post("/modelSelect/getModelDetail",{modelId:I}).then(({data:W})=>{var K,X;f.value=W,k.value.audio=W.audio===!0||W.audio==="true"||W.audio=="optional";const V=W.durationResolutionMap;Array.isArray(V)&&V.length>0&&((K=V[0].resolution)!=null&&K.length&&(k.value.resolution=V[0].resolution[0]),(X=V[0].duration)!=null&&X.length&&(k.value.duration=y(k.value.duration)));const z=C(k.value.mode);if(!(z!==null&&W.mode.some(_=>Array.isArray(_)&&Array.isArray(z)?JSON.stringify(_)===JSON.stringify(z):_==z))){const _=Array.isArray(W.mode[0])?JSON.stringify(W.mode[0]):W.mode[0];p(_)}})});function C(I){if(!I)return null;try{const W=JSON.parse(I);if(Array.isArray(W))return W}catch{return I}return I}const x=G(()=>{function I(W){var z;const V=((z=W==null?void 0:W.split(".").pop())==null?void 0:z.toLowerCase())??"";return["mp4","webm","mov","avi","mkv"].includes(V)?"video":["mp3","wav","ogg","aac","flac","m4a"].includes(V)?"audio":"image"}return v.value.filter(W=>W.src).map(W=>({type:I(W.src),src:W.src??""}))});async function L(){var z,Y,K,X;const{data:I}=await on.post("/production/workbench/getGenerateData",{projectId:(z=t.value)==null?void 0:z.id,scriptId:n.value??0});A.value=I.storyboardList;const W=(Y=t.value)==null?void 0:Y.id,V=n.value;W!=null&&V!=null&&(d(W,V,I.trackList),await u(W,V),I.trackList.forEach(_=>{if(_.id==null)return;const q=s(W,V,_.id);q!=null&&q.length&&(_.medias=q)}),g.value=[...I.trackList]),k.value.duration=y((X=(K=I.trackList)==null?void 0:K[r.value])==null?void 0:X.duration)}function S(){var W,V;const I=(W=g.value[r.value])==null?void 0:W.id;I!=null&&on.post("/production/workbench/updateVideoPrompt",{id:I,prompt:(V=O.value)==null?void 0:V.prompt})}const T=de({});async function D(){var z;if(O.value.id==null||T.value[O.value.id])return;let I=[];const W=O.value.id,V=O.value;k.value.mode=="text"?I=V==null?void 0:V.medias.map(({id:Y,sources:K})=>({id:Y,sources:K})):I=k.value.mode==="text"?[]:(()=>{const Y=["startEndRequired","endFrameOptional","startFrameOptional"],X=(Y.includes(k.value.mode)?v.value.slice(0,2):k.value.mode==="singleImage"?v.value.slice(0,1):v.value).filter(_=>_.id).map(({id:_,sources:q})=>({id:_,sources:q}));return Y.includes(k.value.mode)?X.slice(0,2):k.value.mode==="singleImage"?X.slice(0,1):X})(),T.value[W]=!0;try{const{data:Y}=await on.post("/production/workbench/generateVideoPrompt",{projectId:(z=t.value)==null?void 0:z.id,trackId:W,info:I,model:k.value.model});V.prompt=Y}catch(Y){window.$message.error((Y==null?void 0:Y.message)??"提示词生成失败")}finally{T.value[W]=!1}}function Q(I){var Y,K,X,_;if(I!=null){const q=g.value[I],re=(Y=t.value)==null?void 0:Y.id,le=n.value;re!=null&&le!=null&&(q==null?void 0:q.id)!=null&&a(re,le,q.id,q.medias)}const W=(K=t.value)==null?void 0:K.id,V=n.value,z=g.value[r.value];if(W!=null&&V!=null&&(z==null?void 0:z.id)!=null){const q=s(W,V,z.id);q&&(z.medias=q)}k.value.mode=="singleImage"&&v.value.length>1&&(v.value=v.value.slice(0,1)),k.value.duration=y((_=(X=g.value)==null?void 0:X[r.value])==null?void 0:_.duration)}At(()=>{var I;return(I=O.value)==null?void 0:I.medias},I=>{var Y,K;if(!I)return;const W=(Y=t.value)==null?void 0:Y.id,V=n.value,z=(K=O.value)==null?void 0:K.id;W!=null&&V!=null&&z!=null&&a(W,V,z,I)},{deep:!0}),mn(()=>{var I,W;k.value.model=((I=t.value)==null?void 0:I.videoModel)||"",k.value.mode=((W=t.value)==null?void 0:W.mode)||"",L(),R.value&&R.value.length&&P()});async function M(){const I=_r.confirm({header:$t("workbench.generate.generateConfirm"),body:$t("workbench.generate.generateConfirmBody"),onConfirm:async()=>{var W;I.destroy();try{const{data:V}=await on.post("/production/workbench/generateVideo",{projectId:(W=t.value)==null?void 0:W.id,scriptId:n.value,uploadData:k.value.mode==="text"?[]:(()=>{const z=["startEndRequired","endFrameOptional","startFrameOptional"],K=(z.includes(k.value.mode)?v.value.slice(0,2):k.value.mode==="singleImage"?v.value.slice(0,1):v.value).filter(X=>!!X.src&&X.id).map(({id:X,sources:_})=>({id:X,sources:_}));return z.includes(k.value.mode)?K.slice(0,2):k.value.mode==="singleImage"?K.slice(0,1):K})(),prompt:O.value.prompt,model:k.value.model,mode:k.value.mode,resolution:k.value.resolution,duration:k.value.duration,audio:k.value.audio,trackId:O.value.id});window.$message.success($t("workbench.generate.generateStarted")),O.value.videoList.push({id:V,state:"生成中",src:""})}catch(V){window.$message.error((V==null?void 0:V.message)??"视频发起生成请求失败")}finally{}},onCancel:()=>I.destroy()})}let B=null;function P(){B===null&&(B=setInterval(()=>N(),3e3))}function F(){B&&(clearInterval(B),B=null)}const R=G(()=>g.value.map(I=>I.videoList.filter(W=>W.state=="生成中").map(W=>W.id)).flatMap(I=>I));async function N(){var W;const{data:I}=await on.post("/production/workbench/checkVideoStateList",{projectId:(W=t.value)==null?void 0:W.id,scriptId:n.value??0,videoIds:R.value});I&&I.length&&I.forEach(V=>{for(const z of g.value){const Y=z.videoList.find(K=>K.id==V.id);if(Y){Y.state=V.state,Y.src=(V==null?void 0:V.src)??"",Y.errorReason=(V==null?void 0:V.errorReason)??"";break}}})}return At(()=>R.value,I=>{I&&I.length>0?P():F()}),Pa(()=>{F()}),(I,W)=>{var Y;const V=vi,z=yh;return Ce(),We("div",TPs,[he("div",EPs,[he("div",DPs,[c(GFs,{mode:ge(k).mode,modelValue:ge(v),"onUpdate:modelValue":W[0]||(W[0]=K=>Dn(v)?v.value=K:null),"storyboard-list":ge(A)},null,8,["mode","modelValue","storyboard-list"])])]),he("div",QPs,[c(dPs,{modelValue:ge(k),"onUpdate:modelValue":W[1]||(W[1]=K=>Dn(k)?k.value=K:null),modeOptions:ge(f),trackId:(Y=ge(O))==null?void 0:Y.id,modeList:ge(b),onModeChange:p},null,8,["modelValue","modeOptions","trackId","modeList"])]),he("div",BPs,[ge(O)?(Ce(),We("div",FPs,[c(z,{title:"#"+(ge(r)+1)+I.$t("workbench.generate.generateText"),"header-bordered":"",class:"videoPrompt"},{actions:ve(()=>[c(V,{size:"small",class:"genTextbtn",loading:ge(w),onClick:D},{default:ve(()=>[kt(De(I.$t("workbench.generate.generateText")),1)]),_:1},8,["loading"])]),default:ve(()=>[he("div",PPs,[he("div",{class:"promptInput",onFocusout:S},[c(PJn,{modelValue:ge(O).prompt,"onUpdate:modelValue":W[2]||(W[2]=K=>ge(O).prompt=K),references:ge(x),placeholder:I.$t("workbench.generate.promptPlaceholder")},null,8,["modelValue","references","placeholder"])],32)])]),_:1},8,["title"])])):Vt("",!0),he("div",MPs,[ge(O)?(Ce(),St(SPs,{key:0,"active-track-index":ge(r),"current-track":ge(O),"onUpdate:currentTrack":W[3]||(W[3]=K=>Dn(O)?O.value=K:null),onRefresh:L,onGenerate:M},null,8,["active-track-index","current-track"])):Vt("",!0)])]),he("div",RPs,[c(QFs,{activeTrackIndex:ge(r),"onUpdate:activeTrackIndex":W[4]||(W[4]=K=>Dn(r)?r.value=K:null),genTextLoadingMap:ge(T),"onUpdate:genTextLoadingMap":W[5]||(W[5]=K=>Dn(T)?T.value=K:null),modelValue:ge(g),"onUpdate:modelValue":W[6]||(W[6]=K=>Dn(g)?g.value=K:null),"image-list":ge(v),onChange:Q,modelParmas:ge(k),clampDuration:y,onGetData:L},null,8,["activeTrackIndex","genTextLoadingMap","modelValue","image-list","modelParmas"])])])}}}),NPs=Fr(IPs,[["__scopeId","data-v-52f5de32"]]);var UPs=Object.defineProperty,D_n=e=>{throw TypeError(e)},jPs=(e,t,n)=>t in e?UPs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ky=(e,t,n)=>jPs(e,typeof t!="symbol"?t+"":t,n),Pat=(e,t,n)=>t.has(e)||D_n("Cannot "+n),Jt=(e,t,n)=>(Pat(e,t,"read from private field"),n?n.call(e):t.get(e)),Oo=(e,t,n)=>t.has(e)?D_n("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),jr=(e,t,n,r)=>(Pat(e,t,"write to private field"),t.set(e,n),n),WPs=(e,t,n)=>(Pat(e,t,"access private method"),n);function Aoe(e=""){return`${e}${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function HPs(){return/Mac|iPod|iPhone|iPad/.test(navigator.platform)}function br(e){return Math.round(e*1e3)/1e3}const J1=RO("tracks",()=>{const e=de([]),t=de(new Set),n=de({clips:[],operation:null}),r=G(()=>e.value.find(_=>_.isMain)),o=G(()=>[...e.value].sort((_,q)=>{const re=me=>me.isMain?100:{effect:10,filter:20,sticker:30,subtitle:40,video:50,audio:200}[me.type]||0,le=re(_),ce=re(q);return le!==ce?le-ce:_.order-q.order})),s=G(()=>{let _=0;return e.value.forEach(q=>{q.clips.forEach(re=>{re.endTime>_&&(_=re.endTime)})}),_}),a=G(()=>{const _=[];return e.value.forEach(q=>{q.clips.forEach(re=>{t.value.has(re.id)&&_.push(re)})}),_});function l(_){if((_.type==="video"||_.type==="audio")&&"playbackRate"in _){const q=_,re=q.playbackRate||1;if(typeof q.trimStart=="number"&&typeof q.trimEnd=="number"){const le=q.trimEnd-q.trimStart,ce=br(le/re);return{...q,endTime:br(q.startTime+ce)}}}return _}function d(_){return _.map(q=>({...q,clips:q.clips?q.clips.map(l):[]}))}function u(_){e.value=d(_)}function h(_){_.clips&&_.clips.length>0&&(_.clips=_.clips.map(l)),e.value.push(_)}function f(_){const q=e.value.findIndex(re=>re.id===_);q!==-1&&e.value.splice(q,1)}function g(_,q){const re=e.value.find(le=>le.id===_);re&&Object.assign(re,q)}function k(_,q){const re=e.value.findIndex(ce=>ce.id===_);if(re===-1)return null;const le={id:`track-${Date.now()}`,type:q,name:`${q} ${m(q)+1}`,visible:!0,locked:!1,clips:[],order:re};return e.value.forEach(ce=>{ce.order>=re&&ce.order++}),e.value.splice(re,0,le),le}function A(_,q){const re=e.value.findIndex(ce=>ce.id===_);if(re===-1)return null;const le={id:`track-${Date.now()}`,type:q,name:`${q} ${m(q)+1}`,visible:!0,locked:!1,clips:[],order:re+1};return e.value.forEach(ce=>{ce.order>re&&ce.order++}),e.value.splice(re+1,0,le),le}function m(_){return e.value.filter(q=>q.type===_).length}function v(_,q){const re=e.value.find(le=>le.id===_);if(re){const le=l(q);re.clips.push(le)}}function p(_){e.value.forEach(q=>{const re=q.clips.findIndex(le=>le.id===_);if(re!==-1){const le=q.clips[re];if(le.type==="video"){q.clips.filter(me=>{if(me.type!=="transition")return!1;const ie=me,Ae=(ie.startTime+ie.endTime)/2,H=Math.abs(Ae-le.startTime){const ie=q.clips.findIndex(Ae=>Ae.id===me.id);ie!==-1&&(q.clips.splice(ie,1),t.value.delete(me.id))});const ce=q.clips.findIndex(me=>me.id===_);ce!==-1&&q.clips.splice(ce,1)}else q.clips.splice(re,1)}}),t.value.delete(_)}function b(_){_.forEach(q=>p(q))}function O(_,q){const re={..._};for(const le in q)if(Object.prototype.hasOwnProperty.call(q,le)){const ce=q[le],me=_[le];ce==null?re[le]=ce:typeof ce=="object"&&!Array.isArray(ce)&&typeof me=="object"&&me!==null&&!Array.isArray(me)?re[le]=O(me,ce):re[le]=ce}return re}function w(_,q){e.value.forEach(re=>{const le=re.clips.findIndex(ce=>ce.id===_);if(le!==-1){const ce=re.clips[le];re.clips[le]=O(ce,q)}})}function y(_,q){let re=null;for(const le of e.value){const ce=le.clips.findIndex(me=>me.id===_);if(ce!==-1){re=le.clips.splice(ce,1)[0],le.id;break}}if(re){const le=e.value.find(ce=>ce.id===q);le&&(re.trackId=q,le.clips.push(re))}}function C(_){for(const q of e.value){const re=q.clips.find(le=>le.id===_);if(re)return re}}function x(_,q=!1){q||t.value.clear(),t.value.add(_)}function L(_){t.value.has(_)?t.value.delete(_):t.value.add(_)}function S(_){t.value.delete(_)}function T(){t.value.clear()}function D(_,q,re,le){const ce=e.value.find(me=>me.id===_);return ce?ce.clips.some(me=>le&&me.id===le?!1:me.startTimeq):!1}function Q(){e.value=[],t.value.clear()}function M(){const _=[];e.value.forEach(q=>{q.isMain||q.clips.some(re=>re.type!=="transition")||_.push(q.id)}),_.forEach(q=>{f(q)})}function B(_){const q=_||Array.from(t.value);if(q.length===0)return!1;const re=[];return q.forEach(le=>{const ce=C(le);ce&&re.push(JSON.parse(JSON.stringify(ce)))}),re.length>0?(n.value={clips:re,operation:"copy"},!0):!1}function P(_){const q=_||Array.from(t.value);if(q.length===0)return!1;const re=[];return q.forEach(le=>{const ce=C(le);ce&&re.push(JSON.parse(JSON.stringify(ce)))}),re.length>0?(n.value={clips:re,operation:"cut"},!0):!1}function F(_,q,re,le=[]){const ce=e.value.find(H=>H.id===_);if(!ce)return q;const me=ce.clips.filter(H=>!le.includes(H.id)).sort((H,ee)=>H.startTime-ee.startTime);if(me.length===0)return q;let ie=q,Ae=q+re;for(const H of me)ieH.startTime&&(ie=H.endTime,Ae=ie+re);return Math.max(0,ie)}function R(_,q){if(n.value.clips.length===0)return null;const re=e.value.find(ee=>ee.id===_);if(!re)return null;const le=[],ce=()=>`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,me=Math.min(...n.value.clips.map(ee=>ee.startTime)),ie=Math.max(...n.value.clips.map(ee=>ee.endTime-me)),Ae=n.value.operation==="cut"?n.value.clips.map(ee=>ee.id):[],H=F(_,q,ie,Ae);return n.value.clips.forEach(ee=>{const oe=ee.endTime-ee.startTime,te=ee.startTime-me,J={...ee,id:ce(),trackId:_,startTime:H+te,endTime:H+te+oe,selected:!1};re.clips.push(J),le.push(J)}),n.value.operation==="cut"&&(n.value.clips.forEach(ee=>{p(ee.id)}),n.value={clips:[],operation:null}),le.length>0?le:null}function N(){return n.value.clips.length>0}function I(){return n.value}function W(){n.value={clips:[],operation:null}}function V(_,q){let re=null,le=null,ce=-1;for(const H of e.value){const ee=H.clips.findIndex(oe=>oe.id===_);if(ee!==-1){re=H.clips[ee],le=H,ce=ee;break}}if(!re||!le||ce===-1||q<=re.startTime||q>=re.endTime)return null;const me=()=>`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,ie={...JSON.parse(JSON.stringify(re)),endTime:q},Ae={...JSON.parse(JSON.stringify(re)),id:me(),startTime:q,selected:!1};if("trimStart"in re&&"trimEnd"in re&&"originalDuration"in re){const H=re,ee=H.endTime-H.startTime,oe=(H.trimEnd-H.trimStart)/ee,te=(q-H.startTime)*oe,J=H.trimStart+te;ie.trimEnd=J,Ae.trimStart=J}return le.clips.splice(ce,1,ie,Ae),t.value.has(_)&&(t.value.delete(_),t.value.add(ie.id)),{leftClip:ie,rightClip:Ae}}function z(_,q,re){const{allowShrink:le=!0,allowExpand:ce=!0,handleCollision:me=!0,keepStartTime:ie=!0}=re||{};if(q<.25||q>4)return{success:!1,message:"播放倍速必须在 0.25 到 4 之间"};let Ae=null,H=null;for(const Ge of e.value){const Ye=Ge.clips.find(_e=>_e.id===_);if(Ye){Ae=Ye,H=Ge;break}}if(!Ae||!H)return{success:!1,message:"未找到指定的 Clip"};if(Ae.type!=="video"&&Ae.type!=="audio")return{success:!1,message:"只有视频或音频类型的 Clip 可以调整倍速"};const ee=Ae,oe=ee.playbackRate||1;if(Math.abs(oe-q)<.001)return{success:!0};const te=ee.trimEnd-ee.trimStart,J=ee.endTime-ee.startTime,se=br(te/q),ke=se>J,ye=se{if(Ge.type!=="transition")return!1;const Ye=Ge,_e=(Ye.startTime+Ye.endTime)/2,vt=Math.abs(_e-ee.startTime)Ge.id!==_&&Ge.type!=="transition").sort((Ge,Ye)=>Ge.startTime-Ye.startTime),Re=Fe.filter(Ge=>QeGe.startTime);if(Re.length>0){if(!me)return{success:!1,message:"会与其他 Clip 产生碰撞"};const Ge=Re.filter(_e=>_e.startTime>=ee.startTime),Ye=xe-Math.min(...Ge.map(_e=>_e.startTime));if(Ye>0){const _e=Fe.filter(vt=>vt.startTime>=ee.endTime);for(const vt of _e){const Je=br(vt.startTime+Ye),tt=br(vt.endTime+Ye);w(vt.id,{startTime:Je,endTime:tt}),be.push({id:vt.id,startTime:Je,endTime:tt})}}}w(_,{playbackRate:q,startTime:Qe,endTime:xe});for(const Ge of Se){const Ye=Ge,_e=(Ye.startTime+Ye.endTime)/2,vt=H.clips.filter(Pt=>Pt.type!=="transition");({...ee});const Je=Math.abs(_e-ee.startTime)Ut.id!==_&&Math.abs(Ut.startTime-xe)<.01);if(yt=!!Pt,yt&&Pt){const Ut=(xe+Pt.startTime)/2,je=Ye.transitionDuration/2;w(Ge.id,{startTime:br(Ut-je),endTime:br(Ut+je)})}}else if(Je&&!ie){const Pt=vt.find(Ut=>Ut.id!==_&&Math.abs(Ut.endTime-Qe)<.01);if(yt=!!Pt,yt&&Pt){const Ut=(Pt.endTime+Qe)/2,je=Ye.transitionDuration/2;w(Ge.id,{startTime:br(Ut-je),endTime:br(Ut+je)})}}else Je&&ie&&(yt=!0);yt||(p(Ge.id),fe.push(Ge.id))}return{success:!0,removedTransitions:fe.length>0?fe:void 0,adjustedClips:be.length>0?be:void 0}}function Y(_,q){const re=C(_);if(!re||re.type!=="video"&&re.type!=="audio")return null;const le=re,ce=le.trimEnd-le.trimStart;return br(ce/q)}function K(_,q,re=!0){const le=C(_);if(!le||le.type!=="video"&&le.type!=="audio")return{willCollide:!1};const ce=le,me=ce.trimEnd-ce.trimStart,ie=br(me/q);let Ae,H;re?(Ae=ce.startTime,H=br(ce.startTime+ie)):(H=ce.endTime,Ae=br(Math.max(0,ce.endTime-ie)));let ee=null;for(const te of e.value)if(te.clips.some(J=>J.id===_)){ee=te;break}if(!ee)return{willCollide:!1,newDuration:ie};const oe=ee.clips.filter(te=>te.id!==_&&te.type!=="transition"&&Aete.startTime);return{willCollide:oe.length>0,collidingClipIds:oe.map(te=>te.id),newDuration:ie}}function X(_,q,re=1){const le=q-_;return br(le/re)}return{tracks:e,selectedClipIds:t,clipboard:n,mainTrack:r,sortedTracks:o,totalDuration:s,selectedClips:a,addTrack:h,addTrackAbove:k,addTrackBelow:A,removeTrack:f,updateTrack:g,getTrackCountByType:m,setTracks:u,normalizeTracks:d,normalizeClipDuration:l,addClip:v,removeClip:p,removeClips:b,updateClip:w,moveClipToTrack:y,getClip:C,selectClip:x,toggleClipSelection:L,deselectClip:S,clearSelection:T,hasOverlap:D,reset:Q,cleanupEmptyTracks:M,copyClips:B,cutClips:P,pasteClips:R,hasClipboardContent:N,getClipboardContent:I,clearClipboard:W,splitClip:V,setClipPlaybackRate:z,getClipDurationAtRate:Y,checkPlaybackRateCollision:K,calculateTrackDuration:X}}),Y6=RO("playback",()=>{const e=de(!1),t=de(0),n=de(1),r=de(0);let o=null,s=0;const a=G(()=>{const y=J1().totalDuration;return Math.max(y,r.value)}),l=G(()=>u(t.value)),d=G(()=>u(a.value));function u(y,C=30){const x=Math.floor(y*C),L=Math.floor(x/(C*3600)),S=Math.floor(x%(C*3600)/(C*60)),T=Math.floor(x%(C*60)/C),D=x%C;return`${String(L).padStart(2,"0")}:${String(S).padStart(2,"0")}:${String(T).padStart(2,"0")}:${String(D).padStart(2,"0")}`}function h(y){if(e.value){if(s>0){const C=(y-s)/1e3,x=t.value+C*n.value,L=a.value;if(x>=L){t.value=L,A();return}t.value=x}s=y,o=requestAnimationFrame(h)}}function f(){s=0,o=requestAnimationFrame(h)}function g(){o!==null&&(cancelAnimationFrame(o),o=null),s=0}function k(){e.value||(e.value=!0,f())}function A(){e.value&&(e.value=!1,g())}function m(){e.value?A():k()}function v(y){const C=a.value>0?a.value:1/0;t.value=Math.max(0,Math.min(y,C))}function p(y){n.value=y}function b(y){r.value=y}function O(y){const C=a.value;t.value=Math.max(0,Math.min(t.value+y,C))}function w(){A(),t.value=0,n.value=1,r.value=0}return{isPlaying:e,currentTime:t,playbackRate:n,duration:r,effectiveDuration:a,formattedCurrentTime:l,formattedDuration:d,formatTime:u,play:k,pause:A,togglePlay:m,seekTo:v,setPlaybackRate:p,setDuration:b,adjustTime:O,reset:w}}),WE=RO("history",()=>{const e=de([]),t=de(-1),n=de(50),r=G(()=>t.value>0),o=G(()=>t.valuen.value?e.value.shift():t.value++}function l(k){const A=J1(),m=JSON.parse(k.snapshot);A.tracks=m.tracks,A.selectedClipIds.clear(),m.selectedClipIds.forEach(v=>{A.selectedClipIds.add(v)})}function d(){if(!r.value)return;t.value--;const k=e.value[t.value];l(k)}function u(){if(!o.value)return;t.value++;const k=e.value[t.value];l(k)}function h(){e.value=[],t.value=-1,a("初始状态")}function f(){e.value=[],t.value=-1}function g(){f()}return{historyStack:e,currentIndex:t,maxHistorySize:n,canUndo:r,canRedo:o,createSnapshot:s,pushSnapshot:a,restoreSnapshot:l,undo:d,redo:u,initialize:h,clear:f,reset:g}}),Mat="video-track-scale-settings";function VPs(){try{const e=localStorage.getItem(Mat);if(e)return JSON.parse(e)}catch(e){console.warn("Failed to load scale settings from localStorage:",e)}return null}function zPs(e){try{localStorage.setItem(Mat,JSON.stringify(e))}catch(t){console.warn("Failed to save scale settings to localStorage:",t)}}const Q2=RO("scale",()=>{const e=VPs(),t=de((e==null?void 0:e.scale)??1),n=de(.1),r=de(10),o=de(100),s=de((e==null?void 0:e.snapEnabled)??!0),a=de(10);At([t,s],([y,C])=>{zPs({scale:y,snapEnabled:C})},{immediate:!1});const l=G(()=>o.value*t.value),d=G(()=>{const y=t.value;return y>=5?{majorInterval:1,minorInterval:1/30,majorHeight:20,minorHeight:8}:y>=2?{majorInterval:1,minorInterval:.1,majorHeight:20,minorHeight:10}:y>=1?{majorInterval:1,minorInterval:.2,majorHeight:20,minorHeight:10}:y>=.5?{majorInterval:2,minorInterval:.5,majorHeight:20,minorHeight:10}:y>=.2?{majorInterval:5,minorInterval:1,majorHeight:20,minorHeight:10}:{majorInterval:10,minorInterval:2,majorHeight:20,minorHeight:10}});function u(y){t.value=Math.max(n.value,Math.min(y,r.value))}function h(y=.1){u(t.value+y)}function f(y=.1){u(t.value-y)}function g(){s.value=!s.value}function k(y){s.value=y}function A(y){return y*l.value}function m(y){return y/l.value}function v(y,C){if(!s.value||C.length===0)return y;let x=y,L=a.value;for(const S of C){const T=Math.abs(y-S);T{const e=J1(),t=Q2(),n=WE(),r=de(!1),o=de([]),s=de(0),a=de(0),l=de(""),d=de(new Map),u=de(0),h=de(0),f=de({shift:!1}),g=de(!0),k=de({x:0,y:0}),A=de({enabled:!0,edgeThreshold:80,scrollSpeed:8,maxScrollSpeed:25}),m=de(null),v=de(null),p=de(null),b=de(null),O=de(0),w=de({trackId:"",startTime:0,endTime:0,needNewTrack:!1,visible:!1,clipType:""}),y=de("");let C=document;const x=G(()=>new Set(o.value.map(ce=>ce.id))),L=G(()=>!r.value||!w.value.visible?0:w.value.endTime);function S(ce){ce.enableCrossTrackDrag!==void 0&&(g.value=ce.enableCrossTrackDrag),ce.edgeScroll&&Object.assign(A.value,ce.edgeScroll)}function T(ce,me,ie){m.value=ce,v.value=me,b.value=ie||null}function D(ce){if(!v.value)return;const me=Math.max(0,v.value.scrollLeft+ce);v.value.scrollLeft=me,b.value&&b.value(me)}function Q(){if(!r.value||!A.value.enabled){P();return}const ce=m.value,me=v.value;if(!ce||!me)return;const ie=ce.getBoundingClientRect(),{edgeThreshold:Ae,scrollSpeed:H,maxScrollSpeed:ee}=A.value,oe=u.value-ie.left;let te=0;if(oe0){const J=Math.max(0,Ae-oe)/Ae;te=-Math.min(H+J*(ee-H),ee)}else if(oe>ie.width-Ae){const J=me.scrollWidth-me.clientWidth+500;if(me.scrollLeft40;let te=l.value;if(g.value&&oe){const ye=re(h.value);ye&&(te=ye)}y.value=te;let J=br(ee.startTime+Ae);t.snapEnabled&&!f.value.shift&&(J=q(J,H,te)),J=Math.max(0,J);const se=ee.endTime-ee.startTime,ke=J+se;N(te,J,ke,H.type)}function B(){p.value===null&&(p.value=requestAnimationFrame(Q))}function P(){p.value!==null&&(cancelAnimationFrame(p.value),p.value=null)}function F(ce,me,ie){var Ae;ce.type!=="transition"&&(C=ie||((Ae=me.target)==null?void 0:Ae.ownerDocument)||document,e.selectClip(ce.id),o.value=[ce],r.value=!0,s.value=me.clientX,a.value=me.clientY,u.value=me.clientX,h.value=me.clientY,l.value=ce.trackId,y.value=ce.trackId,d.value.clear(),d.value.set(ce.id,{startTime:ce.startTime,endTime:ce.endTime,trackId:ce.trackId}),k.value={x:0,y:0},O.value=0,w.value={trackId:ce.trackId,startTime:ce.startTime,endTime:ce.endTime,needNewTrack:!1,visible:!1,clipType:ce.type},C.addEventListener("mousemove",R),C.addEventListener("mouseup",V),B())}function R(ce){if(!r.value||o.value.length===0)return;f.value.shift=ce.shiftKey,u.value=ce.clientX,h.value=ce.clientY;const me=ce.clientX-s.value,ie=ce.clientY-a.value;k.value={x:me,y:ie};const Ae=(me+O.value)/t.actualPixelsPerSecond,H=o.value[0],ee=d.value.get(H.id);if(!ee)return;const oe=Math.abs(ie)>40;let te=l.value;if(g.value&&oe){const ye=re(h.value);ye&&(te=ye)}y.value=te;let J=br(ee.startTime+Ae);t.snapEnabled&&!f.value.shift&&(J=q(J,H,te)),J=Math.max(0,J);const se=ee.endTime-ee.startTime,ke=J+se;N(te,J,ke,H.type)}function N(ce,me,ie,Ae){const H=e.tracks.find(ye=>ye.id===ce),ee=l.value,oe=ce!==ee,te=ie-me;let J=me,se=ie,ke=!1;if(oe)if(!H)ke=!0;else{const ye=Ae;H.type===ye?W(ce,me,ie)&&(ke=!0):ke=!0}else{const ye=I(ce,me,te);J=ye.startTime,se=ye.endTime}w.value={trackId:ce,startTime:J,endTime:se,needNewTrack:ke,visible:!0,clipType:Ae}}function I(ce,me,ie){const Ae=e.tracks.find(J=>J.id===ce);if(!Ae)return{startTime:me,endTime:me+ie};const H=new Set(o.value.map(J=>J.id)),ee=Ae.clips.filter(J=>!H.has(J.id)&&J.type!=="transition").sort((J,se)=>J.startTime-se.startTime);let oe=me,te=me+ie;for(const J of ee)if(oeJ.startTime){const se=(oe+te)/2,ke=(J.startTime+J.endTime)/2;(seJ.startTime&&(oe=br(J.endTime)))):oe=br(J.endTime),te=oe+ie;break}return{startTime:oe,endTime:te}}function W(ce,me,ie){const Ae=e.tracks.find(ee=>ee.id===ce);if(!Ae)return!1;const H=new Set(o.value.map(ee=>ee.id));return Ae.clips.some(ee=>H.has(ee.id)||ee.type==="transition"?!1:ee.startTimeme)}function V(){if(!r.value||o.value.length===0){X();return}const ce=y.value!==l.value;if(!g.value&&ce){X();return}ce?K():z(),le(),e.cleanupEmptyTracks(),n.pushSnapshot("移动片段"),X()}function z(){const ce=w.value,me=o.value[0],ie=d.value.get(me.id);if(!ie)return;const Ae=ce.startTime-ie.startTime,H=new Map;o.value.forEach(ee=>{const oe=d.value.get(ee.id);if(oe){const te=oe.endTime-oe.startTime,J=br(Math.max(0,oe.startTime+Ae)),se=br(J+te);e.updateClip(ee.id,{startTime:J,endTime:se}),H.set(ee.id,{startTime:J,endTime:se})}}),Y(ce.trackId,H)}function Y(ce,me){const ie=e.tracks.find(ee=>ee.id===ce);if(!ie)return;const Ae=[...ie.clips].filter(ee=>ee.type!=="transition").map(ee=>{const oe=me.get(ee.id);return{id:ee.id,startTime:oe?oe.startTime:ee.startTime,endTime:oe?oe.endTime:ee.endTime}}).sort((ee,oe)=>ee.startTime-oe.startTime);if(Ae.length<2)return;const H=[];for(let ee=0;eete.startTime){const J=te.endTime-te.startTime,se=br(oe.endTime),ke=br(se+J);te.startTime=se,te.endTime=ke,H.push({id:te.id,startTime:se,endTime:ke})}}H.forEach(ee=>{e.updateClip(ee.id,{startTime:ee.startTime,endTime:ee.endTime})})}function K(){const ce=w.value,me=o.value[0],ie=d.value.get(me.id);if(!ie)return;const Ae=me.type;let H=null;if(ce.needNewTrack){const te=_(Ae);e.addTrack(te),H=te}else H=e.tracks.find(te=>te.id===ce.trackId)||null;if(!H)return;const ee=ce.startTime-ie.startTime,oe=new Map;o.value.forEach(te=>{const J=d.value.get(te.id);if(J){const se=J.endTime-J.startTime,ke=br(Math.max(0,J.startTime+ee)),ye=br(ke+se);te.trackId!==H.id&&e.moveClipToTrack(te.id,H.id),e.updateClip(te.id,{startTime:ke,endTime:ye}),oe.set(te.id,{startTime:ke,endTime:ye})}}),Y(H.id,oe)}function X(){P(),r.value=!1,o.value=[],d.value.clear(),k.value={x:0,y:0},O.value=0,w.value={trackId:"",startTime:0,endTime:0,needNewTrack:!1,visible:!1,clipType:""},y.value="",C.removeEventListener("mousemove",R),C.removeEventListener("mouseup",V)}function _(ce){const me=e.getTrackCountByType(ce),ie={video:"视频",audio:"音频",subtitle:"字幕",sticker:"贴纸",filter:"滤镜",effect:"特效"};return{id:Aoe("track-"),type:ce,name:`${ie[ce]||ce}${me+1}`,visible:!0,locked:!1,clips:[],order:e.tracks.length}}function q(ce,me,ie){if(f.value.shift||!t.snapEnabled)return ce;const Ae=e.tracks.find(J=>J.id===ie);if(!Ae)return ce;const H=[],ee=new Set(e.selectedClipIds);if(Ae.clips.forEach(J=>{J.id!==me.id&&!ee.has(J.id)&&J.type!=="transition"&&(H.push(J.startTime),H.push(J.endTime))}),H.length===0)return ce;const oe=t.timeToPixels(ce),te=t.snapToPosition(oe,H.map(J=>t.timeToPixels(J)));return br(t.pixelsToTime(te))}function re(ce){const me=document.querySelectorAll(".tracks__track");for(const ie of me){const Ae=ie.getBoundingClientRect();if(ce>=Ae.top&&ce<=Ae.bottom)return ie.dataset.trackId||null}return null}function le(){e.tracks.forEach(ce=>{const me=[];ce.clips.forEach(ie=>{if(ie.type!=="transition")return;const Ae=(ie.startTime+ie.endTime)/2,H=ce.clips.find(oe=>oe.type!=="transition"&&Math.abs(oe.endTime-Ae)<.1),ee=ce.clips.find(oe=>oe.type!=="transition"&&oe!==H&&Math.abs(oe.startTime-Ae)<.1);(!H||!ee||Math.abs(H.endTime-ee.startTime)>.1)&&me.push(ie.id)}),me.forEach(ie=>{e.removeClip(ie)})})}return{isDragging:r,draggedClips:o,draggedClipIds:x,dragOffset:k,previewPosition:w,previewEndTime:L,currentTargetTrackId:y,dragStartTrackId:l,edgeScrollConfig:A,setConfig:S,setScrollContainers:T,startDrag:F,handleDragMove:R,handleDragEnd:V,resetDragState:X,startEdgeScroll:B,stopEdgeScroll:P}});function ZPs(e={}){const t=J1(),n=Y6(),r=WE(),o=Q2(),s=e.callbacks||{},a=de(!1);function l(){var C;if(!((C=e.containerRef)!=null&&C.value))return!0;const x=document.activeElement;return x?e.containerRef.value.contains(x):!1}function d(){var C;return(C=e.containerRef)!=null&&C.value?a.value:!0}function u(C){return!C||!(C instanceof HTMLElement)?!1:!!(C instanceof HTMLInputElement||C instanceof HTMLTextAreaElement||C instanceof HTMLSelectElement||C.isContentEditable||C.getAttribute("contenteditable")==="true")}function h(C){var x,L;const S=HPs()?C.metaKey:C.ctrlKey;if(C.code==="Space"){if(u(C.target))return;C.preventDefault(),n.isPlaying?(n.pause(),(x=s.onPause)==null||x.call(s)):(n.play(),(L=s.onPlay)==null||L.call(s));return}if(d()&&!f(C)){if(S&&C.code==="KeyZ"&&!C.shiftKey){C.preventDefault(),r.undo();return}if(S&&C.code==="KeyY"||S&&C.shiftKey&&C.code==="KeyZ"){C.preventDefault(),r.redo();return}if(S&&C.code==="KeyC"){C.preventDefault(),g();return}if(S&&C.code==="KeyX"){C.preventDefault(),k();return}if(S&&C.code==="KeyV"){C.preventDefault(),A();return}if(C.code==="Delete"||C.code==="Backspace"){C.preventDefault(),m();return}if(S&&(C.code==="Equal"||C.code==="NumpadAdd")){C.preventDefault(),o.zoomIn(.1);return}if(S&&(C.code==="Minus"||C.code==="NumpadSubtract")){C.preventDefault(),o.zoomOut(.1);return}if(C.code==="ArrowRight"){C.preventDefault(),n.adjustTime(.1);return}if(C.code==="ArrowLeft"){C.preventDefault(),n.adjustTime(-.1);return}if(C.code==="Escape"){C.preventDefault(),t.clearSelection();return}}}function f(C){var x;const L=C.target;return L instanceof HTMLInputElement||L instanceof HTMLTextAreaElement||L.isContentEditable?((x=e.containerRef)!=null&&x.value&&e.containerRef.value.contains(L),!0):!1}function g(){var C;const x=Array.from(t.selectedClipIds);x.length!==0&&(t.copyClips(x),(C=s.onCopy)==null||C.call(s,x))}function k(){var C;const x=Array.from(t.selectedClipIds);x.length!==0&&(t.cutClips(x),(C=s.onCut)==null||C.call(s,x))}function A(){var C;if(!t.hasClipboardContent())return;const x=t.selectedClips;let L;if(x.length>0?L=x[0].trackId:t.mainTrack&&(L=t.mainTrack.id),!L)return;const S=n.currentTime,T=t.pasteClips(L,S);T&&(r.pushSnapshot("粘贴片段"),(C=s.onPaste)==null||C.call(s,T,L,S))}function m(){var C;const x=Array.from(t.selectedClipIds);x.length!==0&&(t.removeClips(x),r.pushSnapshot("删除片段"),(C=s.onDelete)==null||C.call(s,x))}function v(){a.value=!0}function p(){l()||(a.value=!1)}function b(){a.value=!0}function O(C){var x;const L=C.relatedTarget;(x=e.containerRef)!=null&&x.value&&L&&(e.containerRef.value.contains(L)||(a.value=!1))}function w(){var C;const x=(C=e.containerRef)==null?void 0:C.value;x&&(x.addEventListener("mouseenter",v),x.addEventListener("mouseleave",p),x.addEventListener("focusin",b),x.addEventListener("focusout",O))}function y(){var C;const x=(C=e.containerRef)==null?void 0:C.value;x&&(x.removeEventListener("mouseenter",v),x.removeEventListener("mouseleave",p),x.removeEventListener("focusin",b),x.removeEventListener("focusout",O))}return mn(()=>{document.addEventListener("keydown",h),w()}),Pa(()=>{document.removeEventListener("keydown",h),y()}),{handleKeyDown:h,isActive:a}}function YPs({scrollLeft:e,tracksWidth:t,setScrollLeft:n}){const r=Y6(),o=Q2();At(()=>r.currentTime,s=>{if(!r.isPlaying)return;const a=o.actualPixelsPerSecond,l=s*a,d=e.value+t.value*.9;if(l>d){const u=t.value*.8,h=e.value+u;n(h)}})}const Qg=(e,t)=>{const n=e.__vccOpts||e;for(const[r,o]of t)n[r]=o;return n},XPs={},qPs={width:"1em",height:"1em",viewBox:"0 0 24 24",preserveAspectRatio:"xMidYMid meet",fill:"none",role:"presentation",xmlns:"http://www.w3.org/2000/svg",class:"snap-icon"};function GPs(e,t){return Ce(),We("svg",qPs,[...t[0]||(t[0]=[he("g",null,[he("path",{d:"M11 22h2v-3h-2v3ZM6.106 4.416l1.415-1.414 2.121 2.122-1.414 1.414-2.122-2.122ZM16.48 3.002l1.414 1.414-2.122 2.122-1.414-1.414 2.122-2.122ZM11 2h2v3h-2V2Zm6.894 17.584-1.414 1.414-2.122-2.122 1.414-1.414 2.122 2.122ZM7.52 20.998l-1.414-1.414 2.122-2.122 1.414 1.415-2.121 2.12Z",fill:"currentColor"}),he("path",{d:"M4 16h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2Zm16-6h-7v4h7v-4ZM4 10h7v4H4v-4Z","clip-rule":"evenodd","fill-rule":"evenodd",fill:"currentColor"})],-1)])])}const KPs=Qg(XPs,[["render",GPs],["__scopeId","data-v-dca9589a"]]),JPs={class:"tools-bar"},_Ps={class:"tools-bar__section tools-bar__operations"},$Ps=["disabled","onClick"],eMs={class:"tools-bar__icon"},tMs={class:"tools-bar__label"},nMs=["disabled","title","onClick"],iMs={class:"tools-bar__icon"},rMs={class:"tools-bar__label"},oMs={class:"tools-bar__section tools-bar__playback"},sMs={class:"tools-bar__time"},aMs={class:"tools-bar__time-current"},lMs={class:"tools-bar__time-duration"},cMs=["value"],dMs={class:"tools-bar__section tools-bar__scale"},uMs={class:"tools-bar__scale-config"},hMs=["title"],AMs=["title","disabled","onClick"],fMs={class:"tools-bar__scale-control"},gMs=["disabled"],mMs={class:"tools-bar__scale-slider"},kMs=["min","max"],vMs={class:"tools-bar__scale-value"},pMs=["disabled"],bMs=Xe({__name:"index",props:{operationButtons:{default:()=>["reset","undo","redo","split","delete"]},scaleConfigButtons:{default:()=>["snap"]},locale:{default:()=>({})}},emits:["operation","playback:play","playback:pause"],setup(e,{emit:t}){const n=e,r=t,o=Y6(),s=Q2(),a=WE(),l=J1(),d=mt("config",{}),u=G(()=>o.isPlaying),h=G(()=>o.formattedCurrentTime),f=G(()=>o.formattedDuration),g=G(()=>s.snapEnabled),k=G(()=>s.minScale),A=G(()=>s.maxScale),m=de(o.playbackRate),v=G(()=>d.playbackRates||[.5,1,2,4]),p=de(s.scale),b=G(()=>{var z;return((z=n.locale)==null?void 0:z.snapOn)||"关闭自动吸附"}),O=G(()=>{var z;return((z=n.locale)==null?void 0:z.snapOff)||"开启自动吸附"});function w(z){return typeof z=="object"&&"type"in z&&z.type==="custom"}function y(z){return typeof z=="object"&&!("type"in z)&&"key"in z}function C(z){return typeof z=="object"&&!("type"in z)&&"key"in z}function x(z){return typeof z=="object"||typeof z=="function"}function L(z){const Y=z.disabled;return typeof Y=="function"?Y():Y??!1}function S(z){const Y=z.active;return typeof Y=="function"?Y():Y??!1}function T(z){z.onClick?z.onClick():z.key&&r("operation",z.key)}function D(z){z.onClick&&z.onClick()}function Q(z){return{reset:"↺",undo:"↶",redo:"↷",split:"✂",delete:"🗑"}[z]||""}function M(z){const Y=n.locale||{},K={reset:"重置",undo:"撤销",redo:"重做",split:"分割",delete:"删除"};return Y[z]||K[z]||z}function B(z){switch(z){case"undo":return!a.canUndo;case"redo":return!a.canRedo;case"split":return l.selectedClipIds.size===0;default:return!1}}function P(z){r("operation",z)}function F(){o.isPlaying?(o.pause(),r("playback:pause")):(o.play(),r("playback:play"))}function R(){o.setPlaybackRate(m.value)}function N(){s.toggleSnap()}function I(){s.zoomIn(.1),p.value=s.scale}function W(){s.zoomOut(.1),p.value=s.scale}function V(){s.setScale(p.value)}return(z,Y)=>(Ce(),We("div",JPs,[he("div",_Ps,[io(z.$slots,"operations-prepend",{},void 0,!0),(Ce(!0),We(nn,null,bi(e.operationButtons,(K,X)=>(Ce(),We(nn,{key:X},[typeof K=="string"?(Ce(),We("button",{key:0,class:uo(["tools-bar__btn",{"tools-bar__btn--disabled":B(K)}]),disabled:B(K),onClick:_=>P(K)},[he("span",eMs,De(Q(K)),1),he("span",tMs,De(M(K)),1)],10,$Ps)):w(K)?io(z.$slots,`custom-operation-${K.key}`,{key:1},void 0,!0):y(K)?(Ce(),We("button",{key:2,class:uo(["tools-bar__btn",[{"tools-bar__btn--disabled":L(K)},K.className]]),disabled:L(K),title:K.title,onClick:_=>T(K)},[he("span",iMs,[x(K.icon)?(Ce(),St(Ud(K.icon),{key:0})):(Ce(),We(nn,{key:1},[kt(De(K.icon||""),1)],64))]),he("span",rMs,De(K.label||""),1)],10,nMs)):Vt("",!0)],64))),128)),io(z.$slots,"operations-append",{},void 0,!0)]),he("div",oMs,[io(z.$slots,"playback-prepend",{},void 0,!0),he("button",{class:"tools-bar__btn tools-bar__btn--play",onClick:F},[he("span",{class:"tools-bar__icon",style:eo({marginLeft:u.value?"0":"2px"})},De(u.value?"⏸":"▶"),5)]),he("div",sMs,[he("span",aMs,De(h.value),1),Y[2]||(Y[2]=he("span",{class:"tools-bar__time-separator"},"/",-1)),he("span",lMs,De(f.value),1)]),gh(he("select",{"onUpdate:modelValue":Y[0]||(Y[0]=K=>m.value=K),class:"tools-bar__select",onChange:R},[(Ce(!0),We(nn,null,bi(v.value,K=>(Ce(),We("option",{key:K,value:K},De(K)+"x ",9,cMs))),128))],544),[[Psi,m.value]]),io(z.$slots,"playback-append",{},void 0,!0)]),he("div",dMs,[io(z.$slots,"scale-prepend",{},void 0,!0),he("div",uMs,[(Ce(!0),We(nn,null,bi(e.scaleConfigButtons,(K,X)=>(Ce(),We(nn,{key:X},[typeof K=="string"&&K==="snap"?(Ce(),We("button",{key:0,class:uo(["tools-bar__btn tools-bar__btn--toggle tools-bar__btn--snap",{"tools-bar__btn--active":g.value}]),title:g.value?b.value:O.value,onClick:N},[c(KPs,{class:"tools-bar__snap-icon"})],10,hMs)):w(K)?io(z.$slots,`custom-scale-config-${K.key}`,{key:1},void 0,!0):C(K)?(Ce(),We("button",{key:2,class:uo(["tools-bar__btn tools-bar__btn--toggle",[{"tools-bar__btn--active":S(K)},{"tools-bar__btn--disabled":L(K)},K.className]]),title:K.title,disabled:L(K),onClick:_=>D(K)},[x(K.icon)?(Ce(),St(Ud(K.icon),{key:0})):(Ce(),We(nn,{key:1},[kt(De(K.icon||""),1)],64))],10,AMs)):Vt("",!0)],64))),128))]),he("div",fMs,[he("button",{class:"tools-bar__btn tools-bar__btn--icon",disabled:p.value<=k.value,onClick:W}," − ",8,gMs),he("div",mMs,[gh(he("input",{type:"range",min:k.value,max:A.value,step:.1,"onUpdate:modelValue":Y[1]||(Y[1]=K=>p.value=K),onInput:V},null,40,kMs),[[f4n,p.value,void 0,{number:!0}]]),he("span",vMs,De(p.value.toFixed(1))+"x",1)]),he("button",{class:"tools-bar__btn tools-bar__btn--icon",disabled:p.value>=A.value,onClick:I}," + ",8,pMs)]),io(z.$slots,"scale-append",{},void 0,!0)])]))}}),OMs=Qg(bMs,[["__scopeId","data-v-c36de3a3"]]),wMs={key:0,class:"ruler__mark-label"},yMs=Xe({__name:"index",props:{width:{default:0},scrollLeft:{default:0},trackControlWidth:{default:200}},emits:["scroll","seek"],setup(e,{expose:t,emit:n}){const r=e,o=n,s=Y6(),a=Q2(),l=J1(),d=JZ(),u=de(),h=de(),f=de(!1),g=de(0);let k=null;t({isDraggingCursor:f});const A=G(()=>a.rulerConfig),m=G(()=>a.actualPixelsPerSecond),v=G(()=>{const D=Math.max(l.totalDuration,s.duration,d.previewEndTime,60);return Math.ceil(D*m.value)}),p=G(()=>{const D=[],Q=A.value,M=v.value/m.value,B=Q.minorInterval,P=Q.majorInterval,F=Math.ceil(M/B)+1;for(let R=0;RM)break;const I=Math.abs(Math.round(N/P)*P-N)<.001;D.push({time:N,position:N*m.value,isMajor:I,height:I?Q.majorHeight:Q.minorHeight})}return D}),b=G(()=>s.currentTime*m.value),O=G(()=>r.trackControlWidth+b.value-(r.scrollLeft||0)),w=G(()=>O.value>=r.trackControlWidth);function y(D){const Q=Math.floor(D/60),M=Math.floor(D%60);return`${String(Q).padStart(2,"0")}:${String(M).padStart(2,"0")}`}function C(D){var Q;if(f.value)return;const M=(Q=u.value)==null?void 0:Q.getBoundingClientRect();if(!M)return;const B=(D.clientX-M.left-r.trackControlWidth+(r.scrollLeft||0))/m.value,P=Math.max(0,B);s.seekTo(P),o("seek",P)}function x(){f.value=!0,s.pause(),document.body.style.userSelect="none";let D=null,Q=0,M=0;const B=()=>{f.value&&(M!==0&&h.value&&(h.value.scrollLeft+=M,o("scroll",h.value.scrollLeft),P()),D=requestAnimationFrame(B))},P=()=>{var N;const I=(N=u.value)==null?void 0:N.getBoundingClientRect();if(!I||!h.value)return;let W=(Q-I.left-r.trackControlWidth+h.value.scrollLeft)/m.value;W=Math.max(0,W),s.seekTo(W)},F=N=>{var I;Q=N.clientX;const W=(I=h.value)==null?void 0:I.getBoundingClientRect();if(W)if(N.clientXW.right-50){const V=1-(W.right-N.clientX)/50;M=15*Math.max(0,V)}else M=0;M===0&&P()},R=()=>{f.value=!1,document.body.style.userSelect="",D&&(cancelAnimationFrame(D),D=null),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",R),o("seek",s.currentTime)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",R),D=requestAnimationFrame(B)}function L(){h.value&&o("scroll",h.value.scrollLeft)}function S(){return u.value?u.value.closest(".video-track"):null}function T(){if(!u.value)return;const D=u.value.getBoundingClientRect(),Q=S(),M=Q?Q.getBoundingClientRect().bottom:window.innerHeight,B=D.top-5;g.value=Math.max(M-B,0)}return mn(()=>{ei(()=>{T(),k=new ResizeObserver(()=>{T()}),u.value&&k.observe(u.value);const D=S();D&&k.observe(D)}),window.addEventListener("resize",T)}),Pa(()=>{window.removeEventListener("resize",T),k&&(k.disconnect(),k=null)}),At(()=>r.scrollLeft,D=>{h.value&&h.value.scrollLeft!==D&&(h.value.scrollLeft=D)}),At(b,D=>{if(f.value||!h.value)return;const Q=h.value.clientWidth,M=h.value.scrollLeft;DM+Q&&(h.value.scrollLeft=D-Q+50)}),(D,Q)=>(Ce(),We("div",{class:"ruler",ref_key:"rulerRef",ref:u},[he("div",{class:"ruler__placeholder",style:eo({width:e.trackControlWidth+"px"})},null,4),he("div",{class:"ruler__wrapper",ref_key:"rulerWrapperRef",ref:h,onScroll:L},[he("div",{class:"ruler__content",style:eo({width:v.value+"px"}),onMousedown:C},[(Ce(!0),We(nn,null,bi(p.value,M=>(Ce(),We("div",{key:M.time,class:uo(["ruler__mark",{"ruler__mark--major":M.isMajor}]),style:eo({left:M.position+"px",height:M.height+"px"})},[M.isMajor?(Ce(),We("span",wMs,De(y(M.time)),1)):Vt("",!0)],6))),128))],36)],544),w.value?(Ce(),We("div",{key:0,class:uo(["ruler__cursor-handle",{"ruler__cursor-handle--dragging":f.value}]),style:eo({left:O.value+"px"}),onMousedown:or(x,["stop"])},[he("div",{class:"ruler__cursor-line",style:eo({height:`${g.value}px`}),onMousedown:or(x,["stop"])},null,36)],38)):Vt("",!0)],512))}}),CMs=Qg(yMs,[["__scopeId","data-v-f5735210"]]),xMs={class:"track-control"},LMs={class:"track-control__name"},SMs={key:2,class:"track-control__badge"},TMs={class:"track-control__actions"},EMs=["title"],DMs=["title"],QMs=["title"],BMs=Xe({__name:"TrackControl",props:{track:{},locale:{}},emits:["update","delete"],setup(e,{emit:t}){const n=e,r=t,o=de(!1),s=de(""),a=de();function l(){o.value=!0,s.value=n.track.name,ei(()=>{var k,A;(k=a.value)==null||k.focus(),(A=a.value)==null||A.select()})}function d(){s.value.trim()&&s.value!==n.track.name&&r("update",n.track.id,{name:s.value.trim()}),o.value=!1}function u(){o.value=!1,s.value=""}function h(){r("update",n.track.id,{visible:!n.track.visible})}function f(){r("update",n.track.id,{locked:!n.track.locked})}function g(){var k;const A=(((k=n.locale)==null?void 0:k.confirmDeleteTrack)||'确定要删除轨道"{name}"吗?').replace("{name}",n.track.name);confirm(A)&&r("delete",n.track.id)}return(k,A)=>{var m,v,p,b,O,w;return Ce(),We("div",xMs,[he("div",LMs,[o.value?gh((Ce(),We("input",{key:0,"onUpdate:modelValue":A[0]||(A[0]=y=>s.value=y),class:"track-control__name-input",onBlur:d,onKeyup:[zct(d,["enter"]),zct(u,["esc"])],ref_key:"nameInputRef",ref:a},null,544)),[[f4n,s.value]]):(Ce(),We("span",{key:1,class:"track-control__name-text",onDblclick:l},De(e.track.name),33)),e.track.isMain?(Ce(),We("span",SMs,De(((m=e.locale)==null?void 0:m.mainBadge)||"主"),1)):Vt("",!0)]),he("div",TMs,[he("button",{class:uo(["track-control__btn",{"track-control__btn--active":e.track.visible}]),onClick:h,title:e.track.visible?((v=e.locale)==null?void 0:v.hide)||"隐藏":((p=e.locale)==null?void 0:p.show)||"显示"},De(e.track.visible?"👁":"👁‍🗨"),11,EMs),he("button",{class:uo(["track-control__btn",{"track-control__btn--active":e.track.locked}]),onClick:f,title:e.track.locked?((b=e.locale)==null?void 0:b.unlock)||"解锁":((O=e.locale)==null?void 0:O.lock)||"锁定"},De(e.track.locked?"🔒":"🔓"),11,DMs),e.track.isMain?Vt("",!0):(Ce(),We("button",{key:0,class:"track-control__btn track-control__btn--danger",onClick:g,title:((w=e.locale)==null?void 0:w.delete)||"删除"}," 🗑 ",8,QMs))])])}}}),FMs=Qg(BMs,[["__scopeId","data-v-34ea43ab"]]);function PMs(){const e=J1(),t=Q2(),n=WE(),r=de(!1),o=de(null),s=de("left"),a=de(0),l=de(0),d=de(0),u=de(0),h=de(0);let f=document;const g=de([]),k=de([]);function A(R,N,I){var W;if(R.type==="transition"){y(R,N,I);return}if(f=((W=I.target)==null?void 0:W.ownerDocument)||document,r.value=!0,o.value=R,s.value=N,a.value=I.clientX,l.value=R.startTime,d.value=R.endTime,R.type==="video"||R.type==="audio"){const V=R;u.value=V.trimStart,h.value=V.trimEnd}m(R,N),f.addEventListener("mousemove",T),f.addEventListener("mouseup",P)}function m(R,N){g.value=[],k.value=[];const I=e.tracks.find(W=>W.id===R.trackId);if(I)if(N==="right"){const W=new Set([R.id]);v(I.clips,R.endTime,W)}else{const W=new Set([R.id]);p(I.clips,R.startTime,W)}}function v(R,N,I){const W=R.find(z=>{if(z.type!=="transition")return!1;const Y=z,K=(Y.startTime+Y.endTime)/2;return Math.abs(K-N)=N-Y.transitionDuration});if(!W)return;g.value.push({id:W.id,type:"transition",originalStartTime:W.startTime,originalEndTime:W.endTime,duration:W.transitionDuration});const V=R.find(z=>z.type!=="transition"&&!I.has(z.id)&&Math.abs(z.startTime-N){if(z.type!=="transition")return!1;const Y=z,K=(Y.startTime+Y.endTime)/2;return Math.abs(K-N)z.type!=="transition"&&!I.has(z.id)&&Math.abs(z.endTime-N)Y.id===R.trackId);if(!I)return;const W=(R.startTime+R.endTime)/2,V=I.clips.find(Y=>Y.type!=="transition"&&Math.abs(Y.endTime-W)<.5),z=I.clips.find(Y=>Y.type!=="transition"&&Y!==V&&Math.abs(Y.startTime-W)<.5);if(V&&z){const Y=br(W-N/2),K=br(W+N/2),X=br(W),_=br(N);e.updateClip(R.id,{startTime:Y,endTime:K,transitionDuration:_}),e.updateClip(V.id,{endTime:X}),e.updateClip(z.id,{startTime:X})}}const S=de({shift:!1});function T(R){if(!r.value||!o.value)return;S.value.shift=R.shiftKey;const N=R.clientX-a.value,I=t.pixelsToTime(N);s.value==="left"?D(I):M(I)}function D(R){if(!o.value)return;let N=br(l.value+R);const I=.1,W=d.value-I;if(N=Math.max(0,Math.min(N,W)),!(k.value.length>0&&k.value[0].type==="transition")){const z=e.tracks.find(Y=>Y.id===o.value.trackId);if(z){const Y=z.clips.filter(K=>K.type!=="transition"&&K.id!==o.value.id).find(K=>K.endTime<=l.value+.01&&K.endTime>N);Y&&(N=Math.max(N,Y.endTime))}}let V=0;if(o.value.type==="video"||o.value.type==="audio"){o.value;const z=N-l.value;V=br(u.value+z),V<0&&(N=br(l.value-u.value),V=0);const Y=h.value;V>Y-I&&(V=Y-I,N=br(l.value+(V-u.value)))}if(t.snapEnabled){const z=F(N);if(z!==N&&(o.value.type==="video"||o.value.type==="audio")){const Y=z-N;V=br(V+Y),V<0&&(V=0)}N=z}o.value.type==="video"||o.value.type==="audio"?e.updateClip(o.value.id,{startTime:N,trimStart:Math.max(0,V)}):e.updateClip(o.value.id,{startTime:N}),Q(N)}function Q(R){if(k.value.length===0)return;const N=d.value-R;let I=R;for(let W=0;W0&&g.value[0].type==="transition")){const z=e.tracks.find(Y=>Y.id===o.value.trackId);if(z){const Y=z.clips.filter(K=>K.type!=="transition"&&K.id!==o.value.id).find(K=>K.startTime>=d.value-.01&&K.startTimez.originalDuration&&(V=z.originalDuration,N=br(d.value+(V-h.value)));const K=u.value;VY.originalDuration&&(V=Y.originalDuration)}N=z}if(o.value.type==="video"||o.value.type==="audio"){const z=o.value;e.updateClip(o.value.id,{endTime:N,trimEnd:Math.min(V,z.originalDuration)})}else e.updateClip(o.value.id,{endTime:N});B(N)}function B(R){if(g.value.length===0)return;const N=R-l.value;let I=R,W=N;for(let V=0;VK.id===o.value.trackId);if(!N)return R;const I=new Set;g.value.forEach(K=>I.add(K.id)),k.value.forEach(K=>I.add(K.id));const W=[],V=new Set(e.selectedClipIds);if(N.clips.forEach(K=>{K.id!==o.value.id&&!V.has(K.id)&&!I.has(K.id)&&K.type!=="transition"&&(W.push(K.startTime),W.push(K.endTime))}),W.length===0)return R;const z=t.timeToPixels(R),Y=t.snapToPosition(z,W.map(K=>t.timeToPixels(K)));return br(t.pixelsToTime(Y))}return{isResizing:r,resizingClip:o,resizingEdge:s,startResize:A,handleResizeMove:T,handleResizeEnd:P}}function MMs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Q_n={};(function(e){var t=function(){var A=new Date,m=4,v=3,p=2,b=1,O=m,w={setLogLevel:function(y){y==this.debug?O=b:y==this.info?O=p:y==this.warn?O=v:(y==this.error,O=m)},debug:function(y,C){console.debug===void 0&&(console.debug=console.log),b>=O&&console.debug("["+t.getDurationString(new Date-A,1e3)+"]","["+y+"]",C)},log:function(y,C){this.debug(y.msg)},info:function(y,C){p>=O&&console.info("["+t.getDurationString(new Date-A,1e3)+"]","["+y+"]",C)},warn:function(y,C){v>=O&&console.warn("["+t.getDurationString(new Date-A,1e3)+"]","["+y+"]",C)},error:function(y,C){m>=O&&console.error("["+t.getDurationString(new Date-A,1e3)+"]","["+y+"]",C)}};return w}();t.getDurationString=function(A,m){var v;function p(x,L){for(var S=""+x,T=S.split(".");T[0].length0){for(var v="",p=0;p0&&(v+=","),v+="["+t.getDurationString(A.start(p))+","+t.getDurationString(A.end(p))+"]";return v}else return"(empty)"},e.Log=t;var n=function(A){if(A instanceof ArrayBuffer)this.buffer=A,this.dataview=new DataView(A);else throw"Needs an array buffer";this.position=0};n.prototype.getPosition=function(){return this.position},n.prototype.getEndPosition=function(){return this.buffer.byteLength},n.prototype.getLength=function(){return this.buffer.byteLength},n.prototype.seek=function(A){var m=Math.max(0,Math.min(this.buffer.byteLength,A));return this.position=isNaN(m)||!isFinite(m)?0:m,!0},n.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},n.prototype.readAnyInt=function(A,m){var v=0;if(this.position+A<=this.buffer.byteLength){switch(A){case 1:m?v=this.dataview.getInt8(this.position):v=this.dataview.getUint8(this.position);break;case 2:m?v=this.dataview.getInt16(this.position):v=this.dataview.getUint16(this.position);break;case 3:if(m)throw"No method for reading signed 24 bits values";v=this.dataview.getUint8(this.position)<<16,v|=this.dataview.getUint8(this.position+1)<<8,v|=this.dataview.getUint8(this.position+2);break;case 4:m?v=this.dataview.getInt32(this.position):v=this.dataview.getUint32(this.position);break;case 8:if(m)throw"No method for reading signed 64 bits values";v=this.dataview.getUint32(this.position)<<32,v|=this.dataview.getUint32(this.position+4);break;default:throw"readInt method not implemented for size: "+A}return this.position+=A,v}else throw"Not enough bytes in buffer"},n.prototype.readUint8=function(){return this.readAnyInt(1,!1)},n.prototype.readUint16=function(){return this.readAnyInt(2,!1)},n.prototype.readUint24=function(){return this.readAnyInt(3,!1)},n.prototype.readUint32=function(){return this.readAnyInt(4,!1)},n.prototype.readUint64=function(){return this.readAnyInt(8,!1)},n.prototype.readString=function(A){if(this.position+A<=this.buffer.byteLength){for(var m="",v=0;vthis._byteLength&&(this._byteLength=m);return}for(v<1&&(v=1);m>v;)v*=2;var p=new ArrayBuffer(v),b=new Uint8Array(this._buffer),O=new Uint8Array(p,0,b.length);O.set(b),this.buffer=p,this._byteLength=m}},r.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var A=new ArrayBuffer(this._byteLength),m=new Uint8Array(A),v=new Uint8Array(this._buffer,0,m.length);m.set(v),this.buffer=A}},r.BIG_ENDIAN=!1,r.LITTLE_ENDIAN=!0,r.prototype._byteLength=0,Object.defineProperty(r.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(r.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(A){this._buffer=A,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(r.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(A){this._byteOffset=A,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(r.prototype,"dataView",{get:function(){return this._dataView},set:function(A){this._byteOffset=A.byteOffset,this._buffer=A.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+A.byteLength}}),r.prototype.seek=function(A){var m=Math.max(0,Math.min(this.byteLength,A));this.position=isNaN(m)||!isFinite(m)?0:m},r.prototype.isEof=function(){return this.position>=this._byteLength},r.prototype.mapUint8Array=function(A){this._realloc(A*1);var m=new Uint8Array(this._buffer,this.byteOffset+this.position,A);return this.position+=A*1,m},r.prototype.readInt32Array=function(A,m){A=A??this.byteLength-this.position/4;var v=new Int32Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readInt16Array=function(A,m){A=A??this.byteLength-this.position/2;var v=new Int16Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readInt8Array=function(A){A=A??this.byteLength-this.position;var m=new Int8Array(A);return r.memcpy(m.buffer,0,this.buffer,this.byteOffset+this.position,A*m.BYTES_PER_ELEMENT),this.position+=m.byteLength,m},r.prototype.readUint32Array=function(A,m){A=A??this.byteLength-this.position/4;var v=new Uint32Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readUint16Array=function(A,m){A=A??this.byteLength-this.position/2;var v=new Uint16Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readUint8Array=function(A){A=A??this.byteLength-this.position;var m=new Uint8Array(A);return r.memcpy(m.buffer,0,this.buffer,this.byteOffset+this.position,A*m.BYTES_PER_ELEMENT),this.position+=m.byteLength,m},r.prototype.readFloat64Array=function(A,m){A=A??this.byteLength-this.position/8;var v=new Float64Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readFloat32Array=function(A,m){A=A??this.byteLength-this.position/4;var v=new Float32Array(A);return r.memcpy(v.buffer,0,this.buffer,this.byteOffset+this.position,A*v.BYTES_PER_ELEMENT),r.arrayToNative(v,m??this.endianness),this.position+=v.byteLength,v},r.prototype.readInt32=function(A){var m=this._dataView.getInt32(this.position,A??this.endianness);return this.position+=4,m},r.prototype.readInt16=function(A){var m=this._dataView.getInt16(this.position,A??this.endianness);return this.position+=2,m},r.prototype.readInt8=function(){var A=this._dataView.getInt8(this.position);return this.position+=1,A},r.prototype.readUint32=function(A){var m=this._dataView.getUint32(this.position,A??this.endianness);return this.position+=4,m},r.prototype.readUint16=function(A){var m=this._dataView.getUint16(this.position,A??this.endianness);return this.position+=2,m},r.prototype.readUint8=function(){var A=this._dataView.getUint8(this.position);return this.position+=1,A},r.prototype.readFloat32=function(A){var m=this._dataView.getFloat32(this.position,A??this.endianness);return this.position+=4,m},r.prototype.readFloat64=function(A){var m=this._dataView.getFloat64(this.position,A??this.endianness);return this.position+=8,m},r.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,r.memcpy=function(A,m,v,p,b){var O=new Uint8Array(A,m,b),w=new Uint8Array(v,p,b);O.set(w)},r.arrayToNative=function(A,m){return m==this.endianness?A:this.flipArrayEndianness(A)},r.nativeToEndian=function(A,m){return this.endianness==m?A:this.flipArrayEndianness(A)},r.flipArrayEndianness=function(A){for(var m=new Uint8Array(A.buffer,A.byteOffset,A.byteLength),v=0;vb;p--,b++){var O=m[b];m[b]=m[p],m[p]=O}return A},r.prototype.failurePosition=0,String.fromCharCodeUint8=function(A){for(var m=[],v=0;v>16),this.writeUint8((A&65280)>>8),this.writeUint8(A&255)},r.prototype.adjustUint32=function(A,m){var v=this.position;this.seek(A),this.writeUint32(m),this.seek(v)},r.prototype.mapInt32Array=function(A,m){this._realloc(A*4);var v=new Int32Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*4,v},r.prototype.mapInt16Array=function(A,m){this._realloc(A*2);var v=new Int16Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*2,v},r.prototype.mapInt8Array=function(A){this._realloc(A*1);var m=new Int8Array(this._buffer,this.byteOffset+this.position,A);return this.position+=A*1,m},r.prototype.mapUint32Array=function(A,m){this._realloc(A*4);var v=new Uint32Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*4,v},r.prototype.mapUint16Array=function(A,m){this._realloc(A*2);var v=new Uint16Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*2,v},r.prototype.mapFloat64Array=function(A,m){this._realloc(A*8);var v=new Float64Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*8,v},r.prototype.mapFloat32Array=function(A,m){this._realloc(A*4);var v=new Float32Array(this._buffer,this.byteOffset+this.position,A);return r.arrayToNative(v,m??this.endianness),this.position+=A*4,v};var s=function(A){this.buffers=[],this.bufferIndex=-1,A&&(this.insertBuffer(A),this.bufferIndex=0)};s.prototype=new r(new ArrayBuffer,0,r.BIG_ENDIAN),s.prototype.initialized=function(){var A;return this.bufferIndex>-1?!0:this.buffers.length>0?(A=this.buffers[0],A.fileStart===0?(this.buffer=A,this.bufferIndex=0,t.debug("MultiBufferStream","Stream ready for parsing"),!0):(t.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1)):(t.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1)},ArrayBuffer.concat=function(A,m){t.debug("ArrayBuffer","Trying to create a new buffer of size: "+(A.byteLength+m.byteLength));var v=new Uint8Array(A.byteLength+m.byteLength);return v.set(new Uint8Array(A),0),v.set(new Uint8Array(m),A.byteLength),v.buffer},s.prototype.reduceBuffer=function(A,m,v){var p;return p=new Uint8Array(v),p.set(new Uint8Array(A,m,v)),p.buffer.fileStart=A.fileStart+m,p.buffer.usedBytes=0,p.buffer},s.prototype.insertBuffer=function(A){for(var m=!0,v=0;vp.byteLength){this.buffers.splice(v,1),v--;continue}else t.warn("MultiBufferStream","Buffer (fileStart: "+A.fileStart+" - Length: "+A.byteLength+") already appended, ignoring");else A.fileStart+A.byteLength<=p.fileStart||(A=this.reduceBuffer(A,0,p.fileStart-A.fileStart)),t.debug("MultiBufferStream","Appending new buffer (fileStart: "+A.fileStart+" - Length: "+A.byteLength+")"),this.buffers.splice(v,0,A),v===0&&(this.buffer=A);m=!1;break}else if(A.fileStart0)A=this.reduceBuffer(A,b,O);else{m=!1;break}}}m&&(t.debug("MultiBufferStream","Appending new buffer (fileStart: "+A.fileStart+" - Length: "+A.byteLength+")"),this.buffers.push(A),v===0&&(this.buffer=A))},s.prototype.logBufferLevel=function(A){var m,v,p,b,O=[],w,y="";for(p=0,b=0,m=0;m0&&(y+=w.end-1+"]");var C=A?t.info:t.debug;this.buffers.length===0?C("MultiBufferStream","No more buffer in memory"):C("MultiBufferStream",""+this.buffers.length+" stored buffer(s) ("+p+"/"+b+" bytes), continuous ranges: "+y)},s.prototype.cleanBuffers=function(){var A,m;for(A=0;A"+this.buffer.byteLength+")"),!0}else return!1;else return!1},s.prototype.findPosition=function(A,m,v){var p,b=null,O=-1;for(A===!0?p=0:p=this.bufferIndex;p=m?(t.debug("MultiBufferStream","Found position in existing buffer #"+O),O):-1):-1},s.prototype.findEndContiguousBuf=function(A){var m,v,p,b=A!==void 0?A:this.bufferIndex;if(v=this.buffers[b],this.buffers.length>b+1)for(m=b+1;m>3;return L===31&&x.data.length>=2&&(L=32+((x.data[0]&7)<<3)+((x.data[1]&224)>>5)),L}else return null},w.DecoderConfigDescriptor=function(y){w.Descriptor.call(this,m,y)},w.DecoderConfigDescriptor.prototype=new w.Descriptor,w.DecoderConfigDescriptor.prototype.parse=function(y){this.oti=y.readUint8(),this.streamType=y.readUint8(),this.upStream=(this.streamType>>1&1)!==0,this.streamType=this.streamType>>>2,this.bufferSize=y.readUint24(),this.maxBitrate=y.readUint32(),this.avgBitrate=y.readUint32(),this.size-=13,this.parseRemainingDescriptors(y)},w.DecoderSpecificInfo=function(y){w.Descriptor.call(this,v,y)},w.DecoderSpecificInfo.prototype=new w.Descriptor,w.SLConfigDescriptor=function(y){w.Descriptor.call(this,p,y)},w.SLConfigDescriptor.prototype=new w.Descriptor,this};e.MPEG4DescriptorParser=a;var l={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"],["grpl"],["j2kH"],["etyp",["tyco"]]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){l.FullBox.prototype=new l.Box,l.ContainerBox.prototype=new l.Box,l.SampleEntry.prototype=new l.Box,l.TrackGroupTypeBox.prototype=new l.FullBox,l.BASIC_BOXES.forEach(function(A){l.createBoxCtor(A)}),l.FULL_BOXES.forEach(function(A){l.createFullBoxCtor(A)}),l.CONTAINER_BOXES.forEach(function(A){l.createContainerBoxCtor(A[0],null,A[1])})},Box:function(A,m,v){this.type=A,this.size=m,this.uuid=v},FullBox:function(A,m,v){l.Box.call(this,A,m,v),this.flags=0,this.version=0},ContainerBox:function(A,m,v){l.Box.call(this,A,m,v),this.boxes=[]},SampleEntry:function(A,m,v,p){l.ContainerBox.call(this,A,m),this.hdr_size=v,this.start=p},SampleGroupEntry:function(A){this.grouping_type=A},TrackGroupTypeBox:function(A,m){l.FullBox.call(this,A,m)},createBoxCtor:function(A,m){l.boxCodes.push(A),l[A+"Box"]=function(v){l.Box.call(this,A,v)},l[A+"Box"].prototype=new l.Box,m&&(l[A+"Box"].prototype.parse=m)},createFullBoxCtor:function(A,m){l[A+"Box"]=function(v){l.FullBox.call(this,A,v)},l[A+"Box"].prototype=new l.FullBox,l[A+"Box"].prototype.parse=function(v){this.parseFullHeader(v),m&&m.call(this,v)}},addSubBoxArrays:function(A){if(A){this.subBoxNames=A;for(var m=A.length,v=0;vv?(t.error("BoxParser","Box of type '"+x+"' has a size "+C+" greater than its container size "+v),{code:l.ERR_NOT_ENOUGH_DATA,type:x,size:C,hdr_size:O,start:b}):C!==0&&b+C>A.getEndPosition()?(A.seek(b),t.info("BoxParser","Not enough data in stream to parse the entire '"+x+"' box"),{code:l.ERR_NOT_ENOUGH_DATA,type:x,size:C,hdr_size:O,start:b}):m?{code:l.OK,type:x,size:C,hdr_size:O,start:b}:(l[x+"Box"]?p=new l[x+"Box"](C):x!=="uuid"?(t.warn("BoxParser","Unknown box type: '"+x+"'"),p=new l.Box(x,C),p.has_unparsed_data=!0):l.UUIDBoxes[y]?p=new l.UUIDBoxes[y](C):(t.warn("BoxParser","Unknown uuid type: '"+y+"'"),p=new l.Box(x,C),p.uuid=y,p.has_unparsed_data=!0),p.hdr_size=O,p.start=b,p.write===l.Box.prototype.write&&p.type!=="mdat"&&(t.info("BoxParser","'"+L+"' box writing not yet implemented, keeping unparsed data in memory for later write"),p.parseDataAndRewind(A)),p.parse(A),w=A.getPosition()-(p.start+p.size),w<0?(t.warn("BoxParser","Parsing of box '"+L+"' did not read the entire indicated box data size (missing "+-w+" bytes), seeking forward"),A.seek(p.start+p.size)):w>0&&(t.error("BoxParser","Parsing of box '"+L+"' read "+w+" more bytes than the indicated box data size, seeking backwards"),p.size!==0&&A.seek(p.start+p.size)),{code:l.OK,box:p,size:p.size})},l.Box.prototype.parse=function(A){this.type!="mdat"?this.data=A.readUint8Array(this.size-this.hdr_size):this.size===0?A.seek(A.getEndPosition()):A.seek(this.start+this.size)},l.Box.prototype.parseDataAndRewind=function(A){this.data=A.readUint8Array(this.size-this.hdr_size),A.position-=this.size-this.hdr_size},l.FullBox.prototype.parseDataAndRewind=function(A){this.parseFullHeader(A),this.data=A.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,A.position-=this.size-this.hdr_size},l.FullBox.prototype.parseFullHeader=function(A){this.version=A.readUint8(),this.flags=A.readUint24(),this.hdr_size+=4},l.FullBox.prototype.parse=function(A){this.parseFullHeader(A),this.data=A.readUint8Array(this.size-this.hdr_size)},l.ContainerBox.prototype.parse=function(A){for(var m,v;A.getPosition()>10&31,m[1]=this.language>>5&31,m[2]=this.language&31,this.languageString=String.fromCharCode(m[0]+96,m[1]+96,m[2]+96)},l.SAMPLE_ENTRY_TYPE_VISUAL="Visual",l.SAMPLE_ENTRY_TYPE_AUDIO="Audio",l.SAMPLE_ENTRY_TYPE_HINT="Hint",l.SAMPLE_ENTRY_TYPE_METADATA="Metadata",l.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle",l.SAMPLE_ENTRY_TYPE_SYSTEM="System",l.SAMPLE_ENTRY_TYPE_TEXT="Text",l.SampleEntry.prototype.parseHeader=function(A){A.readUint8Array(6),this.data_reference_index=A.readUint16(),this.hdr_size+=8},l.SampleEntry.prototype.parse=function(A){this.parseHeader(A),this.data=A.readUint8Array(this.size-this.hdr_size)},l.SampleEntry.prototype.parseDataAndRewind=function(A){this.parseHeader(A),this.data=A.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,A.position-=this.size-this.hdr_size},l.SampleEntry.prototype.parseFooter=function(A){l.ContainerBox.prototype.parse.call(this,A)},l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_HINT),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_METADATA),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_SUBTITLE),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_SYSTEM),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_TEXT),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,function(A){var m;this.parseHeader(A),A.readUint16(),A.readUint16(),A.readUint32Array(3),this.width=A.readUint16(),this.height=A.readUint16(),this.horizresolution=A.readUint32(),this.vertresolution=A.readUint32(),A.readUint32(),this.frame_count=A.readUint16(),m=Math.min(31,A.readUint8()),this.compressorname=A.readString(m),m<31&&A.readString(31-m),this.depth=A.readUint16(),A.readUint16(),this.parseFooter(A)}),l.createMediaSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,function(A){this.parseHeader(A),A.readUint32Array(2),this.channel_count=A.readUint16(),this.samplesize=A.readUint16(),A.readUint16(),A.readUint16(),this.samplerate=A.readUint32()/65536,this.parseFooter(A)}),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avc1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avc2"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avc3"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avc4"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"av01"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"dav1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"hev1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"hvt1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"lhe1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"dvh1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"dvhe"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vvc1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vvi1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vvs1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vvcN"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vp08"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"vp09"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"avs3"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"j2ki"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"mjp2"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"mjpg"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"uncv"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"ac-4"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"Opus"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mha1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mha2"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mhm1"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"mhm2"),l.createSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"fLaC"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_VISUAL,"encv"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_AUDIO,"enca"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_SYSTEM,"encs"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_TEXT,"enct"),l.createEncryptedSampleEntryCtor(l.SAMPLE_ENTRY_TYPE_METADATA,"encm"),l.createBoxCtor("a1lx",function(A){var m=A.readUint8()&1,v=((m&1)+1)*16;this.layer_size=[];for(var p=0;p<3;p++)v==16?this.layer_size[p]=A.readUint16():this.layer_size[p]=A.readUint32()}),l.createBoxCtor("a1op",function(A){this.op_index=A.readUint8()}),l.createFullBoxCtor("auxC",function(A){this.aux_type=A.readCString();var m=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=A.readUint8Array(m)}),l.createBoxCtor("av1C",function(A){var m=A.readUint8();if(m>>7&!1){t.error("av1C marker problem");return}if(this.version=m&127,this.version!==1){t.error("av1C version "+this.version+" not supported");return}if(m=A.readUint8(),this.seq_profile=m>>5&7,this.seq_level_idx_0=m&31,m=A.readUint8(),this.seq_tier_0=m>>7&1,this.high_bitdepth=m>>6&1,this.twelve_bit=m>>5&1,this.monochrome=m>>4&1,this.chroma_subsampling_x=m>>3&1,this.chroma_subsampling_y=m>>2&1,this.chroma_sample_position=m&3,m=A.readUint8(),this.reserved_1=m>>5&7,this.reserved_1!==0){t.error("av1C reserved_1 parsing problem");return}if(this.initial_presentation_delay_present=m>>4&1,this.initial_presentation_delay_present===1)this.initial_presentation_delay_minus_one=m&15;else if(this.reserved_2=m&15,this.reserved_2!==0){t.error("av1C reserved_2 parsing problem");return}var v=this.size-this.hdr_size-4;this.configOBUs=A.readUint8Array(v)}),l.createBoxCtor("avcC",function(A){var m,v;for(this.configurationVersion=A.readUint8(),this.AVCProfileIndication=A.readUint8(),this.profile_compatibility=A.readUint8(),this.AVCLevelIndication=A.readUint8(),this.lengthSizeMinusOne=A.readUint8()&3,this.nb_SPS_nalus=A.readUint8()&31,v=this.size-this.hdr_size-6,this.SPS=[],m=0;m0&&(this.ext=A.readUint8Array(v))}),l.createBoxCtor("btrt",function(A){this.bufferSizeDB=A.readUint32(),this.maxBitrate=A.readUint32(),this.avgBitrate=A.readUint32()}),l.createFullBoxCtor("ccst",function(A){var m=A.readUint8();this.all_ref_pics_intra=(m&128)==128,this.intra_pred_used=(m&64)==64,this.max_ref_per_pic=(m&63)>>2,A.readUint24()}),l.createBoxCtor("cdef",function(A){var m;for(this.channel_count=A.readUint16(),this.channel_indexes=[],this.channel_types=[],this.channel_associations=[],m=0;m=32768&&this.component_type_urls.push(A.readCString())}}),l.createFullBoxCtor("co64",function(A){var m,v;if(m=A.readUint32(),this.chunk_offsets=[],this.version===0)for(v=0;v>7}else this.colour_type==="rICC"?this.ICC_profile=A.readUint8Array(this.size-4):this.colour_type==="prof"&&(this.ICC_profile=A.readUint8Array(this.size-4))}),l.createFullBoxCtor("cprt",function(A){this.parseLanguage(A),this.notice=A.readCString()}),l.createFullBoxCtor("cslg",function(A){this.version===0&&(this.compositionToDTSShift=A.readInt32(),this.leastDecodeToDisplayDelta=A.readInt32(),this.greatestDecodeToDisplayDelta=A.readInt32(),this.compositionStartTime=A.readInt32(),this.compositionEndTime=A.readInt32())}),l.createFullBoxCtor("ctts",function(A){var m,v;if(m=A.readUint32(),this.sample_counts=[],this.sample_offsets=[],this.version===0)for(v=0;v>6,this.bsid=m>>1&31,this.bsmod=(m&1)<<2|v>>6&3,this.acmod=v>>3&7,this.lfeon=v>>2&1,this.bit_rate_code=v&3|p>>5&7}),l.createBoxCtor("dec3",function(A){var m=A.readUint16();this.data_rate=m>>3,this.num_ind_sub=m&7,this.ind_subs=[];for(var v=0;v>6,p.bsid=b>>1&31,p.bsmod=(b&1)<<4|O>>4&15,p.acmod=O>>1&7,p.lfeon=O&1,p.num_dep_sub=w>>1&15,p.num_dep_sub>0&&(p.chan_loc=(w&1)<<8|A.readUint8())}}),l.createFullBoxCtor("dfLa",function(A){var m=127,v=128,p=[],b=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];do{var O=A.readUint8(),w=Math.min(O&m,b.length-1);if(w?A.readUint8Array(A.readUint24()):(A.readUint8Array(13),this.samplerate=A.readUint32()>>12,A.readUint8Array(20)),p.push(b[w]),O&v)break}while(!0);this.numMetadataBlocks=p.length+" ("+p.join(", ")+")"}),l.createBoxCtor("dimm",function(A){this.bytessent=A.readUint64()}),l.createBoxCtor("dmax",function(A){this.time=A.readUint32()}),l.createBoxCtor("dmed",function(A){this.bytessent=A.readUint64()}),l.createBoxCtor("dOps",function(A){if(this.Version=A.readUint8(),this.OutputChannelCount=A.readUint8(),this.PreSkip=A.readUint16(),this.InputSampleRate=A.readUint32(),this.OutputGain=A.readInt16(),this.ChannelMappingFamily=A.readUint8(),this.ChannelMappingFamily!==0){this.StreamCount=A.readUint8(),this.CoupledCount=A.readUint8(),this.ChannelMapping=[];for(var m=0;m=4;)this.compatible_brands[v]=A.readString(4),m-=4,v++}),l.createFullBoxCtor("hdlr",function(A){this.version===0&&(A.readUint32(),this.handler=A.readString(4),A.readUint32Array(3),this.name=A.readString(this.size-this.hdr_size-20),this.name[this.name.length-1]==="\0"&&(this.name=this.name.slice(0,-1)))}),l.createBoxCtor("hvcC",function(A){var m,v,p,b;this.configurationVersion=A.readUint8(),b=A.readUint8(),this.general_profile_space=b>>6,this.general_tier_flag=(b&32)>>5,this.general_profile_idc=b&31,this.general_profile_compatibility=A.readUint32(),this.general_constraint_indicator=A.readUint8Array(6),this.general_level_idc=A.readUint8(),this.min_spatial_segmentation_idc=A.readUint16()&4095,this.parallelismType=A.readUint8()&3,this.chroma_format_idc=A.readUint8()&3,this.bit_depth_luma_minus8=A.readUint8()&7,this.bit_depth_chroma_minus8=A.readUint8()&7,this.avgFrameRate=A.readUint16(),b=A.readUint8(),this.constantFrameRate=b>>6,this.numTemporalLayers=(b&13)>>3,this.temporalIdNested=(b&4)>>2,this.lengthSizeMinusOne=b&3,this.nalu_arrays=[];var O=A.readUint8();for(m=0;m>7,w.nalu_type=b&63;var y=A.readUint16();for(v=0;v>4&15,this.length_size=m&15,m=A.readUint8(),this.base_offset_size=m>>4&15,this.version===1||this.version===2?this.index_size=m&15:this.index_size=0,this.items=[];var v=0;if(this.version<2)v=A.readUint16();else if(this.version===2)v=A.readUint32();else throw"version of iloc box not supported";for(var p=0;p>7,this.axis=m&1}),l.createFullBoxCtor("infe",function(A){if((this.version===0||this.version===1)&&(this.item_ID=A.readUint16(),this.item_protection_index=A.readUint16(),this.item_name=A.readCString(),this.content_type=A.readCString(),this.content_encoding=A.readCString()),this.version===1){this.extension_type=A.readString(4),t.warn("BoxParser","Cannot parse extension type"),A.seek(this.start+this.size);return}this.version>=2&&(this.version===2?this.item_ID=A.readUint16():this.version===3&&(this.item_ID=A.readUint32()),this.item_protection_index=A.readUint16(),this.item_type=A.readString(4),this.item_name=A.readCString(),this.item_type==="mime"?(this.content_type=A.readCString(),this.content_encoding=A.readCString()):this.item_type==="uri "&&(this.item_uri_type=A.readCString()))}),l.createFullBoxCtor("ipma",function(A){var m,v;for(entry_count=A.readUint32(),this.associations=[],m=0;m>7===1,this.flags&1?w.property_index=(O&127)<<8|A.readUint8():w.property_index=O&127}}}),l.createFullBoxCtor("iref",function(A){var m,v;for(this.references=[];A.getPosition()>7,p.assignment_type=b&127,p.assignment_type){case 0:p.grouping_type=A.readString(4);break;case 1:p.grouping_type=A.readString(4),p.grouping_type_parameter=A.readUint32();break;case 2:break;case 3:break;case 4:p.sub_track_id=A.readUint32();break;default:t.warn("BoxParser","Unknown leva assignement type")}}}),l.createBoxCtor("lhvC",function(A){var m,v,p;this.configurationVersion=A.readUint8(),this.min_spatial_segmentation_idc=A.readUint16()&4095,this.parallelismType=A.readUint8()&3,p=A.readUint8(),this.numTemporalLayers=(p&13)>>3,this.temporalIdNested=(p&4)>>2,this.lengthSizeMinusOne=p&3,this.nalu_arrays=[];var b=A.readUint8();for(m=0;m>7,O.nalu_type=p&63;var w=A.readUint16();for(v=0;v>8,A.readUint16(),A.readUint32Array(2),this.matrix=A.readUint32Array(9),A.readUint32Array(6),this.next_track_id=A.readUint32()}),l.createBoxCtor("npck",function(A){this.packetssent=A.readUint32()}),l.createBoxCtor("nump",function(A){this.packetssent=A.readUint64()}),l.createFullBoxCtor("padb",function(A){var m=A.readUint32();this.padbits=[];for(var v=0;v0){var m=A.readUint32();this.kid=[];for(var v=0;v0&&(this.data=A.readUint8Array(p))}),l.createFullBoxCtor("clef",function(A){this.width=A.readUint32(),this.height=A.readUint32()}),l.createFullBoxCtor("enof",function(A){this.width=A.readUint32(),this.height=A.readUint32()}),l.createFullBoxCtor("prof",function(A){this.width=A.readUint32(),this.height=A.readUint32()}),l.createContainerBoxCtor("tapt",null,["clef","prof","enof"]),l.createBoxCtor("rtp ",function(A){this.descriptionformat=A.readString(4),this.sdptext=A.readString(this.size-this.hdr_size-4)}),l.createFullBoxCtor("saio",function(A){this.flags&1&&(this.aux_info_type=A.readUint32(),this.aux_info_type_parameter=A.readUint32());var m=A.readUint32();this.offset=[];for(var v=0;v>7,this.avgRateFlag=m>>6&1,this.durationFlag&&(this.duration=A.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=A.readUint8(),this.avgBitRate=A.readUint16(),this.avgFrameRate=A.readUint16()),this.dependency=[];for(var v=A.readUint8(),p=0;p>7,this.num_leading_samples=m&127}),l.createSampleGroupCtor("rash",function(A){if(this.operation_point_count=A.readUint16(),this.description_length!==2+(this.operation_point_count===1?2:this.operation_point_count*6)+9)t.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=A.readUint8Array(this.description_length-2);else{if(this.operation_point_count===1)this.target_rate_share=A.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(var m=0;m>4,this.skip_byte_block=m&15,this.isProtected=A.readUint8(),this.Per_Sample_IV_Size=A.readUint8(),this.KID=l.parseHex16(A),this.constant_IV_size=0,this.constant_IV=0,this.isProtected===1&&this.Per_Sample_IV_Size===0&&(this.constant_IV_size=A.readUint8(),this.constant_IV=A.readUint8Array(this.constant_IV_size))}),l.createSampleGroupCtor("stsa",function(A){t.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),l.createSampleGroupCtor("sync",function(A){var m=A.readUint8();this.NAL_unit_type=m&63}),l.createSampleGroupCtor("tele",function(A){var m=A.readUint8();this.level_independently_decodable=m>>7}),l.createSampleGroupCtor("tsas",function(A){t.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),l.createSampleGroupCtor("tscl",function(A){t.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),l.createSampleGroupCtor("vipr",function(A){t.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),l.createFullBoxCtor("sbgp",function(A){this.grouping_type=A.readString(4),this.version===1?this.grouping_type_parameter=A.readUint32():this.grouping_type_parameter=0,this.entries=[];for(var m=A.readUint32(),v=0;v>6,this.sample_depends_on[p]=m>>4&3,this.sample_is_depended_on[p]=m>>2&3,this.sample_has_redundancy[p]=m&3}),l.createFullBoxCtor("senc"),l.createFullBoxCtor("sgpd",function(A){this.grouping_type=A.readString(4),t.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),this.version===1?this.default_length=A.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=A.readUint32()),this.entries=[];for(var m=A.readUint32(),v=0;v>31&1,p.referenced_size=b&2147483647,p.subsegment_duration=A.readUint32(),b=A.readUint32(),p.starts_with_SAP=b>>31&1,p.SAP_type=b>>28&7,p.SAP_delta_time=b&268435455}}),l.SingleItemTypeReferenceBox=function(A,m,v,p){l.Box.call(this,A,m),this.hdr_size=v,this.start=p},l.SingleItemTypeReferenceBox.prototype=new l.Box,l.SingleItemTypeReferenceBox.prototype.parse=function(A){this.from_item_ID=A.readUint16();var m=A.readUint16();this.references=[];for(var v=0;v>4&15,this.sample_sizes[m+1]=p&15}else if(this.field_size===8)for(m=0;m0)for(v=0;v>4&15,this.default_skip_byte_block=m&15}this.default_isProtected=A.readUint8(),this.default_Per_Sample_IV_Size=A.readUint8(),this.default_KID=l.parseHex16(A),this.default_isProtected===1&&this.default_Per_Sample_IV_Size===0&&(this.default_constant_IV_size=A.readUint8(),this.default_constant_IV=A.readUint8Array(this.default_constant_IV_size))}),l.createFullBoxCtor("tfdt",function(A){this.version==1?this.baseMediaDecodeTime=A.readUint64():this.baseMediaDecodeTime=A.readUint32()}),l.createFullBoxCtor("tfhd",function(A){var m=0;this.track_id=A.readUint32(),this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=A.readUint64(),m+=8):this.base_data_offset=0,this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=A.readUint32(),m+=4):this.default_sample_description_index=0,this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=A.readUint32(),m+=4):this.default_sample_duration=0,this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=A.readUint32(),m+=4):this.default_sample_size=0,this.size-this.hdr_size>m&&this.flags&l.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=A.readUint32(),m+=4):this.default_sample_flags=0}),l.createFullBoxCtor("tfra",function(A){this.track_ID=A.readUint32(),A.readUint24();var m=A.readUint8();this.length_size_of_traf_num=m>>4&3,this.length_size_of_trun_num=m>>2&3,this.length_size_of_sample_num=m&3,this.entries=[];for(var v=A.readUint32(),p=0;p>8,A.readUint16(),this.matrix=A.readInt32Array(9),this.width=A.readUint32(),this.height=A.readUint32()}),l.createBoxCtor("tmax",function(A){this.time=A.readUint32()}),l.createBoxCtor("tmin",function(A){this.time=A.readUint32()}),l.createBoxCtor("totl",function(A){this.bytessent=A.readUint32()}),l.createBoxCtor("tpay",function(A){this.bytessent=A.readUint32()}),l.createBoxCtor("tpyl",function(A){this.bytessent=A.readUint64()}),l.TrackGroupTypeBox.prototype.parse=function(A){this.parseFullHeader(A),this.track_group_id=A.readUint32()},l.createTrackGroupCtor("msrc"),l.TrackReferenceTypeBox=function(A,m,v,p){l.Box.call(this,A,m),this.hdr_size=v,this.start=p},l.TrackReferenceTypeBox.prototype=new l.Box,l.TrackReferenceTypeBox.prototype.parse=function(A){this.track_ids=A.readUint32Array((this.size-this.hdr_size)/4)},l.trefBox.prototype.parse=function(A){for(var m,v;A.getPosition()m&&this.flags&l.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=A.readInt32(),m+=4):this.data_offset=0,this.size-this.hdr_size>m&&this.flags&l.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=A.readUint32(),m+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>m)for(var v=0;v>7&1,this.block_pad_lsb=v>>6&1,this.block_little_endian=v>>5&1,this.block_reversed=v>>4&1,this.pad_unknown=v>>3&1,this.pixel_size=A.readUint32(),this.row_align_size=A.readUint32(),this.tile_align_size=A.readUint32(),this.num_tile_cols_minus_one=A.readUint32(),this.num_tile_rows_minus_one=A.readUint32()}}),l.createFullBoxCtor("url ",function(A){this.flags!==1&&(this.location=A.readCString())}),l.createFullBoxCtor("urn ",function(A){this.name=A.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=A.readCString())}),l.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66",!0,!1,function(A){this.LiveServerManifest=A.readString(this.size-this.hdr_size).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}),l.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,function(A){this.system_id=l.parseHex16(A);var m=A.readUint32();m>0&&(this.data=A.readUint8Array(m))}),l.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1),l.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,function(A){this.default_AlgorithmID=A.readUint24(),this.default_IV_size=A.readUint8(),this.default_KID=l.parseHex16(A)}),l.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,function(A){this.fragment_count=A.readUint8(),this.entries=[];for(var m=0;m>4,this.chromaSubsampling=m>>1&7,this.videoFullRangeFlag=m&1,this.colourPrimaries=A.readUint8(),this.transferCharacteristics=A.readUint8(),this.matrixCoefficients=A.readUint8(),this.codecIntializationDataSize=A.readUint16(),this.codecIntializationData=A.readUint8Array(this.codecIntializationDataSize)):(this.profile=A.readUint8(),this.level=A.readUint8(),m=A.readUint8(),this.bitDepth=m>>4&15,this.colorSpace=m&15,m=A.readUint8(),this.chromaSubsampling=m>>4&15,this.transferFunction=m>>1&7,this.videoFullRangeFlag=m&1,this.codecIntializationDataSize=A.readUint16(),this.codecIntializationData=A.readUint8Array(this.codecIntializationDataSize))}),l.createBoxCtor("vttC",function(A){this.text=A.readString(this.size-this.hdr_size)}),l.createFullBoxCtor("vvcC",function(A){var m,v,p={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(D){this.held_bits=D.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(D){this.held_bits=D.readUint16(),this.num_held_bits=16},extract_bits:function(D){var Q=this.held_bits>>this.num_held_bits-D&(1<1){for(p.stream_read_1_bytes(A),this.ptl_sublayer_present_mask=0,v=this.num_sublayers-2;v>=0;--v){var w=p.extract_bits(1);this.ptl_sublayer_present_mask|=w<1;++v)p.extract_bits(1);for(this.sublayer_level_idc=[],v=this.num_sublayers-2;v>=0;--v)this.ptl_sublayer_present_mask&1<"u"||m===null?m=2:m;v.length>=1;m+=l.decimalToHex(p,0),m+=".",this.hvcC.general_tier_flag===0?m+="L":m+="H",m+=this.hvcC.general_level_idc;var b=!1,O="";for(A=5;A>=0;A--)(this.hvcC.general_constraint_indicator[A]||b)&&(O="."+l.decimalToHex(this.hvcC.general_constraint_indicator[A],0)+O,b=!0);m+=O}return m},l.vvc1SampleEntry.prototype.getCodec=l.vvi1SampleEntry.prototype.getCodec=function(){var A,m=l.SampleEntry.prototype.getCodec.call(this);if(this.vvcC){m+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?m+=".H":m+=".L",m+=this.vvcC.general_level_idc;var v="";if(this.vvcC.general_constraint_info){var p=[],b=0;b|=this.vvcC.ptl_frame_only_constraint<<7,b|=this.vvcC.ptl_multilayer_enabled<<6;var O;for(A=0;A>2&63,p.push(b),b&&(O=A),b=this.vvcC.general_constraint_info[A]>>2&3;if(O===void 0)v=".CA";else{v=".C";var w="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",y=0,C=0;for(A=0;A<=O;++A)for(y=y<<8|p[A],C+=8;C>=5;){var x=y>>C-5&31;v+=w[x],C-=5,y&=(1<o&&(this.size+=8),this.type==="uuid"&&(this.size+=16),t.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+A.getPosition()+(m||"")),this.size>o?A.writeUint32(1):(this.sizePosition=A.getPosition(),A.writeUint32(this.size)),A.writeString(this.type,null,4),this.type==="uuid"&&A.writeUint8Array(this.uuid),this.size>o&&A.writeUint64(this.size)},l.FullBox.prototype.writeHeader=function(A){this.size+=4,l.Box.prototype.writeHeader.call(this,A," v="+this.version+" f="+this.flags),A.writeUint8(this.version),A.writeUint24(this.flags)},l.Box.prototype.write=function(A){this.type==="mdat"?this.data&&(this.size=this.data.length,this.writeHeader(A),A.writeUint8Array(this.data)):(this.size=this.data?this.data.length:0,this.writeHeader(A),this.data&&A.writeUint8Array(this.data))},l.ContainerBox.prototype.write=function(A){this.size=0,this.writeHeader(A);for(var m=0;m=2&&A.writeUint32(this.default_sample_description_index),A.writeUint32(this.entries.length),m=0;m0)for(m=0;m+1m?1:0,this.flags=0,this.size=4,this.version===1&&(this.size+=4),this.writeHeader(A),this.version===1?A.writeUint64(this.baseMediaDecodeTime):A.writeUint32(this.baseMediaDecodeTime)},l.tfhdBox.prototype.write=function(A){this.version=0,this.size=4,this.flags&l.TFHD_FLAG_BASE_DATA_OFFSET&&(this.size+=8),this.flags&l.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&l.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&l.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&l.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(A),A.writeUint32(this.track_id),this.flags&l.TFHD_FLAG_BASE_DATA_OFFSET&&A.writeUint64(this.base_data_offset),this.flags&l.TFHD_FLAG_SAMPLE_DESC&&A.writeUint32(this.default_sample_description_index),this.flags&l.TFHD_FLAG_SAMPLE_DUR&&A.writeUint32(this.default_sample_duration),this.flags&l.TFHD_FLAG_SAMPLE_SIZE&&A.writeUint32(this.default_sample_size),this.flags&l.TFHD_FLAG_SAMPLE_FLAGS&&A.writeUint32(this.default_sample_flags)},l.tkhdBox.prototype.write=function(A){this.version=0,this.size=4*18+2*4,this.writeHeader(A),A.writeUint32(this.creation_time),A.writeUint32(this.modification_time),A.writeUint32(this.track_id),A.writeUint32(0),A.writeUint32(this.duration),A.writeUint32(0),A.writeUint32(0),A.writeInt16(this.layer),A.writeInt16(this.alternate_group),A.writeInt16(this.volume<<8),A.writeUint16(0),A.writeInt32Array(this.matrix),A.writeUint32(this.width),A.writeUint32(this.height)},l.trexBox.prototype.write=function(A){this.version=0,this.flags=0,this.size=4*5,this.writeHeader(A),A.writeUint32(this.track_id),A.writeUint32(this.default_sample_description_index),A.writeUint32(this.default_sample_duration),A.writeUint32(this.default_sample_size),A.writeUint32(this.default_sample_flags)},l.trunBox.prototype.write=function(A){this.version=0,this.size=4,this.flags&l.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&l.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&l.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&l.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&l.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&l.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(A),A.writeUint32(this.sample_count),this.flags&l.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=A.getPosition(),A.writeInt32(this.data_offset)),this.flags&l.TRUN_FLAGS_FIRST_FLAG&&A.writeUint32(this.first_sample_flags);for(var m=0;m0&&A.writeUint8Array(this.codecIntializationData)},l.cttsBox.prototype.unpack=function(A){var m,v,p;for(p=0,m=0;m-1)){if(A[v]instanceof l.Box||m[v]instanceof l.Box||typeof A[v]>"u"||typeof m[v]>"u"||typeof A[v]=="function"||typeof m[v]=="function"||A.subBoxNames&&A.subBoxNames.indexOf(v.slice(0,4))>-1||m.subBoxNames&&m.subBoxNames.indexOf(v.slice(0,4))>-1||v==="data"||v==="start"||v==="size"||v==="creation_time"||v==="modification_time"||l.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(v)>-1)continue;if(A[v]!==m[v])return!1}return!0},l.boxEqual=function(A,m){if(!l.boxEqualFields(A,m))return!1;for(var v=0;v1)for(v=1;v-1&&this.fragmentedTracks.splice(m,1)},g.prototype.setExtractionOptions=function(A,m,v){var p=this.getTrackById(A);if(p){var b={};this.extractedTracks.push(b),b.id=A,b.user=m,b.trak=p,p.nextSample=0,b.nb_samples=1e3,b.samples=[],v&&v.nbSamples&&(b.nb_samples=v.nbSamples)}},g.prototype.unsetExtractionOptions=function(A){for(var m=-1,v=0;v-1&&this.extractedTracks.splice(m,1)},g.prototype.parse=function(){var A,m,v=!1;if(!(this.restoreParsePosition&&!this.restoreParsePosition()))for(;;)if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}else if(this.saveParsePosition&&this.saveParsePosition(),A=l.parseOneBox(this.stream,v),A.code===l.ERR_NOT_ENOUGH_DATA)if(this.processIncompleteBox){if(this.processIncompleteBox(A))continue;return}else return;else{var p;switch(m=A.box,p=m.type!=="uuid"?m.type:m.uuid,this.boxes.push(m),p){case"mdat":this.mdats.push(m);break;case"moof":this.moofs.push(m);break;case"moov":this.moovStartFound=!0,this.mdats.length===0&&(this.isProgressive=!0);default:this[p]!==void 0&&t.warn("ISOFile","Duplicate Box of type: "+p+", overriding previous occurrence"),this[p]=m;break}this.updateUsedBytes&&this.updateUsedBytes(m,A)}},g.prototype.checkBuffer=function(A){if(A==null)throw"Buffer must be defined and non empty";if(A.fileStart===void 0)throw"Buffer must have a fileStart property";return A.byteLength===0?(t.warn("ISOFile","Ignoring empty buffer (fileStart: "+A.fileStart+")"),this.stream.logBufferLevel(),!1):(t.info("ISOFile","Processing buffer (fileStart: "+A.fileStart+")"),A.usedBytes=0,this.stream.insertBuffer(A),this.stream.logBufferLevel(),this.stream.initialized()?!0:(t.warn("ISOFile","Not ready to start parsing"),!1))},g.prototype.appendBuffer=function(A,m){var v;if(this.checkBuffer(A))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(m),this.nextSeekPosition?(v=this.nextSeekPosition,this.nextSeekPosition=void 0):v=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(v=this.stream.getEndFilePositionAfter(v))):this.nextParsePosition?v=this.nextParsePosition:v=0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(t.info("ISOFile","Done processing buffer (fileStart: "+A.fileStart+") - next buffer to fetch should have a fileStart position of "+v),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),t.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),v},g.prototype.getInfo=function(){var A,m,v={},p,b,O,w,y=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(v.hasMoov=!0,v.duration=this.moov.mvhd.duration,v.timescale=this.moov.mvhd.timescale,v.isFragmented=this.moov.mvex!=null,v.isFragmented&&this.moov.mvex.mehd&&(v.fragment_duration=this.moov.mvex.mehd.fragment_duration),v.isProgressive=this.isProgressive,v.hasIOD=this.moov.iods!=null,v.brands=[],v.brands.push(this.ftyp.major_brand),v.brands=v.brands.concat(this.ftyp.compatible_brands),v.created=new Date(y+this.moov.mvhd.creation_time*1e3),v.modified=new Date(y+this.moov.mvhd.modification_time*1e3),v.tracks=[],v.audioTracks=[],v.videoTracks=[],v.subtitleTracks=[],v.metadataTracks=[],v.hintTracks=[],v.otherTracks=[],A=0;A0?v.mime+='video/mp4; codecs="':v.audioTracks&&v.audioTracks.length>0?v.mime+='audio/mp4; codecs="':v.mime+='application/mp4; codecs="',A=0;A=v.samples.length)&&(t.info("ISOFile","Sending fragmented data on track #"+p.id+" for samples ["+Math.max(0,v.nextSample-p.nb_samples)+","+(v.nextSample-1)+"]"),t.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(p.id,p.user,p.segmentStream.buffer,v.nextSample,A||v.nextSample>=v.samples.length),p.segmentStream=null,p!==this.fragmentedTracks[m]))break}}if(this.onSamples!==null)for(m=0;m=v.samples.length)&&(t.debug("ISOFile","Sending samples on track #"+O.id+" for sample "+v.nextSample),this.onSamples&&this.onSamples(O.id,O.user,O.samples),O.samples=[],O!==this.extractedTracks[m]))break}}}},g.prototype.getBox=function(A){var m=this.getBoxes(A,!0);return m.length?m[0]:null},g.prototype.getBoxes=function(A,m){var v=[];return g._sweep.call(this,A,v,m),v},g._sweep=function(A,m,v){this.type&&this.type==A&&m.push(this);for(var p in this.boxes){if(m.length&&v)return;g._sweep.call(this.boxes[p],A,m,v)}},g.prototype.getTrackSamplesInfo=function(A){var m=this.getTrackById(A);if(m)return m.samples},g.prototype.getTrackSample=function(A,m){var v=this.getTrackById(A),p=this.getSample(v,m);return p},g.prototype.releaseUsedSamples=function(A,m){var v=0,p=this.getTrackById(A);p.lastValidSample||(p.lastValidSample=0);for(var b=p.lastValidSample;bA*b.timescale){y=p-1;break}m&&b.is_sync&&(w=p)}for(m&&(y=w),A=v.samples[y].cts,v.nextSample=y;v.samples[y].alreadyRead===v.samples[y].size&&v.samples[y+1];)y++;return O=v.samples[y].offset+v.samples[y].alreadyRead,t.info("ISOFile","Seeking to "+(m?"RAP":"")+" sample #"+v.nextSample+" on track "+v.tkhd.track_id+", time "+t.getDurationString(A,C)+" and offset: "+O),{offset:O,time:A/C}},g.prototype.getTrackDuration=function(A){var m;return A.samples?(m=A.samples[A.samples.length-1],(m.cts+m.duration)/m.timescale):1/0},g.prototype.seek=function(A,m){var v=this.moov,p,b,O,w={offset:1/0,time:1/0};if(this.moov){for(O=0;Othis.getTrackDuration(p))&&(b=this.seekTrack(A,m,p),b.offset-1){w=y;break}switch(w){case"Visual":if(b.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),O.set("width",m.width).set("height",m.height).set("horizresolution",72<<16).set("vertresolution",72<<16).set("frame_count",1).set("compressorname",m.type+" Compressor").set("depth",24),m.avcDecoderConfigRecord){var L=new l.avcCBox;L.parse(new n(m.avcDecoderConfigRecord)),O.addBox(L)}else if(m.hevcDecoderConfigRecord){var S=new l.hvcCBox;S.parse(new n(m.hevcDecoderConfigRecord)),O.addBox(S)}else if(m.vpcDecoderConfigRecord){var T=new l.vpcCBox;T.parse(new n(m.vpcDecoderConfigRecord)),O.addBox(T)}break;case"Audio":b.add("smhd").set("balance",m.balance||0),O.set("channel_count",m.channel_count||2).set("samplesize",m.samplesize||16).set("samplerate",m.samplerate||65536);break;case"Hint":b.add("hmhd");break;case"Subtitle":switch(b.add("sthd"),m.type){case"stpp":O.set("namespace",m.namespace||"nonamespace").set("schema_location",m.schema_location||"").set("auxiliary_mime_types",m.auxiliary_mime_types||"");break}break;case"Metadata":b.add("nmhd");break;case"System":b.add("nmhd");break;default:b.add("nmhd");break}m.description&&O.addBox(m.description),m.description_boxes&&m.description_boxes.forEach(function(Q){O.addBox(Q)}),b.add("dinf").add("dref").addEntry(new l["url Box"]().set("flags",1));var D=b.add("stbl");return D.add("stsd").addEntry(O),D.add("stts").set("sample_counts",[]).set("sample_deltas",[]),D.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),D.add("stco").set("chunk_offsets",[]),D.add("stsz").set("sample_sizes",[]),this.moov.mvex.add("trex").set("track_id",m.id).set("default_sample_description_index",m.default_sample_description_index||1).set("default_sample_duration",m.default_sample_duration||0).set("default_sample_size",m.default_sample_size||0).set("default_sample_flags",m.default_sample_flags||0),this.buildTrakSampleLists(v),m.id}},l.Box.prototype.computeSize=function(A){var m=A||new r;m.endianness=r.BIG_ENDIAN,this.write(m)},g.prototype.addSample=function(A,m,v){var p=v||{},b={},O=this.getTrackById(A);if(O!==null){b.number=O.samples.length,b.track_id=O.tkhd.track_id,b.timescale=O.mdia.mdhd.timescale,b.description_index=p.sample_description_index?p.sample_description_index-1:0,b.description=O.mdia.minf.stbl.stsd.entries[b.description_index],b.data=m,b.size=m.byteLength,b.alreadyRead=b.size,b.duration=p.duration||1,b.cts=p.cts||0,b.dts=p.dts||0,b.is_sync=p.is_sync||!1,b.is_leading=p.is_leading||0,b.depends_on=p.depends_on||0,b.is_depended_on=p.is_depended_on||0,b.has_redundancy=p.has_redundancy||0,b.degradation_priority=p.degradation_priority||0,b.offset=0,b.subsamples=p.subsamples,O.samples.push(b),O.samples_size+=b.size,O.samples_duration+=b.duration,O.first_dts===void 0&&(O.first_dts=p.dts),this.processSamples();var w=this.createSingleSampleMoof(b);return this.addBox(w),w.computeSize(),w.trafs[0].truns[0].data_offset=w.size+8,this.add("mdat").data=new Uint8Array(m),b}},g.prototype.createSingleSampleMoof=function(A){var m=0;A.is_sync?m=1<<25:m=65536;var v=new l.moofBox;v.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++;var p=v.add("traf"),b=this.getTrackById(A.track_id);return p.add("tfhd").set("track_id",A.track_id).set("flags",l.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),p.add("tfdt").set("baseMediaDecodeTime",A.dts-(b.first_dts||0)),p.add("trun").set("flags",l.TRUN_FLAGS_DATA_OFFSET|l.TRUN_FLAGS_DURATION|l.TRUN_FLAGS_SIZE|l.TRUN_FLAGS_FLAGS|l.TRUN_FLAGS_CTS_OFFSET).set("data_offset",0).set("first_sample_flags",0).set("sample_count",1).set("sample_duration",[A.duration]).set("sample_size",[A.size]).set("sample_flags",[m]).set("sample_composition_time_offset",[A.cts-A.dts]),v},g.prototype.lastMoofIndex=0,g.prototype.samplesDataSize=0,g.prototype.resetTables=function(){var A,m,v,p,b,O,w,y;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,A=0;A=2&&(C=b[w].grouping_type+"/0",y=new x(b[w].grouping_type,0),y.is_fragment=!0,m.sample_groups_info[C]||(m.sample_groups_info[C]=y))}else for(w=0;w=2&&(C=p[w].grouping_type+"/0",y=new x(p[w].grouping_type,0),A.sample_groups_info[C]||(A.sample_groups_info[C]=y))},g.setSampleGroupProperties=function(A,m,v,p){var b,O;m.sample_groups=[];for(b in p)if(m.sample_groups[b]={},m.sample_groups[b].grouping_type=p[b].grouping_type,m.sample_groups[b].grouping_type_parameter=p[b].grouping_type_parameter,v>=p[b].last_sample_in_run&&(p[b].last_sample_in_run<0&&(p[b].last_sample_in_run=0),p[b].entry_index++,p[b].entry_index<=p[b].sbgp.entries.length-1&&(p[b].last_sample_in_run+=p[b].sbgp.entries[p[b].entry_index].sample_count)),p[b].entry_index<=p[b].sbgp.entries.length-1?m.sample_groups[b].group_description_index=p[b].sbgp.entries[p[b].entry_index].group_description_index:m.sample_groups[b].group_description_index=-1,m.sample_groups[b].group_description_index!==0){var w;p[b].fragment_description?w=p[b].fragment_description:w=p[b].description,m.sample_groups[b].group_description_index>0?(m.sample_groups[b].group_description_index>65535?O=(m.sample_groups[b].group_description_index>>16)-1:O=m.sample_groups[b].group_description_index-1,w&&O>=0&&(m.sample_groups[b].description=w.entries[O])):w&&w.version>=2&&w.default_group_description_index>0&&(m.sample_groups[b].description=w.entries[w.default_group_description_index-1])}},g.process_sdtp=function(A,m,v){m&&(A?(m.is_leading=A.is_leading[v],m.depends_on=A.sample_depends_on[v],m.is_depended_on=A.sample_is_depended_on[v],m.has_redundancy=A.sample_has_redundancy[v]):(m.is_leading=0,m.depends_on=0,m.is_depended_on=0,m.has_redundancy=0))},g.prototype.buildSampleLists=function(){var A,m;for(A=0;A"u")){for(m=0;mF&&(R++,F<0&&(F=0),F+=O.sample_counts[R]),m>0?(A.samples[m-1].duration=O.sample_deltas[R],A.samples_duration+=A.samples[m-1].duration,Y.dts=A.samples[m-1].dts+A.samples[m-1].duration):Y.dts=0,w?(m>=N&&(I++,N<0&&(N=0),N+=w.sample_counts[I]),Y.cts=A.samples[m].dts+w.sample_offsets[I]):Y.cts=Y.dts,y?(m==y.sample_numbers[W]-1?(Y.is_sync=!0,W++):(Y.is_sync=!1,Y.degradation_priority=0),x&&x.entries[V].sample_delta+z==m+1&&(Y.subsamples=x.entries[V].subsamples,z+=x.entries[V].sample_delta,V++)):Y.is_sync=!0,g.process_sdtp(A.mdia.minf.stbl.sdtp,Y,Y.number),T?Y.degradation_priority=T.priority[m]:Y.degradation_priority=0,x&&x.entries[V].sample_delta+z==m&&(Y.subsamples=x.entries[V].subsamples,z+=x.entries[V].sample_delta),(L.length>0||S.length>0)&&g.setSampleGroupProperties(A,Y,m,A.sample_groups_info)}m>0&&(A.samples[m-1].duration=Math.max(A.mdia.mdhd.duration-A.samples[m-1].dts,0),A.samples_duration+=A.samples[m-1].duration)}},g.prototype.updateSampleLists=function(){var A,m,v,p,b,O,w,y,C,x,L,S,T,D,Q;if(this.moov!==void 0){for(;this.lastMoofIndex0&&g.initSampleGroups(S,L,L.sbgps,S.mdia.minf.stbl.sgpds,L.sgpds),m=0;m0?D.dts=S.samples[S.samples.length-2].dts+S.samples[S.samples.length-2].duration:(L.tfdt?D.dts=L.tfdt.baseMediaDecodeTime:D.dts=0,S.first_traf_merged=!0),D.cts=D.dts,M.flags&l.TRUN_FLAGS_CTS_OFFSET&&(D.cts=D.dts+M.sample_composition_time_offset[v]),Q=w,M.flags&l.TRUN_FLAGS_FLAGS?Q=M.sample_flags[v]:v===0&&M.flags&l.TRUN_FLAGS_FIRST_FLAG&&(Q=M.first_sample_flags),D.is_sync=!(Q>>16&1),D.is_leading=Q>>26&3,D.depends_on=Q>>24&3,D.is_depended_on=Q>>22&3,D.has_redundancy=Q>>20&3,D.degradation_priority=Q&65535;var B=!!(L.tfhd.flags&l.TFHD_FLAG_BASE_DATA_OFFSET),P=!!(L.tfhd.flags&l.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),F=!!(M.flags&l.TRUN_FLAGS_DATA_OFFSET),R=0;B?R=L.tfhd.base_data_offset:P||m===0?R=x.start:R=y,m===0&&v===0?F?D.offset=R+M.data_offset:D.offset=R:D.offset=y,y=D.offset+D.size,(L.sbgps.length>0||L.sgpds.length>0||S.mdia.minf.stbl.sbgps.length>0||S.mdia.minf.stbl.sgpds.length>0)&&g.setSampleGroupProperties(S,D,D.number_in_traf,L.sample_groups_info)}}if(L.subs){S.has_fragment_subsamples=!0;var N=L.first_sample_index;for(m=0;m-1){v=this.stream.buffers[b];var O=v.byteLength-(p.offset+p.alreadyRead-v.fileStart);if(p.size-p.alreadyRead<=O)return t.debug("ISOFile","Getting sample #"+m+" data (alreadyRead: "+p.alreadyRead+" offset: "+(p.offset+p.alreadyRead-v.fileStart)+" read size: "+(p.size-p.alreadyRead)+" full size: "+p.size+")"),r.memcpy(p.data.buffer,p.alreadyRead,v,p.offset+p.alreadyRead-v.fileStart,p.size-p.alreadyRead),v.usedBytes+=p.size-p.alreadyRead,this.stream.logBufferLevel(),p.alreadyRead=p.size,p;if(O===0)return null;t.debug("ISOFile","Getting sample #"+m+" partial data (alreadyRead: "+p.alreadyRead+" offset: "+(p.offset+p.alreadyRead-v.fileStart)+" read size: "+O+" full size: "+p.size+")"),r.memcpy(p.data.buffer,p.alreadyRead,v,p.offset+p.alreadyRead-v.fileStart,O),p.alreadyRead+=O,v.usedBytes+=O,this.stream.logBufferLevel()}else return null}},g.prototype.releaseSample=function(A,m){var v=A.samples[m];return v.data?(this.samplesDataSize-=v.size,v.data=null,v.alreadyRead=0,v.size):0},g.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize},g.prototype.getCodecs=function(){var A,m="";for(A=0;A0&&(m+=","),m+=v.mdia.minf.stbl.stsd.entries[0].getCodec()}return m},g.prototype.getTrexById=function(A){var m;if(!this.moov||!this.moov.mvex)return null;for(m=0;m0&&(b.protection=O.ipro.protections[O.iinf.item_infos[v].protection_index-1]),O.iinf.item_infos[v].item_type?b.type=O.iinf.item_infos[v].item_type:b.type="mime",b.content_type=O.iinf.item_infos[v].content_type,b.content_encoding=O.iinf.item_infos[v].content_encoding;if(O.grpl)for(v=0;v0&&S.property_index-1-1){m=this.stream.buffers[O];var w=m.byteLength-(b.offset+b.alreadyRead-m.fileStart);if(b.length-b.alreadyRead<=w)t.debug("ISOFile","Getting item #"+A+" extent #"+p+" data (alreadyRead: "+b.alreadyRead+" offset: "+(b.offset+b.alreadyRead-m.fileStart)+" read size: "+(b.length-b.alreadyRead)+" full extent size: "+b.length+" full item size: "+v.size+")"),r.memcpy(v.data.buffer,v.alreadyRead,m,b.offset+b.alreadyRead-m.fileStart,b.length-b.alreadyRead),m.usedBytes+=b.length-b.alreadyRead,this.stream.logBufferLevel(),v.alreadyRead+=b.length-b.alreadyRead,b.alreadyRead=b.length;else return t.debug("ISOFile","Getting item #"+A+" extent #"+p+" partial data (alreadyRead: "+b.alreadyRead+" offset: "+(b.offset+b.alreadyRead-m.fileStart)+" read size: "+w+" full extent size: "+b.length+" full item size: "+v.size+")"),r.memcpy(v.data.buffer,v.alreadyRead,m,b.offset+b.alreadyRead-m.fileStart,w),b.alreadyRead+=w,v.alreadyRead+=w,m.usedBytes+=w,this.stream.logBufferLevel(),null}else return null}}return v.alreadyRead===v.size?v:null},g.prototype.releaseItem=function(A){var m=this.items[A];if(m.data){this.itemsDataSize-=m.size,m.data=null,m.alreadyRead=0;for(var v=0;v0?this.moov.traks[A].samples[0].duration:0),m.push(p)}return m},l.Box.prototype.printHeader=function(A){this.size+=8,this.size>o&&(this.size+=8),this.type==="uuid"&&(this.size+=16),A.log(A.indent+"size:"+this.size),A.log(A.indent+"type:"+this.type)},l.FullBox.prototype.printHeader=function(A){this.size+=4,l.Box.prototype.printHeader.call(this,A),A.log(A.indent+"version:"+this.version),A.log(A.indent+"flags:"+this.flags)},l.Box.prototype.print=function(A){this.printHeader(A)},l.ContainerBox.prototype.print=function(A){this.printHeader(A);for(var m=0;m>8)),A.log(A.indent+"matrix: "+this.matrix.join(", ")),A.log(A.indent+"next_track_id: "+this.next_track_id)},l.tkhdBox.prototype.print=function(A){l.FullBox.prototype.printHeader.call(this,A),A.log(A.indent+"creation_time: "+this.creation_time),A.log(A.indent+"modification_time: "+this.modification_time),A.log(A.indent+"track_id: "+this.track_id),A.log(A.indent+"duration: "+this.duration),A.log(A.indent+"volume: "+(this.volume>>8)),A.log(A.indent+"matrix: "+this.matrix.join(", ")),A.log(A.indent+"layer: "+this.layer),A.log(A.indent+"alternate_group: "+this.alternate_group),A.log(A.indent+"width: "+this.width),A.log(A.indent+"height: "+this.height)};var k={};k.createFile=function(A,m){var v=A!==void 0?A:!0,p=new g(m);return p.discardMdatData=!v,p},e.createFile=k.createFile})(Q_n);const OGe=MMs(Q_n),RMs=()=>{let e,t=16.6;self.onmessage=n=>{n.data.event==="start"&&(self.clearInterval(e),e=self.setInterval(()=>{self.postMessage({})},t)),n.data.event==="stop"&&self.clearInterval(e)}},IMs=()=>{const e=new Blob([`(${RMs.toString()})()`]),t=URL.createObjectURL(e);return new Worker(t)},rU=new Map;let wGe=1,ij=null;globalThis.Worker!=null&&(ij=IMs(),ij.onmessage=()=>{wGe+=1;for(const[e,t]of rU)if(wGe%e===0)for(const n of t)n()});const NMs=(e,t)=>{const n=Math.round(t/16.6),r=rU.get(n)??new Set;return r.add(e),rU.set(n,r),rU.size===1&&r.size===1&&(ij==null||ij.postMessage({event:"start"})),()=>{r.delete(e),r.size===0&&rU.delete(n),rU.size===0&&(wGe=0,ij==null||ij.postMessage({event:"stop"}))}};function UMs(e){return e instanceof Error?String(e):typeof e=="object"?JSON.stringify(e,(t,n)=>n instanceof Error?String(n):n):String(e)}function jMs(){const e=new Date;return`${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}.${e.getMilliseconds()}`}let B_n=1;const F_n=[],_kn=["debug","info","warn","error"].reduce((e,t,n)=>Object.assign(e,{[t]:(...r)=>{B_n<=n&&(console[t](...r),F_n.push({lvName:t,timeStr:jMs(),args:r}))}}),{}),foe=new Map,ld={setLogLevel:e=>{B_n=foe.get(e)??1},..._kn,create:e=>Object.fromEntries(Object.entries(_kn).map(([t,n])=>[t,(...r)=>n(e,...r)])),async dump(){return F_n.reduce((e,{lvName:t,timeStr:n,args:r})=>e+`[${t}][${n}] ${r.map(o=>UMs(o)).join(" ")} `,"")}};foe.set(ld.debug,0);foe.set(ld.info,1);foe.set(ld.warn,2);foe.set(ld.error,3);(async function(){if(await Promise.resolve(),!(globalThis.navigator==null||globalThis.document==null)&&(ld.info(`@webav version: 1.2.7, date: ${new Date().toLocaleDateString()}`),ld.info(globalThis.navigator.userAgent),document.addEventListener("visibilitychange",()=>{ld.info(`visibilitychange: ${document.visibilityState}`)}),"PressureObserver"in globalThis)){let e="";new PressureObserver(t=>{const n=JSON.stringify(t.map(r=>r.state));n!==e&&(ld.info(`cpu state change: ${n}`),e=n)}).observe("cpu")}})();class WMs{constructor(t,n,r){this.length_=t,this.scaleFactor_=(t-1)/n,this.interpolate=this.cubic,r.method==="point"?this.interpolate=this.point:r.method==="linear"?this.interpolate=this.linear:r.method==="sinc"&&(this.interpolate=this.sinc),this.tangentFactor_=1-Math.max(0,Math.min(1,r.tension||0)),this.sincFilterSize_=r.sincFilterSize||1,this.kernel_=VMs(r.sincWindow||HMs)}point(t,n){return this.getClippedInput_(Math.round(this.scaleFactor_*t),n)}linear(t,n){t=this.scaleFactor_*t;let r=Math.floor(t);return t-=r,(1-t)*this.getClippedInput_(r,n)+t*this.getClippedInput_(r+1,n)}cubic(t,n){t=this.scaleFactor_*t;let r=Math.floor(t),o=[this.getTangent_(r,n),this.getTangent_(r+1,n)],s=[this.getClippedInput_(r,n),this.getClippedInput_(r+1,n)];t-=r;let a=t*t,l=t*a;return(2*l-3*a+1)*s[0]+(l-2*a+t)*o[0]+(-2*l+3*a)*s[1]+(l-a)*o[1]}sinc(t,n){t=this.scaleFactor_*t;let r=Math.floor(t),o=r-this.sincFilterSize_+1,s=r+this.sincFilterSize_,a=0;for(let l=o;l<=s;l++)a+=this.kernel_(t-l)*this.getClippedInput_(l,n);return a}getTangent_(t,n){return this.tangentFactor_*(this.getClippedInput_(t+1,n)-this.getClippedInput_(t-1,n))/2}getClippedInput_(t,n){return 0<=t&&tt){let d=new l(r.LPFOrder||$kn[r.LPFType],n,t/2);KMs(e,s,a,d)}else{let d=new l(r.LPFOrder||$kn[r.LPFType],t,n/2);JMs(e,s,a,d)}}else P_n(e,s,a);return s}function P_n(e,t,n){for(let r=0,o=t.length;r=0;o--)t[o]=r.filter(t[o])}function JMs(e,t,n,r){for(let o=0,s=e.length;o=0;o--)e[o]=r.filter(e[o]);P_n(e,t,n)}var M_n=e=>{throw TypeError(e)},R_n=(e,t,n)=>t.has(e)||M_n("Cannot "+n),il=(e,t,n)=>(R_n(e,t,"read from private field"),n?n.call(e):t.get(e)),vp=(e,t,n)=>t.has(e)?M_n("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),t1=(e,t,n,r)=>(R_n(e,t,"write to private field"),t.set(e,n),n);const I_n="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHUobil7aWYobj09PSIvIilyZXR1cm57cGFyZW50Om51bGwsbmFtZToiIn07Y29uc3QgZT1uLnNwbGl0KCIvIikuZmlsdGVyKGk9PmkubGVuZ3RoPjApO2lmKGUubGVuZ3RoPT09MCl0aHJvdyBFcnJvcigiSW52YWxpZCBwYXRoIik7Y29uc3QgYT1lW2UubGVuZ3RoLTFdLHI9Ii8iK2Uuc2xpY2UoMCwtMSkuam9pbigiLyIpO3JldHVybntuYW1lOmEscGFyZW50OnJ9fWFzeW5jIGZ1bmN0aW9uIHcobixlKXtjb25zdHtwYXJlbnQ6YSxuYW1lOnJ9PXUobik7aWYoYT09bnVsbClyZXR1cm4gYXdhaXQgbmF2aWdhdG9yLnN0b3JhZ2UuZ2V0RGlyZWN0b3J5KCk7Y29uc3QgaT1hLnNwbGl0KCIvIikuZmlsdGVyKHQ9PnQubGVuZ3RoPjApO3RyeXtsZXQgdD1hd2FpdCBuYXZpZ2F0b3Iuc3RvcmFnZS5nZXREaXJlY3RvcnkoKTtmb3IoY29uc3QgcyBvZiBpKXQ9YXdhaXQgdC5nZXREaXJlY3RvcnlIYW5kbGUocyx7Y3JlYXRlOmUuY3JlYXRlfSk7aWYoZS5pc0ZpbGUpcmV0dXJuIGF3YWl0IHQuZ2V0RmlsZUhhbmRsZShyLHtjcmVhdGU6ZS5jcmVhdGV9KX1jYXRjaCh0KXtpZih0Lm5hbWU9PT0iTm90Rm91bmRFcnJvciIpcmV0dXJuIG51bGw7dGhyb3cgdH19Y29uc3QgZj17fTtzZWxmLm9ubWVzc2FnZT1hc3luYyBuPT57dmFyIGk7Y29uc3R7ZXZ0VHlwZTplLGFyZ3M6YX09bi5kYXRhO2xldCByPWZbYS5maWxlSWRdO3RyeXtsZXQgdDtjb25zdCBzPVtdO2lmKGU9PT0icmVnaXN0ZXIiKXtjb25zdCBsPWF3YWl0IHcoYS5maWxlUGF0aCx7Y3JlYXRlOiEwLGlzRmlsZTohMH0pO2lmKGw9PW51bGwpdGhyb3cgRXJyb3IoYG5vdCBmb3VuZCBmaWxlOiAke2EuZmlsZUlkfWApO3I9YXdhaXQgbC5jcmVhdGVTeW5jQWNjZXNzSGFuZGxlKHttb2RlOmEubW9kZX0pLGZbYS5maWxlSWRdPXJ9ZWxzZSBpZihlPT09ImNsb3NlIilhd2FpdCByLmNsb3NlKCksZGVsZXRlIGZbYS5maWxlSWRdO2Vsc2UgaWYoZT09PSJ0cnVuY2F0ZSIpYXdhaXQgci50cnVuY2F0ZShhLm5ld1NpemUpO2Vsc2UgaWYoZT09PSJ3cml0ZSIpe2NvbnN0e2RhdGE6bCxvcHRzOm99PW4uZGF0YS5hcmdzO3Q9YXdhaXQgci53cml0ZShsLG8pfWVsc2UgaWYoZT09PSJyZWFkIil7Y29uc3R7b2Zmc2V0Omwsc2l6ZTpvfT1uLmRhdGEuYXJncyxnPW5ldyBVaW50OEFycmF5KG8pLGQ9YXdhaXQgci5yZWFkKGcse2F0Omx9KSxjPWcuYnVmZmVyO3Q9ZD09PW8/YzooKGk9Yy50cmFuc2Zlcik9PW51bGw/dm9pZCAwOmkuY2FsbChjLGQpKT8/Yy5zbGljZSgwLGQpLHMucHVzaCh0KX1lbHNlIGU9PT0iZ2V0U2l6ZSI/dD1hd2FpdCByLmdldFNpemUoKTplPT09ImZsdXNoIiYmYXdhaXQgci5mbHVzaCgpO3NlbGYucG9zdE1lc3NhZ2Uoe2V2dFR5cGU6ImNhbGxiYWNrIixjYklkOm4uZGF0YS5jYklkLHJldHVyblZhbDp0fSxzKX1jYXRjaCh0KXtjb25zdCBzPXQ7c2VsZi5wb3N0TWVzc2FnZSh7ZXZ0VHlwZToidGhyb3dFcnJvciIsY2JJZDpuLmRhdGEuY2JJZCxlcnJNc2c6cy5uYW1lKyI6ICIrcy5tZXNzYWdlK2AKYCtKU09OLnN0cmluZ2lmeShuLmRhdGEpfSl9fX0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPW9wZnMtd29ya2VyLUY0UldscWNfLmpzLm1hcAo=",_Ms=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),evn=typeof self<"u"&&self.Blob&&new Blob([_Ms(I_n)],{type:"text/javascript;charset=utf-8"});function $Ms(e){let t;try{if(t=evn&&(self.URL||self.webkitURL).createObjectURL(evn),!t)throw"";const n=new Worker(t,{name:e==null?void 0:e.name});return n.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker("data:text/javascript;base64,"+I_n,{name:e==null?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}async function eRs(e,t,n){const r=tRs();return await r("register",{fileId:e,filePath:t,mode:n}),{read:async(o,s)=>await r("read",{fileId:e,offset:o,size:s}),write:async(o,s)=>await r("write",{fileId:e,data:o,opts:s},[ArrayBuffer.isView(o)?o.buffer:o]),close:async()=>await r("close",{fileId:e}),truncate:async o=>await r("truncate",{fileId:e,newSize:o}),getSize:async()=>await r("getSize",{fileId:e}),flush:async()=>await r("flush",{fileId:e})}}const cue=[];let rMe=0;function tRs(){if(cue.length<3){const t=e();return cue.push(t),t}else{const t=cue[rMe];return rMe=(rMe+1)%cue.length,t}function e(){const t=new $Ms;let n=0,r={};return t.onmessage=({data:o})=>{var s,a;o.evtType==="callback"?(s=r[o.cbId])==null||s.resolve(o.returnVal):o.evtType==="throwError"&&((a=r[o.cbId])==null||a.reject(Error(o.errMsg))),delete r[o.cbId]},async function(o,s,a=[]){n+=1;const l=new Promise((d,u)=>{r[n]={resolve:d,reject:u}});return t.postMessage({cbId:n,evtType:o,args:s},a),l}}}function kye(e){if(e==="/")return{parent:null,name:""};const t=e.split("/").filter(o=>o.length>0);if(t.length===0)throw Error("Invalid path");const n=t[t.length-1],r="/"+t.slice(0,-1).join("/");return{name:n,parent:r}}async function H5(e,t){const{parent:n,name:r}=kye(e);if(n==null)return await navigator.storage.getDirectory();const o=n.split("/").filter(s=>s.length>0);try{let s=await navigator.storage.getDirectory();for(const a of o)s=await s.getDirectoryHandle(a,{create:t.create});return t.isFile?await s.getFileHandle(r,{create:t.create}):await s.getDirectoryHandle(r,{create:t.create})}catch(s){if(s.name==="NotFoundError")return null;throw s}}async function yGe(e){const{parent:t,name:n}=kye(e);if(t==null){const o=await navigator.storage.getDirectory();for await(const s of o.keys())await o.removeEntry(s,{recursive:!0});return}const r=await H5(t,{create:!1,isFile:!1});if(r!=null)try{await r.removeEntry(n,{recursive:!0})}catch(o){if(o.name==="NotFoundError")return;throw o}}function CGe(e,t){return`${e}/${t}`.replace("//","/")}function rj(e){return new U_n(e)}var H3,xAe,EG;const nRs=class N_n{constructor(t){vp(this,H3),vp(this,xAe),vp(this,EG),t1(this,H3,t);const{parent:n,name:r}=kye(t);t1(this,xAe,r),t1(this,EG,n)}get kind(){return"dir"}get name(){return il(this,xAe)}get path(){return il(this,H3)}get parent(){return il(this,EG)==null?null:rj(il(this,EG))}async create(){return await H5(il(this,H3),{create:!0,isFile:!1}),rj(il(this,H3))}async exists(){return await H5(il(this,H3),{create:!1,isFile:!1})instanceof FileSystemDirectoryHandle}async remove(t={}){for(const n of await this.children())try{await n.remove(t)}catch(r){console.warn(r)}try{await yGe(il(this,H3))}catch(n){console.warn(n)}}async children(){const t=await H5(il(this,H3),{create:!1,isFile:!1});if(t==null)return[];const n=[];for await(const r of t.values())n.push((r.kind==="file"?goe:rj)(CGe(il(this,H3),r.name)));return n}async copyTo(t){if(!await this.exists())throw Error(`dir ${this.path} not exists`);if(t instanceof N_n){const n=await t.exists()?rj(CGe(t.path,this.name)):t;return await n.create(),await Promise.all((await this.children()).map(r=>r.copyTo(n))),n}else if(t instanceof FileSystemDirectoryHandle)return await Promise.all((await this.children()).map(async n=>{n.kind==="file"?await n.copyTo(await t.getFileHandle(n.name,{create:!0})):await n.copyTo(await t.getDirectoryHandle(n.name,{create:!0}))})),null;throw Error("Illegal target type")}async moveTo(t){const n=await this.copyTo(t);return await this.remove(),n}};H3=new WeakMap,xAe=new WeakMap,EG=new WeakMap;let U_n=nRs;const xGe=new Map;function goe(e,t="rw"){if(t==="rw"){const n=xGe.get(e)??new Ove(e,t);return xGe.set(e,n),n}return new Ove(e,t)}async function Rat(e,t,n={overwrite:!0}){if(t instanceof Ove){await Rat(e,await t.stream(),n);return}const r=await(e instanceof Ove?e:goe(e,"rw")).createWriter();try{if(n.overwrite&&await r.truncate(0),t instanceof ReadableStream){const o=t.getReader();for(;;){const{done:s,value:a}=await o.read();if(s)break;await r.write(a)}}else await r.write(t)}catch(o){throw o}finally{await r.close()}}let iRs=0;const rRs=()=>++iRs;var sp,DG,LAe,QG,SAe,Rx,TAe,EAe,oU;const oRs=class j_n{constructor(t,n){vp(this,sp),vp(this,DG),vp(this,LAe),vp(this,QG),vp(this,SAe),vp(this,Rx,0),vp(this,TAe,async()=>{}),vp(this,EAe,(()=>{let s=null;return()=>(t1(this,Rx,il(this,Rx)+1),s!=null||(s=new Promise(async(a,l)=>{try{const d=await eRs(il(this,SAe),il(this,sp),il(this,QG));t1(this,TAe,async()=>{s!=null&&(s=null,t1(this,Rx,0),await d.close().catch(console.error))}),a([d,async()=>{t1(this,Rx,il(this,Rx)-1),!(il(this,Rx)>0)&&(s=null,await d.close())}])}catch(d){l(d)}})),s)})()),vp(this,oU,!1),t1(this,SAe,rRs()),t1(this,sp,t),t1(this,QG,{r:"read-only",rw:"readwrite","rw-unsafe":"readwrite-unsafe"}[n]);const{parent:r,name:o}=kye(t);if(r==null)throw Error("Invalid path");t1(this,LAe,o),t1(this,DG,r)}get kind(){return"file"}get path(){return il(this,sp)}get name(){return il(this,LAe)}get parent(){return il(this,DG)==null?null:rj(il(this,DG))}async createWriter(){if(il(this,QG)==="read-only")throw Error("file is read-only");if(il(this,oU))throw Error("Other writer have not been closed");t1(this,oU,!0);try{const t=new TextEncoder,[n,r]=await il(this,EAe).call(this);let o=await n.getSize(),s=!1;return{write:async(a,l={})=>{if(s)throw Error("Writer is closed");const d=typeof a=="string"?t.encode(a):a,u=l.at??o,h=d.byteLength;return o=u+h,await n.write(d,{at:u})},truncate:async a=>{if(s)throw Error("Writer is closed");await n.truncate(a),o>a&&(o=a)},flush:async()=>{if(s)throw Error("Writer is closed");await n.flush()},close:async()=>{if(s)throw Error("Writer is closed");s=!0,t1(this,oU,!1),await r()}}}catch(t){throw t1(this,oU,!1),t}}async createReader(){const[t,n]=await il(this,EAe).call(this);let r=!1,o=0;return{read:async(s,a={})=>{if(r)throw Error("Reader is closed");const l=a.at??o,d=await t.read(l,s);return o=l+d.byteLength,d},getSize:async()=>{if(r)throw Error("Reader is closed");return await t.getSize()},close:async()=>{r||(r=!0,await n())}}}async text(){return new TextDecoder().decode(await this.arrayBuffer())}async arrayBuffer(){const t=await H5(il(this,sp),{create:!1,isFile:!0});return t==null?new ArrayBuffer(0):(await t.getFile()).arrayBuffer()}async stream(){const t=await this.getOriginFile();return t==null?new ReadableStream({pull:n=>{n.close()}}):t.stream()}async getOriginFile(){var t;return(t=await H5(il(this,sp),{create:!1,isFile:!0}))==null?void 0:t.getFile()}async getSize(){const t=await H5(il(this,sp),{create:!1,isFile:!0});return t==null?0:(await t.getFile()).size}async exists(){return await H5(il(this,sp),{create:!1,isFile:!0})instanceof FileSystemFileHandle}async remove(t={}){if(t.force===!0){await il(this,TAe).call(this),await yGe(il(this,sp)),xGe.delete(il(this,sp));return}if(il(this,Rx)>0)throw Error("exists unclosed reader/writer");await yGe(il(this,sp))}async copyTo(t){if(t instanceof j_n)return t.path===this.path?this:(await Rat(t,this),t);if(t instanceof U_n){if(!await this.exists())throw Error(`file ${this.path} not exists`);return await this.copyTo(goe(CGe(t.path,this.name)))}else if(t instanceof FileSystemFileHandle)return await(await this.stream()).pipeTo(await t.createWritable()),null;throw Error("Illegal target type")}async moveTo(t){const n=await this.copyTo(t);return await this.remove(),n}};sp=new WeakMap,DG=new WeakMap,LAe=new WeakMap,QG=new WeakMap,SAe=new WeakMap,Rx=new WeakMap,TAe=new WeakMap,EAe=new WeakMap,oU=new WeakMap;let Ove=oRs;const Iat="/.opfs-tools-temp-dir";async function W_n(e){try{if(e.kind==="file"){if(!await e.exists())return!0;const t=await e.createWriter();await t.truncate(0),await t.close(),await e.remove()}else await e.remove();return!0}catch(t){return console.warn(t),!1}}function sRs(){setInterval(async()=>{for(const e of await rj(Iat).children()){const t=/^\d+-(\d+)$/.exec(e.name);(t==null||Date.now()-Number(t[1])>2592e5)&&await W_n(e)}},60*1e3)}const LGe=[];let tvn=!1;async function aRs(){if(globalThis.localStorage==null)return;const e="OPFS_TOOLS_EXPIRES_TMP_FILES";tvn||(tvn=!0,globalThis.addEventListener("unload",()=>{LGe.length!==0&&localStorage.setItem(e,`${localStorage.getItem(e)??""},${LGe.join(",")}`)}));let t=localStorage.getItem(e)??"";for(const n of t.split(","))n.length!==0&&await W_n(goe(`${Iat}/${n}`))&&(t=t.replace(n,""));localStorage.setItem(e,t.replace(/,{2,}/g,","))}(async function(){var e;globalThis.__opfs_tools_tmpfile_init__!==!0&&(globalThis.__opfs_tools_tmpfile_init__=!0,!(globalThis.FileSystemDirectoryHandle==null||globalThis.FileSystemFileHandle==null||((e=globalThis.navigator)==null?void 0:e.storage.getDirectory)==null)&&(sRs(),await aRs()))})();function lRs(){const e=`${Math.random().toString().slice(2)}-${Date.now()}`;return LGe.push(e),goe(`${Iat}/${e}`)}function cRs(e){const t=new Float32Array(e.map(r=>r.length).reduce((r,o)=>r+o));let n=0;for(const r of e)t.set(r,n),n+=r.length;return t}function dRs(e){const t=[];for(let n=0;nnew Float32Array(n));for(let o=0;onew Float32Array(n));for(let o=0;oe.getChannelData(n))}async function fRs(e,t,n){const r=e.length,o=Array(n.chanCount).fill(0).map(()=>new Float32Array(0));if(r===0)return o;const s=Math.max(...e.map(u=>u.length));if(s===0)return o;if(globalThis.OfflineAudioContext==null)return e.map(u=>new Float32Array(GMs(u,t,n.rate,{method:"sinc",LPF:!1})));const a=new globalThis.OfflineAudioContext(n.chanCount,s*n.rate/t,n.rate),l=a.createBufferSource(),d=a.createBuffer(r,s,t);return e.forEach((u,h)=>d.copyToChannel(u,h)),l.buffer=d,l.connect(a.destination),l.start(),H_n(await a.startRendering())}function V_n(e){return new Promise(t=>{const n=NMs(()=>{n(),t()},e)})}function nvn(e,t,n){const r=n-t,o=new Float32Array(r);let s=0;for(;so.mdia.minf.stbl.stsd.entries).flat().find(({type:o})=>o===t))==null?void 0:r.esds}function vRs(e){let t="mp4a";const n=e.esd.descs[0];if(n==null)return{};t+="."+n.oti.toString(16);const r=n.descs[0];if(r==null)return t.endsWith("40")&&(t+=".2"),{codec:t};const o=(r.data[0]&248)>>3;t+="."+o;const[s,a]=r.data,l=((s&7)<<1)+(a>>7),d=(a&127)>>3;return{codec:t,sampleRate:[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][l],numberOfChannels:d}}async function pRs(e,t,n){const r=OGe.createFile(!1);r.onReady=s=>{var a,l;t({mp4boxFile:r,info:s});const d=(a=s.videoTracks[0])==null?void 0:a.id;d!=null&&r.setExtractionOptions(d,"video",{nbSamples:100});const u=(l=s.audioTracks[0])==null?void 0:l.id;u!=null&&r.setExtractionOptions(u,"audio",{nbSamples:100}),r.start()},r.onSamples=n,await o();async function o(){let s=0;const a=30*1024*1024;for(;;){const l=await e.read(a,{at:s});if(l.byteLength===0)break;l.fileStart=s;const d=r.appendBuffer(l);if(d==null)break;s=d}r.stop()}}function bRs(e){if((e==null?void 0:e.length)!==9)return{};const t=new Int32Array(e.buffer),n=t[0]/65536,r=t[1]/65536,o=t[3]/65536,s=t[4]/65536,a=t[6]/65536,l=t[7]/65536,d=t[8]/(1<<30),u=Math.sqrt(n*n+o*o),h=Math.sqrt(r*r+s*s),f=Math.atan2(o,n),g=f*180/Math.PI;return{scaleX:u,scaleY:h,rotationRad:f,rotationDeg:g,translateX:a,translateY:l,perspective:d}}function ORs(e,t,n){const r=(Math.round(n/90)*90+360)%360;if(r===0)return d=>d;const o=r===90||r===270?t:e,s=r===90||r===270?e:t,a=new OffscreenCanvas(o,s),l=a.getContext("2d");return l.translate(o/2,s/2),l.rotate(-r*Math.PI/180),l.translate(-e/2,-t/2),d=>{if(d==null)return null;l.drawImage(d,0,0);const u=new VideoFrame(a,{timestamp:d.timestamp,duration:d.duration??void 0});return d.close(),u}}let Nat=0;function oMe(e){return e.kind==="file"&&e.createReader instanceof Function}var SGe,DAe,QAe,V3,C0,Ix,rS,BAe,FAe,z3,kD,BG,sU,Nx,iv,FG;const wRs=class aU{constructor(t,n={}){if(Oo(this,SGe,Nat++),Oo(this,DAe,ld.create(`MP4Clip id:${Jt(this,SGe)},`)),Ky(this,"ready"),Oo(this,QAe,!1),Oo(this,V3,{duration:0,width:0,height:0,audioSampleRate:0,audioChanCount:0}),Oo(this,C0),Oo(this,Ix,[]),Oo(this,rS,{perspective:1,rotationRad:0,rotationDeg:0,scaleX:1,scaleY:1,translateX:0,translateY:0}),Oo(this,BAe,o=>o),Oo(this,FAe,1),Oo(this,z3,[]),Oo(this,kD,[]),Oo(this,BG,null),Oo(this,sU,null),Oo(this,Nx,{video:null,audio:null}),Oo(this,iv,{audio:!0}),Ky(this,"tickInterceptor",async(o,s)=>s),Oo(this,FG,new AbortController),!(t instanceof ReadableStream)&&!oMe(t)&&!Array.isArray(t.videoSamples))throw Error("Illegal argument");jr(this,iv,{audio:!0,...n}),jr(this,FAe,typeof n.audio=="object"&&"volume"in n.audio?n.audio.volume:1);const r=async o=>(await Rat(Jt(this,C0),o),Jt(this,C0));jr(this,C0,oMe(t)?t:"localFile"in t?t.localFile:lRs()),this.ready=(t instanceof ReadableStream?r(t).then(o=>ivn(o,Jt(this,iv))):oMe(t)?ivn(t,Jt(this,iv)):Promise.resolve(t)).then(async({videoSamples:o,audioSamples:s,decoderConf:a,headerBoxPos:l,parsedMatrix:d})=>{jr(this,z3,o),jr(this,kD,s),jr(this,Nx,a),jr(this,Ix,l),jr(this,rS,d);const{videoFrameFinder:u,audioFrameFinder:h}=CRs({video:a.video==null?null:{...a.video,hardwareAcceleration:Jt(this,iv).__unsafe_hardwareAcceleration__},audio:a.audio},await Jt(this,C0).createReader(),o,s,Jt(this,iv).audio!==!1?Jt(this,FAe):0);jr(this,BG,u),jr(this,sU,h);const{codedWidth:f,codedHeight:g}=a.video??{};return f&&g&&jr(this,BAe,ORs(f,g,d.rotationDeg)),jr(this,V3,yRs(a,o,s,d.rotationDeg)),Jt(this,DAe).info("MP4Clip meta:",Jt(this,V3)),{...Jt(this,V3)}})}get meta(){return{...Jt(this,V3)}}async getFileHeaderBinData(){await this.ready;const t=await Jt(this,C0).getOriginFile();if(t==null)throw Error("MP4Clip localFile is not origin file");return await new Blob(Jt(this,Ix).map(({start:n,size:r})=>t.slice(n,n+r))).arrayBuffer()}async tick(t){var n,r,o;if(t>=Jt(this,V3).duration)return await this.tickInterceptor(t,{audio:await((n=Jt(this,sU))==null?void 0:n.find(t))??[],state:"done"});const[s,a]=await Promise.all([((r=Jt(this,sU))==null?void 0:r.find(t))??[],(o=Jt(this,BG))==null?void 0:o.find(t).then(Jt(this,BAe))]);return a==null?await this.tickInterceptor(t,{audio:s,state:"success"}):await this.tickInterceptor(t,{video:a,audio:s,state:"success"})}async thumbnails(t=100,n){Jt(this,FG).abort(),jr(this,FG,new AbortController);const r=Jt(this,FG).signal;await this.ready;const o="generate thumbnails aborted";if(r.aborted)throw Error(o);const{width:s,height:a}=Jt(this,V3),l=ERs(t,Math.round(a*(t/s)),{quality:.1,type:"image/png"});return new Promise(async(d,u)=>{let h=[];const f=Jt(this,Nx).video;if(f==null||Jt(this,z3).length===0){g();return}r.addEventListener("abort",()=>{u(Error(o))});async function g(){r.aborted||d(await Promise.all(h.map(async p=>({ts:p.ts,img:await p.img}))))}function k(p){h.push({ts:p.timestamp,img:l(p)})}const{start:A=0,end:m=Jt(this,V3).duration,step:v}=n??{};if(v){let p=A;const b=new Z_n(await Jt(this,C0).createReader(),Jt(this,z3),{...f,hardwareAcceleration:Jt(this,iv).__unsafe_hardwareAcceleration__});for(;p<=m&&!r.aborted;){const O=await b.find(p);O&&k(O),p+=v}b.destroy(),g()}else await FRs(Jt(this,z3),Jt(this,C0),f,r,{start:A,end:m},(p,b)=>{p!=null&&k(p),b&&g()})})}async split(t){if(await this.ready,t<=0||t>=Jt(this,V3).duration)throw Error('"time" out of bounds');const[n,r]=DRs(Jt(this,z3),t),[o,s]=QRs(Jt(this,kD),t),a=new aU({localFile:Jt(this,C0),videoSamples:n??[],audioSamples:o??[],decoderConf:Jt(this,Nx),headerBoxPos:Jt(this,Ix),parsedMatrix:Jt(this,rS)},Jt(this,iv)),l=new aU({localFile:Jt(this,C0),videoSamples:r??[],audioSamples:s??[],decoderConf:Jt(this,Nx),headerBoxPos:Jt(this,Ix),parsedMatrix:Jt(this,rS)},Jt(this,iv));return await Promise.all([a.ready,l.ready]),[a,l]}async clone(){await this.ready;const t=new aU({localFile:Jt(this,C0),videoSamples:[...Jt(this,z3)],audioSamples:[...Jt(this,kD)],decoderConf:Jt(this,Nx),headerBoxPos:Jt(this,Ix),parsedMatrix:Jt(this,rS)},Jt(this,iv));return await t.ready,t.tickInterceptor=this.tickInterceptor,t}async splitTrack(){await this.ready;const t=[];if(Jt(this,z3).length>0){const n=new aU({localFile:Jt(this,C0),videoSamples:[...Jt(this,z3)],audioSamples:[],decoderConf:{video:Jt(this,Nx).video,audio:null},headerBoxPos:Jt(this,Ix),parsedMatrix:Jt(this,rS)},Jt(this,iv));await n.ready,n.tickInterceptor=this.tickInterceptor,t.push(n)}if(Jt(this,kD).length>0){const n=new aU({localFile:Jt(this,C0),videoSamples:[],audioSamples:[...Jt(this,kD)],decoderConf:{audio:Jt(this,Nx).audio,video:null},headerBoxPos:Jt(this,Ix),parsedMatrix:Jt(this,rS)},Jt(this,iv));await n.ready,n.tickInterceptor=this.tickInterceptor,t.push(n)}return t}destroy(){var t,n;Jt(this,QAe)||(Jt(this,DAe).info("MP4Clip destroy"),jr(this,QAe,!0),(t=Jt(this,BG))==null||t.destroy(),(n=Jt(this,sU))==null||n.destroy())}};SGe=new WeakMap,DAe=new WeakMap,QAe=new WeakMap,V3=new WeakMap,C0=new WeakMap,Ix=new WeakMap,rS=new WeakMap,BAe=new WeakMap,FAe=new WeakMap,z3=new WeakMap,kD=new WeakMap,BG=new WeakMap,sU=new WeakMap,Nx=new WeakMap,iv=new WeakMap,FG=new WeakMap;let z_n=wRs;function yRs(e,t,n,r){const o={duration:0,width:0,height:0,audioSampleRate:0,audioChanCount:0};if(e.video!=null&&t.length>0){o.width=e.video.codedWidth??0,o.height=e.video.codedHeight??0;const l=(Math.round(r/90)*90+360)%360;(l===90||l===270)&&([o.width,o.height]=[o.height,o.width])}e.audio!=null&&n.length>0&&(o.audioSampleRate=Yp.sampleRate,o.audioChanCount=Yp.channelCount);let s=0,a=0;if(t.length>0)for(let l=t.length-1;l>=0;l--){const d=t[l];if(!d.deleted){s=d.cts+d.duration;break}}if(n.length>0){const l=n.at(-1);a=l.cts+l.duration}return o.duration=Math.max(s,a),o}function CRs(e,t,n,r,o){return{audioFrameFinder:o===0||e.audio==null||r.length===0?null:new LRs(t,r,e.audio,{volume:o,targetSampleRate:Yp.sampleRate}),videoFrameFinder:e.video==null||n.length===0?null:new Z_n(t,n,e.video)}}async function ivn(e,t={}){let n=null;const r={video:null,audio:null};let o=[],s=[],a=[];const l={perspective:1,rotationRad:0,rotationDeg:0,scaleX:1,scaleY:1,translateX:0,translateY:0};let d=-1,u=-1;const h=await e.createReader();await pRs(h,async g=>{var k;n=g.info;const A=g.mp4boxFile.ftyp;a.push({start:A.start,size:A.size});const m=g.mp4boxFile.moov;a.push({start:m.start,size:m.size}),Object.assign(l,bRs((k=n.videoTracks[0])==null?void 0:k.matrix));let{videoDecoderConf:v,audioDecoderConf:p}=gRs(g.mp4boxFile,g.info);if(r.video=v??null,r.audio=p??null,v==null&&p==null&&ld.error("MP4Clip no video and audio track"),p!=null){const{supported:b}=await AudioDecoder.isConfigSupported(p);b||ld.error(`MP4Clip audio codec is not supported: ${p.codec}`)}if(v!=null){const{supported:b}=await VideoDecoder.isConfigSupported(v);b||ld.error(`MP4Clip video codec is not supported: ${v.codec}`)}ld.info("mp4BoxFile moov ready",{...g.info,tracks:null,videoTracks:null,audioTracks:null},r)},(g,k,A)=>{if(k==="video"){d===-1&&(d=A[0].dts);for(const m of A)o.push(rvn(m,d,"video"))}else if(k==="audio"&&t.audio){u===-1&&(u=A[0].dts);for(const m of A)s.push(rvn(m,u,"audio"))}}),await h.close();const f=o.at(-1)??s.at(-1);if(n==null)throw Error("MP4Clip stream is done, but not emit ready");if(f==null)throw Error("MP4Clip stream not contain any sample");return QGe(o),ld.info("mp4 stream parsed"),{videoSamples:o,audioSamples:s,decoderConf:r,headerBoxPos:a,parsedMatrix:l}}function rvn(e,t=0,n){let r=e.offset;const o=n==="video"&&e.is_sync?BRs(e.data,e.description.type):-1;let s=e.size;return o>0&&(r+=o,s-=o),{...e,is_idr:o>=0,offset:r,size:s,cts:(e.cts-t)/e.timescale*1e6,dts:(e.dts-t)/e.timescale*1e6,duration:e.duration/e.timescale*1e6,timescale:1e6,data:n==="video"?null:e.data}}var $m,lU,cU,PAe,dU,Ux,ap,oS,vD,uU,MAe,PG,pD,RAe,hU,IAe;class Z_n{constructor(t,n,r){Oo(this,$m,null),Oo(this,lU,0),Oo(this,cU,{abort:!1,st:performance.now()}),Ky(this,"find",async o=>{(Jt(this,$m)==null||Jt(this,$m).state==="closed"||o<=Jt(this,lU)||o-Jt(this,lU)>3e6)&&Jt(this,hU).call(this,o),Jt(this,cU).abort=!0,jr(this,lU,o),jr(this,cU,{abort:!1,st:performance.now()});const s=await Jt(this,PG).call(this,o,Jt(this,$m),Jt(this,cU));return jr(this,uU,0),s}),Oo(this,PAe,0),Oo(this,dU,!1),Oo(this,Ux,0),Oo(this,ap,[]),Oo(this,oS,0),Oo(this,vD,0),Oo(this,uU,0),Oo(this,MAe,!1),Oo(this,PG,async(o,s,a)=>{if(s==null||s.state==="closed"||a.abort)return null;if(Jt(this,ap).length>0){const l=Jt(this,ap)[0];return ol.timestamp+(l.duration??0)?(l.close(),await Jt(this,PG).call(this,o,s,a)):(!Jt(this,MAe)&&Jt(this,ap).length<10&&Jt(this,RAe).call(this,s).catch(d=>{throw jr(this,MAe,!0),Jt(this,hU).call(this,o),d}),l))}if(Jt(this,pD)||Jt(this,oS)0){if(performance.now()-a.st>6e3)throw Error(`MP4Clip.tick video timeout, ${JSON.stringify(Jt(this,IAe).call(this))}`);jr(this,uU,Jt(this,uU)+1),await V_n(15)}else{if(Jt(this,Ux)>=this.samples.length)return null;try{await Jt(this,RAe).call(this,s)}catch(l){throw Jt(this,hU).call(this,o),l}}return await Jt(this,PG).call(this,o,s,a)}),Oo(this,pD,!1),Oo(this,RAe,async o=>{var s,a;if(Jt(this,pD)||o.decodeQueueSize>600)return;let l=Jt(this,Ux)+1;if(l>this.samples.length)return;jr(this,pD,!0);let d=!1;for(;l1e3){const k=u[0],A=u.at(-1),m=A.offset+A.size-k.offset;ld.warn(`Read video samples time cost: ${Math.round(g)}ms, file chunk size: ${m}`)}if(o.state==="closed")return;jr(this,PAe,((a=f[0])==null?void 0:a.duration)??0),DGe(o,f,{onDecodingError:k=>{if(Jt(this,dU))throw k;Jt(this,oS)===0&&(jr(this,dU,!0),ld.warn("Downgrade to software decode"),Jt(this,hU).call(this))}}),jr(this,vD,Jt(this,vD)+f.length)}}jr(this,Ux,l),jr(this,pD,!1)}),Oo(this,hU,o=>{var s,a;if(jr(this,pD,!1),Jt(this,ap).forEach(d=>d.close()),jr(this,ap,[]),o==null||o===0)jr(this,Ux,0);else{let d=0;for(let u=0;u{if(jr(this,oS,Jt(this,oS)+1),d.timestamp===-1){d.close();return}let u=d;d.duration==null&&(u=new VideoFrame(d,{duration:Jt(this,PAe)}),d.close()),Jt(this,ap).push(u)},error:d=>{if(d.message.includes("Codec reclaimed due to inactivity")){jr(this,$m,null),ld.warn(d.message);return}const u=`VideoFinder VideoDecoder err: ${d.message}, config: ${JSON.stringify(l)}, state: ${JSON.stringify(Jt(this,IAe).call(this))}`;throw ld.error(u),Error(u)}})),Jt(this,$m).configure(l)}),Oo(this,IAe,()=>{var o,s;return{time:Jt(this,lU),decState:(o=Jt(this,$m))==null?void 0:o.state,decQSize:(s=Jt(this,$m))==null?void 0:s.decodeQueueSize,decCusorIdx:Jt(this,Ux),sampleLen:this.samples.length,inputCnt:Jt(this,vD),outputCnt:Jt(this,oS),cacheFrameLen:Jt(this,ap).length,softDeocde:Jt(this,dU),clipIdCnt:Nat,sleepCnt:Jt(this,uU),memInfo:X_n()}}),Ky(this,"destroy",()=>{var o,s;((o=Jt(this,$m))==null?void 0:o.state)!=="closed"&&((s=Jt(this,$m))==null||s.close()),jr(this,$m,null),Jt(this,cU).abort=!0,Jt(this,ap).forEach(a=>a.close()),jr(this,ap,[]),this.localFileReader.close()}),this.localFileReader=t,this.samples=n,this.conf=r}}$m=new WeakMap,lU=new WeakMap,cU=new WeakMap,PAe=new WeakMap,dU=new WeakMap,Ux=new WeakMap,ap=new WeakMap,oS=new WeakMap,vD=new WeakMap,uU=new WeakMap,MAe=new WeakMap,PG=new WeakMap,pD=new WeakMap,RAe=new WeakMap,hU=new WeakMap,IAe=new WeakMap;function xRs(e,t){for(let n=0;n=r.cts&&ee)break}return 0}var NAe,UAe,Z3,AU,jx,sS,db,fU,jAe,WAe,TGe,EGe;class LRs{constructor(t,n,r,o){Oo(this,NAe,1),Oo(this,UAe),Oo(this,Z3,null),Oo(this,AU,{abort:!1,st:performance.now()}),Ky(this,"find",async s=>{const a=s<=Jt(this,jx)||s-Jt(this,jx)>1e5;(Jt(this,Z3)==null||Jt(this,Z3).state==="closed"||a)&&Jt(this,TGe).call(this),a&&(jr(this,jx,s),jr(this,sS,xRs(s,this.samples))),Jt(this,AU).abort=!0;const l=s-Jt(this,jx);jr(this,jx,s),jr(this,AU,{abort:!1,st:performance.now()});const d=await Jt(this,jAe).call(this,Math.ceil(l*(Jt(this,UAe)/1e6)),Jt(this,Z3),Jt(this,AU));return jr(this,fU,0),d}),Oo(this,jx,0),Oo(this,sS,0),Oo(this,db,{frameCnt:0,data:[]}),Oo(this,fU,0),Oo(this,jAe,async(s,a=null,l)=>{if(a==null||l.abort||a.state==="closed"||s===0)return[];const d=Jt(this,db).frameCnt-s;if(d>0)return d3e3)throw l.abort=!0,Error(`MP4Clip.tick audio timeout, ${JSON.stringify(Jt(this,EGe).call(this))}`);jr(this,fU,Jt(this,fU)+1),await V_n(15)}else{if(Jt(this,sS)>=this.samples.length-1)return ovn(Jt(this,db),Jt(this,db).frameCnt);Jt(this,WAe).call(this,a)}return Jt(this,jAe).call(this,s,a,l)}),Oo(this,WAe,s=>{if(s.decodeQueueSize>10)return;const a=[];let l=Jt(this,sS);for(;l=10))break}jr(this,sS,l),s.decode(a.map(d=>new EncodedAudioChunk({type:"key",timestamp:d.cts,duration:d.duration,data:d.data})))}),Oo(this,TGe,()=>{var s;jr(this,jx,0),jr(this,sS,0),jr(this,db,{frameCnt:0,data:[]}),(s=Jt(this,Z3))==null||s.close(),jr(this,Z3,SRs(this.conf,{resampleRate:Yp.sampleRate,volume:Jt(this,NAe)},a=>{Jt(this,db).data.push(a),Jt(this,db).frameCnt+=a[0].length}))}),Oo(this,EGe,()=>{var s,a;return{time:Jt(this,jx),decState:(s=Jt(this,Z3))==null?void 0:s.state,decQSize:(a=Jt(this,Z3))==null?void 0:a.decodeQueueSize,decCusorIdx:Jt(this,sS),sampleLen:this.samples.length,pcmLen:Jt(this,db).frameCnt,clipIdCnt:Nat,sleepCnt:Jt(this,fU),memInfo:X_n()}}),Ky(this,"destroy",()=>{jr(this,Z3,null),Jt(this,AU).abort=!0,jr(this,db,{frameCnt:0,data:[]}),this.localFileReader.close()}),this.localFileReader=t,this.samples=n,this.conf=r,jr(this,NAe,o.volume),jr(this,UAe,o.targetSampleRate)}}NAe=new WeakMap,UAe=new WeakMap,Z3=new WeakMap,AU=new WeakMap,jx=new WeakMap,sS=new WeakMap,db=new WeakMap,fU=new WeakMap,jAe=new WeakMap,WAe=new WeakMap,TGe=new WeakMap,EGe=new WeakMap;function SRs(e,t,n){let r=0,o=0;const s=h=>{if(o+=1,h.length!==0){if(t.volume!==1)for(const f of h)for(let g=0;g{const f=uRs(h);l?a(()=>fRs(f,h.sampleRate,{rate:t.resampleRate,chanCount:h.numberOfChannels})):s(f),h.close()},error:h=>{h.message.includes("Codec reclaimed due to inactivity")||u("MP4Clip AudioDecoder err",h)}});d.configure(e);function u(h,f){const g=`${h}: ${f.message}, state: ${JSON.stringify({qSize:d.decodeQueueSize,state:d.state,inputCnt:r,outputCnt:o})}`;throw ld.error(g),Error(g)}return{decode(h){r+=h.length;try{for(const f of h)d.decode(f)}catch(f){u("decode audio chunk error",f)}},close(){d.state!=="closed"&&d.close()},get decoding(){return r>o&&d.decodeQueueSize>0},get state(){return d.state},get decodeQueueSize(){return d.decodeQueueSize}}}function TRs(e){const t=[];let n=0;function r(a,l){t[l]=a,o()}function o(){const a=t[n];a!=null&&(e(a),n+=1,o())}let s=0;return a=>{const l=s;s+=1,a().then(d=>r(d,l)).catch(d=>r(d,l))}}function ovn(e,t){const n=[new Float32Array(t),new Float32Array(t)];let r=0,o=0;for(;ot){const l=t-r;n[0].set(s.subarray(0,l),r),n[1].set(a.subarray(0,l),r),e.data[o][0]=s.subarray(l,s.length),e.data[o][1]=a.subarray(l,a.length);break}else n[0].set(s,r),n[1].set(a,r),r+=s.length,o++}return e.data=e.data.slice(o),e.frameCnt-=t,n}async function Y_n(e,t){const n=e[0],r=e.at(-1);if(r==null)return[];const o=r.offset+r.size-n.offset;if(o<3e7){const s=new Uint8Array(await t.read(o,{at:n.offset}));return e.map(a=>{const l=a.offset-n.offset;return new EncodedVideoChunk({type:a.is_sync?"key":"delta",timestamp:a.cts,duration:a.duration,data:s.subarray(l,l+a.size)})})}return await Promise.all(e.map(async s=>new EncodedVideoChunk({type:s.is_sync?"key":"delta",timestamp:s.cts,duration:s.duration,data:await t.read(s.size,{at:s.offset})})))}function ERs(e,t,n){const r=new OffscreenCanvas(e,t),o=r.getContext("2d");return async s=>(o.drawImage(s,0,0,e,t),s.close(),await r.convertToBlob(n))}function DRs(e,t){if(e.length===0)return[];let n=0,r=0,o=-1;for(let d=0;d({...d}));for(let d=n;d({...d,cts:d.cts-t}));for(const d of l)d.cts<0&&(d.deleted=!0,d.cts=-1);return QGe(l),[a,l]}function QRs(e,t){if(e.length===0)return[];let n=-1;for(let s=0;sa.cts)){n=s;break}}if(n===-1)throw Error("Not found audio sample by time");const r=e.slice(0,n).map(s=>({...s})),o=e.slice(n).map(s=>({...s,cts:s.cts-t}));return[r,o]}function DGe(e,t,n){if(e.state==="configured"){for(let r=0;r{if(!(r instanceof Error))throw r;if(r.message.includes("Decoding error")&&n.onDecodingError!=null){n.onDecodingError(r);return}if(!r.message.includes("Aborted due to close"))throw r})}}function BRs(e,t){if(t!=="avc1"&&t!=="hvc1")return 0;const n=new DataView(e.buffer);for(let r=0;r>1&63;if(o===19||o===20||o===32||o===33||o===34)return r}r+=n.getUint32(r)+4}return-1}async function FRs(e,t,n,r,o,s){const a=await t.createReader(),l=await Y_n(e.filter(h=>!h.deleted&&h.is_sync&&h.cts>=o.start&&h.cts<=o.end),a);if(l.length===0||r.aborted){s(null,!0);return}let d=0;DGe(u(),l,{onDecodingError:h=>{ld.warn("thumbnailsByKeyFrame",h),d===0?DGe(u(!0),l,{onDecodingError:f=>{a.close(),ld.error("thumbnailsByKeyFrame retry soft deocde",f)}}):(s(null,!0),a.close())}});function u(h=!1){const f={...n,...h?{hardwareAcceleration:"prefer-software"}:{}},g=new VideoDecoder({output:k=>{d+=1;const A=d===l.length;s(k,A),A&&(a.close(),g.state!=="closed"&&g.close())},error:k=>{const A=`thumbnails decoder error: ${k.message}, config: ${JSON.stringify(f)}, state: ${JSON.stringify({qSize:g.decodeQueueSize,state:g.state,outputCnt:d,inputCnt:l.length})}`;throw ld.error(A),Error(A)}});return r.addEventListener("abort",()=>{a.close(),g.state!=="closed"&&g.close()}),g.configure(f),g}}function QGe(e){let t=0,n=null;for(const r of e)if(!r.deleted){if(r.is_sync&&(t+=1),t>=2)break;(n==null||r.ctso),Oo(this,bD,0),Oo(this,Wx,0),jr(this,eL,{loop:!1,volume:1,...n}),this.ready=WPs(this,BGe,q_n).call(this,t).then(()=>({width:0,height:0,duration:n.loop?1/0:Jt(this,oj).duration}))}get meta(){return{...Jt(this,oj),sampleRate:Yp.sampleRate,chanCount:2}}getPCMData(){return[Jt(this,qS),Jt(this,KD)]}async tick(t){if(!Jt(this,eL).loop&&t>=Jt(this,oj).duration)return await this.tickInterceptor(t,{audio:[],state:"done"});const n=t-Jt(this,bD);if(t3e6)return jr(this,bD,t),jr(this,Wx,Math.ceil(Jt(this,bD)/1e6*Yp.sampleRate)),await this.tickInterceptor(t,{audio:[new Float32Array(0),new Float32Array(0)],state:"success"});jr(this,bD,t);const r=Math.ceil(n/1e6*Yp.sampleRate),o=Jt(this,Wx)+r,s=Jt(this,eL).loop?[nvn(Jt(this,qS),Jt(this,Wx),o),nvn(Jt(this,KD),Jt(this,Wx),o)]:[Jt(this,qS).slice(Jt(this,Wx),o),Jt(this,KD).slice(Jt(this,Wx),o)];return jr(this,Wx,o),await this.tickInterceptor(t,{audio:s,state:"success"})}async split(t){await this.ready;const n=Math.ceil(t/1e6*Yp.sampleRate),r=new HAe(this.getPCMData().map(s=>s.slice(0,n)),Jt(this,eL)),o=new HAe(this.getPCMData().map(s=>s.slice(n)),Jt(this,eL));return[r,o]}async clone(){await this.ready;const t=new HAe(this.getPCMData(),Jt(this,eL));return await t.ready,t}destroy(){jr(this,qS,new Float32Array(0)),jr(this,KD,new Float32Array(0)),ld.info("---- audioclip destroy ----")}};oj=new WeakMap,qS=new WeakMap,KD=new WeakMap,eL=new WeakMap,BGe=new WeakSet,q_n=async function(e){gU.ctx==null&&(gU.ctx=new AudioContext({sampleRate:Yp.sampleRate}));const t=performance.now(),n=e instanceof ReadableStream?await MRs(e,gU.ctx):e;ld.info("Audio clip decoded complete:",performance.now()-t);const r=Jt(this,eL).volume;if(r!==1)for(const o of n)for(let s=0;s0){let A=0,m=0;for(const v of k)for(let p=0;p0?A/m:0)}else l.push(0)}catch{l.push(0)}}const u=Math.max(...l,.001),h=l.map(f=>f/u);return s.destroy(),MW.set(r,h),Lz.set(e,a),{waveformData:h,duration:a}}catch(o){return console.error("Error extracting video audio waveform:",o),{waveformData:[],duration:0}}}function RRs(e,t){if(!e||e.length===0)return new Array(t).fill(0);const n=e[0].length,r=new Float32Array(n);for(let l=0;ll/a)}const IRs={class:"video-clip"},NRs={key:0,class:"video-clip__loading"},URs={key:0,class:"video-clip__thumbnail-placeholder"},jRs={class:"video-clip__info"},WRs={class:"video-clip__name"},HRs={key:0,class:"video-clip__rate"},VRs=40,zRs=120,ZRs=80,YRs=Xe({__name:"VideoClip",props:{clip:{}},setup(e){const t=e,n=Q2(),r=de(),o=de(!1),s=de([]),a=G(()=>t.clip),l=G(()=>{if(a.value.name)return a.value.name;const k=a.value.sourceUrl.split("/");return k[k.length-1]||"Video"}),d=G(()=>(t.clip.endTime-t.clip.startTime)*n.actualPixelsPerSecond),u=G(()=>{const k=Math.sqrt(n.scale),A=ZRs*k;return Math.max(VRs,Math.min(zRs,A))}),h=G(()=>a.value.thumbnails&&a.value.thumbnails.length>0?a.value.thumbnails:s.value),f=G(()=>{const k=h.value,A=a.value.originalDuration,m=a.value.trimStart??0,v=(a.value.trimEnd??A)-m;if(!k||k.length===0||A<=0||v<=0){const y=Math.max(1,Math.ceil(d.value/u.value));return Array.from({length:y},()=>({url:"",width:d.value/y}))}const p=A/k.length,b=[];let O=0;const w=d.value;for(;Ow&&(S=w-O),S>0&&b.push({url:k[L],width:S}),O+=S}return b});async function g(){if(a.value.thumbnails&&a.value.thumbnails.length>0)return;const k=a.value.sourceUrl;if(k){o.value=!0;try{const A=await wve(k,{count:20,width:120});s.value=A.thumbnails}catch(A){console.error("Failed to load video thumbnails:",A)}finally{o.value=!1}}}return At(()=>a.value.sourceUrl,()=>{s.value=[],g()}),mn(()=>{g()}),Pa(()=>{for(const k of s.value)k.startsWith("blob:")&&URL.revokeObjectURL(k)}),(k,A)=>(Ce(),We("div",IRs,[he("div",{class:"video-clip__thumbnails",ref_key:"thumbnailsRef",ref:r},[o.value?(Ce(),We("div",NRs,[...A[0]||(A[0]=[he("span",{class:"video-clip__loading-spinner"},null,-1),he("span",{class:"video-clip__loading-text"},"加载中...",-1)])])):(Ce(),We("div",{key:1,class:"video-clip__thumbnail-track",style:eo({width:d.value+"px"})},[(Ce(!0),We(nn,null,bi(f.value,(m,v)=>(Ce(),We("div",{key:v,class:"video-clip__thumbnail",style:eo({backgroundImage:m.url?`url(${m.url})`:"none",width:m.width+"px",backgroundPosition:"center",backgroundSize:"cover"})},[m.url?Vt("",!0):(Ce(),We("div",URs," 📹 "))],4))),128))],4))],512),he("div",jRs,[he("span",WRs,De(l.value),1),a.value.playbackRate&&a.value.playbackRate!==1?(Ce(),We("span",HRs,De(a.value.playbackRate)+"x ",1)):Vt("",!0)])]))}}),svn=Qg(YRs,[["__scopeId","data-v-611ec10c"]]),XRs={key:0,class:"audio-clip__loading"},qRs=["width","height"],GRs={class:"audio-clip__info"},KRs={class:"audio-clip__name"},JRs={key:0,class:"audio-clip__volume"},_Rs=Xe({__name:"AudioClip",props:{clip:{}},setup(e){const t=e,n=Q2(),r=de(),o=de(),s=de(400),a=de(32),l=de(!1),d=de([]);let u=null;const h=G(()=>t.clip),f=G(()=>{if(h.value.name)return h.value.name;const O=h.value.sourceUrl.split("/");return O[O.length-1]||"Audio"}),g=G(()=>h.value.waveformData&&h.value.waveformData.length>0?h.value.waveformData:d.value),k=G(()=>{const O=g.value;if(!O||O.length===0)return[];const w=h.value.originalDuration;if(w<=0)return O;const y=h.value.trimStart??0,C=h.value.trimEnd??w;if(y===0&&C===w)return O;const x=O.length,L=y/w,S=C/w;let T=Math.floor(L*x),D=Math.ceil(S*x);return T=Math.max(0,Math.min(T,x-1)),D=Math.max(T+1,Math.min(D,x)),O.slice(T,D)});function A(){if(!o.value)return;const O=o.value,w=O.getContext("2d");w&&(w.clearRect(0,0,O.width,O.height),k.value&&k.value.length>0?m(w,k.value):v(w))}function m(O,w){const y=s.value,C=a.value,x=y/w.length,L=Math.max(1,x*.75),S=O.createLinearGradient(0,0,0,C);S.addColorStop(0,"rgba(16, 185, 129, 0.9)"),S.addColorStop(.5,"rgba(16, 185, 129, 1)"),S.addColorStop(1,"rgba(16, 185, 129, 0.9)"),O.fillStyle=S;for(let T=0;TL+S.charCodeAt(0),0);for(let L=0;L{A()})}async function b(){if(h.value.waveformData&&h.value.waveformData.length>0)return;const O=h.value.sourceUrl;if(O){l.value=!0;try{const w=O.match(/\.(mp4|webm|mov|avi)$/i)?await K_n(O,{samples:500}):await Uat(O,{samples:500});d.value=w.waveformData}catch(w){console.error("Failed to load audio waveform:",w)}finally{l.value=!1,ei(()=>{A()})}}}return At(()=>h.value.sourceUrl,()=>{d.value=[],b()}),At(k,()=>{ei(()=>{A()})}),At(()=>[h.value.trimStart,h.value.trimEnd],()=>{ei(()=>{A()})}),At(()=>n.actualPixelsPerSecond,()=>{p()}),mn(()=>{r.value&&(u=new ResizeObserver(()=>{p()}),u.observe(r.value)),p(),b()}),Pa(()=>{u&&(u.disconnect(),u=null)}),(O,w)=>(Ce(),We("div",{class:"audio-clip",ref_key:"clipRef",ref:r},[l.value?(Ce(),We("div",XRs,[...w[0]||(w[0]=[he("span",{class:"audio-clip__loading-spinner"},null,-1),he("span",{class:"audio-clip__loading-text"},"加载波形...",-1)])])):(Ce(),We("canvas",{key:1,ref_key:"canvasRef",ref:o,class:"audio-clip__waveform",width:s.value,height:a.value},null,8,qRs)),he("div",GRs,[he("span",KRs,De(f.value),1),h.value.volume!==void 0?(Ce(),We("span",JRs," 🔊 "+De(Math.round(h.value.volume*100))+"% ",1)):Vt("",!0)])],512))}}),$Rs=Qg(_Rs,[["__scopeId","data-v-61d57c9d"]]),eIs={class:"subtitle-clip__text"},tIs=Xe({__name:"SubtitleClip",props:{clip:{}},setup(e){const t=e,n=G(()=>t.clip),r=(s,a)=>{var l;const d=n.value[s];return d!==void 0?d:((l=n.value.config)==null?void 0:l[s])??a},o=G(()=>({background:r("backgroundColor",void 0),textAlign:r("textAlign","left")}));return(s,a)=>(Ce(),We("div",{class:"subtitle-clip",style:eo(o.value)},[he("div",eIs,De(n.value.text),1)],4))}}),nIs=Qg(tIs,[["__scopeId","data-v-863126a4"]]),iIs={class:"text-clip__content"},rIs=Xe({__name:"TextClip",props:{clip:{}},setup(e){const t=e,n=(a,l)=>{var d;const u=t.clip[a];return u!==void 0?u:((d=t.clip.config)==null?void 0:d[a])??l},r=G(()=>t.clip.text||n("text","自定义文本")),o=G(()=>({background:n("backgroundColor",void 0),textAlign:n("textAlign","center")})),s=G(()=>({fontFamily:n("fontFamily",void 0),fontSize:n("fontSize",void 0)?`${n("fontSize",10)}px`:void 0,color:n("color","#ffffff"),fontWeight:n("fontWeight",600)}));return(a,l)=>(Ce(),We("div",{class:"text-clip",style:eo(o.value)},[he("div",iIs,[he("span",{class:"text-clip__text",style:eo(s.value)},De(r.value),5)])],4))}}),oIs=Qg(rIs,[["__scopeId","data-v-2824ba6a"]]),sIs={class:"sticker-clip"},aIs={key:1,class:"sticker-clip__placeholder"},lIs={class:"sticker-clip__info"},cIs=Xe({__name:"StickerClip",props:{clip:{}},setup(e){const t=e,n=G(()=>t.clip);return(r,o)=>(Ce(),We("div",sIs,[n.value.sourceUrl?(Ce(),We("div",{key:0,class:"sticker-clip__image",style:eo({backgroundImage:`url(${n.value.sourceUrl})`})},null,4)):(Ce(),We("div",aIs," ✨ ")),he("div",lIs,De(n.value.name||"Sticker"),1)]))}}),dIs=Qg(cIs,[["__scopeId","data-v-562f6596"]]),uIs={class:"filter-clip"},hIs={class:"filter-clip__info"},AIs={class:"filter-clip__name"},fIs={class:"filter-clip__type"},gIs=Xe({__name:"FilterClip",props:{clip:{}},setup(e){const t=e,n=G(()=>t.clip);return(r,o)=>(Ce(),We("div",uIs,[o[0]||(o[0]=he("div",{class:"filter-clip__icon"}," 🎨 ",-1)),he("div",hIs,[he("div",AIs,De(n.value.name||"Filter"),1),he("div",fIs,De(n.value.filterType),1)])]))}}),mIs=Qg(gIs,[["__scopeId","data-v-0fe335d3"]]),kIs={class:"effect-clip"},vIs={class:"effect-clip__info"},pIs={class:"effect-clip__name"},bIs={class:"effect-clip__type"},OIs=Xe({__name:"EffectClip",props:{clip:{}},setup(e){const t=e,n=G(()=>t.clip);return(r,o)=>(Ce(),We("div",kIs,[o[0]||(o[0]=he("div",{class:"effect-clip__icon"}," ⭐ ",-1)),he("div",vIs,[he("div",pIs,De(n.value.name||"Effect"),1),he("div",bIs,De(n.value.effectType),1)])]))}}),wIs=Qg(OIs,[["__scopeId","data-v-41c88d2b"]]),yIs={class:"transition-clip"},CIs={class:"transition-clip__info"},xIs={class:"transition-clip__name"},LIs={class:"transition-clip__duration"},SIs=Xe({__name:"TransitionClip",props:{clip:{}},setup(e){const t=e,n=G(()=>t.clip);return(r,o)=>(Ce(),We("div",yIs,[o[0]||(o[0]=he("div",{class:"transition-clip__icon"}," 🔀 ",-1)),he("div",CIs,[he("div",xIs,De(n.value.name||"Transition"),1),he("div",LIs,De(n.value.transitionDuration)+"s",1)])]))}}),TIs=Qg(SIs,[["__scopeId","data-v-14c86e24"]]),EIs={class:"clip__content"},avn=3,DIs=Xe({__name:"ClipItem",props:{clip:{},track:{}},emits:["dragStart","resizeStart","contextMenu","click","dblclick","addTransition"],setup(e,{emit:t}){const n=e,r=t,o=J1(),s=Q2(),a=JZ(),l=mt("config",{}),d=de(),u=de(!1),h=de(!1),f=de({x:0,y:0});let g=!1,k=null;const A=G(()=>o.selectedClipIds.has(n.clip.id)),m=G(()=>a.draggedClipIds.has(n.clip.id));At(()=>a.isDragging,F=>{F||(O.value=null)});const v=G(()=>s.actualPixelsPerSecond),p=G(()=>(l.clipConfigs||{})[n.clip.type]||{}),b=G(()=>({"clip--selected":A.value,"clip--locked":n.track.locked,"clip--dragging":m.value&&a.isDragging,"clip--resizing":u.value,"clip--show-transition-btn":h.value})),O=de(null),w=G(()=>{var F,R,N,I;const W=(n.clip.endTime-n.clip.startTime)*v.value,V=n.clip.startTime*v.value,z=p.value;let Y=32,K=8;n.track.isMain?(Y=64,K=8):n.clip.type==="video"||n.track.type==="video"?(Y=48,K=8):(Y=32,K=8),z.height&&(Y=z.height),z.top&&(K=z.top);const X={left:`${V}px`,width:`${W}px`,height:`${Y}px`,top:`${K}px`,"--clip-bg-color":z.backgroundColor,"--clip-border-color":z.borderColor,"--clip-selected-bg-color":(F=z.selected)==null?void 0:F.backgroundColor,"--clip-selected-border-color":(R=z.selected)==null?void 0:R.borderColor,"--clip-hover-border-color":(N=z.hover)==null?void 0:N.borderColor,"--clip-border-width":z.borderWidth?`${z.borderWidth}px`:"1px","--clip-border-radius":typeof z.borderRadius=="number"?`${z.borderRadius}px`:z.borderRadius||"var(--radius-sm)","--clip-opacity":z.opacity,"--clip-selected-box-shadow":(I=z.selected)==null?void 0:I.boxShadow};if(m.value&&a.isDragging&&O.value){const _=a.dragOffset,q=O.value;X.position="fixed",X.left=`${q.left+_.x}px`,X.top=`${q.top+_.y}px`,X.width=`${q.width}px`,X.height=`${q.height}px`,X.zIndex=1e3,X.pointerEvents="none",X.transform="none"}return X}),y=G(()=>{const F=p.value;return F.component?F.component:{video:svn,audio:$Rs,subtitle:nIs,text:oIs,sticker:dIs,filter:mIs,effect:wIs,transition:TIs}[n.clip.type]||svn}),C=G(()=>n.clip.type==="transition"?null:n.track.clips.filter(F=>F.type!=="transition").find(F=>F.id!==n.clip.id&&Math.abs(F.startTime-n.clip.endTime)<.01)||null),x=G(()=>C.value?n.track.clips.some(F=>F.type==="transition"&&F.startTimen.clip.endTime):!1),L=G(()=>n.clip.type==="transition"?!0:p.value.resizable!==!1);function S(F){var R;if(n.track.locked||(r("click",n.clip,F),F.button!==0))return;if(n.clip.type==="transition"){o.selectClip(n.clip.id);return}g=!0,k=F;const N=F.clientX,I=F.clientY,W=((R=d.value)==null?void 0:R.ownerDocument)||document,V=K=>{if(!g)return;const X=Math.abs(K.clientX-N),_=Math.abs(K.clientY-I);(X>avn||_>avn)&&(g=!1,k&&(d.value&&(O.value=d.value.getBoundingClientRect()),r("dragStart",n.clip,k)),Y())},z=()=>{g=!1,k=null,Y()},Y=()=>{W.removeEventListener("mousemove",V),W.removeEventListener("mouseup",z)};W.addEventListener("mousemove",V),W.addEventListener("mouseup",z)}function T(F,R){var N;if(n.track.locked)return;o.selectClip(n.clip.id),u.value=!0,r("resizeStart",n.clip,F,R);const I=((N=d.value)==null?void 0:N.ownerDocument)||document,W=()=>{u.value=!1,I.removeEventListener("mouseup",W)};I.addEventListener("mouseup",W)}function D(F){r("contextMenu",n.clip,F)}function Q(F){if(!d.value)return;const R=d.value.getBoundingClientRect(),N=F.clientX-R.left,I=s.actualPixelsPerSecond,W=N/I,V=n.clip.startTime+W,z=Math.max(n.clip.startTime,Math.min(V,n.clip.endTime));r("dblclick",n.clip,z)}function M(F){if(!C.value||x.value||n.track.locked){h.value=!1;return}const R=F.currentTarget.getBoundingClientRect(),N=F.clientX-R.left,I=R.width;if(N>=I-2&&N<=I){h.value=!0;const W=((n.clip.endTime+C.value.startTime)/2-n.clip.startTime)*v.value;f.value={x:W,y:R.height/2}}else h.value=!1}function B(){h.value=!1}function P(F){F.stopPropagation(),C.value&&r("addTransition",n.clip.id,C.value.id),h.value=!1}return(F,R)=>(Ce(),We("div",{class:uo(["clip",b.value]),ref_key:"clipRef",ref:d,style:eo(w.value),onMousedown:S,onDblclick:Q,onMousemove:M,onMouseleave:B,onContextmenu:or(D,["prevent"])},[!e.track.locked&&L.value?(Ce(),We("div",{key:0,class:"clip__handle clip__handle--left",onMousedown:R[0]||(R[0]=or(N=>T("left",N),["stop"]))},null,32)):Vt("",!0),he("div",EIs,[(Ce(),St(Ud(y.value),{clip:e.clip},null,8,["clip"]))]),!e.track.locked&&L.value?(Ce(),We("div",{key:1,class:"clip__handle clip__handle--right",onMousedown:R[1]||(R[1]=or(N=>T("right",N),["stop"]))},null,32)):Vt("",!0),h.value&&C.value&&!x.value&&e.clip.type==="video"?(Ce(),We("div",{key:2,class:"clip__transition-btn",style:eo({left:f.value.x+"px",top:f.value.y+"px"}),onMousedown:R[2]||(R[2]=or(()=>{},["stop"])),onClick:P,title:"点击添加转场"},[...R[3]||(R[3]=[he("span",{class:"clip__transition-icon"},"🔀",-1)])],36)):Vt("",!0)],38))}}),QIs=Qg(DIs,[["__scopeId","data-v-4b3e240e"]]),BIs={class:"drag-preview__inner"},FIs={key:0,class:"drag-preview__label"},PIs=Xe({__name:"DragPreview",props:{track:{}},setup(e){const t=e,n=JZ(),r=Q2(),o=G(()=>{const s=n.previewPosition;if(!s.visible)return{};const a=s.startTime*r.actualPixelsPerSecond,l=(s.endTime-s.startTime)*r.actualPixelsPerSecond;let d=32;t.track.isMain?d=64:(s.clipType==="video"||t.track.type==="video")&&(d=48);const u={left:`${a}px`,width:`${l}px`,height:`${d}px`,top:"8px"};return s.needNewTrack&&(u.top=`-${d+8}px`),u});return(s,a)=>(Ce(),We("div",{class:uo(["drag-preview",{"drag-preview--new-track":ge(n).previewPosition.needNewTrack}]),style:eo(o.value)},[he("div",BIs,[ge(n).previewPosition.needNewTrack?(Ce(),We("span",FIs," 新建轨道 ")):Vt("",!0)])],6))}}),MIs=Qg(PIs,[["__scopeId","data-v-5766b4e2"]]),RIs=["data-track-id"],IIs=Xe({__name:"TrackArea",props:{track:{},scrollLeft:{default:0}},emits:["scroll","contextMenu","trackContextMenu","addTransition","dropMedia","seek"],setup(e,{emit:t}){const n=e,r=t,o=Q2(),s=J1(),a=JZ(),l=Y6(),{startResize:d}=PMs(),u=de(),h=de(!1),f=de(null),g=G(()=>o.actualPixelsPerSecond),k=G(()=>!a.isDragging||!a.previewPosition.visible?!1:a.previewPosition.trackId===n.track.id),A=G(()=>{const Q=Math.max(s.totalDuration,a.previewEndTime,60);return Math.ceil(Q*g.value)}),m=G(()=>n.track.isMain?80:n.track.clips.some(Q=>Q.type==="video")||n.track.type==="video"?64:48);function v(){u.value&&r("scroll",u.value.scrollLeft)}At(()=>n.scrollLeft,Q=>{u.value&&u.value.scrollLeft!==Q&&(u.value.scrollLeft=Q)});function p(Q,M){var B;const P=((B=u.value)==null?void 0:B.ownerDocument)||document;a.startDrag(Q,M,P)}function b(Q,M,B){d(Q,M,B)}function O(Q){if(!(Q.button!==0||Q.target.closest(".clip"))&&(s.clearSelection(),u.value)){const M=u.value.getBoundingClientRect(),B=Q.clientX-M.left+u.value.scrollLeft,P=br(B/g.value);l.seekTo(P),r("seek",P)}}function w(Q,M){s.selectClip(Q.id)}function y(Q,M){l.seekTo(M),r("seek",M)}function C(Q,M){r("contextMenu",Q,M)}function x(Q){if(Q.target.closest(".clip")||!u.value)return;const M=u.value.getBoundingClientRect(),B=(Q.clientX-M.left+u.value.scrollLeft)/g.value;r("trackContextMenu",n.track,B,Q)}function L(Q,M){r("addTransition",Q,M)}function S(Q){if(!u.value)return;h.value=!0;const M=u.value.getBoundingClientRect(),B=Q.clientX-M.left+u.value.scrollLeft;f.value=B}function T(Q){Q.target===u.value&&(h.value=!1,f.value=null)}function D(Q){if(h.value=!1,f.value=null,!(!u.value||!Q.dataTransfer))try{const M=Q.dataTransfer.getData("application/json");if(!M)return;const B=JSON.parse(M),P=u.value.getBoundingClientRect(),F=Q.clientX-P.left+u.value.scrollLeft,R=br(F/g.value);r("dropMedia",B,n.track.id,R)}catch(M){console.error("处理拖放失败:",M)}}return(Q,M)=>(Ce(),We("div",{class:"track-area",ref_key:"trackAreaRef",ref:u,onScroll:v,onMousedown:O,onContextmenu:or(x,["prevent"]),onDragover:or(S,["prevent"]),onDrop:or(D,["prevent"]),onDragleave:T},[he("div",{class:uo(["track-area__content",{"track-area__content--drag-over":h.value}]),style:eo({width:A.value+"px",minHeight:m.value+"px"}),"data-track-id":e.track.id},[(Ce(!0),We(nn,null,bi(e.track.clips,B=>(Ce(),St(QIs,{key:B.id,clip:B,track:e.track,"data-clip-id":B.id,onDragStart:p,onResizeStart:b,onClick:w,onDblclick:y,onContextMenu:C,onAddTransition:L},null,8,["clip","track","data-clip-id"]))),128)),k.value?(Ce(),St(MIs,{key:0,track:e.track},null,8,["track"])):Vt("",!0)],14,RIs)],544))}}),NIs=Qg(IIs,[["__scopeId","data-v-9f39c911"]]),UIs={key:0,class:"tracks__empty"},jIs={class:"tracks__empty-content"},WIs={class:"tracks__empty-text"},HIs=["data-track-id"],VIs={class:"tracks__track-area-cell"},zIs=Xe({__name:"index",props:{scrollLeft:{default:0},locale:{default:()=>({})}},emits:["scroll","contextMenu","trackContextMenu","trackDelete","addTransition","dropMedia","update:trackControlWidth","seek"],setup(e,{emit:t}){const n=e,r=t,o=J1(),s=WE(),a=Q2(),l=JZ();Y6();const d=mt("config",{}),u=de(),h=de(),f=de(),g=de(),k=de(n.scrollLeft),A=de(!1),m=de(null),v=G(()=>o.sortedTracks),p=G(()=>a.actualPixelsPerSecond),b=G(()=>{const I=Math.max(o.totalDuration,l.previewEndTime,60);return Math.ceil(I*p.value)}),O=de(200);At(()=>n.scrollLeft,I=>{!A.value&&I!==k.value&&(k.value=I,g.value&&(g.value.scrollLeft=I))}),At(v,(I,W)=>{const V=!W||W.length===0,z=I&&I.length>0;V&&z&&ei(()=>{f.value&&!y&&(y=new ResizeObserver(()=>{x()}),y.observe(f.value)),x()})},{immediate:!0});function w(I,W){W===0&&(m.value=I)}let y=null;function C(I){A.value||(A.value=!0,k.value=I,r("scroll",I),requestAnimationFrame(()=>{A.value=!1}))}mn(()=>{f.value&&(y=new ResizeObserver(()=>{x()}),y.observe(f.value)),ei(()=>{l.setScrollContainers(u.value||null,g.value||null,C)}),ei(()=>{L()})}),Pa(()=>{y&&y.disconnect()});function x(){if(m.value){const I=m.value.getBoundingClientRect().width;O.value=I,r("update:trackControlWidth",I)}}function L(){const I=o.mainTrack;if(!I||!f.value)return;const W=f.value.querySelector(`[data-track-id="${I.id}"]`);W&&W.scrollIntoView({block:"center",behavior:"smooth"})}At(()=>o.mainTrack,I=>{I&&ei(()=>{L()})});function S(){}function T(){g.value&&!A.value&&(A.value=!0,k.value=g.value.scrollLeft,r("scroll",k.value),requestAnimationFrame(()=>{A.value=!1}))}function D(I){A.value||(A.value=!0,k.value=I,g.value&&g.value.scrollLeft!==I&&(g.value.scrollLeft=I),r("scroll",I),requestAnimationFrame(()=>{A.value=!1}))}function Q(I,W){o.updateTrack(I,W),s.pushSnapshot("更新轨道")}function M(I){const W=o.tracks.find(V=>V.id===I);if(W!=null&&W.isMain){alert("主轨道不能删除");return}o.removeTrack(I),s.pushSnapshot("删除轨道"),r("trackDelete",I)}function B(I,W){r("contextMenu",I,W)}function P(I,W,V){r("trackContextMenu",I,W,V)}function F(I,W){r("addTransition",I,W)}function R(I,W,V){r("dropMedia",I,W,V)}function N(I){r("seek",I)}return er("config",d),(I,W)=>{var V;return Ce(),We("div",{class:"tracks",ref_key:"tracksRef",ref:u},[v.value.length===0?(Ce(),We("div",UIs,[he("div",jIs,[W[0]||(W[0]=he("span",{class:"tracks__empty-icon"},"🎬",-1)),he("span",WIs,De(((V=e.locale)==null?void 0:V.emptyTip)||"拖拽媒体文件到此处添加"),1)])])):(Ce(),We("div",{key:1,class:"tracks__scroll-container",ref_key:"scrollContainerRef",ref:h,onScroll:S},[he("div",{class:"tracks__table",ref_key:"tableRef",ref:f},[(Ce(!0),We(nn,null,bi(v.value,(z,Y)=>(Ce(),We("div",{key:z.id,class:uo(["tracks__track",{"tracks__track--locked":z.locked,"tracks__track--hidden":!z.visible}]),"data-track-id":z.id},[he("div",{class:"tracks__track-control-cell",ref_for:!0,ref:K=>w(K,Y)},[c(FMs,{track:z,locale:e.locale,onUpdate:Q,onDelete:M},null,8,["track","locale"])],512),he("div",VIs,[c(NIs,{track:z,"scroll-left":k.value,onScroll:D,onContextMenu:B,onTrackContextMenu:P,onAddTransition:F,onDropMedia:R,onSeek:N},null,8,["track","scroll-left"])])],10,HIs))),128))],512)],544)),he("div",{class:"tracks__scrollbar",onScroll:T,ref_key:"scrollbarRef",ref:g},[he("div",{class:"tracks__scrollbar-content",style:eo({width:b.value+"px"})},null,4)],544)],512)}}}),ZIs=Qg(zIs,[["__scopeId","data-v-88da3b13"]]),YIs=["onClick"],XIs={key:0,class:"context-menu__divider"},qIs={key:0,class:"context-menu__icon"},GIs={class:"context-menu__label"},KIs={key:1,class:"context-menu__shortcut"},JIs=Xe({__name:"index",props:{items:{default:()=>[]}},emits:["select","close"],setup(e,{expose:t,emit:n}){const r=e,o=n,s=de(!1),a=de({x:0,y:0}),l=G(()=>r.items),d=G(()=>({left:`${a.value.x}px`,top:`${a.value.y}px`}));function u(A,m){a.value={x:A,y:m},s.value=!0,setTimeout(()=>{f()},0)}function h(){s.value=!1,o("close")}function f(){const A=document.querySelector(".context-menu");if(!A)return;const m=A.getBoundingClientRect(),v=window.innerWidth,p=window.innerHeight;let{x:b,y:O}=a.value;m.right>v&&(b=v-m.width-10),m.bottom>p&&(O=p-m.height-10),b<0&&(b=10),O<0&&(O=10),a.value={x:b,y:O}}function g(A){A.disabled||A.divider||(o("select",A.key),h())}function k(A){const m=A.target;s.value&&!m.closest(".context-menu")&&A.button===0&&h()}return mn(()=>{document.addEventListener("click",k),document.addEventListener("contextmenu",k)}),Pa(()=>{document.removeEventListener("click",k),document.removeEventListener("contextmenu",k)}),t({show:u,hide:h}),(A,m)=>(Ce(),St(a4,{to:"body"},[s.value?(Ce(),We("div",{key:0,class:"context-menu",style:eo(d.value),onContextmenu:m[0]||(m[0]=or(()=>{},["prevent"]))},[(Ce(!0),We(nn,null,bi(l.value,v=>(Ce(),We("div",{key:v.key,class:uo(["context-menu__item",{"context-menu__item--disabled":v.disabled,"context-menu__item--divider":v.divider,"context-menu__item--danger":v.danger}]),onClick:p=>g(v)},[v.divider?(Ce(),We("div",XIs)):v.slot?io(A.$slots,v.slot,{key:1,item:v}):(Ce(),We(nn,{key:2},[v.icon?(Ce(),We("span",qIs,De(v.icon),1)):Vt("",!0),he("span",GIs,De(v.label),1),v.shortcut?(Ce(),We("span",KIs,De(v.shortcut),1)):Vt("",!0)],64))],10,YIs))),128))],36)):Vt("",!0)]))}}),lvn={"zh-CN":{reset:"重置",undo:"撤销",redo:"重做",delete:"删除",play:"播放",pause:"暂停",snapOn:"关闭吸附",snapOff:"开启吸附",copy:"复制",cut:"剪切",paste:"粘贴",selectAll:"全选",splitClip:"分割",deleteClip:"删除片段",deleteTrack:"删除轨道",lockTrack:"锁定轨道",unlockTrack:"解锁轨道",muteTrack:"静音轨道",unmuteTrack:"取消静音",mainTrack:"主轨道",videoTrack:"视频轨道",audioTrack:"音频轨道",subtitleTrack:"字幕轨道",textTrack:"文本轨道",stickerTrack:"贴纸轨道",filterTrack:"滤镜轨道",effectTrack:"特效轨道",mainBadge:"主",show:"显示",hide:"隐藏",lock:"锁定",unlock:"解锁",emptyTip:"拖拽媒体文件到此处添加",emptyTrackHint:"拖拽媒体到这里",noClipSelected:"未选中片段",confirmDelete:"确定要删除吗?",confirmDeleteTrack:'确定要删除轨道"{name}"吗?'},"en-US":{reset:"Reset",undo:"Undo",redo:"Redo",delete:"Delete",play:"Play",pause:"Pause",snapOn:"Disable Snap",snapOff:"Enable Snap",copy:"Copy",cut:"Cut",paste:"Paste",selectAll:"Select All",splitClip:"Split",deleteClip:"Delete Clip",deleteTrack:"Delete Track",lockTrack:"Lock Track",unlockTrack:"Unlock Track",muteTrack:"Mute Track",unmuteTrack:"Unmute Track",mainTrack:"Main Track",videoTrack:"Video Track",audioTrack:"Audio Track",subtitleTrack:"Subtitle Track",textTrack:"Text Track",stickerTrack:"Sticker Track",filterTrack:"Filter Track",effectTrack:"Effect Track",mainBadge:"Main",show:"Show",hide:"Hide",lock:"Lock",unlock:"Unlock",emptyTip:"Drag and drop media files here to add",emptyTrackHint:"Drop media here",noClipSelected:"No clip selected",confirmDelete:"Are you sure to delete?",confirmDeleteTrack:'Are you sure to delete track "{name}"?'}},_Is={class:"video-track__body"},$Is={class:"video-track__empty-hint"},aMe="1.0.0",eNs=Xe({__name:"index",props:{operationButtons:{default:()=>["reset","undo","redo","delete"]},scaleConfigButtons:{default:()=>["snap"]},trackTypes:{default:()=>({video:{max:5},audio:{max:3},subtitle:{max:2}})},clipConfigs:{default:void 0},showToolsBar:{type:Boolean,default:!0},enableMainTrackMode:{type:Boolean,default:!1},enableCrossTrackDrag:{type:Boolean,default:!0},maxDuration:{},fps:{default:30},pixelsPerSecond:{default:100},minScale:{default:.1},maxScale:{default:10},defaultScale:{default:1},enableSnap:{type:Boolean,default:!0},snapThreshold:{default:10},playbackRates:{default:()=>[.5,1,2,4]},trackControlWidth:{default:160},trackContextMenu:{default:()=>({enabled:!0})},clipContextMenu:{default:()=>({showCommonItems:!0,commonItems:["copy","cut","delete"]})},locale:{default:"zh-CN"},theme:{default:void 0}},emits:["clipMove","clipDelete","clipSelect","clipCopy","clipCut","clipPaste","clipSplit","clip:added","clip:updated","clip:removed","clip:resize-start","clip:resize-end","clip:drag-start","clip:drag-end","trackCreate","trackDelete","track:added","track:removed","track:updated","selection:changed","playback:play","playback:pause","playback:seek","playback:timeupdate","playback:ratechange","scale:changed","history:changed","addTransition","transitionAdded","dropMedia","trackContextMenuSelect","clipContextMenuSelect","data:changed"],setup(e,{expose:t,emit:n}){const r={video:{name:"视频",backgroundColor:"linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)",borderColor:"rgba(255,255,255,0.2)",height:32,top:8,resizable:!0,draggable:!0,borderRadius:6,selected:{borderColor:"#fff",boxShadow:"0 0 0 2px rgba(59, 130, 246, 0.5), 0 4px 12px rgba(0,0,0,0.3)"},hover:{borderColor:"rgba(255,255,255,0.5)"}},audio:{name:"音频",backgroundColor:"linear-gradient(135deg, #10b981 0%, #059669 100%)",borderColor:"rgba(255,255,255,0.2)",height:24,top:12,resizable:!0,draggable:!0,borderRadius:4,selected:{borderColor:"#fff",boxShadow:"0 0 0 2px rgba(16, 185, 129, 0.5), 0 4px 12px rgba(0,0,0,0.3)"},hover:{borderColor:"rgba(255,255,255,0.5)"}},subtitle:{name:"字幕",backgroundColor:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",borderColor:"rgba(255,255,255,0.2)",height:24,top:12,resizable:!0,draggable:!0,borderRadius:4,selected:{borderColor:"#fff",boxShadow:"0 0 0 2px rgba(245, 158, 11, 0.5), 0 4px 12px rgba(0,0,0,0.3)"},hover:{borderColor:"rgba(255,255,255,0.5)"}},sticker:{name:"贴纸",backgroundColor:"linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%)",borderColor:"rgba(255,255,255,0.2)",height:24,top:12,resizable:!1,draggable:!0,borderRadius:4,selected:{borderColor:"#fff",boxShadow:"0 0 0 2px rgba(139, 92, 246, 0.5), 0 4px 12px rgba(0,0,0,0.3)"},hover:{borderColor:"rgba(255,255,255,0.5)"}},filter:{name:"滤镜",backgroundColor:"linear-gradient(135deg, #ec4899 0%, #db2777 100%)",borderColor:"rgba(255,255,255,0.2)",height:16,top:16,resizable:!1,draggable:!0,borderRadius:4,selected:{borderColor:"#fff",boxShadow:"0 0 0 2px rgba(236, 72, 153, 0.5), 0 4px 12px rgba(0,0,0,0.3)"},hover:{borderColor:"rgba(255,255,255,0.5)"}},effect:{name:"特效",backgroundColor:"linear-gradient(135deg, #6366f1 0%, #4f46e5 100%)",borderColor:"rgba(255,255,255,0.2)",height:16,top:16,resizable:!1,draggable:!0,borderRadius:4,selected:{borderColor:"#fff",boxShadow:"0 0 0 2px rgba(99, 102, 241, 0.5), 0 4px 12px rgba(0,0,0,0.3)"},hover:{borderColor:"rgba(255,255,255,0.5)"}},transition:{name:"转场",backgroundColor:"transparent",borderColor:"transparent",height:32,top:8,resizable:!1,draggable:!1}};function o(dt,lt){if(lt===null||typeof lt!="object"||dt===null||typeof dt!="object")return lt;const jt={...dt};for(const Tt in lt)if(lt.hasOwnProperty(Tt)){const gn=lt[Tt],Xt=jt[Tt];gn&&typeof gn=="object"&&!Array.isArray(gn)?jt[Tt]=o(Xt||{},gn):jt[Tt]=gn}return jt}function s(dt){if(!dt)return r;const lt={...r};for(const jt in dt)dt.hasOwnProperty(jt)&&(lt[jt]=o(lt[jt]||{},dt[jt]));return lt}const a=e,l=G(()=>{const dt=lvn["zh-CN"];return typeof a.locale=="string"?{...dt,...lvn[a.locale]||{}}:a.locale?{...dt,...a.locale}:dt}),d=G(()=>s(a.clipConfigs)),u=n,h=J1(),f=Y6(),g=WE(),k=Q2(),A=JZ();At(()=>a.enableCrossTrackDrag,dt=>{A.setConfig({enableCrossTrackDrag:dt})},{immediate:!0});const m=de();let v=[];At(()=>Array.from(h.selectedClipIds),dt=>{const lt=new Set(dt),jt=new Set(v);(lt.size!==jt.size||dt.some(Tt=>!jt.has(Tt)))&&(u("selection:changed",dt,v),u("clipSelect",dt),v=[...dt])},{deep:!0}),ZPs({containerRef:m,callbacks:{onCopy:dt=>{u("clipCopy",dt)},onCut:dt=>{u("clipCut",dt)},onDelete:dt=>{dt.forEach(lt=>u("clipDelete",lt))},onPaste:(dt,lt,jt)=>{u("clipPaste",dt,lt,jt)},onPlay:()=>{u("playback:play")},onPause:()=>{u("playback:pause")}}});let p=new Map;At(()=>A.isDragging,(dt,lt)=>{dt&&!lt?(p.clear(),A.draggedClips.forEach(jt=>{p.set(jt.id,{startTime:jt.startTime,trackId:jt.trackId})})):!dt&<&&(p.forEach((jt,Tt)=>{const gn=h.getClip(Tt);gn&&(gn.startTime!==jt.startTime||gn.trackId!==jt.trackId)&&(u("clipMove",Tt,gn.trackId,gn.startTime),u("clip:drag-end",gn,jt.trackId,gn.trackId))}),p.clear())});const b=de(0),O=de(0),w=de(a.trackControlWidth);YPs({scrollLeft:b,tracksWidth:O,setScrollLeft:dt=>{b.value=dt}});const y=de([]),C=de(null),x=de(null),L=de(0),S=de(null),T=de();mn(()=>{k.minScale=a.minScale,k.maxScale=a.maxScale,k.pixelsPerSecond=a.pixelsPerSecond,k.initScale(a.defaultScale),k.initSnapEnabled(a.enableSnap),k.snapThreshold=a.snapThreshold,g.initialize(),D(a.theme),Q(),window.addEventListener("resize",Q)}),At(()=>a.theme,dt=>{D(dt)},{deep:!0});function D(dt){if(!m.value||!dt)return;const lt=m.value;dt.primaryHue!==void 0&<.style.setProperty("--theme-hue",String(dt.primaryHue)),dt.primarySaturation!==void 0&<.style.setProperty("--theme-saturation",`${dt.primarySaturation}%`),dt.primaryLightness!==void 0&<.style.setProperty("--theme-lightness",`${dt.primaryLightness}%`),dt.primaryColor&<.style.setProperty("--color-primary",dt.primaryColor),dt.bgDark&<.style.setProperty("--color-bg-dark",dt.bgDark),dt.bgMedium&<.style.setProperty("--color-bg-medium",dt.bgMedium),dt.bgLight&<.style.setProperty("--color-bg-light",dt.bgLight),dt.bgElevated&<.style.setProperty("--color-bg-elevated",dt.bgElevated),dt.textPrimary&<.style.setProperty("--color-text-primary",dt.textPrimary),dt.textSecondary&<.style.setProperty("--color-text-secondary",dt.textSecondary),dt.textMuted&<.style.setProperty("--color-text-muted",dt.textMuted),dt.borderColor&<.style.setProperty("--color-border",dt.borderColor),dt.borderRadius&&(dt.borderRadius.sm!==void 0&<.style.setProperty("--radius-sm",`${dt.borderRadius.sm}px`),dt.borderRadius.md!==void 0&<.style.setProperty("--radius-md",`${dt.borderRadius.md}px`),dt.borderRadius.lg!==void 0&<.style.setProperty("--radius-lg",`${dt.borderRadius.lg}px`))}Pa(()=>{window.removeEventListener("resize",Q)});function Q(){if(m.value){const dt=m.value.getBoundingClientRect();O.value=dt.width-w.value}}function M(dt){Math.abs(w.value-dt)>1&&(w.value=dt,Q())}function B(dt){b.value=dt}function P(dt){b.value=dt}function F(dt){switch(dt){case"reset":R();break;case"undo":g.undo();break;case"redo":g.redo();break;case"split":I();break;case"delete":N();break}}function R(){h.reset(),f.reset(),g.reset(),k.reset(),a.enableMainTrackMode&&h.addTrack({id:`track-main-${Date.now()}`,type:"video",name:"主轨道",visible:!0,locked:!1,clips:[],order:0,isMain:!0}),g.initialize()}function N(){const dt=Array.from(h.selectedClipIds);dt.length!==0&&(h.removeClips(dt),g.pushSnapshot("删除片段"),dt.forEach(lt=>{u("clipDelete",lt)}))}function I(){const dt=Array.from(h.selectedClipIds);if(dt.length===0)return;const lt=f.currentTime;dt.forEach(jt=>{const Tt=h.getClip(jt);if(!Tt||lt<=Tt.startTime||lt>=Tt.endTime)return;const gn=h.splitClip(jt,lt);gn&&u("clipSplit",jt,gn.leftClip,gn.rightClip,lt)}),g.pushSnapshot("分割片段")}function W(dt,lt){u("addTransition",dt,lt)}function V(dt,lt,jt){u("dropMedia",dt,lt,jt)}function z(dt){u("playback:seek",dt)}const Y=()=>({copy:{key:"copy",label:l.value.copy||"复制",icon:"📋",shortcut:"Ctrl+C"},cut:{key:"cut",label:l.value.cut||"剪切",icon:"✂️",shortcut:"Ctrl+X"},delete:{key:"delete",label:l.value.deleteClip||"删除",icon:"🗑️",danger:!0,shortcut:"Delete"}});function K(dt,lt){var jt;C.value=dt,x.value=null,S.value="clip";const Tt=[],gn=a.clipContextMenu,Xt=Y();(gn==null?void 0:gn.showCommonItems)!==!1&&((gn==null?void 0:gn.commonItems)||["copy","cut","delete"]).forEach(Jr=>{if(typeof Jr=="string"){const Zn=Xt[Jr];Zn&&Tt.push({...Zn})}else Tt.push(Jr)}),gn!=null&&gn.byType&&gn.byType[dt.type]&&(Tt.length>0&&Tt.push({key:"divider-type",label:"",divider:!0}),Tt.push(...gn.byType[dt.type])),gn!=null&&gn.extraItems&&gn.extraItems.length>0&&(Tt.length>0&&Tt.push({key:"divider-extra",label:"",divider:!0}),Tt.push(...gn.extraItems)),y.value=Tt,(jt=T.value)==null||jt.show(lt.clientX,lt.clientY)}function X(dt,lt,jt){var Tt,gn,Xt;if(((Tt=a.trackContextMenu)==null?void 0:Tt.enabled)===!1)return;C.value=null,x.value=dt,L.value=lt,S.value="track";const Jr=[{key:"paste",label:l.value.paste||"粘贴",icon:"📋",shortcut:"Ctrl+V",disabled:!h.hasClipboardContent()},{key:"divider-1",label:"",divider:!0},{key:"lockTrack",label:dt.locked?l.value.unlockTrack||"解锁轨道":l.value.lockTrack||"锁定轨道",icon:dt.locked?"🔓":"🔒"},{key:"deleteTrack",label:l.value.deleteTrack||"删除轨道",icon:"🗑️",danger:!0,disabled:dt.isMain}],Zn=((gn=a.trackContextMenu)==null?void 0:gn.items)||Jr;y.value=Zn,(Xt=T.value)==null||Xt.show(jt.clientX,jt.clientY)}function _(dt){if(S.value==="clip"&&C.value){const lt=C.value;switch(dt){case"copy":q(lt);break;case"cut":re(lt);break;case"delete":h.removeClip(lt.id),g.pushSnapshot("删除片段"),u("clipDelete",lt.id);break;default:u("clipContextMenuSelect",dt,lt)}}if(S.value==="track"&&x.value){const lt=x.value,jt=L.value;switch(dt){case"paste":le(lt.id,jt);break;case"lockTrack":ce(lt);break;case"deleteTrack":me(lt);break;default:u("trackContextMenuSelect",dt,lt,jt)}}C.value=null,x.value=null,S.value=null,y.value=[]}function q(dt){if(!h.selectedClipIds.has(dt.id))h.copyClips([dt.id]),u("clipCopy",[dt.id]);else{const lt=Array.from(h.selectedClipIds);h.copyClips(lt),u("clipCopy",lt)}}function re(dt){if(!h.selectedClipIds.has(dt.id))h.cutClips([dt.id]),u("clipCut",[dt.id]);else{const lt=Array.from(h.selectedClipIds);h.cutClips(lt),u("clipCut",lt)}}function le(dt,lt){const jt=h.pasteClips(dt,lt);jt&&(g.pushSnapshot("粘贴片段"),u("clipPaste",jt,dt,lt))}function ce(dt){h.updateTrack(dt.id,{locked:!dt.locked}),g.pushSnapshot(dt.locked?"解锁轨道":"锁定轨道")}function me(dt){if(dt.isMain)return;const lt=(l.value.confirmDeleteTrack||'确定要删除轨道"{name}"吗?').replace("{name}",dt.name);confirm(lt)&&(h.removeTrack(dt.id),g.pushSnapshot("删除轨道"),u("trackDelete",dt.id))}const ie=G(()=>({trackTypes:a.trackTypes,clipConfigs:d.value,enableMainTrackMode:a.enableMainTrackMode,enableCrossTrackDrag:a.enableCrossTrackDrag,maxDuration:a.maxDuration,fps:a.fps,playbackRates:a.playbackRates,trackControlWidth:a.trackControlWidth}));er("config",ie);function Ae(dt,lt){d.value[dt]?d.value[dt]=o(d.value[dt],lt):d.value[dt]=lt}function H(dt,lt,jt){u("transitionAdded",dt,lt,jt)}function ee(){return{version:aMe,tracks:JSON.parse(JSON.stringify(h.tracks)),currentTime:f.currentTime,scale:k.scale,snapEnabled:k.snapEnabled}}function oe(dt){dt.version&&dt.version!==aMe&&console.warn(`[VideoTrack] 数据版本不匹配: ${dt.version} -> ${aMe}`),h.setTracks(dt.tracks||[]),dt.currentTime!==void 0&&f.seekTo(dt.currentTime),dt.scale!==void 0&&k.setScale(dt.scale),dt.snapEnabled!==void 0&&k.setSnapEnabled(dt.snapEnabled),g.initialize(),u("data:changed")}function te(){return JSON.stringify(ee(),null,2)}function J(dt){try{const lt=JSON.parse(dt);return oe(lt),!0}catch(lt){return console.error("[VideoTrack] JSON 解析失败:",lt),!1}}function se(dt){h.addTrack(dt),g.pushSnapshot("添加轨道"),u("track:added",dt),u("trackCreate",dt.id)}function ke(dt){const lt=h.tracks.find(jt=>jt.id===dt);lt&&(h.removeTrack(dt),g.pushSnapshot("删除轨道"),u("track:removed",lt),u("trackDelete",dt))}function ye(dt,lt){h.updateTrack(dt,lt),g.pushSnapshot("更新轨道"),u("track:updated",dt,lt)}function Qe(){return h.tracks}function xe(){return h.sortedTracks}function fe(dt){return h.tracks.find(lt=>lt.id===dt)}function be(){return h.mainTrack}function Se(dt,lt){h.addClip(dt,lt),g.pushSnapshot("添加片段"),u("clip:added",lt,dt)}function Fe(dt){const lt=h.getClip(dt);if(lt){const jt=lt.trackId;h.removeClip(dt),g.pushSnapshot("删除片段"),u("clip:removed",lt,jt),u("clipDelete",dt)}}function Re(dt,lt){const jt=h.getClip(dt);if(jt){const Tt={...jt};h.updateClip(dt,lt),g.pushSnapshot("更新片段"),u("clip:updated",dt,lt,Tt)}}function Ge(dt){return h.getClip(dt)}function Ye(dt,lt,jt){const Tt=h.getClip(dt);if(!Tt)return!1;const gn=Tt.trackId,Xt=Tt.endTime-Tt.startTime;return gn!==lt&&h.moveClipToTrack(dt,lt),h.updateClip(dt,{startTime:jt,endTime:jt+Xt}),g.pushSnapshot("移动片段"),u("clipMove",dt,lt,jt),u("clip:drag-end",Tt,gn,lt),!0}function _e(dt,lt,jt){const Tt=h.setClipPlaybackRate(dt,lt,jt);return Tt.success&&(g.pushSnapshot("调整倍速"),h.getClip(dt)&&u("clip:updated",dt,{playbackRate:lt},{})),Tt}function vt(dt,lt){return h.getClipDurationAtRate(dt,lt)}function Je(dt,lt,jt=!0){return h.checkPlaybackRateCollision(dt,lt,jt)}function tt(dt){h.selectClip(dt)}function yt(dt){h.clearSelection(),dt.forEach(lt=>h.selectedClipIds.add(lt))}function Pt(){h.clearSelection()}function Ut(){return h.selectedClips}function je(){return Array.from(h.selectedClipIds)}function gt(){f.play(),u("playback:play")}function Zt(){f.pause(),u("playback:pause")}function pt(){f.isPlaying?Zt():gt()}function wt(dt){f.seekTo(dt),u("playback:seek",dt)}function Yt(){return f.currentTime}function yn(dt){f.setPlaybackRate(dt),u("playback:ratechange",dt)}function Qn(){return f.playbackRate}function ui(){return f.isPlaying}function Ni(){return h.totalDuration}function hi(dt){k.setScale(dt),u("scale:changed",dt)}function Lr(){return k.scale}function Gr(dt=.1){k.zoomIn(dt),u("scale:changed",k.scale)}function Dr(dt=.1){k.zoomOut(dt),u("scale:changed",k.scale)}function Qo(){k.setSnapEnabled(!0)}function Ti(){k.setSnapEnabled(!1)}function oi(){return k.snapEnabled}function cr(){return{canUndo:g.canUndo,canRedo:g.canRedo}}function bs(){g.undo(),u("history:changed",cr())}function Rs(){g.redo(),u("history:changed",cr())}return t({reset:R,registerClipType:Ae,emitTransitionAdded:H,exportData:ee,importData:oe,exportAsJSON:te,importFromJSON:J,addTrack:se,removeTrack:ke,updateTrack:ye,getTracks:Qe,getSortedTracks:xe,getTrackById:fe,getMainTrack:be,addClip:Se,removeClip:Fe,updateClip:Re,getClipById:Ge,moveClip:Ye,setClipPlaybackRate:_e,getClipDurationAtRate:vt,checkPlaybackRateCollision:Je,selectClip:tt,selectClips:yt,clearSelection:Pt,getSelectedClips:Ut,getSelectedClipIds:je,play:gt,pause:Zt,togglePlay:pt,seekTo:wt,getCurrentTime:Yt,setPlaybackRate:yn,getPlaybackRate:Qn,isPlaying:ui,getDuration:Ni,setScale:hi,getScale:Lr,zoomIn:Gr,zoomOut:Dr,enableSnap:Qo,disableSnap:Ti,isSnapEnabled:oi,undo:bs,redo:Rs,getHistoryState:cr}),(dt,lt)=>(Ce(),We("div",{class:"video-track",ref_key:"containerRef",ref:m},[io(dt.$slots,"toolbar-before",{},void 0,!0),e.showToolsBar?(Ce(),St(OMs,{key:0,"operation-buttons":e.operationButtons,"scale-config-buttons":e.scaleConfigButtons,locale:l.value,onOperation:F,"onPlayback:play":lt[0]||(lt[0]=()=>u("playback:play")),"onPlayback:pause":lt[1]||(lt[1]=()=>u("playback:pause"))},Lj({"operations-prepend":ve(()=>[io(dt.$slots,"operations-prepend",{},void 0,!0)]),"operations-append":ve(()=>[io(dt.$slots,"operations-append",{},void 0,!0)]),"playback-prepend":ve(()=>[io(dt.$slots,"playback-prepend",{},void 0,!0)]),"playback-append":ve(()=>[io(dt.$slots,"playback-append",{},void 0,!0)]),"scale-prepend":ve(()=>[io(dt.$slots,"scale-prepend",{},void 0,!0)]),"scale-append":ve(()=>[io(dt.$slots,"scale-append",{},void 0,!0)]),_:2},[bi(dt.$slots,(jt,Tt)=>({name:Tt,fn:ve(gn=>[io(dt.$slots,Tt,H9(Hx(gn)),void 0,!0)])}))]),1032,["operation-buttons","scale-config-buttons","locale"])):Vt("",!0),io(dt.$slots,"toolbar-after",{},void 0,!0),io(dt.$slots,"ruler-before",{},void 0,!0),c(CMs,{width:O.value,"scroll-left":b.value,"track-control-width":w.value,onScroll:B,onSeek:z},null,8,["width","scroll-left","track-control-width"]),io(dt.$slots,"ruler-after",{},void 0,!0),he("div",_Is,[io(dt.$slots,"tracks-before",{},void 0,!0),c(ZIs,{"scroll-left":b.value,locale:l.value,onScroll:P,onContextMenu:K,onTrackContextMenu:X,onAddTransition:W,onDropMedia:V,"onUpdate:trackControlWidth":M,onSeek:z},Lj({"track-control":ve(jt=>[io(dt.$slots,"track-control",H9(Hx(jt)),void 0,!0)]),"track-area":ve(jt=>[io(dt.$slots,"track-area",H9(Hx(jt)),void 0,!0)]),"clip-content":ve(jt=>[io(dt.$slots,"clip-content",H9(Hx(jt)),void 0,!0)]),"empty-track":ve(jt=>[io(dt.$slots,"empty-track",H9(Hx(jt)),()=>[he("div",$Is,De(l.value.emptyTrackHint),1)],!0)]),_:2},[bi(dt.$slots,(jt,Tt)=>({name:Tt,fn:ve(gn=>[io(dt.$slots,Tt,H9(Hx(gn)),void 0,!0)])}))]),1032,["scroll-left","locale"]),io(dt.$slots,"tracks-after",{},void 0,!0)]),c(JIs,{ref_key:"contextMenuRef",ref:T,items:y.value,onSelect:_},{"menu-item":ve(jt=>[io(dt.$slots,"context-menu-item",H9(Hx(jt)),void 0,!0)]),_:3},8,["items"]),io(dt.$slots,"statusbar",{},void 0,!0)],512))}}),tNs=Qg(eNs,[["__scopeId","data-v-aa0c76f8"]]);function nNs(){return[{id:"text-1",type:"subtitle",name:$t("workbench.production.media.titleText"),preview:"Aa",duration:3},{id:"text-2",type:"subtitle",name:$t("workbench.production.media.subtitleText"),preview:$t("workbench.production.media.subtitlePreview"),duration:3},{id:"text-3",type:"text",name:$t("workbench.production.media.customText"),preview:"Text",duration:3}]}function iNs(){return[{id:"trans-1",type:"transition",subType:"fade",name:$t("workbench.production.transition.fade"),icon:"i-round"},{id:"trans-2",type:"transition",subType:"slide",name:$t("workbench.production.transition.slide"),icon:"i-right"},{id:"trans-3",type:"transition",subType:"wipe",name:$t("workbench.production.transition.wipe"),icon:"i-erase"},{id:"trans-4",type:"transition",subType:"dissolve",name:$t("workbench.production.transition.dissolve"),icon:"i-platte"},{id:"trans-5",type:"transition",subType:"zoom",name:$t("workbench.production.transition.zoom"),icon:"i-zoom-in"},{id:"trans-6",type:"transition",subType:"rotate",name:$t("workbench.production.transition.rotate"),icon:"i-redo"}]}function rNs(){return[{id:"fadeIn",type:"effect",effectType:"fadeIn",name:$t("workbench.production.effect.fadeIn"),icon:"i-sun-one"},{id:"fadeOut",type:"effect",effectType:"fadeOut",name:$t("workbench.production.effect.fadeOut"),icon:"i-moon"},{id:"flash",type:"effect",effectType:"flash",name:$t("workbench.production.effect.flash"),icon:"i-flashlamp"},{id:"shake",type:"effect",effectType:"shake",name:$t("workbench.production.effect.shake"),icon:"i-shake"},{id:"zoomIn",type:"effect",effectType:"zoomIn",name:$t("workbench.production.effect.zoomIn"),icon:"i-zoom-in"},{id:"zoomOut",type:"effect",effectType:"zoomOut",name:$t("workbench.production.effect.zoomOut"),icon:"i-zoom-out"},{id:"pulse",type:"effect",effectType:"pulse",name:$t("workbench.production.effect.pulse"),icon:"i-heartbeat"},{id:"rotateIn",type:"effect",effectType:"rotateIn",name:$t("workbench.production.effect.rotateIn"),icon:"i-redo"},{id:"sticker-1",type:"sticker",name:$t("workbench.production.effect.sticker1"),icon:"i-emotion-happy"},{id:"sticker-2",type:"sticker",name:$t("workbench.production.effect.sticker2"),icon:"i-star"}]}function oNs(){return[{id:"grayscale",type:"filter",filterType:"grayscale",filterValue:1,name:$t("workbench.production.filter.grayscale"),icon:"i-dark-mode"},{id:"sepia",type:"filter",filterType:"sepia",filterValue:1,name:$t("workbench.production.filter.sepia"),icon:"i-camera-one"},{id:"warm",type:"filter",filterType:"sepia",filterValue:.3,name:$t("workbench.production.filter.warm"),icon:"i-fire"},{id:"cool",type:"filter",filterType:"hue-rotate",filterValue:180,name:$t("workbench.production.filter.cool"),icon:"i-snowflake"},{id:"saturate",type:"filter",filterType:"saturate",filterValue:2,name:$t("workbench.production.filter.vivid"),icon:"i-brightness"},{id:"brightness",type:"filter",filterType:"brightness",filterValue:1.3,name:$t("workbench.production.filter.bright"),icon:"i-sun-one"},{id:"contrast",type:"filter",filterType:"contrast",filterValue:1.5,name:$t("workbench.production.filter.highContrast"),icon:"i-contrast-view"},{id:"blur",type:"filter",filterType:"blur",filterValue:3,name:$t("workbench.production.filter.blur"),icon:"i-fog"},{id:"invert",type:"filter",filterType:"invert",filterValue:1,name:$t("workbench.production.filter.invert"),icon:"i-reverse-rotation"},{id:"opacity",type:"filter",filterType:"opacity",filterValue:.5,name:$t("workbench.production.filter.semiTransparent"),icon:"i-ghost"}]}function sNs(){return[{id:"video",label:$t("workbench.production.media.video"),icon:"i-video-file"},{id:"media",label:$t("workbench.production.media.media"),icon:"i-video"},{id:"image",label:$t("workbench.production.media.image"),icon:"i-pic"},{id:"audio",label:$t("workbench.production.media.audio"),icon:"i-music"},{id:"text",label:$t("workbench.production.media.subtitle"),icon:"i-text"},{id:"transition",label:$t("workbench.production.media.transition"),icon:"i-switch-themes"},{id:"effect",label:$t("workbench.production.media.effect"),icon:"i-magic"},{id:"filter",label:$t("workbench.production.media.filter"),icon:"i-color-filter"}]}function lMe(e){if(e===0)return $t("workbench.production.media.loading");const t=Math.floor(e/60),n=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,"0")}`:`${n.toFixed(1)}s`}const aNs={class:"mediaLibrary"},lNs={class:"mediaLibraryHeader"},cNs={class:"headerTitle jb ac"},dNs={class:"mediaLibraryTitle"},uNs={class:"mediaLibraryTabs"},hNs={class:"mediaLibraryContent"},ANs={key:0,class:"mediaList"},fNs=["onDragstart"],gNs={class:"mediaItemPreview"},mNs={key:2,class:"mediaItemLoading"},kNs={class:"mediaItemInfo"},vNs={key:0,class:"selected"},pNs={class:"mediaItemName"},bNs={key:1,class:"mediaList"},ONs=["onDragstart"],wNs={class:"mediaItemPreview"},yNs={key:2,class:"mediaItemLoading"},CNs={class:"mediaItemInfo"},xNs={class:"mediaItemName"},LNs={key:2,class:"mediaList"},SNs=["onDragstart"],TNs={class:"mediaItemPreview"},ENs={key:2,class:"mediaItemLoading"},DNs={class:"mediaItemInfo"},QNs={class:"mediaItemName"},BNs={key:3,class:"transitionList"},FNs=["onDragstart"],PNs={class:"transitionItemPreview"},MNs={class:"transitionItemIcon"},RNs={class:"transitionItemName"},INs={key:4,class:"effectList"},NNs=["onDragstart"],UNs={class:"effectItemPreview"},jNs={class:"effectItemName"},WNs={key:5,class:"filterList"},HNs=["onDragstart"],VNs={class:"filterItemPreview"},zNs={class:"filterItemName"},ZNs={key:6,class:"audioList"},YNs=["onDragstart"],XNs={class:"audioItemPreview"},qNs={key:0,class:"mediaItemLoading"},GNs={class:"audioItemInfo"},KNs={class:"audioItemName"},JNs={key:7,class:"textList"},_Ns=["onDragstart"],$Ns={class:"textItemPreview"},eUs={class:"textItemContent"},tUs={class:"textItemName"},nUs=Xe({__name:"mediaLibrary",props:{initialVideoItems:{default:()=>[]},initialMediaItems:{default:()=>[]},initialAudioItems:{default:()=>[]},initialImageItems:{default:()=>[]}},setup(e){const t=e,n=de("video"),r=sNs(),o=de([...t.initialVideoItems]),s=de([...t.initialMediaItems]),a=de([...t.initialAudioItems]),l=de([...t.initialImageItems]),d=de(nNs());At(()=>t.initialVideoItems,p=>{o.value=[...p],p.length>0&&g()}),At(()=>t.initialMediaItems,p=>{s.value=[...p],p.length>0&&g()}),At(()=>t.initialAudioItems,p=>{a.value=[...p],p.length>0&&A()}),At(()=>t.initialImageItems,p=>{l.value=[...p],p.length>0&&k()});const u=de(iNs()),h=de(rNs()),f=de(oNs());async function g(){for(const p of s.value)try{const b=await wve(p.url,{count:10,width:120});p.duration=b.duration,p.thumbnails=b.thumbnails,p.thumbnail=b.thumbnails[0]||"",p.loading=!1}catch(b){console.error(`Failed to load thumbnails for ${p.name}:`,b),p.loading=!1,p.duration=5}for(const p of o.value)try{const b=await wve(p.url,{count:10,width:120});p.duration=b.duration,p.thumbnails=b.thumbnails,p.thumbnail=b.thumbnails[0]||"",p.loading=!1}catch(b){console.error(`Failed to load thumbnails for ${p.name}:`,b),p.loading=!1,p.duration=5}}async function k(){for(const p of l.value)try{const b=new Image;b.crossOrigin="anonymous",await new Promise((O,w)=>{b.onload=()=>{p.thumbnail=p.url,p.loading=!1,O()},b.onerror=w,b.src=p.url})}catch(b){console.error(`Failed to load image ${p.name}:`,b),p.loading=!1}}async function A(){for(const p of a.value)try{const b=await Uat(p.url,{samples:50});p.duration=b.duration,p.waveformData=b.waveformData,p.loading=!1}catch(b){console.error(`Failed to load waveform for ${p.name}:`,b),p.loading=!1,p.duration=30}}function m(p,b){if(!p.dataTransfer)return;const O={...b,sourceUrl:b.url||b.id};p.dataTransfer.effectAllowed="copy",p.dataTransfer.setData("application/json",JSON.stringify(O)),p.dataTransfer.setData("text/plain",b.name),p.target instanceof HTMLElement&&p.target.classList.add("dragging")}function v(p){p.target instanceof HTMLElement&&p.target.classList.remove("dragging")}return mn(()=>{setTimeout(()=>{g(),A(),k()},100)}),(p,b)=>{const O=vi,w=Wu,y=qc,C=kn("i-check-one"),x=bg,L=Gd,S=kn("i-music");return Ce(),We("div",aNs,[he("div",lNs,[he("div",cNs,[he("h3",dNs,De(p.$t("workbench.production.editVideo.clipMaterials")),1),b[0]||(b[0]=he("span",{style:{"font-size":"12px"}},"视频素材名字按照分镜台组#号数字命名",-1))]),he("div",uNs,[(Ce(!0),We(nn,null,bi(ge(r),T=>(Ce(),St(O,{key:T.id,theme:ge(n)===T.id?"primary":"default",variant:ge(n)===T.id?"base":"text",size:"small",onClick:D=>n.value=T.id},{icon:ve(()=>[(Ce(),St(Ud(T.icon),{theme:"outline",size:"18",style:{"margin-right":"4px"}}))]),default:ve(()=>[kt(" "+De(T.label),1)]),_:2},1032,["theme","variant","onClick"]))),128))])]),he("div",hNs,[ge(n)==="video"?(Ce(),We("div",ANs,[(Ce(!0),We(nn,null,bi(ge(o),T=>(Ce(),We("div",{key:T.id,class:"mediaItem",draggable:"true",onDragstart:D=>m(D,T),onDragend:v},[he("div",gNs,[T.thumbnail?(Ce(),St(w,{key:0,src:T.thumbnail,fit:"cover",class:"mediaItemThumbnail"},null,8,["src"])):(Ce(),St(Ud(T.icon),{key:1,theme:"outline",size:"18"})),T.loading?(Ce(),We("div",mNs,[c(y,{size:"small"})])):Vt("",!0)]),he("div",kNs,[T.selected?(Ce(),We("div",vNs,[c(C,{theme:"filled",size:"16",fill:"#000000"})])):Vt("",!0),he("div",pNs,[c(x,{content:T.name},{default:ve(()=>[kt(De(T.name),1)]),_:2},1032,["content"])]),T.duration?(Ce(),St(L,{key:1,size:"small",theme:"default",variant:"light"},{default:ve(()=>[kt(De(ge(lMe)(T.duration)),1)]),_:2},1024)):Vt("",!0)])],40,fNs))),128))])):Vt("",!0),ge(n)==="media"?(Ce(),We("div",bNs,[(Ce(!0),We(nn,null,bi(ge(s),T=>(Ce(),We("div",{key:T.id,class:"mediaItem",draggable:"true",onDragstart:D=>m(D,T),onDragend:v},[he("div",wNs,[T.thumbnail?(Ce(),St(w,{key:0,src:T.thumbnail,fit:"cover",class:"mediaItemThumbnail"},null,8,["src"])):(Ce(),St(Ud(T.icon),{key:1,theme:"outline",size:"18"})),T.loading?(Ce(),We("div",yNs,[c(y,{size:"small"})])):Vt("",!0)]),he("div",CNs,[he("div",xNs,[c(x,{content:T.name},{default:ve(()=>[kt(De(T.name),1)]),_:2},1032,["content"])]),T.duration?(Ce(),St(L,{key:0,size:"small",theme:"default",variant:"light"},{default:ve(()=>[kt(De(ge(lMe)(T.duration)),1)]),_:2},1024)):Vt("",!0)])],40,ONs))),128))])):Vt("",!0),ge(n)==="image"?(Ce(),We("div",LNs,[(Ce(!0),We(nn,null,bi(ge(l),T=>(Ce(),We("div",{key:T.id,class:"mediaItem",draggable:"true",onDragstart:D=>m(D,T),onDragend:v},[he("div",TNs,[T.thumbnail?(Ce(),St(w,{key:0,src:T.thumbnail,fit:"cover",class:"mediaItemThumbnail"},null,8,["src"])):(Ce(),St(Ud(T.icon),{key:1,theme:"outline",size:"18"})),T.loading?(Ce(),We("div",ENs,[c(y,{size:"small"})])):Vt("",!0)]),he("div",DNs,[he("div",QNs,[c(x,{content:T.name},{default:ve(()=>[kt(De(T.name),1)]),_:2},1032,["content"])])])],40,SNs))),128))])):Vt("",!0),ge(n)==="transition"?(Ce(),We("div",BNs,[(Ce(!0),We(nn,null,bi(ge(u),T=>(Ce(),We("div",{key:T.id,class:"transitionItem",draggable:"true",onDragstart:D=>m(D,T),onDragend:v},[he("div",PNs,[he("span",MNs,[(Ce(),St(Ud(T.icon),{theme:"outline",size:"18"}))])]),he("div",RNs,[c(x,{content:T.name},{default:ve(()=>[kt(De(T.name),1)]),_:2},1032,["content"])])],40,FNs))),128))])):Vt("",!0),ge(n)==="effect"?(Ce(),We("div",INs,[(Ce(!0),We(nn,null,bi(ge(h),T=>(Ce(),We("div",{key:T.id,class:"effectItem",draggable:"true",onDragstart:D=>m(D,T),onDragend:v},[he("div",UNs,[(Ce(),St(Ud(T.icon),{theme:"outline",size:"18"}))]),he("div",jNs,[c(x,{content:T.name},{default:ve(()=>[kt(De(T.name),1)]),_:2},1032,["content"])])],40,NNs))),128))])):Vt("",!0),ge(n)==="filter"?(Ce(),We("div",WNs,[(Ce(!0),We(nn,null,bi(ge(f),T=>(Ce(),We("div",{key:T.id,class:"filterItem",draggable:"true",onDragstart:D=>m(D,T),onDragend:v},[he("div",VNs,[(Ce(),St(Ud(T.icon),{theme:"outline",size:"18"}))]),he("div",zNs,[c(x,{content:T.name},{default:ve(()=>[kt(De(T.name),1)]),_:2},1032,["content"])])],40,HNs))),128))])):Vt("",!0),ge(n)==="audio"?(Ce(),We("div",ZNs,[(Ce(!0),We(nn,null,bi(ge(a),T=>(Ce(),We("div",{key:T.id,class:"audioItem",draggable:"true",onDragstart:D=>m(D,T),onDragend:v},[he("div",XNs,[c(S,{theme:"outline",size:"18"}),T.loading?(Ce(),We("div",qNs,[c(y,{size:"small"})])):Vt("",!0)]),he("div",GNs,[he("div",KNs,[c(x,{content:T.name},{default:ve(()=>[kt(De(T.name),1)]),_:2},1032,["content"])]),T.duration?(Ce(),St(L,{key:0,size:"small",theme:"default",variant:"light"},{default:ve(()=>[kt(De(ge(lMe)(T.duration)),1)]),_:2},1024)):Vt("",!0)])],40,YNs))),128))])):Vt("",!0),ge(n)==="text"?(Ce(),We("div",JNs,[(Ce(!0),We(nn,null,bi(ge(d),T=>(Ce(),We("div",{key:T.id,class:"textItem",draggable:"true",onDragstart:D=>m(D,T),onDragend:v},[he("div",$Ns,[he("span",eUs,De(T.preview),1)]),he("div",tUs,[c(x,{content:T.name},{default:ve(()=>[kt(De(T.name),1)]),_:2},1032,["content"])])],40,_Ns))),128))])):Vt("",!0)])])}}}),iUs=Fr(nUs,[["__scopeId","data-v-ea61ae0d"]]),VAe=["t","b","l","r","lt","lb","rt","rb","rotate"];function Sz(e){return document.createElement(e)}const cMe=new WeakMap;function J_n(e,t){if(cMe.has(e))return cMe.get(e)(t);let n=10;new ResizeObserver(o=>{const s=o[0];s!=null&&(n=10/(s.contentRect.width/e.width))}).observe(e);function r(o){const{w:s,h:a}=o,l=n,d=l/2,u=s/2,h=a/2,f=l*1.5,g=f/2;return{...o.fixedAspectRatio?{}:{t:new M3(-d,-h-d,l,l,o),b:new M3(-d,h-d,l,l,o),l:new M3(-u-d,-d,l,l,o),r:new M3(u-d,-d,l,l,o)},lt:new M3(-u-d,-h-d,l,l,o),lb:new M3(-u-d,h-d,l,l,o),rt:new M3(u-d,-h-d,l,l,o),rb:new M3(u-d,h-d,l,l,o),rotate:new M3(-g,-h-l*2-g,f,f,o)}}return cMe.set(e,r),r(t)}const dMe=new WeakMap;function moe(e){if(dMe.has(e))return dMe.get(e);const t={w:e.clientWidth/e.width,h:e.clientHeight/e.height};return new ResizeObserver(()=>{t.w=e.clientWidth/e.width,t.h=e.clientHeight/e.height}).observe(e),dMe.set(e,t),t}var _te=(e=>(e.ActiveSpriteChange="activeSpriteChange",e.AddSprite="addSprite",e))(_te||{}),mv,rB,oB,vH;class rUs{constructor(){fn(this,mv,[]);fn(this,rB,null);fn(this,oB,new oP);jn(this,"on",we(this,oB).on);fn(this,vH,0)}get activeSprite(){return we(this,rB)}set activeSprite(t){t===we(this,rB)||(t==null?void 0:t.interactable)==="disabled"||(rn(this,rB,t),we(this,oB).emit("activeSpriteChange",t))}activeSpriteByCoord(t,n){this.activeSprite=this.getSprites().reverse().find(r=>r.visible&&r.interactable!=="disabled"&&r.rect.checkHit(t,n))??null}async addSprite(t){await t.ready,we(this,mv).push(t),rn(this,mv,we(this,mv).sort((n,r)=>n.zIndex-r.zIndex)),t.on("propsChange",n=>{n.zIndex!=null&&rn(this,mv,we(this,mv).sort((r,o)=>r.zIndex-o.zIndex))}),we(this,oB).emit("addSprite",t)}removeSprite(t){we(this,rB)===t&&(this.activeSprite=null),rn(this,mv,we(this,mv).filter(n=>n!==t)),t.destroy()}getSprites(t={time:!0}){return we(this,mv).filter(n=>n.visible&&(t.time?we(this,vH)>=n.time.offset&&we(this,vH)<=n.time.offset+n.time.duration:!0))}updateRenderTime(t){rn(this,vH,t);const n=this.activeSprite;n!=null&&(tn.time.offset+n.time.duration)&&(this.activeSprite=null)}destroy(){we(this,oB).destroy(),we(this,mv).forEach(t=>t.destroy()),rn(this,mv,[])}}mv=new WeakMap,rB=new WeakMap,oB=new WeakMap,vH=new WeakMap;const oUs=` @@ -16098,7 +16098,7 @@ ${g$n(r)}`;return n}}function g$n(e){let t=`*@${e.name}*`;if(e.name==="param"&&e >>= <<= `),$Xs=/enable|requires|diagnostic/,T2n=new RegExp("[_\\p{XID_Start}]\\p{XID_Continue}*","u"),xN="variable.predefined",eqs={tokenPostfix:".wgsl",defaultToken:"invalid",unicode:!0,atoms:zXs,keywords:ZXs,reserved:YXs,predeclared_enums:XXs,predeclared_types:qXs,predeclared_type_generators:GXs,predeclared_type_aliases:KXs,predeclared_intrinsics:JXs,operators:_Xs,symbols:/[!%&*+\-\.\/:;<=>^|_~,]+/,tokenizer:{root:[[$Xs,"keyword","@directive"],[T2n,{cases:{"@atoms":xN,"@keywords":"keyword","@reserved":"invalid","@predeclared_enums":xN,"@predeclared_types":xN,"@predeclared_type_generators":xN,"@predeclared_type_aliases":xN,"@predeclared_intrinsics":xN,"@default":"identifier"}}],{include:"@commentOrSpace"},{include:"@numbers"},[/[{}()\[\]]/,"@brackets"],["@","annotation","@attribute"],[/@symbols/,{cases:{"@operators":"operator","@default":"delimiter"}}],[/./,"invalid"]],commentOrSpace:[[/\s+/,"white"],[/\/\*/,"comment","@blockComment"],[/\/\/.*$/,"comment"]],blockComment:[[/[^\/*]+/,"comment"],[/\/\*/,"comment","@push"],[/\*\//,"comment","@pop"],[/[\/*]/,"comment"]],attribute:[{include:"@commentOrSpace"},[/\w+/,"annotation","@pop"]],directive:[{include:"@commentOrSpace"},[/[()]/,"@brackets"],[/,/,"delimiter"],[T2n,"meta.content"],[/;/,"delimiter","@pop"]],numbers:[[/0[fh]/,"number.float"],[/[1-9][0-9]*[fh]/,"number.float"],[/[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[fh]?/,"number.float"],[/[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?[fh]?/,"number.float"],[/[0-9]+[eE][+-]?[0-9]+[fh]?/,"number.float"],[/0[xX][0-9a-fA-F]*\.[0-9a-fA-F]+(?:[pP][+-]?[0-9]+[fh]?)?/,"number.hex"],[/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*(?:[pP][+-]?[0-9]+[fh]?)?/,"number.hex"],[/0[xX][0-9a-fA-F]+[pP][+-]?[0-9]+[fh]?/,"number.hex"],[/0[xX][0-9a-fA-F]+[iu]?/,"number.hex"],[/[1-9][0-9]*[iu]?/,"number"],[/0[iu]?/,"number"]]}},tqs=Object.freeze(Object.defineProperty({__proto__:null,conf:VXs,language:eqs},Symbol.toStringTag,{value:"Module"})),nqs={comments:{blockComment:["\x3C!--","-->"]},brackets:[["<",">"]],autoClosingPairs:[{open:"<",close:">"},{open:"'",close:"'"},{open:'"',close:'"'}],surroundingPairs:[{open:"<",close:">"},{open:"'",close:"'"},{open:'"',close:'"'}],onEnterRules:[{beforeText:new RegExp("<([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$","i"),afterText:/^<\/([_:\w][_:\w-.\d]*)\s*>$/i,action:{indentAction:Mt.IndentAction.IndentOutdent}},{beforeText:new RegExp("<(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$","i"),action:{indentAction:Mt.IndentAction.Indent}}]},iqs={defaultToken:"",tokenPostfix:".xml",ignoreCase:!0,qualifiedName:/(?:[\w\.\-]+:)?[\w\.\-]+/,tokenizer:{root:[[/[^<&]+/,""],{include:"@whitespace"},[/(<)(@qualifiedName)/,[{token:"delimiter"},{token:"tag",next:"@tag"}]],[/(<\/)(@qualifiedName)(\s*)(>)/,[{token:"delimiter"},{token:"tag"},"",{token:"delimiter"}]],[/(<\?)(@qualifiedName)/,[{token:"delimiter"},{token:"metatag",next:"@tag"}]],[/(<\!)(@qualifiedName)/,[{token:"delimiter"},{token:"metatag",next:"@tag"}]],[/<\!\[CDATA\[/,{token:"delimiter.cdata",next:"@cdata"}],[/&\w+;/,"string.escape"]],cdata:[[/[^\]]+/,""],[/\]\]>/,{token:"delimiter.cdata",next:"@pop"}],[/\]/,""]],tag:[[/[ \t\r\n]+/,""],[/(@qualifiedName)(\s*=\s*)("[^"]*"|'[^']*')/,["attribute.name","","attribute.value"]],[/(@qualifiedName)(\s*=\s*)("[^">?\/]*|'[^'>?\/]*)(?=[\?\/]\>)/,["attribute.name","","attribute.value"]],[/(@qualifiedName)(\s*=\s*)("[^">]*|'[^'>]*)/,["attribute.name","","attribute.value"]],[/@qualifiedName/,"attribute.name"],[/\?>/,{token:"delimiter",next:"@pop"}],[/(\/)(>)/,[{token:"tag"},{token:"delimiter",next:"@pop"}]],[/>/,{token:"delimiter",next:"@pop"}]],whitespace:[[/[ \t\r\n]+/,""],[/\x3C!--/,{token:"comment",next:"@comment"}]],comment:[[/[^<\-]+/,"comment.content"],[/-->/,{token:"comment",next:"@pop"}],[/\x3C!--/,"comment.content.invalid"],[/[<\-]/,"comment.content"]]}},rqs=Object.freeze(Object.defineProperty({__proto__:null,conf:nqs,language:iqs},Symbol.toStringTag,{value:"Module"})),oqs={comments:{lineComment:"#"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{offSide:!0},onEnterRules:[{beforeText:/:\s*$/,action:{indentAction:Mt.IndentAction.Indent}}]},sqs={tokenPostfix:".yaml",brackets:[{token:"delimiter.bracket",open:"{",close:"}"},{token:"delimiter.square",open:"[",close:"]"}],keywords:["true","True","TRUE","false","False","FALSE","null","Null","Null","~"],numberInteger:/(?:0|[+-]?[0-9]+)/,numberFloat:/(?:0|[+-]?[0-9]+)(?:\.[0-9]+)?(?:e[-+][1-9][0-9]*)?/,numberOctal:/0o[0-7]+/,numberHex:/0x[0-9a-fA-F]+/,numberInfinity:/[+-]?\.(?:inf|Inf|INF)/,numberNaN:/\.(?:nan|Nan|NAN)/,numberDate:/\d{4}-\d\d-\d\d([Tt ]\d\d:\d\d:\d\d(\.\d+)?(( ?[+-]\d\d?(:\d\d)?)|Z)?)?/,escapes:/\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,tokenizer:{root:[{include:"@whitespace"},{include:"@comment"},[/%[^ ]+.*$/,"meta.directive"],[/---/,"operators.directivesEnd"],[/\.{3}/,"operators.documentEnd"],[/[-?:](?= )/,"operators"],{include:"@anchor"},{include:"@tagHandle"},{include:"@flowCollections"},{include:"@blockStyle"},[/@numberInteger(?![ \t]*\S+)/,"number"],[/@numberFloat(?![ \t]*\S+)/,"number.float"],[/@numberOctal(?![ \t]*\S+)/,"number.octal"],[/@numberHex(?![ \t]*\S+)/,"number.hex"],[/@numberInfinity(?![ \t]*\S+)/,"number.infinity"],[/@numberNaN(?![ \t]*\S+)/,"number.nan"],[/@numberDate(?![ \t]*\S+)/,"number.date"],[/(".*?"|'.*?'|[^#'"]*?)([ \t]*)(:)( |$)/,["type","white","operators","white"]],{include:"@flowScalars"},[/.+?(?=(\s+#|$))/,{cases:{"@keywords":"keyword","@default":"string"}}]],object:[{include:"@whitespace"},{include:"@comment"},[/\}/,"@brackets","@pop"],[/,/,"delimiter.comma"],[/:(?= )/,"operators"],[/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/,"type"],{include:"@flowCollections"},{include:"@flowScalars"},{include:"@tagHandle"},{include:"@anchor"},{include:"@flowNumber"},[/[^\},]+/,{cases:{"@keywords":"keyword","@default":"string"}}]],array:[{include:"@whitespace"},{include:"@comment"},[/\]/,"@brackets","@pop"],[/,/,"delimiter.comma"],{include:"@flowCollections"},{include:"@flowScalars"},{include:"@tagHandle"},{include:"@anchor"},{include:"@flowNumber"},[/[^\],]+/,{cases:{"@keywords":"keyword","@default":"string"}}]],multiString:[[/^( +).+$/,"string","@multiStringContinued.$1"]],multiStringContinued:[[/^( *).+$/,{cases:{"$1==$S2":"string","@default":{token:"@rematch",next:"@popall"}}}]],whitespace:[[/[ \t\r\n]+/,"white"]],comment:[[/#.*$/,"comment"]],flowCollections:[[/\[/,"@brackets","@array"],[/\{/,"@brackets","@object"]],flowScalars:[[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/'[^']*'/,"string"],[/"/,"string","@doubleQuotedString"]],doubleQuotedString:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,"string","@pop"]],blockStyle:[[/[>|][0-9]*[+-]?$/,"operators","@multiString"]],flowNumber:[[/@numberInteger(?=[ \t]*[,\]\}])/,"number"],[/@numberFloat(?=[ \t]*[,\]\}])/,"number.float"],[/@numberOctal(?=[ \t]*[,\]\}])/,"number.octal"],[/@numberHex(?=[ \t]*[,\]\}])/,"number.hex"],[/@numberInfinity(?=[ \t]*[,\]\}])/,"number.infinity"],[/@numberNaN(?=[ \t]*[,\]\}])/,"number.nan"],[/@numberDate(?=[ \t]*[,\]\}])/,"number.date"]],tagHandle:[[/\![^ ]*/,"tag"]],anchor:[[/[&*][^ ]+/,"namespace"]]}},aqs=Object.freeze(Object.defineProperty({__proto__:null,conf:oqs,language:sqs},Symbol.toStringTag,{value:"Module"})); - +