@designcombo/state 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1 +1,3 @@
1
- (function(t,e){typeof exports=="object"&&typeof module<"u"?module.exports=e(require("@designcombo/events")):typeof define=="function"&&define.amd?define(["@designcombo/events"],e):(t=typeof globalThis<"u"?globalThis:t||self,t.events=e(t.events))})(this,function(t){"use strict";var m=Object.defineProperty;var I=(t,e,a)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var s=(t,e,a)=>I(t,typeof e!="symbol"?e+"":e,a);class e{constructor(){s(this,"tracks",[]);s(this,"trackItemsMap",{});s(this,"trackItemIds",[]);s(this,"transitionIds",[]);s(this,"transitionsMap",{});s(this,"scale");s(this,"duration");s(this,"activeIds",[]);s(this,"targetIds",[])}notify(){t.dispatch(t.STATE_CHANGED,{payload:{tracks:this.tracks,trackItemIds:this.trackItemIds,trackItemsMap:this.trackItemsMap,transitionIds:this.transitionIds,transitionsMap:this.transitionsMap,scale:this.scale,duration:this.duration}})}selectItem(){const i=this.getTargetIds();this.targetIds=i,t.dispatch(t.LAYER_SELECTION,{payload:{activeIds:this.activeIds,targetIds:i}})}getCurrentTime(){const i=document.getElementById("video-current-time");return(i?parseFloat(i.getAttribute("data-current-time")):0)*1e3}getTargetIds(){const i=this.getCurrentTime();return this.activeIds.filter(r=>this.trackItemIds.includes(r)).map(r=>this.trackItemsMap[r]).filter(r=>{const d=r.display.from,o=r.display.to;return d<=i&&o>=i}).map(r=>r.id)}}return e});
1
+ (function(P,K){typeof exports=="object"&&typeof module<"u"?module.exports=K(require("@designcombo/events")):typeof define=="function"&&define.amd?define(["@designcombo/events"],K):(P=typeof globalThis<"u"?globalThis:P||self,P.events=K(P.events))})(this,function(P){"use strict";var _o=Object.defineProperty;var go=(P,K,ot)=>K in P?_o(P,K,{enumerable:!0,configurable:!0,writable:!0,value:ot}):P[K]=ot;var jt=(P,K,ot)=>go(P,typeof K!="symbol"?K+"":K,ot);var K=function(t,r){return K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(n[a]=o[a])},K(t,r)};function ot(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");K(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}function er(t){var r=typeof Symbol=="function"&&Symbol.iterator,n=r&&t[r],o=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function rr(t,r){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var o=n.call(t),a,u=[],f;try{for(;(r===void 0||r-- >0)&&!(a=o.next()).done;)u.push(a.value)}catch(p){f={error:p}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(f)throw f.error}}return u}function nr(t,r,n){if(n||arguments.length===2)for(var o=0,a=r.length,u;o<a;o++)(u||!(o in r))&&(u||(u=Array.prototype.slice.call(r,0,o)),u[o]=r[o]);return t.concat(u||Array.prototype.slice.call(r))}typeof SuppressedError=="function"&&SuppressedError;function pt(t){return typeof t=="function"}function vn(t){var r=function(o){Error.call(o),o.stack=new Error().stack},n=t(r);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var ir=vn(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
2
+ `+n.map(function(o,a){return a+1+") "+o.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function or(t,r){if(t){var n=t.indexOf(r);0<=n&&t.splice(n,1)}}var ge=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,n,o,a,u;if(!this.closed){this.closed=!0;var f=this._parentage;if(f)if(this._parentage=null,Array.isArray(f))try{for(var p=er(f),T=p.next();!T.done;T=p.next()){var _=T.value;_.remove(this)}}catch(y){r={error:y}}finally{try{T&&!T.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}else f.remove(this);var d=this.initialTeardown;if(pt(d))try{d()}catch(y){u=y instanceof ir?y.errors:[y]}var E=this._finalizers;if(E){this._finalizers=null;try{for(var l=er(E),g=l.next();!g.done;g=l.next()){var m=g.value;try{wn(m)}catch(y){u=u??[],y instanceof ir?u=nr(nr([],rr(u)),rr(y.errors)):u.push(y)}}}catch(y){o={error:y}}finally{try{g&&!g.done&&(a=l.return)&&a.call(l)}finally{if(o)throw o.error}}}if(u)throw new ir(u)}},t.prototype.add=function(r){var n;if(r&&r!==this)if(this.closed)wn(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(r)}},t.prototype._hasParent=function(r){var n=this._parentage;return n===r||Array.isArray(n)&&n.includes(r)},t.prototype._addParent=function(r){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(r),n):n?[n,r]:r},t.prototype._removeParent=function(r){var n=this._parentage;n===r?this._parentage=null:Array.isArray(n)&&or(n,r)},t.prototype.remove=function(r){var n=this._finalizers;n&&or(n,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),Sn=ge.EMPTY;function In(t){return t instanceof ge||t&&"closed"in t&&pt(t.remove)&&pt(t.add)&&pt(t.unsubscribe)}function wn(t){pt(t)?t():t.unsubscribe()}var Tn={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},An={setTimeout:function(t,r){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return setTimeout.apply(void 0,nr([t,r],rr(n)))},clearTimeout:function(t){var r=An.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(t)},delegate:void 0};function ti(t){An.setTimeout(function(){throw t})}function En(){}function me(t){t()}var On=function(t){ot(r,t);function r(n){var o=t.call(this)||this;return o.isStopped=!1,n?(o.destination=n,In(n)&&n.add(o)):o.destination=ii,o}return r.create=function(n,o,a){return new ar(n,o,a)},r.prototype.next=function(n){this.isStopped||this._next(n)},r.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(n){this.destination.next(n)},r.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(ge),ei=Function.prototype.bind;function sr(t,r){return ei.call(t,r)}var ri=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var n=this.partialObserver;if(n.next)try{n.next(r)}catch(o){ve(o)}},t.prototype.error=function(r){var n=this.partialObserver;if(n.error)try{n.error(r)}catch(o){ve(o)}else ve(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(n){ve(n)}},t}(),ar=function(t){ot(r,t);function r(n,o,a){var u=t.call(this)||this,f;if(pt(n)||!n)f={next:n??void 0,error:o??void 0,complete:a??void 0};else{var p;u&&Tn.useDeprecatedNextContext?(p=Object.create(n),p.unsubscribe=function(){return u.unsubscribe()},f={next:n.next&&sr(n.next,p),error:n.error&&sr(n.error,p),complete:n.complete&&sr(n.complete,p)}):f=n}return u.destination=new ri(f),u}return r}(On);function ve(t){ti(t)}function ni(t){throw t}var ii={closed:!0,next:En,error:ni,complete:En},oi=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function si(t){return t}function ai(t){return t.length===0?si:t.length===1?t[0]:function(n){return t.reduce(function(o,a){return a(o)},n)}}var xn=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var n=new t;return n.source=this,n.operator=r,n},t.prototype.subscribe=function(r,n,o){var a=this,u=ui(r)?r:new ar(r,n,o);return me(function(){var f=a,p=f.operator,T=f.source;u.add(p?p.call(u,T):T?a._subscribe(u):a._trySubscribe(u))}),u},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(n){r.error(n)}},t.prototype.forEach=function(r,n){var o=this;return n=Pn(n),new n(function(a,u){var f=new ar({next:function(p){try{r(p)}catch(T){u(T),f.unsubscribe()}},error:u,complete:a});o.subscribe(f)})},t.prototype._subscribe=function(r){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(r)},t.prototype[oi]=function(){return this},t.prototype.pipe=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return ai(r)(this)},t.prototype.toPromise=function(r){var n=this;return r=Pn(r),new r(function(o,a){var u;n.subscribe(function(f){return u=f},function(f){return a(f)},function(){return o(u)})})},t.create=function(r){return new t(r)},t}();function Pn(t){var r;return(r=t??Tn.Promise)!==null&&r!==void 0?r:Promise}function ci(t){return t&&pt(t.next)&&pt(t.error)&&pt(t.complete)}function ui(t){return t&&t instanceof On||ci(t)&&In(t)}var fi=vn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Mn=function(t){ot(r,t);function r(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return r.prototype.lift=function(n){var o=new Cn(this,this);return o.operator=n,o},r.prototype._throwIfClosed=function(){if(this.closed)throw new fi},r.prototype.next=function(n){var o=this;me(function(){var a,u;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var f=er(o.currentObservers),p=f.next();!p.done;p=f.next()){var T=p.value;T.next(n)}}catch(_){a={error:_}}finally{try{p&&!p.done&&(u=f.return)&&u.call(f)}finally{if(a)throw a.error}}}})},r.prototype.error=function(n){var o=this;me(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=n;for(var a=o.observers;a.length;)a.shift().error(n)}})},r.prototype.complete=function(){var n=this;me(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var o=n.observers;o.length;)o.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},r.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},r.prototype._innerSubscribe=function(n){var o=this,a=this,u=a.hasError,f=a.isStopped,p=a.observers;return u||f?Sn:(this.currentObservers=null,p.push(n),new ge(function(){o.currentObservers=null,or(p,n)}))},r.prototype._checkFinalizedStatuses=function(n){var o=this,a=o.hasError,u=o.thrownError,f=o.isStopped;a?n.error(u):f&&n.complete()},r.prototype.asObservable=function(){var n=new xn;return n.source=this,n},r.create=function(n,o){return new Cn(n,o)},r}(xn),Cn=function(t){ot(r,t);function r(n,o){var a=t.call(this)||this;return a.destination=n,a.source=o,a}return r.prototype.next=function(n){var o,a;(a=(o=this.destination)===null||o===void 0?void 0:o.next)===null||a===void 0||a.call(o,n)},r.prototype.error=function(n){var o,a;(a=(o=this.destination)===null||o===void 0?void 0:o.error)===null||a===void 0||a.call(o,n)},r.prototype.complete=function(){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||o===void 0||o.call(n)},r.prototype._subscribe=function(n){var o,a;return(a=(o=this.source)===null||o===void 0?void 0:o.subscribe(n))!==null&&a!==void 0?a:Sn},r}(Mn),Dn=function(t){ot(r,t);function r(n){var o=t.call(this)||this;return o._value=n,o}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(n){var o=t.prototype._subscribe.call(this,n);return!o.closed&&n.next(this._value),o},r.prototype.getValue=function(){var n=this,o=n.hasError,a=n.thrownError,u=n._value;if(o)throw a;return this._throwIfClosed(),u},r.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},r}(Mn),Q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Se={exports:{}};Se.exports,function(t,r){var n=200,o="__lodash_hash_undefined__",a=1,u=2,f=9007199254740991,p="[object Arguments]",T="[object Array]",_="[object AsyncFunction]",d="[object Boolean]",E="[object Date]",l="[object Error]",g="[object Function]",m="[object GeneratorFunction]",y="[object Map]",I="[object Number]",v="[object Null]",h="[object Object]",S="[object Promise]",A="[object Proxy]",G="[object RegExp]",R="[object Set]",F="[object String]",at="[object Symbol]",mt="[object Undefined]",M="[object WeakMap]",j="[object ArrayBuffer]",V="[object DataView]",Oe="[object Float32Array]",xe="[object Float64Array]",Pe="[object Int8Array]",Ar="[object Int16Array]",Er="[object Int32Array]",Or="[object Uint8Array]",xr="[object Uint8ClampedArray]",D="[object Uint16Array]",Pr="[object Uint32Array]",Mr=/[\\^$.*+?()[\]{}|]/g,et=/^\[object .+?Constructor\]$/,Me=/^(?:0|[1-9]\d*)$/,k={};k[Oe]=k[xe]=k[Pe]=k[Ar]=k[Er]=k[Or]=k[xr]=k[D]=k[Pr]=!0,k[p]=k[T]=k[j]=k[d]=k[V]=k[E]=k[l]=k[g]=k[y]=k[I]=k[h]=k[G]=k[R]=k[F]=k[M]=!1;var Ce=typeof Q=="object"&&Q&&Q.Object===Object&&Q,Cr=typeof self=="object"&&self&&self.Object===Object&&self,rt=Ce||Cr||Function("return this")(),De=r&&!r.nodeType&&r,ke=De&&!0&&t&&!t.nodeType&&t,Qt=ke&&ke.exports===De,te=Qt&&Ce.process,je=function(){try{return te&&te.binding&&te.binding("util")}catch{}}(),ee=je&&je.isTypedArray;function Fe(e,i){for(var s=-1,c=e==null?0:e.length,w=0,b=[];++s<c;){var x=e[s];i(x,s,e)&&(b[w++]=x)}return b}function re(e,i){for(var s=-1,c=i.length,w=e.length;++s<c;)e[w+s]=i[s];return e}function Re(e,i){for(var s=-1,c=e==null?0:e.length;++s<c;)if(i(e[s],s,e))return!0;return!1}function Dr(e,i){for(var s=-1,c=Array(e);++s<e;)c[s]=i(s);return c}function kr(e){return function(i){return e(i)}}function Ft(e,i){return e.has(i)}function ne(e,i){return e==null?void 0:e[i]}function ze(e){var i=-1,s=Array(e.size);return e.forEach(function(c,w){s[++i]=[w,c]}),s}function He(e,i){return function(s){return e(i(s))}}function ct(e){var i=-1,s=Array(e.size);return e.forEach(function(c){s[++i]=c}),s}var Rt=Array.prototype,jr=Function.prototype,Ot=Object.prototype,zt=rt["__core-js_shared__"],ie=jr.toString,tt=Ot.hasOwnProperty,Ne=function(){var e=/[^.]+$/.exec(zt&&zt.keys&&zt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ue=Ot.toString,Fr=RegExp("^"+ie.call(tt).replace(Mr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),oe=Qt?rt.Buffer:void 0,Ht=rt.Symbol,Le=rt.Uint8Array,Nt=Ot.propertyIsEnumerable,xt=Rt.splice,nt=Ht?Ht.toStringTag:void 0,Ut=Object.getOwnPropertySymbols,se=oe?oe.isBuffer:void 0,Pt=He(Object.keys,Object),ae=yt(rt,"DataView"),Mt=yt(rt,"Map"),ce=yt(rt,"Promise"),ue=yt(rt,"Set"),fe=yt(rt,"WeakMap"),vt=yt(Object,"create"),Ge=Y(ae),ht=Y(Mt),Rr=Y(ce),zr=Y(ue),Hr=Y(fe),Be=Ht?Ht.prototype:void 0,le=Be?Be.valueOf:void 0;function U(e){var i=-1,s=e==null?0:e.length;for(this.clear();++i<s;){var c=e[i];this.set(c[0],c[1])}}function Nr(){this.__data__=vt?vt(null):{},this.size=0}function Ur(e){var i=this.has(e)&&delete this.__data__[e];return this.size-=i?1:0,i}function Lr(e){var i=this.__data__;if(vt){var s=i[e];return s===o?void 0:s}return tt.call(i,e)?i[e]:void 0}function Gr(e){var i=this.__data__;return vt?i[e]!==void 0:tt.call(i,e)}function Br(e,i){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=vt&&i===void 0?o:i,this}U.prototype.clear=Nr,U.prototype.delete=Ur,U.prototype.get=Lr,U.prototype.has=Gr,U.prototype.set=Br;function B(e){var i=-1,s=e==null?0:e.length;for(this.clear();++i<s;){var c=e[i];this.set(c[0],c[1])}}function $r(){this.__data__=[],this.size=0}function Wr(e){var i=this.__data__,s=Bt(i,e);if(s<0)return!1;var c=i.length-1;return s==c?i.pop():xt.call(i,s,1),--this.size,!0}function Kr(e){var i=this.__data__,s=Bt(i,e);return s<0?void 0:i[s][1]}function Vr(e){return Bt(this.__data__,e)>-1}function Yr(e,i){var s=this.__data__,c=Bt(s,e);return c<0?(++this.size,s.push([e,i])):s[c][1]=i,this}B.prototype.clear=$r,B.prototype.delete=Wr,B.prototype.get=Kr,B.prototype.has=Vr,B.prototype.set=Yr;function X(e){var i=-1,s=e==null?0:e.length;for(this.clear();++i<s;){var c=e[i];this.set(c[0],c[1])}}function Xr(){this.size=0,this.__data__={hash:new U,map:new(Mt||B),string:new U}}function qr(e){var i=it(this,e).delete(e);return this.size-=i?1:0,i}function Jr(e){return it(this,e).get(e)}function Zr(e){return it(this,e).has(e)}function Qr(e,i){var s=it(this,e),c=s.size;return s.set(e,i),this.size+=s.size==c?0:1,this}X.prototype.clear=Xr,X.prototype.delete=qr,X.prototype.get=Jr,X.prototype.has=Zr,X.prototype.set=Qr;function Lt(e){var i=-1,s=e==null?0:e.length;for(this.__data__=new X;++i<s;)this.add(e[i])}function $e(e){return this.__data__.set(e,o),this}function Gt(e){return this.__data__.has(e)}Lt.prototype.add=Lt.prototype.push=$e,Lt.prototype.has=Gt;function ut(e){var i=this.__data__=new B(e);this.size=i.size}function pe(){this.__data__=new B,this.size=0}function tn(e){var i=this.__data__,s=i.delete(e);return this.size=i.size,s}function en(e){return this.__data__.get(e)}function rn(e){return this.__data__.has(e)}function nn(e,i){var s=this.__data__;if(s instanceof B){var c=s.__data__;if(!Mt||c.length<n-1)return c.push([e,i]),this.size=++s.size,this;s=this.__data__=new X(c)}return s.set(e,i),this.size=s.size,this}ut.prototype.clear=pe,ut.prototype.delete=tn,ut.prototype.get=en,ut.prototype.has=rn,ut.prototype.set=nn;function on(e,i){var s=$t(e),c=!s&&Xe(e),w=!s&&!c&&Wt(e),b=!s&&!c&&!w&&Ze(e),x=s||c||w||b,O=x?Dr(e.length,String):[],z=O.length;for(var C in e)tt.call(e,C)&&!(x&&(C=="length"||w&&(C=="offset"||C=="parent")||b&&(C=="buffer"||C=="byteLength"||C=="byteOffset")||dn(C,z)))&&O.push(C);return O}function Bt(e,i){for(var s=e.length;s--;)if(Ye(e[s][0],i))return s;return-1}function de(e,i,s){var c=i(e);return $t(e)?c:re(c,s(e))}function Ct(e){return e==null?e===void 0?mt:v:nt&&nt in Object(e)?bt(e):Ve(e)}function We(e){return lt(e)&&Ct(e)==p}function Ke(e,i,s,c,w){return e===i?!0:e==null||i==null||!lt(e)&&!lt(i)?e!==e&&i!==i:sn(e,i,s,c,Ke,w)}function sn(e,i,s,c,w,b){var x=$t(e),O=$t(i),z=x?T:ft(e),C=O?T:ft(i);z=z==p?h:z,C=C==p?h:C;var $=z==h,q=C==h,N=z==C;if(N&&Wt(e)){if(!Wt(i))return!1;x=!0,$=!1}if(N&&!$)return b||(b=new ut),x||Ze(e)?he(e,i,s,c,w,b):fn(e,i,z,s,c,w,b);if(!(s&a)){var W=$&&tt.call(e,"__wrapped__"),L=q&&tt.call(i,"__wrapped__");if(W||L){var St=W?e.value():e,_t=L?i.value():i;return b||(b=new ut),w(St,_t,s,c,b)}}return N?(b||(b=new ut),ln(e,i,s,c,w,b)):!1}function an(e){if(!Je(e)||yn(e))return!1;var i=qe(e)?Fr:et;return i.test(Y(e))}function cn(e){return lt(e)&&be(e.length)&&!!k[Ct(e)]}function un(e){if(!bn(e))return Pt(e);var i=[];for(var s in Object(e))tt.call(e,s)&&s!="constructor"&&i.push(s);return i}function he(e,i,s,c,w,b){var x=s&a,O=e.length,z=i.length;if(O!=z&&!(x&&z>O))return!1;var C=b.get(e);if(C&&b.get(i))return C==i;var $=-1,q=!0,N=s&u?new Lt:void 0;for(b.set(e,i),b.set(i,e);++$<O;){var W=e[$],L=i[$];if(c)var St=x?c(L,W,$,i,e,b):c(W,L,$,e,i,b);if(St!==void 0){if(St)continue;q=!1;break}if(N){if(!Re(i,function(_t,kt){if(!Ft(N,kt)&&(W===_t||w(W,_t,s,c,b)))return N.push(kt)})){q=!1;break}}else if(!(W===L||w(W,L,s,c,b))){q=!1;break}}return b.delete(e),b.delete(i),q}function fn(e,i,s,c,w,b,x){switch(s){case V:if(e.byteLength!=i.byteLength||e.byteOffset!=i.byteOffset)return!1;e=e.buffer,i=i.buffer;case j:return!(e.byteLength!=i.byteLength||!b(new Le(e),new Le(i)));case d:case E:case I:return Ye(+e,+i);case l:return e.name==i.name&&e.message==i.message;case G:case F:return e==i+"";case y:var O=ze;case R:var z=c&a;if(O||(O=ct),e.size!=i.size&&!z)return!1;var C=x.get(e);if(C)return C==i;c|=u,x.set(e,i);var $=he(O(e),O(i),c,w,b,x);return x.delete(e),$;case at:if(le)return le.call(e)==le.call(i)}return!1}function ln(e,i,s,c,w,b){var x=s&a,O=Dt(e),z=O.length,C=Dt(i),$=C.length;if(z!=$&&!x)return!1;for(var q=z;q--;){var N=O[q];if(!(x?N in i:tt.call(i,N)))return!1}var W=b.get(e);if(W&&b.get(i))return W==i;var L=!0;b.set(e,i),b.set(i,e);for(var St=x;++q<z;){N=O[q];var _t=e[N],kt=i[N];if(c)var Qn=x?c(kt,_t,N,i,e,b):c(_t,kt,N,e,i,b);if(!(Qn===void 0?_t===kt||w(_t,kt,s,c,b):Qn)){L=!1;break}St||(St=N=="constructor")}if(L&&!St){var Qe=e.constructor,tr=i.constructor;Qe!=tr&&"constructor"in e&&"constructor"in i&&!(typeof Qe=="function"&&Qe instanceof Qe&&typeof tr=="function"&&tr instanceof tr)&&(L=!1)}return b.delete(e),b.delete(i),L}function Dt(e){return de(e,_e,pn)}function it(e,i){var s=e.__data__;return hn(i)?s[typeof i=="string"?"string":"hash"]:s.map}function yt(e,i){var s=ne(e,i);return an(s)?s:void 0}function bt(e){var i=tt.call(e,nt),s=e[nt];try{e[nt]=void 0;var c=!0}catch{}var w=Ue.call(e);return c&&(i?e[nt]=s:delete e[nt]),w}var pn=Ut?function(e){return e==null?[]:(e=Object(e),Fe(Ut(e),function(i){return Nt.call(e,i)}))}:gn,ft=Ct;(ae&&ft(new ae(new ArrayBuffer(1)))!=V||Mt&&ft(new Mt)!=y||ce&&ft(ce.resolve())!=S||ue&&ft(new ue)!=R||fe&&ft(new fe)!=M)&&(ft=function(e){var i=Ct(e),s=i==h?e.constructor:void 0,c=s?Y(s):"";if(c)switch(c){case Ge:return V;case ht:return y;case Rr:return S;case zr:return R;case Hr:return M}return i});function dn(e,i){return i=i??f,!!i&&(typeof e=="number"||Me.test(e))&&e>-1&&e%1==0&&e<i}function hn(e){var i=typeof e;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?e!=="__proto__":e===null}function yn(e){return!!Ne&&Ne in e}function bn(e){var i=e&&e.constructor,s=typeof i=="function"&&i.prototype||Ot;return e===s}function Ve(e){return Ue.call(e)}function Y(e){if(e!=null){try{return ie.call(e)}catch{}try{return e+""}catch{}}return""}function Ye(e,i){return e===i||e!==e&&i!==i}var Xe=We(function(){return arguments}())?We:function(e){return lt(e)&&tt.call(e,"callee")&&!Nt.call(e,"callee")},$t=Array.isArray;function ye(e){return e!=null&&be(e.length)&&!qe(e)}var Wt=se||mn;function _n(e,i){return Ke(e,i)}function qe(e){if(!Je(e))return!1;var i=Ct(e);return i==g||i==m||i==_||i==A}function be(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=f}function Je(e){var i=typeof e;return e!=null&&(i=="object"||i=="function")}function lt(e){return e!=null&&typeof e=="object"}var Ze=ee?kr(ee):cn;function _e(e){return ye(e)?on(e):un(e)}function gn(){return[]}function mn(){return!1}t.exports=_n}(Se,Se.exports);var li=Se.exports;const st=cr(li);var Ie={exports:{}};Ie.exports,function(t,r){var n=200,o="__lodash_hash_undefined__",a=9007199254740991,u="[object Arguments]",f="[object Array]",p="[object Boolean]",T="[object Date]",_="[object Error]",d="[object Function]",E="[object GeneratorFunction]",l="[object Map]",g="[object Number]",m="[object Object]",y="[object Promise]",I="[object RegExp]",v="[object Set]",h="[object String]",S="[object Symbol]",A="[object WeakMap]",G="[object ArrayBuffer]",R="[object DataView]",F="[object Float32Array]",at="[object Float64Array]",mt="[object Int8Array]",M="[object Int16Array]",j="[object Int32Array]",V="[object Uint8Array]",Oe="[object Uint8ClampedArray]",xe="[object Uint16Array]",Pe="[object Uint32Array]",Ar=/[\\^$.*+?()[\]{}|]/g,Er=/\w*$/,Or=/^\[object .+?Constructor\]$/,xr=/^(?:0|[1-9]\d*)$/,D={};D[u]=D[f]=D[G]=D[R]=D[p]=D[T]=D[F]=D[at]=D[mt]=D[M]=D[j]=D[l]=D[g]=D[m]=D[I]=D[v]=D[h]=D[S]=D[V]=D[Oe]=D[xe]=D[Pe]=!0,D[_]=D[d]=D[A]=!1;var Pr=typeof Q=="object"&&Q&&Q.Object===Object&&Q,Mr=typeof self=="object"&&self&&self.Object===Object&&self,et=Pr||Mr||Function("return this")(),Me=r&&!r.nodeType&&r,k=Me&&!0&&t&&!t.nodeType&&t,Ce=k&&k.exports===Me;function Cr(e,i){return e.set(i[0],i[1]),e}function rt(e,i){return e.add(i),e}function De(e,i){for(var s=-1,c=e?e.length:0;++s<c&&i(e[s],s,e)!==!1;);return e}function ke(e,i){for(var s=-1,c=i.length,w=e.length;++s<c;)e[w+s]=i[s];return e}function Qt(e,i,s,c){for(var w=-1,b=e?e.length:0;++w<b;)s=i(s,e[w],w,e);return s}function te(e,i){for(var s=-1,c=Array(e);++s<e;)c[s]=i(s);return c}function je(e,i){return e==null?void 0:e[i]}function ee(e){var i=!1;if(e!=null&&typeof e.toString!="function")try{i=!!(e+"")}catch{}return i}function Fe(e){var i=-1,s=Array(e.size);return e.forEach(function(c,w){s[++i]=[w,c]}),s}function re(e,i){return function(s){return e(i(s))}}function Re(e){var i=-1,s=Array(e.size);return e.forEach(function(c){s[++i]=c}),s}var Dr=Array.prototype,kr=Function.prototype,Ft=Object.prototype,ne=et["__core-js_shared__"],ze=function(){var e=/[^.]+$/.exec(ne&&ne.keys&&ne.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),He=kr.toString,ct=Ft.hasOwnProperty,Rt=Ft.toString,jr=RegExp("^"+He.call(ct).replace(Ar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ot=Ce?et.Buffer:void 0,zt=et.Symbol,ie=et.Uint8Array,tt=re(Object.getPrototypeOf,Object),Ne=Object.create,Ue=Ft.propertyIsEnumerable,Fr=Dr.splice,oe=Object.getOwnPropertySymbols,Ht=Ot?Ot.isBuffer:void 0,Le=re(Object.keys,Object),Nt=it(et,"DataView"),xt=it(et,"Map"),nt=it(et,"Promise"),Ut=it(et,"Set"),se=it(et,"WeakMap"),Pt=it(Object,"create"),ae=Y(Nt),Mt=Y(xt),ce=Y(nt),ue=Y(Ut),fe=Y(se),vt=zt?zt.prototype:void 0,Ge=vt?vt.valueOf:void 0;function ht(e){var i=-1,s=e?e.length:0;for(this.clear();++i<s;){var c=e[i];this.set(c[0],c[1])}}function Rr(){this.__data__=Pt?Pt(null):{}}function zr(e){return this.has(e)&&delete this.__data__[e]}function Hr(e){var i=this.__data__;if(Pt){var s=i[e];return s===o?void 0:s}return ct.call(i,e)?i[e]:void 0}function Be(e){var i=this.__data__;return Pt?i[e]!==void 0:ct.call(i,e)}function le(e,i){var s=this.__data__;return s[e]=Pt&&i===void 0?o:i,this}ht.prototype.clear=Rr,ht.prototype.delete=zr,ht.prototype.get=Hr,ht.prototype.has=Be,ht.prototype.set=le;function U(e){var i=-1,s=e?e.length:0;for(this.clear();++i<s;){var c=e[i];this.set(c[0],c[1])}}function Nr(){this.__data__=[]}function Ur(e){var i=this.__data__,s=Gt(i,e);if(s<0)return!1;var c=i.length-1;return s==c?i.pop():Fr.call(i,s,1),!0}function Lr(e){var i=this.__data__,s=Gt(i,e);return s<0?void 0:i[s][1]}function Gr(e){return Gt(this.__data__,e)>-1}function Br(e,i){var s=this.__data__,c=Gt(s,e);return c<0?s.push([e,i]):s[c][1]=i,this}U.prototype.clear=Nr,U.prototype.delete=Ur,U.prototype.get=Lr,U.prototype.has=Gr,U.prototype.set=Br;function B(e){var i=-1,s=e?e.length:0;for(this.clear();++i<s;){var c=e[i];this.set(c[0],c[1])}}function $r(){this.__data__={hash:new ht,map:new(xt||U),string:new ht}}function Wr(e){return Dt(this,e).delete(e)}function Kr(e){return Dt(this,e).get(e)}function Vr(e){return Dt(this,e).has(e)}function Yr(e,i){return Dt(this,e).set(e,i),this}B.prototype.clear=$r,B.prototype.delete=Wr,B.prototype.get=Kr,B.prototype.has=Vr,B.prototype.set=Yr;function X(e){this.__data__=new U(e)}function Xr(){this.__data__=new U}function qr(e){return this.__data__.delete(e)}function Jr(e){return this.__data__.get(e)}function Zr(e){return this.__data__.has(e)}function Qr(e,i){var s=this.__data__;if(s instanceof U){var c=s.__data__;if(!xt||c.length<n-1)return c.push([e,i]),this;s=this.__data__=new B(c)}return s.set(e,i),this}X.prototype.clear=Xr,X.prototype.delete=qr,X.prototype.get=Jr,X.prototype.has=Zr,X.prototype.set=Qr;function Lt(e,i){var s=ye(e)||$t(e)?te(e.length,String):[],c=s.length,w=!!c;for(var b in e)ct.call(e,b)&&!(w&&(b=="length"||hn(b,c)))&&s.push(b);return s}function $e(e,i,s){var c=e[i];(!(ct.call(e,i)&&Xe(c,s))||s===void 0&&!(i in e))&&(e[i]=s)}function Gt(e,i){for(var s=e.length;s--;)if(Xe(e[s][0],i))return s;return-1}function ut(e,i){return e&&he(i,_e(i),e)}function pe(e,i,s,c,w,b,x){var O;if(c&&(O=b?c(e,w,b,x):c(e)),O!==void 0)return O;if(!lt(e))return e;var z=ye(e);if(z){if(O=pn(e),!i)return un(e,O)}else{var C=bt(e),$=C==d||C==E;if(qe(e))return Bt(e,i);if(C==m||C==u||$&&!b){if(ee(e))return b?e:{};if(O=ft($?{}:e),!i)return fn(e,ut(O,e))}else{if(!D[C])return b?e:{};O=dn(e,C,pe,i)}}x||(x=new X);var q=x.get(e);if(q)return q;if(x.set(e,O),!z)var N=s?ln(e):_e(e);return De(N||e,function(W,L){N&&(L=W,W=e[L]),$e(O,L,pe(W,i,s,c,L,e,x))}),O}function tn(e){return lt(e)?Ne(e):{}}function en(e,i,s){var c=i(e);return ye(e)?c:ke(c,s(e))}function rn(e){return Rt.call(e)}function nn(e){if(!lt(e)||bn(e))return!1;var i=be(e)||ee(e)?jr:Or;return i.test(Y(e))}function on(e){if(!Ve(e))return Le(e);var i=[];for(var s in Object(e))ct.call(e,s)&&s!="constructor"&&i.push(s);return i}function Bt(e,i){if(i)return e.slice();var s=new e.constructor(e.length);return e.copy(s),s}function de(e){var i=new e.constructor(e.byteLength);return new ie(i).set(new ie(e)),i}function Ct(e,i){var s=i?de(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.byteLength)}function We(e,i,s){var c=i?s(Fe(e),!0):Fe(e);return Qt(c,Cr,new e.constructor)}function Ke(e){var i=new e.constructor(e.source,Er.exec(e));return i.lastIndex=e.lastIndex,i}function sn(e,i,s){var c=i?s(Re(e),!0):Re(e);return Qt(c,rt,new e.constructor)}function an(e){return Ge?Object(Ge.call(e)):{}}function cn(e,i){var s=i?de(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function un(e,i){var s=-1,c=e.length;for(i||(i=Array(c));++s<c;)i[s]=e[s];return i}function he(e,i,s,c){s||(s={});for(var w=-1,b=i.length;++w<b;){var x=i[w],O=void 0;$e(s,x,O===void 0?e[x]:O)}return s}function fn(e,i){return he(e,yt(e),i)}function ln(e){return en(e,_e,yt)}function Dt(e,i){var s=e.__data__;return yn(i)?s[typeof i=="string"?"string":"hash"]:s.map}function it(e,i){var s=je(e,i);return nn(s)?s:void 0}var yt=oe?re(oe,Object):gn,bt=rn;(Nt&&bt(new Nt(new ArrayBuffer(1)))!=R||xt&&bt(new xt)!=l||nt&&bt(nt.resolve())!=y||Ut&&bt(new Ut)!=v||se&&bt(new se)!=A)&&(bt=function(e){var i=Rt.call(e),s=i==m?e.constructor:void 0,c=s?Y(s):void 0;if(c)switch(c){case ae:return R;case Mt:return l;case ce:return y;case ue:return v;case fe:return A}return i});function pn(e){var i=e.length,s=e.constructor(i);return i&&typeof e[0]=="string"&&ct.call(e,"index")&&(s.index=e.index,s.input=e.input),s}function ft(e){return typeof e.constructor=="function"&&!Ve(e)?tn(tt(e)):{}}function dn(e,i,s,c){var w=e.constructor;switch(i){case G:return de(e);case p:case T:return new w(+e);case R:return Ct(e,c);case F:case at:case mt:case M:case j:case V:case Oe:case xe:case Pe:return cn(e,c);case l:return We(e,c,s);case g:case h:return new w(e);case I:return Ke(e);case v:return sn(e,c,s);case S:return an(e)}}function hn(e,i){return i=i??a,!!i&&(typeof e=="number"||xr.test(e))&&e>-1&&e%1==0&&e<i}function yn(e){var i=typeof e;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?e!=="__proto__":e===null}function bn(e){return!!ze&&ze in e}function Ve(e){var i=e&&e.constructor,s=typeof i=="function"&&i.prototype||Ft;return e===s}function Y(e){if(e!=null){try{return He.call(e)}catch{}try{return e+""}catch{}}return""}function Ye(e){return pe(e,!0,!0)}function Xe(e,i){return e===i||e!==e&&i!==i}function $t(e){return _n(e)&&ct.call(e,"callee")&&(!Ue.call(e,"callee")||Rt.call(e)==u)}var ye=Array.isArray;function Wt(e){return e!=null&&Je(e.length)&&!be(e)}function _n(e){return Ze(e)&&Wt(e)}var qe=Ht||mn;function be(e){var i=lt(e)?Rt.call(e):"";return i==d||i==E}function Je(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=a}function lt(e){var i=typeof e;return!!e&&(i=="object"||i=="function")}function Ze(e){return!!e&&typeof e=="object"}function _e(e){return Wt(e)?Lt(e):on(e)}function gn(){return[]}function mn(){return!1}t.exports=Ye}(Ie,Ie.exports);var pi=Ie.exports;const dt=cr(pi),di=t=>{const r=t.map(n=>new FontFace(n.fontFamily,`url(${n.url})`).load().catch(o=>o));return r.length===0?Promise.resolve(!0):new Promise((n,o)=>{Promise.all(r).then(a=>{a.forEach(u=>{u&&u.family&&(document.fonts.add(u),n(!0))})}).catch(a=>o(a))})},hi=t=>new Promise((r,n)=>{const o=new Image;console.warn("update cdn config for cors?"),o.onload=()=>{const a=o.width,u=o.height;r({width:a,height:u})},o.onerror=a=>{n(a)},o.crossOrigin="anonymous",o.src=t}),yi=t=>new Promise((r,n)=>{const o=new Audio;o.preload="auto",o.addEventListener("loadedmetadata",()=>{const a=o.duration*1e3;r({duration:a})}),o.addEventListener("error",a=>{n(a)}),o.src=t,o.crossOrigin="anonymous",o.load()}),bi=t=>new Promise((r,n)=>{const o=document.createElement("video");o.preload="auto",o.addEventListener("loadedmetadata",()=>{const a=o.duration*1e3,u=o.videoWidth,f=o.videoHeight;r({duration:a,width:u,height:f})}),o.addEventListener("error",a=>{n(a)}),o.src=t,o.load()}),_i=(t,r)=>{const n=document.createElement("div");Object.keys(r).forEach(a=>{a!=="height"&&(n.style[a]=r[a])}),document.body.appendChild(n),n.textContent=t,n.style.whiteSpace="normal",n.style.position="absolute",n.style.visibility="hidden",n.style.display="inline-block",n.style.width=r.width+"px",n.style.fontSize=r.fontSize+"px";const o=getComputedStyle(n).height;return document.body.removeChild(n),parseFloat(o)},ur={color:"#000000",x:0,y:0,blur:0},we=(t,r)=>t?t.from&&!t.to?{from:t.from,to:t.from+((r==null?void 0:r.duration)||5e3)}:t:{from:0,to:(r==null?void 0:r.duration)||5e3},kn=(t,r)=>t?t.from&&!t.to?{from:t.from,to:r.duration}:t:{from:0,to:r.duration};function fr(t,r){const n={x:t.size.width/2,y:t.size.height/2},o={x:r.width/2,y:r.height/2},a=Math.min(t.size.width/r.width,t.size.height/r.height),u=n.x-o.x;return{top:`${n.y-o.y}px`,left:`${u}px`,transform:`scale(${a})`}}const gi=async(t,r)=>{const n=t.details.src,o=await bi(n),a=fr(r,{...o}),u={width:o.width,height:o.height,duration:o.duration,opacity:100,src:n,volume:t.details.volume??100,borderRadius:t.details.borderRadius??0,borderWidth:t.details.borderWidth??0,borderColor:t.details.borderColor||"#000000",boxShadow:t.details.boxShadow||ur,top:a.top||"0px",left:a.left||"0px",transform:a.transform};return{...t,trim:kn(t.trim,{duration:o.duration}),type:"video",name:"video",details:u,display:we(t.display,{duration:o.duration})}},mi=async t=>{const r=t.id,n=t.details,a=(await yi(n.src)).duration;return{id:r,name:"",type:"audio",display:we(t.display,{duration:a}),trim:kn(t.trim,{duration:a}),details:{src:n.src,duration:a,volume:n.volume??100},metadata:{...t.metadata}}},vi=async(t,r)=>{const n=t.details,o=await hi(n.src),a=fr(r,o);return{id:t.id,type:"image",name:"image",display:we(t.display),details:{src:n.src||"",width:n.width||o.width||100,height:n.height||o.height||100,opacity:n.opacity??100,transform:a.transform,border:n.border||"none",borderRadius:n.borderRadius||0,boxShadow:n.boxShadow||ur,top:a.top||"0px",left:a.left||"0px",borderWidth:n.borderWidth??0,borderColor:n.borderColor||"#000000"},metadata:t.metadata||{}}},Si=async(t,r)=>{const n=t.id;await di([{fontFamily:t.details.fontFamily,url:t.details.fontUrl}]);const o=t.details,a=Ii(o),u=_i(t.details.text,a),f=fr(r,{width:a.width,height:u});return{id:n,name:"text",type:"text",display:we(t.display),details:{...a,text:o.text||"",height:u,fontUrl:o.fontUrl,top:f.top,left:f.left,borderWidth:o.borderWidth||0,borderColor:o.borderColor||"#000000",boxShadow:o.boxShadow||ur},metadata:{}}},Ii=t=>({fontFamily:t.fontFamily||"Arial",fontSize:t.fontSize||"16px",fontWeight:t.fontWeight||"normal",fontStyle:t.fontStyle||"normal",textDecoration:t.textDecoration||"none",textAlign:t.textAlign||"left",lineHeight:t.lineHeight||"normal",letterSpacing:t.letterSpacing||"normal",wordSpacing:t.wordSpacing||"normal",color:t.color||"#ffffff",backgroundColor:t.backgroundColor||"transparent",border:t.border||"none",textShadow:t.textShadow||"none",text:t.text||"",opacity:t.opacity??100,width:t.width||300,wordWrap:t.wordWrap||"normal",wordBreak:t.wordBreak||"normal",WebkitTextStrokeColor:t.WebkitTextStrokeColor||"#ffffff",WebkitTextStrokeWidth:t.WebkitTextStrokeWidth||"0px",top:t.top||"0px",left:t.left||"0px"}),jn=t=>Object.keys(t).reduce((r,n)=>{const{display:o}=t[n];return Math.max(r,o.to)},0);function wi(t,r){return t.map(n=>({...n,items:n.items.filter(o=>!r.includes(o))}))}function Ti(t){const r=P.subject.pipe(P.filter(({key:_})=>_.startsWith(P.ADD_PREFIX))),n=P.subject.pipe(P.filter(({key:_})=>_.startsWith(P.HISTORY_PREFIX))),o=P.subject.pipe(P.filter(({key:_})=>_.startsWith(P.ACTIVE_PREFIX))),a=P.subject.pipe(P.filter(({key:_})=>_.startsWith(P.EDIT_PREFIX))),u=n.subscribe(_=>{if(_.key===P.HISTORY_UNDO)return t.undo();if(_.key===P.HISTORY_REDO)return t.redo()}),f=r.subscribe(async _=>{var l,g,m,y;const d=dt(t.getState());if(_.key===P.ADD_TEXT){const I=await Si((l=_.value)==null?void 0:l.payload,{size:{width:1080,height:1920}}),{details:v,...h}=I;d.trackItemDetailsMap[h.id]={type:"text",details:v},d.trackItemsMap[h.id]=h,d.trackItemIds.push(h.id)}if(_.key===P.ADD_IMAGE){const I=await vi((g=_.value)==null?void 0:g.payload,{size:{width:1080,height:1920}}),{details:v,...h}=I;d.trackItemDetailsMap[h.id]={type:"image",details:v},d.trackItemsMap[h.id]=h,d.trackItemIds.push(h.id)}if(_.key===P.ADD_AUDIO){const I=await mi((m=_.value)==null?void 0:m.payload),{details:v,...h}=I;d.trackItemDetailsMap[h.id]={type:"audio",details:v},d.trackItemsMap[h.id]=h,d.trackItemIds.push(h.id)}if(_.key===P.ADD_VIDEO){const I=await gi((y=_.value)==null?void 0:y.payload,{size:{width:1080,height:1920}}),{details:v,...h}=I;d.trackItemDetailsMap[h.id]={type:"video",details:v},d.trackItemsMap[h.id]=h,d.trackItemIds.push(h.id)}const E=jn(d.trackItemsMap);t.updateState({trackItemIds:d.trackItemIds,trackItemDetailsMap:{...d.trackItemDetailsMap},trackItemsMap:{...d.trackItemsMap},duration:E},{updateHistory:!0,kind:"add"})}),p=o.subscribe(_=>{if(_.key===P.ACTIVE_DELETE){const d=dt(t.getState()),E=d.activeIds,l=d.trackItemIds,g=d.trackItemDetailsMap,m=l.filter(h=>!E.includes(h)),y=Object.fromEntries(Object.entries(g).filter(([h])=>!E.includes(h))),I=wi(d.tracks,E),v=jn(d.trackItemsMap);t.updateState({trackItemIds:m,trackItemDetailsMap:y,activeIds:[],tracks:I,duration:v},{updateHistory:!0,kind:"remove"})}}),T=a.subscribe(_=>{var d,E;if(_.key===P.EDIT_OBJECT){const l=t.getState(),g=dt(l.trackItemDetailsMap),m=Object.keys((d=_.value)==null?void 0:d.payload);if(!m.length)return;const y=(E=_.value)==null?void 0:E.payload;m.forEach(I=>{g[I].details={...g[I].details,...y[I].details}}),t.updateState({trackItemDetailsMap:{...g}},{updateHistory:!0,kind:"update:details"})}});return{unsubscribe:()=>{f.unsubscribe(),p.unsubscribe(),T.unsubscribe(),u.unsubscribe()}}}const Ai={Date:!0,RegExp:!0,String:!0,Number:!0};function Fn(t,r,n={cyclesFix:!0},o=[]){var p,T;let a=[];const u=Array.isArray(t);for(const _ in t){const d=t[_],E=u?+_:_;if(!(_ in r)){a.push({type:"REMOVE",path:[E],oldValue:t[_]});continue}const l=r[_],g=typeof d=="object"&&typeof l=="object"&&Array.isArray(d)===Array.isArray(l);if(d&&l&&g&&!Ai[(T=(p=Object.getPrototypeOf(d))==null?void 0:p.constructor)==null?void 0:T.name]&&(!n.cyclesFix||!o.includes(d))){const m=Fn(d,l,n,n.cyclesFix?o.concat([d]):[]);a.push.apply(a,m.map(y=>(y.path.unshift(E),y)))}else d!==l&&!(Number.isNaN(d)&&Number.isNaN(l))&&!(g&&(isNaN(d)?d+""==l+"":+d==+l))&&a.push({path:[E],type:"CHANGE",value:l,oldValue:d})}const f=Array.isArray(r);for(const _ in r)_ in t||a.push({type:"CREATE",path:[f?+_:_],value:r[_]});return a}var lr=Symbol.for("immer-nothing"),Kt=Symbol.for("immer-draftable"),J=Symbol.for("immer-state"),Rn=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function H(t,...r){if(process.env.NODE_ENV!=="production"){const n=Rn[t],o=typeof n=="function"?n.apply(null,r):n;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var It=Object.getPrototypeOf;function wt(t){return!!t&&!!t[J]}function gt(t){var r;return t?zn(t)||Array.isArray(t)||!!t[Kt]||!!((r=t.constructor)!=null&&r[Kt])||Xt(t)||qt(t):!1}var Ei=Object.prototype.constructor.toString();function zn(t){if(!t||typeof t!="object")return!1;const r=It(t);if(r===null)return!0;const n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Ei}function Vt(t,r){Tt(t)===0?Reflect.ownKeys(t).forEach(n=>{r(n,t[n],t)}):t.forEach((n,o)=>r(o,n,t))}function Tt(t){const r=t[J];return r?r.type_:Array.isArray(t)?1:Xt(t)?2:qt(t)?3:0}function Yt(t,r){return Tt(t)===2?t.has(r):Object.prototype.hasOwnProperty.call(t,r)}function pr(t,r){return Tt(t)===2?t.get(r):t[r]}function Hn(t,r,n){const o=Tt(t);o===2?t.set(r,n):o===3?t.add(n):t[r]=n}function Oi(t,r){return t===r?t!==0||1/t===1/r:t!==t&&r!==r}function Xt(t){return t instanceof Map}function qt(t){return t instanceof Set}function At(t){return t.copy_||t.base_}function dr(t,r){if(Xt(t))return new Map(t);if(qt(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=zn(t);if(r===!0||r==="class_only"&&!n){const o=Object.getOwnPropertyDescriptors(t);delete o[J];let a=Reflect.ownKeys(o);for(let u=0;u<a.length;u++){const f=a[u],p=o[f];p.writable===!1&&(p.writable=!0,p.configurable=!0),(p.get||p.set)&&(o[f]={configurable:!0,writable:!0,enumerable:p.enumerable,value:t[f]})}return Object.create(It(t),o)}else{const o=It(t);if(o!==null&&n)return{...t};const a=Object.create(o);return Object.assign(a,t)}}function hr(t,r=!1){return Te(t)||wt(t)||!gt(t)||(Tt(t)>1&&(t.set=t.add=t.clear=t.delete=xi),Object.freeze(t),r&&Object.entries(t).forEach(([n,o])=>hr(o,!0))),t}function xi(){H(2)}function Te(t){return Object.isFrozen(t)}var yr={};function Et(t){const r=yr[t];return r||H(0,t),r}function Pi(t,r){yr[t]||(yr[t]=r)}var Jt;function Nn(){return Jt}function Mi(t,r){return{drafts_:[],parent_:t,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Un(t,r){r&&(Et("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=r)}function br(t){_r(t),t.drafts_.forEach(Ci),t.drafts_=null}function _r(t){t===Jt&&(Jt=t.parent_)}function Ln(t){return Jt=Mi(Jt,t)}function Ci(t){const r=t[J];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function Gn(t,r){r.unfinalizedDrafts_=r.drafts_.length;const n=r.drafts_[0];return t!==void 0&&t!==n?(n[J].modified_&&(br(r),H(4)),gt(t)&&(t=Ae(r,t),r.parent_||Ee(r,t)),r.patches_&&Et("Patches").generateReplacementPatches_(n[J].base_,t,r.patches_,r.inversePatches_)):t=Ae(r,n,[]),br(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),t!==lr?t:void 0}function Ae(t,r,n){if(Te(r))return r;const o=r[J];if(!o)return Vt(r,(a,u)=>Bn(t,o,r,a,u,n)),r;if(o.scope_!==t)return r;if(!o.modified_)return Ee(t,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const a=o.copy_;let u=a,f=!1;o.type_===3&&(u=new Set(a),a.clear(),f=!0),Vt(u,(p,T)=>Bn(t,o,a,p,T,n,f)),Ee(t,a,!1),n&&t.patches_&&Et("Patches").generatePatches_(o,n,t.patches_,t.inversePatches_)}return o.copy_}function Bn(t,r,n,o,a,u,f){if(process.env.NODE_ENV!=="production"&&a===n&&H(5),wt(a)){const p=u&&r&&r.type_!==3&&!Yt(r.assigned_,o)?u.concat(o):void 0,T=Ae(t,a,p);if(Hn(n,o,T),wt(T))t.canAutoFreeze_=!1;else return}else f&&n.add(a);if(gt(a)&&!Te(a)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Ae(t,a),(!r||!r.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&Ee(t,a)}}function Ee(t,r,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&hr(r,n)}function Di(t,r){const n=Array.isArray(t),o={type_:n?1:0,scope_:r?r.scope_:Nn(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let a=o,u=gr;n&&(a=[o],u=Zt);const{revoke:f,proxy:p}=Proxy.revocable(a,u);return o.draft_=p,o.revoke_=f,p}var gr={get(t,r){if(r===J)return t;const n=At(t);if(!Yt(n,r))return ki(t,n,r);const o=n[r];return t.finalized_||!gt(o)?o:o===mr(t.base_,r)?(Sr(t),t.copy_[r]=Ir(o,t)):o},has(t,r){return r in At(t)},ownKeys(t){return Reflect.ownKeys(At(t))},set(t,r,n){const o=$n(At(t),r);if(o!=null&&o.set)return o.set.call(t.draft_,n),!0;if(!t.modified_){const a=mr(At(t),r),u=a==null?void 0:a[J];if(u&&u.base_===n)return t.copy_[r]=n,t.assigned_[r]=!1,!0;if(Oi(n,a)&&(n!==void 0||Yt(t.base_,r)))return!0;Sr(t),vr(t)}return t.copy_[r]===n&&(n!==void 0||r in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[r])||(t.copy_[r]=n,t.assigned_[r]=!0),!0},deleteProperty(t,r){return mr(t.base_,r)!==void 0||r in t.base_?(t.assigned_[r]=!1,Sr(t),vr(t)):delete t.assigned_[r],t.copy_&&delete t.copy_[r],!0},getOwnPropertyDescriptor(t,r){const n=At(t),o=Reflect.getOwnPropertyDescriptor(n,r);return o&&{writable:!0,configurable:t.type_!==1||r!=="length",enumerable:o.enumerable,value:n[r]}},defineProperty(){H(11)},getPrototypeOf(t){return It(t.base_)},setPrototypeOf(){H(12)}},Zt={};Vt(gr,(t,r)=>{Zt[t]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),Zt.deleteProperty=function(t,r){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(r))&&H(13),Zt.set.call(this,t,r,void 0)},Zt.set=function(t,r,n){return process.env.NODE_ENV!=="production"&&r!=="length"&&isNaN(parseInt(r))&&H(14),gr.set.call(this,t[0],r,n,t[0])};function mr(t,r){const n=t[J];return(n?At(n):t)[r]}function ki(t,r,n){var a;const o=$n(r,n);return o?"value"in o?o.value:(a=o.get)==null?void 0:a.call(t.draft_):void 0}function $n(t,r){if(!(r in t))return;let n=It(t);for(;n;){const o=Object.getOwnPropertyDescriptor(n,r);if(o)return o;n=It(n)}}function vr(t){t.modified_||(t.modified_=!0,t.parent_&&vr(t.parent_))}function Sr(t){t.copy_||(t.copy_=dr(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var ji=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(r,n,o)=>{if(typeof r=="function"&&typeof n!="function"){const u=n;n=r;const f=this;return function(T=u,..._){return f.produce(T,d=>n.call(this,d,..._))}}typeof n!="function"&&H(6),o!==void 0&&typeof o!="function"&&H(7);let a;if(gt(r)){const u=Ln(this),f=Ir(r,void 0);let p=!0;try{a=n(f),p=!1}finally{p?br(u):_r(u)}return Un(u,o),Gn(a,u)}else if(!r||typeof r!="object"){if(a=n(r),a===void 0&&(a=r),a===lr&&(a=void 0),this.autoFreeze_&&hr(a,!0),o){const u=[],f=[];Et("Patches").generateReplacementPatches_(r,a,u,f),o(u,f)}return a}else H(1,r)},this.produceWithPatches=(r,n)=>{if(typeof r=="function")return(f,...p)=>this.produceWithPatches(f,T=>r(T,...p));let o,a;return[this.produce(r,n,(f,p)=>{o=f,a=p}),o,a]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){gt(t)||H(8),wt(t)&&(t=Fi(t));const r=Ln(this),n=Ir(t,void 0);return n[J].isManual_=!0,_r(r),n}finishDraft(t,r){const n=t&&t[J];(!n||!n.isManual_)&&H(9);const{scope_:o}=n;return Un(o,r),Gn(void 0,o)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,r){let n;for(n=r.length-1;n>=0;n--){const a=r[n];if(a.path.length===0&&a.op==="replace"){t=a.value;break}}n>-1&&(r=r.slice(n+1));const o=Et("Patches").applyPatches_;return wt(t)?o(t,r):this.produce(t,a=>o(a,r))}};function Ir(t,r){const n=Xt(t)?Et("MapSet").proxyMap_(t,r):qt(t)?Et("MapSet").proxySet_(t,r):Di(t,r);return(r?r.scope_:Nn()).drafts_.push(n),n}function Fi(t){return wt(t)||H(10,t),Wn(t)}function Wn(t){if(!gt(t)||Te(t))return t;const r=t[J];let n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=dr(t,r.scope_.immer_.useStrictShallowCopy_)}else n=dr(t,!0);return Vt(n,(o,a)=>{Hn(n,o,Wn(a))}),r&&(r.finalized_=!1),n}function Kn(){process.env.NODE_ENV!=="production"&&Rn.push('Sets cannot have "replace" patches.',function(l){return"Unsupported patch operation: "+l},function(l){return"Cannot apply patch, path doesn't resolve: "+l},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");const r="replace",n="add",o="remove";function a(l,g,m,y){switch(l.type_){case 0:case 2:return f(l,g,m,y);case 1:return u(l,g,m,y);case 3:return p(l,g,m,y)}}function u(l,g,m,y){let{base_:I,assigned_:v}=l,h=l.copy_;h.length<I.length&&([I,h]=[h,I],[m,y]=[y,m]);for(let S=0;S<I.length;S++)if(v[S]&&h[S]!==I[S]){const A=g.concat([S]);m.push({op:r,path:A,value:E(h[S])}),y.push({op:r,path:A,value:E(I[S])})}for(let S=I.length;S<h.length;S++){const A=g.concat([S]);m.push({op:n,path:A,value:E(h[S])})}for(let S=h.length-1;I.length<=S;--S){const A=g.concat([S]);y.push({op:o,path:A})}}function f(l,g,m,y){const{base_:I,copy_:v}=l;Vt(l.assigned_,(h,S)=>{const A=pr(I,h),G=pr(v,h),R=S?Yt(I,h)?r:n:o;if(A===G&&R===r)return;const F=g.concat(h);m.push(R===o?{op:R,path:F}:{op:R,path:F,value:G}),y.push(R===n?{op:o,path:F}:R===o?{op:n,path:F,value:E(A)}:{op:r,path:F,value:E(A)})})}function p(l,g,m,y){let{base_:I,copy_:v}=l,h=0;I.forEach(S=>{if(!v.has(S)){const A=g.concat([h]);m.push({op:o,path:A,value:S}),y.unshift({op:n,path:A,value:S})}h++}),h=0,v.forEach(S=>{if(!I.has(S)){const A=g.concat([h]);m.push({op:n,path:A,value:S}),y.unshift({op:o,path:A,value:S})}h++})}function T(l,g,m,y){m.push({op:r,path:[],value:g===lr?void 0:g}),y.push({op:r,path:[],value:l})}function _(l,g){return g.forEach(m=>{const{path:y,op:I}=m;let v=l;for(let G=0;G<y.length-1;G++){const R=Tt(v);let F=y[G];typeof F!="string"&&typeof F!="number"&&(F=""+F),(R===0||R===1)&&(F==="__proto__"||F==="constructor")&&H(19),typeof v=="function"&&F==="prototype"&&H(19),v=pr(v,F),typeof v!="object"&&H(18,y.join("/"))}const h=Tt(v),S=d(m.value),A=y[y.length-1];switch(I){case r:switch(h){case 2:return v.set(A,S);case 3:H(16);default:return v[A]=S}case n:switch(h){case 1:return A==="-"?v.push(S):v.splice(A,0,S);case 2:return v.set(A,S);case 3:return v.add(S);default:return v[A]=S}case o:switch(h){case 1:return v.splice(A,1);case 2:return v.delete(A);case 3:return v.delete(m.value);default:return delete v[A]}default:H(17,I)}}),l}function d(l){if(!gt(l))return l;if(Array.isArray(l))return l.map(d);if(Xt(l))return new Map(Array.from(l.entries()).map(([m,y])=>[m,d(y)]));if(qt(l))return new Set(Array.from(l).map(d));const g=Object.create(It(l));for(const m in l)g[m]=d(l[m]);return Yt(l,Kt)&&(g[Kt]=l[Kt]),g}function E(l){return wt(l)?d(l):l}Pi("Patches",{applyPatches_:_,generatePatches_:a,generateReplacementPatches_:T})}var Z=new ji,Ri=Z.produce;Z.produceWithPatches.bind(Z),Z.setAutoFreeze.bind(Z),Z.setUseStrictShallowCopy.bind(Z);var zi=Z.applyPatches.bind(Z);Z.createDraft.bind(Z),Z.finishDraft.bind(Z);var Hi=1/0,Ni=9007199254740991,Ui="[object Arguments]",Li="[object Function]",Gi="[object GeneratorFunction]",Bi="[object Symbol]",$i=typeof Q=="object"&&Q&&Q.Object===Object&&Q,Wi=typeof self=="object"&&self&&self.Object===Object&&self,Ki=$i||Wi||Function("return this")();function Vi(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}function Yi(t,r){for(var n=-1,o=t?t.length:0,a=Array(o);++n<o;)a[n]=r(t[n],n,t);return a}function Xi(t,r){for(var n=-1,o=r.length,a=t.length;++n<o;)t[a+n]=r[n];return t}var wr=Object.prototype,qi=wr.hasOwnProperty,Tr=wr.toString,Vn=Ki.Symbol,Ji=wr.propertyIsEnumerable,Yn=Vn?Vn.isConcatSpreadable:void 0,Xn=Math.max;function Zi(t,r,n,o,a){var u=-1,f=t.length;for(n||(n=ro),a||(a=[]);++u<f;){var p=t[u];n(p)?Xi(a,p):a[a.length]=p}return a}function Qi(t,r){return t=Object(t),to(t,r,function(n,o){return o in t})}function to(t,r,n){for(var o=-1,a=r.length,u={};++o<a;){var f=r[o],p=t[f];n(p,f)&&(u[f]=p)}return u}function eo(t,r){return r=Xn(r===void 0?t.length-1:r,0),function(){for(var n=arguments,o=-1,a=Xn(n.length-r,0),u=Array(a);++o<a;)u[o]=n[r+o];o=-1;for(var f=Array(r+1);++o<r;)f[o]=n[o];return f[r]=u,Vi(t,this,f)}}function ro(t){return oo(t)||io(t)||!!(Yn&&t&&t[Yn])}function no(t){if(typeof t=="string"||lo(t))return t;var r=t+"";return r=="0"&&1/t==-Hi?"-0":r}function io(t){return ao(t)&&qi.call(t,"callee")&&(!Ji.call(t,"callee")||Tr.call(t)==Ui)}var oo=Array.isArray;function so(t){return t!=null&&uo(t.length)&&!co(t)}function ao(t){return qn(t)&&so(t)}function co(t){var r=fo(t)?Tr.call(t):"";return r==Li||r==Gi}function uo(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ni}function fo(t){var r=typeof t;return!!t&&(r=="object"||r=="function")}function qn(t){return!!t&&typeof t=="object"}function lo(t){return typeof t=="symbol"||qn(t)&&Tr.call(t)==Bi}var po=eo(function(t,r){return t==null?{}:Qi(t,Yi(Zi(r),no))}),ho=po;const Jn=cr(ho),yo={tracks:[],trackItemIds:[],trackItemsMap:{},transitionIds:[],transitionsMap:{},scale:{unit:1,zoom:1,segments:1},duration:0,activeIds:[],trackItemDetailsMap:{}},Zn=["tracks","trackItemsMap","trackItemDetailsMap","transitionIds","transitionsMap","trackItemIds"];class bo{constructor(r){jt(this,"stateSubject");jt(this,"stateHistorySubject");jt(this,"prevState");jt(this,"undos",[]);jt(this,"redos",[]);jt(this,"listener");const n=r||yo;this.stateSubject=new Dn(n),this.stateHistorySubject=new Dn({handleRedo:!1,handleUndo:!1}),this.prevState=n,this.initListeners()}initListeners(){Ti(this)}destroyListeners(){this.listener&&this.listener.unsubscribe()}purge(){this.destroyListeners()}updateHistory(r,n){const o=Jn(r,Zn),a=Jn(this.getState(),Zn),u=Fn(a,o);u.length&&(this.undos.push({undos:u,type:n}),this.redos=[])}getStateHistory(){return this.stateHistorySubject.getValue()}subscribeHistory(r){return this.stateHistorySubject.subscribe(r)}getState(){return this.stateSubject.getValue()}subscribe(r){return this.stateSubject.subscribe(r)}updateState(r,n={updateHistory:!1}){const o=this.getState(),a={...o,...r};st(o,a)||(n.updateHistory&&this.updateHistory(a,n.kind),this.prevState=o,this.stateSubject.next(a))}subscribeToScale(r){return this.stateSubject.asObservable().subscribe(n=>{st(n.scale,this.prevState.scale)||r({scale:n.scale})})}subscribeToUpdateItemDetails(r){return this.stateSubject.asObservable().subscribe(n=>{st(n.trackItemDetailsMap,this.prevState.trackItemDetailsMap)||r({trackItemDetailsMap:n.trackItemDetailsMap})})}subscribeToDuration(r){return this.stateSubject.asObservable().subscribe(n=>{n.duration!==this.prevState.duration&&r({duration:n.duration})})}subscribeToHistory(r){return this.stateHistorySubject.asObservable().subscribe(n=>{if(n.handleRedo){const o=this.undos[this.undos.length-1].type;o==="update"&&r({...this.getState(),type:o}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}if(n.handleUndo){const o=this.redos[this.redos.length-1].type;o==="update"&&r({...this.getState(),type:o}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}})}subscribeToAddOrRemoveItems(r){return this.stateSubject.asObservable().subscribe(n=>{st(n.trackItemIds,this.prevState.trackItemIds)||r({trackItemIds:n.trackItemIds})})}subscribeToActiveIds(r){return this.stateSubject.asObservable().subscribe(n=>{st(n.activeIds,this.prevState.activeIds)||r({activeIds:n.activeIds})})}subscribeToTracks(r){return this.stateSubject.asObservable().subscribe(n=>{(!st(n.tracks,this.prevState.tracks)||!st(n.trackItemIds,this.prevState.trackItemIds)||!st(n.trackItemsMap,this.prevState.trackItemsMap)||!st(n.transitionIds,this.prevState.transitionIds)||!st(n.transitionsMap,this.prevState.transitionsMap))&&r({tracks:n.tracks,trackItemIds:n.trackItemIds,trackItemsMap:n.trackItemsMap,transitionIds:n.transitionIds,transitionsMap:n.transitionsMap})})}undo(){const r=this.undos.pop(),n=r==null?void 0:r.undos,o=r==null?void 0:r.type;if(!n||!o)return;Kn();const{trackItemDetailsMap:a,trackItemIds:u,tracks:f,transitionIds:p,transitionsMap:T,trackItemsMap:_}=this.getState(),d=dt({trackItemDetailsMap:a,trackItemIds:u,tracks:f,transitionIds:p,transitionsMap:T,trackItemsMap:_}),E=[],l=[],g=[],m=[],y=[],I=[];n.forEach(M=>{let j;const V=M.path.slice(1);M.type==="CREATE"?j={path:V,op:"remove",value:M.value}:M.type==="CHANGE"?j={path:V,op:"replace",value:M.oldValue}:j={path:V,op:"add",value:M.oldValue},M.path.includes("trackItemIds")?g.push(j):M.path.includes("transitionIds")?l.push(j):M.path.includes("trackItemsMap")?y.push(j):M.path.includes("transitionsMap")?m.push(j):M.path.includes("tracks")?E.push(j):M.path.includes("trackItemDetailsMap")&&I.push(j)});const v=this.applyPatch(d.tracks,E),h=this.applyPatch(d.transitionIds,l),S=this.applyPatch(d.trackItemIds,g),A=this.applyPatch(d.transitionsMap,m),G=this.applyPatch(d.trackItemsMap,y),R=this.applyPatch(d.trackItemDetailsMap,I),F=dt({tracks:v,transitionIds:h,trackItemIds:S,transitionsMap:A,trackItemsMap:G,trackItemDetailsMap:R}),at=dt(this.getState()),mt={...at,...F};this.prevState=at,this.redos.push({redos:n,type:o}),this.stateSubject.next(mt),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!0})}applyPatch(r,n){return n.reverse().reduce((o,a)=>Ri(o,u=>{zi(u,[a])}),r)}redo(){const r=this.redos.pop(),n=r==null?void 0:r.redos,o=r==null?void 0:r.type;if(!n||!o)return;Kn();const{trackItemDetailsMap:a,trackItemIds:u,tracks:f,transitionIds:p,transitionsMap:T,trackItemsMap:_}=this.getState(),d=dt({trackItemDetailsMap:a,trackItemIds:u,tracks:f,transitionIds:p,transitionsMap:T,trackItemsMap:_}),E=[],l=[],g=[],m=[],y=[],I=[];n.forEach(M=>{let j;const V=M.path.slice(1);M.type==="CREATE"?j={path:V,op:"add",value:M.value}:M.type==="CHANGE"?j={path:V,op:"replace",value:M.value}:j={path:V,op:"remove",value:M.oldValue},M.path.includes("trackItemIds")?g.push(j):M.path.includes("transitionIds")?l.push(j):M.path.includes("trackItemsMap")?y.push(j):M.path.includes("transitionsMap")?m.push(j):M.path.includes("trackItemDetailsMap")?I.push(j):E.push(j)});const v=this.applyPatch(d.tracks,E),h=this.applyPatch(d.transitionIds,l),S=this.applyPatch(d.trackItemIds,g),A=this.applyPatch(d.transitionsMap,m),G=this.applyPatch(d.trackItemsMap,y),R=this.applyPatch(d.trackItemDetailsMap,I),F=dt({tracks:v,transitionIds:h,trackItemIds:S,transitionsMap:A,trackItemsMap:G,trackItemDetailsMap:R}),at=dt(this.getState()),mt={...at,...F};this.prevState=at,this.undos.push({undos:n,type:o}),this.stateSubject.next(mt),this.stateHistorySubject.next({handleRedo:!0,handleUndo:!1})}}return bo});
@@ -0,0 +1,67 @@
1
+ import { IKindHistory, IStateManager, IUpdateStateOptions, State } from '@designcombo/types';
2
+ import { Difference } from 'microdiff';
3
+ import { Patch } from 'immer';
4
+
5
+ interface StateHistory {
6
+ handleUndo: boolean;
7
+ handleRedo: boolean;
8
+ }
9
+ declare class StateManager implements IStateManager {
10
+ private stateSubject;
11
+ private stateHistorySubject;
12
+ private prevState;
13
+ undos: {
14
+ undos: Difference[];
15
+ type: IKindHistory;
16
+ }[];
17
+ redos: {
18
+ redos: Difference[];
19
+ type: IKindHistory;
20
+ }[];
21
+ private listener;
22
+ constructor(state?: State);
23
+ initListeners(): void;
24
+ destroyListeners(): void;
25
+ purge(): void;
26
+ updateHistory(newState: State, type: IKindHistory): void;
27
+ getStateHistory(): StateHistory;
28
+ subscribeHistory(callback: (hisotry: StateHistory) => void): import('rxjs').Subscription;
29
+ getState(): State;
30
+ subscribe(callback: (state: State) => void): import('rxjs').Subscription;
31
+ updateState(partialState: Partial<State>, options?: IUpdateStateOptions): void;
32
+ subscribeToScale(callback: (v: {
33
+ scale: State["scale"];
34
+ }) => void): import('rxjs').Subscription;
35
+ subscribeToUpdateItemDetails(callback: (trackItemDetailsMap: {
36
+ trackItemDetailsMap: State["trackItemDetailsMap"];
37
+ }) => void): import('rxjs').Subscription;
38
+ subscribeToDuration(callback: (duration: {
39
+ duration: State["duration"];
40
+ }) => void): import('rxjs').Subscription;
41
+ subscribeToHistory(callback: (hisotry: {
42
+ tracks: State["tracks"];
43
+ trackItemsMap: State["trackItemsMap"];
44
+ trackItemDetailsMap: State["trackItemDetailsMap"];
45
+ trackItemIds: State["trackItemIds"];
46
+ transitionIds: State["transitionIds"];
47
+ transitionsMap: State["transitionsMap"];
48
+ type: IKindHistory;
49
+ }) => void): import('rxjs').Subscription;
50
+ subscribeToAddOrRemoveItems(callback: (trackItemIds: {
51
+ trackItemIds: State["trackItemIds"];
52
+ }) => void): import('rxjs').Subscription;
53
+ subscribeToActiveIds(callback: (activeIds: {
54
+ activeIds: State["activeIds"];
55
+ }) => void): import('rxjs').Subscription;
56
+ subscribeToTracks(callback: (tracksInfo: {
57
+ tracks: State["tracks"];
58
+ trackItemIds: State["trackItemIds"];
59
+ trackItemsMap: State["trackItemsMap"];
60
+ transitionIds: State["transitionIds"];
61
+ transitionsMap: State["transitionsMap"];
62
+ }) => void): import('rxjs').Subscription;
63
+ undo(): void;
64
+ applyPatch(json: any, patches: Patch[]): any;
65
+ redo(): void;
66
+ }
67
+ export default StateManager;
@@ -0,0 +1,4 @@
1
+ export declare const loadFonts: (fonts: {
2
+ fontFamily: string;
3
+ url: string;
4
+ }[]) => Promise<unknown>;
@@ -0,0 +1,26 @@
1
+ import { IAudio, IImage, IText, IVideo } from '@designcombo/types';
2
+
3
+ type OptionsType = {
4
+ size: {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ origin: number;
9
+ };
10
+ export declare const loadVideoItem: (layer: IVideo, options: Partial<OptionsType>) => Promise<IVideo>;
11
+ export declare const loadAudioItem: (payload: IAudio) => Promise<IAudio>;
12
+ export declare const loadImageItem: (payload: IImage, options: {
13
+ origin?: number;
14
+ size?: {
15
+ width: number;
16
+ height: number;
17
+ };
18
+ }) => Promise<IImage>;
19
+ export declare const loadTextItem: (payload: IText, options: {
20
+ origin?: number;
21
+ size?: {
22
+ width: number;
23
+ height: number;
24
+ };
25
+ }) => Promise<IText>;
26
+ export {};
@@ -0,0 +1,13 @@
1
+ export declare const getImageInfo: (src: string) => Promise<{
2
+ width: number;
3
+ height: number;
4
+ }>;
5
+ export declare const getAudioInfo: (src: string) => Promise<{
6
+ duration: number;
7
+ }>;
8
+ export declare const getVideoInfo: (src: string) => Promise<{
9
+ duration: number;
10
+ width: number;
11
+ height: number;
12
+ }>;
13
+ export declare const getTextInfo: (text: string, styles: any) => number;
@@ -0,0 +1,4 @@
1
+ import { ITrack, ITrackItem } from '@designcombo/types';
2
+
3
+ export declare const getDuration: (trackItems: Record<string, ITrackItem>) => number;
4
+ export declare function removeItemsFromTrack(tracks: ITrack[], itemsToRemove: string[]): ITrack[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@designcombo/state",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist"
@@ -16,19 +16,29 @@
16
16
  }
17
17
  },
18
18
  "devDependencies": {
19
+ "@types/lodash.clonedeep": "^4.5.9",
20
+ "@types/lodash.isequal": "^4.5.8",
21
+ "@types/lodash.pick": "^4.4.9",
19
22
  "@types/node": "^20.11.24",
23
+ "rollup-plugin-peer-deps-external": "^2.2.4",
20
24
  "typescript": "^5.3.3",
21
25
  "vite": "^5.2.0",
22
26
  "vite-plugin-dts": "^3.9.1",
23
- "rollup-plugin-peer-deps-external": "^2.2.4",
27
+ "@designcombo/events": "0.1.4",
28
+ "@designcombo/types": "0.1.4",
24
29
  "@designcombo/typescript-config": "0.0.0"
25
30
  },
26
31
  "dependencies": {
32
+ "immer": "^10.1.1",
33
+ "lodash.clonedeep": "^4.5.0",
34
+ "lodash.isequal": "^4.5.0",
35
+ "lodash.pick": "^4.4.0",
36
+ "microdiff": "^1.4.0",
27
37
  "rxjs": "^7.8.1"
28
38
  },
29
39
  "peerDependencies": {
30
- "@designcombo/events": "0.1.3",
31
- "@designcombo/types": "0.1.3"
40
+ "@designcombo/events": "0.1.4",
41
+ "@designcombo/types": "0.1.4"
32
42
  },
33
43
  "scripts": {
34
44
  "dev": "vite",