@designcombo/state 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/handle-events.d.ts +6 -0
- package/dist/index.d.ts +1 -18
- package/dist/index.es.js +2878 -53
- package/dist/index.umd.js +3 -1
- package/dist/state.d.ts +67 -0
- package/dist/utils/fonts.d.ts +4 -0
- package/dist/utils/load-item.d.ts +26 -0
- package/dist/utils/media.d.ts +13 -0
- package/dist/utils/track.d.ts +4 -0
- package/package.json +16 -5
package/dist/index.umd.js
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
(function(
|
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 mo=Object.defineProperty;var vo=(P,K,ot)=>K in P?mo(P,K,{enumerable:!0,configurable:!0,writable:!0,value:ot}):P[K]=ot;var jt=(P,K,ot)=>vo(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),w=p.next();!w.done;w=p.next()){var _=w.value;_.remove(this)}}catch(y){r={error:y}}finally{try{w&&!w.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 v=g.value;try{wn(v)}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,w=f.source;u.add(p?p.call(u,w):w?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(w){u(w),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 w=p.value;w.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),kn=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]",w="[object Array]",_="[object AsyncFunction]",d="[object Boolean]",E="[object Date]",l="[object Error]",g="[object Function]",v="[object GeneratorFunction]",y="[object Map]",T="[object Number]",S="[object Null]",m="[object Object]",h="[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]",k="[object Uint16Array]",Pr="[object Uint32Array]",Mr=/[\\^$.*+?()[\]{}|]/g,et=/^\[object .+?Constructor\]$/,Me=/^(?:0|[1-9]\d*)$/,D={};D[Oe]=D[xe]=D[Pe]=D[Ar]=D[Er]=D[Or]=D[xr]=D[k]=D[Pr]=!0,D[p]=D[w]=D[j]=D[d]=D[V]=D[E]=D[l]=D[g]=D[y]=D[T]=D[m]=D[G]=D[R]=D[F]=D[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")(),ke=r&&!r.nodeType&&r,De=ke&&!0&&t&&!t.nodeType&&t,Qt=De&&De.exports===ke,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,I=0,b=[];++s<c;){var x=e[s];i(x,s,e)&&(b[I++]=x)}return b}function re(e,i){for(var s=-1,c=i.length,I=e.length;++s<c;)e[I+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 kr(e,i){for(var s=-1,c=Array(e);++s<e;)c[s]=i(s);return c}function Dr(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,I){s[++i]=[I,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 Wr(){this.__data__=[],this.size=0}function $r(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=Wr,B.prototype.delete=$r,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 We(e){return this.__data__.set(e,o),this}function Gt(e){return this.__data__.has(e)}Lt.prototype.add=Lt.prototype.push=We,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=Wt(e),c=!s&&Xe(e),I=!s&&!c&&$t(e),b=!s&&!c&&!I&&Ze(e),x=s||c||I||b,O=x?kr(e.length,String):[],z=O.length;for(var C in e)tt.call(e,C)&&!(x&&(C=="length"||I&&(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 Wt(e)?c:re(c,s(e))}function Ct(e){return e==null?e===void 0?mt:S:nt&&nt in Object(e)?bt(e):Ve(e)}function $e(e){return lt(e)&&Ct(e)==p}function Ke(e,i,s,c,I){return e===i?!0:e==null||i==null||!lt(e)&&!lt(i)?e!==e&&i!==i:sn(e,i,s,c,Ke,I)}function sn(e,i,s,c,I,b){var x=Wt(e),O=Wt(i),z=x?w:ft(e),C=O?w:ft(i);z=z==p?m:z,C=C==p?m:C;var W=z==m,q=C==m,N=z==C;if(N&&$t(e)){if(!$t(i))return!1;x=!0,W=!1}if(N&&!W)return b||(b=new ut),x||Ze(e)?he(e,i,s,c,I,b):fn(e,i,z,s,c,I,b);if(!(s&a)){var $=W&&tt.call(e,"__wrapped__"),L=q&&tt.call(i,"__wrapped__");if($||L){var St=$?e.value():e,_t=L?i.value():i;return b||(b=new ut),I(St,_t,s,c,b)}}return N?(b||(b=new ut),ln(e,i,s,c,I,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)&&!!D[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,I,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 W=-1,q=!0,N=s&u?new Lt:void 0;for(b.set(e,i),b.set(i,e);++W<O;){var $=e[W],L=i[W];if(c)var St=x?c(L,$,W,i,e,b):c($,L,W,e,i,b);if(St!==void 0){if(St)continue;q=!1;break}if(N){if(!Re(i,function(_t,Dt){if(!Ft(N,Dt)&&($===_t||I($,_t,s,c,b)))return N.push(Dt)})){q=!1;break}}else if(!($===L||I($,L,s,c,b))){q=!1;break}}return b.delete(e),b.delete(i),q}function fn(e,i,s,c,I,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 T: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 W=he(O(e),O(i),c,I,b,x);return x.delete(e),W;case at:if(le)return le.call(e)==le.call(i)}return!1}function ln(e,i,s,c,I,b){var x=s&a,O=kt(e),z=O.length,C=kt(i),W=C.length;if(z!=W&&!x)return!1;for(var q=z;q--;){var N=O[q];if(!(x?N in i:tt.call(i,N)))return!1}var $=b.get(e);if($&&b.get(i))return $==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],Dt=i[N];if(c)var Qn=x?c(Dt,_t,N,i,e,b):c(_t,Dt,N,e,i,b);if(!(Qn===void 0?_t===Dt||I(_t,Dt,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 kt(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 I=Ue.call(e);return c&&(i?e[nt]=s:delete e[nt]),I}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())!=h||ue&&ft(new ue)!=R||fe&&ft(new fe)!=M)&&(ft=function(e){var i=Ct(e),s=i==m?e.constructor:void 0,c=s?Y(s):"";if(c)switch(c){case Ge:return V;case ht:return y;case Rr:return h;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=$e(function(){return arguments}())?$e:function(e){return lt(e)&&tt.call(e,"callee")&&!Nt.call(e,"callee")},Wt=Array.isArray;function ye(e){return e!=null&&be(e.length)&&!qe(e)}var $t=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==v||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?Dr(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]",w="[object Date]",_="[object Error]",d="[object Function]",E="[object GeneratorFunction]",l="[object Map]",g="[object Number]",v="[object Object]",y="[object Promise]",T="[object RegExp]",S="[object Set]",m="[object String]",h="[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*)$/,k={};k[u]=k[f]=k[G]=k[R]=k[p]=k[w]=k[F]=k[at]=k[mt]=k[M]=k[j]=k[l]=k[g]=k[v]=k[T]=k[S]=k[m]=k[h]=k[V]=k[Oe]=k[xe]=k[Pe]=!0,k[_]=k[d]=k[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,D=Me&&!0&&t&&!t.nodeType&&t,Ce=D&&D.exports===Me;function Cr(e,i){return e.set(i[0],i[1]),e}function rt(e,i){return e.add(i),e}function ke(e,i){for(var s=-1,c=e?e.length:0;++s<c&&i(e[s],s,e)!==!1;);return e}function De(e,i){for(var s=-1,c=i.length,I=e.length;++s<c;)e[I+s]=i[s];return e}function Qt(e,i,s,c){for(var I=-1,b=e?e.length:0;++I<b;)s=i(s,e[I],I,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,I){s[++i]=[I,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 kr=Array.prototype,Dr=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=Dr.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=kr.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 Wr(){this.__data__={hash:new ht,map:new(xt||U),string:new ht}}function $r(e){return kt(this,e).delete(e)}function Kr(e){return kt(this,e).get(e)}function Vr(e){return kt(this,e).has(e)}function Yr(e,i){return kt(this,e).set(e,i),this}B.prototype.clear=Wr,B.prototype.delete=$r,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)||Wt(e)?te(e.length,String):[],c=s.length,I=!!c;for(var b in e)ct.call(e,b)&&!(I&&(b=="length"||hn(b,c)))&&s.push(b);return s}function We(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,I,b,x){var O;if(c&&(O=b?c(e,I,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),W=C==d||C==E;if(qe(e))return Bt(e,i);if(C==v||C==u||W&&!b){if(ee(e))return b?e:{};if(O=ft(W?{}:e),!i)return fn(e,ut(O,e))}else{if(!k[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 ke(N||e,function($,L){N&&(L=$,$=e[L]),We(O,L,pe($,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:De(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 $e(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 I=-1,b=i.length;++I<b;){var x=i[I],O=void 0;We(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 kt(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)!=S||se&&bt(new se)!=A)&&(bt=function(e){var i=Rt.call(e),s=i==v?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 S;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 I=e.constructor;switch(i){case G:return de(e);case p:case w:return new I(+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 $e(e,c,s);case g:case m:return new I(e);case T:return Ke(e);case S:return sn(e,c,s);case h: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 Wt(e){return _n(e)&&ct.call(e,"callee")&&(!Ue.call(e,"callee")||Rt.call(e)==u)}var ye=Array.isArray;function $t(e){return e!=null&&Je(e.length)&&!be(e)}function _n(e){return Ze(e)&&$t(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 $t(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)=>{const n=(r==null?void 0:r.duration)||5e3,o={from:0,to:n};if(!t)return o;if(t.from<0)return console.error("'from' must be a non-negative number. Returning default display."),o;if(t.from!==void 0&&t.to===void 0)return{from:t.from,to:t.from+n};if(t.to!==void 0){if(t.to<0)return console.error("'to' must be a non-negative number. Returning default display."),o;if(t.to<t.from)return console.error("'to' must be greater than or equal to 'from'. Returning default display."),o}return t},Dn=(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:Dn(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:Dn(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"}),wi="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ti=(t=21)=>{let r="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)r+=wi[n[t]&63];return r};const jn=t=>Object.keys(t).reduce((r,n)=>{const{display:o}=t[n];return Math.max(r,o.to)},0);function Ai(t,r){return t.map(n=>({...n,items:n.items.filter(o=>!r.includes(o))}))}function Ei(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,v,y,T;const d=dt(t.getState());if(_.key===P.ADD_TEXT){const S=await Si((l=_.value)==null?void 0:l.payload,{size:{width:1080,height:1920}}),{details:m,...h}=S;d.trackItemDetailsMap[h.id]={type:"text",details:m},d.trackItemsMap[h.id]=h,d.trackItemIds.push(h.id)}if(_.key===P.ADD_IMAGE){const S=await vi((g=_.value)==null?void 0:g.payload,{size:{width:1080,height:1920}}),{details:m,...h}=S;d.trackItemDetailsMap[h.id]={type:"image",details:m},d.trackItemsMap[h.id]=h,d.trackItemIds.push(h.id)}if(_.key===P.ADD_AUDIO){const S=await mi((v=_.value)==null?void 0:v.payload),{details:m,...h}=S;d.trackItemDetailsMap[h.id]={type:"audio",details:m},d.trackItemsMap[h.id]=h,d.trackItemIds.push(h.id)}if(_.key===P.ADD_VIDEO){const S=await gi((y=_.value)==null?void 0:y.payload,{size:{width:1080,height:1920}}),{details:m,...h}=S;d.trackItemDetailsMap[h.id]={type:"video",details:m},d.trackItemsMap[h.id]=h,d.trackItemIds.push(h.id)}d.tracks.unshift({id:Ti(),accepts:["text","audio","helper","video","image"],type:"text",items:[(T=_.value)==null?void 0:T.payload.id],magnetic:!1,static:!1});const E=jn(d.trackItemsMap);t.updateState({trackItemIds:d.trackItemIds,trackItemDetailsMap:{...d.trackItemDetailsMap},trackItemsMap:{...d.trackItemsMap},tracks:d.tracks,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,v=l.filter(m=>!E.includes(m)),y=Object.fromEntries(Object.entries(g).filter(([m])=>!E.includes(m))),T=Ai(d.tracks,E),S=jn(d.trackItemsMap);t.updateState({trackItemIds:v,trackItemDetailsMap:y,activeIds:[],tracks:T,duration:S},{updateHistory:!0,kind:"remove"})}}),w=a.subscribe(_=>{var d,E;if(_.key===P.EDIT_OBJECT){const l=t.getState(),g=dt(l.trackItemDetailsMap),v=Object.keys((d=_.value)==null?void 0:d.payload);if(!v.length)return;const y=(E=_.value)==null?void 0:E.payload;v.forEach(T=>{g[T].details={...g[T].details,...y[T].details}}),t.updateState({trackItemDetailsMap:{...g}},{updateHistory:!0,kind:"update:details"})}});return{unsubscribe:()=>{f.unsubscribe(),p.unsubscribe(),w.unsubscribe(),u.unsubscribe()}}}const Oi={Date:!0,RegExp:!0,String:!0,Number:!0};function Fn(t,r,n={cyclesFix:!0},o=[]){var p,w;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&&!Oi[(w=(p=Object.getPrototypeOf(d))==null?void 0:p.constructor)==null?void 0:w.name]&&(!n.cyclesFix||!o.includes(d))){const v=Fn(d,l,n,n.cyclesFix?o.concat([d]):[]);a.push.apply(a,v.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 xi=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)===xi}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 Pi(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=Mi),Object.freeze(t),r&&Object.entries(t).forEach(([n,o])=>hr(o,!0))),t}function Mi(){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 Ci(t,r){yr[t]||(yr[t]=r)}var Jt;function Nn(){return Jt}function ki(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(Di),t.drafts_=null}function _r(t){t===Jt&&(Jt=t.parent_)}function Ln(t){return Jt=ki(Jt,t)}function Di(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,w)=>Bn(t,o,a,p,w,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,w=Ae(t,a,p);if(Hn(n,o,w),wt(w))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 ji(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 Fi(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=Wn(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(Pi(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 Fi(t,r,n){var a;const o=Wn(r,n);return o?"value"in o?o.value:(a=o.get)==null?void 0:a.call(t.draft_):void 0}function Wn(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 Ri=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(w=u,..._){return f.produce(w,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,w=>r(w,...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=zi(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):ji(t,r);return(r?r.scope_:Nn()).drafts_.push(n),n}function zi(t){return wt(t)||H(10,t),$n(t)}function $n(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,$n(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,v,y){switch(l.type_){case 0:case 2:return f(l,g,v,y);case 1:return u(l,g,v,y);case 3:return p(l,g,v,y)}}function u(l,g,v,y){let{base_:T,assigned_:S}=l,m=l.copy_;m.length<T.length&&([T,m]=[m,T],[v,y]=[y,v]);for(let h=0;h<T.length;h++)if(S[h]&&m[h]!==T[h]){const A=g.concat([h]);v.push({op:r,path:A,value:E(m[h])}),y.push({op:r,path:A,value:E(T[h])})}for(let h=T.length;h<m.length;h++){const A=g.concat([h]);v.push({op:n,path:A,value:E(m[h])})}for(let h=m.length-1;T.length<=h;--h){const A=g.concat([h]);y.push({op:o,path:A})}}function f(l,g,v,y){const{base_:T,copy_:S}=l;Vt(l.assigned_,(m,h)=>{const A=pr(T,m),G=pr(S,m),R=h?Yt(T,m)?r:n:o;if(A===G&&R===r)return;const F=g.concat(m);v.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,v,y){let{base_:T,copy_:S}=l,m=0;T.forEach(h=>{if(!S.has(h)){const A=g.concat([m]);v.push({op:o,path:A,value:h}),y.unshift({op:n,path:A,value:h})}m++}),m=0,S.forEach(h=>{if(!T.has(h)){const A=g.concat([m]);v.push({op:n,path:A,value:h}),y.unshift({op:o,path:A,value:h})}m++})}function w(l,g,v,y){v.push({op:r,path:[],value:g===lr?void 0:g}),y.push({op:r,path:[],value:l})}function _(l,g){return g.forEach(v=>{const{path:y,op:T}=v;let S=l;for(let G=0;G<y.length-1;G++){const R=Tt(S);let F=y[G];typeof F!="string"&&typeof F!="number"&&(F=""+F),(R===0||R===1)&&(F==="__proto__"||F==="constructor")&&H(19),typeof S=="function"&&F==="prototype"&&H(19),S=pr(S,F),typeof S!="object"&&H(18,y.join("/"))}const m=Tt(S),h=d(v.value),A=y[y.length-1];switch(T){case r:switch(m){case 2:return S.set(A,h);case 3:H(16);default:return S[A]=h}case n:switch(m){case 1:return A==="-"?S.push(h):S.splice(A,0,h);case 2:return S.set(A,h);case 3:return S.add(h);default:return S[A]=h}case o:switch(m){case 1:return S.splice(A,1);case 2:return S.delete(A);case 3:return S.delete(v.value);default:return delete S[A]}default:H(17,T)}}),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(([v,y])=>[v,d(y)]));if(qt(l))return new Set(Array.from(l).map(d));const g=Object.create(It(l));for(const v in l)g[v]=d(l[v]);return Yt(l,Kt)&&(g[Kt]=l[Kt]),g}function E(l){return wt(l)?d(l):l}Ci("Patches",{applyPatches_:_,generatePatches_:a,generateReplacementPatches_:w})}var Z=new Ri,Hi=Z.produce;Z.produceWithPatches.bind(Z),Z.setAutoFreeze.bind(Z),Z.setUseStrictShallowCopy.bind(Z);var Ni=Z.applyPatches.bind(Z);Z.createDraft.bind(Z),Z.finishDraft.bind(Z);var Ui=1/0,Li=9007199254740991,Gi="[object Arguments]",Bi="[object Function]",Wi="[object GeneratorFunction]",$i="[object Symbol]",Ki=typeof Q=="object"&&Q&&Q.Object===Object&&Q,Vi=typeof self=="object"&&self&&self.Object===Object&&self,Yi=Ki||Vi||Function("return this")();function Xi(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 qi(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 Ji(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,Zi=wr.hasOwnProperty,Tr=wr.toString,Vn=Yi.Symbol,Qi=wr.propertyIsEnumerable,Yn=Vn?Vn.isConcatSpreadable:void 0,Xn=Math.max;function to(t,r,n,o,a){var u=-1,f=t.length;for(n||(n=io),a||(a=[]);++u<f;){var p=t[u];n(p)?Ji(a,p):a[a.length]=p}return a}function eo(t,r){return t=Object(t),ro(t,r,function(n,o){return o in t})}function ro(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 no(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,Xi(t,this,f)}}function io(t){return ao(t)||so(t)||!!(Yn&&t&&t[Yn])}function oo(t){if(typeof t=="string"||ho(t))return t;var r=t+"";return r=="0"&&1/t==-Ui?"-0":r}function so(t){return uo(t)&&Zi.call(t,"callee")&&(!Qi.call(t,"callee")||Tr.call(t)==Gi)}var ao=Array.isArray;function co(t){return t!=null&&lo(t.length)&&!fo(t)}function uo(t){return qn(t)&&co(t)}function fo(t){var r=po(t)?Tr.call(t):"";return r==Bi||r==Wi}function lo(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Li}function po(t){var r=typeof t;return!!t&&(r=="object"||r=="function")}function qn(t){return!!t&&typeof t=="object"}function ho(t){return typeof t=="symbol"||qn(t)&&Tr.call(t)==$i}var yo=no(function(t,r){return t==null?{}:eo(t,qi(to(r),oo))}),bo=yo;const Jn=cr(bo),_o={tracks:[],trackItemIds:[],trackItemsMap:{},transitionIds:[],transitionsMap:{},scale:{unit:1,zoom:1,segments:1},duration:0,activeIds:[],trackItemDetailsMap:{}},Zn=["tracks","trackItemsMap","trackItemDetailsMap","transitionIds","transitionsMap","trackItemIds"];class go{constructor(r){jt(this,"stateSubject");jt(this,"stateHistorySubject");jt(this,"prevState");jt(this,"undos",[]);jt(this,"redos",[]);jt(this,"listener");const n=r||_o;this.stateSubject=new kn(n),this.stateHistorySubject=new kn({handleRedo:!1,handleUndo:!1}),this.prevState=n,this.initListeners()}initListeners(){Ei(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:w,trackItemsMap:_}=this.getState(),d=dt({trackItemDetailsMap:a,trackItemIds:u,tracks:f,transitionIds:p,transitionsMap:w,trackItemsMap:_}),E=[],l=[],g=[],v=[],y=[],T=[];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")?v.push(j):M.path.includes("tracks")?E.push(j):M.path.includes("trackItemDetailsMap")&&T.push(j)});const S=this.applyPatch(d.tracks,E),m=this.applyPatch(d.transitionIds,l),h=this.applyPatch(d.trackItemIds,g),A=this.applyPatch(d.transitionsMap,v),G=this.applyPatch(d.trackItemsMap,y),R=this.applyPatch(d.trackItemDetailsMap,T),F=dt({tracks:S,transitionIds:m,trackItemIds:h,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)=>Hi(o,u=>{Ni(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:w,trackItemsMap:_}=this.getState(),d=dt({trackItemDetailsMap:a,trackItemIds:u,tracks:f,transitionIds:p,transitionsMap:w,trackItemsMap:_}),E=[],l=[],g=[],v=[],y=[],T=[];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")?v.push(j):M.path.includes("trackItemDetailsMap")?T.push(j):E.push(j)});const S=this.applyPatch(d.tracks,E),m=this.applyPatch(d.transitionIds,l),h=this.applyPatch(d.trackItemIds,g),A=this.applyPatch(d.transitionsMap,v),G=this.applyPatch(d.trackItemsMap,y),R=this.applyPatch(d.trackItemDetailsMap,T),F=dt({tracks:S,transitionIds:m,trackItemIds:h,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 go});
|
package/dist/state.d.ts
ADDED
@@ -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,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;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@designcombo/state",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.5",
|
4
4
|
"private": false,
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -16,19 +16,30 @@
|
|
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
|
-
"
|
27
|
+
"@designcombo/events": "0.1.5",
|
28
|
+
"@designcombo/types": "0.1.5",
|
24
29
|
"@designcombo/typescript-config": "0.0.0"
|
25
30
|
},
|
26
31
|
"dependencies": {
|
27
|
-
"
|
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",
|
37
|
+
"rxjs": "^7.8.1",
|
38
|
+
"nanoid": "^5.0.7"
|
28
39
|
},
|
29
40
|
"peerDependencies": {
|
30
|
-
"@designcombo/events": "0.1.
|
31
|
-
"@designcombo/types": "0.1.
|
41
|
+
"@designcombo/events": "0.1.5",
|
42
|
+
"@designcombo/types": "0.1.5"
|
32
43
|
},
|
33
44
|
"scripts": {
|
34
45
|
"dev": "vite",
|