@imgly/plugin-vectorizer-web 1.86.0-nightly.20261101 → 1.87.0-nightly.20261103
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.d.ts +139 -5
- package/dist/index.mjs +12 -29
- package/dist/index.mjs.map +1 -7
- package/package.json +6 -7
- package/dist/.tsbuildinfo +0 -1
- package/dist/addAsVectorGroup.d.ts +0 -4
- package/dist/createVectorPathBlocks.d.ts +0 -4
- package/dist/plugin.d.ts +0 -22
- package/dist/processVectorization.d.ts +0 -7
- package/dist/types.d.ts +0 -16
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,141 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Config } from "@imgly/vectorizer";
|
|
2
|
+
import "@cesdk/cesdk-js";
|
|
3
|
+
/**
|
|
4
|
+
* A wrapper around a plain canvas
|
|
5
|
+
*
|
|
6
|
+
* The idea is to shield the user from the weird semantics of changing width
|
|
7
|
+
* and height of a canvas by making this a opaque block element instead and
|
|
8
|
+
* managing the internal render resolution of the canvas dynamically
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
interface HTMLCreativeEngineCanvasElement extends HTMLElement {
|
|
13
|
+
/** @internal */
|
|
14
|
+
getInternalCanvas(): HTMLCanvasElement;
|
|
15
|
+
/**
|
|
16
|
+
* Removes the internal canvas
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
dispose(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Clear the canvas
|
|
22
|
+
*
|
|
23
|
+
* This is useful when mounting the canvas into a new position in the DOM.
|
|
24
|
+
* If the canvas is not cleared, it will appear in the new DOM position, with
|
|
25
|
+
* its contents stretched to the new size. It will re-render correctly during
|
|
26
|
+
* the next animation frame, but for a brief moment the canvas contents can
|
|
27
|
+
* flash distorted.
|
|
28
|
+
*
|
|
29
|
+
* Call `clear()` before mounting into the DOM to avoid this. This will cause
|
|
30
|
+
* the canvas to be cleared until rendering the next frame.
|
|
31
|
+
*/
|
|
32
|
+
clear(): void;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'cesdk-canvas': HTMLCreativeEngineCanvasElement;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
declare global {
|
|
40
|
+
interface Window {
|
|
41
|
+
Cypress?: unknown;
|
|
42
|
+
IS_PLAYWRIGHT?: boolean;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
declare global {
|
|
46
|
+
/**
|
|
47
|
+
* Used to communicate the status to C++ in emscripten/CodecBackendWebCodecs.cpp
|
|
48
|
+
* from the exportVideo task
|
|
49
|
+
*/
|
|
50
|
+
var ubq_browserTabHidden: boolean;
|
|
51
|
+
}
|
|
52
|
+
declare global {
|
|
53
|
+
/**
|
|
54
|
+
* Used to communicate the status to C++ in emscripten/CodecBackendWebCodecs.cpp
|
|
55
|
+
* from the exportVideo task
|
|
56
|
+
*/
|
|
57
|
+
var ubq_browserTabHidden: boolean;
|
|
58
|
+
}
|
|
59
|
+
declare global {
|
|
60
|
+
/**
|
|
61
|
+
* Used to communicate the status to C++ in emscripten/CodecBackendWebCodecs.cpp
|
|
62
|
+
* from the exportVideo task
|
|
63
|
+
*/
|
|
64
|
+
var ubq_browserTabHidden: boolean;
|
|
65
|
+
}
|
|
66
|
+
declare global {
|
|
67
|
+
/**
|
|
68
|
+
* Used to communicate the status to C++ in emscripten/CodecBackendWebCodecs.cpp
|
|
69
|
+
* from the exportAudio task
|
|
70
|
+
*/
|
|
71
|
+
var ubq_browserTabHidden: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Dispatched on the engine canvas when the text input has been blurred.
|
|
75
|
+
* Call `preventDefault()` to disallow this and refocus the engine text input.
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
interface BlurEvent extends CustomEvent<EventTarget | null> {
|
|
79
|
+
readonly type: 'cesdk-blur';
|
|
80
|
+
/** Contains the element that has received focus during the blur, or null */
|
|
81
|
+
readonly detail: EventTarget | null;
|
|
82
|
+
/** Force focus back to the engine input */
|
|
83
|
+
preventDefault(): void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Dispatched on the engine canvas right before the engine will refocus its text
|
|
87
|
+
* input after a blur. Call `preventDefault()` to prevent the refocusing.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
interface RefocusEvent extends CustomEvent<EventTarget | null> {
|
|
91
|
+
readonly type: 'cesdk-refocus';
|
|
92
|
+
/** Contains the element that has received focus during the blur, or null */
|
|
93
|
+
readonly detail: EventTarget | null;
|
|
94
|
+
/** Prevent refocusing the engine input */
|
|
95
|
+
preventDefault(): void;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Dispatched on the engine canvas when the text input has been blurred.
|
|
99
|
+
* Call `preventDefault()` to disallow this and refocus the engine text input.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
interface CursorEvent extends CustomEvent<string> {
|
|
103
|
+
readonly type: 'cesdk-cursor';
|
|
104
|
+
/** Contains the cursor style */
|
|
105
|
+
readonly detail: string;
|
|
106
|
+
/** If default is prevented, the Creative Engine won't apply the cursor style to itself. */
|
|
107
|
+
preventDefault(): void;
|
|
108
|
+
}
|
|
109
|
+
declare global {
|
|
110
|
+
interface GlobalEventHandlersEventMap {
|
|
111
|
+
'cesdk-blur': BlurEvent;
|
|
112
|
+
'cesdk-refocus': RefocusEvent;
|
|
113
|
+
'cesdk-cursor': CursorEvent;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
type Location = 'inspectorBar' | 'navigationBar' | 'canvasBarTop' | 'canvasBarBottom' | 'canvasMenu' | 'dock';
|
|
117
|
+
interface UserInterfaceConfiguration {
|
|
118
|
+
locations?: Location | Location[];
|
|
119
|
+
}
|
|
120
|
+
interface PluginConfiguration {
|
|
121
|
+
ui?: UserInterfaceConfiguration;
|
|
122
|
+
/**
|
|
123
|
+
* Configuration for the vectorizer.
|
|
124
|
+
*/
|
|
125
|
+
vectorizer?: Config;
|
|
126
|
+
/**
|
|
127
|
+
* The maximal number of paths for which we create a group instead of
|
|
128
|
+
* inserting a SVG file
|
|
129
|
+
*/
|
|
130
|
+
groupingThreshold?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Timeout in milliseconds for the vectorization process.
|
|
133
|
+
*/
|
|
134
|
+
timeout?: number;
|
|
135
|
+
}
|
|
2
136
|
declare const Plugin: (pluginConfiguration?: PluginConfiguration) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
137
|
+
initialize: (context: import("@cesdk/cesdk-js").EditorPluginContext) => void | Promise<void>;
|
|
138
|
+
name: string;
|
|
139
|
+
version: string;
|
|
6
140
|
};
|
|
7
|
-
export default
|
|
141
|
+
export { Plugin as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var wt=class{constructor(e,t){this.engine=e,this.key=t}hasData(e){return this.engine.block.isValid(e)&&this.engine.block.hasMetadata(e,this.key)}get(e){if(this.hasData(e))return JSON.parse(this.engine.block.getMetadata(e,this.key))}set(e,t){this.engine.block.setMetadata(e,this.key,JSON.stringify(t))}clear(e){this.engine.block.hasMetadata(e,this.key)&&this.engine.block.removeMetadata(e,this.key)}},It=wt,Ct=typeof global=="object"&&global&&global.Object===Object&&global,De=Ct,At=typeof self=="object"&&self&&self.Object===Object&&self,kt=De||At||Function("return this")(),k=kt,jt=k.Symbol,R=jt,Me=Object.prototype,_t=Me.hasOwnProperty,Et=Me.toString,H=R?R.toStringTag:void 0;function Pt(e){var t=_t.call(e,H),r=e[H];try{e[H]=void 0;var a=!0}catch{}var o=Et.call(e);return a&&(t?e[H]=r:delete e[H]),o}var Ot=Pt,Ft=Object.prototype,Vt=Ft.toString;function Rt(e){return Vt.call(e)}var Bt=Rt,Lt="[object Null]",Nt="[object Undefined]",be=R?R.toStringTag:void 0;function Dt(e){return e==null?e===void 0?Nt:Lt:be&&be in Object(e)?Ot(e):Bt(e)}var G=Dt;function Mt(e){return e!=null&&typeof e=="object"}var U=Mt,Tt=Array.isArray,X=Tt;function Ht(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Te=Ht,zt="[object AsyncFunction]",Ut="[object Function]",$t="[object GeneratorFunction]",Wt="[object Proxy]";function Gt(e){if(!Te(e))return!1;var t=G(e);return t==Ut||t==$t||t==zt||t==Wt}var He=Gt,Zt=k["__core-js_shared__"],se=Zt,xe=function(){var e=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function qt(e){return!!xe&&xe in e}var Kt=qt,Xt=Function.prototype,Yt=Xt.toString;function Jt(e){if(e!=null){try{return Yt.call(e)}catch{}try{return e+""}catch{}}return""}var P=Jt,Qt=/[\\^$.*+?()[\]{}|]/g,er=/^\[object .+?Constructor\]$/,tr=Function.prototype,rr=Object.prototype,ar=tr.toString,or=rr.hasOwnProperty,sr=RegExp("^"+ar.call(or).replace(Qt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ir(e){if(!Te(e)||Kt(e))return!1;var t=He(e)?sr:er;return t.test(P(e))}var nr=ir;function lr(e,t){return e?.[t]}var fr=lr;function ur(e,t){var r=fr(e,t);return nr(r)?r:void 0}var B=ur,cr=B(k,"WeakMap"),fe=cr,dr=9007199254740991,pr=/^(?:0|[1-9]\d*)$/;function mr(e,t){var r=typeof e;return t=t??dr,!!t&&(r=="number"||r!="symbol"&&pr.test(e))&&e>-1&&e%1==0&&e<t}var gr=mr;function hr(e,t){return e===t||e!==e&&t!==t}var ze=hr,br=9007199254740991;function xr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=br}var Ue=xr;function vr(e){return e!=null&&Ue(e.length)&&!He(e)}var yr=vr,Sr=Object.prototype;function wr(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||Sr;return e===r}var Ir=wr;function Cr(e,t){for(var r=-1,a=Array(e);++r<e;)a[r]=t(r);return a}var Ar=Cr,kr="[object Arguments]";function jr(e){return U(e)&&G(e)==kr}var ve=jr,$e=Object.prototype,_r=$e.hasOwnProperty,Er=$e.propertyIsEnumerable,Pr=ve(function(){return arguments}())?ve:function(e){return U(e)&&_r.call(e,"callee")&&!Er.call(e,"callee")},Or=Pr;function Fr(){return!1}var Vr=Fr,We=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ye=We&&typeof module=="object"&&module&&!module.nodeType&&module,Rr=ye&&ye.exports===We,Se=Rr?k.Buffer:void 0,Br=Se?Se.isBuffer:void 0,Lr=Br||Vr,ue=Lr,Nr="[object Arguments]",Dr="[object Array]",Mr="[object Boolean]",Tr="[object Date]",Hr="[object Error]",zr="[object Function]",Ur="[object Map]",$r="[object Number]",Wr="[object Object]",Gr="[object RegExp]",Zr="[object Set]",qr="[object String]",Kr="[object WeakMap]",Xr="[object ArrayBuffer]",Yr="[object DataView]",Jr="[object Float32Array]",Qr="[object Float64Array]",ea="[object Int8Array]",ta="[object Int16Array]",ra="[object Int32Array]",aa="[object Uint8Array]",oa="[object Uint8ClampedArray]",sa="[object Uint16Array]",ia="[object Uint32Array]",m={};m[Jr]=m[Qr]=m[ea]=m[ta]=m[ra]=m[aa]=m[oa]=m[sa]=m[ia]=!0;m[Nr]=m[Dr]=m[Xr]=m[Mr]=m[Yr]=m[Tr]=m[Hr]=m[zr]=m[Ur]=m[$r]=m[Wr]=m[Gr]=m[Zr]=m[qr]=m[Kr]=!1;function na(e){return U(e)&&Ue(e.length)&&!!m[G(e)]}var la=na;function fa(e){return function(t){return e(t)}}var ua=fa,Ge=typeof exports=="object"&&exports&&!exports.nodeType&&exports,z=Ge&&typeof module=="object"&&module&&!module.nodeType&&module,ca=z&&z.exports===Ge,ie=ca&&De.process,da=function(){try{var e=z&&z.require&&z.require("util").types;return e||ie&&ie.binding&&ie.binding("util")}catch{}}(),we=da,Ie=we&&we.isTypedArray,pa=Ie?ua(Ie):la,Ze=pa,ma=Object.prototype,ga=ma.hasOwnProperty;function ha(e,t){var r=X(e),a=!r&&Or(e),o=!r&&!a&&ue(e),s=!r&&!a&&!o&&Ze(e),i=r||a||o||s,n=i?Ar(e.length,String):[],u=n.length;for(var l in e)(t||ga.call(e,l))&&!(i&&(l=="length"||o&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||gr(l,u)))&&n.push(l);return n}var ba=ha;function xa(e,t){return function(r){return e(t(r))}}var va=xa,ya=va(Object.keys,Object),Sa=ya,wa=Object.prototype,Ia=wa.hasOwnProperty;function Ca(e){if(!Ir(e))return Sa(e);var t=[];for(var r in Object(e))Ia.call(e,r)&&r!="constructor"&&t.push(r);return t}var Aa=Ca;function ka(e){return yr(e)?ba(e):Aa(e)}var ja=ka,_a=B(Object,"create"),$=_a;function Ea(){this.__data__=$?$(null):{},this.size=0}var Pa=Ea;function Oa(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Fa=Oa,Va="__lodash_hash_undefined__",Ra=Object.prototype,Ba=Ra.hasOwnProperty;function La(e){var t=this.__data__;if($){var r=t[e];return r===Va?void 0:r}return Ba.call(t,e)?t[e]:void 0}var Na=La,Da=Object.prototype,Ma=Da.hasOwnProperty;function Ta(e){var t=this.__data__;return $?t[e]!==void 0:Ma.call(t,e)}var Ha=Ta,za="__lodash_hash_undefined__";function Ua(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=$&&t===void 0?za:t,this}var $a=Ua;function L(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}L.prototype.clear=Pa;L.prototype.delete=Fa;L.prototype.get=Na;L.prototype.has=Ha;L.prototype.set=$a;var Ce=L;function Wa(){this.__data__=[],this.size=0}var Ga=Wa;function Za(e,t){for(var r=e.length;r--;)if(ze(e[r][0],t))return r;return-1}var J=Za,qa=Array.prototype,Ka=qa.splice;function Xa(e){var t=this.__data__,r=J(t,e);if(r<0)return!1;var a=t.length-1;return r==a?t.pop():Ka.call(t,r,1),--this.size,!0}var Ya=Xa;function Ja(e){var t=this.__data__,r=J(t,e);return r<0?void 0:t[r][1]}var Qa=Ja;function eo(e){return J(this.__data__,e)>-1}var to=eo;function ro(e,t){var r=this.__data__,a=J(r,e);return a<0?(++this.size,r.push([e,t])):r[a][1]=t,this}var ao=ro;function N(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}N.prototype.clear=Ga;N.prototype.delete=Ya;N.prototype.get=Qa;N.prototype.has=to;N.prototype.set=ao;var Q=N,oo=B(k,"Map"),W=oo;function so(){this.size=0,this.__data__={hash:new Ce,map:new(W||Q),string:new Ce}}var io=so;function no(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var lo=no;function fo(e,t){var r=e.__data__;return lo(t)?r[typeof t=="string"?"string":"hash"]:r.map}var ee=fo;function uo(e){var t=ee(this,e).delete(e);return this.size-=t?1:0,t}var co=uo;function po(e){return ee(this,e).get(e)}var mo=po;function go(e){return ee(this,e).has(e)}var ho=go;function bo(e,t){var r=ee(this,e),a=r.size;return r.set(e,t),this.size+=r.size==a?0:1,this}var xo=bo;function D(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}D.prototype.clear=io;D.prototype.delete=co;D.prototype.get=mo;D.prototype.has=ho;D.prototype.set=xo;var qe=D;function vo(e,t){for(var r=-1,a=t.length,o=e.length;++r<a;)e[o+r]=t[r];return e}var yo=vo;function So(){this.__data__=new Q,this.size=0}var wo=So;function Io(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Co=Io;function Ao(e){return this.__data__.get(e)}var ko=Ao;function jo(e){return this.__data__.has(e)}var _o=jo,Eo=200;function Po(e,t){var r=this.__data__;if(r instanceof Q){var a=r.__data__;if(!W||a.length<Eo-1)return a.push([e,t]),this.size=++r.size,this;r=this.__data__=new qe(a)}return r.set(e,t),this.size=r.size,this}var Oo=Po;function M(e){var t=this.__data__=new Q(e);this.size=t.size}M.prototype.clear=wo;M.prototype.delete=Co;M.prototype.get=ko;M.prototype.has=_o;M.prototype.set=Oo;var ne=M;function Fo(e,t){for(var r=-1,a=e==null?0:e.length,o=0,s=[];++r<a;){var i=e[r];t(i,r,e)&&(s[o++]=i)}return s}var Vo=Fo;function Ro(){return[]}var Bo=Ro,Lo=Object.prototype,No=Lo.propertyIsEnumerable,Ae=Object.getOwnPropertySymbols,Do=Ae?function(e){return e==null?[]:(e=Object(e),Vo(Ae(e),function(t){return No.call(e,t)}))}:Bo,Mo=Do;function To(e,t,r){var a=t(e);return X(e)?a:yo(a,r(e))}var Ho=To;function zo(e){return Ho(e,ja,Mo)}var ke=zo,Uo=B(k,"DataView"),ce=Uo,$o=B(k,"Promise"),de=$o,Wo=B(k,"Set"),pe=Wo,je="[object Map]",Go="[object Object]",_e="[object Promise]",Ee="[object Set]",Pe="[object WeakMap]",Oe="[object DataView]",Zo=P(ce),qo=P(W),Ko=P(de),Xo=P(pe),Yo=P(fe),E=G;(ce&&E(new ce(new ArrayBuffer(1)))!=Oe||W&&E(new W)!=je||de&&E(de.resolve())!=_e||pe&&E(new pe)!=Ee||fe&&E(new fe)!=Pe)&&(E=function(e){var t=G(e),r=t==Go?e.constructor:void 0,a=r?P(r):"";if(a)switch(a){case Zo:return Oe;case qo:return je;case Ko:return _e;case Xo:return Ee;case Yo:return Pe}return t});var Fe=E,Jo=k.Uint8Array,Ve=Jo,Qo="__lodash_hash_undefined__";function es(e){return this.__data__.set(e,Qo),this}var ts=es;function rs(e){return this.__data__.has(e)}var as=rs;function Y(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new qe;++t<r;)this.add(e[t])}Y.prototype.add=Y.prototype.push=ts;Y.prototype.has=as;var os=Y;function ss(e,t){for(var r=-1,a=e==null?0:e.length;++r<a;)if(t(e[r],r,e))return!0;return!1}var is=ss;function ns(e,t){return e.has(t)}var ls=ns,fs=1,us=2;function cs(e,t,r,a,o,s){var i=r&fs,n=e.length,u=t.length;if(n!=u&&!(i&&u>n))return!1;var l=s.get(e),f=s.get(t);if(l&&f)return l==t&&f==e;var c=-1,d=!0,b=r&us?new os:void 0;for(s.set(e,t),s.set(t,e);++c<n;){var g=e[c],h=t[c];if(a)var x=i?a(h,g,c,t,e,s):a(g,h,c,e,t,s);if(x!==void 0){if(x)continue;d=!1;break}if(b){if(!is(t,function(v,I){if(!ls(b,I)&&(g===v||o(g,v,r,a,s)))return b.push(I)})){d=!1;break}}else if(!(g===h||o(g,h,r,a,s))){d=!1;break}}return s.delete(e),s.delete(t),d}var Ke=cs;function ds(e){var t=-1,r=Array(e.size);return e.forEach(function(a,o){r[++t]=[o,a]}),r}var ps=ds;function ms(e){var t=-1,r=Array(e.size);return e.forEach(function(a){r[++t]=a}),r}var gs=ms,hs=1,bs=2,xs="[object Boolean]",vs="[object Date]",ys="[object Error]",Ss="[object Map]",ws="[object Number]",Is="[object RegExp]",Cs="[object Set]",As="[object String]",ks="[object Symbol]",js="[object ArrayBuffer]",_s="[object DataView]",Re=R?R.prototype:void 0,le=Re?Re.valueOf:void 0;function Es(e,t,r,a,o,s,i){switch(r){case _s:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case js:return!(e.byteLength!=t.byteLength||!s(new Ve(e),new Ve(t)));case xs:case vs:case ws:return ze(+e,+t);case ys:return e.name==t.name&&e.message==t.message;case Is:case As:return e==t+"";case Ss:var n=ps;case Cs:var u=a&hs;if(n||(n=gs),e.size!=t.size&&!u)return!1;var l=i.get(e);if(l)return l==t;a|=bs,i.set(e,t);var f=Ke(n(e),n(t),a,o,s,i);return i.delete(e),f;case ks:if(le)return le.call(e)==le.call(t)}return!1}var Ps=Es,Os=1,Fs=Object.prototype,Vs=Fs.hasOwnProperty;function Rs(e,t,r,a,o,s){var i=r&Os,n=ke(e),u=n.length,l=ke(t),f=l.length;if(u!=f&&!i)return!1;for(var c=u;c--;){var d=n[c];if(!(i?d in t:Vs.call(t,d)))return!1}var b=s.get(e),g=s.get(t);if(b&&g)return b==t&&g==e;var h=!0;s.set(e,t),s.set(t,e);for(var x=i;++c<u;){d=n[c];var v=e[d],I=t[d];if(a)var j=i?a(I,v,d,t,e,s):a(v,I,d,e,t,s);if(!(j===void 0?v===I||o(v,I,r,a,s):j)){h=!1;break}x||(x=d=="constructor")}if(h&&!x){var A=e.constructor,C=t.constructor;A!=C&&"constructor"in e&&"constructor"in t&&!(typeof A=="function"&&A instanceof A&&typeof C=="function"&&C instanceof C)&&(h=!1)}return s.delete(e),s.delete(t),h}var Bs=Rs,Ls=1,Be="[object Arguments]",Le="[object Array]",K="[object Object]",Ns=Object.prototype,Ne=Ns.hasOwnProperty;function Ds(e,t,r,a,o,s){var i=X(e),n=X(t),u=i?Le:Fe(e),l=n?Le:Fe(t);u=u==Be?K:u,l=l==Be?K:l;var f=u==K,c=l==K,d=u==l;if(d&&ue(e)){if(!ue(t))return!1;i=!0,f=!1}if(d&&!f)return s||(s=new ne),i||Ze(e)?Ke(e,t,r,a,o,s):Ps(e,t,u,r,a,o,s);if(!(r&Ls)){var b=f&&Ne.call(e,"__wrapped__"),g=c&&Ne.call(t,"__wrapped__");if(b||g){var h=b?e.value():e,x=g?t.value():t;return s||(s=new ne),o(h,x,r,a,s)}}return d?(s||(s=new ne),Bs(e,t,r,a,o,s)):!1}var Ms=Ds;function Xe(e,t,r,a,o){return e===t?!0:e==null||t==null||!U(e)&&!U(t)?e!==e&&t!==t:Ms(e,t,r,a,Xe,o)}var Ts=Xe;function Hs(e,t){return Ts(e,t)}var zs=Hs,Us=class extends It{get(e){return super.get(e)??{status:"IDLE"}}isDuplicate(e){if(!this.engine.block.isValid(e))return!1;let t=this.get(e);if(t.status==="IDLE"||t.status==="PENDING"||t.status==="ERROR"||!this.engine.block.hasFill(e))return!1;let r=this.engine.block.getFill(e);return!(t.blockId===e||t.fillId===r)}fixDuplicate(e){let t=this.engine.block.getFill(e),r=this.get(e);r.status==="IDLE"||r.status==="PENDING"||r.status==="ERROR"||(this.set(e,{...r,blockId:e,fillId:t}),r.status==="PROCESSING"&&(this.recoverInitialImageData(e),this.clear(e)))}isConsistent(e){if(!this.engine.block.isValid(e))return!1;let t=this.get(e);if(t.status==="IDLE"||t.status==="PENDING")return!0;if(!this.engine.block.hasFill(e))return!1;let r=this.engine.block.getFill(e);if(r==null||e!==t.blockId||r!==t.fillId)return!1;let a=this.engine.block.getSourceSet(r,"fill/image/sourceSet"),o=this.engine.block.getString(r,"fill/image/imageFileURI");if(a.length===0&&!o&&t.status==="PROCESSING")return!0;if(a?.length>0){let s=t.initialSourceSet;if(t.status!=="PROCESSED"&&!zs(a,s))return!1}else if(t.status!=="PROCESSED"&&o!==t.initialImageFileURI)return!1;return!0}recoverInitialImageData(e){if(!this.engine.block.hasFill(e))return;let t=this.get(e);if(t.status==="PENDING"||t.status==="IDLE")return;let r=t.initialSourceSet,a=t.initialImageFileURI,o=t.initialPreviewFileURI,s=this.getValidFill(e,t);s!=null&&(a&&this.engine.block.setString(s,"fill/image/imageFileURI",a),o&&this.engine.block.setString(s,"fill/image/previewFileURI",o),r.length>0&&this.engine.block.setSourceSet(s,"fill/image/sourceSet",r))}getValidFill(e,t){if(!this.engine.block.isValid(e)||!this.engine.block.hasFill(e)||e!==t.blockId)return;let r=this.engine.block.getFill(e);if(r===t.fillId)return r}},Ye=Us;async function $s(e,t,r,a,o){let s=t.engine.block;if(!s.hasFill(e))throw new Error("Block does not support fill");let i=s.getFill(e),n=s.getSourceSet(i,"fill/image/sourceSet"),u=s.getString(i,"fill/image/imageFileURI"),l=s.getString(i,"fill/image/previewFileURI");try{t.engine.block.setState(i,{type:"Pending",progress:0});let f={...r.get(e),version:o,initialSourceSet:n,initialImageFileURI:u,initialPreviewFileURI:l,blockId:e,fillId:i,status:"PROCESSING"};r.set(e,f);let c=await a.processFill(f);if(r.get(e).status!=="PROCESSING"||!r.isConsistent(e)||r.get(e).status!=="PROCESSING"||!r.isConsistent(e)||c==null)return;let d={version:o,initialSourceSet:n,initialImageFileURI:u,initialPreviewFileURI:l,blockId:e,fillId:i,status:"PROCESSED"},b=a.commitProcessing(c,d);(b==null||b===e)&&r.set(e,d),t.engine.editor.addUndoStep()}catch(f){if(t.engine.block.isValid(e)&&(r.set(e,{version:o,initialSourceSet:n,initialImageFileURI:u,initialPreviewFileURI:l,blockId:e,fillId:i,status:"ERROR"}),r.recoverInitialImageData(e)),f!=null&&typeof f=="object"&&"message"in f&&typeof f.message=="string"){let c=f.message==="signal timed out"?"Processing canceled due to timeout":f.message;t.ui.showNotification({type:"error",message:c})}console.log(f)}finally{t.engine.block.isValid(i)&&t.engine.block.setState(i,{type:"Ready"})}}var Je=$s;function Qe(e){return`${e}.fillProcessing.feature`}function Ws(e){return[`${e}.canvasMenu`,`${e}.fillProcessing.canvasMenu`]}function Gs(e){return[`${e}.dock`,`${e}.fillProcessing.dock`]}function Zs(e){return[`${e}.inspectorBar`,`${e}.fillProcessing.inspectorBar`]}function qs(e){return[`${e}.navigationBar`,`${e}.fillProcessing.navigationBar`]}function Ks(e){return[`${e}.canvasBar`,`${e}.fillProcessing.canvasBar`]}function Xs(e){return`plugin.${e}.fillProcessing.canvasMenu.button.label`}function Ys(e){return`plugin.${e}.fillProcessing.dock.button.label`}function Js(e){return`plugin.${e}.fillProcessing.inspectorBar.button.label`}function Qs(e){return`plugin.${e}.fillProcessing.navigationBar.button.label`}function ei(e){return`plugin.${e}.fillProcessing.canvasBar.button.label`}function et(e,{pluginId:t,process:r}){let a=Qe(t),o=new Ye(e.engine,t);return ti(e,o,a),e.engine.event.subscribe([],async s=>{s.forEach(i=>{let n=i.block;if(!(!e.engine.block.isValid(n)||!o.hasData(n))){if(i.type==="Created")o.isDuplicate(n)&&o.fixDuplicate(n);else if(i.type==="Updated")switch(o.get(n).status){case"PENDING":{e.feature.isEnabled(a,{engine:e.engine})&&e.engine.block.isAllowedByScope(n,"fill/change")&&e.engine.block.getState(n).type!=="Pending"&&r(n,o);break}case"PROCESSING":case"PROCESSED":{o.isConsistent(n)||o.clear(n);break}default:}}})}),{featureId:a}}function ti(e,t,r){e.feature.enable(r,({engine:a})=>{let o=a.block.findAllSelected();if(o.length!==1)return!1;let[s]=o;if(!e.engine.block.isVisible(s))return!1;if(e.engine.block.hasFill(s)){if(e.engine.block.getKind(s)==="sticker")return!1;let i=e.engine.block.getFill(s);if(e.engine.block.getType(i)!=="//ly.img.ubq/fill/image")return!1;let n=a.block.getString(i,"fill/image/imageFileURI");return a.block.getSourceSet(i,"fill/image/sourceSet").length>0||n!==""?!0:t.get(s).status==="PROCESSING"}return!1})}function tt(e,t){let{pluginId:r,locations:a}=t,o=new Ye(e.engine,r),s=Xs(r),i=Ws(r),n=i[0],u=Ys(r),l=Gs(r),f=l[0],c=Js(r),d=Zs(r),b=d[0],g=Qs(r),h=qs(r),x=h[0],v=ei(r),I=Ks(r),j=I[0],A=Qe(r);return a?.includes("inspectorBar")&&e.ui.setInspectorBarOrder([b,...e.ui.getInspectorBarOrder()]),a?.includes("navigationBar")&&e.ui.setNavigationBarOrder([x,...e.ui.getNavigationBarOrder()]),a?.includes("canvasBarTop")&&e.ui.setCanvasBarOrder([j,...e.ui.getCanvasBarOrder("top")],"top"),a?.includes("canvasBarBottom")&&e.ui.setCanvasBarOrder([j,...e.ui.getCanvasBarOrder("bottom")],"bottom"),a?.includes("canvasMenu")&&e.ui.setCanvasMenuOrder([n,...e.ui.getCanvasMenuOrder()]),a?.includes("dock")&&e.ui.setDockOrder([...e.ui.getDockOrder(),f]),e.ui.registerComponent(l,({builder:{Button:C},engine:p})=>{let[w]=p.block.findAllSelected(),S=!1,_=!1,F;if(w==null&&(S=!0),!S&&!e.feature.isEnabled(A,{engine:p})&&(S=!0),!S&&!e.engine.block.isAllowedByScope(w,"fill/change")&&(S=!0),!S&&p.block.getState(w)?.type==="Pending"&&(S=!0),!S){let y=o.get(w);if(_=y.status==="PROCESSING",S=y.status==="PENDING"||y.status==="PROCESSING",y.status==="PROCESSING"&&y.progress){let{current:q,total:oe}=y.progress;F=q/oe*100}}let V=`${f}.button`;C(V,{label:u,icon:t.icon,isLoading:_,isDisabled:S,loadingProgress:F,onClick:()=>{let y=o.get(w);(y.status==="IDLE"||y.status==="ERROR"||y.status==="PROCESSED")&&o.set(w,{status:"PENDING"})}})}),[{componentIds:d,variant:"plain",label:c},{componentIds:h,variant:"regular",label:g},{componentIds:I,variant:"regular",label:v},{componentIds:i,variant:"plain",label:s}].forEach(({componentIds:C,label:p,variant:w})=>{let S=C[0];e.ui.registerComponent(C,({builder:{Button:_},engine:F})=>{if(!e.feature.isEnabled(A,{engine:F}))return;let[V]=F.block.findAllSelected();if(!e.engine.block.isAllowedByScope(V,"fill/change"))return;let y=o.get(V),q=y.status==="PROCESSING",oe=y.status==="PENDING"||y.status==="PROCESSING"||F.block.getState(V)?.type==="Pending",he;if(q&&y.progress){let{current:yt,total:St}=y.progress;he=yt/St*100}let vt=`${S}.button`;_(vt,{icon:t.icon,label:p,variant:w,isLoading:q,isDisabled:oe,loadingProgress:he,onClick:()=>{(y.status==="IDLE"||y.status==="ERROR"||y.status==="PROCESSED")&&o.set(V,{status:"PENDING"})}})})}),{canvasMenuComponentId:n,dockComponentId:f,translationsKeys:{inspectorBarLabel:c,navigationBarLabel:g,canvasBarLabel:v,canvasMenuLabel:s,dockLabel:u}}}var Wi=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Gi=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Zi=new RegExp(/[A-Fa-f0-9]{2}/,"g");import*as ht from"@imgly/vectorizer";var ri=typeof global=="object"&&global&&global.Object===Object&&global,rt=ri;var ai=typeof self=="object"&&self&&self.Object===Object&&self,oi=rt||ai||Function("return this")(),te=oi;var si=te.Symbol,T=si;var at=Object.prototype,ii=at.hasOwnProperty,ni=at.toString,Z=T?T.toStringTag:void 0;function li(e){var t=ii.call(e,Z),r=e[Z];try{e[Z]=void 0;var a=!0}catch{}var o=ni.call(e);return a&&(t?e[Z]=r:delete e[Z]),o}var ot=li;var fi=Object.prototype,ui=fi.toString;function ci(e){return ui.call(e)}var st=ci;var di="[object Null]",pi="[object Undefined]",it=T?T.toStringTag:void 0;function mi(e){return e==null?e===void 0?pi:di:it&&it in Object(e)?ot(e):st(e)}var nt=mi;function gi(e){return e!=null&&typeof e=="object"}var lt=gi;var hi="[object Symbol]";function bi(e){return typeof e=="symbol"||lt(e)&&nt(e)==hi}var ft=bi;var xi=/\s/;function vi(e){for(var t=e.length;t--&&xi.test(e.charAt(t)););return t}var ut=vi;var yi=/^\s+/;function Si(e){return e&&e.slice(0,ut(e)+1).replace(yi,"")}var ct=Si;function wi(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var O=wi;var dt=NaN,Ii=/^[-+]0x[0-9a-f]+$/i,Ci=/^0b[01]+$/i,Ai=/^0o[0-7]+$/i,ki=parseInt;function ji(e){if(typeof e=="number")return e;if(ft(e))return dt;if(O(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=O(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=ct(e);var r=Ci.test(e);return r||Ai.test(e)?ki(e.slice(2),r?2:8):Ii.test(e)?dt:+e}var me=ji;var _i=function(){return te.Date.now()},re=_i;var Ei="Expected a function",Pi=Math.max,Oi=Math.min;function Fi(e,t,r){var a,o,s,i,n,u,l=0,f=!1,c=!1,d=!0;if(typeof e!="function")throw new TypeError(Ei);t=me(t)||0,O(r)&&(f=!!r.leading,c="maxWait"in r,s=c?Pi(me(r.maxWait)||0,t):s,d="trailing"in r?!!r.trailing:d);function b(p){var w=a,S=o;return a=o=void 0,l=p,i=e.apply(S,w),i}function g(p){return l=p,n=setTimeout(v,t),f?b(p):i}function h(p){var w=p-u,S=p-l,_=t-w;return c?Oi(_,s-S):_}function x(p){var w=p-u,S=p-l;return u===void 0||w>=t||w<0||c&&S>=s}function v(){var p=re();if(x(p))return I(p);n=setTimeout(v,h(p))}function I(p){return n=void 0,d&&a?b(p):(a=o=void 0,i)}function j(){n!==void 0&&clearTimeout(n),l=0,a=u=o=n=void 0}function A(){return n===void 0?i:I(re())}function C(){var p=re(),w=x(p);if(a=arguments,o=this,u=p,w){if(n===void 0)return g(u);if(c)return clearTimeout(n),n=setTimeout(v,t),b(u)}return n===void 0&&(n=setTimeout(v,t)),i}return C.cancel=j,C.flush=A,C}var pt=Fi;var Vi="Expected a function";function Ri(e,t,r){var a=!0,o=!0;if(typeof e!="function")throw new TypeError(Vi);return O(r)&&(a="leading"in r?!!r.leading:a,o="trailing"in r?!!r.trailing:o),pt(e,t,{leading:a,maxWait:t,trailing:o})}var ge=Ri;var Bi=(e,t)=>t.map(a=>Li(e,a)),Li=(e,t)=>{let r=t.shape.path,a=t.fill.color,o=e.block.create("//ly.img.ubq/graphic");e.block.setKind(o,"shape");let s=e.block.createShape("//ly.img.ubq/shape/vector_path");e.block.setShape(o,s),e.block.setString(s,"vector_path/path",r),e.block.setFloat(s,"vector_path/width",t.transform.width),e.block.setFloat(s,"vector_path/height",t.transform.height);let i=e.block.createFill("color");return e.block.setColor(i,"fill/color/value",{r:a[0],g:a[1],b:a[2],a:a[3]}),e.block.setFill(o,i),e.block.setFloat(o,"width",t.transform.width),e.block.setFloat(o,"height",t.transform.height),e.block.setPositionX(o,t.transform.x),e.block.setPositionY(o,t.transform.y),o},mt=Bi;function Ni(e,t,r){let a=r.engine,o=mt(a,t),s=a.block.getRotation(e),i=a.block.getPositionX(e),n=a.block.getPositionY(e),u=a.block.isSelected(e);switch(a.block.getType(e)){case"//ly.img.ubq/page":{let l=e,f=a.block.group(o);a.block.appendChild(l,f);let c=a.block.getFrameWidth(e)/a.block.getFrameWidth(f);a.block.setPositionX(f,i),a.block.setPositionY(f,n),a.block.setRotation(f,s),a.block.scale(f,c),a.block.setFillEnabled(l,!1),a.block.setSelected(f,u);break}case"//ly.img.ubq/graphic":default:{let l=a.block.getParent(e),f=a.block.group(o);a.block.appendChild(l,f);let c=a.block.getFrameWidth(e)/a.block.getFrameWidth(f);return a.block.setPositionX(f,i),a.block.setPositionY(f,n),a.block.setRotation(f,s),a.block.scale(f,c),a.block.destroy(e),a.block.setSelected(f,u),f}}}var gt=Ni;var Di=5,Mi=3e4;async function bt(e,t,r,a,o,s){Je(t,e,r,{async processFill(i){let n=i.initialSourceSet,u=i.initialImageFileURI,l=n.length>0?n[0].uri:u,f={signal:AbortSignal.timeout(s??Mi),...a,callbacks:{...a?.callbacks??{},progress:ge((g,h,x)=>{let v=r.get(t);v.status!=="PROCESSING"||!r.isConsistent(t)||(a?.callbacks?.progress?.(g,h,x),r.set(t,{...v,progress:{key:g,current:h,total:x}}))},100)},options:{drop_transparent:!1,...a?.options??{}}},c;if(l.startsWith("buffer:")){let g=await e.engine.editor.getMimeType(l),h=e.engine.editor.getBufferLength(l),x=e.engine.editor.getBufferData(l,0,h),v=new Uint8Array(x);c=new Blob([v],{type:g})}else c=await zi(l);let d=new ht.SvgConverter(f);await d.convert(c);let b=JSON.parse(d.to_json());if(b.length<(o??Di))return d.dispose(),b;{let g=d.to_svg(),h=new Blob([g],{type:"image/svg+xml"}),x=await Ti(h,l,e);return d.dispose(),x}},commitProcessing(i,n){if(typeof i=="string"){let u=n.fillId;e.engine.block.setString(u,"fill/image/imageFileURI",i),e.engine.block.setSourceSet(u,"fill/image/sourceSet",[]),e.engine.block.setString(u,"fill/image/previewFileURI","")}else return gt(t,i,e)}},"1.86.0-nightly.20261101")}async function Ti(e,t,r){let o=new URL(t).pathname.split("/"),s=Hi(e.type),n=`${o[o.length-1]?.split(".")?.[0]??"vectorized-image"}.${s}`,l=(await r.unstable_upload(new File([e],n,{type:e.type}),()=>{})).meta?.uri;if(l==null)throw new Error("Could not upload processed fill");return l}function Hi(e){switch(e){case"image/jpeg":return"jpg";case"image/png":return"png";case"image/svg+xml":return"svg";default:return"jpg"}}async function zi(e){return fetch(e).then(t=>t.blob())}var ae="@imgly/plugin-vectorizer-web",xt=(e={})=>({initialize({cesdk:t}){if(t==null)return;Ui(t),et(t,{pluginId:ae,process:(a,o)=>{bt(t,a,o,e?.vectorizer,e?.groupingThreshold,e?.timeout)}});let{translationsKeys:r}=tt(t,{pluginId:ae,icon:"@imgly/icons/Vectorize",locations:e.ui?.locations});t.setTranslations({en:{[r.inspectorBarLabel]:"Vectorizer",[r.navigationBarLabel]:"Vectorizer",[r.canvasBarLabel]:"Vectorizer",[r.canvasMenuLabel]:"Vectorizer",[r.dockLabel]:"Vectorizer"}})}});function Ui(e){e.ui.addIconSet("@imgly/plugin/vectorizer",`
|
|
1
|
+
import*as e from"@imgly/vectorizer";var t=class{constructor(e,t){this.engine=e,this.key=t}hasData(e){return this.engine.block.isValid(e)&&this.engine.block.hasMetadata(e,this.key)}get(e){if(this.hasData(e))return JSON.parse(this.engine.block.getMetadata(e,this.key))}set(e,t){this.engine.block.setMetadata(e,this.key,JSON.stringify(t))}clear(e){this.engine.block.hasMetadata(e,this.key)&&this.engine.block.removeMetadata(e,this.key)}},n=typeof global==`object`&&global&&global.Object===Object&&global,r=typeof self==`object`&&self&&self.Object===Object&&self,i=n||r||Function(`return this`)(),a=i.Symbol,o=Object.prototype,s=o.hasOwnProperty,c=o.toString,l=a?a.toStringTag:void 0;function u(e){var t=s.call(e,l),n=e[l];try{e[l]=void 0;var r=!0}catch{}var i=c.call(e);return r&&(t?e[l]=n:delete e[l]),i}var d=Object.prototype.toString;function f(e){return d.call(e)}var p=`[object Null]`,m=`[object Undefined]`,h=a?a.toStringTag:void 0;function g(e){return e==null?e===void 0?m:p:h&&h in Object(e)?u(e):f(e)}function _(e){return typeof e==`object`&&!!e}var v=Array.isArray;function y(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var b=`[object AsyncFunction]`,x=`[object Function]`,ee=`[object GeneratorFunction]`,te=`[object Proxy]`;function S(e){if(!y(e))return!1;var t=g(e);return t==x||t==ee||t==b||t==te}var C=i[`__core-js_shared__`],w=function(){var e=/[^.]+$/.exec(C&&C.keys&&C.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function ne(e){return!!w&&w in e}var re=Function.prototype.toString;function T(e){if(e!=null){try{return re.call(e)}catch{}try{return e+``}catch{}}return``}var ie=/[\\^$.*+?()[\]{}|]/g,ae=/^\[object .+?Constructor\]$/,oe=Function.prototype,se=Object.prototype,ce=oe.toString,le=se.hasOwnProperty,ue=RegExp(`^`+ce.call(le).replace(ie,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function de(e){return!y(e)||ne(e)?!1:(S(e)?ue:ae).test(T(e))}function fe(e,t){return e?.[t]}function E(e,t){var n=fe(e,t);return de(n)?n:void 0}var D=E(i,`WeakMap`),pe=9007199254740991,me=/^(?:0|[1-9]\d*)$/;function he(e,t){var n=typeof e;return t??=pe,!!t&&(n==`number`||n!=`symbol`&&me.test(e))&&e>-1&&e%1==0&&e<t}function ge(e,t){return e===t||e!==e&&t!==t}var _e=9007199254740991;function ve(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=_e}function ye(e){return e!=null&&ve(e.length)&&!S(e)}var be=Object.prototype;function xe(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||be)}function Se(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Ce=`[object Arguments]`;function we(e){return _(e)&&g(e)==Ce}var Te=Object.prototype,Ee=Te.hasOwnProperty,De=Te.propertyIsEnumerable,Oe=we(function(){return arguments}())?we:function(e){return _(e)&&Ee.call(e,`callee`)&&!De.call(e,`callee`)};function ke(){return!1}var Ae=typeof exports==`object`&&exports&&!exports.nodeType&&exports,je=Ae&&typeof module==`object`&&module&&!module.nodeType&&module,Me=je&&je.exports===Ae?i.Buffer:void 0,O=(Me?Me.isBuffer:void 0)||ke,Ne=`[object Arguments]`,Pe=`[object Array]`,Fe=`[object Boolean]`,Ie=`[object Date]`,Le=`[object Error]`,Re=`[object Function]`,ze=`[object Map]`,Be=`[object Number]`,Ve=`[object Object]`,He=`[object RegExp]`,Ue=`[object Set]`,We=`[object String]`,Ge=`[object WeakMap]`,Ke=`[object ArrayBuffer]`,qe=`[object DataView]`,Je=`[object Float32Array]`,Ye=`[object Float64Array]`,Xe=`[object Int8Array]`,Ze=`[object Int16Array]`,Qe=`[object Int32Array]`,$e=`[object Uint8Array]`,et=`[object Uint8ClampedArray]`,tt=`[object Uint16Array]`,nt=`[object Uint32Array]`,k={};k[Je]=k[Ye]=k[Xe]=k[Ze]=k[Qe]=k[$e]=k[et]=k[tt]=k[nt]=!0,k[Ne]=k[Pe]=k[Ke]=k[Fe]=k[qe]=k[Ie]=k[Le]=k[Re]=k[ze]=k[Be]=k[Ve]=k[He]=k[Ue]=k[We]=k[Ge]=!1;function rt(e){return _(e)&&ve(e.length)&&!!k[g(e)]}function it(e){return function(t){return e(t)}}var at=typeof exports==`object`&&exports&&!exports.nodeType&&exports,A=at&&typeof module==`object`&&module&&!module.nodeType&&module,j=A&&A.exports===at&&n.process,ot=function(){try{return A&&A.require&&A.require(`util`).types||j&&j.binding&&j.binding(`util`)}catch{}}(),st=ot&&ot.isTypedArray,M=st?it(st):rt,ct=Object.prototype.hasOwnProperty;function lt(e,t){var n=v(e),r=!n&&Oe(e),i=!n&&!r&&O(e),a=!n&&!r&&!i&&M(e),o=n||r||i||a,s=o?Se(e.length,String):[],c=s.length;for(var l in e)(t||ct.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||he(l,c)))&&s.push(l);return s}function ut(e,t){return function(n){return e(t(n))}}var dt=ut(Object.keys,Object),ft=Object.prototype.hasOwnProperty;function pt(e){if(!xe(e))return dt(e);var t=[];for(var n in Object(e))ft.call(e,n)&&n!=`constructor`&&t.push(n);return t}function mt(e){return ye(e)?lt(e):pt(e)}var N=E(Object,`create`);function ht(){this.__data__=N?N(null):{},this.size=0}function gt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var _t=`__lodash_hash_undefined__`,vt=Object.prototype.hasOwnProperty;function yt(e){var t=this.__data__;if(N){var n=t[e];return n===_t?void 0:n}return vt.call(t,e)?t[e]:void 0}var bt=Object.prototype.hasOwnProperty;function xt(e){var t=this.__data__;return N?t[e]!==void 0:bt.call(t,e)}var St=`__lodash_hash_undefined__`;function Ct(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=N&&t===void 0?St:t,this}function P(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}P.prototype.clear=ht,P.prototype.delete=gt,P.prototype.get=yt,P.prototype.has=xt,P.prototype.set=Ct;function wt(){this.__data__=[],this.size=0}function F(e,t){for(var n=e.length;n--;)if(ge(e[n][0],t))return n;return-1}var Tt=Array.prototype.splice;function Et(e){var t=this.__data__,n=F(t,e);return n<0?!1:(n==t.length-1?t.pop():Tt.call(t,n,1),--this.size,!0)}function Dt(e){var t=this.__data__,n=F(t,e);return n<0?void 0:t[n][1]}function Ot(e){return F(this.__data__,e)>-1}function kt(e,t){var n=this.__data__,r=F(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function I(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}I.prototype.clear=wt,I.prototype.delete=Et,I.prototype.get=Dt,I.prototype.has=Ot,I.prototype.set=kt;var L=E(i,`Map`);function At(){this.size=0,this.__data__={hash:new P,map:new(L||I),string:new P}}function jt(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function R(e,t){var n=e.__data__;return jt(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function Mt(e){var t=R(this,e).delete(e);return this.size-=+!!t,t}function Nt(e){return R(this,e).get(e)}function Pt(e){return R(this,e).has(e)}function Ft(e,t){var n=R(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function z(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}z.prototype.clear=At,z.prototype.delete=Mt,z.prototype.get=Nt,z.prototype.has=Pt,z.prototype.set=Ft;function It(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Lt(){this.__data__=new I,this.size=0}function Rt(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function zt(e){return this.__data__.get(e)}function Bt(e){return this.__data__.has(e)}var Vt=200;function Ht(e,t){var n=this.__data__;if(n instanceof I){var r=n.__data__;if(!L||r.length<Vt-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new z(r)}return n.set(e,t),this.size=n.size,this}function B(e){var t=this.__data__=new I(e);this.size=t.size}B.prototype.clear=Lt,B.prototype.delete=Rt,B.prototype.get=zt,B.prototype.has=Bt,B.prototype.set=Ht;function Ut(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function Wt(){return[]}var Gt=Object.prototype.propertyIsEnumerable,Kt=Object.getOwnPropertySymbols,qt=Kt?function(e){return e==null?[]:(e=Object(e),Ut(Kt(e),function(t){return Gt.call(e,t)}))}:Wt;function Jt(e,t,n){var r=t(e);return v(e)?r:It(r,n(e))}function Yt(e){return Jt(e,mt,qt)}var V=E(i,`DataView`),H=E(i,`Promise`),U=E(i,`Set`),Xt=`[object Map]`,Zt=`[object Object]`,Qt=`[object Promise]`,W=`[object Set]`,$t=`[object WeakMap]`,en=`[object DataView]`,tn=T(V),nn=T(L),rn=T(H),an=T(U),on=T(D),G=g;(V&&G(new V(/* @__PURE__ */ new ArrayBuffer(1)))!=en||L&&G(new L)!=Xt||H&&G(H.resolve())!=Qt||U&&G(new U)!=W||D&&G(new D)!=$t)&&(G=function(e){var t=g(e),n=t==Zt?e.constructor:void 0,r=n?T(n):``;if(r)switch(r){case tn:return en;case nn:return Xt;case rn:return Qt;case an:return W;case on:return $t}return t});var sn=G,cn=i.Uint8Array,ln=`__lodash_hash_undefined__`;function un(e){return this.__data__.set(e,ln),this}function dn(e){return this.__data__.has(e)}function K(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new z;++t<n;)this.add(e[t])}K.prototype.add=K.prototype.push=un,K.prototype.has=dn;function fn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function pn(e,t){return e.has(t)}var mn=1,hn=2;function gn(e,t,n,r,i,a){var o=n&mn,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&hn?new K:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!fn(t,function(e,t){if(!pn(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}function _n(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function vn(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var yn=1,bn=2,xn=`[object Boolean]`,Sn=`[object Date]`,Cn=`[object Error]`,wn=`[object Map]`,Tn=`[object Number]`,En=`[object RegExp]`,Dn=`[object Set]`,On=`[object String]`,kn=`[object Symbol]`,An=`[object ArrayBuffer]`,jn=`[object DataView]`,Mn=a?a.prototype:void 0,q=Mn?Mn.valueOf:void 0;function Nn(e,t,n,r,i,a,o){switch(n){case jn:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case An:return!(e.byteLength!=t.byteLength||!a(new cn(e),new cn(t)));case xn:case Sn:case Tn:return ge(+e,+t);case Cn:return e.name==t.name&&e.message==t.message;case En:case On:return e==t+``;case wn:var s=_n;case Dn:var c=r&yn;if(s||=vn,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=bn,o.set(e,t);var u=gn(s(e),s(t),r,i,a,o);return o.delete(e),u;case kn:if(q)return q.call(e)==q.call(t)}return!1}var Pn=1,Fn=Object.prototype.hasOwnProperty;function In(e,t,n,r,i,a){var o=n&Pn,s=Yt(e),c=s.length;if(c!=Yt(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:Fn.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var Ln=1,Rn=`[object Arguments]`,zn=`[object Array]`,J=`[object Object]`,Bn=Object.prototype.hasOwnProperty;function Vn(e,t,n,r,i,a){var o=v(e),s=v(t),c=o?zn:sn(e),l=s?zn:sn(t);c=c==Rn?J:c,l=l==Rn?J:l;var u=c==J,d=l==J,f=c==l;if(f&&O(e)){if(!O(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new B,o||M(e)?gn(e,t,n,r,i,a):Nn(e,t,c,n,r,i,a);if(!(n&Ln)){var p=u&&Bn.call(e,`__wrapped__`),m=d&&Bn.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new B,i(h,g,n,r,a)}}return f?(a||=new B,In(e,t,n,r,i,a)):!1}function Hn(e,t,n,r,i){return e===t?!0:e==null||t==null||!_(e)&&!_(t)?e!==e&&t!==t:Vn(e,t,n,r,Hn,i)}function Un(e,t){return Hn(e,t)}var Wn=class extends t{get(e){return super.get(e)??{status:`IDLE`}}isDuplicate(e){if(!this.engine.block.isValid(e))return!1;let t=this.get(e);if(t.status===`IDLE`||t.status===`PENDING`||t.status===`ERROR`||!this.engine.block.hasFill(e))return!1;let n=this.engine.block.getFill(e);return t.blockId!==e&&t.fillId!==n}fixDuplicate(e){let t=this.engine.block.getFill(e),n=this.get(e);n.status!==`IDLE`&&n.status!==`PENDING`&&n.status!==`ERROR`&&(this.set(e,{...n,blockId:e,fillId:t}),n.status===`PROCESSING`&&(this.recoverInitialImageData(e),this.clear(e)))}isConsistent(e){if(!this.engine.block.isValid(e))return!1;let t=this.get(e);if(t.status===`IDLE`||t.status===`PENDING`)return!0;if(!this.engine.block.hasFill(e))return!1;let n=this.engine.block.getFill(e);if(n==null||e!==t.blockId||n!==t.fillId)return!1;let r=this.engine.block.getSourceSet(n,`fill/image/sourceSet`),i=this.engine.block.getString(n,`fill/image/imageFileURI`);if(r.length===0&&!i&&t.status===`PROCESSING`)return!0;if(r?.length>0){let e=t.initialSourceSet;if(t.status!==`PROCESSED`&&!Un(r,e))return!1}else if(t.status!==`PROCESSED`&&i!==t.initialImageFileURI)return!1;return!0}recoverInitialImageData(e){if(!this.engine.block.hasFill(e))return;let t=this.get(e);if(t.status===`PENDING`||t.status===`IDLE`)return;let n=t.initialSourceSet,r=t.initialImageFileURI,i=t.initialPreviewFileURI,a=this.getValidFill(e,t);a!=null&&(r&&this.engine.block.setString(a,`fill/image/imageFileURI`,r),i&&this.engine.block.setString(a,`fill/image/previewFileURI`,i),n.length>0&&this.engine.block.setSourceSet(a,`fill/image/sourceSet`,n))}getValidFill(e,t){if(!this.engine.block.isValid(e)||!this.engine.block.hasFill(e)||e!==t.blockId)return;let n=this.engine.block.getFill(e);if(n===t.fillId)return n}};async function Gn(e,t,n,r,i){let a=t.engine.block;if(!a.hasFill(e))throw Error(`Block does not support fill`);let o=a.getFill(e),s=a.getSourceSet(o,`fill/image/sourceSet`),c=a.getString(o,`fill/image/imageFileURI`),l=a.getString(o,`fill/image/previewFileURI`);try{t.engine.block.setState(o,{type:`Pending`,progress:0});let a={...n.get(e),version:i,initialSourceSet:s,initialImageFileURI:c,initialPreviewFileURI:l,blockId:e,fillId:o,status:`PROCESSING`};n.set(e,a);let u=await r.processFill(a);if(n.get(e).status!==`PROCESSING`||!n.isConsistent(e)||n.get(e).status!==`PROCESSING`||!n.isConsistent(e)||u==null)return;let d={version:i,initialSourceSet:s,initialImageFileURI:c,initialPreviewFileURI:l,blockId:e,fillId:o,status:`PROCESSED`},f=r.commitProcessing(u,d);(f==null||f===e)&&n.set(e,d),t.engine.editor.addUndoStep()}catch(r){if(t.engine.block.isValid(e)&&(n.set(e,{version:i,initialSourceSet:s,initialImageFileURI:c,initialPreviewFileURI:l,blockId:e,fillId:o,status:`ERROR`}),n.recoverInitialImageData(e)),typeof r==`object`&&r&&`message`in r&&typeof r.message==`string`){let e=r.message===`signal timed out`?`Processing canceled due to timeout`:r.message;t.ui.showNotification({type:`error`,message:e})}console.log(r)}finally{t.engine.block.isValid(o)&&t.engine.block.setState(o,{type:`Ready`})}}function Kn(e){return`${e}.fillProcessing.feature`}function qn(e){return[`${e}.canvasMenu`,`${e}.fillProcessing.canvasMenu`]}function Jn(e){return[`${e}.dock`,`${e}.fillProcessing.dock`]}function Yn(e){return[`${e}.inspectorBar`,`${e}.fillProcessing.inspectorBar`]}function Xn(e){return[`${e}.navigationBar`,`${e}.fillProcessing.navigationBar`]}function Zn(e){return[`${e}.canvasBar`,`${e}.fillProcessing.canvasBar`]}function Qn(e){return`plugin.${e}.fillProcessing.canvasMenu.button.label`}function $n(e){return`plugin.${e}.fillProcessing.dock.button.label`}function er(e){return`plugin.${e}.fillProcessing.inspectorBar.button.label`}function tr(e){return`plugin.${e}.fillProcessing.navigationBar.button.label`}function nr(e){return`plugin.${e}.fillProcessing.canvasBar.button.label`}function rr(e,{pluginId:t,process:n}){let r=Kn(t),i=new Wn(e.engine,t);return ir(e,i,r),e.engine.event.subscribe([],async t=>{t.forEach(t=>{let a=t.block;if(e.engine.block.isValid(a)&&i.hasData(a)){if(t.type===`Created`)i.isDuplicate(a)&&i.fixDuplicate(a);else if(t.type===`Updated`)switch(i.get(a).status){case`PENDING`:e.feature.isEnabled(r,{engine:e.engine})&&e.engine.block.isAllowedByScope(a,`fill/change`)&&e.engine.block.getState(a).type!==`Pending`&&n(a,i);break;case`PROCESSING`:case`PROCESSED`:i.isConsistent(a)||i.clear(a)}}})}),{featureId:r}}function ir(e,t,n){e.feature.enable(n,({engine:n})=>{let r=n.block.findAllSelected();if(r.length!==1)return!1;let[i]=r;if(!e.engine.block.isVisible(i))return!1;if(e.engine.block.hasFill(i)){if(e.engine.block.getKind(i)===`sticker`)return!1;let r=e.engine.block.getFill(i);if(e.engine.block.getType(r)!==`//ly.img.ubq/fill/image`)return!1;let a=n.block.getString(r,`fill/image/imageFileURI`);return n.block.getSourceSet(r,`fill/image/sourceSet`).length>0||a!==``||t.get(i).status===`PROCESSING`}return!1})}function ar(e,t){let{pluginId:n,locations:r}=t,i=new Wn(e.engine,n),a=Qn(n),o=qn(n),s=o[0],c=$n(n),l=Jn(n),u=l[0],d=er(n),f=Yn(n),p=f[0],m=tr(n),h=Xn(n),g=h[0],_=nr(n),v=Zn(n),y=v[0],b=Kn(n);return r?.includes(`inspectorBar`)&&e.ui.setInspectorBarOrder([p,...e.ui.getInspectorBarOrder()]),r?.includes(`navigationBar`)&&e.ui.setNavigationBarOrder([g,...e.ui.getNavigationBarOrder()]),r?.includes(`canvasBarTop`)&&e.ui.setCanvasBarOrder([y,...e.ui.getCanvasBarOrder(`top`)],`top`),r?.includes(`canvasBarBottom`)&&e.ui.setCanvasBarOrder([y,...e.ui.getCanvasBarOrder(`bottom`)],`bottom`),r?.includes(`canvasMenu`)&&e.ui.setCanvasMenuOrder([s,...e.ui.getCanvasMenuOrder()]),r?.includes(`dock`)&&e.ui.setDockOrder([...e.ui.getDockOrder(),u]),e.ui.registerComponent(l,({builder:{Button:n},engine:r})=>{let[a]=r.block.findAllSelected(),o=!1,s=!1,l;if(a??(o=!0),!o&&!e.feature.isEnabled(b,{engine:r})&&(o=!0),!o&&!e.engine.block.isAllowedByScope(a,`fill/change`)&&(o=!0),!o&&r.block.getState(a)?.type===`Pending`&&(o=!0),!o){let e=i.get(a);if(s=e.status===`PROCESSING`,o=e.status===`PENDING`||e.status===`PROCESSING`,e.status===`PROCESSING`&&e.progress){let{current:t,total:n}=e.progress;l=t/n*100}}n(`${u}.button`,{label:c,icon:t.icon,isLoading:s,isDisabled:o,loadingProgress:l,onClick:()=>{let e=i.get(a);(e.status===`IDLE`||e.status===`ERROR`||e.status===`PROCESSED`)&&i.set(a,{status:`PENDING`})}})}),[{componentIds:f,variant:`plain`,label:d},{componentIds:h,variant:`regular`,label:m},{componentIds:v,variant:`regular`,label:_},{componentIds:o,variant:`plain`,label:a}].forEach(({componentIds:n,label:r,variant:a})=>{let o=n[0];e.ui.registerComponent(n,({builder:{Button:n},engine:s})=>{if(!e.feature.isEnabled(b,{engine:s}))return;let[c]=s.block.findAllSelected();if(!e.engine.block.isAllowedByScope(c,`fill/change`))return;let l=i.get(c),u=l.status===`PROCESSING`,d=l.status===`PENDING`||l.status===`PROCESSING`||s.block.getState(c)?.type===`Pending`,f;if(u&&l.progress){let{current:e,total:t}=l.progress;f=e/t*100}n(`${o}.button`,{icon:t.icon,label:r,variant:a,isLoading:u,isDisabled:d,loadingProgress:f,onClick:()=>{(l.status===`IDLE`||l.status===`ERROR`||l.status===`PROCESSED`)&&i.set(c,{status:`PENDING`})}})})}),{canvasMenuComponentId:s,dockComponentId:u,translationsKeys:{inspectorBarLabel:d,navigationBarLabel:m,canvasBarLabel:_,canvasMenuLabel:a,dockLabel:c}}}var or=typeof global==`object`&&global&&global.Object===Object&&global,sr=typeof self==`object`&&self&&self.Object===Object&&self,cr=or||sr||Function(`return this`)(),Y=cr.Symbol,lr=Object.prototype,ur=lr.hasOwnProperty,dr=lr.toString,X=Y?Y.toStringTag:void 0;function fr(e){var t=ur.call(e,X),n=e[X];try{e[X]=void 0;var r=!0}catch{}var i=dr.call(e);return r&&(t?e[X]=n:delete e[X]),i}var pr=Object.prototype.toString;function mr(e){return pr.call(e)}var hr=`[object Null]`,gr=`[object Undefined]`,_r=Y?Y.toStringTag:void 0;function vr(e){return e==null?e===void 0?gr:hr:_r&&_r in Object(e)?fr(e):mr(e)}function yr(e){return typeof e==`object`&&!!e}var br=`[object Symbol]`;function xr(e){return typeof e==`symbol`||yr(e)&&vr(e)==br}var Sr=/\s/;function Cr(e){for(var t=e.length;t--&&Sr.test(e.charAt(t)););return t}var wr=/^\s+/;function Tr(e){return e&&e.slice(0,Cr(e)+1).replace(wr,``)}function Z(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var Er=NaN,Dr=/^[-+]0x[0-9a-f]+$/i,Or=/^0b[01]+$/i,kr=/^0o[0-7]+$/i,Ar=parseInt;function jr(e){if(typeof e==`number`)return e;if(xr(e))return Er;if(Z(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=Z(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Tr(e);var n=Or.test(e);return n||kr.test(e)?Ar(e.slice(2),n?2:8):Dr.test(e)?Er:+e}var Q=function(){return cr.Date.now()},Mr=`Expected a function`,Nr=Math.max,Pr=Math.min;function Fr(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(Mr);t=jr(t)||0,Z(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?Nr(jr(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?Pr(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=Q();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Q())}function x(){var e=Q(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}var Ir=`Expected a function`;function Lr(e,t,n){var r=!0,i=!0;if(typeof e!=`function`)throw TypeError(Ir);return Z(n)&&(r=`leading`in n?!!n.leading:r,i=`trailing`in n?!!n.trailing:i),Fr(e,t,{leading:r,maxWait:t,trailing:i})}const Rr=(e,t)=>t.map(t=>zr(e,t)),zr=(e,t)=>{let n=t.shape.path,r=t.fill.color,i=e.block.create(`//ly.img.ubq/graphic`);e.block.setKind(i,`shape`);let a=e.block.createShape(`//ly.img.ubq/shape/vector_path`);e.block.setShape(i,a),e.block.setString(a,`vector_path/path`,n),e.block.setFloat(a,`vector_path/width`,t.transform.width),e.block.setFloat(a,`vector_path/height`,t.transform.height);let o=e.block.createFill(`color`);return e.block.setColor(o,`fill/color/value`,{r:r[0],g:r[1],b:r[2],a:r[3]}),e.block.setFill(i,o),e.block.setFloat(i,`width`,t.transform.width),e.block.setFloat(i,`height`,t.transform.height),e.block.setPositionX(i,t.transform.x),e.block.setPositionY(i,t.transform.y),i};function Br(e,t,n){let r=n.engine,i=Rr(r,t),a=r.block.getRotation(e),o=r.block.getPositionX(e),s=r.block.getPositionY(e),c=r.block.isSelected(e);switch(r.block.getType(e)){case`//ly.img.ubq/page`:{let t=e,n=r.block.group(i);r.block.appendChild(t,n);let l=r.block.getFrameWidth(e)/r.block.getFrameWidth(n);r.block.setPositionX(n,o),r.block.setPositionY(n,s),r.block.setRotation(n,a),r.block.scale(n,l),r.block.setFillEnabled(t,!1),r.block.setSelected(n,c);break}default:{let t=r.block.getParent(e),n=r.block.group(i);r.block.appendChild(t,n);let l=r.block.getFrameWidth(e)/r.block.getFrameWidth(n);return r.block.setPositionX(n,o),r.block.setPositionY(n,s),r.block.setRotation(n,a),r.block.scale(n,l),r.block.destroy(e),r.block.setSelected(n,c),n}}}async function Vr(t,n,r,i,a,o){Gn(n,t,r,{async processFill(s){let c=s.initialSourceSet,l=s.initialImageFileURI,u=c.length>0?c[0].uri:l,d={signal:AbortSignal.timeout(o??3e4),...i,callbacks:{...i?.callbacks??{},progress:Lr((e,t,a)=>{let o=r.get(n);o.status===`PROCESSING`&&r.isConsistent(n)&&(i?.callbacks?.progress?.(e,t,a),r.set(n,{...o,progress:{key:e,current:t,total:a}}))},100)},options:{drop_transparent:!1,...i?.options??{}}},f;if(u.startsWith(`buffer:`)){let e=await t.engine.editor.getMimeType(u),n=t.engine.editor.getBufferLength(u),r=t.engine.editor.getBufferData(u,0,n),i=new Uint8Array(r);f=new Blob([i],{type:e})}else f=await Wr(u);let p=new e.SvgConverter(d);await p.convert(f);let m=JSON.parse(p.to_json());if(m.length<(a??5))return p.dispose(),m;{let e=p.to_svg(),n=await Hr(new Blob([e],{type:`image/svg+xml`}),u,t);return p.dispose(),n}},commitProcessing(e,r){if(typeof e==`string`){let n=r.fillId;t.engine.block.setString(n,`fill/image/imageFileURI`,e),t.engine.block.setSourceSet(n,`fill/image/sourceSet`,[]),t.engine.block.setString(n,`fill/image/previewFileURI`,``)}else return Br(n,e,t)}},`1.87.0-nightly.20261103`)}async function Hr(e,t,n){let r=new URL(t).pathname.split(`/`),i=Ur(e.type),a=`${r[r.length-1]?.split(`.`)?.[0]??`vectorized-image`}.${i}`,o=(await n.unstable_upload(new File([e],a,{type:e.type}),()=>{})).meta?.uri;if(o==null)throw Error(`Could not upload processed fill`);return o}function Ur(e){switch(e){case`image/jpeg`:return`jpg`;case`image/png`:return`png`;case`image/svg+xml`:return`svg`;default:return`jpg`}}async function Wr(e){return fetch(e).then(e=>e.blob())}const $=`@imgly/plugin-vectorizer-web`;var Gr=(e={})=>({initialize({cesdk:t}){if(t==null)return;Kr(t),rr(t,{pluginId:$,process:(n,r)=>{Vr(t,n,r,e?.vectorizer,e?.groupingThreshold,e?.timeout)}});let{translationsKeys:n}=ar(t,{pluginId:$,icon:`@imgly/icons/Vectorize`,locations:e.ui?.locations});t.setTranslations({en:{[n.inspectorBarLabel]:`Vectorizer`,[n.navigationBarLabel]:`Vectorizer`,[n.canvasBarLabel]:`Vectorizer`,[n.canvasMenuLabel]:`Vectorizer`,[n.dockLabel]:`Vectorizer`}})}});function Kr(e){e.ui.addIconSet(`@imgly/plugin/vectorizer`,`
|
|
2
2
|
<svg>
|
|
3
3
|
<symbol
|
|
4
4
|
fill="none"
|
|
@@ -13,31 +13,14 @@ var wt=class{constructor(e,t){this.engine=e,this.key=t}hasData(e){return this.en
|
|
|
13
13
|
<path d="M7 7.50003V4.50003H10V7.50003H7Z" fill="currentColor"/>
|
|
14
14
|
</symbol>
|
|
15
15
|
</svg>
|
|
16
|
-
`)}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
lodash
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
28
|
-
*)
|
|
29
|
-
*/
|
|
30
|
-
/*! Bundled license information:
|
|
31
|
-
|
|
32
|
-
lodash-es/lodash.js:
|
|
33
|
-
(**
|
|
34
|
-
* @license
|
|
35
|
-
* Lodash (Custom Build) <https://lodash.com/>
|
|
36
|
-
* Build: `lodash modularize exports="es" -o ./`
|
|
37
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
38
|
-
* Released under MIT license <https://lodash.com/license>
|
|
39
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
40
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
41
|
-
*)
|
|
42
|
-
*/
|
|
43
|
-
//# sourceMappingURL=index.mjs.map
|
|
16
|
+
`)}const qr=e=>({name:$,version:`1.87.0-nightly.20261103`,...Gr(e)});export{qr as default};
|
|
17
|
+
/**
|
|
18
|
+
* @license
|
|
19
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
20
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
21
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
22
|
+
* Released under MIT license <https://lodash.com/license>
|
|
23
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
24
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
25
|
+
*/
|
|
26
|
+
//# sourceMappingURL=index.mjs.map
|